payload 1.0.27 → 1.0.28

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 (97) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/admin/components/elements/Status/index.js +1 -1
  3. package/dist/admin/components/elements/ViewDescription/types.d.ts +1 -1
  4. package/dist/admin/components/elements/WhereBuilder/index.js +13 -7
  5. package/dist/admin/components/forms/field-types/Array/index.d.ts +3 -2
  6. package/dist/admin/components/forms/field-types/Array/index.js +201 -6
  7. package/dist/admin/components/forms/field-types/Blocks/index.d.ts +3 -2
  8. package/dist/admin/components/forms/field-types/Blocks/index.js +213 -6
  9. package/dist/admin/components/forms/field-types/Collapsible/index.js +2 -2
  10. package/dist/admin/components/forms/field-types/Row/index.js +2 -2
  11. package/dist/admin/components/forms/field-types/Tabs/index.js +2 -2
  12. package/dist/admin/components/forms/field-types/getFieldPath.d.ts +2 -0
  13. package/dist/admin/components/forms/field-types/getFieldPath.js +6 -0
  14. package/dist/admin/components/forms/field-types/index.d.ts +23 -23
  15. package/dist/admin/components/utilities/RenderCustomComponent/types.d.ts +2 -2
  16. package/dist/admin/components/views/collections/List/Cell/field-types/Relationship/index.js +1 -1
  17. package/dist/auth/operations/local/forgotPassword.js +3 -6
  18. package/dist/auth/operations/local/login.js +6 -9
  19. package/dist/auth/operations/local/resetPassword.js +4 -7
  20. package/dist/auth/operations/local/unlock.js +4 -7
  21. package/dist/collections/config/types.d.ts +2 -2
  22. package/dist/collections/dataloader.js +16 -8
  23. package/dist/collections/operations/local/create.d.ts +2 -2
  24. package/dist/collections/operations/local/create.js +11 -13
  25. package/dist/collections/operations/local/find.js +6 -10
  26. package/dist/collections/operations/local/findByID.js +6 -10
  27. package/dist/collections/operations/local/findVersionByID.js +6 -9
  28. package/dist/config/types.d.ts +13 -13
  29. package/dist/fields/config/sanitize.js +3 -3
  30. package/dist/fields/config/schema.js +3 -3
  31. package/dist/fields/config/types.d.ts +9 -9
  32. package/dist/fields/validations.js +43 -1
  33. package/dist/globals/config/types.d.ts +1 -1
  34. package/dist/utilities/getIDType.d.ts +2 -0
  35. package/dist/utilities/getIDType.js +11 -0
  36. package/dist/utilities/isValidID.d.ts +1 -0
  37. package/dist/utilities/isValidID.js +16 -0
  38. package/docs/access-control/collections.mdx +21 -12
  39. package/docs/access-control/fields.mdx +5 -3
  40. package/docs/access-control/globals.mdx +8 -4
  41. package/docs/access-control/overview.mdx +1 -1
  42. package/docs/admin/components.mdx +29 -25
  43. package/docs/admin/customizing-css.mdx +2 -2
  44. package/docs/admin/overview.mdx +2 -2
  45. package/docs/admin/webpack.mdx +8 -7
  46. package/docs/authentication/config.mdx +14 -9
  47. package/docs/authentication/operations.mdx +22 -22
  48. package/docs/authentication/overview.mdx +8 -6
  49. package/docs/authentication/using-middleware.mdx +1 -1
  50. package/docs/configuration/collections.mdx +11 -7
  51. package/docs/configuration/globals.mdx +9 -5
  52. package/docs/configuration/localization.mdx +33 -31
  53. package/docs/configuration/overview.mdx +4 -7
  54. package/docs/email/overview.mdx +11 -7
  55. package/docs/fields/array.mdx +6 -5
  56. package/docs/fields/blocks.mdx +6 -4
  57. package/docs/fields/checkbox.mdx +6 -5
  58. package/docs/fields/code.mdx +6 -5
  59. package/docs/fields/collapsible.mdx +6 -5
  60. package/docs/fields/date.mdx +6 -5
  61. package/docs/fields/email.mdx +6 -5
  62. package/docs/fields/group.mdx +6 -5
  63. package/docs/fields/number.mdx +6 -5
  64. package/docs/fields/overview.mdx +40 -38
  65. package/docs/fields/point.mdx +6 -4
  66. package/docs/fields/radio.mdx +5 -3
  67. package/docs/fields/relationship.mdx +21 -21
  68. package/docs/fields/rich-text.mdx +9 -7
  69. package/docs/fields/row.mdx +5 -3
  70. package/docs/fields/select.mdx +4 -3
  71. package/docs/fields/tabs.mdx +5 -3
  72. package/docs/fields/text.mdx +5 -3
  73. package/docs/fields/textarea.mdx +5 -3
  74. package/docs/fields/ui.mdx +5 -3
  75. package/docs/fields/upload.mdx +5 -3
  76. package/docs/getting-started/concepts.mdx +1 -1
  77. package/docs/graphql/extending.mdx +1 -1
  78. package/docs/graphql/overview.mdx +8 -4
  79. package/docs/hooks/collections.mdx +62 -36
  80. package/docs/hooks/fields.mdx +5 -3
  81. package/docs/hooks/globals.mdx +25 -17
  82. package/docs/local-api/overview.mdx +27 -4
  83. package/docs/plugins/overview.mdx +3 -4
  84. package/docs/production/deployment.mdx +1 -1
  85. package/docs/queries/overview.mdx +4 -2
  86. package/docs/queries/pagination.mdx +1 -1
  87. package/docs/rest-api/overview.mdx +4 -2
  88. package/docs/upload/overview.mdx +35 -29
  89. package/docs/versions/autosave.mdx +4 -2
  90. package/docs/versions/drafts.mdx +8 -4
  91. package/docs/versions/overview.mdx +1 -1
  92. package/package.json +1 -1
  93. package/types.d.ts +21 -0
  94. package/dist/admin/components/forms/field-types/Array/Array.d.ts +0 -5
  95. package/dist/admin/components/forms/field-types/Array/Array.js +0 -201
  96. package/dist/admin/components/forms/field-types/Blocks/Blocks.d.ts +0 -5
  97. package/dist/admin/components/forms/field-types/Blocks/Blocks.js +0 -213
@@ -10,8 +10,8 @@ Payload uses Webpack 5 to build the Admin panel. It comes with support for many
10
10
 
11
11
  To extend the Webpack config, add the `webpack` key to your base Payload config, and provide a function that accepts the default Webpack config as its only argument:
12
12
 
13
- `payload.config.js`
14
- ```js
13
+ `payload.config.ts`
14
+ ```ts
15
15
  import { buildConfig } from 'payload/config';
16
16
 
17
17
  export default buildConfig({
@@ -24,7 +24,7 @@ export default buildConfig({
24
24
  }
25
25
  // highlight-end
26
26
  }
27
- })
27
+ });
28
28
  ```
29
29
 
30
30
  ### Aliasing server-only modules
@@ -52,16 +52,17 @@ You may rely on server-only packages such as the above to perform logic in acces
52
52
  <br/><br/>
53
53
 
54
54
  `collections/Subscriptions/index.js`
55
- ```js
55
+ ```ts
56
+ import { CollectionConfig } from 'payload/types';
56
57
  import createStripeSubscription from './hooks/createStripeSubscription';
57
58
 
58
- const Subscription = {
59
+ const Subscription: CollectionConfig = {
59
60
  slug: 'subscriptions',
60
61
  hooks: {
61
62
  beforeChange: [
62
63
  createStripeSubscription,
63
64
  ]
64
- }
65
+ },
65
66
  fields: [
66
67
  {
67
68
  name: 'stripeSubscriptionID',
@@ -69,7 +70,7 @@ const Subscription = {
69
70
  required: true,
70
71
  }
71
72
  ]
72
- }
73
+ };
73
74
 
74
75
  export default Subscription;
75
76
  ```
@@ -49,7 +49,7 @@ To utilize your API key while interacting with the REST or GraphQL API, add the
49
49
 
50
50
  **For example, using Fetch:**
51
51
 
52
- ```js
52
+ ```ts
53
53
  const response = await fetch("http://localhost:3000/api/pages", {
54
54
  headers: {
55
55
  Authorization: `${collection.labels.singular} API-Key ${YOUR_API_KEY}`,
@@ -77,8 +77,10 @@ Function that accepts one argument, containing `{ req, token, user }`, that allo
77
77
 
78
78
  Example:
79
79
 
80
- ```js
81
- {
80
+ ```ts
81
+ import { CollectionConfig } from 'payload/types';
82
+
83
+ const Customers: CollectionConfig = {
82
84
  slug: 'customers',
83
85
  auth: {
84
86
  forgotPassword: {
@@ -104,7 +106,7 @@ Example:
104
106
  // highlight-end
105
107
  }
106
108
  }
107
- }
109
+ };
108
110
  ```
109
111
 
110
112
  <Banner type="warning">
@@ -123,7 +125,7 @@ Similarly to the above `generateEmailHTML`, you can also customize the subject o
123
125
 
124
126
  Example:
125
127
 
126
- ```js
128
+ ```ts
127
129
  {
128
130
  slug: 'customers',
129
131
  auth: {
@@ -148,8 +150,11 @@ Function that accepts one argument, containing `{ req, token, user }`, that allo
148
150
 
149
151
  Example:
150
152
 
151
- ```js
152
- {
153
+ ```ts
154
+ import { CollectionConfig } from 'payload/types';
155
+
156
+
157
+ const Customers: CollectionConfig = {
153
158
  slug: 'customers',
154
159
  auth: {
155
160
  verify: {
@@ -163,7 +168,7 @@ Example:
163
168
  // highlight-end
164
169
  }
165
170
  }
166
- }
171
+ };
167
172
  ```
168
173
 
169
174
  <Banner type="warning">
@@ -182,7 +187,7 @@ Similarly to the above `generateEmailHTML`, you can also customize the subject o
182
187
 
183
188
  Example:
184
189
 
185
- ```js
190
+ ```ts
186
191
  {
187
192
  slug: 'customers',
188
193
  auth: {
@@ -17,7 +17,7 @@ The Access operation returns what a logged in user can and can't do with the col
17
17
  `GET http://localhost:3000/api/access`
18
18
 
19
19
  Example response:
20
- ```js
20
+ ```ts
21
21
  {
22
22
  canAccessAdmin: true,
23
23
  collections: {
@@ -54,7 +54,7 @@ Example response:
54
54
 
55
55
  **Example GraphQL Query**:
56
56
 
57
- ```
57
+ ```graphql
58
58
  query {
59
59
  Access {
60
60
  pages {
@@ -75,7 +75,7 @@ Returns either a logged in user with token or null when there is no logged in us
75
75
  `GET http://localhost:3000/api/[collection-slug]/me`
76
76
 
77
77
  Example response:
78
- ```js
78
+ ```ts
79
79
  {
80
80
  user: { // The JWT "payload" ;) from the logged in user
81
81
  email: 'dev@payloadcms.com',
@@ -90,7 +90,7 @@ Example response:
90
90
 
91
91
  **Example GraphQL Query**:
92
92
 
93
- ```
93
+ ```graphql
94
94
  query {
95
95
  Me[collection-singular-label] {
96
96
  user {
@@ -106,7 +106,7 @@ query {
106
106
  Accepts an `email` and `password`. On success, it will return the logged in user as well as a token that can be used to authenticate. In the GraphQL and REST APIs, this operation also automatically sets an HTTP-only cookie including the user's token. If you pass an Express `res` to the Local API operation, Payload will set a cookie there as well.
107
107
 
108
108
  **Example REST API login**:
109
- ```js
109
+ ```ts
110
110
  const res = await fetch('http://localhost:3000/api/[collection-slug]/login', {
111
111
  method: 'POST',
112
112
  headers: {
@@ -137,7 +137,7 @@ const json = await res.json();
137
137
 
138
138
  **Example GraphQL Mutation**:
139
139
 
140
- ```
140
+ ```graphql
141
141
  mutation {
142
142
  login[collection-singular-label](email: "dev@payloadcms.com", password: "yikes") {
143
143
  user {
@@ -151,7 +151,7 @@ mutation {
151
151
 
152
152
  **Example Local API login**:
153
153
 
154
- ```js
154
+ ```ts
155
155
  const result = await payload.login({
156
156
  collection: '[collection-slug]',
157
157
  data: {
@@ -166,7 +166,7 @@ const result = await payload.login({
166
166
  As Payload sets HTTP-only cookies, logging out cannot be done by just removing a cookie in JavaScript, as HTTP-only cookies are inaccessible by JS within the browser. So, Payload exposes a `logout` operation to delete the token in a safe way.
167
167
 
168
168
  **Example REST API logout**:
169
- ```js
169
+ ```ts
170
170
  const res = await fetch('http://localhost:3000/api/[collection-slug]/logout', {
171
171
  method: 'POST',
172
172
  headers: {
@@ -192,7 +192,7 @@ This operation requires a non-expired token to send back a new one. If the user'
192
192
  If successful, this operation will automatically renew the user's HTTP-only cookie and will send back the updated token in JSON.
193
193
 
194
194
  **Example REST API token refresh**:
195
- ```js
195
+ ```ts
196
196
  const res = await fetch('http://localhost:3000/api/[collection-slug]/refresh-token', {
197
197
  method: 'POST',
198
198
  headers: {
@@ -239,18 +239,18 @@ mutation {
239
239
  If your collection supports email verification, the Verify operation will be exposed which accepts a verification token and sets the user's `_verified` property to `true`, thereby allowing the user to authenticate with the Payload API.
240
240
 
241
241
  **Example REST API user verification**:
242
- ```js
242
+ ```ts
243
243
  const res = await fetch(`http://localhost:3000/api/[collection-slug]/verify/${TOKEN_HERE}`, {
244
244
  method: 'POST',
245
245
  headers: {
246
246
  'Content-Type': 'application/json',
247
247
  },
248
- })
248
+ });
249
249
  ```
250
250
 
251
251
  **Example GraphQL Mutation**:
252
252
 
253
- ```
253
+ ```graphql
254
254
  mutation {
255
255
  verifyEmail[collection-singular-label](token: "TOKEN_HERE")
256
256
  }
@@ -258,7 +258,7 @@ mutation {
258
258
 
259
259
  **Example Local API verification**:
260
260
 
261
- ```js
261
+ ```ts
262
262
  const result = await payload.verifyEmail({
263
263
  collection: '[collection-slug]',
264
264
  token: 'TOKEN_HERE',
@@ -272,7 +272,7 @@ If a user locks themselves out and you wish to deliberately unlock them, you can
272
272
  To restrict who is allowed to unlock users, you can utilize the [`unlock`](/docs/access-control/overview#unlock) access control function.
273
273
 
274
274
  **Example REST API unlock**:
275
- ```js
275
+ ```ts
276
276
  const res = await fetch(`http://localhost:3000/api/[collection-slug]/unlock`, {
277
277
  method: 'POST',
278
278
  headers: {
@@ -291,7 +291,7 @@ mutation {
291
291
 
292
292
  **Example Local API unlock**:
293
293
 
294
- ```js
294
+ ```ts
295
295
  const result = await payload.unlock({
296
296
  collection: '[collection-slug]',
297
297
  })
@@ -306,7 +306,7 @@ The link to reset the user's password contains a token which is what allows the
306
306
  By default, the Forgot Password operations send users to the Payload Admin panel to reset their password, but you can customize the generated email to send users to the frontend of your app instead by [overriding the email HTML](/docs/authentication/config#forgot-password).
307
307
 
308
308
  **Example REST API Forgot Password**:
309
- ```js
309
+ ```ts
310
310
  const res = await fetch(`http://localhost:3000/api/[collection-slug]/forgot-password`, {
311
311
  method: 'POST',
312
312
  headers: {
@@ -315,7 +315,7 @@ const res = await fetch(`http://localhost:3000/api/[collection-slug]/forgot-pass
315
315
  body: JSON.stringify({
316
316
  email: 'dev@payloadcms.com',
317
317
  }),
318
- })
318
+ });
319
319
  ```
320
320
 
321
321
  **Example GraphQL Mutation**:
@@ -328,14 +328,14 @@ mutation {
328
328
 
329
329
  **Example Local API forgot password**:
330
330
 
331
- ```js
331
+ ```ts
332
332
  const token = await payload.forgotPassword({
333
333
  collection: '[collection-slug]',
334
334
  data: {
335
335
  email: 'dev@payloadcms.com',
336
336
  },
337
337
  disableEmail: false // you can disable the auto-generation of email via local API
338
- })
338
+ });
339
339
  ```
340
340
 
341
341
  <Banner type="success">
@@ -348,7 +348,7 @@ const token = await payload.forgotPassword({
348
348
  After a user has "forgotten" their password and a token is generated, that token can be used to send to the reset password operation along with a new password which will allow the user to reset their password securely.
349
349
 
350
350
  **Example REST API Reset Password**:
351
- ```js
351
+ ```ts
352
352
  const res = await fetch(`http://localhost:3000/api/[collection-slug]/reset-password`, {
353
353
  method: 'POST',
354
354
  headers: {
@@ -358,7 +358,7 @@ const res = await fetch(`http://localhost:3000/api/[collection-slug]/reset-passw
358
358
  token: 'TOKEN_GOES_HERE'
359
359
  password: 'not-today',
360
360
  }),
361
- })
361
+ });
362
362
 
363
363
  const json = await res.json();
364
364
 
@@ -379,7 +379,7 @@ const json = await res.json();
379
379
 
380
380
  **Example GraphQL Mutation**:
381
381
 
382
- ```
382
+ ```graphql
383
383
  mutation {
384
384
  resetPassword[collection-singular-label](token: "TOKEN_GOES_HERE", password: "not-today")
385
385
  }
@@ -32,8 +32,10 @@ Every Payload Collection can opt-in to supporting Authentication by specifying t
32
32
 
33
33
  Simple example collection:
34
34
 
35
- ```js
36
- const Admins = {
35
+ ```ts
36
+ import { CollectionConfig } from 'payload/types';
37
+
38
+ const Admins: CollectionConfig = {
37
39
  slug:
38
40
  // highlight-start
39
41
  auth: {
@@ -95,7 +97,7 @@ However, if you use `fetch` or similar APIs to retrieve Payload resources from i
95
97
 
96
98
  Fetch example, including credentials:
97
99
 
98
- ```js
100
+ ```ts
99
101
  const response = await fetch('http://localhost:3000/api/pages', {
100
102
  credentials: 'include',
101
103
  });
@@ -124,8 +126,8 @@ So, if a user of coolsite.com is logged in and just browsing around on the inter
124
126
 
125
127
  To define domains that should allow users to identify themselves via the Payload HTTP-only cookie, use the `csrf` option on the base Payload config to whitelist domains that you trust.
126
128
 
127
- `payload.config.js`:
128
- ```js
129
+ `payload.config.ts`:
130
+ ```ts
129
131
  import { buildConfig } from 'payload/config';
130
132
 
131
133
  const config = buildConfig({
@@ -148,7 +150,7 @@ export default config;
148
150
  In addition to authenticating via an HTTP-only cookie, you can also identify users via the `Authorization` header on an HTTP request.
149
151
 
150
152
  Example:
151
- ```js
153
+ ```ts
152
154
  const request = await fetch('http://localhost:3000', {
153
155
  headers: {
154
156
  Authorization: `JWT ${token}`
@@ -15,7 +15,7 @@ This approach has a ton of benefits - it's great for isolation of concerns and l
15
15
  </Banner>
16
16
 
17
17
  Example in `server.js`:
18
- ```js
18
+ ```ts
19
19
  import express from 'express';
20
20
  import payload from 'payload';
21
21
 
@@ -31,8 +31,10 @@ It's often best practice to write your Collections in separate files and then im
31
31
 
32
32
  #### Simple collection example
33
33
 
34
- ```js
35
- const Orders = {
34
+ ```ts
35
+ import { CollectionConfig } from 'payload/types';
36
+
37
+ const Orders: CollectionConfig = {
36
38
  slug: 'orders',
37
39
  fields: [
38
40
  {
@@ -47,7 +49,7 @@ const Orders = {
47
49
  required: true,
48
50
  }
49
51
  ]
50
- }
52
+ };
51
53
  ```
52
54
 
53
55
  #### More collection config examples
@@ -80,8 +82,10 @@ If the function is specified, a Preview button will automatically appear in the
80
82
 
81
83
  **Example collection with preview function:**
82
84
 
83
- ```js
84
- const Posts = {
85
+ ```ts
86
+ import { CollectionConfig } from 'payload/types';
87
+
88
+ const Posts: CollectionConfig = {
85
89
  slug: 'posts',
86
90
  fields: [
87
91
  {
@@ -118,14 +122,14 @@ Collections support all field types that Payload has to offer—including simple
118
122
 
119
123
  You can import collection types as follows:
120
124
 
121
- ```js
125
+ ```ts
122
126
  import { CollectionConfig } from 'payload/types';
123
127
 
124
128
  // This is the type used for incoming collection configs.
125
129
  // Only the bare minimum properties are marked as required.
126
130
  ```
127
131
 
128
- ```js
132
+ ```ts
129
133
  import { SanitizedCollectionConfig } from 'payload/types';
130
134
 
131
135
  // This is the type used after an incoming collection config is fully sanitized.
@@ -28,8 +28,10 @@ As with Collection configs, it's often best practice to write your Globals in se
28
28
 
29
29
  #### Simple Global example
30
30
 
31
- ```js
32
- const Nav = {
31
+ ```ts
32
+ import { GlobalConfig } from 'payload/types';
33
+
34
+ const Nav: GlobalConfig = {
33
35
  slug: 'nav',
34
36
  fields: [
35
37
  {
@@ -47,7 +49,9 @@ const Nav = {
47
49
  ]
48
50
  },
49
51
  ]
50
- }
52
+ };
53
+
54
+ export default Nav;
51
55
  ```
52
56
 
53
57
  #### Global config example
@@ -78,14 +82,14 @@ Globals support all field types that Payload has to offer—including simple fie
78
82
 
79
83
  You can import global types as follows:
80
84
 
81
- ```js
85
+ ```ts
82
86
  import { GlobalConfig } from 'payload/types';
83
87
 
84
88
  // This is the type used for incoming global configs.
85
89
  // Only the bare minimum properties are marked as required.
86
90
  ```
87
91
 
88
- ```js
92
+ ```ts
89
93
  import { SanitizedGlobalConfig } from 'payload/types';
90
94
 
91
95
  // This is the type used after an incoming global config is fully sanitized.
@@ -14,21 +14,23 @@ Add the `localization` property to your Payload config to enable localization pr
14
14
 
15
15
  **Example Payload config set up for localization:**
16
16
 
17
- ```js
18
- {
19
- collections: [
20
- ... // collections go here
21
- ],
22
- localization: {
23
- locales: [
24
- 'en',
25
- 'es',
26
- 'de',
27
- ],
28
- defaultLocale: 'en',
29
- fallback: true,
30
- },
31
- }
17
+ ```ts
18
+ import { buildConfig } from 'payload/config'
19
+
20
+ export default buildConfig({
21
+ collections: [
22
+ // collections go here
23
+ ],
24
+ localization: {
25
+ locales: [
26
+ 'en',
27
+ 'es',
28
+ 'de',
29
+ ],
30
+ defaultLocale: 'en',
31
+ fallback: true,
32
+ },
33
+ });
32
34
  ```
33
35
 
34
36
  **Here is a brief explanation of each of the options available within the `localization` property:**
@@ -53,11 +55,11 @@ Payload localization works on a **field** level—not a document level. In addit
53
55
 
54
56
  ```js
55
57
  {
56
- name: 'title',
57
- type: 'text',
58
- // highlight-start
59
- localized: true,
60
- // highlight-end
58
+ name: 'title',
59
+ type: 'text',
60
+ // highlight-start
61
+ localized: true,
62
+ // highlight-end
61
63
  }
62
64
  ```
63
65
 
@@ -66,8 +68,8 @@ With the above configuration, the `title` field will now be saved in the databas
66
68
  All field types with a `name` property support the `localized` property—even the more complex field types like `array`s and `block`s.
67
69
 
68
70
  <Banner>
69
- <strong>Note:</strong><br/>
70
- Enabling localization for field types that support nested fields will automatically create localized "sets" of all fields contained within the field. For example, if you have a page layout using a blocks field type, you have the choice of either localizing the full layout, by enabling localization on the top-level blocks field, or only certain fields within the layout.
71
+ <strong>Note:</strong><br/>
72
+ Enabling localization for field types that support nested fields will automatically create localized "sets" of all fields contained within the field. For example, if you have a page layout using a blocks field type, you have the choice of either localizing the full layout, by enabling localization on the top-level blocks field, or only certain fields within the layout.
71
73
  </Banner>
72
74
 
73
75
  ### Retrieving localized docs
@@ -104,16 +106,16 @@ The `fallbackLocale` arg will accept valid locales as well as `none` to disable
104
106
 
105
107
  ```graphql
106
108
  query {
107
- Posts(locale: de, fallbackLocale: none) {
108
- docs {
109
- title
110
- }
111
- }
109
+ Posts(locale: de, fallbackLocale: none) {
110
+ docs {
111
+ title
112
+ }
113
+ }
112
114
  }
113
115
  ```
114
116
 
115
117
  <Banner>
116
- In GraphQL, specifying the locale at the top level of a query will automatically apply it throughout all nested relationship fields. You can override this behavior by re-specifying locale arguments in nested related document queries.
118
+ In GraphQL, specifying the locale at the top level of a query will automatically apply it throughout all nested relationship fields. You can override this behavior by re-specifying locale arguments in nested related document queries.
117
119
  </Banner>
118
120
 
119
121
  ##### Local API
@@ -124,9 +126,9 @@ You can specify `locale` as well as `fallbackLocale` within the Local API as wel
124
126
 
125
127
  ```js
126
128
  const posts = await payload.find({
127
- collection: 'posts',
128
- locale: 'es',
129
- fallbackLocale: false,
129
+ collection: 'posts',
130
+ locale: 'es',
131
+ fallbackLocale: false,
130
132
  })
131
133
  ```
132
134
 
@@ -43,10 +43,10 @@ Payload is a *config-based*, code-first CMS and application framework. The Paylo
43
43
 
44
44
  #### Simple example
45
45
 
46
- ```js
46
+ ```ts
47
47
  import { buildConfig } from 'payload/config';
48
48
 
49
- const config = buildConfig({
49
+ export default buildConfig({
50
50
  collections: [
51
51
  {
52
52
  slug: 'pages',
@@ -83,9 +83,6 @@ const config = buildConfig({
83
83
  }
84
84
  ]
85
85
  });
86
-
87
- export default config;
88
-
89
86
  ```
90
87
 
91
88
  #### Full example config
@@ -174,14 +171,14 @@ Then, you could import this file into both your Payload config and your server,
174
171
 
175
172
  You can import config types as follows:
176
173
 
177
- ```js
174
+ ```ts
178
175
  import { Config } from 'payload/config';
179
176
 
180
177
  // This is the type used for an incoming Payload config.
181
178
  // Only the bare minimum properties are marked as required.
182
179
  ```
183
180
 
184
- ```js
181
+ ```ts
185
182
  import { SanitizedConfig } from 'payload/config';
186
183
 
187
184
  // This is the type used after an incoming Payload config is fully sanitized.
@@ -40,7 +40,7 @@ The following options are configurable in the `email` property object as part of
40
40
  Simple Mail Transfer Protocol, also known as SMTP can be passed in using the `transportOptions` object on the `email` options.
41
41
 
42
42
  **Example email part using SMTP:**
43
- ```js
43
+ ```ts
44
44
  payload.init({
45
45
  email: {
46
46
  transportOptions: {
@@ -60,6 +60,7 @@ payload.init({
60
60
  fromAddress: 'hello@example.com'
61
61
  }
62
62
  // ...
63
+ })
63
64
  ```
64
65
 
65
66
  <Banner type="warning">
@@ -70,9 +71,9 @@ payload.init({
70
71
 
71
72
  Many third party mail providers are available and offer benefits beyond basic SMTP. As an example your payload init could look this if you wanted to use SendGrid.com though the same approach would work for any other [NodeMailer transports](https://nodemailer.com/transports/) shown here or provided by another third party.
72
73
 
73
- ```js
74
- const nodemailerSendgrid = require('nodemailer-sendgrid');
75
- const payload = require('payload');
74
+ ```ts
75
+ import payload from 'payload'
76
+ import nodemailerSendgrid from 'nodemailer-sendgrid'
76
77
 
77
78
  const sendGridAPIKey = process.env.SENDGRID_API_KEY;
78
79
 
@@ -92,7 +93,10 @@ payload.init({
92
93
  ### Use a custom NodeMailer transport
93
94
  To take full control of the mail transport you may wish to use `nodemailer.createTransport()` on your server and provide it to Payload init.
94
95
 
95
- ```js
96
+ ```ts
97
+ import payload from 'payload'
98
+ import nodemailer from 'nodemailer'
99
+
96
100
  const payload = require('payload');
97
101
  const nodemailer = require('nodemailer');
98
102
 
@@ -112,7 +116,7 @@ payload.init({
112
116
  transport
113
117
  },
114
118
  // ...
115
- }
119
+ });
116
120
  ```
117
121
 
118
122
  ### Sending Mail
@@ -123,7 +127,7 @@ By default, Payload uses a mock implementation that only sends mail to the [ethe
123
127
 
124
128
  To see ethereal credentials, add `logMockCredentials: true` to the email options. This will cause them to be logged to console on startup.
125
129
 
126
- ```js
130
+ ```ts
127
131
  payload.init({
128
132
  email: {
129
133
  fromName: 'Admin',
@@ -41,9 +41,11 @@ keywords: array, fields, config, configuration, documentation, Content Managemen
41
41
 
42
42
  ### Example
43
43
 
44
- `collections/ExampleCollection.js`
45
- ```js
46
- {
44
+ `collections/ExampleCollection.ts`
45
+ ```ts
46
+ import { CollectionConfig } from 'payload/types';
47
+
48
+ const ExampleCollection: CollectionConfig = {
47
49
  slug: 'example-collection',
48
50
  fields: [
49
51
  {
@@ -70,6 +72,5 @@ keywords: array, fields, config, configuration, documentation, Content Managemen
70
72
  ]
71
73
  }
72
74
  ]
73
- }
74
-
75
+ };
75
76
  ```