diff --git a/integration_tests/tests/manage/cancellation.cy.ts b/integration_tests/tests/manage/cancellation.cy.ts index fff4f22e49..eef73dbe9e 100644 --- a/integration_tests/tests/manage/cancellation.cy.ts +++ b/integration_tests/tests/manage/cancellation.cy.ts @@ -1,3 +1,4 @@ +import type { Cancellation } from '@approved-premises/api' import { applicationFactory, bookingFactory, @@ -97,9 +98,11 @@ context('Cancellation', () => { page.completeForm(cancellation) // Then a cancellation should have been created in the API - cy.task('verifyApiPost', `/premises/${premises.id}/bookings/${booking.id}/cancellations`).then(({ reason }) => { - expect(reason).equal(cancellation.reason) - }) + cy.task('verifyApiPost', `/premises/${premises.id}/bookings/${booking.id}/cancellations`).then( + ({ reason }: Cancellation) => { + expect(reason).equal(cancellation.reason) + }, + ) // And I should see a confirmation message const confirmationPage = new BookingCancellationConfirmPage() @@ -138,7 +141,7 @@ context('Cancellation', () => { // Given a booking is available const application = applicationFactory.build() const placement = cas1SpaceBookingFactory.upcoming().build({ applicationId: application.id }) - const premises = extendedPremisesSummaryFactory.build({ bookings: [placement], id: placement.premises.id }) + const premises = premisesFactory.build({ id: placement.premises.id }) const placementId = placement.id const premisesId = premises.id diff --git a/server/@types/shared/index.d.ts b/server/@types/shared/index.d.ts index 8179a1abcd..939cc5fc4e 100644 --- a/server/@types/shared/index.d.ts +++ b/server/@types/shared/index.d.ts @@ -91,6 +91,10 @@ export type { Cas1CruManagementArea } from './models/Cas1CruManagementArea'; export type { Cas1KeyWorkerAllocation } from './models/Cas1KeyWorkerAllocation'; export type { Cas1NewArrival } from './models/Cas1NewArrival'; export type { Cas1NewDeparture } from './models/Cas1NewDeparture'; +export type { Cas1NewOutOfServiceBed } from './models/Cas1NewOutOfServiceBed'; +export type { Cas1NewOutOfServiceBedCancellation } from './models/Cas1NewOutOfServiceBedCancellation'; +export type { Cas1NewSpaceBooking } from './models/Cas1NewSpaceBooking'; +export type { Cas1NewSpaceBookingCancellation } from './models/Cas1NewSpaceBookingCancellation'; export type { Cas1NonArrival } from './models/Cas1NonArrival'; export type { Cas1OutOfServiceBed } from './models/Cas1OutOfServiceBed'; export type { Cas1OutOfServiceBedCancellation } from './models/Cas1OutOfServiceBedCancellation'; @@ -179,10 +183,6 @@ export type { NewBedMove } from './models/NewBedMove'; export type { NewBooking } from './models/NewBooking'; export type { NewBookingNotMade } from './models/NewBookingNotMade'; export type { NewCancellation } from './models/NewCancellation'; -export type { NewCas1OutOfServiceBed } from './models/NewCas1OutOfServiceBed'; -export type { NewCas1OutOfServiceBedCancellation } from './models/NewCas1OutOfServiceBedCancellation'; -export type { NewCas1SpaceBooking } from './models/NewCas1SpaceBooking'; -export type { NewCas1SpaceBookingCancellation } from './models/NewCas1SpaceBookingCancellation'; export type { NewCas2ApplicationNote } from './models/NewCas2ApplicationNote'; export type { NewCas2Arrival } from './models/NewCas2Arrival'; export type { NewCas3Arrival } from './models/NewCas3Arrival'; diff --git a/server/@types/shared/models/ApprovedPremisesApplication.ts b/server/@types/shared/models/ApprovedPremisesApplication.ts index 1f53e3c667..16ceaffdd1 100644 --- a/server/@types/shared/models/ApprovedPremisesApplication.ts +++ b/server/@types/shared/models/ApprovedPremisesApplication.ts @@ -49,5 +49,6 @@ export type ApprovedPremisesApplication = (Application & { caseManagerIsNotApplicant?: boolean; caseManagerUserDetails?: Cas1ApplicationUserDetails; genderForAp?: GenderForAp; + licenceExpiryDate?: string; }); diff --git a/server/@types/shared/models/ApprovedPremisesUserRole.ts b/server/@types/shared/models/ApprovedPremisesUserRole.ts index d25a02955d..1ca55a84d1 100644 --- a/server/@types/shared/models/ApprovedPremisesUserRole.ts +++ b/server/@types/shared/models/ApprovedPremisesUserRole.ts @@ -2,4 +2,4 @@ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export type ApprovedPremisesUserRole = 'assessor' | 'matcher' | 'manager' | 'legacy_manager' | 'future_manager' | 'workflow_manager' | 'cru_member' | 'cru_member_find_and_book_beta' | 'applicant' | 'role_admin' | 'report_viewer' | 'excluded_from_assess_allocation' | 'excluded_from_match_allocation' | 'excluded_from_placement_application_allocation' | 'appeals_manager' | 'janitor' | 'user_manager'; +export type ApprovedPremisesUserRole = 'assessor' | 'matcher' | 'legacy_manager' | 'future_manager' | 'workflow_manager' | 'cru_member' | 'cru_member_find_and_book_beta' | 'applicant' | 'role_admin' | 'report_viewer' | 'excluded_from_assess_allocation' | 'excluded_from_match_allocation' | 'excluded_from_placement_application_allocation' | 'appeals_manager' | 'janitor' | 'user_manager'; diff --git a/server/@types/shared/models/Cas1KeyWorkerAllocation.ts b/server/@types/shared/models/Cas1KeyWorkerAllocation.ts index 5bf1323d0b..82a57d1aa5 100644 --- a/server/@types/shared/models/Cas1KeyWorkerAllocation.ts +++ b/server/@types/shared/models/Cas1KeyWorkerAllocation.ts @@ -5,6 +5,6 @@ import type { StaffMember } from './StaffMember'; export type Cas1KeyWorkerAllocation = { keyWorker: StaffMember; - allocatedAt: string; + allocatedAt?: string; }; diff --git a/server/@types/shared/models/Cas1NewArrival.ts b/server/@types/shared/models/Cas1NewArrival.ts index 856d2a107d..1b00005cb7 100644 --- a/server/@types/shared/models/Cas1NewArrival.ts +++ b/server/@types/shared/models/Cas1NewArrival.ts @@ -3,6 +3,12 @@ /* tslint:disable */ /* eslint-disable */ export type Cas1NewArrival = { - arrivalDateTime: string; + /** + * This is deprecated. Instead use arrivalDate and arrivalTime + * @deprecated + */ + arrivalDateTime?: string; + arrivalDate?: string; + arrivalTime?: string; }; diff --git a/server/@types/shared/models/Cas1NewDeparture.ts b/server/@types/shared/models/Cas1NewDeparture.ts index 78d2eff84a..935e0de0e0 100644 --- a/server/@types/shared/models/Cas1NewDeparture.ts +++ b/server/@types/shared/models/Cas1NewDeparture.ts @@ -3,7 +3,9 @@ /* tslint:disable */ /* eslint-disable */ export type Cas1NewDeparture = { - departureDateTime: string; + departureDateTime?: string; + departureDate?: string; + departureTime?: string; reasonId: string; moveOnCategoryId?: string; notes?: string; diff --git a/server/@types/shared/models/NewCas1OutOfServiceBed.ts b/server/@types/shared/models/Cas1NewOutOfServiceBed.ts similarity index 87% rename from server/@types/shared/models/NewCas1OutOfServiceBed.ts rename to server/@types/shared/models/Cas1NewOutOfServiceBed.ts index ea8f7b4b2f..a78118af46 100644 --- a/server/@types/shared/models/NewCas1OutOfServiceBed.ts +++ b/server/@types/shared/models/Cas1NewOutOfServiceBed.ts @@ -2,7 +2,7 @@ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export type NewCas1OutOfServiceBed = { +export type Cas1NewOutOfServiceBed = { startDate: string; endDate: string; reason: string; diff --git a/server/@types/shared/models/NewCas1OutOfServiceBedCancellation.ts b/server/@types/shared/models/Cas1NewOutOfServiceBedCancellation.ts similarity index 75% rename from server/@types/shared/models/NewCas1OutOfServiceBedCancellation.ts rename to server/@types/shared/models/Cas1NewOutOfServiceBedCancellation.ts index 3cacec7cf6..253c79a166 100644 --- a/server/@types/shared/models/NewCas1OutOfServiceBedCancellation.ts +++ b/server/@types/shared/models/Cas1NewOutOfServiceBedCancellation.ts @@ -2,7 +2,7 @@ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export type NewCas1OutOfServiceBedCancellation = { +export type Cas1NewOutOfServiceBedCancellation = { notes?: string; }; diff --git a/server/@types/shared/models/NewCas1SpaceBooking.ts b/server/@types/shared/models/Cas1NewSpaceBooking.ts similarity index 90% rename from server/@types/shared/models/NewCas1SpaceBooking.ts rename to server/@types/shared/models/Cas1NewSpaceBooking.ts index 7c974e185c..9bd32e9eb7 100644 --- a/server/@types/shared/models/NewCas1SpaceBooking.ts +++ b/server/@types/shared/models/Cas1NewSpaceBooking.ts @@ -3,7 +3,7 @@ /* tslint:disable */ /* eslint-disable */ import type { Cas1SpaceBookingRequirements } from './Cas1SpaceBookingRequirements'; -export type NewCas1SpaceBooking = { +export type Cas1NewSpaceBooking = { arrivalDate: string; departureDate: string; premisesId: string; diff --git a/server/@types/shared/models/NewCas1SpaceBookingCancellation.ts b/server/@types/shared/models/Cas1NewSpaceBookingCancellation.ts similarity index 81% rename from server/@types/shared/models/NewCas1SpaceBookingCancellation.ts rename to server/@types/shared/models/Cas1NewSpaceBookingCancellation.ts index b0bbb47501..d88fcc9b7d 100644 --- a/server/@types/shared/models/NewCas1SpaceBookingCancellation.ts +++ b/server/@types/shared/models/Cas1NewSpaceBookingCancellation.ts @@ -2,7 +2,7 @@ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export type NewCas1SpaceBookingCancellation = { +export type Cas1NewSpaceBookingCancellation = { occurredAt: string; reasonId: string; reasonNotes?: string; diff --git a/server/@types/shared/models/Cas1PremisesSummary.ts b/server/@types/shared/models/Cas1PremisesSummary.ts index 5e0f82d4d9..d5fb4c4453 100644 --- a/server/@types/shared/models/Cas1PremisesSummary.ts +++ b/server/@types/shared/models/Cas1PremisesSummary.ts @@ -22,5 +22,6 @@ export type Cas1PremisesSummary = { */ outOfServiceBeds: number; supportsSpaceBookings: boolean; + managerDetails?: string; }; diff --git a/server/@types/shared/models/Cas1SpaceBooking.ts b/server/@types/shared/models/Cas1SpaceBooking.ts index a6422c2fb4..a7f4c87aae 100644 --- a/server/@types/shared/models/Cas1SpaceBooking.ts +++ b/server/@types/shared/models/Cas1SpaceBooking.ts @@ -8,6 +8,7 @@ import type { Cas1SpaceBookingDates } from './Cas1SpaceBookingDates'; import type { Cas1SpaceBookingDeparture } from './Cas1SpaceBookingDeparture'; import type { Cas1SpaceBookingNonArrival } from './Cas1SpaceBookingNonArrival'; import type { Cas1SpaceBookingRequirements } from './Cas1SpaceBookingRequirements'; +import type { Cas1SpaceBookingSummaryStatus } from './Cas1SpaceBookingSummaryStatus'; import type { NamedId } from './NamedId'; import type { Person } from './Person'; import type { User } from './User'; @@ -24,8 +25,26 @@ export type Cas1SpaceBooking = { requestForPlacementId?: string; expectedArrivalDate: string; expectedDepartureDate: string; + /** + * Use actualArrivalDateOnly and actualArrivalTime + * @deprecated + */ actualArrivalDate?: string; + actualArrivalDateOnly?: string; + /** + * This value may not be defined even if an arrival date is + */ + actualArrivalTime?: string; + /** + * Use actualDepartureDateOnly and actualDepartureTime + * @deprecated + */ actualDepartureDate?: string; + actualDepartureDateOnly?: string; + /** + * This value may not be defined even if a departure date is + */ + actualDepartureTime?: string; /** * actual arrival date or, if not known, the expected arrival date */ @@ -41,5 +60,6 @@ export type Cas1SpaceBooking = { cancellation?: Cas1SpaceBookingCancellation; nonArrival?: Cas1SpaceBookingNonArrival; deliusEventNumber?: string; + status?: Cas1SpaceBookingSummaryStatus; }; diff --git a/server/@types/shared/models/MigrationJobType.ts b/server/@types/shared/models/MigrationJobType.ts index 23bf69515b..e665421f28 100644 --- a/server/@types/shared/models/MigrationJobType.ts +++ b/server/@types/shared/models/MigrationJobType.ts @@ -2,4 +2,4 @@ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export type MigrationJobType = 'update_all_users_from_community_api' | 'update_sentence_type_and_situation' | 'update_booking_status' | 'update_task_due_dates' | 'update_users_pdu_by_api' | 'update_cas2_applications_with_assessments' | 'update_cas2_status_updates_with_assessments' | 'update_cas2_notes_with_assessments' | 'update_cas1_fix_placement_app_links' | 'update_cas1_notice_types' | 'update_cas1_backfill_user_ap_area' | 'update_cas3_application_offender_name' | 'update_cas3_domain_event_type_for_person_departed_updated'; +export type MigrationJobType = 'update_all_users_from_community_api' | 'update_sentence_type_and_situation' | 'update_booking_status' | 'update_task_due_dates' | 'update_users_pdu_by_api' | 'update_cas2_applications_with_assessments' | 'update_cas2_status_updates_with_assessments' | 'update_cas2_notes_with_assessments' | 'update_cas1_fix_placement_app_links' | 'update_cas1_notice_types' | 'update_cas1_backfill_user_ap_area' | 'update_cas3_application_offender_name' | 'update_cas3_domain_event_type_for_person_departed_updated' | 'update_cas1_applications_licence_expiry_date'; diff --git a/server/@types/shared/models/SubmitApprovedPremisesApplication.ts b/server/@types/shared/models/SubmitApprovedPremisesApplication.ts index 99201ae804..cffe9531da 100644 --- a/server/@types/shared/models/SubmitApprovedPremisesApplication.ts +++ b/server/@types/shared/models/SubmitApprovedPremisesApplication.ts @@ -42,5 +42,6 @@ export type SubmitApprovedPremisesApplication = (SubmitApplication & { noticeType?: Cas1ApplicationTimelinessCategory; reasonForShortNotice?: string; reasonForShortNoticeOther?: string; + licenseExpiryDate?: string; }); diff --git a/server/controllers/manage/cancellationsController.ts b/server/controllers/manage/cancellationsController.ts index e53a390e02..902efb65e2 100644 --- a/server/controllers/manage/cancellationsController.ts +++ b/server/controllers/manage/cancellationsController.ts @@ -1,6 +1,6 @@ import type { Request, RequestHandler, Response } from 'express' -import type { NewCancellation, NewCas1SpaceBookingCancellation } from '@approved-premises/api' +import type { Cas1NewSpaceBookingCancellation, NewCancellation } from '@approved-premises/api' import { BookingService, CancellationService, PlacementService } from '../../services' import { catchValidationErrorOrPropogate, fetchErrorsAndUserInput } from '../../utils/validation' @@ -76,11 +76,11 @@ export default class CancellationsController { date, } as NewCancellation - const spaceBookingCancellation = { + const spaceBookingCancellation: Cas1NewSpaceBookingCancellation = { occurredAt: date, reasonId: cancellation.reason, reasonNotes: cancellation.otherReason, - } as NewCas1SpaceBookingCancellation + } try { if (bookingId) { diff --git a/server/controllers/match/placementRequests/spaceBookingsController.ts b/server/controllers/match/placementRequests/spaceBookingsController.ts index 6addd5295b..c0c5fc8560 100644 --- a/server/controllers/match/placementRequests/spaceBookingsController.ts +++ b/server/controllers/match/placementRequests/spaceBookingsController.ts @@ -1,5 +1,5 @@ import type { Request, RequestHandler, Response, TypedRequestHandler } from 'express' -import { ApType, NewCas1SpaceBooking as NewSpaceBooking } from '@approved-premises/api' +import type { ApType, Cas1NewSpaceBooking as NewSpaceBooking } from '@approved-premises/api' import { PlacementRequestService, SpaceService } from '../../../services' import { filterOutAPTypes, placementDates } from '../../../utils/match' import { catchValidationErrorOrPropogate, fetchErrorsAndUserInput } from '../../../utils/validation' diff --git a/server/data/outOfServiceBedClient.test.ts b/server/data/outOfServiceBedClient.test.ts index 8040bb3b83..194bd421d2 100644 --- a/server/data/outOfServiceBedClient.test.ts +++ b/server/data/outOfServiceBedClient.test.ts @@ -1,5 +1,5 @@ -import { - NewCas1OutOfServiceBedCancellation as NewOutOfServiceBedCancellation, +import type { + Cas1NewOutOfServiceBedCancellation as NewOutOfServiceBedCancellation, UpdateCas1OutOfServiceBed as UpdateOutOfServiceBed, } from '@approved-premises/api' import OutOfServiceBedClient from './outOfServiceBedClient' diff --git a/server/data/outOfServiceBedClient.ts b/server/data/outOfServiceBedClient.ts index 1ba6358e6b..d38a090ee1 100644 --- a/server/data/outOfServiceBedClient.ts +++ b/server/data/outOfServiceBedClient.ts @@ -1,8 +1,8 @@ /* istanbul ignore file */ -import { - NewCas1OutOfServiceBed as NewOutOfServiceBed, - NewCas1OutOfServiceBedCancellation as NewOutOfServiceBedCancellation, +import type { + Cas1NewOutOfServiceBed as NewOutOfServiceBed, + Cas1NewOutOfServiceBedCancellation as NewOutOfServiceBedCancellation, Cas1OutOfServiceBed as OutOfServiceBed, Cas1OutOfServiceBedCancellation as OutOfServiceBedCancellation, Cas1OutOfServiceBedSortField as OutOfServiceBedSortField, diff --git a/server/data/placementClient.ts b/server/data/placementClient.ts index 25e347eb69..2b283879b5 100644 --- a/server/data/placementClient.ts +++ b/server/data/placementClient.ts @@ -2,9 +2,9 @@ import type { Cas1AssignKeyWorker, Cas1NewArrival, Cas1NewDeparture, + Cas1NewSpaceBookingCancellation, Cas1NonArrival, Cas1SpaceBooking, - NewCas1SpaceBookingCancellation, } from '@approved-premises/api' import RestClient from './restClient' import config, { ApiConfig } from '../config' @@ -55,7 +55,7 @@ export default class PlacementClient { }) } - async cancel(premisesId: string, placementId: string, cancellation: NewCas1SpaceBookingCancellation) { + async cancel(premisesId: string, placementId: string, cancellation: Cas1NewSpaceBookingCancellation) { return this.restClient.post({ path: paths.premises.placements.cancel({ premisesId, placementId }), data: cancellation, diff --git a/server/data/spaceClient.ts b/server/data/spaceClient.ts index c00a287de8..aaf51783c8 100644 --- a/server/data/spaceClient.ts +++ b/server/data/spaceClient.ts @@ -1,13 +1,13 @@ -import config, { ApiConfig } from '../config' -import RestClient from './restClient' -import paths from '../paths/api' -import { - NewCas1SpaceBooking as NewSpaceBooking, +import type { + Cas1NewSpaceBooking as NewSpaceBooking, PlacementRequest, Cas1SpaceBooking as SpaceBooking, Cas1SpaceSearchParameters as SpaceSearchParameters, Cas1SpaceSearchResults as SpaceSearchResults, -} from '../@types/shared' +} from '@approved-premises/api' +import config, { ApiConfig } from '../config' +import RestClient from './restClient' +import paths from '../paths/api' export default class SpaceClient { restClient: RestClient diff --git a/server/services/outOfServiceBedService.ts b/server/services/outOfServiceBedService.ts index 31d83b11fa..8c11b0ba5d 100644 --- a/server/services/outOfServiceBedService.ts +++ b/server/services/outOfServiceBedService.ts @@ -1,17 +1,16 @@ -import type { Cas1ReferenceData } from '@approved-premises/ui' +import type { Cas1ReferenceData, PaginatedResponse } from '@approved-premises/ui' import type { - NewCas1OutOfServiceBed as NewOutOfServiceBed, - NewCas1OutOfServiceBedCancellation as NewOutOfServiceBedCancellation, + Cas1NewOutOfServiceBed as NewOutOfServiceBed, + Cas1NewOutOfServiceBedCancellation as NewOutOfServiceBedCancellation, Cas1OutOfServiceBed as OutOfServiceBed, Cas1OutOfServiceBedCancellation as OutOfServiceBedCancellation, Cas1OutOfServiceBedSortField as OutOfServiceBedSortField, + Premises, SortDirection, Temporality, UpdateCas1OutOfServiceBed as UpdateOutOfServiceBed, } from '@approved-premises/api' -import { PaginatedResponse } from '@approved-premises/ui' import type { Cas1ReferenceDataClient, OutOfServiceBedClient, RestClientBuilder } from '../data' -import { Premises } from '../@types/shared' export type OutOfServiceBedReasons = Array @@ -28,9 +27,7 @@ export default class OutOfServiceBedService { ): Promise { const outOfServiceBedClient = this.outOfServiceBedClientFactory(token) - const confirmedOutOfServiceBed = await outOfServiceBedClient.create(premisesId, outOfServiceBed) - - return confirmedOutOfServiceBed + return outOfServiceBedClient.create(premisesId, outOfServiceBed) } async getOutOfServiceBed( @@ -40,9 +37,7 @@ export default class OutOfServiceBedService { ): Promise { const outOfServiceBedClient = this.outOfServiceBedClientFactory(token) - const outOfServiceBed = await outOfServiceBedClient.find(premisesId, id) - - return outOfServiceBed + return outOfServiceBedClient.find(premisesId, id) } async updateOutOfServiceBed( @@ -53,24 +48,19 @@ export default class OutOfServiceBedService { ): Promise { const outOfServiceBedClient = this.outOfServiceBedClientFactory(token) - const updatedOutOfServiceBed = await outOfServiceBedClient.update(id, updateOutOfServiceBed, premisesId) - - return updatedOutOfServiceBed + return outOfServiceBedClient.update(id, updateOutOfServiceBed, premisesId) } async getOutOfServiceBedReasons(token: string): Promise { const cas1ReferenceDataClient = this.cas1ReferenceDataClientFactory(token) - const reasons = await cas1ReferenceDataClient.getReferenceData('out-of-service-bed-reasons') - - return reasons + return cas1ReferenceDataClient.getReferenceData('out-of-service-bed-reasons') } async getOutOfServiceBedsForAPremises(token: string, premisesId: Premises['id']): Promise> { const outOfServiceBedClient = this.outOfServiceBedClientFactory(token) - const outOfServiceBeds = await outOfServiceBedClient.getAllByPremises(premisesId) - return outOfServiceBeds + return outOfServiceBedClient.getAllByPremises(premisesId) } async getAllOutOfServiceBeds({ @@ -93,7 +83,8 @@ export default class OutOfServiceBedService { perPage?: number }): Promise> { const outOfServiceBedClient = this.outOfServiceBedClientFactory(token) - const outOfServiceBeds = await outOfServiceBedClient.get({ + + return outOfServiceBedClient.get({ sortBy, sortDirection, page, @@ -102,8 +93,6 @@ export default class OutOfServiceBedService { apAreaId, perPage, }) - - return outOfServiceBeds } async cancelOutOfServiceBed( @@ -114,8 +103,6 @@ export default class OutOfServiceBedService { ): Promise { const outOfServiceBedService = this.outOfServiceBedClientFactory(token) - const cancellation = await outOfServiceBedService.cancel(premisesId, outOfServiceBedId, data) - - return cancellation + return outOfServiceBedService.cancel(premisesId, outOfServiceBedId, data) } } diff --git a/server/services/placementService.ts b/server/services/placementService.ts index 5725abee00..0b9c187600 100644 --- a/server/services/placementService.ts +++ b/server/services/placementService.ts @@ -2,10 +2,10 @@ import type { Cas1AssignKeyWorker, Cas1NewArrival, Cas1NewDeparture, + Cas1NewSpaceBookingCancellation, Cas1NonArrival, Cas1SpaceBooking, DepartureReason, - NewCas1SpaceBookingCancellation, NonArrivalReason, } from '@approved-premises/api' import type { Request } from 'express' @@ -99,7 +99,7 @@ export default class PlacementService { token: string, premisesId: string, placementId: string, - cancellation: NewCas1SpaceBookingCancellation, + cancellation: Cas1NewSpaceBookingCancellation, ) { const placementClient = this.placementClientFactory(token) diff --git a/server/services/spaceService.ts b/server/services/spaceService.ts index 4c9fb29a5a..4cb6d5e48f 100644 --- a/server/services/spaceService.ts +++ b/server/services/spaceService.ts @@ -1,9 +1,5 @@ -import { - NewCas1SpaceBooking as NewSpaceBooking, - PlacementRequest, - Cas1SpaceBooking as SpaceBooking, -} from '@approved-premises/api' -import { SpaceSearchParametersUi } from '../@types/ui' +import type { Cas1NewSpaceBooking, Cas1SpaceBooking, PlacementRequest } from '@approved-premises/api' +import type { SpaceSearchParametersUi } from '@approved-premises/ui' import { RestClientBuilder } from '../data' import SpaceClient from '../data/spaceClient' import { mapUiParamsForApi } from '../utils/match' @@ -14,15 +10,14 @@ export default class SpaceService { async search(token: string, params: SpaceSearchParametersUi) { const spaceClient = this.spaceClientFactory(token) - const spaces = await spaceClient.search(mapUiParamsForApi(params)) - return spaces + return spaceClient.search(mapUiParamsForApi(params)) } async createSpaceBooking( token: string, id: PlacementRequest['id'], - newSpaceBooking: NewSpaceBooking, - ): Promise { + newSpaceBooking: Cas1NewSpaceBooking, + ): Promise { const spaceClient = this.spaceClientFactory(token) return spaceClient.createSpaceBooking(id, newSpaceBooking) diff --git a/server/testutils/factories/cas1NewSpaceBookingCancellation.ts b/server/testutils/factories/cas1NewSpaceBookingCancellation.ts index 226e0eb5a3..35ef28044d 100644 --- a/server/testutils/factories/cas1NewSpaceBookingCancellation.ts +++ b/server/testutils/factories/cas1NewSpaceBookingCancellation.ts @@ -1,9 +1,9 @@ import { Factory } from 'fishery' -import { NewCas1SpaceBookingCancellation } from '@approved-premises/api' +import type { Cas1NewSpaceBookingCancellation } from '@approved-premises/api' import { faker } from '@faker-js/faker' import { DateFormats } from '../../utils/dateUtils' -export default Factory.define(() => ({ +export default Factory.define(() => ({ occurredAt: DateFormats.dateObjToIsoDate(faker.date.recent()), reasonId: faker.string.uuid(), reasonNotes: faker.lorem.words(20), diff --git a/server/testutils/factories/newSpaceBooking.ts b/server/testutils/factories/newSpaceBooking.ts index d8e254c9e1..34d3503530 100644 --- a/server/testutils/factories/newSpaceBooking.ts +++ b/server/testutils/factories/newSpaceBooking.ts @@ -1,11 +1,11 @@ import { Factory } from 'fishery' import { faker } from '@faker-js/faker/locale/en_GB' -import type { NewCas1SpaceBooking } from '@approved-premises/api' +import type { Cas1NewSpaceBooking } from '@approved-premises/api' import { DateFormats } from '../../utils/dateUtils' import spaceBookingRequirementsFactory from './spaceBookingRequirements' -export default Factory.define(() => { +export default Factory.define(() => { const startDate = faker.date.soon() const endDate = faker.date.future() return { diff --git a/server/testutils/factories/outOfServiceBed.ts b/server/testutils/factories/outOfServiceBed.ts index 1a7fbe9241..350627be66 100644 --- a/server/testutils/factories/outOfServiceBed.ts +++ b/server/testutils/factories/outOfServiceBed.ts @@ -1,18 +1,18 @@ import { Factory } from 'fishery' import { faker } from '@faker-js/faker/locale/en_GB' -import { - NewCas1OutOfServiceBed as NewOutOfServiceBed, - Cas1OutOfServiceBed as OutOfServiceBed, - Cas1OutOfServiceBedCancellation as OutOfServiceBedCancellation, - Cas1OutOfServiceBedRevision as OutOfServiceBedRevision, -} from '../../@types/shared' +import type { + Cas1NewOutOfServiceBed, + Cas1OutOfServiceBed, + Cas1OutOfServiceBedCancellation, + Cas1OutOfServiceBedRevision, +} from '@approved-premises/api' import cas1ReferenceDataFactory from './cas1ReferenceData' import { DateFormats } from '../../utils/dateUtils' import userFactory from './user' import namedIdFactory from './namedId' -export const outOfServiceBedFactory = Factory.define(() => ({ +export const outOfServiceBedFactory = Factory.define(() => ({ id: faker.string.uuid(), createdAt: DateFormats.dateObjToIsoDateTime(faker.date.past()), startDate: DateFormats.dateObjToIsoDate(faker.date.future()), @@ -31,7 +31,7 @@ export const outOfServiceBedFactory = Factory.define(() => ({ revisionHistory: outOfServiceBedRevisionFactory.buildList(3), })) -export const newOutOfServiceBedFactory = Factory.define(() => { +export const newOutOfServiceBedFactory = Factory.define(() => { const startDate = faker.date.soon() const endDate = faker.date.future() return { @@ -52,7 +52,7 @@ export const newOutOfServiceBedFactory = Factory.define(() = } }) -export const outOfServiceBedCancellationFactory = Factory.define(() => { +export const outOfServiceBedCancellationFactory = Factory.define(() => { return { createdAt: DateFormats.dateObjToIsoDateTime(faker.date.past()), id: faker.string.uuid(), @@ -60,7 +60,7 @@ export const outOfServiceBedCancellationFactory = Factory.define(() => { +export const outOfServiceBedRevisionFactory = Factory.define(() => { return { id: faker.string.uuid(), updatedAt: DateFormats.dateObjToIsoDateTime(faker.date.past()),