From c4de3a000682b0cbe7c2c5c728439590e6d26814 Mon Sep 17 00:00:00 2001 From: Norbert Csaba Herczeg Date: Fri, 24 Nov 2023 20:09:35 +0100 Subject: [PATCH] JNG-4838 re-format templates to support no formatter operation --- .../src/main/resources/model/class.ts.hbs | 14 +- .../src/main/resources/model/enum.ts.hbs | 4 +- .../main/resources/model/modelIndex.ts.hbs | 5 +- .../src/main/resources/model/operation.ts.hbs | 6 +- .../src/main/resources/rest/filterable.ts.hbs | 4 +- .../src/main/resources/rest/mask.ts.hbs | 17 +- .../main/resources/rest/maskBuilder.ts.hbs | 25 +- .../resources/rest/queryCustomizer.ts.hbs | 9 +- .../src/main/resources/rest/restIndex.ts.hbs | 8 +- .../data-axios/accessServiceImpl.ts.hbs | 105 +-- .../resources/data-axios/axiosProvider.ts.hbs | 14 +- .../data-axios/classServiceImpl.ts.hbs | 514 +++++------ .../implementationInstancesExporter.ts.hbs | 18 +- .../data-axios/judoAxiosProvider.ts.hbs | 46 +- .../data-axios/judoAxiosService.ts.hbs | 36 +- .../data-axios/relationServiceImpl.ts.hbs | 824 +++++++++--------- .../action_group_test__god/pom.xml | 22 - .../data-service/accessService.ts.hbs | 11 +- .../data-service/classService.ts.hbs | 148 ++-- .../data-service/relationService.ts.hbs | 202 ++--- .../data-service/serviceIndex.ts.hbs | 4 +- 21 files changed, 978 insertions(+), 1058 deletions(-) diff --git a/judo-ui-typescript-rest-api/src/main/resources/model/class.ts.hbs b/judo-ui-typescript-rest-api/src/main/resources/model/class.ts.hbs index 3e1d702..6647714 100644 --- a/judo-ui-typescript-rest-api/src/main/resources/model/class.ts.hbs +++ b/judo-ui-typescript-rest-api/src/main/resources/model/class.ts.hbs @@ -2,25 +2,23 @@ import type { JudoStored } from '@judo/data-api-common'; {{# each (getImportTokens application.actor classType) as | token | }} - import { {{ @key }} } from './{{ token }}'; +import { {{ @key }} } from './{{ token }}'; {{/ each }} export interface {{ classDataName classType '' }} { {{# each classType.attributes as | attribute | }} - {{ attribute.name }}{{# if attribute.isRequired }}: {{ else }}?: null | {{/ if}}{{ typescriptType attribute.dataType }}; + {{ attribute.name }}{{# if attribute.isRequired }}: {{ else }}?: null | {{/ if}}{{ typescriptType attribute.dataType }}; {{/ each }} - {{# each classType.relations as | relation | }} - {{ relation.name }}{{# if relation.isOptional }}?: null | {{ else }}:{{/ if}}{{{ getRelationType relation }}}; + {{ relation.name }}{{# if relation.isOptional }}?: null | {{ else }}:{{/ if}}{{{ getRelationType relation }}}; {{/ each }} - } + {{# unless classType.attributes.isEmpty }} - export type {{ classDataName classType '' }}Attributes = '{{{ getClassTypeAttributes classType }}}'; +export type {{ classDataName classType '' }}Attributes = '{{{ getClassTypeAttributes classType }}}'; {{/ unless }} - {{# unless (classTypeRelationsIsEmpty classType) }} - export type {{ classDataName classType '' }}Relations = '{{{ getClassTypeRelations classType }}}'; +export type {{ classDataName classType '' }}Relations = '{{{ getClassTypeRelations classType }}}'; {{/ unless }} export interface {{ classDataName classType 'Stored' }} extends JudoStored<{{ classDataName classType '' }}>, {{ classDataName classType '' }} {}; diff --git a/judo-ui-typescript-rest-api/src/main/resources/model/enum.ts.hbs b/judo-ui-typescript-rest-api/src/main/resources/model/enum.ts.hbs index 9025a03..dff6642 100644 --- a/judo-ui-typescript-rest-api/src/main/resources/model/enum.ts.hbs +++ b/judo-ui-typescript-rest-api/src/main/resources/model/enum.ts.hbs @@ -1,9 +1,7 @@ {{> fragment.header.hbs }} export enum {{ restParamName enumerationType }} { - {{# each enumerationType.members as | member | }} - {{ member.name }} = '{{ member.name }}', + {{ member.name }} = '{{ member.name }}', {{/ each}} - } diff --git a/judo-ui-typescript-rest-api/src/main/resources/model/modelIndex.ts.hbs b/judo-ui-typescript-rest-api/src/main/resources/model/modelIndex.ts.hbs index 0ac0faf..b556744 100644 --- a/judo-ui-typescript-rest-api/src/main/resources/model/modelIndex.ts.hbs +++ b/judo-ui-typescript-rest-api/src/main/resources/model/modelIndex.ts.hbs @@ -1,9 +1,8 @@ {{> fragment.header.hbs }} {{# each (getEnumerationTypes application) as | fileName | }} - export * from './{{ restParamName fileName }}'; +export * from './{{ restParamName fileName }}'; {{/ each }} - {{# each (getClassTypes application) as | fileName | }} - export * from './{{ classDataName fileName '' }}'; +export * from './{{ classDataName fileName '' }}'; {{/ each }} diff --git a/judo-ui-typescript-rest-api/src/main/resources/model/operation.ts.hbs b/judo-ui-typescript-rest-api/src/main/resources/model/operation.ts.hbs index 23fedda..d76234b 100644 --- a/judo-ui-typescript-rest-api/src/main/resources/model/operation.ts.hbs +++ b/judo-ui-typescript-rest-api/src/main/resources/model/operation.ts.hbs @@ -1,13 +1,11 @@ {{> fragment.header.hbs }} {{# each (getOperationTypeFaults operationType) as | fault |}} - import { {{ getFaultTargets fault '' }} } from './{{ getFaultTargets fault '' }}'; +import { {{ getFaultTargets fault '' }} } from './{{ getFaultTargets fault '' }}'; {{/ each }} export interface {{ operationType.FaultContainerName }} { - {{# each operationType.faults as | fault | }} - '{{ fault.target.name.faultKey }}'?: null | {{ getFaultTargets fault '' }}; + {{ fault.target.name.faultKey }}?: null | {{ getFaultTargets fault '' }}; {{/each }} - } diff --git a/judo-ui-typescript-rest-api/src/main/resources/rest/filterable.ts.hbs b/judo-ui-typescript-rest-api/src/main/resources/rest/filterable.ts.hbs index cbb02dc..e3dbc8a 100644 --- a/judo-ui-typescript-rest-api/src/main/resources/rest/filterable.ts.hbs +++ b/judo-ui-typescript-rest-api/src/main/resources/rest/filterable.ts.hbs @@ -3,6 +3,6 @@ import { {{ joinModelImports dataType }} } from '../model'; export interface {{ restFilterName dataType }} { - value: {{# if (isEnumType dataType) }}{{ restParamName dataType }}{{ else }}{{ typescriptType dataType }}{{/ if }}; - operator: {{ typescriptType dataType.operator }}; + value: {{# if (isEnumType dataType) }}{{ restParamName dataType }}{{ else }}{{ typescriptType dataType }}{{/ if }}; + operator: {{ typescriptType dataType.operator }}; } diff --git a/judo-ui-typescript-rest-api/src/main/resources/rest/mask.ts.hbs b/judo-ui-typescript-rest-api/src/main/resources/rest/mask.ts.hbs index 413a55b..e1882fc 100644 --- a/judo-ui-typescript-rest-api/src/main/resources/rest/mask.ts.hbs +++ b/judo-ui-typescript-rest-api/src/main/resources/rest/mask.ts.hbs @@ -2,21 +2,20 @@ import { MaskBuilder{{# if (isGreaterThan (getAggregatedRelationsSize classType) 0) }}, RelationMaskBuilder{{/ if }} } from './MaskBuilder'; import { {{ joinModelImportTokens ( modelImportTokens classType ) }} } from '../model'; - {{# each (getNotClassTypeRelations (getUniqueRelations classType) classType) as | relation | }} - import { {{ getRelationBuilderNames relation }} } from './{{ classDataName relation.target "MaskBuilder" }}'; +import { {{ getRelationBuilderNames relation }} } from './{{ classDataName relation.target "MaskBuilder" }}'; {{/ each}} {{# each (getAggregatedRelations classType) as | relation | }} - export class {{ relationBuilderName relation classType "MaskBuilder" }} extends RelationMaskBuilder { - constructor(protected props: Array<{{ getRelationBuilderNamesWithPipe relation }}>) { - super('{{ relation.name }}', props); - } +export class {{ relationBuilderName relation classType "MaskBuilder" }} extends RelationMaskBuilder { + constructor(protected props: Array<{{ getRelationBuilderNamesWithPipe relation }}>) { + super('{{ relation.name }}', props); + } } {{/ each }} export class {{ classDataName classType "MaskBuilder" }} extends MaskBuilder { - constructor(protected props: Array<{{ generateBuilderProps classType }}>) { - super(props); - } + constructor(protected props: Array<{{ generateBuilderProps classType }}>) { + super(props); + } } diff --git a/judo-ui-typescript-rest-api/src/main/resources/rest/maskBuilder.ts.hbs b/judo-ui-typescript-rest-api/src/main/resources/rest/maskBuilder.ts.hbs index dfa2327..118a428 100644 --- a/judo-ui-typescript-rest-api/src/main/resources/rest/maskBuilder.ts.hbs +++ b/judo-ui-typescript-rest-api/src/main/resources/rest/maskBuilder.ts.hbs @@ -1,21 +1,22 @@ {{> fragment.header.hbs }} export class MaskBuilder { - constructor(protected props: Array) {} + constructor(protected props: Array) {} - build(): string { - const distinctStrings = Array.from(new Set(this.props.filter(p => typeof p === 'string'))); - const distinctBuilders = Array.from(new Set(this.props.filter(p => p instanceof MaskBuilder).map(p => (p as MaskBuilder).build()))); + build(): string { + const distinctStrings = Array.from(new Set(this.props.filter(p => typeof p === 'string'))); + const distinctBuilders = Array.from(new Set(this.props.filter(p => p instanceof MaskBuilder).map(p => (p as MaskBuilder).build()))); - return `{${[...distinctStrings, ...distinctBuilders].join(',')}}` - } + return `{${[...distinctStrings, ...distinctBuilders].join(',')}}` + } } + export class RelationMaskBuilder extends MaskBuilder { - constructor(protected name: string, protected props: Array) { - super(props); - } + constructor(protected name: string, protected props: Array) { + super(props); + } - build(): string { - return `${this.name}${super.build()}` - } + build(): string { + return `${this.name}${super.build()}` + } } diff --git a/judo-ui-typescript-rest-api/src/main/resources/rest/queryCustomizer.ts.hbs b/judo-ui-typescript-rest-api/src/main/resources/rest/queryCustomizer.ts.hbs index 43e3d3c..0a083d2 100644 --- a/judo-ui-typescript-rest-api/src/main/resources/rest/queryCustomizer.ts.hbs +++ b/judo-ui-typescript-rest-api/src/main/resources/rest/queryCustomizer.ts.hbs @@ -2,15 +2,14 @@ import type { QueryCustomizer } from '@judo/data-api-common'; import { {{ classDataName classType "" }} } from '../model/{{ classDataName classType "" }}'; - {{# each (getImportTokensForQueries classType) as | token | }} - import { {{ token }} } from './{{ token }}'; +import { {{ token }} } from './{{ token }}'; {{/ each}} export interface {{ classDataName classType "QueryCustomizer" }} extends QueryCustomizer<{{ classDataName classType "" }}>{ {{# each classType.attributes as |attribute| }} - {{# if attribute.isFilterable }} - {{ attribute.name }}?: Array<{{ restFilterName attribute.dataType }}>; - {{/ if}} +{{# if attribute.isFilterable }} + {{ attribute.name }}?: Array<{{ restFilterName attribute.dataType }}>; +{{/ if}} {{/ each}} } diff --git a/judo-ui-typescript-rest-api/src/main/resources/rest/restIndex.ts.hbs b/judo-ui-typescript-rest-api/src/main/resources/rest/restIndex.ts.hbs index 25eca12..d88c50b 100644 --- a/judo-ui-typescript-rest-api/src/main/resources/rest/restIndex.ts.hbs +++ b/judo-ui-typescript-rest-api/src/main/resources/rest/restIndex.ts.hbs @@ -1,14 +1,12 @@ {{> fragment.header.hbs }} {{# each (getClassTypes application) as | fileName | }} - export * from './{{ classDataName fileName "QueryCustomizer" }}'; +export * from './{{ classDataName fileName "QueryCustomizer" }}'; {{/ each }} - {{# each (getClassTypes application) as | fileName | }} - export * from './{{ classDataName fileName "MaskBuilder" }}'; +export * from './{{ classDataName fileName "MaskBuilder" }}'; {{/ each }} - {{# each (getFilterableDataTypes application) as | fileName | }} - export * from './{{ restFilterName fileName }}'; +export * from './{{ restFilterName fileName }}'; {{/ each }} export * from './MaskBuilder'; diff --git a/judo-ui-typescript-rest-axios/src/main/resources/data-axios/accessServiceImpl.ts.hbs b/judo-ui-typescript-rest-axios/src/main/resources/data-axios/accessServiceImpl.ts.hbs index e53a7a4..92026d4 100644 --- a/judo-ui-typescript-rest-axios/src/main/resources/data-axios/accessServiceImpl.ts.hbs +++ b/judo-ui-typescript-rest-axios/src/main/resources/data-axios/accessServiceImpl.ts.hbs @@ -8,60 +8,65 @@ import { AccessService } from '../data-service'; export class AccessServiceImpl extends JudoAxiosService implements AccessService { {{# if application.principal }} - /** - * @throws {AxiosError} With data containing {@link Array} for status codes: 401, 403. - * @return {Promise<{{ classDataName application.principal "" }}>} - */ - async getPrincipal(): Promise<{{ classDataName application.principal "Stored" }}> { - const response = await this.axios.get(this.getPathForActor('{{ rootPathForApp application }}/~principal')); + /** + * @throws {AxiosError} With data containing {@link Array} for status codes: 401, 403. + * @return {Promise<{{ classDataName application.principal "" }}>} + */ + async getPrincipal(): Promise<{{ classDataName application.principal "Stored" }}> { + const response = await this.axios.get(this.getPathForActor('{{ rootPathForApp application }}/~principal')); - return response.data; - } + return response.data; + } {{/ if }} - /** - * @throws {AxiosError} With data containing {@link Array} for status codes: 401, 403. - * @return {Promise} - */ - async getMetaData(): Promise { - const response = await this.axios.get(this.getPathForActor('{{ rootPathForApp application }}/~meta')); - return response.data; + /** + * @throws {AxiosError} With data containing {@link Array} for status codes: 401, 403. + * @return {Promise} + */ + async getMetaData(): Promise { + const response = await this.axios.get(this.getPathForActor('{{ rootPathForApp application }}/~meta')); + return response.data; + } + + /** + * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. + * @return {Promise} + */ + async uploadFile(attributePath: string, file: File): Promise { + const responseToken: any = await this.axios.post(this.getPathForActor(attributePath + '/~upload-token')); + + if (!responseToken) { + throw new Error(`Could not upload file, could not obtain Upload Token!`); } - /** - * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. - * @return {Promise} - */ - async uploadFile(attributePath: string, file: File): Promise { - const responseToken: any = await this.axios.post(this.getPathForActor(attributePath + '/~upload-token')); - if (!responseToken) { - throw new Error(`Could not upload file, could not obtain Upload Token!`); - } - const formData = new FormData(); - formData.append(file.name, file); - const response = await this.axios.post(this.axiosProvider.getFilePath('upload'), formData, { - headers: { - 'Content-Type': 'multipart/form-data', - 'X-Token': responseToken.data.token, - }, - }); - if (response.status === 200) { - return response; - } else { - throw new Error(`Unexpected upload response: ${response.status}\n${response}`); - } - } - /** - * @throws {AxiosError} With data containing {@link Array} for status codes: 401, 403. - * @return {Promise} - */ - async downloadFile(downloadToken: string, disposition: 'inline' | 'attachment'): Promise { - const response = await this.axios.get(`${this.axiosProvider.getFilePath('download')}?disposition=${disposition}`, { - responseType: 'blob', - headers: { - 'X-Token': downloadToken, - }, - }); - return response; + const formData = new FormData(); + formData.append(file.name, file); + + const response = await this.axios.post(this.axiosProvider.getFilePath('upload'), formData, { + headers: { + 'Content-Type': 'multipart/form-data', + 'X-Token': responseToken.data.token, + }, + }); + + if (response.status === 200) { + return response; + } else { + throw new Error(`Unexpected upload response: ${response.status}\n${response}`); } + } + + /** + * @throws {AxiosError} With data containing {@link Array} for status codes: 401, 403. + * @return {Promise} + */ + async downloadFile(downloadToken: string, disposition: 'inline' | 'attachment'): Promise { + const response = await this.axios.get(`${this.axiosProvider.getFilePath('download')}?disposition=${disposition}`, { + responseType: 'blob', + headers: { + 'X-Token': downloadToken, + }, + }); + return response; + } } diff --git a/judo-ui-typescript-rest-axios/src/main/resources/data-axios/axiosProvider.ts.hbs b/judo-ui-typescript-rest-axios/src/main/resources/data-axios/axiosProvider.ts.hbs index 13702fd..7b4daeb 100644 --- a/judo-ui-typescript-rest-axios/src/main/resources/data-axios/axiosProvider.ts.hbs +++ b/judo-ui-typescript-rest-axios/src/main/resources/data-axios/axiosProvider.ts.hbs @@ -3,14 +3,14 @@ import type { AxiosInstance } from 'axios'; export interface JudoAxiosProviderInitData { - axios: AxiosInstance; - basePathFactory?: () => string; - filePathFactory?: () => string; + axios: AxiosInstance; + basePathFactory?: () => string; + filePathFactory?: () => string; } export interface AxiosProvider { - init(data: JudoAxiosProviderInitData): void; - getAxios(): AxiosInstance; - getBasePath(suffix?: string): string; - getFilePath(suffix?: string): string; + init(data: JudoAxiosProviderInitData): void; + getAxios(): AxiosInstance; + getBasePath(suffix?: string): string; + getFilePath(suffix?: string): string; } diff --git a/judo-ui-typescript-rest-axios/src/main/resources/data-axios/classServiceImpl.ts.hbs b/judo-ui-typescript-rest-axios/src/main/resources/data-axios/classServiceImpl.ts.hbs index a891eac..362b0b7 100644 --- a/judo-ui-typescript-rest-axios/src/main/resources/data-axios/classServiceImpl.ts.hbs +++ b/judo-ui-typescript-rest-axios/src/main/resources/data-axios/classServiceImpl.ts.hbs @@ -10,279 +10,279 @@ import type { {{ serviceClassName classType }} } from '../data-service'; */ export class {{ serviceClassName classType }}Impl extends JudoAxiosService implements {{ serviceClassName classType }} { {{# if classType.isTemplateable }} - /** - * @throws {AxiosError} With data containing {@link Array} for status codes: 401, 403. - */ - async getTemplate(): Promise<{{ classDataName classType "" }}> { - const path = '{{ restPath classType '/~template' '' '' }}'; - const response = await this.axios.get(this.getPathForActor(path)); - - return response.data; - } + /** + * @throws {AxiosError} With data containing {@link Array} for status codes: 401, 403. + */ + async getTemplate(): Promise<{{ classDataName classType "" }}> { + const path = '{{ restPath classType '/~template' '' '' }}'; + const response = await this.axios.get(this.getPathForActor(path)); + + return response.data; + } {{/ if }} {{# if classType.isMapped }} - /** - * @throws {AxiosError} With data containing {@link Array} for status codes: 401, 403. - */ - async refresh(target: JudoIdentifiable<{{ classDataName classType "" }}>, queryCustomizer?:{{ classDataName classType "QueryCustomizer" }}): Promise<{{ classDataName classType "Stored" }}> { - const path = '{{ restPath classType '/~get' '' '' }}'; - const response = await this.axios.post(this.getPathForActor(path), queryCustomizer, { - headers: { - 'X-Judo-SignedIdentifier': target.__signedIdentifier, - }, - }); - - return response.data; - } + /** + * @throws {AxiosError} With data containing {@link Array} for status codes: 401, 403. + */ + async refresh(target: JudoIdentifiable<{{ classDataName classType "" }}>, queryCustomizer?:{{ classDataName classType "QueryCustomizer" }}): Promise<{{ classDataName classType "Stored" }}> { + const path = '{{ restPath classType '/~get' '' '' }}'; + const response = await this.axios.post(this.getPathForActor(path), queryCustomizer, { + headers: { + 'X-Judo-SignedIdentifier': target.__signedIdentifier, + }, + }); + + return response.data; + } {{/ if }} {{# if classType.isDeletable }} - /** - * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. - */ - async delete(target: JudoIdentifiable<{{ classDataName classType "" }}>): Promise { - const path = '{{ restPath classType '/~delete' '' '' }}'; - await this.axios.post(this.getPathForActor(path), undefined, { - headers: { - 'X-Judo-SignedIdentifier': target.__signedIdentifier, - }, - }); - } + /** + * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. + */ + async delete(target: JudoIdentifiable<{{ classDataName classType "" }}>): Promise { + const path = '{{ restPath classType '/~delete' '' '' }}'; + await this.axios.post(this.getPathForActor(path), undefined, { + headers: { + 'X-Judo-SignedIdentifier': target.__signedIdentifier, + }, + }); + } {{/ if }} {{# if classType.isUpdatable }} - /** - * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. - */ - async update(target: Partial<{{ classDataName classType "Stored" }}>): Promise<{{ classDataName classType "Stored" }}> { - const path = '{{ restPath classType '/~update' '' '' }}'; - const response = await this.axios.post(this.getPathForActor(path), target, { - headers: { - 'X-Judo-SignedIdentifier': target.__signedIdentifier!, - }, - }); - - return response.data; - } + /** + * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. + */ + async update(target: Partial<{{ classDataName classType "Stored" }}>): Promise<{{ classDataName classType "Stored" }}> { + const path = '{{ restPath classType '/~update' '' '' }}'; + const response = await this.axios.post(this.getPathForActor(path), target, { + headers: { + 'X-Judo-SignedIdentifier': target.__signedIdentifier!, + }, + }); + + return response.data; + } {{/ if }} {{# each classType.relations as | relation | }} - {{# if relation.target.isTemplateable }} - async getTemplateFor{{ firstToUpper relation.name }}(): Promise<{{ classDataName relation.target "" }}> { - const path = '{{ restPath relation.target "/~template" "" "" }}'; - const response = await this.axios.get(this.getPathForActor(path)); - - return response.data; - } - {{/ if }} - - {{# if relation.isCreatable }} - /** - * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. - */ - async create{{ firstToUpper relation.name }}(owner: JudoIdentifiable<{{ classDataName classType "" }}>, target: JudoIdentifiable<{{ classDataName relation.target "" }}>): Promise<{{ classDataName relation.target "Stored" }}> { - const path = '{{ restPath classType "/~update/" relation.name "/~create" }}'; - const response = await this.axios.post(this.getPathForActor(path), target, { - headers: { - 'X-Judo-SignedIdentifier': owner.__signedIdentifier!, - }, - }); - - return response.data; - } - {{/ if }} - - {{# if relation.isRefreshable }} - /** - * @throws {AxiosError} With data containing {@link Array} for status codes: 401, 403. - */ - async {{# if relation.isCollection }}list{{ else }}get{{/ if }}{{ firstToUpper relation.name }}(target: JudoIdentifiable<{{ classDataName classType "" }}>, queryCustomizer?:{{ classDataName relation.target "QueryCustomizer" }}): Promise<{{# if relation.isCollection }}Array<{{/ if }}{{ classDataName relation.target "Stored" }}{{# if relation.isCollection }}>{{/ if }}> { - const path = '{{ restPath classType "/" relation.name "/~" }}{{# if relation.isCollection }}list{{ else }}get{{/ if }}'; - const response = await this.axios.post(this.getPathForActor(path), queryCustomizer ?? {}, { - headers: { - 'X-Judo-SignedIdentifier': target.__signedIdentifier!, - }, - }); - - return response.data; - } - {{/ if }} - - /** - * @throws {AxiosError} With data containing {@link Array} for status codes: 401, 403. - */ - async getRangeFor{{ firstToUpper relation.name }}(owner?: JudoIdentifiable<{{ classDataName classType "" }}> | {{ classDataName classType "" }}, queryCustomizer?:{{ classDataName relation.target "QueryCustomizer" }}): Promise> { - const path = '{{ restPath classType "/" relation.name "/~range" }}'; - const response = await this.axios.post(this.getPathForActor(path), { owner: owner ?? {}, queryCustomizer: queryCustomizer ?? {} }); - - return response.data; + {{# if relation.target.isTemplateable }} + async getTemplateFor{{ firstToUpper relation.name }}(): Promise<{{ classDataName relation.target "" }}> { + const path = '{{ restPath relation.target "/~template" "" "" }}'; + const response = await this.axios.get(this.getPathForActor(path)); + + return response.data; + } + {{/ if }} + + {{# if relation.isCreatable }} + /** + * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. + */ + async create{{ firstToUpper relation.name }}(owner: JudoIdentifiable<{{ classDataName classType "" }}>, target: JudoIdentifiable<{{ classDataName relation.target "" }}>): Promise<{{ classDataName relation.target "Stored" }}> { + const path = '{{ restPath classType "/~update/" relation.name "/~create" }}'; + const response = await this.axios.post(this.getPathForActor(path), target, { + headers: { + 'X-Judo-SignedIdentifier': owner.__signedIdentifier!, + }, + }); + + return response.data; + } + {{/ if }} + + {{# if relation.isRefreshable }} + /** + * @throws {AxiosError} With data containing {@link Array} for status codes: 401, 403. + */ + async {{# if relation.isCollection }}list{{ else }}get{{/ if }}{{ firstToUpper relation.name }}(target: JudoIdentifiable<{{ classDataName classType "" }}>, queryCustomizer?:{{ classDataName relation.target "QueryCustomizer" }}): Promise<{{# if relation.isCollection }}Array<{{/ if }}{{ classDataName relation.target "Stored" }}{{# if relation.isCollection }}>{{/ if }}> { + const path = '{{ restPath classType "/" relation.name "/~" }}{{# if relation.isCollection }}list{{ else }}get{{/ if }}'; + const response = await this.axios.post(this.getPathForActor(path), queryCustomizer ?? {}, { + headers: { + 'X-Judo-SignedIdentifier': target.__signedIdentifier!, + }, + }); + + return response.data; + } + {{/ if }} + + /** + * @throws {AxiosError} With data containing {@link Array} for status codes: 401, 403. + */ + async getRangeFor{{ firstToUpper relation.name }}(owner?: JudoIdentifiable<{{ classDataName classType "" }}> | {{ classDataName classType "" }}, queryCustomizer?:{{ classDataName relation.target "QueryCustomizer" }}): Promise> { + const path = '{{ restPath classType "/" relation.name "/~range" }}'; + const response = await this.axios.post(this.getPathForActor(path), { owner: owner ?? {}, queryCustomizer: queryCustomizer ?? {} }); + + return response.data; + } + + {{# if relation.isSetable }} + /** + * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. + */ + async set{{ firstToUpper relation.name }}(owner: JudoIdentifiable<{{ classDataName classType "" }}>, selected:{{# if relation.isCollection }}Array<{{/ if }}JudoIdentifiable<{{ classDataName relation.target "" }}>{{# if relation.isCollection }}>{{/ if }}): Promise { + const path = '{{ restPath classType "/~update/" relation.name "/~set" }}'; + await this.axios.post(this.getPathForActor(path), selected, { + headers: { + 'X-Judo-SignedIdentifier': owner.__signedIdentifier!, + }, + }); + } + {{/ if }} + + {{# if relation.isUnsetable }} + /** + * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. + */ + async unset{{ firstToUpper relation.name }}(owner: JudoIdentifiable<{{ classDataName classType "" }}>): Promise { + const path = '{{ restPath classType "/~update/" relation.name "/~unset" }}'; + await this.axios.post(this.getPathForActor(path), undefined, { + headers: { + 'X-Judo-SignedIdentifier': owner.__signedIdentifier!, + }, + }); + } + {{/ if }} + + {{# if relation.isAddable }} + /** + * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. + */ + async add{{ firstToUpper relation.name }}(owner: JudoIdentifiable<{{ classDataName classType "" }}>, selected: Array>): Promise { + const path = '{{ restPath classType "/~update/" relation.name "/~add" }}'; + await this.axios.post(this.getPathForActor(path), selected, { + headers: { + 'X-Judo-SignedIdentifier': owner.__signedIdentifier!, + }, + }); + } + {{/ if }} + + {{# if relation.isRemovable }} + /** + * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. + */ + async remove{{ firstToUpper relation.name }}(owner: JudoIdentifiable<{{ classDataName classType "" }}>, selected: Array>): Promise { + const path = '{{ restPath classType "/~update/" relation.name "/~remove" }}'; + await this.axios.post(this.getPathForActor(path), selected, { + headers: { + 'X-Judo-SignedIdentifier': owner.__signedIdentifier!, + }, + }); + } + {{/ if }} + + {{# if relation.isDeletable }} + /** + * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. + */ + async delete{{ firstToUpper relation.name }}(target: JudoIdentifiable<{{ classDataName relation.target "" }}>): Promise { + const path = '{{ restPath relation.target "/~delete" "" "" }}'; + await this.axios.post(this.getPathForActor(path), undefined, { + headers: { + 'X-Judo-SignedIdentifier': target.__signedIdentifier, + }, + }); + } + {{/ if }} + + {{# each relation.target.operations as | operation | }} + /** + * @throws {AxiosError}{{# if (hasFaults operation) }}With data containing {@link{{ faultContainerName operation }} } for business related errors (status code is 422).{{/ if }} + * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. + */ + async {{ operation.name }}For{{ firstToUpper relation.name }}({{# if operation.isMapped }}owner: JudoIdentifiable<{{ classDataName relation.target "" }}>{{/ if }}{{# if operation.input }}{{# if operation.isMapped }},{{/ if }}target:{{ classDataName operation.input.target "" }}{{/ if }}): Promise<{{# if operation.output }}{{ classDataName operation.output.target "Stored" }}{{ else }}void{{/ if }}> { + const path = '{{ operationRestPath relation.target operation '' }}'; + const response = await this.axios.post(this.getPathForActor(path){{# if operation.input }}, target{{ else }}, undefined{{/ if }}{{# if operation.isMapped }}, { + headers: { + 'X-Judo-SignedIdentifier': owner.__signedIdentifier!, + }, + } {{/ if }}); + + {{# if operation.output }} + return response.data; + {{/ if }} + } + + {{# if operation.input }} + {{# if operation.input.target.isTemplateable }} + async getTemplateOn{{ firstToUpper operation.name }}For{{ firstToUpper relation.name }}(): Promise<{{ classDataName operation.input.target "" }}> { + const path = '{{ restPath operation.input.target "/~template" "" "" }}'; + const response = await this.axios.get(this.getPathForActor(path)); + + return response.data; } - - {{# if relation.isSetable }} - /** - * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. - */ - async set{{ firstToUpper relation.name }}(owner: JudoIdentifiable<{{ classDataName classType "" }}>, selected:{{# if relation.isCollection }}Array<{{/ if }}JudoIdentifiable<{{ classDataName relation.target "" }}>{{# if relation.isCollection }}>{{/ if }}): Promise { - const path = '{{ restPath classType "/~update/" relation.name "/~set" }}'; - await this.axios.post(this.getPathForActor(path), selected, { - headers: { - 'X-Judo-SignedIdentifier': owner.__signedIdentifier!, - }, - }); - } - {{/ if }} - - {{# if relation.isUnsetable }} - /** - * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. - */ - async unset{{ firstToUpper relation.name }}(owner: JudoIdentifiable<{{ classDataName classType "" }}>): Promise { - const path = '{{ restPath classType "/~update/" relation.name "/~unset" }}'; - await this.axios.post(this.getPathForActor(path), undefined, { - headers: { - 'X-Judo-SignedIdentifier': owner.__signedIdentifier!, - }, - }); - } - {{/ if }} - - {{# if relation.isAddable }} - /** - * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. - */ - async add{{ firstToUpper relation.name }}(owner: JudoIdentifiable<{{ classDataName classType "" }}>, selected: Array>): Promise { - const path = '{{ restPath classType "/~update/" relation.name "/~add" }}'; - await this.axios.post(this.getPathForActor(path), selected, { - headers: { - 'X-Judo-SignedIdentifier': owner.__signedIdentifier!, - }, - }); - } - {{/ if }} - - {{# if relation.isRemovable }} - /** - * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. - */ - async remove{{ firstToUpper relation.name }}(owner: JudoIdentifiable<{{ classDataName classType "" }}>, selected: Array>): Promise { - const path = '{{ restPath classType "/~update/" relation.name "/~remove" }}'; - await this.axios.post(this.getPathForActor(path), selected, { - headers: { - 'X-Judo-SignedIdentifier': owner.__signedIdentifier!, - }, - }); - } - {{/ if }} - - {{# if relation.isDeletable }} - /** - * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. - */ - async delete{{ firstToUpper relation.name }}(target: JudoIdentifiable<{{ classDataName relation.target "" }}>): Promise { - const path = '{{ restPath relation.target "/~delete" "" "" }}'; - await this.axios.post(this.getPathForActor(path), undefined, { - headers: { - 'X-Judo-SignedIdentifier': target.__signedIdentifier, - }, - }); - } - {{/ if }} - - {{# each relation.target.operations as | operation | }} - /** - * @throws {AxiosError}{{# if (hasFaults operation) }}With data containing {@link{{ faultContainerName operation }} } for business related errors (status code is 422).{{/ if }} - * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. - */ - async {{ operation.name }}For{{ firstToUpper relation.name }}({{# if operation.isMapped }}owner: JudoIdentifiable<{{ classDataName relation.target "" }}>{{/ if }}{{# if operation.input }}{{# if operation.isMapped }},{{/ if }}target:{{ classDataName operation.input.target "" }}{{/ if }}): Promise<{{# if operation.output }}{{ classDataName operation.output.target "Stored" }}{{ else }}void{{/ if }}> { - const path = '{{ operationRestPath relation.target operation '' }}'; - const response = await this.axios.post(this.getPathForActor(path){{# if operation.input }}, target{{ else }}, undefined{{/ if }}{{# if operation.isMapped }}, { - headers: { - 'X-Judo-SignedIdentifier': owner.__signedIdentifier!, - }, - } {{/ if }}); - - {{# if operation.output }} - return response.data; - {{/ if }} - } - - {{# if operation.input }} - {{# if operation.input.target.isTemplateable }} - async getTemplateOn{{ firstToUpper operation.name }}For{{ firstToUpper relation.name }}(): Promise<{{ classDataName operation.input.target "" }}> { - const path = '{{ restPath operation.input.target "/~template" "" "" }}'; - const response = await this.axios.get(this.getPathForActor(path)); - - return response.data; - } - {{/ if }} - {{/ if }} - - {{# if operation.isInputRangeable }} - /** - * @throws {AxiosError} With data containing {@link Array} for status codes: 401, 403. - */ - async getRangeOn{{ firstToUpper operation.name }}For{{ firstToUpper relation.name }}(owner?: {{ classDataName relation.target "Stored" }}, queryCustomizer?:{{ classDataName operation.input.target "QueryCustomizer" }}): Promise> { - const path = '{{ operationRestPath relation.target operation '/~range' }}'; - const response = await this.axios.post(this.getPathForActor(path), { owner: owner ?? {}, queryCustomizer: queryCustomizer ?? {} }); - - return response.data; - } - {{/ if }} - {{/ each }} + {{/ if }} + {{/ if }} + + {{# if operation.isInputRangeable }} + /** + * @throws {AxiosError} With data containing {@link Array} for status codes: 401, 403. + */ + async getRangeOn{{ firstToUpper operation.name }}For{{ firstToUpper relation.name }}(owner?: {{ classDataName relation.target "Stored" }}, queryCustomizer?:{{ classDataName operation.input.target "QueryCustomizer" }}): Promise> { + const path = '{{ operationRestPath relation.target operation '/~range' }}'; + const response = await this.axios.post(this.getPathForActor(path), { owner: owner ?? {}, queryCustomizer: queryCustomizer ?? {} }); + + return response.data; + } + {{/ if }} + {{/ each }} {{/ each }} {{# each classType.operations as | operation | }} - /** - * @throws {AxiosError}{{# if (hasFaults operation) }}With data containing {@link{{ faultContainerName operation }} } for business related errors (status code is 422).{{/ if }} - * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. - */ - async {{ operation.name }}({{# if operation.isMapped }}owner: JudoIdentifiable<{{ classDataName classType "" }}>{{/ if }}{{# if operation.input }}{{# if operation.isMapped }},{{/ if }}target:{{ classDataName operation.input.target "" }}{{/ if }}): Promise<{{# if operation.output }}{{ classDataName operation.output.target "Stored" }}{{ else }}void{{/ if }}> { - const path = '{{ operationRestPath classType operation '' }}'; - const response = await this.axios.post(this.getPathForActor(path){{# if operation.input }}, target{{ else }}, undefined{{/ if }}{{# if operation.isMapped }}, { - headers: { - 'X-Judo-SignedIdentifier': owner.__signedIdentifier!, - }, - } {{/ if }}); - - {{# if operation.output }} - return response.data; - {{/ if }} - } - - {{# if operation.input }} - {{# if operation.input.target.isTemplateable }} - async getTemplateOn{{ firstToUpper operation.name }}(): Promise<{{ classDataName operation.input.target "" }}> { - const path = '{{ restPath operation.input.target "/~template" "" "" }}'; - const response = await this.axios.get(this.getPathForActor(path)); - - return response.data; - } - {{/ if }} - - {{# each operation.input.target.relations as | relation | }} - /** - * @throws {AxiosError} With data containing {@link Array} for status codes: 401, 403. - */ - async getRangeOn{{ firstToUpper operation.name }}For{{ firstToUpper relation.name }}(owner?: JudoIdentifiable<{{ classDataName operation.input.target "" }}>, queryCustomizer?:{{ classDataName relation.target "QueryCustomizer" }}): Promise> { - const path = '{{ restPath operation.input.target "/" relation.name "/~range" }}'; - const response = await this.axios.post(this.getPathForActor(path), { owner: owner ?? {}, queryCustomizer: queryCustomizer ?? {} }); - - return response.data; - } - {{/ each }} - {{/ if }} - - {{# if operation.isInputRangeable }} - /** - * @throws {AxiosError} With data containing {@link Array} for status codes: 401, 403. - */ - async getRangeOn{{ firstToUpper operation.name }}(owner?: {{ classDataName classType "Stored" }}, queryCustomizer?:{{ classDataName operation.input.target "QueryCustomizer" }}): Promise> { - const path = '{{ operationRestPath classType operation '/~range' }}'; - const response = await this.axios.post(this.getPathForActor(path), { owner: owner ?? {}, queryCustomizer: queryCustomizer ?? {} }); - - return response.data; - } + /** + * @throws {AxiosError}{{# if (hasFaults operation) }}With data containing {@link{{ faultContainerName operation }} } for business related errors (status code is 422).{{/ if }} + * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. + */ + async {{ operation.name }}({{# if operation.isMapped }}owner: JudoIdentifiable<{{ classDataName classType "" }}>{{/ if }}{{# if operation.input }}{{# if operation.isMapped }},{{/ if }}target:{{ classDataName operation.input.target "" }}{{/ if }}): Promise<{{# if operation.output }}{{ classDataName operation.output.target "Stored" }}{{ else }}void{{/ if }}> { + const path = '{{ operationRestPath classType operation '' }}'; + const response = await this.axios.post(this.getPathForActor(path){{# if operation.input }}, target{{ else }}, undefined{{/ if }}{{# if operation.isMapped }}, { + headers: { + 'X-Judo-SignedIdentifier': owner.__signedIdentifier!, + }, + } {{/ if }}); + + {{# if operation.output }} + return response.data; {{/ if }} + } + + {{# if operation.input }} + {{# if operation.input.target.isTemplateable }} + async getTemplateOn{{ firstToUpper operation.name }}(): Promise<{{ classDataName operation.input.target "" }}> { + const path = '{{ restPath operation.input.target "/~template" "" "" }}'; + const response = await this.axios.get(this.getPathForActor(path)); + + return response.data; + } + {{/ if }} + + {{# each operation.input.target.relations as | relation | }} + /** + * @throws {AxiosError} With data containing {@link Array} for status codes: 401, 403. + */ + async getRangeOn{{ firstToUpper operation.name }}For{{ firstToUpper relation.name }}(owner?: JudoIdentifiable<{{ classDataName operation.input.target "" }}>, queryCustomizer?:{{ classDataName relation.target "QueryCustomizer" }}): Promise> { + const path = '{{ restPath operation.input.target "/" relation.name "/~range" }}'; + const response = await this.axios.post(this.getPathForActor(path), { owner: owner ?? {}, queryCustomizer: queryCustomizer ?? {} }); + + return response.data; + } + {{/ each }} + {{/ if }} + + {{# if operation.isInputRangeable }} + /** + * @throws {AxiosError} With data containing {@link Array} for status codes: 401, 403. + */ + async getRangeOn{{ firstToUpper operation.name }}(owner?: {{ classDataName classType "Stored" }}, queryCustomizer?:{{ classDataName operation.input.target "QueryCustomizer" }}): Promise> { + const path = '{{ operationRestPath classType operation '/~range' }}'; + const response = await this.axios.post(this.getPathForActor(path), { owner: owner ?? {}, queryCustomizer: queryCustomizer ?? {} }); + + return response.data; + } + {{/ if }} {{/ each }} } diff --git a/judo-ui-typescript-rest-axios/src/main/resources/data-axios/implementationInstancesExporter.ts.hbs b/judo-ui-typescript-rest-axios/src/main/resources/data-axios/implementationInstancesExporter.ts.hbs index 00dd376..e44154f 100644 --- a/judo-ui-typescript-rest-axios/src/main/resources/data-axios/implementationInstancesExporter.ts.hbs +++ b/judo-ui-typescript-rest-axios/src/main/resources/data-axios/implementationInstancesExporter.ts.hbs @@ -2,29 +2,23 @@ import { judoAxiosProvider } from './JudoAxiosProvider'; import { AccessServiceImpl } from './AccessServiceImpl'; - {{# each (getClassTypes application) as | impl | }} - import type { {{ serviceClassName impl }} } from '../data-service'; +import type { {{ serviceClassName impl }} } from '../data-service'; {{/ each }} - {{# each application.relationTypes as | impl | }} - import type { {{ serviceRelationName impl }} } from '../data-service'; +import type { {{ serviceRelationName impl }} } from '../data-service'; {{/ each }} - {{# each (getClassTypes application) as | impl | }} - import { {{ serviceClassName impl }}Impl } from './{{ serviceClassName impl }}Impl'; +import { {{ serviceClassName impl }}Impl } from './{{ serviceClassName impl }}Impl'; {{/ each }} - {{# each application.relationTypes as | impl | }} - import { {{ serviceRelationName impl }}Impl } from './{{ serviceRelationName impl }}Impl'; +import { {{ serviceRelationName impl }}Impl } from './{{ serviceRelationName impl }}Impl'; {{/ each }} export const accessServiceImpl = new AccessServiceImpl(judoAxiosProvider); - {{# each (getClassTypes application) as | impl | }} - export const {{ firstToLower (serviceClassName impl) }}Impl: {{ serviceClassName impl }} = new {{ serviceClassName impl }}Impl(judoAxiosProvider); +export const {{ firstToLower (serviceClassName impl) }}Impl: {{ serviceClassName impl }} = new {{ serviceClassName impl }}Impl(judoAxiosProvider); {{/ each }} - {{# each application.relationTypes as | impl | }} - export const {{ firstToLower (serviceRelationName impl) }}Impl: {{ serviceRelationName impl }} = new {{ serviceRelationName impl }}Impl(judoAxiosProvider); +export const {{ firstToLower (serviceRelationName impl) }}Impl: {{ serviceRelationName impl }} = new {{ serviceRelationName impl }}Impl(judoAxiosProvider); {{/ each }} diff --git a/judo-ui-typescript-rest-axios/src/main/resources/data-axios/judoAxiosProvider.ts.hbs b/judo-ui-typescript-rest-axios/src/main/resources/data-axios/judoAxiosProvider.ts.hbs index 8a7e7dd..e9dfa28 100644 --- a/judo-ui-typescript-rest-axios/src/main/resources/data-axios/judoAxiosProvider.ts.hbs +++ b/judo-ui-typescript-rest-axios/src/main/resources/data-axios/judoAxiosProvider.ts.hbs @@ -4,36 +4,36 @@ import type { AxiosInstance } from 'axios'; import { AxiosProvider, JudoAxiosProviderInitData } from './AxiosProvider'; export class JudoAxiosProvider implements AxiosProvider { - private axios?: AxiosInstance; - private basePathFactory?: () => string; - private filePathFactory?: () => string; - - init(data: JudoAxiosProviderInitData): void { - this.axios = data.axios; - this.basePathFactory = data.basePathFactory; - this.filePathFactory = data.filePathFactory; - } + private axios?: AxiosInstance; + private basePathFactory?: () => string; + private filePathFactory?: () => string; + + init(data: JudoAxiosProviderInitData): void { + this.axios = data.axios; + this.basePathFactory = data.basePathFactory; + this.filePathFactory = data.filePathFactory; + } - getAxios(): AxiosInstance { + getAxios(): AxiosInstance { if (!this.axios) { - throw new Error('[JudoAxiosProvider] Axios instance has not been set yet. Please init() the provider first!'); - } - return this.axios; + throw new Error('[JudoAxiosProvider] Axios instance has not been set yet. Please init() the provider first!'); } + return this.axios; + } - getBasePath(suffix?: string): string { - let base = typeof this.basePathFactory !== 'function' ? '/{{ application.name }}' : this.basePathFactory(); - base = base.replace(/\/+$/, ''); + getBasePath(suffix?: string): string { + let base = typeof this.basePathFactory !== 'function' ? '/{{ application.name }}' : this.basePathFactory(); + base = base.replace(/\/+$/, ''); - return base + (suffix ? ('/' + suffix) : ''); - } + return base + (suffix ? ('/' + suffix) : ''); + } - getFilePath(suffix?: string): string { - let base = typeof this.filePathFactory !== 'function' ? '/{{ application.name }}' : this.filePathFactory(); - base = base.replace(/\/+$/, ''); + getFilePath(suffix?: string): string { + let base = typeof this.filePathFactory !== 'function' ? '/{{ application.name }}' : this.filePathFactory(); + base = base.replace(/\/+$/, ''); - return base + (suffix ? ('/' + suffix) : ''); - } + return base + (suffix ? ('/' + suffix) : ''); + } } export const judoAxiosProvider: AxiosProvider = new JudoAxiosProvider(); diff --git a/judo-ui-typescript-rest-axios/src/main/resources/data-axios/judoAxiosService.ts.hbs b/judo-ui-typescript-rest-axios/src/main/resources/data-axios/judoAxiosService.ts.hbs index 0b59359..f6fa8a6 100644 --- a/judo-ui-typescript-rest-axios/src/main/resources/data-axios/judoAxiosService.ts.hbs +++ b/judo-ui-typescript-rest-axios/src/main/resources/data-axios/judoAxiosService.ts.hbs @@ -4,27 +4,27 @@ import type { AxiosInstance } from 'axios'; import { AxiosProvider } from './AxiosProvider'; export abstract class JudoAxiosService { - protected readonly axiosProvider: AxiosProvider; + protected readonly axiosProvider: AxiosProvider; - constructor(axiosProvider: AxiosProvider) { - this.axiosProvider = axiosProvider; - } + constructor(axiosProvider: AxiosProvider) { + this.axiosProvider = axiosProvider; + } - protected get axios(): AxiosInstance { - return this.axiosProvider.getAxios(); - } + protected get axios(): AxiosInstance { + return this.axiosProvider.getAxios(); + } - protected getBasePath(suffix?: string): string { - return this.axiosProvider.getBasePath(suffix); - } + protected getBasePath(suffix?: string): string { + return this.axiosProvider.getBasePath(suffix); + } - protected getPathForApp(path?: string): string { - const tmp = path ? path : ''; - return this.getBasePath('{{ application.modelName }}' + (tmp.length && !tmp.startsWith('/') ? '/' + tmp : tmp)); - } + protected getPathForApp(path?: string): string { + const tmp = path ? path : ''; + return this.getBasePath('{{ application.modelName }}' + (tmp.length && !tmp.startsWith('/') ? '/' + tmp : tmp)); + } - protected getPathForActor(path?: string): string { - const tmp = path ? path : ''; - return this.getPathForApp('{{ rootPathForApp application }}' + (tmp.length && !tmp.startsWith('/') ? '/' + tmp : tmp)); - } + protected getPathForActor(path?: string): string { + const tmp = path ? path : ''; + return this.getPathForApp('{{ rootPathForApp application }}' + (tmp.length && !tmp.startsWith('/') ? '/' + tmp : tmp)); + } } diff --git a/judo-ui-typescript-rest-axios/src/main/resources/data-axios/relationServiceImpl.ts.hbs b/judo-ui-typescript-rest-axios/src/main/resources/data-axios/relationServiceImpl.ts.hbs index c969c67..27b4609 100644 --- a/judo-ui-typescript-rest-axios/src/main/resources/data-axios/relationServiceImpl.ts.hbs +++ b/judo-ui-typescript-rest-axios/src/main/resources/data-axios/relationServiceImpl.ts.hbs @@ -6,457 +6,457 @@ import type { {{ joinedTokensForApiImport relation }} } from '../data-api'; import type { {{ serviceRelationName relation }} } from '../data-service'; /** -* Relation Service Implementation for {{ classDataName (getRelationOwnerAsClassType relation) "" }}.{{ relation.name }} -*/ + * Relation Service Implementation for {{ classDataName (getRelationOwnerAsClassType relation) "" }}.{{ relation.name }} + */ export class {{ serviceRelationName relation }}Impl extends JudoAxiosService implements {{ serviceRelationName relation }} { {{# if relation.isListable }} - {{# if relation.isCollection }} - /** - * From: relation.isListable, relation.isCollection - * @throws {AxiosError} With data containing {@link Array} for status codes: 401, 403. - */ - async list(owner?: JudoIdentifiable, queryCustomizer?: {{ classDataName relation.target "QueryCustomizer" }}): Promise> { - const path = '{{ restPath (getRelationOwnerAsClassType relation) "/" relation.name "/~list" }}'; - const response = await this.axios.post(this.getPathForActor(path), queryCustomizer ?? {}, owner ? { - headers: { - 'X-Judo-SignedIdentifier': owner.__signedIdentifier, - }, - } : undefined); - - return response.data; - } - {{/ if }} + {{# if relation.isCollection }} + /** + * From: relation.isListable, relation.isCollection + * @throws {AxiosError} With data containing {@link Array} for status codes: 401, 403. + */ + async list(owner?: JudoIdentifiable, queryCustomizer?: {{ classDataName relation.target "QueryCustomizer" }}): Promise> { + const path = '{{ restPath (getRelationOwnerAsClassType relation) "/" relation.name "/~list" }}'; + const response = await this.axios.post(this.getPathForActor(path), queryCustomizer ?? {}, owner ? { + headers: { + 'X-Judo-SignedIdentifier': owner.__signedIdentifier, + }, + } : undefined); + + return response.data; + } + {{/ if }} {{/ if }} {{# if relation.isRefreshable }} - {{# if relation.isAccess }} - {{# unless relation.isCollection }} - /** - * From: relation.isAccess, !relation.isCollection - * @throws {AxiosError} With data containing {@link Array} for status codes: 401, 403. - */ - async refreshFor{{ firstToUpper relation.name }}(queryCustomizer?: {{ classDataName relation.target "QueryCustomizer" }}): Promise<{{ classDataName relation.target "Stored" }}> { - const path = '{{ restPath (getRelationOwnerAsClassType relation) "/" relation.name "/~get" }}'; - const response = await this.axios.post(this.getPathForActor(path), queryCustomizer ?? {}); - - return response.data; - } - {{/ unless }} - {{/ if }} - - /** - * From: relation.isRefreshable - * @throws {AxiosError} With data containing {@link Array} for status codes: 401, 403. - */ - async refresh(owner?: JudoIdentifiable, queryCustomizer?: {{ classDataName relation.target "QueryCustomizer" }}): Promise<{{ classDataName relation.target "Stored" }}> { - const path = '{{ restPath relation.target "/~get" "" "" }}'; - const response = await this.axios.post(this.getPathForActor(path), queryCustomizer ?? {}, owner ? { - headers: { - 'X-Judo-SignedIdentifier': owner.__signedIdentifier, - }, - } : undefined); - - return response.data; - } + {{# if relation.isAccess }} + {{# unless relation.isCollection }} + /** + * From: relation.isAccess, !relation.isCollection + * @throws {AxiosError} With data containing {@link Array} for status codes: 401, 403. + */ + async refreshFor{{ firstToUpper relation.name }}(queryCustomizer?: {{ classDataName relation.target "QueryCustomizer" }}): Promise<{{ classDataName relation.target "Stored" }}> { + const path = '{{ restPath (getRelationOwnerAsClassType relation) "/" relation.name "/~get" }}'; + const response = await this.axios.post(this.getPathForActor(path), queryCustomizer ?? {}); + + return response.data; + } + {{/ unless }} + {{/ if }} + + /** + * From: relation.isRefreshable + * @throws {AxiosError} With data containing {@link Array} for status codes: 401, 403. + */ + async refresh(owner?: JudoIdentifiable, queryCustomizer?: {{ classDataName relation.target "QueryCustomizer" }}): Promise<{{ classDataName relation.target "Stored" }}> { + const path = '{{ restPath relation.target "/~get" "" "" }}'; + const response = await this.axios.post(this.getPathForActor(path), queryCustomizer ?? {}, owner ? { + headers: { + 'X-Judo-SignedIdentifier': owner.__signedIdentifier, + }, + } : undefined); + + return response.data; + } {{/ if }} {{# if relation.isRangeable }} - /** - * From: relation.isRangeable - * @throws {AxiosError} With data containing {@link Array} for status codes: 401, 403. - */ - async getRangeFor{{ firstToUpper relation.name }}({{# unless relation.isAccess }}owner: JudoIdentifiable<{{ classDataName (getRelationOwnerAsClassType relation) "" }}> | {{ classDataName (getRelationOwnerAsClassType relation) "" }}, {{/ unless }}queryCustomizer?:{{ classDataName relation.target "QueryCustomizer" }}): Promise> { - const path = '{{ restPath (getRelationOwnerAsClassType relation) "/" relation.name "/~range" }}'; - const response = await this.axios.post(this.getPathForActor(path), { - {{# unless relation.isAccess }}owner: owner ?? {},{{/ unless }} - queryCustomizer: queryCustomizer ?? {} - }); - - return response.data; - } + /** + * From: relation.isRangeable + * @throws {AxiosError} With data containing {@link Array} for status codes: 401, 403. + */ + async getRangeFor{{ firstToUpper relation.name }}({{# unless relation.isAccess }}owner: JudoIdentifiable<{{ classDataName (getRelationOwnerAsClassType relation) "" }}> | {{ classDataName (getRelationOwnerAsClassType relation) "" }}, {{/ unless }}queryCustomizer?:{{ classDataName relation.target "QueryCustomizer" }}): Promise> { + const path = '{{ restPath (getRelationOwnerAsClassType relation) "/" relation.name "/~range" }}'; + const response = await this.axios.post(this.getPathForActor(path), { + {{# unless relation.isAccess }}owner: owner ?? {},{{/ unless }} + queryCustomizer: queryCustomizer ?? {} + }); + + return response.data; + } {{/ if }} {{# if relation.target.isTemplateable }} - /** - * From: relation.target.isTemplateable - * @throws {AxiosError} With data containing {@link Array} for status codes: 401, 403. - */ - async getTemplate(): Promise<{{ classDataName relation.target "" }}> { - const path = '{{ restPath relation.target "/~template" "" "" }}'; - const response = await this.axios.get(this.getPathForActor(path)); - - return response.data; - } + /** + * From: relation.target.isTemplateable + * @throws {AxiosError} With data containing {@link Array} for status codes: 401, 403. + */ + async getTemplate(): Promise<{{ classDataName relation.target "" }}> { + const path = '{{ restPath relation.target "/~template" "" "" }}'; + const response = await this.axios.get(this.getPathForActor(path)); + + return response.data; + } {{/ if }} {{# if relation.isCreatable }} - /** - * From: relation.isCreatable - * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. - */ - async create({{# unless relation.isAccess }}owner: JudoIdentifiable<{{ classDataName (getRelationOwnerAsClassType relation) "" }}>, {{/ unless }}target: {{ classDataName relation.target "" }}): Promise<{{ classDataName relation.target "Stored" }}> { - {{# unless relation.isAccess }} - const path = '{{ restPath (getRelationOwnerAsClassType relation) "/~update/" relation.name "/~create" }}'; - {{ else }} - const path = '{{ restPath (getRelationOwnerAsClassType relation) "/" relation.name "/~create" }}'; - {{/ unless }} - const response = await this.axios.post(this.getPathForActor(path), target{{# unless relation.isAccess }}, { - headers: { - 'X-Judo-SignedIdentifier': owner.__signedIdentifier, - }, - } {{/ unless }}); - - return response.data; - } + /** + * From: relation.isCreatable + * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. + */ + async create({{# unless relation.isAccess }}owner: JudoIdentifiable<{{ classDataName (getRelationOwnerAsClassType relation) "" }}>, {{/ unless }}target: {{ classDataName relation.target "" }}): Promise<{{ classDataName relation.target "Stored" }}> { + {{# unless relation.isAccess }} + const path = '{{ restPath (getRelationOwnerAsClassType relation) "/~update/" relation.name "/~create" }}'; + {{ else }} + const path = '{{ restPath (getRelationOwnerAsClassType relation) "/" relation.name "/~create" }}'; + {{/ unless }} + const response = await this.axios.post(this.getPathForActor(path), target{{# unless relation.isAccess }}, { + headers: { + 'X-Judo-SignedIdentifier': owner.__signedIdentifier, + }, + } {{/ unless }}); + + return response.data; + } {{/ if }} {{# if relation.isDeletable }} - /** - * From: relation.isDeletable - * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. - */ - async delete(target: JudoIdentifiable<{{ classDataName relation.target "" }}>): Promise { - const path = '{{ restPath relation.target "/~delete" "" "" }}'; - await this.axios.post(this.getPathForActor(path), undefined, { - headers: { - 'X-Judo-SignedIdentifier': target.__signedIdentifier, - }, - }); - } + /** + * From: relation.isDeletable + * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. + */ + async delete(target: JudoIdentifiable<{{ classDataName relation.target "" }}>): Promise { + const path = '{{ restPath relation.target "/~delete" "" "" }}'; + await this.axios.post(this.getPathForActor(path), undefined, { + headers: { + 'X-Judo-SignedIdentifier': target.__signedIdentifier, + }, + }); + } {{/ if }} {{# if relation.isUpdatable }} - /** - * From: relation.isUpdatable - * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. - */ - async update(target: Partial<{{ classDataName relation.target "Stored" }}>): Promise<{{ classDataName relation.target "Stored" }}> { - const path = '{{ restPath relation.target "/~update" "" "" }}'; - const response = await this.axios.post(this.getPathForActor(path), target, { - headers: { - 'X-Judo-SignedIdentifier': target.__signedIdentifier, - }, - }); - - return response.data; - } + /** + * From: relation.isUpdatable + * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. + */ + async update(target: Partial<{{ classDataName relation.target "Stored" }}>): Promise<{{ classDataName relation.target "Stored" }}> { + const path = '{{ restPath relation.target "/~update" "" "" }}'; + const response = await this.axios.post(this.getPathForActor(path), target, { + headers: { + 'X-Judo-SignedIdentifier': target.__signedIdentifier, + }, + }); + + return response.data; + } {{/ if }} {{# if relation.isSetable }} - /** - * From: relation.isSetable - * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. - */ - async set{{ firstToUpper relation.name }}({{# unless relation.isAccess }}owner: JudoIdentifiable<{{ classDataName (getRelationOwnerAsClassType relation) "" }}>, {{/ unless }}selected:{{# if relation.isCollection }}Array<{{/ if }}JudoIdentifiable<{{ classDataName relation.target "" }}>{{# if relation.isCollection }}>{{/ if }}): Promise { - const path = '{{ restPath (getRelationOwnerAsClassType relation) "/~update/" relation.name "/~set" }}'; - await this.axios.post(this.getPathForActor(path), selected{{# unless relation.isAccess }}, { - headers: { - 'X-Judo-SignedIdentifier': owner.__signedIdentifier!, - }, - } {{/ unless }}); - } + /** + * From: relation.isSetable + * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. + */ + async set{{ firstToUpper relation.name }}({{# unless relation.isAccess }}owner: JudoIdentifiable<{{ classDataName (getRelationOwnerAsClassType relation) "" }}>, {{/ unless }}selected:{{# if relation.isCollection }}Array<{{/ if }}JudoIdentifiable<{{ classDataName relation.target "" }}>{{# if relation.isCollection }}>{{/ if }}): Promise { + const path = '{{ restPath (getRelationOwnerAsClassType relation) "/~update/" relation.name "/~set" }}'; + await this.axios.post(this.getPathForActor(path), selected{{# unless relation.isAccess }}, { + headers: { + 'X-Judo-SignedIdentifier': owner.__signedIdentifier!, + }, + } {{/ unless }}); + } {{/ if }} {{# if relation.isUnsetable }} - /** - * From: relation.isUnsetable - * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. - */ - async unset{{ firstToUpper relation.name }}({{# unless relation.isAccess }}owner: JudoIdentifiable<{{ classDataName (getRelationOwnerAsClassType relation) "" }}>, {{/ unless }}): Promise { - const path = '{{ restPath (getRelationOwnerAsClassType relation) "/~update/" relation.name "/~unset" }}'; - await this.axios.post(this.getPathForActor(path), undefined{{# unless relation.isAccess }}, { - headers: { - 'X-Judo-SignedIdentifier': owner.__signedIdentifier!, - }, - } {{/ unless }}); - } + /** + * From: relation.isUnsetable + * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. + */ + async unset{{ firstToUpper relation.name }}({{# unless relation.isAccess }}owner: JudoIdentifiable<{{ classDataName (getRelationOwnerAsClassType relation) "" }}>, {{/ unless }}): Promise { + const path = '{{ restPath (getRelationOwnerAsClassType relation) "/~update/" relation.name "/~unset" }}'; + await this.axios.post(this.getPathForActor(path), undefined{{# unless relation.isAccess }}, { + headers: { + 'X-Judo-SignedIdentifier': owner.__signedIdentifier!, + }, + } {{/ unless }}); + } {{/ if }} {{# if relation.isAddable }} - /** - * From: relation.isAddable - * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. - */ - async add{{ firstToUpper relation.name }}({{# unless relation.isAccess }}owner: JudoIdentifiable<{{ classDataName (getRelationOwnerAsClassType relation) "" }}>, {{/ unless }}selected: Array>): Promise { - const path = '{{ restPath (getRelationOwnerAsClassType relation) "/~update/" relation.name "/~add" }}'; - await this.axios.post(this.getPathForActor(path), selected{{# unless relation.isAccess }}, { - headers: { - 'X-Judo-SignedIdentifier': owner.__signedIdentifier!, - }, - } {{/ unless }}); - } + /** + * From: relation.isAddable + * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. + */ + async add{{ firstToUpper relation.name }}({{# unless relation.isAccess }}owner: JudoIdentifiable<{{ classDataName (getRelationOwnerAsClassType relation) "" }}>, {{/ unless }}selected: Array>): Promise { + const path = '{{ restPath (getRelationOwnerAsClassType relation) "/~update/" relation.name "/~add" }}'; + await this.axios.post(this.getPathForActor(path), selected{{# unless relation.isAccess }}, { + headers: { + 'X-Judo-SignedIdentifier': owner.__signedIdentifier!, + }, + } {{/ unless }}); + } {{/ if }} {{# if relation.isRemovable }} - /** - * From: relation.isRemovable - * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. - */ - async remove{{ firstToUpper relation.name }}({{# unless relation.isAccess }}owner: JudoIdentifiable<{{ classDataName (getRelationOwnerAsClassType relation) "" }}>, {{/ unless }}selected: Array>): Promise { - const path = '{{ restPath (getRelationOwnerAsClassType relation) "/~update/" relation.name "/~remove" }}'; - await this.axios.post(this.getPathForActor(path), selected{{# unless relation.isAccess }}, { - headers: { - 'X-Judo-SignedIdentifier': owner.__signedIdentifier!, - }, - } {{/ unless }}); - } + /** + * From: relation.isRemovable + * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. + */ + async remove{{ firstToUpper relation.name }}({{# unless relation.isAccess }}owner: JudoIdentifiable<{{ classDataName (getRelationOwnerAsClassType relation) "" }}>, {{/ unless }}selected: Array>): Promise { + const path = '{{ restPath (getRelationOwnerAsClassType relation) "/~update/" relation.name "/~remove" }}'; + await this.axios.post(this.getPathForActor(path), selected{{# unless relation.isAccess }}, { + headers: { + 'X-Judo-SignedIdentifier': owner.__signedIdentifier!, + }, + } {{/ unless }}); + } {{/ if }} {{# each relation.target.relations as | targetRelation | }} - {{# if targetRelation.isListable }} - {{# if targetRelation.isCollection }} - async list{{ firstToUpper targetRelation.name }}(owner: JudoIdentifiable<{{ classDataName relation.target "" }}>, queryCustomizer?: {{ classDataName targetRelation.target "QueryCustomizer" }}): Promise> { - const path = '{{ restPath relation.target "/" targetRelation.name "/~list" }}'; - const response = await this.axios.post(this.getPathForActor(path), queryCustomizer ?? {}, { - headers: { - 'X-Judo-SignedIdentifier': owner.__signedIdentifier, - }, - }); - - return response.data; - } - {{ else }} - async get{{ firstToUpper targetRelation.name }}(owner: JudoIdentifiable<{{ classDataName relation.target "" }}>, queryCustomizer?: {{ classDataName targetRelation.target "QueryCustomizer" }}): Promise<{{ classDataName targetRelation.target "Stored" }}> { - const path = '{{ restPath relation.target "/" targetRelation.name "/~get" }}'; - const response = await this.axios.post(this.getPathForActor(path), queryCustomizer ?? {}, { - headers: { - 'X-Judo-SignedIdentifier': owner.__signedIdentifier, - }, - }); - - return response.data; - } - {{/ if }} + {{# if targetRelation.isListable }} + {{# if targetRelation.isCollection }} + async list{{ firstToUpper targetRelation.name }}(owner: JudoIdentifiable<{{ classDataName relation.target "" }}>, queryCustomizer?: {{ classDataName targetRelation.target "QueryCustomizer" }}): Promise> { + const path = '{{ restPath relation.target "/" targetRelation.name "/~list" }}'; + const response = await this.axios.post(this.getPathForActor(path), queryCustomizer ?? {}, { + headers: { + 'X-Judo-SignedIdentifier': owner.__signedIdentifier, + }, + }); + + return response.data; + } + {{ else }} + async get{{ firstToUpper targetRelation.name }}(owner: JudoIdentifiable<{{ classDataName relation.target "" }}>, queryCustomizer?: {{ classDataName targetRelation.target "QueryCustomizer" }}): Promise<{{ classDataName targetRelation.target "Stored" }}> { + const path = '{{ restPath relation.target "/" targetRelation.name "/~get" }}'; + const response = await this.axios.post(this.getPathForActor(path), queryCustomizer ?? {}, { + headers: { + 'X-Judo-SignedIdentifier': owner.__signedIdentifier, + }, + }); + + return response.data; + } + {{/ if }} + {{/ if }} + + {{# if targetRelation.isRangeable }} + {{# neq relation.name targetRelation.name }} + /** + * Form: targetRelation.isRangeable + * @throws {AxiosError} With data containing {@link Array} for status codes: 401, 403. + */ + async getRangeFor{{ firstToUpper targetRelation.name }}(owner: JudoIdentifiable<{{ classDataName relation.target "" }}> | {{ classDataName relation.target "" }}, queryCustomizer?: {{ classDataName targetRelation.target "QueryCustomizer" }}): Promise> { + const path = '{{ restPath relation.target "/" targetRelation.name "/~range" }}'; + const response = await this.axios.post(this.getPathForActor(path), { + owner: owner, + queryCustomizer: queryCustomizer ?? {} + }); + + return response.data; + } + {{/ neq }} + {{/ if }} + + {{# if targetRelation.target.isTemplateable }} + async getTemplateFor{{ firstToUpper targetRelation.name }}(): Promise<{{ classDataName targetRelation.target "" }}> { + const path = '{{ restPath targetRelation.target "/~template" "" "" }}'; + const response = await this.axios.get(this.getPathForActor(path)); + + return response.data; + } + {{/ if }} + + {{# if targetRelation.isCreatable }} + async create{{ firstToUpper targetRelation.name }}(owner: JudoIdentifiable<{{ classDataName relation.target "" }}>, target: {{ classDataName targetRelation.target "" }}): Promise<{{ classDataName targetRelation.target "Stored" }}> { + const path = '{{ restPath relation.target "/~update/" targetRelation.name "/~create" }}'; + const response = await this.axios.post(this.getPathForActor(path), target, { + headers: { + 'X-Judo-SignedIdentifier': owner.__signedIdentifier, + }, + }); + + return response.data; + } + {{/ if }} + + {{# if targetRelation.isDeletable }} + async delete{{ firstToUpper targetRelation.name }}(target: JudoIdentifiable<{{ classDataName targetRelation.target "" }}>): Promise { + const path = '{{ restPath targetRelation.target "/~delete" "" "" }}'; + await this.axios.post(this.getPathForActor(path), undefined, { + headers: { + 'X-Judo-SignedIdentifier': target.__signedIdentifier, + }, + }); + } + {{/ if }} + + {{# if targetRelation.isUpdatable }} + async update{{ firstToUpper targetRelation.name }}(owner: JudoIdentifiable<{{ classDataName relation.target "" }}>, target: Partial<{{ classDataName targetRelation.target "Stored" }}>): Promise<{{ classDataName targetRelation.target "Stored" }}> { + const path = '{{ restPath relation.target "/~update/" targetRelation.name "/~update" }}'; + const response = await this.axios.post(this.getPathForActor(path), target, { + headers: { + 'X-Judo-SignedIdentifier': owner.__signedIdentifier, + }, + }); + + return response.data; + } + {{/ if }} + + {{# if targetRelation.isSetable }} + {{# neq relation.name targetRelation.name }} + /** + * From: targetRelation.isSetable + * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. + */ + async set{{ firstToUpper targetRelation.name }}(owner: JudoIdentifiable<{{ classDataName relation.target "" }}>, selected: {{# if targetRelation.isCollection }}Array<{{/ if }}JudoIdentifiable<{{ classDataName targetRelation.target "" }}>{{# if targetRelation.isCollection}}>{{/ if }}): Promise { + const path = '{{ restPath relation.target "/~update/" targetRelation.name "/~set" }}'; + await this.axios.post(this.getPathForActor(path), selected, { + headers: { + 'X-Judo-SignedIdentifier': owner.__signedIdentifier, + }, + }); + } + {{/ neq }} + {{/ if }} + + {{# if targetRelation.isUnsetable }} + {{# neq relation.name targetRelation.name }} + /** + * From: targetRelation.isUnsetable + * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. + */ + async unset{{ firstToUpper targetRelation.name }}(owner: JudoIdentifiable<{{ classDataName relation.target "" }}>): Promise { + const path = '{{ restPath relation.target "/~update/" targetRelation.name "/~unset" }}'; + await this.axios.post(this.getPathForActor(path), undefined, { + headers: { + 'X-Judo-SignedIdentifier': owner.__signedIdentifier, + }, + }); + } + {{/ neq }} + {{/ if }} + + {{# if targetRelation.isAddable }} + {{# neq relation.name targetRelation.name }} + /** + * From: targetRelation.isAddable + * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. + */ + async add{{ firstToUpper targetRelation.name }}(owner: JudoIdentifiable<{{ classDataName relation.target "" }}>, selected: Array>): Promise { + const path = '{{ restPath relation.target "/~update/" targetRelation.name "/~add" }}'; + await this.axios.post(this.getPathForActor(path), selected, { + headers: { + 'X-Judo-SignedIdentifier': owner.__signedIdentifier, + }, + }); + } + {{/ neq }} + {{/ if }} + + {{# if targetRelation.isRemovable }} + {{# neq relation.name targetRelation.name }} + /** + * From: targetRelation.isRemovable + * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. + */ + async remove{{ firstToUpper targetRelation.name }}(owner: JudoIdentifiable<{{ classDataName relation.target "" }}>, selected: Array>): Promise { + const path = '{{ restPath relation.target "/~update/" targetRelation.name "/~remove" }}'; + await this.axios.post(this.getPathForActor(path), selected, { + headers: { + 'X-Judo-SignedIdentifier': owner.__signedIdentifier, + }, + }); + } + {{/ neq }} + {{/ if }} + + {{# each targetRelation.target.operations as | operation | }} + /** + * From: targetRelation.target.operations + * @throws {AxiosError}{{# if (hasFaults operation) }}With data containing {@link{{ faultContainerName operation }} } for business related errors (status code is 422).{{/ if }} + * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. + */ + async {{ operation.name }}For{{ firstToUpper targetRelation.name }}({{# unless operation.isStatic }}owner: JudoIdentifiable<{{ classDataName targetRelation.target "" }}>{{/ unless }}{{# if operation.input }}{{# unless operation.isStatic }}, {{/ unless }}target:{{ classDataName operation.input.target "" }}{{/ if }}): Promise<{{# if operation.output }}{{ classDataName operation.output.target "Stored" }}{{ else }}void{{/ if }}> { + const path = '{{ operationRestPath relation.target operation '' }}'; + const response = await this.axios.post(this.getPathForActor(path){{# if operation.input }}, target{{ else }}, undefined{{/ if }}{{# unless operation.isStatic }}, { + headers: { + 'X-Judo-SignedIdentifier': owner.__signedIdentifier!, + }, + } {{/ unless }}); + + {{# if operation.output }} + return response.data; {{/ if }} - - {{# if targetRelation.isRangeable }} - {{# neq relation.name targetRelation.name }} - /** - * Form: targetRelation.isRangeable - * @throws {AxiosError} With data containing {@link Array} for status codes: 401, 403. - */ - async getRangeFor{{ firstToUpper targetRelation.name }}(owner: JudoIdentifiable<{{ classDataName relation.target "" }}> | {{ classDataName relation.target "" }}, queryCustomizer?: {{ classDataName targetRelation.target "QueryCustomizer" }}): Promise> { - const path = '{{ restPath relation.target "/" targetRelation.name "/~range" }}'; - const response = await this.axios.post(this.getPathForActor(path), { - owner: owner, - queryCustomizer: queryCustomizer ?? {} - }); - - return response.data; - } - {{/ neq }} - {{/ if }} - - {{# if targetRelation.target.isTemplateable }} - async getTemplateFor{{ firstToUpper targetRelation.name }}(): Promise<{{ classDataName targetRelation.target "" }}> { - const path = '{{ restPath targetRelation.target "/~template" "" "" }}'; - const response = await this.axios.get(this.getPathForActor(path)); - - return response.data; - } - {{/ if }} - - {{# if targetRelation.isCreatable }} - async create{{ firstToUpper targetRelation.name }}(owner: JudoIdentifiable<{{ classDataName relation.target "" }}>, target: {{ classDataName targetRelation.target "" }}): Promise<{{ classDataName targetRelation.target "Stored" }}> { - const path = '{{ restPath relation.target "/~update/" targetRelation.name "/~create" }}'; - const response = await this.axios.post(this.getPathForActor(path), target, { - headers: { - 'X-Judo-SignedIdentifier': owner.__signedIdentifier, - }, - }); - - return response.data; - } - {{/ if }} - - {{# if targetRelation.isDeletable }} - async delete{{ firstToUpper targetRelation.name }}(target: JudoIdentifiable<{{ classDataName targetRelation.target "" }}>): Promise { - const path = '{{ restPath targetRelation.target "/~delete" "" "" }}'; - await this.axios.post(this.getPathForActor(path), undefined, { - headers: { - 'X-Judo-SignedIdentifier': target.__signedIdentifier, - }, - }); - } - {{/ if }} - - {{# if targetRelation.isUpdatable }} - async update{{ firstToUpper targetRelation.name }}(owner: JudoIdentifiable<{{ classDataName relation.target "" }}>, target: Partial<{{ classDataName targetRelation.target "Stored" }}>): Promise<{{ classDataName targetRelation.target "Stored" }}> { - const path = '{{ restPath relation.target "/~update/" targetRelation.name "/~update" }}'; - const response = await this.axios.post(this.getPathForActor(path), target, { - headers: { - 'X-Judo-SignedIdentifier': owner.__signedIdentifier, - }, - }); - - return response.data; - } - {{/ if }} - - {{# if targetRelation.isSetable }} - {{# neq relation.name targetRelation.name }} - /** - * From: targetRelation.isSetable - * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. - */ - async set{{ firstToUpper targetRelation.name }}(owner: JudoIdentifiable<{{ classDataName relation.target "" }}>, selected: {{# if targetRelation.isCollection }}Array<{{/ if }}JudoIdentifiable<{{ classDataName targetRelation.target "" }}>{{# if targetRelation.isCollection}}>{{/ if }}): Promise { - const path = '{{ restPath relation.target "/~update/" targetRelation.name "/~set" }}'; - await this.axios.post(this.getPathForActor(path), selected, { - headers: { - 'X-Judo-SignedIdentifier': owner.__signedIdentifier, - }, - }); - } - {{/ neq }} - {{/ if }} - - {{# if targetRelation.isUnsetable }} - {{# neq relation.name targetRelation.name }} - /** - * From: targetRelation.isUnsetable - * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. - */ - async unset{{ firstToUpper targetRelation.name }}(owner: JudoIdentifiable<{{ classDataName relation.target "" }}>): Promise { - const path = '{{ restPath relation.target "/~update/" targetRelation.name "/~unset" }}'; - await this.axios.post(this.getPathForActor(path), undefined, { - headers: { - 'X-Judo-SignedIdentifier': owner.__signedIdentifier, - }, - }); - } - {{/ neq }} - {{/ if }} - - {{# if targetRelation.isAddable }} - {{# neq relation.name targetRelation.name }} - /** - * From: targetRelation.isAddable - * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. - */ - async add{{ firstToUpper targetRelation.name }}(owner: JudoIdentifiable<{{ classDataName relation.target "" }}>, selected: Array>): Promise { - const path = '{{ restPath relation.target "/~update/" targetRelation.name "/~add" }}'; - await this.axios.post(this.getPathForActor(path), selected, { - headers: { - 'X-Judo-SignedIdentifier': owner.__signedIdentifier, - }, - }); - } - {{/ neq }} - {{/ if }} - - {{# if targetRelation.isRemovable }} - {{# neq relation.name targetRelation.name }} - /** - * From: targetRelation.isRemovable - * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. - */ - async remove{{ firstToUpper targetRelation.name }}(owner: JudoIdentifiable<{{ classDataName relation.target "" }}>, selected: Array>): Promise { - const path = '{{ restPath relation.target "/~update/" targetRelation.name "/~remove" }}'; - await this.axios.post(this.getPathForActor(path), selected, { - headers: { - 'X-Judo-SignedIdentifier': owner.__signedIdentifier, - }, - }); - } - {{/ neq }} - {{/ if }} - - {{# each targetRelation.target.operations as | operation | }} - /** - * From: targetRelation.target.operations - * @throws {AxiosError}{{# if (hasFaults operation) }}With data containing {@link{{ faultContainerName operation }} } for business related errors (status code is 422).{{/ if }} - * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. - */ - async {{ operation.name }}For{{ firstToUpper targetRelation.name }}({{# unless operation.isStatic }}owner: JudoIdentifiable<{{ classDataName targetRelation.target "" }}>{{/ unless }}{{# if operation.input }}{{# unless operation.isStatic }}, {{/ unless }}target:{{ classDataName operation.input.target "" }}{{/ if }}): Promise<{{# if operation.output }}{{ classDataName operation.output.target "Stored" }}{{ else }}void{{/ if }}> { - const path = '{{ operationRestPath relation.target operation '' }}'; - const response = await this.axios.post(this.getPathForActor(path){{# if operation.input }}, target{{ else }}, undefined{{/ if }}{{# unless operation.isStatic }}, { - headers: { - 'X-Judo-SignedIdentifier': owner.__signedIdentifier!, - }, - } {{/ unless }}); - - {{# if operation.output }} - return response.data; - {{/ if }} - } - - {{# if operation.input }} - {{# if operation.input.target.isTemplateable }} - async getTemplateOn{{ firstToUpper operation.name }}For{{ firstToUpper targetRelation.name }}(): Promise<{{ classDataName operation.input.target "" }}> { - const path = '{{ restPath operation.input.target "/~template" "" "" }}'; - const response = await this.axios.get(this.getPathForActor(path)); - - return response.data; - } - {{/ if }} - {{/ if }} - - {{# if operation.isInputRangeable }} - {{# neq relation.name targetRelation.name }} - /** - * From: targetRelation.target.operations operation.isInputRangeable - * @throws {AxiosError} With data containing {@link Array} for status codes: 401, 403. - */ - async getRangeOn{{ firstToUpper operation.name }}For{{ firstToUpper targetRelation.name }}({{# unless operation.isStatic }}owner: JudoIdentifiable<{{ classDataName targetRelation.target "" }}> | {{ classDataName targetRelation.target "" }}, {{/ unless }}queryCustomizer?:{{ classDataName operation.input.target "QueryCustomizer" }}): Promise> { - const path = '{{ operationRestPath targetRelation.target operation '/~range' }}'; - const response = await this.axios.post(this.getPathForActor(path), { - {{# unless operation.isStatic }}owner: owner ?? {},{{/ unless }} - queryCustomizer: queryCustomizer ?? {} - }); - - return response.data; - } - {{/ neq }} - {{/ if }} - {{/ each }} + } + + {{# if operation.input }} + {{# if operation.input.target.isTemplateable }} + async getTemplateOn{{ firstToUpper operation.name }}For{{ firstToUpper targetRelation.name }}(): Promise<{{ classDataName operation.input.target "" }}> { + const path = '{{ restPath operation.input.target "/~template" "" "" }}'; + const response = await this.axios.get(this.getPathForActor(path)); + + return response.data; + } + {{/ if }} + {{/ if }} + + {{# if operation.isInputRangeable }} + {{# neq relation.name targetRelation.name }} + /** + * From: targetRelation.target.operations operation.isInputRangeable + * @throws {AxiosError} With data containing {@link Array} for status codes: 401, 403. + */ + async getRangeOn{{ firstToUpper operation.name }}For{{ firstToUpper targetRelation.name }}({{# unless operation.isStatic }}owner: JudoIdentifiable<{{ classDataName targetRelation.target "" }}> | {{ classDataName targetRelation.target "" }}, {{/ unless }}queryCustomizer?:{{ classDataName operation.input.target "QueryCustomizer" }}): Promise> { + const path = '{{ operationRestPath targetRelation.target operation '/~range' }}'; + const response = await this.axios.post(this.getPathForActor(path), { + {{# unless operation.isStatic }}owner: owner ?? {},{{/ unless }} + queryCustomizer: queryCustomizer ?? {} + }); + + return response.data; + } + {{/ neq }} + {{/ if }} + {{/ each }} {{/ each }} {{# each relation.target.operations as | operation | }} - /** - * From: relation.target.operations - * @throws {AxiosError}{{# if (hasFaults operation) }}With data containing {@link{{ faultContainerName operation }} } for business related errors (status code is 422).{{/ if }} - * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. - */ - async {{ operation.name }}({{# unless operation.isStatic }}owner: JudoIdentifiable<{{ classDataName relation.target "" }}>{{/ unless }}{{# if operation.input }}{{# unless operation.isStatic }}, {{/ unless }}target:{{ classDataName operation.input.target "" }}{{/ if }}): Promise<{{# if operation.output }}{{ classDataName operation.output.target "Stored" }}{{ else }}void{{/ if }}> { - const path = '{{ operationRestPath relation.target operation '' }}'; - const response = await this.axios.post(this.getPathForActor(path){{# if operation.input }}, target{{ else }}, undefined{{/ if }}{{# unless operation.isStatic }}, { - headers: { - 'X-Judo-SignedIdentifier': owner.__signedIdentifier!, - }, - } {{/ unless }}); - - {{# if operation.output }} - return response.data; - {{/ if }} - } - - {{# if operation.input }} - {{# if operation.input.target.isTemplateable }} - async getTemplateOn{{ firstToUpper operation.name }}(): Promise<{{ classDataName operation.input.target "" }}> { - const path = '{{ restPath operation.input.target "/~template" "" "" }}'; - const response = await this.axios.get(this.getPathForActor(path)); - - return response.data; - } - {{/ if }} - {{/ if }} - - {{# if operation.isInputRangeable }} - {{# neq relation.name targetRelation.name }} - /** - * From: relation.target.operations operation.isInputRangeable - * @throws {AxiosError} With data containing {@link Array} for status codes: 401, 403. - */ - async getRangeOn{{ firstToUpper operation.name }}({{# unless operation.isStatic }}owner: JudoIdentifiable<{{ classDataName relation.target "" }}> | {{ classDataName relation.target "" }}, {{/ unless }}queryCustomizer?:{{ classDataName operation.input.target "QueryCustomizer" }}): Promise> { - const path = '{{ operationRestPath relation.target operation '/~range' }}'; - const response = await this.axios.post(this.getPathForActor(path), { - {{# unless operation.isStatic }}owner: owner ?? {},{{/ unless }} - queryCustomizer: queryCustomizer ?? {} - }); - - return response.data; - } - {{/ neq }} + /** + * From: relation.target.operations + * @throws {AxiosError}{{# if (hasFaults operation) }}With data containing {@link{{ faultContainerName operation }} } for business related errors (status code is 422).{{/ if }} + * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. + */ + async {{ operation.name }}({{# unless operation.isStatic }}owner: JudoIdentifiable<{{ classDataName relation.target "" }}>{{/ unless }}{{# if operation.input }}{{# unless operation.isStatic }}, {{/ unless }}target:{{ classDataName operation.input.target "" }}{{/ if }}): Promise<{{# if operation.output }}{{ classDataName operation.output.target "Stored" }}{{ else }}void{{/ if }}> { + const path = '{{ operationRestPath relation.target operation '' }}'; + const response = await this.axios.post(this.getPathForActor(path){{# if operation.input }}, target{{ else }}, undefined{{/ if }}{{# unless operation.isStatic }}, { + headers: { + 'X-Judo-SignedIdentifier': owner.__signedIdentifier!, + }, + } {{/ unless }}); + + {{# if operation.output }} + return response.data; {{/ if }} + } + + {{# if operation.input }} + {{# if operation.input.target.isTemplateable }} + async getTemplateOn{{ firstToUpper operation.name }}(): Promise<{{ classDataName operation.input.target "" }}> { + const path = '{{ restPath operation.input.target "/~template" "" "" }}'; + const response = await this.axios.get(this.getPathForActor(path)); + + return response.data; + } + {{/ if }} + {{/ if }} + + {{# if operation.isInputRangeable }} + {{# neq relation.name targetRelation.name }} + /** + * From: relation.target.operations operation.isInputRangeable + * @throws {AxiosError} With data containing {@link Array} for status codes: 401, 403. + */ + async getRangeOn{{ firstToUpper operation.name }}({{# unless operation.isStatic }}owner: JudoIdentifiable<{{ classDataName relation.target "" }}> | {{ classDataName relation.target "" }}, {{/ unless }}queryCustomizer?:{{ classDataName operation.input.target "QueryCustomizer" }}): Promise> { + const path = '{{ operationRestPath relation.target operation '/~range' }}'; + const response = await this.axios.post(this.getPathForActor(path), { + {{# unless operation.isStatic }}owner: owner ?? {},{{/ unless }} + queryCustomizer: queryCustomizer ?? {} + }); + + return response.data; + } + {{/ neq }} + {{/ if }} {{/ each }} } diff --git a/judo-ui-typescript-rest-itest/ActionGroupTest/action_group_test__god/pom.xml b/judo-ui-typescript-rest-itest/ActionGroupTest/action_group_test__god/pom.xml index cb32474..a683778 100644 --- a/judo-ui-typescript-rest-itest/ActionGroupTest/action_group_test__god/pom.xml +++ b/judo-ui-typescript-rest-itest/ActionGroupTest/action_group_test__god/pom.xml @@ -133,28 +133,6 @@ - - format code - - pnpm - - test - - run format - - - - - format - - pnpm - - test - - run format - - - build diff --git a/judo-ui-typescript-rest-service/src/main/resources/data-service/accessService.ts.hbs b/judo-ui-typescript-rest-service/src/main/resources/data-service/accessService.ts.hbs index 6357371..98c5a75 100644 --- a/judo-ui-typescript-rest-service/src/main/resources/data-service/accessService.ts.hbs +++ b/judo-ui-typescript-rest-service/src/main/resources/data-service/accessService.ts.hbs @@ -1,17 +1,16 @@ {{> fragment.header.hbs }} import type { JudoDownloadFile, JudoMetaData } from '@judo/data-api-common'; -{{# if application.principal }} import { {{ classDataName application.principal "Stored" }} } from '../data-api';{{/ if }} +{{# if application.principal }}import { {{ classDataName application.principal "Stored" }} } from '../data-api';{{/ if }} export interface AccessService { - {{# if application.principal }} - getPrincipal(): Promise<{{ classDataName application.principal "Stored" }}>; + getPrincipal(): Promise<{{ classDataName application.principal "Stored" }}>; {{/if}} - getMetaData(): Promise; + getMetaData(): Promise; - uploadFile(attributePath: string, file: File): Promise; + uploadFile(attributePath: string, file: File): Promise; - downloadFile(downloadToken: string, disposition: 'inline' | 'attachment'): Promise; + downloadFile(downloadToken: string, disposition: 'inline' | 'attachment'): Promise; } diff --git a/judo-ui-typescript-rest-service/src/main/resources/data-service/classService.ts.hbs b/judo-ui-typescript-rest-service/src/main/resources/data-service/classService.ts.hbs index a23d65d..a5bcdf9 100644 --- a/judo-ui-typescript-rest-service/src/main/resources/data-service/classService.ts.hbs +++ b/judo-ui-typescript-rest-service/src/main/resources/data-service/classService.ts.hbs @@ -7,88 +7,68 @@ import { {{ joinedTokensForApiImportClassService classType }} } from '../data-ap * Class Service for {{ classDataName classType "" }} */ export interface {{ serviceClassName classType }} { - {{# if classType.isTemplateable }} - getTemplate(): Promise<{{ classDataName classType '' }}>; - {{/ if }} - - {{# if classType.isMapped }} - refresh(target: JudoIdentifiable<{{ classDataName classType "" }}>, queryCustomizer?: {{ classDataName classType "QueryCustomizer" }}): Promise<{{ classDataName classType "Stored" }}>; - {{/ if }} - - {{# if classType.isDeletable }} - delete(target: JudoIdentifiable<{{ classDataName classType "" }}>): Promise; - {{/ if }} - - {{# if classType.isUpdatable }} - update(target: Partial<{{ classDataName classType "Stored" }}>): Promise<{{ classDataName classType "Stored" }}>; - {{/ if }} - - {{# each classType.relations as | relation | }} - - {{# if relation.target.isTemplateable }} - getTemplateFor{{ firstToUpper relation.name }}(): Promise<{{ classDataName relation.target "" }}>; - {{/ if }} - - {{# if relation.isCreatable }} - create{{ firstToUpper relation.name }}(owner: JudoIdentifiable<{{ classDataName classType "" }}>, target: JudoIdentifiable<{{ classDataName relation.target "" }}>): Promise<{{ classDataName relation.target "Stored" }}>; - {{/ if }} - - {{# if relation.isRefreshable }} - {{# if relation.isCollection }}list{{ else }}get{{/ if }}{{ firstToUpper relation.name }}(target: JudoIdentifiable<{{ classDataName classType "" }}>, queryCustomizer?: {{ classDataName relation.target "QueryCustomizer" }}): Promise<{{# if relation.isCollection }}Array<{{/ if }}{{ classDataName relation.target "Stored" }}{{# if relation.isCollection }}>{{/ if }}> - {{/ if }} - - getRangeFor{{ firstToUpper relation.name }}(owner?: JudoIdentifiable<{{ classDataName classType "" }}> | {{ classDataName classType "" }}, queryCustomizer?: {{ classDataName relation.target "QueryCustomizer" }}): Promise>; - - {{# if relation.isSetable }} - set{{ firstToUpper relation.name }}(owner: JudoIdentifiable<{{ classDataName classType "" }}>, selected: {{# if relation.isCollection }}Array<{{/ if }}JudoIdentifiable<{{ classDataName relation.target "" }}>{{# if relation.isCollection }}>{{/ if }}): Promise; - {{/ if }} - - {{# if relation.isUnsetable }} - unset{{ firstToUpper relation.name }}(owner: JudoIdentifiable<{{ classDataName classType "" }}>): Promise; - {{/ if }} - - {{# if relation.isAddable }} - add{{ firstToUpper relation.name }}(owner: JudoIdentifiable<{{ classDataName classType "" }}>, selected: Array>): Promise; - {{/ if }} - - {{# if relation.isRemovable }} - remove{{ firstToUpper relation.name }}(owner: JudoIdentifiable<{{ classDataName classType "" }}>, selected: Array>): Promise; - {{/ if }} - - {{# if relation.isDeletable }} - delete{{ firstToUpper relation.name }}(target: JudoIdentifiable<{{ classDataName relation.target "" }}>): Promise; - {{/ if }} - - {{# each relation.target.operations as | operation | }} - {{ operation.name }}For{{ firstToUpper relation.name }}({{# if operation.isMapped }}owner: JudoIdentifiable<{{ classDataName relation.target "" }}>{{/ if }}{{# if operation.input }}{{# if operation.isMapped }}, {{/ if }}target: {{ classDataName operation.input.target "" }}{{/ if }}): Promise<{{# if operation.output }}{{ classDataName operation.output.target "Stored" }}{{ else }}void{{/ if }}>; - - {{# if operation.input }} - {{# if operation.input.target.isTemplateable }} - getTemplateOn{{ firstToUpper operation.name }}For{{ firstToUpper relation.name }}(): Promise<{{ classDataName operation.input.target "" }}>; - {{/ if }} - {{/ if }} - - {{# if operation.isInputRangeable }} - getRangeOn{{ firstToUpper operation.name }}For{{ firstToUpper relation.name }}(owner?: {{ classDataName relation.target "Stored" }}, queryCustomizer?: {{ classDataName operation.input.target "QueryCustomizer" }}): Promise>; - {{/ if }} - {{/ each }} - - {{/ each }} - {{# each classType.operations as | operation | }} - {{ operation.name }}({{# if operation.isMapped }}owner: JudoIdentifiable<{{ classDataName classType "" }}>{{/ if }}{{# if operation.input }}{{# if operation.isMapped }}, {{/ if }}target: {{ classDataName operation.input.target "" }}{{/ if }}): Promise<{{# if operation.output }}{{ classDataName operation.output.target "Stored" }}{{ else }}void{{/ if }}>; - - {{# if operation.input }} - {{# if operation.input.target.isTemplateable }} - getTemplateOn{{ firstToUpper operation.name }}(): Promise<{{ classDataName operation.input.target "" }}>; - {{/ if }} - {{/ if }} - - {{# each operation.input.target.relations as | relation | }} - getRangeOn{{ firstToUpper operation.name }}For{{ firstToUpper relation.name }}(owner?: JudoIdentifiable<{{ classDataName operation.input.target "" }}>, queryCustomizer?:{{ classDataName relation.target "QueryCustomizer" }}): Promise>; - {{/ each }} - - {{# if operation.isInputRangeable }} - getRangeOn{{ firstToUpper operation.name }}(owner?: {{ classDataName classType "Stored" }}, queryCustomizer?: {{ classDataName operation.input.target "QueryCustomizer" }}): Promise>; - {{/ if }} - {{/ each }} + {{# if classType.isTemplateable }} + getTemplate(): Promise<{{ classDataName classType '' }}>; + {{/ if }} + {{# if classType.isMapped }} + refresh(target: JudoIdentifiable<{{ classDataName classType "" }}>, queryCustomizer?: {{ classDataName classType "QueryCustomizer" }}): Promise<{{ classDataName classType "Stored" }}>; + {{/ if }} + {{# if classType.isDeletable }} + delete(target: JudoIdentifiable<{{ classDataName classType "" }}>): Promise; + {{/ if }} + {{# if classType.isUpdatable }} + update(target: Partial<{{ classDataName classType "Stored" }}>): Promise<{{ classDataName classType "Stored" }}>; + {{/ if }} + {{# each classType.relations as | relation | }} + {{# if relation.target.isTemplateable }} + getTemplateFor{{ firstToUpper relation.name }}(): Promise<{{ classDataName relation.target "" }}>; + {{/ if }} + {{# if relation.isCreatable }} + create{{ firstToUpper relation.name }}(owner: JudoIdentifiable<{{ classDataName classType "" }}>, target: JudoIdentifiable<{{ classDataName relation.target "" }}>): Promise<{{ classDataName relation.target "Stored" }}>; + {{/ if }} + {{# if relation.isRefreshable }} + {{# if relation.isCollection }}list{{ else }}get{{/ if }}{{ firstToUpper relation.name }}(target: JudoIdentifiable<{{ classDataName classType "" }}>, queryCustomizer?: {{ classDataName relation.target "QueryCustomizer" }}): Promise<{{# if relation.isCollection }}Array<{{/ if }}{{ classDataName relation.target "Stored" }}{{# if relation.isCollection }}>{{/ if }}> + {{/ if }} + getRangeFor{{ firstToUpper relation.name }}(owner?: JudoIdentifiable<{{ classDataName classType "" }}> | {{ classDataName classType "" }}, queryCustomizer?: {{ classDataName relation.target "QueryCustomizer" }}): Promise>; + {{# if relation.isSetable }} + set{{ firstToUpper relation.name }}(owner: JudoIdentifiable<{{ classDataName classType "" }}>, selected: {{# if relation.isCollection }}Array<{{/ if }}JudoIdentifiable<{{ classDataName relation.target "" }}>{{# if relation.isCollection }}>{{/ if }}): Promise; + {{/ if }} + {{# if relation.isUnsetable }} + unset{{ firstToUpper relation.name }}(owner: JudoIdentifiable<{{ classDataName classType "" }}>): Promise; + {{/ if }} + {{# if relation.isAddable }} + add{{ firstToUpper relation.name }}(owner: JudoIdentifiable<{{ classDataName classType "" }}>, selected: Array>): Promise; + {{/ if }} + {{# if relation.isRemovable }} + remove{{ firstToUpper relation.name }}(owner: JudoIdentifiable<{{ classDataName classType "" }}>, selected: Array>): Promise; + {{/ if }} + {{# if relation.isDeletable }} + delete{{ firstToUpper relation.name }}(target: JudoIdentifiable<{{ classDataName relation.target "" }}>): Promise; + {{/ if }} + {{# each relation.target.operations as | operation | }} + {{ operation.name }}For{{ firstToUpper relation.name }}({{# if operation.isMapped }}owner: JudoIdentifiable<{{ classDataName relation.target "" }}>{{/ if }}{{# if operation.input }}{{# if operation.isMapped }}, {{/ if }}target: {{ classDataName operation.input.target "" }}{{/ if }}): Promise<{{# if operation.output }}{{ classDataName operation.output.target "Stored" }}{{ else }}void{{/ if }}>; + {{# if operation.input }} + {{# if operation.input.target.isTemplateable }} + getTemplateOn{{ firstToUpper operation.name }}For{{ firstToUpper relation.name }}(): Promise<{{ classDataName operation.input.target "" }}>; + {{/ if }} + {{/ if }} + {{# if operation.isInputRangeable }} + getRangeOn{{ firstToUpper operation.name }}For{{ firstToUpper relation.name }}(owner?: {{ classDataName relation.target "Stored" }}, queryCustomizer?: {{ classDataName operation.input.target "QueryCustomizer" }}): Promise>; + {{/ if }} + {{/ each }} + {{/ each }} + {{# each classType.operations as | operation | }} + {{ operation.name }}({{# if operation.isMapped }}owner: JudoIdentifiable<{{ classDataName classType "" }}>{{/ if }}{{# if operation.input }}{{# if operation.isMapped }}, {{/ if }}target: {{ classDataName operation.input.target "" }}{{/ if }}): Promise<{{# if operation.output }}{{ classDataName operation.output.target "Stored" }}{{ else }}void{{/ if }}>; + {{# if operation.input }} + {{# if operation.input.target.isTemplateable }} + getTemplateOn{{ firstToUpper operation.name }}(): Promise<{{ classDataName operation.input.target "" }}>; + {{/ if }} + {{/ if }} + {{# each operation.input.target.relations as | relation | }} + getRangeOn{{ firstToUpper operation.name }}For{{ firstToUpper relation.name }}(owner?: JudoIdentifiable<{{ classDataName operation.input.target "" }}>, queryCustomizer?:{{ classDataName relation.target "QueryCustomizer" }}): Promise>; + {{/ each }} + {{# if operation.isInputRangeable }} + getRangeOn{{ firstToUpper operation.name }}(owner?: {{ classDataName classType "Stored" }}, queryCustomizer?: {{ classDataName operation.input.target "QueryCustomizer" }}): Promise>; + {{/ if }} + {{/ each }} } diff --git a/judo-ui-typescript-rest-service/src/main/resources/data-service/relationService.ts.hbs b/judo-ui-typescript-rest-service/src/main/resources/data-service/relationService.ts.hbs index 2b1509c..d525af2 100644 --- a/judo-ui-typescript-rest-service/src/main/resources/data-service/relationService.ts.hbs +++ b/judo-ui-typescript-rest-service/src/main/resources/data-service/relationService.ts.hbs @@ -4,145 +4,119 @@ import type { JudoIdentifiable } from '@judo/data-api-common'; import { {{ joinedTokensForApiImport relation }} } from '../data-api'; /** -* Relation Service for {{ classDataName (getRelationOwnerAsClassType relation) "" }}.{{ relation.name }} -*/ + * Relation Service for {{ classDataName (getRelationOwnerAsClassType relation) "" }}.{{ relation.name }} + */ export interface {{ serviceRelationName relation }} { {{# if relation.isListable }} - {{# if relation.isCollection }} - list(owner?: JudoIdentifiable, queryCustomizer?: {{ classDataName relation.target "QueryCustomizer" }}): Promise>; - {{/ if }} + {{# if relation.isCollection }} + list(owner?: JudoIdentifiable, queryCustomizer?: {{ classDataName relation.target "QueryCustomizer" }}): Promise>; + {{/ if }} {{/ if }} - {{# if relation.isRefreshable }} - {{# if relation.isAccess }} - {{# unless relation.isCollection }} - refreshFor{{ firstToUpper relation.name }}(queryCustomizer?: {{ classDataName relation.target "QueryCustomizer" }}): Promise<{{ classDataName relation.target "Stored" }}>; - {{/ unless }} - {{/ if }} - refresh(owner?: JudoIdentifiable, queryCustomizer?: {{ classDataName relation.target "QueryCustomizer" }}): Promise<{{ classDataName relation.target "Stored" }}>; + {{# if relation.isAccess }} + {{# unless relation.isCollection }} + refreshFor{{ firstToUpper relation.name }}(queryCustomizer?: {{ classDataName relation.target "QueryCustomizer" }}): Promise<{{ classDataName relation.target "Stored" }}>; + {{/ unless }} + {{/ if }} + refresh(owner?: JudoIdentifiable, queryCustomizer?: {{ classDataName relation.target "QueryCustomizer" }}): Promise<{{ classDataName relation.target "Stored" }}>; {{/ if }} - {{# if relation.isRangeable }} - getRangeFor{{ firstToUpper relation.name }}({{# unless relation.isAccess }}owner: JudoIdentifiable<{{ classDataName (getRelationOwnerAsClassType relation) "" }}> | {{ classDataName (getRelationOwnerAsClassType relation) "" }}, {{/ unless }}queryCustomizer?: {{ classDataName relation.target "QueryCustomizer" }}): Promise>; + getRangeFor{{ firstToUpper relation.name }}({{# unless relation.isAccess }}owner: JudoIdentifiable<{{ classDataName (getRelationOwnerAsClassType relation) "" }}> | {{ classDataName (getRelationOwnerAsClassType relation) "" }}, {{/ unless }}queryCustomizer?: {{ classDataName relation.target "QueryCustomizer" }}): Promise>; {{/ if }} - {{# if relation.target.isTemplateable }} - getTemplate(): Promise<{{ classDataName relation.target "" }}>; + getTemplate(): Promise<{{ classDataName relation.target "" }}>; {{/ if }} - {{# if relation.isCreatable }} - create({{# unless relation.isAccess }}owner: JudoIdentifiable<{{ classDataName (getRelationOwnerAsClassType relation) "" }}>, {{/ unless }}target: {{ classDataName relation.target "" }}): Promise<{{ classDataName relation.target "Stored" }}>; + create({{# unless relation.isAccess }}owner: JudoIdentifiable<{{ classDataName (getRelationOwnerAsClassType relation) "" }}>, {{/ unless }}target: {{ classDataName relation.target "" }}): Promise<{{ classDataName relation.target "Stored" }}>; {{/ if }} - {{# if relation.isDeletable }} - delete(target: JudoIdentifiable<{{ classDataName relation.target "" }}>): Promise; + delete(target: JudoIdentifiable<{{ classDataName relation.target "" }}>): Promise; {{/ if }} - {{# if relation.isUpdatable }} - update(target: Partial<{{ classDataName relation.target "Stored" }}>): Promise<{{ classDataName relation.target "Stored" }}>; + update(target: Partial<{{ classDataName relation.target "Stored" }}>): Promise<{{ classDataName relation.target "Stored" }}>; {{/ if }} - {{# if relation.isSetable }} - set{{ firstToUpper relation.name }}({{# unless relation.isAccess }}owner: JudoIdentifiable<{{ classDataName (getRelationOwnerAsClassType relation) "" }}>, {{/ unless }}selected:{{# if relation.isCollection }}Array<{{/ if }}JudoIdentifiable<{{ classDataName relation.target "" }}>{{# if relation.isCollection }}>{{/ if }}): Promise; + set{{ firstToUpper relation.name }}({{# unless relation.isAccess }}owner: JudoIdentifiable<{{ classDataName (getRelationOwnerAsClassType relation) "" }}>, {{/ unless }}selected:{{# if relation.isCollection }}Array<{{/ if }}JudoIdentifiable<{{ classDataName relation.target "" }}>{{# if relation.isCollection }}>{{/ if }}): Promise; {{/ if }} - {{# if relation.isUnsetable }} - unset{{ firstToUpper relation.name }}({{# unless relation.isAccess }}owner: JudoIdentifiable<{{ classDataName (getRelationOwnerAsClassType relation) "" }}>, {{/ unless }}): Promise; + unset{{ firstToUpper relation.name }}({{# unless relation.isAccess }}owner: JudoIdentifiable<{{ classDataName (getRelationOwnerAsClassType relation) "" }}>, {{/ unless }}): Promise; {{/ if }} - {{# if relation.isAddable }} - add{{ firstToUpper relation.name }}({{# unless relation.isAccess }}owner: JudoIdentifiable<{{ classDataName (getRelationOwnerAsClassType relation) "" }}>, {{/ unless }}selected: Array>): Promise; + add{{ firstToUpper relation.name }}({{# unless relation.isAccess }}owner: JudoIdentifiable<{{ classDataName (getRelationOwnerAsClassType relation) "" }}>, {{/ unless }}selected: Array>): Promise; {{/ if }} - {{# if relation.isRemovable }} - remove{{ firstToUpper relation.name }}({{# unless relation.isAccess }}owner: JudoIdentifiable<{{ classDataName (getRelationOwnerAsClassType relation) "" }}>, {{/ unless }}selected: Array>): Promise; + remove{{ firstToUpper relation.name }}({{# unless relation.isAccess }}owner: JudoIdentifiable<{{ classDataName (getRelationOwnerAsClassType relation) "" }}>, {{/ unless }}selected: Array>): Promise; {{/ if }} - {{# each relation.target.relations as | targetRelation | }} - {{# if targetRelation.isListable }} - {{# if targetRelation.isCollection }} - list{{ firstToUpper targetRelation.name }}(owner: JudoIdentifiable<{{ classDataName relation.target "" }}>, queryCustomizer?: {{ classDataName targetRelation.target "QueryCustomizer" }}): Promise>; - {{ else }} - get{{ firstToUpper targetRelation.name }}(owner: JudoIdentifiable<{{ classDataName relation.target "" }}>, queryCustomizer?: {{ classDataName targetRelation.target "QueryCustomizer" }}): Promise<{{ classDataName targetRelation.target "Stored" }}>; - {{/ if }} - {{/ if }} - - {{# if targetRelation.isRangeable }} - {{# neq relation.name targetRelation.name }} - getRangeFor{{ firstToUpper targetRelation.name }}(owner: JudoIdentifiable<{{ classDataName relation.target "" }}> | {{ classDataName relation.target "" }}, queryCustomizer: {{ classDataName targetRelation.target "QueryCustomizer" }}): Promise>; - {{/ neq }} - {{/ if }} - - {{# if targetRelation.target.isTemplateable }} - getTemplateFor{{ firstToUpper targetRelation.name }}(): Promise<{{ classDataName targetRelation.target "" }}>; - {{/ if }} - - {{# if targetRelation.isCreatable }} - create{{ firstToUpper targetRelation.name }}(owner: JudoIdentifiable<{{ classDataName relation.target "" }}>, target: {{ classDataName targetRelation.target "" }}): Promise<{{ classDataName targetRelation.target "Stored" }}>; - {{/ if }} - - {{# if targetRelation.isDeletable }} - delete{{ firstToUpper targetRelation.name }}(target: JudoIdentifiable<{{ classDataName targetRelation.target "" }}>): Promise; - {{/ if }} - - {{# if targetRelation.isUpdatable }} - update{{ firstToUpper targetRelation.name }}(owner: JudoIdentifiable<{{ classDataName relation.target "" }}>, target: Partial<{{ classDataName targetRelation.target "Stored" }}>): Promise<{{ classDataName targetRelation.target "Stored" }}>; - {{/ if }} - - {{# if targetRelation.isSetable }} - {{# neq relation.name targetRelation.name }} - set{{ firstToUpper targetRelation.name }}(owner: JudoIdentifiable<{{ classDataName relation.target "" }}>, selected: {{# if targetRelation.isCollection }}Array<{{/ if }}JudoIdentifiable<{{ classDataName targetRelation.target "" }}>{{# if targetRelation.isCollection }}>{{/ if }}): Promise; - {{/ neq }} - {{/ if }} - - {{# if targetRelation.isUnsetable }} - {{# neq relation.name targetRelation.name }} - unset{{ firstToUpper targetRelation.name }}(owner: JudoIdentifiable<{{ classDataName relation.target "" }}>, target: JudoIdentifiable<{{ classDataName targetRelation.target "" }}>): Promise; - {{/ neq }} - {{/ if }} - - {{# if targetRelation.isAddable }} - {{# neq relation.name targetRelation.name }} - add{{ firstToUpper targetRelation.name }}(owner: JudoIdentifiable<{{ classDataName relation.target "" }}>, selected: Array>): Promise; - {{/ neq }} - {{/ if }} - - {{# if targetRelation.isRemovable }} - {{# neq relation.name targetRelation.name }} - remove{{ firstToUpper targetRelation.name }}(owner: JudoIdentifiable<{{ classDataName relation.target "" }}>, selected: Array>): Promise; - {{/ neq }} - {{/ if }} - - {{# each targetRelation.target.operations as | operation | }} - {{ operation.name }}For{{ firstToUpper targetRelation.name }}({{# unless operation.isStatic }}owner: JudoIdentifiable<{{ classDataName targetRelation.target "" }}>{{/ unless }}{{# if operation.input }}{{# unless operation.isStatic }}, {{/ unless }}target: {{ classDataName operation.input.target "" }}{{/ if }}): Promise<{{# if operation.output }}{{ classDataName operation.output.target "Stored" }}{{ else }}void{{/ if }}>; - - {{# if operation.input }} - {{# if operation.input.target.isTemplateable }} - getTemplateOn{{ firstToUpper operation.name }}For{{ firstToUpper targetRelation.name }}(): Promise<{{ classDataName operation.input.target "" }}>; - {{/ if }} - {{/ if }} - - {{# if operation.isInputRangeable }} - {{# neq relation.name targetRelation.name }} - getRangeOn{{ firstToUpper operation.name }}For{{ firstToUpper targetRelation.name }}({{# unless operation.isStatic }}owner: JudoIdentifiable<{{ classDataName targetRelation.target "" }}> | {{ classDataName targetRelation.target "" }}, {{/ unless }}queryCustomizer?: {{ classDataName operation.input.target "QueryCustomizer" }}): Promise>; - {{/ neq }} - {{/ if }} - {{/ each }} + {{# if targetRelation.isListable }} + {{# if targetRelation.isCollection }} + list{{ firstToUpper targetRelation.name }}(owner: JudoIdentifiable<{{ classDataName relation.target "" }}>, queryCustomizer?: {{ classDataName targetRelation.target "QueryCustomizer" }}): Promise>; + {{ else }} + get{{ firstToUpper targetRelation.name }}(owner: JudoIdentifiable<{{ classDataName relation.target "" }}>, queryCustomizer?: {{ classDataName targetRelation.target "QueryCustomizer" }}): Promise<{{ classDataName targetRelation.target "Stored" }}>; + {{/ if }} + {{/ if }} + {{# if targetRelation.isRangeable }} + {{# neq relation.name targetRelation.name }} + getRangeFor{{ firstToUpper targetRelation.name }}(owner: JudoIdentifiable<{{ classDataName relation.target "" }}> | {{ classDataName relation.target "" }}, queryCustomizer: {{ classDataName targetRelation.target "QueryCustomizer" }}): Promise>; + {{/ neq }} + {{/ if }} + {{# if targetRelation.target.isTemplateable }} + getTemplateFor{{ firstToUpper targetRelation.name }}(): Promise<{{ classDataName targetRelation.target "" }}>; + {{/ if }} + {{# if targetRelation.isCreatable }} + create{{ firstToUpper targetRelation.name }}(owner: JudoIdentifiable<{{ classDataName relation.target "" }}>, target: {{ classDataName targetRelation.target "" }}): Promise<{{ classDataName targetRelation.target "Stored" }}>; + {{/ if }} + {{# if targetRelation.isDeletable }} + delete{{ firstToUpper targetRelation.name }}(target: JudoIdentifiable<{{ classDataName targetRelation.target "" }}>): Promise; + {{/ if }} + {{# if targetRelation.isUpdatable }} + update{{ firstToUpper targetRelation.name }}(owner: JudoIdentifiable<{{ classDataName relation.target "" }}>, target: Partial<{{ classDataName targetRelation.target "Stored" }}>): Promise<{{ classDataName targetRelation.target "Stored" }}>; + {{/ if }} + {{# if targetRelation.isSetable }} + {{# neq relation.name targetRelation.name }} + set{{ firstToUpper targetRelation.name }}(owner: JudoIdentifiable<{{ classDataName relation.target "" }}>, selected: {{# if targetRelation.isCollection }}Array<{{/ if }}JudoIdentifiable<{{ classDataName targetRelation.target "" }}>{{# if targetRelation.isCollection }}>{{/ if }}): Promise; + {{/ neq }} + {{/ if }} + {{# if targetRelation.isUnsetable }} + {{# neq relation.name targetRelation.name }} + unset{{ firstToUpper targetRelation.name }}(owner: JudoIdentifiable<{{ classDataName relation.target "" }}>, target: JudoIdentifiable<{{ classDataName targetRelation.target "" }}>): Promise; + {{/ neq }} + {{/ if }} + {{# if targetRelation.isAddable }} + {{# neq relation.name targetRelation.name }} + add{{ firstToUpper targetRelation.name }}(owner: JudoIdentifiable<{{ classDataName relation.target "" }}>, selected: Array>): Promise; + {{/ neq }} + {{/ if }} + {{# if targetRelation.isRemovable }} + {{# neq relation.name targetRelation.name }} + remove{{ firstToUpper targetRelation.name }}(owner: JudoIdentifiable<{{ classDataName relation.target "" }}>, selected: Array>): Promise; + {{/ neq }} + {{/ if }} + {{# each targetRelation.target.operations as | operation | }} + {{ operation.name }}For{{ firstToUpper targetRelation.name }}({{# unless operation.isStatic }}owner: JudoIdentifiable<{{ classDataName targetRelation.target "" }}>{{/ unless }}{{# if operation.input }}{{# unless operation.isStatic }}, {{/ unless }}target: {{ classDataName operation.input.target "" }}{{/ if }}): Promise<{{# if operation.output }}{{ classDataName operation.output.target "Stored" }}{{ else }}void{{/ if }}>; + {{# if operation.input }} + {{# if operation.input.target.isTemplateable }} + getTemplateOn{{ firstToUpper operation.name }}For{{ firstToUpper targetRelation.name }}(): Promise<{{ classDataName operation.input.target "" }}>; + {{/ if }} + {{/ if }} + {{# if operation.isInputRangeable }} + {{# neq relation.name targetRelation.name }} + getRangeOn{{ firstToUpper operation.name }}For{{ firstToUpper targetRelation.name }}({{# unless operation.isStatic }}owner: JudoIdentifiable<{{ classDataName targetRelation.target "" }}> | {{ classDataName targetRelation.target "" }}, {{/ unless }}queryCustomizer?: {{ classDataName operation.input.target "QueryCustomizer" }}): Promise>; + {{/ neq }} + {{/ if }} + {{/ each }} {{/ each}} - {{# each relation.target.operations as | operation | }} - {{ operation.name }}({{# unless operation.isStatic }}owner: JudoIdentifiable<{{ classDataName relation.target "" }}>{{/ unless }}{{# if operation.input }}{{# unless operation.isStatic }}, {{/ unless }}target: {{ classDataName operation.input.target "" }}{{/ if }}): Promise<{{# if operation.output }}{{ classDataName operation.output.target "Stored" }}{{ else }}void{{/ if }}>; - - {{# if operation.input }} - {{# if operation.input.target.isTemplateable }} - getTemplateOn{{ firstToUpper operation.name }}(): Promise<{{ classDataName operation.input.target "" }}>; - {{/ if }} - {{/ if }} - - {{# if operation.isInputRangeable }} - {{# neq relation.name targetRelation.name }} - getRangeOn{{ firstToUpper operation.name }}({{# unless operation.isStatic }}owner: JudoIdentifiable<{{ classDataName relation.target "" }}> | {{ classDataName relation.target "" }}, {{/ unless }}queryCustomizer?: {{ classDataName operation.input.target "QueryCustomizer" }}): Promise>; - {{/ neq }} - {{/ if }} + {{ operation.name }}({{# unless operation.isStatic }}owner: JudoIdentifiable<{{ classDataName relation.target "" }}>{{/ unless }}{{# if operation.input }}{{# unless operation.isStatic }}, {{/ unless }}target: {{ classDataName operation.input.target "" }}{{/ if }}): Promise<{{# if operation.output }}{{ classDataName operation.output.target "Stored" }}{{ else }}void{{/ if }}>; + {{# if operation.input }} + {{# if operation.input.target.isTemplateable }} + getTemplateOn{{ firstToUpper operation.name }}(): Promise<{{ classDataName operation.input.target "" }}>; + {{/ if }} + {{/ if }} + {{# if operation.isInputRangeable }} + {{# neq relation.name targetRelation.name }} + getRangeOn{{ firstToUpper operation.name }}({{# unless operation.isStatic }}owner: JudoIdentifiable<{{ classDataName relation.target "" }}> | {{ classDataName relation.target "" }}, {{/ unless }}queryCustomizer?: {{ classDataName operation.input.target "QueryCustomizer" }}): Promise>; + {{/ neq }} + {{/ if }} {{/ each }} } diff --git a/judo-ui-typescript-rest-service/src/main/resources/data-service/serviceIndex.ts.hbs b/judo-ui-typescript-rest-service/src/main/resources/data-service/serviceIndex.ts.hbs index c0480cb..c60898e 100644 --- a/judo-ui-typescript-rest-service/src/main/resources/data-service/serviceIndex.ts.hbs +++ b/judo-ui-typescript-rest-service/src/main/resources/data-service/serviceIndex.ts.hbs @@ -2,8 +2,8 @@ export * from './AccessService'; {{# each application.relationTypes as | fileName | }} - export * from './{{ serviceRelationName fileName }}'; +export * from './{{ serviceRelationName fileName }}'; {{/ each }} {{# each (getClassTypes application) as | fileName | }} - export * from './{{ serviceClassName fileName }}'; +export * from './{{ serviceClassName fileName }}'; {{/ each }}