|
|
@ -24,7 +24,7 @@ export function createTypeParser(replacerFn = (t: string) => t) { |
|
|
return (originalType: string) => |
|
|
return (originalType: string) => |
|
|
flattenUnionTypes([], originalType) |
|
|
flattenUnionTypes([], originalType) |
|
|
.map(type => { |
|
|
.map(type => { |
|
|
type = removeTypeModifiers(type); |
|
|
type = removeTypeModifiers(normalizeTypeAnnotations(type)); |
|
|
type = type.replace( |
|
|
type = type.replace( |
|
|
/System\.([0-9A-Za-z]+)/g, |
|
|
/System\.([0-9A-Za-z]+)/g, |
|
|
(_, match) => SYSTEM_TYPES.get(match) ?? strings.camelize(match), |
|
|
(_, match) => SYSTEM_TYPES.get(match) ?? strings.camelize(match), |
|
|
@ -45,11 +45,15 @@ export function flattenUnionTypes(types: string[], type: string) { |
|
|
return types; |
|
|
return types; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
export function removeTypeModifiers(type: string) { |
|
|
export function normalizeTypeAnnotations(type: string) { |
|
|
type = type.startsWith('[') ? type.slice(1, -1) + '[]' : type; |
|
|
type = type.replace(/\[(.+)+\]/g, '$1[]'); |
|
|
return type.replace(/\?/g, ''); |
|
|
return type.replace(/\?/g, ''); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export function removeTypeModifiers(type: string) { |
|
|
|
|
|
return type.replace(/\[\]/g, ''); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
export function createTypesToImportsReducer(solution: string, namespace: string) { |
|
|
export function createTypesToImportsReducer(solution: string, namespace: string) { |
|
|
const mapTypeToImport = createTypeToImportMapper(solution, namespace); |
|
|
const mapTypeToImport = createTypeToImportMapper(solution, namespace); |
|
|
|
|
|
|
|
|
@ -75,13 +79,14 @@ export function createTypesToImportsReducer(solution: string, namespace: string) |
|
|
|
|
|
|
|
|
export function createTypeToImportMapper(solution: string, namespace: string) { |
|
|
export function createTypeToImportMapper(solution: string, namespace: string) { |
|
|
const adaptType = createTypeAdapter(solution); |
|
|
const adaptType = createTypeAdapter(solution); |
|
|
|
|
|
const simplifyType = createTypeSimplifier(solution); |
|
|
|
|
|
|
|
|
return (type: string, isEnum: boolean) => { |
|
|
return (type: string, isEnum: boolean) => { |
|
|
if (!type || type.startsWith('System')) return; |
|
|
if (!type || type.startsWith('System')) return; |
|
|
|
|
|
|
|
|
const modelNamespace = parseNamespace(solution, type); |
|
|
const modelNamespace = parseNamespace(solution, type); |
|
|
const refs = [type]; |
|
|
const refs = [removeTypeModifiers(type)]; |
|
|
const specifiers = [adaptType(type.split('<')[0])]; |
|
|
const specifiers = [adaptType(simplifyType(type).split('<')[0])]; |
|
|
const path = /^Volo\.Abp\.(Application\.Dtos|ObjectExtending)/.test(type) |
|
|
const path = /^Volo\.Abp\.(Application\.Dtos|ObjectExtending)/.test(type) |
|
|
? '@abp/ng.core' |
|
|
? '@abp/ng.core' |
|
|
: isEnum |
|
|
: isEnum |
|
|
|