@formspec/build 0.1.0-alpha.36 → 0.1.0-alpha.38
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 +36 -1
- package/dist/analyzer/class-analyzer.d.ts +4 -0
- package/dist/analyzer/class-analyzer.d.ts.map +1 -1
- package/dist/analyzer/program.d.ts.map +1 -1
- package/dist/analyzer/tsdoc-parser.d.ts.map +1 -1
- package/dist/build-alpha.d.ts +2 -0
- package/dist/build-beta.d.ts +2 -0
- package/dist/build-internal.d.ts +2 -0
- package/dist/build.d.ts +2 -0
- package/dist/cli.cjs +213 -8
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +213 -8
- package/dist/cli.js.map +1 -1
- package/dist/generators/discovered-schema.d.ts +2 -0
- package/dist/generators/discovered-schema.d.ts.map +1 -1
- package/dist/index.cjs +213 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +213 -8
- package/dist/index.js.map +1 -1
- package/dist/internals.cjs +219 -6
- package/dist/internals.cjs.map +1 -1
- package/dist/internals.js +219 -6
- package/dist/internals.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -76,7 +76,7 @@ Public helpers in this workflow:
|
|
|
76
76
|
- `resolveModuleExportDeclaration(context, exportName?)` - Resolve only schema-source declarations (`class`, `interface`, `type` alias).
|
|
77
77
|
- `generateSchemasFromDeclaration(...)` - Generate from a resolved schema-source declaration.
|
|
78
78
|
- `generateSchemasFromParameter(...)` - Generate from a method or function parameter declaration.
|
|
79
|
-
- `generateSchemasFromReturnType(...)` - Generate from a method or function return type.
|
|
79
|
+
- `generateSchemasFromReturnType(...)` - Generate from a method or function return type, unwrapping awaited `Promise<T>`-style returns before generation.
|
|
80
80
|
- `generateSchemasFromType(...)` - Generate directly from a resolved `ts.Type`.
|
|
81
81
|
|
|
82
82
|
Use `resolveModuleExportDeclaration(...)` when your tooling wants to hand a resolved
|
|
@@ -180,6 +180,41 @@ const result = generateSchemas({
|
|
|
180
180
|
|
|
181
181
|
Generation validates canonical IR before emitting schemas. Invalid inputs now fail generation with structured diagnostic codes surfaced in the thrown error.
|
|
182
182
|
|
|
183
|
+
### Handling Generation Failures
|
|
184
|
+
|
|
185
|
+
Static generation APIs such as `generateSchemas()` still throw on invalid input, but the thrown error message now includes stable diagnostic codes that consumers can inspect or surface directly.
|
|
186
|
+
|
|
187
|
+
```ts
|
|
188
|
+
import { generateSchemas } from "@formspec/build";
|
|
189
|
+
|
|
190
|
+
try {
|
|
191
|
+
const { jsonSchema, uiSchema } = generateSchemas({
|
|
192
|
+
filePath: "./src/forms.ts",
|
|
193
|
+
typeName: "Invoice",
|
|
194
|
+
});
|
|
195
|
+
} catch (error) {
|
|
196
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
197
|
+
|
|
198
|
+
if (message.includes("UNSUPPORTED_CUSTOM_TYPE_OVERRIDE")) {
|
|
199
|
+
// An extension tried to override a TS global built-in such as Date or Array
|
|
200
|
+
} else if (message.includes("SYNTHETIC_SETUP_FAILURE")) {
|
|
201
|
+
// Extension setup failed before tag type-checking could run
|
|
202
|
+
} else if (message.includes("TYPE_MISMATCH")) {
|
|
203
|
+
// A tag was applied to an incompatible field or target type
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
throw error;
|
|
207
|
+
}
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
The most relevant codes for extension-backed static analysis failures are:
|
|
211
|
+
|
|
212
|
+
- `UNSUPPORTED_CUSTOM_TYPE_OVERRIDE` for extension custom types that conflict with unsupported TypeScript global built-ins.
|
|
213
|
+
- `SYNTHETIC_SETUP_FAILURE` for invalid or conflicting extension custom type registrations and other synthetic compiler setup failures.
|
|
214
|
+
- `TYPE_MISMATCH` for normal tag-on-type incompatibilities in author source.
|
|
215
|
+
|
|
216
|
+
As a rule of thumb, `UNSUPPORTED_CUSTOM_TYPE_OVERRIDE` and `SYNTHETIC_SETUP_FAILURE` indicate extension configuration problems, while `TYPE_MISMATCH` usually indicates an authoring error in the analyzed source.
|
|
217
|
+
|
|
183
218
|
## Internal Entry Point
|
|
184
219
|
|
|
185
220
|
Low-level canonical IR generators, analyzer primitives, and validation helpers are intentionally no longer exported from the package root. If you need those unstable internals inside the monorepo, import them from `@formspec/build/internals`.
|
|
@@ -11,6 +11,7 @@ import type { FieldNode, TypeNode, AnnotationNode, TypeDefinition, JsonValue, Re
|
|
|
11
11
|
import type { ExtensionRegistry } from "../extensions/index.js";
|
|
12
12
|
import type { MetadataPolicyInput } from "@formspec/core";
|
|
13
13
|
import { normalizeMetadataPolicy } from "../metadata/index.js";
|
|
14
|
+
export declare function isResolvableObjectLikeAliasTypeNode(typeNode: ts.TypeNode): boolean;
|
|
14
15
|
/**
|
|
15
16
|
* Layout metadata extracted from `@Group` and `@ShowWhen` TSDoc tags.
|
|
16
17
|
* One entry per field, in the same order as `fields`.
|
|
@@ -47,6 +48,7 @@ export interface IRClassAnalysis {
|
|
|
47
48
|
/** Static methods */
|
|
48
49
|
readonly staticMethods: readonly MethodInfo[];
|
|
49
50
|
}
|
|
51
|
+
export type AnalyzeTypeAliasToIRFailureKind = "duplicate-properties" | "not-object-like";
|
|
50
52
|
/**
|
|
51
53
|
* Result of analyzing a type alias into IR — either success or error.
|
|
52
54
|
*/
|
|
@@ -55,6 +57,7 @@ export type AnalyzeTypeAliasToIRResult = {
|
|
|
55
57
|
readonly analysis: IRClassAnalysis;
|
|
56
58
|
} | {
|
|
57
59
|
readonly ok: false;
|
|
60
|
+
readonly kind: AnalyzeTypeAliasToIRFailureKind;
|
|
58
61
|
readonly error: string;
|
|
59
62
|
};
|
|
60
63
|
export interface DeclarationRootInfo {
|
|
@@ -95,6 +98,7 @@ export declare function analyzeInterfaceToIR(interfaceDecl: ts.InterfaceDeclarat
|
|
|
95
98
|
* Analyzes a type alias declaration and produces canonical IR FieldNodes.
|
|
96
99
|
*/
|
|
97
100
|
export declare function analyzeTypeAliasToIR(typeAlias: ts.TypeAliasDeclaration, checker: ts.TypeChecker, file?: string, extensionRegistry?: ExtensionRegistry, metadataPolicy?: MetadataPolicyInput, discriminatorOptions?: DiscriminatorResolutionOptions): AnalyzeTypeAliasToIRResult;
|
|
101
|
+
export declare function getAnalyzableObjectLikePropertyName(name: ts.PropertyName): string | null;
|
|
98
102
|
/**
|
|
99
103
|
* Resolves a TypeScript type to a canonical IR TypeNode.
|
|
100
104
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class-analyzer.d.ts","sourceRoot":"","sources":["../../src/analyzer/class-analyzer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAGL,KAAK,4BAA4B,EAElC,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EACV,SAAS,EACT,QAAQ,EAIR,cAAc,EAId,cAAc,EACd,SAAS,EACT,gBAAgB,EAEjB,MAAM,0BAA0B,CAAC;AAQlC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAgC,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"class-analyzer.d.ts","sourceRoot":"","sources":["../../src/analyzer/class-analyzer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAGL,KAAK,4BAA4B,EAElC,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EACV,SAAS,EACT,QAAQ,EAIR,cAAc,EAId,cAAc,EACd,SAAS,EACT,gBAAgB,EAEjB,MAAM,0BAA0B,CAAC;AAQlC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAA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AAE,aAAa,EAAE,CAAC;IAC5B,uBAAuB;IACvB,cAAc,EAAE,EAAE,CAAC,QAAQ,GAAG,SAAS,CAAC;IACxC,2BAA2B;IAC3B,UAAU,EAAE,EAAE,CAAC,IAAI,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,2BAA2B;IAC3B,QAAQ,EAAE,EAAE,CAAC,QAAQ,GAAG,SAAS,CAAC;IAClC,oBAAoB;IACpB,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC;IACd,0DAA0D;IAC1D,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,iEAAiE;IACjE,QAAQ,EAAE,OAAO,CAAC;CACnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"program.d.ts","sourceRoot":"","sources":["../../src/analyzer/program.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"program.d.ts","sourceRoot":"","sources":["../../src/analyzer/program.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAIjC,OAAO,EASL,KAAK,8BAA8B,EACnC,KAAK,eAAe,EAErB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAE1D;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,6BAA6B;IAC7B,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC;IACpB,uCAAuC;IACvC,OAAO,EAAE,EAAE,CAAC,WAAW,CAAC;IACxB,qCAAqC;IACrC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC;CAC3B;AAED;;;;;;GAMG;AACH,wBAAgB,+BAA+B,CA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,CAAC,WAAW,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC;IAC/B,4EAA4E;IAC5E,QAAQ,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC;CAC7B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,kBAAkB,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1D;AA4DD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,EAAE,CAAC,IAAI,EACb,IAAI,SAAK,EACT,OAAO,CAAC,EAAE,iBAAiB,GAC1B,gBAAgB,CAsSlB;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,OAAO,CAsB5D;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,mBAAmB,CAmC7E;AAMD;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,GACX;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAEpD"}
|
package/dist/build-alpha.d.ts
CHANGED
|
@@ -554,6 +554,8 @@ export declare interface GenerateSchemasFromProgramOptions extends StaticSchemaG
|
|
|
554
554
|
/**
|
|
555
555
|
* Generates schemas for a method or function return type.
|
|
556
556
|
*
|
|
557
|
+
* Awaited `Promise<T>`-style return types are unwrapped before generation.
|
|
558
|
+
*
|
|
557
559
|
* @public
|
|
558
560
|
*/
|
|
559
561
|
export declare function generateSchemasFromReturnType(options: GenerateSchemasFromReturnTypeOptions): DiscoveredTypeSchemas;
|
package/dist/build-beta.d.ts
CHANGED
|
@@ -554,6 +554,8 @@ export declare interface GenerateSchemasFromProgramOptions extends StaticSchemaG
|
|
|
554
554
|
/**
|
|
555
555
|
* Generates schemas for a method or function return type.
|
|
556
556
|
*
|
|
557
|
+
* Awaited `Promise<T>`-style return types are unwrapped before generation.
|
|
558
|
+
*
|
|
557
559
|
* @public
|
|
558
560
|
*/
|
|
559
561
|
export declare function generateSchemasFromReturnType(options: GenerateSchemasFromReturnTypeOptions): DiscoveredTypeSchemas;
|
package/dist/build-internal.d.ts
CHANGED
|
@@ -554,6 +554,8 @@ export declare interface GenerateSchemasFromProgramOptions extends StaticSchemaG
|
|
|
554
554
|
/**
|
|
555
555
|
* Generates schemas for a method or function return type.
|
|
556
556
|
*
|
|
557
|
+
* Awaited `Promise<T>`-style return types are unwrapped before generation.
|
|
558
|
+
*
|
|
557
559
|
* @public
|
|
558
560
|
*/
|
|
559
561
|
export declare function generateSchemasFromReturnType(options: GenerateSchemasFromReturnTypeOptions): DiscoveredTypeSchemas;
|
package/dist/build.d.ts
CHANGED
|
@@ -554,6 +554,8 @@ export declare interface GenerateSchemasFromProgramOptions extends StaticSchemaG
|
|
|
554
554
|
/**
|
|
555
555
|
* Generates schemas for a method or function return type.
|
|
556
556
|
*
|
|
557
|
+
* Awaited `Promise<T>`-style return types are unwrapped before generation.
|
|
558
|
+
*
|
|
557
559
|
* @public
|
|
558
560
|
*/
|
|
559
561
|
export declare function generateSchemasFromReturnType(options: GenerateSchemasFromReturnTypeOptions): DiscoveredTypeSchemas;
|
package/dist/cli.cjs
CHANGED
|
@@ -2223,6 +2223,16 @@ function buildSupportingDeclarations(sourceFile, extensionTypeNames) {
|
|
|
2223
2223
|
return true;
|
|
2224
2224
|
}).map((statement) => statement.getText(sourceFile));
|
|
2225
2225
|
}
|
|
2226
|
+
function pushUniqueCompilerDiagnostics(target, additions) {
|
|
2227
|
+
for (const diagnostic of additions) {
|
|
2228
|
+
if ((diagnostic.code === "UNSUPPORTED_CUSTOM_TYPE_OVERRIDE" || diagnostic.code === "SYNTHETIC_SETUP_FAILURE") && target.some(
|
|
2229
|
+
(existing) => existing.code === diagnostic.code && existing.message === diagnostic.message
|
|
2230
|
+
)) {
|
|
2231
|
+
continue;
|
|
2232
|
+
}
|
|
2233
|
+
target.push(diagnostic);
|
|
2234
|
+
}
|
|
2235
|
+
}
|
|
2226
2236
|
function renderSyntheticArgumentExpression(valueKind, argumentText) {
|
|
2227
2237
|
const trimmed = argumentText.trim();
|
|
2228
2238
|
if (trimmed === "") {
|
|
@@ -2489,6 +2499,16 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
|
|
|
2489
2499
|
if (result.diagnostics.length === 0) {
|
|
2490
2500
|
return [];
|
|
2491
2501
|
}
|
|
2502
|
+
const setupDiagnostic = result.diagnostics.find((diagnostic) => diagnostic.kind !== "typescript");
|
|
2503
|
+
if (setupDiagnostic !== void 0) {
|
|
2504
|
+
return [
|
|
2505
|
+
makeDiagnostic(
|
|
2506
|
+
setupDiagnostic.kind === "unsupported-custom-type-override" ? "UNSUPPORTED_CUSTOM_TYPE_OVERRIDE" : "SYNTHETIC_SETUP_FAILURE",
|
|
2507
|
+
setupDiagnostic.message,
|
|
2508
|
+
provenance
|
|
2509
|
+
)
|
|
2510
|
+
];
|
|
2511
|
+
}
|
|
2492
2512
|
const expectedLabel = definition.valueKind === null ? "compatible argument" : capabilityLabel(definition.valueKind);
|
|
2493
2513
|
return [
|
|
2494
2514
|
makeDiagnostic(
|
|
@@ -2652,7 +2672,7 @@ function parseTSDocTags(node, file = "", options) {
|
|
|
2652
2672
|
options
|
|
2653
2673
|
);
|
|
2654
2674
|
if (compilerDiagnostics.length > 0) {
|
|
2655
|
-
diagnostics
|
|
2675
|
+
pushUniqueCompilerDiagnostics(diagnostics, compilerDiagnostics);
|
|
2656
2676
|
continue;
|
|
2657
2677
|
}
|
|
2658
2678
|
const constraintNode = (0, import_internal2.parseConstraintTagValue)(
|
|
@@ -2739,7 +2759,7 @@ function parseTSDocTags(node, file = "", options) {
|
|
|
2739
2759
|
options
|
|
2740
2760
|
);
|
|
2741
2761
|
if (compilerDiagnostics.length > 0) {
|
|
2742
|
-
diagnostics
|
|
2762
|
+
pushUniqueCompilerDiagnostics(diagnostics, compilerDiagnostics);
|
|
2743
2763
|
continue;
|
|
2744
2764
|
}
|
|
2745
2765
|
const constraintNode = (0, import_internal2.parseConstraintTagValue)(
|
|
@@ -2773,7 +2793,7 @@ function parseTSDocTags(node, file = "", options) {
|
|
|
2773
2793
|
options
|
|
2774
2794
|
);
|
|
2775
2795
|
if (compilerDiagnostics.length > 0) {
|
|
2776
|
-
diagnostics
|
|
2796
|
+
pushUniqueCompilerDiagnostics(diagnostics, compilerDiagnostics);
|
|
2777
2797
|
continue;
|
|
2778
2798
|
}
|
|
2779
2799
|
const constraintNode = (0, import_internal2.parseConstraintTagValue)(
|
|
@@ -3003,6 +3023,21 @@ function isObjectType(type) {
|
|
|
3003
3023
|
function isIntersectionType(type) {
|
|
3004
3024
|
return !!(type.flags & ts3.TypeFlags.Intersection);
|
|
3005
3025
|
}
|
|
3026
|
+
function isResolvableObjectLikeAliasTypeNode(typeNode) {
|
|
3027
|
+
if (ts3.isParenthesizedTypeNode(typeNode)) {
|
|
3028
|
+
return isResolvableObjectLikeAliasTypeNode(typeNode.type);
|
|
3029
|
+
}
|
|
3030
|
+
if (ts3.isTypeLiteralNode(typeNode) || ts3.isTypeReferenceNode(typeNode)) {
|
|
3031
|
+
return true;
|
|
3032
|
+
}
|
|
3033
|
+
return ts3.isIntersectionTypeNode(typeNode) && typeNode.types.length > 0 && typeNode.types.every((member) => isResolvableObjectLikeAliasTypeNode(member));
|
|
3034
|
+
}
|
|
3035
|
+
function isSemanticallyPlainObjectLikeType(type, checker) {
|
|
3036
|
+
if (isIntersectionType(type)) {
|
|
3037
|
+
return type.types.length > 0 && type.types.every((member) => isSemanticallyPlainObjectLikeType(member, checker));
|
|
3038
|
+
}
|
|
3039
|
+
return isObjectType(type) && checker.getSignaturesOfType(type, ts3.SignatureKind.Call).length === 0 && checker.getSignaturesOfType(type, ts3.SignatureKind.Construct).length === 0 && !checker.isArrayType(type) && !checker.isTupleType(type);
|
|
3040
|
+
}
|
|
3006
3041
|
function isTypeReference(type) {
|
|
3007
3042
|
return !!(type.flags & ts3.TypeFlags.Object) && !!(type.objectFlags & ts3.ObjectFlags.Reference);
|
|
3008
3043
|
}
|
|
@@ -3255,6 +3290,7 @@ function analyzeTypeAliasToIR(typeAlias, checker, file = "", extensionRegistry,
|
|
|
3255
3290
|
const kindDesc = ts3.SyntaxKind[typeAlias.type.kind] ?? "unknown";
|
|
3256
3291
|
return {
|
|
3257
3292
|
ok: false,
|
|
3293
|
+
kind: "not-object-like",
|
|
3258
3294
|
error: `Type alias "${typeAlias.name.text}" at line ${String(line + 1)} is not an object-like type alias (found ${kindDesc})`
|
|
3259
3295
|
};
|
|
3260
3296
|
}
|
|
@@ -3269,6 +3305,7 @@ function analyzeTypeAliasToIR(typeAlias, checker, file = "", extensionRegistry,
|
|
|
3269
3305
|
const { line } = sourceFile.getLineAndCharacterOfPosition(typeAlias.getStart());
|
|
3270
3306
|
return {
|
|
3271
3307
|
ok: false,
|
|
3308
|
+
kind: "duplicate-properties",
|
|
3272
3309
|
error: `Type alias "${name}" at line ${String(line + 1)} contains duplicate property names across object-like members: ${duplicatePropertyNames.join(", ")}`
|
|
3273
3310
|
};
|
|
3274
3311
|
}
|
|
@@ -3965,10 +4002,10 @@ function findDuplicateObjectLikeTypeAliasPropertyNames(members) {
|
|
|
3965
4002
|
return [...duplicates].sort();
|
|
3966
4003
|
}
|
|
3967
4004
|
function getAnalyzableObjectLikePropertyName(name) {
|
|
3968
|
-
if (
|
|
3969
|
-
return
|
|
4005
|
+
if (ts3.isIdentifier(name) || ts3.isStringLiteral(name) || ts3.isNumericLiteral(name)) {
|
|
4006
|
+
return name.text;
|
|
3970
4007
|
}
|
|
3971
|
-
return
|
|
4008
|
+
return null;
|
|
3972
4009
|
}
|
|
3973
4010
|
function applyEnumMemberDisplayNames(type, annotations) {
|
|
3974
4011
|
if (!annotations.some(
|
|
@@ -4178,6 +4215,19 @@ function resolveTypeNode(type, checker, file, typeRegistry, visiting, sourceNode
|
|
|
4178
4215
|
diagnostics
|
|
4179
4216
|
);
|
|
4180
4217
|
}
|
|
4218
|
+
if (resolvedSourceTypeNode !== void 0 && isResolvableObjectLikeAliasTypeNode(resolvedSourceTypeNode) && isSemanticallyPlainObjectLikeType(type, checker)) {
|
|
4219
|
+
return resolveObjectType(
|
|
4220
|
+
type,
|
|
4221
|
+
checker,
|
|
4222
|
+
file,
|
|
4223
|
+
typeRegistry,
|
|
4224
|
+
visiting,
|
|
4225
|
+
sourceNode,
|
|
4226
|
+
metadataPolicy,
|
|
4227
|
+
extensionRegistry,
|
|
4228
|
+
diagnostics
|
|
4229
|
+
);
|
|
4230
|
+
}
|
|
4181
4231
|
}
|
|
4182
4232
|
if (isObjectType(type)) {
|
|
4183
4233
|
return resolveObjectType(
|
|
@@ -5101,6 +5151,95 @@ function findInterfaceByName(sourceFile, interfaceName) {
|
|
|
5101
5151
|
function findTypeAliasByName(sourceFile, aliasName) {
|
|
5102
5152
|
return findNodeByName(sourceFile, aliasName, ts4.isTypeAliasDeclaration, (n) => n.name.text);
|
|
5103
5153
|
}
|
|
5154
|
+
function getResolvedObjectRootType(rootType, typeRegistry) {
|
|
5155
|
+
if (rootType.kind === "object") {
|
|
5156
|
+
return rootType;
|
|
5157
|
+
}
|
|
5158
|
+
if (rootType.kind !== "reference") {
|
|
5159
|
+
return null;
|
|
5160
|
+
}
|
|
5161
|
+
const definition = typeRegistry[rootType.name];
|
|
5162
|
+
return definition?.type.kind === "object" ? definition.type : null;
|
|
5163
|
+
}
|
|
5164
|
+
function createResolvedObjectAliasAnalysis(name, rootType, typeRegistry, rootInfo, diagnostics) {
|
|
5165
|
+
const resolvedRootType = getResolvedObjectRootType(rootType, typeRegistry);
|
|
5166
|
+
if (resolvedRootType === null) {
|
|
5167
|
+
return null;
|
|
5168
|
+
}
|
|
5169
|
+
const fields = resolvedRootType.properties.map((property) => ({
|
|
5170
|
+
kind: "field",
|
|
5171
|
+
name: property.name,
|
|
5172
|
+
...property.metadata !== void 0 && { metadata: property.metadata },
|
|
5173
|
+
type: property.type,
|
|
5174
|
+
required: !property.optional,
|
|
5175
|
+
constraints: property.constraints,
|
|
5176
|
+
annotations: property.annotations,
|
|
5177
|
+
provenance: property.provenance
|
|
5178
|
+
}));
|
|
5179
|
+
return {
|
|
5180
|
+
name,
|
|
5181
|
+
...rootInfo.metadata !== void 0 && { metadata: rootInfo.metadata },
|
|
5182
|
+
fields,
|
|
5183
|
+
fieldLayouts: fields.map(() => ({})),
|
|
5184
|
+
typeRegistry,
|
|
5185
|
+
...rootInfo.annotations.length > 0 && { annotations: [...rootInfo.annotations] },
|
|
5186
|
+
...diagnostics.length > 0 && { diagnostics: [...diagnostics] },
|
|
5187
|
+
instanceMethods: [],
|
|
5188
|
+
staticMethods: []
|
|
5189
|
+
};
|
|
5190
|
+
}
|
|
5191
|
+
function containsTypeReferenceInObjectLikeAlias(typeNode) {
|
|
5192
|
+
if (ts4.isParenthesizedTypeNode(typeNode)) {
|
|
5193
|
+
return containsTypeReferenceInObjectLikeAlias(typeNode.type);
|
|
5194
|
+
}
|
|
5195
|
+
if (ts4.isTypeReferenceNode(typeNode)) {
|
|
5196
|
+
return true;
|
|
5197
|
+
}
|
|
5198
|
+
return ts4.isIntersectionTypeNode(typeNode) && typeNode.types.some((member) => containsTypeReferenceInObjectLikeAlias(member));
|
|
5199
|
+
}
|
|
5200
|
+
function collectFallbackAliasMemberPropertyNames(typeNode, checker) {
|
|
5201
|
+
if (ts4.isParenthesizedTypeNode(typeNode)) {
|
|
5202
|
+
return collectFallbackAliasMemberPropertyNames(typeNode.type, checker);
|
|
5203
|
+
}
|
|
5204
|
+
if (ts4.isTypeLiteralNode(typeNode)) {
|
|
5205
|
+
const propertyNames = [];
|
|
5206
|
+
for (const member of typeNode.members) {
|
|
5207
|
+
if (!ts4.isPropertySignature(member)) {
|
|
5208
|
+
continue;
|
|
5209
|
+
}
|
|
5210
|
+
const propertyName = getAnalyzableObjectLikePropertyName(member.name);
|
|
5211
|
+
if (propertyName !== null) {
|
|
5212
|
+
propertyNames.push(propertyName);
|
|
5213
|
+
}
|
|
5214
|
+
}
|
|
5215
|
+
return propertyNames;
|
|
5216
|
+
}
|
|
5217
|
+
if (ts4.isTypeReferenceNode(typeNode)) {
|
|
5218
|
+
return checker.getTypeFromTypeNode(typeNode).getProperties().map((property) => property.getName());
|
|
5219
|
+
}
|
|
5220
|
+
return null;
|
|
5221
|
+
}
|
|
5222
|
+
function findFallbackAliasDuplicatePropertyNames(typeNode, checker) {
|
|
5223
|
+
if (!ts4.isIntersectionTypeNode(typeNode)) {
|
|
5224
|
+
return [];
|
|
5225
|
+
}
|
|
5226
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5227
|
+
const duplicates = /* @__PURE__ */ new Set();
|
|
5228
|
+
for (const member of typeNode.types) {
|
|
5229
|
+
const propertyNames = collectFallbackAliasMemberPropertyNames(member, checker);
|
|
5230
|
+
if (propertyNames === null) {
|
|
5231
|
+
continue;
|
|
5232
|
+
}
|
|
5233
|
+
for (const propertyName of propertyNames) {
|
|
5234
|
+
if (seen.has(propertyName)) {
|
|
5235
|
+
duplicates.add(propertyName);
|
|
5236
|
+
} else {
|
|
5237
|
+
seen.add(propertyName);
|
|
5238
|
+
}
|
|
5239
|
+
}
|
|
5240
|
+
}
|
|
5241
|
+
return [...duplicates].sort();
|
|
5242
|
+
}
|
|
5104
5243
|
function analyzeNamedTypeToIR(filePath, typeName, extensionRegistry, metadataPolicy, discriminatorOptions) {
|
|
5105
5244
|
const ctx = createProgramContext(filePath);
|
|
5106
5245
|
return analyzeNamedTypeToIRFromProgramContext(
|
|
@@ -5149,6 +5288,51 @@ function analyzeNamedTypeToIRFromProgramContext(ctx, filePath, typeName, extensi
|
|
|
5149
5288
|
if (result.ok) {
|
|
5150
5289
|
return result.analysis;
|
|
5151
5290
|
}
|
|
5291
|
+
const fallbackEligible = result.kind === "not-object-like" && isResolvableObjectLikeAliasTypeNode(typeAlias.type) && containsTypeReferenceInObjectLikeAlias(typeAlias.type);
|
|
5292
|
+
if (!fallbackEligible) {
|
|
5293
|
+
throw new Error(result.error);
|
|
5294
|
+
}
|
|
5295
|
+
const duplicatePropertyNames = findFallbackAliasDuplicatePropertyNames(
|
|
5296
|
+
typeAlias.type,
|
|
5297
|
+
ctx.checker
|
|
5298
|
+
);
|
|
5299
|
+
if (duplicatePropertyNames.length > 0) {
|
|
5300
|
+
const sourceFile = typeAlias.getSourceFile();
|
|
5301
|
+
const { line } = sourceFile.getLineAndCharacterOfPosition(typeAlias.getStart());
|
|
5302
|
+
throw new Error(
|
|
5303
|
+
`Type alias "${typeAlias.name.text}" at line ${String(line + 1)} contains duplicate property names across object-like members: ${duplicatePropertyNames.join(", ")}`
|
|
5304
|
+
);
|
|
5305
|
+
}
|
|
5306
|
+
const rootInfo = analyzeDeclarationRootInfo(
|
|
5307
|
+
typeAlias,
|
|
5308
|
+
ctx.checker,
|
|
5309
|
+
analysisFilePath,
|
|
5310
|
+
extensionRegistry,
|
|
5311
|
+
metadataPolicy
|
|
5312
|
+
);
|
|
5313
|
+
const diagnostics = [...rootInfo.diagnostics];
|
|
5314
|
+
const typeRegistry = {};
|
|
5315
|
+
const rootType = resolveTypeNode(
|
|
5316
|
+
ctx.checker.getTypeAtLocation(typeAlias),
|
|
5317
|
+
ctx.checker,
|
|
5318
|
+
analysisFilePath,
|
|
5319
|
+
typeRegistry,
|
|
5320
|
+
/* @__PURE__ */ new Set(),
|
|
5321
|
+
typeAlias,
|
|
5322
|
+
createAnalyzerMetadataPolicy(metadataPolicy, discriminatorOptions),
|
|
5323
|
+
extensionRegistry,
|
|
5324
|
+
diagnostics
|
|
5325
|
+
);
|
|
5326
|
+
const fallbackAnalysis = createResolvedObjectAliasAnalysis(
|
|
5327
|
+
typeAlias.name.text,
|
|
5328
|
+
rootType,
|
|
5329
|
+
typeRegistry,
|
|
5330
|
+
rootInfo,
|
|
5331
|
+
diagnostics
|
|
5332
|
+
);
|
|
5333
|
+
if (fallbackAnalysis !== null) {
|
|
5334
|
+
return fallbackAnalysis;
|
|
5335
|
+
}
|
|
5152
5336
|
throw new Error(result.error);
|
|
5153
5337
|
}
|
|
5154
5338
|
throw new Error(
|
|
@@ -5693,15 +5877,36 @@ function generateSchemasFromParameter(options) {
|
|
|
5693
5877
|
}
|
|
5694
5878
|
function generateSchemasFromReturnType(options) {
|
|
5695
5879
|
const signature = options.context.checker.getSignatureFromDeclaration(options.declaration);
|
|
5696
|
-
const
|
|
5880
|
+
const returnType = signature !== void 0 ? options.context.checker.getReturnTypeOfSignature(signature) : options.context.checker.getTypeAtLocation(options.declaration);
|
|
5881
|
+
const type = unwrapPromiseType(options.context.checker, returnType);
|
|
5882
|
+
const sourceNode = type !== returnType ? unwrapPromiseTypeNode(options.declaration.type) ?? options.declaration.type ?? options.declaration : options.declaration.type ?? options.declaration;
|
|
5697
5883
|
const fallbackName = options.declaration.name !== void 0 && ts7.isIdentifier(options.declaration.name) ? `${options.declaration.name.text}ReturnType` : "ReturnType";
|
|
5698
5884
|
return generateSchemasFromResolvedType({
|
|
5699
5885
|
...options,
|
|
5700
5886
|
type,
|
|
5701
|
-
sourceNode
|
|
5887
|
+
sourceNode,
|
|
5702
5888
|
name: fallbackName
|
|
5703
5889
|
});
|
|
5704
5890
|
}
|
|
5891
|
+
function unwrapPromiseType(checker, type) {
|
|
5892
|
+
if (!("getAwaitedType" in checker) || typeof checker.getAwaitedType !== "function") {
|
|
5893
|
+
return type;
|
|
5894
|
+
}
|
|
5895
|
+
return checker.getAwaitedType(type) ?? type;
|
|
5896
|
+
}
|
|
5897
|
+
function unwrapPromiseTypeNode(typeNode) {
|
|
5898
|
+
if (typeNode === void 0) {
|
|
5899
|
+
return void 0;
|
|
5900
|
+
}
|
|
5901
|
+
if (ts7.isParenthesizedTypeNode(typeNode)) {
|
|
5902
|
+
const unwrapped = unwrapPromiseTypeNode(typeNode.type);
|
|
5903
|
+
return unwrapped ?? typeNode;
|
|
5904
|
+
}
|
|
5905
|
+
return isPromiseTypeReferenceNode(typeNode) ? typeNode.typeArguments[0] : typeNode;
|
|
5906
|
+
}
|
|
5907
|
+
function isPromiseTypeReferenceNode(typeNode) {
|
|
5908
|
+
return ts7.isTypeReferenceNode(typeNode) && ts7.isIdentifier(typeNode.typeName) && typeNode.typeName.text === "Promise" && typeNode.typeArguments !== void 0 && typeNode.typeArguments.length > 0;
|
|
5909
|
+
}
|
|
5705
5910
|
var ts7, import_internals6;
|
|
5706
5911
|
var init_discovered_schema = __esm({
|
|
5707
5912
|
"src/generators/discovered-schema.ts"() {
|