Skip to content

Commit eb2f763

Browse files
r1tsuuAlessioGr
andauthored
feat: allow users/plugins to modify and extend generated types for fields & config, add generated types for json field (#6984)
- Improves type for `jsonSchema` property of JSON field - Adds type generation of JSON field with `jsonSchema` - Adds `typescriptSchema` property to fields that allows you override default field type generation by providing a JSON schema. - Adds `typescript.schema` property in payload config, to allow for any modifications of the type schemas --------- Co-authored-by: Alessio Gravili <alessio@gravili.de>
1 parent 955b845 commit eb2f763

27 files changed

+528
-309
lines changed

docs/fields/array.mdx

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,27 @@ keywords: array, fields, config, configuration, documentation, Content Managemen
2626

2727
## Config
2828

29-
| Option | Description |
30-
| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
31-
| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
32-
| **`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. |
33-
| **`fields`** \* | Array of field types to correspond to each row of the Array. |
34-
| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |
35-
| **`minRows`** | A number for the fewest allowed items during validation when a value is present. |
36-
| **`maxRows`** | A number for the most allowed items during validation when a value is present. |
37-
| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
38-
| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
39-
| **`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) |
40-
| **`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. |
41-
| **`defaultValue`** | Provide an array of row data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
42-
| **`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`. |
43-
| **`required`** | Require this field to have a value. |
44-
| **`labels`** | Customize the row labels appearing in the Admin dashboard. |
45-
| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
46-
| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
47-
| **`interfaceName`** | Create a top level, reusable [Typescript interface](/docs/typescript/generating-types#custom-field-interfaces) & [GraphQL type](/docs/graphql/graphql-schema#custom-field-schemas). |
48-
| **`dbName`** | Custom table name for the field when using SQL database adapter ([Postgres](/docs/database/postgres)). Auto-generated from name if not defined. |
29+
| Option | Description |
30+
| ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
31+
| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
32+
| **`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. |
33+
| **`fields`** \* | Array of field types to correspond to each row of the Array. |
34+
| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |
35+
| **`minRows`** | A number for the fewest allowed items during validation when a value is present. |
36+
| **`maxRows`** | A number for the most allowed items during validation when a value is present. |
37+
| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
38+
| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
39+
| **`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) |
40+
| **`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. |
41+
| **`defaultValue`** | Provide an array of row data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
42+
| **`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`. |
43+
| **`required`** | Require this field to have a value. |
44+
| **`labels`** | Customize the row labels appearing in the Admin dashboard. |
45+
| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
46+
| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
47+
| **`interfaceName`** | Create a top level, reusable [Typescript interface](/docs/typescript/generating-types#custom-field-interfaces) & [GraphQL type](/docs/graphql/graphql-schema#custom-field-schemas). |
48+
| **`dbName`** | Custom table name for the field when using SQL database adapter ([Postgres](/docs/database/postgres)). Auto-generated from name if not defined. |
49+
| **`typescriptSchema`** | Override field type generation with providing a JSON schema |
4950

5051
_\* An asterisk denotes that a property is required._
5152

0 commit comments

Comments
 (0)