Environment ABP Framework: 10.6.0 UI: Angular @abp/ng.core: 10.6.0 @abp/ng.schematics: 10.6.0 @volo/abp.ng.audit-logging: 10.6.0 ABP Studio CLI: 3.1.3 Operating system: Windows
Description: I implemented a custom application service endpoint that returns entity change history as: Task<List<EntityChangeWithUsernameDto>>
After generating Angular proxies, the generated EntityChangeWithUsernameDto references EntityChangeDto, but the generated file neither declares nor imports that type. Angular compilation fails with: Cannot find name 'EntityChangeDto'.
There also appears to be a related issue in the generated Audit Logging service: package-provided DTOs are imported from the local generated models file instead of @volo/abp.ng.audit-logging/proxy.
The response to /api/abp/api-definition?includeTypes=true includes contains a complete EntityChangeDto in the types section, including its base type and property definitions.
With the help of ChatGPT I found two problems in @abp/ng.schematics:
VOLO_PACKAGE_PROXY_IMPORTS maps EntityChangeDto and other Audit Logging DTOs to @volo/abp.ng.audit-logging/proxy, so those DTOs are intentionally excluded from local model generation. However, the model import logic skips a referenced type when it shares the model’s C# namespace. This leaves EntityChangeWithUsernameDto without the necessary package import.
The shared createTypeToImportMapper does not apply VOLO_PACKAGE_PROXY_IMPORTS when constructing imports. The model-generation path subsequently applies package resolution, but the service-generation path does not perform that same step.
Made local fixes to utils/model.js and utils/type.js to work around the issue but will need a permanent fix.
3 Answer(s)
-
0
This is a bug/limitation in the Angular proxy generator (
@abp/ng.schematics10.6.0) around package DTO import resolution, and it can surface exactly as you described:- Your custom DTO (
EntityChangeWithUsernameDto) referencesVolo.Abp.AuditLogging.EntityChangeDto. EntityChangeDtois inVOLO_PACKAGE_PROXY_IMPORTS, so it is intentionally not generated into your localmodels.ts.- However, the model import builder can still end up not adding the required
import type { EntityChangeDto } from '@volo/abp.ng.audit-logging/proxy', leaving an unbound type and causingCannot find name 'EntityChangeDto'.
- Your custom DTO (
Verified from the ABP repo:
EntityChangeDtois explicitly mapped to the audit-logging proxy package:
export const VOLO_PACKAGE_PROXY_IMPORTS = new Map<string, string>([ ['Volo.Abp.AuditLogging.EntityChangeDto', '@volo/abp.ng.audit-logging/proxy'], // ... ]);(from
npm/ng-packs/packages/schematics/src/constants/volo.ts)- Workaround (safe & minimal, no schematics patch): ensure your generated DTO file has the correct import by introducing a tiny “bridge” type in your own contract so the generator is forced to import it from the package.
- Create a DTO in your own namespace that directly uses
EntityChangeDtoin a property (not only via inheritance/indirect reference). Example:
- Create a DTO in your own namespace that directly uses
using Volo.Abp.AuditLogging; namespace Acme.MyApp.Audit { public class EntityChangeWithUsernameDto { public EntityChangeDto Change { get; set; } = default!; public string? UserName { get; set; } } }- Change your endpoint to return that DTO shape (composition instead of inheritance/flattening).
- Re-run:
abp generate-proxy -t ngThis typically makes the generator treat the reference as an “external” type and it will import it (and since it’s in
VOLO_PACKAGE_PROXY_IMPORTS, it should import from@volo/abp.ng.audit-logging/proxy).- Alternative workaround (most direct, but requires re-applying after regen): add the missing import manually in the generated file that contains
EntityChangeWithUsernameDto:
import type { EntityChangeDto } from '@volo/abp.ng.audit-logging/proxy';and/or fix wrong service imports that incorrectly point to local
./modelsinstead of the package proxy. This is consistent with what you already did locally.What to do for a permanent fix (upstream):
- The generator already has the mapping (
VOLO_PACKAGE_PROXY_IMPORTS) and also has aresolveAbpPackages(models)step inutils/model.tsthat rewrites import paths for model imports, but the behavior you observed indicates the import collection step can skip adding the import before that resolution can apply. - So this needs to be fixed inside
@abp/ng.schematicsso that:- referenced types that are excluded from local model generation (because they are in
VOLO_PACKAGE_PROXY_IMPORTS) are still imported, even if they share the same C# namespace as the current model; and - service-generation import building applies the same package import mapping logic as model-generation (so services don’t accidentally import audit-logging DTOs from local
./models).
- referenced types that are excluded from local model generation (because they are in
- The generator already has the mapping (
If you want to avoid maintaining a fork, the only “no-regeneration-maintenance” workaround today is the composition DTO approach above (return a DTO that has an
EntityChangeDtoproperty), because it tends to produce stable imports.
(Links omitted because no specific public issue/patch URL was provided in the verified tool context for this exact 10.6.0 scenario.)
This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
EntityChangeWithUsernameDto is not a custom Dto it's an ABP DTO that's part of the audit logging namespace and is the return from IAuditLogsAppService.GetEntityChangesWithUsernameAsync.
Yes, I know it's a bug but just wanted to make sure you're aware of the issue and can provide a permanent fix so that future ABP updates don't override my manual fix
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Hi,
This is a bug in the Angular proxy generator. The fix is in https://github.com/abpframework/abp/pull/26212 and will be in the next release. After you upgrade, you won't need your local changes anymore.
Until then, you can keep your changes. If you want them to stay after reinstalling packages, save them as a patch with
patch-package:yarn add patch-package --dev npx patch-package @abp/ng.schematicsThen add
"postinstall": "patch-package"to thescriptsinpackage.json. If you use npm, install it withnpm install patch-package --save-devinstead. Remove the patch and the script after you upgrade.We've refunded your ticket.
Thanks
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)