fix: error when passing functions to array or block fields labels property (#11056)

Fixes https://github.com/payloadcms/payload/issues/11055

Functions passed to array field, block field or block `labels` were not properly handled in the client config, causing those functions to be sent to the client. This leads to a "Functions cannot be passed directly to Client Component" error
This commit is contained in:
Alessio Gravili
2025-02-07 14:52:01 -07:00
committed by GitHub
parent d7a7fbf93a
commit 6d48cf9bbf
7 changed files with 179 additions and 2 deletions

View File

@@ -13,6 +13,7 @@ export interface Config {
collections: {
posts: Post;
media: Media;
test: Test;
users: User;
'payload-locked-documents': PayloadLockedDocument;
'payload-preferences': PayloadPreference;
@@ -22,6 +23,7 @@ export interface Config {
collectionsSelect: {
posts: PostsSelect<false> | PostsSelect<true>;
media: MediaSelect<false> | MediaSelect<true>;
test: TestSelect<false> | TestSelect<true>;
users: UsersSelect<false> | UsersSelect<true>;
'payload-locked-documents': PayloadLockedDocumentsSelect<false> | PayloadLockedDocumentsSelect<true>;
'payload-preferences': PayloadPreferencesSelect<false> | PayloadPreferencesSelect<true>;
@@ -133,6 +135,28 @@ export interface Media {
};
};
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "test".
*/
export interface Test {
id: string;
test_array?:
| {
test_text?:
| {
text?: string | null;
id?: string | null;
blockName?: string | null;
blockType: 'test_text';
}[]
| null;
id?: string | null;
}[]
| null;
updatedAt: string;
createdAt: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "users".
@@ -165,6 +189,10 @@ export interface PayloadLockedDocument {
relationTo: 'media';
value: string | Media;
} | null)
| ({
relationTo: 'test';
value: string | Test;
} | null)
| ({
relationTo: 'users';
value: string | User;
@@ -273,6 +301,30 @@ export interface MediaSelect<T extends boolean = true> {
};
};
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "test_select".
*/
export interface TestSelect<T extends boolean = true> {
test_array?:
| T
| {
test_text?:
| T
| {
test_text?:
| T
| {
text?: T;
id?: T;
blockName?: T;
};
};
id?: T;
};
updatedAt?: T;
createdAt?: T;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "users_select".