Skip to content

Commit

Permalink
Merge pull request #1097 from danskernesdigitalebibliotek/DDFFORM-555…
Browse files Browse the repository at this point in the history
…-opdateringer-til-orval

Ddfform 555 opdateringer til orval
  • Loading branch information
kasperbirch1 authored Apr 11, 2024
2 parents 5763ac1 + 56636c4 commit 3fe6698
Show file tree
Hide file tree
Showing 113 changed files with 3,435 additions and 2,513 deletions.
2 changes: 1 addition & 1 deletion orval.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default defineConfig({
prettier: true
},
input: {
target: "https://cover.dandigbib.org/api/v2/spec.yaml",
target: "https://cover.dandigbib.org/spec.yaml",
converterOptions: {
indent: 2
}
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
"cypress:open": "cypress open",
"codegen:dbc:gateway": "CODEGEN_SCHEMA_PROFILE=next graphql-codegen -r dotenv/config --config dbc-gateway.codegen.yml",
"codegen:rest-services": "orval",
"codegen:client:fbs": "orval --project fbsAdapter",
"codegen:client:cover": "orval --project coverService",
"codegen:client:publizon": "orval --project publizonAdapter",
"codegen:client:fbs": "rm -rf src/core/fbs/model/*.* && orval --project fbsAdapter",
"codegen:client:cover": "rm -rf src/core/cover-service-api/model/*.* && orval --project coverService",
"codegen:client:publizon": "rm -rf src/core/publizon/model/*.* && orval --project publizonAdapter",
"codegen:client:dpl-cms": "rm -rf src/core/dpl-cms/model/*.* && orval --project dplCms",
"post-process-generated-graphql": "ts-node ./scripts/post-process-generated-graphql.ts"
},
Expand Down
4 changes: 3 additions & 1 deletion src/components/reservation/ReservationModalBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ export const ReservationModalBody = ({
// This state is used to show the success or error modal.
setReservationResponse(res);
// Because after a successful reservation the holdings (reservations) are updated.
queryClient.invalidateQueries(getGetHoldingsV3QueryKey());
queryClient.invalidateQueries(
getGetHoldingsV3QueryKey({ recordid: faustIds })
);
}
}
);
Expand Down
81 changes: 51 additions & 30 deletions src/core/cover-service-api/cover-service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Generated by orval v6.8.1 🍺
* Generated by orval v6.26.0 🍺
* Do not edit manually.
* DDF Cover Service
* This service provides covers for library materials indexed by isbn, issn, faust, pid.
Expand All @@ -8,58 +8,52 @@ The service is provided by [Det Digitale Folkebibliotek](https://detdigitalefolk
Authentication is done via OAuth2 against auth.dbc.dk. To obtain a valid token follow the instructions here: [Open Platform](https://openplatform.dbc.dk/v3/). To use the "Authorize" option in this tool use your 'client_id' and 'client_secret' and fill in '@agency' (e.g. '@123456') for both username and password.
* OpenAPI spec version: 2.0
*/
import {
useQuery,
UseQueryOptions,
import { useQuery } from "react-query";
import type {
QueryFunction,
UseQueryResult,
QueryKey
QueryKey,
UseQueryOptions,
UseQueryResult
} from "react-query";
import type { Cover, GetCoverCollectionParams } from "./model";
import { fetcher, ErrorType, BodyType } from "./mutator/fetcher";

type AwaitedInput<T> = PromiseLike<T> | T;

type Awaited<O> = O extends AwaitedInput<infer T> ? T : never;
import { fetcher } from "./mutator/fetcher";
import type { ErrorType } from "./mutator/fetcher";

/**
* Get covers by identifier in specific image format(s), specific image size(s) and with or without generic covers.
* @summary Search multiple covers
*/
export const getCoverCollection = (
params?: GetCoverCollectionParams,
params: GetCoverCollectionParams,
signal?: AbortSignal
) => {
return fetcher<Cover[]>({
url: `/api/v2/covers`,
method: "get",
signal,
params
method: "GET",
params,
signal
});
};

export const getGetCoverCollectionQueryKey = (
params?: GetCoverCollectionParams
) => [`/api/v2/covers`, ...(params ? [params] : [])];

export type GetCoverCollectionQueryResult = NonNullable<
Awaited<ReturnType<typeof getCoverCollection>>
>;
export type GetCoverCollectionQueryError = ErrorType<void>;
params: GetCoverCollectionParams
) => {
return [`/api/v2/covers`, ...(params ? [params] : [])] as const;
};

export const useGetCoverCollection = <
export const getGetCoverCollectionQueryOptions = <
TData = Awaited<ReturnType<typeof getCoverCollection>>,
TError = ErrorType<void>
>(
params?: GetCoverCollectionParams,
params: GetCoverCollectionParams,
options?: {
query?: UseQueryOptions<
Awaited<ReturnType<typeof getCoverCollection>>,
TError,
TData
>;
}
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
) => {
const { query: queryOptions } = options ?? {};

const queryKey =
Expand All @@ -69,14 +63,41 @@ export const useGetCoverCollection = <
Awaited<ReturnType<typeof getCoverCollection>>
> = ({ signal }) => getCoverCollection(params, signal);

const query = useQuery<
return { queryKey, queryFn, ...queryOptions } as UseQueryOptions<
Awaited<ReturnType<typeof getCoverCollection>>,
TError,
TData
>(queryKey, queryFn, queryOptions);
> & { queryKey: QueryKey };
};

export type GetCoverCollectionQueryResult = NonNullable<
Awaited<ReturnType<typeof getCoverCollection>>
>;
export type GetCoverCollectionQueryError = ErrorType<void>;

return {
queryKey,
...query
/**
* @summary Search multiple covers
*/
export const useGetCoverCollection = <
TData = Awaited<ReturnType<typeof getCoverCollection>>,
TError = ErrorType<void>
>(
params: GetCoverCollectionParams,
options?: {
query?: UseQueryOptions<
Awaited<ReturnType<typeof getCoverCollection>>,
TError,
TData
>;
}
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
const queryOptions = getGetCoverCollectionQueryOptions(params, options);

const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
queryKey: QueryKey;
};

query.queryKey = queryOptions.queryKey;

return query;
};
6 changes: 3 additions & 3 deletions src/core/cover-service-api/model/cover.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Generated by orval v6.8.1 🍺
* Generated by orval v6.26.0 🍺
* Do not edit manually.
* DDF Cover Service
* This service provides covers for library materials indexed by isbn, issn, faust, pid.
Expand All @@ -8,11 +8,11 @@ The service is provided by [Det Digitale Folkebibliotek](https://detdigitalefolk
Authentication is done via OAuth2 against auth.dbc.dk. To obtain a valid token follow the instructions here: [Open Platform](https://openplatform.dbc.dk/v3/). To use the "Authorize" option in this tool use your 'client_id' and 'client_secret' and fill in '@agency' (e.g. '@123456') for both username and password.
* OpenAPI spec version: 2.0
*/
import type { CoverType } from "./coverType";
import type { CoverImageUrls } from "./coverImageUrls";
import type { CoverType } from "./coverType";

export interface Cover {
id?: string;
type?: CoverType;
imageUrls?: CoverImageUrls;
type?: CoverType;
}
10 changes: 7 additions & 3 deletions src/core/cover-service-api/model/coverImageUrls.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Generated by orval v6.8.1 🍺
* Generated by orval v6.26.0 🍺
* Do not edit manually.
* DDF Cover Service
* This service provides covers for library materials indexed by isbn, issn, faust, pid.
Expand All @@ -12,8 +12,12 @@ import type { ImageUrl } from "./imageUrl";

export type CoverImageUrls = {
default?: ImageUrl;
large?: ImageUrl;
medium?: ImageUrl;
"medium-large"?: ImageUrl;
original?: ImageUrl;
small?: ImageUrl;
medium?: ImageUrl;
large?: ImageUrl;
"small-medium"?: ImageUrl;
"x-small"?: ImageUrl;
"xx-small"?: ImageUrl;
};
2 changes: 1 addition & 1 deletion src/core/cover-service-api/model/coverType.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Generated by orval v6.8.1 🍺
* Generated by orval v6.26.0 🍺
* Do not edit manually.
* DDF Cover Service
* This service provides covers for library materials indexed by isbn, issn, faust, pid.
Expand Down
25 changes: 24 additions & 1 deletion src/core/cover-service-api/model/getCoverCollectionParams.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Generated by orval v6.8.1 🍺
* Generated by orval v6.26.0 🍺
* Do not edit manually.
* DDF Cover Service
* This service provides covers for library materials indexed by isbn, issn, faust, pid.
Expand All @@ -12,7 +12,30 @@ import type { GetCoverCollectionType } from "./getCoverCollectionType";
import type { GetCoverCollectionSizesItem } from "./getCoverCollectionSizesItem";

export type GetCoverCollectionParams = {
/**
* The type of the identifier, i.e. 'isbn', 'faust', 'pid' or 'issn'
*/
type: GetCoverCollectionType;
/**
* A list of identifiers of {type}. Maximum number os identifiers per reqeust is 200
*/
identifiers: string[];
/**
* A list of image sizes for the cover(s) you want to receive. Please note:
- If the cover is not available for the requested size 'null' will be returned for that size.
- If the 'sizes' parameter is omitted the 'default' size will be returned,
- If you request the 'original' size a cover will always be returned.
The different sizes in pixels (height).
- default: 1000px
- original: [variable]
- xx-small: 104px
- x-small: 136px
- small: 160px
- small-medium: 230px
- medium: 270px
- medium-large: 430px
- large: 540px
*/
sizes?: GetCoverCollectionSizesItem[];
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Generated by orval v6.8.1 🍺
* Generated by orval v6.26.0 🍺
* Do not edit manually.
* DDF Cover Service
* This service provides covers for library materials indexed by isbn, issn, faust, pid.
Expand All @@ -16,7 +16,11 @@ export type GetCoverCollectionSizesItem =
export const GetCoverCollectionSizesItem = {
default: "default",
original: "original",
"xx-small": "xx-small",
"x-small": "x-small",
small: "small",
"small-medium": "small-medium",
medium: "medium",
"medium-large": "medium-large",
large: "large"
} as const;
2 changes: 1 addition & 1 deletion src/core/cover-service-api/model/getCoverCollectionType.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Generated by orval v6.8.1 🍺
* Generated by orval v6.26.0 🍺
* Do not edit manually.
* DDF Cover Service
* This service provides covers for library materials indexed by isbn, issn, faust, pid.
Expand Down
5 changes: 3 additions & 2 deletions src/core/cover-service-api/model/imageUrl.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Generated by orval v6.8.1 🍺
* Generated by orval v6.26.0 🍺
* Do not edit manually.
* DDF Cover Service
* This service provides covers for library materials indexed by isbn, issn, faust, pid.
Expand All @@ -11,7 +11,8 @@ Authentication is done via OAuth2 against auth.dbc.dk. To obtain a valid token f
import type { ImageUrlSize } from "./imageUrlSize";

export interface ImageUrl {
url?: string | null;
format?: string;
size?: ImageUrlSize;
/** @nullable */
url?: string | null;
}
6 changes: 5 additions & 1 deletion src/core/cover-service-api/model/imageUrlSize.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Generated by orval v6.8.1 🍺
* Generated by orval v6.26.0 🍺
* Do not edit manually.
* DDF Cover Service
* This service provides covers for library materials indexed by isbn, issn, faust, pid.
Expand All @@ -15,7 +15,11 @@ export type ImageUrlSize = typeof ImageUrlSize[keyof typeof ImageUrlSize];
export const ImageUrlSize = {
default: "default",
original: "original",
"xx-small": "xx-small",
"x-small": "x-small",
small: "small",
"small-medium": "small-medium",
medium: "medium",
"medium-large": "medium-large",
large: "large"
} as const;
17 changes: 14 additions & 3 deletions src/core/cover-service-api/model/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
/**
* Generated by orval v6.26.0 🍺
* Do not edit manually.
* DDF Cover Service
* This service provides covers for library materials indexed by isbn, issn, faust, pid.
The service is provided by [Det Digitale Folkebibliotek](https://detdigitalefolkebibliotek.dk/section/i-brug-paa-biblioteket/cover-service)
### Authentication notes
Authentication is done via OAuth2 against auth.dbc.dk. To obtain a valid token follow the instructions here: [Open Platform](https://openplatform.dbc.dk/v3/). To use the "Authorize" option in this tool use your 'client_id' and 'client_secret' and fill in '@agency' (e.g. '@123456') for both username and password.
* OpenAPI spec version: 2.0
*/

export * from "./cover";
export * from "./coverImageUrls";
export * from "./coverType";
export * from "./imageUrlSize";
export * from "./getCoverCollectionParams";
export * from "./getCoverCollectionSizesItem";
export * from "./imageUrl";
export * from "./coverImageUrls";
export * from "./getCoverCollectionType";
export * from "./imageUrl";
export * from "./imageUrlSize";
2 changes: 1 addition & 1 deletion src/core/cover-service-api/mutator/fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const fetcher = async <ResponseType>({
data
}: {
url: string;
method: "get" | "post" | "put" | "delete" | "patch" | "head";
method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD";
params?: unknown;
data?: BodyType<unknown>;
signal?: AbortSignal;
Expand Down
Loading

0 comments on commit 3fe6698

Please sign in to comment.