payload 4.0.0-internal.e7d4ebc → 4.0.0-internal.f05c47f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/RichText.d.ts +1 -1
- package/dist/admin/RichText.d.ts.map +1 -1
- package/dist/admin/RichText.js.map +1 -1
- package/dist/admin/adapters/devReload.d.ts +13 -0
- package/dist/admin/adapters/devReload.d.ts.map +1 -1
- package/dist/admin/adapters/devReload.js +14 -1
- package/dist/admin/adapters/devReload.js.map +1 -1
- package/dist/admin/functions/index.d.ts +10 -1
- 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 +1 -1
- package/dist/admin/types.d.ts.map +1 -1
- package/dist/admin/types.js.map +1 -1
- package/dist/admin/views/index.d.ts +1 -1
- package/dist/admin/views/index.d.ts.map +1 -1
- package/dist/admin/views/index.js.map +1 -1
- package/dist/auth/endpoints/login.d.ts.map +1 -1
- package/dist/auth/endpoints/login.js +2 -11
- package/dist/auth/endpoints/login.js.map +1 -1
- package/dist/auth/endpoints/refresh.d.ts.map +1 -1
- package/dist/auth/endpoints/refresh.js +4 -6
- package/dist/auth/endpoints/refresh.js.map +1 -1
- package/dist/auth/executeAccess.d.ts +1 -1
- package/dist/auth/executeAccess.d.ts.map +1 -1
- package/dist/auth/executeAccess.js.map +1 -1
- package/dist/auth/getLoginOptions.js.map +1 -1
- package/dist/auth/loginWithCookie.d.ts +33 -0
- package/dist/auth/loginWithCookie.d.ts.map +1 -0
- package/dist/auth/loginWithCookie.js +34 -0
- package/dist/auth/loginWithCookie.js.map +1 -0
- package/dist/auth/operations/me.d.ts +0 -7
- package/dist/auth/operations/me.d.ts.map +1 -1
- package/dist/auth/operations/me.js +0 -6
- package/dist/auth/operations/me.js.map +1 -1
- package/dist/auth/operations/refresh.d.ts +0 -7
- package/dist/auth/operations/refresh.d.ts.map +1 -1
- package/dist/auth/operations/refresh.js +0 -6
- package/dist/auth/operations/refresh.js.map +1 -1
- package/dist/auth/serverFunctions/cookies.d.ts +47 -0
- package/dist/auth/serverFunctions/cookies.d.ts.map +1 -0
- package/dist/auth/serverFunctions/cookies.js +52 -0
- package/dist/auth/serverFunctions/cookies.js.map +1 -0
- package/dist/auth/serverFunctions/login.d.ts +29 -0
- package/dist/auth/serverFunctions/login.d.ts.map +1 -0
- package/dist/auth/serverFunctions/login.js +63 -0
- package/dist/auth/serverFunctions/login.js.map +1 -0
- package/dist/auth/serverFunctions/logout.d.ts +17 -0
- package/dist/auth/serverFunctions/logout.d.ts.map +1 -0
- package/dist/auth/serverFunctions/logout.js +58 -0
- package/dist/auth/serverFunctions/logout.js.map +1 -0
- package/dist/auth/serverFunctions/refresh.d.ts +17 -0
- package/dist/auth/serverFunctions/refresh.d.ts.map +1 -0
- package/dist/auth/serverFunctions/refresh.js +61 -0
- package/dist/auth/serverFunctions/refresh.js.map +1 -0
- package/dist/auth/types.d.ts +9 -14
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/auth/types.js.map +1 -1
- package/dist/branching/appendBranchFilter.d.ts +28 -0
- package/dist/branching/appendBranchFilter.d.ts.map +1 -0
- package/dist/branching/appendBranchFilter.js +84 -0
- package/dist/branching/appendBranchFilter.js.map +1 -0
- package/dist/branching/appendBranchFilter.spec.js +166 -0
- package/dist/branching/appendBranchFilter.spec.js.map +1 -0
- package/dist/branching/branchIDs.d.ts +34 -0
- package/dist/branching/branchIDs.d.ts.map +1 -0
- package/dist/branching/branchIDs.js +87 -0
- package/dist/branching/branchIDs.js.map +1 -0
- package/dist/branching/branchIDs.spec.js +167 -0
- package/dist/branching/branchIDs.spec.js.map +1 -0
- package/dist/branching/collections.d.ts +6 -0
- package/dist/branching/collections.d.ts.map +1 -0
- package/dist/branching/collections.js +184 -0
- package/dist/branching/collections.js.map +1 -0
- package/dist/branching/endpoints/merge.d.ts +11 -0
- package/dist/branching/endpoints/merge.d.ts.map +1 -0
- package/dist/branching/endpoints/merge.js +50 -0
- package/dist/branching/endpoints/merge.js.map +1 -0
- package/dist/branching/forkDocument.d.ts +18 -0
- package/dist/branching/forkDocument.d.ts.map +1 -0
- package/dist/branching/forkDocument.js +123 -0
- package/dist/branching/forkDocument.js.map +1 -0
- package/dist/branching/globals.d.ts +49 -0
- package/dist/branching/globals.d.ts.map +1 -0
- package/dist/branching/globals.js +145 -0
- package/dist/branching/globals.js.map +1 -0
- package/dist/branching/hooks.d.ts +29 -0
- package/dist/branching/hooks.d.ts.map +1 -0
- package/dist/branching/hooks.js +82 -0
- package/dist/branching/hooks.js.map +1 -0
- package/dist/branching/injectBranchFields.d.ts +44 -0
- package/dist/branching/injectBranchFields.d.ts.map +1 -0
- package/dist/branching/injectBranchFields.js +132 -0
- package/dist/branching/injectBranchFields.js.map +1 -0
- package/dist/branching/merge.d.ts +65 -0
- package/dist/branching/merge.d.ts.map +1 -0
- package/dist/branching/merge.js +297 -0
- package/dist/branching/merge.js.map +1 -0
- package/dist/branching/preflight.d.ts +53 -0
- package/dist/branching/preflight.d.ts.map +1 -0
- package/dist/branching/preflight.js +156 -0
- package/dist/branching/preflight.js.map +1 -0
- package/dist/branching/resolveBranch.d.ts +37 -0
- package/dist/branching/resolveBranch.d.ts.map +1 -0
- package/dist/branching/resolveBranch.js +126 -0
- package/dist/branching/resolveBranch.js.map +1 -0
- package/dist/branching/resolveBranchQuery.d.ts +43 -0
- package/dist/branching/resolveBranchQuery.d.ts.map +1 -0
- package/dist/branching/resolveBranchQuery.js +87 -0
- package/dist/branching/resolveBranchQuery.js.map +1 -0
- package/dist/branching/resolveBranchRowID.d.ts +22 -0
- package/dist/branching/resolveBranchRowID.d.ts.map +1 -0
- package/dist/branching/resolveBranchRowID.js +51 -0
- package/dist/branching/resolveBranchRowID.js.map +1 -0
- package/dist/branching/sanitizeBranchingConfig.d.ts +31 -0
- package/dist/branching/sanitizeBranchingConfig.d.ts.map +1 -0
- package/dist/branching/sanitizeBranchingConfig.js +94 -0
- package/dist/branching/sanitizeBranchingConfig.js.map +1 -0
- package/dist/branching/tombstone.d.ts +28 -0
- package/dist/branching/tombstone.d.ts.map +1 -0
- package/dist/branching/tombstone.js +152 -0
- package/dist/branching/tombstone.js.map +1 -0
- package/dist/branching/types.d.ts +77 -0
- package/dist/branching/types.d.ts.map +1 -0
- package/dist/branching/types.js +15 -0
- package/dist/branching/types.js.map +1 -0
- package/dist/branching/versions.d.ts +39 -0
- package/dist/branching/versions.d.ts.map +1 -0
- package/dist/branching/versions.js +117 -0
- package/dist/branching/versions.js.map +1 -0
- package/dist/collections/config/defaults.d.ts +4 -4
- package/dist/collections/config/defaults.d.ts.map +1 -1
- package/dist/collections/config/defaults.js +37 -32
- package/dist/collections/config/defaults.js.map +1 -1
- package/dist/collections/config/sanitize.d.ts +4 -8
- package/dist/collections/config/sanitize.d.ts.map +1 -1
- package/dist/collections/config/sanitize.js +4 -21
- package/dist/collections/config/sanitize.js.map +1 -1
- package/dist/collections/config/types.d.ts +66 -49
- package/dist/collections/config/types.d.ts.map +1 -1
- package/dist/collections/config/types.js.map +1 -1
- package/dist/collections/config/useAsTitle.spec.js +27 -27
- package/dist/collections/config/useAsTitle.spec.js.map +1 -1
- package/dist/collections/operations/create.d.ts.map +1 -1
- package/dist/collections/operations/create.js +10 -0
- package/dist/collections/operations/create.js.map +1 -1
- package/dist/collections/operations/findByID.d.ts.map +1 -1
- package/dist/collections/operations/findByID.js +6 -0
- package/dist/collections/operations/findByID.js.map +1 -1
- package/dist/collections/operations/local/count.d.ts +9 -4
- 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/create.d.ts +9 -4
- 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 +9 -4
- 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/find.d.ts +9 -4
- 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 +9 -4
- 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/update.d.ts +9 -4
- package/dist/collections/operations/local/update.d.ts.map +1 -1
- package/dist/collections/operations/local/update.js.map +1 -1
- package/dist/collections/operations/restoreVersion.d.ts.map +1 -1
- package/dist/collections/operations/restoreVersion.js +7 -4
- package/dist/collections/operations/restoreVersion.js.map +1 -1
- package/dist/collections/operations/updateByID.d.ts +7 -0
- package/dist/collections/operations/updateByID.d.ts.map +1 -1
- package/dist/collections/operations/updateByID.js +2 -0
- package/dist/collections/operations/updateByID.js.map +1 -1
- package/dist/collections/operations/utilities/update.d.ts +9 -1
- package/dist/collections/operations/utilities/update.d.ts.map +1 -1
- package/dist/collections/operations/utilities/update.js +9 -7
- package/dist/collections/operations/utilities/update.js.map +1 -1
- package/dist/config/build.js +1 -1
- package/dist/config/build.js.map +1 -1
- package/dist/config/client.d.ts +3 -1
- package/dist/config/client.d.ts.map +1 -1
- package/dist/config/client.js +9 -0
- package/dist/config/client.js.map +1 -1
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +48 -41
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/orderable/index.d.ts +1 -1
- package/dist/config/orderable/index.d.ts.map +1 -1
- package/dist/config/orderable/index.js +2 -2
- package/dist/config/orderable/index.js.map +1 -1
- package/dist/config/sanitize.d.ts +1 -1
- package/dist/config/sanitize.d.ts.map +1 -1
- package/dist/config/sanitize.js +62 -32
- package/dist/config/sanitize.js.map +1 -1
- package/dist/config/sanitize.spec.js +101 -0
- package/dist/config/sanitize.spec.js.map +1 -0
- package/dist/config/types.d.ts +417 -404
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js.map +1 -1
- package/dist/database/createDatabaseAdapter.d.ts +1 -1
- package/dist/database/createDatabaseAdapter.d.ts.map +1 -1
- package/dist/database/createDatabaseAdapter.js +0 -2
- package/dist/database/createDatabaseAdapter.js.map +1 -1
- package/dist/database/types.d.ts +50 -0
- package/dist/database/types.d.ts.map +1 -1
- package/dist/database/types.js.map +1 -1
- package/dist/exports/auth.d.ts +5 -0
- package/dist/exports/auth.d.ts.map +1 -0
- package/dist/exports/auth.js +6 -0
- package/dist/exports/auth.js.map +1 -0
- package/dist/exports/shared.d.ts +1 -0
- package/dist/exports/shared.d.ts.map +1 -1
- package/dist/exports/shared.js +1 -0
- package/dist/exports/shared.js.map +1 -1
- package/dist/fields/baseFields/slug/duplicateContext.d.ts +11 -0
- package/dist/fields/baseFields/slug/duplicateContext.d.ts.map +1 -0
- package/dist/fields/baseFields/slug/duplicateContext.js +21 -0
- package/dist/fields/baseFields/slug/duplicateContext.js.map +1 -0
- package/dist/fields/baseFields/slug/fillEmptyLocalizedSlugs.d.ts +22 -0
- package/dist/fields/baseFields/slug/fillEmptyLocalizedSlugs.d.ts.map +1 -0
- package/dist/fields/baseFields/slug/fillEmptyLocalizedSlugs.js +63 -0
- package/dist/fields/baseFields/slug/fillEmptyLocalizedSlugs.js.map +1 -0
- package/dist/fields/baseFields/slug/generateSlug.d.ts +12 -18
- package/dist/fields/baseFields/slug/generateSlug.d.ts.map +1 -1
- package/dist/fields/baseFields/slug/generateSlug.js +97 -40
- package/dist/fields/baseFields/slug/generateSlug.js.map +1 -1
- package/dist/fields/baseFields/slug/generateSlugBeforeDuplicate.d.ts +18 -0
- package/dist/fields/baseFields/slug/generateSlugBeforeDuplicate.d.ts.map +1 -0
- package/dist/fields/baseFields/slug/generateSlugBeforeDuplicate.js +20 -0
- package/dist/fields/baseFields/slug/generateSlugBeforeDuplicate.js.map +1 -0
- package/dist/fields/baseFields/slug/getSlugFallbackValue.d.ts +22 -0
- package/dist/fields/baseFields/slug/getSlugFallbackValue.d.ts.map +1 -0
- package/dist/fields/baseFields/slug/getSlugFallbackValue.js +23 -0
- package/dist/fields/baseFields/slug/getSlugFallbackValue.js.map +1 -0
- package/dist/fields/baseFields/slug/hasValue.d.ts +3 -0
- package/dist/fields/baseFields/slug/hasValue.d.ts.map +1 -0
- package/dist/fields/baseFields/slug/hasValue.js +3 -0
- package/dist/fields/baseFields/slug/hasValue.js.map +1 -0
- package/dist/fields/config/reservedFieldNames.spec.js +18 -18
- package/dist/fields/config/reservedFieldNames.spec.js.map +1 -1
- package/dist/fields/config/sanitize.d.ts +6 -6
- package/dist/fields/config/sanitize.d.ts.map +1 -1
- package/dist/fields/config/sanitize.js +32 -22
- package/dist/fields/config/sanitize.js.map +1 -1
- package/dist/fields/config/sanitize.spec.js +105 -105
- package/dist/fields/config/sanitize.spec.js.map +1 -1
- package/dist/fields/config/types.d.ts +4 -3
- 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/hooks/beforeValidate/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/beforeValidate/traverseFields.js +2 -0
- package/dist/fields/hooks/beforeValidate/traverseFields.js.map +1 -1
- package/dist/fields/validations.d.ts.map +1 -1
- package/dist/fields/validations.js +7 -8
- package/dist/fields/validations.js.map +1 -1
- package/dist/fields/validations.spec.js +61 -37
- package/dist/fields/validations.spec.js.map +1 -1
- package/dist/globals/config/sanitize.d.ts +3 -7
- package/dist/globals/config/sanitize.d.ts.map +1 -1
- package/dist/globals/config/sanitize.js +3 -6
- package/dist/globals/config/sanitize.js.map +1 -1
- package/dist/globals/config/sanitize.spec.js +6 -6
- package/dist/globals/config/sanitize.spec.js.map +1 -1
- package/dist/globals/config/types.d.ts +5 -0
- package/dist/globals/config/types.d.ts.map +1 -1
- package/dist/globals/config/types.js.map +1 -1
- package/dist/globals/operations/countGlobalVersions.d.ts.map +1 -1
- package/dist/globals/operations/countGlobalVersions.js +1 -0
- package/dist/globals/operations/countGlobalVersions.js.map +1 -1
- package/dist/globals/operations/local/findOne.d.ts +5 -0
- 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/findVersions.d.ts +5 -0
- 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/update.d.ts +5 -0
- package/dist/globals/operations/local/update.d.ts.map +1 -1
- package/dist/globals/operations/local/update.js.map +1 -1
- package/dist/index.bundled.d.ts +1497 -797
- package/dist/index.d.ts +98 -33
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +79 -57
- package/dist/index.js.map +1 -1
- package/dist/preferences/keys.d.ts +7 -0
- package/dist/preferences/keys.d.ts.map +1 -1
- package/dist/preferences/keys.js +6 -0
- package/dist/preferences/keys.js.map +1 -1
- package/dist/query-presets/constraints.js +1 -1
- 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 +37 -43
- package/dist/queues/config/collection.js.map +1 -1
- package/dist/queues/config/global.d.ts +5 -6
- package/dist/queues/config/global.d.ts.map +1 -1
- package/dist/queues/config/global.js +1 -1
- package/dist/queues/config/global.js.map +1 -1
- package/dist/queues/config/types/index.d.ts +29 -24
- package/dist/queues/config/types/index.d.ts.map +1 -1
- package/dist/queues/config/types/index.js.map +1 -1
- package/dist/queues/config/types/taskTypes.d.ts +4 -7
- package/dist/queues/config/types/taskTypes.d.ts.map +1 -1
- package/dist/queues/config/types/taskTypes.js.map +1 -1
- package/dist/queues/config/types/workflowJSONTypes.d.ts +10 -9
- package/dist/queues/config/types/workflowJSONTypes.d.ts.map +1 -1
- package/dist/queues/config/types/workflowJSONTypes.js.map +1 -1
- package/dist/queues/config/types/workflowTypes.d.ts +11 -58
- package/dist/queues/config/types/workflowTypes.d.ts.map +1 -1
- package/dist/queues/config/types/workflowTypes.js.map +1 -1
- package/dist/queues/endpoints/handleSchedules.js +1 -1
- package/dist/queues/endpoints/handleSchedules.js.map +1 -1
- package/dist/queues/errors/handleTaskError.js +4 -4
- package/dist/queues/errors/handleTaskError.js.map +1 -1
- package/dist/queues/errors/handleWorkflowError.js +1 -1
- package/dist/queues/errors/handleWorkflowError.js.map +1 -1
- package/dist/queues/errors/index.d.ts +6 -0
- package/dist/queues/errors/index.d.ts.map +1 -1
- package/dist/queues/errors/index.js +5 -0
- package/dist/queues/errors/index.js.map +1 -1
- package/dist/queues/localAPI.d.ts +4 -4
- package/dist/queues/localAPI.d.ts.map +1 -1
- package/dist/queues/localAPI.js +63 -66
- package/dist/queues/localAPI.js.map +1 -1
- package/dist/queues/operations/handleSchedules/countRunnableOrActiveJobsForQueue.d.ts +4 -4
- package/dist/queues/operations/handleSchedules/countRunnableOrActiveJobsForQueue.d.ts.map +1 -1
- package/dist/queues/operations/handleSchedules/countRunnableOrActiveJobsForQueue.js.map +1 -1
- package/dist/queues/operations/handleSchedules/index.d.ts +1 -1
- package/dist/queues/operations/handleSchedules/index.d.ts.map +1 -1
- package/dist/queues/operations/handleSchedules/index.js +1 -1
- package/dist/queues/operations/handleSchedules/index.js.map +1 -1
- package/dist/queues/operations/runJobs/heartbeat.d.ts +13 -0
- package/dist/queues/operations/runJobs/heartbeat.d.ts.map +1 -0
- package/dist/queues/operations/runJobs/heartbeat.js +66 -0
- package/dist/queues/operations/runJobs/heartbeat.js.map +1 -0
- package/dist/queues/operations/runJobs/index.d.ts.map +1 -1
- package/dist/queues/operations/runJobs/index.js +133 -84
- package/dist/queues/operations/runJobs/index.js.map +1 -1
- package/dist/queues/operations/runJobs/runJSONJob/index.d.ts.map +1 -1
- package/dist/queues/operations/runJobs/runJSONJob/index.js +6 -3
- package/dist/queues/operations/runJobs/runJSONJob/index.js.map +1 -1
- package/dist/queues/operations/runJobs/runJob/getRunTaskFunction.js +5 -5
- package/dist/queues/operations/runJobs/runJob/getRunTaskFunction.js.map +1 -1
- package/dist/queues/operations/runJobs/runJob/getUpdateJobFunction.d.ts +2 -1
- package/dist/queues/operations/runJobs/runJob/getUpdateJobFunction.d.ts.map +1 -1
- package/dist/queues/operations/runJobs/runJob/getUpdateJobFunction.js +39 -8
- package/dist/queues/operations/runJobs/runJob/getUpdateJobFunction.js.map +1 -1
- package/dist/queues/operations/runJobs/runJob/importHandlerPath.js.map +1 -1
- package/dist/queues/operations/runJobs/runJob/index.d.ts.map +1 -1
- package/dist/queues/operations/runJobs/runJob/index.js +4 -4
- package/dist/queues/operations/runJobs/runJob/index.js.map +1 -1
- package/dist/queues/utilities/updateJob.d.ts.map +1 -1
- package/dist/queues/utilities/updateJob.js +3 -0
- package/dist/queues/utilities/updateJob.js.map +1 -1
- package/dist/types/index.d.ts +12 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/uploads/cropImage.d.ts +1 -1
- package/dist/uploads/cropImage.d.ts.map +1 -1
- package/dist/uploads/cropImage.js.map +1 -1
- package/dist/uploads/generateFileData.js +4 -1
- package/dist/uploads/generateFileData.js.map +1 -1
- package/dist/uploads/getImageSize.d.ts +12 -1
- package/dist/uploads/getImageSize.d.ts.map +1 -1
- package/dist/uploads/getImageSize.js +20 -18
- package/dist/uploads/getImageSize.js.map +1 -1
- package/dist/uploads/getImageSize.spec.js +298 -0
- package/dist/uploads/getImageSize.spec.js.map +1 -0
- package/dist/uploads/probeImageSize.d.ts +39 -0
- package/dist/uploads/probeImageSize.d.ts.map +1 -0
- package/dist/uploads/probeImageSize.js +374 -0
- package/dist/uploads/probeImageSize.js.map +1 -0
- package/dist/uploads/probeImageSize.spec.js +366 -0
- package/dist/uploads/probeImageSize.spec.js.map +1 -0
- package/dist/uploads/types.d.ts +28 -6
- package/dist/uploads/types.d.ts.map +1 -1
- package/dist/uploads/types.js.map +1 -1
- package/dist/utilities/appendNonTrashedFilter.d.ts +1 -1
- package/dist/utilities/appendNonTrashedFilter.d.ts.map +1 -1
- package/dist/utilities/appendNonTrashedFilter.js.map +1 -1
- package/dist/utilities/configToJSONSchema.spec.js +33 -33
- package/dist/utilities/configToJSONSchema.spec.js.map +1 -1
- package/dist/utilities/createLocalReq.d.ts +5 -0
- package/dist/utilities/createLocalReq.d.ts.map +1 -1
- package/dist/utilities/createLocalReq.js +8 -1
- package/dist/utilities/createLocalReq.js.map +1 -1
- package/dist/utilities/fieldValueExists.d.ts +29 -0
- package/dist/utilities/fieldValueExists.d.ts.map +1 -0
- package/dist/utilities/fieldValueExists.js +27 -0
- package/dist/utilities/fieldValueExists.js.map +1 -0
- package/dist/utilities/getNextVersion.d.ts +7 -0
- package/dist/utilities/getNextVersion.d.ts.map +1 -0
- package/dist/utilities/getNextVersion.js +20 -0
- package/dist/utilities/getNextVersion.js.map +1 -0
- package/dist/utilities/getNextVersion.spec.js +16 -0
- package/dist/utilities/getNextVersion.spec.js.map +1 -0
- package/dist/utilities/getRequestOrigin.d.ts.map +1 -1
- package/dist/utilities/getRequestOrigin.js.map +1 -1
- package/dist/utilities/getUniqueFieldValue.d.ts +27 -0
- package/dist/utilities/getUniqueFieldValue.d.ts.map +1 -0
- package/dist/utilities/getUniqueFieldValue.js +26 -0
- package/dist/utilities/getUniqueFieldValue.js.map +1 -0
- package/dist/utilities/headersWithCors.js +1 -1
- package/dist/utilities/headersWithCors.js.map +1 -1
- package/dist/utilities/logError.d.ts.map +1 -1
- package/dist/utilities/logError.js +5 -2
- package/dist/utilities/logError.js.map +1 -1
- package/dist/utilities/nextJsDevReloadStrategy.d.ts +7 -0
- package/dist/utilities/nextJsDevReloadStrategy.d.ts.map +1 -0
- package/dist/utilities/nextJsDevReloadStrategy.js +59 -0
- package/dist/utilities/nextJsDevReloadStrategy.js.map +1 -0
- package/dist/utilities/nextJsDevReloadStrategy.spec.js +123 -0
- package/dist/utilities/nextJsDevReloadStrategy.spec.js.map +1 -0
- package/dist/utilities/traverseFields.d.ts.map +1 -1
- package/dist/utilities/traverseFields.js +20 -22
- package/dist/utilities/traverseFields.js.map +1 -1
- package/dist/utilities/traverseFields.spec.js +112 -0
- package/dist/utilities/traverseFields.spec.js.map +1 -1
- package/dist/utilities/unflattenData.d.ts +3 -0
- package/dist/utilities/unflattenData.d.ts.map +1 -0
- package/dist/utilities/unflattenData.js +14 -0
- package/dist/utilities/unflattenData.js.map +1 -0
- package/dist/versions/buildCollectionFields.d.ts.map +1 -1
- package/dist/versions/buildCollectionFields.js +23 -0
- package/dist/versions/buildCollectionFields.js.map +1 -1
- package/dist/versions/buildGlobalFields.d.ts.map +1 -1
- package/dist/versions/buildGlobalFields.js +14 -0
- package/dist/versions/buildGlobalFields.js.map +1 -1
- package/dist/versions/deleteScheduledPublishJobs.js +2 -2
- package/dist/versions/deleteScheduledPublishJobs.js.map +1 -1
- package/dist/versions/drafts/replaceWithDraftIfAvailable.d.ts.map +1 -1
- package/dist/versions/drafts/replaceWithDraftIfAvailable.js +8 -1
- package/dist/versions/drafts/replaceWithDraftIfAvailable.js.map +1 -1
- package/dist/versions/getLatestCollectionVersion.d.ts.map +1 -1
- package/dist/versions/getLatestCollectionVersion.js +10 -2
- package/dist/versions/getLatestCollectionVersion.js.map +1 -1
- package/package.json +11 -5
- package/skills/payload/SKILL.md +517 -0
- package/skills/payload/reference/ACCESS-CONTROL-ADVANCED.md +704 -0
- package/skills/payload/reference/ACCESS-CONTROL.md +696 -0
- package/skills/payload/reference/ADAPTERS.md +305 -0
- package/skills/payload/reference/ADVANCED.md +386 -0
- package/skills/payload/reference/COLLECTIONS.md +301 -0
- package/skills/payload/reference/ENDPOINTS.md +634 -0
- package/skills/payload/reference/FIELD-TYPE-GUARDS.md +553 -0
- package/skills/payload/reference/FIELDS.md +739 -0
- package/skills/payload/reference/HOOKS.md +186 -0
- package/skills/payload/reference/PLUGIN-DEVELOPMENT.md +1436 -0
- package/skills/payload/reference/QUERIES.md +274 -0
- package/dist/database/defaultUpdateJobs.d.ts +0 -3
- package/dist/database/defaultUpdateJobs.d.ts.map +0 -1
- package/dist/database/defaultUpdateJobs.js +0 -41
- package/dist/database/defaultUpdateJobs.js.map +0 -1
- package/dist/uploads/tempFile.d.ts +0 -7
- package/dist/uploads/tempFile.d.ts.map +0 -1
- package/dist/uploads/tempFile.js +0 -39
- package/dist/uploads/tempFile.js.map +0 -1
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { PayloadRequest, Where } from '../types/index.js';
|
|
2
|
+
type BaseArgs = {
|
|
3
|
+
branch?: false | string;
|
|
4
|
+
globalSlug: string;
|
|
5
|
+
req?: Partial<PayloadRequest>;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Branch predicate for reading a global.
|
|
9
|
+
*
|
|
10
|
+
* Unlike collections, this does not have to resolve everything inside one
|
|
11
|
+
* query: a global is a single document, so there is no result set to paginate
|
|
12
|
+
* or count and nothing a post-query step could get wrong. The query fetches the
|
|
13
|
+
* branch's row and main's row together and `pickBranchGlobal` prefers the
|
|
14
|
+
* branch's — one round trip, at most two rows.
|
|
15
|
+
*/
|
|
16
|
+
export declare const resolveBranchGlobalQuery: ({ branch, globalSlug, req, where, }: {
|
|
17
|
+
where: undefined | Where;
|
|
18
|
+
} & BaseArgs) => undefined | Where;
|
|
19
|
+
/** True when the read should fetch two rows so the branch's copy can win. */
|
|
20
|
+
export declare const branchGlobalNeedsBothRows: (args: BaseArgs) => boolean;
|
|
21
|
+
/** Picks the branch's copy of a global when it has one, else main's. */
|
|
22
|
+
export declare const pickBranchGlobal: <T extends Record<string, any>>(docs: T[], branch: string) => T | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* The branch a global write should be scoped to, or `null` on main.
|
|
25
|
+
*
|
|
26
|
+
* Storage differs too much between adapters to upsert the branch's copy here —
|
|
27
|
+
* Mongo keeps every global in one discriminated collection, Drizzle gives each
|
|
28
|
+
* its own table — so each adapter performs the upsert and calls
|
|
29
|
+
* `recordBranchGlobalChange` once it has.
|
|
30
|
+
*/
|
|
31
|
+
export declare const resolveBranchGlobalWrite: (args: BaseArgs) => null | string;
|
|
32
|
+
/** Registers a global as changed on a branch, if it is not already. */
|
|
33
|
+
export declare const recordBranchGlobalChange: ({ branch, globalSlug, req, }: {
|
|
34
|
+
branch: string;
|
|
35
|
+
} & BaseArgs) => Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Branch predicate for global version reads.
|
|
38
|
+
*
|
|
39
|
+
* Strict equality rather than the read-through used for the global itself: a
|
|
40
|
+
* version list must not interleave two branches' histories, and ordering by
|
|
41
|
+
* timestamp would pick between them nondeterministically. A branch that has
|
|
42
|
+
* never touched the global simply has no versions of it, and the global read
|
|
43
|
+
* still falls back to main.
|
|
44
|
+
*/
|
|
45
|
+
export declare const resolveBranchGlobalVersionQuery: ({ branch, globalSlug, req, where, }: {
|
|
46
|
+
where: undefined | Where;
|
|
47
|
+
} & BaseArgs) => undefined | Where;
|
|
48
|
+
export {};
|
|
49
|
+
//# sourceMappingURL=globals.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"globals.d.ts","sourceRoot":"","sources":["../../src/branching/globals.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAK9D,KAAK,QAAQ,GAAG;IACd,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,CAAA;IACvB,UAAU,EAAE,MAAM,CAAA;IAClB,GAAG,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAA;CAC9B,CAAA;AAqBD;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,wCAKlC;IAAE,KAAK,EAAE,SAAS,GAAG,KAAK,CAAA;CAAE,GAAG,QAAQ,KAAG,SAAS,GAAG,KAcxD,CAAA;AAED,6EAA6E;AAC7E,eAAO,MAAM,yBAAyB,SAAU,QAAQ,KAAG,OAI1D,CAAA;AAED,wEAAwE;AACxE,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QACtD,CAAC,EAAE,UACD,MAAM,KACb,CAAC,GAAG,SAAyE,CAAA;AAEhF;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,SAAU,QAAQ,KAAG,IAAI,GAAG,MAIhE,CAAA;AAED,uEAAuE;AACvE,eAAO,MAAM,wBAAwB,iCAIlC;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,QAAQ,KAAG,OAAO,CAAC,IAAI,CA2B9C,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,+BAA+B,wCAKzC;IAAE,KAAK,EAAE,SAAS,GAAG,KAAK,CAAA;CAAE,GAAG,QAAQ,KAAG,SAAS,GAAG,KAUxD,CAAA"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { resolveBranch } from './resolveBranch.js';
|
|
2
|
+
import { branchChangesCollectionSlug, branchField, MAIN_BRANCH } from './types.js';
|
|
3
|
+
const bypassed = (branch, req)=>branch === false || !req?.payload || Boolean(req.context?._branchBypass);
|
|
4
|
+
const activeBranch = ({ branch, globalSlug, req })=>{
|
|
5
|
+
if (bypassed(branch, req)) {
|
|
6
|
+
return null;
|
|
7
|
+
}
|
|
8
|
+
const branching = req.payload.config?.branching;
|
|
9
|
+
if (!branching?.enabled || !branching.branchableGlobals.has(globalSlug)) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
return branch === false ? null : branch ?? resolveBranch(req);
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Branch predicate for reading a global.
|
|
16
|
+
*
|
|
17
|
+
* Unlike collections, this does not have to resolve everything inside one
|
|
18
|
+
* query: a global is a single document, so there is no result set to paginate
|
|
19
|
+
* or count and nothing a post-query step could get wrong. The query fetches the
|
|
20
|
+
* branch's row and main's row together and `pickBranchGlobal` prefers the
|
|
21
|
+
* branch's — one round trip, at most two rows.
|
|
22
|
+
*/ export const resolveBranchGlobalQuery = ({ branch, globalSlug, req, where })=>{
|
|
23
|
+
const active = activeBranch({
|
|
24
|
+
branch,
|
|
25
|
+
globalSlug,
|
|
26
|
+
req
|
|
27
|
+
});
|
|
28
|
+
if (!active) {
|
|
29
|
+
return where;
|
|
30
|
+
}
|
|
31
|
+
const base = where && Object.keys(where).length ? [
|
|
32
|
+
where
|
|
33
|
+
] : [];
|
|
34
|
+
if (active === MAIN_BRANCH) {
|
|
35
|
+
return {
|
|
36
|
+
and: [
|
|
37
|
+
...base,
|
|
38
|
+
{
|
|
39
|
+
[branchField]: {
|
|
40
|
+
equals: MAIN_BRANCH
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
and: [
|
|
48
|
+
...base,
|
|
49
|
+
{
|
|
50
|
+
[branchField]: {
|
|
51
|
+
in: [
|
|
52
|
+
active,
|
|
53
|
+
MAIN_BRANCH
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
/** True when the read should fetch two rows so the branch's copy can win. */ export const branchGlobalNeedsBothRows = (args)=>{
|
|
61
|
+
const active = activeBranch(args);
|
|
62
|
+
return Boolean(active) && active !== MAIN_BRANCH;
|
|
63
|
+
};
|
|
64
|
+
/** Picks the branch's copy of a global when it has one, else main's. */ export const pickBranchGlobal = (docs, branch)=>docs.find((doc)=>doc?.[branchField] === branch) ?? docs[0];
|
|
65
|
+
/**
|
|
66
|
+
* The branch a global write should be scoped to, or `null` on main.
|
|
67
|
+
*
|
|
68
|
+
* Storage differs too much between adapters to upsert the branch's copy here —
|
|
69
|
+
* Mongo keeps every global in one discriminated collection, Drizzle gives each
|
|
70
|
+
* its own table — so each adapter performs the upsert and calls
|
|
71
|
+
* `recordBranchGlobalChange` once it has.
|
|
72
|
+
*/ export const resolveBranchGlobalWrite = (args)=>{
|
|
73
|
+
const active = activeBranch(args);
|
|
74
|
+
return active && active !== MAIN_BRANCH ? active : null;
|
|
75
|
+
};
|
|
76
|
+
/** Registers a global as changed on a branch, if it is not already. */ export const recordBranchGlobalChange = async ({ branch, globalSlug, req })=>{
|
|
77
|
+
const existing = await req.payload.find({
|
|
78
|
+
collection: branchChangesCollectionSlug,
|
|
79
|
+
limit: 1,
|
|
80
|
+
overrideAccess: true,
|
|
81
|
+
pagination: false,
|
|
82
|
+
req: req,
|
|
83
|
+
where: {
|
|
84
|
+
and: [
|
|
85
|
+
{
|
|
86
|
+
branch: {
|
|
87
|
+
equals: branch
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
globalSlug: {
|
|
92
|
+
equals: globalSlug
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
]
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
if (existing.docs.length) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
await req.payload.create({
|
|
102
|
+
collection: branchChangesCollectionSlug,
|
|
103
|
+
data: {
|
|
104
|
+
branch,
|
|
105
|
+
entityType: 'global',
|
|
106
|
+
globalSlug,
|
|
107
|
+
operation: 'update'
|
|
108
|
+
},
|
|
109
|
+
overrideAccess: true,
|
|
110
|
+
req: req
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Branch predicate for global version reads.
|
|
115
|
+
*
|
|
116
|
+
* Strict equality rather than the read-through used for the global itself: a
|
|
117
|
+
* version list must not interleave two branches' histories, and ordering by
|
|
118
|
+
* timestamp would pick between them nondeterministically. A branch that has
|
|
119
|
+
* never touched the global simply has no versions of it, and the global read
|
|
120
|
+
* still falls back to main.
|
|
121
|
+
*/ export const resolveBranchGlobalVersionQuery = ({ branch, globalSlug, req, where })=>{
|
|
122
|
+
const active = activeBranch({
|
|
123
|
+
branch,
|
|
124
|
+
globalSlug,
|
|
125
|
+
req
|
|
126
|
+
});
|
|
127
|
+
if (!active) {
|
|
128
|
+
return where;
|
|
129
|
+
}
|
|
130
|
+
const base = where && Object.keys(where).length ? [
|
|
131
|
+
where
|
|
132
|
+
] : [];
|
|
133
|
+
return {
|
|
134
|
+
and: [
|
|
135
|
+
...base,
|
|
136
|
+
{
|
|
137
|
+
[branchField]: {
|
|
138
|
+
equals: active
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
]
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
//# sourceMappingURL=globals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/branching/globals.ts"],"sourcesContent":["import type { PayloadRequest, Where } from '../types/index.js'\n\nimport { resolveBranch } from './resolveBranch.js'\nimport { branchChangesCollectionSlug, branchField, MAIN_BRANCH } from './types.js'\n\ntype BaseArgs = {\n branch?: false | string\n globalSlug: string\n req?: Partial<PayloadRequest>\n}\n\nconst bypassed = (branch: false | string | undefined, req?: Partial<PayloadRequest>): boolean =>\n branch === false ||\n !req?.payload ||\n Boolean((req.context as Record<string, unknown> | undefined)?._branchBypass)\n\nconst activeBranch = ({ branch, globalSlug, req }: BaseArgs): null | string => {\n if (bypassed(branch, req)) {\n return null\n }\n\n const branching = req!.payload!.config?.branching\n\n if (!branching?.enabled || !branching.branchableGlobals.has(globalSlug)) {\n return null\n }\n\n return branch === false ? null : (branch ?? resolveBranch(req as PayloadRequest))\n}\n\n/**\n * Branch predicate for reading a global.\n *\n * Unlike collections, this does not have to resolve everything inside one\n * query: a global is a single document, so there is no result set to paginate\n * or count and nothing a post-query step could get wrong. The query fetches the\n * branch's row and main's row together and `pickBranchGlobal` prefers the\n * branch's — one round trip, at most two rows.\n */\nexport const resolveBranchGlobalQuery = ({\n branch,\n globalSlug,\n req,\n where,\n}: { where: undefined | Where } & BaseArgs): undefined | Where => {\n const active = activeBranch({ branch, globalSlug, req })\n\n if (!active) {\n return where\n }\n\n const base = where && Object.keys(where).length ? [where] : []\n\n if (active === MAIN_BRANCH) {\n return { and: [...base, { [branchField]: { equals: MAIN_BRANCH } }] }\n }\n\n return { and: [...base, { [branchField]: { in: [active, MAIN_BRANCH] } }] }\n}\n\n/** True when the read should fetch two rows so the branch's copy can win. */\nexport const branchGlobalNeedsBothRows = (args: BaseArgs): boolean => {\n const active = activeBranch(args)\n\n return Boolean(active) && active !== MAIN_BRANCH\n}\n\n/** Picks the branch's copy of a global when it has one, else main's. */\nexport const pickBranchGlobal = <T extends Record<string, any>>(\n docs: T[],\n branch: string,\n): T | undefined => docs.find((doc) => doc?.[branchField] === branch) ?? docs[0]\n\n/**\n * The branch a global write should be scoped to, or `null` on main.\n *\n * Storage differs too much between adapters to upsert the branch's copy here —\n * Mongo keeps every global in one discriminated collection, Drizzle gives each\n * its own table — so each adapter performs the upsert and calls\n * `recordBranchGlobalChange` once it has.\n */\nexport const resolveBranchGlobalWrite = (args: BaseArgs): null | string => {\n const active = activeBranch(args)\n\n return active && active !== MAIN_BRANCH ? active : null\n}\n\n/** Registers a global as changed on a branch, if it is not already. */\nexport const recordBranchGlobalChange = async ({\n branch,\n globalSlug,\n req,\n}: { branch: string } & BaseArgs): Promise<void> => {\n const existing = await req!.payload!.find({\n collection: branchChangesCollectionSlug,\n limit: 1,\n overrideAccess: true,\n pagination: false,\n req: req as PayloadRequest,\n where: {\n and: [{ branch: { equals: branch } }, { globalSlug: { equals: globalSlug } }],\n },\n })\n\n if (existing.docs.length) {\n return\n }\n\n await req!.payload!.create({\n collection: branchChangesCollectionSlug,\n data: {\n branch,\n entityType: 'global',\n globalSlug,\n operation: 'update',\n },\n overrideAccess: true,\n req: req as PayloadRequest,\n })\n}\n\n/**\n * Branch predicate for global version reads.\n *\n * Strict equality rather than the read-through used for the global itself: a\n * version list must not interleave two branches' histories, and ordering by\n * timestamp would pick between them nondeterministically. A branch that has\n * never touched the global simply has no versions of it, and the global read\n * still falls back to main.\n */\nexport const resolveBranchGlobalVersionQuery = ({\n branch,\n globalSlug,\n req,\n where,\n}: { where: undefined | Where } & BaseArgs): undefined | Where => {\n const active = activeBranch({ branch, globalSlug, req })\n\n if (!active) {\n return where\n }\n\n const base = where && Object.keys(where).length ? [where] : []\n\n return { and: [...base, { [branchField]: { equals: active } }] }\n}\n"],"names":["resolveBranch","branchChangesCollectionSlug","branchField","MAIN_BRANCH","bypassed","branch","req","payload","Boolean","context","_branchBypass","activeBranch","globalSlug","branching","config","enabled","branchableGlobals","has","resolveBranchGlobalQuery","where","active","base","Object","keys","length","and","equals","in","branchGlobalNeedsBothRows","args","pickBranchGlobal","docs","find","doc","resolveBranchGlobalWrite","recordBranchGlobalChange","existing","collection","limit","overrideAccess","pagination","create","data","entityType","operation","resolveBranchGlobalVersionQuery"],"mappings":"AAEA,SAASA,aAAa,QAAQ,qBAAoB;AAClD,SAASC,2BAA2B,EAAEC,WAAW,EAAEC,WAAW,QAAQ,aAAY;AAQlF,MAAMC,WAAW,CAACC,QAAoCC,MACpDD,WAAW,SACX,CAACC,KAAKC,WACNC,QAASF,IAAIG,OAAO,EAA0CC;AAEhE,MAAMC,eAAe,CAAC,EAAEN,MAAM,EAAEO,UAAU,EAAEN,GAAG,EAAY;IACzD,IAAIF,SAASC,QAAQC,MAAM;QACzB,OAAO;IACT;IAEA,MAAMO,YAAYP,IAAKC,OAAO,CAAEO,MAAM,EAAED;IAExC,IAAI,CAACA,WAAWE,WAAW,CAACF,UAAUG,iBAAiB,CAACC,GAAG,CAACL,aAAa;QACvE,OAAO;IACT;IAEA,OAAOP,WAAW,QAAQ,OAAQA,UAAUL,cAAcM;AAC5D;AAEA;;;;;;;;CAQC,GACD,OAAO,MAAMY,2BAA2B,CAAC,EACvCb,MAAM,EACNO,UAAU,EACVN,GAAG,EACHa,KAAK,EACmC;IACxC,MAAMC,SAAST,aAAa;QAAEN;QAAQO;QAAYN;IAAI;IAEtD,IAAI,CAACc,QAAQ;QACX,OAAOD;IACT;IAEA,MAAME,OAAOF,SAASG,OAAOC,IAAI,CAACJ,OAAOK,MAAM,GAAG;QAACL;KAAM,GAAG,EAAE;IAE9D,IAAIC,WAAWjB,aAAa;QAC1B,OAAO;YAAEsB,KAAK;mBAAIJ;gBAAM;oBAAE,CAACnB,YAAY,EAAE;wBAAEwB,QAAQvB;oBAAY;gBAAE;aAAE;QAAC;IACtE;IAEA,OAAO;QAAEsB,KAAK;eAAIJ;YAAM;gBAAE,CAACnB,YAAY,EAAE;oBAAEyB,IAAI;wBAACP;wBAAQjB;qBAAY;gBAAC;YAAE;SAAE;IAAC;AAC5E,EAAC;AAED,2EAA2E,GAC3E,OAAO,MAAMyB,4BAA4B,CAACC;IACxC,MAAMT,SAAST,aAAakB;IAE5B,OAAOrB,QAAQY,WAAWA,WAAWjB;AACvC,EAAC;AAED,sEAAsE,GACtE,OAAO,MAAM2B,mBAAmB,CAC9BC,MACA1B,SACkB0B,KAAKC,IAAI,CAAC,CAACC,MAAQA,KAAK,CAAC/B,YAAY,KAAKG,WAAW0B,IAAI,CAAC,EAAE,CAAA;AAEhF;;;;;;;CAOC,GACD,OAAO,MAAMG,2BAA2B,CAACL;IACvC,MAAMT,SAAST,aAAakB;IAE5B,OAAOT,UAAUA,WAAWjB,cAAciB,SAAS;AACrD,EAAC;AAED,qEAAqE,GACrE,OAAO,MAAMe,2BAA2B,OAAO,EAC7C9B,MAAM,EACNO,UAAU,EACVN,GAAG,EAC2B;IAC9B,MAAM8B,WAAW,MAAM9B,IAAKC,OAAO,CAAEyB,IAAI,CAAC;QACxCK,YAAYpC;QACZqC,OAAO;QACPC,gBAAgB;QAChBC,YAAY;QACZlC,KAAKA;QACLa,OAAO;YACLM,KAAK;gBAAC;oBAAEpB,QAAQ;wBAAEqB,QAAQrB;oBAAO;gBAAE;gBAAG;oBAAEO,YAAY;wBAAEc,QAAQd;oBAAW;gBAAE;aAAE;QAC/E;IACF;IAEA,IAAIwB,SAASL,IAAI,CAACP,MAAM,EAAE;QACxB;IACF;IAEA,MAAMlB,IAAKC,OAAO,CAAEkC,MAAM,CAAC;QACzBJ,YAAYpC;QACZyC,MAAM;YACJrC;YACAsC,YAAY;YACZ/B;YACAgC,WAAW;QACb;QACAL,gBAAgB;QAChBjC,KAAKA;IACP;AACF,EAAC;AAED;;;;;;;;CAQC,GACD,OAAO,MAAMuC,kCAAkC,CAAC,EAC9CxC,MAAM,EACNO,UAAU,EACVN,GAAG,EACHa,KAAK,EACmC;IACxC,MAAMC,SAAST,aAAa;QAAEN;QAAQO;QAAYN;IAAI;IAEtD,IAAI,CAACc,QAAQ;QACX,OAAOD;IACT;IAEA,MAAME,OAAOF,SAASG,OAAOC,IAAI,CAACJ,OAAOK,MAAM,GAAG;QAACL;KAAM,GAAG,EAAE;IAE9D,OAAO;QAAEM,KAAK;eAAIJ;YAAM;gBAAE,CAACnB,YAAY,EAAE;oBAAEwB,QAAQN;gBAAO;YAAE;SAAE;IAAC;AACjE,EAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { CollectionAfterChangeHook, CollectionBeforeChangeHook, CollectionBeforeOperationHook } from '../index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Stamps documents created on a branch so the read predicate can find them.
|
|
4
|
+
*
|
|
5
|
+
* `_branchDocID` is deliberately left null. For a document created on a branch
|
|
6
|
+
* the canonical ID *is* the row's own ID, and the ID rewrite treats a null
|
|
7
|
+
* `_branchDocID` as "self" — so setting it would mean an extra write after
|
|
8
|
+
* insert to learn the generated ID, for no gain. Only forked rows, which point
|
|
9
|
+
* at a different main row, need it populated.
|
|
10
|
+
*/
|
|
11
|
+
export declare const stampBranchOnCreate: CollectionBeforeChangeHook;
|
|
12
|
+
/**
|
|
13
|
+
* Records a branch-created document in the changeset registry.
|
|
14
|
+
*
|
|
15
|
+
* The registry is not consulted to *read* branch-created documents — those are
|
|
16
|
+
* found by `_branch` alone. It exists so merge and the changed-documents view
|
|
17
|
+
* can enumerate what a branch has done.
|
|
18
|
+
*/
|
|
19
|
+
export declare const recordBranchCreate: CollectionAfterChangeHook;
|
|
20
|
+
/**
|
|
21
|
+
* Redirects a branch update onto the branch's own copy of the document,
|
|
22
|
+
* copy-on-writing that copy into existence the first time.
|
|
23
|
+
*
|
|
24
|
+
* Rewriting `args.id` rather than intercepting the write means the rest of the
|
|
25
|
+
* operation — field hooks, validation, version creation — runs unmodified
|
|
26
|
+
* against a real row.
|
|
27
|
+
*/
|
|
28
|
+
export declare const forkOnBranchUpdate: CollectionBeforeOperationHook;
|
|
29
|
+
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/branching/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,0BAA0B,EAC1B,6BAA6B,EAC9B,MAAM,aAAa,CAAA;AAMpB;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,EAAE,0BAYjC,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,EAAE,yBA0BhC,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,EAAE,6BA6BhC,CAAA"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { forkDocument } from './forkDocument.js';
|
|
2
|
+
import { resolveBranch } from './resolveBranch.js';
|
|
3
|
+
import { branchChangesCollectionSlug, branchField, branchOpField, MAIN_BRANCH } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Stamps documents created on a branch so the read predicate can find them.
|
|
6
|
+
*
|
|
7
|
+
* `_branchDocID` is deliberately left null. For a document created on a branch
|
|
8
|
+
* the canonical ID *is* the row's own ID, and the ID rewrite treats a null
|
|
9
|
+
* `_branchDocID` as "self" — so setting it would mean an extra write after
|
|
10
|
+
* insert to learn the generated ID, for no gain. Only forked rows, which point
|
|
11
|
+
* at a different main row, need it populated.
|
|
12
|
+
*/ export const stampBranchOnCreate = ({ data, operation, req })=>{
|
|
13
|
+
const branch = resolveBranch(req);
|
|
14
|
+
if (branch === MAIN_BRANCH || operation !== 'create') {
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
...data,
|
|
19
|
+
[branchField]: branch,
|
|
20
|
+
[branchOpField]: 'create'
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Records a branch-created document in the changeset registry.
|
|
25
|
+
*
|
|
26
|
+
* The registry is not consulted to *read* branch-created documents — those are
|
|
27
|
+
* found by `_branch` alone. It exists so merge and the changed-documents view
|
|
28
|
+
* can enumerate what a branch has done.
|
|
29
|
+
*/ export const recordBranchCreate = async ({ collection, doc, operation, req })=>{
|
|
30
|
+
const branch = resolveBranch(req);
|
|
31
|
+
if (branch === MAIN_BRANCH || operation !== 'create') {
|
|
32
|
+
return doc;
|
|
33
|
+
}
|
|
34
|
+
await req.payload.create({
|
|
35
|
+
collection: branchChangesCollectionSlug,
|
|
36
|
+
data: {
|
|
37
|
+
branch,
|
|
38
|
+
collectionSlug: collection.slug,
|
|
39
|
+
doc: {
|
|
40
|
+
relationTo: collection.slug,
|
|
41
|
+
value: doc.id
|
|
42
|
+
},
|
|
43
|
+
entityType: 'collection',
|
|
44
|
+
operation: 'create'
|
|
45
|
+
},
|
|
46
|
+
overrideAccess: true,
|
|
47
|
+
req
|
|
48
|
+
});
|
|
49
|
+
return doc;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Redirects a branch update onto the branch's own copy of the document,
|
|
53
|
+
* copy-on-writing that copy into existence the first time.
|
|
54
|
+
*
|
|
55
|
+
* Rewriting `args.id` rather than intercepting the write means the rest of the
|
|
56
|
+
* operation — field hooks, validation, version creation — runs unmodified
|
|
57
|
+
* against a real row.
|
|
58
|
+
*/ export const forkOnBranchUpdate = async ({ args, collection, operation, req })=>{
|
|
59
|
+
if (operation !== 'updateByID' && operation !== 'update') {
|
|
60
|
+
return args;
|
|
61
|
+
}
|
|
62
|
+
const id = args.id;
|
|
63
|
+
if (id === undefined || id === null) {
|
|
64
|
+
return args;
|
|
65
|
+
}
|
|
66
|
+
const branch = resolveBranch(req);
|
|
67
|
+
if (branch === MAIN_BRANCH) {
|
|
68
|
+
return args;
|
|
69
|
+
}
|
|
70
|
+
// Ensures the branch has its own copy, but leaves `args.id` as the canonical
|
|
71
|
+
// ID. Canonical IDs are the only identity the API exposes; the read path
|
|
72
|
+
// resolves them through the where-tree rewrite and the write path through
|
|
73
|
+
// `resolveBranchRowID`.
|
|
74
|
+
await forkDocument({
|
|
75
|
+
id,
|
|
76
|
+
collectionSlug: collection.slug,
|
|
77
|
+
req
|
|
78
|
+
});
|
|
79
|
+
return args;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/branching/hooks.ts"],"sourcesContent":["import type {\n CollectionAfterChangeHook,\n CollectionBeforeChangeHook,\n CollectionBeforeOperationHook,\n} from '../index.js'\n\nimport { forkDocument } from './forkDocument.js'\nimport { resolveBranch } from './resolveBranch.js'\nimport { branchChangesCollectionSlug, branchField, branchOpField, MAIN_BRANCH } from './types.js'\n\n/**\n * Stamps documents created on a branch so the read predicate can find them.\n *\n * `_branchDocID` is deliberately left null. For a document created on a branch\n * the canonical ID *is* the row's own ID, and the ID rewrite treats a null\n * `_branchDocID` as \"self\" — so setting it would mean an extra write after\n * insert to learn the generated ID, for no gain. Only forked rows, which point\n * at a different main row, need it populated.\n */\nexport const stampBranchOnCreate: CollectionBeforeChangeHook = ({ data, operation, req }) => {\n const branch = resolveBranch(req)\n\n if (branch === MAIN_BRANCH || operation !== 'create') {\n return data\n }\n\n return {\n ...data,\n [branchField]: branch,\n [branchOpField]: 'create',\n }\n}\n\n/**\n * Records a branch-created document in the changeset registry.\n *\n * The registry is not consulted to *read* branch-created documents — those are\n * found by `_branch` alone. It exists so merge and the changed-documents view\n * can enumerate what a branch has done.\n */\nexport const recordBranchCreate: CollectionAfterChangeHook = async ({\n collection,\n doc,\n operation,\n req,\n}) => {\n const branch = resolveBranch(req)\n\n if (branch === MAIN_BRANCH || operation !== 'create') {\n return doc\n }\n\n await req.payload.create({\n collection: branchChangesCollectionSlug,\n data: {\n branch,\n collectionSlug: collection.slug,\n doc: { relationTo: collection.slug, value: doc.id },\n entityType: 'collection',\n operation: 'create',\n },\n overrideAccess: true,\n req,\n })\n\n return doc\n}\n\n/**\n * Redirects a branch update onto the branch's own copy of the document,\n * copy-on-writing that copy into existence the first time.\n *\n * Rewriting `args.id` rather than intercepting the write means the rest of the\n * operation — field hooks, validation, version creation — runs unmodified\n * against a real row.\n */\nexport const forkOnBranchUpdate: CollectionBeforeOperationHook = async ({\n args,\n collection,\n operation,\n req,\n}) => {\n if (operation !== 'updateByID' && operation !== 'update') {\n return args\n }\n\n const id = (args as { id?: number | string }).id\n\n if (id === undefined || id === null) {\n return args\n }\n\n const branch = resolveBranch(req)\n\n if (branch === MAIN_BRANCH) {\n return args\n }\n\n // Ensures the branch has its own copy, but leaves `args.id` as the canonical\n // ID. Canonical IDs are the only identity the API exposes; the read path\n // resolves them through the where-tree rewrite and the write path through\n // `resolveBranchRowID`.\n await forkDocument({ id, collectionSlug: collection.slug, req })\n\n return args\n}\n"],"names":["forkDocument","resolveBranch","branchChangesCollectionSlug","branchField","branchOpField","MAIN_BRANCH","stampBranchOnCreate","data","operation","req","branch","recordBranchCreate","collection","doc","payload","create","collectionSlug","slug","relationTo","value","id","entityType","overrideAccess","forkOnBranchUpdate","args","undefined"],"mappings":"AAMA,SAASA,YAAY,QAAQ,oBAAmB;AAChD,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,2BAA2B,EAAEC,WAAW,EAAEC,aAAa,EAAEC,WAAW,QAAQ,aAAY;AAEjG;;;;;;;;CAQC,GACD,OAAO,MAAMC,sBAAkD,CAAC,EAAEC,IAAI,EAAEC,SAAS,EAAEC,GAAG,EAAE;IACtF,MAAMC,SAAST,cAAcQ;IAE7B,IAAIC,WAAWL,eAAeG,cAAc,UAAU;QACpD,OAAOD;IACT;IAEA,OAAO;QACL,GAAGA,IAAI;QACP,CAACJ,YAAY,EAAEO;QACf,CAACN,cAAc,EAAE;IACnB;AACF,EAAC;AAED;;;;;;CAMC,GACD,OAAO,MAAMO,qBAAgD,OAAO,EAClEC,UAAU,EACVC,GAAG,EACHL,SAAS,EACTC,GAAG,EACJ;IACC,MAAMC,SAAST,cAAcQ;IAE7B,IAAIC,WAAWL,eAAeG,cAAc,UAAU;QACpD,OAAOK;IACT;IAEA,MAAMJ,IAAIK,OAAO,CAACC,MAAM,CAAC;QACvBH,YAAYV;QACZK,MAAM;YACJG;YACAM,gBAAgBJ,WAAWK,IAAI;YAC/BJ,KAAK;gBAAEK,YAAYN,WAAWK,IAAI;gBAAEE,OAAON,IAAIO,EAAE;YAAC;YAClDC,YAAY;YACZb,WAAW;QACb;QACAc,gBAAgB;QAChBb;IACF;IAEA,OAAOI;AACT,EAAC;AAED;;;;;;;CAOC,GACD,OAAO,MAAMU,qBAAoD,OAAO,EACtEC,IAAI,EACJZ,UAAU,EACVJ,SAAS,EACTC,GAAG,EACJ;IACC,IAAID,cAAc,gBAAgBA,cAAc,UAAU;QACxD,OAAOgB;IACT;IAEA,MAAMJ,KAAK,AAACI,KAAkCJ,EAAE;IAEhD,IAAIA,OAAOK,aAAaL,OAAO,MAAM;QACnC,OAAOI;IACT;IAEA,MAAMd,SAAST,cAAcQ;IAE7B,IAAIC,WAAWL,aAAa;QAC1B,OAAOmB;IACT;IAEA,6EAA6E;IAC7E,yEAAyE;IACzE,0EAA0E;IAC1E,wBAAwB;IACxB,MAAMxB,aAAa;QAAEoB;QAAIJ,gBAAgBJ,WAAWK,IAAI;QAAER;IAAI;IAE9D,OAAOe;AACT,EAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { CollectionConfig } from '../collections/config/types.js';
|
|
2
|
+
import type { Field } from '../fields/config/types.js';
|
|
3
|
+
import type { GlobalConfig } from '../globals/config/types.js';
|
|
4
|
+
/**
|
|
5
|
+
* `_branch` — which branch a row belongs to. `'main'` is a non-null sentinel
|
|
6
|
+
* rather than NULL so that compound `(field, _branch)` unique indexes keep
|
|
7
|
+
* enforcing uniqueness among main rows on Postgres, which treats NULLs as
|
|
8
|
+
* distinct.
|
|
9
|
+
*/
|
|
10
|
+
export declare const buildBranchField: () => Field;
|
|
11
|
+
/**
|
|
12
|
+
* `_branchDocID` — the canonical document this row represents. Null on main
|
|
13
|
+
* rows, meaning "self".
|
|
14
|
+
*
|
|
15
|
+
* Declared as a self-referential `relationship` rather than `text` for two
|
|
16
|
+
* reasons: it inherits the collection's own ID type (which may be text,
|
|
17
|
+
* number, or a custom ID), and Payload's Drizzle builder special-cases
|
|
18
|
+
* `not_in` for relationship fields to emit `(col NOT IN (...) OR col IS NULL)`,
|
|
19
|
+
* without which every main row would be excluded from a branch read.
|
|
20
|
+
*/
|
|
21
|
+
export declare const buildBranchDocIDField: (slug: string) => Field;
|
|
22
|
+
/** `_branchOp` — what this row represents on its branch. Null on main rows. */
|
|
23
|
+
export declare const buildBranchOpField: () => Field;
|
|
24
|
+
/** `_branchParent` — the canonical parent document, for version rows. */
|
|
25
|
+
export declare const buildBranchParentField: (slug: string) => Field;
|
|
26
|
+
/**
|
|
27
|
+
* Injects the branch discriminator fields and rewrites `unique: true` fields
|
|
28
|
+
* into branch-scoped compound indexes.
|
|
29
|
+
*
|
|
30
|
+
* A branch holds a full copy of a document, so an unscoped unique index would
|
|
31
|
+
* reject the copy outright. Scoping by `_branch` lets two branches each hold a
|
|
32
|
+
* document with the same value while preserving uniqueness within a branch.
|
|
33
|
+
*/
|
|
34
|
+
export declare const injectBranchFields: (collection: CollectionConfig) => CollectionConfig;
|
|
35
|
+
/**
|
|
36
|
+
* Globals need only the discriminator.
|
|
37
|
+
*
|
|
38
|
+
* No `_branchDocID`, because a global's identity is its slug and is stable
|
|
39
|
+
* across branches — the whole canonical-ID translation problem does not arise.
|
|
40
|
+
* No `_branchOp`, because globals cannot be created or deleted through the API,
|
|
41
|
+
* so there are no tombstones.
|
|
42
|
+
*/
|
|
43
|
+
export declare const injectGlobalBranchFields: (global: GlobalConfig) => GlobalConfig;
|
|
44
|
+
//# sourceMappingURL=injectBranchFields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"injectBranchFields.d.ts","sourceRoot":"","sources":["../../src/branching/injectBranchFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACtE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AA6B9D;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,QAAO,KAOlC,CAAA;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB,SAAU,MAAM,KAAG,KAOnD,CAAA;AAEF,+EAA+E;AAC/E,eAAO,MAAM,kBAAkB,QAAO,KAKpC,CAAA;AAEF,yEAAyE;AACzE,eAAO,MAAM,sBAAsB,SAAU,MAAM,KAAG,KAOpD,CAAA;AAKF;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,eAAgB,gBAAgB,KAAG,gBAiCjE,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,WAAY,YAAY,KAAG,YAM/D,CAAA"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { forkOnBranchUpdate, recordBranchCreate, stampBranchOnCreate } from './hooks.js';
|
|
2
|
+
import { branchDocIDField, branchField, branchOpField, branchParentField, MAIN_BRANCH } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* These columns are branch bookkeeping, not content. They are `admin.hidden`,
|
|
5
|
+
* but hidden is not the same as read-only: the admin form round-trips every
|
|
6
|
+
* field it loaded, so an edit made on a branch would submit the `_branch` it
|
|
7
|
+
* was read with and stamp it back onto the shadow row — quietly moving that
|
|
8
|
+
* row onto `main` and duplicating the document in production.
|
|
9
|
+
*
|
|
10
|
+
* Denying field-level create/update makes them internally writable only.
|
|
11
|
+
* Field access is skipped under `overrideAccess: true`, which is exactly the
|
|
12
|
+
* exemption merge needs to flip `_branch` to `'main'` (§16), and the
|
|
13
|
+
* copy-on-write paths write through `payload.db` directly, below field access
|
|
14
|
+
* entirely.
|
|
15
|
+
*/ const internalOnly = {
|
|
16
|
+
access: {
|
|
17
|
+
create: ()=>false,
|
|
18
|
+
update: ()=>false
|
|
19
|
+
},
|
|
20
|
+
admin: {
|
|
21
|
+
disabled: {
|
|
22
|
+
bulkEdit: true
|
|
23
|
+
},
|
|
24
|
+
hidden: true
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* `_branch` — which branch a row belongs to. `'main'` is a non-null sentinel
|
|
29
|
+
* rather than NULL so that compound `(field, _branch)` unique indexes keep
|
|
30
|
+
* enforcing uniqueness among main rows on Postgres, which treats NULLs as
|
|
31
|
+
* distinct.
|
|
32
|
+
*/ export const buildBranchField = ()=>({
|
|
33
|
+
name: branchField,
|
|
34
|
+
type: 'text',
|
|
35
|
+
...internalOnly,
|
|
36
|
+
defaultValue: MAIN_BRANCH,
|
|
37
|
+
index: true,
|
|
38
|
+
required: true
|
|
39
|
+
});
|
|
40
|
+
/**
|
|
41
|
+
* `_branchDocID` — the canonical document this row represents. Null on main
|
|
42
|
+
* rows, meaning "self".
|
|
43
|
+
*
|
|
44
|
+
* Declared as a self-referential `relationship` rather than `text` for two
|
|
45
|
+
* reasons: it inherits the collection's own ID type (which may be text,
|
|
46
|
+
* number, or a custom ID), and Payload's Drizzle builder special-cases
|
|
47
|
+
* `not_in` for relationship fields to emit `(col NOT IN (...) OR col IS NULL)`,
|
|
48
|
+
* without which every main row would be excluded from a branch read.
|
|
49
|
+
*/ export const buildBranchDocIDField = (slug)=>({
|
|
50
|
+
name: branchDocIDField,
|
|
51
|
+
type: 'relationship',
|
|
52
|
+
...internalOnly,
|
|
53
|
+
index: true,
|
|
54
|
+
maxDepth: 0,
|
|
55
|
+
relationTo: slug
|
|
56
|
+
});
|
|
57
|
+
/** `_branchOp` — what this row represents on its branch. Null on main rows. */ export const buildBranchOpField = ()=>({
|
|
58
|
+
name: branchOpField,
|
|
59
|
+
type: 'text',
|
|
60
|
+
...internalOnly,
|
|
61
|
+
index: true
|
|
62
|
+
});
|
|
63
|
+
/** `_branchParent` — the canonical parent document, for version rows. */ export const buildBranchParentField = (slug)=>({
|
|
64
|
+
name: branchParentField,
|
|
65
|
+
type: 'relationship',
|
|
66
|
+
...internalOnly,
|
|
67
|
+
index: true,
|
|
68
|
+
maxDepth: 0,
|
|
69
|
+
relationTo: slug
|
|
70
|
+
});
|
|
71
|
+
const hasField = (fields, name)=>fields.some((field)=>'name' in field && field.name === name);
|
|
72
|
+
/**
|
|
73
|
+
* Injects the branch discriminator fields and rewrites `unique: true` fields
|
|
74
|
+
* into branch-scoped compound indexes.
|
|
75
|
+
*
|
|
76
|
+
* A branch holds a full copy of a document, so an unscoped unique index would
|
|
77
|
+
* reject the copy outright. Scoping by `_branch` lets two branches each hold a
|
|
78
|
+
* document with the same value while preserving uniqueness within a branch.
|
|
79
|
+
*/ export const injectBranchFields = (collection)=>{
|
|
80
|
+
if (!hasField(collection.fields, branchField)) {
|
|
81
|
+
collection.fields.push(buildBranchField());
|
|
82
|
+
}
|
|
83
|
+
if (!hasField(collection.fields, branchDocIDField)) {
|
|
84
|
+
collection.fields.push(buildBranchDocIDField(collection.slug));
|
|
85
|
+
}
|
|
86
|
+
if (!hasField(collection.fields, branchOpField)) {
|
|
87
|
+
collection.fields.push(buildBranchOpField());
|
|
88
|
+
}
|
|
89
|
+
const indexes = collection.indexes ?? [];
|
|
90
|
+
for (const field of collection.fields){
|
|
91
|
+
if ('name' in field && 'unique' in field && field.unique) {
|
|
92
|
+
field.unique = false;
|
|
93
|
+
indexes.push({
|
|
94
|
+
fields: [
|
|
95
|
+
field.name,
|
|
96
|
+
branchField
|
|
97
|
+
],
|
|
98
|
+
unique: true
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
collection.indexes = indexes;
|
|
103
|
+
collection.hooks = collection.hooks ?? {};
|
|
104
|
+
collection.hooks.beforeChange = [
|
|
105
|
+
...collection.hooks.beforeChange ?? [],
|
|
106
|
+
stampBranchOnCreate
|
|
107
|
+
];
|
|
108
|
+
collection.hooks.afterChange = [
|
|
109
|
+
...collection.hooks.afterChange ?? [],
|
|
110
|
+
recordBranchCreate
|
|
111
|
+
];
|
|
112
|
+
collection.hooks.beforeOperation = [
|
|
113
|
+
...collection.hooks.beforeOperation ?? [],
|
|
114
|
+
forkOnBranchUpdate
|
|
115
|
+
];
|
|
116
|
+
return collection;
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Globals need only the discriminator.
|
|
120
|
+
*
|
|
121
|
+
* No `_branchDocID`, because a global's identity is its slug and is stable
|
|
122
|
+
* across branches — the whole canonical-ID translation problem does not arise.
|
|
123
|
+
* No `_branchOp`, because globals cannot be created or deleted through the API,
|
|
124
|
+
* so there are no tombstones.
|
|
125
|
+
*/ export const injectGlobalBranchFields = (global)=>{
|
|
126
|
+
if (!hasField(global.fields, branchField)) {
|
|
127
|
+
global.fields.push(buildBranchField());
|
|
128
|
+
}
|
|
129
|
+
return global;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
//# sourceMappingURL=injectBranchFields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/branching/injectBranchFields.ts"],"sourcesContent":["import type { CollectionConfig } from '../collections/config/types.js'\nimport type { Field } from '../fields/config/types.js'\nimport type { GlobalConfig } from '../globals/config/types.js'\n\nimport { forkOnBranchUpdate, recordBranchCreate, stampBranchOnCreate } from './hooks.js'\nimport {\n branchDocIDField,\n branchField,\n branchOpField,\n branchParentField,\n MAIN_BRANCH,\n} from './types.js'\n\n/**\n * These columns are branch bookkeeping, not content. They are `admin.hidden`,\n * but hidden is not the same as read-only: the admin form round-trips every\n * field it loaded, so an edit made on a branch would submit the `_branch` it\n * was read with and stamp it back onto the shadow row — quietly moving that\n * row onto `main` and duplicating the document in production.\n *\n * Denying field-level create/update makes them internally writable only.\n * Field access is skipped under `overrideAccess: true`, which is exactly the\n * exemption merge needs to flip `_branch` to `'main'` (§16), and the\n * copy-on-write paths write through `payload.db` directly, below field access\n * entirely.\n */\nconst internalOnly = {\n access: { create: () => false, update: () => false },\n admin: { disabled: { bulkEdit: true }, hidden: true },\n} as const\n\n/**\n * `_branch` — which branch a row belongs to. `'main'` is a non-null sentinel\n * rather than NULL so that compound `(field, _branch)` unique indexes keep\n * enforcing uniqueness among main rows on Postgres, which treats NULLs as\n * distinct.\n */\nexport const buildBranchField = (): Field => ({\n name: branchField,\n type: 'text',\n ...internalOnly,\n defaultValue: MAIN_BRANCH,\n index: true,\n required: true,\n})\n\n/**\n * `_branchDocID` — the canonical document this row represents. Null on main\n * rows, meaning \"self\".\n *\n * Declared as a self-referential `relationship` rather than `text` for two\n * reasons: it inherits the collection's own ID type (which may be text,\n * number, or a custom ID), and Payload's Drizzle builder special-cases\n * `not_in` for relationship fields to emit `(col NOT IN (...) OR col IS NULL)`,\n * without which every main row would be excluded from a branch read.\n */\nexport const buildBranchDocIDField = (slug: string): Field => ({\n name: branchDocIDField,\n type: 'relationship',\n ...internalOnly,\n index: true,\n maxDepth: 0,\n relationTo: slug,\n})\n\n/** `_branchOp` — what this row represents on its branch. Null on main rows. */\nexport const buildBranchOpField = (): Field => ({\n name: branchOpField,\n type: 'text',\n ...internalOnly,\n index: true,\n})\n\n/** `_branchParent` — the canonical parent document, for version rows. */\nexport const buildBranchParentField = (slug: string): Field => ({\n name: branchParentField,\n type: 'relationship',\n ...internalOnly,\n index: true,\n maxDepth: 0,\n relationTo: slug,\n})\n\nconst hasField = (fields: Field[], name: string): boolean =>\n fields.some((field) => 'name' in field && field.name === name)\n\n/**\n * Injects the branch discriminator fields and rewrites `unique: true` fields\n * into branch-scoped compound indexes.\n *\n * A branch holds a full copy of a document, so an unscoped unique index would\n * reject the copy outright. Scoping by `_branch` lets two branches each hold a\n * document with the same value while preserving uniqueness within a branch.\n */\nexport const injectBranchFields = (collection: CollectionConfig): CollectionConfig => {\n if (!hasField(collection.fields, branchField)) {\n collection.fields.push(buildBranchField())\n }\n\n if (!hasField(collection.fields, branchDocIDField)) {\n collection.fields.push(buildBranchDocIDField(collection.slug))\n }\n\n if (!hasField(collection.fields, branchOpField)) {\n collection.fields.push(buildBranchOpField())\n }\n\n const indexes = collection.indexes ?? []\n\n for (const field of collection.fields) {\n if ('name' in field && 'unique' in field && field.unique) {\n field.unique = false\n indexes.push({ fields: [field.name, branchField], unique: true })\n }\n }\n\n collection.indexes = indexes\n\n collection.hooks = collection.hooks ?? {}\n collection.hooks.beforeChange = [...(collection.hooks.beforeChange ?? []), stampBranchOnCreate]\n collection.hooks.afterChange = [...(collection.hooks.afterChange ?? []), recordBranchCreate]\n collection.hooks.beforeOperation = [\n ...(collection.hooks.beforeOperation ?? []),\n forkOnBranchUpdate,\n ]\n\n return collection\n}\n\n/**\n * Globals need only the discriminator.\n *\n * No `_branchDocID`, because a global's identity is its slug and is stable\n * across branches — the whole canonical-ID translation problem does not arise.\n * No `_branchOp`, because globals cannot be created or deleted through the API,\n * so there are no tombstones.\n */\nexport const injectGlobalBranchFields = (global: GlobalConfig): GlobalConfig => {\n if (!hasField(global.fields, branchField)) {\n global.fields.push(buildBranchField())\n }\n\n return global\n}\n"],"names":["forkOnBranchUpdate","recordBranchCreate","stampBranchOnCreate","branchDocIDField","branchField","branchOpField","branchParentField","MAIN_BRANCH","internalOnly","access","create","update","admin","disabled","bulkEdit","hidden","buildBranchField","name","type","defaultValue","index","required","buildBranchDocIDField","slug","maxDepth","relationTo","buildBranchOpField","buildBranchParentField","hasField","fields","some","field","injectBranchFields","collection","push","indexes","unique","hooks","beforeChange","afterChange","beforeOperation","injectGlobalBranchFields","global"],"mappings":"AAIA,SAASA,kBAAkB,EAAEC,kBAAkB,EAAEC,mBAAmB,QAAQ,aAAY;AACxF,SACEC,gBAAgB,EAChBC,WAAW,EACXC,aAAa,EACbC,iBAAiB,EACjBC,WAAW,QACN,aAAY;AAEnB;;;;;;;;;;;;CAYC,GACD,MAAMC,eAAe;IACnBC,QAAQ;QAAEC,QAAQ,IAAM;QAAOC,QAAQ,IAAM;IAAM;IACnDC,OAAO;QAAEC,UAAU;YAAEC,UAAU;QAAK;QAAGC,QAAQ;IAAK;AACtD;AAEA;;;;;CAKC,GACD,OAAO,MAAMC,mBAAmB,IAAc,CAAA;QAC5CC,MAAMb;QACNc,MAAM;QACN,GAAGV,YAAY;QACfW,cAAcZ;QACda,OAAO;QACPC,UAAU;IACZ,CAAA,EAAE;AAEF;;;;;;;;;CASC,GACD,OAAO,MAAMC,wBAAwB,CAACC,OAAyB,CAAA;QAC7DN,MAAMd;QACNe,MAAM;QACN,GAAGV,YAAY;QACfY,OAAO;QACPI,UAAU;QACVC,YAAYF;IACd,CAAA,EAAE;AAEF,6EAA6E,GAC7E,OAAO,MAAMG,qBAAqB,IAAc,CAAA;QAC9CT,MAAMZ;QACNa,MAAM;QACN,GAAGV,YAAY;QACfY,OAAO;IACT,CAAA,EAAE;AAEF,uEAAuE,GACvE,OAAO,MAAMO,yBAAyB,CAACJ,OAAyB,CAAA;QAC9DN,MAAMX;QACNY,MAAM;QACN,GAAGV,YAAY;QACfY,OAAO;QACPI,UAAU;QACVC,YAAYF;IACd,CAAA,EAAE;AAEF,MAAMK,WAAW,CAACC,QAAiBZ,OACjCY,OAAOC,IAAI,CAAC,CAACC,QAAU,UAAUA,SAASA,MAAMd,IAAI,KAAKA;AAE3D;;;;;;;CAOC,GACD,OAAO,MAAMe,qBAAqB,CAACC;IACjC,IAAI,CAACL,SAASK,WAAWJ,MAAM,EAAEzB,cAAc;QAC7C6B,WAAWJ,MAAM,CAACK,IAAI,CAAClB;IACzB;IAEA,IAAI,CAACY,SAASK,WAAWJ,MAAM,EAAE1B,mBAAmB;QAClD8B,WAAWJ,MAAM,CAACK,IAAI,CAACZ,sBAAsBW,WAAWV,IAAI;IAC9D;IAEA,IAAI,CAACK,SAASK,WAAWJ,MAAM,EAAExB,gBAAgB;QAC/C4B,WAAWJ,MAAM,CAACK,IAAI,CAACR;IACzB;IAEA,MAAMS,UAAUF,WAAWE,OAAO,IAAI,EAAE;IAExC,KAAK,MAAMJ,SAASE,WAAWJ,MAAM,CAAE;QACrC,IAAI,UAAUE,SAAS,YAAYA,SAASA,MAAMK,MAAM,EAAE;YACxDL,MAAMK,MAAM,GAAG;YACfD,QAAQD,IAAI,CAAC;gBAAEL,QAAQ;oBAACE,MAAMd,IAAI;oBAAEb;iBAAY;gBAAEgC,QAAQ;YAAK;QACjE;IACF;IAEAH,WAAWE,OAAO,GAAGA;IAErBF,WAAWI,KAAK,GAAGJ,WAAWI,KAAK,IAAI,CAAC;IACxCJ,WAAWI,KAAK,CAACC,YAAY,GAAG;WAAKL,WAAWI,KAAK,CAACC,YAAY,IAAI,EAAE;QAAGpC;KAAoB;IAC/F+B,WAAWI,KAAK,CAACE,WAAW,GAAG;WAAKN,WAAWI,KAAK,CAACE,WAAW,IAAI,EAAE;QAAGtC;KAAmB;IAC5FgC,WAAWI,KAAK,CAACG,eAAe,GAAG;WAC7BP,WAAWI,KAAK,CAACG,eAAe,IAAI,EAAE;QAC1CxC;KACD;IAED,OAAOiC;AACT,EAAC;AAED;;;;;;;CAOC,GACD,OAAO,MAAMQ,2BAA2B,CAACC;IACvC,IAAI,CAACd,SAASc,OAAOb,MAAM,EAAEzB,cAAc;QACzCsC,OAAOb,MAAM,CAACK,IAAI,CAAClB;IACrB;IAEA,OAAO0B;AACT,EAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { Payload, PayloadRequest } from '../types/index.js';
|
|
2
|
+
import type { BlockedChange } from './preflight.js';
|
|
3
|
+
import type { BranchOperation } from './types.js';
|
|
4
|
+
export type MergeableChange = {
|
|
5
|
+
changeID: number | string;
|
|
6
|
+
collectionSlug: string;
|
|
7
|
+
docID: number | string;
|
|
8
|
+
operation: BranchOperation;
|
|
9
|
+
};
|
|
10
|
+
export type MergeWarning = {
|
|
11
|
+
changeID: number | string;
|
|
12
|
+
collectionSlug: string;
|
|
13
|
+
docID: number | string;
|
|
14
|
+
message: string;
|
|
15
|
+
reason: 'main-moved';
|
|
16
|
+
};
|
|
17
|
+
export type MergeResult = {
|
|
18
|
+
/** Changes the merging user is not permitted to apply. */
|
|
19
|
+
blocked: BlockedChange[];
|
|
20
|
+
/** True when at least one selected change can be applied. */
|
|
21
|
+
canMerge: boolean;
|
|
22
|
+
mergeable: MergeableChange[];
|
|
23
|
+
merged: MergeableChange[];
|
|
24
|
+
warnings: MergeWarning[];
|
|
25
|
+
};
|
|
26
|
+
export type MergeOptions = {
|
|
27
|
+
branch: string;
|
|
28
|
+
/** Change IDs to apply. Omit to apply every pending change. */
|
|
29
|
+
changes?: (number | string)[];
|
|
30
|
+
/** Report what would happen without writing anything. */
|
|
31
|
+
dryRun?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Skip the per-document permission preflight, matching how every other Local
|
|
34
|
+
* API operation defaults to trusting server-side callers.
|
|
35
|
+
*
|
|
36
|
+
* HTTP callers must pass `false` together with `user`: the preflight is the
|
|
37
|
+
* enforcement boundary for branching, since branch writes are deliberately
|
|
38
|
+
* permissive on the assumption that nothing is real until merge.
|
|
39
|
+
*
|
|
40
|
+
* @default true
|
|
41
|
+
*/
|
|
42
|
+
overrideAccess?: boolean;
|
|
43
|
+
req?: PayloadRequest;
|
|
44
|
+
/**
|
|
45
|
+
* The user whose production permissions the merge is checked against.
|
|
46
|
+
* Defaults to `req.user`.
|
|
47
|
+
*/
|
|
48
|
+
user?: NonNullable<PayloadRequest['user']>;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Applies a branch's changes to `main`.
|
|
52
|
+
*
|
|
53
|
+
* Branch data wins outright — there is no field-level reconciliation. What
|
|
54
|
+
* replaces conflict resolution is selection: callers choose which changes to
|
|
55
|
+
* apply, and anything left behind keeps the branch open.
|
|
56
|
+
*
|
|
57
|
+
* Every write runs through the ordinary Local API so that all document hooks,
|
|
58
|
+
* validation and version creation behave exactly as they would for a hand-made
|
|
59
|
+
* edit on main.
|
|
60
|
+
*/
|
|
61
|
+
export declare const mergeBranch: (payload: Payload, { branch, changes: selected, dryRun, overrideAccess, req: incomingReq, user, }: MergeOptions) => Promise<MergeResult>;
|
|
62
|
+
export declare const getBranchesLocalAPI: (payload: Payload) => {
|
|
63
|
+
merge: (options: MergeOptions) => Promise<MergeResult>;
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=merge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../src/branching/merge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAejD,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAA;IACzB,cAAc,EAAE,MAAM,CAAA;IACtB,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;IACtB,SAAS,EAAE,eAAe,CAAA;CAC3B,CAAA;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAA;IACzB,cAAc,EAAE,MAAM,CAAA;IACtB,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;IACtB,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,YAAY,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,0DAA0D;IAC1D,OAAO,EAAE,aAAa,EAAE,CAAA;IACxB,6DAA6D;IAC7D,QAAQ,EAAE,OAAO,CAAA;IACjB,SAAS,EAAE,eAAe,EAAE,CAAA;IAC5B,MAAM,EAAE,eAAe,EAAE,CAAA;IACzB,QAAQ,EAAE,YAAY,EAAE,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,EAAE,MAAM,CAAA;IACd,+DAA+D;IAC/D,OAAO,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAA;IAC7B,yDAAyD;IACzD,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB;;;;;;;;;OASG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,GAAG,CAAC,EAAE,cAAc,CAAA;IACpB;;;OAGG;IACH,IAAI,CAAC,EAAE,WAAW,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAA;CAC3C,CAAA;AAKD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,WAAW,YACb,OAAO,kFAQb,YAAY,KACd,OAAO,CAAC,WAAW,CAyJrB,CAAA;AA6FD,eAAO,MAAM,mBAAmB,YAAa,OAAO;IAClD,KAAK,YAAY,YAAY;CAC7B,CAAA"}
|