adorn-api 1.0.13 → 1.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter/express/auth.d.ts +8 -0
- package/dist/adapter/express/auth.d.ts.map +1 -1
- package/dist/adapter/express/bootstrap.d.ts +14 -1
- package/dist/adapter/express/bootstrap.d.ts.map +1 -1
- package/dist/adapter/express/coercion.d.ts +81 -1
- package/dist/adapter/express/coercion.d.ts.map +1 -1
- package/dist/adapter/express/index.d.ts +1 -0
- package/dist/adapter/express/index.d.ts.map +1 -1
- package/dist/adapter/express/merge.d.ts +17 -0
- package/dist/adapter/express/merge.d.ts.map +1 -1
- package/dist/adapter/express/openapi.d.ts +55 -0
- package/dist/adapter/express/openapi.d.ts.map +1 -1
- package/dist/adapter/express/router.d.ts +6 -0
- package/dist/adapter/express/router.d.ts.map +1 -1
- package/dist/adapter/express/swagger.d.ts +6 -0
- package/dist/adapter/express/swagger.d.ts.map +1 -1
- package/dist/adapter/express/types.d.ts +39 -0
- package/dist/adapter/express/types.d.ts.map +1 -1
- package/dist/adapter/express/validation.d.ts +19 -2
- package/dist/adapter/express/validation.d.ts.map +1 -1
- package/dist/cli.cjs +192 -11
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +192 -11
- package/dist/cli.js.map +1 -1
- package/dist/compiler/analyze/index.d.ts +5 -0
- package/dist/compiler/analyze/index.d.ts.map +1 -0
- package/dist/compiler/analyze/scanControllers.d.ts +52 -0
- package/dist/compiler/analyze/scanControllers.d.ts.map +1 -1
- package/dist/compiler/cache/isStale.d.ts +26 -0
- package/dist/compiler/cache/isStale.d.ts.map +1 -1
- package/dist/compiler/cache/loadArtifacts.d.ts +36 -0
- package/dist/compiler/cache/loadArtifacts.d.ts.map +1 -1
- package/dist/compiler/cache/schema.d.ts +14 -0
- package/dist/compiler/cache/schema.d.ts.map +1 -1
- package/dist/compiler/cache/writeCache.d.ts +6 -0
- package/dist/compiler/cache/writeCache.d.ts.map +1 -1
- package/dist/compiler/gems.d.ts +75 -0
- package/dist/compiler/gems.d.ts.map +1 -0
- package/dist/compiler/generator/index.d.ts +7 -0
- package/dist/compiler/generator/index.d.ts.map +1 -0
- package/dist/compiler/generator/manifest.d.ts +23 -0
- package/dist/compiler/generator/manifest.d.ts.map +1 -0
- package/dist/compiler/generator/openapi.d.ts +118 -0
- package/dist/compiler/generator/openapi.d.ts.map +1 -0
- package/dist/compiler/graph/builder.d.ts +24 -0
- package/dist/compiler/graph/builder.d.ts.map +1 -0
- package/dist/compiler/graph/index.d.ts +7 -0
- package/dist/compiler/graph/index.d.ts.map +1 -0
- package/dist/compiler/graph/schemaGraph.d.ts +67 -0
- package/dist/compiler/graph/schemaGraph.d.ts.map +1 -0
- package/dist/compiler/graph/types.d.ts +203 -0
- package/dist/compiler/graph/types.d.ts.map +1 -0
- package/dist/compiler/index.d.ts +12 -0
- package/dist/compiler/index.d.ts.map +1 -0
- package/dist/compiler/ir/index.d.ts +7 -0
- package/dist/compiler/ir/index.d.ts.map +1 -0
- package/dist/compiler/ir/pipeline.d.ts +82 -0
- package/dist/compiler/ir/pipeline.d.ts.map +1 -0
- package/dist/compiler/ir/stages.d.ts +40 -0
- package/dist/compiler/ir/stages.d.ts.map +1 -0
- package/dist/compiler/ir/visitor.d.ts +98 -0
- package/dist/compiler/ir/visitor.d.ts.map +1 -0
- package/dist/compiler/manifest/emit.d.ts +14 -0
- package/dist/compiler/manifest/emit.d.ts.map +1 -1
- package/dist/compiler/manifest/format.d.ts +42 -0
- package/dist/compiler/manifest/format.d.ts.map +1 -1
- package/dist/compiler/manifest/index.d.ts +6 -0
- package/dist/compiler/manifest/index.d.ts.map +1 -0
- package/dist/compiler/runner/createProgram.d.ts +16 -0
- package/dist/compiler/runner/createProgram.d.ts.map +1 -1
- package/dist/compiler/runner/index.d.ts +5 -0
- package/dist/compiler/runner/index.d.ts.map +1 -0
- package/dist/compiler/schema/extractAnnotations.d.ts +47 -0
- package/dist/compiler/schema/extractAnnotations.d.ts.map +1 -1
- package/dist/compiler/schema/index.d.ts +6 -0
- package/dist/compiler/schema/index.d.ts.map +1 -0
- package/dist/compiler/schema/intersectionHandler.d.ts +37 -0
- package/dist/compiler/schema/intersectionHandler.d.ts.map +1 -1
- package/dist/compiler/schema/objectHandler.d.ts +86 -0
- package/dist/compiler/schema/objectHandler.d.ts.map +1 -1
- package/dist/compiler/schema/openapi.d.ts +15 -0
- package/dist/compiler/schema/openapi.d.ts.map +1 -1
- package/dist/compiler/schema/parameters.d.ts +72 -0
- package/dist/compiler/schema/parameters.d.ts.map +1 -1
- package/dist/compiler/schema/primitives.d.ts +58 -0
- package/dist/compiler/schema/primitives.d.ts.map +1 -1
- package/dist/compiler/schema/typeToJsonSchema.d.ts +20 -0
- package/dist/compiler/schema/typeToJsonSchema.d.ts.map +1 -1
- package/dist/compiler/schema/types.d.ts +15 -0
- package/dist/compiler/schema/types.d.ts.map +1 -1
- package/dist/compiler/schema/unionHandler.d.ts +60 -0
- package/dist/compiler/schema/unionHandler.d.ts.map +1 -1
- package/dist/compiler/transform/dedup.d.ts +35 -0
- package/dist/compiler/transform/dedup.d.ts.map +1 -0
- package/dist/compiler/transform/flatten.d.ts +50 -0
- package/dist/compiler/transform/flatten.d.ts.map +1 -0
- package/dist/compiler/transform/index.d.ts +7 -0
- package/dist/compiler/transform/index.d.ts.map +1 -0
- package/dist/compiler/transform/inline.d.ts +46 -0
- package/dist/compiler/transform/inline.d.ts.map +1 -0
- package/dist/compiler/validation/emitPrecompiledValidators.d.ts +16 -0
- package/dist/compiler/validation/emitPrecompiledValidators.d.ts.map +1 -1
- package/dist/compiler/validation/index.d.ts +5 -0
- package/dist/compiler/validation/index.d.ts.map +1 -0
- package/dist/decorators/Auth.d.ts +17 -0
- package/dist/decorators/Auth.d.ts.map +1 -1
- package/dist/decorators/Controller.d.ts +15 -0
- package/dist/decorators/Controller.d.ts.map +1 -1
- package/dist/decorators/Public.d.ts +13 -0
- package/dist/decorators/Public.d.ts.map +1 -1
- package/dist/decorators/Use.d.ts +18 -0
- package/dist/decorators/Use.d.ts.map +1 -1
- package/dist/decorators/methods.d.ts +20 -0
- package/dist/decorators/methods.d.ts.map +1 -1
- package/dist/express.cjs +71 -11
- package/dist/express.cjs.map +1 -1
- package/dist/express.d.ts +1 -0
- package/dist/express.d.ts.map +1 -1
- package/dist/express.js +71 -11
- package/dist/express.js.map +1 -1
- package/dist/index.cjs +160 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +155 -2
- package/dist/index.js.map +1 -1
- package/dist/metal/applyListQuery.d.ts +73 -0
- package/dist/metal/applyListQuery.d.ts.map +1 -1
- package/dist/metal/index.cjs.map +1 -1
- package/dist/metal/index.d.ts +4 -0
- package/dist/metal/index.d.ts.map +1 -1
- package/dist/metal/index.js.map +1 -1
- package/dist/metal/listQuery.d.ts +19 -0
- package/dist/metal/listQuery.d.ts.map +1 -1
- package/dist/metal/queryOptions.d.ts +8 -0
- package/dist/metal/queryOptions.d.ts.map +1 -1
- package/dist/metal/readMetalBag.d.ts +36 -0
- package/dist/metal/readMetalBag.d.ts.map +1 -1
- package/dist/metal/registerMetalEntities.d.ts +20 -0
- package/dist/metal/registerMetalEntities.d.ts.map +1 -1
- package/dist/metal/schemaFromEntity.d.ts +30 -0
- package/dist/metal/schemaFromEntity.d.ts.map +1 -1
- package/dist/metal/searchWhere.d.ts +39 -0
- package/dist/metal/searchWhere.d.ts.map +1 -1
- package/dist/metal/symbolMetadata.d.ts +6 -0
- package/dist/metal/symbolMetadata.d.ts.map +1 -1
- package/dist/runtime/auth/runtime.d.ts +155 -6
- package/dist/runtime/auth/runtime.d.ts.map +1 -1
- package/dist/runtime/metadata/bucket.d.ts +1 -2
- package/dist/runtime/metadata/bucket.d.ts.map +1 -1
- package/dist/runtime/metadata/key.d.ts +1 -1
- package/dist/runtime/metadata/key.d.ts.map +1 -1
- package/dist/runtime/metadata/read.d.ts +1 -2
- package/dist/runtime/metadata/read.d.ts.map +1 -1
- package/dist/runtime/metadata/types.d.ts +74 -0
- package/dist/runtime/metadata/types.d.ts.map +1 -1
- package/dist/runtime/polyfill.d.ts +1 -1
- package/dist/runtime/polyfill.d.ts.map +1 -1
- package/dist/runtime/upload.d.ts +37 -0
- package/dist/runtime/upload.d.ts.map +1 -1
- package/dist/runtime/validation/ajv.d.ts +100 -0
- package/dist/runtime/validation/ajv.d.ts.map +1 -1
- package/dist/runtime/validation/index.d.ts +9 -0
- package/dist/runtime/validation/index.d.ts.map +1 -1
- package/dist/scripts/adorn-example.cjs +238 -6
- package/dist/scripts/adorn-example.cjs.map +1 -1
- package/dist/utils/port.d.ts +9 -0
- package/dist/utils/port.d.ts.map +1 -0
- package/package.json +3 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/compiler/runner/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,uBAAuB,EAAE,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -1,10 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema annotation extraction module.
|
|
3
|
+
* Parses decorator-based schema annotations from TypeScript source code.
|
|
4
|
+
*/
|
|
1
5
|
import ts from "typescript";
|
|
6
|
+
/**
|
|
7
|
+
* Represents a fragment of JSON Schema that can be merged with other fragments.
|
|
8
|
+
* Used for collecting schema annotations from decorators.
|
|
9
|
+
*/
|
|
2
10
|
export interface SchemaFragment {
|
|
3
11
|
[key: string]: unknown;
|
|
4
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Extracts schema annotation fragments from a property or parameter declaration.
|
|
15
|
+
* Looks for decorators like @Min, @Max, @Pattern, etc. and converts them to JSON Schema fragments.
|
|
16
|
+
*
|
|
17
|
+
* @param checker - TypeScript type checker for symbol resolution
|
|
18
|
+
* @param prop - The property or parameter declaration to analyze
|
|
19
|
+
* @returns Array of schema fragments from found decorators
|
|
20
|
+
*/
|
|
5
21
|
export declare function extractPropertySchemaFragments(checker: ts.TypeChecker, prop: ts.PropertyDeclaration | ts.ParameterDeclaration): SchemaFragment[];
|
|
22
|
+
/**
|
|
23
|
+
* Merges multiple schema fragments into a single schema object.
|
|
24
|
+
* Later fragments override earlier ones for conflicting keys.
|
|
25
|
+
*
|
|
26
|
+
* @param base - The base schema object to merge into
|
|
27
|
+
* @param frags - Variable number of schema fragments to merge
|
|
28
|
+
* @returns The merged schema object
|
|
29
|
+
*/
|
|
6
30
|
export declare function mergeFragments(base: Record<string, unknown>, ...frags: SchemaFragment[]): Record<string, unknown>;
|
|
31
|
+
/**
|
|
32
|
+
* Extracts the description from JSDoc comments on a node.
|
|
33
|
+
*
|
|
34
|
+
* @param checker - TypeScript type checker
|
|
35
|
+
* @param node - The AST node to extract description from
|
|
36
|
+
* @returns The cleaned description text, or undefined if no description found
|
|
37
|
+
*/
|
|
7
38
|
export declare function extractJSDocDescription(checker: ts.TypeChecker, node: ts.Node): string | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Extracts JSDoc tags from a node and converts them to schema properties.
|
|
41
|
+
* Supports @example, @default, @description, and @deprecated tags.
|
|
42
|
+
*
|
|
43
|
+
* @param checker - TypeScript type checker
|
|
44
|
+
* @param node - The AST node to extract tags from
|
|
45
|
+
* @returns Object mapping tag names to their extracted values
|
|
46
|
+
*/
|
|
8
47
|
export declare function extractJSDocTags(checker: ts.TypeChecker, node: ts.Node): Record<string, unknown>;
|
|
48
|
+
/**
|
|
49
|
+
* Extracts schema annotation fragments from a class declaration.
|
|
50
|
+
* Looks for class-level decorators and JSDoc comments.
|
|
51
|
+
*
|
|
52
|
+
* @param checker - TypeScript type checker for symbol resolution
|
|
53
|
+
* @param classDecl - The class declaration to analyze
|
|
54
|
+
* @returns Array of schema fragments from found annotations
|
|
55
|
+
*/
|
|
9
56
|
export declare function extractClassSchemaFragments(checker: ts.TypeChecker, classDecl: ts.ClassDeclaration): SchemaFragment[];
|
|
10
57
|
//# sourceMappingURL=extractAnnotations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractAnnotations.d.ts","sourceRoot":"","sources":["../../../src/compiler/schema/extractAnnotations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,MAAM,WAAW,cAAc;IAC7B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,EAAE,CAAC,WAAW,EACvB,IAAI,EAAE,EAAE,CAAC,mBAAmB,GAAG,EAAE,CAAC,oBAAoB,GACrD,cAAc,EAAE,CAkGlB;AA+DD,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,KAAK,EAAE,cAAc,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAMjH;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,EAAE,CAAC,WAAW,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,MAAM,GAAG,SAAS,CAmBlG;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,EAAE,CAAC,WAAW,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA+BhG;AA+BD,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,EAAE,CAAC,WAAW,EACvB,SAAS,EAAE,EAAE,CAAC,gBAAgB,GAC7B,cAAc,EAAE,CA4DlB"}
|
|
1
|
+
{"version":3,"file":"extractAnnotations.d.ts","sourceRoot":"","sources":["../../../src/compiler/schema/extractAnnotations.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;;;;;GAOG;AACH,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,EAAE,CAAC,WAAW,EACvB,IAAI,EAAE,EAAE,CAAC,mBAAmB,GAAG,EAAE,CAAC,oBAAoB,GACrD,cAAc,EAAE,CAkGlB;AA+DD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,KAAK,EAAE,cAAc,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAMjH;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,EAAE,CAAC,WAAW,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,MAAM,GAAG,SAAS,CAmBlG;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,EAAE,CAAC,WAAW,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA+BhG;AA+BD;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,EAAE,CAAC,WAAW,EACvB,SAAS,EAAE,EAAE,CAAC,gBAAgB,GAC7B,cAAc,EAAE,CA4DlB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/compiler/schema/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACpB,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -1,7 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Intersection type handling module.
|
|
3
|
+
* Converts TypeScript intersection types to JSON Schema allOf constructs.
|
|
4
|
+
*/
|
|
1
5
|
import ts from "typescript";
|
|
2
6
|
import type { JsonSchema, SchemaContext } from "./types.js";
|
|
7
|
+
/**
|
|
8
|
+
* Handles TypeScript intersection types and converts them to JSON Schema.
|
|
9
|
+
* Tries to collapse branded intersections and builds named schemas for complex intersections.
|
|
10
|
+
*
|
|
11
|
+
* @param type - The intersection type to convert
|
|
12
|
+
* @param ctx - The schema generation context
|
|
13
|
+
* @param typeNode - Optional type node for additional context
|
|
14
|
+
* @returns The generated JSON Schema
|
|
15
|
+
*/
|
|
3
16
|
export declare function handleIntersection(type: ts.IntersectionType, ctx: SchemaContext, typeNode?: ts.TypeNode): JsonSchema;
|
|
17
|
+
/**
|
|
18
|
+
* Attempts to collapse a branded intersection type to a simpler schema.
|
|
19
|
+
* A branded intersection is one that combines a primitive type with a brand object type.
|
|
20
|
+
*
|
|
21
|
+
* @param types - The constituent types of the intersection
|
|
22
|
+
* @param ctx - The schema generation context
|
|
23
|
+
* @param typeNode - Optional type node for additional context
|
|
24
|
+
* @returns The simplified schema if collapse is possible, null otherwise
|
|
25
|
+
*/
|
|
4
26
|
export declare function tryCollapseBrandedIntersection(types: readonly ts.Type[], ctx: SchemaContext, _typeNode?: ts.TypeNode): JsonSchema | null;
|
|
27
|
+
/**
|
|
28
|
+
* Checks if a TypeScript type represents a primitive type (string, number, boolean, bigint, or their literals).
|
|
29
|
+
*
|
|
30
|
+
* @param t - The type to check
|
|
31
|
+
* @returns True if the type is a primitive or primitive literal
|
|
32
|
+
*/
|
|
5
33
|
export declare function isPrimitiveLike(t: ts.Type): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Checks if a TypeScript type represents a brand/billing object type.
|
|
36
|
+
* Brand objects are simple objects with only brand-related properties like __brand or brand.
|
|
37
|
+
*
|
|
38
|
+
* @param checker - TypeScript type checker
|
|
39
|
+
* @param t - The type to check
|
|
40
|
+
* @param _ctx - The schema generation context (unused)
|
|
41
|
+
* @returns True if the type appears to be a brand object
|
|
42
|
+
*/
|
|
6
43
|
export declare function isBrandObject(checker: ts.TypeChecker, t: ts.Type, _ctx: SchemaContext): boolean;
|
|
7
44
|
//# sourceMappingURL=intersectionHandler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intersectionHandler.d.ts","sourceRoot":"","sources":["../../../src/compiler/schema/intersectionHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG5D,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,EAAE,CAAC,gBAAgB,EACzB,GAAG,EAAE,aAAa,EAClB,QAAQ,CAAC,EAAE,EAAE,CAAC,QAAQ,GACrB,UAAU,CA6BZ;AAED,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE,SAAS,EAAE,CAAC,IAAI,EAAE,EACzB,GAAG,EAAE,aAAa,EAClB,SAAS,CAAC,EAAE,EAAE,CAAC,QAAQ,GACtB,UAAU,GAAG,IAAI,CAanB;AAED,wBAAgB,eAAe,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,GAAG,OAAO,CAInD;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,EAAE,CAAC,WAAW,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,aAAa,GAAG,OAAO,CAkB/F"}
|
|
1
|
+
{"version":3,"file":"intersectionHandler.d.ts","sourceRoot":"","sources":["../../../src/compiler/schema/intersectionHandler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG5D;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,EAAE,CAAC,gBAAgB,EACzB,GAAG,EAAE,aAAa,EAClB,QAAQ,CAAC,EAAE,EAAE,CAAC,QAAQ,GACrB,UAAU,CA6BZ;AAED;;;;;;;;GAQG;AACH,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE,SAAS,EAAE,CAAC,IAAI,EAAE,EACzB,GAAG,EAAE,aAAa,EAClB,SAAS,CAAC,EAAE,EAAE,CAAC,QAAQ,GACtB,UAAU,GAAG,IAAI,CAanB;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,GAAG,OAAO,CAInD;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,EAAE,CAAC,WAAW,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,aAAa,GAAG,OAAO,CAkB/F"}
|
|
@@ -1,20 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Object type handling module.
|
|
3
|
+
* Converts TypeScript object types and interfaces to JSON Schema.
|
|
4
|
+
*/
|
|
1
5
|
import ts from "typescript";
|
|
2
6
|
import type { JsonSchema, SchemaContext } from "./types.js";
|
|
7
|
+
/**
|
|
8
|
+
* Handles TypeScript object types and converts them to JSON Schema.
|
|
9
|
+
* Manages named schemas, component registration, and cycle detection.
|
|
10
|
+
*
|
|
11
|
+
* @param type - The object type to convert
|
|
12
|
+
* @param ctx - The schema generation context
|
|
13
|
+
* @param typeNode - Optional type node for additional context
|
|
14
|
+
* @returns The generated JSON Schema
|
|
15
|
+
*/
|
|
3
16
|
export declare function handleObjectType(type: ts.ObjectType, ctx: SchemaContext, typeNode?: ts.TypeNode): JsonSchema;
|
|
17
|
+
/**
|
|
18
|
+
* Builds the actual object schema from a TypeScript object type.
|
|
19
|
+
* Extracts properties, handles required fields, and processes Record types.
|
|
20
|
+
*
|
|
21
|
+
* @param type - The object type to convert
|
|
22
|
+
* @param ctx - The schema generation context
|
|
23
|
+
* @param typeNode - Optional type node for additional context
|
|
24
|
+
* @returns The generated object schema
|
|
25
|
+
*/
|
|
4
26
|
export declare function buildObjectSchema(type: ts.ObjectType, ctx: SchemaContext, _typeNode?: ts.TypeNode): JsonSchema;
|
|
27
|
+
/**
|
|
28
|
+
* Checks if a TypeScript type represents a Record type.
|
|
29
|
+
*
|
|
30
|
+
* @param type - The type to check
|
|
31
|
+
* @param _checker - TypeScript type checker (unused)
|
|
32
|
+
* @returns True if the type is a Record type
|
|
33
|
+
*/
|
|
5
34
|
export declare function isRecordType(type: ts.ObjectType, _checker: ts.TypeChecker): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Extracts the value type from a Record type.
|
|
37
|
+
* For Record<K, V>, returns V.
|
|
38
|
+
*
|
|
39
|
+
* @param type - The Record type to extract from
|
|
40
|
+
* @param _checker - TypeScript type checker (unused)
|
|
41
|
+
* @returns The value type, or null if not a Record or has no type arguments
|
|
42
|
+
*/
|
|
6
43
|
export declare function getRecordValueType(type: ts.ObjectType, _checker: ts.TypeChecker): ts.Type | null;
|
|
44
|
+
/**
|
|
45
|
+
* Checks if a type represents a Metal ORM wrapper type (e.g., HasManyCollection, BelongsToReference).
|
|
46
|
+
*
|
|
47
|
+
* @param type - The type to check
|
|
48
|
+
* @param checker - TypeScript type checker for symbol resolution
|
|
49
|
+
* @returns True if the type is a Metal ORM wrapper
|
|
50
|
+
*/
|
|
7
51
|
export declare function isMetalOrmWrapperType(type: ts.Type, checker: ts.TypeChecker): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Checks if a TypeScript type represents a callable/method-like type.
|
|
54
|
+
*
|
|
55
|
+
* @param type - The type to check
|
|
56
|
+
* @returns True if the type has call signatures (is callable)
|
|
57
|
+
*/
|
|
8
58
|
export declare function isMethodLike(type: ts.Type): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Checks if a property name represents an iterator or Symbol property that should be excluded.
|
|
61
|
+
*
|
|
62
|
+
* @param propName - The property name to check
|
|
63
|
+
* @returns True if the property should be excluded from schema generation
|
|
64
|
+
*/
|
|
9
65
|
export declare function isIteratorOrSymbolProperty(propName: string): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Gets the type name from a type node or generates an anonymous name.
|
|
68
|
+
*
|
|
69
|
+
* @param typeNode - The type node to extract name from
|
|
70
|
+
* @param _ctx - The schema generation context (unused)
|
|
71
|
+
* @returns The type name or generated anonymous name
|
|
72
|
+
*/
|
|
10
73
|
export declare function getTypeNameFromNode(typeNode: ts.TypeNode | undefined, _ctx: SchemaContext): string;
|
|
11
74
|
interface MetalOrmWrapperInfo {
|
|
12
75
|
wrapperName: string;
|
|
13
76
|
targetTypeArgs: ReadonlyArray<ts.Type>;
|
|
14
77
|
isReadonlyArray: boolean;
|
|
15
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Finds and extracts information about a Metal ORM wrapper type within a type.
|
|
81
|
+
* Handles both direct wrapper types and wrapper types within intersections.
|
|
82
|
+
*
|
|
83
|
+
* @param type - The type to analyze
|
|
84
|
+
* @param checker - TypeScript type checker for symbol resolution
|
|
85
|
+
* @returns Wrapper info if found, null otherwise
|
|
86
|
+
*/
|
|
16
87
|
export declare function findMetalOrmWrapper(type: ts.Type, checker: ts.TypeChecker): MetalOrmWrapperInfo | null;
|
|
88
|
+
/**
|
|
89
|
+
* Gets the name of a Metal ORM wrapper type if applicable.
|
|
90
|
+
*
|
|
91
|
+
* @param type - The type to check
|
|
92
|
+
* @param _checker - TypeScript type checker (unused)
|
|
93
|
+
* @returns The wrapper type name if applicable, null otherwise
|
|
94
|
+
*/
|
|
17
95
|
export declare function getWrapperTypeName(type: ts.Type, _checker: ts.TypeChecker): string | null;
|
|
96
|
+
/**
|
|
97
|
+
* Handles Metal ORM wrapper types and converts them to appropriate JSON Schema.
|
|
98
|
+
* Different wrapper types result in different schema structures.
|
|
99
|
+
*
|
|
100
|
+
* @param type - The wrapper object type to convert
|
|
101
|
+
* @param ctx - The schema generation context
|
|
102
|
+
* @returns The generated JSON Schema for the wrapper
|
|
103
|
+
*/
|
|
18
104
|
export declare function handleMetalOrmWrapper(type: ts.ObjectType, ctx: SchemaContext): JsonSchema;
|
|
19
105
|
export {};
|
|
20
106
|
//# sourceMappingURL=objectHandler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"objectHandler.d.ts","sourceRoot":"","sources":["../../../src/compiler/schema/objectHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG5D,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,EAAE,CAAC,UAAU,EACnB,GAAG,EAAE,aAAa,EAClB,QAAQ,CAAC,EAAE,EAAE,CAAC,QAAQ,GACrB,UAAU,
|
|
1
|
+
{"version":3,"file":"objectHandler.d.ts","sourceRoot":"","sources":["../../../src/compiler/schema/objectHandler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG5D;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,EAAE,CAAC,UAAU,EACnB,GAAG,EAAE,aAAa,EAClB,QAAQ,CAAC,EAAE,EAAE,CAAC,QAAQ,GACrB,UAAU,CA4CZ;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,EAAE,CAAC,UAAU,EACnB,GAAG,EAAE,aAAa,EAClB,SAAS,CAAC,EAAE,EAAE,CAAC,QAAQ,GACtB,UAAU,CAmDZ;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,EAAE,QAAQ,EAAE,EAAE,CAAC,WAAW,GAAG,OAAO,CAQnF;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,EAAE,QAAQ,EAAE,EAAE,CAAC,WAAW,GAAG,EAAE,CAAC,IAAI,GAAG,IAAI,CAchG;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,WAAW,GAAG,OAAO,CAErF;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,OAAO,CAGnD;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEpE;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,GAAG,SAAS,EAAE,IAAI,EAAE,aAAa,GAAG,MAAM,CAKlG;AA0ID,UAAU,mBAAmB;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,aAAa,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IACvC,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,EAAE,CAAC,IAAI,EACb,OAAO,EAAE,EAAE,CAAC,WAAW,GACtB,mBAAmB,GAAG,IAAI,CAwB5B;AAwBD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,CAAC,WAAW,GAAG,MAAM,GAAG,IAAI,CAKzF;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,EAAE,GAAG,EAAE,aAAa,GAAG,UAAU,CAsDzF"}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAPI specification generation module.
|
|
3
|
+
* Converts scanned controllers to OpenAPI 3.1 format.
|
|
4
|
+
*/
|
|
1
5
|
import ts from "typescript";
|
|
2
6
|
import type { ScannedController } from "../analyze/scanControllers.js";
|
|
3
7
|
import type { JsonSchema } from "./types.js";
|
|
8
|
+
/**
|
|
9
|
+
* OpenAPI 3.1 specification interface.
|
|
10
|
+
*/
|
|
4
11
|
export interface OpenAPI31 {
|
|
5
12
|
openapi: "3.1.0";
|
|
6
13
|
info: {
|
|
@@ -12,6 +19,14 @@ export interface OpenAPI31 {
|
|
|
12
19
|
};
|
|
13
20
|
paths: Record<string, Record<string, any>>;
|
|
14
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Generates an OpenAPI 3.1 specification from scanned controllers.
|
|
24
|
+
*
|
|
25
|
+
* @param controllers - Array of scanned controllers to include in the spec
|
|
26
|
+
* @param checker - TypeScript type checker for type analysis
|
|
27
|
+
* @param options - Optional title and version for the OpenAPI info object
|
|
28
|
+
* @returns Complete OpenAPI 3.1 specification object
|
|
29
|
+
*/
|
|
15
30
|
export declare function generateOpenAPI(controllers: ScannedController[], checker: ts.TypeChecker, options?: {
|
|
16
31
|
title?: string;
|
|
17
32
|
version?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openapi.d.ts","sourceRoot":"","sources":["../../../src/compiler/schema/openapi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,KAAK,EAAE,iBAAiB,EAAsC,MAAM,+BAA+B,CAAC;AAG3G,OAAO,KAAK,EAAiB,UAAU,EAAE,MAAM,YAAY,CAAC;AAU5D,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,UAAU,EAAE;QACV,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;KACrC,CAAC;IACF,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;CAC5C;AAED,wBAAgB,eAAe,CAC7B,WAAW,EAAE,iBAAiB,EAAE,EAChC,OAAO,EAAE,EAAE,CAAC,WAAW,EACvB,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAO,GACjD,SAAS,CAuCX"}
|
|
1
|
+
{"version":3,"file":"openapi.d.ts","sourceRoot":"","sources":["../../../src/compiler/schema/openapi.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,KAAK,EAAE,iBAAiB,EAAsC,MAAM,+BAA+B,CAAC;AAG3G,OAAO,KAAK,EAAiB,UAAU,EAAE,MAAM,YAAY,CAAC;AAU5D;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,UAAU,EAAE;QACV,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;KACrC,CAAC;IACF,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;CAC5C;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,WAAW,EAAE,iBAAiB,EAAE,EAChC,OAAO,EAAE,EAAE,CAAC,WAAW,EACvB,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAO,GACjD,SAAS,CAuCX"}
|
|
@@ -1,16 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parameter specification building module.
|
|
3
|
+
* Converts scanned parameters to OpenAPI parameter objects.
|
|
4
|
+
*/
|
|
1
5
|
import type { ScannedOperation } from "../analyze/scanControllers.js";
|
|
2
6
|
import type { SchemaContext, JsonSchema } from "./types.js";
|
|
7
|
+
/**
|
|
8
|
+
* Builds OpenAPI path parameter objects from scanned operation parameters.
|
|
9
|
+
* Adds them to the provided parameters array.
|
|
10
|
+
*
|
|
11
|
+
* @param operation - The scanned operation containing path parameters
|
|
12
|
+
* @param ctx - The schema generation context
|
|
13
|
+
* @param parameters - Array to accumulate parameter objects
|
|
14
|
+
*/
|
|
3
15
|
export declare function buildPathParameters(operation: ScannedOperation, ctx: SchemaContext, parameters: any[]): void;
|
|
16
|
+
/**
|
|
17
|
+
* Builds OpenAPI query parameter objects from scanned operation parameters.
|
|
18
|
+
* Handles both individual query parameters and query objects.
|
|
19
|
+
*
|
|
20
|
+
* @param operation - The scanned operation containing query parameters
|
|
21
|
+
* @param ctx - The schema generation context
|
|
22
|
+
* @param parameters - Array to accumulate parameter objects
|
|
23
|
+
*/
|
|
4
24
|
export declare function buildQueryParameters(operation: ScannedOperation, ctx: SchemaContext, parameters: any[]): void;
|
|
25
|
+
/**
|
|
26
|
+
* Builds OpenAPI header parameter objects from scanned operation parameters.
|
|
27
|
+
* Extracts individual header parameters from a headers object.
|
|
28
|
+
*
|
|
29
|
+
* @param operation - The scanned operation containing header parameters
|
|
30
|
+
* @param ctx - The schema generation context
|
|
31
|
+
* @param parameters - Array to accumulate parameter objects
|
|
32
|
+
*/
|
|
5
33
|
export declare function buildHeaderParameters(operation: ScannedOperation, ctx: SchemaContext, parameters: any[]): void;
|
|
34
|
+
/**
|
|
35
|
+
* Builds OpenAPI cookie parameter objects from scanned operation parameters.
|
|
36
|
+
* Extracts individual cookie parameters from a cookies object.
|
|
37
|
+
*
|
|
38
|
+
* @param operation - The scanned operation containing cookie parameters
|
|
39
|
+
* @param ctx - The schema generation context
|
|
40
|
+
* @param parameters - Array to accumulate parameter objects
|
|
41
|
+
*/
|
|
6
42
|
export declare function buildCookieParameters(operation: ScannedOperation, ctx: SchemaContext, parameters: any[]): void;
|
|
43
|
+
/**
|
|
44
|
+
* Determines OpenAPI serialization style/explode options based on schema type.
|
|
45
|
+
*
|
|
46
|
+
* @param schemaType - The schema type(s) to analyze
|
|
47
|
+
* @returns Object containing style and explode options if applicable
|
|
48
|
+
*/
|
|
7
49
|
export declare function determineQuerySerialization(schemaType: string | string[] | undefined): {
|
|
8
50
|
style?: string;
|
|
9
51
|
explode?: boolean;
|
|
10
52
|
};
|
|
53
|
+
/**
|
|
54
|
+
* Generates an example value description for a schema.
|
|
55
|
+
* Creates a human-readable example showing the expected structure.
|
|
56
|
+
*
|
|
57
|
+
* @param schema - The JSON Schema to generate example for
|
|
58
|
+
* @param propName - The property name for the example
|
|
59
|
+
* @returns A description string with example value
|
|
60
|
+
*/
|
|
11
61
|
export declare function generateExampleValue(schema: JsonSchema, propName: string): string;
|
|
62
|
+
/**
|
|
63
|
+
* Parses an example value from a description string.
|
|
64
|
+
* Extracts the JSON object from "Example: propName={...}" format.
|
|
65
|
+
*
|
|
66
|
+
* @param description - The description string to parse
|
|
67
|
+
* @returns The extracted JSON string, or default if not found
|
|
68
|
+
*/
|
|
12
69
|
export declare function parseExampleValue(description: string): string;
|
|
70
|
+
/**
|
|
71
|
+
* Recursively resolves $ref references in a JSON Schema.
|
|
72
|
+
*
|
|
73
|
+
* @param schema - The schema to resolve references in
|
|
74
|
+
* @param components - Map of component schemas for reference resolution
|
|
75
|
+
* @returns The resolved schema with all references followed
|
|
76
|
+
*/
|
|
13
77
|
export declare function resolveSchemaRef(schema: JsonSchema, components: Map<string, JsonSchema>): JsonSchema;
|
|
78
|
+
/**
|
|
79
|
+
* Resolves object schema references and collects all properties.
|
|
80
|
+
* Handles allOf composition and $ref resolution.
|
|
81
|
+
*
|
|
82
|
+
* @param schema - The object schema to process
|
|
83
|
+
* @param components - Map of component schemas for reference resolution
|
|
84
|
+
* @returns Object containing all collected properties and required fields
|
|
85
|
+
*/
|
|
14
86
|
export declare function resolveAndCollectObjectProps(schema: JsonSchema, components: Map<string, JsonSchema>): {
|
|
15
87
|
properties: Record<string, JsonSchema>;
|
|
16
88
|
required: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parameters.d.ts","sourceRoot":"","sources":["../../../src/compiler/schema/parameters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAI5D,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,gBAAgB,EAAE,GAAG,EAAE,aAAa,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,IAAI,CAkC5G;AAED,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,gBAAgB,EAAE,GAAG,EAAE,aAAa,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"parameters.d.ts","sourceRoot":"","sources":["../../../src/compiler/schema/parameters.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAI5D;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,gBAAgB,EAAE,GAAG,EAAE,aAAa,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,IAAI,CAkC5G;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,gBAAgB,EAAE,GAAG,EAAE,aAAa,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,IAAI,CA4H7G;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,gBAAgB,EAAE,GAAG,EAAE,aAAa,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,IAAI,CAmB9G;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,gBAAgB,EAAE,GAAG,EAAE,aAAa,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,IAAI,CAqB9G;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAS5H;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAyBjF;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAM7D;AA+CD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,UAAU,CAWpG;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,UAAU,EAClB,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,GAClC;IAAE,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAiChE"}
|
|
@@ -1,10 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Primitive type handling module.
|
|
3
|
+
* Converts TypeScript primitive types to JSON Schema.
|
|
4
|
+
*/
|
|
1
5
|
import ts from "typescript";
|
|
2
6
|
import type { JsonSchema, SchemaContext } from "./types.js";
|
|
7
|
+
/**
|
|
8
|
+
* Handles TypeScript primitive types and converts them to JSON Schema.
|
|
9
|
+
* Supports string, number, boolean, bigint, null, undefined, Date, and literal types.
|
|
10
|
+
*
|
|
11
|
+
* @param type - The primitive type to convert
|
|
12
|
+
* @param ctx - The schema generation context
|
|
13
|
+
* @param typeNode - Optional type node for additional context
|
|
14
|
+
* @returns The generated JSON Schema, or null if not a recognized primitive
|
|
15
|
+
*/
|
|
3
16
|
export declare function handlePrimitiveType(type: ts.Type, ctx: SchemaContext, typeNode?: ts.TypeNode): JsonSchema | null;
|
|
17
|
+
/**
|
|
18
|
+
* Checks if a TypeScript type represents a Date type.
|
|
19
|
+
* Handles both direct Date references and aliased Date types.
|
|
20
|
+
*
|
|
21
|
+
* @param type - The type to check
|
|
22
|
+
* @param checker - TypeScript type checker for symbol resolution
|
|
23
|
+
* @returns True if the type represents Date
|
|
24
|
+
*/
|
|
4
25
|
export declare function isDateType(type: ts.Type, checker: ts.TypeChecker): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Checks if a TypeScript type represents a Set type.
|
|
28
|
+
*
|
|
29
|
+
* @param type - The type to check
|
|
30
|
+
* @param _checker - TypeScript type checker (unused)
|
|
31
|
+
* @returns True if the type is a Set type
|
|
32
|
+
*/
|
|
5
33
|
export declare function isSetType(type: ts.Type, _checker: ts.TypeChecker): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Normalizes numeric types to either integer or number based on naming conventions.
|
|
36
|
+
* Types named like "id", "page", "pageSize", etc. are converted to integer schema.
|
|
37
|
+
*
|
|
38
|
+
* @param type - The numeric type to normalize
|
|
39
|
+
* @param checker - TypeScript type checker for symbol resolution
|
|
40
|
+
* @param typeNode - Optional type node for name extraction
|
|
41
|
+
* @param propertyName - Optional property name for name-based inference
|
|
42
|
+
* @returns The normalized numeric schema
|
|
43
|
+
*/
|
|
6
44
|
export declare function normalizeNumericType(type: ts.Type, checker: ts.TypeChecker, typeNode?: ts.TypeNode, propertyName?: string): JsonSchema;
|
|
45
|
+
/**
|
|
46
|
+
* Determines if a type should be represented as an integer based on its name.
|
|
47
|
+
* Common patterns include "id", "page", "pageSize", "limit", etc.
|
|
48
|
+
*
|
|
49
|
+
* @param typeName - The type or property name to check
|
|
50
|
+
* @returns True if the name suggests an integer type
|
|
51
|
+
*/
|
|
7
52
|
export declare function shouldBeIntegerType(typeName: string | null): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Extracts the explicit type name from a type reference node or type alias declaration.
|
|
55
|
+
*
|
|
56
|
+
* @param typeNode - The type node to extract name from
|
|
57
|
+
* @returns The extracted type name, or null if not found
|
|
58
|
+
*/
|
|
8
59
|
export declare function getExplicitTypeNameFromNode(typeNode?: ts.TypeNode): string | null;
|
|
60
|
+
/**
|
|
61
|
+
* Gets the effective symbol for a type, resolving type aliases.
|
|
62
|
+
*
|
|
63
|
+
* @param type - The type to get symbol from
|
|
64
|
+
* @param checker - TypeScript type checker for alias resolution
|
|
65
|
+
* @returns The effective symbol, or null if not found
|
|
66
|
+
*/
|
|
9
67
|
export declare function getEffectiveSymbol(type: ts.Type, checker: ts.TypeChecker): ts.Symbol | null;
|
|
10
68
|
//# sourceMappingURL=primitives.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"primitives.d.ts","sourceRoot":"","sources":["../../../src/compiler/schema/primitives.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE5D,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,EAAE,CAAC,IAAI,EACb,GAAG,EAAE,aAAa,EAClB,QAAQ,CAAC,EAAE,EAAE,CAAC,QAAQ,GACrB,UAAU,GAAG,IAAI,CA4CnB;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,WAAW,GAAG,OAAO,CAc1E;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,CAAC,WAAW,GAAG,OAAO,CAM1E;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,WAAW,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC,QAAQ,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,UAAU,CAUtI;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GA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BAAgB,2BAA2B,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,QAAQ,GAAG,MAAM,GAAG,IAAI,CAgBjF;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,WAAW,GAAG,EAAE,CAAC,MAAM,GAAG,IAAI,CAM3F"}
|
|
@@ -1,6 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Main type-to-JSON-Schema conversion module.
|
|
3
|
+
* Routes different TypeScript types to appropriate handlers.
|
|
4
|
+
*/
|
|
1
5
|
import ts from "typescript";
|
|
2
6
|
import type { JsonSchema, SchemaContext } from "./types.js";
|
|
3
7
|
export type { JsonSchema, DiscriminatorObject, SchemaContext } from "./types.js";
|
|
8
|
+
/**
|
|
9
|
+
* Converts a TypeScript type to a JSON Schema object.
|
|
10
|
+
* This is the main entry point for schema generation, routing to appropriate type handlers.
|
|
11
|
+
*
|
|
12
|
+
* @param type - The TypeScript type to convert
|
|
13
|
+
* @param ctx - The schema generation context
|
|
14
|
+
* @param typeNode - Optional type node for additional context
|
|
15
|
+
* @returns The generated JSON Schema
|
|
16
|
+
*/
|
|
4
17
|
export declare function typeToJsonSchema(type: ts.Type, ctx: SchemaContext, typeNode?: ts.TypeNode): JsonSchema;
|
|
18
|
+
/**
|
|
19
|
+
* Creates a new schema generation context with fresh component registry and type stack.
|
|
20
|
+
*
|
|
21
|
+
* @param checker - TypeScript type checker for type analysis
|
|
22
|
+
* @param mode - Generation mode ("request" or "response"), defaults to "response"
|
|
23
|
+
* @returns A new SchemaContext for schema generation
|
|
24
|
+
*/
|
|
5
25
|
export declare function createSchemaContext(checker: ts.TypeChecker, mode?: "request" | "response"): SchemaContext;
|
|
6
26
|
//# sourceMappingURL=typeToJsonSchema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeToJsonSchema.d.ts","sourceRoot":"","sources":["../../../src/compiler/schema/typeToJsonSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAM5D,YAAY,EAAE,UAAU,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEjF,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,EAAE,CAAC,IAAI,EACb,GAAG,EAAE,aAAa,EAClB,QAAQ,CAAC,EAAE,EAAE,CAAC,QAAQ,GACrB,UAAU,CAkCZ;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,EAAE,CAAC,WAAW,EAAE,IAAI,GAAE,SAAS,GAAG,UAAuB,GAAG,aAAa,CAQrH"}
|
|
1
|
+
{"version":3,"file":"typeToJsonSchema.d.ts","sourceRoot":"","sources":["../../../src/compiler/schema/typeToJsonSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAM5D,YAAY,EAAE,UAAU,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEjF;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,EAAE,CAAC,IAAI,EACb,GAAG,EAAE,aAAa,EAClB,QAAQ,CAAC,EAAE,EAAE,CAAC,QAAQ,GACrB,UAAU,CAkCZ;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,EAAE,CAAC,WAAW,EAAE,IAAI,GAAE,SAAS,GAAG,UAAuB,GAAG,aAAa,CAQrH"}
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON Schema type definitions for the compiler.
|
|
3
|
+
* Core types used throughout schema generation.
|
|
4
|
+
*/
|
|
1
5
|
import ts from "typescript";
|
|
6
|
+
/**
|
|
7
|
+
* JSON Schema representation used throughout the compiler.
|
|
8
|
+
* Extended with OpenAPI and vendor-specific properties.
|
|
9
|
+
*/
|
|
2
10
|
export interface JsonSchema {
|
|
3
11
|
type?: string | string[];
|
|
4
12
|
properties?: Record<string, JsonSchema>;
|
|
@@ -39,10 +47,17 @@ export interface JsonSchema {
|
|
|
39
47
|
"x-metal-orm-rel"?: Record<string, unknown>;
|
|
40
48
|
"x-ts-type"?: string;
|
|
41
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* OpenAPI discriminator object for polymorphism support.
|
|
52
|
+
*/
|
|
42
53
|
export interface DiscriminatorObject {
|
|
43
54
|
propertyName: string;
|
|
44
55
|
mapping?: Record<string, string>;
|
|
45
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Context object passed through schema generation functions.
|
|
59
|
+
* Provides access to type checker, component registry, and generation options.
|
|
60
|
+
*/
|
|
46
61
|
export interface SchemaContext {
|
|
47
62
|
checker: ts.TypeChecker;
|
|
48
63
|
components: Map<string, JsonSchema>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/compiler/schema/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACxC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,IAAI,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CA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C,CAAC;IACxB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,IAAI,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB"}
|
|
@@ -1,10 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Union type handling module.
|
|
3
|
+
* Converts TypeScript union types to JSON Schema anyOf/oneOf constructs.
|
|
4
|
+
*/
|
|
1
5
|
import ts from "typescript";
|
|
2
6
|
import type { JsonSchema, DiscriminatorObject, SchemaContext } from "./types.js";
|
|
7
|
+
/**
|
|
8
|
+
* Handles TypeScript union types and converts them to JSON Schema.
|
|
9
|
+
* Creates anyOf schemas with optional discriminator for union members.
|
|
10
|
+
*
|
|
11
|
+
* @param type - The union type to convert
|
|
12
|
+
* @param ctx - The schema generation context
|
|
13
|
+
* @param typeNode - Optional type node for additional context
|
|
14
|
+
* @returns The generated JSON Schema
|
|
15
|
+
*/
|
|
3
16
|
export declare function handleUnion(type: ts.UnionType, ctx: SchemaContext, typeNode?: ts.TypeNode): JsonSchema;
|
|
17
|
+
/**
|
|
18
|
+
* Detects if a union type forms a discriminated union.
|
|
19
|
+
* A discriminated union has a common property with literal values that can be used for discrimination.
|
|
20
|
+
*
|
|
21
|
+
* @param types - The constituent types of the union
|
|
22
|
+
* @param ctx - The schema generation context
|
|
23
|
+
* @param branches - The generated schemas for each branch (unused in current impl)
|
|
24
|
+
* @returns Discriminator object if discriminated union detected, null otherwise
|
|
25
|
+
*/
|
|
4
26
|
export declare function detectDiscriminatedUnion(types: readonly ts.Type[], ctx: SchemaContext, _branches: JsonSchema[]): DiscriminatorObject | null;
|
|
27
|
+
/**
|
|
28
|
+
* Finds property names that are common across all types in a union.
|
|
29
|
+
*
|
|
30
|
+
* @param checker - TypeScript type checker for property lookup
|
|
31
|
+
* @param types - The types to analyze
|
|
32
|
+
* @returns Array of property names present in all types
|
|
33
|
+
*/
|
|
5
34
|
export declare function findCommonPropertyNames(checker: ts.TypeChecker, types: readonly ts.Type[]): string[];
|
|
35
|
+
/**
|
|
36
|
+
* Checks if a property is required (non-optional) in a given type.
|
|
37
|
+
*
|
|
38
|
+
* @param checker - TypeScript type checker for symbol analysis
|
|
39
|
+
* @param type - The type to check
|
|
40
|
+
* @param propName - The property name to check
|
|
41
|
+
* @returns True if the property is required
|
|
42
|
+
*/
|
|
6
43
|
export declare function isRequiredProperty(checker: ts.TypeChecker, type: ts.Type, propName: string): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Gets the literal string values of a property across a type.
|
|
46
|
+
* Used for detecting discriminated unions.
|
|
47
|
+
*
|
|
48
|
+
* @param checker - TypeScript type checker for property type analysis
|
|
49
|
+
* @param type - The type to check
|
|
50
|
+
* @param propName - The property name to get values for
|
|
51
|
+
* @returns Set of literal values, or null if not a literal union
|
|
52
|
+
*/
|
|
7
53
|
export declare function getPropertyLiteralValues(checker: ts.TypeChecker, type: ts.Type, propName: string): Set<string> | null;
|
|
54
|
+
/**
|
|
55
|
+
* Checks if multiple sets are pairwise disjoint (have no common elements).
|
|
56
|
+
*
|
|
57
|
+
* @param sets - Array of sets to check for disjointness
|
|
58
|
+
* @returns True if all sets are pairwise disjoint
|
|
59
|
+
*/
|
|
8
60
|
export declare function areSetsDisjoint(sets: Array<Set<string>>): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Gets the schema name for a union branch type.
|
|
63
|
+
* Used for discriminator mapping.
|
|
64
|
+
*
|
|
65
|
+
* @param type - The type to get name for
|
|
66
|
+
* @param ctx - The schema generation context
|
|
67
|
+
* @returns The schema name, or generated anonymous name
|
|
68
|
+
*/
|
|
9
69
|
export declare function getBranchSchemaName(type: ts.Type, ctx: SchemaContext): string;
|
|
10
70
|
//# sourceMappingURL=unionHandler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unionHandler.d.ts","sourceRoot":"","sources":["../../../src/compiler/schema/unionHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,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