diff --git a/npm/ng-packs/packages/schematics/src/constants/volo.ts b/npm/ng-packs/packages/schematics/src/constants/volo.ts index b5a6ae7d20..976f553f44 100644 --- a/npm/ng-packs/packages/schematics/src/constants/volo.ts +++ b/npm/ng-packs/packages/schematics/src/constants/volo.ts @@ -4,6 +4,9 @@ export const VOLO_REMOTE_STREAM_CONTENT = [ 'Volo.Abp.Content.RemoteStreamContent', ]; +export const SAAS_NAMESPACE = 'Volo.Saas'; +export const TENANT_KEY = 'tenant'; + export const VOLO_PACKAGE_PROXY_IMPORTS = new Map([ ['Volo.Abp.Identity.IdentityUserDto', '@volo/abp.ng.identity/proxy'], ['Volo.Abp.Identity.IdentityRoleDto', '@volo/abp.ng.identity/proxy'], @@ -18,8 +21,8 @@ export const VOLO_PACKAGE_PROXY_IMPORTS = new Map([ ['Volo.Chat.ChatConversationDto', '@volo/abp.ng.chat/proxy'], ['Volo.Abp.Gdpr.GdprRequestDto', '@volo/abp.ng.gdpr/proxy'], ['Volo.Saas.Tenants.TenantDto', '@volo/abp.ng.saas/proxy'], - ['Volo.Saas.TenantConnectionStringsDto', '@volo/abp.ng.saas/proxy'], - ['Volo.Saas.EditionDto', '@volo/abp.ng.saas/proxy'], + ['Volo.Saas.Tenants.TenantConnectionStringDto', '@volo/abp.ng.saas/proxy'], + ['Volo.Saas.Tenants.EditionDto', '@volo/abp.ng.saas/proxy'], [ 'Volo.Abp.TextTemplateManagement.TextTemplates.TextTemplateContentDto', '@volo/abp.ng.saas/proxy', diff --git a/npm/ng-packs/packages/schematics/src/utils/model.ts b/npm/ng-packs/packages/schematics/src/utils/model.ts index 7d0182dcf5..d7c118969d 100644 --- a/npm/ng-packs/packages/schematics/src/utils/model.ts +++ b/npm/ng-packs/packages/schematics/src/utils/model.ts @@ -16,7 +16,7 @@ import { extendsSelf, removeTypeModifiers, } from './type'; -import { VOLO_PACKAGE_PROXY_IMPORTS, VOLO_REGEX } from '../constants'; +import { SAAS_NAMESPACE, TENANT_KEY, VOLO_PACKAGE_PROXY_IMPORTS, VOLO_REGEX } from '../constants'; // eslint-disable-next-line @typescript-eslint/no-var-requires const shouldQuote = require('should-quote'); @@ -41,7 +41,7 @@ export function createImportRefsToModelReducer(params: ModelGeneratorParams) { sortInterfaces(interfaces); interfaces.forEach(_interface => { - if (VOLO_REGEX.test(_interface.ref)) return; + if (VOLO_REGEX.test(_interface.ref) || VOLO_PACKAGE_PROXY_IMPORTS.has(_interface.ref)) return; if (types[_interface.ref]!.isEnum) { if (!enums.includes(_interface.ref)) enums.push(_interface.ref); @@ -203,15 +203,12 @@ export function parseBaseTypeWithGenericTypes(type: string): string[] { return nodeToText(parsedTypeNode); } -const tenantKey = 'tenant'; -const saasNamespace = 'Volo.Saas'; - export function resolveAbpPackages(models: Model[]) { for (const model of models) { renamePropForTenant(model.interfaces); model.imports.forEach((imp, i) => { - fixImportName(imp); + fixImportNameForTenant(imp); for (const ref of imp.refs) { const path = VOLO_PACKAGE_PROXY_IMPORTS.get(ref); @@ -226,8 +223,8 @@ export function resolveAbpPackages(models: Model[]) { function renamePropForTenant(interfaces: Interface[]) { for (const inters of interfaces) { for (const prop of inters.properties) { - const isTenant = prop.name.toLocaleLowerCase().includes(tenantKey); - const isSaasDto = prop.refs.filter(f => f.startsWith(saasNamespace)).length > 0; + const isTenant = prop.name.toLocaleLowerCase().includes(TENANT_KEY); + const isSaasDto = prop.refs.filter(f => f.startsWith(SAAS_NAMESPACE)).length > 0; if (isTenant && isSaasDto) { prop.type = 'Saas' + prop.type; @@ -236,9 +233,9 @@ function renamePropForTenant(interfaces: Interface[]) { } } -function fixImportName(imp: Import) { +function fixImportNameForTenant(imp: Import) { imp.specifiers.forEach((spe, index) => { - const isTenant = spe.toLocaleLowerCase().includes(tenantKey); + const isTenant = spe.toLocaleLowerCase().includes(TENANT_KEY); if (isTenant) { imp.specifiers[index] = 'Saas' + spe;