mirror of
https://github.com/ae-utbm/sith.git
synced 2025-03-09 23:07:11 +00:00
Fix paginated TS interfaces
This commit is contained in:
parent
d284bea0eb
commit
58b7566e8f
@ -1,4 +1,4 @@
|
||||
import type { Client, Options, RequestResult } from "@hey-api/client-fetch";
|
||||
import type { Client, Options, RequestResult, TDataShape } from "@hey-api/client-fetch";
|
||||
import { client } from "#openapi";
|
||||
|
||||
export interface PaginatedResponse<T> {
|
||||
@ -14,6 +14,7 @@ export interface PaginatedRequest {
|
||||
// biome-ignore lint/style/useNamingConvention: api is in snake_case
|
||||
page_size?: number;
|
||||
};
|
||||
url: string;
|
||||
}
|
||||
|
||||
type PaginatedEndpoint<T> = <ThrowOnError extends boolean = false>(
|
||||
@ -30,7 +31,7 @@ export const paginated = async <T>(
|
||||
options?: PaginatedRequest,
|
||||
): Promise<T[]> => {
|
||||
const maxPerPage = 199;
|
||||
const queryParams = options ?? {};
|
||||
const queryParams = options ?? ({} as PaginatedRequest);
|
||||
queryParams.query = queryParams.query ?? {};
|
||||
queryParams.query.page_size = maxPerPage;
|
||||
queryParams.query.page = 1;
|
||||
@ -53,8 +54,9 @@ export const paginated = async <T>(
|
||||
return results;
|
||||
};
|
||||
|
||||
interface Request {
|
||||
interface Request extends TDataShape {
|
||||
client?: Client;
|
||||
url: string;
|
||||
}
|
||||
|
||||
interface InterceptorOptions {
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { paginated } from "#core:utils/api";
|
||||
import { History, initialUrlParams, updateQueryString } from "#core:utils/history";
|
||||
import {
|
||||
type AlbumFetchAlbumData,
|
||||
type AlbumSchema,
|
||||
type PictureSchema,
|
||||
type PicturesFetchPicturesData,
|
||||
@ -77,7 +78,7 @@ document.addEventListener("alpine:init", () => {
|
||||
this.albums = await paginated(albumFetchAlbum, {
|
||||
// biome-ignore lint/style/useNamingConvention: API is snake_case
|
||||
query: { parent_id: this.config.parentId },
|
||||
});
|
||||
} as AlbumFetchAlbumData);
|
||||
this.loading = false;
|
||||
},
|
||||
}));
|
||||
|
@ -3,8 +3,8 @@
|
||||
"outDir": "./staticfiles/generated/bundled/",
|
||||
"sourceMap": true,
|
||||
"noImplicitAny": true,
|
||||
"module": "es6",
|
||||
"target": "es6",
|
||||
"module": "esnext",
|
||||
"target": "es2022",
|
||||
"allowJs": true,
|
||||
"moduleResolution": "node",
|
||||
"experimentalDecorators": true,
|
||||
@ -12,7 +12,6 @@
|
||||
"esModuleInterop": true,
|
||||
"resolveJsonModule": true,
|
||||
"types": ["jquery", "alpinejs"],
|
||||
"lib": ["es7"],
|
||||
"paths": {
|
||||
"#openapi": ["./staticfiles/generated/openapi/index.ts"],
|
||||
"#core:*": ["./core/static/bundled/*"],
|
||||
|
Loading…
x
Reference in New Issue
Block a user