From cb34075483b5fb5a60cc923e1dc3fa6f118a1d91 Mon Sep 17 00:00:00 2001 From: Sugat Bajracharya Date: Wed, 31 Jul 2024 14:35:33 +0545 Subject: [PATCH] Fix conflict with target branch --- shared-libs/cht-datasource/src/person.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/shared-libs/cht-datasource/src/person.ts b/shared-libs/cht-datasource/src/person.ts index d39ff305f8e..29cac45eb2e 100644 --- a/shared-libs/cht-datasource/src/person.ts +++ b/shared-libs/cht-datasource/src/person.ts @@ -26,6 +26,12 @@ export namespace v1 { readonly parent?: Place.v1.PlaceWithLineage | NormalizedParent, } + interface getPageParams { + personType: ContactTypeQualifier; + limit?: number; + skip?: number; + } + const assertPersonQualifier: (qualifier: unknown) => asserts qualifier is UuidQualifier = (qualifier: unknown) => { if (!isUuidQualifier(qualifier)) { throw new Error(`Invalid identifier [${JSON.stringify(qualifier)}].`); @@ -121,21 +127,22 @@ export namespace v1 { */ export const getPage = ( context: DataContext - ): (personType: ContactTypeQualifier, limit: number, skip: number) => Promise => { + ): ({ personType, limit, skip }: getPageParams) => Promise => { assertDataContext(context); const fn = adapt(context, Local.Person.v1.getPage, Remote.Person.v1.getPage); /** * Returns an array of people for the provided page specifications. - * @param personType the type of people to return - * @param limit the maximum number of people to return. Default is 100. - * @param skip the number of people to skip. Default is 0. + * @param params the function params + * @param params.personType the type of people to return + * @param params.limit the maximum number of people to return. Default is 100. + * @param params.skip the number of people to skip. Default is 0. * @returns an array of people for the provided page specifications. * @throws Error if no type is provided or if the type is not for a person * @throws Error if the provided `limit` value is `<=0` * @throws Error if the provided `skip` value is `<0` */ - const curriedFn = async (personType: ContactTypeQualifier, limit = 100, skip = 0): Promise => { + const curriedFn = async ({ personType, limit = 100, skip = 0}: getPageParams): Promise => { assertTypeQualifier(personType); assertLimit(limit); assertSkip(skip);