@dudousxd/nestjs-codegen 0.17.0 → 0.17.1

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 CHANGED
@@ -1,5 +1,28 @@
1
1
  # @dudousxd/nestjs-codegen
2
2
 
3
+ ## 0.17.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Support mixin controllers that OVERRIDE an inherited route.
8
+
9
+ Two gaps made the override pattern undiscoverable, so a subclass that customised
10
+ one route silently lost every route it did not override:
11
+
12
+ - **Heritage by identifier.** Discovery required a literal call expression
13
+ (`extends factory(Entity)`). But an override has to name the factory's products
14
+ in its own decorators (e.g. `@ApplyFilter(SomeTable.filter)`) and cannot
15
+ reference itself at decoration time, so the factory call must be bound to a
16
+ const first — `extends SomeTable`. That form now resolves through the const's
17
+ initialiser.
18
+ - **Override deduplication.** The derived class's own method now shadows the
19
+ inherited one of the same name. Emitting both produced two routes with the same
20
+ name (tripping the collision check); dropping the inherited siblings would have
21
+ lost the routes the subclass left alone.
22
+
23
+ An overriding method also keeps the route's mixin binding, so its `filterFields`
24
+ still resolve from the call-site entity.
25
+
3
26
  ## 0.17.0
4
27
 
5
28
  ### Minor Changes
package/dist/cli/main.cjs CHANGED
@@ -4203,6 +4203,19 @@ function resolveParamClass(method, decoratorName, sourceFile, project) {
4203
4203
 
4204
4204
  // src/discovery/heritage.ts
4205
4205
  var import_ts_morph8 = require("ts-morph");
4206
+ function resolveHeritageCall(node) {
4207
+ if (!node) return void 0;
4208
+ const expr = unwrapExpression(node);
4209
+ if (import_ts_morph8.Node.isCallExpression(expr)) return expr;
4210
+ if (!import_ts_morph8.Node.isIdentifier(expr)) return void 0;
4211
+ const decl = expr.getDefinitions().map((d) => d.getDeclarationNode()).find(
4212
+ (n) => n !== void 0 && import_ts_morph8.Node.isVariableDeclaration(n)
4213
+ );
4214
+ const init = decl?.getInitializer();
4215
+ if (!init) return void 0;
4216
+ const unwrapped = unwrapExpression(init);
4217
+ return import_ts_morph8.Node.isCallExpression(unwrapped) ? unwrapped : void 0;
4218
+ }
4206
4219
  function unwrapExpression(node) {
4207
4220
  let current = node;
4208
4221
  while (import_ts_morph8.Node.isAsExpression(current) || import_ts_morph8.Node.isSatisfiesExpression(current) || import_ts_morph8.Node.isParenthesizedExpression(current) || import_ts_morph8.Node.isTypeAssertion(current)) {
@@ -4230,8 +4243,8 @@ function resolveReturnedClass(factoryDecl) {
4230
4243
  return void 0;
4231
4244
  }
4232
4245
  function resolveInheritedMethods(cls) {
4233
- const expr = cls.getExtends()?.getExpression();
4234
- if (!expr || !import_ts_morph8.Node.isCallExpression(expr)) return void 0;
4246
+ const expr = resolveHeritageCall(cls.getExtends()?.getExpression());
4247
+ if (!expr) return void 0;
4235
4248
  const callee = expr.getExpression();
4236
4249
  if (!import_ts_morph8.Node.isIdentifier(callee)) return void 0;
4237
4250
  const factoryDecl = callee.getDefinitions().map((d) => d.getDeclarationNode()).find((n) => import_ts_morph8.Node.isFunctionDeclaration(n));
@@ -4786,9 +4799,11 @@ function extractFromSourceFile(sourceFile, project) {
4786
4799
  factoryFilePath: inherited.factoryFilePath,
4787
4800
  classArgs: inherited.classArgs
4788
4801
  } : void 0;
4802
+ const ownMethods = cls.getMethods();
4803
+ const ownNames = new Set(ownMethods.map((m) => m.getName()));
4789
4804
  const methods = [
4790
- ...cls.getMethods().map((method) => ({ method })),
4791
- ...(inherited?.methods ?? []).map((method) => ({ method, mixin: mixinBinding }))
4805
+ ...ownMethods.map((method) => ({ method, mixin: mixinBinding })),
4806
+ ...(inherited?.methods ?? []).filter((method) => !ownNames.has(method.getName())).map((method) => ({ method, mixin: mixinBinding }))
4792
4807
  ];
4793
4808
  for (const { method, mixin } of methods) {
4794
4809
  const verb = resolveVerb(method);
@@ -5014,7 +5029,7 @@ async function watch(config, onChange, options = {}) {
5014
5029
  }
5015
5030
 
5016
5031
  // src/index.ts
5017
- var VERSION = "0.17.0";
5032
+ var VERSION = "0.17.1";
5018
5033
 
5019
5034
  // src/cli/codegen.ts
5020
5035
  async function runCodegen(opts = {}) {