Skip to content

Commit

Permalink
Tri-Intersection also now auto-generated.
Browse files Browse the repository at this point in the history
  • Loading branch information
buchananwill committed Apr 11, 2024
1 parent e2e9a1f commit 5d5b173
Show file tree
Hide file tree
Showing 24 changed files with 316 additions and 71 deletions.
1 change: 1 addition & 0 deletions app/api/READ-ONLY-generated-actions/Carousel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { generateBaseEndpointSet } from '../actions/template-base-endpoints';

export const {
getPage,
getAll,
deleteIdList,
postList,
putList,
Expand Down
1 change: 1 addition & 0 deletions app/api/READ-ONLY-generated-actions/CarouselGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { generateBaseEndpointSet } from '../actions/template-base-endpoints';

export const {
getPage,
getAll,
deleteIdList,
postList,
putList,
Expand Down
1 change: 1 addition & 0 deletions app/api/READ-ONLY-generated-actions/CarouselGroupOption.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { generateIntersectionEndpointSet } from '../actions/template-intersectio

export const {
getPage,
getAll,
deleteIdList,
postList,
putList,
Expand Down
1 change: 1 addition & 0 deletions app/api/READ-ONLY-generated-actions/CarouselOption.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { generateIntersectionEndpointSet } from '../actions/template-intersectio

export const {
getPage,
getAll,
deleteIdList,
postList,
putList,
Expand Down
1 change: 1 addition & 0 deletions app/api/READ-ONLY-generated-actions/CarouselOrder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { generateBaseEndpointSet } from '../actions/template-base-endpoints';

export const {
getPage,
getAll,
deleteIdList,
postList,
putList,
Expand Down
1 change: 1 addition & 0 deletions app/api/READ-ONLY-generated-actions/CarouselOrderItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { generateIntersectionEndpointSet } from '../actions/template-intersectio

export const {
getPage,
getAll,
deleteIdList,
postList,
putList,
Expand Down
1 change: 1 addition & 0 deletions app/api/READ-ONLY-generated-actions/Organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { generateGraphEndpointSet } from '../actions/template-graph-endpoints';

export const {
getPage,
getAll,
deleteIdList,
postList,
putList,
Expand Down
21 changes: 11 additions & 10 deletions app/api/READ-ONLY-generated-actions/OrganizationType.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
'use server';
import { OrganizationTypeDto } from '../dtos/OrganizationTypeDtoSchema';
import { generateBaseEndpointSet } from '../actions/template-base-endpoints';
import { generateGraphEndpointSet } from '../actions/template-graph-endpoints';
import { generateBaseEndpointSet } from '../actions/template-base-endpoints';

export const { getGraph, getGraphByNodeList, getGraphByRootId, putGraph } =
generateGraphEndpointSet<
OrganizationTypeDto
>(
'/api/v2/organizations/types'
);



export const {
getPage,
getAll,
deleteIdList,
postList,
putList,
Expand All @@ -22,12 +32,3 @@ export const {
);



export const { getGraph, getGraphByNodeList, getGraphByRootId, putGraph } =
generateGraphEndpointSet<
OrganizationTypeDto
>(
'/api/v2/organizations/types'
);


24 changes: 24 additions & 0 deletions app/api/READ-ONLY-generated-actions/Person.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
'use server';
import { PersonDto } from '../dtos/PersonDtoSchema';
import { generateBaseEndpointSet } from '../actions/template-base-endpoints';

export const {
getPage,
getAll,
deleteIdList,
postList,
putList,
getOne,
postOne,
putOne,
deleteOne,
getDtoListByBodyList,
getDtoListByParamList
} = generateBaseEndpointSet<
PersonDto,
number
>(
'/api/v2/persons'
);


29 changes: 29 additions & 0 deletions app/api/READ-ONLY-generated-actions/ProviderRole.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
'use server';
import { ProviderRoleDto } from '../dtos/ProviderRoleDtoSchema';
import { generateBaseEndpointSet } from '../actions/template-base-endpoints';
import { generateWithTypeEndpointSet } from '../actions/template-type-endpoints';

export const {
getPage,
getAll,
deleteIdList,
postList,
putList,
getOne,
postOne,
putOne,
deleteOne,
getDtoListByBodyList,
getDtoListByParamList
} = generateBaseEndpointSet<
ProviderRoleDto,
number
>(
'/api/v2/providerRoles'
);


export const { getByTypeIdList } = generateWithTypeEndpointSet<ProviderRoleDto>(
'/api/v2/providerRoles'
);

34 changes: 34 additions & 0 deletions app/api/READ-ONLY-generated-actions/ProviderRoleType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
'use server';
import { ProviderRoleTypeDto } from '../dtos/ProviderRoleTypeDtoSchema';
import { generateBaseEndpointSet } from '../actions/template-base-endpoints';
import { generateGraphEndpointSet } from '../actions/template-graph-endpoints';

export const {
getPage,
getAll,
deleteIdList,
postList,
putList,
getOne,
postOne,
putOne,
deleteOne,
getDtoListByBodyList,
getDtoListByParamList
} = generateBaseEndpointSet<
ProviderRoleTypeDto,
number
>(
'/api/v2/providerRoles'
);



export const { getGraph, getGraphByNodeList, getGraphByRootId, putGraph } =
generateGraphEndpointSet<
ProviderRoleTypeDto
>(
'/api/v2/providerRoles/types'
);


Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
'use server';
import { ProviderRoleTypeWorkTaskTypeSuitabilityDto } from '../dtos/ProviderRoleTypeWorkTaskTypeSuitabilityDtoSchema';
import { generateBaseEndpointSet } from '../actions/template-base-endpoints';
import { generateTriIntersectionEndpointSet } from '../actions/template-tri-intersection-endpoints';

export const {
getPage,
getAll,
deleteIdList,
postList,
putList,
getOne,
postOne,
putOne,
deleteOne,
getDtoListByBodyList,
getDtoListByParamList
} = generateBaseEndpointSet<
ProviderRoleTypeWorkTaskTypeSuitabilityDto,
number
>(
'/api/v2/workTaskType/providerRoleTypeSuitability'
);



export const {
getByRowIdListAndColumnIdListAndLayerId,
getByRowIdListAndLayerId,
getColumnIdListAndLayerId,
getTriIntersectionTable
} = generateTriIntersectionEndpointSet<
ProviderRoleTypeWorkTaskTypeSuitabilityDto,
number,
number,
number
>('/api/v2/workTaskType/providerRoleTypeSuitability');

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { generateBaseEndpointSet } from '../actions/template-base-endpoints';

export const {
getPage,
getAll,
deleteIdList,
postList,
putList,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { generateIntersectionEndpointSet } from '../actions/template-intersectio

export const {
getPage,
getAll,
deleteIdList,
postList,
putList,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { generateBaseEndpointSet } from '../actions/template-base-endpoints';

export const {
getPage,
getAll,
deleteIdList,
postList,
putList,
Expand Down
1 change: 1 addition & 0 deletions app/api/READ-ONLY-generated-actions/WorkTaskType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { generateGraphEndpointSet } from '../actions/template-graph-endpoints';

export const {
getPage,
getAll,
deleteIdList,
postList,
putList,
Expand Down
52 changes: 19 additions & 33 deletions app/api/actions/custom/provider-roles.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use server';
import { ActionResponsePromise } from '../actionResponse';
import { API_BASE_URL } from '../../main';
import { API_BASE_URL, isNotUndefined } from '../../main';
import {
getWithoutBody,
patchEntityList,
Expand All @@ -11,6 +11,8 @@ import { ProviderRoleDto } from '../../dtos/ProviderRoleDtoSchema';
import { NewProviderRoleDto } from '../../dtos/NewProviderRoleDtoSchema-Validation';
import { WorkTaskCompetencyDto } from '../../dtos/WorkTaskCompetencyDtoSchema';
import { ProviderRoleTypeWorkTaskTypeSuitabilityDto } from '../../dtos/ProviderRoleTypeWorkTaskTypeSuitabilityDtoSchema';
import { getAll } from '../../READ-ONLY-generated-actions/ProviderRoleType';
import { getByTypeIdList } from '../../READ-ONLY-generated-actions/ProviderRole';

const url = `${API_BASE_URL}/providers`;

Expand All @@ -23,36 +25,20 @@ export async function createTeacher(
return postEntitiesWithDifferentReturnType(formData, teachersUrl);
}

export async function updateTeachers(
teacherDtoList: ProviderRoleDto[]
): ActionResponsePromise<ProviderRoleDto[]> {
return patchEntityList(teacherDtoList, teachersUrl);
}

export async function getTeachers(): ActionResponsePromise<ProviderRoleDto[]> {
return getWithoutBody(teachersUrl);
}

export async function patchWorkTaskSuitabilities(
updatedSuitabilities: ProviderRoleTypeWorkTaskTypeSuitabilityDto[]
) {
return patchEntityList(
updatedSuitabilities,
`${url}/workTaskTypeSuitabilityRatings`
);
}

export async function getWorkTaskSuitabilities(
partyIdList: number[],
workTaskTypeIdList: number[]
) {
return postIntersectionTableRequest<
number,
number,
ProviderRoleTypeWorkTaskTypeSuitabilityDto
>({
idsForHasIdTypeT: partyIdList,
idsForHasIdTypeU: workTaskTypeIdList,
url: `${API_BASE_URL}/providers/workTaskCompetencies/intersectionTable`
});
export async function getTeachersV2() {
return getAll()
.then((r) => {
if (isNotUndefined(r.data)) {
const teacherType = r.data.find(
(roleType) => roleType.name.toLowerCase() === 'teacher'
);
if (isNotUndefined(teacherType))
return getByTypeIdList([teacherType.id]);
}
})
.then((r) => {
if (isNotUndefined(r) && isNotUndefined(r.data)) return r.data;
else return [];
})
.catch((e) => console.error(e));
}
6 changes: 6 additions & 0 deletions app/api/actions/template-base-endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export interface PageRequest {

export interface BaseEndpointSet<T, ID_TYPE extends string | number> {
getPage: (pageRequest: PageRequest) => ActionResponsePromise<Page<T>>;
getAll: () => ActionResponsePromise<T[]>;
putList: (dtoList: T[]) => ActionResponsePromise<T[]>;
postList: (dtoList: T[]) => ActionResponsePromise<T[]>;
deleteIdList: (idDeletionList: ID_TYPE[]) => ActionResponsePromise<ID_TYPE[]>;
Expand All @@ -51,6 +52,10 @@ async function getDtoList<T>(
): ActionResponsePromise<Page<T>> {
return getWithoutBody(`${url}?page=${page}&size=${pageSize}`);
}

async function getAll<T>(url: string) {
return getWithoutBody<T[]>(`${url}/listAll`);
}
async function getDtoListByParamList<T, ID_TYPE extends string | number>(
idList: ID_TYPE[],
url: string
Expand Down Expand Up @@ -123,6 +128,7 @@ export function generateBaseEndpointSet<

return {
getPage: (pageRequest) => getDtoList<T>(pageRequest, generatedUrl),
getAll: () => getAll(generatedUrl),
putList: (dtoList) => putDtoList(dtoList, generatedUrl),
postList: (dtoList) => postDtoList(dtoList, generatedUrl),
deleteIdList: (idDeletionList) =>
Expand Down
2 changes: 1 addition & 1 deletion app/api/actions/template-intersection-endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async function getIntersectionTable<T, U, V>(
export function generateIntersectionEndpointSet<T, U, V>(
path: string | string[]
): IntersectionEndpoints<T, U, V> {
const generatedUrl = constructUrl(path, 'graphs');
const generatedUrl = constructUrl(path);

return {
getIntersectionTable: (idsForHasIdTypeT, idsForHasIdTypeU) =>
Expand Down
Loading

0 comments on commit 5d5b173

Please sign in to comment.