payload 4.0.0-internal.d28e9fb → 4.0.0-internal.fa345ef
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/LICENSE.md +1 -1
- package/bin.js +11 -0
- package/dist/admin/RichText.d.ts +4 -17
- package/dist/admin/RichText.d.ts.map +1 -1
- package/dist/admin/RichText.js.map +1 -1
- package/dist/admin/adapters/cookies.d.ts +21 -0
- package/dist/admin/adapters/cookies.d.ts.map +1 -0
- package/dist/admin/adapters/cookies.js +3 -0
- package/dist/admin/adapters/cookies.js.map +1 -0
- package/dist/admin/adapters/devReload.d.ts +9 -0
- package/dist/admin/adapters/devReload.d.ts.map +1 -0
- package/dist/admin/adapters/devReload.js +6 -0
- package/dist/admin/adapters/devReload.js.map +1 -0
- package/dist/admin/adapters/index.d.ts +7 -0
- package/dist/admin/adapters/index.d.ts.map +1 -0
- package/dist/admin/adapters/index.js +3 -0
- package/dist/admin/adapters/index.js.map +1 -0
- package/dist/admin/adapters/render.d.ts +16 -0
- package/dist/admin/adapters/render.d.ts.map +1 -0
- package/dist/admin/adapters/render.js +7 -0
- package/dist/admin/adapters/render.js.map +1 -0
- package/dist/admin/adapters/router.d.ts +56 -0
- package/dist/admin/adapters/router.d.ts.map +1 -0
- package/dist/admin/adapters/router.js +3 -0
- package/dist/admin/adapters/router.js.map +1 -0
- package/dist/admin/adapters/server.d.ts +23 -0
- package/dist/admin/adapters/server.d.ts.map +1 -0
- package/dist/admin/adapters/server.js +6 -0
- package/dist/admin/adapters/server.js.map +1 -0
- package/dist/admin/adapters/views.d.ts +36 -0
- package/dist/admin/adapters/views.d.ts.map +1 -0
- package/dist/admin/adapters/views.js +7 -0
- package/dist/admin/adapters/views.js.map +1 -0
- package/dist/admin/elements/Table.d.ts +1 -0
- package/dist/admin/elements/Table.d.ts.map +1 -1
- package/dist/admin/elements/Table.js.map +1 -1
- package/dist/admin/fields/Row.d.ts +2 -2
- package/dist/admin/fields/Row.d.ts.map +1 -1
- package/dist/admin/fields/Row.js.map +1 -1
- package/dist/admin/forms/Description.d.ts +2 -2
- package/dist/admin/forms/Description.d.ts.map +1 -1
- package/dist/admin/forms/Description.js.map +1 -1
- package/dist/admin/forms/Field.d.ts +10 -5
- package/dist/admin/forms/Field.d.ts.map +1 -1
- package/dist/admin/forms/Field.js.map +1 -1
- package/dist/admin/functions/index.d.ts +9 -0
- 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 +3 -2
- package/dist/admin/types.d.ts.map +1 -1
- package/dist/admin/types.js.map +1 -1
- package/dist/admin/views/dashboard.d.ts +7 -0
- package/dist/admin/views/dashboard.d.ts.map +1 -1
- package/dist/admin/views/dashboard.js.map +1 -1
- package/dist/admin/views/document.d.ts +5 -3
- package/dist/admin/views/document.d.ts.map +1 -1
- package/dist/admin/views/document.js.map +1 -1
- package/dist/admin/views/hierarchyList.d.ts +1 -0
- package/dist/admin/views/hierarchyList.d.ts.map +1 -1
- package/dist/admin/views/hierarchyList.js.map +1 -1
- package/dist/admin/views/list.d.ts +10 -1
- package/dist/admin/views/list.d.ts.map +1 -1
- package/dist/admin/views/list.js.map +1 -1
- package/dist/auth/baseFields/apiKey.d.ts +10 -2
- package/dist/auth/baseFields/apiKey.d.ts.map +1 -1
- package/dist/auth/baseFields/apiKey.js +35 -24
- package/dist/auth/baseFields/apiKey.js.map +1 -1
- package/dist/auth/cookies.d.ts.map +1 -1
- package/dist/auth/defaultAccess.d.ts +1 -1
- package/dist/auth/defaultAccess.d.ts.map +1 -1
- package/dist/auth/defaultAccess.js +1 -1
- package/dist/auth/defaultAccess.js.map +1 -1
- package/dist/auth/defaultUser.d.ts.map +1 -1
- package/dist/auth/defaultUser.js +2 -1
- package/dist/auth/defaultUser.js.map +1 -1
- package/dist/auth/ensureUsernameOrEmail.d.ts.map +1 -1
- package/dist/auth/executeAccess.d.ts.map +1 -1
- package/dist/auth/executeAuthStrategies.d.ts.map +1 -1
- package/dist/auth/extractAccessFromPermission.d.ts.map +1 -1
- package/dist/auth/extractJWT.d.ts.map +1 -1
- package/dist/auth/getAuthFields.d.ts.map +1 -1
- package/dist/auth/getAuthFields.js +2 -2
- package/dist/auth/getAuthFields.js.map +1 -1
- package/dist/auth/getFieldsToSign.d.ts.map +1 -1
- package/dist/auth/getLoginOptions.d.ts.map +1 -1
- package/dist/auth/isUserLocked.d.ts.map +1 -1
- package/dist/auth/jwt.d.ts.map +1 -1
- package/dist/auth/operations/access.d.ts.map +1 -1
- package/dist/auth/operations/auth.d.ts +2 -2
- package/dist/auth/operations/auth.d.ts.map +1 -1
- package/dist/auth/operations/auth.js.map +1 -1
- package/dist/auth/operations/forgotPassword.d.ts.map +1 -1
- package/dist/auth/operations/init.d.ts.map +1 -1
- package/dist/auth/operations/local/auth.d.ts.map +1 -1
- package/dist/auth/operations/login.d.ts +2 -1
- package/dist/auth/operations/login.d.ts.map +1 -1
- package/dist/auth/operations/login.js.map +1 -1
- package/dist/auth/operations/logout.d.ts.map +1 -1
- package/dist/auth/operations/me.d.ts.map +1 -1
- package/dist/auth/operations/me.js.map +1 -1
- package/dist/auth/operations/refresh.d.ts.map +1 -1
- package/dist/auth/operations/refresh.js +9 -3
- package/dist/auth/operations/refresh.js.map +1 -1
- package/dist/auth/operations/registerFirstUser.d.ts.map +1 -1
- package/dist/auth/operations/resetPassword.d.ts.map +1 -1
- package/dist/auth/operations/resetPassword.js.map +1 -1
- package/dist/auth/operations/unlock.d.ts.map +1 -1
- package/dist/auth/operations/verifyEmail.d.ts.map +1 -1
- package/dist/auth/sendVerificationEmail.d.ts +2 -2
- package/dist/auth/sendVerificationEmail.d.ts.map +1 -1
- package/dist/auth/sendVerificationEmail.js +1 -1
- package/dist/auth/sendVerificationEmail.js.map +1 -1
- package/dist/auth/sessions.d.ts +4 -5
- package/dist/auth/sessions.d.ts.map +1 -1
- package/dist/auth/sessions.js +5 -3
- package/dist/auth/sessions.js.map +1 -1
- package/dist/auth/strategies/apiKey.d.ts.map +1 -1
- package/dist/auth/strategies/apiKey.js +6 -17
- package/dist/auth/strategies/apiKey.js.map +1 -1
- package/dist/auth/strategies/local/authenticate.d.ts.map +1 -1
- package/dist/auth/strategies/local/generatePasswordSaltHash.d.ts.map +1 -1
- package/dist/auth/strategies/local/incrementLoginAttempts.d.ts +2 -2
- package/dist/auth/strategies/local/incrementLoginAttempts.d.ts.map +1 -1
- package/dist/auth/strategies/local/incrementLoginAttempts.js +1 -1
- package/dist/auth/strategies/local/incrementLoginAttempts.js.map +1 -1
- package/dist/auth/strategies/local/register.d.ts.map +1 -1
- package/dist/auth/strategies/local/resetLoginAttempts.d.ts.map +1 -1
- package/dist/auth/types.d.ts +28 -21
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/auth/types.js.map +1 -1
- package/dist/bin/build.d.ts +25 -0
- package/dist/bin/build.d.ts.map +1 -0
- package/dist/bin/build.js +80 -0
- package/dist/bin/build.js.map +1 -0
- package/dist/bin/build.spec.js +170 -0
- package/dist/bin/build.spec.js.map +1 -0
- package/dist/bin/generateImportMap/index.d.ts.map +1 -1
- package/dist/bin/generateImportMap/index.js +8 -5
- package/dist/bin/generateImportMap/index.js.map +1 -1
- package/dist/bin/generateImportMap/iterateCollections.d.ts.map +1 -1
- package/dist/bin/generateImportMap/iterateCollections.js +11 -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 +12 -0
- package/dist/bin/generateImportMap/iterateConfig.js.map +1 -1
- package/dist/bin/generateImportMap/iterateFields.d.ts.map +1 -1
- package/dist/bin/generateImportMap/iterateFields.js +4 -1
- package/dist/bin/generateImportMap/iterateFields.js.map +1 -1
- package/dist/bin/generateImportMap/utilities/getFromImportMap.d.ts.map +1 -1
- package/dist/bin/generateImportMap/utilities/resolveImportMapFilePath.d.ts +5 -1
- package/dist/bin/generateImportMap/utilities/resolveImportMapFilePath.d.ts.map +1 -1
- package/dist/bin/generateImportMap/utilities/resolveImportMapFilePath.js +32 -18
- package/dist/bin/generateImportMap/utilities/resolveImportMapFilePath.js.map +1 -1
- package/dist/bin/generateTypes.d.ts +3 -2
- package/dist/bin/generateTypes.d.ts.map +1 -1
- package/dist/bin/generateTypes.js +11 -1
- package/dist/bin/generateTypes.js.map +1 -1
- package/dist/bin/index.d.ts.map +1 -1
- package/dist/bin/index.js +9 -0
- package/dist/bin/index.js.map +1 -1
- package/dist/bin/loadEnv.d.ts +3 -1
- package/dist/bin/loadEnv.d.ts.map +1 -1
- package/dist/bin/loadEnv.js +40 -10
- package/dist/bin/loadEnv.js.map +1 -1
- package/dist/bin/migrate.d.ts.map +1 -1
- package/dist/collections/config/client.d.ts +1 -1
- package/dist/collections/config/client.d.ts.map +1 -1
- package/dist/collections/config/client.js +1 -0
- package/dist/collections/config/client.js.map +1 -1
- package/dist/collections/config/defaults.d.ts +0 -4
- package/dist/collections/config/defaults.d.ts.map +1 -1
- package/dist/collections/config/defaults.js +2 -17
- package/dist/collections/config/defaults.js.map +1 -1
- package/dist/collections/config/defaults.spec.js +47 -0
- package/dist/collections/config/defaults.spec.js.map +1 -0
- package/dist/collections/config/sanitize.d.ts +10 -1
- package/dist/collections/config/sanitize.d.ts.map +1 -1
- package/dist/collections/config/sanitize.js +214 -230
- package/dist/collections/config/sanitize.js.map +1 -1
- package/dist/collections/config/sanitizeCompoundIndexes.d.ts.map +1 -1
- package/dist/collections/config/types.d.ts +11 -7
- package/dist/collections/config/types.d.ts.map +1 -1
- package/dist/collections/config/types.js.map +1 -1
- package/dist/collections/config/useAsTitle.d.ts.map +1 -1
- package/dist/collections/dataloader.d.ts.map +1 -1
- package/dist/collections/endpoints/create.d.ts.map +1 -1
- package/dist/collections/endpoints/create.js +0 -2
- package/dist/collections/endpoints/create.js.map +1 -1
- package/dist/collections/endpoints/updateByID.d.ts.map +1 -1
- package/dist/collections/endpoints/updateByID.js +1 -2
- package/dist/collections/endpoints/updateByID.js.map +1 -1
- package/dist/collections/operations/count.d.ts.map +1 -1
- package/dist/collections/operations/count.js +1 -0
- package/dist/collections/operations/count.js.map +1 -1
- package/dist/collections/operations/countVersions.d.ts.map +1 -1
- package/dist/collections/operations/create.d.ts +0 -1
- package/dist/collections/operations/create.d.ts.map +1 -1
- package/dist/collections/operations/create.js +15 -6
- 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 +3 -0
- package/dist/collections/operations/delete.js.map +1 -1
- package/dist/collections/operations/deleteByID.d.ts.map +1 -1
- package/dist/collections/operations/duplicate.d.ts.map +1 -1
- package/dist/collections/operations/find.d.ts.map +1 -1
- package/dist/collections/operations/findByID.d.ts.map +1 -1
- package/dist/collections/operations/findDistinct.d.ts.map +1 -1
- package/dist/collections/operations/findDistinct.js +1 -0
- package/dist/collections/operations/findDistinct.js.map +1 -1
- package/dist/collections/operations/findVersionByID.d.ts.map +1 -1
- package/dist/collections/operations/findVersions.d.ts.map +1 -1
- package/dist/collections/operations/local/count.d.ts +3 -3
- package/dist/collections/operations/local/count.d.ts.map +1 -1
- package/dist/collections/operations/local/count.js.map +1 -1
- package/dist/collections/operations/local/countVersions.d.ts +3 -3
- package/dist/collections/operations/local/countVersions.d.ts.map +1 -1
- package/dist/collections/operations/local/countVersions.js.map +1 -1
- package/dist/collections/operations/local/create.d.ts +3 -3
- package/dist/collections/operations/local/create.d.ts.map +1 -1
- package/dist/collections/operations/local/create.js.map +1 -1
- package/dist/collections/operations/local/delete.d.ts +3 -3
- package/dist/collections/operations/local/delete.d.ts.map +1 -1
- package/dist/collections/operations/local/delete.js.map +1 -1
- package/dist/collections/operations/local/duplicate.d.ts +3 -3
- package/dist/collections/operations/local/duplicate.d.ts.map +1 -1
- package/dist/collections/operations/local/duplicate.js.map +1 -1
- package/dist/collections/operations/local/find.d.ts +3 -3
- package/dist/collections/operations/local/find.d.ts.map +1 -1
- package/dist/collections/operations/local/find.js.map +1 -1
- package/dist/collections/operations/local/findByID.d.ts +3 -3
- package/dist/collections/operations/local/findByID.d.ts.map +1 -1
- package/dist/collections/operations/local/findByID.js.map +1 -1
- package/dist/collections/operations/local/findDistinct.d.ts +2 -2
- package/dist/collections/operations/local/findDistinct.d.ts.map +1 -1
- package/dist/collections/operations/local/findDistinct.js.map +1 -1
- package/dist/collections/operations/local/findVersionByID.d.ts +3 -3
- package/dist/collections/operations/local/findVersionByID.d.ts.map +1 -1
- package/dist/collections/operations/local/findVersionByID.js.map +1 -1
- package/dist/collections/operations/local/findVersions.d.ts +3 -3
- package/dist/collections/operations/local/findVersions.d.ts.map +1 -1
- package/dist/collections/operations/local/findVersions.js.map +1 -1
- package/dist/collections/operations/local/restoreVersion.d.ts +3 -3
- package/dist/collections/operations/local/restoreVersion.d.ts.map +1 -1
- package/dist/collections/operations/local/restoreVersion.js.map +1 -1
- package/dist/collections/operations/local/update.d.ts +7 -11
- package/dist/collections/operations/local/update.d.ts.map +1 -1
- package/dist/collections/operations/local/update.js +1 -2
- package/dist/collections/operations/local/update.js.map +1 -1
- package/dist/collections/operations/restoreVersion.d.ts.map +1 -1
- package/dist/collections/operations/update.d.ts +0 -1
- package/dist/collections/operations/update.d.ts.map +1 -1
- package/dist/collections/operations/update.js +8 -4
- package/dist/collections/operations/update.js.map +1 -1
- package/dist/collections/operations/updateByID.d.ts +0 -1
- package/dist/collections/operations/updateByID.d.ts.map +1 -1
- package/dist/collections/operations/updateByID.js +1 -5
- package/dist/collections/operations/updateByID.js.map +1 -1
- package/dist/collections/operations/utilities/buildAfterOperation.d.ts.map +1 -1
- package/dist/collections/operations/utilities/copyDataWithFreshRowIDs.d.ts +9 -0
- package/dist/collections/operations/utilities/copyDataWithFreshRowIDs.d.ts.map +1 -0
- package/dist/collections/operations/utilities/copyDataWithFreshRowIDs.js +170 -0
- package/dist/collections/operations/utilities/copyDataWithFreshRowIDs.js.map +1 -0
- package/dist/collections/operations/utilities/sanitizeSortQuery.d.ts.map +1 -1
- package/dist/collections/operations/utilities/types.d.ts +0 -9
- package/dist/collections/operations/utilities/types.d.ts.map +1 -1
- package/dist/collections/operations/utilities/types.js.map +1 -1
- package/dist/collections/operations/utilities/update.d.ts +1 -2
- package/dist/collections/operations/utilities/update.d.ts.map +1 -1
- package/dist/collections/operations/utilities/update.js +64 -65
- package/dist/collections/operations/utilities/update.js.map +1 -1
- package/dist/config/build.d.ts.map +1 -1
- package/dist/config/build.js +8 -0
- package/dist/config/build.js.map +1 -1
- package/dist/config/client.d.ts +3 -3
- package/dist/config/client.d.ts.map +1 -1
- package/dist/config/client.js +2 -1
- package/dist/config/client.js.map +1 -1
- package/dist/config/defaults.d.ts +0 -4
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +0 -78
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/definePlugin.d.ts +10 -10
- package/dist/config/definePlugin.d.ts.map +1 -1
- package/dist/config/definePlugin.js +7 -11
- package/dist/config/definePlugin.js.map +1 -1
- package/dist/config/orderable/index.d.ts.map +1 -1
- package/dist/config/orderable/index.js +23 -0
- package/dist/config/orderable/index.js.map +1 -1
- package/dist/config/sanitize.d.ts.map +1 -1
- package/dist/config/sanitize.js +362 -271
- package/dist/config/sanitize.js.map +1 -1
- package/dist/config/types.d.ts +125 -38
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js +2 -0
- package/dist/config/types.js.map +1 -1
- package/dist/database/combineQueries.d.ts.map +1 -1
- package/dist/database/getLocalizedPaths.d.ts.map +1 -1
- package/dist/database/getLocalizedPaths.js +1 -1
- package/dist/database/getLocalizedPaths.js.map +1 -1
- package/dist/database/migrations/findMigrationDir.d.ts.map +1 -1
- package/dist/database/migrations/getPredefinedMigration.d.ts.map +1 -1
- package/dist/database/migrations/migrationsCollection.d.ts.map +1 -1
- package/dist/database/migrations/migrationsCollection.js +2 -1
- package/dist/database/migrations/migrationsCollection.js.map +1 -1
- package/dist/database/migrations/readMigrationFiles.d.ts.map +1 -1
- package/dist/database/migrations/writeMigrationIndex.d.ts.map +1 -1
- package/dist/database/sanitizeJoinQuery.d.ts.map +1 -1
- package/dist/database/sanitizeWhereQuery.d.ts.map +1 -1
- package/dist/duplicateDocument/index.d.ts.map +1 -1
- package/dist/email/getStringifiedToAddress.d.ts.map +1 -1
- package/dist/errors/ValidationError.d.ts +1 -0
- package/dist/errors/ValidationError.d.ts.map +1 -1
- package/dist/errors/ValidationError.js.map +1 -1
- package/dist/exports/internal.d.ts +0 -1
- package/dist/exports/internal.d.ts.map +1 -1
- package/dist/exports/internal.js +0 -1
- package/dist/exports/internal.js.map +1 -1
- package/dist/exports/migrations.d.ts +5 -13
- package/dist/exports/migrations.d.ts.map +1 -1
- package/dist/exports/migrations.js +5 -13
- package/dist/exports/migrations.js.map +1 -1
- package/dist/exports/shared.d.ts +23 -1
- package/dist/exports/shared.d.ts.map +1 -1
- package/dist/exports/shared.js +23 -1
- package/dist/exports/shared.js.map +1 -1
- package/dist/fields/baseFields/slug/countVersions.d.ts.map +1 -1
- package/dist/fields/baseFields/slug/generateSlug.d.ts.map +1 -1
- package/dist/fields/baseFields/slug/index.js +1 -1
- package/dist/fields/baseFields/slug/index.js.map +1 -1
- package/dist/fields/config/client.d.ts +3 -3
- package/dist/fields/config/client.d.ts.map +1 -1
- package/dist/fields/config/client.js +12 -13
- 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 +315 -338
- package/dist/fields/config/sanitize.js.map +1 -1
- package/dist/fields/config/sanitizeJoinField.d.ts.map +1 -1
- package/dist/fields/config/types.d.ts +45 -66
- package/dist/fields/config/types.d.ts.map +1 -1
- package/dist/fields/config/types.js +1 -1
- package/dist/fields/config/types.js.map +1 -1
- package/dist/fields/getDefaultValue.d.ts.map +1 -1
- package/dist/fields/hooks/afterChange/index.d.ts.map +1 -1
- package/dist/fields/hooks/afterChange/promise.d.ts.map +1 -1
- package/dist/fields/hooks/afterChange/promise.js +1 -1
- package/dist/fields/hooks/afterChange/promise.js.map +1 -1
- package/dist/fields/hooks/afterChange/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/promise.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/promise.js +12 -3
- package/dist/fields/hooks/afterRead/promise.js.map +1 -1
- package/dist/fields/hooks/afterRead/relationshipPopulationPromise.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/virtualFieldPopulationPromise.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/cloneDataFromOriginalDoc.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/getExistingRowDoc.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/index.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/promise.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/promise.js +3 -3
- package/dist/fields/hooks/beforeChange/promise.js.map +1 -1
- package/dist/fields/hooks/beforeChange/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/beforeDuplicate/index.d.ts.map +1 -1
- package/dist/fields/hooks/beforeDuplicate/promise.d.ts.map +1 -1
- package/dist/fields/hooks/beforeDuplicate/promise.js +2 -2
- package/dist/fields/hooks/beforeDuplicate/promise.js.map +1 -1
- package/dist/fields/hooks/beforeDuplicate/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/beforeValidate/index.d.ts.map +1 -1
- package/dist/fields/hooks/beforeValidate/promise.d.ts.map +1 -1
- package/dist/fields/hooks/beforeValidate/promise.js +11 -2
- package/dist/fields/hooks/beforeValidate/promise.js.map +1 -1
- package/dist/fields/hooks/beforeValidate/traverseFields.d.ts.map +1 -1
- package/dist/fields/isFieldDisabled.d.ts.map +1 -1
- package/dist/fields/mergeBaseFields.d.ts.map +1 -1
- package/dist/fields/setDefaultBeforeDuplicate.d.ts.map +1 -1
- package/dist/fields/validations.d.ts.map +1 -1
- package/dist/fields/validations.js +5 -4
- package/dist/fields/validations.js.map +1 -1
- package/dist/globals/config/client.d.ts.map +1 -1
- package/dist/globals/config/sanitize.d.ts +6 -1
- package/dist/globals/config/sanitize.d.ts.map +1 -1
- package/dist/globals/config/sanitize.js +122 -132
- package/dist/globals/config/sanitize.js.map +1 -1
- package/dist/globals/config/sanitize.spec.js +43 -0
- package/dist/globals/config/sanitize.spec.js.map +1 -0
- package/dist/globals/endpoints/update.d.ts.map +1 -1
- package/dist/globals/endpoints/update.js +0 -2
- package/dist/globals/endpoints/update.js.map +1 -1
- package/dist/globals/operations/countGlobalVersions.d.ts.map +1 -1
- package/dist/globals/operations/docAccess.d.ts.map +1 -1
- package/dist/globals/operations/findOne.d.ts.map +1 -1
- package/dist/globals/operations/findVersionByID.d.ts.map +1 -1
- package/dist/globals/operations/findVersions.d.ts.map +1 -1
- package/dist/globals/operations/local/countVersions.d.ts +3 -3
- package/dist/globals/operations/local/countVersions.d.ts.map +1 -1
- package/dist/globals/operations/local/countVersions.js.map +1 -1
- package/dist/globals/operations/local/findOne.d.ts +3 -3
- package/dist/globals/operations/local/findOne.d.ts.map +1 -1
- package/dist/globals/operations/local/findOne.js.map +1 -1
- package/dist/globals/operations/local/findVersionByID.d.ts +3 -3
- package/dist/globals/operations/local/findVersionByID.d.ts.map +1 -1
- package/dist/globals/operations/local/findVersionByID.js.map +1 -1
- package/dist/globals/operations/local/findVersions.d.ts +3 -3
- package/dist/globals/operations/local/findVersions.d.ts.map +1 -1
- package/dist/globals/operations/local/findVersions.js.map +1 -1
- package/dist/globals/operations/local/restoreVersion.d.ts +3 -3
- package/dist/globals/operations/local/restoreVersion.d.ts.map +1 -1
- package/dist/globals/operations/local/restoreVersion.js.map +1 -1
- package/dist/globals/operations/local/update.d.ts +7 -9
- package/dist/globals/operations/local/update.d.ts.map +1 -1
- package/dist/globals/operations/local/update.js +1 -2
- package/dist/globals/operations/local/update.js.map +1 -1
- package/dist/globals/operations/restoreVersion.d.ts.map +1 -1
- package/dist/globals/operations/update.d.ts +0 -1
- package/dist/globals/operations/update.d.ts.map +1 -1
- package/dist/globals/operations/update.js +52 -58
- package/dist/globals/operations/update.js.map +1 -1
- package/dist/hierarchy/addHierarchyToCollection.d.ts.map +1 -1
- package/dist/hierarchy/buildParentField.d.ts.map +1 -1
- package/dist/hierarchy/constants.d.ts.map +1 -1
- package/dist/hierarchy/getInitialTreeData.d.ts.map +1 -1
- package/dist/hierarchy/hooks/collectionAfterDelete.d.ts.map +1 -1
- package/dist/hierarchy/hooks/collectionAfterRead.d.ts.map +1 -1
- package/dist/hierarchy/hooks/collectionBeforeChange.d.ts.map +1 -1
- package/dist/hierarchy/hooks/collectionBeforeDelete.d.ts.map +1 -1
- package/dist/hierarchy/hooks/collectionBeforeOperation.d.ts.map +1 -1
- package/dist/hierarchy/hooks/ensureSafeCollectionsChange.d.ts.map +1 -1
- package/dist/hierarchy/injectHierarchyButton.d.ts.map +1 -1
- package/dist/hierarchy/resolveHierarchyCollections.d.ts.map +1 -1
- package/dist/hierarchy/resolveHierarchyCollections.js +1 -1
- package/dist/hierarchy/resolveHierarchyCollections.js.map +1 -1
- package/dist/hierarchy/sanitizeHierarchyCollection.d.ts.map +1 -1
- package/dist/hierarchy/sanitizeHierarchyCollection.js +3 -1
- package/dist/hierarchy/sanitizeHierarchyCollection.js.map +1 -1
- package/dist/hierarchy/types.d.ts +8 -1
- package/dist/hierarchy/types.d.ts.map +1 -1
- package/dist/hierarchy/types.js.map +1 -1
- package/dist/index.bundled.d.ts +808 -366
- package/dist/index.d.ts +72 -24
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +55 -55
- package/dist/index.js.map +1 -1
- package/dist/kv/adapters/DatabaseKVAdapter.d.ts.map +1 -1
- package/dist/kv/adapters/DatabaseKVAdapter.js +1 -0
- package/dist/kv/adapters/DatabaseKVAdapter.js.map +1 -1
- package/dist/locked-documents/config.d.ts.map +1 -1
- package/dist/locked-documents/config.js +2 -1
- package/dist/locked-documents/config.js.map +1 -1
- package/dist/preferences/config.d.ts.map +1 -1
- package/dist/preferences/config.js +2 -1
- package/dist/preferences/config.js.map +1 -1
- package/dist/preferences/deleteUserPreferences.d.ts.map +1 -1
- package/dist/preferences/keys.d.ts +4 -0
- package/dist/preferences/keys.d.ts.map +1 -1
- package/dist/preferences/keys.js +4 -1
- package/dist/preferences/keys.js.map +1 -1
- package/dist/preferences/types.d.ts +15 -0
- package/dist/preferences/types.d.ts.map +1 -1
- package/dist/preferences/types.js +3 -1
- package/dist/preferences/types.js.map +1 -1
- package/dist/query-presets/access.d.ts.map +1 -1
- package/dist/query-presets/config.d.ts.map +1 -1
- package/dist/query-presets/config.js +77 -37
- package/dist/query-presets/config.js.map +1 -1
- package/dist/query-presets/constraints.d.ts.map +1 -1
- package/dist/query-presets/constraints.js +3 -2
- package/dist/query-presets/constraints.js.map +1 -1
- package/dist/queues/config/collection.d.ts.map +1 -1
- package/dist/queues/config/collection.js +2 -1
- package/dist/queues/config/collection.js.map +1 -1
- package/dist/queues/config/generateJobsJSONSchemas.d.ts +1 -1
- package/dist/queues/config/generateJobsJSONSchemas.d.ts.map +1 -1
- package/dist/queues/config/generateJobsJSONSchemas.js +33 -12
- package/dist/queues/config/generateJobsJSONSchemas.js.map +1 -1
- package/dist/queues/config/global.d.ts.map +1 -1
- package/dist/queues/config/global.js +2 -1
- package/dist/queues/config/global.js.map +1 -1
- package/dist/queues/endpoints/run.d.ts.map +1 -1
- package/dist/queues/localAPI.d.ts.map +1 -1
- package/dist/queues/operations/handleSchedules/getQueuesWithSchedules.d.ts.map +1 -1
- package/dist/queues/operations/runJobs/index.d.ts.map +1 -1
- package/dist/queues/operations/runJobs/runJSONJob/index.d.ts.map +1 -1
- package/dist/queues/operations/runJobs/runJob/getRunTaskFunction.d.ts.map +1 -1
- package/dist/queues/operations/runJobs/runJob/index.d.ts.map +1 -1
- package/dist/queues/utilities/getJobTaskStatus.d.ts.map +1 -1
- package/dist/translations/getLocalI18n.d.ts.map +1 -1
- package/dist/types/index.d.ts +18 -8
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/uploads/checkFileAccess.d.ts.map +1 -1
- package/dist/uploads/checkFileRestrictions.d.ts.map +1 -1
- package/dist/uploads/docWithFilenameExists.d.ts.map +1 -1
- package/dist/uploads/endpoints/getFileFromURL.d.ts.map +1 -1
- package/dist/uploads/endpoints/getFileFromURL.js +9 -5
- package/dist/uploads/endpoints/getFileFromURL.js.map +1 -1
- package/dist/uploads/fetchAPI-multipart/isEligibleRequest.d.ts.map +1 -1
- package/dist/uploads/fetchAPI-multipart/processNested.d.ts.map +1 -1
- package/dist/uploads/fetchAPI-multipart/utilities.d.ts.map +1 -1
- package/dist/uploads/fileExists.d.ts.map +1 -1
- package/dist/uploads/generateFileData.d.ts +2 -1
- package/dist/uploads/generateFileData.d.ts.map +1 -1
- package/dist/uploads/generateFileData.js +5 -2
- package/dist/uploads/generateFileData.js.map +1 -1
- package/dist/uploads/getBaseFields.d.ts.map +1 -1
- package/dist/uploads/getBaseFields.js +7 -19
- package/dist/uploads/getBaseFields.js.map +1 -1
- package/dist/uploads/getExternalFile.d.ts.map +1 -1
- package/dist/uploads/getFileByPath.d.ts.map +1 -1
- package/dist/uploads/getFileTypeFallback.d.ts.map +1 -1
- package/dist/uploads/getSafeFilename.d.ts.map +1 -1
- package/dist/uploads/image-resizing/createImageSize.d.ts.map +1 -1
- package/dist/uploads/image-resizing/generateImageSizeFilename.d.ts.map +1 -1
- package/dist/uploads/image-resizing/getImageResizeAction.d.ts.map +1 -1
- package/dist/uploads/image-resizing/parseFilename.d.ts.map +1 -1
- package/dist/uploads/image-resizing/sanitizeResizeConfig.d.ts.map +1 -1
- package/dist/uploads/matchMimeType.d.ts +8 -0
- package/dist/uploads/matchMimeType.d.ts.map +1 -0
- package/dist/uploads/matchMimeType.js +19 -0
- package/dist/uploads/matchMimeType.js.map +1 -0
- package/dist/uploads/matchMimeType.spec.js +66 -0
- package/dist/uploads/matchMimeType.spec.js.map +1 -0
- package/dist/uploads/mimeTypeValidator.d.ts.map +1 -1
- package/dist/uploads/safeFetch.d.ts +1 -1
- package/dist/uploads/safeFetch.d.ts.map +1 -1
- package/dist/uploads/safeFetch.js +11 -5
- package/dist/uploads/safeFetch.js.map +1 -1
- package/dist/uploads/saveBufferToFile.d.ts.map +1 -1
- package/dist/uploads/tempFile.d.ts.map +1 -1
- package/dist/uploads/types.d.ts +33 -29
- package/dist/uploads/types.d.ts.map +1 -1
- package/dist/uploads/types.js.map +1 -1
- package/dist/uploads/uploadFiles.d.ts.map +1 -1
- package/dist/utilities/addDataAndFileToRequest.d.ts.map +1 -1
- package/dist/utilities/addDataAndFileToRequest.js +6 -0
- package/dist/utilities/addDataAndFileToRequest.js.map +1 -1
- package/dist/utilities/addLocalesToRequest.d.ts.map +1 -1
- package/dist/utilities/addSelectGenericsToGeneretedTypes.d.ts.map +1 -1
- package/dist/utilities/appendDateTimezoneSelectFields.d.ts.map +1 -1
- package/dist/utilities/appendDateTimezoneSelectFields.js +2 -2
- package/dist/utilities/appendDateTimezoneSelectFields.js.map +1 -1
- package/dist/utilities/appendNonTrashedFilter.d.ts.map +1 -1
- package/dist/utilities/appendUploadSelectFields.d.ts.map +1 -1
- package/dist/utilities/canAccessAdmin.d.ts.map +1 -1
- package/dist/utilities/checkDocumentLockStatus.d.ts.map +1 -1
- package/dist/utilities/configToJSONSchema.d.ts +68 -16
- package/dist/utilities/configToJSONSchema.d.ts.map +1 -1
- package/dist/utilities/configToJSONSchema.js +311 -117
- package/dist/utilities/configToJSONSchema.js.map +1 -1
- package/dist/utilities/configToJSONSchema.spec.js +619 -85
- package/dist/utilities/configToJSONSchema.spec.js.map +1 -1
- package/dist/utilities/createLocalReq.d.ts +2 -2
- package/dist/utilities/createLocalReq.d.ts.map +1 -1
- package/dist/utilities/createLocalReq.js.map +1 -1
- package/dist/utilities/createPayloadRequest.d.ts.map +1 -1
- package/dist/utilities/createPayloadRequest.js +1 -0
- package/dist/utilities/createPayloadRequest.js.map +1 -1
- package/dist/utilities/deepCopyObject.d.ts.map +1 -1
- package/dist/utilities/deepCopyObject.js +8 -0
- package/dist/utilities/deepCopyObject.js.map +1 -1
- package/dist/utilities/dependencies/dependencyChecker.js +1 -1
- package/dist/utilities/dependencies/dependencyChecker.js.map +1 -1
- package/dist/utilities/dependencies/getDependencies.d.ts.map +1 -1
- package/dist/utilities/dependencies/getDependencies.js +5 -5
- package/dist/utilities/dependencies/getDependencies.js.map +1 -1
- package/dist/utilities/dependencies/resolveFrom.d.ts.map +1 -1
- package/dist/utilities/dynamicImport.js +1 -1
- package/dist/utilities/dynamicImport.js.map +1 -1
- package/dist/utilities/escapeRegExp.d.ts.map +1 -1
- package/dist/utilities/extractID.d.ts.map +1 -1
- package/dist/utilities/filterDataToSelectedLocales.d.ts.map +1 -1
- package/dist/utilities/filterDataToSelectedLocales.js +5 -12
- package/dist/utilities/filterDataToSelectedLocales.js.map +1 -1
- package/dist/utilities/filterDataToSelectedLocales.spec.js +1 -2
- package/dist/utilities/filterDataToSelectedLocales.spec.js.map +1 -1
- package/dist/utilities/flattenAllFields.d.ts.map +1 -1
- package/dist/utilities/flattenAllFields.js +78 -102
- package/dist/utilities/flattenAllFields.js.map +1 -1
- package/dist/utilities/formatAdminURL.d.ts.map +1 -1
- package/dist/utilities/formatErrors.d.ts.map +1 -1
- package/dist/utilities/formatErrors.js +3 -1
- package/dist/utilities/formatErrors.js.map +1 -1
- package/dist/utilities/formatLabels.d.ts.map +1 -1
- package/dist/utilities/getBestFitFromSizes.d.ts.map +1 -1
- package/dist/utilities/getBlockSelect.d.ts.map +1 -1
- package/dist/utilities/getDataByPath.d.ts.map +1 -1
- package/dist/utilities/getEntityPermissions/getEntityPermissions.d.ts.map +1 -1
- package/dist/utilities/getEntityPermissions/getEntityPermissions.js +2 -0
- package/dist/utilities/getEntityPermissions/getEntityPermissions.js.map +1 -1
- package/dist/utilities/getEntityPermissions/populateFieldPermissions.d.ts +7 -1
- package/dist/utilities/getEntityPermissions/populateFieldPermissions.d.ts.map +1 -1
- package/dist/utilities/getEntityPermissions/populateFieldPermissions.js +24 -7
- package/dist/utilities/getEntityPermissions/populateFieldPermissions.js.map +1 -1
- package/dist/utilities/getFieldByPath.d.ts.map +1 -1
- package/dist/utilities/getFieldByPath.js +1 -1
- package/dist/utilities/getFieldByPath.js.map +1 -1
- package/dist/utilities/getFieldPermissions.d.ts.map +1 -1
- package/dist/utilities/getObjectDotNotation.d.ts.map +1 -1
- package/dist/utilities/getRequestEntity.d.ts.map +1 -1
- package/dist/utilities/getRequestLanguage.d.ts +2 -2
- package/dist/utilities/getRequestLanguage.d.ts.map +1 -1
- package/dist/utilities/getRequestLanguage.js.map +1 -1
- package/dist/utilities/getRequestOrigin.d.ts.map +1 -1
- package/dist/utilities/getSafeRedirect.d.ts.map +1 -1
- package/dist/utilities/getSelectMode.d.ts.map +1 -1
- package/dist/utilities/getSiblingData.d.ts.map +1 -1
- package/dist/utilities/getTranslatedLabel.d.ts.map +1 -1
- package/dist/utilities/getVersionsConfig.d.ts.map +1 -1
- package/dist/utilities/getVersionsConfig.js.map +1 -1
- package/dist/utilities/handleEndpoints.d.ts.map +1 -1
- package/dist/utilities/handleEndpoints.js +7 -4
- package/dist/utilities/handleEndpoints.js.map +1 -1
- package/dist/utilities/headersWithCors.d.ts.map +1 -1
- package/dist/utilities/isEntityHidden.d.ts.map +1 -1
- package/dist/utilities/isURLAllowed.d.ts.map +1 -1
- package/dist/utilities/isValidID.d.ts.map +1 -1
- package/dist/utilities/logError.d.ts.map +1 -1
- package/dist/utilities/logger.d.ts.map +1 -1
- package/dist/utilities/mergeHeaders.d.ts.map +1 -1
- package/dist/utilities/mergeListSearchAndWhere.d.ts.map +1 -1
- package/dist/utilities/mergeLocalizedData.d.ts +14 -4
- package/dist/utilities/mergeLocalizedData.d.ts.map +1 -1
- package/dist/utilities/mergeLocalizedData.js +54 -46
- package/dist/utilities/mergeLocalizedData.js.map +1 -1
- package/dist/utilities/mergeLocalizedData.spec.js +23 -23
- package/dist/utilities/mergeLocalizedData.spec.js.map +1 -1
- package/dist/utilities/optionsAreEqual.d.ts.map +1 -1
- package/dist/utilities/parseBooleanString.d.ts.map +1 -1
- package/dist/utilities/parseCookies.d.ts.map +1 -1
- package/dist/utilities/parseParams/index.d.ts +2 -5
- package/dist/utilities/parseParams/index.d.ts.map +1 -1
- package/dist/utilities/parseParams/index.js.map +1 -1
- package/dist/utilities/parseParams/index.spec.js +0 -9
- package/dist/utilities/parseParams/index.spec.js.map +1 -1
- package/dist/utilities/profiling.d.ts.map +1 -1
- package/dist/utilities/reduceFieldsToValues.d.ts.map +1 -1
- package/dist/utilities/resolveSelect.d.ts.map +1 -1
- package/dist/utilities/routeError.d.ts.map +1 -1
- package/dist/utilities/sanitizeFallbackLocale.d.ts.map +1 -1
- package/dist/utilities/sanitizeInternalFields.d.ts.map +1 -1
- package/dist/utilities/sanitizeJoinParams.d.ts.map +1 -1
- package/dist/utilities/sanitizePopulateParam.d.ts.map +1 -1
- package/dist/utilities/sanitizeSelect.d.ts.map +1 -1
- package/dist/utilities/sanitizeSelectParam.d.ts.map +1 -1
- package/dist/utilities/sanitizeSortParams.d.ts.map +1 -1
- package/dist/utilities/setsAreEqual.d.ts.map +1 -1
- package/dist/utilities/slugify.d.ts.map +1 -1
- package/dist/utilities/stripUnselectedFields.d.ts.map +1 -1
- package/dist/utilities/telemetry/events/adminInit.d.ts.map +1 -1
- package/dist/utilities/telemetry/events/serverInit.d.ts.map +1 -1
- package/dist/utilities/telemetry/index.d.ts.map +1 -1
- package/dist/utilities/telemetry/oneWayHash.d.ts.map +1 -1
- package/dist/utilities/timestamp.d.ts.map +1 -1
- package/dist/utilities/toKebabCase.d.ts.map +1 -1
- package/dist/utilities/transformColumnPreferences.d.ts.map +1 -1
- package/dist/utilities/transformColumnPreferences.js +4 -2
- package/dist/utilities/transformColumnPreferences.js.map +1 -1
- package/dist/utilities/transformWhereQuery.d.ts.map +1 -1
- package/dist/utilities/traverseFields.d.ts.map +1 -1
- package/dist/utilities/traverseFields.js +2 -4
- package/dist/utilities/traverseFields.js.map +1 -1
- package/dist/utilities/traverseForLocalizedFields.d.ts.map +1 -1
- package/dist/utilities/traverseForLocalizedFields.js +3 -0
- package/dist/utilities/traverseForLocalizedFields.js.map +1 -1
- package/dist/utilities/unflatten.d.ts.map +1 -1
- package/dist/utilities/validateMimeType.d.ts.map +1 -1
- package/dist/utilities/validateTimezones.d.ts.map +1 -1
- package/dist/utilities/validateWhereQuery.d.ts.map +1 -1
- package/dist/utilities/wordBoundariesRegex.d.ts.map +1 -1
- package/dist/utilities/wrapInternalEndpoints.d.ts.map +1 -1
- package/dist/versions/baseFields.d.ts +1 -2
- package/dist/versions/baseFields.d.ts.map +1 -1
- package/dist/versions/baseFields.js +0 -13
- package/dist/versions/baseFields.js.map +1 -1
- package/dist/versions/buildCollectionFields.d.ts.map +1 -1
- package/dist/versions/buildCollectionFields.js +0 -2
- package/dist/versions/buildCollectionFields.js.map +1 -1
- package/dist/versions/buildGlobalFields.d.ts.map +1 -1
- package/dist/versions/buildGlobalFields.js +0 -2
- package/dist/versions/buildGlobalFields.js.map +1 -1
- package/dist/versions/buildSingleLocalePublishData.d.ts +32 -0
- package/dist/versions/buildSingleLocalePublishData.d.ts.map +1 -0
- package/dist/versions/buildSingleLocalePublishData.js +37 -0
- package/dist/versions/buildSingleLocalePublishData.js.map +1 -0
- package/dist/versions/buildVersionCompoundIndexes.d.ts.map +1 -1
- package/dist/versions/deleteCollectionVersions.d.ts.map +1 -1
- package/dist/versions/deleteScheduledPublishJobs.d.ts.map +1 -1
- package/dist/versions/drafts/appendVersionToQueryKey.d.ts.map +1 -1
- package/dist/versions/drafts/getQueryDraftsSelect.d.ts.map +1 -1
- package/dist/versions/drafts/getQueryDraftsSort.d.ts.map +1 -1
- package/dist/versions/drafts/replaceWithDraftIfAvailable.d.ts.map +1 -1
- package/dist/versions/enforceMaxVersions.d.ts.map +1 -1
- package/dist/versions/getLatestCollectionVersion.d.ts.map +1 -1
- package/dist/versions/getLatestGlobalVersion.d.ts.map +1 -1
- package/dist/versions/migrations/localizeStatus/shared.d.ts.map +1 -1
- package/dist/versions/saveVersion.d.ts +0 -2
- package/dist/versions/saveVersion.d.ts.map +1 -1
- package/dist/versions/saveVersion.js +12 -17
- package/dist/versions/saveVersion.js.map +1 -1
- package/dist/versions/schedule/job.d.ts.map +1 -1
- package/dist/versions/schedule/job.js +2 -9
- package/dist/versions/schedule/job.js.map +1 -1
- package/dist/versions/types.d.ts +2 -15
- package/dist/versions/types.d.ts.map +1 -1
- package/dist/versions/types.js.map +1 -1
- package/package.json +23 -20
- package/dist/database/migrations/templates/localizeStatus.d.ts +0 -10
- package/dist/database/migrations/templates/localizeStatus.d.ts.map +0 -1
- package/dist/database/migrations/templates/localizeStatus.js +0 -54
- package/dist/database/migrations/templates/localizeStatus.js.map +0 -1
- package/dist/utilities/sanitizeProfiler.d.ts +0 -38
- package/dist/utilities/sanitizeProfiler.d.ts.map +0 -1
- package/dist/utilities/sanitizeProfiler.js +0 -101
- package/dist/utilities/sanitizeProfiler.js.map +0 -1
- package/dist/versions/migrations/localizeStatus/index.d.ts +0 -12
- package/dist/versions/migrations/localizeStatus/index.d.ts.map +0 -1
- package/dist/versions/migrations/localizeStatus/index.js +0 -33
- package/dist/versions/migrations/localizeStatus/index.js.map +0 -1
- package/dist/versions/migrations/localizeStatus/mongo/down.d.ts +0 -9
- package/dist/versions/migrations/localizeStatus/mongo/down.d.ts.map +0 -1
- package/dist/versions/migrations/localizeStatus/mongo/down.js +0 -112
- package/dist/versions/migrations/localizeStatus/mongo/down.js.map +0 -1
- package/dist/versions/migrations/localizeStatus/mongo/index.d.ts +0 -8
- package/dist/versions/migrations/localizeStatus/mongo/index.d.ts.map +0 -1
- package/dist/versions/migrations/localizeStatus/mongo/index.js +0 -8
- package/dist/versions/migrations/localizeStatus/mongo/index.js.map +0 -1
- package/dist/versions/migrations/localizeStatus/mongo/up.d.ts +0 -9
- package/dist/versions/migrations/localizeStatus/mongo/up.d.ts.map +0 -1
- package/dist/versions/migrations/localizeStatus/mongo/up.js +0 -220
- package/dist/versions/migrations/localizeStatus/mongo/up.js.map +0 -1
- package/dist/versions/migrations/localizeStatus/sql/down.d.ts +0 -11
- package/dist/versions/migrations/localizeStatus/sql/down.d.ts.map +0 -1
- package/dist/versions/migrations/localizeStatus/sql/down.js +0 -213
- package/dist/versions/migrations/localizeStatus/sql/down.js.map +0 -1
- package/dist/versions/migrations/localizeStatus/sql/index.d.ts +0 -8
- package/dist/versions/migrations/localizeStatus/sql/index.d.ts.map +0 -1
- package/dist/versions/migrations/localizeStatus/sql/index.js +0 -8
- package/dist/versions/migrations/localizeStatus/sql/index.js.map +0 -1
- package/dist/versions/migrations/localizeStatus/sql/migrateMainCollection.d.ts +0 -13
- package/dist/versions/migrations/localizeStatus/sql/migrateMainCollection.d.ts.map +0 -1
- package/dist/versions/migrations/localizeStatus/sql/migrateMainCollection.js +0 -51
- package/dist/versions/migrations/localizeStatus/sql/migrateMainCollection.js.map +0 -1
- package/dist/versions/migrations/localizeStatus/sql/migrateMainGlobal.d.ts +0 -13
- package/dist/versions/migrations/localizeStatus/sql/migrateMainGlobal.d.ts.map +0 -1
- package/dist/versions/migrations/localizeStatus/sql/migrateMainGlobal.js +0 -54
- package/dist/versions/migrations/localizeStatus/sql/migrateMainGlobal.js.map +0 -1
- package/dist/versions/migrations/localizeStatus/sql/up.d.ts +0 -11
- package/dist/versions/migrations/localizeStatus/sql/up.d.ts.map +0 -1
- package/dist/versions/migrations/localizeStatus/sql/up.js +0 -277
- package/dist/versions/migrations/localizeStatus/sql/up.js.map +0 -1
- package/dist/versions/saveSnapshot.d.ts +0 -18
- package/dist/versions/saveSnapshot.d.ts.map +0 -1
- package/dist/versions/saveSnapshot.js +0 -38
- package/dist/versions/saveSnapshot.js.map +0 -1
|
@@ -10,16 +10,13 @@ import { getSelectMode } from '../../utilities/getSelectMode.js';
|
|
|
10
10
|
import { hasDraftsEnabled, hasDraftValidationEnabled, hasLocalizeStatusEnabled } from '../../utilities/getVersionsConfig.js';
|
|
11
11
|
import { initTransaction } from '../../utilities/initTransaction.js';
|
|
12
12
|
import { killTransaction } from '../../utilities/killTransaction.js';
|
|
13
|
-
import { mergeLocalizedData } from '../../utilities/mergeLocalizedData.js';
|
|
14
13
|
import { resolveSelect } from '../../utilities/resolveSelect.js';
|
|
15
14
|
import { sanitizeSelect } from '../../utilities/sanitizeSelect.js';
|
|
15
|
+
import { buildLocalizedPublishData } from '../../versions/buildSingleLocalePublishData.js';
|
|
16
16
|
import { getLatestGlobalVersion } from '../../versions/getLatestGlobalVersion.js';
|
|
17
17
|
import { saveVersion } from '../../versions/saveVersion.js';
|
|
18
18
|
export const updateOperation = async (args)=>{
|
|
19
|
-
|
|
20
|
-
args.req.locale = args.publishSpecificLocale;
|
|
21
|
-
}
|
|
22
|
-
const { slug, autosave, depth, disableTransaction, draft: draftArg, globalConfig, overrideAccess, overrideLock, populate, publishAllLocales: publishAllLocalesArg, publishSpecificLocale, req: { fallbackLocale, locale, payload, payload: { config } = {} }, req, select: incomingSelect, showHiddenFields, unpublishAllLocales: unpublishAllLocalesArg } = args;
|
|
19
|
+
const { slug, autosave, depth, disableTransaction, draft: draftArg, globalConfig, overrideAccess, overrideLock, populate, publishAllLocales: publishAllLocalesArg, req: { fallbackLocale, locale, payload, payload: { config } = {} }, req, select: incomingSelect, showHiddenFields, unpublishAllLocales: unpublishAllLocalesArg } = args;
|
|
23
20
|
try {
|
|
24
21
|
const shouldCommit = !disableTransaction && await initTransaction(req);
|
|
25
22
|
// /////////////////////////////////////
|
|
@@ -38,7 +35,7 @@ export const updateOperation = async (args)=>{
|
|
|
38
35
|
}
|
|
39
36
|
}
|
|
40
37
|
let { data } = args;
|
|
41
|
-
const publishAllLocales = !draftArg && (publishAllLocalesArg ?? (hasLocalizeStatusEnabled(globalConfig) ? false : true));
|
|
38
|
+
const publishAllLocales = !draftArg && (publishAllLocalesArg ?? (hasLocalizeStatusEnabled(globalConfig) && locale !== 'all' ? false : true));
|
|
42
39
|
const unpublishAllLocales = typeof unpublishAllLocalesArg === 'string' ? unpublishAllLocalesArg === 'true' : !!unpublishAllLocalesArg;
|
|
43
40
|
const isSavingDraft = Boolean(draftArg && hasDraftsEnabled(globalConfig)) && data._status !== 'published' && !publishAllLocales;
|
|
44
41
|
if (isSavingDraft) {
|
|
@@ -61,7 +58,7 @@ export const updateOperation = async (args)=>{
|
|
|
61
58
|
const globalVersionResult = await getLatestGlobalVersion({
|
|
62
59
|
slug,
|
|
63
60
|
config: globalConfig,
|
|
64
|
-
locale: locale,
|
|
61
|
+
locale: publishAllLocales || unpublishAllLocales ? 'all' : locale,
|
|
65
62
|
payload,
|
|
66
63
|
req,
|
|
67
64
|
where: query
|
|
@@ -155,14 +152,20 @@ export const updateOperation = async (args)=>{
|
|
|
155
152
|
unpublishAllLocales
|
|
156
153
|
};
|
|
157
154
|
let result = await beforeChange(beforeChangeArgs);
|
|
158
|
-
|
|
155
|
+
if (config?.localization && hasLocalizeStatusEnabled(globalConfig) && typeof result._status === 'string') {
|
|
156
|
+
const statusStr = result._status;
|
|
157
|
+
result._status = {};
|
|
158
|
+
for (const localeCode of config.localization.localeCodes){
|
|
159
|
+
;
|
|
160
|
+
result._status[localeCode] = statusStr;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
159
163
|
// /////////////////////////////////////
|
|
160
164
|
// Handle Localized Data Merging
|
|
161
165
|
// /////////////////////////////////////
|
|
166
|
+
let localizedPublishData = null;
|
|
162
167
|
if (config && config.localization && globalConfig.versions) {
|
|
163
|
-
|
|
164
|
-
let snapshotData;
|
|
165
|
-
if (globalConfig.versions.drafts && globalConfig.versions.drafts.localizeStatus) {
|
|
168
|
+
if (hasLocalizeStatusEnabled(globalConfig)) {
|
|
166
169
|
if (publishAllLocales || unpublishAllLocales) {
|
|
167
170
|
let accessibleLocaleCodes = config.localization.localeCodes;
|
|
168
171
|
if (config.localization.filterAvailableLocales) {
|
|
@@ -178,43 +181,26 @@ export const updateOperation = async (args)=>{
|
|
|
178
181
|
for (const localeCode of accessibleLocaleCodes){
|
|
179
182
|
result._status[localeCode] = unpublishAllLocales ? 'draft' : 'published';
|
|
180
183
|
}
|
|
181
|
-
} else if (!isSavingDraft) {
|
|
182
|
-
|
|
183
|
-
currentGlobal = await payload.db.findGlobal({
|
|
184
|
+
} else if (!isSavingDraft && result._status && typeof result._status === 'object' && !Array.isArray(result._status) && result._status[locale] === 'published') {
|
|
185
|
+
const currentGlobal = await payload.db.findGlobal({
|
|
184
186
|
slug: globalConfig.slug,
|
|
187
|
+
locale: 'all',
|
|
185
188
|
req,
|
|
186
189
|
where: query
|
|
187
190
|
});
|
|
188
|
-
|
|
191
|
+
localizedPublishData = buildLocalizedPublishData({
|
|
192
|
+
config,
|
|
193
|
+
currentDoc: currentGlobal,
|
|
194
|
+
fields: globalConfig.fields,
|
|
195
|
+
locale: locale,
|
|
196
|
+
result
|
|
197
|
+
});
|
|
189
198
|
}
|
|
190
|
-
} else if (publishSpecificLocale) {
|
|
191
|
-
// previous way of publishing a single locale
|
|
192
|
-
currentGlobal = (await getLatestGlobalVersion({
|
|
193
|
-
slug,
|
|
194
|
-
config: globalConfig,
|
|
195
|
-
payload,
|
|
196
|
-
published: true,
|
|
197
|
-
req,
|
|
198
|
-
where: query
|
|
199
|
-
})).global;
|
|
200
|
-
snapshotData = {
|
|
201
|
-
...result,
|
|
202
|
-
_status: 'draft'
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
if (snapshotData) {
|
|
206
|
-
snapshotToSave = deepCopyObjectSimple(snapshotData);
|
|
207
|
-
result = mergeLocalizedData({
|
|
208
|
-
configBlockReferences: config.blocks,
|
|
209
|
-
dataWithLocales: result || {},
|
|
210
|
-
docWithLocales: currentGlobal || {},
|
|
211
|
-
fields: globalConfig.fields,
|
|
212
|
-
selectedLocales: [
|
|
213
|
-
locale
|
|
214
|
-
]
|
|
215
|
-
});
|
|
216
199
|
}
|
|
217
200
|
}
|
|
201
|
+
const dataToUpdate = {
|
|
202
|
+
...localizedPublishData ?? result
|
|
203
|
+
};
|
|
218
204
|
// /////////////////////////////////////
|
|
219
205
|
// Update
|
|
220
206
|
// /////////////////////////////////////
|
|
@@ -227,59 +213,67 @@ export const updateOperation = async (args)=>{
|
|
|
227
213
|
select: incomingSelect
|
|
228
214
|
})
|
|
229
215
|
});
|
|
216
|
+
let resultWithLocales = result;
|
|
230
217
|
if (!isSavingDraft) {
|
|
231
218
|
const now = new Date().toISOString();
|
|
232
219
|
// Ensure global has createdAt
|
|
233
|
-
if (!
|
|
234
|
-
|
|
220
|
+
if (!dataToUpdate.createdAt) {
|
|
221
|
+
dataToUpdate.createdAt = now;
|
|
235
222
|
}
|
|
236
223
|
// Ensure updatedAt date is always updated
|
|
237
|
-
|
|
224
|
+
dataToUpdate.updatedAt = now;
|
|
238
225
|
if (globalExists) {
|
|
239
|
-
|
|
226
|
+
resultWithLocales = await payload.db.updateGlobal({
|
|
240
227
|
slug,
|
|
241
|
-
data:
|
|
228
|
+
data: dataToUpdate,
|
|
242
229
|
req,
|
|
243
230
|
select
|
|
244
231
|
});
|
|
245
232
|
} else {
|
|
246
|
-
|
|
233
|
+
resultWithLocales = await payload.db.createGlobal({
|
|
247
234
|
slug,
|
|
248
|
-
data:
|
|
235
|
+
data: dataToUpdate,
|
|
249
236
|
req
|
|
250
237
|
});
|
|
251
238
|
}
|
|
239
|
+
resultWithLocales.updatedAt = now;
|
|
240
|
+
if (localizedPublishData) {
|
|
241
|
+
// Keep full locale payload for version writes during single-locale publish.
|
|
242
|
+
resultWithLocales = {
|
|
243
|
+
...result,
|
|
244
|
+
createdAt: resultWithLocales.createdAt ?? result.createdAt ?? now,
|
|
245
|
+
updatedAt: now
|
|
246
|
+
};
|
|
247
|
+
}
|
|
252
248
|
}
|
|
253
249
|
// /////////////////////////////////////
|
|
254
250
|
// Create version
|
|
255
251
|
// /////////////////////////////////////
|
|
256
252
|
if (globalConfig.versions) {
|
|
257
|
-
const { globalType } =
|
|
258
|
-
|
|
253
|
+
const { globalType } = resultWithLocales;
|
|
254
|
+
resultWithLocales = await saveVersion({
|
|
259
255
|
autosave,
|
|
260
|
-
docWithLocales:
|
|
256
|
+
docWithLocales: resultWithLocales,
|
|
261
257
|
draft: isSavingDraft,
|
|
262
258
|
global: globalConfig,
|
|
263
259
|
operation: 'update',
|
|
264
260
|
payload,
|
|
265
|
-
publishSpecificLocale,
|
|
266
261
|
req,
|
|
267
262
|
select,
|
|
268
|
-
snapshot: snapshotToSave,
|
|
269
263
|
unpublish: unpublishAllLocales
|
|
270
264
|
});
|
|
271
|
-
|
|
272
|
-
...
|
|
265
|
+
resultWithLocales = {
|
|
266
|
+
...resultWithLocales,
|
|
273
267
|
globalType
|
|
274
268
|
};
|
|
275
269
|
}
|
|
276
270
|
// /////////////////////////////////////
|
|
277
271
|
// Execute globalType field if not selected
|
|
278
272
|
// /////////////////////////////////////
|
|
279
|
-
if (select &&
|
|
273
|
+
if (select && resultWithLocales.globalType) {
|
|
280
274
|
const selectMode = getSelectMode(select);
|
|
281
275
|
if (selectMode === 'include' && !select['globalType'] || selectMode === 'exclude' && select['globalType'] === false) {
|
|
282
|
-
delete
|
|
276
|
+
delete resultWithLocales['globalType'];
|
|
283
277
|
}
|
|
284
278
|
}
|
|
285
279
|
// /////////////////////////////////////
|
|
@@ -289,7 +283,7 @@ export const updateOperation = async (args)=>{
|
|
|
289
283
|
collection: null,
|
|
290
284
|
context: req.context,
|
|
291
285
|
depth: depth,
|
|
292
|
-
doc:
|
|
286
|
+
doc: resultWithLocales,
|
|
293
287
|
draft: draftArg,
|
|
294
288
|
fallbackLocale: null,
|
|
295
289
|
global: globalConfig,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/globals/operations/update.ts"],"sourcesContent":["import type { DeepPartial } from 'ts-essentials'\n\nimport type { FindOptions } from '../../collections/operations/local/find.js'\nimport type { GlobalSlug, JsonObject } from '../../index.js'\nimport type {\n Operation,\n PayloadRequest,\n PopulateType,\n SelectType,\n TransformGlobalWithSelect,\n Where,\n} from '../../types/index.js'\nimport type {\n DataFromGlobalSlug,\n SanitizedGlobalConfig,\n SelectFromGlobalSlug,\n} from '../config/types.js'\n\nimport { executeAccess } from '../../auth/executeAccess.js'\nimport { afterChange } from '../../fields/hooks/afterChange/index.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { beforeChange } from '../../fields/hooks/beforeChange/index.js'\nimport { beforeValidate } from '../../fields/hooks/beforeValidate/index.js'\nimport { deepCopyObjectSimple } from '../../index.js'\nimport { checkDocumentLockStatus } from '../../utilities/checkDocumentLockStatus.js'\nimport { commitTransaction } from '../../utilities/commitTransaction.js'\nimport { getSelectMode } from '../../utilities/getSelectMode.js'\nimport {\n hasDraftsEnabled,\n hasDraftValidationEnabled,\n hasLocalizeStatusEnabled,\n} from '../../utilities/getVersionsConfig.js'\nimport { initTransaction } from '../../utilities/initTransaction.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport { mergeLocalizedData } from '../../utilities/mergeLocalizedData.js'\nimport { resolveSelect } from '../../utilities/resolveSelect.js'\nimport { sanitizeSelect } from '../../utilities/sanitizeSelect.js'\nimport { getLatestGlobalVersion } from '../../versions/getLatestGlobalVersion.js'\nimport { saveVersion } from '../../versions/saveVersion.js'\ntype Args<TSlug extends GlobalSlug> = {\n autosave?: boolean\n data: DeepPartial<Omit<DataFromGlobalSlug<TSlug>, 'id'>>\n depth?: number\n disableTransaction?: boolean\n draft?: boolean\n globalConfig: SanitizedGlobalConfig\n overrideAccess?: boolean\n overrideLock?: boolean\n populate?: PopulateType\n publishAllLocales?: boolean\n publishSpecificLocale?: string\n req: PayloadRequest\n showHiddenFields?: boolean\n slug: string\n unpublishAllLocales?: boolean\n} & Pick<FindOptions<string, SelectType>, 'select'>\n\nexport const updateOperation = async <\n TSlug extends GlobalSlug,\n TSelect extends SelectFromGlobalSlug<TSlug>,\n>(\n args: Args<TSlug>,\n): Promise<TransformGlobalWithSelect<TSlug, TSelect>> => {\n if (args.publishSpecificLocale) {\n args.req.locale = args.publishSpecificLocale\n }\n\n const {\n slug,\n autosave,\n depth,\n disableTransaction,\n draft: draftArg,\n globalConfig,\n overrideAccess,\n overrideLock,\n populate,\n publishAllLocales: publishAllLocalesArg,\n publishSpecificLocale,\n req: { fallbackLocale, locale, payload, payload: { config } = {} },\n req,\n select: incomingSelect,\n showHiddenFields,\n unpublishAllLocales: unpublishAllLocalesArg,\n } = args\n\n try {\n const shouldCommit = !disableTransaction && (await initTransaction(req))\n\n // /////////////////////////////////////\n // beforeOperation - Global\n // /////////////////////////////////////\n\n if (globalConfig.hooks?.beforeOperation?.length) {\n for (const hook of globalConfig.hooks.beforeOperation) {\n args =\n (await hook({\n args,\n context: args.req.context,\n global: globalConfig,\n operation: 'update',\n overrideAccess,\n req: args.req,\n })) || args\n }\n }\n\n let { data } = args\n\n const publishAllLocales =\n !draftArg && (publishAllLocalesArg ?? (hasLocalizeStatusEnabled(globalConfig) ? false : true))\n const unpublishAllLocales =\n typeof unpublishAllLocalesArg === 'string'\n ? unpublishAllLocalesArg === 'true'\n : !!unpublishAllLocalesArg\n const isSavingDraft =\n Boolean(draftArg && hasDraftsEnabled(globalConfig)) &&\n data._status !== 'published' &&\n !publishAllLocales\n\n if (isSavingDraft) {\n data._status = 'draft'\n }\n\n // /////////////////////////////////////\n // 1. Retrieve and execute access\n // /////////////////////////////////////\n\n const accessResults = !overrideAccess\n ? await executeAccess(\n {\n data,\n req,\n },\n globalConfig.access.update,\n )\n : true\n\n // /////////////////////////////////////\n // Retrieve document\n // /////////////////////////////////////\n\n const query: Where = overrideAccess ? undefined! : (accessResults as Where)\n\n // /////////////////////////////////////\n // 2. Retrieve document\n // /////////////////////////////////////\n const globalVersionResult = await getLatestGlobalVersion({\n slug,\n config: globalConfig,\n locale: locale!,\n payload,\n req,\n where: query,\n })\n const { global, globalExists } = globalVersionResult || {}\n\n let globalJSON: JsonObject = {}\n\n if (globalVersionResult && globalVersionResult.global) {\n globalJSON = deepCopyObjectSimple(global)\n\n if (globalJSON._id) {\n delete globalJSON._id\n }\n }\n\n const originalDoc = await afterRead({\n collection: null,\n context: req.context,\n depth: 0,\n doc: deepCopyObjectSimple(globalJSON),\n draft: draftArg!,\n fallbackLocale: fallbackLocale!,\n global: globalConfig,\n locale: locale!,\n overrideAccess: true,\n req,\n showHiddenFields: showHiddenFields!,\n })\n\n // ///////////////////////////////////////////\n // Handle potentially locked global documents\n // ///////////////////////////////////////////\n\n await checkDocumentLockStatus({\n globalSlug: slug,\n lockErrorMessage: `Global with slug \"${slug}\" is currently locked by another user and cannot be updated.`,\n overrideLock,\n req,\n })\n\n // /////////////////////////////////////\n // beforeValidate - Fields\n // /////////////////////////////////////\n\n data = await beforeValidate({\n collection: null,\n context: req.context,\n data,\n doc: originalDoc,\n global: globalConfig,\n operation: 'update',\n overrideAccess: overrideAccess!,\n req,\n })\n\n // /////////////////////////////////////\n // beforeValidate - Global\n // /////////////////////////////////////\n\n if (globalConfig.hooks?.beforeValidate?.length) {\n for (const hook of globalConfig.hooks.beforeValidate) {\n data =\n (await hook({\n context: req.context,\n data,\n global: globalConfig,\n originalDoc,\n overrideAccess,\n req,\n })) || data\n }\n }\n\n // /////////////////////////////////////\n // beforeChange - Global\n // /////////////////////////////////////\n\n if (globalConfig.hooks?.beforeChange?.length) {\n for (const hook of globalConfig.hooks.beforeChange) {\n data =\n (await hook({\n context: req.context,\n data,\n global: globalConfig,\n originalDoc,\n overrideAccess,\n req,\n })) || data\n }\n }\n\n // /////////////////////////////////////\n // beforeChange - Fields\n // /////////////////////////////////////\n\n const beforeChangeArgs = {\n collection: null,\n context: req.context,\n data,\n doc: originalDoc,\n docWithLocales: globalJSON,\n global: globalConfig,\n operation: 'update' as Operation,\n req,\n skipValidation:\n (isSavingDraft && !hasDraftValidationEnabled(globalConfig)) ||\n // Skip validation for unpublish operations — they only change _status, not document data\n unpublishAllLocales,\n }\n\n let result: JsonObject = await beforeChange(beforeChangeArgs)\n let snapshotToSave: JsonObject | undefined\n\n // /////////////////////////////////////\n // Handle Localized Data Merging\n // /////////////////////////////////////\n\n if (config && config.localization && globalConfig.versions) {\n let currentGlobal: JsonObject | null = null\n let snapshotData: JsonObject | undefined\n\n if (globalConfig.versions.drafts && globalConfig.versions.drafts.localizeStatus) {\n if (publishAllLocales || unpublishAllLocales) {\n let accessibleLocaleCodes = config.localization.localeCodes\n\n if (config.localization.filterAvailableLocales) {\n const filteredLocales = await config.localization.filterAvailableLocales({\n locales: config.localization.locales,\n req,\n })\n accessibleLocaleCodes = filteredLocales.map((locale) =>\n typeof locale === 'string' ? locale : locale.code,\n )\n }\n\n if (typeof result._status !== 'object' || result._status === null) {\n result._status = {}\n }\n\n for (const localeCode of accessibleLocaleCodes) {\n result._status[localeCode] = unpublishAllLocales ? 'draft' : 'published'\n }\n } else if (!isSavingDraft) {\n // publishing a single locale\n currentGlobal = await payload.db.findGlobal({\n slug: globalConfig.slug,\n req,\n where: query,\n })\n snapshotData = result\n }\n } else if (publishSpecificLocale) {\n // previous way of publishing a single locale\n currentGlobal = (\n await getLatestGlobalVersion({\n slug,\n config: globalConfig,\n payload,\n published: true,\n req,\n where: query,\n })\n ).global\n snapshotData = {\n ...result,\n _status: 'draft',\n }\n }\n\n if (snapshotData) {\n snapshotToSave = deepCopyObjectSimple(snapshotData)\n\n result = mergeLocalizedData({\n configBlockReferences: config.blocks,\n dataWithLocales: result || {},\n docWithLocales: currentGlobal || {},\n fields: globalConfig.fields,\n selectedLocales: [locale!],\n })\n }\n }\n // /////////////////////////////////////\n // Update\n // /////////////////////////////////////\n\n const select = sanitizeSelect({\n fields: globalConfig.flattenedFields,\n select: resolveSelect({\n config: globalConfig.select,\n operation: 'update',\n req,\n select: incomingSelect,\n }),\n })\n\n if (!isSavingDraft) {\n const now = new Date().toISOString()\n // Ensure global has createdAt\n if (!result.createdAt) {\n result.createdAt = now\n }\n\n // Ensure updatedAt date is always updated\n result.updatedAt = now\n\n if (globalExists) {\n result = await payload.db.updateGlobal({\n slug,\n data: result,\n req,\n select,\n })\n } else {\n result = await payload.db.createGlobal({\n slug,\n data: result,\n req,\n })\n }\n }\n\n // /////////////////////////////////////\n // Create version\n // /////////////////////////////////////\n if (globalConfig.versions) {\n const { globalType } = result\n result = await saveVersion({\n autosave,\n docWithLocales: result,\n draft: isSavingDraft,\n global: globalConfig,\n operation: 'update',\n payload,\n publishSpecificLocale,\n req,\n select,\n snapshot: snapshotToSave,\n unpublish: unpublishAllLocales,\n })\n\n result = {\n ...result,\n globalType,\n }\n }\n\n // /////////////////////////////////////\n // Execute globalType field if not selected\n // /////////////////////////////////////\n if (select && result.globalType) {\n const selectMode = getSelectMode(select)\n if (\n (selectMode === 'include' && !select['globalType']) ||\n (selectMode === 'exclude' && select['globalType'] === false)\n ) {\n delete result['globalType']\n }\n }\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n result = await afterRead({\n collection: null,\n context: req.context,\n depth: depth!,\n doc: result,\n draft: draftArg!,\n fallbackLocale: null,\n global: globalConfig,\n locale: locale!,\n overrideAccess: overrideAccess!,\n populate,\n req,\n select,\n showHiddenFields: showHiddenFields!,\n })\n\n // /////////////////////////////////////\n // afterRead - Global\n // /////////////////////////////////////\n\n if (globalConfig.hooks?.afterRead?.length) {\n for (const hook of globalConfig.hooks.afterRead) {\n result =\n (await hook({\n context: req.context,\n doc: result,\n global: globalConfig,\n overrideAccess,\n req,\n })) || result\n }\n }\n\n // /////////////////////////////////////\n // afterChange - Fields\n // /////////////////////////////////////\n\n result = await afterChange({\n collection: null,\n context: req.context,\n data,\n doc: result,\n global: globalConfig,\n operation: 'update',\n previousDoc: originalDoc,\n req,\n })\n\n // /////////////////////////////////////\n // afterChange - Global\n // /////////////////////////////////////\n\n if (globalConfig.hooks?.afterChange?.length) {\n for (const hook of globalConfig.hooks.afterChange) {\n result =\n (await hook({\n context: req.context,\n data,\n doc: result,\n global: globalConfig,\n overrideAccess,\n previousDoc: originalDoc,\n req,\n })) || result\n }\n }\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n if (shouldCommit) {\n await commitTransaction(req)\n }\n\n return result as TransformGlobalWithSelect<TSlug, TSelect>\n } catch (error: unknown) {\n await killTransaction(req)\n throw error\n }\n}\n"],"names":["executeAccess","afterChange","afterRead","beforeChange","beforeValidate","deepCopyObjectSimple","checkDocumentLockStatus","commitTransaction","getSelectMode","hasDraftsEnabled","hasDraftValidationEnabled","hasLocalizeStatusEnabled","initTransaction","killTransaction","mergeLocalizedData","resolveSelect","sanitizeSelect","getLatestGlobalVersion","saveVersion","updateOperation","args","publishSpecificLocale","req","locale","slug","autosave","depth","disableTransaction","draft","draftArg","globalConfig","overrideAccess","overrideLock","populate","publishAllLocales","publishAllLocalesArg","fallbackLocale","payload","config","select","incomingSelect","showHiddenFields","unpublishAllLocales","unpublishAllLocalesArg","shouldCommit","hooks","beforeOperation","length","hook","context","global","operation","data","isSavingDraft","Boolean","_status","accessResults","access","update","query","undefined","globalVersionResult","where","globalExists","globalJSON","_id","originalDoc","collection","doc","globalSlug","lockErrorMessage","beforeChangeArgs","docWithLocales","skipValidation","result","snapshotToSave","localization","versions","currentGlobal","snapshotData","drafts","localizeStatus","accessibleLocaleCodes","localeCodes","filterAvailableLocales","filteredLocales","locales","map","code","localeCode","db","findGlobal","published","configBlockReferences","blocks","dataWithLocales","fields","selectedLocales","flattenedFields","now","Date","toISOString","createdAt","updatedAt","updateGlobal","createGlobal","globalType","snapshot","unpublish","selectMode","previousDoc","error"],"mappings":"AAkBA,SAASA,aAAa,QAAQ,8BAA6B;AAC3D,SAASC,WAAW,QAAQ,0CAAyC;AACrE,SAASC,SAAS,QAAQ,wCAAuC;AACjE,SAASC,YAAY,QAAQ,2CAA0C;AACvE,SAASC,cAAc,QAAQ,6CAA4C;AAC3E,SAASC,oBAAoB,QAAQ,iBAAgB;AACrD,SAASC,uBAAuB,QAAQ,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8C,QAAQ;YAC3C,KAAK,MAAMC,QAAQlB,aAAae,KAAK,CAAC5C,WAAW,CAAE;gBACjDyE,SACE,AAAC,MAAM1B,KAAK;oBACVC,SAAS3B,IAAI2B,OAAO;oBACpBG;oBACAgB,KAAKM;oBACLxB,QAAQpB;oBACRC;oBACA+E,aAAa5C;oBACb5C;gBACF,MAAOoD;YACX;QACF;QAEA,wCAAwC;QACxC,iBAAiB;QACjB,wCAAwC;QAExC,IAAI9B,cAAc;YAChB,MAAMrC,kBAAkBe;QAC1B;QAEA,OAAOoD;IACT,EAAE,OAAOqC,OAAgB;QACvB,MAAMlG,gBAAgBS;QACtB,MAAMyF;IACR;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/globals/operations/update.ts"],"sourcesContent":["import type { DeepPartial } from 'ts-essentials'\n\nimport type { FindOptions } from '../../collections/operations/local/find.js'\nimport type { GlobalSlug, JsonObject } from '../../index.js'\nimport type {\n Operation,\n PayloadRequest,\n PopulateType,\n SelectType,\n TransformGlobalWithSelect,\n Where,\n} from '../../types/index.js'\nimport type {\n DataFromGlobalSlug,\n SanitizedGlobalConfig,\n SelectFromGlobalSlug,\n} from '../config/types.js'\n\nimport { executeAccess } from '../../auth/executeAccess.js'\nimport { afterChange } from '../../fields/hooks/afterChange/index.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { beforeChange } from '../../fields/hooks/beforeChange/index.js'\nimport { beforeValidate } from '../../fields/hooks/beforeValidate/index.js'\nimport { deepCopyObjectSimple } from '../../index.js'\nimport { checkDocumentLockStatus } from '../../utilities/checkDocumentLockStatus.js'\nimport { commitTransaction } from '../../utilities/commitTransaction.js'\nimport { getSelectMode } from '../../utilities/getSelectMode.js'\nimport {\n hasDraftsEnabled,\n hasDraftValidationEnabled,\n hasLocalizeStatusEnabled,\n} from '../../utilities/getVersionsConfig.js'\nimport { initTransaction } from '../../utilities/initTransaction.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport { resolveSelect } from '../../utilities/resolveSelect.js'\nimport { sanitizeSelect } from '../../utilities/sanitizeSelect.js'\nimport { buildLocalizedPublishData } from '../../versions/buildSingleLocalePublishData.js'\nimport { getLatestGlobalVersion } from '../../versions/getLatestGlobalVersion.js'\nimport { saveVersion } from '../../versions/saveVersion.js'\ntype Args<TSlug extends GlobalSlug> = {\n autosave?: boolean\n data: DeepPartial<Omit<DataFromGlobalSlug<TSlug>, 'id'>>\n depth?: number\n disableTransaction?: boolean\n draft?: boolean\n globalConfig: SanitizedGlobalConfig\n overrideAccess?: boolean\n overrideLock?: boolean\n populate?: PopulateType\n publishAllLocales?: boolean\n req: PayloadRequest\n showHiddenFields?: boolean\n slug: string\n unpublishAllLocales?: boolean\n} & Pick<FindOptions<string, SelectType>, 'select'>\n\nexport const updateOperation = async <\n TSlug extends GlobalSlug,\n TSelect extends SelectFromGlobalSlug<TSlug>,\n>(\n args: Args<TSlug>,\n): Promise<TransformGlobalWithSelect<TSlug, TSelect>> => {\n const {\n slug,\n autosave,\n depth,\n disableTransaction,\n draft: draftArg,\n globalConfig,\n overrideAccess,\n overrideLock,\n populate,\n publishAllLocales: publishAllLocalesArg,\n req: { fallbackLocale, locale, payload, payload: { config } = {} },\n req,\n select: incomingSelect,\n showHiddenFields,\n unpublishAllLocales: unpublishAllLocalesArg,\n } = args\n\n try {\n const shouldCommit = !disableTransaction && (await initTransaction(req))\n\n // /////////////////////////////////////\n // beforeOperation - Global\n // /////////////////////////////////////\n\n if (globalConfig.hooks?.beforeOperation?.length) {\n for (const hook of globalConfig.hooks.beforeOperation) {\n args =\n (await hook({\n args,\n context: args.req.context,\n global: globalConfig,\n operation: 'update',\n overrideAccess,\n req: args.req,\n })) || args\n }\n }\n\n let { data } = args\n\n const publishAllLocales =\n !draftArg &&\n (publishAllLocalesArg ??\n (hasLocalizeStatusEnabled(globalConfig) && locale !== 'all' ? false : true))\n const unpublishAllLocales =\n typeof unpublishAllLocalesArg === 'string'\n ? unpublishAllLocalesArg === 'true'\n : !!unpublishAllLocalesArg\n const isSavingDraft =\n Boolean(draftArg && hasDraftsEnabled(globalConfig)) &&\n data._status !== 'published' &&\n !publishAllLocales\n\n if (isSavingDraft) {\n data._status = 'draft'\n }\n\n // /////////////////////////////////////\n // 1. Retrieve and execute access\n // /////////////////////////////////////\n\n const accessResults = !overrideAccess\n ? await executeAccess(\n {\n data,\n req,\n },\n globalConfig.access.update,\n )\n : true\n\n // /////////////////////////////////////\n // Retrieve document\n // /////////////////////////////////////\n\n const query: Where = overrideAccess ? undefined! : (accessResults as Where)\n\n // /////////////////////////////////////\n // 2. Retrieve document\n // /////////////////////////////////////\n const globalVersionResult = await getLatestGlobalVersion({\n slug,\n config: globalConfig,\n locale: publishAllLocales || unpublishAllLocales ? 'all' : locale!,\n payload,\n req,\n where: query,\n })\n const { global, globalExists } = globalVersionResult || {}\n\n let globalJSON: JsonObject = {}\n\n if (globalVersionResult && globalVersionResult.global) {\n globalJSON = deepCopyObjectSimple(global)\n\n if (globalJSON._id) {\n delete globalJSON._id\n }\n }\n\n const originalDoc = await afterRead({\n collection: null,\n context: req.context,\n depth: 0,\n doc: deepCopyObjectSimple(globalJSON),\n draft: draftArg!,\n fallbackLocale: fallbackLocale!,\n global: globalConfig,\n locale: locale!,\n overrideAccess: true,\n req,\n showHiddenFields: showHiddenFields!,\n })\n\n // ///////////////////////////////////////////\n // Handle potentially locked global documents\n // ///////////////////////////////////////////\n\n await checkDocumentLockStatus({\n globalSlug: slug,\n lockErrorMessage: `Global with slug \"${slug}\" is currently locked by another user and cannot be updated.`,\n overrideLock,\n req,\n })\n\n // /////////////////////////////////////\n // beforeValidate - Fields\n // /////////////////////////////////////\n\n data = await beforeValidate({\n collection: null,\n context: req.context,\n data,\n doc: originalDoc,\n global: globalConfig,\n operation: 'update',\n overrideAccess: overrideAccess!,\n req,\n })\n\n // /////////////////////////////////////\n // beforeValidate - Global\n // /////////////////////////////////////\n\n if (globalConfig.hooks?.beforeValidate?.length) {\n for (const hook of globalConfig.hooks.beforeValidate) {\n data =\n (await hook({\n context: req.context,\n data,\n global: globalConfig,\n originalDoc,\n overrideAccess,\n req,\n })) || data\n }\n }\n\n // /////////////////////////////////////\n // beforeChange - Global\n // /////////////////////////////////////\n\n if (globalConfig.hooks?.beforeChange?.length) {\n for (const hook of globalConfig.hooks.beforeChange) {\n data =\n (await hook({\n context: req.context,\n data,\n global: globalConfig,\n originalDoc,\n overrideAccess,\n req,\n })) || data\n }\n }\n\n // /////////////////////////////////////\n // beforeChange - Fields\n // /////////////////////////////////////\n\n const beforeChangeArgs = {\n collection: null,\n context: req.context,\n data,\n doc: originalDoc,\n docWithLocales: globalJSON,\n global: globalConfig,\n operation: 'update' as Operation,\n req,\n skipValidation:\n (isSavingDraft && !hasDraftValidationEnabled(globalConfig)) ||\n // Skip validation for unpublish operations — they only change _status, not document data\n unpublishAllLocales,\n }\n\n let result: JsonObject = await beforeChange(beforeChangeArgs)\n\n if (\n config?.localization &&\n hasLocalizeStatusEnabled(globalConfig) &&\n typeof result._status === 'string'\n ) {\n const statusStr = result._status\n result._status = {}\n for (const localeCode of config.localization.localeCodes) {\n ;(result._status as Record<string, unknown>)[localeCode] = statusStr\n }\n }\n\n // /////////////////////////////////////\n // Handle Localized Data Merging\n // /////////////////////////////////////\n\n let localizedPublishData: JsonObject | null = null\n\n if (config && config.localization && globalConfig.versions) {\n if (hasLocalizeStatusEnabled(globalConfig)) {\n if (publishAllLocales || unpublishAllLocales) {\n let accessibleLocaleCodes = config.localization.localeCodes\n\n if (config.localization.filterAvailableLocales) {\n const filteredLocales = await config.localization.filterAvailableLocales({\n locales: config.localization.locales,\n req,\n })\n accessibleLocaleCodes = filteredLocales.map((locale) =>\n typeof locale === 'string' ? locale : locale.code,\n )\n }\n\n if (typeof result._status !== 'object' || result._status === null) {\n result._status = {}\n }\n\n for (const localeCode of accessibleLocaleCodes) {\n result._status[localeCode] = unpublishAllLocales ? 'draft' : 'published'\n }\n } else if (\n !isSavingDraft &&\n result._status &&\n typeof result._status === 'object' &&\n !Array.isArray(result._status) &&\n (result._status as Record<string, unknown>)[locale!] === 'published'\n ) {\n const currentGlobal = await payload.db.findGlobal({\n slug: globalConfig.slug,\n locale: 'all',\n req,\n where: query,\n })\n\n localizedPublishData = buildLocalizedPublishData({\n config,\n currentDoc: currentGlobal as JsonObject,\n fields: globalConfig.fields,\n locale: locale!,\n result,\n })\n }\n }\n }\n\n const dataToUpdate: JsonObject = { ...(localizedPublishData ?? result) }\n\n // /////////////////////////////////////\n // Update\n // /////////////////////////////////////\n\n const select = sanitizeSelect({\n fields: globalConfig.flattenedFields,\n select: resolveSelect({\n config: globalConfig.select,\n operation: 'update',\n req,\n select: incomingSelect,\n }),\n })\n\n let resultWithLocales: JsonObject = result\n\n if (!isSavingDraft) {\n const now = new Date().toISOString()\n // Ensure global has createdAt\n if (!dataToUpdate.createdAt) {\n dataToUpdate.createdAt = now\n }\n\n // Ensure updatedAt date is always updated\n dataToUpdate.updatedAt = now\n\n if (globalExists) {\n resultWithLocales = await payload.db.updateGlobal({\n slug,\n data: dataToUpdate,\n req,\n select,\n })\n } else {\n resultWithLocales = await payload.db.createGlobal({\n slug,\n data: dataToUpdate,\n req,\n })\n }\n\n resultWithLocales.updatedAt = now\n\n if (localizedPublishData) {\n // Keep full locale payload for version writes during single-locale publish.\n resultWithLocales = {\n ...result,\n createdAt: resultWithLocales.createdAt ?? result.createdAt ?? now,\n updatedAt: now,\n }\n }\n }\n\n // /////////////////////////////////////\n // Create version\n // /////////////////////////////////////\n if (globalConfig.versions) {\n const { globalType } = resultWithLocales\n resultWithLocales = await saveVersion({\n autosave,\n docWithLocales: resultWithLocales,\n draft: isSavingDraft,\n global: globalConfig,\n operation: 'update',\n payload,\n req,\n select,\n unpublish: unpublishAllLocales,\n })\n\n resultWithLocales = {\n ...resultWithLocales,\n globalType,\n }\n }\n\n // /////////////////////////////////////\n // Execute globalType field if not selected\n // /////////////////////////////////////\n if (select && resultWithLocales.globalType) {\n const selectMode = getSelectMode(select)\n if (\n (selectMode === 'include' && !select['globalType']) ||\n (selectMode === 'exclude' && select['globalType'] === false)\n ) {\n delete resultWithLocales['globalType']\n }\n }\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n result = await afterRead({\n collection: null,\n context: req.context,\n depth: depth!,\n doc: resultWithLocales,\n draft: draftArg!,\n fallbackLocale: null,\n global: globalConfig,\n locale: locale!,\n overrideAccess: overrideAccess!,\n populate,\n req,\n select,\n showHiddenFields: showHiddenFields!,\n })\n\n // /////////////////////////////////////\n // afterRead - Global\n // /////////////////////////////////////\n\n if (globalConfig.hooks?.afterRead?.length) {\n for (const hook of globalConfig.hooks.afterRead) {\n result =\n (await hook({\n context: req.context,\n doc: result,\n global: globalConfig,\n overrideAccess,\n req,\n })) || result\n }\n }\n\n // /////////////////////////////////////\n // afterChange - Fields\n // /////////////////////////////////////\n\n result = await afterChange({\n collection: null,\n context: req.context,\n data,\n doc: result,\n global: globalConfig,\n operation: 'update',\n previousDoc: originalDoc,\n req,\n })\n\n // /////////////////////////////////////\n // afterChange - Global\n // /////////////////////////////////////\n\n if (globalConfig.hooks?.afterChange?.length) {\n for (const hook of globalConfig.hooks.afterChange) {\n result =\n (await hook({\n context: req.context,\n data,\n doc: result,\n global: globalConfig,\n overrideAccess,\n previousDoc: originalDoc,\n req,\n })) || result\n }\n }\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n if (shouldCommit) {\n await commitTransaction(req)\n }\n\n return result as TransformGlobalWithSelect<TSlug, TSelect>\n } catch (error: unknown) {\n await killTransaction(req)\n throw error\n }\n}\n"],"names":["executeAccess","afterChange","afterRead","beforeChange","beforeValidate","deepCopyObjectSimple","checkDocumentLockStatus","commitTransaction","getSelectMode","hasDraftsEnabled","hasDraftValidationEnabled","hasLocalizeStatusEnabled","initTransaction","killTransaction","resolveSelect","sanitizeSelect","buildLocalizedPublishData","getLatestGlobalVersion","saveVersion","updateOperation","args","slug","autosave","depth","disableTransaction","draft","draftArg","globalConfig","overrideAccess","overrideLock","populate","publishAllLocales","publishAllLocalesArg","req","fallbackLocale","locale","payload","config","select","incomingSelect","showHiddenFields","unpublishAllLocales","unpublishAllLocalesArg","shouldCommit","hooks","beforeOperation","length","hook","context","global","operation","data","isSavingDraft","Boolean","_status","accessResults","access","update","query","undefined","globalVersionResult","where","globalExists","globalJSON","_id","originalDoc","collection","doc","globalSlug","lockErrorMessage","beforeChangeArgs","docWithLocales","skipValidation","result","localization","statusStr","localeCode","localeCodes","localizedPublishData","versions","accessibleLocaleCodes","filterAvailableLocales","filteredLocales","locales","map","code","Array","isArray","currentGlobal","db","findGlobal","currentDoc","fields","dataToUpdate","flattenedFields","resultWithLocales","now","Date","toISOString","createdAt","updatedAt","updateGlobal","createGlobal","globalType","unpublish","selectMode","previousDoc","error"],"mappings":"AAkBA,SAASA,aAAa,QAAQ,8BAA6B;AAC3D,SAASC,WAAW,QAAQ,0CAAyC;AACrE,SAASC,SAAS,QAAQ,wCAAuC;AACjE,SAASC,YAAY,QAAQ,2CAA0C;AACvE,SAASC,cAAc,QAAQ,6CAA4C;AAC3E,SAASC,oBAAoB,QAAQ,iBAAgB;AACrD,SAASC,uBAAuB,QAAQ,6CAA4C;AACpF,SAASC,iBAAiB,QAAQ,uCAAsC;AACxE,SAASC,aAAa,QAAQ,mCAAkC;AAChE,SACEC,gBAAgB,EAChBC,yBAAyB,EACzBC,wBAAwB,QACnB,uCAAsC;AAC7C,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,aAAa,QAAQ,mCAAkC;AAChE,SAASC,cAAc,QAAQ,oCAAmC;AAClE,SAASC,yBAAyB,QAAQ,iDAAgD;AAC1F,SAASC,sBAAsB,QAAQ,2CAA0C;AACjF,SAASC,WAAW,QAAQ,gCAA+B;AAkB3D,OAAO,MAAMC,kBAAkB,OAI7BC;IAEA,MAAM,EACJC,IAAI,EACJC,QAAQ,EACRC,KAAK,EACLC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C;IACT,EAAE,OAAOkC,OAAgB;QACvB,MAAM9F,gBAAgBoB;QACtB,MAAM0E;IACR;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addHierarchyToCollection.d.ts","sourceRoot":"","sources":["../../src/hierarchy/addHierarchyToCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AAQtE,eAAO,MAAM,wBAAwB,
|
|
1
|
+
{"version":3,"file":"addHierarchyToCollection.d.ts","sourceRoot":"","sources":["../../src/hierarchy/addHierarchyToCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AAQtE,eAAO,MAAM,wBAAwB,GAAI,8FAMtC;IACD,gBAAgB,EAAE,gBAAgB,CAAA;IAClC,eAAe,EAAE,MAAM,CAAA;IACvB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,iBAAiB,EAAE,MAAM,CAAA;IACzB,kBAAkB,EAAE,MAAM,CAAA;CAC3B,SAkEA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildParentField.d.ts","sourceRoot":"","sources":["../../src/hierarchy/buildParentField.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAA;AAExE,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"buildParentField.d.ts","sourceRoot":"","sources":["../../src/hierarchy/buildParentField.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAA;AAExE,eAAO,MAAM,gBAAgB,GAAI,qEAK9B;IACD,cAAc,EAAE,MAAM,CAAA;IACtB;;OAEG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,SAAS,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,CAAA;IAC5C,eAAe,EAAE,MAAM,CAAA;CACxB,KAAG,uBA0CH,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/hierarchy/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,eAAO,MAAM,yBAAyB,gBAAgB,CAAA;AACtD,eAAO,MAAM,0BAA0B,iBAAiB,CAAA;AACxD,eAAO,MAAM,wBAAwB,OAAO,CAAA;AAE5C,+CAA+C;AAC/C,eAAO,MAAM,4BAA4B,MAAM,CAAA;AAE/C,0DAA0D;AAC1D,eAAO,MAAM,4BAA4B,KAAK,CAAA;AAE9C,6DAA6D;AAC7D,eAAO,MAAM,sBAAsB,OAAO,CAAA;AAE1C,8FAA8F;AAC9F,eAAO,MAAM,qBAAqB,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/hierarchy/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,eAAO,MAAM,yBAAyB,gBAAgB,CAAA;AACtD,eAAO,MAAM,0BAA0B,iBAAiB,CAAA;AACxD,eAAO,MAAM,wBAAwB,OAAO,CAAA;AAE5C,+CAA+C;AAC/C,eAAO,MAAM,4BAA4B,MAAM,CAAA;AAE/C,0DAA0D;AAC1D,eAAO,MAAM,4BAA4B,KAAK,CAAA;AAE9C,6DAA6D;AAC7D,eAAO,MAAM,sBAAsB,OAAO,CAAA;AAE1C,8FAA8F;AAC9F,eAAO,MAAM,qBAAqB,GAAI,eAAe,MAAM,KAAG,MAA+B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getInitialTreeData.d.ts","sourceRoot":"","sources":["../../src/hierarchy/getInitialTreeData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAI9D,MAAM,MAAM,sBAAsB,GA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C,EAAE,MAAM,EAAE,CAAA;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,cAAc,CAAC,SAAS,CAAC,CAAA;IAClC,uGAAuG;IACvG,cAAc,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAAA;IACvC,oFAAoF;IACpF,oBAAoB,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAAA;IAC7C,IAAI,EAAE,cAAc,CAAC,MAAM,CAAC,CAAA;CAC7B,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,UAAU,EAAE,CAAA;IAElB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAC7F,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAU,mIAUtC,sBAAsB,KAAG,OAAO,CAAC,eAAe,CA0IlD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collectionAfterDelete.d.ts","sourceRoot":"","sources":["../../../src/hierarchy/hooks/collectionAfterDelete.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAA;AAE/D,KAAK,IAAI,GAAG;IACV;;OAEG;IACH,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC3C,CAAA;AAED,eAAO,MAAM,8BAA8B,
|
|
1
|
+
{"version":3,"file":"collectionAfterDelete.d.ts","sourceRoot":"","sources":["../../../src/hierarchy/hooks/collectionAfterDelete.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAA;AAE/D,KAAK,IAAI,GAAG;IACV;;OAEG;IACH,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC3C,CAAA;AAED,eAAO,MAAM,8BAA8B,GACxC,wBAAwB,IAAI,KAAG,yBAgB/B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collectionAfterRead.d.ts","sourceRoot":"","sources":["../../../src/hierarchy/hooks/collectionAfterRead.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAkB,MAAM,gBAAgB,CAAA;AAgC7E,KAAK,IAAI,GAAG;IACV;;OAEG;IACH,eAAe,EAAE,MAAM,CAAA;IACvB;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAA;IACzB;;OAEG;IACH,kBAAkB,EAAE,MAAM,CAAA;CAC3B,CAAA;AAED,eAAO,MAAM,4BAA4B
|
|
1
|
+
{"version":3,"file":"collectionAfterRead.d.ts","sourceRoot":"","sources":["../../../src/hierarchy/hooks/collectionAfterRead.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAkB,MAAM,gBAAgB,CAAA;AAgC7E,KAAK,IAAI,GAAG;IACV;;OAEG;IACH,eAAe,EAAE,MAAM,CAAA;IACvB;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAA;IACzB;;OAEG;IACH,kBAAkB,EAAE,MAAM,CAAA;CAC3B,CAAA;AAED,eAAO,MAAM,4BAA4B,GACtC,4DAA4D,IAAI,KAAG,uBAuDnE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collectionBeforeChange.d.ts","sourceRoot":"","sources":["../../../src/hierarchy/hooks/collectionBeforeChange.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,0BAA0B,EAI3B,MAAM,gBAAgB,CAAA;AAEvB,KAAK,IAAI,GAAG;IACV;;OAEG;IACH,eAAe,EAAE,MAAM,CAAA;CACxB,CAAA;AAED,eAAO,MAAM,+BAA+B,
|
|
1
|
+
{"version":3,"file":"collectionBeforeChange.d.ts","sourceRoot":"","sources":["../../../src/hierarchy/hooks/collectionBeforeChange.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,0BAA0B,EAI3B,MAAM,gBAAgB,CAAA;AAEvB,KAAK,IAAI,GAAG;IACV;;OAEG;IACH,eAAe,EAAE,MAAM,CAAA;CACxB,CAAA;AAED,eAAO,MAAM,+BAA+B,GACzC,qBAAqB,IAAI,KAAG,0BAgC5B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collectionBeforeDelete.d.ts","sourceRoot":"","sources":["../../../src/hierarchy/hooks/collectionBeforeDelete.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAA;AAEhE,KAAK,IAAI,GAAG;IACV;;OAEG;IACH,eAAe,EAAE,MAAM,CAAA;CACxB,CAAA;AAED,eAAO,MAAM,+BAA+B,
|
|
1
|
+
{"version":3,"file":"collectionBeforeDelete.d.ts","sourceRoot":"","sources":["../../../src/hierarchy/hooks/collectionBeforeDelete.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAA;AAEhE,KAAK,IAAI,GAAG;IACV;;OAEG;IACH,eAAe,EAAE,MAAM,CAAA;CACxB,CAAA;AAED,eAAO,MAAM,+BAA+B,GACzC,qBAAqB,IAAI,KAAG,0BAe5B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collectionBeforeOperation.d.ts","sourceRoot":"","sources":["../../../src/hierarchy/hooks/collectionBeforeOperation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAA;AAC5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,KAAK,IAAI,GAAG;IACV;;OAEG;IACH,eAAe,EAAE,MAAM,CAAA;IACvB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAA;IACzB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAA;IACtB;;OAEG;IACH,kBAAkB,EAAE,MAAM,CAAA;CAC3B,CAAA;AA0BD,eAAO,MAAM,kCAAkC,GAAI,KAAK,SAAS,cAAc,
|
|
1
|
+
{"version":3,"file":"collectionBeforeOperation.d.ts","sourceRoot":"","sources":["../../../src/hierarchy/hooks/collectionBeforeOperation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAA;AAC5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,KAAK,IAAI,GAAG;IACV;;OAEG;IACH,eAAe,EAAE,MAAM,CAAA;IACvB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAA;IACzB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAA;IACtB;;OAEG;IACH,kBAAkB,EAAE,MAAM,CAAA;CAC3B,CAAA;AA0BD,eAAO,MAAM,kCAAkC,GAAI,KAAK,SAAS,cAAc,EAAE,4FAM9E,IAAI,KAAG,mBAAmB,CAAC,KAAK,CA0DlC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ensureSafeCollectionsChange.d.ts","sourceRoot":"","sources":["../../../src/hierarchy/hooks/ensureSafeCollectionsChange.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,4BAA4B,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAIjG,eAAO,MAAM,2BAA2B,
|
|
1
|
+
{"version":3,"file":"ensureSafeCollectionsChange.d.ts","sourceRoot":"","sources":["../../../src/hierarchy/hooks/ensureSafeCollectionsChange.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,4BAA4B,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAIjG,eAAO,MAAM,2BAA2B,GACrC,mEAKE;IACD,eAAe,EAAE,MAAM,CAAA;IACvB,WAAW,EAAE,cAAc,CAAA;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB,KAAG,4BAmIH,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"injectHierarchyButton.d.ts","sourceRoot":"","sources":["../../src/hierarchy/injectHierarchyButton.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AAEtE;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,
|
|
1
|
+
{"version":3,"file":"injectHierarchyButton.d.ts","sourceRoot":"","sources":["../../src/hierarchy/injectHierarchyButton.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AAEtE;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAAI,sEAKnC;IACD,UAAU,EAAE,gBAAgB,CAAA;IAC5B,SAAS,EAAE,MAAM,CAAA;IACjB,uBAAuB,EAAE,MAAM,CAAA;IAC/B,eAAe,EAAE,MAAM,CAAA;CACxB,KAAG,IAiCH,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveHierarchyCollections.d.ts","sourceRoot":"","sources":["../../src/hierarchy/resolveHierarchyCollections.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAuBhD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,2BAA2B,
|
|
1
|
+
{"version":3,"file":"resolveHierarchyCollections.d.ts","sourceRoot":"","sources":["../../src/hierarchy/resolveHierarchyCollections.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAuBhD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,2BAA2B,GAAI,QAAQ,MAAM,KAAG,IAiJ5D,CAAA"}
|
|
@@ -211,7 +211,7 @@ import { injectHierarchyButton } from './injectHierarchyButton.js';
|
|
|
211
211
|
admin: {
|
|
212
212
|
components: {
|
|
213
213
|
Field: {
|
|
214
|
-
path: '@payloadcms/
|
|
214
|
+
path: '@payloadcms/ui/rsc#HierarchyTypeFieldServer',
|
|
215
215
|
serverProps: {
|
|
216
216
|
collectionOptions,
|
|
217
217
|
parentFieldName
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hierarchy/resolveHierarchyCollections.ts"],"sourcesContent":["import type { CollectionConfig, SanitizedCollectionConfig } from '../collections/config/types.js'\nimport type { Config } from '../config/types.js'\nimport type {\n JoinField,\n Option,\n RelationshipField,\n SelectField,\n Validate,\n} from '../fields/config/types.js'\nimport type { Document } from '../types/index.js'\nimport type {\n HierarchyJoinFieldConfig,\n SanitizedHierarchyConfig,\n SanitizedHierarchyRelatedCollection,\n} from './types.js'\n\nimport { sanitizeJoinField } from '../fields/config/sanitizeJoinField.js'\nimport { fieldAffectsData } from '../fields/config/types.js'\nimport { extractID } from '../utilities/extractID.js'\nimport { flattenAllFields } from '../utilities/flattenAllFields.js'\nimport { getHierarchyFieldName } from './constants.js'\nimport { hierarchyCollectionAfterDelete } from './hooks/collectionAfterDelete.js'\nimport { injectHierarchyButton } from './injectHierarchyButton.js'\n\n/**\n * Resolves hierarchy relationships across collections.\n *\n * This function runs after individual collection sanitization to establish\n * cross-collection hierarchy relationships. It discovers which collections\n * reference each hierarchy and configures the necessary fields, components,\n * and hooks.\n *\n * @remarks\n * Must be called after all collections are sanitized.\n *\n * **What it does:**\n * - Discovers related collections by scanning for hierarchy relationship fields\n * - Injects `HierarchyButton` component when `custom.hierarchy.injectHeaderButton` is set\n * - Adds `collectionSpecific` validation to ensure hierarchy items accept the document type\n * - Injects the `hierarchyType` select field when `collectionSpecific` is enabled\n * - Injects join field when `joinField` is configured\n * - Adds `afterDelete` hook to clear hierarchy references when items are deleted\n * - Populates `relatedCollections` in the sanitized hierarchy config\n */\nexport const resolveHierarchyCollections = (config: Config): void => {\n const hierarchyCollections =\n config.collections?.filter((col) => col.hierarchy && typeof col.hierarchy === 'object') || []\n\n for (const hierarchyCollection of hierarchyCollections) {\n const hierarchy = hierarchyCollection.hierarchy\n\n // TypeScript guard - hierarchy is guaranteed to be an object by the filter above\n if (!hierarchy || typeof hierarchy !== 'object') {\n continue\n }\n\n const hierarchyConfig = hierarchy as SanitizedHierarchyConfig\n const defaultFieldName = getHierarchyFieldName(hierarchyCollection.slug)\n const parentFieldName = hierarchyConfig.parentFieldName ?? defaultFieldName\n const isParentFieldNameOverridden = parentFieldName !== defaultFieldName\n const collectionSpecific = hierarchyConfig.collectionSpecific\n const typeFieldName = collectionSpecific ? collectionSpecific.fieldName : undefined\n const allowHasMany = hierarchyConfig.allowHasMany ?? true\n\n // Build relatedCollections by scanning all collections for hierarchy fields\n const sanitizedRelatedCollections: Record<string, SanitizedHierarchyRelatedCollection> = {}\n\n const selfParentField = hierarchyCollection.fields.find(\n (field) =>\n fieldAffectsData(field) &&\n field.name === parentFieldName &&\n field.type === 'relationship' &&\n (field as RelationshipField).relationTo === hierarchyCollection.slug,\n ) as RelationshipField | undefined\n\n // Check if the hierarchy collection's own parent field should be replaced with a header button\n if (selfParentField?.custom?.hierarchy?.injectHeaderButton === true) {\n injectHierarchyButton({\n collection: hierarchyCollection,\n fieldName: parentFieldName,\n hierarchyCollectionSlug: hierarchyCollection.slug,\n parentFieldName: hierarchyConfig.parentFieldName,\n })\n }\n\n for (const collection of config.collections || []) {\n // Skip the hierarchy collection itself (handled above)\n if (collection.slug === hierarchyCollection.slug) {\n continue\n }\n\n // Find hierarchy field by the default name (what createFolderField uses)\n const hierarchyField = collection.fields.find(\n (field) =>\n fieldAffectsData(field) &&\n field.name === defaultFieldName &&\n field.type === 'relationship' &&\n (field as RelationshipField).relationTo === hierarchyCollection.slug,\n ) as RelationshipField | undefined\n\n // If parentFieldName is overridden, rename the field to match\n if (hierarchyField && isParentFieldNameOverridden) {\n hierarchyField.name = parentFieldName\n }\n\n if (!hierarchyField) {\n continue\n }\n\n const fieldHasMany = hierarchyField.hasMany ?? allowHasMany\n\n // If collectionSpecific, inject validation to check hierarchy allows this collection type\n if (collectionSpecific) {\n injectCollectionSpecificValidation({\n hierarchyField,\n hierarchySlug: hierarchyCollection.slug,\n typeFieldName: typeFieldName!,\n })\n }\n\n // Store discovered collection with hasMany info\n sanitizedRelatedCollections[collection.slug] = {\n fieldName: parentFieldName,\n hasMany: fieldHasMany,\n }\n\n // Inject HierarchyButton if field requests it\n if (hierarchyField.custom?.hierarchy?.injectHeaderButton === true) {\n injectHierarchyButton({\n collection,\n fieldName: parentFieldName,\n hierarchyCollectionSlug: hierarchyCollection.slug,\n parentFieldName: hierarchyConfig.parentFieldName,\n })\n }\n }\n\n // If collectionSpecific, add type field to hierarchy collection\n if (hierarchyConfig.collectionSpecific) {\n injectTypeField({\n config,\n hierarchyCollection: hierarchyCollection as SanitizedCollectionConfig,\n parentFieldName: hierarchyConfig.parentFieldName,\n sanitizedRelatedCollections,\n typeFieldName: hierarchyConfig.collectionSpecific.fieldName,\n })\n }\n\n // If joinField is configured, add the join field to query children\n if (hierarchyConfig.joinField) {\n injectJoinField({\n config,\n hierarchyCollection: hierarchyCollection as SanitizedCollectionConfig,\n joinFieldConfig: hierarchyConfig.joinField,\n parentFieldName,\n relatedSlugs: Object.keys(sanitizedRelatedCollections),\n })\n }\n\n // Update hierarchy config with sanitized relatedCollections\n if (hierarchyConfig) {\n hierarchyConfig.relatedCollections = sanitizedRelatedCollections\n }\n\n // Add afterDelete hook to clear folder references from related documents\n if (Object.keys(sanitizedRelatedCollections).length > 0) {\n injectAfterDeleteHook({\n hierarchyCollection: hierarchyCollection as SanitizedCollectionConfig,\n sanitizedRelatedCollections,\n })\n }\n\n // Add sidebar tab for this hierarchy collection (unless explicitly disabled)\n if (hierarchyConfig.admin.injectSidebarTab !== false) {\n injectSidebarTab({\n config,\n hierarchyCollection,\n hierarchyConfig,\n })\n\n // Hide from nav when sidebar tab is injected (unless user explicitly set group)\n if (hierarchyCollection.admin?.group === undefined) {\n hierarchyCollection.admin = {\n ...hierarchyCollection.admin,\n group: false,\n }\n }\n }\n }\n}\n\n/**\n * Injects validation for collectionSpecific hierarchy fields.\n * Ensures the selected hierarchy item allows documents of this collection type.\n */\nfunction injectCollectionSpecificValidation({\n hierarchyField,\n hierarchySlug,\n typeFieldName,\n}: {\n hierarchyField: RelationshipField\n hierarchySlug: string\n typeFieldName: string\n}): void {\n const existingValidate = hierarchyField.validate\n\n const validate: Validate<unknown> = async (value, options) => {\n // Run existing validation first if present\n if (existingValidate) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const existingResult = await existingValidate(value as any, options as any)\n if (existingResult !== true) {\n return existingResult\n }\n }\n\n // No hierarchy selected, no validation needed\n if (!value) {\n return true\n }\n\n const { collectionSlug, overrideAccess, previousValue, req } = options\n const newID = extractID<Document>(value)\n\n // Value didn't change, no validation needed\n if (previousValue && extractID<Document>(previousValue) === newID) {\n return true\n }\n\n // Fetch the hierarchy item to check its type field\n let parentItem: Document | null = null\n if (typeof newID === 'string' || typeof newID === 'number') {\n try {\n parentItem = await req.payload.findByID({\n id: newID,\n collection: hierarchySlug,\n depth: 0,\n overrideAccess: overrideAccess ?? false,\n req,\n select: { [typeFieldName]: true },\n })\n } catch {\n return `Hierarchy item with ID ${newID} not found`\n }\n }\n\n if (!parentItem) {\n return `Hierarchy item with ID ${newID} not found`\n }\n\n const allowedTypes: string[] = (parentItem[typeFieldName] as string[]) || []\n\n // If hierarchy has no types, it accepts all collections\n if (allowedTypes.length === 0) {\n return true\n }\n\n // Check if this collection is allowed\n if (collectionSlug && allowedTypes.includes(collectionSlug)) {\n return true\n }\n\n return `Hierarchy item \"${newID}\" does not allow documents of type \"${collectionSlug}\"`\n }\n\n hierarchyField.validate = validate\n}\n\n/**\n * Injects the hierarchyType select field into a hierarchy collection.\n */\nfunction injectTypeField({\n config,\n hierarchyCollection,\n parentFieldName,\n sanitizedRelatedCollections,\n typeFieldName,\n}: {\n config: Config\n hierarchyCollection: CollectionConfig | SanitizedCollectionConfig\n parentFieldName: string\n sanitizedRelatedCollections: Record<string, SanitizedHierarchyRelatedCollection>\n typeFieldName: string\n}): void {\n const collectionOptions: Option[] = Object.keys(sanitizedRelatedCollections).map((slug) => {\n const relatedCollection = config.collections?.find((c) => c.slug === slug)\n return {\n label: relatedCollection?.labels?.plural || slug,\n value: slug,\n }\n })\n\n const typeField: SelectField = {\n name: typeFieldName,\n type: 'select',\n admin: {\n components: {\n Field: {\n path: '@payloadcms/next/rsc#HierarchyTypeFieldServer',\n serverProps: {\n collectionOptions,\n parentFieldName,\n },\n },\n },\n position: 'sidebar',\n },\n hasMany: true,\n options: collectionOptions,\n }\n\n hierarchyCollection.fields = hierarchyCollection.fields || []\n hierarchyCollection.fields.push(typeField)\n\n // Recompute flattenedFields since we added a field after initial sanitization\n // This is required for the field to be queryable\n if ('flattenedFields' in hierarchyCollection) {\n hierarchyCollection.flattenedFields = flattenAllFields({\n fields: hierarchyCollection.fields,\n })\n }\n}\n\n/**\n * Injects a join field to query all children of a hierarchy item.\n */\nfunction injectJoinField({\n config,\n hierarchyCollection,\n joinFieldConfig,\n parentFieldName,\n relatedSlugs,\n}: {\n config: Config\n hierarchyCollection: SanitizedCollectionConfig\n joinFieldConfig: HierarchyJoinFieldConfig\n parentFieldName: string\n relatedSlugs: string[]\n}): void {\n const { name, admin: userAdmin, ...userConfig } = joinFieldConfig\n\n const hasJoinField = hierarchyCollection.fields?.some(\n (field) => 'name' in field && field.name === name,\n )\n\n if (hasJoinField) {\n return\n }\n\n const joinField: JoinField = {\n // User config (spread first so auto-generated values take precedence for required fields)\n ...userConfig,\n // Auto-generated values (these cannot be overridden)\n name,\n type: 'join',\n collection: [hierarchyCollection.slug, ...relatedSlugs],\n hasMany: true,\n on: parentFieldName,\n // Merge admin config\n admin: {\n ...userAdmin,\n },\n }\n\n hierarchyCollection.fields = hierarchyCollection.fields || []\n hierarchyCollection.fields.push(joinField)\n\n // Sanitize the join field to register it properly\n sanitizeJoinField({\n config,\n field: joinField,\n joins: hierarchyCollection.joins,\n parentIsLocalized: false,\n polymorphicJoins: hierarchyCollection.polymorphicJoins,\n })\n\n // Recompute flattenedFields since we added a field after initial sanitization\n hierarchyCollection.flattenedFields = flattenAllFields({\n fields: hierarchyCollection.fields,\n })\n}\n\n/**\n * Injects afterDelete hook to clear hierarchy references from related documents.\n */\nfunction injectAfterDeleteHook({\n hierarchyCollection,\n sanitizedRelatedCollections,\n}: {\n hierarchyCollection: CollectionConfig | SanitizedCollectionConfig\n sanitizedRelatedCollections: Record<string, SanitizedHierarchyRelatedCollection>\n}): void {\n // Build map of collection slugs to their field names\n const relatedCollectionFieldMap: Record<string, string> = {}\n for (const [slug, relatedConfig] of Object.entries(sanitizedRelatedCollections)) {\n relatedCollectionFieldMap[slug] = relatedConfig.fieldName\n }\n\n hierarchyCollection.hooks = hierarchyCollection.hooks || {}\n hierarchyCollection.hooks.afterDelete = [\n ...(hierarchyCollection.hooks.afterDelete || []),\n hierarchyCollectionAfterDelete({ relatedCollections: relatedCollectionFieldMap }),\n ]\n}\n\n/**\n * Injects a sidebar tab for a hierarchy collection.\n */\nfunction injectSidebarTab({\n config,\n hierarchyCollection,\n hierarchyConfig,\n}: {\n config: Config\n hierarchyCollection: CollectionConfig\n hierarchyConfig: SanitizedHierarchyConfig\n}): void {\n const tabSlug = `hierarchy-${hierarchyCollection.slug}`\n const Icon = hierarchyConfig.admin.components.Icon\n\n // Initialize admin config structure\n config.admin = config.admin || {}\n config.admin.components = config.admin.components || {}\n config.admin.components.sidebar = config.admin.components.sidebar || {}\n config.admin.components.sidebar.tabs = config.admin.components.sidebar.tabs || []\n\n // Check if tab already exists\n const hasTab = config.admin.components.sidebar.tabs.some((tab) => tab.slug === tabSlug)\n\n if (!hasTab) {\n config.admin.components.sidebar.tabs.push({\n slug: tabSlug,\n components: {\n Content: {\n clientProps: {\n hierarchyCollectionSlug: hierarchyCollection.slug,\n },\n path: '@payloadcms/ui/rsc#HierarchySidebarTabServer',\n },\n Icon,\n },\n label: hierarchyCollection.labels?.plural || hierarchyCollection.slug,\n })\n }\n}\n"],"names":["sanitizeJoinField","fieldAffectsData","extractID","flattenAllFields","getHierarchyFieldName","hierarchyCollectionAfterDelete","injectHierarchyButton","resolveHierarchyCollections","config","hierarchyCollections","collections","filter","col","hierarchy","hierarchyCollection","hierarchyConfig","defaultFieldName","slug","parentFieldName","isParentFieldNameOverridden","collectionSpecific","typeFieldName","fieldName","undefined","allowHasMany","sanitizedRelatedCollections","selfParentField","fields","find","field","name","type","relationTo","custom","injectHeaderButton","collection","hierarchyCollectionSlug","hierarchyField","fieldHasMany","hasMany","injectCollectionSpecificValidation","hierarchySlug","injectTypeField","joinField","injectJoinField","joinFieldConfig","relatedSlugs","Object","keys","relatedCollections","length","injectAfterDeleteHook","admin","injectSidebarTab","group","existingValidate","validate","value","options","existingResult","collectionSlug","overrideAccess","previousValue","req","newID","parentItem","payload","findByID","id","depth","select","allowedTypes","includes","collectionOptions","map","relatedCollection","c","label","labels","plural","typeField","components","Field","path","serverProps","position","push","flattenedFields","userAdmin","userConfig","hasJoinField","some","on","joins","parentIsLocalized","polymorphicJoins","relatedCollectionFieldMap","relatedConfig","entries","hooks","afterDelete","tabSlug","Icon","sidebar","tabs","hasTab","tab","Content","clientProps"],"mappings":"AAgBA,SAASA,iBAAiB,QAAQ,wCAAuC;AACzE,SAASC,gBAAgB,QAAQ,4BAA2B;AAC5D,SAASC,SAAS,QAAQ,4BAA2B;AACrD,SAASC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ClB,IAAI,CAAC;YACxCrE,MAAMoF;YACNpB,YAAY;gBACV0B,SAAS;oBACPC,aAAa;wBACXxE,yBAAyBtB,oBAAoBG,IAAI;oBACnD;oBACAkE,MAAM;gBACR;gBACAmB;YACF;YACAzB,OAAO/D,oBAAoBgE,MAAM,EAAEC,UAAUjE,oBAAoBG,IAAI;QACvE;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/hierarchy/resolveHierarchyCollections.ts"],"sourcesContent":["import type { CollectionConfig, SanitizedCollectionConfig } from '../collections/config/types.js'\nimport type { Config } from '../config/types.js'\nimport type {\n JoinField,\n Option,\n RelationshipField,\n SelectField,\n Validate,\n} from '../fields/config/types.js'\nimport type { Document } from '../types/index.js'\nimport type {\n HierarchyJoinFieldConfig,\n SanitizedHierarchyConfig,\n SanitizedHierarchyRelatedCollection,\n} from './types.js'\n\nimport { sanitizeJoinField } from '../fields/config/sanitizeJoinField.js'\nimport { fieldAffectsData } from '../fields/config/types.js'\nimport { extractID } from '../utilities/extractID.js'\nimport { flattenAllFields } from '../utilities/flattenAllFields.js'\nimport { getHierarchyFieldName } from './constants.js'\nimport { hierarchyCollectionAfterDelete } from './hooks/collectionAfterDelete.js'\nimport { injectHierarchyButton } from './injectHierarchyButton.js'\n\n/**\n * Resolves hierarchy relationships across collections.\n *\n * This function runs after individual collection sanitization to establish\n * cross-collection hierarchy relationships. It discovers which collections\n * reference each hierarchy and configures the necessary fields, components,\n * and hooks.\n *\n * @remarks\n * Must be called after all collections are sanitized.\n *\n * **What it does:**\n * - Discovers related collections by scanning for hierarchy relationship fields\n * - Injects `HierarchyButton` component when `custom.hierarchy.injectHeaderButton` is set\n * - Adds `collectionSpecific` validation to ensure hierarchy items accept the document type\n * - Injects the `hierarchyType` select field when `collectionSpecific` is enabled\n * - Injects join field when `joinField` is configured\n * - Adds `afterDelete` hook to clear hierarchy references when items are deleted\n * - Populates `relatedCollections` in the sanitized hierarchy config\n */\nexport const resolveHierarchyCollections = (config: Config): void => {\n const hierarchyCollections =\n config.collections?.filter((col) => col.hierarchy && typeof col.hierarchy === 'object') || []\n\n for (const hierarchyCollection of hierarchyCollections) {\n const hierarchy = hierarchyCollection.hierarchy\n\n // TypeScript guard - hierarchy is guaranteed to be an object by the filter above\n if (!hierarchy || typeof hierarchy !== 'object') {\n continue\n }\n\n const hierarchyConfig = hierarchy as SanitizedHierarchyConfig\n const defaultFieldName = getHierarchyFieldName(hierarchyCollection.slug)\n const parentFieldName = hierarchyConfig.parentFieldName ?? defaultFieldName\n const isParentFieldNameOverridden = parentFieldName !== defaultFieldName\n const collectionSpecific = hierarchyConfig.collectionSpecific\n const typeFieldName = collectionSpecific ? collectionSpecific.fieldName : undefined\n const allowHasMany = hierarchyConfig.allowHasMany ?? true\n\n // Build relatedCollections by scanning all collections for hierarchy fields\n const sanitizedRelatedCollections: Record<string, SanitizedHierarchyRelatedCollection> = {}\n\n const selfParentField = hierarchyCollection.fields.find(\n (field) =>\n fieldAffectsData(field) &&\n field.name === parentFieldName &&\n field.type === 'relationship' &&\n (field as RelationshipField).relationTo === hierarchyCollection.slug,\n ) as RelationshipField | undefined\n\n // Check if the hierarchy collection's own parent field should be replaced with a header button\n if (selfParentField?.custom?.hierarchy?.injectHeaderButton === true) {\n injectHierarchyButton({\n collection: hierarchyCollection,\n fieldName: parentFieldName,\n hierarchyCollectionSlug: hierarchyCollection.slug,\n parentFieldName: hierarchyConfig.parentFieldName,\n })\n }\n\n for (const collection of config.collections || []) {\n // Skip the hierarchy collection itself (handled above)\n if (collection.slug === hierarchyCollection.slug) {\n continue\n }\n\n // Find hierarchy field by the default name (what createFolderField uses)\n const hierarchyField = collection.fields.find(\n (field) =>\n fieldAffectsData(field) &&\n field.name === defaultFieldName &&\n field.type === 'relationship' &&\n (field as RelationshipField).relationTo === hierarchyCollection.slug,\n ) as RelationshipField | undefined\n\n // If parentFieldName is overridden, rename the field to match\n if (hierarchyField && isParentFieldNameOverridden) {\n hierarchyField.name = parentFieldName\n }\n\n if (!hierarchyField) {\n continue\n }\n\n const fieldHasMany = hierarchyField.hasMany ?? allowHasMany\n\n // If collectionSpecific, inject validation to check hierarchy allows this collection type\n if (collectionSpecific) {\n injectCollectionSpecificValidation({\n hierarchyField,\n hierarchySlug: hierarchyCollection.slug,\n typeFieldName: typeFieldName!,\n })\n }\n\n // Store discovered collection with hasMany info\n sanitizedRelatedCollections[collection.slug] = {\n fieldName: parentFieldName,\n hasMany: fieldHasMany,\n }\n\n // Inject HierarchyButton if field requests it\n if (hierarchyField.custom?.hierarchy?.injectHeaderButton === true) {\n injectHierarchyButton({\n collection,\n fieldName: parentFieldName,\n hierarchyCollectionSlug: hierarchyCollection.slug,\n parentFieldName: hierarchyConfig.parentFieldName,\n })\n }\n }\n\n // If collectionSpecific, add type field to hierarchy collection\n if (hierarchyConfig.collectionSpecific) {\n injectTypeField({\n config,\n hierarchyCollection: hierarchyCollection as SanitizedCollectionConfig,\n parentFieldName: hierarchyConfig.parentFieldName,\n sanitizedRelatedCollections,\n typeFieldName: hierarchyConfig.collectionSpecific.fieldName,\n })\n }\n\n // If joinField is configured, add the join field to query children\n if (hierarchyConfig.joinField) {\n injectJoinField({\n config,\n hierarchyCollection: hierarchyCollection as SanitizedCollectionConfig,\n joinFieldConfig: hierarchyConfig.joinField,\n parentFieldName,\n relatedSlugs: Object.keys(sanitizedRelatedCollections),\n })\n }\n\n // Update hierarchy config with sanitized relatedCollections\n if (hierarchyConfig) {\n hierarchyConfig.relatedCollections = sanitizedRelatedCollections\n }\n\n // Add afterDelete hook to clear folder references from related documents\n if (Object.keys(sanitizedRelatedCollections).length > 0) {\n injectAfterDeleteHook({\n hierarchyCollection: hierarchyCollection as SanitizedCollectionConfig,\n sanitizedRelatedCollections,\n })\n }\n\n // Add sidebar tab for this hierarchy collection (unless explicitly disabled)\n if (hierarchyConfig.admin.injectSidebarTab !== false) {\n injectSidebarTab({\n config,\n hierarchyCollection,\n hierarchyConfig,\n })\n\n // Hide from nav when sidebar tab is injected (unless user explicitly set group)\n if (hierarchyCollection.admin?.group === undefined) {\n hierarchyCollection.admin = {\n ...hierarchyCollection.admin,\n group: false,\n }\n }\n }\n }\n}\n\n/**\n * Injects validation for collectionSpecific hierarchy fields.\n * Ensures the selected hierarchy item allows documents of this collection type.\n */\nfunction injectCollectionSpecificValidation({\n hierarchyField,\n hierarchySlug,\n typeFieldName,\n}: {\n hierarchyField: RelationshipField\n hierarchySlug: string\n typeFieldName: string\n}): void {\n const existingValidate = hierarchyField.validate\n\n const validate: Validate<unknown> = async (value, options) => {\n // Run existing validation first if present\n if (existingValidate) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const existingResult = await existingValidate(value as any, options as any)\n if (existingResult !== true) {\n return existingResult\n }\n }\n\n // No hierarchy selected, no validation needed\n if (!value) {\n return true\n }\n\n const { collectionSlug, overrideAccess, previousValue, req } = options\n const newID = extractID<Document>(value)\n\n // Value didn't change, no validation needed\n if (previousValue && extractID<Document>(previousValue) === newID) {\n return true\n }\n\n // Fetch the hierarchy item to check its type field\n let parentItem: Document | null = null\n if (typeof newID === 'string' || typeof newID === 'number') {\n try {\n parentItem = await req.payload.findByID({\n id: newID,\n collection: hierarchySlug,\n depth: 0,\n overrideAccess: overrideAccess ?? false,\n req,\n select: { [typeFieldName]: true },\n })\n } catch {\n return `Hierarchy item with ID ${newID} not found`\n }\n }\n\n if (!parentItem) {\n return `Hierarchy item with ID ${newID} not found`\n }\n\n const allowedTypes: string[] = (parentItem[typeFieldName] as string[]) || []\n\n // If hierarchy has no types, it accepts all collections\n if (allowedTypes.length === 0) {\n return true\n }\n\n // Check if this collection is allowed\n if (collectionSlug && allowedTypes.includes(collectionSlug)) {\n return true\n }\n\n return `Hierarchy item \"${newID}\" does not allow documents of type \"${collectionSlug}\"`\n }\n\n hierarchyField.validate = validate\n}\n\n/**\n * Injects the hierarchyType select field into a hierarchy collection.\n */\nfunction injectTypeField({\n config,\n hierarchyCollection,\n parentFieldName,\n sanitizedRelatedCollections,\n typeFieldName,\n}: {\n config: Config\n hierarchyCollection: CollectionConfig | SanitizedCollectionConfig\n parentFieldName: string\n sanitizedRelatedCollections: Record<string, SanitizedHierarchyRelatedCollection>\n typeFieldName: string\n}): void {\n const collectionOptions: Option[] = Object.keys(sanitizedRelatedCollections).map((slug) => {\n const relatedCollection = config.collections?.find((c) => c.slug === slug)\n return {\n label: relatedCollection?.labels?.plural || slug,\n value: slug,\n }\n })\n\n const typeField: SelectField = {\n name: typeFieldName,\n type: 'select',\n admin: {\n components: {\n Field: {\n path: '@payloadcms/ui/rsc#HierarchyTypeFieldServer',\n serverProps: {\n collectionOptions,\n parentFieldName,\n },\n },\n },\n position: 'sidebar',\n },\n hasMany: true,\n options: collectionOptions,\n }\n\n hierarchyCollection.fields = hierarchyCollection.fields || []\n hierarchyCollection.fields.push(typeField)\n\n // Recompute flattenedFields since we added a field after initial sanitization\n // This is required for the field to be queryable\n if ('flattenedFields' in hierarchyCollection) {\n hierarchyCollection.flattenedFields = flattenAllFields({\n fields: hierarchyCollection.fields,\n })\n }\n}\n\n/**\n * Injects a join field to query all children of a hierarchy item.\n */\nfunction injectJoinField({\n config,\n hierarchyCollection,\n joinFieldConfig,\n parentFieldName,\n relatedSlugs,\n}: {\n config: Config\n hierarchyCollection: SanitizedCollectionConfig\n joinFieldConfig: HierarchyJoinFieldConfig\n parentFieldName: string\n relatedSlugs: string[]\n}): void {\n const { name, admin: userAdmin, ...userConfig } = joinFieldConfig\n\n const hasJoinField = hierarchyCollection.fields?.some(\n (field) => 'name' in field && field.name === name,\n )\n\n if (hasJoinField) {\n return\n }\n\n const joinField: JoinField = {\n // User config (spread first so auto-generated values take precedence for required fields)\n ...userConfig,\n // Auto-generated values (these cannot be overridden)\n name,\n type: 'join',\n collection: [hierarchyCollection.slug, ...relatedSlugs],\n hasMany: true,\n on: parentFieldName,\n // Merge admin config\n admin: {\n ...userAdmin,\n },\n }\n\n hierarchyCollection.fields = hierarchyCollection.fields || []\n hierarchyCollection.fields.push(joinField)\n\n // Sanitize the join field to register it properly\n sanitizeJoinField({\n config,\n field: joinField,\n joins: hierarchyCollection.joins,\n parentIsLocalized: false,\n polymorphicJoins: hierarchyCollection.polymorphicJoins,\n })\n\n // Recompute flattenedFields since we added a field after initial sanitization\n hierarchyCollection.flattenedFields = flattenAllFields({\n fields: hierarchyCollection.fields,\n })\n}\n\n/**\n * Injects afterDelete hook to clear hierarchy references from related documents.\n */\nfunction injectAfterDeleteHook({\n hierarchyCollection,\n sanitizedRelatedCollections,\n}: {\n hierarchyCollection: CollectionConfig | SanitizedCollectionConfig\n sanitizedRelatedCollections: Record<string, SanitizedHierarchyRelatedCollection>\n}): void {\n // Build map of collection slugs to their field names\n const relatedCollectionFieldMap: Record<string, string> = {}\n for (const [slug, relatedConfig] of Object.entries(sanitizedRelatedCollections)) {\n relatedCollectionFieldMap[slug] = relatedConfig.fieldName\n }\n\n hierarchyCollection.hooks = hierarchyCollection.hooks || {}\n hierarchyCollection.hooks.afterDelete = [\n ...(hierarchyCollection.hooks.afterDelete || []),\n hierarchyCollectionAfterDelete({ relatedCollections: relatedCollectionFieldMap }),\n ]\n}\n\n/**\n * Injects a sidebar tab for a hierarchy collection.\n */\nfunction injectSidebarTab({\n config,\n hierarchyCollection,\n hierarchyConfig,\n}: {\n config: Config\n hierarchyCollection: CollectionConfig\n hierarchyConfig: SanitizedHierarchyConfig\n}): void {\n const tabSlug = `hierarchy-${hierarchyCollection.slug}`\n const Icon = hierarchyConfig.admin.components.Icon\n\n // Initialize admin config structure\n config.admin = config.admin || {}\n config.admin.components = config.admin.components || {}\n config.admin.components.sidebar = config.admin.components.sidebar || {}\n config.admin.components.sidebar.tabs = config.admin.components.sidebar.tabs || []\n\n // Check if tab already exists\n const hasTab = config.admin.components.sidebar.tabs.some((tab) => tab.slug === tabSlug)\n\n if (!hasTab) {\n config.admin.components.sidebar.tabs.push({\n slug: tabSlug,\n components: {\n Content: {\n clientProps: {\n hierarchyCollectionSlug: hierarchyCollection.slug,\n },\n path: '@payloadcms/ui/rsc#HierarchySidebarTabServer',\n },\n Icon,\n },\n label: hierarchyCollection.labels?.plural || hierarchyCollection.slug,\n })\n }\n}\n"],"names":["sanitizeJoinField","fieldAffectsData","extractID","flattenAllFields","getHierarchyFieldName","hierarchyCollectionAfterDelete","injectHierarchyButton","resolveHierarchyCollections","config","hierarchyCollections","collections","filter","col","hierarchy","hierarchyCollection","hierarchyConfig","defaultFieldName","slug","parentFieldName","isParentFieldNameOverridden","collectionSpecific","typeFieldName","fieldName","undefined","allowHasMany","sanitizedRelatedCollections","selfParentField","fields","find","field","name","type","relationTo","custom","injectHeaderButton","collection","hierarchyCollectionSlug","hierarchyField","fieldHasMany","hasMany","injectCollectionSpecificValidation","hierarchySlug","injectTypeField","joinField","injectJoinField","joinFieldConfig","relatedSlugs","Object","keys","relatedCollections","length","injectAfterDeleteHook","admin","injectSidebarTab","group","existingValidate","validate","value","options","existingResult","collectionSlug","overrideAccess","previousValue","req","newID","parentItem","payload","findByID","id","depth","select","allowedTypes","includes","collectionOptions","map","relatedCollection","c","label","labels","plural","typeField","components","Field","path","serverProps","position","push","flattenedFields","userAdmin","userConfig","hasJoinField","some","on","joins","parentIsLocalized","polymorphicJoins","relatedCollectionFieldMap","relatedConfig","entries","hooks","afterDelete","tabSlug","Icon","sidebar","tabs","hasTab","tab","Content","clientProps"],"mappings":"AAgBA,SAASA,iBAAiB,QAAQ,wCAAuC;AACzE,SAASC,gBAAgB,QAAQ,4BAA2B;AAC5D,SAASC,SAAS,QAAQ,4BAA2B;AACrD,SAASC,gBAAgB,QAAQ,mCAAkC;AACnE,SAASC,qBAAqB,QAAQ,iBAAgB;AACtD,SAASC,8BAA8B,QAAQ,mCAAkC;AACjF,SAASC,qBAAqB,QAAQ,6BAA4B;AAElE;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,MAAMC,8BAA8B,CAACC;IAC1C,MAAMC,uBACJD,OAAOE,WAAW,EAAEC,OAAO,CAACC,MAAQA,IAAIC,SAA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file":"sanitizeHierarchyCollection.d.ts","sourceRoot":"","sources":["../../src/hierarchy/sanitizeHierarchyCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACtE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAgBhD;;;;;;;;;GASG;AACH,eAAO,MAAM,2BAA2B,
|
|
1
|
+
{"version":3,"file":"sanitizeHierarchyCollection.d.ts","sourceRoot":"","sources":["../../src/hierarchy/sanitizeHierarchyCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACtE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAgBhD;;;;;;;;;GASG;AACH,eAAO,MAAM,2BAA2B,GACtC,kBAAkB,gBAAgB,EAClC,SAAS,MAAM,KACd,IAoIF,CAAA"}
|
|
@@ -64,6 +64,7 @@ import { ensureSafeCollectionsChange } from './hooks/ensureSafeCollectionsChange
|
|
|
64
64
|
const slugify = collectionConfig.hierarchy.slugify ?? ((text)=>defaultSlugify(text) ?? '');
|
|
65
65
|
const treeLimit = collectionConfig.hierarchy.admin?.treeLimit ?? DEFAULT_HIERARCHY_TREE_LIMIT;
|
|
66
66
|
const iconComponent = collectionConfig.hierarchy.admin?.components?.Icon;
|
|
67
|
+
const smallIconComponent = collectionConfig.hierarchy.admin?.components?.SmallIcon;
|
|
67
68
|
const slugField = collectionConfig.hierarchy.slugField;
|
|
68
69
|
// Apply hierarchy to collection (adds fields and hooks)
|
|
69
70
|
addHierarchyToCollection({
|
|
@@ -96,7 +97,8 @@ import { ensureSafeCollectionsChange } from './hooks/ensureSafeCollectionsChange
|
|
|
96
97
|
collectionConfig.hierarchy = {
|
|
97
98
|
admin: {
|
|
98
99
|
components: {
|
|
99
|
-
Icon: iconComponent || '@payloadcms/ui#TagIcon'
|
|
100
|
+
Icon: iconComponent || '@payloadcms/ui#TagIcon',
|
|
101
|
+
SmallIcon: smallIconComponent || iconComponent || '@payloadcms/ui#TagIcon'
|
|
100
102
|
},
|
|
101
103
|
injectSidebarTab,
|
|
102
104
|
treeLimit,
|