@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.
@@ -3340,23 +3340,52 @@ function resolveInheritedMethods(cls) {
3340
3340
  const returnedClass = resolveReturnedClass(factoryDecl);
3341
3341
  if (!returnedClass) return void 0;
3342
3342
  const classArgs = [];
3343
+ const namedClassArgs = {};
3343
3344
  for (const arg of expr.getArguments()) {
3344
- if (!import_ts_morph6.Node.isIdentifier(arg)) continue;
3345
- const decl = arg.getDefinitions().map((d) => d.getDeclarationNode()).find((n) => import_ts_morph6.Node.isClassDeclaration(n));
3346
- if (decl) {
3347
- classArgs.push({
3348
- name: decl.getName() ?? arg.getText(),
3349
- filePath: decl.getSourceFile().getFilePath()
3350
- });
3345
+ const positional = resolveClassReference(arg);
3346
+ if (positional) {
3347
+ classArgs.push(positional);
3348
+ continue;
3349
+ }
3350
+ if (!import_ts_morph6.Node.isObjectLiteralExpression(arg)) continue;
3351
+ for (const prop of arg.getProperties()) {
3352
+ const named = resolvePropertyClassReference(prop);
3353
+ if (!named) continue;
3354
+ namedClassArgs[named.key] ??= named.ref;
3351
3355
  }
3352
3356
  }
3353
3357
  return {
3354
3358
  methods: returnedClass.getMethods(),
3355
3359
  factoryName: callee.getText(),
3356
3360
  factoryFilePath: factoryDecl.getSourceFile().getFilePath(),
3357
- classArgs
3361
+ classArgs,
3362
+ namedClassArgs
3358
3363
  };
3359
3364
  }
3365
+ function resolveClassReference(node) {
3366
+ const expr = unwrapExpression(node);
3367
+ if (!import_ts_morph6.Node.isIdentifier(expr)) return void 0;
3368
+ const decl = expr.getDefinitions().map((d) => d.getDeclarationNode()).find((n) => n !== void 0 && import_ts_morph6.Node.isClassDeclaration(n));
3369
+ if (!decl) return void 0;
3370
+ return {
3371
+ name: decl.getName() ?? expr.getText(),
3372
+ filePath: decl.getSourceFile().getFilePath()
3373
+ };
3374
+ }
3375
+ function resolvePropertyClassReference(prop) {
3376
+ if (import_ts_morph6.Node.isShorthandPropertyAssignment(prop)) {
3377
+ const ref2 = resolveClassReference(prop.getNameNode());
3378
+ return ref2 ? { key: prop.getName(), ref: ref2 } : void 0;
3379
+ }
3380
+ if (!import_ts_morph6.Node.isPropertyAssignment(prop)) return void 0;
3381
+ const init = prop.getInitializer();
3382
+ if (!init) return void 0;
3383
+ const ref = resolveClassReference(init);
3384
+ if (!ref) return void 0;
3385
+ const nameNode = prop.getNameNode();
3386
+ const key = import_ts_morph6.Node.isStringLiteral(nameNode) ? nameNode.getLiteralValue() : prop.getName();
3387
+ return { key, ref };
3388
+ }
3360
3389
  var mixinTypeProject;
3361
3390
  function getMixinTypeProject() {
3362
3391
  mixinTypeProject ??= new import_ts_morph6.Project({
@@ -3386,7 +3415,7 @@ function resolveInstantiatedReturnType(cls, methodName) {
3386
3415
 
3387
3416
  // src/discovery/filter-for.ts
3388
3417
  function resolveMixinEntityClass(mixin, project) {
3389
- const entityArg = mixin?.classArgs[0];
3418
+ const entityArg = mixin?.namedClassArgs?.entity ?? mixin?.classArgs[0];
3390
3419
  if (!entityArg) return void 0;
3391
3420
  const file = project.getSourceFile(entityArg.filePath) ?? project.addSourceFileAtPathIfExists(entityArg.filePath);
3392
3421
  return file?.getClass(entityArg.name);
@@ -4619,7 +4648,8 @@ function extractFromSourceFile(sourceFile, project) {
4619
4648
  const mixinBinding = inherited ? {
4620
4649
  factoryName: inherited.factoryName,
4621
4650
  factoryFilePath: inherited.factoryFilePath,
4622
- classArgs: inherited.classArgs
4651
+ classArgs: inherited.classArgs,
4652
+ namedClassArgs: inherited.namedClassArgs
4623
4653
  } : void 0;
4624
4654
  const ownMethods = cls.getMethods();
4625
4655
  const ownNames = new Set(ownMethods.map((m) => m.getName()));
@@ -4851,7 +4881,7 @@ async function watch(config, onChange, options = {}) {
4851
4881
  }
4852
4882
 
4853
4883
  // src/index.ts
4854
- var VERSION = "0.17.2";
4884
+ var VERSION = "0.18.0";
4855
4885
 
4856
4886
  // src/generate-manifest.ts
4857
4887
  var MANIFEST_FILE = ".codegen-manifest.json";