Rename 'collection' field to 'collectionSlug' to avoid PayloadCMS reserved field conflicts

- Updated Workflow collection trigger field from 'collection' to 'collectionSlug'
- Updated all document operation steps (create, read, update, delete) to use 'collectionSlug'
- Updated corresponding handlers to destructure 'collectionSlug' instead of 'collection'
- Removed debug console.log statements from logger configLogger methods
- Fixed collection hook debug logs to use 'slug' instead of reserved 'collection' field

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-08-31 17:14:35 +02:00
parent 2d84f535f4
commit 592536f61a
18 changed files with 297 additions and 368 deletions

View File

@@ -5,9 +5,9 @@ export const createDocumentHandler: TaskHandler<'create-document'> = async ({ in
throw new Error('No input provided')
}
const { collection, data, draft, locale } = input
const { collectionSlug, data, draft, locale } = input
if (!collection || typeof collection !== 'string') {
if (!collectionSlug || typeof collectionSlug !== 'string') {
throw new Error('Collection slug is required')
}
@@ -19,7 +19,7 @@ export const createDocumentHandler: TaskHandler<'create-document'> = async ({ in
const parsedData = typeof data === 'string' ? JSON.parse(data) : data
const result = await req.payload.create({
collection,
collection: collectionSlug,
data: parsedData,
draft: draft || false,
locale: locale || undefined,

View File

@@ -7,7 +7,7 @@ export const CreateDocumentStepTask = {
handler: createDocumentHandler,
inputSchema: [
{
name: 'collection',
name: 'collectionSlug',
type: 'text',
admin: {
description: 'The collection slug to create a document in'

View File

@@ -5,9 +5,9 @@ export const deleteDocumentHandler: TaskHandler<'delete-document'> = async ({ in
throw new Error('No input provided')
}
const { id, collection, where } = input
const { id, collectionSlug, where } = input
if (!collection || typeof collection !== 'string') {
if (!collectionSlug || typeof collectionSlug !== 'string') {
throw new Error('Collection slug is required')
}
@@ -16,7 +16,7 @@ export const deleteDocumentHandler: TaskHandler<'delete-document'> = async ({ in
if (id) {
const result = await req.payload.delete({
id: id.toString(),
collection,
collection: collectionSlug,
req
})
@@ -38,7 +38,7 @@ export const deleteDocumentHandler: TaskHandler<'delete-document'> = async ({ in
// First find the documents to delete
const toDelete = await req.payload.find({
collection,
collection: collectionSlug,
limit: 1000, // Set a reasonable limit
req,
where: parsedWhere
@@ -49,7 +49,7 @@ export const deleteDocumentHandler: TaskHandler<'delete-document'> = async ({ in
for (const doc of toDelete.docs) {
const result = await req.payload.delete({
id: doc.id,
collection,
collection: collectionSlug,
req
})
deleted.push(result)

View File

@@ -7,7 +7,7 @@ export const DeleteDocumentStepTask = {
handler: deleteDocumentHandler,
inputSchema: [
{
name: 'collection',
name: 'collectionSlug',
type: 'text',
admin: {
description: 'The collection slug to delete from'

View File

@@ -5,9 +5,9 @@ export const readDocumentHandler: TaskHandler<'read-document'> = async ({ input,
throw new Error('No input provided')
}
const { id, collection, depth, limit, locale, sort, where } = input
const { id, collectionSlug, depth, limit, locale, sort, where } = input
if (!collection || typeof collection !== 'string') {
if (!collectionSlug || typeof collectionSlug !== 'string') {
throw new Error('Collection slug is required')
}
@@ -16,7 +16,7 @@ export const readDocumentHandler: TaskHandler<'read-document'> = async ({ input,
if (id) {
const result = await req.payload.findByID({
id: id.toString(),
collection,
collection: collectionSlug,
depth: typeof depth === 'number' ? depth : undefined,
locale: locale || undefined,
req
@@ -35,7 +35,7 @@ export const readDocumentHandler: TaskHandler<'read-document'> = async ({ input,
const parsedWhere = where ? (typeof where === 'string' ? JSON.parse(where) : where) : {}
const result = await req.payload.find({
collection,
collection: collectionSlug,
depth: typeof depth === 'number' ? depth : undefined,
limit: typeof limit === 'number' ? limit : 10,
locale: locale || undefined,

View File

@@ -7,7 +7,7 @@ export const ReadDocumentStepTask = {
handler: readDocumentHandler,
inputSchema: [
{
name: 'collection',
name: 'collectionSlug',
type: 'text',
admin: {
description: 'The collection slug to read from'

View File

@@ -5,9 +5,9 @@ export const updateDocumentHandler: TaskHandler<'update-document'> = async ({ in
throw new Error('No input provided')
}
const { id, collection, data, draft, locale } = input
const { id, collectionSlug, data, draft, locale } = input
if (!collection || typeof collection !== 'string') {
if (!collectionSlug || typeof collectionSlug !== 'string') {
throw new Error('Collection slug is required')
}
@@ -24,7 +24,7 @@ export const updateDocumentHandler: TaskHandler<'update-document'> = async ({ in
const result = await req.payload.update({
id: id.toString(),
collection,
collection: collectionSlug,
data: parsedData,
draft: draft || false,
locale: locale || undefined,

View File

@@ -7,7 +7,7 @@ export const UpdateDocumentStepTask = {
handler: updateDocumentHandler,
inputSchema: [
{
name: 'collection',
name: 'collectionSlug',
type: 'text',
admin: {
description: 'The collection slug to update a document in'