File tree Expand file tree Collapse file tree 4 files changed +16
-29
lines changed
backend-client/src/schemas Expand file tree Collapse file tree 4 files changed +16
-29
lines changed Original file line number Diff line number Diff line change @@ -10,16 +10,14 @@ import type {
1010import { TemplateRepository } from '../../infra' ;
1111import { TemplateClient } from '../../app/template-client' ;
1212import { LetterUploadRepository } from '../../infra/letter-upload-repository' ;
13- import {
14- DatabaseTemplate ,
15- TemplateFilter ,
16- } from 'nhs-notify-web-template-management-utils' ;
13+ import { DatabaseTemplate } from 'nhs-notify-web-template-management-utils' ;
1714import { ProofingQueue } from '../../infra/proofing-queue' ;
1815import { createMockLogger } from 'nhs-notify-web-template-management-test-helper-utils/mock-logger' ;
1916import { isoDateRegExp } from 'nhs-notify-web-template-management-test-helper-utils' ;
2017import { ClientConfigRepository } from '../../infra/client-config-repository' ;
2118import { isRightToLeft } from 'nhs-notify-web-template-management-utils/enum' ;
2219import { TemplateQuery } from '../../infra/template-repository/query' ;
20+ import { TemplateFilter } from 'nhs-notify-backend-client/src/types/filters' ;
2321
2422jest . mock ( 'node:crypto' ) ;
2523jest . mock ( 'nhs-notify-web-template-management-utils/enum' ) ;
Original file line number Diff line number Diff line change @@ -12,8 +12,7 @@ import {
1212 ClientConfiguration ,
1313 $LockNumber ,
1414 $TemplateDto ,
15- $ListTemplateFilters ,
16- ListTemplateFilters ,
15+ $TemplateFilter ,
1716} from 'nhs-notify-backend-client' ;
1817import { LETTER_MULTIPART } from 'nhs-notify-backend-client/src/schemas/constants' ;
1918import {
@@ -29,6 +28,7 @@ import { LetterUploadRepository } from '../infra/letter-upload-repository';
2928import { ProofingQueue } from '../infra/proofing-queue' ;
3029import { ClientConfigRepository } from '../infra/client-config-repository' ;
3130import { TemplateRepository } from '../infra' ;
31+ import { TemplateFilter } from 'nhs-notify-backend-client/src/types/filters' ;
3232
3333export class TemplateClient {
3434 private $LetterForProofing = z . intersection (
@@ -421,10 +421,10 @@ export class TemplateClient {
421421 user : User ,
422422 filters ?: unknown
423423 ) : Promise < Result < TemplateDto [ ] > > {
424- let parsedFilters : ListTemplateFilters = { } ;
424+ let parsedFilters : TemplateFilter = { } ;
425425
426426 if ( filters ) {
427- const validation = await validate ( $ListTemplateFilters , filters ) ;
427+ const validation = await validate ( $TemplateFilter , filters ) ;
428428
429429 if ( validation . error ) {
430430 return validation ;
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ import {
3131 TEMPLATE_TYPE_LIST ,
3232 VIRUS_SCAN_STATUS_LIST ,
3333} from './union-lists' ;
34+ import { TemplateFilter } from '../types/filters' ;
3435
3536export const $LetterType = schemaFor < LetterType > ( ) ( z . enum ( LETTER_TYPE_LIST ) ) ;
3637
@@ -177,18 +178,13 @@ export const $TemplateDto = schemaFor<
177178 ] )
178179) ;
179180
180- export type ListTemplateFilters = {
181- templateStatus ?: TemplateStatus ;
182- templateType ?: TemplateType ;
183- language ?: Language ;
184- letterType ?: LetterType ;
185- } ;
186-
187- export const $ListTemplateFilters = schemaFor < ListTemplateFilters > ( ) (
188- z . object ( {
189- templateStatus : $TemplateStatusActive . optional ( ) ,
190- templateType : $TemplateType . optional ( ) ,
191- language : $Language . optional ( ) ,
192- letterType : $LetterType . optional ( ) ,
193- } )
181+ export const $TemplateFilter = schemaFor < TemplateFilter > ( ) (
182+ z
183+ . object ( {
184+ templateStatus : $TemplateStatusActive ,
185+ templateType : $TemplateType ,
186+ language : $Language ,
187+ letterType : $LetterType ,
188+ } )
189+ . partial ( )
194190) ;
Original file line number Diff line number Diff line change @@ -125,13 +125,6 @@ export type DatabaseTemplate = {
125125 supplierReferences ?: Record < string , string > ;
126126} & DbOnlyTemplateProperties ;
127127
128- export type TemplateFilter = Partial <
129- Pick <
130- DatabaseTemplate ,
131- 'templateStatus' | 'templateType' | 'language' | 'letterType'
132- >
133- > ;
134-
135128type DbOnlyTemplateProperties = {
136129 owner : string ;
137130 version : number ;
You can’t perform that action at this time.
0 commit comments