payload 3.84.0 → 4.0.0-internal.38b7f1d
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/admin/elements/Nav.d.ts +13 -0
- package/dist/admin/elements/Nav.d.ts.map +1 -1
- package/dist/admin/elements/Nav.js.map +1 -1
- package/dist/admin/functions/index.d.ts +1 -38
- package/dist/admin/functions/index.d.ts.map +1 -1
- package/dist/admin/functions/index.js.map +1 -1
- package/dist/admin/types.d.ts +5 -4
- package/dist/admin/types.d.ts.map +1 -1
- package/dist/admin/types.js.map +1 -1
- package/dist/admin/views/hierarchyList.d.ts +9 -0
- package/dist/admin/views/hierarchyList.d.ts.map +1 -0
- package/dist/admin/views/hierarchyList.js +3 -0
- package/dist/admin/views/hierarchyList.js.map +1 -0
- package/dist/admin/views/index.d.ts +1 -3
- package/dist/admin/views/index.d.ts.map +1 -1
- package/dist/admin/views/index.js.map +1 -1
- package/dist/admin/views/list.d.ts +43 -2
- package/dist/admin/views/list.d.ts.map +1 -1
- package/dist/admin/views/list.js.map +1 -1
- package/dist/bin/generateImportMap/iterateCollections.d.ts.map +1 -1
- package/dist/bin/generateImportMap/iterateCollections.js +1 -0
- package/dist/bin/generateImportMap/iterateCollections.js.map +1 -1
- package/dist/bin/generateImportMap/iterateConfig.d.ts.map +1 -1
- package/dist/bin/generateImportMap/iterateConfig.js +7 -0
- package/dist/bin/generateImportMap/iterateConfig.js.map +1 -1
- package/dist/bin/generateImportMap/iterateGlobals.d.ts.map +1 -1
- package/dist/bin/generateImportMap/iterateGlobals.js +20 -8
- package/dist/bin/generateImportMap/iterateGlobals.js.map +1 -1
- package/dist/bin/index.d.ts.map +1 -1
- package/dist/bin/index.js +1 -3
- package/dist/bin/index.js.map +1 -1
- package/dist/collections/config/client.d.ts +4 -2
- package/dist/collections/config/client.d.ts.map +1 -1
- package/dist/collections/config/client.js +13 -1
- package/dist/collections/config/client.js.map +1 -1
- package/dist/collections/config/defaults.js +1 -1
- package/dist/collections/config/defaults.js.map +1 -1
- package/dist/collections/config/sanitize.d.ts.map +1 -1
- package/dist/collections/config/sanitize.js +51 -10
- package/dist/collections/config/sanitize.js.map +1 -1
- package/dist/collections/config/types.d.ts +76 -91
- package/dist/collections/config/types.d.ts.map +1 -1
- package/dist/collections/config/types.js.map +1 -1
- package/dist/collections/operations/create.d.ts.map +1 -1
- package/dist/collections/operations/create.js +24 -19
- package/dist/collections/operations/create.js.map +1 -1
- package/dist/collections/operations/delete.d.ts.map +1 -1
- package/dist/collections/operations/delete.js +7 -2
- package/dist/collections/operations/delete.js.map +1 -1
- package/dist/collections/operations/deleteByID.d.ts.map +1 -1
- package/dist/collections/operations/deleteByID.js +7 -2
- package/dist/collections/operations/deleteByID.js.map +1 -1
- package/dist/collections/operations/find.d.ts.map +1 -1
- package/dist/collections/operations/find.js +7 -2
- package/dist/collections/operations/find.js.map +1 -1
- package/dist/collections/operations/findByID.d.ts.map +1 -1
- package/dist/collections/operations/findByID.js +10 -5
- package/dist/collections/operations/findByID.js.map +1 -1
- package/dist/collections/operations/findVersionByID.d.ts.map +1 -1
- package/dist/collections/operations/findVersionByID.js +6 -4
- package/dist/collections/operations/findVersionByID.js.map +1 -1
- package/dist/collections/operations/findVersions.d.ts.map +1 -1
- package/dist/collections/operations/findVersions.js +6 -4
- package/dist/collections/operations/findVersions.js.map +1 -1
- package/dist/collections/operations/restoreVersion.d.ts.map +1 -1
- package/dist/collections/operations/restoreVersion.js +7 -2
- package/dist/collections/operations/restoreVersion.js.map +1 -1
- package/dist/collections/operations/update.d.ts.map +1 -1
- package/dist/collections/operations/update.js +7 -2
- package/dist/collections/operations/update.js.map +1 -1
- package/dist/collections/operations/updateByID.d.ts.map +1 -1
- package/dist/collections/operations/updateByID.js +7 -2
- package/dist/collections/operations/updateByID.js.map +1 -1
- package/dist/collections/operations/utilities/update.d.ts.map +1 -1
- package/dist/collections/operations/utilities/update.js +5 -4
- package/dist/collections/operations/utilities/update.js.map +1 -1
- package/dist/config/client.d.ts.map +1 -1
- package/dist/config/client.js +0 -10
- package/dist/config/client.js.map +1 -1
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +0 -15
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/orderable/index.d.ts.map +1 -1
- package/dist/config/orderable/index.js +0 -4
- package/dist/config/orderable/index.js.map +1 -1
- package/dist/config/sanitize.d.ts.map +1 -1
- package/dist/config/sanitize.js +3 -38
- package/dist/config/sanitize.js.map +1 -1
- package/dist/config/types.d.ts +120 -13
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js.map +1 -1
- package/dist/database/migrations/config/batchTransform.d.ts +16 -0
- package/dist/database/migrations/config/batchTransform.d.ts.map +1 -0
- package/dist/database/migrations/config/batchTransform.js +17 -0
- package/dist/database/migrations/config/batchTransform.js.map +1 -0
- package/dist/database/migrations/config/batchTransform.spec.js +68 -0
- package/dist/database/migrations/config/batchTransform.spec.js.map +1 -0
- package/dist/database/migrations/config/bootstrapConfigState.d.ts +4 -0
- package/dist/database/migrations/config/bootstrapConfigState.d.ts.map +1 -0
- package/dist/database/migrations/config/bootstrapConfigState.js +10 -0
- package/dist/database/migrations/config/bootstrapConfigState.js.map +1 -0
- package/dist/database/migrations/config/configStateStore.d.ts +4 -0
- package/dist/database/migrations/config/configStateStore.d.ts.map +1 -0
- package/dist/database/migrations/config/configStateStore.js +29 -0
- package/dist/database/migrations/config/configStateStore.js.map +1 -0
- package/dist/database/migrations/config/diffConfig.d.ts +3 -0
- package/dist/database/migrations/config/diffConfig.d.ts.map +1 -0
- package/dist/database/migrations/config/diffConfig.js +123 -0
- package/dist/database/migrations/config/diffConfig.js.map +1 -0
- package/dist/database/migrations/config/diffConfig.spec.js +136 -0
- package/dist/database/migrations/config/diffConfig.spec.js.map +1 -0
- package/dist/database/migrations/config/generateDataMigrationCode.d.ts +11 -0
- package/dist/database/migrations/config/generateDataMigrationCode.d.ts.map +1 -0
- package/dist/database/migrations/config/generateDataMigrationCode.js +28 -0
- package/dist/database/migrations/config/generateDataMigrationCode.js.map +1 -0
- package/dist/database/migrations/config/generateDataMigrationCode.spec.js +52 -0
- package/dist/database/migrations/config/generateDataMigrationCode.spec.js.map +1 -0
- package/dist/database/migrations/config/index.d.ts +9 -0
- package/dist/database/migrations/config/index.d.ts.map +1 -0
- package/dist/database/migrations/config/index.js +9 -0
- package/dist/database/migrations/config/index.js.map +1 -0
- package/dist/database/migrations/config/prompts.d.ts +5 -0
- package/dist/database/migrations/config/prompts.d.ts.map +1 -0
- package/dist/database/migrations/config/prompts.js +49 -0
- package/dist/database/migrations/config/prompts.js.map +1 -0
- package/dist/database/migrations/config/serializeConfig.d.ts +4 -0
- package/dist/database/migrations/config/serializeConfig.d.ts.map +1 -0
- package/dist/database/migrations/config/serializeConfig.js +65 -0
- package/dist/database/migrations/config/serializeConfig.js.map +1 -0
- package/dist/database/migrations/config/serializeConfig.spec.js +146 -0
- package/dist/database/migrations/config/serializeConfig.spec.js.map +1 -0
- package/dist/database/migrations/config/types.d.ts +66 -0
- package/dist/database/migrations/config/types.d.ts.map +1 -0
- package/dist/database/migrations/config/types.js.map +1 -0
- package/dist/database/migrations/migrate.d.ts.map +1 -1
- package/dist/database/migrations/migrate.js +3 -0
- package/dist/database/migrations/migrate.js.map +1 -1
- package/dist/database/types.d.ts +29 -0
- package/dist/database/types.d.ts.map +1 -1
- package/dist/database/types.js.map +1 -1
- package/dist/exports/migrations.d.ts +1 -0
- package/dist/exports/migrations.d.ts.map +1 -1
- package/dist/exports/migrations.js +2 -1
- package/dist/exports/migrations.js.map +1 -1
- package/dist/exports/shared.d.ts +6 -3
- package/dist/exports/shared.d.ts.map +1 -1
- package/dist/exports/shared.js +4 -2
- package/dist/exports/shared.js.map +1 -1
- package/dist/fields/baseFields/slug/index.d.ts.map +1 -1
- package/dist/fields/baseFields/slug/index.js +6 -4
- package/dist/fields/baseFields/slug/index.js.map +1 -1
- package/dist/fields/config/client.d.ts.map +1 -1
- package/dist/fields/config/client.js +3 -2
- package/dist/fields/config/client.js.map +1 -1
- package/dist/fields/config/sanitize.d.ts.map +1 -1
- package/dist/fields/config/sanitize.js +12 -10
- package/dist/fields/config/sanitize.js.map +1 -1
- package/dist/fields/config/sanitizeJoinField.d.ts.map +1 -1
- package/dist/fields/config/sanitizeJoinField.js +3 -0
- package/dist/fields/config/sanitizeJoinField.js.map +1 -1
- package/dist/fields/config/types.d.ts +17 -73
- package/dist/fields/config/types.d.ts.map +1 -1
- package/dist/fields/config/types.js +11 -1
- package/dist/fields/config/types.js.map +1 -1
- package/dist/fields/isFieldDisabled.d.ts +12 -0
- package/dist/fields/isFieldDisabled.d.ts.map +1 -0
- package/dist/fields/isFieldDisabled.js +15 -0
- package/dist/fields/isFieldDisabled.js.map +1 -0
- package/dist/fields/isFieldDisabled.spec.js +134 -0
- package/dist/fields/isFieldDisabled.spec.js.map +1 -0
- package/dist/fields/validations.js +1 -1
- package/dist/fields/validations.js.map +1 -1
- package/dist/globals/config/client.d.ts +1 -1
- package/dist/globals/config/client.d.ts.map +1 -1
- package/dist/globals/config/client.js +2 -1
- package/dist/globals/config/client.js.map +1 -1
- package/dist/globals/config/sanitize.js +6 -2
- package/dist/globals/config/sanitize.js.map +1 -1
- package/dist/globals/config/types.d.ts +4 -57
- package/dist/globals/config/types.d.ts.map +1 -1
- package/dist/globals/config/types.js.map +1 -1
- package/dist/globals/operations/findOne.d.ts.map +1 -1
- package/dist/globals/operations/findOne.js +7 -2
- package/dist/globals/operations/findOne.js.map +1 -1
- package/dist/globals/operations/findVersionByID.d.ts.map +1 -1
- package/dist/globals/operations/findVersionByID.js +6 -4
- package/dist/globals/operations/findVersionByID.js.map +1 -1
- package/dist/globals/operations/findVersions.d.ts.map +1 -1
- package/dist/globals/operations/findVersions.js +6 -4
- package/dist/globals/operations/findVersions.js.map +1 -1
- package/dist/globals/operations/update.d.ts.map +1 -1
- package/dist/globals/operations/update.js +7 -2
- package/dist/globals/operations/update.js.map +1 -1
- package/dist/hierarchy/addHierarchyToCollection.d.ts +9 -0
- package/dist/hierarchy/addHierarchyToCollection.d.ts.map +1 -0
- package/dist/hierarchy/addHierarchyToCollection.js +76 -0
- package/dist/hierarchy/addHierarchyToCollection.js.map +1 -0
- package/dist/hierarchy/buildParentField.d.ts +11 -0
- package/dist/hierarchy/buildParentField.d.ts.map +1 -0
- package/dist/hierarchy/buildParentField.js +42 -0
- package/dist/hierarchy/buildParentField.js.map +1 -0
- package/dist/hierarchy/constants.d.ts +15 -0
- package/dist/hierarchy/constants.d.ts.map +1 -0
- package/dist/hierarchy/constants.js +11 -0
- package/dist/hierarchy/constants.js.map +1 -0
- package/dist/hierarchy/createFolderField.d.ts +39 -0
- package/dist/hierarchy/createFolderField.d.ts.map +1 -0
- package/dist/hierarchy/createFolderField.js +54 -0
- package/dist/hierarchy/createFolderField.js.map +1 -0
- package/dist/hierarchy/createTagField.d.ts +44 -0
- package/dist/hierarchy/createTagField.d.ts.map +1 -0
- package/dist/hierarchy/createTagField.js +48 -0
- package/dist/hierarchy/createTagField.js.map +1 -0
- package/dist/hierarchy/getInitialTreeData.d.ts +27 -0
- package/dist/hierarchy/getInitialTreeData.d.ts.map +1 -0
- package/dist/hierarchy/getInitialTreeData.js +125 -0
- package/dist/hierarchy/getInitialTreeData.js.map +1 -0
- package/dist/hierarchy/hooks/collectionAfterDelete.d.ts +14 -0
- package/dist/hierarchy/hooks/collectionAfterDelete.d.ts.map +1 -0
- package/dist/hierarchy/hooks/collectionAfterDelete.js +21 -0
- package/dist/hierarchy/hooks/collectionAfterDelete.js.map +1 -0
- package/dist/hierarchy/hooks/collectionAfterRead.d.ts +27 -0
- package/dist/hierarchy/hooks/collectionAfterRead.d.ts.map +1 -0
- package/dist/hierarchy/hooks/collectionAfterRead.js +72 -0
- package/dist/hierarchy/hooks/collectionAfterRead.js.map +1 -0
- package/dist/hierarchy/hooks/collectionBeforeChange.d.ts +19 -0
- package/dist/hierarchy/hooks/collectionBeforeChange.d.ts.map +1 -0
- package/dist/hierarchy/hooks/collectionBeforeChange.js +90 -0
- package/dist/hierarchy/hooks/collectionBeforeChange.js.map +1 -0
- package/dist/hierarchy/hooks/collectionBeforeDelete.d.ts +15 -0
- package/dist/hierarchy/hooks/collectionBeforeDelete.d.ts.map +1 -0
- package/dist/hierarchy/hooks/collectionBeforeDelete.js +20 -0
- package/dist/hierarchy/hooks/collectionBeforeDelete.js.map +1 -0
- package/dist/hierarchy/hooks/collectionBeforeOperation.d.ts +33 -0
- package/dist/hierarchy/hooks/collectionBeforeOperation.d.ts.map +1 -0
- package/dist/hierarchy/hooks/collectionBeforeOperation.js +66 -0
- package/dist/hierarchy/hooks/collectionBeforeOperation.js.map +1 -0
- package/dist/hierarchy/hooks/ensureSafeCollectionsChange.d.ts +8 -0
- package/dist/hierarchy/hooks/ensureSafeCollectionsChange.d.ts.map +1 -0
- package/dist/hierarchy/hooks/ensureSafeCollectionsChange.js +108 -0
- package/dist/hierarchy/hooks/ensureSafeCollectionsChange.js.map +1 -0
- package/dist/hierarchy/injectHierarchyButton.d.ts +14 -0
- package/dist/hierarchy/injectHierarchyButton.d.ts.map +1 -0
- package/dist/hierarchy/injectHierarchyButton.js +37 -0
- package/dist/hierarchy/injectHierarchyButton.js.map +1 -0
- package/dist/hierarchy/presets.d.ts +13 -0
- package/dist/hierarchy/presets.d.ts.map +1 -0
- package/dist/hierarchy/presets.js +52 -0
- package/dist/hierarchy/presets.js.map +1 -0
- package/dist/hierarchy/resolveHierarchyCollections.d.ts +23 -0
- package/dist/hierarchy/resolveHierarchyCollections.d.ts.map +1 -0
- package/dist/hierarchy/resolveHierarchyCollections.js +321 -0
- package/dist/hierarchy/resolveHierarchyCollections.js.map +1 -0
- package/dist/hierarchy/sanitizeHierarchyCollection.d.ts +14 -0
- package/dist/hierarchy/sanitizeHierarchyCollection.d.ts.map +1 -0
- package/dist/hierarchy/sanitizeHierarchyCollection.js +117 -0
- package/dist/hierarchy/sanitizeHierarchyCollection.js.map +1 -0
- package/dist/hierarchy/types.d.ts +155 -0
- package/dist/hierarchy/types.d.ts.map +1 -0
- package/dist/hierarchy/types.js +6 -0
- package/dist/hierarchy/types.js.map +1 -0
- package/dist/hierarchy/utils/buildLocalizedHierarchyPaths.d.ts +77 -0
- package/dist/hierarchy/utils/buildLocalizedHierarchyPaths.d.ts.map +1 -0
- package/dist/hierarchy/utils/buildLocalizedHierarchyPaths.js +77 -0
- package/dist/hierarchy/utils/buildLocalizedHierarchyPaths.js.map +1 -0
- package/dist/hierarchy/utils/computePaths.d.ts +31 -0
- package/dist/hierarchy/utils/computePaths.d.ts.map +1 -0
- package/dist/hierarchy/utils/computePaths.js +445 -0
- package/dist/hierarchy/utils/computePaths.js.map +1 -0
- package/dist/hierarchy/utils/findUseAsTitle.d.ts +14 -0
- package/dist/hierarchy/utils/findUseAsTitle.d.ts.map +1 -0
- package/dist/hierarchy/utils/findUseAsTitle.js +89 -0
- package/dist/hierarchy/utils/findUseAsTitle.js.map +1 -0
- package/dist/hierarchy/utils/getAncestors.d.ts +34 -0
- package/dist/hierarchy/utils/getAncestors.d.ts.map +1 -0
- package/dist/hierarchy/utils/getAncestors.js +94 -0
- package/dist/hierarchy/utils/getAncestors.js.map +1 -0
- package/dist/hierarchy/utils/getLocalizedValue.d.ts +30 -0
- package/dist/hierarchy/utils/getLocalizedValue.d.ts.map +1 -0
- package/dist/hierarchy/utils/getLocalizedValue.js +46 -0
- package/dist/hierarchy/utils/getLocalizedValue.js.map +1 -0
- package/dist/hierarchy/utils/getLocalizedValue.spec.js +250 -0
- package/dist/hierarchy/utils/getLocalizedValue.spec.js.map +1 -0
- package/dist/index.bundled.d.ts +856 -558
- package/dist/index.d.ts +29 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -8
- package/dist/index.js.map +1 -1
- package/dist/preferences/keys.d.ts +8 -4
- package/dist/preferences/keys.d.ts.map +1 -1
- package/dist/preferences/keys.js +7 -4
- package/dist/preferences/keys.js.map +1 -1
- package/dist/preferences/types.d.ts +1 -1
- package/dist/preferences/types.d.ts.map +1 -1
- package/dist/preferences/types.js.map +1 -1
- package/dist/query-presets/config.d.ts.map +1 -1
- package/dist/query-presets/config.js +5 -1
- package/dist/query-presets/config.js.map +1 -1
- package/dist/queues/config/types/index.d.ts +0 -21
- package/dist/queues/config/types/index.d.ts.map +1 -1
- package/dist/queues/config/types/index.js.map +1 -1
- package/dist/queues/config/types/taskTypes.d.ts +0 -20
- package/dist/queues/config/types/taskTypes.d.ts.map +1 -1
- package/dist/queues/config/types/taskTypes.js.map +1 -1
- package/dist/queues/errors/handleWorkflowError.d.ts.map +1 -1
- package/dist/queues/errors/handleWorkflowError.js +9 -1
- package/dist/queues/errors/handleWorkflowError.js.map +1 -1
- package/dist/queues/localAPI.d.ts.map +1 -1
- package/dist/queues/localAPI.js +26 -67
- package/dist/queues/localAPI.js.map +1 -1
- package/dist/queues/operations/handleSchedules/index.d.ts.map +1 -1
- package/dist/queues/operations/handleSchedules/index.js +1 -4
- package/dist/queues/operations/handleSchedules/index.js.map +1 -1
- package/dist/queues/operations/runJobs/index.d.ts.map +1 -1
- package/dist/queues/operations/runJobs/index.js +40 -37
- package/dist/queues/operations/runJobs/index.js.map +1 -1
- package/dist/queues/operations/runJobs/runJob/getRunTaskFunction.d.ts.map +1 -1
- package/dist/queues/operations/runJobs/runJob/getRunTaskFunction.js +3 -22
- package/dist/queues/operations/runJobs/runJob/getRunTaskFunction.js.map +1 -1
- package/dist/queues/operations/runJobs/runJob/getUpdateJobFunction.d.ts.map +1 -1
- package/dist/queues/operations/runJobs/runJob/getUpdateJobFunction.js +0 -2
- package/dist/queues/operations/runJobs/runJob/getUpdateJobFunction.js.map +1 -1
- package/dist/queues/utilities/updateJob.d.ts +1 -3
- package/dist/queues/utilities/updateJob.d.ts.map +1 -1
- package/dist/queues/utilities/updateJob.js +2 -18
- package/dist/queues/utilities/updateJob.js.map +1 -1
- package/dist/types/index.d.ts +44 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/uploads/getBaseFields.d.ts.map +1 -1
- package/dist/uploads/getBaseFields.js +35 -69
- package/dist/uploads/getBaseFields.js.map +1 -1
- package/dist/uploads/getSafeFilename.d.ts +9 -4
- package/dist/uploads/getSafeFilename.d.ts.map +1 -1
- package/dist/uploads/getSafeFilename.js +5 -5
- package/dist/uploads/getSafeFilename.js.map +1 -1
- package/dist/utilities/appendDateTimezoneSelectFields.d.ts +13 -0
- package/dist/utilities/appendDateTimezoneSelectFields.d.ts.map +1 -0
- package/dist/utilities/appendDateTimezoneSelectFields.js +47 -0
- package/dist/utilities/appendDateTimezoneSelectFields.js.map +1 -0
- package/dist/utilities/appendUploadSelectFields.d.ts.map +1 -1
- package/dist/utilities/appendUploadSelectFields.js +3 -0
- package/dist/utilities/appendUploadSelectFields.js.map +1 -1
- package/dist/utilities/extractID.js +1 -1
- package/dist/utilities/extractID.js.map +1 -1
- package/dist/utilities/formatAdminURL.d.ts +13 -2
- package/dist/utilities/formatAdminURL.d.ts.map +1 -1
- package/dist/utilities/formatAdminURL.js.map +1 -1
- package/dist/utilities/handleEndpoints.d.ts.map +1 -1
- package/dist/utilities/handleEndpoints.js +0 -1
- package/dist/utilities/handleEndpoints.js.map +1 -1
- package/dist/utilities/resolveSelect.d.ts +16 -0
- package/dist/utilities/resolveSelect.d.ts.map +1 -0
- package/dist/utilities/resolveSelect.js +19 -0
- package/dist/utilities/resolveSelect.js.map +1 -0
- package/dist/utilities/sanitizeSelect.d.ts +1 -2
- package/dist/utilities/sanitizeSelect.d.ts.map +1 -1
- package/dist/utilities/sanitizeSelect.js +19 -25
- package/dist/utilities/sanitizeSelect.js.map +1 -1
- package/dist/versions/baseFields.d.ts.map +1 -1
- package/dist/versions/baseFields.js +3 -2
- package/dist/versions/baseFields.js.map +1 -1
- package/dist/versions/buildCollectionFields.d.ts.map +1 -1
- package/dist/versions/buildCollectionFields.js +0 -1
- package/dist/versions/buildCollectionFields.js.map +1 -1
- package/dist/versions/buildGlobalFields.d.ts.map +1 -1
- package/dist/versions/buildGlobalFields.js +0 -1
- package/dist/versions/buildGlobalFields.js.map +1 -1
- package/dist/versions/payloadPackageList.d.ts.map +1 -1
- package/dist/versions/payloadPackageList.js +0 -1
- package/dist/versions/payloadPackageList.js.map +1 -1
- package/package.json +4 -4
- package/dist/admin/views/folderList.d.ts +0 -56
- package/dist/admin/views/folderList.d.ts.map +0 -1
- package/dist/admin/views/folderList.js +0 -3
- package/dist/admin/views/folderList.js.map +0 -1
- package/dist/folders/addFolderCollection.d.ts +0 -10
- package/dist/folders/addFolderCollection.d.ts.map +0 -1
- package/dist/folders/addFolderCollection.js +0 -26
- package/dist/folders/addFolderCollection.js.map +0 -1
- package/dist/folders/addFolderFieldToCollection.d.ts +0 -8
- package/dist/folders/addFolderFieldToCollection.d.ts.map +0 -1
- package/dist/folders/addFolderFieldToCollection.js +0 -20
- package/dist/folders/addFolderFieldToCollection.js.map +0 -1
- package/dist/folders/buildFolderField.d.ts +0 -8
- package/dist/folders/buildFolderField.d.ts.map +0 -1
- package/dist/folders/buildFolderField.js +0 -87
- package/dist/folders/buildFolderField.js.map +0 -1
- package/dist/folders/constants.d.ts +0 -3
- package/dist/folders/constants.d.ts.map +0 -1
- package/dist/folders/constants.js +0 -4
- package/dist/folders/constants.js.map +0 -1
- package/dist/folders/createFolderCollection.d.ts +0 -11
- package/dist/folders/createFolderCollection.d.ts.map +0 -1
- package/dist/folders/createFolderCollection.js +0 -115
- package/dist/folders/createFolderCollection.js.map +0 -1
- package/dist/folders/hooks/deleteSubfoldersAfterDelete.d.ts +0 -8
- package/dist/folders/hooks/deleteSubfoldersAfterDelete.d.ts.map +0 -1
- package/dist/folders/hooks/deleteSubfoldersAfterDelete.js +0 -15
- package/dist/folders/hooks/deleteSubfoldersAfterDelete.js.map +0 -1
- package/dist/folders/hooks/dissasociateAfterDelete.d.ts +0 -8
- package/dist/folders/hooks/dissasociateAfterDelete.d.ts.map +0 -1
- package/dist/folders/hooks/dissasociateAfterDelete.js +0 -20
- package/dist/folders/hooks/dissasociateAfterDelete.js.map +0 -1
- package/dist/folders/hooks/ensureSafeCollectionsChange.d.ts +0 -5
- package/dist/folders/hooks/ensureSafeCollectionsChange.d.ts.map +0 -1
- package/dist/folders/hooks/ensureSafeCollectionsChange.js +0 -107
- package/dist/folders/hooks/ensureSafeCollectionsChange.js.map +0 -1
- package/dist/folders/hooks/reparentChildFolder.d.ts +0 -24
- package/dist/folders/hooks/reparentChildFolder.d.ts.map +0 -1
- package/dist/folders/hooks/reparentChildFolder.js +0 -72
- package/dist/folders/hooks/reparentChildFolder.js.map +0 -1
- package/dist/folders/types.d.ts +0 -118
- package/dist/folders/types.d.ts.map +0 -1
- package/dist/folders/types.js.map +0 -1
- package/dist/folders/utils/buildFolderWhereConstraints.d.ts +0 -13
- package/dist/folders/utils/buildFolderWhereConstraints.d.ts.map +0 -1
- package/dist/folders/utils/buildFolderWhereConstraints.js +0 -45
- package/dist/folders/utils/buildFolderWhereConstraints.js.map +0 -1
- package/dist/folders/utils/formatFolderOrDocumentItem.d.ts +0 -12
- package/dist/folders/utils/formatFolderOrDocumentItem.d.ts.map +0 -1
- package/dist/folders/utils/formatFolderOrDocumentItem.js +0 -30
- package/dist/folders/utils/formatFolderOrDocumentItem.js.map +0 -1
- package/dist/folders/utils/getFolderBreadcrumbs.d.ts +0 -14
- package/dist/folders/utils/getFolderBreadcrumbs.d.ts.map +0 -1
- package/dist/folders/utils/getFolderBreadcrumbs.js +0 -45
- package/dist/folders/utils/getFolderBreadcrumbs.js.map +0 -1
- package/dist/folders/utils/getFolderData.d.ts +0 -33
- package/dist/folders/utils/getFolderData.d.ts.map +0 -1
- package/dist/folders/utils/getFolderData.js +0 -88
- package/dist/folders/utils/getFolderData.js.map +0 -1
- package/dist/folders/utils/getFoldersAndDocumentsFromJoin.d.ts +0 -24
- package/dist/folders/utils/getFoldersAndDocumentsFromJoin.d.ts.map +0 -1
- package/dist/folders/utils/getFoldersAndDocumentsFromJoin.js +0 -66
- package/dist/folders/utils/getFoldersAndDocumentsFromJoin.js.map +0 -1
- package/dist/folders/utils/getOrphanedDocs.d.ts +0 -15
- package/dist/folders/utils/getOrphanedDocs.d.ts.map +0 -1
- package/dist/folders/utils/getOrphanedDocs.js +0 -40
- package/dist/folders/utils/getOrphanedDocs.js.map +0 -1
- /package/dist/{folders → database/migrations/config}/types.js +0 -0
package/dist/config/client.js
CHANGED
|
@@ -131,16 +131,6 @@ export const createClientConfig = ({ config, i18n, importMap })=>{
|
|
|
131
131
|
importMap
|
|
132
132
|
});
|
|
133
133
|
break;
|
|
134
|
-
case 'folders':
|
|
135
|
-
if (config.folders) {
|
|
136
|
-
clientConfig.folders = {
|
|
137
|
-
slug: config.folders.slug,
|
|
138
|
-
browseByFolder: config.folders.browseByFolder,
|
|
139
|
-
debug: config.folders.debug,
|
|
140
|
-
fieldName: config.folders.fieldName
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
break;
|
|
144
134
|
case 'globals':
|
|
145
135
|
;
|
|
146
136
|
clientConfig.globals = createClientGlobalConfigs({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/config/client.ts"],"sourcesContent":["import type { I18nClient, TFunction } from '@payloadcms/translations'\nimport type { DeepPartial } from 'ts-essentials'\n\nimport type { ImportMap } from '../bin/generateImportMap/index.js'\nimport type { ClientBlock } from '../fields/config/types.js'\nimport type { BlockSlug, TypedUser } from '../index.js'\nimport type {\n ClientWidget,\n RootLivePreviewConfig,\n SanitizedConfig,\n ServerOnlyLivePreviewProperties,\n} from './types.js'\n\nimport {\n type ClientCollectionConfig,\n createClientCollectionConfigs,\n} from '../collections/config/client.js'\nimport { createClientBlocks, createClientFields } from '../fields/config/client.js'\nimport { type ClientGlobalConfig, createClientGlobalConfigs } from '../globals/config/client.js'\n\nexport type ServerOnlyRootProperties = keyof Pick<\n SanitizedConfig,\n | 'bin'\n | 'cors'\n | 'csrf'\n | 'custom'\n | 'db'\n | 'editor'\n | 'email'\n | 'endpoints'\n | 'graphQL'\n | 'hooks'\n | 'i18n'\n | 'jobs'\n | 'kv'\n | 'logger'\n | 'onInit'\n | 'plugins'\n | 'queryPresets'\n | 'secret'\n | 'sharp'\n | 'typescript'\n>\n\nexport type ServerOnlyRootAdminProperties = keyof Pick<SanitizedConfig['admin'], 'components'>\n\nexport type ClientConfig = {\n admin: {\n dashboard?: {\n widgets: ClientWidget[]\n }\n livePreview?: Omit<RootLivePreviewConfig, ServerOnlyLivePreviewProperties>\n } & Omit<SanitizedConfig['admin'], 'components' | 'dashboard' | 'dependencies' | 'livePreview'>\n blocks: ClientBlock[]\n blocksMap: Record<BlockSlug, ClientBlock>\n collections: ClientCollectionConfig[]\n custom?: Record<string, any>\n globals: ClientGlobalConfig[]\n unauthenticated?: boolean\n} & Omit<SanitizedConfig, 'admin' | 'collections' | 'globals' | 'i18n' | ServerOnlyRootProperties>\n\nexport type UnauthenticatedClientConfig = {\n admin: {\n routes: ClientConfig['admin']['routes']\n user: ClientConfig['admin']['user']\n }\n collections: [\n {\n auth: ClientCollectionConfig['auth']\n slug: string\n },\n ]\n globals: []\n routes: ClientConfig['routes']\n serverURL: ClientConfig['serverURL']\n unauthenticated: true\n}\n\nexport const serverOnlyAdminConfigProperties: readonly Partial<ServerOnlyRootAdminProperties>[] = []\n\nexport const serverOnlyConfigProperties: readonly Partial<ServerOnlyRootProperties>[] = [\n 'endpoints',\n 'db',\n 'editor',\n 'plugins',\n 'sharp',\n 'onInit',\n 'secret',\n 'hooks',\n 'bin',\n 'i18n',\n 'typescript',\n 'cors',\n 'csrf',\n 'email',\n 'custom',\n 'graphQL',\n 'jobs',\n 'logger',\n 'kv',\n 'queryPresets',\n // `admin`, `onInit`, `localization`, `collections`, and `globals` are all handled separately\n]\n\nexport type CreateClientConfigArgs = {\n config: SanitizedConfig\n i18n: I18nClient\n importMap: ImportMap\n /**\n * If unauthenticated, the client config will omit some sensitive properties\n * such as field schemas, etc. This is useful for login and error pages where\n * the page source should not contain this information.\n *\n * For example, allow `true` to generate a client config for the \"create first user\" page\n * where there is no user yet, but the config should still be complete.\n */\n user: true | TypedUser\n}\n\nexport const createUnauthenticatedClientConfig = ({\n clientConfig,\n}: {\n /**\n * Send the previously generated client config to share memory when applicable.\n * E.g. the admin-enabled collection config can reference the existing collection rather than creating a new object.\n */\n clientConfig: ClientConfig\n}): UnauthenticatedClientConfig => {\n /**\n * To share memory, find the admin user collection from the existing client config.\n */\n const adminUserCollection = clientConfig.collections.find(\n ({ slug }) => slug === clientConfig.admin.user,\n )!\n\n return {\n admin: {\n routes: clientConfig.admin.routes,\n user: clientConfig.admin.user,\n },\n collections: [\n {\n slug: adminUserCollection.slug,\n auth: adminUserCollection.auth,\n },\n ],\n globals: [],\n routes: clientConfig.routes,\n serverURL: clientConfig.serverURL,\n unauthenticated: true,\n }\n}\n\nexport const createClientConfig = ({\n config,\n i18n,\n importMap,\n}: CreateClientConfigArgs): ClientConfig => {\n const clientConfig = {} as DeepPartial<ClientConfig>\n\n for (const key in config) {\n if (serverOnlyConfigProperties.includes(key as any)) {\n continue\n }\n\n switch (key) {\n case 'admin':\n clientConfig.admin = {\n autoLogin: config.admin.autoLogin,\n autoRefresh: config.admin.autoRefresh,\n avatar: config.admin.avatar,\n custom: config.admin.custom,\n dateFormat: config.admin.dateFormat,\n importMap: config.admin.importMap,\n meta: config.admin.meta,\n routes: config.admin.routes,\n theme: config.admin.theme,\n timezones: config.admin.timezones,\n toast: config.admin.toast,\n user: config.admin.user,\n }\n\n if (config.admin.dashboard?.widgets) {\n ;(clientConfig.admin.dashboard ??= {}).widgets = config.admin.dashboard.widgets.map(\n (widget) => {\n const { Component: _, fields, label, ...rest } = widget\n return {\n ...rest,\n ...(fields?.length\n ? {\n fields: createClientFields({\n defaultIDType: config.db.defaultIDType,\n fields,\n i18n,\n importMap,\n }),\n }\n : {}),\n // Resolve label function to string for client\n label:\n typeof label === 'function' ? label({ i18n, t: i18n.t as TFunction }) : label,\n }\n },\n )\n }\n\n if (config.admin.livePreview) {\n clientConfig.admin.livePreview = {}\n\n if (config.admin.livePreview.breakpoints) {\n clientConfig.admin.livePreview.breakpoints = config.admin.livePreview.breakpoints\n }\n\n if (config.admin.livePreview.collections) {\n clientConfig.admin.livePreview.collections = config.admin.livePreview.collections\n }\n\n if (config.admin.livePreview.globals) {\n clientConfig.admin.livePreview.globals = config.admin.livePreview.globals\n }\n }\n\n break\n\n case 'blocks': {\n ;(clientConfig.blocks as ClientBlock[]) = createClientBlocks({\n blocks: config.blocks!,\n defaultIDType: config.db.defaultIDType,\n i18n,\n importMap,\n }).filter((block) => typeof block !== 'string') as ClientBlock[]\n\n clientConfig.blocksMap = {}\n if (clientConfig.blocks?.length) {\n for (const block of clientConfig.blocks) {\n if (!block?.slug) {\n continue\n }\n\n clientConfig.blocksMap[block.slug] = block as ClientBlock\n }\n }\n\n break\n }\n\n case 'collections':\n ;(clientConfig.collections as ClientCollectionConfig[]) = createClientCollectionConfigs({\n collections: config.collections,\n defaultIDType: config.db.defaultIDType,\n i18n,\n importMap,\n })\n\n break\n\n case 'folders':\n if (config.folders) {\n clientConfig.folders = {\n slug: config.folders.slug,\n browseByFolder: config.folders.browseByFolder,\n debug: config.folders.debug,\n fieldName: config.folders.fieldName,\n }\n }\n\n break\n\n case 'globals':\n ;(clientConfig.globals as ClientGlobalConfig[]) = createClientGlobalConfigs({\n defaultIDType: config.db.defaultIDType,\n globals: config.globals,\n i18n,\n importMap,\n })\n\n break\n\n case 'localization':\n if (typeof config.localization === 'object' && config.localization) {\n clientConfig.localization = {}\n\n if (config.localization.defaultLocale) {\n clientConfig.localization.defaultLocale = config.localization.defaultLocale\n }\n\n if (config.localization.defaultLocalePublishOption) {\n clientConfig.localization.defaultLocalePublishOption =\n config.localization.defaultLocalePublishOption\n }\n\n if (config.localization.fallback) {\n clientConfig.localization.fallback = config.localization.fallback\n }\n\n if (config.localization.localeCodes) {\n clientConfig.localization.localeCodes = config.localization.localeCodes\n }\n\n if (config.localization.locales) {\n clientConfig.localization.locales = []\n\n for (const locale of config.localization.locales) {\n if (locale) {\n const clientLocale: Partial<(typeof config.localization.locales)[0]> = {}\n\n if (locale.code) {\n clientLocale.code = locale.code\n }\n\n if (locale.fallbackLocale) {\n clientLocale.fallbackLocale = locale.fallbackLocale\n }\n\n if (locale.label) {\n clientLocale.label = locale.label\n }\n\n if (locale.rtl) {\n clientLocale.rtl = locale.rtl\n }\n\n clientConfig.localization.locales.push(clientLocale)\n }\n }\n }\n }\n\n break\n\n default:\n ;(clientConfig as any)[key] = config[key as keyof SanitizedConfig]\n }\n }\n\n return clientConfig as ClientConfig\n}\n"],"names":["createClientCollectionConfigs","createClientBlocks","createClientFields","createClientGlobalConfigs","serverOnlyAdminConfigProperties","serverOnlyConfigProperties","createUnauthenticatedClientConfig","clientConfig","adminUserCollection","collections","find","slug","admin","user","routes","auth","globals","serverURL","unauthenticated","createClientConfig","config","i18n","importMap","key","includes","autoLogin","autoRefresh","avatar","custom","dateFormat","meta","theme","timezones","toast","dashboard","widgets","map","widget","Component","_","fields","label","rest","length","defaultIDType","db","t","livePreview","breakpoints","blocks","filter","block","blocksMap","folders","browseByFolder","debug","fieldName","localization","defaultLocale","defaultLocalePublishOption","fallback","localeCodes","locales","locale","clientLocale","code","fallbackLocale","rtl","push"],"mappings":"AAaA,SAEEA,6BAA6B,QACxB,kCAAiC;AACxC,SAASC,kBAAkB,EAAEC,kBAAkB,QAAQ,6BAA4B;AACnF,SAAkCC,yBAAyB,QAAQ,8BAA6B;AA4DhG,OAAO,MAAMC,kCAAqF,EAAE,CAAA;AAEpG,OAAO,MAAMC,6BAA2E;IACtF;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CAED,CAAA;AAiBD,OAAO,MAAMC,oCAAoC,CAAC,EAChDC,YAAY,EAOb;IACC;;GAEC,GACD,MAAMC,sBAAsBD,aAAaE,WAAW,CAACC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AAE;wBAClDpD,aAAakD,YAAY,CAACE,0BAA0B,GAClDvC,OAAOqC,YAAY,CAACE,0BAA0B;oBAClD;oBAEA,IAAIvC,OAAOqC,YAAY,CAACG,QAAQ,EAAE;wBAChCrD,aAAakD,YAAY,CAACG,QAAQ,GAAGxC,OAAOqC,YAAY,CAACG,QAAQ;oBACnE;oBAEA,IAAIxC,OAAOqC,YAAY,CAACI,WAAW,EAAE;wBACnCtD,aAAakD,YAAY,CAACI,WAAW,GAAGzC,OAAOqC,YAAY,CAACI,WAAW;oBACzE;oBAEA,IAAIzC,OAAOqC,YAAY,CAACK,OAAO,EAAE;wBAC/BvD,aAAakD,YAAY,CAACK,OAAO,GAAG,EAAE;wBAEtC,KAAK,MAAMC,UAAU3C,OAAOqC,YAAY,CAACK,OAAO,CAAE;4BAChD,IAAIC,QAAQ;gCACV,MAAMC,eAAiE,CAAC;gCAExE,IAAID,OAAOE,IAAI,EAAE;oCACfD,aAAaC,IAAI,GAAGF,OAAOE,IAAI;gCACjC;gCAEA,IAAIF,OAAOG,cAAc,EAAE;oCACzBF,aAAaE,cAAc,GAAGH,OAAOG,cAAc;gCACrD;gCAEA,IAAIH,OAAOtB,KAAK,EAAE;oCAChBuB,aAAavB,KAAK,GAAGsB,OAAOtB,KAAK;gCACnC;gCAEA,IAAIsB,OAAOI,GAAG,EAAE;oCACdH,aAAaG,GAAG,GAAGJ,OAAOI,GAAG;gCAC/B;gCAEA5D,aAAakD,YAAY,CAACK,OAAO,CAACM,IAAI,CAACJ;4BACzC;wBACF;oBACF;gBACF;gBAEA;YAEF;;gBACIzD,YAAoB,CAACgB,IAAI,GAAGH,MAAM,CAACG,IAA6B;QACtE;IACF;IAEA,OAAOhB;AACT,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../src/config/client.ts"],"sourcesContent":["import type { I18nClient, TFunction } from '@payloadcms/translations'\nimport type { DeepPartial } from 'ts-essentials'\n\nimport type { ImportMap } from '../bin/generateImportMap/index.js'\nimport type { ClientBlock } from '../fields/config/types.js'\nimport type { BlockSlug, TypedUser } from '../index.js'\nimport type {\n ClientWidget,\n RootLivePreviewConfig,\n SanitizedConfig,\n ServerOnlyLivePreviewProperties,\n} from './types.js'\n\nimport {\n type ClientCollectionConfig,\n createClientCollectionConfigs,\n} from '../collections/config/client.js'\nimport { createClientBlocks, createClientFields } from '../fields/config/client.js'\nimport { type ClientGlobalConfig, createClientGlobalConfigs } from '../globals/config/client.js'\n\nexport type ServerOnlyRootProperties = keyof Pick<\n SanitizedConfig,\n | 'bin'\n | 'cors'\n | 'csrf'\n | 'custom'\n | 'db'\n | 'editor'\n | 'email'\n | 'endpoints'\n | 'graphQL'\n | 'hooks'\n | 'i18n'\n | 'jobs'\n | 'kv'\n | 'logger'\n | 'onInit'\n | 'plugins'\n | 'queryPresets'\n | 'secret'\n | 'sharp'\n | 'typescript'\n>\n\nexport type ServerOnlyRootAdminProperties = keyof Pick<SanitizedConfig['admin'], 'components'>\n\nexport type ClientConfig = {\n admin: {\n dashboard?: {\n widgets: ClientWidget[]\n }\n livePreview?: Omit<RootLivePreviewConfig, ServerOnlyLivePreviewProperties>\n } & Omit<SanitizedConfig['admin'], 'components' | 'dashboard' | 'dependencies' | 'livePreview'>\n blocks: ClientBlock[]\n blocksMap: Record<BlockSlug, ClientBlock>\n collections: ClientCollectionConfig[]\n custom?: Record<string, any>\n globals: ClientGlobalConfig[]\n unauthenticated?: boolean\n} & Omit<SanitizedConfig, 'admin' | 'collections' | 'globals' | 'i18n' | ServerOnlyRootProperties>\n\nexport type UnauthenticatedClientConfig = {\n admin: {\n routes: ClientConfig['admin']['routes']\n user: ClientConfig['admin']['user']\n }\n collections: [\n {\n auth: ClientCollectionConfig['auth']\n slug: string\n },\n ]\n globals: []\n routes: ClientConfig['routes']\n serverURL: ClientConfig['serverURL']\n unauthenticated: true\n}\n\nexport const serverOnlyAdminConfigProperties: readonly Partial<ServerOnlyRootAdminProperties>[] = []\n\nexport const serverOnlyConfigProperties: readonly Partial<ServerOnlyRootProperties>[] = [\n 'endpoints',\n 'db',\n 'editor',\n 'plugins',\n 'sharp',\n 'onInit',\n 'secret',\n 'hooks',\n 'bin',\n 'i18n',\n 'typescript',\n 'cors',\n 'csrf',\n 'email',\n 'custom',\n 'graphQL',\n 'jobs',\n 'logger',\n 'kv',\n 'queryPresets',\n // `admin`, `onInit`, `localization`, `collections`, and `globals` are all handled separately\n]\n\nexport type CreateClientConfigArgs = {\n config: SanitizedConfig\n i18n: I18nClient\n importMap: ImportMap\n /**\n * If unauthenticated, the client config will omit some sensitive properties\n * such as field schemas, etc. This is useful for login and error pages where\n * the page source should not contain this information.\n *\n * For example, allow `true` to generate a client config for the \"create first user\" page\n * where there is no user yet, but the config should still be complete.\n */\n user: true | TypedUser\n}\n\nexport const createUnauthenticatedClientConfig = ({\n clientConfig,\n}: {\n /**\n * Send the previously generated client config to share memory when applicable.\n * E.g. the admin-enabled collection config can reference the existing collection rather than creating a new object.\n */\n clientConfig: ClientConfig\n}): UnauthenticatedClientConfig => {\n /**\n * To share memory, find the admin user collection from the existing client config.\n */\n const adminUserCollection = clientConfig.collections.find(\n ({ slug }) => slug === clientConfig.admin.user,\n )!\n\n return {\n admin: {\n routes: clientConfig.admin.routes,\n user: clientConfig.admin.user,\n },\n collections: [\n {\n slug: adminUserCollection.slug,\n auth: adminUserCollection.auth,\n },\n ],\n globals: [],\n routes: clientConfig.routes,\n serverURL: clientConfig.serverURL,\n unauthenticated: true,\n }\n}\n\nexport const createClientConfig = ({\n config,\n i18n,\n importMap,\n}: CreateClientConfigArgs): ClientConfig => {\n const clientConfig = {} as DeepPartial<ClientConfig>\n\n for (const key in config) {\n if (serverOnlyConfigProperties.includes(key as any)) {\n continue\n }\n\n switch (key) {\n case 'admin':\n clientConfig.admin = {\n autoLogin: config.admin.autoLogin,\n autoRefresh: config.admin.autoRefresh,\n avatar: config.admin.avatar,\n custom: config.admin.custom,\n dateFormat: config.admin.dateFormat,\n importMap: config.admin.importMap,\n meta: config.admin.meta,\n routes: config.admin.routes,\n theme: config.admin.theme,\n timezones: config.admin.timezones,\n toast: config.admin.toast,\n user: config.admin.user,\n }\n\n if (config.admin.dashboard?.widgets) {\n ;(clientConfig.admin.dashboard ??= {}).widgets = config.admin.dashboard.widgets.map(\n (widget) => {\n const { Component: _, fields, label, ...rest } = widget\n return {\n ...rest,\n ...(fields?.length\n ? {\n fields: createClientFields({\n defaultIDType: config.db.defaultIDType,\n fields,\n i18n,\n importMap,\n }),\n }\n : {}),\n // Resolve label function to string for client\n label:\n typeof label === 'function' ? label({ i18n, t: i18n.t as TFunction }) : label,\n }\n },\n )\n }\n\n if (config.admin.livePreview) {\n clientConfig.admin.livePreview = {}\n\n if (config.admin.livePreview.breakpoints) {\n clientConfig.admin.livePreview.breakpoints = config.admin.livePreview.breakpoints\n }\n\n if (config.admin.livePreview.collections) {\n clientConfig.admin.livePreview.collections = config.admin.livePreview.collections\n }\n\n if (config.admin.livePreview.globals) {\n clientConfig.admin.livePreview.globals = config.admin.livePreview.globals\n }\n }\n\n break\n\n case 'blocks': {\n ;(clientConfig.blocks as ClientBlock[]) = createClientBlocks({\n blocks: config.blocks!,\n defaultIDType: config.db.defaultIDType,\n i18n,\n importMap,\n }).filter((block) => typeof block !== 'string') as ClientBlock[]\n\n clientConfig.blocksMap = {}\n if (clientConfig.blocks?.length) {\n for (const block of clientConfig.blocks) {\n if (!block?.slug) {\n continue\n }\n\n clientConfig.blocksMap[block.slug] = block as ClientBlock\n }\n }\n\n break\n }\n\n case 'collections':\n ;(clientConfig.collections as ClientCollectionConfig[]) = createClientCollectionConfigs({\n collections: config.collections,\n defaultIDType: config.db.defaultIDType,\n i18n,\n importMap,\n })\n\n break\n\n case 'globals':\n ;(clientConfig.globals as ClientGlobalConfig[]) = createClientGlobalConfigs({\n defaultIDType: config.db.defaultIDType,\n globals: config.globals,\n i18n,\n importMap,\n })\n\n break\n\n case 'localization':\n if (typeof config.localization === 'object' && config.localization) {\n clientConfig.localization = {}\n\n if (config.localization.defaultLocale) {\n clientConfig.localization.defaultLocale = config.localization.defaultLocale\n }\n\n if (config.localization.defaultLocalePublishOption) {\n clientConfig.localization.defaultLocalePublishOption =\n config.localization.defaultLocalePublishOption\n }\n\n if (config.localization.fallback) {\n clientConfig.localization.fallback = config.localization.fallback\n }\n\n if (config.localization.localeCodes) {\n clientConfig.localization.localeCodes = config.localization.localeCodes\n }\n\n if (config.localization.locales) {\n clientConfig.localization.locales = []\n\n for (const locale of config.localization.locales) {\n if (locale) {\n const clientLocale: Partial<(typeof config.localization.locales)[0]> = {}\n\n if (locale.code) {\n clientLocale.code = locale.code\n }\n\n if (locale.fallbackLocale) {\n clientLocale.fallbackLocale = locale.fallbackLocale\n }\n\n if (locale.label) {\n clientLocale.label = locale.label\n }\n\n if (locale.rtl) {\n clientLocale.rtl = locale.rtl\n }\n\n clientConfig.localization.locales.push(clientLocale)\n }\n }\n }\n }\n\n break\n\n default:\n ;(clientConfig as any)[key] = config[key as keyof SanitizedConfig]\n }\n }\n\n return clientConfig as ClientConfig\n}\n"],"names":["createClientCollectionConfigs","createClientBlocks","createClientFields","createClientGlobalConfigs","serverOnlyAdminConfigProperties","serverOnlyConfigProperties","createUnauthenticatedClientConfig","clientConfig","adminUserCollection","collections","find","slug","admin","user","routes","auth","globals","serverURL","unauthenticated","createClientConfig","config","i18n","importMap","key","includes","autoLogin","autoRefresh","avatar","custom","dateFormat","meta","theme","timezones","toast","dashboard","widgets","map","widget","Component","_","fields","label","rest","length","defaultIDType","db","t","livePreview","breakpoints","blocks","filter","block","blocksMap","localization","defaultLocale","defaultLocalePublishOption","fallback","localeCodes","locales","locale","clientLocale","code","fallbackLocale","rtl","push"],"mappings":"AAaA,SAEEA,6BAA6B,QACxB,kCAAiC;AACxC,SAASC,kBAAkB,EAAEC,kBAAkB,QAAQ,6BAA4B;AACnF,SAAkCC,yBAAyB,QAAQ,8BAA6B;AA4DhG,OAAO,MAAMC,kCAAqF,EAAE,CAAA;AAEpG,OAAO,MAAMC,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OAAOiC,YAAY,CAACE,0BAA0B;oBAClD;oBAEA,IAAInC,OAAOiC,YAAY,CAACG,QAAQ,EAAE;wBAChCjD,aAAa8C,YAAY,CAACG,QAAQ,GAAGpC,OAAOiC,YAAY,CAACG,QAAQ;oBACnE;oBAEA,IAAIpC,OAAOiC,YAAY,CAACI,WAAW,EAAE;wBACnClD,aAAa8C,YAAY,CAACI,WAAW,GAAGrC,OAAOiC,YAAY,CAACI,WAAW;oBACzE;oBAEA,IAAIrC,OAAOiC,YAAY,CAACK,OAAO,EAAE;wBAC/BnD,aAAa8C,YAAY,CAACK,OAAO,GAAG,EAAE;wBAEtC,KAAK,MAAMC,UAAUvC,OAAOiC,YAAY,CAACK,OAAO,CAAE;4BAChD,IAAIC,QAAQ;gCACV,MAAMC,eAAiE,CAAC;gCAExE,IAAID,OAAOE,IAAI,EAAE;oCACfD,aAAaC,IAAI,GAAGF,OAAOE,IAAI;gCACjC;gCAEA,IAAIF,OAAOG,cAAc,EAAE;oCACzBF,aAAaE,cAAc,GAAGH,OAAOG,cAAc;gCACrD;gCAEA,IAAIH,OAAOlB,KAAK,EAAE;oCAChBmB,aAAanB,KAAK,GAAGkB,OAAOlB,KAAK;gCACnC;gCAEA,IAAIkB,OAAOI,GAAG,EAAE;oCACdH,aAAaG,GAAG,GAAGJ,OAAOI,GAAG;gCAC/B;gCAEAxD,aAAa8C,YAAY,CAACK,OAAO,CAACM,IAAI,CAACJ;4BACzC;wBACF;oBACF;gBACF;gBAEA;YAEF;;gBACIrD,YAAoB,CAACgB,IAAI,GAAGH,MAAM,CAACG,IAA6B;QACtE;IACF;IAEA,OAAOhB;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/config/defaults.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/config/defaults.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAKxC;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,GAAG,QAAQ,GAAG,QAAQ,CAwE7D,CAAA;AAED,eAAO,MAAM,mBAAmB,WAAY,MAAM,KAAG,MA4FpD,CAAA"}
|
package/dist/config/defaults.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { defaultAccess } from '../auth/defaultAccess.js';
|
|
2
|
-
import { foldersSlug, parentFolderFieldName } from '../folders/constants.js';
|
|
3
2
|
import { databaseKVAdapter } from '../kv/adapters/DatabaseKVAdapter.js';
|
|
4
3
|
/**
|
|
5
4
|
* @deprecated - remove in 4.0. This is error-prone, as mutating this object will affect any objects that use the defaults as a base.
|
|
@@ -20,7 +19,6 @@ import { databaseKVAdapter } from '../kv/adapters/DatabaseKVAdapter.js';
|
|
|
20
19
|
},
|
|
21
20
|
routes: {
|
|
22
21
|
account: '/account',
|
|
23
|
-
browseByFolder: '/browse-by-folder',
|
|
24
22
|
createFirstUser: '/create-first-user',
|
|
25
23
|
forgot: '/forgot',
|
|
26
24
|
inactivity: '/logout-inactivity',
|
|
@@ -101,7 +99,6 @@ export const addDefaultsToConfig = (config)=>{
|
|
|
101
99
|
},
|
|
102
100
|
routes: {
|
|
103
101
|
account: '/account',
|
|
104
|
-
browseByFolder: '/browse-by-folder',
|
|
105
102
|
createFirstUser: '/create-first-user',
|
|
106
103
|
forgot: '/forgot',
|
|
107
104
|
inactivity: '/logout-inactivity',
|
|
@@ -171,18 +168,6 @@ export const addDefaultsToConfig = (config)=>{
|
|
|
171
168
|
if (config.kv?.kvCollection) {
|
|
172
169
|
config.collections.push(config.kv.kvCollection);
|
|
173
170
|
}
|
|
174
|
-
if (config.folders !== false && config.collections.some((collection)=>Boolean(collection.folders))) {
|
|
175
|
-
config.folders = {
|
|
176
|
-
slug: config.folders?.slug ?? foldersSlug,
|
|
177
|
-
browseByFolder: config.folders?.browseByFolder ?? true,
|
|
178
|
-
collectionOverrides: config.folders?.collectionOverrides || undefined,
|
|
179
|
-
collectionSpecific: config.folders?.collectionSpecific ?? true,
|
|
180
|
-
debug: config.folders?.debug ?? false,
|
|
181
|
-
fieldName: config.folders?.fieldName ?? parentFolderFieldName
|
|
182
|
-
};
|
|
183
|
-
} else {
|
|
184
|
-
config.folders = false;
|
|
185
|
-
}
|
|
186
171
|
return config;
|
|
187
172
|
};
|
|
188
173
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/config/defaults.ts"],"sourcesContent":["import type { JobsConfig } from '../queues/config/types/index.js'\nimport type { Config } from './types.js'\n\nimport { defaultAccess } from '../auth/defaultAccess.js'\nimport { foldersSlug, parentFolderFieldName } from '../folders/constants.js'\nimport { databaseKVAdapter } from '../kv/adapters/DatabaseKVAdapter.js'\n\n/**\n * @deprecated - remove in 4.0. This is error-prone, as mutating this object will affect any objects that use the defaults as a base.\n */\nexport const defaults: Omit<Config, 'db' | 'editor' | 'secret'> = {\n admin: {\n avatar: 'gravatar',\n components: {},\n custom: {},\n dateFormat: 'MMMM do yyyy, h:mm a',\n dependencies: {},\n importMap: {\n baseDir: `${typeof process?.cwd === 'function' ? process.cwd() : ''}`,\n },\n meta: {\n defaultOGImageType: 'dynamic',\n robots: 'noindex, nofollow',\n titleSuffix: '- Payload',\n },\n routes: {\n account: '/account',\n browseByFolder: '/browse-by-folder',\n createFirstUser: '/create-first-user',\n forgot: '/forgot',\n inactivity: '/logout-inactivity',\n login: '/login',\n logout: '/logout',\n reset: '/reset',\n unauthorized: '/unauthorized',\n },\n theme: 'all',\n },\n auth: {\n jwtOrder: ['JWT', 'Bearer', 'cookie'],\n },\n bin: [],\n collections: [],\n cookiePrefix: 'payload',\n cors: [],\n csrf: [],\n custom: {},\n defaultDepth: 2,\n defaultMaxTextLength: 40000,\n endpoints: [],\n globals: [],\n graphQL: {\n disablePlaygroundInProduction: true,\n maxComplexity: 1000,\n schemaOutputFile: `${typeof process?.cwd === 'function' ? process.cwd() : ''}/schema.graphql`,\n },\n hooks: {},\n i18n: {},\n jobs: {\n access: {\n cancel: defaultAccess,\n queue: defaultAccess,\n run: defaultAccess,\n },\n deleteJobOnComplete: true,\n depth: 0,\n } as JobsConfig,\n\n localization: false,\n maxDepth: 10,\n routes: {\n admin: '/admin',\n api: '/api',\n graphQL: '/graphql',\n graphQLPlayground: '/graphql-playground',\n },\n serverURL: '',\n telemetry: true,\n typescript: {\n autoGenerate: true,\n outputFile: `${typeof process?.cwd === 'function' ? process.cwd() : ''}/payload-types.ts`,\n },\n upload: {},\n}\n\nexport const addDefaultsToConfig = (config: Config): Config => {\n config.admin = {\n avatar: 'gravatar',\n components: {},\n custom: {},\n dateFormat: 'MMMM do yyyy, h:mm a',\n dependencies: {},\n theme: 'all',\n ...(config.admin || {}),\n importMap: {\n baseDir: `${typeof process?.cwd === 'function' ? process.cwd() : ''}`,\n ...(config?.admin?.importMap || {}),\n },\n meta: {\n defaultOGImageType: 'dynamic',\n robots: 'noindex, nofollow',\n titleSuffix: '- Payload',\n ...(config?.admin?.meta || {}),\n },\n routes: {\n account: '/account',\n browseByFolder: '/browse-by-folder',\n createFirstUser: '/create-first-user',\n forgot: '/forgot',\n inactivity: '/logout-inactivity',\n login: '/login',\n logout: '/logout',\n reset: '/reset',\n unauthorized: '/unauthorized',\n ...(config?.admin?.routes || {}),\n },\n }\n\n config.bin = config.bin ?? []\n config.collections = config.collections ?? []\n config.cookiePrefix = config.cookiePrefix ?? 'payload'\n config.cors = config.cors ?? []\n config.csrf = config.csrf ?? []\n config.custom = config.custom ?? {}\n config.defaultDepth = config.defaultDepth ?? 2\n config.defaultMaxTextLength = config.defaultMaxTextLength ?? 40000\n config.endpoints = config.endpoints ?? []\n config.globals = config.globals ?? []\n config.graphQL = {\n disableIntrospectionInProduction: true,\n disablePlaygroundInProduction: true,\n maxComplexity: 1000,\n schemaOutputFile: `${typeof process?.cwd === 'function' ? process.cwd() : ''}/schema.graphql`,\n ...(config.graphQL || {}),\n }\n config.hooks = config.hooks ?? {}\n config.i18n = config.i18n ?? {}\n config.jobs = {\n deleteJobOnComplete: true,\n depth: 0,\n ...(config.jobs || {}),\n access: {\n cancel: defaultAccess,\n queue: defaultAccess,\n run: defaultAccess,\n ...(config.jobs?.access || {}),\n },\n } as JobsConfig\n config.localization = config.localization ?? false\n config.maxDepth = config.maxDepth ?? 10\n config.routes = {\n admin: '/admin',\n api: '/api',\n graphQL: '/graphql',\n graphQLPlayground: '/graphql-playground',\n ...(config.routes || {}),\n }\n config.serverURL = config.serverURL ?? ''\n config.telemetry = config.telemetry ?? true\n config.typescript = {\n autoGenerate: true,\n outputFile: `${typeof process?.cwd === 'function' ? process.cwd() : ''}/payload-types.ts`,\n ...(config.typescript || {}),\n }\n config.upload = config.upload ?? {}\n\n config.auth = {\n jwtOrder: ['JWT', 'Bearer', 'cookie'],\n ...(config.auth || {}),\n }\n\n config.kv = config.kv ?? databaseKVAdapter()\n\n if (config.kv?.kvCollection) {\n config.collections.push(config.kv.kvCollection)\n }\n\n if (\n config.folders !== false &&\n config.collections.some((collection) => Boolean(collection.folders))\n ) {\n config.folders = {\n slug: config.folders?.slug ?? foldersSlug,\n browseByFolder: config.folders?.browseByFolder ?? true,\n collectionOverrides: config.folders?.collectionOverrides || undefined,\n collectionSpecific: config.folders?.collectionSpecific ?? true,\n debug: config.folders?.debug ?? false,\n fieldName: config.folders?.fieldName ?? parentFolderFieldName,\n }\n } else {\n config.folders = false\n }\n\n return config\n}\n"],"names":["defaultAccess","foldersSlug","parentFolderFieldName","databaseKVAdapter","defaults","admin","avatar","components","custom","dateFormat","dependencies","importMap","baseDir","process","cwd","meta","defaultOGImageType","robots","titleSuffix","routes","account","browseByFolder","createFirstUser","forgot","inactivity","login","logout","reset","unauthorized","theme","auth","jwtOrder","bin","collections","cookiePrefix","cors","csrf","defaultDepth","defaultMaxTextLength","endpoints","globals","graphQL","disablePlaygroundInProduction","maxComplexity","schemaOutputFile","hooks","i18n","jobs","access","cancel","queue","run","deleteJobOnComplete","depth","localization","maxDepth","api","graphQLPlayground","serverURL","telemetry","typescript","autoGenerate","outputFile","upload","addDefaultsToConfig","config","disableIntrospectionInProduction","kv","kvCollection","push","folders","some","collection","Boolean","slug","collectionOverrides","undefined","collectionSpecific","debug","fieldName"],"mappings":"AAGA,SAASA,aAAa,QAAQ,2BAA0B;AACxD,SAASC,WAAW,EAAEC,qBAAqB,QAAQ,0BAAyB;AAC5E,SAASC,iBAAiB,QAAQ,sCAAqC;AAEvE;;CAEC,GACD,OAAO,MAAMC,WAAqD;IAChEC,OAAO;QACLC,QAAQ;QACRC,YAAY,CAAC;QACbC,QAAQ,CAAC;QACTC,YAAY;QACZC,cAAc,CAAC;QACfC,WAAW;YACTC,SAAS,GAAG,OAAOC,SAASC,QAAQ,aAAaD,QAAQC,GAAG,KAAK,IAAI;QACvE;QACAC,MAAM;YACJC,oBAAoB;YACpBC,QAAQ;YACRC,aAAa;QACf;QACAC,QAAQ;YACNC,SAAS;YACTC,gBAAgB;YAChBC,iBAAiB;YACjBC,QAAQ;YACRC,YAAY;YACZC,OAAO;YACPC,QAAQ;YACRC,OAAO;YACPC,cAAc;QAChB;QACAC,OAAO;IACT;IACAC,MAAM;QACJC,UAAU;YAAC;YAAO;YAAU;SAAS;IACvC;IACAC,KAAK,EAAE;IACPC,aAAa,EAAE;IACfC,cAAc;IACdC,MAAM,EAAE;IACRC,MAAM,EAAE;IACR5B,QAAQ,CAAC;IACT6B,cAAc;IACdC,sBAAsB;IACtBC,WAAW,EAAE;IACbC,SAAS,EAAE;IACXC,SAAS;QACPC,+BAA+B;QAC/BC,eAAe;QACfC,kBAAkB,GAAG,OAAO/B,SAASC,QAAQ,aAAaD,QAAQC,GAAG,KAAK,GAAG,eAAe,CAAC;IAC/F;IACA+B,OAAO,CAAC;IACRC,MAAM,CAAC;IACPC,MAAM;QACJC,Q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OL,UAAU,GAAG;QAClBC,cAAc;QACdC,YAAY,GAAG,OAAOjD,SAASC,QAAQ,aAAaD,QAAQC,GAAG,KAAK,GAAG,iBAAiB,CAAC;QACzF,GAAImD,OAAOL,UAAU,IAAI,CAAC,CAAC;IAC7B;IACAK,OAAOF,MAAM,GAAGE,OAAOF,MAAM,IAAI,CAAC;IAElCE,OAAOnC,IAAI,GAAG;QACZC,UAAU;YAAC;YAAO;YAAU;SAAS;QACrC,GAAIkC,OAAOnC,IAAI,IAAI,CAAC,CAAC;IACvB;IAEAmC,OAAOE,EAAE,GAAGF,OAAOE,EAAE,IAAIhE;IAEzB,IAAI8D,OAAOE,EAAE,EAAEC,cAAc;QAC3BH,OAAOhC,WAAW,CAACoC,IAAI,CAACJ,OAAOE,EAAE,CAACC,YAAY;IAChD;IAEA,IACEH,OAAOK,OAAO,KAAK,SACnBL,OAAOhC,WAAW,CAACsC,IAAI,CAAC,CAACC,aAAeC,QAAQD,WAAWF,OAAO,IAClE;QACAL,OAAOK,OAAO,GAAG;YACfI,MAAMT,OAAOK,OAAO,EAAEI,QAAQzE;YAC9BoB,gBAAgB4C,OAAOK,OAAO,EAAEjD,kBAAkB;YAClDsD,qBAAqBV,OAAOK,OAAO,EAAEK,uBAAuBC;YAC5DC,oBAAoBZ,OAAOK,OAAO,EAAEO,sBAAsB;YAC1DC,OAAOb,OAAOK,OAAO,EAAEQ,SAAS;YAChCC,WAAWd,OAAOK,OAAO,EAAES,aAAa7E;QAC1C;IACF,OAAO;QACL+D,OAAOK,OAAO,GAAG;IACnB;IAEA,OAAOL;AACT,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../src/config/defaults.ts"],"sourcesContent":["import type { JobsConfig } from '../queues/config/types/index.js'\nimport type { Config } from './types.js'\n\nimport { defaultAccess } from '../auth/defaultAccess.js'\nimport { databaseKVAdapter } from '../kv/adapters/DatabaseKVAdapter.js'\n\n/**\n * @deprecated - remove in 4.0. This is error-prone, as mutating this object will affect any objects that use the defaults as a base.\n */\nexport const defaults: Omit<Config, 'db' | 'editor' | 'secret'> = {\n admin: {\n avatar: 'gravatar',\n components: {},\n custom: {},\n dateFormat: 'MMMM do yyyy, h:mm a',\n dependencies: {},\n importMap: {\n baseDir: `${typeof process?.cwd === 'function' ? process.cwd() : ''}`,\n },\n meta: {\n defaultOGImageType: 'dynamic',\n robots: 'noindex, nofollow',\n titleSuffix: '- Payload',\n },\n routes: {\n account: '/account',\n createFirstUser: '/create-first-user',\n forgot: '/forgot',\n inactivity: '/logout-inactivity',\n login: '/login',\n logout: '/logout',\n reset: '/reset',\n unauthorized: '/unauthorized',\n },\n theme: 'all',\n },\n auth: {\n jwtOrder: ['JWT', 'Bearer', 'cookie'],\n },\n bin: [],\n collections: [],\n cookiePrefix: 'payload',\n cors: [],\n csrf: [],\n custom: {},\n defaultDepth: 2,\n defaultMaxTextLength: 40000,\n endpoints: [],\n globals: [],\n graphQL: {\n disablePlaygroundInProduction: true,\n maxComplexity: 1000,\n schemaOutputFile: `${typeof process?.cwd === 'function' ? process.cwd() : ''}/schema.graphql`,\n },\n hooks: {},\n i18n: {},\n jobs: {\n access: {\n cancel: defaultAccess,\n queue: defaultAccess,\n run: defaultAccess,\n },\n deleteJobOnComplete: true,\n depth: 0,\n } as JobsConfig,\n\n localization: false,\n maxDepth: 10,\n routes: {\n admin: '/admin',\n api: '/api',\n graphQL: '/graphql',\n graphQLPlayground: '/graphql-playground',\n },\n serverURL: '',\n telemetry: true,\n typescript: {\n autoGenerate: true,\n outputFile: `${typeof process?.cwd === 'function' ? process.cwd() : ''}/payload-types.ts`,\n },\n upload: {},\n}\n\nexport const addDefaultsToConfig = (config: Config): Config => {\n config.admin = {\n avatar: 'gravatar',\n components: {},\n custom: {},\n dateFormat: 'MMMM do yyyy, h:mm a',\n dependencies: {},\n theme: 'all',\n ...(config.admin || {}),\n importMap: {\n baseDir: `${typeof process?.cwd === 'function' ? process.cwd() : ''}`,\n ...(config?.admin?.importMap || {}),\n },\n meta: {\n defaultOGImageType: 'dynamic',\n robots: 'noindex, nofollow',\n titleSuffix: '- Payload',\n ...(config?.admin?.meta || {}),\n },\n routes: {\n account: '/account',\n createFirstUser: '/create-first-user',\n forgot: '/forgot',\n inactivity: '/logout-inactivity',\n login: '/login',\n logout: '/logout',\n reset: '/reset',\n unauthorized: '/unauthorized',\n ...(config?.admin?.routes || {}),\n },\n }\n\n config.bin = config.bin ?? []\n config.collections = config.collections ?? []\n config.cookiePrefix = config.cookiePrefix ?? 'payload'\n config.cors = config.cors ?? []\n config.csrf = config.csrf ?? []\n config.custom = config.custom ?? {}\n config.defaultDepth = config.defaultDepth ?? 2\n config.defaultMaxTextLength = config.defaultMaxTextLength ?? 40000\n config.endpoints = config.endpoints ?? []\n config.globals = config.globals ?? []\n config.graphQL = {\n disableIntrospectionInProduction: true,\n disablePlaygroundInProduction: true,\n maxComplexity: 1000,\n schemaOutputFile: `${typeof process?.cwd === 'function' ? process.cwd() : ''}/schema.graphql`,\n ...(config.graphQL || {}),\n }\n config.hooks = config.hooks ?? {}\n config.i18n = config.i18n ?? {}\n config.jobs = {\n deleteJobOnComplete: true,\n depth: 0,\n ...(config.jobs || {}),\n access: {\n cancel: defaultAccess,\n queue: defaultAccess,\n run: defaultAccess,\n ...(config.jobs?.access || {}),\n },\n } as JobsConfig\n config.localization = config.localization ?? false\n config.maxDepth = config.maxDepth ?? 10\n config.routes = {\n admin: '/admin',\n api: '/api',\n graphQL: '/graphql',\n graphQLPlayground: '/graphql-playground',\n ...(config.routes || {}),\n }\n config.serverURL = config.serverURL ?? ''\n config.telemetry = config.telemetry ?? true\n config.typescript = {\n autoGenerate: true,\n outputFile: `${typeof process?.cwd === 'function' ? process.cwd() : ''}/payload-types.ts`,\n ...(config.typescript || {}),\n }\n config.upload = config.upload ?? {}\n\n config.auth = {\n jwtOrder: ['JWT', 'Bearer', 'cookie'],\n ...(config.auth || {}),\n }\n\n config.kv = config.kv ?? databaseKVAdapter()\n\n if (config.kv?.kvCollection) {\n config.collections.push(config.kv.kvCollection)\n }\n\n return config\n}\n"],"names":["defaultAccess","databaseKVAdapter","defaults","admin","avatar","components","custom","dateFormat","dependencies","importMap","baseDir","process","cwd","meta","defaultOGImageType","robots","titleSuffix","routes","account","createFirstUser","forgot","inactivity","login","logout","reset","unauthorized","theme","auth","jwtOrder","bin","collections","cookiePrefix","cors","csrf","defaultDepth","defaultMaxTextLength","endpoints","globals","graphQL","disablePlaygroundInProduction","maxComplexity","schemaOutputFile","hooks","i18n","jobs","access","cancel","queue","run","deleteJobOnComplete","depth","localization","maxDepth","api","graphQLPlayground","serverURL","telemetry","typescript","autoGenerate","outputFile","upload","addDefaultsToConfig","config","disableIntrospectionInProduction","kv","kvCollection","push"],"mappings":"AAGA,SAASA,aAAa,QAAQ,2BAA0B;AACxD,SAASC,iBAAiB,QAAQ,sCAAqC;AAEvE;;CAEC,GACD,OAAO,MAAMC,WAAqD;IAChEC,OAAO;QACLC,QAAQ;QACRC,YAAY,CAAC;QACbC,QAAQ,CAAC;QACTC,YAAY;QACZC,cAAc,CAAC;QACfC,WAAW;YACTC,SAAS,GAAG,OAAOC,SAASC,QAAQ,aAAaD,QAAQC,GAAG,KAAK,IAAI;QACvE;QACAC,MAAM;YACJC,oBAAoB;YACpBC,QAAQ;YACRC,aAAa;QACf;QACAC,QAAQ;YACNC,SAAS;YACTC,iBAAiB;YACjBC,QAAQ;YACRC,YAAY;YACZC,OAAO;YACPC,QAAQ;YACRC,OAAO;YACPC,cAAc;QAChB;QACAC,OAAO;IACT;IACAC,MAAM;QACJC,UAAU;YAAC;YAAO;YAAU;SAAS;IACvC;IACAC,KAAK,EAAE;IACPC,aAAa,EAAE;IACfC,cAAc;IACdC,MAAM,EAAE;IACRC,MAAM,EAAE;IACR3B,QAAQ,CAAC;IACT4B,cAAc;IACdC,sBAAsB;IACtBC,WAAW,EAAE;IACbC,SAAS,EAAE;IACXC,SAAS;QACPC,+BAA+B;QAC/BC,eAAe;QACfC,kBAAkB,GAAG,OAAO9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AAC;IACzB;IACA6C,OAAOP,SAAS,GAAGO,OAAOP,SAAS,IAAI;IACvCO,OAAON,SAAS,GAAGM,OAAON,SAAS,IAAI;IACvCM,OAAOL,UAAU,GAAG;QAClBC,cAAc;QACdC,YAAY,GAAG,OAAOhD,SAASC,QAAQ,aAAaD,QAAQC,GAAG,KAAK,GAAG,iBAAiB,CAAC;QACzF,GAAIkD,OAAOL,UAAU,IAAI,CAAC,CAAC;IAC7B;IACAK,OAAOF,MAAM,GAAGE,OAAOF,MAAM,IAAI,CAAC;IAElCE,OAAOnC,IAAI,GAAG;QACZC,UAAU;YAAC;YAAO;YAAU;SAAS;QACrC,GAAIkC,OAAOnC,IAAI,IAAI,CAAC,CAAC;IACvB;IAEAmC,OAAOE,EAAE,GAAGF,OAAOE,EAAE,IAAI/D;IAEzB,IAAI6D,OAAOE,EAAE,EAAEC,cAAc;QAC3BH,OAAOhC,WAAW,CAACoC,IAAI,CAACJ,OAAOE,EAAE,CAACC,YAAY;IAChD;IAEA,OAAOH;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/config/orderable/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAoB,gBAAgB,EAAE,MAAM,mCAAmC,CAAA;AAC3F,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAEnD,OAAO,KAAK,EAA4B,eAAe,EAAE,MAAM,aAAa,CAAA;AAc5E,eAAO,MAAM,yBAAyB,eACxB,gBAAgB,UACpB,MAAM,uBACO,MAAM,EAAE,+BACA,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/config/orderable/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAoB,gBAAgB,EAAE,MAAM,mCAAmC,CAAA;AAC3F,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAEnD,OAAO,KAAK,EAA4B,eAAe,EAAE,MAAM,aAAa,CAAA;AAc5E,eAAO,MAAM,yBAAyB,eACxB,gBAAgB,UACpB,MAAM,uBACO,MAAM,EAAE,+BACA,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,kBAuF9D,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,cAAc,EAAE,MAAM,CAAA;IACtB,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,YAAY,EAAE,SAAS,GAAG,MAAM,CAAA;IAChC,kBAAkB,EAAE,MAAM,CAAA;IAC1B,MAAM,EAAE;QACN,EAAE,EAAE,MAAM,CAAA;QACV,GAAG,EAAE,MAAM,CAAA;KACZ,CAAA;CACF,CAAA;AAED,eAAO,MAAM,oBAAoB,WACvB,eAAe,8BACK,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,SA4L7D,CAAA"}
|
|
@@ -17,11 +17,7 @@ export const addOrderableFieldsAndHook = async (collection, config, orderableFie
|
|
|
17
17
|
name: orderableFieldName,
|
|
18
18
|
type: 'text',
|
|
19
19
|
admin: {
|
|
20
|
-
disableBulkEdit: true,
|
|
21
20
|
disabled: true,
|
|
22
|
-
disableGroupBy: true,
|
|
23
|
-
disableListColumn: true,
|
|
24
|
-
disableListFilter: true,
|
|
25
21
|
hidden: true,
|
|
26
22
|
readOnly: true
|
|
27
23
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/config/orderable/index.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { BeforeChangeHook, CollectionConfig } from '../../collections/config/types.js'\nimport type { Config } from '../../config/types.js'\nimport type { Field, TextField } from '../../fields/config/types.js'\nimport type { Endpoint, PayloadHandler, SanitizedConfig } from '../types.js'\n\nimport { executeAccess } from '../../auth/executeAccess.js'\nimport { APIError } from '../../errors/index.js'\nimport { sanitizeField } from '../../fields/config/sanitize.js'\nimport { combineWhereConstraints } from '../../utilities/combineWhereConstraints.js'\nimport { commitTransaction } from '../../utilities/commitTransaction.js'\nimport { initTransaction } from '../../utilities/initTransaction.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport { generateKeyBetween, generateNKeysBetween } from './fractional-indexing.js'\nimport { getJoinScopeContext } from './utils/getJoinScopeContext.js'\nimport { getJoinScopeWhereFromDocData } from './utils/getJoinScopeWhereFromDocData.js'\nimport { resolvePendingTargetKey } from './utils/resolvePendingTargetKey.js'\n\nexport const addOrderableFieldsAndHook = async (\n collection: CollectionConfig,\n config: Config,\n orderableFieldNames: string[],\n joinFieldPathsByCollection?: Map<string, Map<string, string>>,\n) => {\n // 1. Add fields\n for (const orderableFieldName of orderableFieldNames) {\n const orderField: TextField = {\n name: orderableFieldName,\n type: 'text',\n admin: {\n disableBulkEdit: true,\n disabled: true,\n disableGroupBy: true,\n disableListColumn: true,\n disableListFilter: true,\n hidden: true,\n readOnly: true,\n },\n hooks: {\n beforeDuplicate: [\n ({ siblingData }) => {\n delete siblingData[orderableFieldName]\n },\n ],\n },\n index: true,\n }\n\n // Sanitize the field using the standard sanitization logic\n await sanitizeField({\n collectionConfig: collection,\n config,\n existingFieldNames: new Set(),\n field: orderField,\n index: 0,\n isTopLevelField: true,\n joinPath: '',\n parentIndexPath: '',\n parentIsLocalized: false,\n parentSchemaPath: '',\n requireFieldLevelRichTextEditor: false,\n validRelationships: null,\n })\n\n collection.fields.unshift(orderField)\n }\n\n // 2. Add hook\n if (!collection.hooks) {\n collection.hooks = {}\n }\n if (!collection.hooks.beforeChange) {\n collection.hooks.beforeChange = []\n }\n\n const orderBeforeChangeHook: BeforeChangeHook = async ({ data, originalDoc, req }) => {\n for (const orderableFieldName of orderableFieldNames) {\n if (!data[orderableFieldName] && !originalDoc?.[orderableFieldName]) {\n const joinScopeWhere = getJoinScopeWhereFromDocData({\n collectionSlug: collection.slug,\n data,\n joinFieldPathsByCollection,\n orderableFieldName,\n originalDoc,\n })\n\n const lastDoc = await req.payload.find({\n collection: collection.slug,\n depth: 0,\n limit: 1,\n pagination: false,\n req,\n select: { [orderableFieldName]: true },\n sort: `-${orderableFieldName}`,\n where: combineWhereConstraints([\n {\n [orderableFieldName]: {\n exists: true,\n },\n },\n joinScopeWhere ?? undefined,\n ]),\n })\n\n const lastOrderValue = lastDoc.docs[0]?.[orderableFieldName] || null\n data[orderableFieldName] = generateKeyBetween(lastOrderValue, null)\n }\n }\n\n return data\n }\n\n collection.hooks.beforeChange.push(orderBeforeChangeHook)\n}\n\n/**\n * The body of the reorder endpoint.\n * @internal\n */\nexport type OrderableEndpointBody = {\n collectionSlug: string\n docsToMove: string[]\n newKeyWillBe: 'greater' | 'less'\n orderableFieldName: string\n target: {\n id: string\n key: string\n }\n}\n\nexport const addOrderableEndpoint = (\n config: SanitizedConfig,\n joinFieldPathsByCollection: Map<string, Map<string, string>>,\n) => {\n // 3. Add endpoint\n const reorderHandler: PayloadHandler = async (req) => {\n const body = (await req.json?.()) as OrderableEndpointBody\n\n const { collectionSlug, docsToMove, newKeyWillBe, orderableFieldName, target } = body\n\n if (!Array.isArray(docsToMove) || docsToMove.length === 0) {\n return new Response(JSON.stringify({ error: 'docsToMove must be a non-empty array' }), {\n headers: { 'Content-Type': 'application/json' },\n status: 400,\n })\n }\n if (newKeyWillBe !== 'greater' && newKeyWillBe !== 'less') {\n return new Response(JSON.stringify({ error: 'newKeyWillBe must be \"greater\" or \"less\"' }), {\n headers: { 'Content-Type': 'application/json' },\n status: 400,\n })\n }\n const collection = config.collections.find((c) => c.slug === collectionSlug)\n if (!collection) {\n return new Response(JSON.stringify({ error: `Collection ${collectionSlug} not found` }), {\n headers: { 'Content-Type': 'application/json' },\n status: 400,\n })\n }\n if (typeof orderableFieldName !== 'string') {\n return new Response(JSON.stringify({ error: 'orderableFieldName must be a string' }), {\n headers: { 'Content-Type': 'application/json' },\n status: 400,\n })\n }\n\n const { joinScopeWhere, targetDoc } = await getJoinScopeContext({\n collectionSlug: collection.slug,\n joinFieldPathsByCollection,\n orderableFieldName,\n req,\n target,\n })\n\n // Prevent reordering if user doesn't have editing permissions\n if (collection.access?.update) {\n await executeAccess(\n {\n // Currently only one doc can be moved at a time. We should review this if we want to allow\n // multiple docs to be moved at once in the future.\n id: docsToMove[0],\n data: {},\n req,\n },\n collection.access.update,\n )\n }\n /**\n * If there is no target.key, we can assume the user enabled `orderable`\n * on a collection with existing documents, and that this is the first\n * time they tried to reorder them. Therefore, we perform a one-time\n * migration by setting the key value for all documents. We do this\n * instead of enforcing `required` and `unique` at the database schema\n * level, so that users don't have to run a migration when they enable\n * `orderable` on a collection with existing documents.\n */\n if (!target.key) {\n const { docs } = await req.payload.find({\n collection: collection.slug,\n depth: 0,\n limit: 0,\n req,\n select: { [orderableFieldName]: true },\n where: combineWhereConstraints([\n {\n [orderableFieldName]: {\n exists: false,\n },\n },\n joinScopeWhere ?? undefined,\n ]),\n })\n await initTransaction(req)\n // We cannot update all documents in a single operation with `payload.update`,\n // because they would all end up with the same order key (`a0`).\n try {\n for (const doc of docs) {\n await req.payload.update({\n id: doc.id,\n collection: collection.slug,\n data: {\n // no data needed since the order hooks will handle this\n },\n depth: 0,\n req,\n })\n await commitTransaction(req)\n }\n } catch (e) {\n await killTransaction(req)\n if (e instanceof Error) {\n throw new APIError(e.message, httpStatus.INTERNAL_SERVER_ERROR)\n }\n }\n\n return new Response(JSON.stringify({ message: 'initial migration', success: true }), {\n headers: { 'Content-Type': 'application/json' },\n status: 200,\n })\n }\n\n if (\n typeof target !== 'object' ||\n typeof target.id === 'undefined' ||\n typeof target.key !== 'string'\n ) {\n return new Response(JSON.stringify({ error: 'target must be an object with id' }), {\n headers: { 'Content-Type': 'application/json' },\n status: 400,\n })\n }\n\n const targetId = target.id\n const targetKey = await resolvePendingTargetKey({\n collectionSlug: collection.slug,\n orderableFieldName,\n req,\n targetDoc,\n targetID: targetId,\n targetKey: target.key,\n })\n\n // The reason the endpoint does not receive this docId as an argument is that there\n // are situations where the user may not see or know what the next or previous one is. For\n // example, access control restrictions, if docBefore is the last one on the page, etc.\n const adjacentDoc = await req.payload.find({\n collection: collection.slug,\n depth: 0,\n limit: 1,\n pagination: false,\n select: { [orderableFieldName]: true },\n sort: newKeyWillBe === 'greater' ? orderableFieldName : `-${orderableFieldName}`,\n where: combineWhereConstraints([\n {\n [orderableFieldName]: {\n [newKeyWillBe === 'greater' ? 'greater_than' : 'less_than']: targetKey,\n },\n },\n joinScopeWhere ?? undefined,\n ]),\n })\n const adjacentDocKey = adjacentDoc.docs?.[0]?.[orderableFieldName] || null\n\n // Currently N (= docsToMove.length) is always 1. Maybe in the future we will\n // allow dragging and reordering multiple documents at once via the UI.\n const orderValues =\n newKeyWillBe === 'greater'\n ? generateNKeysBetween(targetKey, adjacentDocKey, docsToMove.length)\n : generateNKeysBetween(adjacentDocKey, targetKey, docsToMove.length)\n\n // Update each document with its new order value\n for (const [index, id] of docsToMove.entries()) {\n await req.payload.update({\n id,\n collection: collection.slug,\n data: {\n [orderableFieldName]: orderValues[index],\n },\n depth: 0,\n req,\n })\n }\n\n return new Response(JSON.stringify({ orderValues, success: true }), {\n headers: { 'Content-Type': 'application/json' },\n status: 200,\n })\n }\n\n const reorderEndpoint: Endpoint = {\n handler: reorderHandler,\n method: 'post',\n path: '/reorder',\n }\n\n if (!config.endpoints) {\n config.endpoints = []\n }\n\n config.endpoints.push(reorderEndpoint)\n}\n"],"names":["status","httpStatus","executeAccess","APIError","sanitizeField","combineWhereConstraints","commitTransaction","initTransaction","killTransaction","generateKeyBetween","generateNKeysBetween","getJoinScopeContext","getJoinScopeWhereFromDocData","resolvePendingTargetKey","addOrderableFieldsAndHook","collection","config","orderableFieldNames","joinFieldPathsByCollection","orderableFieldName","orderField","name","type","admin","disableBulkEdit","disabled","disableGroupBy","disableListColumn","disableListFilter","hidden","readOnly","hooks","beforeDuplicate","siblingData","index","collectionConfig","existingFieldNames","Set","field","isTopLevelField","joinPath","parentIndexPath","parentIsLocalized","parentSchemaPath","requireFieldLevelRichTextEditor","validRelationships","fields","unshift","beforeChange","orderBeforeChangeHook","data","originalDoc","req","joinScopeWhere","collectionSlug","slug","lastDoc","payload","find","depth","limit","pagination","select","sort","where","exists","undefined","lastOrderValue","docs","push","addOrderableEndpoint","reorderHandler","body","json","docsToMove","newKeyWillBe","target","Array","isArray","length","Response","JSON","stringify","error","headers","collections","c","targetDoc","access","update","id","key","doc","e","Error","message","INTERNAL_SERVER_ERROR","success","targetId","targetKey","targetID","adjacentDoc","adjacentDocKey","orderValues","entries","reorderEndpoint","handler","method","path","endpoints"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAOlD,SAASC,aAAa,QAAQ,8BAA6B;AAC3D,SAASC,QAAQ,QAAQ,wBAAuB;AAChD,SAASC,aAAa,QAAQ,kCAAiC;AAC/D,SAASC,uBAAuB,QAAQ,6CAA4C;AACpF,SAASC,iBAAiB,QAAQ,uCAAsC;AACxE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,kBAAkB,EAAEC,oBAAoB,QAAQ,2BAA0B;AACnF,SAASC,mBAAmB,QAAQ,iCAAgC;AACpE,SAASC,4BAA4B,QAAQ,0CAAyC;AACtF,SAASC,uBAAuB,QAAQ,qCAAoC;AAE5E,OAAO,MAAMC,4BAA4B,OACvCC,YACAC,QACAC,qBACAC;IAEA,gBAAgB;IAChB,KAAK,MAAMC,sBAAsBF,oBAAqB;QACpD,MAAMG,aAAwB;YAC5BC,MAAMF;YACNG,MAAM;YACNC,OAAO;gBACLC,iBAAiB;gBACjBC,UAAU;gBACVC,gBAAgB;gBAChBC,mBAAmB;gBACnBC,mBAAmB;gBACnBC,QAAQ;gBACRC,UAAU;YACZ;YACAC,OAAO;gBACLC,iBAAiB;oBACf,CAAC,EAAEC,WAAW,EAAE;wBACd,OAAOA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B4F,gBAAgBH,WAAWzB,WAAWK,MAAM;QAEvE,gDAAgD;QAChD,KAAK,MAAM,CAAC7C,OAAOwD,GAAG,IAAIhB,WAAW8B,OAAO,GAAI;YAC9C,MAAMpD,IAAIK,OAAO,CAACgC,MAAM,CAAC;gBACvBC;gBACA3E,YAAYA,WAAWwC,IAAI;gBAC3BL,MAAM;oBACJ,CAAC/B,mBAAmB,EAAEoF,WAAW,CAACrE,MAAM;gBAC1C;gBACAyB,OAAO;gBACPP;YACF;QACF;QAEA,OAAO,IAAI4B,SAASC,KAAKC,SAAS,CAAC;YAAEqB;YAAaN,SAAS;QAAK,IAAI;YAClEb,SAAS;gBAAE,gBAAgB;YAAmB;YAC9CpF,QAAQ;QACV;IACF;IAEA,MAAMyG,kBAA4B;QAChCC,SAASnC;QACToC,QAAQ;QACRC,MAAM;IACR;IAEA,IAAI,CAAC5F,OAAO6F,SAAS,EAAE;QACrB7F,OAAO6F,SAAS,GAAG,EAAE;IACvB;IAEA7F,OAAO6F,SAAS,CAACxC,IAAI,CAACoC;AACxB,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/config/orderable/index.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { BeforeChangeHook, CollectionConfig } from '../../collections/config/types.js'\nimport type { Config } from '../../config/types.js'\nimport type { Field, TextField } from '../../fields/config/types.js'\nimport type { Endpoint, PayloadHandler, SanitizedConfig } from '../types.js'\n\nimport { executeAccess } from '../../auth/executeAccess.js'\nimport { APIError } from '../../errors/index.js'\nimport { sanitizeField } from '../../fields/config/sanitize.js'\nimport { combineWhereConstraints } from '../../utilities/combineWhereConstraints.js'\nimport { commitTransaction } from '../../utilities/commitTransaction.js'\nimport { initTransaction } from '../../utilities/initTransaction.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport { generateKeyBetween, generateNKeysBetween } from './fractional-indexing.js'\nimport { getJoinScopeContext } from './utils/getJoinScopeContext.js'\nimport { getJoinScopeWhereFromDocData } from './utils/getJoinScopeWhereFromDocData.js'\nimport { resolvePendingTargetKey } from './utils/resolvePendingTargetKey.js'\n\nexport const addOrderableFieldsAndHook = async (\n collection: CollectionConfig,\n config: Config,\n orderableFieldNames: string[],\n joinFieldPathsByCollection?: Map<string, Map<string, string>>,\n) => {\n // 1. Add fields\n for (const orderableFieldName of orderableFieldNames) {\n const orderField: TextField = {\n name: orderableFieldName,\n type: 'text',\n admin: {\n disabled: true,\n hidden: true,\n readOnly: true,\n },\n hooks: {\n beforeDuplicate: [\n ({ siblingData }) => {\n delete siblingData[orderableFieldName]\n },\n ],\n },\n index: true,\n }\n\n // Sanitize the field using the standard sanitization logic\n await sanitizeField({\n collectionConfig: collection,\n config,\n existingFieldNames: new Set(),\n field: orderField,\n index: 0,\n isTopLevelField: true,\n joinPath: '',\n parentIndexPath: '',\n parentIsLocalized: false,\n parentSchemaPath: '',\n requireFieldLevelRichTextEditor: false,\n validRelationships: null,\n })\n\n collection.fields.unshift(orderField)\n }\n\n // 2. Add hook\n if (!collection.hooks) {\n collection.hooks = {}\n }\n if (!collection.hooks.beforeChange) {\n collection.hooks.beforeChange = []\n }\n\n const orderBeforeChangeHook: BeforeChangeHook = async ({ data, originalDoc, req }) => {\n for (const orderableFieldName of orderableFieldNames) {\n if (!data[orderableFieldName] && !originalDoc?.[orderableFieldName]) {\n const joinScopeWhere = getJoinScopeWhereFromDocData({\n collectionSlug: collection.slug,\n data,\n joinFieldPathsByCollection,\n orderableFieldName,\n originalDoc,\n })\n\n const lastDoc = await req.payload.find({\n collection: collection.slug,\n depth: 0,\n limit: 1,\n pagination: false,\n req,\n select: { [orderableFieldName]: true },\n sort: `-${orderableFieldName}`,\n where: combineWhereConstraints([\n {\n [orderableFieldName]: {\n exists: true,\n },\n },\n joinScopeWhere ?? undefined,\n ]),\n })\n\n const lastOrderValue = lastDoc.docs[0]?.[orderableFieldName] || null\n data[orderableFieldName] = generateKeyBetween(lastOrderValue, null)\n }\n }\n\n return data\n }\n\n collection.hooks.beforeChange.push(orderBeforeChangeHook)\n}\n\n/**\n * The body of the reorder endpoint.\n * @internal\n */\nexport type OrderableEndpointBody = {\n collectionSlug: string\n docsToMove: string[]\n newKeyWillBe: 'greater' | 'less'\n orderableFieldName: string\n target: {\n id: string\n key: string\n }\n}\n\nexport const addOrderableEndpoint = (\n config: SanitizedConfig,\n joinFieldPathsByCollection: Map<string, Map<string, string>>,\n) => {\n // 3. Add endpoint\n const reorderHandler: PayloadHandler = async (req) => {\n const body = (await req.json?.()) as OrderableEndpointBody\n\n const { collectionSlug, docsToMove, newKeyWillBe, orderableFieldName, target } = body\n\n if (!Array.isArray(docsToMove) || docsToMove.length === 0) {\n return new Response(JSON.stringify({ error: 'docsToMove must be a non-empty array' }), {\n headers: { 'Content-Type': 'application/json' },\n status: 400,\n })\n }\n if (newKeyWillBe !== 'greater' && newKeyWillBe !== 'less') {\n return new Response(JSON.stringify({ error: 'newKeyWillBe must be \"greater\" or \"less\"' }), {\n headers: { 'Content-Type': 'application/json' },\n status: 400,\n })\n }\n const collection = config.collections.find((c) => c.slug === collectionSlug)\n if (!collection) {\n return new Response(JSON.stringify({ error: `Collection ${collectionSlug} not found` }), {\n headers: { 'Content-Type': 'application/json' },\n status: 400,\n })\n }\n if (typeof orderableFieldName !== 'string') {\n return new Response(JSON.stringify({ error: 'orderableFieldName must be a string' }), {\n headers: { 'Content-Type': 'application/json' },\n status: 400,\n })\n }\n\n const { joinScopeWhere, targetDoc } = await getJoinScopeContext({\n collectionSlug: collection.slug,\n joinFieldPathsByCollection,\n orderableFieldName,\n req,\n target,\n })\n\n // Prevent reordering if user doesn't have editing permissions\n if (collection.access?.update) {\n await executeAccess(\n {\n // Currently only one doc can be moved at a time. We should review this if we want to allow\n // multiple docs to be moved at once in the future.\n id: docsToMove[0],\n data: {},\n req,\n },\n collection.access.update,\n )\n }\n /**\n * If there is no target.key, we can assume the user enabled `orderable`\n * on a collection with existing documents, and that this is the first\n * time they tried to reorder them. Therefore, we perform a one-time\n * migration by setting the key value for all documents. We do this\n * instead of enforcing `required` and `unique` at the database schema\n * level, so that users don't have to run a migration when they enable\n * `orderable` on a collection with existing documents.\n */\n if (!target.key) {\n const { docs } = await req.payload.find({\n collection: collection.slug,\n depth: 0,\n limit: 0,\n req,\n select: { [orderableFieldName]: true },\n where: combineWhereConstraints([\n {\n [orderableFieldName]: {\n exists: false,\n },\n },\n joinScopeWhere ?? undefined,\n ]),\n })\n await initTransaction(req)\n // We cannot update all documents in a single operation with `payload.update`,\n // because they would all end up with the same order key (`a0`).\n try {\n for (const doc of docs) {\n await req.payload.update({\n id: doc.id,\n collection: collection.slug,\n data: {\n // no data needed since the order hooks will handle this\n },\n depth: 0,\n req,\n })\n await commitTransaction(req)\n }\n } catch (e) {\n await killTransaction(req)\n if (e instanceof Error) {\n throw new APIError(e.message, httpStatus.INTERNAL_SERVER_ERROR)\n }\n }\n\n return new Response(JSON.stringify({ message: 'initial migration', success: true }), {\n headers: { 'Content-Type': 'application/json' },\n status: 200,\n })\n }\n\n if (\n typeof target !== 'object' ||\n typeof target.id === 'undefined' ||\n typeof target.key !== 'string'\n ) {\n return new Response(JSON.stringify({ error: 'target must be an object with id' }), {\n headers: { 'Content-Type': 'application/json' },\n status: 400,\n })\n }\n\n const targetId = target.id\n const targetKey = await resolvePendingTargetKey({\n collectionSlug: collection.slug,\n orderableFieldName,\n req,\n targetDoc,\n targetID: targetId,\n targetKey: target.key,\n })\n\n // The reason the endpoint does not receive this docId as an argument is that there\n // are situations where the user may not see or know what the next or previous one is. For\n // example, access control restrictions, if docBefore is the last one on the page, etc.\n const adjacentDoc = await req.payload.find({\n collection: collection.slug,\n depth: 0,\n limit: 1,\n pagination: false,\n select: { [orderableFieldName]: true },\n sort: newKeyWillBe === 'greater' ? orderableFieldName : `-${orderableFieldName}`,\n where: combineWhereConstraints([\n {\n [orderableFieldName]: {\n [newKeyWillBe === 'greater' ? 'greater_than' : 'less_than']: targetKey,\n },\n },\n joinScopeWhere ?? undefined,\n ]),\n })\n const adjacentDocKey = adjacentDoc.docs?.[0]?.[orderableFieldName] || null\n\n // Currently N (= docsToMove.length) is always 1. Maybe in the future we will\n // allow dragging and reordering multiple documents at once via the UI.\n const orderValues =\n newKeyWillBe === 'greater'\n ? generateNKeysBetween(targetKey, adjacentDocKey, docsToMove.length)\n : generateNKeysBetween(adjacentDocKey, targetKey, docsToMove.length)\n\n // Update each document with its new order value\n for (const [index, id] of docsToMove.entries()) {\n await req.payload.update({\n id,\n collection: collection.slug,\n data: {\n [orderableFieldName]: orderValues[index],\n },\n depth: 0,\n req,\n })\n }\n\n return new Response(JSON.stringify({ orderValues, success: true }), {\n headers: { 'Content-Type': 'application/json' },\n status: 200,\n })\n }\n\n const reorderEndpoint: Endpoint = {\n handler: reorderHandler,\n method: 'post',\n path: '/reorder',\n }\n\n if (!config.endpoints) {\n config.endpoints = []\n }\n\n config.endpoints.push(reorderEndpoint)\n}\n"],"names":["status","httpStatus","executeAccess","APIError","sanitizeField","combineWhereConstraints","commitTransaction","initTransaction","killTransaction","generateKeyBetween","generateNKeysBetween","getJoinScopeContext","getJoinScopeWhereFromDocData","resolvePendingTargetKey","addOrderableFieldsAndHook","collection","config","orderableFieldNames","joinFieldPathsByCollection","orderableFieldName","orderField","name","type","admin","disabled","hidden","readOnly","hooks","beforeDuplicate","siblingData","index","collectionConfig","existingFieldNames","Set","field","isTopLevelField","joinPath","parentIndexPath","parentIsLocalized","parentSchemaPath","requireFieldLevelRichTextEditor","validRelationships","fields","unshift","beforeChange","orderBeforeChangeHook","data","originalDoc","req","joinScopeWhere","collectionSlug","slug","lastDoc","payload","find","depth","limit","pagination","select","sort","where","exists","undefined","lastOrderValue","docs","push","addOrderableEndpoint","reorderHandler","body","json","docsToMove","newKeyWillBe","target","Array","isArray","length","Response","JSON","stringify","error","headers","collections","c","targetDoc","access","update","id","key","doc","e","Error","message","INTERNAL_SERVER_ERROR","success","targetId","targetKey","targetID","adjacentDoc","adjacentDocKey","orderValues","entries","reorderEndpoint","handler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AASnC;QACToC,QAAQ;QACRC,MAAM;IACR;IAEA,IAAI,CAACxF,OAAOyF,SAAS,EAAE;QACrBzF,OAAOyF,SAAS,GAAG,EAAE;IACvB;IAEAzF,OAAOyF,SAAS,CAACxC,IAAI,CAACoC;AACxB,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;
|
|
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"}
|
package/dist/config/sanitize.js
CHANGED
|
@@ -6,9 +6,8 @@ import { sanitizeCollection } from '../collections/config/sanitize.js';
|
|
|
6
6
|
import { migrationsCollection } from '../database/migrations/migrationsCollection.js';
|
|
7
7
|
import { DuplicateCollection, InvalidConfiguration } from '../errors/index.js';
|
|
8
8
|
import { defaultTimezones } from '../fields/baseFields/timezone/defaultTimezones.js';
|
|
9
|
-
import { addFolderCollection } from '../folders/addFolderCollection.js';
|
|
10
|
-
import { addFolderFieldToCollection } from '../folders/addFolderFieldToCollection.js';
|
|
11
9
|
import { sanitizeGlobal } from '../globals/config/sanitize.js';
|
|
10
|
+
import { resolveHierarchyCollections } from '../hierarchy/resolveHierarchyCollections.js';
|
|
12
11
|
import { baseBlockFields, formatLabels, sanitizeFields } from '../index.js';
|
|
13
12
|
import { getLockedDocumentsCollection, lockedDocumentsCollectionSlug } from '../locked-documents/config.js';
|
|
14
13
|
import { getPreferencesCollection, preferencesCollectionSlug } from '../preferences/config.js';
|
|
@@ -144,9 +143,6 @@ export const sanitizeConfig = async (incomingConfig)=>{
|
|
|
144
143
|
lockedDocumentsCollectionSlug,
|
|
145
144
|
preferencesCollectionSlug
|
|
146
145
|
];
|
|
147
|
-
if (config.folders !== false) {
|
|
148
|
-
validRelationships.push(config.folders.slug);
|
|
149
|
-
}
|
|
150
146
|
const dashboardWidgets = config.admin?.dashboard?.widgets ?? [];
|
|
151
147
|
for (const widget of dashboardWidgets){
|
|
152
148
|
if (widget.fields?.length) {
|
|
@@ -187,7 +183,6 @@ export const sanitizeConfig = async (incomingConfig)=>{
|
|
|
187
183
|
config.blocks.push(flattenedSanitizedBlock);
|
|
188
184
|
}
|
|
189
185
|
}
|
|
190
|
-
const folderEnabledCollections = [];
|
|
191
186
|
// Track orderable join fields during sanitization
|
|
192
187
|
const orderableJoins = [];
|
|
193
188
|
for(let i = 0; i < config.collections.length; i++){
|
|
@@ -205,18 +200,7 @@ export const sanitizeConfig = async (incomingConfig)=>{
|
|
|
205
200
|
validRelationships.push(queryPresetsCollectionSlug);
|
|
206
201
|
}
|
|
207
202
|
}
|
|
208
|
-
if (config.folders !== false && config.collections[i].folders) {
|
|
209
|
-
addFolderFieldToCollection({
|
|
210
|
-
collection: config.collections[i],
|
|
211
|
-
collectionSpecific: config.folders.collectionSpecific,
|
|
212
|
-
folderFieldName: config.folders.fieldName,
|
|
213
|
-
folderSlug: config.folders.slug
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
203
|
config.collections[i] = await sanitizeCollection(config, config.collections[i], richTextSanitizationPromises, validRelationships, orderableJoins);
|
|
217
|
-
if (config.folders !== false && config.collections[i].folders) {
|
|
218
|
-
folderEnabledCollections.push(config.collections[i]);
|
|
219
|
-
}
|
|
220
204
|
}
|
|
221
205
|
// Process orderable features after all collections are sanitized
|
|
222
206
|
const fieldsToAdd = new Map();
|
|
@@ -266,6 +250,8 @@ export const sanitizeConfig = async (incomingConfig)=>{
|
|
|
266
250
|
config.globals[i] = await sanitizeGlobal(config, config.globals[i], richTextSanitizationPromises, validRelationships);
|
|
267
251
|
}
|
|
268
252
|
}
|
|
253
|
+
// Resolve hierarchy relationships across collections (also adds sidebar tabs)
|
|
254
|
+
resolveHierarchyCollections(config);
|
|
269
255
|
if (schedulePublishCollections.length || schedulePublishGlobals.length) {
|
|
270
256
|
;
|
|
271
257
|
((config.jobs ??= {}).tasks ??= []).push(getSchedulePublishTask({
|
|
@@ -290,31 +276,10 @@ export const sanitizeConfig = async (incomingConfig)=>{
|
|
|
290
276
|
defaultJobsCollection = config.jobs.jobsCollectionOverrides({
|
|
291
277
|
defaultJobsCollection
|
|
292
278
|
});
|
|
293
|
-
const hooks = defaultJobsCollection?.hooks;
|
|
294
|
-
// @todo - delete this check in 4.0
|
|
295
|
-
if (hooks && config?.jobs?.runHooks !== true) {
|
|
296
|
-
for (const [hookKey, hook] of Object.entries(hooks)){
|
|
297
|
-
const defaultAmount = hookKey === 'afterRead' || hookKey === 'beforeChange' ? 1 : 0;
|
|
298
|
-
if (hook.length > defaultAmount) {
|
|
299
|
-
// eslint-disable-next-line no-console
|
|
300
|
-
console.warn(`The jobsCollectionOverrides function is returning a collection with an additional ${hookKey} hook defined. These hooks will not run unless the jobs.runHooks option is set to true. Setting this option to true will negatively impact performance.`);
|
|
301
|
-
break;
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
279
|
}
|
|
306
280
|
const sanitizedJobsCollection = await sanitizeCollection(config, defaultJobsCollection, richTextSanitizationPromises, validRelationships);
|
|
307
281
|
(config.collections ??= []).push(sanitizedJobsCollection);
|
|
308
282
|
}
|
|
309
|
-
if (config.folders !== false && folderEnabledCollections.length) {
|
|
310
|
-
await addFolderCollection({
|
|
311
|
-
collectionSpecific: config.folders.collectionSpecific,
|
|
312
|
-
config: config,
|
|
313
|
-
folderEnabledCollections,
|
|
314
|
-
richTextSanitizationPromises,
|
|
315
|
-
validRelationships
|
|
316
|
-
});
|
|
317
|
-
}
|
|
318
283
|
const lockedDocumentsCollection = getLockedDocumentsCollection(config);
|
|
319
284
|
if (lockedDocumentsCollection) {
|
|
320
285
|
configWithDefaults.collections.push(await sanitizeCollection(config, lockedDocumentsCollection, richTextSanitizationPromises, validRelationships));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/config/sanitize.ts"],"sourcesContent":["import type { AcceptedLanguages } from '@payloadcms/translations'\n\nimport { en } from '@payloadcms/translations/languages/en'\nimport { deepMergeSimple } from '@payloadcms/translations/utilities'\n\nimport type { OrderableJoinInfo } from '../fields/config/sanitizeJoinField.js'\nimport type { CollectionSlug, GlobalSlug, SanitizedCollectionConfig } from '../index.js'\nimport type { SanitizedJobsConfig } from '../queues/config/types/index.js'\nimport type {\n Config,\n LocalizationConfigWithLabels,\n LocalizationConfigWithNoLabels,\n SanitizedConfig,\n Timezone,\n Widget,\n WidgetInstance,\n} from './types.js'\n\nimport { defaultUserCollection } from '../auth/defaultUser.js'\nimport { authRootEndpoints } from '../auth/endpoints/index.js'\nimport { sanitizeCollection } from '../collections/config/sanitize.js'\nimport { migrationsCollection } from '../database/migrations/migrationsCollection.js'\nimport { DuplicateCollection, InvalidConfiguration } from '../errors/index.js'\nimport { defaultTimezones } from '../fields/baseFields/timezone/defaultTimezones.js'\nimport { addFolderCollection } from '../folders/addFolderCollection.js'\nimport { addFolderFieldToCollection } from '../folders/addFolderFieldToCollection.js'\nimport { sanitizeGlobal } from '../globals/config/sanitize.js'\nimport { baseBlockFields, formatLabels, sanitizeFields } from '../index.js'\nimport {\n getLockedDocumentsCollection,\n lockedDocumentsCollectionSlug,\n} from '../locked-documents/config.js'\nimport { getPreferencesCollection, preferencesCollectionSlug } from '../preferences/config.js'\nimport { getQueryPresetsConfig, queryPresetsCollectionSlug } from '../query-presets/config.js'\nimport { getDefaultJobsCollection, jobsCollectionSlug } from '../queues/config/collection.js'\nimport { getJobStatsGlobal } from '../queues/config/global.js'\nimport { flattenAllFields, flattenBlock } from '../utilities/flattenAllFields.js'\nimport { hasScheduledPublishEnabled } from '../utilities/getVersionsConfig.js'\nimport { validateTimezones } from '../utilities/validateTimezones.js'\nimport { getSchedulePublishTask } from '../versions/schedule/job.js'\nimport { addDefaultsToConfig } from './defaults.js'\nimport { addOrderableEndpoint, addOrderableFieldsAndHook } from './orderable/index.js'\n\nconst sanitizeAdminConfig = (configToSanitize: Config): Partial<SanitizedConfig> => {\n const sanitizedConfig = { ...configToSanitize }\n\n if (configToSanitize?.compatibility?.allowLocalizedWithinLocalized) {\n process.env.NEXT_PUBLIC_PAYLOAD_COMPATIBILITY_allowLocalizedWithinLocalized = 'true'\n }\n\n // default logging level will be 'error' if not provided\n sanitizedConfig.loggingLevels = {\n Forbidden: 'info',\n Locked: 'info',\n MissingFile: 'info',\n NotFound: 'info',\n ValidationError: 'info',\n ...(sanitizedConfig.loggingLevels || {}),\n }\n ;(sanitizedConfig.admin!.dashboard ??= { widgets: [] }).widgets.push({\n slug: 'collections',\n Component: '@payloadcms/next/rsc#CollectionCards',\n minWidth: 'full',\n })\n sanitizedConfig.admin!.dashboard.defaultLayout ??= [\n {\n widgetSlug: 'collections',\n width: 'full',\n } satisfies WidgetInstance,\n ]\n\n // add default user collection if none provided\n if (!sanitizedConfig?.admin?.user) {\n const firstCollectionWithAuth = sanitizedConfig.collections!.find(({ auth }) => Boolean(auth))\n\n if (firstCollectionWithAuth) {\n sanitizedConfig.admin!.user = firstCollectionWithAuth.slug\n } else {\n sanitizedConfig.admin!.user = defaultUserCollection.slug\n sanitizedConfig.collections!.push(defaultUserCollection)\n }\n }\n\n const userCollection = sanitizedConfig.collections!.find(\n ({ slug }) => slug === sanitizedConfig.admin!.user,\n )\n\n if (!userCollection || !userCollection.auth) {\n throw new InvalidConfiguration(\n `${sanitizedConfig.admin!.user} is not a valid admin user collection`,\n )\n }\n\n if (sanitizedConfig?.admin?.timezones) {\n if (typeof configToSanitize?.admin?.timezones?.supportedTimezones === 'function') {\n sanitizedConfig.admin.timezones.supportedTimezones =\n configToSanitize.admin.timezones.supportedTimezones({ defaultTimezones })\n }\n\n if (!sanitizedConfig?.admin?.timezones?.supportedTimezones) {\n sanitizedConfig.admin.timezones.supportedTimezones = defaultTimezones\n }\n } else {\n sanitizedConfig.admin!.timezones = {\n supportedTimezones: defaultTimezones,\n }\n }\n\n validateTimezones({\n source: 'admin.timezones.supportedTimezones',\n timezones: sanitizedConfig.admin!.timezones.supportedTimezones as Timezone[],\n })\n\n return sanitizedConfig as unknown as Partial<SanitizedConfig>\n}\n\nexport const sanitizeConfig = async (incomingConfig: Config): Promise<SanitizedConfig> => {\n const configWithDefaults = addDefaultsToConfig(incomingConfig)\n\n const config: Partial<SanitizedConfig> = sanitizeAdminConfig(configWithDefaults)\n\n if (!config.endpoints) {\n config.endpoints = []\n }\n\n for (const endpoint of authRootEndpoints) {\n config.endpoints.push(endpoint)\n }\n\n if (config.localization && config.localization.locales?.length > 0) {\n // clone localization config so to not break everything\n const firstLocale = config.localization.locales[0]\n if (typeof firstLocale === 'string') {\n config.localization.localeCodes = [\n ...(config.localization as unknown as LocalizationConfigWithNoLabels).locales,\n ]\n\n // is string[], so convert to Locale[]\n config.localization.locales = (\n config.localization as unknown as LocalizationConfigWithNoLabels\n ).locales.map((locale) => ({\n code: locale,\n label: locale,\n rtl: false,\n toString: () => locale,\n }))\n } else {\n // is Locale[], so convert to string[] for localeCodes\n config.localization.localeCodes = config.localization.locales.map((locale) => locale.code)\n\n config.localization.locales = (\n config.localization as LocalizationConfigWithLabels\n ).locales.map((locale) => ({\n ...locale,\n toString: () => locale.code,\n }))\n }\n\n // Default fallback to true if not provided\n config.localization.fallback = config.localization?.fallback ?? true\n }\n\n const i18nConfig: SanitizedConfig['i18n'] = {\n fallbackLanguage: 'en',\n supportedLanguages: {\n en,\n },\n translations: {},\n }\n\n if (incomingConfig?.i18n) {\n i18nConfig.supportedLanguages =\n incomingConfig.i18n?.supportedLanguages || i18nConfig.supportedLanguages\n\n const supportedLangKeys = <AcceptedLanguages[]>Object.keys(i18nConfig.supportedLanguages)\n const fallbackLang = incomingConfig.i18n?.fallbackLanguage || i18nConfig.fallbackLanguage\n\n i18nConfig.fallbackLanguage = supportedLangKeys.includes(fallbackLang)\n ? fallbackLang\n : supportedLangKeys[0]!\n i18nConfig.translations =\n (incomingConfig.i18n?.translations as SanitizedConfig['i18n']['translations']) ||\n i18nConfig.translations\n }\n\n config.i18n = i18nConfig\n\n const richTextSanitizationPromises: Array<(config: SanitizedConfig) => Promise<void>> = []\n\n const schedulePublishCollections: CollectionSlug[] = []\n\n const queryPresetsCollections: CollectionSlug[] = []\n\n const schedulePublishGlobals: GlobalSlug[] = []\n\n const collectionSlugs = new Set<CollectionSlug>()\n\n const validRelationships = [\n ...(config.collections?.map((c) => c.slug) ?? []),\n jobsCollectionSlug,\n lockedDocumentsCollectionSlug,\n preferencesCollectionSlug,\n ]\n\n if (config.folders !== false) {\n validRelationships.push(config.folders!.slug)\n }\n\n const dashboardWidgets = config.admin?.dashboard?.widgets ?? ([] as Widget[])\n\n for (const widget of dashboardWidgets) {\n if (widget.fields?.length) {\n widget.fields = await sanitizeFields({\n config: config as unknown as Config,\n existingFieldNames: new Set(),\n fields: widget.fields,\n parentIsLocalized: false,\n richTextSanitizationPromises,\n validRelationships,\n })\n }\n }\n\n /**\n * Blocks sanitization needs to happen before collections, as collection/global join field sanitization needs config.blocks\n * to be populated with the sanitized blocks\n */\n config.blocks = []\n\n if (incomingConfig.blocks?.length) {\n for (const block of incomingConfig.blocks) {\n const sanitizedBlock = block\n\n if (sanitizedBlock._sanitized === true) {\n continue\n }\n sanitizedBlock._sanitized = true\n\n sanitizedBlock.fields = sanitizedBlock.fields.concat(baseBlockFields)\n\n sanitizedBlock.labels = !sanitizedBlock.labels\n ? formatLabels(sanitizedBlock.slug)\n : sanitizedBlock.labels\n\n sanitizedBlock.fields = await sanitizeFields({\n config: config as unknown as Config,\n existingFieldNames: new Set(),\n fields: sanitizedBlock.fields,\n parentIsLocalized: false,\n richTextSanitizationPromises,\n validRelationships,\n })\n\n const flattenedSanitizedBlock = flattenBlock({ block })\n\n config.blocks.push(flattenedSanitizedBlock)\n }\n }\n\n const folderEnabledCollections: SanitizedCollectionConfig[] = []\n\n // Track orderable join fields during sanitization\n const orderableJoins: OrderableJoinInfo[] = []\n\n for (let i = 0; i < config.collections!.length; i++) {\n if (collectionSlugs.has(config.collections![i]!.slug)) {\n throw new DuplicateCollection('slug', config.collections![i]!.slug)\n }\n\n collectionSlugs.add(config.collections![i]!.slug)\n\n const draftsConfig = config.collections![i]?.versions?.drafts\n\n if (typeof draftsConfig === 'object' && draftsConfig.schedulePublish) {\n schedulePublishCollections.push(config.collections![i]!.slug)\n }\n\n if (config.collections![i]!.enableQueryPresets) {\n queryPresetsCollections.push(config.collections![i]!.slug)\n\n if (!validRelationships.includes(queryPresetsCollectionSlug)) {\n validRelationships.push(queryPresetsCollectionSlug)\n }\n }\n\n if (config.folders !== false && config.collections![i]!.folders) {\n addFolderFieldToCollection({\n collection: config.collections![i]!,\n collectionSpecific: config.folders!.collectionSpecific,\n folderFieldName: config.folders!.fieldName,\n folderSlug: config.folders!.slug,\n })\n }\n\n config.collections![i] = await sanitizeCollection(\n config as unknown as Config,\n config.collections![i]!,\n richTextSanitizationPromises,\n validRelationships,\n orderableJoins,\n )\n\n if (config.folders !== false && config.collections![i]!.folders) {\n folderEnabledCollections.push(config.collections![i]!)\n }\n }\n\n // Process orderable features after all collections are sanitized\n const fieldsToAdd = new Map<SanitizedCollectionConfig, string[]>()\n const joinFieldPathsByCollection = new Map<string, Map<string, string>>()\n\n // Handle collection.orderable\n for (const collection of config.collections!) {\n if (collection.orderable) {\n const currentFields = fieldsToAdd.get(collection) || []\n fieldsToAdd.set(collection, [...currentFields, '_order'])\n collection.defaultSort = collection.defaultSort ?? '_order'\n }\n }\n\n // Handle orderable join fields (tracked during sanitization)\n for (const joinInfo of orderableJoins) {\n const targetCollection = config.collections!.find(\n (c) => c.slug === joinInfo.targetCollectionSlug,\n )\n if (targetCollection) {\n const currentFields = fieldsToAdd.get(targetCollection) || []\n fieldsToAdd.set(targetCollection, [...currentFields, joinInfo.orderFieldName])\n\n const currentJoinFieldPaths =\n joinFieldPathsByCollection.get(targetCollection.slug) || new Map<string, string>()\n currentJoinFieldPaths.set(joinInfo.orderFieldName, joinInfo.joinFieldOn)\n joinFieldPathsByCollection.set(targetCollection.slug, currentJoinFieldPaths)\n }\n }\n\n // Add fields, hooks, and update flattenedFields\n for (const [collection, orderableFields] of fieldsToAdd) {\n await addOrderableFieldsAndHook(\n collection,\n config as unknown as Config,\n orderableFields,\n joinFieldPathsByCollection,\n )\n // Regenerate flattenedFields since we added new fields\n collection.flattenedFields = flattenAllFields({ fields: collection.fields })\n }\n\n // Add endpoint if any orderable features exist\n if (fieldsToAdd.size > 0) {\n addOrderableEndpoint(config as SanitizedConfig, joinFieldPathsByCollection)\n }\n\n if (config.globals!.length > 0) {\n for (let i = 0; i < config.globals!.length; i++) {\n if (hasScheduledPublishEnabled(config.globals![i]!)) {\n schedulePublishGlobals.push(config.globals![i]!.slug)\n }\n\n config.globals![i] = await sanitizeGlobal(\n config as unknown as Config,\n config.globals![i]!,\n richTextSanitizationPromises,\n validRelationships,\n )\n }\n }\n\n if (schedulePublishCollections.length || schedulePublishGlobals.length) {\n ;((config.jobs ??= {} as SanitizedJobsConfig).tasks ??= []).push(\n getSchedulePublishTask({\n adminUserSlug: config.admin!.user,\n collections: schedulePublishCollections,\n globals: schedulePublishGlobals,\n }),\n )\n }\n\n ;(config.jobs ??= {} as SanitizedJobsConfig).enabled = Boolean(\n (Array.isArray(configWithDefaults.jobs?.tasks) && configWithDefaults.jobs?.tasks?.length) ||\n (Array.isArray(configWithDefaults.jobs?.workflows) &&\n configWithDefaults.jobs?.workflows?.length),\n )\n\n // Need to add default jobs collection before locked documents collections\n if (config.jobs.enabled) {\n // Check for schedule property in both tasks and workflows\n const hasScheduleProperty =\n (config?.jobs?.tasks?.length && config.jobs.tasks.some((task) => task.schedule)) ||\n (config?.jobs?.workflows?.length &&\n config.jobs.workflows.some((workflow) => workflow.schedule))\n\n if (hasScheduleProperty) {\n config.jobs.scheduling = true\n // Add payload-jobs-stats global for tracking when a job of a specific slug was last run\n ;(config.globals ??= []).push(\n await sanitizeGlobal(\n config as unknown as Config,\n getJobStatsGlobal(config as unknown as Config),\n richTextSanitizationPromises,\n validRelationships,\n ),\n )\n\n config.jobs.stats = true\n }\n\n let defaultJobsCollection = getDefaultJobsCollection(config.jobs)\n\n if (typeof config.jobs.jobsCollectionOverrides === 'function') {\n defaultJobsCollection = config.jobs.jobsCollectionOverrides({\n defaultJobsCollection,\n })\n\n const hooks = defaultJobsCollection?.hooks\n // @todo - delete this check in 4.0\n if (hooks && config?.jobs?.runHooks !== true) {\n for (const [hookKey, hook] of Object.entries(hooks)) {\n const defaultAmount = hookKey === 'afterRead' || hookKey === 'beforeChange' ? 1 : 0\n if (hook.length > defaultAmount) {\n // eslint-disable-next-line no-console\n console.warn(\n `The jobsCollectionOverrides function is returning a collection with an additional ${hookKey} hook defined. These hooks will not run unless the jobs.runHooks option is set to true. Setting this option to true will negatively impact performance.`,\n )\n break\n }\n }\n }\n }\n const sanitizedJobsCollection = await sanitizeCollection(\n config as unknown as Config,\n defaultJobsCollection,\n richTextSanitizationPromises,\n validRelationships,\n )\n\n ;(config.collections ??= []).push(sanitizedJobsCollection)\n }\n\n if (config.folders !== false && folderEnabledCollections.length) {\n await addFolderCollection({\n collectionSpecific: config.folders!.collectionSpecific,\n config: config as unknown as Config,\n folderEnabledCollections,\n richTextSanitizationPromises,\n validRelationships,\n })\n }\n\n const lockedDocumentsCollection = getLockedDocumentsCollection(config as unknown as Config)\n\n if (lockedDocumentsCollection) {\n configWithDefaults.collections!.push(\n await sanitizeCollection(\n config as unknown as Config,\n lockedDocumentsCollection,\n richTextSanitizationPromises,\n validRelationships,\n ),\n )\n }\n\n configWithDefaults.collections!.push(\n await sanitizeCollection(\n config as unknown as Config,\n getPreferencesCollection(config as unknown as Config),\n richTextSanitizationPromises,\n validRelationships,\n ),\n )\n\n const migrations = await sanitizeCollection(\n config as unknown as Config,\n migrationsCollection,\n richTextSanitizationPromises,\n validRelationships,\n )\n\n // @ts-expect-error indexSortableFields is only valid for @payloadcms/db-mongodb\n if (config?.db?.indexSortableFields) {\n migrations.indexes = [\n {\n fields: ['batch', 'name'],\n unique: false,\n },\n ]\n }\n configWithDefaults.collections!.push(migrations)\n\n if (queryPresetsCollections.length > 0) {\n configWithDefaults.collections!.push(\n await sanitizeCollection(\n config as unknown as Config,\n getQueryPresetsConfig(config as unknown as Config),\n richTextSanitizationPromises,\n validRelationships,\n ),\n )\n }\n\n if (config.serverURL !== '') {\n config.csrf!.push(config.serverURL!)\n }\n\n const uploadAdapters = new Set<string>()\n // interact with all collections\n for (const collection of config.collections!) {\n // deduped upload adapters\n if (collection.upload?.adapter) {\n uploadAdapters.add(collection.upload.adapter)\n }\n }\n\n if (!config.upload) {\n config.upload = { adapters: [] }\n }\n\n config.upload.adapters = Array.from(\n new Set(config.collections!.map((c) => c.upload?.adapter).filter(Boolean) as string[]),\n )\n\n // Pass through the email config as is so adapters don't break\n if (incomingConfig.email) {\n config.email = incomingConfig.email\n }\n\n /*\n Execute richText sanitization\n */\n if (typeof incomingConfig.editor === 'function') {\n config.editor = await incomingConfig.editor({\n config: config as SanitizedConfig,\n isRoot: true,\n parentIsLocalized: false,\n })\n if (config.editor.i18n && Object.keys(config.editor.i18n).length >= 0) {\n config.i18n.translations = deepMergeSimple(config.i18n.translations, config.editor.i18n)\n }\n }\n\n const promises: Promise<void>[] = []\n\n for (const sanitizeFunction of richTextSanitizationPromises) {\n promises.push(sanitizeFunction(config as SanitizedConfig))\n }\n\n await Promise.all(promises)\n\n return config as SanitizedConfig\n}\n"],"names":["en","deepMergeSimple","defaultUserCollection","authRootEndpoints","sanitizeCollection","migrationsCollection","DuplicateCollection","InvalidConfiguration","defaultTimezones","addFolderCollection","addFolderFieldToCollection","sanitizeGlobal","baseBlockFields","formatLabels","sanitizeFields","getLockedDocumentsCollection","lockedDocumentsCollectionSlug","getPreferencesCollection","preferencesCollectionSlug","getQueryPresetsConfig","queryPresetsCollectionSlug","getDefaultJobsCollection","jobsCollectionSlug","getJobStatsGlobal","flattenAllFields","flattenBlock","hasScheduledPublishEnabled","validateTimezones","getSchedulePublishTask","addDefaultsToConfig","addOrderableEndpoint","addOrderableFieldsAndHook","sanitizeAdminConfig","configToSanitize","sanitizedConfig","compatibility","allowLocalizedWithinLocalized","process","env","NEXT_PUBLIC_PAYLOAD_COMPATIBILITY_allowLocalizedWithinLocalized","loggingLevels","Forbidden","Locked","MissingFile","NotFound","ValidationError","admin","dashboard","widgets","push","slug","Component","minWidth","defaultLayout","widgetSlug","width","user","firstCollectionWithAuth","collections","find","auth","Boolean","userCollection","timezones","supportedTimezones","source","sanitizeConfig","incomingConfig","configWithDefaults","config","endpoints","endpoint","localization","locales","length","firstLocale","localeCodes","map","locale","code","label","rtl","toString","fallback","i18nConfig","fallbackLanguage","supportedLanguages","translations","i18n","supportedLangKeys","Object","keys","fallbackLang","includes","richTextSanitizationPromises","schedulePublishCollections","queryPresetsCollections","schedulePublishGlobals","collectionSlugs","Set","validRelationships","c","folders","dashboardWidgets","widget","fields","existingFieldNames","parentIsLocalized","blocks","block","sanitizedBlock","_sanitized","concat","labels","flattenedSanitizedBlock","folderEnabledCollections","orderableJoins","i","has","add","draftsConfig","versions","drafts","schedulePublish","enableQueryPresets","collection","collectionSpecific","folderFieldName","fieldName","folderSlug","fieldsToAdd","Map","joinFieldPathsByCollection","orderable","currentFields","get","set","defaultSort","joinInfo","targetCollection","targetCollectionSlug","orderFieldName","currentJoinFieldPaths","joinFieldOn","orderableFields","flattenedFields","size","globals","jobs","tasks","adminUserSlug","enabled","Array","isArray","workflows","hasScheduleProperty","some","task","schedule","workflow","scheduling","stats","defaultJobsCollection","jobsCollectionOverrides","hooks","runHooks","hookKey","hook","entries","defaultAmount","console","warn","sanitizedJobsCollection","lockedDocumentsCollection","migrations","db","indexSortableFields","indexes","unique","serverURL","csrf","uploadAdap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zH,eAAeyH,MAAM,CAAC;YAC1CvH,QAAQA;YACRwH,QAAQ;YACRlF,mBAAmB;QACrB;QACA,IAAItC,OAAOuH,MAAM,CAACpG,IAAI,IAAIE,OAAOC,IAAI,CAACtB,OAAOuH,MAAM,CAACpG,IAAI,EAAEd,MAAM,IAAI,GAAG;YACrEL,OAAOmB,IAAI,CAACD,YAAY,GAAGtF,gBAAgBoE,OAAOmB,IAAI,CAACD,YAAY,EAAElB,OAAOuH,MAAM,CAACpG,IAAI;QACzF;IACF;IAEA,MAAMsG,WAA4B,EAAE;IAEpC,KAAK,MAAMC,oBAAoBjG,6BAA8B;QAC3DgG,SAAS7I,IAAI,CAAC8I,iBAAiB1H;IACjC;IAEA,MAAM2H,QAAQC,GAAG,CAACH;IAElB,OAAOzH;AACT,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../src/config/sanitize.ts"],"sourcesContent":["import type { AcceptedLanguages } from '@payloadcms/translations'\n\nimport { en } from '@payloadcms/translations/languages/en'\nimport { deepMergeSimple } from '@payloadcms/translations/utilities'\n\nimport type { OrderableJoinInfo } from '../fields/config/sanitizeJoinField.js'\nimport type { CollectionSlug, GlobalSlug, SanitizedCollectionConfig } from '../index.js'\nimport type { SanitizedJobsConfig } from '../queues/config/types/index.js'\nimport type {\n Config,\n LocalizationConfigWithLabels,\n LocalizationConfigWithNoLabels,\n SanitizedConfig,\n Timezone,\n Widget,\n WidgetInstance,\n} from './types.js'\n\nimport { defaultUserCollection } from '../auth/defaultUser.js'\nimport { authRootEndpoints } from '../auth/endpoints/index.js'\nimport { sanitizeCollection } from '../collections/config/sanitize.js'\nimport { migrationsCollection } from '../database/migrations/migrationsCollection.js'\nimport { DuplicateCollection, InvalidConfiguration } from '../errors/index.js'\nimport { defaultTimezones } from '../fields/baseFields/timezone/defaultTimezones.js'\nimport { sanitizeGlobal } from '../globals/config/sanitize.js'\nimport { resolveHierarchyCollections } from '../hierarchy/resolveHierarchyCollections.js'\nimport { baseBlockFields, formatLabels, sanitizeFields } from '../index.js'\nimport {\n getLockedDocumentsCollection,\n lockedDocumentsCollectionSlug,\n} from '../locked-documents/config.js'\nimport { getPreferencesCollection, preferencesCollectionSlug } from '../preferences/config.js'\nimport { getQueryPresetsConfig, queryPresetsCollectionSlug } from '../query-presets/config.js'\nimport { getDefaultJobsCollection, jobsCollectionSlug } from '../queues/config/collection.js'\nimport { getJobStatsGlobal } from '../queues/config/global.js'\nimport { flattenAllFields, flattenBlock } from '../utilities/flattenAllFields.js'\nimport { hasScheduledPublishEnabled } from '../utilities/getVersionsConfig.js'\nimport { validateTimezones } from '../utilities/validateTimezones.js'\nimport { getSchedulePublishTask } from '../versions/schedule/job.js'\nimport { addDefaultsToConfig } from './defaults.js'\nimport { addOrderableEndpoint, addOrderableFieldsAndHook } from './orderable/index.js'\n\nconst sanitizeAdminConfig = (configToSanitize: Config): Partial<SanitizedConfig> => {\n const sanitizedConfig = { ...configToSanitize }\n\n if (configToSanitize?.compatibility?.allowLocalizedWithinLocalized) {\n process.env.NEXT_PUBLIC_PAYLOAD_COMPATIBILITY_allowLocalizedWithinLocalized = 'true'\n }\n\n // default logging level will be 'error' if not provided\n sanitizedConfig.loggingLevels = {\n Forbidden: 'info',\n Locked: 'info',\n MissingFile: 'info',\n NotFound: 'info',\n ValidationError: 'info',\n ...(sanitizedConfig.loggingLevels || {}),\n }\n ;(sanitizedConfig.admin!.dashboard ??= { widgets: [] }).widgets.push({\n slug: 'collections',\n Component: '@payloadcms/next/rsc#CollectionCards',\n minWidth: 'full',\n })\n sanitizedConfig.admin!.dashboard.defaultLayout ??= [\n {\n widgetSlug: 'collections',\n width: 'full',\n } satisfies WidgetInstance,\n ]\n\n // add default user collection if none provided\n if (!sanitizedConfig?.admin?.user) {\n const firstCollectionWithAuth = sanitizedConfig.collections!.find(({ auth }) => Boolean(auth))\n\n if (firstCollectionWithAuth) {\n sanitizedConfig.admin!.user = firstCollectionWithAuth.slug\n } else {\n sanitizedConfig.admin!.user = defaultUserCollection.slug\n sanitizedConfig.collections!.push(defaultUserCollection)\n }\n }\n\n const userCollection = sanitizedConfig.collections!.find(\n ({ slug }) => slug === sanitizedConfig.admin!.user,\n )\n\n if (!userCollection || !userCollection.auth) {\n throw new InvalidConfiguration(\n `${sanitizedConfig.admin!.user} is not a valid admin user collection`,\n )\n }\n\n if (sanitizedConfig?.admin?.timezones) {\n if (typeof configToSanitize?.admin?.timezones?.supportedTimezones === 'function') {\n sanitizedConfig.admin.timezones.supportedTimezones =\n configToSanitize.admin.timezones.supportedTimezones({ defaultTimezones })\n }\n\n if (!sanitizedConfig?.admin?.timezones?.supportedTimezones) {\n sanitizedConfig.admin.timezones.supportedTimezones = defaultTimezones\n }\n } else {\n sanitizedConfig.admin!.timezones = {\n supportedTimezones: defaultTimezones,\n }\n }\n\n validateTimezones({\n source: 'admin.timezones.supportedTimezones',\n timezones: sanitizedConfig.admin!.timezones.supportedTimezones as Timezone[],\n })\n\n return sanitizedConfig as unknown as Partial<SanitizedConfig>\n}\n\nexport const sanitizeConfig = async (incomingConfig: Config): Promise<SanitizedConfig> => {\n const configWithDefaults = addDefaultsToConfig(incomingConfig)\n\n const config: Partial<SanitizedConfig> = sanitizeAdminConfig(configWithDefaults)\n\n if (!config.endpoints) {\n config.endpoints = []\n }\n\n for (const endpoint of authRootEndpoints) {\n config.endpoints.push(endpoint)\n }\n\n if (config.localization && config.localization.locales?.length > 0) {\n // clone localization config so to not break everything\n const firstLocale = config.localization.locales[0]\n if (typeof firstLocale === 'string') {\n config.localization.localeCodes = [\n ...(config.localization as unknown as LocalizationConfigWithNoLabels).locales,\n ]\n\n // is string[], so convert to Locale[]\n config.localization.locales = (\n config.localization as unknown as LocalizationConfigWithNoLabels\n ).locales.map((locale) => ({\n code: locale,\n label: locale,\n rtl: false,\n toString: () => locale,\n }))\n } else {\n // is Locale[], so convert to string[] for localeCodes\n config.localization.localeCodes = config.localization.locales.map((locale) => locale.code)\n\n config.localization.locales = (\n config.localization as LocalizationConfigWithLabels\n ).locales.map((locale) => ({\n ...locale,\n toString: () => locale.code,\n }))\n }\n\n // Default fallback to true if not provided\n config.localization.fallback = config.localization?.fallback ?? true\n }\n\n const i18nConfig: SanitizedConfig['i18n'] = {\n fallbackLanguage: 'en',\n supportedLanguages: {\n en,\n },\n translations: {},\n }\n\n if (incomingConfig?.i18n) {\n i18nConfig.supportedLanguages =\n incomingConfig.i18n?.supportedLanguages || i18nConfig.supportedLanguages\n\n const supportedLangKeys = <AcceptedLanguages[]>Object.keys(i18nConfig.supportedLanguages)\n const fallbackLang = incomingConfig.i18n?.fallbackLanguage || i18nConfig.fallbackLanguage\n\n i18nConfig.fallbackLanguage = supportedLangKeys.includes(fallbackLang)\n ? fallbackLang\n : supportedLangKeys[0]!\n i18nConfig.translations =\n (incomingConfig.i18n?.translations as SanitizedConfig['i18n']['translations']) ||\n i18nConfig.translations\n }\n\n config.i18n = i18nConfig\n\n const richTextSanitizationPromises: Array<(config: SanitizedConfig) => Promise<void>> = []\n\n const schedulePublishCollections: CollectionSlug[] = []\n\n const queryPresetsCollections: CollectionSlug[] = []\n\n const schedulePublishGlobals: GlobalSlug[] = []\n\n const collectionSlugs = new Set<CollectionSlug>()\n\n const validRelationships = [\n ...(config.collections?.map((c) => c.slug) ?? []),\n jobsCollectionSlug,\n lockedDocumentsCollectionSlug,\n preferencesCollectionSlug,\n ]\n\n const dashboardWidgets = config.admin?.dashboard?.widgets ?? ([] as Widget[])\n\n for (const widget of dashboardWidgets) {\n if (widget.fields?.length) {\n widget.fields = await sanitizeFields({\n config: config as unknown as Config,\n existingFieldNames: new Set(),\n fields: widget.fields,\n parentIsLocalized: false,\n richTextSanitizationPromises,\n validRelationships,\n })\n }\n }\n\n /**\n * Blocks sanitization needs to happen before collections, as collection/global join field sanitization needs config.blocks\n * to be populated with the sanitized blocks\n */\n config.blocks = []\n\n if (incomingConfig.blocks?.length) {\n for (const block of incomingConfig.blocks) {\n const sanitizedBlock = block\n\n if (sanitizedBlock._sanitized === true) {\n continue\n }\n sanitizedBlock._sanitized = true\n\n sanitizedBlock.fields = sanitizedBlock.fields.concat(baseBlockFields)\n\n sanitizedBlock.labels = !sanitizedBlock.labels\n ? formatLabels(sanitizedBlock.slug)\n : sanitizedBlock.labels\n\n sanitizedBlock.fields = await sanitizeFields({\n config: config as unknown as Config,\n existingFieldNames: new Set(),\n fields: sanitizedBlock.fields,\n parentIsLocalized: false,\n richTextSanitizationPromises,\n validRelationships,\n })\n\n const flattenedSanitizedBlock = flattenBlock({ block })\n\n config.blocks.push(flattenedSanitizedBlock)\n }\n }\n\n // Track orderable join fields during sanitization\n const orderableJoins: OrderableJoinInfo[] = []\n\n for (let i = 0; i < config.collections!.length; i++) {\n if (collectionSlugs.has(config.collections![i]!.slug)) {\n throw new DuplicateCollection('slug', config.collections![i]!.slug)\n }\n\n collectionSlugs.add(config.collections![i]!.slug)\n\n const draftsConfig = config.collections![i]?.versions?.drafts\n\n if (typeof draftsConfig === 'object' && draftsConfig.schedulePublish) {\n schedulePublishCollections.push(config.collections![i]!.slug)\n }\n\n if (config.collections![i]!.enableQueryPresets) {\n queryPresetsCollections.push(config.collections![i]!.slug)\n\n if (!validRelationships.includes(queryPresetsCollectionSlug)) {\n validRelationships.push(queryPresetsCollectionSlug)\n }\n }\n\n config.collections![i] = await sanitizeCollection(\n config as unknown as Config,\n config.collections![i]!,\n richTextSanitizationPromises,\n validRelationships,\n orderableJoins,\n )\n }\n\n // Process orderable features after all collections are sanitized\n const fieldsToAdd = new Map<SanitizedCollectionConfig, string[]>()\n const joinFieldPathsByCollection = new Map<string, Map<string, string>>()\n\n // Handle collection.orderable\n for (const collection of config.collections!) {\n if (collection.orderable) {\n const currentFields = fieldsToAdd.get(collection) || []\n fieldsToAdd.set(collection, [...currentFields, '_order'])\n collection.defaultSort = collection.defaultSort ?? '_order'\n }\n }\n\n // Handle orderable join fields (tracked during sanitization)\n for (const joinInfo of orderableJoins) {\n const targetCollection = config.collections!.find(\n (c) => c.slug === joinInfo.targetCollectionSlug,\n )\n if (targetCollection) {\n const currentFields = fieldsToAdd.get(targetCollection) || []\n fieldsToAdd.set(targetCollection, [...currentFields, joinInfo.orderFieldName])\n\n const currentJoinFieldPaths =\n joinFieldPathsByCollection.get(targetCollection.slug) || new Map<string, string>()\n currentJoinFieldPaths.set(joinInfo.orderFieldName, joinInfo.joinFieldOn)\n joinFieldPathsByCollection.set(targetCollection.slug, currentJoinFieldPaths)\n }\n }\n\n // Add fields, hooks, and update flattenedFields\n for (const [collection, orderableFields] of fieldsToAdd) {\n await addOrderableFieldsAndHook(\n collection,\n config as unknown as Config,\n orderableFields,\n joinFieldPathsByCollection,\n )\n // Regenerate flattenedFields since we added new fields\n collection.flattenedFields = flattenAllFields({ fields: collection.fields })\n }\n\n // Add endpoint if any orderable features exist\n if (fieldsToAdd.size > 0) {\n addOrderableEndpoint(config as SanitizedConfig, joinFieldPathsByCollection)\n }\n\n if (config.globals!.length > 0) {\n for (let i = 0; i < config.globals!.length; i++) {\n if (hasScheduledPublishEnabled(config.globals![i]!)) {\n schedulePublishGlobals.push(config.globals![i]!.slug)\n }\n\n config.globals![i] = await sanitizeGlobal(\n config as unknown as Config,\n config.globals![i]!,\n richTextSanitizationPromises,\n validRelationships,\n )\n }\n }\n\n // Resolve hierarchy relationships across collections (also adds sidebar tabs)\n resolveHierarchyCollections(config as unknown as Config)\n\n if (schedulePublishCollections.length || schedulePublishGlobals.length) {\n ;((config.jobs ??= {} as SanitizedJobsConfig).tasks ??= []).push(\n getSchedulePublishTask({\n adminUserSlug: config.admin!.user,\n collections: schedulePublishCollections,\n globals: schedulePublishGlobals,\n }),\n )\n }\n\n ;(config.jobs ??= {} as SanitizedJobsConfig).enabled = Boolean(\n (Array.isArray(configWithDefaults.jobs?.tasks) && configWithDefaults.jobs?.tasks?.length) ||\n (Array.isArray(configWithDefaults.jobs?.workflows) &&\n configWithDefaults.jobs?.workflows?.length),\n )\n\n // Need to add default jobs collection before locked documents collections\n if (config.jobs.enabled) {\n // Check for schedule property in both tasks and workflows\n const hasScheduleProperty =\n (config?.jobs?.tasks?.length && config.jobs.tasks.some((task) => task.schedule)) ||\n (config?.jobs?.workflows?.length &&\n config.jobs.workflows.some((workflow) => workflow.schedule))\n\n if (hasScheduleProperty) {\n config.jobs.scheduling = true\n // Add payload-jobs-stats global for tracking when a job of a specific slug was last run\n ;(config.globals ??= []).push(\n await sanitizeGlobal(\n config as unknown as Config,\n getJobStatsGlobal(config as unknown as Config),\n richTextSanitizationPromises,\n validRelationships,\n ),\n )\n\n config.jobs.stats = true\n }\n\n let defaultJobsCollection = getDefaultJobsCollection(config.jobs)\n\n if (typeof config.jobs.jobsCollectionOverrides === 'function') {\n defaultJobsCollection = config.jobs.jobsCollectionOverrides({\n defaultJobsCollection,\n })\n }\n const sanitizedJobsCollection = await sanitizeCollection(\n config as unknown as Config,\n defaultJobsCollection,\n richTextSanitizationPromises,\n validRelationships,\n )\n\n ;(config.collections ??= []).push(sanitizedJobsCollection)\n }\n\n const lockedDocumentsCollection = getLockedDocumentsCollection(config as unknown as Config)\n\n if (lockedDocumentsCollection) {\n configWithDefaults.collections!.push(\n await sanitizeCollection(\n config as unknown as Config,\n lockedDocumentsCollection,\n richTextSanitizationPromises,\n validRelationships,\n ),\n )\n }\n\n configWithDefaults.collections!.push(\n await sanitizeCollection(\n config as unknown as Config,\n getPreferencesCollection(config as unknown as Config),\n richTextSanitizationPromises,\n validRelationships,\n ),\n )\n\n const migrations = await sanitizeCollection(\n config as unknown as Config,\n migrationsCollection,\n richTextSanitizationPromises,\n validRelationships,\n )\n\n // @ts-expect-error indexSortableFields is only valid for @payloadcms/db-mongodb\n if (config?.db?.indexSortableFields) {\n migrations.indexes = [\n {\n fields: ['batch', 'name'],\n unique: false,\n },\n ]\n }\n configWithDefaults.collections!.push(migrations)\n\n if (queryPresetsCollections.length > 0) {\n configWithDefaults.collections!.push(\n await sanitizeCollection(\n config as unknown as Config,\n getQueryPresetsConfig(config as unknown as Config),\n richTextSanitizationPromises,\n validRelationships,\n ),\n )\n }\n\n if (config.serverURL !== '') {\n config.csrf!.push(config.serverURL!)\n }\n\n const uploadAdapters = new Set<string>()\n // interact with all collections\n for (const collection of config.collections!) {\n // deduped upload adapters\n if (collection.upload?.adapter) {\n uploadAdapters.add(collection.upload.adapter)\n }\n }\n\n if (!config.upload) {\n config.upload = { adapters: [] }\n }\n\n config.upload.adapters = Array.from(\n new Set(config.collections!.map((c) => c.upload?.adapter).filter(Boolean) as string[]),\n )\n\n // Pass through the email config as is so adapters don't break\n if (incomingConfig.email) {\n config.email = incomingConfig.email\n }\n\n /*\n Execute richText sanitization\n */\n if (typeof incomingConfig.editor === 'function') {\n config.editor = await incomingConfig.editor({\n config: config as SanitizedConfig,\n isRoot: true,\n parentIsLocalized: false,\n })\n if (config.editor.i18n && Object.keys(config.editor.i18n).length >= 0) {\n config.i18n.translations = deepMergeSimple(config.i18n.translations, config.editor.i18n)\n }\n }\n\n const promises: Promise<void>[] = []\n\n for (const sanitizeFunction of richTextSanitizationPromises) {\n promises.push(sanitizeFunction(config as SanitizedConfig))\n }\n\n await Promise.all(promises)\n\n return config as SanitizedConfig\n}\n"],"names":["en","deepMergeSimple","defaultUserCollection","authRootEndpoints","sanitizeCollection","migrationsCollection","DuplicateCollection","InvalidConfiguration","defaultTimezones","sanitizeGlobal","resolveHierarchyCollections","baseBlockFields","formatLabels","sanitizeFields","getLockedDocumentsCollection","lockedDocumentsCollectionSlug","getPreferencesCollection","preferencesCollectionSlug","getQueryPresetsConfig","queryPresetsCollectionSlug","getDefaultJobsCollection","jobsCollectionSlug","getJobStatsGlobal","flattenAllFields","flattenBlock","hasScheduledPublishEnabled","validateTimezones","getSchedulePublishTask","addDefaultsToConfig","addOrderableEndpoint","addOrderableFieldsAndHook","sanitizeAdminConfig","configToSanitize","sanitizedConfig","compatibility","allowLocalizedWithinLocalized","process","env","NEXT_PUBLIC_PAYLOAD_COMPATIBILITY_allowLocalizedWithinLocalized","loggingLevels","Forbidden","Locked","MissingFile","NotFound","ValidationError","admin","dashboard","widgets","push","slug","Component","minWidth","defaultLayout","widgetSlug","width","user","firstCollectionWithAuth","collections","find","auth","Boolean","userCollection","timezones","supportedTimezones","source","sanitizeConfig","incomingConfig","configWithDefaults","config","endpoints","endpoint","localization","locales","length","firstLocale","localeCodes","map","locale","code","label","rtl","toString","fallback","i18nConfig","fallbackLanguage","supportedLanguages","translations","i18n","supportedLangKeys","Object","keys","fallbackLang","includes","richTextSanitizationPromises","schedulePublishCollections","queryPresetsCollections","schedulePublishGlobals","collectionSlugs","Set","validRelationships","c","dashboardWidgets","widget","fields","existingFieldNames","parentIsLocalized","blocks","block","sanitizedBlock","_sanitized","concat","labels","flattenedSanitizedBlock","orderableJoins","i","has","add","draftsConfig","versions","drafts","schedulePublish","enableQueryPresets","fieldsToAdd","Map","joinFieldPathsByCollection","collection","orderable","currentFields","get","set","defaultSort","joinInfo","targetCollection","targetCollectionSlug","orderFieldName","currentJoinFieldPaths","joinFieldOn","orderableFields","flattenedFields","size","globals","jobs","tasks","adminUserSlug","enabled","Array","isArray","workflows","hasScheduleProperty","some","task","schedule","workflow","scheduling","stats","defaultJobsCollection","jobsCollectionOverrides","sanitizedJobsCollection","lockedDocumentsCollection","migrations","db","indexSortableFields","indexes","unique","serverURL","csrf","uploadAdapters","upload","adapter","adapters","from","filter","email","editor","isRoot","promises","sanitizeFunction","Promise","all"],"mappings":"AAEA,SAASA,EAAE,QAAQ,wCAAuC;AAC1D,SAASC,eAAe,QAAQ,qCAAoC;AAepE,SAASC,qBAAqB,QAAQ,yBAAwB;AAC9D,SAASC,iBAAiB,QAAQ,6BAA4B;AAC9D,SAASC,kBAAkB,QAAQ,oCAAmC;AACtE,SAASC,oBAAoB,QAAQ,iDAAgD;AACrF,SAASC,mBAAmB,EAAEC,oBAAoB,QAAQ,qBAAoB;AAC9E,SAASC,gBAAgB,QAAQ,oDAAmD;AACpF,SAASC,cAAc,QAAQ,gCAA+B;AAC9D,SAASC,2BAA2B,QAAQ,8CA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