@sdk-it/core 0.46.0 → 0.46.1
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 +43 -0
- package/dist/lib/deriver.d.ts +8 -0
- package/dist/lib/deriver.d.ts.map +1 -1
- package/dist/lib/deriver.js +98 -69
- package/dist/lib/deriver.js.map +3 -3
- package/dist/lib/paths.d.ts.map +1 -1
- package/dist/lib/paths.js +9 -1
- package/dist/lib/paths.js.map +2 -2
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# @sdk-it/core
|
|
2
|
+
|
|
3
|
+
Low-level TypeScript analysis, OpenAPI reference, schema, and file utilities
|
|
4
|
+
used by SDK-IT analyzers and generators.
|
|
5
|
+
|
|
6
|
+
Most applications should start with
|
|
7
|
+
[`@sdk-it/cli`](../cli/README.md), [`@sdk-it/spec`](../spec/README.md), or a
|
|
8
|
+
language generator. Use `@sdk-it/core` when building an analyzer or extending
|
|
9
|
+
the generation pipeline.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @sdk-it/core typescript openapi3-ts
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Create a TypeScript program
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { getProgram } from '@sdk-it/core';
|
|
21
|
+
|
|
22
|
+
const program = getProgram('./tsconfig.json');
|
|
23
|
+
const checker = program.getTypeChecker();
|
|
24
|
+
|
|
25
|
+
for (const sourceFile of program.getSourceFiles()) {
|
|
26
|
+
if (!sourceFile.isDeclarationFile) {
|
|
27
|
+
console.log(sourceFile.fileName);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Resolve an OpenAPI reference
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
import { resolveRef } from '@sdk-it/core';
|
|
36
|
+
|
|
37
|
+
const schema = resolveRef(openapi, openapi.components!.schemas!.User!);
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
The root export includes TypeScript program helpers, type derivation, route
|
|
41
|
+
analysis, OpenAPI reference helpers, and Zod schema evaluation. Lower-level
|
|
42
|
+
modules are also available through subpaths such as
|
|
43
|
+
`@sdk-it/core/file-system.js` and `@sdk-it/core/paths.js`.
|
package/dist/lib/deriver.d.ts
CHANGED
|
@@ -17,6 +17,14 @@ export declare class TypeDeriver {
|
|
|
17
17
|
}): void;
|
|
18
18
|
private warn;
|
|
19
19
|
serializeType(type: ts.Type): any;
|
|
20
|
+
private serialize;
|
|
21
|
+
/**
|
|
22
|
+
* Preserve the inferred type of `satisfies` expressions unless the operand is
|
|
23
|
+
* an empty array; only then recover its declared element type.
|
|
24
|
+
*/
|
|
25
|
+
private typeOfExpression;
|
|
26
|
+
private emptyArraySatisfies;
|
|
27
|
+
private typeOfShorthand;
|
|
20
28
|
serializeNode(node: ts.Node): any;
|
|
21
29
|
}
|
|
22
30
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deriver.d.ts","sourceRoot":"","sources":["../../src/lib/deriver.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,MAAM,YAAY,CAAC;AAKvD,KAAK,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAErC,eAAO,MAAM,YAAY,eAA0B,CAAC;AACpD,eAAO,MAAM,MAAM,eAAsB,CAAC;AAC1C,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAQlD,CAAC;AAOF,wBAAgB,YAAY,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,MAAM,GAAG,SAAS,CAW9D;AAED,qBAAa,WAAW;IACtB,SAAgB,SAAS,EAAE,SAAS,CAAM;IAC1C,SAAgB,OAAO,EAAE,EAAE,CAAC,WAAW,CAAC;IACxC,SAAgB,QAAQ,EAAE,MAAM,CAAC,MAAM,E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,MAAM,CAAA;KAAE;IAInD,OAAO,CAAC,IAAI;IAeZ,aAAa,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,GAAG;IAIjC,OAAO,CAAC,SAAS;IAkRjB;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAYxB,OAAO,CAAC,mBAAmB;IAqB3B,OAAO,CAAC,eAAe;IAiBvB,aAAa,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,GAAG;CAoRlC"}
|
package/dist/lib/deriver.js
CHANGED
|
@@ -52,6 +52,9 @@ class TypeDeriver {
|
|
|
52
52
|
console.warn(parts.join("\n"));
|
|
53
53
|
}
|
|
54
54
|
serializeType(type) {
|
|
55
|
+
return this.serialize(type, false);
|
|
56
|
+
}
|
|
57
|
+
serialize(type, widenLiteralValues) {
|
|
55
58
|
if (this.typesMap[type.aliasSymbol?.getName() || type.symbol?.getName()]) {
|
|
56
59
|
return {
|
|
57
60
|
[deriveSymbol]: true,
|
|
@@ -67,7 +70,7 @@ class TypeDeriver {
|
|
|
67
70
|
[deriveSymbol]: true,
|
|
68
71
|
kind: "record",
|
|
69
72
|
optional: false,
|
|
70
|
-
[$types]: [this.
|
|
73
|
+
[$types]: [this.serialize(indexType, widenLiteralValues)]
|
|
71
74
|
};
|
|
72
75
|
}
|
|
73
76
|
if (type.flags & TypeFlags.Any) {
|
|
@@ -84,12 +87,19 @@ class TypeDeriver {
|
|
|
84
87
|
[$types]: []
|
|
85
88
|
};
|
|
86
89
|
}
|
|
90
|
+
if (type.flags & TypeFlags.Never) {
|
|
91
|
+
return {
|
|
92
|
+
[deriveSymbol]: true,
|
|
93
|
+
kind: "never",
|
|
94
|
+
optional: false,
|
|
95
|
+
[$types]: []
|
|
96
|
+
};
|
|
97
|
+
}
|
|
87
98
|
if (type.isStringLiteral()) {
|
|
88
99
|
return {
|
|
89
100
|
[deriveSymbol]: true,
|
|
90
101
|
optional: false,
|
|
91
|
-
kind: "literal",
|
|
92
|
-
value: type.value,
|
|
102
|
+
...widenLiteralValues ? {} : { kind: "literal", value: type.value },
|
|
93
103
|
[$types]: ["string"]
|
|
94
104
|
};
|
|
95
105
|
}
|
|
@@ -97,8 +107,7 @@ class TypeDeriver {
|
|
|
97
107
|
return {
|
|
98
108
|
[deriveSymbol]: true,
|
|
99
109
|
optional: false,
|
|
100
|
-
kind: "literal",
|
|
101
|
-
value: type.value,
|
|
110
|
+
...widenLiteralValues ? {} : { kind: "literal", value: type.value },
|
|
102
111
|
[$types]: ["number"]
|
|
103
112
|
};
|
|
104
113
|
}
|
|
@@ -106,8 +115,10 @@ class TypeDeriver {
|
|
|
106
115
|
return {
|
|
107
116
|
[deriveSymbol]: true,
|
|
108
117
|
optional: false,
|
|
109
|
-
|
|
110
|
-
|
|
118
|
+
...widenLiteralValues ? {} : {
|
|
119
|
+
kind: "literal",
|
|
120
|
+
value: this.checker.typeToString(type) === "true"
|
|
121
|
+
},
|
|
111
122
|
[$types]: ["boolean"]
|
|
112
123
|
};
|
|
113
124
|
}
|
|
@@ -156,7 +167,7 @@ class TypeDeriver {
|
|
|
156
167
|
continue;
|
|
157
168
|
}
|
|
158
169
|
}
|
|
159
|
-
types.push(this.
|
|
170
|
+
types.push(this.serialize(intersectionType, widenLiteralValues));
|
|
160
171
|
}
|
|
161
172
|
return {
|
|
162
173
|
[deriveSymbol]: true,
|
|
@@ -175,7 +186,7 @@ class TypeDeriver {
|
|
|
175
186
|
continue;
|
|
176
187
|
}
|
|
177
188
|
}
|
|
178
|
-
types.push(this.
|
|
189
|
+
types.push(this.serialize(unionType, widenLiteralValues));
|
|
179
190
|
}
|
|
180
191
|
return {
|
|
181
192
|
[deriveSymbol]: true,
|
|
@@ -185,12 +196,13 @@ class TypeDeriver {
|
|
|
185
196
|
};
|
|
186
197
|
}
|
|
187
198
|
if (this.checker.isArrayLikeType(type)) {
|
|
188
|
-
const
|
|
189
|
-
|
|
199
|
+
const elementType = this.checker.getIndexTypeOfType(
|
|
200
|
+
type,
|
|
201
|
+
ts.IndexKind.Number
|
|
202
|
+
);
|
|
203
|
+
if (!elementType) {
|
|
190
204
|
const typeName = type.symbol?.getName() || "<unknown>";
|
|
191
|
-
this.warn(
|
|
192
|
-
`Could not find generic type argument for array type ${typeName}`
|
|
193
|
-
);
|
|
205
|
+
this.warn(`Could not find element type for array type ${typeName}`);
|
|
194
206
|
return {
|
|
195
207
|
[deriveSymbol]: true,
|
|
196
208
|
optional: false,
|
|
@@ -198,50 +210,17 @@ class TypeDeriver {
|
|
|
198
210
|
[$types]: ["any"]
|
|
199
211
|
};
|
|
200
212
|
}
|
|
201
|
-
const
|
|
202
|
-
if (!typeSymbol) {
|
|
203
|
-
return {
|
|
204
|
-
[deriveSymbol]: true,
|
|
205
|
-
optional: false,
|
|
206
|
-
kind: "array",
|
|
207
|
-
[$types]: [this.serializeType(argType)]
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
if (typeSymbol.valueDeclaration) {
|
|
211
|
-
return {
|
|
212
|
-
kind: "array",
|
|
213
|
-
[deriveSymbol]: true,
|
|
214
|
-
[$types]: [this.serializeNode(typeSymbol.valueDeclaration)]
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
const maybeDeclaration = typeSymbol.declarations?.[0];
|
|
218
|
-
if (maybeDeclaration) {
|
|
219
|
-
if (ts.isMappedTypeNode(maybeDeclaration)) {
|
|
220
|
-
const resolvedType = sortObjectKeys(
|
|
221
|
-
this.checker.getPropertiesOfType(argType).reduce((acc, prop) => {
|
|
222
|
-
const propType = this.checker.getTypeOfSymbol(prop);
|
|
223
|
-
acc[prop.name] = this.serializeType(propType);
|
|
224
|
-
return acc;
|
|
225
|
-
}, {})
|
|
226
|
-
);
|
|
227
|
-
return {
|
|
228
|
-
kind: "array",
|
|
229
|
-
optional: false,
|
|
230
|
-
[deriveSymbol]: true,
|
|
231
|
-
[$types]: [resolvedType]
|
|
232
|
-
};
|
|
233
|
-
} else {
|
|
234
|
-
return {
|
|
235
|
-
kind: "array",
|
|
236
|
-
...this.serializeNode(maybeDeclaration)
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
}
|
|
213
|
+
const mappedElementType = this.typesMap[elementType.aliasSymbol?.getName() || elementType.symbol?.getName()];
|
|
240
214
|
return {
|
|
241
215
|
kind: "array",
|
|
242
216
|
optional: false,
|
|
243
217
|
[deriveSymbol]: true,
|
|
244
|
-
[$types]: [
|
|
218
|
+
[$types]: mappedElementType ? [mappedElementType] : [
|
|
219
|
+
this.serialize(
|
|
220
|
+
elementType,
|
|
221
|
+
widenLiteralValues || this.checker.isTupleType(type)
|
|
222
|
+
)
|
|
223
|
+
]
|
|
245
224
|
};
|
|
246
225
|
}
|
|
247
226
|
if (type.isClass()) {
|
|
@@ -278,19 +257,24 @@ class TypeDeriver {
|
|
|
278
257
|
if (properties.length > 0) {
|
|
279
258
|
const serializedProps = {};
|
|
280
259
|
for (const prop of properties) {
|
|
281
|
-
const
|
|
260
|
+
const declarations = prop.getDeclarations() ?? [];
|
|
261
|
+
const propAssingment = declarations.find(
|
|
282
262
|
(it) => ts.isPropertyAssignment(it)
|
|
283
263
|
);
|
|
264
|
+
const shorthand = declarations.find(
|
|
265
|
+
(it) => ts.isShorthandPropertyAssignment(it)
|
|
266
|
+
);
|
|
267
|
+
const shorthandType = shorthand ? this.typeOfShorthand(shorthand) : void 0;
|
|
284
268
|
if (propAssingment) {
|
|
285
|
-
|
|
286
|
-
propAssingment.initializer
|
|
269
|
+
serializedProps[prop.name] = this.serialize(
|
|
270
|
+
this.typeOfExpression(propAssingment.initializer),
|
|
271
|
+
widenLiteralValues
|
|
272
|
+
);
|
|
273
|
+
} else if (shorthandType) {
|
|
274
|
+
serializedProps[prop.name] = this.serialize(
|
|
275
|
+
shorthandType,
|
|
276
|
+
widenLiteralValues
|
|
287
277
|
);
|
|
288
|
-
serializedProps[prop.name] = this.serializeType(type2);
|
|
289
|
-
} else if ((prop.getDeclarations() ?? []).find(
|
|
290
|
-
(it) => ts.isPropertySignature(it)
|
|
291
|
-
)) {
|
|
292
|
-
const propType = this.checker.getTypeOfSymbol(prop);
|
|
293
|
-
serializedProps[prop.name] = this.serializeType(propType);
|
|
294
278
|
} else {
|
|
295
279
|
const propType = this.checker.getTypeOfSymbol(prop);
|
|
296
280
|
serializedProps[prop.name] = this.serializeType(propType);
|
|
@@ -326,6 +310,47 @@ class TypeDeriver {
|
|
|
326
310
|
]
|
|
327
311
|
};
|
|
328
312
|
}
|
|
313
|
+
/**
|
|
314
|
+
* Preserve the inferred type of `satisfies` expressions unless the operand is
|
|
315
|
+
* an empty array; only then recover its declared element type.
|
|
316
|
+
*/
|
|
317
|
+
typeOfExpression(node) {
|
|
318
|
+
const satisfies = this.emptyArraySatisfies(node);
|
|
319
|
+
if (satisfies) {
|
|
320
|
+
return this.checker.getTypeFromTypeNode(satisfies.type);
|
|
321
|
+
}
|
|
322
|
+
let expression = node;
|
|
323
|
+
while (ts.isParenthesizedExpression(expression)) {
|
|
324
|
+
expression = expression.expression;
|
|
325
|
+
}
|
|
326
|
+
return this.checker.getTypeAtLocation(expression);
|
|
327
|
+
}
|
|
328
|
+
emptyArraySatisfies(node) {
|
|
329
|
+
let expression = node;
|
|
330
|
+
while (ts.isParenthesizedExpression(expression)) {
|
|
331
|
+
expression = expression.expression;
|
|
332
|
+
}
|
|
333
|
+
if (!ts.isSatisfiesExpression(expression)) {
|
|
334
|
+
return void 0;
|
|
335
|
+
}
|
|
336
|
+
let operand = expression.expression;
|
|
337
|
+
while (ts.isParenthesizedExpression(operand)) {
|
|
338
|
+
operand = operand.expression;
|
|
339
|
+
}
|
|
340
|
+
if (!ts.isArrayLiteralExpression(operand) || operand.elements.length > 0) {
|
|
341
|
+
return void 0;
|
|
342
|
+
}
|
|
343
|
+
const annotation = this.checker.getTypeFromTypeNode(expression.type);
|
|
344
|
+
return this.checker.isArrayLikeType(annotation) ? expression : void 0;
|
|
345
|
+
}
|
|
346
|
+
typeOfShorthand(node) {
|
|
347
|
+
const symbol = this.checker.getShorthandAssignmentValueSymbol(node);
|
|
348
|
+
const declaration = symbol?.valueDeclaration ?? symbol?.declarations?.[0];
|
|
349
|
+
if (!declaration || !ts.isVariableDeclaration(declaration) || !declaration.initializer) {
|
|
350
|
+
return void 0;
|
|
351
|
+
}
|
|
352
|
+
return this.emptyArraySatisfies(declaration.initializer) ? this.typeOfExpression(declaration.initializer) : this.checker.getTypeAtLocation(node.name);
|
|
353
|
+
}
|
|
329
354
|
serializeNode(node) {
|
|
330
355
|
this.currentNode = node;
|
|
331
356
|
if (ts.isObjectLiteralExpression(node)) {
|
|
@@ -337,8 +362,14 @@ class TypeDeriver {
|
|
|
337
362
|
}
|
|
338
363
|
for (const prop of node.properties) {
|
|
339
364
|
if (ts.isPropertyAssignment(prop)) {
|
|
340
|
-
|
|
341
|
-
|
|
365
|
+
props[prop.name.getText()] = this.serializeType(
|
|
366
|
+
this.typeOfExpression(prop.initializer)
|
|
367
|
+
);
|
|
368
|
+
} else if (ts.isShorthandPropertyAssignment(prop)) {
|
|
369
|
+
const type = this.typeOfShorthand(prop);
|
|
370
|
+
if (type) {
|
|
371
|
+
props[prop.name.text] = this.serializeType(type);
|
|
372
|
+
}
|
|
342
373
|
}
|
|
343
374
|
}
|
|
344
375
|
return sortObjectKeys(props);
|
|
@@ -456,8 +487,7 @@ class TypeDeriver {
|
|
|
456
487
|
return this.serializeType(type);
|
|
457
488
|
}
|
|
458
489
|
if (ts.isSatisfiesExpression(node)) {
|
|
459
|
-
|
|
460
|
-
return this.serializeType(type);
|
|
490
|
+
return this.serializeType(this.typeOfExpression(node));
|
|
461
491
|
}
|
|
462
492
|
if (ts.isTypeLiteralNode(node)) {
|
|
463
493
|
const symbolType = this.checker.getTypeAtLocation(node);
|
|
@@ -556,8 +586,7 @@ class TypeDeriver {
|
|
|
556
586
|
return this.serializeType(type);
|
|
557
587
|
}
|
|
558
588
|
if (ts.isParenthesizedExpression(node)) {
|
|
559
|
-
|
|
560
|
-
return this.serializeType(type);
|
|
589
|
+
return this.serializeType(this.typeOfExpression(node));
|
|
561
590
|
}
|
|
562
591
|
if (ts.isNonNullExpression(node)) {
|
|
563
592
|
const type = this.checker.getTypeAtLocation(node);
|
package/dist/lib/deriver.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/lib/deriver.ts"],
|
|
4
|
-
"sourcesContent": ["import ts, { TypeFlags, symbolName } from 'typescript';\n\nimport { isInterfaceType } from './program.js';\nimport { sortObjectKeys } from './utils.js';\n\ntype Collector = Record<string, any>;\n\nexport const deriveSymbol = Symbol.for('serialize');\nexport const $types = Symbol.for('types');\nexport const defaultTypesMap: Record<string, string> = {\n Readable: 'any',\n ReadableStream: 'any',\n DateConstructor: 'string',\n ArrayBufferConstructor: 'any',\n SharedArrayBufferConstructor: 'any',\n Int8ArrayConstructor: 'any',\n Uint8Array: 'any',\n};\n\ninterface TraceContext {\n file?: string;\n operation?: string;\n}\n\nexport function nodeLocation(node: ts.Node): string | undefined {\n try {\n const sourceFile = node.getSourceFile();\n if (!sourceFile) return undefined;\n const { line, character } = sourceFile.getLineAndCharacterOfPosition(\n node.getStart(),\n );\n return `${sourceFile.fileName}:${line + 1}:${character + 1}`;\n } catch {\n return undefined;\n }\n}\n\nexport class TypeDeriver {\n public readonly collector: Collector = {};\n public readonly checker: ts.TypeChecker;\n public readonly typesMap: Record<string, string>;\n private trace: TraceContext = {};\n private currentNode?: ts.Node;\n constructor(\n checker: ts.TypeChecker,\n typeMappings: Record<string, string> = defaultTypesMap,\n ) {\n this.checker = checker;\n this.typesMap = typeMappings;\n }\n\n setTrace(ctx: { file?: string; operation?: string }) {\n this.trace = { ...ctx };\n }\n\n private warn(message: string, node?: ts.Node) {\n const parts = [`\\x1b[33m\\u26a0 ${message}\\x1b[0m`];\n const resolvedNode = node ?? this.currentNode;\n const location = resolvedNode ? nodeLocation(resolvedNode) : undefined;\n if (location) {\n parts.push(` at \\x1b[36m${location}\\x1b[0m`);\n } else if (this.trace.file) {\n parts.push(` at \\x1b[36m${this.trace.file}\\x1b[0m`);\n }\n if (this.trace.operation) {\n parts.push(` in \\x1b[2m${this.trace.operation}\\x1b[0m`);\n }\n console.warn(parts.join('\\n'));\n }\n\n serializeType(type: ts.Type): any {\n if (this.typesMap[type.aliasSymbol?.getName() || type.symbol?.getName()]) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [\n this.typesMap[type.aliasSymbol?.getName() || type.symbol?.getName()],\n ],\n };\n }\n const indexType = type.getStringIndexType();\n if (indexType) {\n return {\n [deriveSymbol]: true,\n kind: 'record',\n optional: false,\n [$types]: [this.serializeType(indexType)],\n };\n }\n if (type.flags & TypeFlags.Any) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [],\n };\n }\n if (type.flags & TypeFlags.Unknown) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [],\n };\n }\n if (type.isStringLiteral()) {\n return {\n [deriveSymbol]: true,\n optional: false,\n kind: 'literal',\n value: type.value,\n [$types]: ['string'],\n };\n }\n if (type.isNumberLiteral()) {\n return {\n [deriveSymbol]: true,\n optional: false,\n kind: 'literal',\n value: type.value,\n [$types]: ['number'],\n };\n }\n if (type.flags & TypeFlags.BooleanLiteral) {\n return {\n [deriveSymbol]: true,\n optional: false,\n kind: 'literal',\n value: this.checker.typeToString(type) === 'true',\n [$types]: ['boolean'],\n };\n }\n if (type.flags & TypeFlags.TemplateLiteral) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: ['string'],\n };\n }\n if (type.flags & TypeFlags.String) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: ['string'],\n };\n }\n if (type.flags & TypeFlags.Number) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: ['number'],\n };\n }\n if (type.flags & ts.TypeFlags.Boolean) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: ['boolean'],\n };\n }\n if (type.flags & TypeFlags.Null) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: ['null'],\n };\n }\n if (type.isIntersection()) {\n let optional: boolean | undefined;\n const types: any[] = [];\n for (const intersectionType of type.types) {\n if (optional === undefined) {\n optional = (intersectionType.flags & ts.TypeFlags.Undefined) !== 0;\n if (optional) {\n continue;\n }\n }\n\n types.push(this.serializeType(intersectionType));\n }\n return {\n [deriveSymbol]: true,\n kind: 'intersection',\n optional,\n [$types]: types,\n };\n }\n if (type.isUnion()) {\n let optional: boolean | undefined;\n const types: any[] = [];\n for (const unionType of type.types) {\n if (optional === undefined) {\n // ignore undefined\n optional = (unionType.flags & ts.TypeFlags.Undefined) !== 0;\n if (optional) {\n continue;\n }\n }\n\n types.push(this.serializeType(unionType));\n }\n return {\n [deriveSymbol]: true,\n kind: 'union',\n optional,\n [$types]: types,\n };\n }\n if (this.checker.isArrayLikeType(type)) {\n const [argType] = this.checker.getTypeArguments(type as ts.TypeReference);\n if (!argType) {\n const typeName = type.symbol?.getName() || '<unknown>';\n this.warn(\n `Could not find generic type argument for array type ${typeName}`,\n );\n return {\n [deriveSymbol]: true,\n optional: false,\n kind: 'array',\n [$types]: ['any'],\n };\n }\n const typeSymbol = argType.getSymbol();\n if (!typeSymbol) {\n return {\n [deriveSymbol]: true,\n optional: false,\n kind: 'array',\n [$types]: [this.serializeType(argType)],\n };\n }\n\n if (typeSymbol.valueDeclaration) {\n return {\n kind: 'array',\n [deriveSymbol]: true,\n [$types]: [this.serializeNode(typeSymbol.valueDeclaration)],\n };\n }\n const maybeDeclaration = typeSymbol.declarations?.[0];\n if (maybeDeclaration) {\n if (ts.isMappedTypeNode(maybeDeclaration)) {\n const resolvedType = sortObjectKeys(\n this.checker\n .getPropertiesOfType(argType)\n .reduce<Record<string, unknown>>((acc, prop) => {\n const propType = this.checker.getTypeOfSymbol(prop);\n acc[prop.name] = this.serializeType(propType);\n return acc;\n }, {}),\n );\n return {\n kind: 'array',\n optional: false,\n [deriveSymbol]: true,\n [$types]: [resolvedType],\n };\n } else {\n return {\n kind: 'array',\n ...this.serializeNode(maybeDeclaration),\n };\n }\n }\n\n return {\n kind: 'array',\n optional: false,\n [deriveSymbol]: true,\n [$types]: ['any'],\n };\n }\n if (type.isClass()) {\n const declaration = type.symbol?.valueDeclaration;\n if (!declaration) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [type.symbol.getName()],\n };\n }\n return this.serializeNode(declaration);\n }\n if (isInterfaceType(type)) {\n const valueDeclaration =\n type.symbol.valueDeclaration ?? type.symbol.declarations?.[0];\n if (!valueDeclaration) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [type.symbol.getName()],\n };\n }\n return this.serializeNode(valueDeclaration);\n }\n if (type.flags & TypeFlags.Object) {\n if (this.typesMap[symbolName(type.symbol)]) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [this.typesMap[symbolName(type.symbol)]],\n };\n }\n const properties = this.checker.getPropertiesOfType(type);\n if (properties.length > 0) {\n const serializedProps: Record<string, any> = {};\n for (const prop of properties) {\n const propAssingment = (prop.getDeclarations() ?? []).find((it) =>\n ts.isPropertyAssignment(it),\n );\n // get literal properties values if any\n if (propAssingment) {\n const type = this.checker.getTypeAtLocation(\n propAssingment.initializer,\n );\n serializedProps[prop.name] = this.serializeType(type);\n } else if (\n (prop.getDeclarations() ?? []).find((it) =>\n ts.isPropertySignature(it),\n )\n ) {\n const propType = this.checker.getTypeOfSymbol(prop);\n serializedProps[prop.name] = this.serializeType(propType);\n } else {\n const propType = this.checker.getTypeOfSymbol(prop);\n serializedProps[prop.name] = this.serializeType(propType);\n }\n }\n return {\n [deriveSymbol]: true,\n kind: 'object',\n optional: false,\n [$types]: [sortObjectKeys(serializedProps)],\n };\n }\n const declaration =\n type.symbol.valueDeclaration ?? type.symbol.declarations?.[0];\n if (!declaration) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [type.symbol.getName()],\n };\n }\n return this.serializeNode(declaration);\n }\n\n this.warn(`Unhandled type: ${type.flags} ${ts.TypeFlags[type.flags]}`);\n\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [\n this.checker.typeToString(\n type,\n undefined,\n ts.TypeFormatFlags.NoTruncation,\n ),\n ],\n };\n }\n\n serializeNode(node: ts.Node): any {\n this.currentNode = node;\n if (ts.isObjectLiteralExpression(node)) {\n const symbolType = this.checker.getTypeAtLocation(node);\n const props: Record<string, any> = {};\n for (const symbol of symbolType.getProperties()) {\n const type = this.checker.getTypeOfSymbol(symbol);\n props[symbol.name] = this.serializeType(type);\n }\n\n // get literal properties values if any\n for (const prop of node.properties) {\n if (ts.isPropertyAssignment(prop)) {\n const type = this.checker.getTypeAtLocation(prop.initializer);\n props[prop.name.getText()] = this.serializeType(type);\n }\n }\n\n return sortObjectKeys(props);\n }\n if (ts.isPropertyAccessExpression(node)) {\n const symbol = this.checker.getSymbolAtLocation(node.name);\n if (!symbol) {\n this.warn(`No symbol found for ${node.name.getText()}`, node);\n return null;\n }\n const type = this.checker.getTypeOfSymbol(symbol);\n return this.serializeType(type);\n }\n if (ts.isPropertySignature(node)) {\n const symbol = this.checker.getSymbolAtLocation(node.name);\n if (!symbol) {\n this.warn(`No symbol found for ${node.name.getText()}`, node);\n return null;\n }\n const type = this.checker.getTypeOfSymbol(symbol);\n return this.serializeType(type);\n }\n if (ts.isPropertyDeclaration(node)) {\n const symbol = this.checker.getSymbolAtLocation(node.name);\n if (!symbol) {\n this.warn(`No symbol found for ${node.name.getText()}`, node);\n return null;\n }\n const type = this.checker.getTypeOfSymbol(symbol);\n return this.serializeType(type);\n }\n if (ts.isInterfaceDeclaration(node)) {\n if (!node.name?.text) {\n throw new Error('Interface has no name');\n }\n if (this.typesMap[node.name.text]) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [this.typesMap[node.name.text]],\n };\n }\n if (!this.collector[node.name.text]) {\n this.collector[node.name.text] = {};\n const members: Record<string, any> = {};\n for (const member of node.members.filter(ts.isPropertySignature)) {\n members[member.name.getText()] = this.serializeNode(member);\n }\n this.collector[node.name.text] = sortObjectKeys(members);\n }\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [`#/components/schemas/${node.name.text}`],\n };\n }\n if (ts.isClassDeclaration(node)) {\n if (!node.name?.text) {\n throw new Error('Class has no name');\n }\n if (this.typesMap[node.name.text]) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [this.typesMap[node.name.text]],\n };\n }\n\n if (!this.collector[node.name.text]) {\n this.collector[node.name.text] = {};\n const members: Record<string, unknown> = {};\n for (const member of node.members.filter(ts.isPropertyDeclaration)) {\n members[member.name!.getText()] = this.serializeNode(member);\n }\n this.collector[node.name.text] = sortObjectKeys(members);\n }\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [`#/components/schemas/${node.name.text}`],\n $ref: `#/components/schemas/${node.name.text}`,\n };\n }\n if (ts.isVariableDeclaration(node)) {\n const symbol = this.checker.getSymbolAtLocation(node.name);\n if (!symbol) {\n this.warn(`No symbol found for ${node.name.getText()}`, node);\n return null;\n }\n if (!node.type) {\n this.warn(`No type found for ${node.name.getText()}`, node);\n return 'any';\n }\n const type = this.checker.getTypeFromTypeNode(node.type);\n return this.serializeType(type);\n }\n if (ts.isIdentifier(node)) {\n const symbol = this.checker.getSymbolAtLocation(node);\n if (!symbol) {\n this.warn(`No symbol found for identifier ${node.getText()}`, node);\n return null;\n }\n const type = this.checker.getTypeAtLocation(node);\n return this.serializeType(type);\n }\n if (ts.isAwaitExpression(node)) {\n const type = this.checker.getTypeAtLocation(node);\n return this.serializeType(type);\n }\n if (ts.isCallExpression(node)) {\n const type = this.checker.getTypeAtLocation(node);\n return this.serializeType(type);\n }\n if (ts.isAsExpression(node)) {\n const type = this.checker.getTypeAtLocation(node);\n return this.serializeType(type);\n }\n if (ts.isSatisfiesExpression(node)) {\n // Unlike `as`, `satisfies` checks the operand without widening it, so the\n // node's own type is the narrow inferred one -- `[] satisfies Share[]` is\n // `never[]`, which carries no schema. The annotation is the declared\n // contract callers code against, so derive from that instead.\n const type = this.checker.getTypeFromTypeNode(node.type);\n return this.serializeType(type);\n }\n if (ts.isTypeLiteralNode(node)) {\n const symbolType = this.checker.getTypeAtLocation(node);\n const props: Record<string, unknown> = {};\n for (const symbol of symbolType.getProperties()) {\n const type = this.checker.getTypeOfSymbol(symbol);\n props[symbol.name] = this.serializeType(type);\n }\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [sortObjectKeys(props)],\n };\n }\n if (node.kind === ts.SyntaxKind.NullKeyword) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: ['null'],\n };\n }\n if (node.kind === ts.SyntaxKind.BooleanKeyword) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: ['boolean'],\n };\n }\n if (node.kind === ts.SyntaxKind.TrueKeyword) {\n return {\n [deriveSymbol]: true,\n optional: false,\n kind: 'literal',\n value: true,\n [$types]: ['boolean'],\n };\n }\n if (node.kind === ts.SyntaxKind.FalseKeyword) {\n return {\n [deriveSymbol]: true,\n optional: false,\n kind: 'literal',\n value: false,\n [$types]: ['boolean'],\n };\n }\n if (ts.isFunctionDeclaration(node)) {\n if (!node.name) {\n this.warn('Function declaration has no name', node);\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: ['any'],\n };\n }\n\n const functionName = node.name.text;\n if (this.typesMap[functionName]) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [this.typesMap[functionName]],\n };\n }\n\n if (node.type) {\n const returnType = this.checker.getTypeFromTypeNode(node.type);\n return this.serializeType(returnType);\n }\n\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: ['any'],\n };\n }\n if (ts.isArrayLiteralExpression(node)) {\n const type = this.checker.getTypeAtLocation(node);\n return this.serializeType(type);\n }\n if (ts.isStringLiteral(node) || ts.isNumericLiteral(node)) {\n const type = this.checker.getTypeAtLocation(node);\n return this.serializeType(type);\n }\n // Handle template literals in expression position\n if (\n ts.isTemplateExpression(node) ||\n ts.isNoSubstitutionTemplateLiteral(node)\n ) {\n const type = this.checker.getTypeAtLocation(node);\n return this.serializeType(type);\n }\n if (ts.isTaggedTemplateExpression(node)) {\n const type = this.checker.getTypeAtLocation(node);\n return this.serializeType(type);\n }\n\n // Handle binary expressions (||, &&, +, -, etc.)\n if (ts.isBinaryExpression(node)) {\n const type = this.checker.getTypeAtLocation(node);\n return this.serializeType(type);\n }\n\n // Handle conditional/ternary expressions (x ? y : z)\n if (ts.isConditionalExpression(node)) {\n const type = this.checker.getTypeAtLocation(node);\n return this.serializeType(type);\n }\n\n // Handle parenthesized expressions ((value))\n if (ts.isParenthesizedExpression(node)) {\n const type = this.checker.getTypeAtLocation(node);\n return this.serializeType(type);\n }\n\n // Handle non-null assertions (value!)\n if (ts.isNonNullExpression(node)) {\n const type = this.checker.getTypeAtLocation(node);\n return this.serializeType(type);\n }\n\n this.warn(\n `Unhandled node: ${ts.SyntaxKind[node.kind]} \"${node.getText()}\" (type: ${this.checker.typeToString(\n this.checker.getTypeAtLocation(node),\n undefined,\n ts.TypeFormatFlags.NoTruncation,\n )})`,\n node,\n );\n\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: ['any'],\n };\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,OAAO,MAAM,WAAW,kBAAkB;AAE1C,SAAS,uBAAuB;AAChC,SAAS,sBAAsB;AAIxB,MAAM,eAAe,OAAO,IAAI,WAAW;AAC3C,MAAM,SAAS,OAAO,IAAI,OAAO;AACjC,MAAM,kBAA0C;AAAA,EACrD,UAAU;AAAA,EACV,gBAAgB;AAAA,EAChB,iBAAiB;AAAA,EACjB,wBAAwB;AAAA,EACxB,8BAA8B;AAAA,EAC9B,sBAAsB;AAAA,EACtB,YAAY;AACd;AAOO,SAAS,aAAa,MAAmC;AAC9D,MAAI;AACF,UAAM,aAAa,KAAK,cAAc;AACtC,QAAI,CAAC,WAAY,QAAO;AACxB,UAAM,EAAE,MAAM,UAAU,IAAI,WAAW;AAAA,MACrC,KAAK,SAAS;AAAA,IA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K,QAAQ;AAAA,QACrF,KAAK,QAAQ,kBAAkB,IAAI;AAAA,QACnC;AAAA,QACA,GAAG,gBAAgB;AAAA,MACrB,CAAC;AAAA,MACD;AAAA,IACF;AAEA,WAAO;AAAA,MACL,CAAC,YAAY,GAAG;AAAA,MAChB,UAAU;AAAA,MACV,CAAC,MAAM,GAAG,CAAC,KAAK;AAAA,IAClB;AAAA,EACF;AACF;",
|
|
6
|
-
"names": [
|
|
4
|
+
"sourcesContent": ["import ts, { TypeFlags, symbolName } from 'typescript';\n\nimport { isInterfaceType } from './program.js';\nimport { sortObjectKeys } from './utils.js';\n\ntype Collector = Record<string, any>;\n\nexport const deriveSymbol = Symbol.for('serialize');\nexport const $types = Symbol.for('types');\nexport const defaultTypesMap: Record<string, string> = {\n Readable: 'any',\n ReadableStream: 'any',\n DateConstructor: 'string',\n ArrayBufferConstructor: 'any',\n SharedArrayBufferConstructor: 'any',\n Int8ArrayConstructor: 'any',\n Uint8Array: 'any',\n};\n\ninterface TraceContext {\n file?: string;\n operation?: string;\n}\n\nexport function nodeLocation(node: ts.Node): string | undefined {\n try {\n const sourceFile = node.getSourceFile();\n if (!sourceFile) return undefined;\n const { line, character } = sourceFile.getLineAndCharacterOfPosition(\n node.getStart(),\n );\n return `${sourceFile.fileName}:${line + 1}:${character + 1}`;\n } catch {\n return undefined;\n }\n}\n\nexport class TypeDeriver {\n public readonly collector: Collector = {};\n public readonly checker: ts.TypeChecker;\n public readonly typesMap: Record<string, string>;\n private trace: TraceContext = {};\n private currentNode?: ts.Node;\n constructor(\n checker: ts.TypeChecker,\n typeMappings: Record<string, string> = defaultTypesMap,\n ) {\n this.checker = checker;\n this.typesMap = typeMappings;\n }\n\n setTrace(ctx: { file?: string; operation?: string }) {\n this.trace = { ...ctx };\n }\n\n private warn(message: string, node?: ts.Node) {\n const parts = [`\\x1b[33m\\u26a0 ${message}\\x1b[0m`];\n const resolvedNode = node ?? this.currentNode;\n const location = resolvedNode ? nodeLocation(resolvedNode) : undefined;\n if (location) {\n parts.push(` at \\x1b[36m${location}\\x1b[0m`);\n } else if (this.trace.file) {\n parts.push(` at \\x1b[36m${this.trace.file}\\x1b[0m`);\n }\n if (this.trace.operation) {\n parts.push(` in \\x1b[2m${this.trace.operation}\\x1b[0m`);\n }\n console.warn(parts.join('\\n'));\n }\n\n serializeType(type: ts.Type): any {\n return this.serialize(type, false);\n }\n\n private serialize(type: ts.Type, widenLiteralValues: boolean): unknown {\n if (this.typesMap[type.aliasSymbol?.getName() || type.symbol?.getName()]) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [\n this.typesMap[type.aliasSymbol?.getName() || type.symbol?.getName()],\n ],\n };\n }\n const indexType = type.getStringIndexType();\n if (indexType) {\n return {\n [deriveSymbol]: true,\n kind: 'record',\n optional: false,\n [$types]: [this.serialize(indexType, widenLiteralValues)],\n };\n }\n if (type.flags & TypeFlags.Any) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [],\n };\n }\n if (type.flags & TypeFlags.Unknown) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [],\n };\n }\n if (type.flags & TypeFlags.Never) {\n return {\n [deriveSymbol]: true,\n kind: 'never',\n optional: false,\n [$types]: [],\n };\n }\n if (type.isStringLiteral()) {\n return {\n [deriveSymbol]: true,\n optional: false,\n ...(widenLiteralValues ? {} : { kind: 'literal', value: type.value }),\n [$types]: ['string'],\n };\n }\n if (type.isNumberLiteral()) {\n return {\n [deriveSymbol]: true,\n optional: false,\n ...(widenLiteralValues ? {} : { kind: 'literal', value: type.value }),\n [$types]: ['number'],\n };\n }\n if (type.flags & TypeFlags.BooleanLiteral) {\n return {\n [deriveSymbol]: true,\n optional: false,\n ...(widenLiteralValues\n ? {}\n : {\n kind: 'literal',\n value: this.checker.typeToString(type) === 'true',\n }),\n [$types]: ['boolean'],\n };\n }\n if (type.flags & TypeFlags.TemplateLiteral) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: ['string'],\n };\n }\n if (type.flags & TypeFlags.String) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: ['string'],\n };\n }\n if (type.flags & TypeFlags.Number) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: ['number'],\n };\n }\n if (type.flags & ts.TypeFlags.Boolean) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: ['boolean'],\n };\n }\n if (type.flags & TypeFlags.Null) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: ['null'],\n };\n }\n if (type.isIntersection()) {\n let optional: boolean | undefined;\n const types: any[] = [];\n for (const intersectionType of type.types) {\n if (optional === undefined) {\n optional = (intersectionType.flags & ts.TypeFlags.Undefined) !== 0;\n if (optional) {\n continue;\n }\n }\n\n types.push(this.serialize(intersectionType, widenLiteralValues));\n }\n return {\n [deriveSymbol]: true,\n kind: 'intersection',\n optional,\n [$types]: types,\n };\n }\n if (type.isUnion()) {\n let optional: boolean | undefined;\n const types: any[] = [];\n for (const unionType of type.types) {\n if (optional === undefined) {\n // ignore undefined\n optional = (unionType.flags & ts.TypeFlags.Undefined) !== 0;\n if (optional) {\n continue;\n }\n }\n\n types.push(this.serialize(unionType, widenLiteralValues));\n }\n return {\n [deriveSymbol]: true,\n kind: 'union',\n optional,\n [$types]: types,\n };\n }\n if (this.checker.isArrayLikeType(type)) {\n const elementType = this.checker.getIndexTypeOfType(\n type,\n ts.IndexKind.Number,\n );\n if (!elementType) {\n const typeName = type.symbol?.getName() || '<unknown>';\n this.warn(`Could not find element type for array type ${typeName}`);\n return {\n [deriveSymbol]: true,\n optional: false,\n kind: 'array',\n [$types]: ['any'],\n };\n }\n const mappedElementType =\n this.typesMap[\n elementType.aliasSymbol?.getName() || elementType.symbol?.getName()\n ];\n return {\n kind: 'array',\n optional: false,\n [deriveSymbol]: true,\n [$types]: mappedElementType\n ? [mappedElementType]\n : [\n this.serialize(\n elementType,\n widenLiteralValues || this.checker.isTupleType(type),\n ),\n ],\n };\n }\n if (type.isClass()) {\n const declaration = type.symbol?.valueDeclaration;\n if (!declaration) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [type.symbol.getName()],\n };\n }\n return this.serializeNode(declaration);\n }\n if (isInterfaceType(type)) {\n const valueDeclaration =\n type.symbol.valueDeclaration ?? type.symbol.declarations?.[0];\n if (!valueDeclaration) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [type.symbol.getName()],\n };\n }\n return this.serializeNode(valueDeclaration);\n }\n if (type.flags & TypeFlags.Object) {\n if (this.typesMap[symbolName(type.symbol)]) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [this.typesMap[symbolName(type.symbol)]],\n };\n }\n const properties = this.checker.getPropertiesOfType(type);\n if (properties.length > 0) {\n const serializedProps: Record<string, any> = {};\n for (const prop of properties) {\n const declarations = prop.getDeclarations() ?? [];\n const propAssingment = declarations.find((it) =>\n ts.isPropertyAssignment(it),\n );\n const shorthand = declarations.find((it) =>\n ts.isShorthandPropertyAssignment(it),\n );\n const shorthandType = shorthand\n ? this.typeOfShorthand(shorthand)\n : undefined;\n // get literal properties values if any\n if (propAssingment) {\n serializedProps[prop.name] = this.serialize(\n this.typeOfExpression(propAssingment.initializer),\n widenLiteralValues,\n );\n } else if (shorthandType) {\n serializedProps[prop.name] = this.serialize(\n shorthandType,\n widenLiteralValues,\n );\n } else {\n const propType = this.checker.getTypeOfSymbol(prop);\n serializedProps[prop.name] = this.serializeType(propType);\n }\n }\n return {\n [deriveSymbol]: true,\n kind: 'object',\n optional: false,\n [$types]: [sortObjectKeys(serializedProps)],\n };\n }\n const declaration =\n type.symbol.valueDeclaration ?? type.symbol.declarations?.[0];\n if (!declaration) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [type.symbol.getName()],\n };\n }\n return this.serializeNode(declaration);\n }\n\n this.warn(`Unhandled type: ${type.flags} ${ts.TypeFlags[type.flags]}`);\n\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [\n this.checker.typeToString(\n type,\n undefined,\n ts.TypeFormatFlags.NoTruncation,\n ),\n ],\n };\n }\n\n /**\n * Preserve the inferred type of `satisfies` expressions unless the operand is\n * an empty array; only then recover its declared element type.\n */\n private typeOfExpression(node: ts.Expression): ts.Type {\n const satisfies = this.emptyArraySatisfies(node);\n if (satisfies) {\n return this.checker.getTypeFromTypeNode(satisfies.type);\n }\n let expression = node;\n while (ts.isParenthesizedExpression(expression)) {\n expression = expression.expression;\n }\n return this.checker.getTypeAtLocation(expression);\n }\n\n private emptyArraySatisfies(\n node: ts.Expression,\n ): ts.SatisfiesExpression | undefined {\n let expression = node;\n while (ts.isParenthesizedExpression(expression)) {\n expression = expression.expression;\n }\n if (!ts.isSatisfiesExpression(expression)) {\n return undefined;\n }\n let operand = expression.expression;\n while (ts.isParenthesizedExpression(operand)) {\n operand = operand.expression;\n }\n if (!ts.isArrayLiteralExpression(operand) || operand.elements.length > 0) {\n return undefined;\n }\n const annotation = this.checker.getTypeFromTypeNode(expression.type);\n return this.checker.isArrayLikeType(annotation) ? expression : undefined;\n }\n\n private typeOfShorthand(\n node: ts.ShorthandPropertyAssignment,\n ): ts.Type | undefined {\n const symbol = this.checker.getShorthandAssignmentValueSymbol(node);\n const declaration = symbol?.valueDeclaration ?? symbol?.declarations?.[0];\n if (\n !declaration ||\n !ts.isVariableDeclaration(declaration) ||\n !declaration.initializer\n ) {\n return undefined;\n }\n return this.emptyArraySatisfies(declaration.initializer)\n ? this.typeOfExpression(declaration.initializer)\n : this.checker.getTypeAtLocation(node.name);\n }\n\n serializeNode(node: ts.Node): any {\n this.currentNode = node;\n if (ts.isObjectLiteralExpression(node)) {\n const symbolType = this.checker.getTypeAtLocation(node);\n const props: Record<string, any> = {};\n for (const symbol of symbolType.getProperties()) {\n const type = this.checker.getTypeOfSymbol(symbol);\n props[symbol.name] = this.serializeType(type);\n }\n\n // get literal properties values if any\n for (const prop of node.properties) {\n if (ts.isPropertyAssignment(prop)) {\n props[prop.name.getText()] = this.serializeType(\n this.typeOfExpression(prop.initializer),\n );\n } else if (ts.isShorthandPropertyAssignment(prop)) {\n const type = this.typeOfShorthand(prop);\n if (type) {\n props[prop.name.text] = this.serializeType(type);\n }\n }\n }\n\n return sortObjectKeys(props);\n }\n if (ts.isPropertyAccessExpression(node)) {\n const symbol = this.checker.getSymbolAtLocation(node.name);\n if (!symbol) {\n this.warn(`No symbol found for ${node.name.getText()}`, node);\n return null;\n }\n const type = this.checker.getTypeOfSymbol(symbol);\n return this.serializeType(type);\n }\n if (ts.isPropertySignature(node)) {\n const symbol = this.checker.getSymbolAtLocation(node.name);\n if (!symbol) {\n this.warn(`No symbol found for ${node.name.getText()}`, node);\n return null;\n }\n const type = this.checker.getTypeOfSymbol(symbol);\n return this.serializeType(type);\n }\n if (ts.isPropertyDeclaration(node)) {\n const symbol = this.checker.getSymbolAtLocation(node.name);\n if (!symbol) {\n this.warn(`No symbol found for ${node.name.getText()}`, node);\n return null;\n }\n const type = this.checker.getTypeOfSymbol(symbol);\n return this.serializeType(type);\n }\n if (ts.isInterfaceDeclaration(node)) {\n if (!node.name?.text) {\n throw new Error('Interface has no name');\n }\n if (this.typesMap[node.name.text]) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [this.typesMap[node.name.text]],\n };\n }\n if (!this.collector[node.name.text]) {\n this.collector[node.name.text] = {};\n const members: Record<string, any> = {};\n for (const member of node.members.filter(ts.isPropertySignature)) {\n members[member.name.getText()] = this.serializeNode(member);\n }\n this.collector[node.name.text] = sortObjectKeys(members);\n }\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [`#/components/schemas/${node.name.text}`],\n };\n }\n if (ts.isClassDeclaration(node)) {\n if (!node.name?.text) {\n throw new Error('Class has no name');\n }\n if (this.typesMap[node.name.text]) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [this.typesMap[node.name.text]],\n };\n }\n\n if (!this.collector[node.name.text]) {\n this.collector[node.name.text] = {};\n const members: Record<string, unknown> = {};\n for (const member of node.members.filter(ts.isPropertyDeclaration)) {\n members[member.name!.getText()] = this.serializeNode(member);\n }\n this.collector[node.name.text] = sortObjectKeys(members);\n }\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [`#/components/schemas/${node.name.text}`],\n $ref: `#/components/schemas/${node.name.text}`,\n };\n }\n if (ts.isVariableDeclaration(node)) {\n const symbol = this.checker.getSymbolAtLocation(node.name);\n if (!symbol) {\n this.warn(`No symbol found for ${node.name.getText()}`, node);\n return null;\n }\n if (!node.type) {\n this.warn(`No type found for ${node.name.getText()}`, node);\n return 'any';\n }\n const type = this.checker.getTypeFromTypeNode(node.type);\n return this.serializeType(type);\n }\n if (ts.isIdentifier(node)) {\n const symbol = this.checker.getSymbolAtLocation(node);\n if (!symbol) {\n this.warn(`No symbol found for identifier ${node.getText()}`, node);\n return null;\n }\n const type = this.checker.getTypeAtLocation(node);\n return this.serializeType(type);\n }\n if (ts.isAwaitExpression(node)) {\n const type = this.checker.getTypeAtLocation(node);\n return this.serializeType(type);\n }\n if (ts.isCallExpression(node)) {\n const type = this.checker.getTypeAtLocation(node);\n return this.serializeType(type);\n }\n if (ts.isAsExpression(node)) {\n const type = this.checker.getTypeAtLocation(node);\n return this.serializeType(type);\n }\n if (ts.isSatisfiesExpression(node)) {\n return this.serializeType(this.typeOfExpression(node));\n }\n if (ts.isTypeLiteralNode(node)) {\n const symbolType = this.checker.getTypeAtLocation(node);\n const props: Record<string, unknown> = {};\n for (const symbol of symbolType.getProperties()) {\n const type = this.checker.getTypeOfSymbol(symbol);\n props[symbol.name] = this.serializeType(type);\n }\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [sortObjectKeys(props)],\n };\n }\n if (node.kind === ts.SyntaxKind.NullKeyword) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: ['null'],\n };\n }\n if (node.kind === ts.SyntaxKind.BooleanKeyword) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: ['boolean'],\n };\n }\n if (node.kind === ts.SyntaxKind.TrueKeyword) {\n return {\n [deriveSymbol]: true,\n optional: false,\n kind: 'literal',\n value: true,\n [$types]: ['boolean'],\n };\n }\n if (node.kind === ts.SyntaxKind.FalseKeyword) {\n return {\n [deriveSymbol]: true,\n optional: false,\n kind: 'literal',\n value: false,\n [$types]: ['boolean'],\n };\n }\n if (ts.isFunctionDeclaration(node)) {\n if (!node.name) {\n this.warn('Function declaration has no name', node);\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: ['any'],\n };\n }\n\n const functionName = node.name.text;\n if (this.typesMap[functionName]) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [this.typesMap[functionName]],\n };\n }\n\n if (node.type) {\n const returnType = this.checker.getTypeFromTypeNode(node.type);\n return this.serializeType(returnType);\n }\n\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: ['any'],\n };\n }\n if (ts.isArrayLiteralExpression(node)) {\n const type = this.checker.getTypeAtLocation(node);\n return this.serializeType(type);\n }\n if (ts.isStringLiteral(node) || ts.isNumericLiteral(node)) {\n const type = this.checker.getTypeAtLocation(node);\n return this.serializeType(type);\n }\n // Handle template literals in expression position\n if (\n ts.isTemplateExpression(node) ||\n ts.isNoSubstitutionTemplateLiteral(node)\n ) {\n const type = this.checker.getTypeAtLocation(node);\n return this.serializeType(type);\n }\n if (ts.isTaggedTemplateExpression(node)) {\n const type = this.checker.getTypeAtLocation(node);\n return this.serializeType(type);\n }\n\n // Handle binary expressions (||, &&, +, -, etc.)\n if (ts.isBinaryExpression(node)) {\n const type = this.checker.getTypeAtLocation(node);\n return this.serializeType(type);\n }\n\n // Handle conditional/ternary expressions (x ? y : z)\n if (ts.isConditionalExpression(node)) {\n const type = this.checker.getTypeAtLocation(node);\n return this.serializeType(type);\n }\n\n // Handle parenthesized expressions ((value))\n if (ts.isParenthesizedExpression(node)) {\n return this.serializeType(this.typeOfExpression(node));\n }\n\n // Handle non-null assertions (value!)\n if (ts.isNonNullExpression(node)) {\n const type = this.checker.getTypeAtLocation(node);\n return this.serializeType(type);\n }\n\n this.warn(\n `Unhandled node: ${ts.SyntaxKind[node.kind]} \"${node.getText()}\" (type: ${this.checker.typeToString(\n this.checker.getTypeAtLocation(node),\n undefined,\n ts.TypeFormatFlags.NoTruncation,\n )})`,\n node,\n );\n\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: ['any'],\n };\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,MAAM,WAAW,kBAAkB;AAE1C,SAAS,uBAAuB;AAChC,SAAS,sBAAsB;AAIxB,MAAM,eAAe,OAAO,IAAI,WAAW;AAC3C,MAAM,SAAS,OAAO,IAAI,OAAO;AACjC,MAAM,kBAA0C;AAAA,EACrD,UAAU;AAAA,EACV,gBAAgB;AAAA,EAChB,iBAAiB;AAAA,EACjB,wBAAwB;AAAA,EACxB,8BAA8B;AAAA,EAC9B,sBAAsB;AAAA,EACtB,YAAY;AACd;AAOO,SAAS,aAAa,MAAmC;AAC9D,MAAI;AACF,UAAM,aAAa,KAAK,cAAc;AACtC,QAAI,CAAC,WAAY,QAAO;AACxB,UAAM,EAAE,MAAM,UAAU,IAAI,WAAW;AAAA,MACrC,KAAK,SAAS;AAAA,IAChB;AACA,WAAO,GAAG,WAAW,QAAQ,IAAI,OAAO,CAAC,IAAI,YAAY,CAAC;AAAA,EAC5D,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEO,MAAM,YAAY;AAAA,EACP,YAAuB,CAAC;AAAA,EACxB;AAAA,EACA;AAAA,EACR,QAAsB,CAAC;AAAA,EACvB;AAAA,EACR,YACE,SACA,eAAuC,iBACvC;AACA,SAAK,UAAU;AACf,SAAK,WAAW;AAAA,EAClB;AAAA,EAEA,SAAS,KAA4C;AACnD,SAAK,QAAQ,EAAE,GAAG,IAAI;AAAA,EACxB;AAAA,EAEQ,KAAK,SAAiB,MAAgB;AAC5C,UAAM,QAAQ,CAAC,kBAAkB,OAAO,SAAS;AACjD,UAAM,eAAe,QAAQ,KAAK;AAClC,UAAM,WAAW,e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AG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC;IAC/C,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,MAAM,WAAW,GAAG,CACxB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,eAAe,KACvB,WAAW,CAAC;AACjB,qBAAa,KAAK;;gBAeJ,MAAM,EAAE;QAAE,OAAO,EAAE,YAAY,EAAE,CAAC;QAAC,WAAW,CAAC,EAAE,WAAW,CAAA;KAAE;IAK1E,OAAO,CACL,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,SAAS,EAAE,QAAQ,EAAE,EACrB,SAAS,EAAE,YAAY,EAAE,EACzB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,aAAa;IAyHrB,OAAO,IAAI,MAAM,EAAE;IAcnB,gBAAgB,IAAI,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC;IAI1C,QAAQ;CA0Ef;AAED,UAAU,QAAQ;IAChB,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,GAAG,CAkExE;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,MAAM,CAEzD"}
|
package/dist/lib/paths.js
CHANGED
|
@@ -210,6 +210,8 @@ function toSchema(data) {
|
|
|
210
210
|
return { $ref: data };
|
|
211
211
|
}
|
|
212
212
|
return { type: data };
|
|
213
|
+
} else if (data.kind === "never") {
|
|
214
|
+
return { not: {} };
|
|
213
215
|
} else if (data.kind === "literal") {
|
|
214
216
|
return { enum: [data.value], type: data[$types][0] };
|
|
215
217
|
} else if (data.kind === "record") {
|
|
@@ -221,7 +223,13 @@ function toSchema(data) {
|
|
|
221
223
|
const items = data[$types].map(toSchema);
|
|
222
224
|
return { type: "array", items: data[$types].length ? items[0] : {} };
|
|
223
225
|
} else if (data.kind === "union") {
|
|
224
|
-
|
|
226
|
+
const schemas = data[$types].map(toSchema);
|
|
227
|
+
const unique = [
|
|
228
|
+
...new Map(
|
|
229
|
+
schemas.map((schema) => [JSON.stringify(schema), schema])
|
|
230
|
+
).values()
|
|
231
|
+
];
|
|
232
|
+
return unique.length === 1 ? unique[0] : { anyOf: unique };
|
|
225
233
|
} else if (data.kind === "intersection") {
|
|
226
234
|
const ANON_OBJECT = "__type";
|
|
227
235
|
const meaningful = data[$types].filter((m) => {
|
package/dist/lib/paths.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/lib/paths.ts"],
|
|
4
|
-
"sourcesContent": ["import type {\n HeadersObject,\n OperationObject,\n ParameterObject,\n PathsObject,\n ResponseObject,\n ResponsesObject,\n SchemaObject,\n} from 'openapi3-ts/oas31';\n\nimport { $types } from './deriver.js';\nimport { sortArray, sortObjectKeys } from './utils.js';\nimport { type InjectImport, evalZod } from './zod-jsonschema.js';\n\nexport type OperationInfo = {\n tool?: string;\n toolDescription?: string;\n summary?: string;\n description?: string;\n tags?: string[];\n};\nexport type Method =\n 'get' | 'post' | 'put' | 'patch' | 'delete' | 'trace' | 'head';\n\nexport const methods = [\n 'get',\n 'post',\n 'put',\n 'patch',\n 'delete',\n 'trace',\n 'head',\n] as const;\nexport type SemanticSource =\n 'query' | 'queries' | 'body' | 'params' | 'headers';\n\nconst semanticSourceToOpenAPI = {\n queries: 'query',\n query: 'query',\n headers: 'header',\n params: 'path',\n} as const;\nexport interface Selector {\n name: string;\n against: string;\n source: SemanticSource;\n}\n\nexport interface ResponseItem {\n statusCode: string;\n response?: DateType;\n contentType: string;\n headers: (string | Record<string, string[]>)[];\n middlewareName?: string;\n}\n\nexport type OnOperation = (\n sourceFile: string,\n method: Method,\n path: string,\n operation: OperationObject,\n) => PathsObject;\nexport class Paths {\n #imports: InjectImport[] = [];\n #onOperation?: OnOperation;\n #sharedResponses = new Map<string, SchemaObject>();\n #operations: Array<{\n sourceFile: string;\n name: string;\n path: string;\n method: Method;\n selectors: Selector[];\n responses: ResponsesObject;\n contentType?: string;\n info: OperationInfo;\n }> = [];\n\n constructor(config: { imports: InjectImport[]; onOperation?: OnOperation }) {\n this.#imports = config.imports;\n this.#onOperation = config.onOperation;\n }\n\n addPath(\n name: string,\n path: string,\n method: Method,\n contentType: string | undefined,\n selectors: Selector[],\n responses: ResponseItem[],\n sourceFile: string,\n info: OperationInfo,\n ) {\n const responsesObject = this.#responseItemToResponses(responses);\n\n this.#operations.push({\n name,\n path: this.#tunePath(path),\n sourceFile,\n contentType: contentType,\n method,\n selectors,\n responses: responsesObject,\n info,\n });\n return this;\n }\n\n #responseItemToResponses(responses: ResponseItem[]): ResponsesObject {\n const responsesObject: ResponsesObject = {};\n for (const item of responses) {\n const ct = item.contentType;\n let schema = item.response ? toSchema(item.response) : {};\n\n // Deduplicate named middleware responses via $ref\n if (item.middlewareName) {\n const sanitizedCt = ct.replace(/\\//g, '_');\n const sharedKey = `${item.middlewareName}${item.statusCode}_${sanitizedCt}`;\n if (!this.#sharedResponses.has(sharedKey)) {\n this.#sharedResponses.set(sharedKey, schema);\n }\n schema = { $ref: `#/components/schemas/${sharedKey}` };\n }\n\n if (!responsesObject[item.statusCode]) {\n responsesObject[item.statusCode] = {\n description: `Response for ${item.statusCode}`,\n content:\n ct !== 'empty'\n ? {\n [ct]:\n ct === 'application/octet-stream'\n ? { schema: { type: 'string', format: 'binary' } }\n : { schema },\n }\n : undefined,\n headers: item.headers.length\n ? item.headers.reduce<HeadersObject>((acc, current) => {\n const headers =\n typeof current === 'string' ? { [current]: [] } : current;\n const sortedHeaders = Object.entries(sortObjectKeys(headers));\n return sortedHeaders.reduce<HeadersObject>(\n (subAcc, [key, value]) => {\n const header: HeadersObject = {\n [key]: {\n schema: {\n type: 'string',\n enum: value.length ? value : undefined,\n },\n },\n };\n return { ...subAcc, ...header };\n },\n acc,\n );\n }, {})\n : undefined,\n } satisfies ResponseObject;\n } else {\n if (!responsesObject[item.statusCode].content[ct]) {\n responsesObject[item.statusCode].content[ct] = { schema };\n } else {\n const existing = responsesObject[item.statusCode].content[ct]\n .schema as SchemaObject;\n if (existing.oneOf) {\n if (\n !existing.oneOf.find(\n (it) => JSON.stringify(it) === JSON.stringify(schema),\n )\n ) {\n existing.oneOf.push(schema);\n }\n } else if (JSON.stringify(existing) !== JSON.stringify(schema)) {\n responsesObject[item.statusCode].content[ct].schema = {\n oneOf: [existing, schema],\n };\n }\n }\n }\n }\n return responsesObject;\n }\n\n async #selectosToParameters(selectors: Selector[]) {\n const parameters: ParameterObject[] = [];\n const bodySchemaProps: Record<\n string,\n { required: boolean; schema: SchemaObject }\n > = {};\n for (const selector of selectors) {\n const { optional, schema } = await evalZod(\n selector.against,\n this.#imports,\n );\n if (selector.source === 'body') {\n bodySchemaProps[selector.name] = {\n required: !optional,\n schema,\n };\n continue;\n }\n const parameter: ParameterObject = {\n in: semanticSourceToOpenAPI[selector.source],\n name: selector.name,\n required: !optional,\n schema,\n };\n parameters.push(parameter);\n }\n return { parameters, bodySchemaProps };\n }\n\n getTags(): string[] {\n const tags = new Set<string>();\n\n for (const operation of this.#operations) {\n if (operation.info.tags) {\n for (const tag of operation.info.tags) {\n tags.add(tag);\n }\n }\n }\n\n return Array.from(tags);\n }\n\n getSharedSchemas(): Record<string, SchemaObject> {\n return Object.fromEntries(this.#sharedResponses);\n }\n\n async getPaths() {\n const operations: PathsObject = {};\n\n for (const operation of this.#operations) {\n const { path, method, selectors } = operation;\n const { parameters, bodySchemaProps } =\n await this.#selectosToParameters(selectors);\n const bodySchema: Record<string, SchemaObject> = {};\n const required: string[] = [];\n const sortedBodySchemaProps = Object.entries(\n sortObjectKeys(bodySchemaProps),\n );\n for (const [key, value] of sortedBodySchemaProps) {\n if (value.required) {\n required.push(key);\n }\n bodySchema[key] = value.schema;\n }\n\n const operationObject: OperationObject = {\n operationId: operation.name,\n parameters,\n tags: operation.info.tags,\n // || undefined would omit the value from final openapi spec\n description: operation.info.description || undefined,\n summary: operation.info.summary || undefined,\n 'x-tool': operation.info.tool\n ? {\n name: operation.info.tool || undefined,\n description: operation.info.toolDescription || undefined,\n }\n : undefined,\n requestBody: Object.keys(bodySchema).length\n ? {\n required: required.length ? true : false,\n content: {\n [operation.contentType || 'application/json']: {\n schema: {\n required: required.length ? sortArray(required) : undefined,\n type: 'object',\n properties: bodySchema,\n },\n },\n },\n }\n : undefined,\n responses:\n Object.keys(operation.responses).length === 0\n ? undefined\n : operation.responses,\n };\n if (!operations[path]) {\n operations[path] = {};\n }\n operations[path][method] = operationObject;\n if (this.#onOperation) {\n const paths = this.#onOperation?.(\n operation.sourceFile,\n method,\n path,\n operationObject,\n );\n Object.assign(operations, paths ?? {});\n }\n }\n return operations;\n }\n\n /**\n * Converts Express/Node.js style path parameters (/path/:param) to OpenAPI style (/path/{param})\n */\n #tunePath(path: string): string {\n return path.replace(/:([^/]+)/g, '{$1}');\n }\n}\n\ninterface DateType {\n [$types]: any[];\n kind: string;\n optional: boolean;\n value?: string;\n}\n\nexport function toSchema(data: DateType | string | null | undefined): any {\n if (data === null || data === undefined) {\n return { type: 'any' };\n } else if (typeof data === 'string') {\n const isRef = data.startsWith('#');\n if (isRef) {\n return { $ref: data };\n }\n return { type: data };\n } else if (data.kind === 'literal') {\n return { enum: [data.value], type: data[$types][0] };\n } else if (data.kind === 'record') {\n return {\n type: 'object',\n additionalProperties: toSchema(data[$types][0]),\n };\n } else if (data.kind === 'array') {\n const items = data[$types].map(toSchema);\n return { type: 'array', items: data[$types].length ? items[0] : {} };\n } else if (data.kind === 'union') {\n return { anyOf: data[$types].map(toSchema) };\n } else if (data.kind === 'intersection') {\n // TS gives anonymous/empty object types the synthetic symbol name \"__type\".\n // Members like `& {}` (the autocomplete-trick wrapper) contribute no schema\n // info \u2014 drop them so `(string & {})` emits as plain `{type:'string'}`.\n const ANON_OBJECT = '__type';\n const meaningful = (data[$types] as unknown[]).filter((m) => {\n if (!m || typeof m !== 'object') return true;\n const node = m as { kind?: unknown; [$types]?: readonly unknown[] };\n return !(\n !node.kind &&\n node[$types]?.length === 1 &&\n node[$types][0] === ANON_OBJECT\n );\n });\n if (meaningful.length === 0) return {};\n if (meaningful.length === 1)\n return toSchema(meaningful[0] as DateType | string);\n return { allOf: meaningful.map((m) => toSchema(m as DateType | string)) };\n } else if ($types in data) {\n return data[$types].map(toSchema)[0] ?? {};\n } else {\n const props: Record<string, unknown> = {};\n const required: string[] = [];\n const sortedEntries = Object.entries(sortObjectKeys(data));\n for (const [key, value] of sortedEntries) {\n props[key] = toSchema(value as any);\n if (!(value as any).optional) {\n required.push(key);\n }\n }\n return {\n type: 'object',\n properties: props,\n required: sortArray(required),\n additionalProperties: false,\n };\n }\n}\n\nexport function isHttpMethod(name: string): name is Method {\n return ['get', 'post', 'put', 'delete', 'patch'].includes(name);\n}\n"],
|
|
5
|
-
"mappings": "AAUA,SAAS,cAAc;AACvB,SAAS,WAAW,sBAAsB;AAC1C,SAA4B,eAAe;AAYpC,MAAM,UAAU;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAIA,MAAM,0BAA0B;AAAA,EAC9B,SAAS;AAAA,EACT,OAAO;AAAA,EACP,SAAS;AAAA,EACT,QAAQ;AACV;AAqBO,MAAM,MAAM;AAAA,EACjB,WAA2B,CAAC;AAAA,EAC5B;AAAA,EACA,mBAAmB,oBAAI,IAA0B;AAAA,EACjD,cASK,CAAC;AAAA,EAEN,YAAY,QAAgE;AAC1E,SAAK,WAAW,OA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,WAAW;AAClC,WAAO,EAAE,MAAM,CAAC,KAAK,KAAK,GAAG,MAAM,KAAK,MAAM,EAAE,CAAC,EAAE;AAAA,EACrD,WAAW,KAAK,SAAS,UAAU;AACjC,WAAO;AAAA,MACL,MAAM;AAAA,MACN,sBAAsB,SAAS,KAAK,MAAM,EAAE,CAAC,CAAC;AAAA,IAChD;AAAA,EACF,WAAW,KAAK,SAAS,SAAS;AAChC,UAAM,QAAQ,KAAK,MAAM,EAAE,IAAI,QAAQ;AACvC,WAAO,EAAE,MAAM,SAAS,OAAO,KAAK,MAAM,EAAE,SAAS,MAAM,CAAC,IAAI,CAAC,EAAE;AAAA,EACrE,WAAW,KAAK,SAAS,SAAS;AAChC,
|
|
4
|
+
"sourcesContent": ["import type {\n HeadersObject,\n OperationObject,\n ParameterObject,\n PathsObject,\n ResponseObject,\n ResponsesObject,\n SchemaObject,\n} from 'openapi3-ts/oas31';\n\nimport { $types } from './deriver.js';\nimport { sortArray, sortObjectKeys } from './utils.js';\nimport { type InjectImport, evalZod } from './zod-jsonschema.js';\n\nexport type OperationInfo = {\n tool?: string;\n toolDescription?: string;\n summary?: string;\n description?: string;\n tags?: string[];\n};\nexport type Method =\n 'get' | 'post' | 'put' | 'patch' | 'delete' | 'trace' | 'head';\n\nexport const methods = [\n 'get',\n 'post',\n 'put',\n 'patch',\n 'delete',\n 'trace',\n 'head',\n] as const;\nexport type SemanticSource =\n 'query' | 'queries' | 'body' | 'params' | 'headers';\n\nconst semanticSourceToOpenAPI = {\n queries: 'query',\n query: 'query',\n headers: 'header',\n params: 'path',\n} as const;\nexport interface Selector {\n name: string;\n against: string;\n source: SemanticSource;\n}\n\nexport interface ResponseItem {\n statusCode: string;\n response?: DateType;\n contentType: string;\n headers: (string | Record<string, string[]>)[];\n middlewareName?: string;\n}\n\nexport type OnOperation = (\n sourceFile: string,\n method: Method,\n path: string,\n operation: OperationObject,\n) => PathsObject;\nexport class Paths {\n #imports: InjectImport[] = [];\n #onOperation?: OnOperation;\n #sharedResponses = new Map<string, SchemaObject>();\n #operations: Array<{\n sourceFile: string;\n name: string;\n path: string;\n method: Method;\n selectors: Selector[];\n responses: ResponsesObject;\n contentType?: string;\n info: OperationInfo;\n }> = [];\n\n constructor(config: { imports: InjectImport[]; onOperation?: OnOperation }) {\n this.#imports = config.imports;\n this.#onOperation = config.onOperation;\n }\n\n addPath(\n name: string,\n path: string,\n method: Method,\n contentType: string | undefined,\n selectors: Selector[],\n responses: ResponseItem[],\n sourceFile: string,\n info: OperationInfo,\n ) {\n const responsesObject = this.#responseItemToResponses(responses);\n\n this.#operations.push({\n name,\n path: this.#tunePath(path),\n sourceFile,\n contentType: contentType,\n method,\n selectors,\n responses: responsesObject,\n info,\n });\n return this;\n }\n\n #responseItemToResponses(responses: ResponseItem[]): ResponsesObject {\n const responsesObject: ResponsesObject = {};\n for (const item of responses) {\n const ct = item.contentType;\n let schema = item.response ? toSchema(item.response) : {};\n\n // Deduplicate named middleware responses via $ref\n if (item.middlewareName) {\n const sanitizedCt = ct.replace(/\\//g, '_');\n const sharedKey = `${item.middlewareName}${item.statusCode}_${sanitizedCt}`;\n if (!this.#sharedResponses.has(sharedKey)) {\n this.#sharedResponses.set(sharedKey, schema);\n }\n schema = { $ref: `#/components/schemas/${sharedKey}` };\n }\n\n if (!responsesObject[item.statusCode]) {\n responsesObject[item.statusCode] = {\n description: `Response for ${item.statusCode}`,\n content:\n ct !== 'empty'\n ? {\n [ct]:\n ct === 'application/octet-stream'\n ? { schema: { type: 'string', format: 'binary' } }\n : { schema },\n }\n : undefined,\n headers: item.headers.length\n ? item.headers.reduce<HeadersObject>((acc, current) => {\n const headers =\n typeof current === 'string' ? { [current]: [] } : current;\n const sortedHeaders = Object.entries(sortObjectKeys(headers));\n return sortedHeaders.reduce<HeadersObject>(\n (subAcc, [key, value]) => {\n const header: HeadersObject = {\n [key]: {\n schema: {\n type: 'string',\n enum: value.length ? value : undefined,\n },\n },\n };\n return { ...subAcc, ...header };\n },\n acc,\n );\n }, {})\n : undefined,\n } satisfies ResponseObject;\n } else {\n if (!responsesObject[item.statusCode].content[ct]) {\n responsesObject[item.statusCode].content[ct] = { schema };\n } else {\n const existing = responsesObject[item.statusCode].content[ct]\n .schema as SchemaObject;\n if (existing.oneOf) {\n if (\n !existing.oneOf.find(\n (it) => JSON.stringify(it) === JSON.stringify(schema),\n )\n ) {\n existing.oneOf.push(schema);\n }\n } else if (JSON.stringify(existing) !== JSON.stringify(schema)) {\n responsesObject[item.statusCode].content[ct].schema = {\n oneOf: [existing, schema],\n };\n }\n }\n }\n }\n return responsesObject;\n }\n\n async #selectosToParameters(selectors: Selector[]) {\n const parameters: ParameterObject[] = [];\n const bodySchemaProps: Record<\n string,\n { required: boolean; schema: SchemaObject }\n > = {};\n for (const selector of selectors) {\n const { optional, schema } = await evalZod(\n selector.against,\n this.#imports,\n );\n if (selector.source === 'body') {\n bodySchemaProps[selector.name] = {\n required: !optional,\n schema,\n };\n continue;\n }\n const parameter: ParameterObject = {\n in: semanticSourceToOpenAPI[selector.source],\n name: selector.name,\n required: !optional,\n schema,\n };\n parameters.push(parameter);\n }\n return { parameters, bodySchemaProps };\n }\n\n getTags(): string[] {\n const tags = new Set<string>();\n\n for (const operation of this.#operations) {\n if (operation.info.tags) {\n for (const tag of operation.info.tags) {\n tags.add(tag);\n }\n }\n }\n\n return Array.from(tags);\n }\n\n getSharedSchemas(): Record<string, SchemaObject> {\n return Object.fromEntries(this.#sharedResponses);\n }\n\n async getPaths() {\n const operations: PathsObject = {};\n\n for (const operation of this.#operations) {\n const { path, method, selectors } = operation;\n const { parameters, bodySchemaProps } =\n await this.#selectosToParameters(selectors);\n const bodySchema: Record<string, SchemaObject> = {};\n const required: string[] = [];\n const sortedBodySchemaProps = Object.entries(\n sortObjectKeys(bodySchemaProps),\n );\n for (const [key, value] of sortedBodySchemaProps) {\n if (value.required) {\n required.push(key);\n }\n bodySchema[key] = value.schema;\n }\n\n const operationObject: OperationObject = {\n operationId: operation.name,\n parameters,\n tags: operation.info.tags,\n // || undefined would omit the value from final openapi spec\n description: operation.info.description || undefined,\n summary: operation.info.summary || undefined,\n 'x-tool': operation.info.tool\n ? {\n name: operation.info.tool || undefined,\n description: operation.info.toolDescription || undefined,\n }\n : undefined,\n requestBody: Object.keys(bodySchema).length\n ? {\n required: required.length ? true : false,\n content: {\n [operation.contentType || 'application/json']: {\n schema: {\n required: required.length ? sortArray(required) : undefined,\n type: 'object',\n properties: bodySchema,\n },\n },\n },\n }\n : undefined,\n responses:\n Object.keys(operation.responses).length === 0\n ? undefined\n : operation.responses,\n };\n if (!operations[path]) {\n operations[path] = {};\n }\n operations[path][method] = operationObject;\n if (this.#onOperation) {\n const paths = this.#onOperation?.(\n operation.sourceFile,\n method,\n path,\n operationObject,\n );\n Object.assign(operations, paths ?? {});\n }\n }\n return operations;\n }\n\n /**\n * Converts Express/Node.js style path parameters (/path/:param) to OpenAPI style (/path/{param})\n */\n #tunePath(path: string): string {\n return path.replace(/:([^/]+)/g, '{$1}');\n }\n}\n\ninterface DateType {\n [$types]: any[];\n kind: string;\n optional: boolean;\n value?: string;\n}\n\nexport function toSchema(data: DateType | string | null | undefined): any {\n if (data === null || data === undefined) {\n return { type: 'any' };\n } else if (typeof data === 'string') {\n const isRef = data.startsWith('#');\n if (isRef) {\n return { $ref: data };\n }\n return { type: data };\n } else if (data.kind === 'never') {\n return { not: {} };\n } else if (data.kind === 'literal') {\n return { enum: [data.value], type: data[$types][0] };\n } else if (data.kind === 'record') {\n return {\n type: 'object',\n additionalProperties: toSchema(data[$types][0]),\n };\n } else if (data.kind === 'array') {\n const items = data[$types].map(toSchema);\n return { type: 'array', items: data[$types].length ? items[0] : {} };\n } else if (data.kind === 'union') {\n const schemas = data[$types].map(toSchema);\n const unique = [\n ...new Map(\n schemas.map((schema) => [JSON.stringify(schema), schema]),\n ).values(),\n ];\n return unique.length === 1 ? unique[0] : { anyOf: unique };\n } else if (data.kind === 'intersection') {\n // TS gives anonymous/empty object types the synthetic symbol name \"__type\".\n // Members like `& {}` (the autocomplete-trick wrapper) contribute no schema\n // info \u2014 drop them so `(string & {})` emits as plain `{type:'string'}`.\n const ANON_OBJECT = '__type';\n const meaningful = (data[$types] as unknown[]).filter((m) => {\n if (!m || typeof m !== 'object') return true;\n const node = m as { kind?: unknown; [$types]?: readonly unknown[] };\n return !(\n !node.kind &&\n node[$types]?.length === 1 &&\n node[$types][0] === ANON_OBJECT\n );\n });\n if (meaningful.length === 0) return {};\n if (meaningful.length === 1)\n return toSchema(meaningful[0] as DateType | string);\n return { allOf: meaningful.map((m) => toSchema(m as DateType | string)) };\n } else if ($types in data) {\n return data[$types].map(toSchema)[0] ?? {};\n } else {\n const props: Record<string, unknown> = {};\n const required: string[] = [];\n const sortedEntries = Object.entries(sortObjectKeys(data));\n for (const [key, value] of sortedEntries) {\n props[key] = toSchema(value as any);\n if (!(value as any).optional) {\n required.push(key);\n }\n }\n return {\n type: 'object',\n properties: props,\n required: sortArray(required),\n additionalProperties: false,\n };\n }\n}\n\nexport function isHttpMethod(name: string): name is Method {\n return ['get', 'post', 'put', 'delete', 'patch'].includes(name);\n}\n"],
|
|
5
|
+
"mappings": "AAUA,SAAS,cAAc;AACvB,SAAS,WAAW,sBAAsB;AAC1C,SAA4B,eAAe;AAYpC,MAAM,UAAU;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAIA,MAAM,0BAA0B;AAAA,EAC9B,SAAS;AAAA,EACT,OAAO;AAAA,EACP,SAAS;AAAA,EACT,QAAQ;AACV;AAqBO,MAAM,MAAM;AAAA,EACjB,WAA2B,CAAC;AAAA,EAC5B;AAAA,EACA,mBAAmB,oBAAI,IAA0B;AAAA,EACjD,cASK,CAAC;AAAA,EAEN,YAAY,QAAgE;AAC1E,SAAK,WAAW,OAAO;AACvB,SAAK,eAAe,OAAO;AAAA,EAC7B;AAAA,EAEA,QACE,MACA,MACA,QACA,aACA,WACA,WACA,YACA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