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.
- package/dist/collections/config/sanitize.d.ts.map +1 -1
- package/dist/collections/config/sanitize.js +222 -228
- package/dist/collections/config/sanitize.js.map +1 -1
- package/dist/config/sanitize.d.ts.map +1 -1
- package/dist/config/sanitize.js +233 -254
- package/dist/config/sanitize.js.map +1 -1
- package/dist/exports/internal.d.ts +0 -1
- package/dist/exports/internal.d.ts.map +1 -1
- package/dist/exports/internal.js +0 -1
- package/dist/exports/internal.js.map +1 -1
- package/dist/fields/config/sanitize.d.ts.map +1 -1
- package/dist/fields/config/sanitize.js +323 -334
- package/dist/fields/config/sanitize.js.map +1 -1
- package/dist/globals/config/sanitize.d.ts.map +1 -1
- package/dist/globals/config/sanitize.js +125 -131
- package/dist/globals/config/sanitize.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -19
- package/dist/index.js.map +1 -1
- package/dist/utilities/flattenAllFields.d.ts.map +1 -1
- package/dist/utilities/flattenAllFields.js +93 -102
- package/dist/utilities/flattenAllFields.js.map +1 -1
- package/package.json +2 -2
- package/dist/utilities/sanitizeProfiler.d.ts +0 -38
- package/dist/utilities/sanitizeProfiler.d.ts.map +0 -1
- package/dist/utilities/sanitizeProfiler.js +0 -101
- package/dist/utilities/sanitizeProfiler.js.map +0 -1
package/dist/config/sanitize.js
CHANGED
|
@@ -16,7 +16,6 @@ import { getDefaultJobsCollection, jobsCollectionSlug } from '../queues/config/c
|
|
|
16
16
|
import { getJobStatsGlobal } from '../queues/config/global.js';
|
|
17
17
|
import { flattenAllFields, flattenBlock } from '../utilities/flattenAllFields.js';
|
|
18
18
|
import { hasScheduledPublishEnabled } from '../utilities/getVersionsConfig.js';
|
|
19
|
-
import { endSpan, startSpan } from '../utilities/sanitizeProfiler.js';
|
|
20
19
|
import { validateTimezones } from '../utilities/validateTimezones.js';
|
|
21
20
|
import { getSchedulePublishTask } from '../versions/schedule/job.js';
|
|
22
21
|
import { addDefaultsToConfig } from './defaults.js';
|
|
@@ -85,283 +84,263 @@ const sanitizeAdminConfig = (configToSanitize)=>{
|
|
|
85
84
|
return sanitizedConfig;
|
|
86
85
|
};
|
|
87
86
|
export const sanitizeConfig = async (incomingConfig)=>{
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
toString: ()=>locale.code
|
|
118
|
-
}));
|
|
119
|
-
}
|
|
120
|
-
// Default fallback to true if not provided
|
|
121
|
-
config.localization.fallback = config.localization?.fallback ?? true;
|
|
122
|
-
}
|
|
123
|
-
const i18nConfig = {
|
|
124
|
-
fallbackLanguage: 'en',
|
|
125
|
-
supportedLanguages: {
|
|
126
|
-
en
|
|
127
|
-
},
|
|
128
|
-
translations: {}
|
|
129
|
-
};
|
|
130
|
-
if (incomingConfig?.i18n) {
|
|
131
|
-
i18nConfig.supportedLanguages = incomingConfig.i18n?.supportedLanguages || i18nConfig.supportedLanguages;
|
|
132
|
-
const supportedLangKeys = Object.keys(i18nConfig.supportedLanguages);
|
|
133
|
-
const fallbackLang = incomingConfig.i18n?.fallbackLanguage || i18nConfig.fallbackLanguage;
|
|
134
|
-
i18nConfig.fallbackLanguage = supportedLangKeys.includes(fallbackLang) ? fallbackLang : supportedLangKeys[0];
|
|
135
|
-
i18nConfig.translations = incomingConfig.i18n?.translations || i18nConfig.translations;
|
|
87
|
+
const configWithDefaults = addDefaultsToConfig(incomingConfig);
|
|
88
|
+
const config = sanitizeAdminConfig(configWithDefaults);
|
|
89
|
+
if (!config.endpoints) {
|
|
90
|
+
config.endpoints = [];
|
|
91
|
+
}
|
|
92
|
+
for (const endpoint of authRootEndpoints){
|
|
93
|
+
config.endpoints.push(endpoint);
|
|
94
|
+
}
|
|
95
|
+
if (config.localization && config.localization.locales?.length > 0) {
|
|
96
|
+
// clone localization config so to not break everything
|
|
97
|
+
const firstLocale = config.localization.locales[0];
|
|
98
|
+
if (typeof firstLocale === 'string') {
|
|
99
|
+
config.localization.localeCodes = [
|
|
100
|
+
...config.localization.locales
|
|
101
|
+
];
|
|
102
|
+
// is string[], so convert to Locale[]
|
|
103
|
+
config.localization.locales = config.localization.locales.map((locale)=>({
|
|
104
|
+
code: locale,
|
|
105
|
+
label: locale,
|
|
106
|
+
rtl: false,
|
|
107
|
+
toString: ()=>locale
|
|
108
|
+
}));
|
|
109
|
+
} else {
|
|
110
|
+
// is Locale[], so convert to string[] for localeCodes
|
|
111
|
+
config.localization.localeCodes = config.localization.locales.map((locale)=>locale.code);
|
|
112
|
+
config.localization.locales = config.localization.locales.map((locale)=>({
|
|
113
|
+
...locale,
|
|
114
|
+
toString: ()=>locale.code
|
|
115
|
+
}));
|
|
136
116
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
117
|
+
// Default fallback to true if not provided
|
|
118
|
+
config.localization.fallback = config.localization?.fallback ?? true;
|
|
119
|
+
}
|
|
120
|
+
const i18nConfig = {
|
|
121
|
+
fallbackLanguage: 'en',
|
|
122
|
+
supportedLanguages: {
|
|
123
|
+
en
|
|
124
|
+
},
|
|
125
|
+
translations: {}
|
|
126
|
+
};
|
|
127
|
+
if (incomingConfig?.i18n) {
|
|
128
|
+
i18nConfig.supportedLanguages = incomingConfig.i18n?.supportedLanguages || i18nConfig.supportedLanguages;
|
|
129
|
+
const supportedLangKeys = Object.keys(i18nConfig.supportedLanguages);
|
|
130
|
+
const fallbackLang = incomingConfig.i18n?.fallbackLanguage || i18nConfig.fallbackLanguage;
|
|
131
|
+
i18nConfig.fallbackLanguage = supportedLangKeys.includes(fallbackLang) ? fallbackLang : supportedLangKeys[0];
|
|
132
|
+
i18nConfig.translations = incomingConfig.i18n?.translations || i18nConfig.translations;
|
|
133
|
+
}
|
|
134
|
+
config.i18n = i18nConfig;
|
|
135
|
+
const richTextSanitizationPromises = [];
|
|
136
|
+
const schedulePublishCollections = [];
|
|
137
|
+
const queryPresetsCollections = [];
|
|
138
|
+
const schedulePublishGlobals = [];
|
|
139
|
+
const collectionSlugs = new Set();
|
|
140
|
+
const validRelationships = [
|
|
141
|
+
...config.collections?.map((c)=>c.slug) ?? [],
|
|
142
|
+
jobsCollectionSlug,
|
|
143
|
+
lockedDocumentsCollectionSlug,
|
|
144
|
+
preferencesCollectionSlug
|
|
145
|
+
];
|
|
146
|
+
const dashboardWidgets = config.admin?.dashboard?.widgets ?? [];
|
|
147
|
+
for (const widget of dashboardWidgets){
|
|
148
|
+
if (widget.fields?.length) {
|
|
149
|
+
widget.fields = await sanitizeFields({
|
|
150
|
+
config: config,
|
|
151
|
+
existingFieldNames: new Set(),
|
|
152
|
+
fields: widget.fields,
|
|
153
|
+
parentIsLocalized: false,
|
|
154
|
+
richTextSanitizationPromises,
|
|
155
|
+
validRelationships
|
|
156
|
+
});
|
|
161
157
|
}
|
|
162
|
-
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
163
160
|
* Blocks sanitization needs to happen before collections, as collection/global join field sanitization needs config.blocks
|
|
164
161
|
* to be populated with the sanitized blocks
|
|
165
162
|
*/ config.blocks = [];
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
172
|
-
sanitizedBlock._sanitized = true;
|
|
173
|
-
sanitizedBlock.fields = sanitizedBlock.fields.concat(baseBlockFields);
|
|
174
|
-
sanitizedBlock.labels = !sanitizedBlock.labels ? formatLabels(sanitizedBlock.slug) : sanitizedBlock.labels;
|
|
175
|
-
sanitizedBlock.fields = await sanitizeFields({
|
|
176
|
-
config: config,
|
|
177
|
-
existingFieldNames: new Set(),
|
|
178
|
-
fields: sanitizedBlock.fields,
|
|
179
|
-
parentIsLocalized: false,
|
|
180
|
-
richTextSanitizationPromises,
|
|
181
|
-
validRelationships
|
|
182
|
-
});
|
|
183
|
-
const flattenedSanitizedBlock = flattenBlock({
|
|
184
|
-
block
|
|
185
|
-
});
|
|
186
|
-
config.blocks.push(flattenedSanitizedBlock);
|
|
163
|
+
if (incomingConfig.blocks?.length) {
|
|
164
|
+
for (const block of incomingConfig.blocks){
|
|
165
|
+
const sanitizedBlock = block;
|
|
166
|
+
if (sanitizedBlock._sanitized === true) {
|
|
167
|
+
continue;
|
|
187
168
|
}
|
|
169
|
+
sanitizedBlock._sanitized = true;
|
|
170
|
+
sanitizedBlock.fields = sanitizedBlock.fields.concat(baseBlockFields);
|
|
171
|
+
sanitizedBlock.labels = !sanitizedBlock.labels ? formatLabels(sanitizedBlock.slug) : sanitizedBlock.labels;
|
|
172
|
+
sanitizedBlock.fields = await sanitizeFields({
|
|
173
|
+
config: config,
|
|
174
|
+
existingFieldNames: new Set(),
|
|
175
|
+
fields: sanitizedBlock.fields,
|
|
176
|
+
parentIsLocalized: false,
|
|
177
|
+
richTextSanitizationPromises,
|
|
178
|
+
validRelationships
|
|
179
|
+
});
|
|
180
|
+
const flattenedSanitizedBlock = flattenBlock({
|
|
181
|
+
block
|
|
182
|
+
});
|
|
183
|
+
config.blocks.push(flattenedSanitizedBlock);
|
|
188
184
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
collectionSlugs.add(config.collections[i].slug);
|
|
196
|
-
const draftsConfig = config.collections[i]?.versions?.drafts;
|
|
197
|
-
if (typeof draftsConfig === 'object' && draftsConfig.schedulePublish) {
|
|
198
|
-
schedulePublishCollections.push(config.collections[i].slug);
|
|
199
|
-
}
|
|
200
|
-
if (config.collections[i].enableQueryPresets) {
|
|
201
|
-
queryPresetsCollections.push(config.collections[i].slug);
|
|
202
|
-
if (!validRelationships.includes(queryPresetsCollectionSlug)) {
|
|
203
|
-
validRelationships.push(queryPresetsCollectionSlug);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
config.collections[i] = await sanitizeCollection(config, config.collections[i], richTextSanitizationPromises, validRelationships, orderableJoins);
|
|
185
|
+
}
|
|
186
|
+
// Track orderable join fields during sanitization
|
|
187
|
+
const orderableJoins = [];
|
|
188
|
+
for(let i = 0; i < config.collections.length; i++){
|
|
189
|
+
if (collectionSlugs.has(config.collections[i].slug)) {
|
|
190
|
+
throw new DuplicateCollection('slug', config.collections[i].slug);
|
|
207
191
|
}
|
|
208
|
-
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
for (const collection of config.collections){
|
|
213
|
-
if (collection.orderable) {
|
|
214
|
-
const currentFields = fieldsToAdd.get(collection) || [];
|
|
215
|
-
fieldsToAdd.set(collection, [
|
|
216
|
-
...currentFields,
|
|
217
|
-
'_order'
|
|
218
|
-
]);
|
|
219
|
-
collection.defaultSort = collection.defaultSort ?? '_order';
|
|
220
|
-
}
|
|
192
|
+
collectionSlugs.add(config.collections[i].slug);
|
|
193
|
+
const draftsConfig = config.collections[i]?.versions?.drafts;
|
|
194
|
+
if (typeof draftsConfig === 'object' && draftsConfig.schedulePublish) {
|
|
195
|
+
schedulePublishCollections.push(config.collections[i].slug);
|
|
221
196
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
const currentFields = fieldsToAdd.get(targetCollection) || [];
|
|
227
|
-
fieldsToAdd.set(targetCollection, [
|
|
228
|
-
...currentFields,
|
|
229
|
-
joinInfo.orderFieldName
|
|
230
|
-
]);
|
|
231
|
-
const currentJoinFieldPaths = joinFieldPathsByCollection.get(targetCollection.slug) || new Map();
|
|
232
|
-
currentJoinFieldPaths.set(joinInfo.orderFieldName, joinInfo.joinFieldOn);
|
|
233
|
-
joinFieldPathsByCollection.set(targetCollection.slug, currentJoinFieldPaths);
|
|
197
|
+
if (config.collections[i].enableQueryPresets) {
|
|
198
|
+
queryPresetsCollections.push(config.collections[i].slug);
|
|
199
|
+
if (!validRelationships.includes(queryPresetsCollectionSlug)) {
|
|
200
|
+
validRelationships.push(queryPresetsCollectionSlug);
|
|
234
201
|
}
|
|
235
202
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
203
|
+
config.collections[i] = await sanitizeCollection(config, config.collections[i], richTextSanitizationPromises, validRelationships, orderableJoins);
|
|
204
|
+
}
|
|
205
|
+
// Process orderable features after all collections are sanitized
|
|
206
|
+
const fieldsToAdd = new Map();
|
|
207
|
+
const joinFieldPathsByCollection = new Map();
|
|
208
|
+
// Handle collection.orderable
|
|
209
|
+
for (const collection of config.collections){
|
|
210
|
+
if (collection.orderable) {
|
|
211
|
+
const currentFields = fieldsToAdd.get(collection) || [];
|
|
212
|
+
fieldsToAdd.set(collection, [
|
|
213
|
+
...currentFields,
|
|
214
|
+
'_order'
|
|
215
|
+
]);
|
|
216
|
+
collection.defaultSort = collection.defaultSort ?? '_order';
|
|
243
217
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
218
|
+
}
|
|
219
|
+
// Handle orderable join fields (tracked during sanitization)
|
|
220
|
+
for (const joinInfo of orderableJoins){
|
|
221
|
+
const targetCollection = config.collections.find((c)=>c.slug === joinInfo.targetCollectionSlug);
|
|
222
|
+
if (targetCollection) {
|
|
223
|
+
const currentFields = fieldsToAdd.get(targetCollection) || [];
|
|
224
|
+
fieldsToAdd.set(targetCollection, [
|
|
225
|
+
...currentFields,
|
|
226
|
+
joinInfo.orderFieldName
|
|
227
|
+
]);
|
|
228
|
+
const currentJoinFieldPaths = joinFieldPathsByCollection.get(targetCollection.slug) || new Map();
|
|
229
|
+
currentJoinFieldPaths.set(joinInfo.orderFieldName, joinInfo.joinFieldOn);
|
|
230
|
+
joinFieldPathsByCollection.set(targetCollection.slug, currentJoinFieldPaths);
|
|
247
231
|
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
232
|
+
}
|
|
233
|
+
// Add fields, hooks, and update flattenedFields
|
|
234
|
+
for (const [collection, orderableFields] of fieldsToAdd){
|
|
235
|
+
await addOrderableFieldsAndHook(collection, config, orderableFields, joinFieldPathsByCollection);
|
|
236
|
+
// Regenerate flattenedFields since we added new fields
|
|
237
|
+
collection.flattenedFields = flattenAllFields({
|
|
238
|
+
fields: collection.fields
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
// Add endpoint if any orderable features exist
|
|
242
|
+
if (fieldsToAdd.size > 0) {
|
|
243
|
+
addOrderableEndpoint(config, joinFieldPathsByCollection);
|
|
244
|
+
}
|
|
245
|
+
if (config.globals.length > 0) {
|
|
246
|
+
for(let i = 0; i < config.globals.length; i++){
|
|
247
|
+
if (hasScheduledPublishEnabled(config.globals[i])) {
|
|
248
|
+
schedulePublishGlobals.push(config.globals[i].slug);
|
|
254
249
|
}
|
|
250
|
+
config.globals[i] = await sanitizeGlobal(config, config.globals[i], richTextSanitizationPromises, validRelationships);
|
|
255
251
|
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
} finally{
|
|
261
|
-
endSpan(__hierSpan);
|
|
262
|
-
}
|
|
263
|
-
if (schedulePublishCollections.length || schedulePublishGlobals.length) {
|
|
264
|
-
;
|
|
265
|
-
((config.jobs ??= {}).tasks ??= []).push(getSchedulePublishTask({
|
|
266
|
-
adminUserSlug: config.admin.user,
|
|
267
|
-
collections: schedulePublishCollections,
|
|
268
|
-
globals: schedulePublishGlobals
|
|
269
|
-
}));
|
|
270
|
-
}
|
|
252
|
+
}
|
|
253
|
+
// Resolve hierarchy relationships across collections (also adds sidebar tabs)
|
|
254
|
+
resolveHierarchyCollections(config);
|
|
255
|
+
if (schedulePublishCollections.length || schedulePublishGlobals.length) {
|
|
271
256
|
;
|
|
272
|
-
(config.jobs ??= {}).
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
const sanitizedJobsCollection = await sanitizeCollection(config, defaultJobsCollection, richTextSanitizationPromises, validRelationships);
|
|
289
|
-
(config.collections ??= []).push(sanitizedJobsCollection);
|
|
290
|
-
}
|
|
291
|
-
const lockedDocumentsCollection = getLockedDocumentsCollection(config);
|
|
292
|
-
if (lockedDocumentsCollection) {
|
|
293
|
-
configWithDefaults.collections.push(await sanitizeCollection(config, lockedDocumentsCollection, richTextSanitizationPromises, validRelationships));
|
|
294
|
-
}
|
|
295
|
-
configWithDefaults.collections.push(await sanitizeCollection(config, getPreferencesCollection(config), richTextSanitizationPromises, validRelationships));
|
|
296
|
-
const migrations = await sanitizeCollection(config, migrationsCollection, richTextSanitizationPromises, validRelationships);
|
|
297
|
-
// @ts-expect-error indexSortableFields is only valid for @payloadcms/db-mongodb
|
|
298
|
-
if (config?.db?.indexSortableFields) {
|
|
299
|
-
migrations.indexes = [
|
|
300
|
-
{
|
|
301
|
-
fields: [
|
|
302
|
-
'batch',
|
|
303
|
-
'name'
|
|
304
|
-
],
|
|
305
|
-
unique: false
|
|
306
|
-
}
|
|
307
|
-
];
|
|
308
|
-
}
|
|
309
|
-
configWithDefaults.collections.push(migrations);
|
|
310
|
-
if (queryPresetsCollections.length > 0) {
|
|
311
|
-
configWithDefaults.collections.push(await sanitizeCollection(config, getQueryPresetsConfig(config), richTextSanitizationPromises, validRelationships));
|
|
257
|
+
((config.jobs ??= {}).tasks ??= []).push(getSchedulePublishTask({
|
|
258
|
+
adminUserSlug: config.admin.user,
|
|
259
|
+
collections: schedulePublishCollections,
|
|
260
|
+
globals: schedulePublishGlobals
|
|
261
|
+
}));
|
|
262
|
+
}
|
|
263
|
+
;
|
|
264
|
+
(config.jobs ??= {}).enabled = Boolean(Array.isArray(configWithDefaults.jobs?.tasks) && configWithDefaults.jobs?.tasks?.length || Array.isArray(configWithDefaults.jobs?.workflows) && configWithDefaults.jobs?.workflows?.length);
|
|
265
|
+
// Need to add default jobs collection before locked documents collections
|
|
266
|
+
if (config.jobs.enabled) {
|
|
267
|
+
// Check for schedule property in both tasks and workflows
|
|
268
|
+
const hasScheduleProperty = config?.jobs?.tasks?.length && config.jobs.tasks.some((task)=>task.schedule) || config?.jobs?.workflows?.length && config.jobs.workflows.some((workflow)=>workflow.schedule);
|
|
269
|
+
if (hasScheduleProperty) {
|
|
270
|
+
config.jobs.scheduling = true;
|
|
271
|
+
(config.globals ??= []).push(await sanitizeGlobal(config, getJobStatsGlobal(config), richTextSanitizationPromises, validRelationships));
|
|
272
|
+
config.jobs.stats = true;
|
|
312
273
|
}
|
|
313
|
-
|
|
314
|
-
|
|
274
|
+
let defaultJobsCollection = getDefaultJobsCollection(config.jobs);
|
|
275
|
+
if (typeof config.jobs.jobsCollectionOverrides === 'function') {
|
|
276
|
+
defaultJobsCollection = config.jobs.jobsCollectionOverrides({
|
|
277
|
+
defaultJobsCollection
|
|
278
|
+
});
|
|
315
279
|
}
|
|
316
|
-
const
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
280
|
+
const sanitizedJobsCollection = await sanitizeCollection(config, defaultJobsCollection, richTextSanitizationPromises, validRelationships);
|
|
281
|
+
(config.collections ??= []).push(sanitizedJobsCollection);
|
|
282
|
+
}
|
|
283
|
+
const lockedDocumentsCollection = getLockedDocumentsCollection(config);
|
|
284
|
+
if (lockedDocumentsCollection) {
|
|
285
|
+
configWithDefaults.collections.push(await sanitizeCollection(config, lockedDocumentsCollection, richTextSanitizationPromises, validRelationships));
|
|
286
|
+
}
|
|
287
|
+
configWithDefaults.collections.push(await sanitizeCollection(config, getPreferencesCollection(config), richTextSanitizationPromises, validRelationships));
|
|
288
|
+
const migrations = await sanitizeCollection(config, migrationsCollection, richTextSanitizationPromises, validRelationships);
|
|
289
|
+
// @ts-expect-error indexSortableFields is only valid for @payloadcms/db-mongodb
|
|
290
|
+
if (config?.db?.indexSortableFields) {
|
|
291
|
+
migrations.indexes = [
|
|
292
|
+
{
|
|
293
|
+
fields: [
|
|
294
|
+
'batch',
|
|
295
|
+
'name'
|
|
296
|
+
],
|
|
297
|
+
unique: false
|
|
322
298
|
}
|
|
299
|
+
];
|
|
300
|
+
}
|
|
301
|
+
configWithDefaults.collections.push(migrations);
|
|
302
|
+
if (queryPresetsCollections.length > 0) {
|
|
303
|
+
configWithDefaults.collections.push(await sanitizeCollection(config, getQueryPresetsConfig(config), richTextSanitizationPromises, validRelationships));
|
|
304
|
+
}
|
|
305
|
+
if (config.serverURL !== '') {
|
|
306
|
+
config.csrf.push(config.serverURL);
|
|
307
|
+
}
|
|
308
|
+
const uploadAdapters = new Set();
|
|
309
|
+
// interact with all collections
|
|
310
|
+
for (const collection of config.collections){
|
|
311
|
+
// deduped upload adapters
|
|
312
|
+
if (collection.upload?.adapter) {
|
|
313
|
+
uploadAdapters.add(collection.upload.adapter);
|
|
323
314
|
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
315
|
+
}
|
|
316
|
+
if (!config.upload) {
|
|
317
|
+
config.upload = {
|
|
318
|
+
adapters: []
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
config.upload.adapters = Array.from(new Set(config.collections.map((c)=>c.upload?.adapter).filter(Boolean)));
|
|
322
|
+
// Pass through the email config as is so adapters don't break
|
|
323
|
+
if (incomingConfig.email) {
|
|
324
|
+
config.email = incomingConfig.email;
|
|
325
|
+
}
|
|
326
|
+
/*
|
|
335
327
|
Execute richText sanitization
|
|
336
328
|
*/ if (typeof incomingConfig.editor === 'function') {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
if (config.editor.i18n && Object.keys(config.editor.i18n).length >= 0) {
|
|
345
|
-
config.i18n.translations = deepMergeSimple(config.i18n.translations, config.editor.i18n);
|
|
346
|
-
}
|
|
347
|
-
} finally{
|
|
348
|
-
endSpan(__editorSpan);
|
|
349
|
-
}
|
|
329
|
+
config.editor = await incomingConfig.editor({
|
|
330
|
+
config: config,
|
|
331
|
+
isRoot: true,
|
|
332
|
+
parentIsLocalized: false
|
|
333
|
+
});
|
|
334
|
+
if (config.editor.i18n && Object.keys(config.editor.i18n).length >= 0) {
|
|
335
|
+
config.i18n.translations = deepMergeSimple(config.i18n.translations, config.editor.i18n);
|
|
350
336
|
}
|
|
351
|
-
const promises = [];
|
|
352
|
-
for (const sanitizeFunction of richTextSanitizationPromises){
|
|
353
|
-
promises.push(sanitizeFunction(config));
|
|
354
|
-
}
|
|
355
|
-
const __richtextSpan = startSpan('richTextDeferredBatch', String(promises.length));
|
|
356
|
-
try {
|
|
357
|
-
await Promise.all(promises);
|
|
358
|
-
} finally{
|
|
359
|
-
endSpan(__richtextSpan);
|
|
360
|
-
}
|
|
361
|
-
return config;
|
|
362
|
-
} finally{
|
|
363
|
-
endSpan(__profSpan);
|
|
364
337
|
}
|
|
338
|
+
const promises = [];
|
|
339
|
+
for (const sanitizeFunction of richTextSanitizationPromises){
|
|
340
|
+
promises.push(sanitizeFunction(config));
|
|
341
|
+
}
|
|
342
|
+
await Promise.all(promises);
|
|
343
|
+
return config;
|
|
365
344
|
};
|
|
366
345
|
|
|
367
346
|
//# sourceMappingURL=sanitize.js.map
|