@dudousxd/nestjs-codegen 0.20.0 → 0.21.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 +27 -0
- package/dist/cli/main.cjs +6 -6
- package/dist/cli/main.cjs.map +1 -1
- package/dist/cli/main.js +6 -6
- package/dist/cli/main.js.map +1 -1
- package/dist/index.cjs +6 -6
- 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 +6 -6
- package/dist/index.js.map +1 -1
- package/dist/nest/index.cjs +6 -6
- package/dist/nest/index.cjs.map +1 -1
- package/dist/nest/index.js +6 -6
- package/dist/nest/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @dudousxd/nestjs-codegen
|
|
2
2
|
|
|
3
|
+
## 0.21.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 71b4485: Tell an overridden route from an inherited one by the class it is declared on, not by its file
|
|
8
|
+
|
|
9
|
+
`extractApplyFilterInfo` decided whether a route was the controller's OWN by
|
|
10
|
+
comparing the method's file to the factory's (`declFile !== mixin.factoryFilePath`).
|
|
11
|
+
That is a proxy for the real question, and it breaks on the one shape where the
|
|
12
|
+
two come apart: a controller factory declared in the SAME file as a controller
|
|
13
|
+
that calls it. There, a genuine override reads as inherited, its
|
|
14
|
+
`@ApplyFilter(SomeFilter)` is mistaken for the factory talking about itself, and
|
|
15
|
+
the factory's `filter` option silently outranks the filter the override names —
|
|
16
|
+
typing the route against a filter the runtime does not use.
|
|
17
|
+
|
|
18
|
+
`extractDtoContract` now takes the `@Controller` class the route was discovered
|
|
19
|
+
on and passes it down, so the check is `method.getParent() === controllerClass`:
|
|
20
|
+
the ground truth the discovery pass already computed when it merged own and
|
|
21
|
+
inherited methods. The parameter is optional — omitting it degrades to the
|
|
22
|
+
previous file comparison, so an external caller of the exported
|
|
23
|
+
`extractDtoContract` keeps working unchanged.
|
|
24
|
+
|
|
25
|
+
This also settles a disagreement between packages. `@dudousxd/nestjs-filter-codegen`
|
|
26
|
+
asks the same question via `controllerClass.getMethod(name)` and was already
|
|
27
|
+
right about the colocated case; the two have to agree on what an override IS, not
|
|
28
|
+
merely on how to rank one, or the same route ends up described twice, differently.
|
|
29
|
+
|
|
3
30
|
## 0.20.0
|
|
4
31
|
|
|
5
32
|
### Minor Changes
|
package/dist/cli/main.cjs
CHANGED
|
@@ -3736,7 +3736,7 @@ function extractFilterForHints(classDecl, project) {
|
|
|
3736
3736
|
}
|
|
3737
3737
|
return hints;
|
|
3738
3738
|
}
|
|
3739
|
-
function extractApplyFilterInfo(method, sourceFile, project, mixin) {
|
|
3739
|
+
function extractApplyFilterInfo(method, sourceFile, project, mixin, controllerClass) {
|
|
3740
3740
|
const declFile = method.getSourceFile();
|
|
3741
3741
|
const mixinEntity = resolveMixinEntityClass(mixin, project);
|
|
3742
3742
|
for (const param of method.getParameters()) {
|
|
@@ -3762,7 +3762,7 @@ function extractApplyFilterInfo(method, sourceFile, project, mixin) {
|
|
|
3762
3762
|
const filterClassName = filterClassArg.getText();
|
|
3763
3763
|
const resolved = factoryStaticClass ? void 0 : findType(filterClassName, declFile, project);
|
|
3764
3764
|
const declaredClass = factoryStaticClass ?? (resolved?.kind === "class" ? resolved.decl : resolveLocalClassDeclaration(filterClassArg));
|
|
3765
|
-
const ownRoute = !mixin || declFile.getFilePath() !== mixin.factoryFilePath;
|
|
3765
|
+
const ownRoute = !mixin || (controllerClass ? method.getParent() === controllerClass : declFile.getFilePath() !== mixin.factoryFilePath);
|
|
3766
3766
|
const namedByRoute = ownRoute && import_ts_morph7.Node.isIdentifier(filterClassArg) ? declaredClass : void 0;
|
|
3767
3767
|
for (const candidate of orderFilterCandidates({
|
|
3768
3768
|
namedByRoute,
|
|
@@ -4353,9 +4353,9 @@ function unwrapNamedContainer(node, names) {
|
|
|
4353
4353
|
}
|
|
4354
4354
|
return node;
|
|
4355
4355
|
}
|
|
4356
|
-
function extractDtoContract(method, sourceFile, project, mixin) {
|
|
4356
|
+
function extractDtoContract(method, sourceFile, project, mixin, controllerClass) {
|
|
4357
4357
|
let body = extractBodyType(method, sourceFile, project);
|
|
4358
|
-
const filterInfo = extractApplyFilterInfo(method, sourceFile, project, mixin);
|
|
4358
|
+
const filterInfo = extractApplyFilterInfo(method, sourceFile, project, mixin, controllerClass);
|
|
4359
4359
|
const query = extractQueryType(method, sourceFile, project);
|
|
4360
4360
|
const uploads = extractUploadedFiles(method);
|
|
4361
4361
|
const multipartBody = uploads.fields ? `{ ${uploads.fields} }` : null;
|
|
@@ -4918,7 +4918,7 @@ function extractDtoRoute(args) {
|
|
|
4918
4918
|
const methodName = method.getName();
|
|
4919
4919
|
const classAs = readAsDecorator(cls, `class ${className}`);
|
|
4920
4920
|
const methodAs = readAsDecorator(method, `${className}.${methodName}`);
|
|
4921
|
-
const dtoContract = extractDtoContract(method, sourceFile, project, mixin);
|
|
4921
|
+
const dtoContract = extractDtoContract(method, sourceFile, project, mixin, cls);
|
|
4922
4922
|
const mixinResponse = mixin ? resolveInstantiatedReturnType(cls, methodName) : void 0;
|
|
4923
4923
|
return buildRoute({
|
|
4924
4924
|
className,
|
|
@@ -5199,7 +5199,7 @@ async function watch(config, onChange, options = {}) {
|
|
|
5199
5199
|
}
|
|
5200
5200
|
|
|
5201
5201
|
// src/index.ts
|
|
5202
|
-
var VERSION = "0.
|
|
5202
|
+
var VERSION = "0.21.0";
|
|
5203
5203
|
|
|
5204
5204
|
// src/cli/codegen.ts
|
|
5205
5205
|
async function runCodegen(opts = {}) {
|