diff --git a/docs/fields/array.mdx b/docs/fields/array.mdx
index 62dd88016f..913ec98203 100644
--- a/docs/fields/array.mdx
+++ b/docs/fields/array.mdx
@@ -26,26 +26,27 @@ keywords: array, fields, config, configuration, documentation, Content Managemen
## Config
-| Option | Description |
-| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
-| **`label`** | Text used as the heading in the Admin panel or an object with keys for each language. Auto-generated from name if not defined. |
-| **`fields`** \* | Array of field types to correspond to each row of the Array. |
-| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |
-| **`minRows`** | A number for the fewest allowed items during validation when a value is present. |
-| **`maxRows`** | A number for the most allowed items during validation when a value is present. |
-| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
-| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
-| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
-| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
-| **`defaultValue`** | Provide an array of row data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
-| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. If enabled, a separate, localized set of all data within this Array will be kept, so there is no need to specify each nested field as `localized`. |
-| **`required`** | Require this field to have a value. |
-| **`labels`** | Customize the row labels appearing in the Admin dashboard. |
-| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
-| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
-| **`interfaceName`** | Create a top level, reusable [Typescript interface](/docs/typescript/generating-types#custom-field-interfaces) & [GraphQL type](/docs/graphql/graphql-schema#custom-field-schemas). |
-| **`dbName`** | Custom table name for the field when using SQL database adapter ([Postgres](/docs/database/postgres)). Auto-generated from name if not defined. |
+| Option | Description |
+| ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
+| **`label`** | Text used as the heading in the Admin panel or an object with keys for each language. Auto-generated from name if not defined. |
+| **`fields`** \* | Array of field types to correspond to each row of the Array. |
+| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |
+| **`minRows`** | A number for the fewest allowed items during validation when a value is present. |
+| **`maxRows`** | A number for the most allowed items during validation when a value is present. |
+| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
+| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
+| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
+| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
+| **`defaultValue`** | Provide an array of row data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
+| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. If enabled, a separate, localized set of all data within this Array will be kept, so there is no need to specify each nested field as `localized`. |
+| **`required`** | Require this field to have a value. |
+| **`labels`** | Customize the row labels appearing in the Admin dashboard. |
+| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
+| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
+| **`interfaceName`** | Create a top level, reusable [Typescript interface](/docs/typescript/generating-types#custom-field-interfaces) & [GraphQL type](/docs/graphql/graphql-schema#custom-field-schemas). |
+| **`dbName`** | Custom table name for the field when using SQL database adapter ([Postgres](/docs/database/postgres)). Auto-generated from name if not defined. |
+| **`typescriptSchema`** | Override field type generation with providing a JSON schema |
_\* An asterisk denotes that a property is required._
diff --git a/docs/fields/blocks.mdx b/docs/fields/blocks.mdx
index 10094fbc63..ab0799d61d 100644
--- a/docs/fields/blocks.mdx
+++ b/docs/fields/blocks.mdx
@@ -28,24 +28,25 @@ keywords: blocks, fields, config, configuration, documentation, Content Manageme
## Field config
-| Option | Description |
-| ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
-| **`label`** | Text used as the heading in the Admin panel or an object with keys for each language. Auto-generated from name if not defined. |
-| **`blocks`** \* | Array of [block configs](/docs/fields/blocks#block-configs) to be made available to this field. |
-| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |
-| **`minRows`** | A number for the fewest allowed items during validation when a value is present. |
-| **`maxRows`** | A number for the most allowed items during validation when a value is present. |
-| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
-| **`hooks`** | Provide field-level hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
-| **`access`** | Provide field-level access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
-| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API response or the Admin panel. |
-| **`defaultValue`** | Provide an array of block data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
-| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. If enabled, a separate, localized set of all data within this field will be kept, so there is no need to specify each nested field as `localized`. |
-| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. |
-| **`labels`** | Customize the block row labels appearing in the Admin dashboard. |
-| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
-| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
+| Option | Description |
+| ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
+| **`label`** | Text used as the heading in the Admin panel or an object with keys for each language. Auto-generated from name if not defined. |
+| **`blocks`** \* | Array of [block configs](/docs/fields/blocks#block-configs) to be made available to this field. |
+| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |
+| **`minRows`** | A number for the fewest allowed items during validation when a value is present. |
+| **`maxRows`** | A number for the most allowed items during validation when a value is present. |
+| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
+| **`hooks`** | Provide field-level hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
+| **`access`** | Provide field-level access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
+| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API response or the Admin panel. |
+| **`defaultValue`** | Provide an array of block data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
+| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. If enabled, a separate, localized set of all data within this field will be kept, so there is no need to specify each nested field as `localized`. |
+| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. |
+| **`labels`** | Customize the block row labels appearing in the Admin dashboard. |
+| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
+| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
+| **`typescriptSchema`** | Override field type generation with providing a JSON schema |
_\* An asterisk denotes that a property is required._
diff --git a/docs/fields/checkbox.mdx b/docs/fields/checkbox.mdx
index b9327c1ec9..13fe541182 100644
--- a/docs/fields/checkbox.mdx
+++ b/docs/fields/checkbox.mdx
@@ -17,21 +17,22 @@ keywords: checkbox, fields, config, configuration, documentation, Content Manage
## Config
-| Option | Description |
-| ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
-| **`label`** | Text used as a field label in the Admin panel or an object with keys for each language. |
-| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |
-| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. |
-| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
-| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
-| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
-| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
-| **`defaultValue`** | Provide data to be used for this field's default value, will default to false if field is also `required`. [More](/docs/fields/overview#default-values) |
-| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
-| **`required`** | Require this field to have a value. |
-| **`admin`** | Admin-specific configuration. See the [default field admin config](/docs/fields/overview#admin-config) for more details. |
-| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
+| Option | Description |
+| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
+| **`label`** | Text used as a field label in the Admin panel or an object with keys for each language. |
+| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |
+| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. |
+| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
+| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
+| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
+| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
+| **`defaultValue`** | Provide data to be used for this field's default value, will default to false if field is also `required`. [More](/docs/fields/overview#default-values) |
+| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
+| **`required`** | Require this field to have a value. |
+| **`admin`** | Admin-specific configuration. See the [default field admin config](/docs/fields/overview#admin-config) for more details. |
+| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
+| **`typescriptSchema`** | Override field type generation with providing a JSON schema |
_\* An asterisk denotes that a property is required._
diff --git a/docs/fields/code.mdx b/docs/fields/code.mdx
index 7f09468479..7b09c1ebcb 100644
--- a/docs/fields/code.mdx
+++ b/docs/fields/code.mdx
@@ -23,24 +23,25 @@ This field uses the `monaco-react` editor syntax highlighting.
## Config
-| Option | Description |
-| ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
-| **`label`** | Text used as a field label in the Admin panel or an object with keys for each language. |
-| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. |
-| **`index`** | Build an [index](/docs/database#overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. |
-| **`minLength`** | Used by the default validation function to ensure values are of a minimum character length. |
-| **`maxLength`** | Used by the default validation function to ensure values are of a maximum character length. |
-| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |
-| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
-| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
-| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
-| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
-| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
-| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
-| **`required`** | Require this field to have a value. |
-| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
-| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
+| Option | Description |
+| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
+| **`label`** | Text used as a field label in the Admin panel or an object with keys for each language. |
+| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. |
+| **`index`** | Build an [index](/docs/database#overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. |
+| **`minLength`** | Used by the default validation function to ensure values are of a minimum character length. |
+| **`maxLength`** | Used by the default validation function to ensure values are of a maximum character length. |
+| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |
+| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
+| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
+| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
+| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
+| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
+| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
+| **`required`** | Require this field to have a value. |
+| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
+| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
+| **`typescriptSchema`** | Override field type generation with providing a JSON schema |
_\* An asterisk denotes that a property is required._
diff --git a/docs/fields/date.mdx b/docs/fields/date.mdx
index 8e530b2278..2877ce4ee0 100644
--- a/docs/fields/date.mdx
+++ b/docs/fields/date.mdx
@@ -22,21 +22,22 @@ This field uses [`react-datepicker`](https://www.npmjs.com/package/react-datepic
## Config
-| Option | Description |
-| ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
-| **`label`** | Text used as a field label in the Admin panel or an object with keys for each language. |
-| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. |
-| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |
-| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
-| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
-| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
-| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
-| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
-| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
-| **`required`** | Require this field to have a value. |
-| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
-| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
+| Option | Description |
+| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
+| **`label`** | Text used as a field label in the Admin panel or an object with keys for each language. |
+| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. |
+| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |
+| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
+| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
+| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
+| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
+| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
+| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
+| **`required`** | Require this field to have a value. |
+| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
+| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
+| **`typescriptSchema`** | Override field type generation with providing a JSON schema |
_\* An asterisk denotes that a property is required._
diff --git a/docs/fields/email.mdx b/docs/fields/email.mdx
index f4bcfa12e6..31c6235113 100644
--- a/docs/fields/email.mdx
+++ b/docs/fields/email.mdx
@@ -17,22 +17,23 @@ keywords: email, fields, config, configuration, documentation, Content Managemen
## Config
-| Option | Description |
-| ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
-| **`label`** | Text used as a field label in the Admin panel or an object with keys for each language. |
-| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. |
-| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. |
-| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |
-| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
-| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
-| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
-| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
-| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
-| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
-| **`required`** | Require this field to have a value. |
-| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
-| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
+| Option | Description |
+| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
+| **`label`** | Text used as a field label in the Admin panel or an object with keys for each language. |
+| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. |
+| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. |
+| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |
+| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
+| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
+| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
+| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
+| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
+| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
+| **`required`** | Require this field to have a value. |
+| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
+| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
+| **`typescriptSchema`** | Override field type generation with providing a JSON schema |
_\* An asterisk denotes that a property is required._
diff --git a/docs/fields/group.mdx b/docs/fields/group.mdx
index f72f38e441..ada1449b17 100644
--- a/docs/fields/group.mdx
+++ b/docs/fields/group.mdx
@@ -20,21 +20,22 @@ keywords: group, fields, config, configuration, documentation, Content Managemen
## Config
-| Option | Description |
-| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
-| **`fields`** \* | Array of field types to nest within this Group. |
-| **`label`** | Used as a heading in the Admin panel and to name the generated GraphQL type. |
-| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |
-| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
-| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
-| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
-| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
-| **`defaultValue`** | Provide an object of data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
-| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. If enabled, a separate, localized set of all data within this Group will be kept, so there is no need to specify each nested field as `localized`. |
-| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
-| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
-| **`interfaceName`** | Create a top level, reusable [Typescript interface](/docs/typescript/generating-types#custom-field-interfaces) & [GraphQL type](/docs/graphql/graphql-schema#custom-field-schemas). |
+| Option | Description |
+| ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
+| **`fields`** \* | Array of field types to nest within this Group. |
+| **`label`** | Used as a heading in the Admin panel and to name the generated GraphQL type. |
+| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |
+| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
+| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
+| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
+| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
+| **`defaultValue`** | Provide an object of data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
+| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. If enabled, a separate, localized set of all data within this Group will be kept, so there is no need to specify each nested field as `localized`. |
+| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
+| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
+| **`interfaceName`** | Create a top level, reusable [Typescript interface](/docs/typescript/generating-types#custom-field-interfaces) & [GraphQL type](/docs/graphql/graphql-schema#custom-field-schemas). |
+| **`typescriptSchema`** | Override field type generation with providing a JSON schema |
_\* An asterisk denotes that a property is required._
diff --git a/docs/fields/json.mdx b/docs/fields/json.mdx
index b90c63f560..837db23a33 100644
--- a/docs/fields/json.mdx
+++ b/docs/fields/json.mdx
@@ -23,23 +23,24 @@ This field uses the `monaco-react` editor syntax highlighting.
## Config
-| Option | Description |
-| ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
-| **`label`** | Text used as a field label in the Admin panel or an object with keys for each language. |
-| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. |
-| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. |
-| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |
-| **`jsonSchema`** | Provide a JSON schema that will be used for validation. [JSON schemas](https://json-schema.org/learn/getting-started-step-by-step)
-| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
-| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
-| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
-| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
-| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
-| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
-| **`required`** | Require this field to have a value. |
-| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
-| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
+| Option | Description |
+| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
+| **`label`** | Text used as a field label in the Admin panel or an object with keys for each language. |
+| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. |
+| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. |
+| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |
+| **`jsonSchema`** | Provide a JSON schema that will be used for validation. [JSON schemas](https://json-schema.org/learn/getting-started-step-by-step) |
+| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
+| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
+| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
+| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
+| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
+| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
+| **`required`** | Require this field to have a value. |
+| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
+| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
+| **`typescriptSchema`** | Override field type generation with providing a JSON schema |
_\* An asterisk denotes that a property is required._
diff --git a/docs/fields/number.mdx b/docs/fields/number.mdx
index 067b6bfa6d..67addaea73 100644
--- a/docs/fields/number.mdx
+++ b/docs/fields/number.mdx
@@ -20,27 +20,28 @@ keywords: number, fields, config, configuration, documentation, Content Manageme
## Config
-| Option | Description |
-|--------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
-| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
-| **`label`** | Text used as a field label in the Admin panel or an object with keys for each language. |
-| **`min`** | Minimum value accepted. Used in the default `validation` function. |
-| **`max`** | Maximum value accepted. Used in the default `validation` function. |
-| **`hasMany`** | Makes this field an ordered array of numbers instead of just a single number. |
-| **`minRows`** | Minimum number of numbers in the numbers array, if `hasMany` is set to true. |
-| **`maxRows`** | Maximum number of numbers in the numbers array, if `hasMany` is set to true. |
-| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. |
-| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. |
-| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |
-| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
-| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
-| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
-| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
-| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
-| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
-| **`required`** | Require this field to have a value. |
-| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
-| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
+| Option | Description |
+| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
+| **`label`** | Text used as a field label in the Admin panel or an object with keys for each language. |
+| **`min`** | Minimum value accepted. Used in the default `validation` function. |
+| **`max`** | Maximum value accepted. Used in the default `validation` function. |
+| **`hasMany`** | Makes this field an ordered array of numbers instead of just a single number. |
+| **`minRows`** | Minimum number of numbers in the numbers array, if `hasMany` is set to true. |
+| **`maxRows`** | Maximum number of numbers in the numbers array, if `hasMany` is set to true. |
+| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. |
+| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. |
+| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |
+| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
+| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
+| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
+| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
+| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
+| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
+| **`required`** | Require this field to have a value. |
+| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
+| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
+| **`typescriptSchema`** | Override field type generation with providing a JSON schema |
_\* An asterisk denotes that a property is required._
diff --git a/docs/fields/point.mdx b/docs/fields/point.mdx
index c42e7f781e..b81b5ffc86 100644
--- a/docs/fields/point.mdx
+++ b/docs/fields/point.mdx
@@ -27,22 +27,23 @@ The data structure in the database matches the GeoJSON structure to represent po
## Config
-| Option | Description |
-| ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
-| **`label`** | Used as a field label in the Admin panel and to name the generated GraphQL type. |
-| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. |
-| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. To support location queries, point index defaults to `2dsphere`, to disable the index set to `false`. |
-| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |
-| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
-| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
-| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
-| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
-| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
-| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
-| **`required`** | Require this field to have a value. |
-| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
-| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
+| Option | Description |
+| ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
+| **`label`** | Used as a field label in the Admin panel and to name the generated GraphQL type. |
+| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. |
+| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. To support location queries, point index defaults to `2dsphere`, to disable the index set to `false`. |
+| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |
+| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
+| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
+| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
+| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
+| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
+| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
+| **`required`** | Require this field to have a value. |
+| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
+| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
+| **`typescriptSchema`** | Override field type generation with providing a JSON schema |
_\* An asterisk denotes that a property is required._
diff --git a/docs/fields/radio.mdx b/docs/fields/radio.mdx
index 62fdd84810..453c1d9115 100644
--- a/docs/fields/radio.mdx
+++ b/docs/fields/radio.mdx
@@ -20,23 +20,24 @@ keywords: radio, fields, config, configuration, documentation, Content Managemen
## Config
-| Option | Description |
-| ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
-| **`options`** \* | Array of options to allow the field to store. Can either be an array of strings, or an array of objects containing an `label` string and a `value` string. |
-| **`label`** | Text used as a field label in the Admin panel or an object with keys for each language. |
-| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |
-| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. |
-| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
-| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
-| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
-| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
-| **`defaultValue`** | Provide data to be used for this field's default value. The default value must exist within provided values in `options`. [More](/docs/fields/overview#default-values) |
-| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
-| **`required`** | Require this field to have a value. |
-| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
-| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
-| **`enumName`** | Custom enum name for this field when using SQL database adapter ([Postgres](/docs/database/postgres)). Auto-generated from name if not defined.
+| Option | Description |
+| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
+| **`options`** \* | Array of options to allow the field to store. Can either be an array of strings, or an array of objects containing an `label` string and a `value` string. |
+| **`label`** | Text used as a field label in the Admin panel or an object with keys for each language. |
+| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |
+| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. |
+| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
+| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
+| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
+| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
+| **`defaultValue`** | Provide data to be used for this field's default value. The default value must exist within provided values in `options`. [More](/docs/fields/overview#default-values) |
+| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
+| **`required`** | Require this field to have a value. |
+| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
+| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
+| **`enumName`** | Custom enum name for this field when using SQL database adapter ([Postgres](/docs/database/postgres)). Auto-generated from name if not defined. |
+| **`typescriptSchema`** | Override field type generation with providing a JSON schema |
_\* An asterisk denotes that a property is required._
diff --git a/docs/fields/relationship.mdx b/docs/fields/relationship.mdx
index 4176f665b8..b00247f1e5 100644
--- a/docs/fields/relationship.mdx
+++ b/docs/fields/relationship.mdx
@@ -26,28 +26,29 @@ keywords: relationship, fields, config, configuration, documentation, Content Ma
## Config
-| Option | Description |
-|---------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
-| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
-| **`relationTo`** \* | Provide one or many collection `slug`s to be able to assign relationships to. |
-| **`filterOptions`** | A query to filter which options appear in the UI and validate against. [More](#filtering-relationship-options). |
-| **`hasMany`** | Boolean when, if set to `true`, allows this field to have many relations instead of only one. |
-| **`minRows`** | A number for the fewest allowed items during validation when a value is present. Used with `hasMany`. |
-| **`maxRows`** | A number for the most allowed items during validation when a value is present. Used with `hasMany`. |
-| **`maxDepth`** | Sets a maximum population depth for this field, regardless of the remaining depth when this field is reached. [Max Depth](/docs/getting-started/concepts#field-level-max-depth) |
-| **`label`** | Text used as a field label in the Admin panel or an object with keys for each language. |
-| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. |
-| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |
-| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. |
-| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
-| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
-| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
-| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
-| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
-| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
-| **`required`** | Require this field to have a value. |
-| **`admin`** | Admin-specific configuration. See the [default field admin config](/docs/fields/overview#admin-config) for more details. |
-| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
+| Option | Description |
+| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
+| **`relationTo`** \* | Provide one or many collection `slug`s to be able to assign relationships to. |
+| **`filterOptions`** | A query to filter which options appear in the UI and validate against. [More](#filtering-relationship-options). |
+| **`hasMany`** | Boolean when, if set to `true`, allows this field to have many relations instead of only one. |
+| **`minRows`** | A number for the fewest allowed items during validation when a value is present. Used with `hasMany`. |
+| **`maxRows`** | A number for the most allowed items during validation when a value is present. Used with `hasMany`. |
+| **`maxDepth`** | Sets a maximum population depth for this field, regardless of the remaining depth when this field is reached. [Max Depth](/docs/getting-started/concepts#field-level-max-depth) |
+| **`label`** | Text used as a field label in the Admin panel or an object with keys for each language. |
+| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. |
+| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |
+| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. |
+| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
+| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
+| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
+| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
+| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
+| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
+| **`required`** | Require this field to have a value. |
+| **`admin`** | Admin-specific configuration. See the [default field admin config](/docs/fields/overview#admin-config) for more details. |
+| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
+| **`typescriptSchema`** | Override field type generation with providing a JSON schema |
_\* An asterisk denotes that a property is required._
diff --git a/docs/fields/rich-text.mdx b/docs/fields/rich-text.mdx
index 6f6a28d9df..e814a10c2c 100644
--- a/docs/fields/rich-text.mdx
+++ b/docs/fields/rich-text.mdx
@@ -41,21 +41,22 @@ Right now, Payload is officially supporting two rich text editors:
## Config
-| Option | Description |
-| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
-| **`label`** | Text used as a field label in the Admin panel or an object with keys for each language. |
-| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |
-| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
-| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
-| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
-| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
-| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
-| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
-| **`required`** | Require this field to have a value. |
-| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
-| **`editor`** | Override the rich text editor specified in your base configuration for this field. |
-| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
+| Option | Description |
+| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
+| **`label`** | Text used as a field label in the Admin panel or an object with keys for each language. |
+| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |
+| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
+| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
+| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
+| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
+| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
+| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
+| **`required`** | Require this field to have a value. |
+| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
+| **`editor`** | Override the rich text editor specified in your base configuration for this field. |
+| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
+| **`typescriptSchema`** | Override field type generation with providing a JSON schema |
_\* An asterisk denotes that a property is required._
diff --git a/docs/fields/select.mdx b/docs/fields/select.mdx
index 676d76dd31..8da11850b8 100644
--- a/docs/fields/select.mdx
+++ b/docs/fields/select.mdx
@@ -20,26 +20,27 @@ keywords: select, multi-select, fields, config, configuration, documentation, Co
## Config
-| Option | Description |
-| ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
-| **`options`** \* | Array of options to allow the field to store. Can either be an array of strings, or an array of objects containing a `label` string and a `value` string. |
-| **`hasMany`** | Boolean when, if set to `true`, allows this field to have many selections instead of only one. |
-| **`label`** | Text used as a field label in the Admin panel or an object with keys for each language. |
-| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. |
-| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |
-| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. |
-| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
-| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
-| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
-| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
-| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
-| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
-| **`required`** | Require this field to have a value. |
-| **`admin`** | Admin-specific configuration. See the [default field admin config](/docs/fields/overview#admin-config) for more details. |
-| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
-| **`enumName`** | Custom enum name for this field when using SQL database adapter ([Postgres](/docs/database/postgres)). Auto-generated from name if not defined. |
-| **`dbName`** | Custom table name (if `hasMany` set to `true`) for this field when using SQL database adapter ([Postgres](/docs/database/postgres)). Auto-generated from name if not defined. |
+| Option | Description |
+| ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
+| **`options`** \* | Array of options to allow the field to store. Can either be an array of strings, or an array of objects containing a `label` string and a `value` string. |
+| **`hasMany`** | Boolean when, if set to `true`, allows this field to have many selections instead of only one. |
+| **`label`** | Text used as a field label in the Admin panel or an object with keys for each language. |
+| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. |
+| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |
+| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. |
+| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
+| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
+| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
+| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
+| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
+| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
+| **`required`** | Require this field to have a value. |
+| **`admin`** | Admin-specific configuration. See the [default field admin config](/docs/fields/overview#admin-config) for more details. |
+| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
+| **`enumName`** | Custom enum name for this field when using SQL database adapter ([Postgres](/docs/database/postgres)). Auto-generated from name if not defined. |
+| **`dbName`** | Custom table name (if `hasMany` set to `true`) for this field when using SQL database adapter ([Postgres](/docs/database/postgres)). Auto-generated from name if not defined. |
+| **`typescriptSchema`** | Override field type generation with providing a JSON schema |
_\* An asterisk denotes that a property is required._
diff --git a/docs/fields/text.mdx b/docs/fields/text.mdx
index 47f33b1333..2272a9c162 100644
--- a/docs/fields/text.mdx
+++ b/docs/fields/text.mdx
@@ -20,27 +20,28 @@ keywords: text, fields, config, configuration, documentation, Content Management
## Config
-| Option | Description |
-| ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
-| **`label`** | Text used as a field label in the Admin panel or an object with keys for each language. |
-| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. |
-| **`minLength`** | Used by the default validation function to ensure values are of a minimum character length. |
-| **`maxLength`** | Used by the default validation function to ensure values are of a maximum character length. |
-| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |
-| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. |
-| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
-| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
-| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
-| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
-| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
-| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
-| **`required`** | Require this field to have a value. |
-| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
-| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
-| **`hasMany`** | Makes this field an ordered array of text instead of just a single text. |
-| **`minRows`** | Minimum number of texts in the array, if `hasMany` is set to true. |
-| **`maxRows`** | Maximum number of texts in the array, if `hasMany` is set to true. |
+| Option | Description |
+| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
+| **`label`** | Text used as a field label in the Admin panel or an object with keys for each language. |
+| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. |
+| **`minLength`** | Used by the default validation function to ensure values are of a minimum character length. |
+| **`maxLength`** | Used by the default validation function to ensure values are of a maximum character length. |
+| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |
+| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. |
+| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
+| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
+| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
+| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
+| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
+| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
+| **`required`** | Require this field to have a value. |
+| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
+| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
+| **`hasMany`** | Makes this field an ordered array of text instead of just a single text. |
+| **`minRows`** | Minimum number of texts in the array, if `hasMany` is set to true. |
+| **`maxRows`** | Maximum number of texts in the array, if `hasMany` is set to true. |
+| **`typescriptSchema`** | Override field type generation with providing a JSON schema |
_\* An asterisk denotes that a property is required._
diff --git a/docs/fields/textarea.mdx b/docs/fields/textarea.mdx
index d2384f8eef..8a0551631b 100644
--- a/docs/fields/textarea.mdx
+++ b/docs/fields/textarea.mdx
@@ -20,24 +20,25 @@ keywords: textarea, fields, config, configuration, documentation, Content Manage
## Config
-| Option | Description |
-| ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
-| **`label`** | Text used as a field label in the Admin panel or an object with keys for each language. |
-| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. |
-| **`minLength`** | Used by the default validation function to ensure values are of a minimum character length. |
-| **`maxLength`** | Used by the default validation function to ensure values are of a maximum character length. |
-| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |
-| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. |
-| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
-| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
-| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
-| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
-| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
-| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
-| **`required`** | Require this field to have a value. |
-| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
-| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
+| Option | Description |
+| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
+| **`label`** | Text used as a field label in the Admin panel or an object with keys for each language. |
+| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. |
+| **`minLength`** | Used by the default validation function to ensure values are of a minimum character length. |
+| **`maxLength`** | Used by the default validation function to ensure values are of a maximum character length. |
+| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |
+| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. |
+| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
+| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
+| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
+| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
+| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
+| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
+| **`required`** | Require this field to have a value. |
+| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
+| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
+| **`typescriptSchema`** | Override field type generation with providing a JSON schema |
_\* An asterisk denotes that a property is required._
diff --git a/docs/fields/upload.mdx b/docs/fields/upload.mdx
index 468620f9e7..934131e653 100644
--- a/docs/fields/upload.mdx
+++ b/docs/fields/upload.mdx
@@ -34,25 +34,26 @@ keywords: upload, images media, fields, config, configuration, documentation, Co
## Config
-| Option | Description |
-| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
-| **`*relationTo`** \* | Provide a single collection `slug` to allow this field to accept a relation to. Note: the related collection must be configured to support Uploads. |
-| **`filterOptions`** | A query to filter which options appear in the UI and validate against. [More](#filtering-upload-options). |
-| **`maxDepth`** | Sets a number limit on iterations of related documents to populate when queried. [Depth](/docs/getting-started/concepts#depth) |
-| **`label`** | Text used as a field label in the Admin panel or an object with keys for each language. |
-| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. |
-| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |
-| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. |
-| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
-| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
-| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
-| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
-| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
-| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
-| **`required`** | Require this field to have a value. |
-| **`admin`** | Admin-specific configuration. See the [default field admin config](/docs/fields/overview#admin-config) for more details. |
-| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
+| Option | Description |
+| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
+| **`*relationTo`** \* | Provide a single collection `slug` to allow this field to accept a relation to. Note: the related collection must be configured to support Uploads. |
+| **`filterOptions`** | A query to filter which options appear in the UI and validate against. [More](#filtering-upload-options). |
+| **`maxDepth`** | Sets a number limit on iterations of related documents to populate when queried. [Depth](/docs/getting-started/concepts#depth) |
+| **`label`** | Text used as a field label in the Admin panel or an object with keys for each language. |
+| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. |
+| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |
+| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. |
+| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
+| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
+| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
+| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
+| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
+| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
+| **`required`** | Require this field to have a value. |
+| **`admin`** | Admin-specific configuration. See the [default field admin config](/docs/fields/overview#admin-config) for more details. |
+| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
+| **`typescriptSchema`** | Override field type generation with providing a JSON schema |
_\* An asterisk denotes that a property is required._
diff --git a/docs/typescript/generating-types.mdx b/docs/typescript/generating-types.mdx
index 8128314d44..be189544c9 100644
--- a/docs/typescript/generating-types.mdx
+++ b/docs/typescript/generating-types.mdx
@@ -61,16 +61,55 @@ You can specify where you want your types to be generated by adding a property t
The above example places your types next to your Payload config itself as the file `generated-types.ts`.
+## Custom generated types
+
+Payload generates your types based on a JSON schema. You can extend that JSON schema, and thus the generated types, by passing a function to `typescript.schema`:
+
+```ts
+// payload.config.ts
+{
+ // ...
+ typescript: {
+ schema: [
+ ({ jsonSchema }) => {
+ // Modify the JSON schema here
+ jsonSchema.definitions.Test = {
+ type: 'object',
+ properties: {
+ title: { type: 'string' },
+ content: { type: 'string' },
+ },
+ required: ['title', 'content'],
+ }
+ return jsonSchema
+ },
+ ]
+ }
+}
+
+// This will generate the following type in your payload-types.ts:
+
+export interface Test {
+ title: string;
+ content: string;
+ [k: string]: unknown;
+}
+```
+
+This function takes the existing JSON schema as an argument and returns the modified JSON schema. It can be useful for plugins that wish to generate their own types.
+
## Example Usage
For example, let's look at the following simple Payload config:
```ts
+import type { Config } from 'payload'
+
const config: Config = {
serverURL: process.env.PAYLOAD_PUBLIC_SERVER_URL,
admin: {
user: 'users',
- }
+ },
collections: [
{
slug: 'users',
diff --git a/packages/payload/src/config/schema.ts b/packages/payload/src/config/schema.ts
index 1a6a99ec61..b26886f1a0 100644
--- a/packages/payload/src/config/schema.ts
+++ b/packages/payload/src/config/schema.ts
@@ -204,6 +204,7 @@ export default joi.object({
autoGenerate: joi.boolean(),
declare: joi.alternatives().try(joi.boolean(), joi.object({ ignoreTSError: joi.boolean() })),
outputFile: joi.string(),
+ schema: joi.array().items(joi.func()),
}),
upload: joi.object(),
})
diff --git a/packages/payload/src/config/types.ts b/packages/payload/src/config/types.ts
index 348c4592e6..520c53bf24 100644
--- a/packages/payload/src/config/types.ts
+++ b/packages/payload/src/config/types.ts
@@ -6,6 +6,7 @@ import type {
} from '@payloadcms/translations'
import type { Options as ExpressFileUploadOptions } from 'express-fileupload'
import type GraphQL from 'graphql'
+import type { JSONSchema4 } from 'json-schema'
import type { DestinationStream, LoggerOptions } from 'pino'
import type React from 'react'
import type { JSX } from 'react'
@@ -744,6 +745,12 @@ export type Config = {
/** Filename to write the generated types to */
outputFile?: string
+
+ /**
+ * Allows you to modify the base JSON schema that is generated during generate:types. This JSON schema will be used
+ * to generate the TypeScript interfaces.
+ */
+ schema?: Array<(args: { jsonSchema: JSONSchema4 }) => JSONSchema4>
}
/**
* Customize the handling of incoming file uploads for collections that have uploads enabled.
diff --git a/packages/payload/src/fields/config/client.ts b/packages/payload/src/fields/config/client.ts
index 201e817b9d..16ba218ef5 100644
--- a/packages/payload/src/fields/config/client.ts
+++ b/packages/payload/src/fields/config/client.ts
@@ -8,6 +8,7 @@ export type ServerOnlyFieldProperties =
| 'editor' // This is a `richText` only property
| 'filterOptions' // This is a `relationship` and `upload` only property
| 'label'
+ | 'typescriptSchema'
| keyof Pick
export type ServerOnlyFieldAdminProperties = keyof Pick<
@@ -33,6 +34,7 @@ export const createClientFieldConfig = ({
'filterOptions', // This is a `relationship` and `upload` only property
'editor', // This is a `richText` only property
'custom',
+ 'typescriptSchema',
// `fields`
// `blocks`
// `tabs`
diff --git a/packages/payload/src/fields/config/schema.ts b/packages/payload/src/fields/config/schema.ts
index a64de83e75..28de1103ac 100644
--- a/packages/payload/src/fields/config/schema.ts
+++ b/packages/payload/src/fields/config/schema.ts
@@ -65,6 +65,7 @@ export const baseField = joi
localized: joi.boolean().default(false),
required: joi.boolean().default(false),
saveToJWT: joi.alternatives().try(joi.boolean(), joi.string()).default(false),
+ typescriptSchema: joi.array().items(joi.func()),
unique: joi.boolean().default(false),
validate: joi.func(),
})
diff --git a/packages/payload/src/fields/config/types.ts b/packages/payload/src/fields/config/types.ts
index 2d6484f621..bd27233733 100644
--- a/packages/payload/src/fields/config/types.ts
+++ b/packages/payload/src/fields/config/types.ts
@@ -5,6 +5,7 @@ import type { CSSProperties } from 'react'
//eslint-disable-next-line @typescript-eslint/no-unused-vars
import monacoeditor from 'monaco-editor' // IMPORTANT - DO NOT REMOVE: This is required for pnpm's default isolated mode to work - even though the import is not used. This is due to a typescript bug: https://github.com/microsoft/TypeScript/issues/47663#issuecomment-1519138189. (tsbugisolatedmode)
+import type { JSONSchema4 } from 'json-schema'
import type React from 'react'
import type { RichTextAdapter, RichTextAdapterProvider } from '../../admin/RichText.js'
@@ -231,6 +232,11 @@ export interface FieldBase {
name: string
required?: boolean
saveToJWT?: boolean | string
+ /**
+ * Allows you to modify the base JSON schema that is generated during generate:types for this field.
+ * This JSON schema will be used to generate the TypeScript interface of this field.
+ */
+ typescriptSchema?: Array<(args: { jsonSchema: JSONSchema4 }) => JSONSchema4>
unique?: boolean
validate?: Validate
}
@@ -530,7 +536,11 @@ type JSONAdmin = Admin & {
export type JSONField = Omit & {
admin?: JSONAdmin
- jsonSchema?: Record
+ jsonSchema?: {
+ fileMatch: string[]
+ schema: JSONSchema4
+ uri: string
+ }
type: 'json'
}
diff --git a/packages/payload/src/utilities/configToJSONSchema.spec.ts b/packages/payload/src/utilities/configToJSONSchema.spec.ts
index ca000cb72a..b8238c2c49 100644
--- a/packages/payload/src/utilities/configToJSONSchema.spec.ts
+++ b/packages/payload/src/utilities/configToJSONSchema.spec.ts
@@ -2,6 +2,7 @@ import type { Config } from '../config/types.js'
import { sanitizeConfig } from '../config/sanitize.js'
import { configToJSONSchema } from './configToJSONSchema.js'
+import { JSONSchema4 } from 'json-schema'
describe('configToJSONSchema', () => {
it('should handle optional arrays with required fields', async () => {
@@ -146,4 +147,58 @@ describe('configToJSONSchema', () => {
type: 'object',
})
})
+
+ it('should handle custom typescript schema and JSON field schema', async () => {
+ const customSchema: JSONSchema4 = {
+ type: 'object',
+ properties: {
+ id: {
+ type: 'number',
+ },
+ required: ['id'],
+ },
+ }
+
+ const config: Partial = {
+ collections: [
+ {
+ fields: [
+ {
+ type: 'text',
+ name: 'withCustom',
+ typescriptSchema: [() => customSchema],
+ },
+ {
+ type: 'json',
+ name: 'jsonWithSchema',
+ jsonSchema: {
+ uri: 'a://b/foo.json',
+ fileMatch: ['a://b/foo.json'],
+ schema: customSchema,
+ },
+ },
+ ],
+ slug: 'test',
+ timestamps: false,
+ },
+ ],
+ }
+
+ const sanitizedConfig = await sanitizeConfig(config as Config)
+ const schema = configToJSONSchema(sanitizedConfig, 'text')
+
+ expect(schema?.definitions?.test).toStrictEqual({
+ additionalProperties: false,
+ properties: {
+ id: {
+ type: 'string',
+ },
+ withCustom: customSchema,
+ jsonWithSchema: customSchema,
+ },
+ required: ['id'],
+ title: 'Test',
+ type: 'object',
+ })
+ })
})
diff --git a/packages/payload/src/utilities/configToJSONSchema.ts b/packages/payload/src/utilities/configToJSONSchema.ts
index bc4ce71ef3..b50b90e530 100644
--- a/packages/payload/src/utilities/configToJSONSchema.ts
+++ b/packages/payload/src/utilities/configToJSONSchema.ts
@@ -152,6 +152,7 @@ export function fieldsToJSONSchema(
if (isRequired) requiredFieldNames.add(field.name)
let fieldSchema: JSONSchema4
+
switch (field.type) {
case 'text':
if (field.hasMany === true) {
@@ -189,7 +190,7 @@ export function fieldsToJSONSchema(
}
case 'json': {
- fieldSchema = {
+ fieldSchema = field.jsonSchema?.schema || {
type: ['object', 'array', 'string', 'number', 'boolean', 'null'],
}
break
@@ -516,6 +517,12 @@ export function fieldsToJSONSchema(
}
}
+ if ('typescriptSchema' in field && field?.typescriptSchema?.length) {
+ for (const schema of field.typescriptSchema) {
+ fieldSchema = schema({ jsonSchema: fieldSchema })
+ }
+ }
+
if (fieldSchema && fieldAffectsData(field)) {
fieldSchemas.set(field.name, fieldSchema)
}
@@ -694,7 +701,7 @@ export function configToJSONSchema(
{ auth: {} },
)
- return {
+ let jsonSchema: JSONSchema4 = {
additionalProperties: false,
definitions: {
...entityDefinitions,
@@ -713,4 +720,12 @@ export function configToJSONSchema(
required: ['user', 'locale', 'collections', 'globals', 'auth'],
title: 'Config',
}
+
+ if (config?.typescript?.schema?.length) {
+ for (const schema of config.typescript.schema) {
+ jsonSchema = schema({ jsonSchema })
+ }
+ }
+
+ return jsonSchema
}
diff --git a/test/_community/config.ts b/test/_community/config.ts
index b8c8879319..56ba6c0621 100644
--- a/test/_community/config.ts
+++ b/test/_community/config.ts
@@ -18,6 +18,61 @@ export default buildConfigWithDefaults({
cors: ['http://localhost:3000', 'http://localhost:3001'],
globals: [
MenuGlobal,
+ {
+ slug: 'custom-ts',
+ fields: [
+ {
+ name: 'custom',
+ type: 'text',
+ typescriptSchema: [
+ () => ({
+ enum: ['hello', 'world'],
+ }),
+ ],
+ },
+ {
+ name: 'withDefinitionsUsage',
+ type: 'text',
+ typescriptSchema: [
+ () => ({
+ type: 'array',
+ items: {
+ $ref: `#/definitions/objectWithNumber`,
+ },
+ }),
+ ],
+ },
+ {
+ name: 'json',
+ type: 'json',
+ required: true,
+ jsonSchema: {
+ uri: 'a://b/foo.json',
+ fileMatch: ['a://b/foo.json'],
+ schema: {
+ type: 'array',
+ items: {
+ type: 'object',
+ additionalProperties: false,
+ properties: {
+ id: {
+ type: 'string',
+ },
+ name: {
+ type: 'string',
+ },
+ age: {
+ type: 'integer',
+ },
+ // Add other properties here
+ },
+ required: ['id', 'name'], // Specify which properties are required
+ },
+ },
+ },
+ },
+ ],
+ },
// ...add more globals here
],
onInit: async (payload) => {
@@ -48,5 +103,21 @@ export default buildConfigWithDefaults({
},
typescript: {
outputFile: path.resolve(dirname, 'payload-types.ts'),
+ schema: [
+ ({ jsonSchema }) => {
+ jsonSchema.definitions.objectWithNumber = {
+ type: 'object',
+ properties: {
+ id: {
+ type: 'number',
+ required: true,
+ },
+ },
+ required: true,
+ additionalProperties: false,
+ }
+ return jsonSchema
+ },
+ ],
},
})
diff --git a/test/_community/payload-types.ts b/test/_community/payload-types.ts
index 081ba6b61d..03aefb25ad 100644
--- a/test/_community/payload-types.ts
+++ b/test/_community/payload-types.ts
@@ -18,6 +18,7 @@ export interface Config {
};
globals: {
menu: Menu;
+ 'custom-ts': CustomT;
};
locale: null;
user: User & {
@@ -149,6 +150,6 @@ export interface Auth {
declare module 'payload' {
- // @ts-ignore
+ // @ts-ignore
export interface GeneratedTypes extends Config {}
-}
\ No newline at end of file
+}