@dudousxd/nestjs-codegen 0.7.1 → 0.8.0
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/CHANGELOG.md +6 -0
- package/dist/cli/main.cjs +23 -4
- package/dist/cli/main.cjs.map +1 -1
- package/dist/cli/main.js +23 -4
- package/dist/cli/main.js.map +1 -1
- package/dist/index.cjs +23 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +23 -4
- package/dist/index.js.map +1 -1
- package/dist/nest/index.cjs +22 -3
- package/dist/nest/index.cjs.map +1 -1
- package/dist/nest/index.js +22 -3
- package/dist/nest/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @dudousxd/nestjs-codegen
|
|
2
2
|
|
|
3
|
+
## 0.8.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 685583d: feat(core): synthesize the route `query` type from individual `@Query('name')` params. Handlers using named query params (e.g. `@Query('years') years?: number[]`, `@Query('q') q?: string | string[]`) now emit a typed `query` object — one property per param, keyed by the string-literal name, typed by the parameter annotation, optional when the param has `?` / a default / a `| undefined` type — instead of `query: never`. The existing whole-object `@Query() dto` form is unchanged and still wins when both forms appear on the same handler.
|
|
8
|
+
|
|
3
9
|
## 0.7.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/cli/main.cjs
CHANGED
|
@@ -3536,14 +3536,33 @@ function extractQueryType(method, sourceFile, project) {
|
|
|
3536
3536
|
for (const param of method.getParameters()) {
|
|
3537
3537
|
const queryDecorator = param.getDecorators().find((d) => d.getName() === "Query");
|
|
3538
3538
|
if (!queryDecorator) continue;
|
|
3539
|
-
|
|
3540
|
-
if (queryArgs.length > 0) continue;
|
|
3539
|
+
if (queryDecorator.getArguments().length > 0) continue;
|
|
3541
3540
|
const typeNode = param.getTypeNode();
|
|
3542
3541
|
if (typeNode) {
|
|
3543
3542
|
return resolveTypeNodeToString(typeNode, sourceFile, project, 3);
|
|
3544
3543
|
}
|
|
3545
3544
|
}
|
|
3546
|
-
|
|
3545
|
+
const entries = [];
|
|
3546
|
+
for (const param of method.getParameters()) {
|
|
3547
|
+
const queryDecorator = param.getDecorators().find((d) => d.getName() === "Query");
|
|
3548
|
+
if (!queryDecorator) continue;
|
|
3549
|
+
const queryArgs = queryDecorator.getArguments();
|
|
3550
|
+
const nameArg = queryArgs[0];
|
|
3551
|
+
if (!nameArg || !import_ts_morph7.Node.isStringLiteral(nameArg)) continue;
|
|
3552
|
+
const queryName = nameArg.getLiteralValue();
|
|
3553
|
+
const typeNode = param.getTypeNode();
|
|
3554
|
+
const queryType = typeNode ? resolveTypeNodeToString(typeNode, sourceFile, project, 3) : "string";
|
|
3555
|
+
entries.push(`${queryName}${isParamOptional(param) ? "?" : ""}: ${queryType}`);
|
|
3556
|
+
}
|
|
3557
|
+
return entries.length > 0 ? `{ ${entries.join("; ")} }` : null;
|
|
3558
|
+
}
|
|
3559
|
+
function isParamOptional(param) {
|
|
3560
|
+
if (param.hasQuestionToken() || param.hasInitializer()) return true;
|
|
3561
|
+
const typeNode = param.getTypeNode();
|
|
3562
|
+
if (typeNode && import_ts_morph7.Node.isUnionTypeNode(typeNode)) {
|
|
3563
|
+
return typeNode.getTypeNodes().some((t) => t.getKind() === import_ts_morph7.SyntaxKind.UndefinedKeyword);
|
|
3564
|
+
}
|
|
3565
|
+
return false;
|
|
3547
3566
|
}
|
|
3548
3567
|
function extractParamsType(method, sourceFile, project) {
|
|
3549
3568
|
const entries = [];
|
|
@@ -4481,7 +4500,7 @@ async function watch(config, onChange) {
|
|
|
4481
4500
|
}
|
|
4482
4501
|
|
|
4483
4502
|
// src/index.ts
|
|
4484
|
-
var VERSION = "0.
|
|
4503
|
+
var VERSION = "0.8.0";
|
|
4485
4504
|
|
|
4486
4505
|
// src/cli/codegen.ts
|
|
4487
4506
|
async function runCodegen(opts = {}) {
|