mirror of
https://github.com/xtr-dev/payload-automation.git
synced 2025-12-11 01:03:23 +00:00
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:
@@ -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,
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -7,7 +7,7 @@ export const DeleteDocumentStepTask = {
|
||||
handler: deleteDocumentHandler,
|
||||
inputSchema: [
|
||||
{
|
||||
name: 'collection',
|
||||
name: 'collectionSlug',
|
||||
type: 'text',
|
||||
admin: {
|
||||
description: 'The collection slug to delete from'
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -7,7 +7,7 @@ export const ReadDocumentStepTask = {
|
||||
handler: readDocumentHandler,
|
||||
inputSchema: [
|
||||
{
|
||||
name: 'collection',
|
||||
name: 'collectionSlug',
|
||||
type: 'text',
|
||||
admin: {
|
||||
description: 'The collection slug to read from'
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user