mirror of
https://github.com/xtr-dev/payload-automation.git
synced 2025-12-10 00:43:23 +00:00
- Introduce `WorkflowBuilder` for visual workflow configuration - Add child components: `WorkflowToolbar`, `StepConfigurationForm`, and `StepNode` - Implement `WorkflowBuilderField` for integration with PayloadCMS - Provide dynamic step type handling and JSON-based configuration editing - Enhance UI with drag-and-drop functionality and step dependencies management
125 lines
2.8 KiB
TypeScript
125 lines
2.8 KiB
TypeScript
import type {CollectionSlug} from 'payload';
|
|
|
|
import { lexicalEditor } from '@payloadcms/richtext-lexical'
|
|
import path from 'path'
|
|
import {buildConfig} from 'payload'
|
|
import sharp from 'sharp'
|
|
import { fileURLToPath } from 'url'
|
|
|
|
import {workflowsPlugin} from "../src/plugin/index.js"
|
|
import {CreateDocumentStepTask,HttpRequestStepTask} from "../src/steps/index.js"
|
|
import { testEmailAdapter } from './helpers/testEmailAdapter.js'
|
|
import { seed } from './seed.js'
|
|
|
|
const filename = fileURLToPath(import.meta.url)
|
|
const dirname = path.dirname(filename)
|
|
|
|
if (!process.env.ROOT_DIR) {
|
|
process.env.ROOT_DIR = dirname
|
|
}
|
|
|
|
const buildConfigWithMemoryDB = async () => {
|
|
// Use MongoDB adapter for testing instead of SQLite
|
|
const { mongooseAdapter } = await import('@payloadcms/db-mongodb')
|
|
|
|
return buildConfig({
|
|
admin: {
|
|
importMap: {
|
|
baseDir: path.resolve(dirname, '..'),
|
|
},
|
|
},
|
|
globals: [
|
|
{
|
|
slug: 'settings',
|
|
fields: [
|
|
{
|
|
name: 'siteName',
|
|
type: 'text'
|
|
}
|
|
]
|
|
}
|
|
],
|
|
collections: [
|
|
{
|
|
slug: 'posts',
|
|
fields: [
|
|
{
|
|
name: 'content',
|
|
type: 'textarea'
|
|
}
|
|
],
|
|
},
|
|
{
|
|
slug: 'media',
|
|
fields: [],
|
|
upload: {
|
|
staticDir: path.resolve(dirname, 'media'),
|
|
},
|
|
},
|
|
{
|
|
slug: 'auditLog',
|
|
fields: [
|
|
{
|
|
name: 'post',
|
|
type: 'relationship',
|
|
relationTo: 'posts'
|
|
},
|
|
{
|
|
name: 'user',
|
|
type: 'relationship',
|
|
relationTo: 'users',
|
|
required: false
|
|
},
|
|
{
|
|
name: 'message',
|
|
type: 'textarea'
|
|
}
|
|
]
|
|
}
|
|
],
|
|
db: mongooseAdapter({
|
|
url: process.env.DATABASE_URI || 'mongodb://localhost:27017/payload-test',
|
|
}),
|
|
editor: lexicalEditor(),
|
|
email: testEmailAdapter,
|
|
jobs: {
|
|
deleteJobOnComplete: false,
|
|
jobsCollectionOverrides: ({ defaultJobsCollection }) => {
|
|
return {
|
|
...defaultJobsCollection,
|
|
admin: {
|
|
...(defaultJobsCollection.admin ?? {}),
|
|
hidden: false,
|
|
},
|
|
}
|
|
},
|
|
tasks: []
|
|
},
|
|
onInit: async (payload) => {
|
|
await seed(payload)
|
|
},
|
|
plugins: [
|
|
workflowsPlugin<CollectionSlug>({
|
|
collectionTriggers: {
|
|
posts: true,
|
|
media: true
|
|
},
|
|
globalTriggers: {
|
|
settings: true
|
|
},
|
|
steps: [
|
|
HttpRequestStepTask,
|
|
CreateDocumentStepTask
|
|
],
|
|
}),
|
|
],
|
|
secret: process.env.PAYLOAD_SECRET || 'test-secret_key',
|
|
sharp,
|
|
typescript: {
|
|
outputFile: path.resolve(dirname, 'payload-types.ts'),
|
|
},
|
|
})
|
|
}
|
|
|
|
export default buildConfigWithMemoryDB()
|