|
|
|
@ -22,7 +22,7 @@ import { |
|
|
|
} from './type'; |
|
|
|
import { eBindingSourceId } from '../enums'; |
|
|
|
import { camelizeHyphen } from './text'; |
|
|
|
import {VOLO_REMOTE_STREAM_CONTENT} from "../constants"; |
|
|
|
import { VOLO_REMOTE_STREAM_CONTENT } from '../constants'; |
|
|
|
|
|
|
|
export function serializeParameters(parameters: Property[]) { |
|
|
|
return parameters.map(p => p.name + p.optional + ': ' + p.type + p.default, '').join(', '); |
|
|
|
@ -39,9 +39,12 @@ export function createControllerToServiceMapper({ |
|
|
|
const name = controller.controllerName; |
|
|
|
const namespace = parseNamespace(solution, controller.type); |
|
|
|
const actions = Object.values(controller.actions); |
|
|
|
const typeWithoutIRemoteStreamContent = getTypesWithoutIRemoteStreamContent(types) |
|
|
|
const imports = actions.reduce(createActionToImportsReducer(solution, typeWithoutIRemoteStreamContent, namespace), []); |
|
|
|
imports.push(new Import({ path: '@abp/ng.core', specifiers: ['RestService'] })); |
|
|
|
const typeWithoutIRemoteStreamContent = getTypesWithoutIRemoteStreamContent(types); |
|
|
|
const imports = actions.reduce( |
|
|
|
createActionToImportsReducer(solution, typeWithoutIRemoteStreamContent, namespace), |
|
|
|
[], |
|
|
|
); |
|
|
|
imports.push(new Import({ path: '@abp/ng.core', specifiers: ['RestService', 'Rest'] })); |
|
|
|
imports.push(new Import({ path: '@angular/core', specifiers: ['Injectable'] })); |
|
|
|
sortImports(imports); |
|
|
|
const methods = actions.map(mapActionToMethod); |
|
|
|
@ -51,9 +54,9 @@ export function createControllerToServiceMapper({ |
|
|
|
} |
|
|
|
|
|
|
|
function getTypesWithoutIRemoteStreamContent(types: Record<string, Type>) { |
|
|
|
const newType = {...types} |
|
|
|
delete newType[VOLO_REMOTE_STREAM_CONTENT] |
|
|
|
return newType |
|
|
|
const newType = { ...types }; |
|
|
|
delete newType[VOLO_REMOTE_STREAM_CONTENT]; |
|
|
|
return newType; |
|
|
|
} |
|
|
|
function sortMethods(methods: Method[]) { |
|
|
|
methods.sort((a, b) => (a.signature.name > b.signature.name ? 1 : -1)); |
|
|
|
@ -76,7 +79,7 @@ export function createActionToBodyMapper() { |
|
|
|
return ({ httpMethod, parameters, returnValue, url }: Action) => { |
|
|
|
const responseType = adaptType(returnValue.typeSimple); |
|
|
|
const responseTypeWithNamespace = returnValue.typeSimple; |
|
|
|
const body = new Body({ method: httpMethod, responseType, url ,responseTypeWithNamespace}); |
|
|
|
const body = new Body({ method: httpMethod, responseType, url, responseTypeWithNamespace }); |
|
|
|
|
|
|
|
parameters.forEach(body.registerActionParameter); |
|
|
|
|
|
|
|
@ -90,6 +93,8 @@ export function createActionToSignatureMapper() { |
|
|
|
return (action: Action) => { |
|
|
|
const signature = new Signature({ name: getMethodNameFromAction(action) }); |
|
|
|
const versionParameter = getVersionParameter(action); |
|
|
|
const restConfig = new Property({ name: 'config', type: 'Partial<Rest.Config>' }); |
|
|
|
restConfig.setOptional(true); |
|
|
|
const parameters = [ |
|
|
|
...action.parametersOnMethod, |
|
|
|
...(versionParameter ? [versionParameter] : []), |
|
|
|
@ -101,6 +106,7 @@ export function createActionToSignatureMapper() { |
|
|
|
parameter.setOptional(p.isOptional); |
|
|
|
return parameter; |
|
|
|
}); |
|
|
|
signature.parameters.push(restConfig); |
|
|
|
|
|
|
|
return signature; |
|
|
|
}; |
|
|
|
|