Generated Types
Reference for all TypeScript types generated by strapi2front.
Content Type Interfaces
Section titled “Content Type Interfaces”Collection Types
Section titled “Collection Types”For each collection type, these interfaces are generated:
// Base interfaceexport interface Article { id: number; documentId: string; title: string; slug: string; content: string; createdAt: string; updatedAt: string; publishedAt: string | null; locale: string;}
// With relations populatedexport interface ArticleWithRelations extends Article { author?: Author; categories?: Category[]; cover?: StrapiMedia;}
// For create operationsexport 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;}Single Types
Section titled “Single Types”export interface Homepage { id: number; documentId: string; heroTitle: string; heroSubtitle: string; createdAt: string; updatedAt: string; publishedAt: string | null;}Components
Section titled “Components”export interface SharedSeo { metaTitle: string; metaDescription: string; shareImage?: StrapiMedia;}
export interface BlocksHero { title: string; subtitle?: string; backgroundImage?: StrapiMedia;}Strapi System Types
Section titled “Strapi System Types”StrapiMedia
Section titled “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;}Pagination
Section titled “Pagination”export interface StrapiPagination { page: number; pageSize: number; pageCount: number; total: number;}
export interface StrapiMeta { pagination: StrapiPagination;}API Response Types
Section titled “API Response Types”// List responseexport interface ArticleListResponse { data: Article[]; meta: StrapiMeta;}
// Single responseexport interface ArticleSingleResponse { data: Article; meta: Record<string, unknown>;}Field Type Reference
Section titled “Field Type Reference”Primitive Types
Section titled “Primitive Types”| Strapi Field | TypeScript Type |
|---|---|
string | string |
text | string |
richtext | string |
email | string |
password | string |
uid | string |
integer | number |
biginteger | string |
decimal | number |
float | number |
boolean | boolean |
date | string |
datetime | string |
time | string |
json | unknown |
Enumeration
Section titled “Enumeration”// Strapi enumeration: ["draft", "review", "published"]status: "draft" | "review" | "published";Blocks (Rich Text Editor)
Section titled “Blocks (Rich Text Editor)”// With @strapi/blocks-react-renderer installedcontent: BlocksContent;
// Without the packagecontent: unknown[];Dynamic Zones
Section titled “Dynamic Zones”type ContentBlock = | { __component: "blocks.hero"; title: string } | { __component: "blocks.text"; content: string } | { __component: "blocks.image"; image: StrapiMedia };
// Field typecontent?: ContentBlock[];Service Types
Section titled “Service Types”Find Parameters
Section titled “Find Parameters”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";}Filter Operators
Section titled “Filter Operators”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>[];}Zod Schema Types
Section titled “Zod Schema Types”Inferred Types
Section titled “Inferred Types”import { z } from "zod";import { articleCreateSchema, articleUpdateSchema } from "./schemas";
// Inferred input typesexport type ArticleCreateInput = z.infer<typeof articleCreateSchema>;export type ArticleUpdateInput = z.infer<typeof articleUpdateSchema>;Advanced Relation Types
Section titled “Advanced Relation Types”// With advancedRelations: trueexport 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; }; }>;}Importing Types
Section titled “Importing Types”By-Feature Structure
Section titled “By-Feature Structure”// Import from content type folderimport type { Article, ArticleWithRelations, ArticleCreate, ArticleUpdate,} from "@/strapi/collections/article";
// Import from specific fileimport type { Article } from "@/strapi/collections/article/types";Shared Types
Section titled “Shared Types”// Media and system typesimport type { StrapiMedia, StrapiMediaFormats, StrapiPagination,} from "@/strapi/shared/types";