@dudousxd/nestjs-codegen 0.7.0 → 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 +12 -0
- package/dist/cli/main.cjs +38 -14
- package/dist/cli/main.cjs.map +1 -1
- package/dist/cli/main.js +38 -14
- package/dist/cli/main.js.map +1 -1
- package/dist/index.cjs +38 -14
- 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 +38 -14
- 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/nest/index.js
CHANGED
|
@@ -1514,14 +1514,33 @@ function extractQueryType(method, sourceFile, project) {
|
|
|
1514
1514
|
for (const param of method.getParameters()) {
|
|
1515
1515
|
const queryDecorator = param.getDecorators().find((d) => d.getName() === "Query");
|
|
1516
1516
|
if (!queryDecorator) continue;
|
|
1517
|
-
|
|
1518
|
-
if (queryArgs.length > 0) continue;
|
|
1517
|
+
if (queryDecorator.getArguments().length > 0) continue;
|
|
1519
1518
|
const typeNode = param.getTypeNode();
|
|
1520
1519
|
if (typeNode) {
|
|
1521
1520
|
return resolveTypeNodeToString(typeNode, sourceFile, project, 3);
|
|
1522
1521
|
}
|
|
1523
1522
|
}
|
|
1524
|
-
|
|
1523
|
+
const entries = [];
|
|
1524
|
+
for (const param of method.getParameters()) {
|
|
1525
|
+
const queryDecorator = param.getDecorators().find((d) => d.getName() === "Query");
|
|
1526
|
+
if (!queryDecorator) continue;
|
|
1527
|
+
const queryArgs = queryDecorator.getArguments();
|
|
1528
|
+
const nameArg = queryArgs[0];
|
|
1529
|
+
if (!nameArg || !Node5.isStringLiteral(nameArg)) continue;
|
|
1530
|
+
const queryName = nameArg.getLiteralValue();
|
|
1531
|
+
const typeNode = param.getTypeNode();
|
|
1532
|
+
const queryType = typeNode ? resolveTypeNodeToString(typeNode, sourceFile, project, 3) : "string";
|
|
1533
|
+
entries.push(`${queryName}${isParamOptional(param) ? "?" : ""}: ${queryType}`);
|
|
1534
|
+
}
|
|
1535
|
+
return entries.length > 0 ? `{ ${entries.join("; ")} }` : null;
|
|
1536
|
+
}
|
|
1537
|
+
function isParamOptional(param) {
|
|
1538
|
+
if (param.hasQuestionToken() || param.hasInitializer()) return true;
|
|
1539
|
+
const typeNode = param.getTypeNode();
|
|
1540
|
+
if (typeNode && Node5.isUnionTypeNode(typeNode)) {
|
|
1541
|
+
return typeNode.getTypeNodes().some((t) => t.getKind() === SyntaxKind2.UndefinedKeyword);
|
|
1542
|
+
}
|
|
1543
|
+
return false;
|
|
1525
1544
|
}
|
|
1526
1545
|
function extractParamsType(method, sourceFile, project) {
|
|
1527
1546
|
const entries = [];
|