payload 1.6.32 → 1.7.1

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 (212) hide show
  1. package/dist/admin/Root.js +1 -0
  2. package/dist/admin/Root.js.map +1 -1
  3. package/dist/admin/components/Routes.js +8 -3
  4. package/dist/admin/components/Routes.js.map +1 -1
  5. package/dist/admin/components/elements/Nav/index.js +8 -4
  6. package/dist/admin/components/elements/Nav/index.js.map +1 -1
  7. package/dist/admin/components/elements/PreviewButton/index.js +30 -12
  8. package/dist/admin/components/elements/PreviewButton/index.js.map +1 -1
  9. package/dist/admin/components/elements/Status/index.js +5 -4
  10. package/dist/admin/components/elements/Status/index.js.map +1 -1
  11. package/dist/admin/components/forms/Form/index.js +7 -0
  12. package/dist/admin/components/forms/Form/index.js.map +1 -1
  13. package/dist/admin/components/forms/Form/initContextState.js +1 -0
  14. package/dist/admin/components/forms/Form/initContextState.js.map +1 -1
  15. package/dist/admin/components/forms/Form/types.d.ts +1 -0
  16. package/dist/admin/components/forms/field-types/Array/index.js +1 -2
  17. package/dist/admin/components/forms/field-types/Array/index.js.map +1 -1
  18. package/dist/admin/components/forms/field-types/Blocks/BlocksDrawer/index.js +11 -1
  19. package/dist/admin/components/forms/field-types/Blocks/BlocksDrawer/index.js.map +1 -1
  20. package/dist/admin/components/forms/field-types/Blocks/index.js +1 -2
  21. package/dist/admin/components/forms/field-types/Blocks/index.js.map +1 -1
  22. package/dist/admin/components/forms/field-types/Textarea/index.scss +6 -5
  23. package/dist/admin/components/utilities/DocumentInfo/index.d.ts +1 -1
  24. package/dist/admin/components/utilities/DocumentInfo/index.js +18 -12
  25. package/dist/admin/components/utilities/DocumentInfo/index.js.map +1 -1
  26. package/dist/admin/components/utilities/DocumentInfo/types.d.ts +0 -3
  27. package/dist/admin/components/views/Dashboard/Default.js +8 -4
  28. package/dist/admin/components/views/Dashboard/Default.js.map +1 -1
  29. package/dist/admin/components/views/Dashboard/index.js +2 -1
  30. package/dist/admin/components/views/Dashboard/index.js.map +1 -1
  31. package/dist/admin/components/views/Dashboard/types.d.ts +2 -1
  32. package/dist/admin/components/views/Global/index.scss +15 -5
  33. package/dist/admin/components/views/Version/Version.js +5 -2
  34. package/dist/admin/components/views/Version/Version.js.map +1 -1
  35. package/dist/admin/components/views/collections/Edit/Default.js +5 -2
  36. package/dist/admin/components/views/collections/Edit/Default.js.map +1 -1
  37. package/dist/admin/components/views/collections/Edit/Upload/index.js +7 -4
  38. package/dist/admin/components/views/collections/Edit/Upload/index.js.map +1 -1
  39. package/dist/admin/components/views/collections/Edit/index.scss +11 -3
  40. package/dist/admin/components/views/collections/List/RelationshipProvider/index.js +11 -4
  41. package/dist/admin/components/views/collections/List/RelationshipProvider/index.js.map +1 -1
  42. package/dist/auth/getExecuteStaticAccess.js +17 -15
  43. package/dist/auth/getExecuteStaticAccess.js.map +1 -1
  44. package/dist/auth/strategies/apiKey.js +0 -1
  45. package/dist/auth/strategies/apiKey.js.map +1 -1
  46. package/dist/collections/buildSchema.js +1 -1
  47. package/dist/collections/buildSchema.js.map +1 -1
  48. package/dist/collections/config/defaults.d.ts +1 -0
  49. package/dist/collections/config/defaults.js +1 -0
  50. package/dist/collections/config/defaults.js.map +1 -1
  51. package/dist/collections/config/sanitize.js +5 -4
  52. package/dist/collections/config/sanitize.js.map +1 -1
  53. package/dist/collections/config/schema.js +2 -0
  54. package/dist/collections/config/schema.js.map +1 -1
  55. package/dist/collections/config/types.d.ts +13 -3
  56. package/dist/collections/initLocal.js +3 -2
  57. package/dist/collections/initLocal.js.map +1 -1
  58. package/dist/collections/operations/delete.js +11 -9
  59. package/dist/collections/operations/delete.js.map +1 -1
  60. package/dist/collections/operations/deleteByID.js +13 -11
  61. package/dist/collections/operations/deleteByID.js.map +1 -1
  62. package/dist/collections/operations/find.d.ts +0 -1
  63. package/dist/collections/operations/find.js +14 -11
  64. package/dist/collections/operations/find.js.map +1 -1
  65. package/dist/collections/operations/findByID.js +15 -12
  66. package/dist/collections/operations/findByID.js.map +1 -1
  67. package/dist/collections/operations/findVersionByID.js +13 -11
  68. package/dist/collections/operations/findVersionByID.js.map +1 -1
  69. package/dist/collections/operations/findVersions.js +9 -5
  70. package/dist/collections/operations/findVersions.js.map +1 -1
  71. package/dist/collections/operations/local/find.d.ts +0 -1
  72. package/dist/collections/operations/local/find.js +1 -2
  73. package/dist/collections/operations/local/find.js.map +1 -1
  74. package/dist/collections/operations/restoreVersion.js +12 -10
  75. package/dist/collections/operations/restoreVersion.js.map +1 -1
  76. package/dist/collections/operations/update.js +13 -10
  77. package/dist/collections/operations/update.js.map +1 -1
  78. package/dist/collections/operations/updateByID.js +12 -10
  79. package/dist/collections/operations/updateByID.js.map +1 -1
  80. package/dist/config/defaults.js +1 -0
  81. package/dist/config/defaults.js.map +1 -1
  82. package/dist/config/schema.js +3 -0
  83. package/dist/config/schema.js.map +1 -1
  84. package/dist/config/types.d.ts +13 -2
  85. package/dist/email/build.d.ts +1 -1
  86. package/dist/email/build.js +6 -3
  87. package/dist/email/build.js.map +1 -1
  88. package/dist/email/defaults.d.ts +2 -0
  89. package/dist/email/defaults.js +8 -0
  90. package/dist/email/defaults.js.map +1 -0
  91. package/dist/email/mockHandler.js +3 -2
  92. package/dist/email/mockHandler.js.map +1 -1
  93. package/dist/email/sendEmail.js +1 -1
  94. package/dist/email/sendEmail.js.map +1 -1
  95. package/dist/errors/QueryError.d.ts +8 -0
  96. package/dist/errors/QueryError.js +15 -0
  97. package/dist/errors/QueryError.js.map +1 -0
  98. package/dist/fields/config/schema.js +1 -0
  99. package/dist/fields/config/schema.js.map +1 -1
  100. package/dist/fields/config/types.d.ts +4 -0
  101. package/dist/fields/config/types.js.map +1 -1
  102. package/dist/fields/validations.d.ts +1 -1
  103. package/dist/globals/buildModel.js +1 -1
  104. package/dist/globals/buildModel.js.map +1 -1
  105. package/dist/globals/config/sanitize.js +7 -5
  106. package/dist/globals/config/sanitize.js.map +1 -1
  107. package/dist/globals/config/schema.js +2 -0
  108. package/dist/globals/config/schema.js.map +1 -1
  109. package/dist/globals/config/types.d.ts +12 -2
  110. package/dist/globals/initLocal.js +3 -2
  111. package/dist/globals/initLocal.js.map +1 -1
  112. package/dist/globals/operations/findOne.js +15 -11
  113. package/dist/globals/operations/findOne.js.map +1 -1
  114. package/dist/globals/operations/findVersionByID.js +14 -11
  115. package/dist/globals/operations/findVersionByID.js.map +1 -1
  116. package/dist/globals/operations/findVersions.js +10 -5
  117. package/dist/globals/operations/findVersions.js.map +1 -1
  118. package/dist/globals/operations/update.js +14 -11
  119. package/dist/globals/operations/update.js.map +1 -1
  120. package/dist/graphql/errorHandler.d.ts +1 -8
  121. package/dist/graphql/errorHandler.js +2 -9
  122. package/dist/graphql/errorHandler.js.map +1 -1
  123. package/dist/graphql/graphQLHandler.d.ts +1 -6
  124. package/dist/graphql/graphQLHandler.js +24 -7
  125. package/dist/graphql/graphQLHandler.js.map +1 -1
  126. package/dist/graphql/registerSchema.js +2 -20
  127. package/dist/graphql/registerSchema.js.map +1 -1
  128. package/dist/initHTTP.js +1 -1
  129. package/dist/initHTTP.js.map +1 -1
  130. package/dist/mongoose/buildQuery.d.ts +76 -2
  131. package/dist/mongoose/buildQuery.js +274 -149
  132. package/dist/mongoose/buildQuery.js.map +1 -1
  133. package/dist/mongoose/sanitizeQueryValue.d.ts +12 -0
  134. package/dist/mongoose/{sanitizeFormattedValue.js → sanitizeQueryValue.js} +27 -26
  135. package/dist/mongoose/sanitizeQueryValue.js.map +1 -0
  136. package/dist/payload.d.ts +8 -6
  137. package/dist/payload.js +6 -2
  138. package/dist/payload.js.map +1 -1
  139. package/dist/translations/cs.json +1 -0
  140. package/dist/translations/de.json +1 -0
  141. package/dist/translations/en.json +1 -0
  142. package/dist/translations/es.json +1 -0
  143. package/dist/translations/fr.json +1 -0
  144. package/dist/translations/hr.json +1 -0
  145. package/dist/translations/hu.json +1 -0
  146. package/dist/translations/index.d.ts +21 -0
  147. package/dist/translations/it.json +1 -0
  148. package/dist/translations/ja.json +1 -0
  149. package/dist/translations/my.json +1 -0
  150. package/dist/translations/nb.json +1 -0
  151. package/dist/translations/nl.json +1 -0
  152. package/dist/translations/pl.json +1 -0
  153. package/dist/translations/pt.json +1 -0
  154. package/dist/translations/ru.json +1 -0
  155. package/dist/translations/sv.json +1 -0
  156. package/dist/translations/th.json +1 -0
  157. package/dist/translations/tr.json +1 -0
  158. package/dist/translations/ua.json +1 -0
  159. package/dist/translations/vi.json +1 -0
  160. package/dist/translations/zh.json +1 -0
  161. package/dist/uploads/generateFileData.js +4 -2
  162. package/dist/uploads/generateFileData.js.map +1 -1
  163. package/dist/utilities/flattenWhereConstraints.d.ts +2 -2
  164. package/dist/utilities/flattenWhereConstraints.js +12 -13
  165. package/dist/utilities/flattenWhereConstraints.js.map +1 -1
  166. package/dist/utilities/getEntityPolicies.d.ts +6 -10
  167. package/dist/utilities/getEntityPolicies.js +25 -15
  168. package/dist/utilities/getEntityPolicies.js.map +1 -1
  169. package/dist/versions/drafts/queryDrafts.d.ts +4 -3
  170. package/dist/versions/drafts/queryDrafts.js +11 -9
  171. package/dist/versions/drafts/queryDrafts.js.map +1 -1
  172. package/dist/versions/drafts/replaceWithDraftIfAvailable.d.ts +4 -2
  173. package/dist/versions/drafts/replaceWithDraftIfAvailable.js +16 -13
  174. package/dist/versions/drafts/replaceWithDraftIfAvailable.js.map +1 -1
  175. package/docs/access-control/collections.mdx +1 -1
  176. package/docs/admin/hooks.mdx +0 -1
  177. package/docs/configuration/collections.mdx +15 -13
  178. package/docs/configuration/express.mdx +34 -0
  179. package/docs/configuration/globals.mdx +6 -4
  180. package/docs/configuration/localization.mdx +9 -0
  181. package/docs/configuration/overview.mdx +1 -0
  182. package/docs/fields/array.mdx +2 -1
  183. package/docs/fields/blocks.mdx +1 -0
  184. package/docs/fields/checkbox.mdx +1 -0
  185. package/docs/fields/code.mdx +1 -0
  186. package/docs/fields/collapsible.mdx +1 -0
  187. package/docs/fields/date.mdx +33 -32
  188. package/docs/fields/email.mdx +1 -0
  189. package/docs/fields/group.mdx +1 -0
  190. package/docs/fields/json.mdx +1 -0
  191. package/docs/fields/number.mdx +1 -0
  192. package/docs/fields/point.mdx +1 -0
  193. package/docs/fields/radio.mdx +1 -0
  194. package/docs/fields/relationship.mdx +2 -1
  195. package/docs/fields/rich-text.mdx +1 -0
  196. package/docs/fields/row.mdx +1 -0
  197. package/docs/fields/select.mdx +1 -0
  198. package/docs/fields/tabs.mdx +1 -0
  199. package/docs/fields/text.mdx +1 -0
  200. package/docs/fields/textarea.mdx +2 -1
  201. package/docs/fields/ui.mdx +1 -0
  202. package/docs/fields/upload.mdx +1 -0
  203. package/docs/getting-started/installation.mdx +2 -0
  204. package/docs/hooks/collections.mdx +7 -1
  205. package/docs/queries/overview.mdx +1 -1
  206. package/docs/rest-api/overview.mdx +2 -1
  207. package/package.json +4 -5
  208. package/dist/mongoose/sanitizeFormattedValue.d.ts +0 -2
  209. package/dist/mongoose/sanitizeFormattedValue.js.map +0 -1
  210. package/dist/versions/defaults.d.ts +0 -3
  211. package/dist/versions/defaults.js +0 -18
  212. package/dist/versions/defaults.js.map +0 -1
@@ -1,18 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const flattenWhereConstraints = (query) => {
4
- if (!query.where && !query.and && !query.or) {
5
- return Object.keys(query).map((key) => query[key]);
3
+ // Take a where query and flatten it to all top-level operators
4
+ const flattenWhereConstraints = (query) => Object.entries(query).reduce((flattenedConstraints, [key, val]) => {
5
+ if ((key === 'and' || key === 'or') && Array.isArray(val)) {
6
+ return [
7
+ ...flattenedConstraints,
8
+ ...val.map((subVal) => flattenWhereConstraints(subVal)),
9
+ ];
6
10
  }
7
- if (query.where) {
8
- const whereResult = flattenWhereConstraints(query.where);
9
- return Object.keys(whereResult).map((key) => whereResult[key]);
10
- }
11
- const nested = [...query.or || [], ...query.and || []];
12
- if (nested.length > 0) {
13
- return nested.flatMap((nest) => flattenWhereConstraints(nest));
14
- }
15
- return query;
16
- };
11
+ return [
12
+ ...flattenedConstraints,
13
+ val,
14
+ ];
15
+ }, []);
17
16
  exports.default = flattenWhereConstraints;
18
17
  //# sourceMappingURL=flattenWhereConstraints.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"flattenWhereConstraints.js","sourceRoot":"","sources":["../../src/utilities/flattenWhereConstraints.ts"],"names":[],"mappings":";;AAEA,MAAM,uBAAuB,GAAG,CAAC,KAAK,EAAgB,EAAE;IACtD,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE;QAC3C,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;KACpD;IACD,IAAI,KAAK,CAAC,KAAK,EAAE;QACf,MAAM,WAAW,GAAG,uBAAuB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACzD,OAAO,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC;KAChE;IACD,MAAM,MAAM,GAAG,CAAC,GAAG,KAAK,CAAC,EAAE,IAAI,EAAE,EAAE,GAAG,KAAK,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC;IACvD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;QACrB,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,uBAAuB,CAAC,IAAI,CAAC,CAAC,CAAC;KAChE;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,kBAAe,uBAAuB,CAAC"}
1
+ {"version":3,"file":"flattenWhereConstraints.js","sourceRoot":"","sources":["../../src/utilities/flattenWhereConstraints.ts"],"names":[],"mappings":";;AAEA,+DAA+D;AAC/D,MAAM,uBAAuB,GAAG,CAAC,KAAY,EAAgB,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,oBAAoB,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE;IAChI,IAAI,CAAC,GAAG,KAAK,KAAK,IAAI,GAAG,KAAK,IAAI,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QACzD,OAAO;YACL,GAAG,oBAAoB;YACvB,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC;SACxD,CAAC;KACH;IAED,OAAO;QACL,GAAG,oBAAoB;QACvB,GAAG;KACJ,CAAC;AACJ,CAAC,EAAE,EAAE,CAAC,CAAC;AAEP,kBAAe,uBAAuB,CAAC"}
@@ -1,19 +1,15 @@
1
1
  import { AllOperations } from '../types';
2
- import type { CollectionConfig } from '../collections/config/types';
3
- import type { GlobalConfig } from '../globals/config/types';
2
+ import type { SanitizedCollectionConfig } from '../collections/config/types';
3
+ import type { SanitizedGlobalConfig } from '../globals/config/types';
4
4
  import type { PayloadRequest } from '../express/types';
5
5
  import type { CollectionPermission, GlobalPermission } from '../auth/types';
6
- type Args = ({
6
+ type Args = {
7
7
  req: PayloadRequest;
8
8
  operations: AllOperations[];
9
9
  id?: string;
10
- } & ({
11
- type: 'collection';
12
- entity: CollectionConfig;
13
- } | {
14
- type: 'global';
15
- entity: GlobalConfig;
16
- }));
10
+ type: 'collection' | 'global';
11
+ entity: SanitizedCollectionConfig | SanitizedGlobalConfig;
12
+ };
17
13
  type ReturnType<T extends Args> = T['type'] extends 'global' ? [GlobalPermission, Promise<void>[]] : [CollectionPermission, Promise<void>[]];
18
14
  export declare function getEntityPolicies<T extends Args>(args: T): ReturnType<T>;
19
15
  export {};
@@ -71,9 +71,10 @@ function getEntityPolicies(args) {
71
71
  };
72
72
  }
73
73
  };
74
- const executeFieldPolicies = ({ policiesObj = {}, fields, operation, }) => {
75
- const mutablePolicies = policiesObj;
76
- fields.forEach((field) => {
74
+ const executeFieldPolicies = async ({ policiesObj, fields, operation, entityAccessPromise, }) => {
75
+ const mutablePolicies = policiesObj.fields;
76
+ fields.forEach(async (field) => {
77
+ var _a;
77
78
  if (field.name) {
78
79
  if (!mutablePolicies[field.name])
79
80
  mutablePolicies[field.name] = {};
@@ -87,25 +88,29 @@ function getEntityPolicies(args) {
87
88
  }));
88
89
  }
89
90
  else {
91
+ if (entityAccessPromise)
92
+ await entityAccessPromise;
90
93
  mutablePolicies[field.name][operation] = {
91
- permission: isLoggedIn,
94
+ permission: (_a = policiesObj[operation]) === null || _a === void 0 ? void 0 : _a.permission,
92
95
  };
93
96
  }
94
97
  if (field.fields) {
95
98
  if (!mutablePolicies[field.name].fields)
96
99
  mutablePolicies[field.name].fields = {};
97
100
  executeFieldPolicies({
98
- policiesObj: mutablePolicies[field.name].fields,
101
+ policiesObj: mutablePolicies[field.name],
99
102
  fields: field.fields,
100
103
  operation,
104
+ entityAccessPromise,
101
105
  });
102
106
  }
103
107
  }
104
108
  else if (field.fields) {
105
109
  executeFieldPolicies({
106
- policiesObj: mutablePolicies,
110
+ policiesObj,
107
111
  fields: field.fields,
108
112
  operation,
113
+ entityAccessPromise,
109
114
  });
110
115
  }
111
116
  else if (field.type === 'tabs') {
@@ -114,16 +119,18 @@ function getEntityPolicies(args) {
114
119
  if (!mutablePolicies[tab.name])
115
120
  mutablePolicies[tab.name] = { fields: {} };
116
121
  executeFieldPolicies({
117
- policiesObj: mutablePolicies[tab.name].fields,
122
+ policiesObj: mutablePolicies[tab.name],
118
123
  fields: tab.fields,
119
124
  operation,
125
+ entityAccessPromise,
120
126
  });
121
127
  }
122
128
  else {
123
129
  executeFieldPolicies({
124
- policiesObj: mutablePolicies,
130
+ policiesObj,
125
131
  fields: tab.fields,
126
132
  operation,
133
+ entityAccessPromise,
127
134
  });
128
135
  }
129
136
  });
@@ -131,24 +138,27 @@ function getEntityPolicies(args) {
131
138
  });
132
139
  };
133
140
  operations.forEach((operation) => {
134
- executeFieldPolicies({
135
- policiesObj: policies.fields,
136
- fields: entity.fields,
137
- operation,
138
- });
141
+ let entityAccessPromise;
139
142
  if (typeof entity.access[operation] === 'function') {
140
- promises.push(createAccessPromise({
143
+ entityAccessPromise = createAccessPromise({
141
144
  policiesObj: policies,
142
145
  access: entity.access[operation],
143
146
  operation,
144
147
  accessLevel: 'entity',
145
- }));
148
+ });
149
+ promises.push(entityAccessPromise);
146
150
  }
147
151
  else {
148
152
  policies[operation] = {
149
153
  permission: isLoggedIn,
150
154
  };
151
155
  }
156
+ executeFieldPolicies({
157
+ policiesObj: policies,
158
+ fields: entity.fields,
159
+ operation,
160
+ entityAccessPromise,
161
+ });
152
162
  });
153
163
  return [policies, promises];
154
164
  }
@@ -1 +1 @@
1
- {"version":3,"file":"getEntityPolicies.js","sourceRoot":"","sources":["../../src/utilities/getEntityPolicies.ts"],"names":[],"mappings":";;;AAEA,kDAAiE;AA8BjE,SAAgB,iBAAiB,CAAiB,IAAO;IACvD,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;IACnD,MAAM,UAAU,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAChC,+CAA+C;IAC/C,2CAA2C;IAC3C,6CAA6C;IAC7C,+CAA+C;IAC/C,MAAM,QAAQ,GAAG;QACf,MAAM,EAAE,EAAE;KACS,CAAC;IACtB,MAAM,QAAQ,GAAG,EAAsB,CAAC;IACxC,IAAI,gBAAgB,CAAC;IAErB,KAAK,UAAU,YAAY,CAAC,EAAE,KAAK,KAAwB,EAAE;;QAC3D,IAAI,MAAM,CAAC,IAAI,EAAE;YACf,IAAI,IAAI,KAAK,QAAQ,EAAE;gBACrB,OAAO,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC;oBAC5B,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AE,GAAG,CAAC,MAAM;4BAClB,SAAS;4BACT,mBAAmB;yBACpB,CAAC,CAAC;qBACJ;yBAAM;wBACL,oBAAoB,CAAC;4BACnB,WAAW;4BACX,MAAM,EAAE,GAAG,CAAC,MAAM;4BAClB,SAAS;4BACT,mBAAmB;yBACpB,CAAC,CAAC;qBACJ;gBACH,CAAC,CAAC,CAAC;aACJ;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,UAAU,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;QAC/B,IAAI,mBAAkC,CAAC;QAEvC,IAAI,OAAO,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,UAAU,EAAE;YAClD,mBAAmB,GAAG,mBAAmB,CAAC;gBACxC,WAAW,EAAE,QAAQ;gBACrB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC;gBAChC,SAAS;gBACT,WAAW,EAAE,QAAQ;aACtB,CAAC,CAAC;YACH,QAAQ,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;SACpC;aAAM;YACL,QAAQ,CAAC,SAAS,CAAC,GAAG;gBACpB,UAAU,EAAE,UAAU;aACvB,CAAC;SACH;QAED,oBAAoB,CAAC;YACnB,WAAW,EAAE,QAAQ;YACrB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,SAAS;YACT,mBAAmB;SACpB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAkB,CAAC;AAC/C,CAAC;AA7KD,8CA6KC"}
@@ -1,16 +1,17 @@
1
1
  import { PaginateOptions } from 'mongoose';
2
2
  import { AccessResult } from '../../config/types';
3
- import { Where } from '../../types';
3
+ import { PayloadRequest, Where } from '../../types';
4
4
  import { Payload } from '../../payload';
5
5
  import { PaginatedDocs } from '../../mongoose/types';
6
6
  import { Collection, TypeWithID } from '../../collections/config/types';
7
7
  type Args = {
8
8
  accessResult: AccessResult;
9
9
  collection: Collection;
10
- locale: string;
10
+ req: PayloadRequest;
11
+ overrideAccess: boolean;
11
12
  paginationOptions?: PaginateOptions;
12
13
  payload: Payload;
13
14
  where: Where;
14
15
  };
15
- export declare const queryDrafts: <T extends TypeWithID>({ accessResult, collection, locale, payload, paginationOptions, where: incomingWhere, }: Args) => Promise<PaginatedDocs<T>>;
16
+ export declare const queryDrafts: <T extends TypeWithID>({ accessResult, collection, req, overrideAccess, payload, paginationOptions, where: incomingWhere, }: Args) => Promise<PaginatedDocs<T>>;
16
17
  export {};
@@ -3,23 +3,25 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.queryDrafts = void 0;
4
4
  const auth_1 = require("../../auth");
5
5
  const appendVersionToQueryKey_1 = require("./appendVersionToQueryKey");
6
- const queryDrafts = async ({ accessResult, collection, locale, payload, paginationOptions, where: incomingWhere, }) => {
6
+ const queryDrafts = async ({ accessResult, collection, req, overrideAccess, payload, paginationOptions, where: incomingWhere, }) => {
7
7
  var _a;
8
8
  const VersionModel = payload.versions[collection.config.slug];
9
9
  const where = (0, appendVersionToQueryKey_1.appendVersionToQueryKey)(incomingWhere || {});
10
10
  const versionQueryToBuild = {
11
- where: {
12
- ...where,
13
- and: [
14
- ...(where === null || where === void 0 ? void 0 : where.and) || [],
15
- ],
16
- },
11
+ ...where,
12
+ and: [
13
+ ...(where === null || where === void 0 ? void 0 : where.and) || [],
14
+ ],
17
15
  };
18
16
  if ((0, auth_1.hasWhereAccessResult)(accessResult)) {
19
17
  const versionAccessResult = (0, appendVersionToQueryKey_1.appendVersionToQueryKey)(accessResult);
20
- versionQueryToBuild.where.and.push(versionAccessResult);
18
+ versionQueryToBuild.and.push(versionAccessResult);
21
19
  }
22
- const versionQuery = await VersionModel.buildQuery(versionQueryToBuild, locale);
20
+ const versionQuery = await VersionModel.buildQuery({
21
+ where: versionQueryToBuild,
22
+ req,
23
+ overrideAccess,
24
+ });
23
25
  const aggregate = VersionModel.aggregate([
24
26
  // Sort so that newest are first
25
27
  { $sort: { updatedAt: -1 } },
@@ -1 +1 @@
1
- {"version":3,"file":"queryDrafts.js","sourceRoot":"","sources":["../../../src/versions/drafts/queryDrafts.ts"],"names":[],"mappings":";;;AAMA,qCAAkD;AAClD,uEAAoE;AAkB7D,MAAM,WAAW,GAAG,KAAK,EAAwB,EACtD,YAAY,EACZ,UAAU,EACV,MAAM,EACN,OAAO,EACP,iBAAiB,EACjB,KAAK,EAAE,aAAa,GACf,EAA6B,EAAE;;IACpC,MAAM,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAoB,CAAC;IAEjF,MAAM,KAAK,GAAG,IAAA,iDAAuB,EAAC,aAAa,IAAI,EAAE,CAAC,CAAC;IAE3D,MAAM,mBAAmB,GAAqB;QAC5C,KAAK,EAAE;YACL,GAAG,KAAK;YACR,GAAG,EAAE;gBACH,GAAG,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,GAAG,KAAI,EAAE;aACpB;SACF;KACF,CAAC;IAEF,IAAI,IAAA,2BAAoB,EAAC,YAAY,CAAC,EAAE;QACtC,MAAM,mBAAmB,GAAG,IAAA,iDAAuB,EAAC,YAAY,CAAC,CAAC;QAClE,mBAAmB,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;KACzD;IAED,MAAM,YAAY,GAAG,MAAM,YAAY,CAAC,UAAU,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAC;IAEhF,MAAM,SAAS,GAAG,YAAY,CAAC,SAAS,CAAsB;QAC5D,gCAAgC;QAChC,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE;QAC5B,iDAAiD;QACjD;YACE,MAAM,EAAE;gBACN,GAAG,EAAE,SAAS;gBACd,OAAO,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE;gBAC/B,SAAS,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE;gBACnC,SAAS,E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AC,SAAS;YACxB,SAAS,EAAE,GAAG,CAAC,SAAS;SACzB,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC,CAAC;AApFW,QAAA,WAAW,eAoFtB"}
@@ -1,4 +1,5 @@
1
1
  import { Payload } from '../../payload';
2
+ import { PayloadRequest } from '../../types';
2
3
  import { AccessResult } from '../../config/types';
3
4
  import { SanitizedCollectionConfig, TypeWithID } from '../../collections/config/types';
4
5
  import { SanitizedGlobalConfig } from '../../globals/config/types';
@@ -7,8 +8,9 @@ type Arguments<T> = {
7
8
  entity: SanitizedCollectionConfig | SanitizedGlobalConfig;
8
9
  entityType: 'collection' | 'global';
9
10
  doc: T;
10
- locale: string;
11
+ req: PayloadRequest;
12
+ overrideAccess: boolean;
11
13
  accessResult: AccessResult;
12
14
  };
13
- declare const replaceWithDraftIfAvailable: <T extends TypeWithID>({ payload, entity, entityType, doc, locale, accessResult, }: Arguments<T>) => Promise<T>;
15
+ declare const replaceWithDraftIfAvailable: <T extends TypeWithID>({ payload, entity, entityType, doc, req, overrideAccess, accessResult, }: Arguments<T>) => Promise<T>;
14
16
  export default replaceWithDraftIfAvailable;
@@ -7,28 +7,26 @@ const types_1 = require("../../types");
7
7
  const auth_1 = require("../../auth");
8
8
  const sanitizeInternalFields_1 = __importDefault(require("../../utilities/sanitizeInternalFields"));
9
9
  const appendVersionToQueryKey_1 = require("./appendVersionToQueryKey");
10
- const replaceWithDraftIfAvailable = async ({ payload, entity, entityType, doc, locale, accessResult, }) => {
10
+ const replaceWithDraftIfAvailable = async ({ payload, entity, entityType, doc, req, overrideAccess, accessResult, }) => {
11
11
  const VersionModel = payload.versions[entity.slug];
12
12
  const queryToBuild = {
13
- where: {
14
- and: [
15
- {
16
- 'version._status': {
17
- equals: 'draft',
18
- },
13
+ and: [
14
+ {
15
+ 'version._status': {
16
+ equals: 'draft',
19
17
  },
20
- ],
21
- },
18
+ },
19
+ ],
22
20
  };
23
21
  if (entityType === 'collection') {
24
- queryToBuild.where.and.push({
22
+ queryToBuild.and.push({
25
23
  parent: {
26
24
  equals: doc.id,
27
25
  },
28
26
  });
29
27
  }
30
28
  if ((0, types_1.docHasTimestamps)(doc)) {
31
- queryToBuild.where.and.push({
29
+ queryToBuild.and.push({
32
30
  updatedAt: {
33
31
  greater_than: doc.updatedAt,
34
32
  },
@@ -36,9 +34,14 @@ const replaceWithDraftIfAvailable = async ({ payload, entity, entityType, doc, l
36
34
  }
37
35
  if ((0, auth_1.hasWhereAccessResult)(accessResult)) {
38
36
  const versionAccessResult = (0, appendVersionToQueryKey_1.appendVersionToQueryKey)(accessResult);
39
- queryToBuild.where.and.push(versionAccessResult);
37
+ queryToBuild.and.push(versionAccessResult);
40
38
  }
41
- const query = await VersionModel.buildQuery(queryToBuild, locale);
39
+ const query = await VersionModel.buildQuery({
40
+ where: queryToBuild,
41
+ req,
42
+ overrideAccess,
43
+ globalSlug: entityType === 'global' ? entity.slug : undefined,
44
+ });
42
45
  let draft = await VersionModel.findOne(query, {}, {
43
46
  lean: true,
44
47
  sort: { updatedAt: 'desc' },
@@ -1 +1 @@
1
- {"version":3,"file":"replaceWithDraftIfAvailable.js","sourceRoot":"","sources":["../../../src/versions/drafts/replaceWithDraftIfAvailable.ts"],"names":[],"mappings":";;;;;AACA,uCAAsD;AACtD,qCAAkD;AAGlD,oGAA4E;AAC5E,uEAAoE;AAYpE,MAAM,2BAA2B,GAAG,KAAK,EAAwB,EAC/D,OAAO,EACP,MAAM,EACN,UAAU,EACV,GAAG,EACH,MAAM,EACN,YAAY,GACC,EAAc,EAAE;IAC7B,MAAM,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAoB,CAAC;IAEtE,MAAM,YAAY,GAAqB;QACrC,KAAK,EAAE;YACL,GAAG,EAAE;gBACH;oBACE,iBAAiB,EAAE;wBACjB,MAAM,EAAE,OAAO;qBAChB;iBACF;aACF;SACF;KACF,CAAC;IAEF,IAAI,UAAU,KAAK,YAAY,EAAE;QAC/B,Y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{"version":3,"file":"replaceWithDraftIfAvailable.js","sourceRoot":"","sources":["../../../src/versions/drafts/replaceWithDraftIfAvailable.ts"],"names":[],"mappings":";;;;;AACA,uCAAsE;AACtE,qCAAkD;AAGlD,oGAA4E;AAC5E,uEAAoE;AAapE,MAAM,2BAA2B,GAAG,KAAK,EAAwB,EAC/D,OAAO,EACP,MAAM,EACN,UAAU,EACV,GAAG,EACH,GAAG,EACH,cAAc,EACd,YAAY,GACC,EAAc,EAAE;IAC7B,MAAM,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAoB,CAAC;IAEtE,MAAM,YAAY,GAAU;QAC1B,GAAG,EAAE;YACH;gBACE,iBAAiB,EAAE;oBACjB,MAAM,EAAE,OAAO;iBAChB;aACF;SACF;KACF,CAAC;IAEF,IAAI,UAAU,KAAK,YAAY,EAAE;QAC/B,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC;YACpB,MAAM,EAAE;gBACN,MAAM,EAAE,GAAG,CAAC,EAAE;aACf;SACF,CAAC,CAAC;KACJ;IAED,IAAI,IAAA,wBAAgB,EAAC,GAAG,CAAC,EAAE;QACzB,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC;YACpB,SAAS,EAAE;gBACT,YAAY,EAAE,GAAG,CAAC,SAAS;aAC5B;SACF,CAAC,CAAC;KACJ;IAED,IAAI,IAAA,2BAAoB,EAAC,YAAY,CAAC,EAAE;QACtC,MAAM,mBAAmB,GAAG,IAAA,iDAAuB,EAAC,YAAY,CAAC,CAAC;QAClE,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;KAC5C;IAED,MAAM,KAAK,GAAG,MAAM,YAAY,CAAC,UAAU,CAAC;QAC1C,KAAK,EAAE,YAAY;QACnB,GAAG;QACH,cAAc;QACd,UAAU,EAAE,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;KAC9D,CAAC,CAAC;IAEH,IAAI,KAAK,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,EAAE;QAChD,IAAI,EAAE,IAAI;QACV,IAAI,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE;KAC5B,CAAC,CAAC;IAEH,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,GAAG,CAAC;KACZ;IAED,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;IAC1C,KAAK,GAAG,IAAA,gCAAsB,EAAC,KAAK,CAAC,CAAC;IAEtC,mDAAmD;IACnD,yCAAyC;IACzC,4CAA4C;IAC5C,OAAO;QACL,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,GAAG,KAAK,CAAC,OAAO;QAChB,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,SAAS,EAAE,KAAK,CAAC,SAAS;KAC3B,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,2BAA2B,CAAC"}
@@ -43,7 +43,7 @@ const Posts: CollectionConfig = {
43
43
  // highlight-end
44
44
  };
45
45
 
46
- export default Categories;
46
+ export default Posts;
47
47
  ```
48
48
 
49
49
  ### Create
@@ -166,7 +166,6 @@ The `useDocumentInfo` hook provides lots of information about the document curre
166
166
  |---------------------------|--------------------------------------------------------------------------------------------------------------------| |
167
167
  | **`collection`** | If the doc is a collection, its collection config will be returned |
168
168
  | **`global`** | If the doc is a global, its global config will be returned |
169
- | **`type`** | The type of document being edited (collection or global) |
170
169
  | **`id`** | If the doc is a collection, its ID will be returned |
171
170
  | **`preferencesKey`** | The `preferences` key to use when interacting with document-level user preferences |
172
171
  | **`versions`** | Versions of the current doc |
@@ -27,8 +27,9 @@ It's often best practice to write your Collections in separate files and then im
27
27
  | **`endpoints`** | Add custom routes to the REST API. [More](/docs/rest-api/overview#custom-endpoints) |
28
28
  | **`graphQL`** | An object with `singularName` and `pluralName` strings used in schema generation. Auto-generated from slug if not defined. |
29
29
  | **`typescript`** | An object with property `interface` as the text used in schema generation. Auto-generated from slug if not defined. |
30
- | **`defaultSort`** | Pass a top-level field to sort by default in the collection List view. Prefix the name of the field with a minus symbol ("-") to sort in descending order. |
31
- | **`pagination`** | Set pagination-specific options for this collection. [More](#pagination) |
30
+ | **`defaultSort`** | Pass a top-level field to sort by default in the collection List view. Prefix the name of the field with a minus symbol ("-") to sort in descending order. |
31
+ | **`pagination`** | Set pagination-specific options for this collection. [More](#pagination) |
32
+ | **`custom`** | Extension point for adding custom data (e.g. for plugins) |
32
33
 
33
34
  *\* An asterisk denotes that a property is required.*
34
35
 
@@ -63,18 +64,19 @@ You can find an assortment of [example collection configs](https://github.com/pa
63
64
 
64
65
  You can customize the way that the Admin panel behaves on a collection-by-collection basis by defining the `admin` property on a collection's config.
65
66
 
66
- | Option | Description |
67
- | --------------------------- | -------------|
68
- | `group` | Text used as a label for grouping collection links together in the navigation. |
69
- | `hooks` | Admin-specific hooks for this collection. [More](#admin-hooks) |
70
- | `useAsTitle` | Specify a top-level field to use for a document title throughout the Admin panel. If no field is defined, the ID of the document is used as the title. |
71
- | `description` | Text or React component to display below the Collection label in the List view to give editors more information. |
72
- | `defaultColumns` | Array of field names that correspond to which columns to show by default in this collection's List view. |
73
- | `disableDuplicate ` | Disables the "Duplicate" button while editing documents within this collection. |
67
+ | Option | Description |
68
+ |------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
69
+ | `group` | Text used as a label for grouping collection links together in the navigation. |
70
+ | `hidden` | Set to true or a function, called with the current user, returning true to exclude this collection from navigation and admin routing. |
71
+ | `hooks` | Admin-specific hooks for this collection. [More](#admin-hooks) |
72
+ | `useAsTitle` | Specify a top-level field to use for a document title throughout the Admin panel. If no field is defined, the ID of the document is used as the title. |
73
+ | `description` | Text or React component to display below the Collection label in the List view to give editors more information. |
74
+ | `defaultColumns` | Array of field names that correspond to which columns to show by default in this collection's List view. |
75
+ | `disableDuplicate ` | Disables the "Duplicate" button while editing documents within this collection. |
74
76
  | `enableRichTextRelationship` | The [Rich Text](/docs/fields/rich-text) field features a `Relationship` element which allows for users to automatically reference related documents within their rich text. Set to `true` by default. |
75
- | `preview` | Function to generate preview URLS within the Admin panel that can point to your app. [More](#preview). |
76
- | `components` | Swap in your own React components to be used within this collection. [More](/docs/admin/components#collections) |
77
- | `listSearchableFields` | Specify which fields should be searched in the List search view. [More](#list-searchable-fields) |
77
+ | `preview` | Function to generate preview URLS within the Admin panel that can point to your app. [More](#preview). |
78
+ | `components` | Swap in your own React components to be used within this collection. [More](/docs/admin/components#collections) |
79
+ | `listSearchableFields` | Specify which fields should be searched in the List search view. [More](#list-searchable-fields) |
78
80
 
79
81
  ### Preview
80
82
 
@@ -8,6 +8,40 @@ keywords: config, configuration, documentation, Content Management System, cms,
8
8
 
9
9
  Payload utilizes a few Express-specific middleware packages within its own routers. You can customize how they work by passing in configuration options to the main Payload config's `express` property.
10
10
 
11
+ ### Custom Middleware
12
+
13
+ Payload allows you to pass in custom Express middleware to be used on all of the routes it opens. This is useful for adding logging or any other custom functionality to your endpoints.
14
+
15
+ There are 2 exposed properties. Each property is an array of middleware functions.
16
+
17
+ - `preMiddleware` - runs before any of the Payload middleware
18
+ - `postMiddleware` - runs after all of the Payload middleware
19
+
20
+ ```ts
21
+ {
22
+ express: {
23
+ preMiddleware: [
24
+ (req, res, next) => {
25
+ // do something
26
+ next()
27
+ }
28
+ ],
29
+ postMiddleware: [
30
+ (req, res, next) => {
31
+ // do something
32
+ next()
33
+ }
34
+ ]
35
+ }
36
+ }
37
+
38
+ // Example logging middleware function
39
+ const requestLoggerMiddleware = (req, res, next) => {
40
+ req.payload.logger.info(`request: ${req.method} ${req.url}`)
41
+ next()
42
+ }
43
+ ```
44
+
11
45
  ### JSON
12
46
 
13
47
  `express.json()` is used to parse JSON body content into JavaScript objects accessible on the Express `req`. Payload allows you to customize all of the `json` method's options. Common examples of customization use-cases are increasing the max allowed JSON body size which defaults to `2MB`.
@@ -25,6 +25,7 @@ As with Collection configs, it's often best practice to write your Globals in se
25
25
  | **`endpoints`** | Add custom routes to the REST API. [More](/docs/rest-api/overview#custom-endpoints) |
26
26
  | **`graphQL.name`** | Text used in schema generation. Auto-generated from slug if not defined. |
27
27
  | **`typescript`** | An object with property `interface` as the text used in schema generation. Auto-generated from slug if not defined. |
28
+ | **`custom`** | Extension point for adding custom data (e.g. for plugins) |
28
29
 
29
30
  _\* An asterisk denotes that a property is required._
30
31
 
@@ -64,10 +65,11 @@ You can find an [example Global config](https://github.com/payloadcms/public-dem
64
65
 
65
66
  You can customize the way that the Admin panel behaves on a Global-by-Global basis by defining the `admin` property on a Global's config.
66
67
 
67
- | Option | Description |
68
- | ------------ | ----------------------------------------------------------------------------------------------------------------------- |
69
- | `components` | Swap in your own React components to be used within this Global. [More](/docs/admin/components#globals) |
70
- | `preview` | Function to generate a preview URL within the Admin panel for this global that can point to your app. [More](#preview). |
68
+ | Option | Description |
69
+ |--------------|-----------------------------------------------------------------------------------------------------------------------------------|
70
+ | `hidden` | Set to true or a function, called with the current user, returning true to exclude this global from navigation and admin routing. |
71
+ | `components` | Swap in your own React components to be used within this Global. [More](/docs/admin/components#globals) |
72
+ | `preview` | Function to generate a preview URL within the Admin panel for this global that can point to your app. [More](#preview). |
71
73
 
72
74
  ### Preview
73
75
 
@@ -72,6 +72,15 @@ All field types with a `name` property support the `localized` property—even t
72
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.
73
73
  </Banner>
74
74
 
75
+ <Banner type="warning">
76
+ <strong>Important:</strong>
77
+ <br />
78
+ When converting an existing field to or from `localized: true` the data
79
+ structure in the document will change for this field and so existing data for
80
+ this field will be lost. Before changing the localization setting on fields
81
+ with existing data, you may need to consider a field migration strategy.
82
+ </Banner>
83
+
75
84
  ### Retrieving localized docs
76
85
 
77
86
  When retrieving documents, you can specify which locale you'd like to receive as well as which fallback locale should be used.
@@ -43,6 +43,7 @@ Payload is a _config-based_, code-first CMS and application framework. The Paylo
43
43
  | `hooks` | Tap into Payload-wide hooks. [More](/docs/hooks/overview) |
44
44
  | `plugins` | An array of Payload plugins. [More](/docs/plugins/overview) |
45
45
  | `endpoints` | An array of custom API endpoints added to the Payload router. [More](/docs/rest-api/overview#custom-endpoints) |
46
+ | `custom` | Extension point for adding custom data (e.g. for plugins) |
46
47
 
47
48
  #### Simple example
48
49
 
@@ -35,7 +35,8 @@ keywords: array, fields, config, configuration, documentation, Content Managemen
35
35
  | **`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`. |
36
36
  | **`required`** | Require this field to have a value. |
37
37
  | **`labels`** | Customize the row labels appearing in the Admin dashboard. |
38
- | **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
38
+ | **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
39
+ | **`custom`** | Extension point for adding custom data (e.g. for plugins) |
39
40
 
40
41
  *\* An asterisk denotes that a property is required.*
41
42
 
@@ -37,6 +37,7 @@ keywords: blocks, fields, config, configuration, documentation, Content Manageme
37
37
  | **`unique`** | Enforce that each entry in the Collection has a unique value for this field. |
38
38
  | **`labels`** | Customize the block row labels appearing in the Admin dashboard. |
39
39
  | **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
40
+ | **`custom`** | Extension point for adding custom data (e.g. for plugins) |
40
41
 
41
42
  *\* An asterisk denotes that a property is required.*
42
43
 
@@ -26,6 +26,7 @@ keywords: checkbox, fields, config, configuration, documentation, Content Manage
26
26
  | **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
27
27
  | **`required`** | Require this field to have a value. |
28
28
  | **`admin`** | Admin-specific configuration. See the [default field admin config](/docs/fields/overview#admin-config) for more details. |
29
+ | **`custom`** | Extension point for adding custom data (e.g. for plugins) |
29
30
 
30
31
  *\* An asterisk denotes that a property is required.*
31
32
 
@@ -32,6 +32,7 @@ This field uses the `monaco-react` editor syntax highlighting.
32
32
  | **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
33
33
  | **`required`** | Require this field to have a value. |
34
34
  | **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
35
+ | **`custom`** | Extension point for adding custom data (e.g. for plugins) |
35
36
 
36
37
  _\* An asterisk denotes that a property is required._
37
38
 
@@ -17,6 +17,7 @@ keywords: row, fields, config, configuration, documentation, Content Management
17
17
  | **`label`** * | A label to render within the header of the collapsible component. This can be a string, function or react component. Function/components receive `({ data, path })` as args. |
18
18
  | **`fields`** * | Array of field types to nest within this Collapsible. |
19
19
  | **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
20
+ | **`custom`** | Extension point for adding custom data (e.g. for plugins) |
20
21
 
21
22
  *\* An asterisk denotes that a property is required.*
22
23