Open Closed

ABP 10.6 Angular proxy generation produces missing or incorrect imports for Audit Logging DTOs #10896


User avatar
0
rshapiro created

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:

  1. 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.

  2. 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.

This issue is similar to issues #20680 and #20741

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

2 Answer(s)
  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent
    • This is a bug/limitation in the Angular proxy generator (@abp/ng.schematics 10.6.0) around package DTO import resolution, and it can surface exactly as you described:

      • Your custom DTO (EntityChangeWithUsernameDto) references Volo.Abp.AuditLogging.EntityChangeDto.
      • EntityChangeDto is in VOLO_PACKAGE_PROXY_IMPORTS, so it is intentionally not generated into your local models.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 causing Cannot find name 'EntityChangeDto'.
    • Verified from the ABP repo: EntityChangeDto is 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.
      1. Create a DTO in your own namespace that directly uses EntityChangeDto in a property (not only via inheritance/indirect reference). Example:
    using Volo.Abp.AuditLogging;
    
         namespace Acme.MyApp.Audit
         {
             public class EntityChangeWithUsernameDto
             {
                 public EntityChangeDto Change { get; set; } = default!;
                 public string? UserName { get; set; }
             }
         }
    
    1. Change your endpoint to return that DTO shape (composition instead of inheritance/flattening).
    2. Re-run:
    abp generate-proxy -t ng
    

    This 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 ./models instead 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 a resolveAbpPackages(models) step in utils/model.ts that 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.schematics so that:
        1. 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
        2. 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).
    • 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 EntityChangeDto property), 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)
  • User Avatar
    0
    rshapiro created

    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)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 28, 2026, 11:44
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.