{
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "$id": "https://dashremix.com/spec/commerce/1.1.0/commerce@1.schema.json",
 "title": "commerce@1 v1.1.0",
 "description": "One property per table (an array of rows). Generated from schema.sql by spec/build.py. Extension tables (x_<owner>_*) belong to forks and board-derived tables (d_*) to the board that rebuilds them; both are allowed as additional properties.",
 "type": "object",
 "properties": {
  "meta": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "key": {
      "type": "string"
     },
     "value": {
      "type": [
       "string",
       "null"
      ]
     }
    },
    "required": [
     "key"
    ],
    "additionalProperties": false
   }
  },
  "channels": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "channel_id": {
      "type": "string"
     },
     "name": {
      "type": "string"
     },
     "kind": {
      "type": "string",
      "enum": [
       "online_store",
       "marketplace",
       "pos",
       "ticketing",
       "direct",
       "unknown"
      ]
     },
     "source": {
      "type": "string"
     },
     "source_ref": {
      "type": "string"
     },
     "imported_at": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?Z$"
     },
     "confidence": {
      "type": [
       "string",
       "null"
      ],
      "enum": [
       "rule",
       "default",
       "detected",
       "manual",
       null
      ]
     }
    },
    "required": [
     "channel_id",
     "name",
     "kind",
     "source",
     "source_ref",
     "imported_at"
    ],
    "additionalProperties": false
   }
  },
  "products": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "product_id": {
      "type": "string"
     },
     "name": {
      "type": "string"
     },
     "sku": {
      "type": [
       "string",
       "null"
      ]
     },
     "category": {
      "type": [
       "string",
       "null"
      ]
     },
     "source": {
      "type": "string"
     },
     "source_ref": {
      "type": "string"
     },
     "imported_at": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?Z$"
     },
     "confidence": {
      "type": [
       "string",
       "null"
      ],
      "enum": [
       "rule",
       "default",
       "detected",
       "manual",
       null
      ]
     }
    },
    "required": [
     "product_id",
     "name",
     "source",
     "source_ref",
     "imported_at"
    ],
    "additionalProperties": false
   }
  },
  "events": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "event_id": {
      "type": "string"
     },
     "name": {
      "type": "string"
     },
     "starts_at": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?Z$"
     },
     "tz": {
      "type": "string"
     },
     "capacity": {
      "type": [
       "integer",
       "null"
      ]
     },
     "source": {
      "type": "string"
     },
     "source_ref": {
      "type": "string"
     },
     "imported_at": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?Z$"
     },
     "confidence": {
      "type": [
       "string",
       "null"
      ],
      "enum": [
       "rule",
       "default",
       "detected",
       "manual",
       null
      ]
     }
    },
    "required": [
     "event_id",
     "name",
     "starts_at",
     "tz",
     "source",
     "source_ref",
     "imported_at"
    ],
    "additionalProperties": false
   }
  },
  "orders": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "order_id": {
      "type": "string"
     },
     "channel_id": {
      "type": "string"
     },
     "customer_id": {
      "type": [
       "string",
       "null"
      ]
     },
     "ordered_on": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
     },
     "ordered_at": {
      "type": [
       "string",
       "null"
      ],
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?Z$"
     },
     "tz": {
      "type": [
       "string",
       "null"
      ]
     },
     "ship_country": {
      "type": [
       "string",
       "null"
      ],
      "pattern": "^[A-Z]{2}$"
     },
     "ship_region": {
      "type": [
       "string",
       "null"
      ]
     },
     "status": {
      "type": "string",
      "enum": [
       "pending",
       "completed",
       "cancelled",
       "unknown"
      ]
     },
     "currency": {
      "type": "string",
      "pattern": "^[A-Z]{3}$"
     },
     "gross_amount": {
      "type": "number"
     },
     "discount_amount": {
      "type": "number"
     },
     "shipping_amount": {
      "type": "number"
     },
     "tax_amount": {
      "type": "number"
     },
     "total_amount": {
      "type": "number"
     },
     "source": {
      "type": "string"
     },
     "source_ref": {
      "type": "string"
     },
     "imported_at": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?Z$"
     },
     "confidence": {
      "type": [
       "string",
       "null"
      ],
      "enum": [
       "rule",
       "default",
       "detected",
       "manual",
       null
      ]
     }
    },
    "required": [
     "order_id",
     "channel_id",
     "ordered_on",
     "status",
     "currency",
     "gross_amount",
     "discount_amount",
     "shipping_amount",
     "tax_amount",
     "total_amount",
     "source",
     "source_ref",
     "imported_at"
    ],
    "additionalProperties": false
   }
  },
  "order_lines": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "line_id": {
      "type": "string"
     },
     "order_id": {
      "type": "string"
     },
     "product_id": {
      "type": [
       "string",
       "null"
      ]
     },
     "event_id": {
      "type": [
       "string",
       "null"
      ]
     },
     "quantity": {
      "type": "number"
     },
     "currency": {
      "type": "string",
      "pattern": "^[A-Z]{3}$"
     },
     "gross_amount": {
      "type": "number"
     },
     "discount_amount": {
      "type": "number"
     },
     "source": {
      "type": "string"
     },
     "source_ref": {
      "type": "string"
     },
     "imported_at": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?Z$"
     },
     "confidence": {
      "type": [
       "string",
       "null"
      ],
      "enum": [
       "rule",
       "default",
       "detected",
       "manual",
       null
      ]
     }
    },
    "required": [
     "line_id",
     "order_id",
     "quantity",
     "currency",
     "gross_amount",
     "discount_amount",
     "source",
     "source_ref",
     "imported_at"
    ],
    "additionalProperties": false
   }
  },
  "refunds": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "refund_id": {
      "type": "string"
     },
     "order_id": {
      "type": "string"
     },
     "line_id": {
      "type": [
       "string",
       "null"
      ]
     },
     "refunded_on": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
     },
     "quantity": {
      "type": [
       "number",
       "null"
      ]
     },
     "currency": {
      "type": "string",
      "pattern": "^[A-Z]{3}$"
     },
     "merchandise_amount": {
      "type": "number"
     },
     "shipping_amount": {
      "type": "number"
     },
     "tax_amount": {
      "type": "number"
     },
     "total_amount": {
      "type": "number"
     },
     "source": {
      "type": "string"
     },
     "source_ref": {
      "type": "string"
     },
     "imported_at": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?Z$"
     },
     "confidence": {
      "type": [
       "string",
       "null"
      ],
      "enum": [
       "rule",
       "default",
       "detected",
       "manual",
       null
      ]
     }
    },
    "required": [
     "refund_id",
     "order_id",
     "refunded_on",
     "currency",
     "merchandise_amount",
     "shipping_amount",
     "tax_amount",
     "total_amount",
     "source",
     "source_ref",
     "imported_at"
    ],
    "additionalProperties": false
   }
  },
  "order_taxes": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "tax_id": {
      "type": "string"
     },
     "order_id": {
      "type": "string"
     },
     "refund_id": {
      "type": [
       "string",
       "null"
      ]
     },
     "jurisdiction": {
      "type": "string"
     },
     "tax_kind": {
      "type": "string",
      "enum": [
       "sales_tax",
       "vat",
       "gst",
       "other",
       "unknown"
      ]
     },
     "rate": {
      "type": [
       "number",
       "null"
      ]
     },
     "taxable_amount": {
      "type": [
       "number",
       "null"
      ]
     },
     "currency": {
      "type": "string",
      "pattern": "^[A-Z]{3}$"
     },
     "tax_amount": {
      "type": "number"
     },
     "source": {
      "type": "string"
     },
     "source_ref": {
      "type": "string"
     },
     "imported_at": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?Z$"
     },
     "confidence": {
      "type": [
       "string",
       "null"
      ],
      "enum": [
       "rule",
       "default",
       "detected",
       "manual",
       null
      ]
     }
    },
    "required": [
     "tax_id",
     "order_id",
     "jurisdiction",
     "tax_kind",
     "currency",
     "tax_amount",
     "source",
     "source_ref",
     "imported_at"
    ],
    "additionalProperties": false
   }
  },
  "event_sales_targets": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "target_id": {
      "type": "string"
     },
     "event_id": {
      "type": "string"
     },
     "target_on": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
     },
     "tickets_target": {
      "type": "integer"
     },
     "source": {
      "type": "string"
     },
     "source_ref": {
      "type": "string"
     },
     "imported_at": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?Z$"
     },
     "confidence": {
      "type": [
       "string",
       "null"
      ],
      "enum": [
       "rule",
       "default",
       "detected",
       "manual",
       null
      ]
     }
    },
    "required": [
     "target_id",
     "event_id",
     "target_on",
     "tickets_target",
     "source",
     "source_ref",
     "imported_at"
    ],
    "additionalProperties": false
   }
  },
  "pos_daily": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "summary_id": {
      "type": "string"
     },
     "channel_id": {
      "type": "string"
     },
     "sold_on": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
     },
     "daypart": {
      "type": "string",
      "enum": [
       "all_day",
       "breakfast",
       "lunch",
       "afternoon",
       "dinner",
       "late_night",
       "other"
      ]
     },
     "covers": {
      "type": [
       "integer",
       "null"
      ]
     },
     "checks": {
      "type": [
       "integer",
       "null"
      ]
     },
     "currency": {
      "type": "string",
      "pattern": "^[A-Z]{3}$"
     },
     "gross_amount": {
      "type": "number"
     },
     "discount_amount": {
      "type": "number"
     },
     "refund_amount": {
      "type": "number"
     },
     "net_amount": {
      "type": "number"
     },
     "source": {
      "type": "string"
     },
     "source_ref": {
      "type": "string"
     },
     "imported_at": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?Z$"
     },
     "confidence": {
      "type": [
       "string",
       "null"
      ],
      "enum": [
       "rule",
       "default",
       "detected",
       "manual",
       null
      ]
     }
    },
    "required": [
     "summary_id",
     "channel_id",
     "sold_on",
     "daypart",
     "currency",
     "gross_amount",
     "discount_amount",
     "refund_amount",
     "net_amount",
     "source",
     "source_ref",
     "imported_at"
    ],
    "additionalProperties": false
   }
  },
  "supplier_invoice_lines": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "line_id": {
      "type": "string"
     },
     "invoice_id": {
      "type": "string"
     },
     "supplier_id": {
      "type": "string"
     },
     "issued_on": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
     },
     "item_id": {
      "type": [
       "string",
       "null"
      ]
     },
     "item_name": {
      "type": "string"
     },
     "category": {
      "type": [
       "string",
       "null"
      ]
     },
     "kind": {
      "type": "string",
      "enum": [
       "purchase",
       "credit"
      ]
     },
     "quantity": {
      "type": [
       "number",
       "null"
      ]
     },
     "unit": {
      "type": [
       "string",
       "null"
      ]
     },
     "currency": {
      "type": "string",
      "pattern": "^[A-Z]{3}$"
     },
     "amount": {
      "type": "number"
     },
     "source": {
      "type": "string"
     },
     "source_ref": {
      "type": "string"
     },
     "imported_at": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?Z$"
     },
     "confidence": {
      "type": [
       "string",
       "null"
      ],
      "enum": [
       "rule",
       "default",
       "detected",
       "manual",
       null
      ]
     }
    },
    "required": [
     "line_id",
     "invoice_id",
     "supplier_id",
     "issued_on",
     "item_name",
     "kind",
     "currency",
     "amount",
     "source",
     "source_ref",
     "imported_at"
    ],
    "additionalProperties": false
   }
  },
  "affiliate_daily": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "activity_id": {
      "type": "string"
     },
     "partner_id": {
      "type": "string"
     },
     "partner_name": {
      "type": [
       "string",
       "null"
      ]
     },
     "activity_on": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
     },
     "status": {
      "type": "string",
      "enum": [
       "pending",
       "approved",
       "paid",
       "reversed",
       "unknown"
      ]
     },
     "payout_id": {
      "type": [
       "string",
       "null"
      ]
     },
     "clicks": {
      "type": [
       "integer",
       "null"
      ]
     },
     "conversions": {
      "type": [
       "integer",
       "null"
      ]
     },
     "currency": {
      "type": "string",
      "pattern": "^[A-Z]{3}$"
     },
     "commission_amount": {
      "type": "number"
     },
     "source": {
      "type": "string"
     },
     "source_ref": {
      "type": "string"
     },
     "imported_at": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?Z$"
     },
     "confidence": {
      "type": [
       "string",
       "null"
      ],
      "enum": [
       "rule",
       "default",
       "detected",
       "manual",
       null
      ]
     }
    },
    "required": [
     "activity_id",
     "partner_id",
     "activity_on",
     "status",
     "currency",
     "commission_amount",
     "source",
     "source_ref",
     "imported_at"
    ],
    "additionalProperties": false
   }
  },
  "sponsorship_deals": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "deal_id": {
      "type": "string"
     },
     "sponsor_id": {
      "type": "string"
     },
     "sponsor_name": {
      "type": [
       "string",
       "null"
      ]
     },
     "campaign": {
      "type": "string"
     },
     "booked_on": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
     },
     "due_on": {
      "type": [
       "string",
       "null"
      ],
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
     },
     "delivered_on": {
      "type": [
       "string",
       "null"
      ],
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
     },
     "status": {
      "type": "string",
      "enum": [
       "booked",
       "delivered",
       "cancelled"
      ]
     },
     "currency": {
      "type": "string",
      "pattern": "^[A-Z]{3}$"
     },
     "booked_amount": {
      "type": "number"
     },
     "source": {
      "type": "string"
     },
     "source_ref": {
      "type": "string"
     },
     "imported_at": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?Z$"
     },
     "confidence": {
      "type": [
       "string",
       "null"
      ],
      "enum": [
       "rule",
       "default",
       "detected",
       "manual",
       null
      ]
     }
    },
    "required": [
     "deal_id",
     "sponsor_id",
     "campaign",
     "booked_on",
     "status",
     "currency",
     "booked_amount",
     "source",
     "source_ref",
     "imported_at"
    ],
    "additionalProperties": false
   }
  },
  "sponsorship_payouts": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "payment_id": {
      "type": "string"
     },
     "deal_id": {
      "type": "string"
     },
     "received_on": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
     },
     "currency": {
      "type": "string",
      "pattern": "^[A-Z]{3}$"
     },
     "amount": {
      "type": "number"
     },
     "source": {
      "type": "string"
     },
     "source_ref": {
      "type": "string"
     },
     "imported_at": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?Z$"
     },
     "confidence": {
      "type": [
       "string",
       "null"
      ],
      "enum": [
       "rule",
       "default",
       "detected",
       "manual",
       null
      ]
     }
    },
    "required": [
     "payment_id",
     "deal_id",
     "received_on",
     "currency",
     "amount",
     "source",
     "source_ref",
     "imported_at"
    ],
    "additionalProperties": false
   }
  },
  "import_issues": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "issue_id": {
      "type": "string"
     },
     "severity": {
      "type": "string",
      "enum": [
       "info",
       "warn",
       "error"
      ]
     },
     "code": {
      "type": "string"
     },
     "detail": {
      "type": "string"
     },
     "source": {
      "type": "string"
     },
     "source_ref": {
      "type": "string"
     },
     "imported_at": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?Z$"
     },
     "confidence": {
      "type": [
       "string",
       "null"
      ],
      "enum": [
       "rule",
       "default",
       "detected",
       "manual",
       null
      ]
     }
    },
    "required": [
     "issue_id",
     "severity",
     "code",
     "detail",
     "source",
     "source_ref",
     "imported_at"
    ],
    "additionalProperties": false
   }
  },
  "overrides": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "override_id": {
      "type": "string"
     },
     "target": {
      "type": "string"
     },
     "field": {
      "type": [
       "string",
       "null"
      ]
     },
     "old_value": {
      "type": [
       "string",
       "null"
      ]
     },
     "new_value": {
      "type": [
       "string",
       "null"
      ]
     },
     "reason": {
      "type": "string"
     },
     "evidence": {
      "type": [
       "string",
       "null"
      ]
     },
     "author": {
      "type": [
       "string",
       "null"
      ]
     },
     "created_at": {
      "type": [
       "string",
       "null"
      ]
     }
    },
    "required": [
     "override_id",
     "target",
     "reason"
    ],
    "additionalProperties": false
   }
  },
  "annotations": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "annotation_id": {
      "type": "string"
     },
     "target": {
      "type": "string"
     },
     "kind": {
      "type": "string"
     },
     "body": {
      "type": "string"
     },
     "author": {
      "type": [
       "string",
       "null"
      ]
     },
     "source_ref": {
      "type": [
       "string",
       "null"
      ]
     },
     "created_at": {
      "type": [
       "string",
       "null"
      ]
     },
     "data_hash": {
      "type": [
       "string",
       "null"
      ]
     },
     "status": {
      "type": [
       "string",
       "null"
      ]
     }
    },
    "required": [
     "annotation_id",
     "target",
     "kind",
     "body"
    ],
    "additionalProperties": false
   }
  },
  "metric_registry": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "metric_id": {
      "type": "string"
     },
     "version": {
      "type": [
       "integer",
       "null"
      ]
     },
     "unit": {
      "type": [
       "string",
       "null"
      ]
     },
     "params": {
      "type": [
       "string",
       "null"
      ]
     },
     "description": {
      "type": [
       "string",
       "null"
      ]
     },
     "sql": {
      "type": [
       "string",
       "null"
      ]
     },
     "test": {
      "type": [
       "string",
       "null"
      ]
     }
    },
    "required": [
     "metric_id"
    ],
    "additionalProperties": false
   }
  }
 },
 "required": [
  "meta",
  "overrides",
  "annotations",
  "metric_registry"
 ],
 "patternProperties": {
  "^x_[a-z0-9_]+$": {
   "type": "array"
  },
  "^d_[a-z0-9_]+$": {
   "type": "array"
  }
 },
 "additionalProperties": false
}
