{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/Fujio-Turner/mobile_field_service/docs/schema/products.json",
  "title": "field.products",
  "type": "object",
  "additionalProperties": true,
  "required": ["type", "audit", "sku", "name", "uom"],
  "properties": {
    "type": { "const": "product" },
    "audit": { "$ref": "#/$defs/audit" },
    "sku": { "type": "string", "minLength": 1 },
    "name": { "type": "string", "minLength": 1 },
    "uom": { "type": "string", "minLength": 1 },
    "description": { "type": "string" },
    "category": { "type": "string" },
    "barcode": { "type": "string" },
    "active": { "type": "boolean" },
    "defaultRateId": { "type": "string" },
    "embedding": { "type": "object", "additionalProperties": true }
  },
  "$defs": {
    "unixSeconds": { "type": "integer", "minimum": 0 },
    "auditStamp": {
      "type": "object",
      "additionalProperties": false,
      "required": ["dt", "ver", "by"],
      "properties": {
        "dt": { "$ref": "#/$defs/unixSeconds" },
        "ver": { "type": "string" },
        "by": { "type": "string" }
      }
    },
    "audit": {
      "type": "object",
      "additionalProperties": false,
      "required": ["cr", "up"],
      "properties": {
        "cr": { "$ref": "#/$defs/auditStamp" },
        "up": { "$ref": "#/$defs/auditStamp" }
      }
    }
  }
}
