Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Orval #589

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
"mutationobserver-shim": "^0.3.7",
"node-sass": "^7.0.1",
"nyc": "^15.1.0",
"orval": "^6.8.1",
"orval": "^6.18.1",
"postcss": "^8.4.31",
"postcss-cli": "^10.1.0",
"postcss-loader": "^7.3.3",
Expand Down Expand Up @@ -154,7 +154,7 @@
"graphql": "^16.8.1",
"graphql-tag": "^2.12.6",
"lodash": "^4.17.21",
"orval": "^6.8.1",
"orval": "^6.18.1",
"prop-types": "^15.8.1",
"react": "^18.1.0",
"react-device-detect": "^2.2.2",
Expand Down
73 changes: 47 additions & 26 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.18.1 🍺
* 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,
import { useQuery } from "react-query";
import type {
UseQueryOptions,
QueryFunction,
UseQueryResult,
QueryKey
} 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
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;
};
2 changes: 1 addition & 1 deletion 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.18.1 🍺
* Do not edit manually.
* DDF Cover Service
* This service provides covers for library materials indexed by isbn, issn, faust, pid.
Expand Down
6 changes: 5 additions & 1 deletion 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.18.1 🍺
* Do not edit manually.
* DDF Cover Service
* This service provides covers for library materials indexed by isbn, issn, faust, pid.
Expand All @@ -13,7 +13,11 @@ import type { ImageUrl } from "./imageUrl";
export type CoverImageUrls = {
default?: ImageUrl;
original?: ImageUrl;
"xx-small"?: ImageUrl;
"x-small"?: ImageUrl;
small?: ImageUrl;
"small-medium"?: ImageUrl;
medium?: ImageUrl;
"medium-large"?: ImageUrl;
large?: 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.18.1 🍺
* 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.18.1 🍺
* 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.18.1 🍺
* 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.18.1 🍺
* Do not edit manually.
* DDF Cover Service
* This service provides covers for library materials indexed by isbn, issn, faust, pid.
Expand Down
2 changes: 1 addition & 1 deletion 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.18.1 🍺
* Do not edit manually.
* DDF Cover Service
* This service provides covers for library materials indexed by isbn, issn, faust, pid.
Expand Down
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.18.1 🍺
* 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.18.1 🍺
* 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";
Loading
Loading