@dudousxd/nestjs-codegen 0.24.0 → 0.25.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/dist/cli/main.js CHANGED
@@ -1635,6 +1635,32 @@ function resolveFactoryStaticClass(node) {
1635
1635
  if (!Node5.isIdentifier(inner)) return void 0;
1636
1636
  return inner.getDefinitions().map((d) => d.getDeclarationNode()).find((n) => n !== void 0 && Node5.isClassDeclaration(n));
1637
1637
  }
1638
+ function resolveBaseClass(cls) {
1639
+ const heritage = cls.getExtends()?.getExpression();
1640
+ if (!heritage) return void 0;
1641
+ const call = resolveHeritageCall(heritage);
1642
+ if (call) {
1643
+ const factoryDecl = resolveFactoryDeclaration(call);
1644
+ return factoryDecl ? resolveReturnedClass(factoryDecl) : void 0;
1645
+ }
1646
+ const expr = unwrapExpression(heritage);
1647
+ if (!Node5.isIdentifier(expr)) return void 0;
1648
+ return expr.getDefinitions().map((d) => d.getDeclarationNode()).find((n) => n !== void 0 && Node5.isClassDeclaration(n));
1649
+ }
1650
+ function collectMethodsThroughChain(returnedClass) {
1651
+ const byName = /* @__PURE__ */ new Map();
1652
+ const seen = /* @__PURE__ */ new Set();
1653
+ let current = returnedClass;
1654
+ while (current && !seen.has(current)) {
1655
+ seen.add(current);
1656
+ for (const method of current.getMethods()) {
1657
+ const name = method.getName();
1658
+ if (!byName.has(name)) byName.set(name, method);
1659
+ }
1660
+ current = resolveBaseClass(current);
1661
+ }
1662
+ return [...byName.values()];
1663
+ }
1638
1664
  function resolveInheritedMethods(cls) {
1639
1665
  const expr = resolveHeritageCall(cls.getExtends()?.getExpression());
1640
1666
  if (!expr) return void 0;
@@ -1674,7 +1700,7 @@ function resolveInheritedMethods(cls) {
1674
1700
  }
1675
1701
  }
1676
1702
  return {
1677
- methods: returnedClass.getMethods(),
1703
+ methods: collectMethodsThroughChain(returnedClass),
1678
1704
  // The DECLARATION's name, not the call-site text: consumers look the factory
1679
1705
  // back up by name inside `factoryFilePath`, which a qualified
1680
1706
  // `tables.createTableController` would never match. For a bare identifier
@@ -3048,7 +3074,7 @@ function extractDtoRoute(args) {
3048
3074
  const methodName = method.getName();
3049
3075
  const classAs = readAsDecorator(cls, `class ${className}`);
3050
3076
  const methodAs = readAsDecorator(method, `${className}.${methodName}`);
3051
- const dtoContract = extractDtoContract(method, sourceFile, project, mixin, cls);
3077
+ const dtoContract = extractDtoContract(method, method.getSourceFile(), project, mixin, cls);
3052
3078
  const mixinResponse = mixin ? resolveInstantiatedReturnType(cls, methodName) : void 0;
3053
3079
  return buildRoute({
3054
3080
  className,
@@ -5255,7 +5281,7 @@ async function watch(config, onChange, options = {}) {
5255
5281
  }
5256
5282
 
5257
5283
  // src/index.ts
5258
- var VERSION = "0.24.0";
5284
+ var VERSION = "0.25.0";
5259
5285
 
5260
5286
  // src/cli/codegen.ts
5261
5287
  async function runCodegen(opts = {}) {