@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/dist/cli/main.js
CHANGED
|
@@ -3517,14 +3517,33 @@ function extractQueryType(method, sourceFile, project) {
|
|
|
3517
3517
|
for (const param of method.getParameters()) {
|
|
3518
3518
|
const queryDecorator = param.getDecorators().find((d) => d.getName() === "Query");
|
|
3519
3519
|
if (!queryDecorator) continue;
|
|
3520
|
-
|
|
3521
|
-
if (queryArgs.length > 0) continue;
|
|
3520
|
+
if (queryDecorator.getArguments().length > 0) continue;
|
|
3522
3521
|
const typeNode = param.getTypeNode();
|
|
3523
3522
|
if (typeNode) {
|
|
3524
3523
|
return resolveTypeNodeToString(typeNode, sourceFile, project, 3);
|
|
3525
3524
|
}
|
|
3526
3525
|
}
|
|
3527
|
-
|
|
3526
|
+
const entries = [];
|
|
3527
|
+
for (const param of method.getParameters()) {
|
|
3528
|
+
const queryDecorator = param.getDecorators().find((d) => d.getName() === "Query");
|
|
3529
|
+
if (!queryDecorator) continue;
|
|
3530
|
+
const queryArgs = queryDecorator.getArguments();
|
|
3531
|
+
const nameArg = queryArgs[0];
|
|
3532
|
+
if (!nameArg || !Node6.isStringLiteral(nameArg)) continue;
|
|
3533
|
+
const queryName = nameArg.getLiteralValue();
|
|
3534
|
+
const typeNode = param.getTypeNode();
|
|
3535
|
+
const queryType = typeNode ? resolveTypeNodeToString(typeNode, sourceFile, project, 3) : "string";
|
|
3536
|
+
entries.push(`${queryName}${isParamOptional(param) ? "?" : ""}: ${queryType}`);
|
|
3537
|
+
}
|
|
3538
|
+
return entries.length > 0 ? `{ ${entries.join("; ")} }` : null;
|
|
3539
|
+
}
|
|
3540
|
+
function isParamOptional(param) {
|
|
3541
|
+
if (param.hasQuestionToken() || param.hasInitializer()) return true;
|
|
3542
|
+
const typeNode = param.getTypeNode();
|
|
3543
|
+
if (typeNode && Node6.isUnionTypeNode(typeNode)) {
|
|
3544
|
+
return typeNode.getTypeNodes().some((t) => t.getKind() === SyntaxKind3.UndefinedKeyword);
|
|
3545
|
+
}
|
|
3546
|
+
return false;
|
|
3528
3547
|
}
|
|
3529
3548
|
function extractParamsType(method, sourceFile, project) {
|
|
3530
3549
|
const entries = [];
|
|
@@ -4462,7 +4481,7 @@ async function watch(config, onChange) {
|
|
|
4462
4481
|
}
|
|
4463
4482
|
|
|
4464
4483
|
// src/index.ts
|
|
4465
|
-
var VERSION = "0.
|
|
4484
|
+
var VERSION = "0.8.0";
|
|
4466
4485
|
|
|
4467
4486
|
// src/cli/codegen.ts
|
|
4468
4487
|
async function runCodegen(opts = {}) {
|