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`:
<img width="886" alt="image"
src="https://github.com/user-attachments/assets/78125ce8-bd89-4269-bc56-966d8e0c3968"
/>

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.
This commit is contained in:
Sasha
2025-04-03 00:12:35 +03:00
committed by GitHub
parent d29bdfc10f
commit 760cfadaad

View File

@@ -1,5 +1,6 @@
// @ts-strict-ignore // @ts-strict-ignore
import type { User } from '../../auth/types.js' 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 { TaskConfig } from '../../queues/config/types/taskTypes.js'
import type { SchedulePublishTaskInput } from './types.js' import type { SchedulePublishTaskInput } from './types.js'
@@ -87,11 +88,15 @@ export const getSchedulePublishTask = ({
name: 'locale', name: 'locale',
type: 'text', type: 'text',
}, },
{ ...(collections.length > 0
name: 'doc', ? [
type: 'relationship', {
relationTo: collections, name: 'doc',
}, type: 'relationship',
relationTo: collections,
} satisfies Field,
]
: []),
{ {
name: 'global', name: 'global',
type: 'select', type: 'select',