Browse Source
Merge pull request #20083 from abpframework/auto-merge/rel-8-2/2783
Merge branch dev with rel-8.2
pull/20092/head
maliming
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with
30 additions and
3 deletions
-
npm/ng-packs/packages/schematics/src/commands/api/index.ts
-
npm/ng-packs/packages/schematics/src/utils/generics.ts
-
npm/ng-packs/packages/schematics/src/utils/model.ts
|
|
|
@ -29,6 +29,7 @@ import { |
|
|
|
sanitizeTypeNames, |
|
|
|
sanitizeControllerTypeNames, |
|
|
|
serializeParameters, |
|
|
|
resolveSelfGenericProps, |
|
|
|
} from '../../utils'; |
|
|
|
import * as cases from '../../utils/text'; |
|
|
|
|
|
|
|
@ -49,6 +50,8 @@ export default function (schema: GenerateProxySchema) { |
|
|
|
const data = readProxyConfig(tree); |
|
|
|
data.types = sanitizeTypeNames(data.types); |
|
|
|
|
|
|
|
resolveSelfGenericProps({ solution, types: data.types }); |
|
|
|
|
|
|
|
const types = data.types; |
|
|
|
const modules = data.modules; |
|
|
|
const serviceType = schema.serviceType || defaultEServiceType; |
|
|
|
|
|
|
|
@ -72,7 +72,7 @@ export function extractSimpleGenerics(sourceType: string) { |
|
|
|
return { |
|
|
|
identifier: getLastSegment(identifier), |
|
|
|
generics: generics.map(getLastSegment), |
|
|
|
array |
|
|
|
array, |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
@ -80,10 +80,10 @@ export function extractGenerics(sourceType: string) { |
|
|
|
const isArray = /\[\]$/.test(sourceType); |
|
|
|
const regex = /(?<identifier>[^<]+)(<(?<generics>.+)>)?/g; |
|
|
|
const { identifier = '', generics = '' } = regex.exec(sourceType)?.groups ?? {}; |
|
|
|
return { |
|
|
|
return { |
|
|
|
identifier, |
|
|
|
generics: generics.split(/,\s*/).filter(Boolean), |
|
|
|
array: isArray ? '[]':'' |
|
|
|
array: isArray ? '[]' : '', |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -201,3 +201,27 @@ export function parseBaseTypeWithGenericTypes(type: string): string[] { |
|
|
|
|
|
|
|
return nodeToText(parsedTypeNode); |
|
|
|
} |
|
|
|
|
|
|
|
export function resolveSelfGenericProps(params: Partial<ModelGeneratorParams>) { |
|
|
|
const { types, solution } = params; |
|
|
|
if (!types || !solution) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
Object.keys(types) |
|
|
|
.filter(f => f.startsWith(solution)) |
|
|
|
.forEach(key => { |
|
|
|
const type = types[key]; |
|
|
|
if (type.genericArguments?.length) { |
|
|
|
type.properties?.map(prop => { |
|
|
|
if (prop.type.includes('<>')) { |
|
|
|
prop.type = prop.type.replace('<>', `<${type.genericArguments!.join(', ')}>`); |
|
|
|
prop.typeSimple = prop.typeSimple.replace( |
|
|
|
'<>', |
|
|
|
`<${type.genericArguments!.join(', ')}>`, |
|
|
|
); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|