From 49960fabf29edfb031d96bcec3aaee5f13cc24b5 Mon Sep 17 00:00:00 2001 From: XanderD99 Date: Fri, 27 Sep 2024 13:28:57 +0200 Subject: [PATCH] update Strapi5ResponseData to automatically add StrapiSystemFields to types --- src/runtime/types/v5.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/runtime/types/v5.ts b/src/runtime/types/v5.ts index e20a53bb..e63ab5fb 100644 --- a/src/runtime/types/v5.ts +++ b/src/runtime/types/v5.ts @@ -19,12 +19,24 @@ export interface Strapi5RequestParams { locale?: StrapiLocale } -export interface Strapi5SystemFields { +export interface StrapiSystemFields { documentId: string - locale?: StrapiLocale + locale?: string } -export type Strapi5ResponseData = Strapi5SystemFields & T +export type Strapi5ResponseData = T extends object + ? T extends Array + ? Array> // Handle arrays + : T extends Record + ? { [K in keyof T]: Strapi5ResponseData } & StrapiSystemFields + : T + : T + +// Pagination interface for optional pagination info in the meta field +export interface StrapiResponseMetaPagination { + page: number + pageSize: number +} export interface Strapi5ResponseSingle { data: Strapi5ResponseData