From ce9fb42cc0d0f1b5276a072224195dcb5df5565c Mon Sep 17 00:00:00 2001 From: Kasper Birch Date: Thu, 19 Sep 2024 15:01:26 +0200 Subject: [PATCH] Add `/external/agencyid/catalog/holdingsLogistics/v1` to FBS adapter This is necessary because some of the libraries use that system instead of `/external/agencyid/catalog/holdings/v3`. https://reload.atlassian.net/browse/DDFHER-83 --- src/core/fbs/fbs-adapter.yaml | 86 +++++++++++++++ src/core/fbs/fbs.ts | 100 ++++++++++++++++++ src/core/fbs/model/agencySection.ts | 13 +++ ...gencyidCatalogHoldingsLogisticsV1Params.ts | 17 +++ ...ingsForBibliographicalRecordLogisticsV1.ts | 17 +++ src/core/fbs/model/holdingsLogisticsV1.ts | 17 +++ src/core/fbs/model/index.ts | 5 + src/core/fbs/model/placementV1.ts | 17 +++ 8 files changed, 272 insertions(+) create mode 100644 src/core/fbs/model/agencySection.ts create mode 100644 src/core/fbs/model/getExternalAgencyidCatalogHoldingsLogisticsV1Params.ts create mode 100644 src/core/fbs/model/holdingsForBibliographicalRecordLogisticsV1.ts create mode 100644 src/core/fbs/model/holdingsLogisticsV1.ts create mode 100644 src/core/fbs/model/placementV1.ts diff --git a/src/core/fbs/fbs-adapter.yaml b/src/core/fbs/fbs-adapter.yaml index 04dbdd8b78..810c3ff062 100644 --- a/src/core/fbs/fbs-adapter.yaml +++ b/src/core/fbs/fbs-adapter.yaml @@ -223,6 +223,36 @@ paths: description: "\n Returns an array of holdings for each bibliographical record.\n The holdings lists the materials on each placement, and whether they are available on-shelf or lent out." operationId: getHoldingsV3 summary: "Get placement holdings for bibliographical records." + /external/agencyid/catalog/holdingsLogistics/v1: + get: + summary: "Get placement holdings for bibliographical records." + description: "Returns an array of holdings for each bibliographical record. The holdings list the materials on each placement, and whether they are available on-shelf or lent out." + parameters: + - name: recordid + in: query + description: "Identifies the bibliographical records - The FAUST number." + required: true + type: array + items: + type: string + - name: exclude + in: query + description: "Identifies the branchIds which are excluded from the result." + required: false + type: array + items: + type: string + responses: + 200: + description: "An array of holdings with updated logistics placement." + schema: + type: array + items: + $ref: "#/definitions/HoldingsForBibliographicalRecordLogisticsV1" + 400: + description: "Bad request" + 401: + description: "Unauthorized" /external/agencyid/patron/patronid/fees/v2: get: parameters: @@ -869,6 +899,62 @@ definitions: - reservations - reservable - holdings + HoldingsForBibliographicalRecordLogisticsV1: + type: object + properties: + recordId: + type: string + description: "Identifies the bibliographical record for the available materials, The FAUST number" + reservations: + type: integer + description: "Total number of current active reservations for the bibliographical record" + reservable: + type: boolean + description: "True if there is any reservable materials" + holdings: + type: array + items: + $ref: "#/definitions/HoldingsLogisticsV1" + required: + - recordId + - holdings + HoldingsLogisticsV1: + properties: + branch: + $ref: "#/definitions/AgencyBranch" + lmsPlacement: + $ref: "#/definitions/PlacementV1" + logisticsPlacement: + type: array + items: + type: string + description: "Logistics placement information in an array of strings." + materials: + type: array + items: + $ref: "#/definitions/MaterialV3" + required: + - branch + - materials + PlacementV1: + properties: + section: + $ref: "#/definitions/AgencySection" + location: + $ref: "#/definitions/AgencyLocation" + sublocation: + $ref: "#/definitions/AgencySublocation" + department: + $ref: "#/definitions/AgencyDepartment" + + AgencySection: + properties: + sectionId: + type: string + description: "Section identifier" + title: + type: string + description: "Name of the section" HoldingsV3: properties: branch: diff --git a/src/core/fbs/fbs.ts b/src/core/fbs/fbs.ts index 146bc5f3dd..a4ef4bd8f3 100644 --- a/src/core/fbs/fbs.ts +++ b/src/core/fbs/fbs.ts @@ -26,8 +26,10 @@ import type { FeeV2, GetAvailabilityV3Params, GetBranchesParams, + GetExternalAgencyidCatalogHoldingsLogisticsV1Params, GetFeesV2Params, GetHoldingsV3Params, + HoldingsForBibliographicalRecordLogisticsV1, HoldingsForBibliographicalRecordV3, LoanV2, PatronWithGuardianRequest, @@ -878,6 +880,104 @@ export const useGetHoldingsV3 = < return query; }; +/** + * Returns an array of holdings for each bibliographical record. The holdings list the materials on each placement, and whether they are available on-shelf or lent out. + * @summary Get placement holdings for bibliographical records. + */ +export const getExternalAgencyidCatalogHoldingsLogisticsV1 = ( + params: GetExternalAgencyidCatalogHoldingsLogisticsV1Params, + signal?: AbortSignal +) => { + return fetcher({ + url: `/external/agencyid/catalog/holdingsLogistics/v1`, + method: "GET", + params, + signal + }); +}; + +export const getGetExternalAgencyidCatalogHoldingsLogisticsV1QueryKey = ( + params: GetExternalAgencyidCatalogHoldingsLogisticsV1Params +) => { + return [ + `/external/agencyid/catalog/holdingsLogistics/v1`, + ...(params ? [params] : []) + ] as const; +}; + +export const getGetExternalAgencyidCatalogHoldingsLogisticsV1QueryOptions = < + TData = Awaited< + ReturnType + >, + TError = ErrorType +>( + params: GetExternalAgencyidCatalogHoldingsLogisticsV1Params, + options?: { + query?: UseQueryOptions< + Awaited>, + TError, + TData + >; + } +) => { + const { query: queryOptions } = options ?? {}; + + const queryKey = + queryOptions?.queryKey ?? + getGetExternalAgencyidCatalogHoldingsLogisticsV1QueryKey(params); + + const queryFn: QueryFunction< + Awaited> + > = ({ signal }) => + getExternalAgencyidCatalogHoldingsLogisticsV1(params, signal); + + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey }; +}; + +export type GetExternalAgencyidCatalogHoldingsLogisticsV1QueryResult = + NonNullable< + Awaited> + >; +export type GetExternalAgencyidCatalogHoldingsLogisticsV1QueryError = + ErrorType; + +/** + * @summary Get placement holdings for bibliographical records. + */ +export const useGetExternalAgencyidCatalogHoldingsLogisticsV1 = < + TData = Awaited< + ReturnType + >, + TError = ErrorType +>( + params: GetExternalAgencyidCatalogHoldingsLogisticsV1Params, + options?: { + query?: UseQueryOptions< + Awaited>, + TError, + TData + >; + } +): UseQueryResult & { queryKey: QueryKey } => { + const queryOptions = + getGetExternalAgencyidCatalogHoldingsLogisticsV1QueryOptions( + params, + options + ); + + const query = useQuery(queryOptions) as UseQueryResult & { + queryKey: QueryKey; + }; + + query.queryKey = queryOptions.queryKey; + + return query; +}; + /** * Returns array of fees. diff --git a/src/core/fbs/model/agencySection.ts b/src/core/fbs/model/agencySection.ts new file mode 100644 index 0000000000..7327e02f95 --- /dev/null +++ b/src/core/fbs/model/agencySection.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v6.26.0 🍺 + * Do not edit manually. + * FBS Adapter + * OpenAPI spec version: 1.0 + */ + +export interface AgencySection { + /** Section identifier */ + sectionId?: string; + /** Name of the section */ + title?: string; +} diff --git a/src/core/fbs/model/getExternalAgencyidCatalogHoldingsLogisticsV1Params.ts b/src/core/fbs/model/getExternalAgencyidCatalogHoldingsLogisticsV1Params.ts new file mode 100644 index 0000000000..1e2b56507e --- /dev/null +++ b/src/core/fbs/model/getExternalAgencyidCatalogHoldingsLogisticsV1Params.ts @@ -0,0 +1,17 @@ +/** + * Generated by orval v6.26.0 🍺 + * Do not edit manually. + * FBS Adapter + * OpenAPI spec version: 1.0 + */ + +export type GetExternalAgencyidCatalogHoldingsLogisticsV1Params = { + /** + * Identifies the bibliographical records - The FAUST number. + */ + recordid: string[]; + /** + * Identifies the branchIds which are excluded from the result. + */ + exclude?: string[]; +}; diff --git a/src/core/fbs/model/holdingsForBibliographicalRecordLogisticsV1.ts b/src/core/fbs/model/holdingsForBibliographicalRecordLogisticsV1.ts new file mode 100644 index 0000000000..5dffc98d61 --- /dev/null +++ b/src/core/fbs/model/holdingsForBibliographicalRecordLogisticsV1.ts @@ -0,0 +1,17 @@ +/** + * Generated by orval v6.26.0 🍺 + * Do not edit manually. + * FBS Adapter + * OpenAPI spec version: 1.0 + */ +import type { HoldingsLogisticsV1 } from "./holdingsLogisticsV1"; + +export interface HoldingsForBibliographicalRecordLogisticsV1 { + holdings: HoldingsLogisticsV1[]; + /** Identifies the bibliographical record for the available materials, The FAUST number */ + recordId: string; + /** True if there is any reservable materials */ + reservable?: boolean; + /** Total number of current active reservations for the bibliographical record */ + reservations?: number; +} diff --git a/src/core/fbs/model/holdingsLogisticsV1.ts b/src/core/fbs/model/holdingsLogisticsV1.ts new file mode 100644 index 0000000000..f18d9d1d4d --- /dev/null +++ b/src/core/fbs/model/holdingsLogisticsV1.ts @@ -0,0 +1,17 @@ +/** + * Generated by orval v6.26.0 🍺 + * Do not edit manually. + * FBS Adapter + * OpenAPI spec version: 1.0 + */ +import type { AgencyBranch } from "./agencyBranch"; +import type { PlacementV1 } from "./placementV1"; +import type { MaterialV3 } from "./materialV3"; + +export interface HoldingsLogisticsV1 { + branch: AgencyBranch; + lmsPlacement?: PlacementV1; + /** Logistics placement information in an array of strings. */ + logisticsPlacement?: string[]; + materials: MaterialV3[]; +} diff --git a/src/core/fbs/model/index.ts b/src/core/fbs/model/index.ts index e41e120c5f..ad3d5ccf5a 100644 --- a/src/core/fbs/model/index.ts +++ b/src/core/fbs/model/index.ts @@ -10,6 +10,7 @@ export * from "./addressV2"; export * from "./agencyBranch"; export * from "./agencyDepartment"; export * from "./agencyLocation"; +export * from "./agencySection"; export * from "./agencySublocation"; export * from "./authenticatedPatronV4"; export * from "./authenticatedPatronV6"; @@ -29,11 +30,14 @@ export * from "./feeMaterialV2"; export * from "./feeV2"; export * from "./getAvailabilityV3Params"; export * from "./getBranchesParams"; +export * from "./getExternalAgencyidCatalogHoldingsLogisticsV1Params"; export * from "./getFeesV2Params"; export * from "./getHoldingsV3Params"; export * from "./guardian"; export * from "./holdings"; +export * from "./holdingsForBibliographicalRecordLogisticsV1"; export * from "./holdingsForBibliographicalRecordV3"; +export * from "./holdingsLogisticsV1"; export * from "./holdingsV3"; export * from "./iLLBibliographicRecord"; export * from "./loanDetails"; @@ -55,6 +59,7 @@ export * from "./period"; export * from "./periodical"; export * from "./periodicalReservation"; export * from "./pincodeChange"; +export * from "./placementV1"; export * from "./renewedLoanV2"; export * from "./reservationDetails"; export * from "./reservationDetailsV2"; diff --git a/src/core/fbs/model/placementV1.ts b/src/core/fbs/model/placementV1.ts new file mode 100644 index 0000000000..1e76a4022f --- /dev/null +++ b/src/core/fbs/model/placementV1.ts @@ -0,0 +1,17 @@ +/** + * Generated by orval v6.26.0 🍺 + * Do not edit manually. + * FBS Adapter + * OpenAPI spec version: 1.0 + */ +import type { AgencyDepartment } from "./agencyDepartment"; +import type { AgencyLocation } from "./agencyLocation"; +import type { AgencySection } from "./agencySection"; +import type { AgencySublocation } from "./agencySublocation"; + +export interface PlacementV1 { + department?: AgencyDepartment; + location?: AgencyLocation; + section?: AgencySection; + sublocation?: AgencySublocation; +}