payload 1.6.32 → 1.7.0

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 (181) hide show
  1. package/dist/admin/components/Routes.js +8 -3
  2. package/dist/admin/components/Routes.js.map +1 -1
  3. package/dist/admin/components/elements/Nav/index.js +8 -4
  4. package/dist/admin/components/elements/Nav/index.js.map +1 -1
  5. package/dist/admin/components/elements/PreviewButton/index.js +30 -12
  6. package/dist/admin/components/elements/PreviewButton/index.js.map +1 -1
  7. package/dist/admin/components/elements/Status/index.js +5 -4
  8. package/dist/admin/components/elements/Status/index.js.map +1 -1
  9. package/dist/admin/components/forms/Form/index.js +7 -0
  10. package/dist/admin/components/forms/Form/index.js.map +1 -1
  11. package/dist/admin/components/forms/Form/initContextState.js +1 -0
  12. package/dist/admin/components/forms/Form/initContextState.js.map +1 -1
  13. package/dist/admin/components/forms/Form/types.d.ts +1 -0
  14. package/dist/admin/components/forms/field-types/Array/index.js +1 -2
  15. package/dist/admin/components/forms/field-types/Array/index.js.map +1 -1
  16. package/dist/admin/components/forms/field-types/Blocks/BlocksDrawer/index.js +11 -1
  17. package/dist/admin/components/forms/field-types/Blocks/BlocksDrawer/index.js.map +1 -1
  18. package/dist/admin/components/forms/field-types/Blocks/index.js +1 -2
  19. package/dist/admin/components/forms/field-types/Blocks/index.js.map +1 -1
  20. package/dist/admin/components/forms/field-types/Textarea/index.scss +6 -5
  21. package/dist/admin/components/utilities/DocumentInfo/index.d.ts +1 -1
  22. package/dist/admin/components/utilities/DocumentInfo/index.js +18 -12
  23. package/dist/admin/components/utilities/DocumentInfo/index.js.map +1 -1
  24. package/dist/admin/components/utilities/DocumentInfo/types.d.ts +0 -3
  25. package/dist/admin/components/views/Dashboard/Default.js +8 -4
  26. package/dist/admin/components/views/Dashboard/Default.js.map +1 -1
  27. package/dist/admin/components/views/Dashboard/index.js +2 -1
  28. package/dist/admin/components/views/Dashboard/index.js.map +1 -1
  29. package/dist/admin/components/views/Dashboard/types.d.ts +2 -1
  30. package/dist/admin/components/views/Global/index.scss +15 -5
  31. package/dist/admin/components/views/Version/Version.js +5 -2
  32. package/dist/admin/components/views/Version/Version.js.map +1 -1
  33. package/dist/admin/components/views/collections/Edit/Default.js +5 -2
  34. package/dist/admin/components/views/collections/Edit/Default.js.map +1 -1
  35. package/dist/admin/components/views/collections/Edit/Upload/index.js +7 -4
  36. package/dist/admin/components/views/collections/Edit/Upload/index.js.map +1 -1
  37. package/dist/admin/components/views/collections/Edit/index.scss +11 -3
  38. package/dist/admin/components/views/collections/List/RelationshipProvider/index.js +11 -4
  39. package/dist/admin/components/views/collections/List/RelationshipProvider/index.js.map +1 -1
  40. package/dist/auth/getExecuteStaticAccess.js +17 -15
  41. package/dist/auth/getExecuteStaticAccess.js.map +1 -1
  42. package/dist/auth/strategies/apiKey.js +0 -1
  43. package/dist/auth/strategies/apiKey.js.map +1 -1
  44. package/dist/collections/buildSchema.js +1 -1
  45. package/dist/collections/buildSchema.js.map +1 -1
  46. package/dist/collections/config/sanitize.js +5 -4
  47. package/dist/collections/config/sanitize.js.map +1 -1
  48. package/dist/collections/config/schema.js +1 -0
  49. package/dist/collections/config/schema.js.map +1 -1
  50. package/dist/collections/config/types.d.ts +9 -2
  51. package/dist/collections/initLocal.js +3 -2
  52. package/dist/collections/initLocal.js.map +1 -1
  53. package/dist/collections/operations/delete.js +11 -9
  54. package/dist/collections/operations/delete.js.map +1 -1
  55. package/dist/collections/operations/deleteByID.js +13 -11
  56. package/dist/collections/operations/deleteByID.js.map +1 -1
  57. package/dist/collections/operations/find.d.ts +0 -1
  58. package/dist/collections/operations/find.js +14 -11
  59. package/dist/collections/operations/find.js.map +1 -1
  60. package/dist/collections/operations/findByID.js +15 -12
  61. package/dist/collections/operations/findByID.js.map +1 -1
  62. package/dist/collections/operations/findVersionByID.js +13 -11
  63. package/dist/collections/operations/findVersionByID.js.map +1 -1
  64. package/dist/collections/operations/findVersions.js +9 -5
  65. package/dist/collections/operations/findVersions.js.map +1 -1
  66. package/dist/collections/operations/local/find.d.ts +0 -1
  67. package/dist/collections/operations/local/find.js +1 -2
  68. package/dist/collections/operations/local/find.js.map +1 -1
  69. package/dist/collections/operations/restoreVersion.js +12 -10
  70. package/dist/collections/operations/restoreVersion.js.map +1 -1
  71. package/dist/collections/operations/update.js +13 -10
  72. package/dist/collections/operations/update.js.map +1 -1
  73. package/dist/collections/operations/updateByID.js +12 -10
  74. package/dist/collections/operations/updateByID.js.map +1 -1
  75. package/dist/config/schema.js +1 -0
  76. package/dist/config/schema.js.map +1 -1
  77. package/dist/config/types.d.ts +7 -1
  78. package/dist/email/build.d.ts +1 -1
  79. package/dist/email/build.js +6 -3
  80. package/dist/email/build.js.map +1 -1
  81. package/dist/email/defaults.d.ts +2 -0
  82. package/dist/email/defaults.js +8 -0
  83. package/dist/email/defaults.js.map +1 -0
  84. package/dist/email/mockHandler.js +3 -2
  85. package/dist/email/mockHandler.js.map +1 -1
  86. package/dist/email/sendEmail.js +1 -1
  87. package/dist/email/sendEmail.js.map +1 -1
  88. package/dist/errors/QueryError.d.ts +8 -0
  89. package/dist/errors/QueryError.js +15 -0
  90. package/dist/errors/QueryError.js.map +1 -0
  91. package/dist/fields/validations.d.ts +1 -1
  92. package/dist/globals/buildModel.js +1 -1
  93. package/dist/globals/buildModel.js.map +1 -1
  94. package/dist/globals/config/sanitize.js +5 -5
  95. package/dist/globals/config/sanitize.js.map +1 -1
  96. package/dist/globals/config/schema.js +1 -0
  97. package/dist/globals/config/schema.js.map +1 -1
  98. package/dist/globals/config/types.d.ts +8 -1
  99. package/dist/globals/initLocal.js +3 -2
  100. package/dist/globals/initLocal.js.map +1 -1
  101. package/dist/globals/operations/findOne.js +15 -11
  102. package/dist/globals/operations/findOne.js.map +1 -1
  103. package/dist/globals/operations/findVersionByID.js +14 -11
  104. package/dist/globals/operations/findVersionByID.js.map +1 -1
  105. package/dist/globals/operations/findVersions.js +10 -5
  106. package/dist/globals/operations/findVersions.js.map +1 -1
  107. package/dist/globals/operations/update.js +14 -11
  108. package/dist/globals/operations/update.js.map +1 -1
  109. package/dist/graphql/errorHandler.d.ts +1 -8
  110. package/dist/graphql/errorHandler.js +2 -9
  111. package/dist/graphql/errorHandler.js.map +1 -1
  112. package/dist/graphql/graphQLHandler.d.ts +1 -6
  113. package/dist/graphql/graphQLHandler.js +24 -7
  114. package/dist/graphql/graphQLHandler.js.map +1 -1
  115. package/dist/graphql/registerSchema.js +0 -18
  116. package/dist/graphql/registerSchema.js.map +1 -1
  117. package/dist/initHTTP.js +1 -1
  118. package/dist/initHTTP.js.map +1 -1
  119. package/dist/mongoose/buildQuery.d.ts +76 -2
  120. package/dist/mongoose/buildQuery.js +274 -149
  121. package/dist/mongoose/buildQuery.js.map +1 -1
  122. package/dist/mongoose/sanitizeQueryValue.d.ts +12 -0
  123. package/dist/mongoose/{sanitizeFormattedValue.js → sanitizeQueryValue.js} +27 -26
  124. package/dist/mongoose/sanitizeQueryValue.js.map +1 -0
  125. package/dist/payload.d.ts +8 -6
  126. package/dist/payload.js +6 -2
  127. package/dist/payload.js.map +1 -1
  128. package/dist/translations/cs.json +1 -0
  129. package/dist/translations/de.json +1 -0
  130. package/dist/translations/en.json +1 -0
  131. package/dist/translations/es.json +1 -0
  132. package/dist/translations/fr.json +1 -0
  133. package/dist/translations/hr.json +1 -0
  134. package/dist/translations/hu.json +1 -0
  135. package/dist/translations/index.d.ts +21 -0
  136. package/dist/translations/it.json +1 -0
  137. package/dist/translations/ja.json +1 -0
  138. package/dist/translations/my.json +1 -0
  139. package/dist/translations/nb.json +1 -0
  140. package/dist/translations/nl.json +1 -0
  141. package/dist/translations/pl.json +1 -0
  142. package/dist/translations/pt.json +1 -0
  143. package/dist/translations/ru.json +1 -0
  144. package/dist/translations/sv.json +1 -0
  145. package/dist/translations/th.json +1 -0
  146. package/dist/translations/tr.json +1 -0
  147. package/dist/translations/ua.json +1 -0
  148. package/dist/translations/vi.json +1 -0
  149. package/dist/translations/zh.json +1 -0
  150. package/dist/uploads/generateFileData.js +4 -2
  151. package/dist/uploads/generateFileData.js.map +1 -1
  152. package/dist/utilities/flattenWhereConstraints.d.ts +2 -2
  153. package/dist/utilities/flattenWhereConstraints.js +12 -13
  154. package/dist/utilities/flattenWhereConstraints.js.map +1 -1
  155. package/dist/utilities/getEntityPolicies.d.ts +6 -10
  156. package/dist/utilities/getEntityPolicies.js +25 -15
  157. package/dist/utilities/getEntityPolicies.js.map +1 -1
  158. package/dist/versions/drafts/queryDrafts.d.ts +4 -3
  159. package/dist/versions/drafts/queryDrafts.js +11 -9
  160. package/dist/versions/drafts/queryDrafts.js.map +1 -1
  161. package/dist/versions/drafts/replaceWithDraftIfAvailable.d.ts +4 -2
  162. package/dist/versions/drafts/replaceWithDraftIfAvailable.js +16 -13
  163. package/dist/versions/drafts/replaceWithDraftIfAvailable.js.map +1 -1
  164. package/docs/access-control/collections.mdx +1 -1
  165. package/docs/admin/hooks.mdx +0 -1
  166. package/docs/configuration/collections.mdx +12 -11
  167. package/docs/configuration/express.mdx +34 -0
  168. package/docs/configuration/globals.mdx +5 -4
  169. package/docs/configuration/localization.mdx +9 -0
  170. package/docs/fields/date.mdx +32 -32
  171. package/docs/fields/textarea.mdx +1 -1
  172. package/docs/getting-started/installation.mdx +2 -0
  173. package/docs/hooks/collections.mdx +7 -1
  174. package/docs/queries/overview.mdx +1 -1
  175. package/docs/rest-api/overview.mdx +1 -1
  176. package/package.json +4 -4
  177. package/dist/mongoose/sanitizeFormattedValue.d.ts +0 -2
  178. package/dist/mongoose/sanitizeFormattedValue.js.map +0 -1
  179. package/dist/versions/defaults.d.ts +0 -3
  180. package/dist/versions/defaults.js +0 -18
  181. 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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;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,Y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AAC;QAEF,MAAM,GAAG,MAAM,YAAY,CAAC,iBAAiB,CAAC,SAAS,EAAE,wBAAwB,CAAC,CAAC;KACpF;SAAM;QACL,MAAM,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC;KAC3B;IAED,OAAO;QACL,GAAG,MAAM;QACT,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YAC9B,GAAG,EAAE,GAAG,CAAC,GAAG;YACZ,GAAG,GAAG,CAAC,OAAO;YACd,SAAS,EAAE,GAAG,CAAC,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,E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I,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"}
1
+ {"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 |
@@ -63,18 +63,19 @@ You can find an assortment of [example collection configs](https://github.com/pa
63
63
 
64
64
  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
65
 
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. |
66
+ | Option | Description |
67
+ |------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
68
+ | `group` | Text used as a label for grouping collection links together in the navigation. |
69
+ | `hidden` | Set to true or a function, called with the current user, returning true to exclude this collection from navigation and admin routing. |
70
+ | `hooks` | Admin-specific hooks for this collection. [More](#admin-hooks) |
71
+ | `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. |
72
+ | `description` | Text or React component to display below the Collection label in the List view to give editors more information. |
73
+ | `defaultColumns` | Array of field names that correspond to which columns to show by default in this collection's List view. |
74
+ | `disableDuplicate ` | Disables the "Duplicate" button while editing documents within this collection. |
74
75
  | `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) |
76
+ | `preview` | Function to generate preview URLS within the Admin panel that can point to your app. [More](#preview). |
77
+ | `components` | Swap in your own React components to be used within this collection. [More](/docs/admin/components#collections) |
78
+ | `listSearchableFields` | Specify which fields should be searched in the List search view. [More](#list-searchable-fields) |
78
79
 
79
80
  ### Preview
80
81
 
@@ -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`.
@@ -64,10 +64,11 @@ You can find an [example Global config](https://github.com/payloadcms/public-dem
64
64
 
65
65
  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
66
 
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). |
67
+ | Option | Description |
68
+ |--------------|-----------------------------------------------------------------------------------------------------------------------------------|
69
+ | `hidden` | Set to true or a function, called with the current user, returning true to exclude this global from navigation and admin routing. |
70
+ | `components` | Swap in your own React components to be used within this Global. [More](/docs/admin/components#globals) |
71
+ | `preview` | Function to generate a preview URL within the Admin panel for this global that can point to your app. [More](#preview). |
71
72
 
72
73
  ### Preview
73
74
 
@@ -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.
@@ -18,7 +18,7 @@ This field uses [`react-datepicker`](https://www.npmjs.com/package/react-datepic
18
18
  | Option | Description |
19
19
  | ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
20
20
  | **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
21
- | **`label`** | Text used as a field label in the Admin panel or an object with keys for each language. |
21
+ | **`label`** | Text used as a field label in the Admin panel or an object with keys for each language. |
22
22
  | **`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. |
23
23
  | **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |
24
24
  | **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
@@ -28,7 +28,7 @@ This field uses [`react-datepicker`](https://www.npmjs.com/package/react-datepic
28
28
  | **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
29
29
  | **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
30
30
  | **`required`** | Require this field to have a value. |
31
- | **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
31
+ | **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
32
32
 
33
33
  _\* An asterisk denotes that a property is required._
34
34
 
@@ -36,19 +36,19 @@ _\* An asterisk denotes that a property is required._
36
36
 
37
37
  In addition to the default [field admin config](/docs/fields/overview#admin-config), you can customize the following fields that will adjust how the component displays in the admin panel via the `date` property.
38
38
 
39
- | Property | Option | Description |
40
- | ---------------------- | -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
41
- | **`placeholder`** | | Placeholder text for the field. |
42
- | **`date`** | | Pass options to customize date field appearance. |
43
- | | **`displayFormat`** | Format date to be shown in field **cell**. |
44
- | | **`pickerAppearance`** \* | Determines the appearance of the datepicker: `dayAndTime` `timeOnly` `dayOnly` `monthOnly`. |
45
- | | **`monthsToShow`** \* | Number of months to display max is 2. Defaults to 1. |
46
- | | **`minDate`** \* | Min date value to allow. |
47
- | | **`maxDate`** \* | Max date value to allow. |
48
- | | **`minTime`** \* | Min time value to allow. |
49
- | | **`maxTime`** \* | Max date value to allow. |
50
- | | **`timeIntervals`** \* | Time intervals to display. Defaults to 30 minutes. |
51
- | | **`timeFormat`** \* | Determines time format. Defaults to `'h:mm aa'`. |
39
+ | Property | Description |
40
+ | ------------------------------ | ------------------------------------------------------------------------------------------- |
41
+ | **`placeholder`** | Placeholder text for the field. |
42
+ | **`date`** | Pass options to customize date field appearance. |
43
+ | **`date.displayFormat`** | Format date to be shown in field **cell**. |
44
+ | **`date.pickerAppearance`** \* | Determines the appearance of the datepicker: `dayAndTime` `timeOnly` `dayOnly` `monthOnly`. |
45
+ | **`date.monthsToShow`** \* | Number of months to display max is 2. Defaults to 1. |
46
+ | **`date.minDate`** \* | Min date value to allow. |
47
+ | **`date.maxDate`** \* | Max date value to allow. |
48
+ | **`date.minTime`** \* | Min time value to allow. |
49
+ | **`date.maxTime`** \* | Max date value to allow. |
50
+ | **`date.timeIntervals`** \* | Time intervals to display. Defaults to 30 minutes. |
51
+ | **`date.timeFormat`** \* | Determines time format. Defaults to `'h:mm aa'`. |
52
52
 
53
53
  _\* This property is passed directly to [react-datepicker](https://github.com/Hacker0x01/react-datepicker/blob/master/docs/datepicker.md). ._
54
54
 
@@ -60,48 +60,48 @@ These properties only affect how the date is displayed in the UI. The full date
60
60
 
61
61
  `pickerAppearance` sets the appearance of the **react datepicker**, the options available are `dayAndTime`, `dayOnly`, `timeOnly`, and `monthOnly`. By default, the datepicker will display `dayOnly`.
62
62
 
63
- When only `pickerAppearance`, an equivalent format will be rendered in the date field cell. To overwrite this format, set `displayFormat`.
63
+ When only `pickerAppearance` is set, an equivalent format will be rendered in the date field cell. To overwrite this format, set `displayFormat`.
64
64
 
65
65
  ### Example
66
66
 
67
67
  `collections/ExampleCollection.ts`
68
68
 
69
69
  ```ts
70
- import { CollectionConfig } from 'payload/types';
70
+ import { CollectionConfig } from "payload/types";
71
71
 
72
72
  const ExampleCollection: CollectionConfig = {
73
- slug: 'example-collection',
73
+ slug: "example-collection",
74
74
  fields: [
75
- {
76
- name: 'dateOnly',
77
- type: 'date',
75
+ {
76
+ name: "dateOnly",
77
+ type: "date",
78
78
  admin: {
79
79
  date: {
80
- pickerAppearance: 'dayOnly',
81
- displayFormat: 'd MMM yyy',
80
+ pickerAppearance: "dayOnly",
81
+ displayFormat: "d MMM yyy",
82
82
  },
83
83
  },
84
84
  },
85
85
  {
86
- name: 'timeOnly',
87
- type: 'date',
86
+ name: "timeOnly",
87
+ type: "date",
88
88
  admin: {
89
89
  date: {
90
- pickerAppearance: 'timeOnly',
91
- displayFormat: 'h:mm:ss a',
90
+ pickerAppearance: "timeOnly",
91
+ displayFormat: "h:mm:ss a",
92
92
  },
93
93
  },
94
94
  },
95
95
  {
96
- name: 'monthOnly',
97
- type: 'date',
96
+ name: "monthOnly",
97
+ type: "date",
98
98
  admin: {
99
99
  date: {
100
- pickerAppearance: 'monthOnly',
101
- displayFormat: 'MMMM yyyy',
100
+ pickerAppearance: "monthOnly",
101
+ displayFormat: "MMMM yyyy",
102
102
  },
103
103
  },
104
104
  },
105
- ]
105
+ ],
106
106
  };
107
107
  ```
@@ -25,7 +25,7 @@ keywords: textarea, fields, config, configuration, documentation, Content Manage
25
25
  | **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
26
26
  | **`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) |
27
27
  | **`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. |
28
- | **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) [More](/docs/fields/overview#default-values) |
28
+ | **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values)|
29
29
  | **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
30
30
  | **`required`** | Require this field to have a value. |
31
31
  | **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |