payload 4.0.0-internal.d28e9fb → 4.0.0-internal.e16cf59

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.
@@ -1 +1 @@
1
- {"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../../src/collections/config/sanitize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAA;AACjF,OAAO,KAAK,EACV,gBAAgB,EAChB,yBAAyB,EAG1B,MAAM,YAAY,CAAA;AA4BnB;;;GAGG;AACH,eAAO,MAAM,wBAAwB,eAAgB,gBAAgB,KAAG,IAuBvE,CAAA;AAED,eAAO,MAAM,kBAAkB,WACrB,MAAM,cACF,gBAAgB,iCAKG,KAAK,CAAC,CAAC,MAAM,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,wBAC1D,MAAM,EAAE,mBAIb,iBAAiB,EAAE,KACnC,OAAO,CAAC,yBAAyB,CA+TnC,CAAA"}
1
+ {"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../../src/collections/config/sanitize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAA;AACjF,OAAO,KAAK,EACV,gBAAgB,EAChB,yBAAyB,EAG1B,MAAM,YAAY,CAAA;AA2BnB;;;GAGG;AACH,eAAO,MAAM,wBAAwB,eAAgB,gBAAgB,KAAG,IAuBvE,CAAA;AAED,eAAO,MAAM,kBAAkB,WACrB,MAAM,cACF,gBAAgB,iCAKG,KAAK,CAAC,CAAC,MAAM,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,wBAC1D,MAAM,EAAE,mBAIb,iBAAiB,EAAE,KACnC,OAAO,CAAC,yBAAyB,CA0TnC,CAAA"}
@@ -11,7 +11,6 @@ import { getBaseUploadFields } from '../../uploads/getBaseFields.js';
11
11
  import { flattenAllFields } from '../../utilities/flattenAllFields.js';
12
12
  import { formatLabels } from '../../utilities/formatLabels.js';
13
13
  import { miniChalk } from '../../utilities/miniChalk.js';
14
- import { endSpan, startSpan } from '../../utilities/sanitizeProfiler.js';
15
14
  import { traverseForLocalizedFields } from '../../utilities/traverseForLocalizedFields.js';
16
15
  import { baseVersionFields } from '../../versions/baseFields.js';
17
16
  import { versionDefaults } from '../../versions/defaults.js';
@@ -48,257 +47,252 @@ export const sanitizeCollection = async (config, collection, /**
48
47
  if (collection._sanitized) {
49
48
  return collection;
50
49
  }
51
- const __profSpan = startSpan('sanitizeCollection', collection.slug);
52
- try {
53
- collection._sanitized = true;
54
- warnOnInvalidCustomViews(collection);
55
- // /////////////////////////////////
56
- // Make copy of collection config
57
- // /////////////////////////////////
58
- const sanitized = addDefaultsToCollectionConfig(collection);
59
- // /////////////////////////////////
60
- // Convert folders/tags to hierarchy
61
- // /////////////////////////////////
62
- const presetCount = [
63
- sanitized.folders,
64
- sanitized.tags,
65
- sanitized.hierarchy
66
- ].filter(Boolean).length;
67
- if (presetCount > 1) {
68
- throw new Error(`Collection "${sanitized.slug}": Only one of 'folders', 'tags', or 'hierarchy' can be specified`);
50
+ collection._sanitized = true;
51
+ warnOnInvalidCustomViews(collection);
52
+ // /////////////////////////////////
53
+ // Make copy of collection config
54
+ // /////////////////////////////////
55
+ const sanitized = addDefaultsToCollectionConfig(collection);
56
+ // /////////////////////////////////
57
+ // Convert folders/tags to hierarchy
58
+ // /////////////////////////////////
59
+ const presetCount = [
60
+ sanitized.folders,
61
+ sanitized.tags,
62
+ sanitized.hierarchy
63
+ ].filter(Boolean).length;
64
+ if (presetCount > 1) {
65
+ throw new Error(`Collection "${sanitized.slug}": Only one of 'folders', 'tags', or 'hierarchy' can be specified`);
66
+ }
67
+ if (sanitized.folders) {
68
+ sanitized.labels = {
69
+ plural: 'Folders',
70
+ singular: 'Folder',
71
+ ...sanitized.labels
72
+ };
73
+ sanitized.hierarchy = buildFoldersHierarchy(sanitized.folders, sanitized.slug);
74
+ // Set admin.group: false when sidebar tab enabled (folders accessed via tab)
75
+ const sidebarTabEnabled = typeof sanitized.hierarchy === 'object' && sanitized.hierarchy.admin?.injectSidebarTab !== false;
76
+ if (sidebarTabEnabled && sanitized.admin.group === undefined) {
77
+ sanitized.admin.group = false;
69
78
  }
70
- if (sanitized.folders) {
71
- sanitized.labels = {
72
- plural: 'Folders',
73
- singular: 'Folder',
74
- ...sanitized.labels
75
- };
76
- sanitized.hierarchy = buildFoldersHierarchy(sanitized.folders, sanitized.slug);
77
- // Set admin.group: false when sidebar tab enabled (folders accessed via tab)
78
- const sidebarTabEnabled = typeof sanitized.hierarchy === 'object' && sanitized.hierarchy.admin?.injectSidebarTab !== false;
79
- if (sidebarTabEnabled && sanitized.admin.group === undefined) {
80
- sanitized.admin.group = false;
81
- }
82
- delete sanitized.folders;
79
+ delete sanitized.folders;
80
+ }
81
+ if (sanitized.tags) {
82
+ sanitized.labels = {
83
+ plural: 'Tags',
84
+ singular: 'Tag',
85
+ ...sanitized.labels
86
+ };
87
+ sanitized.hierarchy = buildTagsHierarchy(sanitized.tags, sanitized.slug);
88
+ // Tags also hidden from nav by default
89
+ if (sanitized.admin.group === undefined) {
90
+ sanitized.admin.group = false;
83
91
  }
84
- if (sanitized.tags) {
85
- sanitized.labels = {
86
- plural: 'Tags',
87
- singular: 'Tag',
88
- ...sanitized.labels
89
- };
90
- sanitized.hierarchy = buildTagsHierarchy(sanitized.tags, sanitized.slug);
91
- // Tags also hidden from nav by default
92
- if (sanitized.admin.group === undefined) {
93
- sanitized.admin.group = false;
94
- }
95
- delete sanitized.tags;
92
+ delete sanitized.tags;
93
+ }
94
+ // /////////////////////////////////
95
+ // Sanitize fields
96
+ // /////////////////////////////////
97
+ const validRelationships = _validRelationships ?? config.collections.map((c)=>c.slug) ?? [];
98
+ const joins = {};
99
+ const polymorphicJoins = [];
100
+ sanitized.fields = await sanitizeFields({
101
+ collectionConfig: sanitized,
102
+ config,
103
+ fields: sanitized.fields,
104
+ joinPath: '',
105
+ joins,
106
+ orderableJoins,
107
+ parentIsLocalized: false,
108
+ polymorphicJoins,
109
+ richTextSanitizationPromises,
110
+ validRelationships
111
+ });
112
+ if (sanitized.endpoints !== false) {
113
+ if (!sanitized.endpoints) {
114
+ sanitized.endpoints = [];
96
115
  }
97
- // /////////////////////////////////
98
- // Sanitize fields
99
- // /////////////////////////////////
100
- const validRelationships = _validRelationships ?? config.collections.map((c)=>c.slug) ?? [];
101
- const joins = {};
102
- const polymorphicJoins = [];
103
- sanitized.fields = await sanitizeFields({
104
- collectionConfig: sanitized,
105
- config,
106
- fields: sanitized.fields,
107
- joinPath: '',
108
- joins,
109
- orderableJoins,
110
- parentIsLocalized: false,
111
- polymorphicJoins,
112
- richTextSanitizationPromises,
113
- validRelationships
114
- });
115
- if (sanitized.endpoints !== false) {
116
- if (!sanitized.endpoints) {
117
- sanitized.endpoints = [];
118
- }
119
- if (sanitized.auth) {
120
- for (const endpoint of authCollectionEndpoints){
121
- sanitized.endpoints.push(endpoint);
122
- }
123
- }
124
- if (sanitized.upload) {
125
- for (const endpoint of uploadCollectionEndpoints){
126
- sanitized.endpoints.push(endpoint);
127
- }
116
+ if (sanitized.auth) {
117
+ for (const endpoint of authCollectionEndpoints){
118
+ sanitized.endpoints.push(endpoint);
128
119
  }
129
- for (const endpoint of defaultCollectionEndpoints){
120
+ }
121
+ if (sanitized.upload) {
122
+ for (const endpoint of uploadCollectionEndpoints){
130
123
  sanitized.endpoints.push(endpoint);
131
124
  }
132
125
  }
133
- if (sanitized.timestamps !== false) {
134
- // add default timestamps fields only as needed
135
- let hasUpdatedAt = null;
136
- let hasCreatedAt = null;
137
- let hasDeletedAt = null;
138
- sanitized.fields.some((field)=>{
139
- if (fieldAffectsData(field)) {
140
- if (field.name === 'updatedAt') {
141
- hasUpdatedAt = true;
142
- }
143
- if (field.name === 'createdAt') {
144
- hasCreatedAt = true;
145
- }
146
- if (field.name === 'deletedAt') {
147
- hasDeletedAt = true;
148
- }
126
+ for (const endpoint of defaultCollectionEndpoints){
127
+ sanitized.endpoints.push(endpoint);
128
+ }
129
+ }
130
+ if (sanitized.timestamps !== false) {
131
+ // add default timestamps fields only as needed
132
+ let hasUpdatedAt = null;
133
+ let hasCreatedAt = null;
134
+ let hasDeletedAt = null;
135
+ sanitized.fields.some((field)=>{
136
+ if (fieldAffectsData(field)) {
137
+ if (field.name === 'updatedAt') {
138
+ hasUpdatedAt = true;
139
+ }
140
+ if (field.name === 'createdAt') {
141
+ hasCreatedAt = true;
142
+ }
143
+ if (field.name === 'deletedAt') {
144
+ hasDeletedAt = true;
149
145
  }
150
- return hasCreatedAt && hasUpdatedAt && (!sanitized.trash || hasDeletedAt);
151
- });
152
- if (!hasUpdatedAt) {
153
- sanitized.fields.push({
154
- name: 'updatedAt',
155
- type: 'date',
156
- admin: {
157
- disabled: {
158
- bulkEdit: true
159
- },
160
- hidden: true
161
- },
162
- index: true,
163
- label: ({ t })=>t('general:updatedAt')
164
- });
165
146
  }
166
- if (!hasCreatedAt) {
167
- sanitized.fields.push({
168
- name: 'createdAt',
169
- admin: {
170
- disabled: {
171
- bulkEdit: true
172
- },
173
- hidden: true
147
+ return hasCreatedAt && hasUpdatedAt && (!sanitized.trash || hasDeletedAt);
148
+ });
149
+ if (!hasUpdatedAt) {
150
+ sanitized.fields.push({
151
+ name: 'updatedAt',
152
+ type: 'date',
153
+ admin: {
154
+ disabled: {
155
+ bulkEdit: true
174
156
  },
175
- // The default sort for list view is createdAt. Thus, enabling indexing by default, is a major performance improvement, especially for large or a large amount of collections.
176
- type: 'date',
177
- index: true,
178
- label: ({ t })=>t('general:createdAt')
179
- });
180
- }
181
- if (sanitized.trash && !hasDeletedAt) {
182
- sanitized.fields.push({
183
- name: 'deletedAt',
184
- type: 'date',
185
- admin: {
186
- disabled: {
187
- bulkEdit: true
188
- },
189
- hidden: true
157
+ hidden: true
158
+ },
159
+ index: true,
160
+ label: ({ t })=>t('general:updatedAt')
161
+ });
162
+ }
163
+ if (!hasCreatedAt) {
164
+ sanitized.fields.push({
165
+ name: 'createdAt',
166
+ admin: {
167
+ disabled: {
168
+ bulkEdit: true
190
169
  },
191
- index: true,
192
- label: ({ t })=>t('general:deletedAt')
193
- });
194
- }
170
+ hidden: true
171
+ },
172
+ // The default sort for list view is createdAt. Thus, enabling indexing by default, is a major performance improvement, especially for large or a large amount of collections.
173
+ type: 'date',
174
+ index: true,
175
+ label: ({ t })=>t('general:createdAt')
176
+ });
195
177
  }
196
- const defaultLabels = formatLabels(sanitized.slug);
197
- sanitized.labels = {
198
- plural: sanitized.labels?.plural || defaultLabels.plural,
199
- singular: sanitized.labels?.singular || defaultLabels.singular
200
- };
201
- if (sanitized.versions) {
202
- if (sanitized.timestamps === false) {
203
- throw new TimestampsRequired(collection);
204
- }
205
- if (sanitized.versions === true) {
206
- sanitized.versions = {
207
- drafts: false,
208
- maxPerDoc: 100
178
+ if (sanitized.trash && !hasDeletedAt) {
179
+ sanitized.fields.push({
180
+ name: 'deletedAt',
181
+ type: 'date',
182
+ admin: {
183
+ disabled: {
184
+ bulkEdit: true
185
+ },
186
+ hidden: true
187
+ },
188
+ index: true,
189
+ label: ({ t })=>t('general:deletedAt')
190
+ });
191
+ }
192
+ }
193
+ const defaultLabels = formatLabels(sanitized.slug);
194
+ sanitized.labels = {
195
+ plural: sanitized.labels?.plural || defaultLabels.plural,
196
+ singular: sanitized.labels?.singular || defaultLabels.singular
197
+ };
198
+ if (sanitized.versions) {
199
+ if (sanitized.timestamps === false) {
200
+ throw new TimestampsRequired(collection);
201
+ }
202
+ if (sanitized.versions === true) {
203
+ sanitized.versions = {
204
+ drafts: false,
205
+ maxPerDoc: 100
206
+ };
207
+ }
208
+ sanitized.versions.maxPerDoc = typeof sanitized.versions.maxPerDoc === 'number' ? sanitized.versions.maxPerDoc : 100;
209
+ if (sanitized.versions.drafts) {
210
+ if (sanitized.versions.drafts === true) {
211
+ sanitized.versions.drafts = {
212
+ autosave: false,
213
+ validate: false
209
214
  };
210
215
  }
211
- sanitized.versions.maxPerDoc = typeof sanitized.versions.maxPerDoc === 'number' ? sanitized.versions.maxPerDoc : 100;
212
- if (sanitized.versions.drafts) {
213
- if (sanitized.versions.drafts === true) {
214
- sanitized.versions.drafts = {
215
- autosave: false,
216
- validate: false
217
- };
218
- }
219
- const hasLocalizedFields = traverseForLocalizedFields(sanitized.fields);
220
- if (config.localization) {
221
- if (hasLocalizedFields && sanitized.versions.drafts.localizeStatus === undefined) {
222
- sanitized.versions.drafts.localizeStatus = false;
223
- }
224
- }
225
- // TODO v4: remove this sanitization check, should not need to enable the experimental flag
226
- if (sanitized.versions.drafts.localizeStatus && !config.experimental?.localizeStatus) {
216
+ const hasLocalizedFields = traverseForLocalizedFields(sanitized.fields);
217
+ if (config.localization) {
218
+ if (hasLocalizedFields && sanitized.versions.drafts.localizeStatus === undefined) {
227
219
  sanitized.versions.drafts.localizeStatus = false;
228
- console.log(miniChalk.yellowBold(`Warning: "localizeStatus" for drafts is an experimental feature. To enable, set "experimental.localizeStatus" to true in your Payload config.`));
229
- }
230
- if (sanitized.versions.drafts.autosave === true) {
231
- sanitized.versions.drafts.autosave = {
232
- interval: versionDefaults.autosaveInterval
233
- };
234
220
  }
235
- if (sanitized.versions.drafts.validate === undefined) {
236
- sanitized.versions.drafts.validate = false;
237
- }
238
- sanitized.fields = mergeBaseFields(sanitized.fields, baseVersionFields({
239
- localized: sanitized.versions.drafts.localizeStatus ?? false
240
- }));
241
221
  }
242
- } else {
243
- delete sanitized.versions;
244
- }
245
- // Sanitize hierarchy configuration (phase 1 - per collection)
246
- sanitizeHierarchyCollection(sanitized, config);
247
- if (sanitized.upload) {
248
- if (sanitized.upload === true) {
249
- sanitized.upload = {};
222
+ // TODO v4: remove this sanitization check, should not need to enable the experimental flag
223
+ if (sanitized.versions.drafts.localizeStatus && !config.experimental?.localizeStatus) {
224
+ sanitized.versions.drafts.localizeStatus = false;
225
+ console.log(miniChalk.yellowBold(`Warning: "localizeStatus" for drafts is an experimental feature. To enable, set "experimental.localizeStatus" to true in your Payload config.`));
250
226
  }
251
- sanitized.upload.cacheTags = sanitized.upload?.cacheTags ?? true;
252
- sanitized.upload.bulkUpload = sanitized.upload?.bulkUpload ?? true;
253
- sanitized.upload.staticDir = sanitized.upload.staticDir || sanitized.slug;
254
- sanitized.admin.useAsTitle = sanitized.admin?.useAsTitle && sanitized.admin.useAsTitle !== 'id' ? sanitized.admin.useAsTitle : 'filename';
255
- const uploadFields = getBaseUploadFields({
256
- collection: sanitized,
257
- config
258
- });
259
- sanitized.fields = mergeBaseFields(sanitized.fields, uploadFields);
260
- }
261
- if (sanitized.auth) {
262
- sanitized.auth = addDefaultsToAuthConfig(typeof sanitized.auth === 'boolean' ? {} : sanitized.auth);
263
- // disable duplicate for auth enabled collections by default
264
- sanitized.disableDuplicate = sanitized.disableDuplicate ?? true;
265
- if (sanitized.auth.loginWithUsername) {
266
- if (sanitized.auth.loginWithUsername === true) {
267
- sanitized.auth.loginWithUsername = addDefaultsToLoginWithUsernameConfig({});
268
- } else {
269
- const loginWithUsernameWithDefaults = addDefaultsToLoginWithUsernameConfig(sanitized.auth.loginWithUsername);
270
- // if allowEmailLogin is false, requireUsername must be true
271
- if (loginWithUsernameWithDefaults.allowEmailLogin === false) {
272
- loginWithUsernameWithDefaults.requireUsername = true;
273
- }
274
- sanitized.auth.loginWithUsername = loginWithUsernameWithDefaults;
275
- }
276
- } else {
277
- sanitized.auth.loginWithUsername = false;
227
+ if (sanitized.versions.drafts.autosave === true) {
228
+ sanitized.versions.drafts.autosave = {
229
+ interval: versionDefaults.autosaveInterval
230
+ };
278
231
  }
279
- if (!collection?.admin?.useAsTitle) {
280
- sanitized.admin.useAsTitle = sanitized.auth.loginWithUsername ? 'username' : 'email';
232
+ if (sanitized.versions.drafts.validate === undefined) {
233
+ sanitized.versions.drafts.validate = false;
281
234
  }
282
- sanitized.fields = mergeBaseFields(sanitized.fields, getBaseAuthFields(sanitized.auth));
235
+ sanitized.fields = mergeBaseFields(sanitized.fields, baseVersionFields({
236
+ localized: sanitized.versions.drafts.localizeStatus ?? false
237
+ }));
283
238
  }
284
- if (collection?.admin?.pagination?.limits?.length) {
285
- sanitized.admin.pagination.limits = collection.admin.pagination.limits;
239
+ } else {
240
+ delete sanitized.versions;
241
+ }
242
+ // Sanitize hierarchy configuration (phase 1 - per collection)
243
+ sanitizeHierarchyCollection(sanitized, config);
244
+ if (sanitized.upload) {
245
+ if (sanitized.upload === true) {
246
+ sanitized.upload = {};
286
247
  }
287
- validateUseAsTitle(sanitized);
288
- const sanitizedConfig = sanitized;
289
- sanitizedConfig.joins = joins;
290
- sanitizedConfig.polymorphicJoins = polymorphicJoins;
291
- sanitizedConfig.flattenedFields = flattenAllFields({
292
- fields: sanitizedConfig.fields
293
- });
294
- sanitizedConfig.sanitizedIndexes = sanitizeCompoundIndexes({
295
- fields: sanitizedConfig.flattenedFields,
296
- indexes: sanitizedConfig.indexes
248
+ sanitized.upload.cacheTags = sanitized.upload?.cacheTags ?? true;
249
+ sanitized.upload.bulkUpload = sanitized.upload?.bulkUpload ?? true;
250
+ sanitized.upload.staticDir = sanitized.upload.staticDir || sanitized.slug;
251
+ sanitized.admin.useAsTitle = sanitized.admin?.useAsTitle && sanitized.admin.useAsTitle !== 'id' ? sanitized.admin.useAsTitle : 'filename';
252
+ const uploadFields = getBaseUploadFields({
253
+ collection: sanitized,
254
+ config
297
255
  });
298
- return sanitizedConfig;
299
- } finally{
300
- endSpan(__profSpan);
256
+ sanitized.fields = mergeBaseFields(sanitized.fields, uploadFields);
257
+ }
258
+ if (sanitized.auth) {
259
+ sanitized.auth = addDefaultsToAuthConfig(typeof sanitized.auth === 'boolean' ? {} : sanitized.auth);
260
+ // disable duplicate for auth enabled collections by default
261
+ sanitized.disableDuplicate = sanitized.disableDuplicate ?? true;
262
+ if (sanitized.auth.loginWithUsername) {
263
+ if (sanitized.auth.loginWithUsername === true) {
264
+ sanitized.auth.loginWithUsername = addDefaultsToLoginWithUsernameConfig({});
265
+ } else {
266
+ const loginWithUsernameWithDefaults = addDefaultsToLoginWithUsernameConfig(sanitized.auth.loginWithUsername);
267
+ // if allowEmailLogin is false, requireUsername must be true
268
+ if (loginWithUsernameWithDefaults.allowEmailLogin === false) {
269
+ loginWithUsernameWithDefaults.requireUsername = true;
270
+ }
271
+ sanitized.auth.loginWithUsername = loginWithUsernameWithDefaults;
272
+ }
273
+ } else {
274
+ sanitized.auth.loginWithUsername = false;
275
+ }
276
+ if (!collection?.admin?.useAsTitle) {
277
+ sanitized.admin.useAsTitle = sanitized.auth.loginWithUsername ? 'username' : 'email';
278
+ }
279
+ sanitized.fields = mergeBaseFields(sanitized.fields, getBaseAuthFields(sanitized.auth));
280
+ }
281
+ if (collection?.admin?.pagination?.limits?.length) {
282
+ sanitized.admin.pagination.limits = collection.admin.pagination.limits;
301
283
  }
284
+ validateUseAsTitle(sanitized);
285
+ const sanitizedConfig = sanitized;
286
+ sanitizedConfig.joins = joins;
287
+ sanitizedConfig.polymorphicJoins = polymorphicJoins;
288
+ sanitizedConfig.flattenedFields = flattenAllFields({
289
+ fields: sanitizedConfig.fields
290
+ });
291
+ sanitizedConfig.sanitizedIndexes = sanitizeCompoundIndexes({
292
+ fields: sanitizedConfig.flattenedFields,
293
+ indexes: sanitizedConfig.indexes
294
+ });
295
+ return sanitizedConfig;
302
296
  };
303
297
 
304
298
  //# sourceMappingURL=sanitize.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/collections/config/sanitize.ts"],"sourcesContent":["import type { Config, SanitizedConfig } from '../../config/types.js'\nimport type { OrderableJoinInfo } from '../../fields/config/sanitizeJoinField.js'\nimport type {\n CollectionConfig,\n SanitizedCollectionConfig,\n SanitizedJoin,\n SanitizedJoins,\n} from './types.js'\n\nimport { authCollectionEndpoints } from '../../auth/endpoints/index.js'\nimport { getBaseAuthFields } from '../../auth/getAuthFields.js'\nimport { TimestampsRequired } from '../../errors/TimestampsRequired.js'\nimport { sanitizeFields } from '../../fields/config/sanitize.js'\nimport { fieldAffectsData } from '../../fields/config/types.js'\nimport { mergeBaseFields } from '../../fields/mergeBaseFields.js'\nimport { buildFoldersHierarchy, buildTagsHierarchy } from '../../hierarchy/presets.js'\nimport { sanitizeHierarchyCollection } from '../../hierarchy/sanitizeHierarchyCollection.js'\nimport { uploadCollectionEndpoints } from '../../uploads/endpoints/index.js'\nimport { getBaseUploadFields } from '../../uploads/getBaseFields.js'\nimport { flattenAllFields } from '../../utilities/flattenAllFields.js'\nimport { formatLabels } from '../../utilities/formatLabels.js'\nimport { miniChalk } from '../../utilities/miniChalk.js'\nimport { endSpan, startSpan } from '../../utilities/sanitizeProfiler.js'\nimport { traverseForLocalizedFields } from '../../utilities/traverseForLocalizedFields.js'\nimport { baseVersionFields } from '../../versions/baseFields.js'\nimport { versionDefaults } from '../../versions/defaults.js'\nimport { defaultCollectionEndpoints } from '../endpoints/index.js'\nimport {\n addDefaultsToAuthConfig,\n addDefaultsToCollectionConfig,\n addDefaultsToLoginWithUsernameConfig,\n} from './defaults.js'\nimport { sanitizeCompoundIndexes } from './sanitizeCompoundIndexes.js'\nimport { validateUseAsTitle } from './useAsTitle.js'\n\n/**\n * Warns at startup when custom collection views are misconfigured with a missing `path`.\n * Views without `path` will never be matched by the router and are silently ignored.\n */\nexport const warnOnInvalidCustomViews = (collection: CollectionConfig): void => {\n const views = collection.admin?.components?.views\n if (!views || typeof views !== 'object') {\n return\n }\n\n for (const [key, view] of Object.entries(views)) {\n if (key === 'edit' || key === 'list') {\n continue\n }\n\n if (view && typeof view === 'object' && 'Component' in view && !('path' in view)) {\n console.warn(\n `[Payload] Custom collection view \"${key}\" in collection \"${collection.slug}\" is missing a \"path\" property. The view will never be rendered.`,\n )\n }\n\n if (view && typeof view === 'object' && 'path' in view && !('Component' in view)) {\n console.warn(\n `[Payload] Custom collection view \"${key}\" in collection \"${collection.slug}\" has a \"path\" but is missing a \"Component\". The view will never be rendered.`,\n )\n }\n }\n}\n\nexport const sanitizeCollection = async (\n config: Config,\n collection: CollectionConfig,\n /**\n * If this property is set, RichText fields won't be sanitized immediately. Instead, they will be added to this array as promises\n * so that you can sanitize them together, after the config has been sanitized.\n */\n richTextSanitizationPromises?: Array<(config: SanitizedConfig) => Promise<void>>,\n _validRelationships?: string[],\n /**\n * Tracker for orderable join fields - populated during sanitization\n */\n orderableJoins?: OrderableJoinInfo[],\n): Promise<SanitizedCollectionConfig> => {\n if (collection._sanitized) {\n return collection as SanitizedCollectionConfig\n }\n\n const __profSpan = startSpan('sanitizeCollection', collection.slug)\n try {\n collection._sanitized = true\n\n warnOnInvalidCustomViews(collection)\n\n // /////////////////////////////////\n // Make copy of collection config\n // /////////////////////////////////\n\n const sanitized: CollectionConfig = addDefaultsToCollectionConfig(collection)\n\n // /////////////////////////////////\n // Convert folders/tags to hierarchy\n // /////////////////////////////////\n\n const presetCount = [sanitized.folders, sanitized.tags, sanitized.hierarchy].filter(\n Boolean,\n ).length\n if (presetCount > 1) {\n throw new Error(\n `Collection \"${sanitized.slug}\": Only one of 'folders', 'tags', or 'hierarchy' can be specified`,\n )\n }\n\n if (sanitized.folders) {\n sanitized.labels = {\n plural: 'Folders',\n singular: 'Folder',\n ...sanitized.labels,\n }\n sanitized.hierarchy = buildFoldersHierarchy(sanitized.folders, sanitized.slug)\n // Set admin.group: false when sidebar tab enabled (folders accessed via tab)\n const sidebarTabEnabled =\n typeof sanitized.hierarchy === 'object' &&\n sanitized.hierarchy.admin?.injectSidebarTab !== false\n if (sidebarTabEnabled && sanitized.admin!.group === undefined) {\n sanitized.admin!.group = false\n }\n delete sanitized.folders\n }\n\n if (sanitized.tags) {\n sanitized.labels = {\n plural: 'Tags',\n singular: 'Tag',\n ...sanitized.labels,\n }\n sanitized.hierarchy = buildTagsHierarchy(sanitized.tags, sanitized.slug)\n // Tags also hidden from nav by default\n if (sanitized.admin!.group === undefined) {\n sanitized.admin!.group = false\n }\n delete sanitized.tags\n }\n\n // /////////////////////////////////\n // Sanitize fields\n // /////////////////////////////////\n\n const validRelationships = _validRelationships ?? config.collections!.map((c) => c.slug) ?? []\n\n const joins: SanitizedJoins = {}\n\n const polymorphicJoins: SanitizedJoin[] = []\n\n sanitized.fields = await sanitizeFields({\n collectionConfig: sanitized,\n config,\n fields: sanitized.fields,\n joinPath: '',\n joins,\n orderableJoins,\n parentIsLocalized: false,\n polymorphicJoins,\n richTextSanitizationPromises,\n validRelationships,\n })\n\n if (sanitized.endpoints !== false) {\n if (!sanitized.endpoints) {\n sanitized.endpoints = []\n }\n\n if (sanitized.auth) {\n for (const endpoint of authCollectionEndpoints) {\n sanitized.endpoints.push(endpoint)\n }\n }\n\n if (sanitized.upload) {\n for (const endpoint of uploadCollectionEndpoints) {\n sanitized.endpoints.push(endpoint)\n }\n }\n\n for (const endpoint of defaultCollectionEndpoints) {\n sanitized.endpoints.push(endpoint)\n }\n }\n\n if (sanitized.timestamps !== false) {\n // add default timestamps fields only as needed\n let hasUpdatedAt: boolean | null = null\n let hasCreatedAt: boolean | null = null\n let hasDeletedAt: boolean | null = null\n\n sanitized.fields.some((field) => {\n if (fieldAffectsData(field)) {\n if (field.name === 'updatedAt') {\n hasUpdatedAt = true\n }\n\n if (field.name === 'createdAt') {\n hasCreatedAt = true\n }\n\n if (field.name === 'deletedAt') {\n hasDeletedAt = true\n }\n }\n\n return hasCreatedAt && hasUpdatedAt && (!sanitized.trash || hasDeletedAt)\n })\n\n if (!hasUpdatedAt) {\n sanitized.fields.push({\n name: 'updatedAt',\n type: 'date',\n admin: {\n disabled: { bulkEdit: true },\n hidden: true,\n },\n index: true,\n label: ({ t }) => t('general:updatedAt'),\n })\n }\n\n if (!hasCreatedAt) {\n sanitized.fields.push({\n name: 'createdAt',\n admin: {\n disabled: { bulkEdit: true },\n hidden: true,\n },\n // The default sort for list view is createdAt. Thus, enabling indexing by default, is a major performance improvement, especially for large or a large amount of collections.\n type: 'date',\n index: true,\n label: ({ t }) => t('general:createdAt'),\n })\n }\n\n if (sanitized.trash && !hasDeletedAt) {\n sanitized.fields.push({\n name: 'deletedAt',\n type: 'date',\n admin: {\n disabled: { bulkEdit: true },\n hidden: true,\n },\n index: true,\n label: ({ t }) => t('general:deletedAt'),\n })\n }\n }\n\n const defaultLabels = formatLabels(sanitized.slug)\n\n sanitized.labels = {\n plural: sanitized.labels?.plural || defaultLabels.plural,\n singular: sanitized.labels?.singular || defaultLabels.singular,\n }\n\n if (sanitized.versions) {\n if (sanitized.timestamps === false) {\n throw new TimestampsRequired(collection)\n }\n\n if (sanitized.versions === true) {\n sanitized.versions = {\n drafts: false,\n maxPerDoc: 100,\n }\n }\n\n sanitized.versions.maxPerDoc =\n typeof sanitized.versions.maxPerDoc === 'number' ? sanitized.versions.maxPerDoc : 100\n\n if (sanitized.versions.drafts) {\n if (sanitized.versions.drafts === true) {\n sanitized.versions.drafts = {\n autosave: false,\n validate: false,\n }\n }\n\n const hasLocalizedFields = traverseForLocalizedFields(sanitized.fields)\n\n if (config.localization) {\n if (hasLocalizedFields && sanitized.versions.drafts.localizeStatus === undefined) {\n sanitized.versions.drafts.localizeStatus = false\n }\n }\n\n // TODO v4: remove this sanitization check, should not need to enable the experimental flag\n if (sanitized.versions.drafts.localizeStatus && !config.experimental?.localizeStatus) {\n sanitized.versions.drafts.localizeStatus = false\n console.log(\n miniChalk.yellowBold(\n `Warning: \"localizeStatus\" for drafts is an experimental feature. To enable, set \"experimental.localizeStatus\" to true in your Payload config.`,\n ),\n )\n }\n\n if (sanitized.versions.drafts.autosave === true) {\n sanitized.versions.drafts.autosave = {\n interval: versionDefaults.autosaveInterval,\n }\n }\n\n if (sanitized.versions.drafts.validate === undefined) {\n sanitized.versions.drafts.validate = false\n }\n\n sanitized.fields = mergeBaseFields(\n sanitized.fields,\n baseVersionFields({\n localized: sanitized.versions.drafts.localizeStatus ?? false,\n }),\n )\n }\n } else {\n delete sanitized.versions\n }\n\n // Sanitize hierarchy configuration (phase 1 - per collection)\n sanitizeHierarchyCollection(sanitized, config)\n\n if (sanitized.upload) {\n if (sanitized.upload === true) {\n sanitized.upload = {}\n }\n\n sanitized.upload.cacheTags = sanitized.upload?.cacheTags ?? true\n sanitized.upload.bulkUpload = sanitized.upload?.bulkUpload ?? true\n sanitized.upload.staticDir = sanitized.upload.staticDir || sanitized.slug\n sanitized.admin!.useAsTitle =\n sanitized.admin?.useAsTitle && sanitized.admin.useAsTitle !== 'id'\n ? sanitized.admin.useAsTitle\n : 'filename'\n\n const uploadFields = getBaseUploadFields({\n collection: sanitized,\n config,\n })\n\n sanitized.fields = mergeBaseFields(sanitized.fields, uploadFields)\n }\n\n if (sanitized.auth) {\n sanitized.auth = addDefaultsToAuthConfig(\n typeof sanitized.auth === 'boolean' ? {} : sanitized.auth,\n )\n\n // disable duplicate for auth enabled collections by default\n sanitized.disableDuplicate = sanitized.disableDuplicate ?? true\n\n if (sanitized.auth.loginWithUsername) {\n if (sanitized.auth.loginWithUsername === true) {\n sanitized.auth.loginWithUsername = addDefaultsToLoginWithUsernameConfig({})\n } else {\n const loginWithUsernameWithDefaults = addDefaultsToLoginWithUsernameConfig(\n sanitized.auth.loginWithUsername,\n )\n\n // if allowEmailLogin is false, requireUsername must be true\n if (loginWithUsernameWithDefaults.allowEmailLogin === false) {\n loginWithUsernameWithDefaults.requireUsername = true\n }\n sanitized.auth.loginWithUsername = loginWithUsernameWithDefaults\n }\n } else {\n sanitized.auth.loginWithUsername = false\n }\n\n if (!collection?.admin?.useAsTitle) {\n sanitized.admin!.useAsTitle = sanitized.auth.loginWithUsername ? 'username' : 'email'\n }\n\n sanitized.fields = mergeBaseFields(sanitized.fields, getBaseAuthFields(sanitized.auth))\n }\n\n if (collection?.admin?.pagination?.limits?.length) {\n sanitized.admin!.pagination!.limits = collection.admin.pagination.limits\n }\n\n validateUseAsTitle(sanitized)\n\n const sanitizedConfig = sanitized as SanitizedCollectionConfig\n\n sanitizedConfig.joins = joins\n sanitizedConfig.polymorphicJoins = polymorphicJoins\n\n sanitizedConfig.flattenedFields = flattenAllFields({ fields: sanitizedConfig.fields })\n\n sanitizedConfig.sanitizedIndexes = sanitizeCompoundIndexes({\n fields: sanitizedConfig.flattenedFields,\n indexes: sanitizedConfig.indexes,\n })\n\n return sanitizedConfig\n } finally {\n endSpan(__profSpan)\n }\n}\n"],"names":["authCollectionEndpoints","getBaseAuthFields","TimestampsRequired","sanitizeFields","fieldAffectsData","mergeBaseFields","buildFoldersHierarchy","buildTagsHierarchy","sanitizeHierarchyCollection","uploadCollectionEndpoints","getBaseUploadFields","flattenAllFields","formatLabels","miniChalk","endSpan","startSpan","traverseForLocalizedFields","baseVersionFields","versionDefaults","defaultCollectionEndpoints","addDefaultsToAuthConfig","addDefaultsToCollectionConfig","addDefaultsToLoginWithUsernameConfig","sanitizeCompoundIndexes","validateUseAsTitle","warnOnInvalidCustomViews","collection","views","admin","components","key","view","Object","entries","console","warn","slug","sanitizeCollection","config","richTextSanitizationPromises","_validRelationships","orderableJoins","_sanitized","__profSpan","sanitized","presetCount","folders","tags","hierarchy","filter","Boolean","length","Error","labels","plural","singular","sidebarTabEnabled","injectSidebarTab","group","undefined","validRelationships","collections","map","c","joins","polymorphicJoins","fields","collectionConfig","joinPath","parentIsLocalized","endpoints","auth","endpoint","push","upload","timestamps","hasUpdatedAt","hasCreatedAt","hasDeletedAt","some","field","name","trash","type","disabled","bulkEdit","hidden","index","label","t","defaultLabels","versions","drafts","maxPerDoc","autosave","validate","hasLocalizedFields","localization","localizeStatus","experimental","log","yellowBold","interval","autosaveInterval","localized","cacheTags","bulkUpload","staticDir","useAsTitle","uploadFields","disableDuplicate","loginWithUsername","loginWithUsernameWithDefaults","allowEmailLogin","requireUsername","pagination","limits","sanitizedConfig","flattenedFields","sanitizedIndexes","indexes"],"mappings":"AASA,SAASA,uBAAuB,QAAQ,gCAA+B;AACv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QAAQmD,gBAAgBnD,MAAM;QAAC;QAEpFmD,gBAAgBE,gBAAgB,GAAGhG,wBAAwB;YACzD2C,QAAQmD,gBAAgBC,eAAe;YACvCE,SAASH,gBAAgBG,OAAO;QAClC;QAEA,OAAOH;IACP,SAAU;QACRvG,QAAQ6B;IACV;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/collections/config/sanitize.ts"],"sourcesContent":["import type { Config, SanitizedConfig } from '../../config/types.js'\nimport type { OrderableJoinInfo } from '../../fields/config/sanitizeJoinField.js'\nimport type {\n CollectionConfig,\n SanitizedCollectionConfig,\n SanitizedJoin,\n SanitizedJoins,\n} from './types.js'\n\nimport { authCollectionEndpoints } from '../../auth/endpoints/index.js'\nimport { getBaseAuthFields } from '../../auth/getAuthFields.js'\nimport { TimestampsRequired } from '../../errors/TimestampsRequired.js'\nimport { sanitizeFields } from '../../fields/config/sanitize.js'\nimport { fieldAffectsData } from '../../fields/config/types.js'\nimport { mergeBaseFields } from '../../fields/mergeBaseFields.js'\nimport { buildFoldersHierarchy, buildTagsHierarchy } from '../../hierarchy/presets.js'\nimport { sanitizeHierarchyCollection } from '../../hierarchy/sanitizeHierarchyCollection.js'\nimport { uploadCollectionEndpoints } from '../../uploads/endpoints/index.js'\nimport { getBaseUploadFields } from '../../uploads/getBaseFields.js'\nimport { flattenAllFields } from '../../utilities/flattenAllFields.js'\nimport { formatLabels } from '../../utilities/formatLabels.js'\nimport { miniChalk } from '../../utilities/miniChalk.js'\nimport { traverseForLocalizedFields } from '../../utilities/traverseForLocalizedFields.js'\nimport { baseVersionFields } from '../../versions/baseFields.js'\nimport { versionDefaults } from '../../versions/defaults.js'\nimport { defaultCollectionEndpoints } from '../endpoints/index.js'\nimport {\n addDefaultsToAuthConfig,\n addDefaultsToCollectionConfig,\n addDefaultsToLoginWithUsernameConfig,\n} from './defaults.js'\nimport { sanitizeCompoundIndexes } from './sanitizeCompoundIndexes.js'\nimport { validateUseAsTitle } from './useAsTitle.js'\n\n/**\n * Warns at startup when custom collection views are misconfigured with a missing `path`.\n * Views without `path` will never be matched by the router and are silently ignored.\n */\nexport const warnOnInvalidCustomViews = (collection: CollectionConfig): void => {\n const views = collection.admin?.components?.views\n if (!views || typeof views !== 'object') {\n return\n }\n\n for (const [key, view] of Object.entries(views)) {\n if (key === 'edit' || key === 'list') {\n continue\n }\n\n if (view && typeof view === 'object' && 'Component' in view && !('path' in view)) {\n console.warn(\n `[Payload] Custom collection view \"${key}\" in collection \"${collection.slug}\" is missing a \"path\" property. The view will never be rendered.`,\n )\n }\n\n if (view && typeof view === 'object' && 'path' in view && !('Component' in view)) {\n console.warn(\n `[Payload] Custom collection view \"${key}\" in collection \"${collection.slug}\" has a \"path\" but is missing a \"Component\". The view will never be rendered.`,\n )\n }\n }\n}\n\nexport const sanitizeCollection = async (\n config: Config,\n collection: CollectionConfig,\n /**\n * If this property is set, RichText fields won't be sanitized immediately. Instead, they will be added to this array as promises\n * so that you can sanitize them together, after the config has been sanitized.\n */\n richTextSanitizationPromises?: Array<(config: SanitizedConfig) => Promise<void>>,\n _validRelationships?: string[],\n /**\n * Tracker for orderable join fields - populated during sanitization\n */\n orderableJoins?: OrderableJoinInfo[],\n): Promise<SanitizedCollectionConfig> => {\n if (collection._sanitized) {\n return collection as SanitizedCollectionConfig\n }\n\n collection._sanitized = true\n\n warnOnInvalidCustomViews(collection)\n\n // /////////////////////////////////\n // Make copy of collection config\n // /////////////////////////////////\n\n const sanitized: CollectionConfig = addDefaultsToCollectionConfig(collection)\n\n // /////////////////////////////////\n // Convert folders/tags to hierarchy\n // /////////////////////////////////\n\n const presetCount = [sanitized.folders, sanitized.tags, sanitized.hierarchy].filter(\n Boolean,\n ).length\n if (presetCount > 1) {\n throw new Error(\n `Collection \"${sanitized.slug}\": Only one of 'folders', 'tags', or 'hierarchy' can be specified`,\n )\n }\n\n if (sanitized.folders) {\n sanitized.labels = {\n plural: 'Folders',\n singular: 'Folder',\n ...sanitized.labels,\n }\n sanitized.hierarchy = buildFoldersHierarchy(sanitized.folders, sanitized.slug)\n // Set admin.group: false when sidebar tab enabled (folders accessed via tab)\n const sidebarTabEnabled =\n typeof sanitized.hierarchy === 'object' &&\n sanitized.hierarchy.admin?.injectSidebarTab !== false\n if (sidebarTabEnabled && sanitized.admin!.group === undefined) {\n sanitized.admin!.group = false\n }\n delete sanitized.folders\n }\n\n if (sanitized.tags) {\n sanitized.labels = {\n plural: 'Tags',\n singular: 'Tag',\n ...sanitized.labels,\n }\n sanitized.hierarchy = buildTagsHierarchy(sanitized.tags, sanitized.slug)\n // Tags also hidden from nav by default\n if (sanitized.admin!.group === undefined) {\n sanitized.admin!.group = false\n }\n delete sanitized.tags\n }\n\n // /////////////////////////////////\n // Sanitize fields\n // /////////////////////////////////\n\n const validRelationships = _validRelationships ?? config.collections!.map((c) => c.slug) ?? []\n\n const joins: SanitizedJoins = {}\n\n const polymorphicJoins: SanitizedJoin[] = []\n\n sanitized.fields = await sanitizeFields({\n collectionConfig: sanitized,\n config,\n fields: sanitized.fields,\n joinPath: '',\n joins,\n orderableJoins,\n parentIsLocalized: false,\n polymorphicJoins,\n richTextSanitizationPromises,\n validRelationships,\n })\n\n if (sanitized.endpoints !== false) {\n if (!sanitized.endpoints) {\n sanitized.endpoints = []\n }\n\n if (sanitized.auth) {\n for (const endpoint of authCollectionEndpoints) {\n sanitized.endpoints.push(endpoint)\n }\n }\n\n if (sanitized.upload) {\n for (const endpoint of uploadCollectionEndpoints) {\n sanitized.endpoints.push(endpoint)\n }\n }\n\n for (const endpoint of defaultCollectionEndpoints) {\n sanitized.endpoints.push(endpoint)\n }\n }\n\n if (sanitized.timestamps !== false) {\n // add default timestamps fields only as needed\n let hasUpdatedAt: boolean | null = null\n let hasCreatedAt: boolean | null = null\n let hasDeletedAt: boolean | null = null\n\n sanitized.fields.some((field) => {\n if (fieldAffectsData(field)) {\n if (field.name === 'updatedAt') {\n hasUpdatedAt = true\n }\n\n if (field.name === 'createdAt') {\n hasCreatedAt = true\n }\n\n if (field.name === 'deletedAt') {\n hasDeletedAt = true\n }\n }\n\n return hasCreatedAt && hasUpdatedAt && (!sanitized.trash || hasDeletedAt)\n })\n\n if (!hasUpdatedAt) {\n sanitized.fields.push({\n name: 'updatedAt',\n type: 'date',\n admin: {\n disabled: { bulkEdit: true },\n hidden: true,\n },\n index: true,\n label: ({ t }) => t('general:updatedAt'),\n })\n }\n\n if (!hasCreatedAt) {\n sanitized.fields.push({\n name: 'createdAt',\n admin: {\n disabled: { bulkEdit: true },\n hidden: true,\n },\n // The default sort for list view is createdAt. Thus, enabling indexing by default, is a major performance improvement, especially for large or a large amount of collections.\n type: 'date',\n index: true,\n label: ({ t }) => t('general:createdAt'),\n })\n }\n\n if (sanitized.trash && !hasDeletedAt) {\n sanitized.fields.push({\n name: 'deletedAt',\n type: 'date',\n admin: {\n disabled: { bulkEdit: true },\n hidden: true,\n },\n index: true,\n label: ({ t }) => t('general:deletedAt'),\n })\n }\n }\n\n const defaultLabels = formatLabels(sanitized.slug)\n\n sanitized.labels = {\n plural: sanitized.labels?.plural || defaultLabels.plural,\n singular: sanitized.labels?.singular || defaultLabels.singular,\n }\n\n if (sanitized.versions) {\n if (sanitized.timestamps === false) {\n throw new TimestampsRequired(collection)\n }\n\n if (sanitized.versions === true) {\n sanitized.versions = {\n drafts: false,\n maxPerDoc: 100,\n }\n }\n\n sanitized.versions.maxPerDoc =\n typeof sanitized.versions.maxPerDoc === 'number' ? sanitized.versions.maxPerDoc : 100\n\n if (sanitized.versions.drafts) {\n if (sanitized.versions.drafts === true) {\n sanitized.versions.drafts = {\n autosave: false,\n validate: false,\n }\n }\n\n const hasLocalizedFields = traverseForLocalizedFields(sanitized.fields)\n\n if (config.localization) {\n if (hasLocalizedFields && sanitized.versions.drafts.localizeStatus === undefined) {\n sanitized.versions.drafts.localizeStatus = false\n }\n }\n\n // TODO v4: remove this sanitization check, should not need to enable the experimental flag\n if (sanitized.versions.drafts.localizeStatus && !config.experimental?.localizeStatus) {\n sanitized.versions.drafts.localizeStatus = false\n console.log(\n miniChalk.yellowBold(\n `Warning: \"localizeStatus\" for drafts is an experimental feature. To enable, set \"experimental.localizeStatus\" to true in your Payload config.`,\n ),\n )\n }\n\n if (sanitized.versions.drafts.autosave === true) {\n sanitized.versions.drafts.autosave = {\n interval: versionDefaults.autosaveInterval,\n }\n }\n\n if (sanitized.versions.drafts.validate === undefined) {\n sanitized.versions.drafts.validate = false\n }\n\n sanitized.fields = mergeBaseFields(\n sanitized.fields,\n baseVersionFields({\n localized: sanitized.versions.drafts.localizeStatus ?? false,\n }),\n )\n }\n } else {\n delete sanitized.versions\n }\n\n // Sanitize hierarchy configuration (phase 1 - per collection)\n sanitizeHierarchyCollection(sanitized, config)\n\n if (sanitized.upload) {\n if (sanitized.upload === true) {\n sanitized.upload = {}\n }\n\n sanitized.upload.cacheTags = sanitized.upload?.cacheTags ?? true\n sanitized.upload.bulkUpload = sanitized.upload?.bulkUpload ?? true\n sanitized.upload.staticDir = sanitized.upload.staticDir || sanitized.slug\n sanitized.admin!.useAsTitle =\n sanitized.admin?.useAsTitle && sanitized.admin.useAsTitle !== 'id'\n ? sanitized.admin.useAsTitle\n : 'filename'\n\n const uploadFields = getBaseUploadFields({\n collection: sanitized,\n config,\n })\n\n sanitized.fields = mergeBaseFields(sanitized.fields, uploadFields)\n }\n\n if (sanitized.auth) {\n sanitized.auth = addDefaultsToAuthConfig(\n typeof sanitized.auth === 'boolean' ? {} : sanitized.auth,\n )\n\n // disable duplicate for auth enabled collections by default\n sanitized.disableDuplicate = sanitized.disableDuplicate ?? true\n\n if (sanitized.auth.loginWithUsername) {\n if (sanitized.auth.loginWithUsername === true) {\n sanitized.auth.loginWithUsername = addDefaultsToLoginWithUsernameConfig({})\n } else {\n const loginWithUsernameWithDefaults = addDefaultsToLoginWithUsernameConfig(\n sanitized.auth.loginWithUsername,\n )\n\n // if allowEmailLogin is false, requireUsername must be true\n if (loginWithUsernameWithDefaults.allowEmailLogin === false) {\n loginWithUsernameWithDefaults.requireUsername = true\n }\n sanitized.auth.loginWithUsername = loginWithUsernameWithDefaults\n }\n } else {\n sanitized.auth.loginWithUsername = false\n }\n\n if (!collection?.admin?.useAsTitle) {\n sanitized.admin!.useAsTitle = sanitized.auth.loginWithUsername ? 'username' : 'email'\n }\n\n sanitized.fields = mergeBaseFields(sanitized.fields, getBaseAuthFields(sanitized.auth))\n }\n\n if (collection?.admin?.pagination?.limits?.length) {\n sanitized.admin!.pagination!.limits = collection.admin.pagination.limits\n }\n\n validateUseAsTitle(sanitized)\n\n const sanitizedConfig = sanitized as SanitizedCollectionConfig\n\n sanitizedConfig.joins = joins\n sanitizedConfig.polymorphicJoins = polymorphicJoins\n\n sanitizedConfig.flattenedFields = flattenAllFields({ fields: sanitizedConfig.fields })\n\n sanitizedConfig.sanitizedIndexes = sanitizeCompoundIndexes({\n fields: sanitizedConfig.flattenedFields,\n indexes: sanitizedConfig.indexes,\n })\n\n return sanitizedConfig\n}\n"],"names":["authCollectionEndpoints","getBaseAuthFields","TimestampsRequired","sanitizeFields","fieldAffectsData","mergeBaseFields","buildFoldersHierarchy","buildTagsHierarchy","sanitizeHierarchyCollection","uploadCollectionEndpoints","getBaseUploadFields","flattenAllFields","formatLabels","miniChalk","traverseForLocalizedFields","baseVersionFields","versionDefaults","defaultCollectionEndpoints","addDefaultsToAuthConfig","addDefaultsToCollectionConfig","addDefaultsToLoginWithUsernameConfig","sanitizeCompoundIndexes","validateUseAsTitle","warnOnInvalidCustomViews","collection","views","admin","components","key","view","Object","entries","console","warn","slug","sanitizeCollection","config","richTextSanitizationPromises","_validRelationships","orderableJoins","_sanitized","sanitized","presetCount","folders","tags","hierarchy","filter","Boolean","length","Error","labels","plural","singular","sidebarTabEnabled","injectSidebarTab","group","undefined","validRelationships","collections","map","c","joins","polymorphicJoins","fields","collectionConfig","joinPath","parentIsLocalized","endpoints","auth","endpoint","push","upload","timestamps","hasUpdatedAt","hasCreatedAt","hasDeletedAt","some","field","name","trash","type","disabled","bulkEdit","hidden","index","label","t","defaultLabels","versions","drafts","maxPerDoc","autosave","validate","hasLocalizedFields","localization","localizeStatus","experimental","log","yellowBold","interval","autosaveInterval","localized","cacheTags","bulkUpload","staticDir","useAsTitle","uploadFields","disableDuplicate","loginWithUsername","loginWithUsernameWithDefaults","allowEmailLogin","requireUsername","pagination","limits","sanitizedConfig","flattenedFields","sanitizedIndexes","indexes"],"mappings":"AASA,SAASA,uBAAuB,QAAQ,gCAA+B;AACvE,SAASC,iBAAiB,QAAQ,8BAA6B;AAC/D,SAASC,kBAAkB,QAAQ,qCAAoC;AACvE,SAASC,cAAc,QAAQ,kCAAiC;AAChE,SAASC,gBAAgB,QAAQ,+BAA8B;AAC/D,SAASC,eAAe,QAAQ,kCAAiC;AACjE,SAASC,qBAAqB,EAAEC,kBAAkB,QAAQ,6BAA4B;AACtF,SAASC,2BAA2B,QAAQ,iDAAgD;AAC5F,SAASC,yBAAyB,QAAQ,mCAAkC;AAC5E,SAASC,mBAAmB,QAAQ,iCAAgC;AACpE,SAASC,gBAAgB,QAAQ,sCAAqC;AACtE,SAASC,YAAY,QAAQ,kCAAiC;AAC9D,SAASC,SAAS,QAAQ,+BAA8B;AACxD,SAASC,0BAA0B,QAAQ,gDAA+C;AAC1F,SAASC,iBAAiB,QAAQ,+BAA8B;AAChE,SAASC,eAAe,QAAQ,6BAA4B;AAC5D,SAASC,0BAA0B,QAAQ,wBAAuB;AAClE,SACEC,uBAAuB,EACvBC,6BAA6B,EAC7BC,oCAAoC,QAC/B,gBAAe;AACtB,SAASC,uBAAuB,QAAQ,+BAA8B;AACtE,SAASC,kBAAkB,QAAQ,kBAAiB;AAEpD;;;CAGC,GACD,OAAO,MAAMC,2BAA2B,CAACC;IACvC,MAAMC,QAAQD,WAAWE,KAAK,EAAEC,YAAYF;IAC5C,IAAI,CAACA,SAAS,OAAOA,UAAU,UAAU;QACvC;IACF;IAEA,KAAK,MAAM,CAACG,KAAKC,KAAK,IAAIC,OAAOC,OAAO,CAACN,OAAQ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rD,KAAK,GAAGA;IACxBqD,gBAAgBpD,gBAAgB,GAAGA;IAEnCoD,gBAAgBC,eAAe,GAAGxG,iBAAiB;QAAEoD,QAAQmD,gBAAgBnD,MAAM;IAAC;IAEpFmD,gBAAgBE,gBAAgB,GAAG/F,wBAAwB;QACzD0C,QAAQmD,gBAAgBC,eAAe;QACvCE,SAASH,gBAAgBG,OAAO;IAClC;IAEA,OAAOH;AACT,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../src/config/sanitize.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,MAAM,EAGN,eAAe,EAIhB,MAAM,YAAY,CAAA;AAoGnB,eAAO,MAAM,cAAc,mBAA0B,MAAM,KAAG,OAAO,CAAC,eAAe,CA4ZpF,CAAA"}
1
+ {"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../src/config/sanitize.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,MAAM,EAGN,eAAe,EAIhB,MAAM,YAAY,CAAA;AAmGnB,eAAO,MAAM,cAAc,mBAA0B,MAAM,KAAG,OAAO,CAAC,eAAe,CAwYpF,CAAA"}