Skip to content

Commit 0f6cda3

Browse files
committed
Fix paginated TS interfaces
1 parent 60db7e2 commit 0f6cda3

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

core/static/bundled/utils/api.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Client, Options, RequestResult } from "@hey-api/client-fetch";
1+
import type { Client, Options, RequestResult, TDataShape } from "@hey-api/client-fetch";
22
import { client } from "#openapi";
33

44
export interface PaginatedResponse<T> {
@@ -14,6 +14,7 @@ export interface PaginatedRequest {
1414
// biome-ignore lint/style/useNamingConvention: api is in snake_case
1515
page_size?: number;
1616
};
17+
url: string;
1718
}
1819

1920
type PaginatedEndpoint<T> = <ThrowOnError extends boolean = false>(
@@ -30,7 +31,7 @@ export const paginated = async <T>(
3031
options?: PaginatedRequest,
3132
): Promise<T[]> => {
3233
const maxPerPage = 199;
33-
const queryParams = options ?? {};
34+
const queryParams = options ?? ({} as PaginatedRequest);
3435
queryParams.query = queryParams.query ?? {};
3536
queryParams.query.page_size = maxPerPage;
3637
queryParams.query.page = 1;
@@ -53,8 +54,9 @@ export const paginated = async <T>(
5354
return results;
5455
};
5556

56-
interface Request {
57+
interface Request extends TDataShape {
5758
client?: Client;
59+
url: string;
5860
}
5961

6062
interface InterceptorOptions {

sas/static/bundled/sas/album-index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { paginated } from "#core:utils/api";
22
import { History, initialUrlParams, updateQueryString } from "#core:utils/history";
33
import {
4+
type AlbumFetchAlbumData,
45
type AlbumSchema,
56
type PictureSchema,
67
type PicturesFetchPicturesData,
@@ -77,7 +78,7 @@ document.addEventListener("alpine:init", () => {
7778
this.albums = await paginated(albumFetchAlbum, {
7879
// biome-ignore lint/style/useNamingConvention: API is snake_case
7980
query: { parent_id: this.config.parentId },
80-
});
81+
} as AlbumFetchAlbumData);
8182
this.loading = false;
8283
},
8384
}));

tsconfig.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@
33
"outDir": "./staticfiles/generated/bundled/",
44
"sourceMap": true,
55
"noImplicitAny": true,
6-
"module": "es6",
7-
"target": "es6",
6+
"module": "esnext",
7+
"target": "es2022",
88
"allowJs": true,
99
"moduleResolution": "node",
1010
"experimentalDecorators": true,
1111
"allowSyntheticDefaultImports": true,
1212
"esModuleInterop": true,
1313
"resolveJsonModule": true,
1414
"types": ["jquery", "alpinejs"],
15-
"lib": ["es7"],
1615
"paths": {
1716
"#openapi": ["./staticfiles/generated/openapi/client/index.ts"],
1817
"#core:*": ["./core/static/bundled/*"],

0 commit comments

Comments
 (0)