@dudousxd/nestjs-codegen 0.17.2 → 0.18.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 +26 -0
- package/dist/cli/main.cjs +41 -11
- package/dist/cli/main.cjs.map +1 -1
- package/dist/cli/main.js +41 -11
- package/dist/cli/main.js.map +1 -1
- package/dist/extension/index.d.cts +1 -1
- package/dist/extension/index.d.ts +1 -1
- package/dist/{index-DCF9QSPY.d.cts → index-Dyf4ttwU.d.cts} +24 -1
- package/dist/{index-DCF9QSPY.d.ts → index-Dyf4ttwU.d.ts} +24 -1
- package/dist/index.cjs +41 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +41 -11
- package/dist/index.js.map +1 -1
- package/dist/nest/index.cjs +41 -11
- package/dist/nest/index.cjs.map +1 -1
- package/dist/nest/index.d.cts +1 -1
- package/dist/nest/index.d.ts +1 -1
- package/dist/nest/index.js +41 -11
- package/dist/nest/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/main.js
CHANGED
|
@@ -3504,23 +3504,52 @@ function resolveInheritedMethods(cls) {
|
|
|
3504
3504
|
const returnedClass = resolveReturnedClass(factoryDecl);
|
|
3505
3505
|
if (!returnedClass) return void 0;
|
|
3506
3506
|
const classArgs = [];
|
|
3507
|
+
const namedClassArgs = {};
|
|
3507
3508
|
for (const arg of expr.getArguments()) {
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3509
|
+
const positional = resolveClassReference(arg);
|
|
3510
|
+
if (positional) {
|
|
3511
|
+
classArgs.push(positional);
|
|
3512
|
+
continue;
|
|
3513
|
+
}
|
|
3514
|
+
if (!Node5.isObjectLiteralExpression(arg)) continue;
|
|
3515
|
+
for (const prop of arg.getProperties()) {
|
|
3516
|
+
const named = resolvePropertyClassReference(prop);
|
|
3517
|
+
if (!named) continue;
|
|
3518
|
+
namedClassArgs[named.key] ??= named.ref;
|
|
3515
3519
|
}
|
|
3516
3520
|
}
|
|
3517
3521
|
return {
|
|
3518
3522
|
methods: returnedClass.getMethods(),
|
|
3519
3523
|
factoryName: callee.getText(),
|
|
3520
3524
|
factoryFilePath: factoryDecl.getSourceFile().getFilePath(),
|
|
3521
|
-
classArgs
|
|
3525
|
+
classArgs,
|
|
3526
|
+
namedClassArgs
|
|
3522
3527
|
};
|
|
3523
3528
|
}
|
|
3529
|
+
function resolveClassReference(node) {
|
|
3530
|
+
const expr = unwrapExpression(node);
|
|
3531
|
+
if (!Node5.isIdentifier(expr)) return void 0;
|
|
3532
|
+
const decl = expr.getDefinitions().map((d) => d.getDeclarationNode()).find((n) => n !== void 0 && Node5.isClassDeclaration(n));
|
|
3533
|
+
if (!decl) return void 0;
|
|
3534
|
+
return {
|
|
3535
|
+
name: decl.getName() ?? expr.getText(),
|
|
3536
|
+
filePath: decl.getSourceFile().getFilePath()
|
|
3537
|
+
};
|
|
3538
|
+
}
|
|
3539
|
+
function resolvePropertyClassReference(prop) {
|
|
3540
|
+
if (Node5.isShorthandPropertyAssignment(prop)) {
|
|
3541
|
+
const ref2 = resolveClassReference(prop.getNameNode());
|
|
3542
|
+
return ref2 ? { key: prop.getName(), ref: ref2 } : void 0;
|
|
3543
|
+
}
|
|
3544
|
+
if (!Node5.isPropertyAssignment(prop)) return void 0;
|
|
3545
|
+
const init = prop.getInitializer();
|
|
3546
|
+
if (!init) return void 0;
|
|
3547
|
+
const ref = resolveClassReference(init);
|
|
3548
|
+
if (!ref) return void 0;
|
|
3549
|
+
const nameNode = prop.getNameNode();
|
|
3550
|
+
const key = Node5.isStringLiteral(nameNode) ? nameNode.getLiteralValue() : prop.getName();
|
|
3551
|
+
return { key, ref };
|
|
3552
|
+
}
|
|
3524
3553
|
var mixinTypeProject;
|
|
3525
3554
|
function getMixinTypeProject() {
|
|
3526
3555
|
mixinTypeProject ??= new Project3({
|
|
@@ -3550,7 +3579,7 @@ function resolveInstantiatedReturnType(cls, methodName) {
|
|
|
3550
3579
|
|
|
3551
3580
|
// src/discovery/filter-for.ts
|
|
3552
3581
|
function resolveMixinEntityClass(mixin, project) {
|
|
3553
|
-
const entityArg = mixin?.classArgs[0];
|
|
3582
|
+
const entityArg = mixin?.namedClassArgs?.entity ?? mixin?.classArgs[0];
|
|
3554
3583
|
if (!entityArg) return void 0;
|
|
3555
3584
|
const file = project.getSourceFile(entityArg.filePath) ?? project.addSourceFileAtPathIfExists(entityArg.filePath);
|
|
3556
3585
|
return file?.getClass(entityArg.name);
|
|
@@ -4802,7 +4831,8 @@ function extractFromSourceFile(sourceFile, project) {
|
|
|
4802
4831
|
const mixinBinding = inherited ? {
|
|
4803
4832
|
factoryName: inherited.factoryName,
|
|
4804
4833
|
factoryFilePath: inherited.factoryFilePath,
|
|
4805
|
-
classArgs: inherited.classArgs
|
|
4834
|
+
classArgs: inherited.classArgs,
|
|
4835
|
+
namedClassArgs: inherited.namedClassArgs
|
|
4806
4836
|
} : void 0;
|
|
4807
4837
|
const ownMethods = cls.getMethods();
|
|
4808
4838
|
const ownNames = new Set(ownMethods.map((m) => m.getName()));
|
|
@@ -5034,7 +5064,7 @@ async function watch(config, onChange, options = {}) {
|
|
|
5034
5064
|
}
|
|
5035
5065
|
|
|
5036
5066
|
// src/index.ts
|
|
5037
|
-
var VERSION = "0.
|
|
5067
|
+
var VERSION = "0.18.0";
|
|
5038
5068
|
|
|
5039
5069
|
// src/cli/codegen.ts
|
|
5040
5070
|
async function runCodegen(opts = {}) {
|