payload 1.2.0 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +161 -16
- package/components/fields/Array.ts +1 -2
- package/components/fields/Blocks.ts +1 -2
- package/components/fields/Cell.ts +1 -1
- package/components/fields/Checkbox.ts +1 -2
- package/components/fields/Code.ts +1 -2
- package/components/fields/DateTime.ts +1 -2
- package/components/fields/Email.ts +1 -2
- package/components/fields/Group.ts +1 -2
- package/components/fields/Number.ts +1 -2
- package/components/fields/Password.ts +1 -2
- package/components/fields/RadioGroup/RadioInput.ts +1 -2
- package/components/fields/RadioGroup/index.ts +1 -2
- package/components/fields/Relationship.ts +1 -2
- package/components/fields/RichText.ts +1 -2
- package/components/fields/Row.ts +1 -2
- package/components/fields/Select.ts +1 -2
- package/components/fields/Text.ts +1 -2
- package/components/fields/Textarea.ts +1 -2
- package/components/fields/Upload.ts +1 -2
- package/components/views/Cell.ts +1 -2
- package/components/views/Edit.ts +1 -2
- package/components/views/List.ts +1 -2
- package/dist/admin/components/elements/ReactSelect/index.js +4 -4
- package/dist/admin/components/elements/ReactSelect/types.d.ts +11 -10
- package/dist/admin/components/elements/Status/index.js +1 -1
- package/dist/admin/components/elements/VersionsCount/index.js +1 -1
- package/dist/admin/components/elements/WhereBuilder/Condition/Text/index.js +5 -1
- package/dist/admin/components/forms/Form/context.d.ts +15 -0
- package/dist/admin/components/forms/Form/context.js +16 -1
- package/dist/admin/components/forms/field-types/Blocks/SectionTitle/index.scss +3 -2
- package/dist/admin/components/forms/field-types/Blocks/index.js +1 -1
- package/dist/admin/components/forms/field-types/Code/Code.js +3 -4
- package/dist/admin/components/forms/field-types/Code/index.scss +177 -78
- package/dist/admin/components/forms/field-types/Relationship/AddNew/index.js +0 -1
- package/dist/admin/components/forms/field-types/Relationship/GetFilterOptions/index.d.ts +11 -0
- package/dist/admin/components/forms/field-types/Relationship/GetFilterOptions/index.js +37 -0
- package/dist/admin/components/forms/field-types/Relationship/findOptionsByValue.d.ts +8 -0
- package/dist/admin/components/forms/field-types/Relationship/findOptionsByValue.js +29 -0
- package/dist/admin/components/forms/field-types/Relationship/index.js +89 -139
- package/dist/admin/components/forms/field-types/Relationship/optionsReducer.d.ts +2 -2
- package/dist/admin/components/forms/field-types/Relationship/optionsReducer.js +2 -29
- package/dist/admin/components/forms/field-types/Relationship/types.d.ts +14 -2
- package/dist/admin/components/forms/field-types/RichText/elements/link/Element.js +3 -3
- package/dist/admin/components/forms/field-types/RichText/elements/link/index.scss +2 -1
- package/dist/admin/components/forms/field-types/RichText/elements/upload/Button/index.js +1 -1
- package/dist/admin/components/forms/field-types/Row/index.js +1 -1
- package/dist/admin/components/forms/field-types/Select/Input.d.ts +2 -2
- package/dist/admin/components/forms/field-types/Select/Input.js +13 -3
- package/dist/admin/components/forms/field-types/Textarea/Input.js +1 -1
- package/dist/admin/components/forms/field-types/Textarea/index.scss +3 -6
- package/dist/admin/components/forms/useField/index.d.ts +5 -0
- package/dist/admin/components/forms/useField/index.js +5 -0
- package/dist/admin/components/utilities/I18n/index.js +1 -1
- package/dist/admin/components/views/Account/index.js +6 -1
- package/dist/admin/components/views/Global/index.scss +31 -24
- package/dist/admin/components/views/Login/index.js +1 -1
- package/dist/admin/components/views/Version/RenderFieldsToDiff/fields/Iterable/index.js +1 -1
- package/dist/admin/components/views/Version/RenderFieldsToDiff/fields/Nested/index.js +15 -9
- package/dist/admin/components/views/Version/RenderFieldsToDiff/fields/Relationship/index.js +5 -2
- package/dist/admin/components/views/Version/RenderFieldsToDiff/fields/Select/index.d.ts +5 -0
- package/dist/admin/components/views/Version/RenderFieldsToDiff/fields/Select/index.js +34 -0
- package/dist/admin/components/views/Version/RenderFieldsToDiff/fields/Select/index.scss +10 -0
- package/dist/admin/components/views/Version/RenderFieldsToDiff/fields/Text/index.js +3 -2
- package/dist/admin/components/views/Version/RenderFieldsToDiff/fields/index.js +3 -2
- package/dist/admin/components/views/Versions/index.js +1 -1
- package/dist/admin/components/views/collections/Edit/Default.js +2 -0
- package/dist/admin/components/views/collections/Edit/SetStepNav.d.ts +7 -0
- package/dist/admin/components/views/collections/Edit/SetStepNav.js +31 -0
- package/dist/admin/components/views/collections/Edit/index.js +2 -36
- package/dist/admin/components/views/collections/Edit/index.scss +19 -4
- package/dist/admin/hooks/usePayloadAPI.js +3 -1
- package/dist/collections/buildSchema.js +5 -1
- package/dist/collections/config/types.d.ts +16 -3
- package/dist/collections/operations/find.js +11 -6
- package/dist/collections/operations/findVersions.js +4 -5
- package/dist/collections/operations/update.js +8 -9
- package/dist/collections/requestHandlers/find.js +4 -3
- package/dist/collections/requestHandlers/update.js +3 -3
- package/dist/config/schema.js +2 -2
- package/dist/config/types.d.ts +269 -6
- package/dist/config/types.js +1 -1
- package/dist/email/build.js +2 -2
- package/dist/express/types.d.ts +26 -2
- package/dist/fields/config/sanitize.spec.js +5 -5
- package/dist/fields/config/types.d.ts +3 -3
- package/dist/fields/hooks/afterRead/relationshipPopulationPromise.js +73 -21
- package/dist/fields/hooks/beforeChange/promise.js +7 -1
- package/dist/globals/operations/findVersions.js +4 -5
- package/dist/globals/operations/update.js +4 -4
- package/dist/globals/requestHandlers/update.js +3 -3
- package/dist/graphql/schema/fieldToWhereInputSchemaMap.js +7 -7
- package/dist/graphql/schema/operators.d.ts +1 -0
- package/dist/graphql/schema/operators.js +2 -1
- package/dist/mongoose/types.d.ts +3 -3
- package/dist/translations/de.json +100 -100
- package/dist/translations/en.json +3 -1
- package/dist/translations/es.json +1 -1
- package/dist/translations/fr.json +1 -1
- package/dist/translations/index.d.ts +5 -0
- package/dist/translations/it.json +19 -16
- package/dist/translations/my.json +1 -1
- package/dist/translations/nl.json +1 -1
- package/dist/translations/pl.json +1 -1
- package/dist/translations/pt.json +1 -1
- package/dist/translations/ru.json +1 -1
- package/dist/translations/sv.json +1 -1
- package/dist/translations/vi.json +1 -1
- package/dist/utilities/isNumber.d.ts +1 -0
- package/dist/utilities/isNumber.js +8 -0
- package/dist/versions/drafts/saveCollectionDraft.js +4 -3
- package/dist/versions/drafts/saveGlobalDraft.js +4 -3
- package/dist/versions/ensurePublishedCollectionVersion.js +2 -1
- package/dist/versions/ensurePublishedGlobalVersion.js +2 -1
- package/dist/versions/getLatestCollectionVersion.d.ts +10 -0
- package/dist/versions/getLatestCollectionVersion.js +27 -0
- package/dist/versions/getLatestGlobalVersion.d.ts +10 -0
- package/dist/versions/getLatestGlobalVersion.js +27 -0
- package/docs/admin/components.mdx +1 -5
- package/docs/authentication/config.mdx +1 -1
- package/docs/configuration/globals.mdx +12 -12
- package/docs/configuration/i18n.mdx +1 -1
- package/docs/fields/array.mdx +14 -14
- package/docs/fields/blocks.mdx +1 -1
- package/docs/fields/checkbox.mdx +2 -2
- package/docs/fields/code.mdx +1 -1
- package/docs/fields/date.mdx +1 -1
- package/docs/fields/email.mdx +1 -1
- package/docs/fields/number.mdx +1 -1
- package/docs/fields/radio.mdx +1 -1
- package/docs/fields/relationship.mdx +1 -1
- package/docs/fields/rich-text.mdx +1 -1
- package/docs/fields/select.mdx +2 -2
- package/docs/fields/text.mdx +2 -2
- package/docs/fields/textarea.mdx +1 -1
- package/docs/fields/upload.mdx +51 -17
- package/docs/production/preventing-abuse.mdx +6 -6
- package/package.json +3 -2
package/docs/fields/upload.mdx
CHANGED
|
@@ -23,24 +23,24 @@ keywords: upload, images media, fields, config, configuration, documentation, Co
|
|
|
23
23
|
|
|
24
24
|
### Config
|
|
25
25
|
|
|
26
|
-
| Option | Description
|
|
27
|
-
| ----------------
|
|
28
|
-
| **`name`** * | To be used as the property name when stored and retrieved from the database.
|
|
29
|
-
| **`*relationTo`** * | Provide a single collection `slug` to allow this field to accept a relation to. <strong>Note: the related collection must be configured to support Uploads.</strong>
|
|
30
|
-
| **`filterOptions`** | A query to filter which options appear in the UI and validate against. [More](#filtering-
|
|
31
|
-
| **`maxDepth`** | Sets a number limit on iterations of related documents to populate when queried. [Depth](/docs/getting-started/concepts#depth)
|
|
32
|
-
| **`label`** |
|
|
33
|
-
| **`unique`** | Enforce that each entry in the Collection has a unique value for this field.
|
|
34
|
-
| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation)
|
|
26
|
+
| Option | Description |
|
|
27
|
+
| ---------------- |-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
28
|
+
| **`name`** * | To be used as the property name when stored and retrieved from the database. |
|
|
29
|
+
| **`*relationTo`** * | Provide a single collection `slug` to allow this field to accept a relation to. <strong>Note: the related collection must be configured to support Uploads.</strong> |
|
|
30
|
+
| **`filterOptions`** | A query to filter which options appear in the UI and validate against. [More](#filtering-upload-options). |
|
|
31
|
+
| **`maxDepth`** | Sets a number limit on iterations of related documents to populate when queried. [Depth](/docs/getting-started/concepts#depth) |
|
|
32
|
+
| **`label`** | Text used as a field label in the Admin panel or an object with keys for each language. |
|
|
33
|
+
| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. |
|
|
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
35
|
| **`index`** | Build a [MongoDB index](https://docs.mongodb.com/manual/indexes/) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. |
|
|
36
|
-
| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT.
|
|
37
|
-
| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks)
|
|
38
|
-
| **`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)
|
|
39
|
-
| **`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.
|
|
40
|
-
| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values)
|
|
41
|
-
| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config.
|
|
42
|
-
| **`required`** | Require this field to have a value.
|
|
43
|
-
| **`admin`** | Admin-specific configuration. See the [default field admin config](/docs/fields/overview#admin-config) for more details.
|
|
36
|
+
| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
|
|
37
|
+
| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
|
|
38
|
+
| **`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) |
|
|
39
|
+
| **`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. |
|
|
40
|
+
| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
|
|
41
|
+
| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
|
|
42
|
+
| **`required`** | Require this field to have a value. |
|
|
43
|
+
| **`admin`** | Admin-specific configuration. See the [default field admin config](/docs/fields/overview#admin-config) for more details. |
|
|
44
44
|
|
|
45
45
|
*\* An asterisk denotes that a property is required.*
|
|
46
46
|
|
|
@@ -63,3 +63,37 @@ const ExampleCollection: CollectionConfig = {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
```
|
|
66
|
+
|
|
67
|
+
### Filtering upload options
|
|
68
|
+
|
|
69
|
+
Options can be dynamically limited by supplying a [query constraint](/docs/queries/overview), which will be used both for validating input and filtering available uploads in the UI.
|
|
70
|
+
|
|
71
|
+
The `filterOptions` property can either be a `Where` query directly, or a function that returns one. When using a function, it will be called with an argument object with the following properties:
|
|
72
|
+
|
|
73
|
+
| Property | Description |
|
|
74
|
+
| ------------- | -------------|
|
|
75
|
+
| `relationTo` | The `relationTo` to filter against (as defined on the field) |
|
|
76
|
+
| `data` | An object of the full collection or global document currently being edited |
|
|
77
|
+
| `siblingData` | An object of the document data limited to fields within the same parent to the field |
|
|
78
|
+
| `id` | The value of the collection `id`, will be `undefined` on create request |
|
|
79
|
+
| `user` | The currently authenticated user object |
|
|
80
|
+
|
|
81
|
+
**Example:**
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
const uploadField = {
|
|
85
|
+
name: 'image',
|
|
86
|
+
type: 'upload',
|
|
87
|
+
relationTo: 'media',
|
|
88
|
+
filterOptions: {
|
|
89
|
+
mimeType: { contains: 'image' },
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
You can learn more about writing queries [here](/docs/queries/overview).
|
|
95
|
+
|
|
96
|
+
<Banner type="warning">
|
|
97
|
+
<strong>Note:</strong><br/>
|
|
98
|
+
When an upload field has both <strong>filterOptions</strong> and a custom <strong>validate</strong> function, the api will not validate <strong>filterOptions</strong> unless you call the default upload field validation function imported from <strong>payload/fields/validations</strong> in your validate function.
|
|
99
|
+
</Banner>
|
|
@@ -18,12 +18,12 @@ Set the max number of failed login attempts before a user account is locked out
|
|
|
18
18
|
|
|
19
19
|
To prevent DDoS, brute-force, and similar attacks, you can set IP-based rate limits so that once a certain threshold of requests has been hit by a single IP, further requests from the same IP will be ignored. The Payload config `rateLimit` property accepts an object with the following properties:
|
|
20
20
|
|
|
21
|
-
| Option | Description
|
|
22
|
-
| ---------------------------- |
|
|
23
|
-
| **`window`** | Time in milliseconds to track requests per IP |
|
|
24
|
-
| **`max`** | Number of requests served from a single IP before limiting |
|
|
25
|
-
| **`skip`** | Express middleware function that can return true (or promise resulting in true) that will bypass limit |
|
|
26
|
-
| **`trustProxy`** | True or false, to enable to allow requests to pass through a proxy such as a load balancer or an `nginx` reverse proxy |
|
|
21
|
+
| Option | Description |
|
|
22
|
+
| ---------------------------- | ----------- |
|
|
23
|
+
| **`window`** | Time in milliseconds to track requests per IP. Defaults to `90000` (15 minutes). |
|
|
24
|
+
| **`max`** | Number of requests served from a single IP before limiting. Defaults to `500`. |
|
|
25
|
+
| **`skip`** | Express middleware function that can return true (or promise resulting in true) that will bypass limit. |
|
|
26
|
+
| **`trustProxy`** | True or false, to enable to allow requests to pass through a proxy such as a load balancer or an `nginx` reverse proxy. |
|
|
27
27
|
|
|
28
28
|
<Banner type="warning">
|
|
29
29
|
<strong>Warning:</strong><br/>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "payload",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "Node, React and MongoDB Headless CMS and Application Framework",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
"release:minor": "release-it minor",
|
|
53
53
|
"release:major": "release-it major",
|
|
54
54
|
"release:beta": "release-it prepatch --config .release-it.beta.json",
|
|
55
|
+
"fix": "eslint \"src/**/*.ts\" --fix",
|
|
55
56
|
"lint": "eslint \"src/**/*.ts\""
|
|
56
57
|
},
|
|
57
58
|
"bugs": {
|
|
@@ -94,6 +95,7 @@
|
|
|
94
95
|
"@faceless-ui/scroll-info": "^1.2.3",
|
|
95
96
|
"@faceless-ui/window-info": "^2.0.2",
|
|
96
97
|
"@types/is-plain-object": "^2.0.4",
|
|
98
|
+
"@types/sharp": "^0.26.1",
|
|
97
99
|
"babel-jest": "^26.3.0",
|
|
98
100
|
"babel-loader": "^8.1.0",
|
|
99
101
|
"body-parser": "^1.19.0",
|
|
@@ -255,7 +257,6 @@
|
|
|
255
257
|
"@types/react-router-dom": "^5.1.6",
|
|
256
258
|
"@types/react-select": "^3.0.26",
|
|
257
259
|
"@types/sass": "^1.16.0",
|
|
258
|
-
"@types/sharp": "^0.26.1",
|
|
259
260
|
"@types/shelljs": "^0.8.11",
|
|
260
261
|
"@types/testing-library__jest-dom": "^5.9.5",
|
|
261
262
|
"@types/uuid": "^8.3.0",
|