Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

13.2 KB
Raw Blame
import { woocommerceRegisterTrigger } from './register-trigger';
import {
  couponTriggerOutputSchema,
  customerTriggerOutputSchema,
  deletedCustomerTriggerOutputSchema,
  orderTriggerOutputSchema,
  productTriggerOutputSchema,
} from '../output-schemas';

const sampleData = {
  product: {
    id: 20,
    sku: '',
    name: 'My Product',
    slug: 'my-product',
    tags: [],
    type: 'simple',
    price: '5',
    _links: {
      self: [
        {
          href: 'https://myshop.com/index.php?rest_route=/wc/v3/products/20',
        },
      ],
      collection: [
        {
          href: 'https://myshop.com/index.php?rest_route=/wc/v3/products',
        },
      ],
    },
    images: [],
    description: '<p>Description <strong>bold</strong></p>\n<p>New Line</p>\n',
    date_created: '2023-07-06T14:51:45',
    date_modified: '2023-07-06T14:51:45',
    total_sales: 0,
    stock_status: 'instock',
    rating_count: 0,
    status: 'publish',
    weight: '',
    on_sale: false,
    virtual: false,
    featured: false,
    downloads: [],
    meta_data: [],
    parent_id: 0,
    permalink: 'https://myshop.com/?product=my-product',
    tax_class: '',
    attributes: [],
    backorders: 'no',
    categories: [
      {
        id: 15,
        name: 'Uncategorized',
        slug: 'uncategorized',
      },
    ],
    dimensions: {
      width: '',
      height: '',
      length: '',
    },
    menu_order: 0,
    price_html:
      '<span class="woocommerce-Price-amount amount"><bdi>5,000 <span class="woocommerce-Price-currencySymbol">د.ا</span></bdi></span>',
    sale_price: '',
    tax_status: 'taxable',
    upsell_ids: [],
    variations: [],
    backordered: false,
    button_text: '',
    has_options: false,
    purchasable: true,
    related_ids: [12],
    downloadable: false,
    external_url: '',
    manage_stock: false,
    purchase_note: '',
    regular_price: '5',
    average_rating: '0.00',
    cross_sell_ids: [],
    download_limit: -1,
    shipping_class: '',
    stock_quantity: null,
    date_on_sale_to: null,
    download_expiry: -1,
    reviews_allowed: true,
    date_created_gmt: '2023-07-06T14:51:45',
    grouped_products: [],
    low_stock_amount: null,
    shipping_taxable: true,
    date_modified_gmt: '2023-07-06T14:51:45',
    date_on_sale_from: null,
    shipping_class_id: 0,
    shipping_required: true,
    short_description: '',
    sold_individually: false,
    backorders_allowed: false,
    catalog_visibility: 'visible',
    default_attributes: [],
    date_on_sale_to_gmt: null,
    date_on_sale_from_gmt: null,
  },
  order: {
    id: 17,
    total: '2.000',
    _links: {
      self: [
        {
          href: 'https://myshop.com/index.php?rest_route=/wc/v3/orders/17',
        },
      ],
      customer: [
        {
          href: 'https://myshop.com/index.php?rest_route=/wc/v3/customers/1',
        },
      ],
      collection: [
        {
          href: 'https://myshop.com/index.php?rest_route=/wc/v3/orders',
        },
      ],
    },
    number: '17',
    status: 'pending',
    shipping_total: '0.000',
    currency_symbol: '$',
    date_created_gmt: '2023-07-06T14:17:03',
    payment_method_title: 'Cash on delivery',
    billing: {
      city: 'City',
      email: '[email protected]',
      phone: '123123123',
      state: 'State',
      company: '',
      country: 'CO',
      postcode: '11111',
      address_1: '1 Street',
      address_2: '',
      last_name: 'Last',
      first_name: 'First',
    },
    refunds: [],
    version: '7.8.2',
    cart_tax: '0.000',
    currency: 'USD',
    shipping: {
      city: 'City',
      phone: '',
      state: 'State',
      company: '',
      country: 'CO',
      postcode: '11111',
      address_1: '1 Street',
      address_2: '',
      last_name: 'Last',
      first_name: 'First',
    },
    date_paid: null,
    fee_lines: [],
    meta_data: [
      {
        id: 228,
        key: 'is_vat_exempt',
        value: 'no',
      },
    ],
    order_key: 'wc_order_C66uDC3RekAax',
    parent_id: 0,
    tax_lines: [],
    total_tax: '0.000',
    line_items: [
      {
        id: 9,
        sku: '',
        name: 'First Product',
        image: {
          id: '',
          src: '',
        },
        price: 1,
        taxes: [],
        total: '2.000',
        quantity: 2,
        subtotal: '2.000',
        meta_data: [],
        tax_class: '',
        total_tax: '0.000',
        product_id: 12,
        parent_name: null,
        subtotal_tax: '0.000',
        variation_id: 0,
      },
    ],
    created_via: 'checkout',
    customer_id: 1,
    is_editable: false,
    payment_url:
      'https://myshop.com/?page_id=8&order-pay=17&pay_for_order=true&key=wc_order_C66uDC3RekAax',
    coupon_lines: [],
    date_created: '2023-07-06T14:17:03',
    discount_tax: '0.000',
    shipping_tax: '0.000',
    customer_note: '',
    date_modified: '2023-07-06T14:25:02',
    date_paid_gmt: null,
    needs_payment: true,
    date_completed: null,
    discount_total: '0.000',
    payment_method: 'cod',
    shipping_lines: [
      {
        id: 10,
        taxes: [],
        total: '0.000',
        meta_data: [
          {
            id: 75,
            key: 'Items',
            value: 'First Product × 2',
            display_key: 'Items',
            display_value: 'First Product × 2',
          },
        ],
        method_id: 'free_shipping',
        total_tax: '0.000',
        instance_id: '1',
        method_title: 'Free shipping',
      },
    ],
    transaction_id: '',
    needs_processing: true,
    date_modified_gmt: '2023-07-06T14:25:02',
    prices_include_tax: false,
  },
  coupon: {
    id: 22,
    code: '5dollars',
    _links: {
      self: [
        {
          href: 'https://myshop.com/index.php?rest_route=/wc/v3/coupons/22',
        },
      ],
      collection: [
        {
          href: 'https://myshop.com/index.php?rest_route=/wc/v3/coupons',
        },
      ],
    },
    amount: '5.00',
    status: 'publish',
    used_by: [],
    meta_data: [],
    description: '',
    product_ids: [20],
    usage_count: 0,
    usage_limit: null,
    date_created: '2023-07-09T15:10:14',
    date_expires: '2023-07-31T00:00:00',
    date_modified: '2023-07-09T15:23:03',
    discount_type: 'fixed_cart',
    free_shipping: true,
    maximum_amount: '0.00',
    minimum_amount: '0.00',
    date_created_gmt: '2023-07-09T15:10:14',
    date_expires_gmt: '2023-07-31T00:00:00',
    date_modified_gmt: '2023-07-09T15:23:03',
    usage_limit_per_user: 1,
    individual_use: false,
    email_restrictions: [],
    exclude_sale_items: false,
    product_categories: [],
    excluded_product_ids: [],
    limit_usage_to_x_items: null,
    excluded_product_categories: [],
  },
  customer: {
    id: 1,
    role: 'administrator',
    email: '[email protected]',
    avatar_url: '',
    username: 'username',
    first_name: 'First',
    last_name: 'Last',
    date_created: '2023-07-05T14:13:10',
    date_modified: '2023-07-06T14:58:43',
    date_created_gmt: '2023-07-05T14:13:10',
    date_modified_gmt: '2023-07-06T14:58:43',
    is_paying_customer: false,
    _links: {
      self: [
        {
          href: 'https://myshop.com/index.php?rest_route=/wc/v3/customers/1',
        },
      ],
      collection: [
        {
          href: 'https://myshop.com/index.php?rest_route=/wc/v3/customers',
        },
      ],
    },
    billing: {
      city: 'City',
      email: '[email protected]',
      phone: '123123123',
      state: 'State',
      company: '',
      country: 'CO',
      postcode: '11111',
      address_1: '# Street',
      address_2: '',
      last_name: 'Last',
      first_name: 'First',
    },
    shipping: {
      city: 'City',
      email: '[email protected]',
      phone: '123123123',
      state: 'State',
      company: '',
      country: 'CO',
      postcode: '11111',
      address_1: '# Street',
      address_2: '',
      last_name: 'Last',
      first_name: 'First',
    },
  },
};
export const triggers = [
  {
    name: 'product_created',
    topic: 'product.created',
    displayName: 'Product Created',
    description: 'Triggers when a new product is created.',
    aiMetadata: {
      description:
        'Fires when a new product is created in the WooCommerce store, emitting the new product record.',
    },
    sampleData: sampleData.product,
    outputSchema: productTriggerOutputSchema,
    testDataEndpoint: '/wp-json/wc/v3/products',
  },
  {
    name: 'product_updated',
    topic: 'product.updated',
    displayName: 'Product Updated',
    description: 'Triggers when an existing product is updated.',
    aiMetadata: {
      description:
        'Fires when an existing product is updated in the WooCommerce store, emitting the changed product record.',
    },
    sampleData: sampleData.product,
    outputSchema: productTriggerOutputSchema,
    testDataEndpoint: '/wp-json/wc/v3/products',
  },
  {
    name: 'product_deleted',
    topic: 'product.deleted',
    displayName: 'Product Deleted',
    description: 'Triggers when an existing product is deleted.',
    aiMetadata: {
      description:
        'Fires when a product is deleted from the WooCommerce store, emitting the deleted product record.',
    },
    sampleData: sampleData.product,
    outputSchema: productTriggerOutputSchema,
    testDataEndpoint: '/wp-json/wc/v3/products',
  },
  {
    name: 'order_created',
    topic: 'order.created',
    displayName: 'Order Created',
    description: 'Triggers when a new order is created.',
    aiMetadata: {
      description:
        'Fires when a new order is placed in the WooCommerce store, emitting the new order record including line items, totals, and customer details.',
    },
    sampleData: sampleData.order,
    outputSchema: orderTriggerOutputSchema,
    testDataEndpoint: '/wp-json/wc/v3/orders',
  },
  {
    name: 'order_updated',
    topic: 'order.updated',
    displayName: 'Order Updated',
    description: 'Triggers when an existing order is updated.',
    aiMetadata: {
      description:
        'Fires when an existing order is updated in the WooCommerce store, such as a status or detail change, emitting the changed order record.',
    },
    sampleData: sampleData.order,
    outputSchema: orderTriggerOutputSchema,
    testDataEndpoint: '/wp-json/wc/v3/orders',
  },
  {
    name: 'order_deleted',
    topic: 'order.deleted',
    displayName: 'Order Deleted',
    description: 'Triggers when an existing order is deleted.',
    aiMetadata: {
      description:
        'Fires when an order is deleted from the WooCommerce store, emitting the deleted order record.',
    },
    sampleData: sampleData.order,
    outputSchema: orderTriggerOutputSchema,
    testDataEndpoint: '/wp-json/wc/v3/orders',
  },
  {
    name: 'coupon_created',
    topic: 'coupon.created',
    displayName: 'Coupon Created',
    description: 'Triggers when a new coupon is created.',
    aiMetadata: {
      description:
        'Fires when a new discount coupon is created in the WooCommerce store, emitting the new coupon record.',
    },
    sampleData: sampleData.coupon,
    outputSchema: couponTriggerOutputSchema,
    testDataEndpoint: '/wp-json/wc/v3/coupons',
  },
  {
    name: 'coupon_updated',
    topic: 'coupon.updated',
    displayName: 'Coupon Updated',
    description: 'Triggers when an existing coupon is updated.',
    aiMetadata: {
      description:
        'Fires when an existing coupon is updated in the WooCommerce store, emitting the changed coupon record.',
    },
    sampleData: sampleData.coupon,
    outputSchema: couponTriggerOutputSchema,
    testDataEndpoint: '/wp-json/wc/v3/coupons',
  },
  {
    name: 'coupon_deleted',
    topic: 'coupon.deleted',
    displayName: 'Coupon Deleted',
    description: 'Triggers when an existing coupon is deleted.',
    aiMetadata: {
      description:
        'Fires when a coupon is deleted from the WooCommerce store, emitting the deleted coupon record.',
    },
    sampleData: sampleData.coupon,
    outputSchema: couponTriggerOutputSchema,
    testDataEndpoint: '/wp-json/wc/v3/coupons',
  },
  {
    name: 'customer_created',
    topic: 'customer.created',
    displayName: 'Customer Created',
    description: 'Triggers when a new customer is created.',
    aiMetadata: {
      description:
        'Fires when a new customer account is created in the WooCommerce store, emitting the new customer record.',
    },
    sampleData: sampleData.customer,
    outputSchema: customerTriggerOutputSchema,
    testDataEndpoint: '/wp-json/wc/v3/customers',
  },
  {
    name: 'customer_updated',
    topic: 'customer.updated',
    displayName: 'Customer Updated',
    description: 'Triggers when an existing customer is updated.',
    aiMetadata: {
      description:
        'Fires when an existing customer is updated in the WooCommerce store, emitting the changed customer record.',
    },
    sampleData: sampleData.customer,
    outputSchema: customerTriggerOutputSchema,
    testDataEndpoint: '/wp-json/wc/v3/customers',
  },
  {
    name: 'customer_deleted',
    topic: 'customer.deleted',
    displayName: 'Customer Deleted',
    description: 'Triggers when an existing customer is deleted.',
    aiMetadata: {
      description:
        'Fires when a customer account is deleted from the WooCommerce store, emitting the deleted customer record.',
    },
    sampleData: sampleData.customer,
    outputSchema: deletedCustomerTriggerOutputSchema,
    testDataEndpoint: '/wp-json/wc/v3/customers',
  },
].map((trigger) => woocommerceRegisterTrigger(trigger));