# seeds/orders/seed.yaml
#
# Order Management POC — Seed Manifest
#
# Standard seeder contract:
#   - admin user: password Admin123!, role admin, verified
#   - role-specific demo users: password Demo123!, verified
#   - predictable data with stable SKUs/codes for deterministic tests
#   - idempotent: safe to run on every server start
#
# Execution order (four phases):
#   Phase 1 — Roles
#   Phase 2 — Users
#   Phase 3 — Assignments
#   Phase 4 — Domain data (products, discounts, customers, orders, order items)
#
# Note on computed fields:
#   OrderItem.subtotal and Order.orderTotal are computed fields that the
#   engine calculates automatically. They are not set in seed data.

# ─── Phase 1: Roles ─────────────────────────────────────────────

roles:
  - name: admin
    description: "Full system access. Can manage all resources, discounts, and delete orders."

  - name: customer
    description: "End user. Can place orders, view own records."

  - name: staff
    description: "Internal staff. Can view all orders, manage products, cannot delete orders."

# ─── Phase 2: Users ─────────────────────────────────────────────

users:
  - username: admin
    email: admin@orders.example.com
    password: "Admin123!"
    verified: true

  - username: alice
    email: alice@orders.example.com
    password: "Demo123!"
    verified: true

  - username: bob
    email: bob@orders.example.com
    password: "Demo123!"
    verified: true

  - username: carol
    email: carol@orders.example.com
    password: "Demo123!"
    verified: true

  - username: diana
    email: diana@orders.example.com
    password: "Demo123!"
    verified: true

# ─── Phase 3: Assignments ───────────────────────────────────────

assignments:
  - username: admin
    roles: [admin]

  - username: alice
    roles: [customer]

  - username: bob
    roles: [customer]

  - username: carol
    roles: [staff]

  - username: diana
    roles: [staff]

# ─── Phase 4: Domain data ───────────────────────────────────────

data:

  # ── Products ───────────────────────────────────────────────────

  - action: adl.orders.product.create
    data:
      sku: "WIDGET-001"
      name: "Basic Widget"
      description: "A simple, affordable widget for everyday use."
      unitPrice: "9.99"
      stockQty: 100
      isActive: true

  - action: adl.orders.product.create
    data:
      sku: "WIDGET-002"
      name: "Pro Widget"
      description: "Professional-grade widget with enhanced durability."
      unitPrice: "24.99"
      stockQty: 50
      isActive: true

  - action: adl.orders.product.create
    data:
      sku: "GADGET-001"
      name: "Gadget Classic"
      description: "The original gadget. Reliable and well-tested."
      unitPrice: "49.99"
      stockQty: 25
      isActive: true

  - action: adl.orders.product.create
    data:
      sku: "GADGET-002"
      name: "Gadget Pro"
      description: "Top-of-the-line gadget with all premium features."
      unitPrice: "99.99"
      stockQty: 10
      isActive: true

  - action: adl.orders.product.create
    data:
      sku: "SERVICE-001"
      name: "Annual Support"
      description: "One year of premium technical support and maintenance."
      unitPrice: "199.00"
      stockQty: 999
      isActive: true

  # ── Discounts ──────────────────────────────────────────────────

  - action: adl.orders.discount.create
    data:
      code: "SAVE10"
      type: "percentage"
      value: "10"
      maxUses: 100
      isActive: true

  - action: adl.orders.discount.create
    data:
      code: "FLAT5"
      type: "fixed"
      value: "5.00"
      maxUses: 50
      isActive: true

  # ── Customers ──────────────────────────────────────────────────

  - action: adl.orders.customer.create
    as: alice
    data:
      firstName: "Alice"
      lastName: "Johnson"
      email: "alice@customer.example.com"
      phone: "+15555550101"

  - action: adl.orders.customer.create
    as: bob
    data:
      firstName: "Bob"
      lastName: "Smith"
      email: "bob@customer.example.com"
      phone: "+15555550102"

  # ── Orders ─────────────────────────────────────────────────────
  #
  # Orders reference customers by ID, which are auto-generated UUIDs.
  # The seeder resolves "lookup:" references to find the customer by
  # a query field. If the seeder does not support lookup references,
  # these orders will need to be created via the API after boot.
  #
  # Order 1: alice, delivered, 2 items (WIDGET-001 x2, GADGET-001 x1)
  # Order 2: alice, pending, 1 item (SERVICE-001 x1)
  # Order 3: bob, confirmed, 1 item (WIDGET-002 x3)
  # Order 4: bob, cancelled, 1 item (GADGET-002 x1)

  - action: adl.orders.order.create
    as: admin
    data:
      customerId: "lookup:customer:email:alice@customer.example.com"
      customerName: "Alice Johnson"
      status: "delivered"
      shippingAddress:
        street: "123 Main Street"
        city: "Springfield"
        state: "IL"
        postalCode: "62701"
        country: "US"
      lineItems:
        - productId: "lookup:product:sku:WIDGET-001"
          productName: "Basic Widget"
          quantity: 2
          unitPrice: "9.99"
        - productId: "lookup:product:sku:GADGET-001"
          productName: "Gadget Classic"
          quantity: 1
          unitPrice: "49.99"
      notes: "Please gift wrap if possible."

  - action: adl.orders.order.create
    as: admin
    data:
      customerId: "lookup:customer:email:alice@customer.example.com"
      customerName: "Alice Johnson"
      status: "pending"
      shippingAddress:
        street: "123 Main Street"
        city: "Springfield"
        state: "IL"
        postalCode: "62701"
        country: "US"
      lineItems:
        - productId: "lookup:product:sku:SERVICE-001"
          productName: "Annual Support"
          quantity: 1
          unitPrice: "199.00"

  - action: adl.orders.order.create
    as: admin
    data:
      customerId: "lookup:customer:email:bob@customer.example.com"
      customerName: "Bob Smith"
      status: "confirmed"
      shippingAddress:
        street: "456 Oak Avenue"
        city: "Portland"
        state: "OR"
        postalCode: "97201"
        country: "US"
      lineItems:
        - productId: "lookup:product:sku:WIDGET-002"
          productName: "Pro Widget"
          quantity: 3
          unitPrice: "24.99"

  - action: adl.orders.order.create
    as: admin
    data:
      customerId: "lookup:customer:email:bob@customer.example.com"
      customerName: "Bob Smith"
      status: "cancelled"
      shippingAddress:
        street: "456 Oak Avenue"
        city: "Portland"
        state: "OR"
        postalCode: "97201"
        country: "US"
      lineItems:
        - productId: "lookup:product:sku:GADGET-002"
          productName: "Gadget Pro"
          quantity: 1
          unitPrice: "99.99"
