/**
 * 工作流示例 Mock 数据
 * 符合 docs/04-数据模型设计.md 规范
 */

import type { WorkflowDefinition } from '#/types/workflow'

/**
 * 示例工作流：HTTP→审批→邮件
 * 对应文档中的示例
 */
export const EXAMPLE_WORKFLOW: WorkflowDefinition = {
  id: 'wf_001',
  name: 'HTTP→审批→邮件',
  description: '从 API 获取用户信息，发起审批，审批通过后发送邮件通知',
  schemaVersion: '1.0',
  nodes: [
    {
      id: 'n1',
      type: 'http_request',
      name: 'Get User',
      position: { x: 100, y: 100 },
      config: {
        url: 'https://api.example.com/users/1',
        method: 'GET',
      },
    },
    {
      id: 'n2',
      type: 'approval',
      name: '审批',
      position: { x: 320, y: 100 },
      config: {
        assignee: '${workflow.input.approver}',
        title: '用户信息审批',
        formFields: [
          { id: 'approved', label: '同意?', type: 'boolean', required: true },
        ],
      },
    },
    {
      id: 'n3',
      type: 'send_mail',
      name: '通知',
      position: { x: 540, y: 100 },
      config: {
        to: '${nodes.n1.output.body.email}',
        subject: '审批已通过',
        content: 'Hello ${nodes.n1.output.body.name}, 您的申请已通过审批。',
      },
    },
  ],
  edges: [
    {
      source: 'n1',
      target: 'n2',
    },
    {
      source: 'n2',
      target: 'n3',
      condition: '${nodes.n2.output.approved} == true',
    },
  ],
  variables: {
    env: 'dev',
  },
  metadata: {
    version: '1.0',
    createdBy: 'admin',
    createdAt: '2025-01-01T10:00:00Z',
  },
}

/**
 * 空白工作流模板
 */
export const EMPTY_WORKFLOW: WorkflowDefinition = {
  id: '',
  name: '未命名工作流',
  description: '',
  schemaVersion: '1.0',
  nodes: [],
  edges: [],
  variables: {},
  metadata: {},
}

