import type { CatalogNodeEntry } from '../workflow-node-catalog'

export const INTEGRATION_NEW_NODES: CatalogNodeEntry[] = [
  {
    type: 'github_pr_review',
    label: 'GitHub PR Review',
    description: 'Fetch PR diff and files from GitHub for automated code review.',
    category: 'integration',
    color: 'text-emerald-500',
    iconName: 'GitPullRequest',
    inputs: [{ name: 'trigger', type: 'any', description: 'Any input or webhook event' }],
    outputs: [
      { name: 'diff', type: 'text', description: 'PR diff content' },
      { name: 'files', type: 'array', description: 'Changed file list with patch info' },
      { name: 'metadata', type: 'json', description: 'PR title, author, labels, base/head' },
    ],
    requiredConfig: ['repo', 'prNumber'],
    optionalConfig: ['includeComments', 'fileFilter'],
    exampleConfig: {
      repo: 'conectlens/lenserfight',
      prNumber: '{{n1.event.data.number}}',
      includeComments: true,
      fileFilter: '*.ts,*.tsx',
    },
    acceptsInputTypes: ['json', 'any', 'void'],
    producesOutputType: 'json',
    n8nEquivalent: 'n8n-nodes-base.github',
  },
  {
    type: 'github_issue_create',
    label: 'GitHub Issue Create',
    description: 'Create a new GitHub issue with title, body, labels, and assignees.',
    category: 'integration',
    color: 'text-emerald-500',
    iconName: 'CircleDot',
    inputs: [{ name: 'data', type: 'json', description: 'Issue data from upstream analysis' }],
    outputs: [{ name: 'issue', type: 'json', description: 'Created issue with number and URL' }],
    requiredConfig: ['repo', 'title'],
    optionalConfig: ['body', 'labels', 'assignees', 'milestone'],
    exampleConfig: {
      repo: 'conectlens/lenserfight',
      title: 'Bug: {{n1.analysis.category}} — {{n1.analysis.summary}}',
      body: '## Description\n{{n1.analysis.details}}\n\n## Steps to Reproduce\n{{n1.analysis.steps}}',
      labels: ['bug', 'auto-triaged'],
      assignees: ['octocat'],
    },
    acceptsInputTypes: ['json', 'text', 'any'],
    producesOutputType: 'json',
    n8nEquivalent: 'n8n-nodes-base.github',
  },
  {
    type: 'notion_write',
    label: 'Notion Write',
    description: 'Create or update a Notion page or add rows to a database.',
    category: 'integration',
    color: 'text-emerald-500',
    iconName: 'FileText',
    inputs: [{ name: 'data', type: 'json', required: true, description: 'Content to write' }],
    outputs: [{ name: 'page', type: 'json', description: 'Created/updated page metadata' }],
    requiredConfig: ['databaseId'],
    optionalConfig: ['properties', 'content', 'icon', 'cover'],
    exampleConfig: {
      databaseId: 'abc-123-def-456',
      properties: {
        Name: { title: [{ text: { content: '{{n1.title}}' } }] },
        Status: { select: { name: 'Done' } },
        Score: { number: '{{n2.score}}' },
      },
    },
    acceptsInputTypes: ['json', 'any'],
    producesOutputType: 'json',
    n8nEquivalent: 'n8n-nodes-base.notion',
  },
  {
    type: 'calendar_create',
    label: 'Calendar Create',
    description: 'Create a calendar event in Google Calendar.',
    category: 'integration',
    color: 'text-emerald-500',
    iconName: 'CalendarPlus',
    inputs: [{ name: 'data', type: 'json', description: 'Event details from upstream' }],
    outputs: [{ name: 'event', type: 'json', description: 'Created event with ID and link' }],
    requiredConfig: ['calendarId', 'summary', 'startTime', 'endTime'],
    optionalConfig: ['description', 'location', 'attendees', 'timezone'],
    exampleConfig: {
      calendarId: 'primary',
      summary: 'Weekly Battle Review — {{n1.weekLabel}}',
      startTime: '{{n1.nextMonday}}T10:00:00',
      endTime: '{{n1.nextMonday}}T11:00:00',
      timezone: 'Europe/Istanbul',
      description: 'Review top battles and community highlights from the past week.',
      attendees: ['team@conectlens.com'],
    },
    acceptsInputTypes: ['json', 'any', 'void'],
    producesOutputType: 'json',
    n8nEquivalent: 'n8n-nodes-base.googleCalendar',
  },
  {
    type: 'linear_issue_create',
    label: 'Linear Issue Create',
    description: 'Create a new issue in Linear with project, team, and priority assignment.',
    category: 'integration',
    color: 'text-emerald-500',
    iconName: 'SquareKanban',
    inputs: [{ name: 'data', type: 'json', description: 'Issue data from upstream' }],
    outputs: [{ name: 'issue', type: 'json', description: 'Created issue with identifier and URL' }],
    requiredConfig: ['teamId', 'title'],
    optionalConfig: ['description', 'priority', 'labels', 'assigneeId', 'projectId'],
    exampleConfig: {
      teamId: 'TEAM-123',
      title: 'Workflow failure: {{n1.workflowName}} — {{n1.error.message}}',
      description: 'Automated issue from workflow error handler.\n\nRun ID: {{ctx.runId}}\nError: {{n1.error.stack}}',
      priority: 2,
      labels: ['workflow-alert', 'auto-created'],
    },
    acceptsInputTypes: ['json', 'text', 'any'],
    producesOutputType: 'json',
    n8nEquivalent: 'n8n-nodes-base.linear',
  },
  {
    type: 'jira_issue_create',
    label: 'Jira Issue Create',
    description: 'Create a Jira issue with project, type, priority, and custom fields.',
    category: 'integration',
    color: 'text-emerald-500',
    iconName: 'SquareKanban',
    inputs: [{ name: 'data', type: 'json', description: 'Issue data from upstream' }],
    outputs: [{ name: 'issue', type: 'json', description: 'Created issue with key and URL' }],
    requiredConfig: ['projectKey', 'issueType', 'summary'],
    optionalConfig: ['description', 'priority', 'labels', 'assignee', 'components', 'customFields'],
    exampleConfig: {
      projectKey: 'LF',
      issueType: 'Bug',
      summary: 'Auto-detected: {{n1.classifier.category}} in {{n1.source}}',
      description: '{{n1.details}}',
      priority: 'Medium',
      labels: ['auto-triaged'],
    },
    acceptsInputTypes: ['json', 'text', 'any'],
    producesOutputType: 'json',
    n8nEquivalent: 'n8n-nodes-base.jira',
  },
]
