Skip to content

Generated Types

Reference for all TypeScript types generated by strapi2front.

For each collection type, these interfaces are generated:

// Base interface
export interface Article {
id: number;
documentId: string;
title: string;
slug: string;
content: string;
createdAt: string;
updatedAt: string;
publishedAt: string | null;
locale: string;
}
// With relations populated
export interface ArticleWithRelations extends Article {
author?: Author;
categories?: Category[];
cover?: StrapiMedia;
}
// For create operations
export interface ArticleCreate {
title: string;
slug: string;
content: string;
author?: string;
categories?: string[];
cover?: number | null;
}
// For update operations (all optional)
export interface ArticleUpdate {
title?: string;
slug?: string;
content?: string;
author?: string;
categories?: string[];
cover?: number | null;
}
export interface Homepage {
id: number;
documentId: string;
heroTitle: string;
heroSubtitle: string;
createdAt: string;
updatedAt: string;
publishedAt: string | null;
}
export interface SharedSeo {
metaTitle: string;
metaDescription: string;
shareImage?: StrapiMedia;
}
export interface BlocksHero {
title: string;
subtitle?: string;
backgroundImage?: StrapiMedia;
}
export interface StrapiMedia {
id: number;
documentId: string;
name: string;
alternativeText: string | null;
caption: string | null;
width: number | null;
height: number | null;
formats: StrapiMediaFormats | null;
hash: string;
ext: string;
mime: string;
size: number;
url: string;
previewUrl: string | null;
provider: string;
createdAt: string;
updatedAt: string;
}
export interface StrapiMediaFormats {
thumbnail?: StrapiMediaFormat;
small?: StrapiMediaFormat;
medium?: StrapiMediaFormat;
large?: StrapiMediaFormat;
}
export interface StrapiMediaFormat {
name: string;
hash: string;
ext: string;
mime: string;
width: number;
height: number;
size: number;
url: string;
}
export interface StrapiPagination {
page: number;
pageSize: number;
pageCount: number;
total: number;
}
export interface StrapiMeta {
pagination: StrapiPagination;
}
// List response
export interface ArticleListResponse {
data: Article[];
meta: StrapiMeta;
}
// Single response
export interface ArticleSingleResponse {
data: Article;
meta: Record<string, unknown>;
}
Strapi FieldTypeScript Type
stringstring
textstring
richtextstring
emailstring
passwordstring
uidstring
integernumber
bigintegerstring
decimalnumber
floatnumber
booleanboolean
datestring
datetimestring
timestring
jsonunknown
// Strapi enumeration: ["draft", "review", "published"]
status: "draft" | "review" | "published";
// With @strapi/blocks-react-renderer installed
content: BlocksContent;
// Without the package
content: unknown[];
type ContentBlock =
| { __component: "blocks.hero"; title: string }
| { __component: "blocks.text"; content: string }
| { __component: "blocks.image"; image: StrapiMedia };
// Field type
content?: ContentBlock[];
export interface FindParams<T> {
fields?: (keyof T)[];
filters?: FilterQuery<T>;
sort?: string | string[];
pagination?: {
page?: number;
pageSize?: number;
start?: number;
limit?: number;
};
populate?: string[] | Record<string, PopulateQuery>;
locale?: string;
status?: "draft" | "published";
}
export interface FilterOperators<T> {
$eq?: T;
$ne?: T;
$lt?: T;
$lte?: T;
$gt?: T;
$gte?: T;
$in?: T[];
$notIn?: T[];
$contains?: string;
$notContains?: string;
$startsWith?: string;
$endsWith?: string;
$null?: boolean;
$notNull?: boolean;
}
export interface FilterQuery<T> {
[K in keyof T]?: T[K] | FilterOperators<T[K]>;
} & {
$or?: FilterQuery<T>[];
$and?: FilterQuery<T>[];
}
import { z } from "zod";
import { articleCreateSchema, articleUpdateSchema } from "./schemas";
// Inferred input types
export type ArticleCreateInput = z.infer<typeof articleCreateSchema>;
export type ArticleUpdateInput = z.infer<typeof articleUpdateSchema>;
// With advancedRelations: true
export interface RelationInput {
connect?: Array<string | {
documentId: string;
locale?: string;
status?: "draft" | "published";
position?: {
before?: string;
after?: string;
start?: boolean;
end?: boolean;
};
}>;
disconnect?: Array<string | {
documentId: string;
locale?: string;
status?: "draft" | "published";
}>;
set?: Array<string | {
documentId: string;
locale?: string;
status?: "draft" | "published";
position?: {
before?: string;
after?: string;
start?: boolean;
end?: boolean;
};
}>;
}
// Import from content type folder
import type {
Article,
ArticleWithRelations,
ArticleCreate,
ArticleUpdate,
} from "@/strapi/collections/article";
// Import from specific file
import type { Article } from "@/strapi/collections/article/types";
// Media and system types
import type {
StrapiMedia,
StrapiMediaFormats,
StrapiPagination,
} from "@/strapi/shared/types";