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 '@backend-api/templates/infra' ;
1111import { TemplateClient } from '@backend-api/templates/app/template-client' ;
1212import { LetterUploadRepository } from '@backend-api/templates/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 '@backend-api/templates/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 '@backend-api/templates/infra/client-config-repository' ;
2118import { isRightToLeft } from 'nhs-notify-web-template-management-utils/enum' ;
2219import { TemplateQuery } from '@backend-api/templates/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 @@ -11,8 +11,7 @@ import {
1111 $CreateUpdateNonLetter ,
1212 ClientConfiguration ,
1313 $TemplateDto ,
14- $ListTemplateFilters ,
15- ListTemplateFilters ,
14+ $TemplateFilter ,
1615} from 'nhs-notify-backend-client' ;
1716import { TemplateRepository } from '@backend-api/templates/infra' ;
1817import { LETTER_MULTIPART } from 'nhs-notify-backend-client/src/schemas/constants' ;
@@ -28,6 +27,7 @@ import { z } from 'zod/v4';
2827import { LetterUploadRepository } from '../infra/letter-upload-repository' ;
2928import { ProofingQueue } from '../infra/proofing-queue' ;
3029import { ClientConfigRepository } from '../infra/client-config-repository' ;
30+ import { TemplateFilter } from 'nhs-notify-backend-client/src/types/filters' ;
3131
3232export class TemplateClient {
3333 private $LetterForProofing = z . intersection (
@@ -373,10 +373,10 @@ export class TemplateClient {
373373 user : User ,
374374 filters ?: unknown
375375 ) : Promise < Result < TemplateDto [ ] > > {
376- let parsedFilters : ListTemplateFilters = { } ;
376+ let parsedFilters : TemplateFilter = { } ;
377377
378378 if ( filters ) {
379- const validation = await validate ( $ListTemplateFilters , filters ) ;
379+ const validation = await validate ( $TemplateFilter , filters ) ;
380380
381381 if ( validation . error ) {
382382 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
@@ -163,18 +164,13 @@ export const $TemplateDto = schemaFor<TemplateDto>()(
163164 ] )
164165) ;
165166
166- export type ListTemplateFilters = {
167- templateStatus ?: TemplateStatus ;
168- templateType ?: TemplateType ;
169- language ?: Language ;
170- letterType ?: LetterType ;
171- } ;
172-
173- export const $ListTemplateFilters = schemaFor < ListTemplateFilters > ( ) (
174- z . object ( {
175- templateStatus : $TemplateStatusActive . optional ( ) ,
176- templateType : $TemplateType . optional ( ) ,
177- language : $Language . optional ( ) ,
178- letterType : $LetterType . optional ( ) ,
179- } )
167+ export const $TemplateFilter = schemaFor < TemplateFilter > ( ) (
168+ z
169+ . object ( {
170+ templateStatus : $TemplateStatusActive ,
171+ templateType : $TemplateType ,
172+ language : $Language ,
173+ letterType : $LetterType ,
174+ } )
175+ . partial ( )
180176) ;
Original file line number Diff line number Diff line change @@ -123,13 +123,6 @@ export type DatabaseTemplate = {
123123 supplierReferences ?: Record < string , string > ;
124124} & DbOnlyTemplateProperties ;
125125
126- export type TemplateFilter = Partial <
127- Pick <
128- DatabaseTemplate ,
129- 'templateStatus' | 'templateType' | 'language' | 'letterType'
130- >
131- > ;
132-
133126type DbOnlyTemplateProperties = {
134127 owner : string ;
135128 version : number ;
You can’t perform that action at this time.
0 commit comments