From 760cfadaadfc35694750a280e189ccda1de8a590 Mon Sep 17 00:00:00 2001 From: Sasha <64744993+r1tsuu@users.noreply.github.com> Date: Thu, 3 Apr 2025 00:12:35 +0300 Subject: [PATCH] fix: do not append `doc` input for scheduled publish job if it's enabled only for globals (#11892) Fixes https://github.com/payloadcms/payload/issues/11891 Previously, if you had scheduled publish enabled only for globals, not collections - you'd get an error on `payload generate:types`: image This was caused by appending the `doc` field to the scheduled publish job input schema with empty `collections` array. Now we skip this field if we don't have any collections. --- packages/payload/src/versions/schedule/job.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/payload/src/versions/schedule/job.ts b/packages/payload/src/versions/schedule/job.ts index cf3450b5d..a53ba9272 100644 --- a/packages/payload/src/versions/schedule/job.ts +++ b/packages/payload/src/versions/schedule/job.ts @@ -1,5 +1,6 @@ // @ts-strict-ignore import type { User } from '../../auth/types.js' +import type { Field } from '../../fields/config/types.js' import type { TaskConfig } from '../../queues/config/types/taskTypes.js' import type { SchedulePublishTaskInput } from './types.js' @@ -87,11 +88,15 @@ export const getSchedulePublishTask = ({ name: 'locale', type: 'text', }, - { - name: 'doc', - type: 'relationship', - relationTo: collections, - }, + ...(collections.length > 0 + ? [ + { + name: 'doc', + type: 'relationship', + relationTo: collections, + } satisfies Field, + ] + : []), { name: 'global', type: 'select',