payload 1.6.9 → 1.6.11

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.
Files changed (78) hide show
  1. package/dist/admin/components/elements/DatePicker/DatePicker.js +8 -13
  2. package/dist/admin/components/elements/DatePicker/DatePicker.js.map +1 -1
  3. package/dist/admin/components/forms/field-types/Relationship/createRelationMap.d.ts +2 -1
  4. package/dist/admin/components/forms/field-types/Relationship/createRelationMap.js +6 -5
  5. package/dist/admin/components/forms/field-types/Relationship/createRelationMap.js.map +1 -1
  6. package/dist/admin/components/forms/field-types/Relationship/index.js +7 -3
  7. package/dist/admin/components/forms/field-types/Relationship/index.js.map +1 -1
  8. package/dist/admin/components/forms/field-types/Relationship/types.d.ts +4 -7
  9. package/dist/admin/components/forms/field-types/RichText/plugins/withHTML.js +1 -1
  10. package/dist/admin/components/forms/field-types/RichText/plugins/withHTML.js.map +1 -1
  11. package/dist/admin/components/utilities/Config/index.js +17 -1
  12. package/dist/admin/components/utilities/Config/index.js.map +1 -1
  13. package/dist/admin/components/views/Account/Default.js +3 -3
  14. package/dist/admin/components/views/Account/Default.js.map +1 -1
  15. package/dist/admin/components/views/Global/Default.js +2 -2
  16. package/dist/admin/components/views/Global/Default.js.map +1 -1
  17. package/dist/admin/components/views/Version/Compare/index.js +2 -2
  18. package/dist/admin/components/views/Version/Compare/index.js.map +1 -1
  19. package/dist/admin/components/views/Version/Version.js +4 -4
  20. package/dist/admin/components/views/Version/Version.js.map +1 -1
  21. package/dist/admin/components/views/Versions/columns.d.ts +1 -1
  22. package/dist/admin/components/views/Versions/columns.js +4 -2
  23. package/dist/admin/components/views/Versions/columns.js.map +1 -1
  24. package/dist/admin/components/views/collections/Edit/Auth/index.js +9 -8
  25. package/dist/admin/components/views/collections/Edit/Auth/index.js.map +1 -1
  26. package/dist/admin/components/views/collections/Edit/Default.js +3 -3
  27. package/dist/admin/components/views/collections/Edit/Default.js.map +1 -1
  28. package/dist/admin/components/views/collections/List/Cell/field-types/Date/index.js +4 -2
  29. package/dist/admin/components/views/collections/List/Cell/field-types/Date/index.js.map +1 -1
  30. package/dist/admin/hooks/useTitle.js +4 -2
  31. package/dist/admin/hooks/useTitle.js.map +1 -1
  32. package/dist/admin/utilities/formatDate/getSupportedDateLocale.d.ts +1 -0
  33. package/dist/admin/utilities/formatDate/getSupportedDateLocale.js +14 -0
  34. package/dist/admin/utilities/formatDate/getSupportedDateLocale.js.map +1 -0
  35. package/dist/admin/utilities/formatDate/index.d.ts +1 -0
  36. package/dist/admin/utilities/formatDate/index.js +36 -0
  37. package/dist/admin/utilities/formatDate/index.js.map +1 -0
  38. package/dist/bin/build.js +1 -1
  39. package/dist/bin/build.js.map +1 -1
  40. package/dist/bin/generateGraphQLSchema.js +1 -1
  41. package/dist/bin/generateGraphQLSchema.js.map +1 -1
  42. package/dist/bin/generateTypes.d.ts +1 -1
  43. package/dist/bin/generateTypes.js +2 -2
  44. package/dist/bin/generateTypes.js.map +1 -1
  45. package/dist/collections/operations/update.js +27 -27
  46. package/dist/collections/operations/update.js.map +1 -1
  47. package/dist/collections/requestHandlers/update.d.ts +1 -0
  48. package/dist/collections/requestHandlers/update.js.map +1 -1
  49. package/dist/config/build.d.ts +1 -1
  50. package/dist/config/build.js +6 -3
  51. package/dist/config/build.js.map +1 -1
  52. package/dist/config/load.d.ts +1 -1
  53. package/dist/config/load.js +6 -6
  54. package/dist/config/load.js.map +1 -1
  55. package/dist/config/schema.js.map +1 -1
  56. package/dist/config/types.d.ts +2 -2
  57. package/dist/config/validate.d.ts +1 -1
  58. package/dist/config/validate.js +3 -3
  59. package/dist/config/validate.js.map +1 -1
  60. package/dist/fields/config/schema.js +1 -0
  61. package/dist/fields/config/schema.js.map +1 -1
  62. package/dist/fields/config/types.d.ts +2 -1
  63. package/dist/fields/config/types.js.map +1 -1
  64. package/dist/globals/operations/update.js +20 -20
  65. package/dist/globals/operations/update.js.map +1 -1
  66. package/dist/payload.js +3 -3
  67. package/dist/payload.js.map +1 -1
  68. package/dist/translations/es.json +30 -17
  69. package/dist/translations/hr.json +1 -1
  70. package/dist/translations/index.d.ts +15 -2
  71. package/dist/versions/saveVersion.js +1 -1
  72. package/dist/versions/saveVersion.js.map +1 -1
  73. package/docs/fields/date.mdx +2 -2
  74. package/docs/fields/radio.mdx +3 -3
  75. package/docs/fields/relationship.mdx +70 -57
  76. package/docs/production/deployment.mdx +6 -0
  77. package/errors.js +34 -1
  78. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  ---
2
- title: Radio Field
2
+ title: Radio Group Field
3
3
  label: Radio Group
4
4
  order: 120
5
5
  desc: The Radio field type allows for the selection of one value from a predefined set of possible values. Learn how to use Radio fields, see examples and options.
@@ -7,7 +7,7 @@ keywords: radio, fields, config, configuration, documentation, Content Managemen
7
7
  ---
8
8
 
9
9
  <Banner >
10
- The Radio field type allows for the selection of one value from a predefined set of possible values and presents a radio group-style set of inputs to the Admin panel.
10
+ The Radio Group field type allows for the selection of one value from a predefined set of possible values and presents a radio group-style set of inputs to the Admin panel.
11
11
  </Banner>
12
12
 
13
13
  ### Config
@@ -37,7 +37,7 @@ keywords: radio, fields, config, configuration, documentation, Content Managemen
37
37
 
38
38
  ### Admin config
39
39
 
40
- In addition to the default [field admin config](/docs/fields/overview#admin-config), the Radio field type allows for the specification of the following `admin` properties:
40
+ In addition to the default [field admin config](/docs/fields/overview#admin-config), the Radio Group field type allows for the specification of the following `admin` properties:
41
41
 
42
42
  **`layout`**
43
43
 
@@ -6,8 +6,9 @@ desc: The Relationship field provides the ability to relate documents together.
6
6
  keywords: relationship, fields, config, configuration, documentation, Content Management System, cms, headless, javascript, node, react, express
7
7
  ---
8
8
 
9
- <Banner >
10
- The Relationship field is one of the most powerful fields Payload features. It provides for the ability to easily relate documents together.
9
+ <Banner>
10
+ The Relationship field is one of the most powerful fields Payload features. It
11
+ provides for the ability to easily relate documents together.
11
12
  </Banner>
12
13
 
13
14
  **Example uses:**
@@ -18,31 +19,33 @@ keywords: relationship, fields, config, configuration, documentation, Content Ma
18
19
 
19
20
  ### Config
20
21
 
21
- | Option | Description |
22
- | ---------------- | ----------- |
23
- | **`name`** * | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
24
- | **`relationTo`** * | Provide one or many collection `slug`s to be able to assign relationships to. |
25
- | **`filterOptions`** | A query to filter which options appear in the UI and validate against. [More](#filtering-relationship-options). |
26
- | **`hasMany`** | Boolean when, if set to `true`, allows this field to have many relations instead of only one. |
27
- | **`maxDepth`** | Sets a number limit on iterations of related documents to populate when queried. [Depth](/docs/getting-started/concepts#depth) |
28
- | **`label`** | Text used as a field label in the Admin panel or an object with keys for each language. |
29
- | **`unique`** | Enforce that each entry in the Collection has a unique value for this field. |
30
- | **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |
31
- | **`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. |
32
- | **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
33
- | **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
34
- | **`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) |
35
- | **`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. |
36
- | **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
37
- | **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
38
- | **`required`** | Require this field to have a value. |
39
- | **`admin`** | Admin-specific configuration. See the [default field admin config](/docs/fields/overview#admin-config) for more details. |
40
-
41
- *\* An asterisk denotes that a property is required.*
22
+ | Option | Description |
23
+ | ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
24
+ | **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
25
+ | **`relationTo`** \* | Provide one or many collection `slug`s to be able to assign relationships to. |
26
+ | **`filterOptions`** | A query to filter which options appear in the UI and validate against. [More](#filtering-relationship-options). |
27
+ | **`hasMany`** | Boolean when, if set to `true`, allows this field to have many relations instead of only one. |
28
+ | **`maxDepth`** | Sets a number limit on iterations of related documents to populate when queried. [Depth](/docs/getting-started/concepts#depth) |
29
+ | **`label`** | Text used as a field label in the Admin panel or an object with keys for each language. |
30
+ | **`unique`** | Enforce that each entry in the Collection has a unique value for this field. |
31
+ | **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |
32
+ | **`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. |
33
+ | **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
34
+ | **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
35
+ | **`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) |
36
+ | **`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. |
37
+ | **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
38
+ | **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
39
+ | **`required`** | Require this field to have a value. |
40
+ | **`admin`** | Admin-specific configuration. See the [default field admin config](/docs/fields/overview#admin-config) for more details. |
41
+
42
+ _\* An asterisk denotes that a property is required._
42
43
 
43
44
  <Banner type="success">
44
- <strong>Tip:</strong><br/>
45
- The <a href="/docs/getting-started/concepts#depth">Depth</a> parameter can be used to automatically populate related documents that are returned by the API.
45
+ <strong>Tip:</strong>
46
+ <br />
47
+ The <a href="/docs/getting-started/concepts#depth">Depth</a> parameter can be
48
+ used to automatically populate related documents that are returned by the API.
46
49
  </Banner>
47
50
 
48
51
  ### Admin config
@@ -51,7 +54,11 @@ In addition to the default [field admin config](/docs/fields/overview#admin-conf
51
54
 
52
55
  **`isSortable`**
53
56
 
54
- Set to `true` if you'd like this field to be sortable within the Admin UI using drag and drop. (Only works when `hasMany` is set to `true`)
57
+ Set to `true` if you'd like this field to be sortable within the Admin UI using drag and drop (only works when `hasMany` is set to `true`).
58
+
59
+ **`allowCreate`**
60
+
61
+ Set to `false` if you'd like to disable the ability to create new documents from within the relationship field (hides the "Add new" button in the admin UI).
55
62
 
56
63
  ### Filtering relationship options
57
64
 
@@ -59,33 +66,33 @@ Options can be dynamically limited by supplying a [query constraint](/docs/queri
59
66
 
60
67
  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:
61
68
 
62
- | Property | Description |
63
- | ------------- | -------------|
64
- | `relationTo` | The `relationTo` to filter against (as defined on the field) |
65
- | `data` | An object of the full collection or global document currently being edited |
66
- | `siblingData` | An object of the document data limited to fields within the same parent to the field |
67
- | `id` | The value of the collection `id`, will be `undefined` on create request |
68
- | `user` | The currently authenticated user object |
69
+ | Property | Description |
70
+ | ------------- | ------------------------------------------------------------------------------------ |
71
+ | `relationTo` | The `relationTo` to filter against (as defined on the field) |
72
+ | `data` | An object of the full collection or global document currently being edited |
73
+ | `siblingData` | An object of the document data limited to fields within the same parent to the field |
74
+ | `id` | The value of the collection `id`, will be `undefined` on create request |
75
+ | `user` | The currently authenticated user object |
69
76
 
70
77
  **Example:**
71
78
 
72
79
  ```ts
73
80
  const relationshipField = {
74
- name: 'purchase',
75
- type: 'relationship',
76
- relationTo: ['products', 'services'],
81
+ name: "purchase",
82
+ type: "relationship",
83
+ relationTo: ["products", "services"],
77
84
  filterOptions: ({ relationTo, siblingData }) => {
78
85
  // returns a Where query dynamically by the type of relationship
79
- if (relationTo === 'products') {
86
+ if (relationTo === "products") {
80
87
  return {
81
- 'stock': { greater_than: siblingData.quantity }
82
- }
88
+ stock: { greater_than: siblingData.quantity },
89
+ };
83
90
  }
84
91
 
85
- if (relationTo === 'services') {
92
+ if (relationTo === "services") {
86
93
  return {
87
- 'isAvailable': { equals: true }
88
- }
94
+ isAvailable: { equals: true },
95
+ };
89
96
  }
90
97
  },
91
98
  };
@@ -94,8 +101,13 @@ const relationshipField = {
94
101
  You can learn more about writing queries [here](/docs/queries/overview).
95
102
 
96
103
  <Banner type="warning">
97
- <strong>Note:</strong><br/>
98
- When a relationship 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 relationship field validation function imported from <strong>payload/fields/validations</strong> in your validate function.
104
+ <strong>Note:</strong>
105
+ <br />
106
+ When a relationship field has both <strong>filterOptions</strong> and a custom{" "}
107
+ <strong>validate</strong> function, the api will not validate{" "}
108
+ <strong>filterOptions</strong> unless you call the default relationship field
109
+ validation function imported from <strong>payload/fields/validations</strong>{" "}
110
+ in your validate function.
99
111
  </Banner>
100
112
 
101
113
  ### How the data is saved
@@ -123,10 +135,10 @@ The most simple pattern of a relationship is to use `hasMany: false` with a `rel
123
135
  The shape of the data to save for a document with the field configured this way would be:
124
136
 
125
137
  ```json
126
- {
127
- // Mongo ObjectID of the related user
128
- "owner": "6031ac9e1289176380734024"
129
- }
138
+ {
139
+ // Mongo ObjectID of the related user
140
+ "owner": "6031ac9e1289176380734024"
141
+ }
130
142
  ```
131
143
 
132
144
  When querying documents in this collection via REST API, you could query as follows:
@@ -154,12 +166,12 @@ Also known as **dynamic references**, in this configuration, the `relationTo` fi
154
166
  The shape of the data to save for a document with more than one relationship type would be:
155
167
 
156
168
  ```json
157
- {
158
- "owner": {
159
- "relationTo": "organizations",
160
- "value": "6031ac9e1289176380734024"
161
- }
169
+ {
170
+ "owner": {
171
+ "relationTo": "organizations",
172
+ "value": "6031ac9e1289176380734024"
162
173
  }
174
+ }
163
175
  ```
164
176
 
165
177
  Here is an example for how to query documents by this data (note the difference in referencing the `owner.value`):
@@ -193,9 +205,9 @@ The `hasMany` tells Payload that there may be more than one collection saved to
193
205
  To save the to `hasMany` relationship field we need to send an array of IDs:
194
206
 
195
207
  ```json
196
- {
197
- "owners": [ "6031ac9e1289176380734024", "602c3c327b811235943ee12b" ]
198
- }
208
+ {
209
+ "owners": ["6031ac9e1289176380734024", "602c3c327b811235943ee12b"]
210
+ }
199
211
  ```
200
212
 
201
213
  When querying documents, the format does not change for arrays:
@@ -227,7 +239,8 @@ Relationship fields with `hasMany` set to more than one kind of collections save
227
239
  {
228
240
  "relationTo": "users",
229
241
  "value": "6031ac9e1289176380734024"
230
- }, {
242
+ },
243
+ {
231
244
  "relationTo": "organizations",
232
245
  "value": "602c3c327b811235943ee12b"
233
246
  }
@@ -12,9 +12,15 @@ keywords: deployment, production, config, configuration, documentation, Content
12
12
 
13
13
  There are many ways to deploy Payload to a production environment. When evaluating how you will deploy Payload, you need to consider these main aspects:
14
14
 
15
+ 1. [Basics](#basics)
15
16
  1. [Security](#security)
16
17
  1. [Your MongoDB](#mongodb)
17
18
  1. [Permanent File Storage](#file-storage)
19
+ 1. [Docker](#docker)
20
+
21
+ ## Basics
22
+
23
+ In order for Payload to run, it requires both the server code and the built admin panel. These will be the `dist` and `build` directories by default. If you've used `create-payload-app` to create your project, executing the `build` npm script will build both and output these directories.
18
24
 
19
25
  ## Security
20
26
 
package/errors.js CHANGED
@@ -1,6 +1,39 @@
1
- const { APIError, Forbidden } = require('./dist/errors');
1
+ const {
2
+ APIError,
3
+ AuthenticationError,
4
+ DuplicateCollection,
5
+ DuplicateGlobal,
6
+ ErrorDeletingFile,
7
+ FileUploadError,
8
+ Forbidden,
9
+ InvalidConfiguration,
10
+ InvalidFieldName,
11
+ InvalidFieldRelationship,
12
+ LockedAuth,
13
+ MissingCollectionLabel,
14
+ MissingFieldInputOptions,
15
+ MissingFieldType,
16
+ MissingFile,
17
+ NotFound,
18
+ ValidationError,
19
+ } = require('./dist/errors');
2
20
 
3
21
  module.exports = {
4
22
  APIError,
23
+ AuthenticationError,
24
+ DuplicateCollection,
25
+ DuplicateGlobal,
26
+ ErrorDeletingFile,
27
+ FileUploadError,
5
28
  Forbidden,
29
+ InvalidConfiguration,
30
+ InvalidFieldName,
31
+ InvalidFieldRelationship,
32
+ LockedAuth,
33
+ MissingCollectionLabel,
34
+ MissingFieldInputOptions,
35
+ MissingFieldType,
36
+ MissingFile,
37
+ NotFound,
38
+ ValidationError,
6
39
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payload",
3
- "version": "1.6.9",
3
+ "version": "1.6.11",
4
4
  "description": "Node, React and MongoDB Headless CMS and Application Framework",
5
5
  "license": "MIT",
6
6
  "engines": {