diff --git a/core/src/adapters/property-base-adapter/generated/api-types.ts b/core/src/adapters/property-base-adapter/generated/api-types.ts index db13a4f4a..999db19f2 100644 --- a/core/src/adapters/property-base-adapter/generated/api-types.ts +++ b/core/src/adapters/property-base-adapter/generated/api-types.ts @@ -696,7 +696,7 @@ export interface paths { }; }; }; - "/facilities/rental-id/{rentalId}": { + "/facilities/by-rental-id/{rentalId}": { /** * Get a facility by rental ID * @description Returns a facility with the specified rental ID @@ -726,6 +726,66 @@ export interface paths { }; }; }; + "/facilities/by-property-code/{propertyCode}": { + /** + * Get facilities by property code + * @description Returns a list of facilities for the specified property code + */ + get: { + parameters: { + path: { + /** @description The property code of the property */ + propertyCode: string; + }; + }; + responses: { + /** @description Successfully retrieved the facilities */ + 200: { + content: { + "application/json": components["schemas"]["GetFacilitiesByPropertyCodeResponse"]; + }; + }; + /** @description Facilities not found */ + 404: { + content: never; + }; + /** @description Internal server error */ + 500: { + content: never; + }; + }; + }; + }; + "/facilities/by-building-code/{buildingCode}": { + /** + * Get facilities by building code + * @description Returns a list of facilities for the specified building code + */ + get: { + parameters: { + path: { + /** @description The building code of the building */ + buildingCode: string; + }; + }; + responses: { + /** @description Successfully retrieved the facilities */ + 200: { + content: { + "application/json": components["schemas"]["GetFacilitiesByBuildingCodeResponse"]; + }; + }; + /** @description Facilities not found */ + 404: { + content: never; + }; + /** @description Internal server error */ + 500: { + content: never; + }; + }; + }; + }; "/health": { /** * Check system health status @@ -1394,6 +1454,88 @@ export interface components { }; }; }; + GetFacilitiesByPropertyCodeResponse: { + content: ({ + id: string; + code: string; + name: string | null; + entrance: string | null; + deleted: boolean; + type: { + code: string; + name: string | null; + }; + rentalInformation: ({ + apartmentNumber: string | null; + rentalId: string | null; + type: { + code: string; + name: string | null; + }; + }) | null; + property: { + id: string | null; + name: string | null; + code: string | null; + }; + building: { + id: string | null; + name: string | null; + code: string | null; + }; + areaSize: number | null; + })[]; + _links: { + self: { + href: string; + }; + link: { + href: string; + templated: boolean; + }; + }; + }; + GetFacilitiesByBuildingCodeResponse: { + content: ({ + id: string; + code: string; + name: string | null; + entrance: string | null; + deleted: boolean; + type: { + code: string; + name: string | null; + }; + rentalInformation: ({ + apartmentNumber: string | null; + rentalId: string | null; + type: { + code: string; + name: string | null; + }; + }) | null; + property: { + id: string | null; + name: string | null; + code: string | null; + }; + building: { + id: string | null; + name: string | null; + code: string | null; + }; + areaSize: number | null; + })[]; + _links: { + self: { + href: string; + }; + link: { + href: string; + templated: boolean; + }; + }; + }; }; responses: never; parameters: never; diff --git a/core/src/adapters/property-base-adapter/index.ts b/core/src/adapters/property-base-adapter/index.ts index 208d3a6e4..7be5ab5ff 100644 --- a/core/src/adapters/property-base-adapter/index.ts +++ b/core/src/adapters/property-base-adapter/index.ts @@ -397,7 +397,7 @@ export async function getFacilityByRentalId( > { try { const fetchResponse = await client().GET( - '/facilities/rental-id/{rentalId}', + '/facilities/by-rental-id/{rentalId}', { params: { path: { rentalId } }, } @@ -475,3 +475,64 @@ export async function getMaintenanceUnitsByPropertyCode( return { ok: false, err: 'unknown' } } } + +type GetFacilitiesByPropertyCodeResponse = + components['schemas']['GetFacilitiesByPropertyCodeResponse']['content'] + +export async function getFacilitiesByPropertyCode( + propertyCode: string +): Promise< + AdapterResult +> { + try { + const fetchResponse = await client().GET( + '/facilities/by-property-code/{propertyCode}', + { + params: { path: { propertyCode } }, + } + ) + + if (fetchResponse.response.status === 404) { + return { ok: false, err: 'not-found' } + } + + if (!fetchResponse.data?.content) { + return { ok: false, err: 'unknown' } + } + + return { ok: true, data: fetchResponse.data.content } + } catch (err) { + logger.error({ err }, 'property-base-adapter.getFacilitiesByPropertyCode') + return { ok: false, err: 'unknown' } + } +} + +type GetFacilitiesByBuildingCodeResponse = + components['schemas']['GetFacilitiesByBuildingCodeResponse']['content'] +export async function getFacilitiesByBuildingCode( + buildingCode: string +): Promise< + AdapterResult +> { + try { + const fetchResponse = await client().GET( + '/facilities/by-building-code/{buildingCode}', + { + params: { path: { buildingCode } }, + } + ) + + if (fetchResponse.response.status === 404) { + return { ok: false, err: 'not-found' } + } + + if (!fetchResponse.data?.content) { + return { ok: false, err: 'unknown' } + } + + return { ok: true, data: fetchResponse.data.content } + } catch (err) { + logger.error({ err }, 'property-base-adapter.getFacilitiesByBuildingCode') + return { ok: false, err: 'unknown' } + } +} diff --git a/core/src/services/property-base-service/index.ts b/core/src/services/property-base-service/index.ts index 61518e46c..d0cac22da 100644 --- a/core/src/services/property-base-service/index.ts +++ b/core/src/services/property-base-service/index.ts @@ -1381,4 +1381,148 @@ export const routes = (router: KoaRouter) => { ctx.body = { error: 'Internal server error', ...metadata } } }) + + /** + * @swagger + * /propertyBase/facilities/by-property-code/{propertyCode}: + * get: + * summary: Get facilities by property code. + * description: Returns all facilities belonging to a property. + * tags: + * - Property base Service + * security: + * - bearerAuth: [] + * parameters: + * - in: path + * name: propertyCode + * required: true + * schema: + * type: string + * description: The code of the property for which to retrieve facilities. + * responses: + * 200: + * description: Successfully retrieved the facilities. + * content: + * application/json: + * schema: + * type: object + * properties: + * content: + * type: array + * items: + * type: object + * 404: + * description: Facilities not found. + * 500: + * description: Internal server error. + */ + router.get('(.*)/facilities/by-property-code/:propertyCode', async (ctx) => { + const metadata = generateRouteMetadata(ctx) + const { propertyCode } = ctx.params + + logger.info(`GET /facilities/by-property-code/${propertyCode}`, metadata) + + try { + const result = + await propertyBaseAdapter.getFacilitiesByPropertyCode(propertyCode) + + if (!result.ok) { + if (result.err === 'not-found') { + ctx.status = 404 + ctx.body = { error: 'Facilities not found', ...metadata } + return + } + + logger.error( + result.err, + 'Error getting facilities from property-base', + metadata + ) + ctx.status = 500 + ctx.body = { error: 'Internal server error', ...metadata } + return + } + + ctx.body = { + content: result.data satisfies Array, + ...metadata, + } + } catch (error) { + logger.error(error, 'Internal server error', metadata) + ctx.status = 500 + ctx.body = { error: 'Internal server error', ...metadata } + } + }) + + /** + * @swagger + * /propertyBase/facilities/by-building-code/{buildingCode}: + * get: + * summary: Get facilities by building code. + * description: Returns all facilities belonging to a building. + * tags: + * - Property base Service + * security: + * - bearerAuth: [] + * parameters: + * - in: path + * name: buildingCode + * required: true + * schema: + * type: string + * description: The code of the building for which to retrieve facilities. + * responses: + * 200: + * description: Successfully retrieved the facilities. + * content: + * application/json: + * schema: + * type: object + * properties: + * content: + * type: array + * items: + * type: object + * 404: + * description: Facilities not found. + * 500: + * description: Internal server error. + */ + router.get('(.*)/facilities/by-building-code/:buildingCode', async (ctx) => { + const metadata = generateRouteMetadata(ctx) + const { buildingCode } = ctx.params + + logger.info(`GET /facilities/by-building-code/${buildingCode}`, metadata) + + try { + const result = + await propertyBaseAdapter.getFacilitiesByBuildingCode(buildingCode) + + if (!result.ok) { + if (result.err === 'not-found') { + ctx.status = 404 + ctx.body = { error: 'Facilities not found', ...metadata } + return + } + + logger.error( + result.err, + 'Error getting facilities from property-base', + metadata + ) + ctx.status = 500 + ctx.body = { error: 'Internal server error', ...metadata } + return + } + + ctx.body = { + content: result.data satisfies Array, + ...metadata, + } + } catch (error) { + logger.error(error, 'Internal server error', metadata) + ctx.status = 500 + ctx.body = { error: 'Internal server error', ...metadata } + } + }) } diff --git a/services/property/src/adapters/facility-adapter.ts b/services/property/src/adapters/facility-adapter.ts index e06a8ca4c..31e93433d 100644 --- a/services/property/src/adapters/facility-adapter.ts +++ b/services/property/src/adapters/facility-adapter.ts @@ -5,6 +5,18 @@ import { trimStrings } from '@src/utils/data-conversion' import { prisma } from './db' +const getAreasByPropertyObjectIds = async ( + propertyObjectIds: string[] +): Promise> => { + if (propertyObjectIds.length === 0) return new Map() + + const areas = await prisma.quantityValue.findMany({ + where: { code: { in: propertyObjectIds } }, + }) + + return new Map(areas.map((area) => [area.code, area.value])) +} + export const getFacilityByRentalId = async (rentalId: string) => { try { const result = await prisma.propertyStructure.findFirst({ @@ -12,35 +24,15 @@ export const getFacilityByRentalId = async (rentalId: string) => { rentalId, propertyObject: { objectTypeId: 'balok' }, }, - select: { - buildingCode: true, - buildingName: true, - propertyCode: true, - propertyName: true, - propertyId: true, - buildingId: true, - rentalId: true, + include: { propertyObject: { - select: { - rentalInformation: { - select: { - apartmentNumber: true, - rentalInformationType: { select: { name: true, code: true } }, - }, - }, + include: { facility: { - select: { - id: true, - location: true, - entrance: true, - usage: true, - name: true, - code: true, - propertyObjectId: true, - availableFrom: true, - availableTo: true, - deleteMark: true, - facilityType: { select: { code: true, name: true } }, + include: { facilityType: true }, + }, + rentalInformation: { + include: { + rentalInformationType: true, }, }, }, @@ -56,21 +48,58 @@ export const getFacilityByRentalId = async (rentalId: string) => { 'rentalinformation-not-found' ) - const { - propertyObject: { facility, rentalInformation }, - } = result + // Get area for this facility + const areaSizeMap = await getAreasByPropertyObjectIds([ + result.propertyObject.facility.propertyObjectId, + ]) + const areaSize = + areaSizeMap.get(result.propertyObject.facility.propertyObjectId) ?? null - return trimStrings({ - ...result, - propertyObject: { facility, rentalInformation }, - }) + const facility = { + id: result.propertyObject.facility.id, + code: result.propertyObject.facility.code, + name: result.propertyObject.facility.name ?? null, + entrance: result.propertyObject.facility.entrance ?? null, + deleted: Boolean(result.propertyObject.facility.deleteMark), + type: { + code: result.propertyObject.facility.facilityType?.code || '', + name: result.propertyObject.facility.facilityType?.name || null, + }, + areaSize, + building: { + id: result.buildingId, + code: result.buildingCode, + name: result.buildingName, + }, + property: { + id: result.propertyId, + code: result.propertyCode, + name: result.propertyName, + }, + rentalInformation: { + rentalId: result.rentalId, + apartmentNumber: + result.propertyObject.rentalInformation.apartmentNumber, + type: { + code: + result.propertyObject.rentalInformation.rentalInformationType + ?.code || '', + name: + result.propertyObject.rentalInformation.rentalInformationType + ?.name || null, + }, + }, + } + + return trimStrings(facility) } catch (err) { if ( err instanceof Error && (err.message === 'property-structure-not-found' || err.message === 'property-object-not-found' || err.message === 'facility-not-found' || - err.message === 'rentalinformation-not-found') + err.message === 'rentalinformation-not-found' || + err.message.includes('rental-information-not-found')) ) { return null } @@ -80,40 +109,216 @@ export const getFacilityByRentalId = async (rentalId: string) => { } } -export const getFacilitySizeByRentalId = async (rentalId: string) => { +export const getFacilitiesByPropertyCode = async (propertyCode: string) => { try { - const propertyInfo = await prisma.propertyStructure.findFirst({ + const result = await prisma.propertyStructure.findMany({ where: { - rentalId, + propertyCode, propertyObject: { objectTypeId: 'balok' }, - NOT: { propertyCode: null }, }, - select: { - name: true, + include: { propertyObject: { - select: { - id: true, + include: { + facility: { + include: { facilityType: true }, + }, + rentalInformation: { + include: { + rentalInformationType: true, + }, + }, }, }, }, }) - if (propertyInfo === null) { - logger.warn( - 'residence-adapter.getFacilitySizeByRentalId: No property structure found for rentalId' - ) + assert(result.length > 0, 'property-structure-not-found') + + result.forEach((item, index) => { + assert(item.propertyObject, `property-object-not-found-at-index-${index}`) + if (item.propertyObject.facility) { + assert( + item.propertyObject.facility, + `facility-not-found-at-index-${index}` + ) + } + if (item.propertyObject.rentalInformation) { + assert( + item.propertyObject.rentalInformation, + `rental-information-not-found-at-index-${index}` + ) + } + }) + + // Get areas for all facilities + const propertyObjectIds = result + .filter((item) => item.propertyObject.facility) + .map((item) => item.propertyObject.facility!.propertyObjectId) + + const areaSizeMap = await getAreasByPropertyObjectIds(propertyObjectIds) + + const facilities = result + .filter((item) => item.propertyObject.facility) + .map((item) => ({ + id: item.propertyObject.facility!.id, + code: item.propertyObject.facility!.code, + name: item.propertyObject.facility!.name ?? null, + entrance: item.propertyObject.facility!.entrance ?? null, + deleted: Boolean(item.propertyObject.facility!.deleteMark), + type: { + code: item.propertyObject.facility!.facilityType?.code, + name: item.propertyObject.facility!.facilityType?.name || null, + }, + areaSize: + areaSizeMap.get(item.propertyObject.facility!.propertyObjectId) ?? + null, + building: { + id: item.buildingId, + code: item.buildingCode, + name: item.buildingName, + }, + property: { + id: item.propertyId, + code: item.propertyCode, + name: item.propertyName, + }, + rentalInformation: item.propertyObject.rentalInformation + ? { + rentalId: item.rentalId, + apartmentNumber: + item.propertyObject.rentalInformation.apartmentNumber || null, + type: { + code: + item.propertyObject.rentalInformation.rentalInformationType + ?.code || '', + name: + item.propertyObject.rentalInformation.rentalInformationType + ?.name || null, + }, + } + : null, + })) + + return trimStrings(facilities) + } catch (err) { + if ( + err instanceof Error && + (err.message === 'property-structure-not-found' || + err.message.includes('property-object-not-found') || + err.message.includes('facility-not-found') || + err.message.includes('rental-information-not-found')) + ) { return null } - const areaSize = await prisma.quantityValue.findFirst({ + logger.error({ err }, 'facility-adapter.getFacilitiesByPropertyCode') + throw err + } +} + +export const getFacilitiesByBuildingCode = async (buildingCode: string) => { + try { + const result = await prisma.propertyStructure.findMany({ where: { - code: propertyInfo.propertyObject.id, + buildingCode, + propertyObject: { objectTypeId: 'balok' }, + }, + include: { + propertyObject: { + include: { + facility: { + include: { facilityType: true }, + }, + rentalInformation: { + include: { + rentalInformationType: true, + }, + }, + }, + }, }, }) - return areaSize + assert(result.length > 0, 'property-structure-not-found') + + result.forEach((item, index) => { + assert(item.propertyObject, `property-object-not-found-at-index-${index}`) + if (item.propertyObject.facility) { + assert( + item.propertyObject.facility, + `facility-not-found-at-index-${index}` + ) + } + if (item.propertyObject.rentalInformation) { + assert( + item.propertyObject.rentalInformation, + `rental-information-not-found-at-index-${index}` + ) + } + }) + + // Get areas for all facilities + const propertyObjectIds = result + .filter((item) => item.propertyObject.facility) + .map((item) => item.propertyObject.facility!.propertyObjectId) + + const areaSizeMap = await getAreasByPropertyObjectIds(propertyObjectIds) + + const facilities = result + .filter((item) => item.propertyObject.facility) + .map((item) => ({ + id: item.propertyObject.facility!.id, + code: item.propertyObject.facility!.code, + name: item.propertyObject.facility!.name ?? null, + entrance: item.propertyObject.facility!.entrance ?? null, + deleted: Boolean(item.propertyObject.facility!.deleteMark), + type: { + code: item.propertyObject.facility!.facilityType?.code, + name: item.propertyObject.facility!.facilityType?.name || null, + }, + areaSize: + areaSizeMap.get(item.propertyObject.facility!.propertyObjectId) ?? + null, + building: { + id: item.buildingId, + code: item.buildingCode, + name: item.buildingName, + }, + property: { + id: item.propertyId, + code: item.propertyCode, + name: item.propertyName, + }, + rentalInformation: item.propertyObject.rentalInformation + ? { + rentalId: item.rentalId, + apartmentNumber: + item.propertyObject.rentalInformation.apartmentNumber || null, + type: { + code: + item.propertyObject.rentalInformation.rentalInformationType + ?.code || '', + name: + item.propertyObject.rentalInformation.rentalInformationType + ?.name || null, + }, + } + : null, + })) + + return trimStrings(facilities) } catch (err) { - logger.error({ err }, 'facility-adapter.getFacilitySizeByRentalId') + if ( + err instanceof Error && + (err.message === 'property-structure-not-found' || + err.message.includes('property-object-not-found') || + err.message.includes('facility-not-found') || + err.message.includes('rental-information-not-found')) + ) { + return null + } + + logger.error({ err }, 'facility-adapter.getFacilitiesByBuildingCode') throw err } } diff --git a/services/property/src/routes/facilities.ts b/services/property/src/routes/facilities.ts index 54dbc3b64..0a2070188 100644 --- a/services/property/src/routes/facilities.ts +++ b/services/property/src/routes/facilities.ts @@ -2,10 +2,15 @@ import KoaRouter from '@koa/router' import { logger, generateRouteMetadata } from '@onecore/utilities' import { + getFacilitiesByBuildingCode, + getFacilitiesByPropertyCode, getFacilityByRentalId, - getFacilitySizeByRentalId, } from '@src/adapters/facility-adapter' -import { GetFacilityByRentalIdResponse } from '@src/types/facility' +import { + GetFacilityByRentalIdResponse, + GetFacilitiesByPropertyCodeResponse, + GetFacilitiesByBuildingCodeResponse, +} from '@src/types/facility' /** * @swagger @@ -17,7 +22,7 @@ import { GetFacilityByRentalIdResponse } from '@src/types/facility' export const routes = (router: KoaRouter) => { /** * @swagger - * /facilities/rental-id/{rentalId}: + * /facilities/by-rental-id/{rentalId}: * get: * summary: Get a facility by rental ID * description: Returns a facility with the specified rental ID @@ -42,8 +47,9 @@ export const routes = (router: KoaRouter) => { * 500: * description: Internal server error */ - router.get('(.*)/facilities/rental-id/:rentalId', async (ctx) => { + router.get('/facilities/by-rental-id/:rentalId', async (ctx) => { const metadata = generateRouteMetadata(ctx) + logger.info(`GET /facilities/by-rental-id/${ctx.params.rentalId}`, metadata) try { const facility = await getFacilityByRentalId(ctx.params.rentalId) @@ -53,42 +59,8 @@ export const routes = (router: KoaRouter) => { return } - const areaSize = await getFacilitySizeByRentalId(ctx.params.rentalId) - const payload: GetFacilityByRentalIdResponse = { - content: { - id: facility.propertyObject.facility.id, - code: facility.propertyObject.facility.code, - name: facility.propertyObject.facility.name, - entrance: facility.propertyObject.facility.entrance, - deleted: Boolean(facility.propertyObject.facility.deleteMark), - type: { - code: facility.propertyObject.facility.facilityType.code, - name: facility.propertyObject.facility.facilityType.name, - }, - areaSize: areaSize?.value ?? null, - building: { - id: facility.buildingId, - code: facility.buildingCode, - name: facility.buildingName, - }, - property: { - id: facility.propertyId, - code: facility.propertyCode, - name: facility.propertyName, - }, - rentalInformation: { - rentalId: facility.rentalId, - apartmentNumber: - facility.propertyObject.rentalInformation.apartmentNumber, - type: { - code: facility.propertyObject.rentalInformation - .rentalInformationType.code, - name: facility.propertyObject.rentalInformation - .rentalInformationType.name, - }, - }, - }, + content: facility, ...metadata, } @@ -101,4 +73,126 @@ export const routes = (router: KoaRouter) => { ctx.body = { reason: errorMessage, ...metadata } } }) + + /** + * @swagger + * /facilities/by-property-code/{propertyCode}: + * get: + * summary: Get facilities by property code + * description: Returns a list of facilities for the specified property code + * tags: + * - Facilities + * parameters: + * - in: path + * name: propertyCode + * required: true + * schema: + * type: string + * description: The property code of the property + * responses: + * 200: + * description: Successfully retrieved the facilities + * content: + * application/json: + * schema: + * $ref: '#/components/schemas/GetFacilitiesByPropertyCodeResponse' + * 404: + * description: Facilities not found + * 500: + * description: Internal server error + */ + router.get('/facilities/by-property-code/:propertyCode', async (ctx) => { + const metadata = generateRouteMetadata(ctx) + logger.info( + `GET /facilities/property-code/${ctx.params.propertyCode}`, + metadata + ) + + try { + const facilities = await getFacilitiesByPropertyCode( + ctx.params.propertyCode + ) + if (!facilities || facilities.length === 0) { + ctx.status = 404 + ctx.body = { reason: 'facilities-not-found', ...metadata } + return + } + + const payload: GetFacilitiesByPropertyCodeResponse = { + content: facilities, + ...metadata, + } + + ctx.status = 200 + ctx.body = payload + } catch (err) { + logger.error(err, 'Error fetching facilities by property code') + ctx.status = 500 + const errorMessage = err instanceof Error ? err.message : 'unknown error' + ctx.body = { reason: errorMessage, ...metadata } + } + }) + + /** + * @swagger + * /facilities/by-building-code/{buildingCode}: + * get: + * summary: Get facilities by building code + * description: Returns a list of facilities for the specified building code + * tags: + * - Facilities + * parameters: + * - in: path + * name: buildingCode + * required: true + * schema: + * type: string + * description: The building code of the building + * responses: + * 200: + * description: Successfully retrieved the facilities + * content: + * application/json: + * schema: + * $ref: '#/components/schemas/GetFacilitiesByBuildingCodeResponse' + * 404: + * description: Facilities not found + * 500: + * description: Internal server error + */ + router.get('/facilities/by-building-code/:buildingCode', async (ctx) => { + const metadata = generateRouteMetadata(ctx) + logger.info( + `GET /facilities/building-code/${ctx.params.buildingCode}`, + metadata + ) + + try { + console.log( + 'Fetching facilities by building code:', + ctx.params.buildingCode + ) + const facilities = await getFacilitiesByBuildingCode( + ctx.params.buildingCode + ) + if (!facilities || facilities.length === 0) { + ctx.status = 404 + ctx.body = { reason: 'facilities-not-found', ...metadata } + return + } + + const payload: GetFacilitiesByBuildingCodeResponse = { + content: facilities, + ...metadata, + } + + ctx.status = 200 + ctx.body = payload + } catch (err) { + logger.error(err, 'Error fetching facilities by building code') + ctx.status = 500 + const errorMessage = err instanceof Error ? err.message : 'unknown error' + ctx.body = { reason: errorMessage, ...metadata } + } + }) } diff --git a/services/property/src/routes/swagger.ts b/services/property/src/routes/swagger.ts index 58289789b..6c4756d63 100644 --- a/services/property/src/routes/swagger.ts +++ b/services/property/src/routes/swagger.ts @@ -74,6 +74,14 @@ const schemas = { name: 'GetFacilityByRentalIdResponse', target: 'openApi3', }).definitions, + ...zodToJsonSchema(types.GetFacilitiesByPropertyCodeResponseSchema, { + name: 'GetFacilitiesByPropertyCodeResponse', + target: 'openApi3', + }).definitions, + ...zodToJsonSchema(types.GetFacilitiesByBuildingCodeResponseSchema, { + name: 'GetFacilitiesByBuildingCodeResponse', + target: 'openApi3', + }).definitions, } swaggerSpec.definition.components = { diff --git a/services/property/src/types/facility.ts b/services/property/src/types/facility.ts index e43d3dbe6..03be273fa 100644 --- a/services/property/src/types/facility.ts +++ b/services/property/src/types/facility.ts @@ -42,3 +42,17 @@ export const GetFacilityByRentalIdResponseSchema = createGenericResponseSchema( export type GetFacilityByRentalIdResponse = z.infer< typeof GetFacilityByRentalIdResponseSchema > + +export const GetFacilitiesByPropertyCodeResponseSchema = + createGenericResponseSchema(z.array(FacilityDetailsSchema)) + +export type GetFacilitiesByPropertyCodeResponse = z.infer< + typeof GetFacilitiesByPropertyCodeResponseSchema +> + +export const GetFacilitiesByBuildingCodeResponseSchema = + createGenericResponseSchema(z.array(FacilityDetailsSchema)) + +export type GetFacilitiesByBuildingCodeResponse = z.infer< + typeof GetFacilitiesByBuildingCodeResponseSchema +>