{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://curatorapproved.com/catalog.schema.json",
  "title": "The Curator public catalog v1",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "$schema",
    "schemaVersion",
    "title",
    "url",
    "description",
    "items"
  ],
  "properties": {
    "$schema": {
      "const": "https://curatorapproved.com/catalog.schema.json"
    },
    "schemaVersion": {
      "const": 1
    },
    "title": {
      "type": "string"
    },
    "url": {
      "type": "string",
      "format": "uri",
      "pattern": "^https://"
    },
    "description": {
      "type": "string"
    },
    "items": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "number",
          "type",
          "name",
          "url",
          "category",
          "subcategory",
          "description",
          "attribution",
          "images",
          "merchant",
          "price",
          "details",
          "selectionNote",
          "sources",
          "referral"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
          },
          "number": {
            "type": "string",
            "pattern": "^[0-9]+$"
          },
          "type": {
            "enum": [
              "product",
              "music",
              "store"
            ]
          },
          "name": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "pattern": "^https://"
          },
          "category": {
            "type": "string"
          },
          "subcategory": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "attribution": {
            "type": "string"
          },
          "images": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "url",
                "alt"
              ],
              "properties": {
                "url": {
                  "type": "string",
                  "format": "uri",
                  "pattern": "^https://"
                },
                "alt": {
                  "type": "string"
                }
              }
            },
            "minItems": 1
          },
          "merchant": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "name",
              "productUrl",
              "outboundUrl"
            ],
            "properties": {
              "name": {
                "type": "string"
              },
              "productUrl": {
                "type": "string",
                "format": "uri",
                "pattern": "^https://"
              },
              "outboundUrl": {
                "type": "string",
                "format": "uri",
                "pattern": "^https://"
              }
            }
          },
          "price": {
            "anyOf": [
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "amount",
                  "currency",
                  "checkedOn",
                  "context"
                ],
                "properties": {
                  "amount": {
                    "type": "number",
                    "minimum": 0
                  },
                  "currency": {
                    "type": "string",
                    "pattern": "^[A-Z]{3}$"
                  },
                  "checkedOn": {
                    "type": "string",
                    "format": "date"
                  },
                  "context": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              },
              {
                "type": "null"
              }
            ]
          },
          "details": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "name",
                "value"
              ],
              "properties": {
                "name": {
                  "type": "string"
                },
                "value": {
                  "type": "string"
                }
              }
            }
          },
          "selectionNote": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "name",
                "url"
              ],
              "properties": {
                "name": {
                  "type": "string"
                },
                "url": {
                  "type": "string",
                  "format": "uri",
                  "pattern": "^https://"
                }
              }
            },
            "minItems": 1
          },
          "referral": {
            "anyOf": [
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "reward",
                  "disclosure",
                  "offerText",
                  "code"
                ],
                "properties": {
                  "reward": {
                    "const": "store_credit"
                  },
                  "disclosure": {
                    "type": "string"
                  },
                  "offerText": {
                    "type": "string"
                  },
                  "code": {
                    "type": "string"
                  }
                }
              },
              {
                "type": "null"
              }
            ]
          },
          "music": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "artist",
              "releaseDate",
              "trackCount",
              "displayedDuration",
              "embedUrl"
            ],
            "properties": {
              "artist": {
                "type": "string"
              },
              "releaseDate": {
                "anyOf": [
                  { "type": "string", "format": "date" },
                  { "type": "null" }
                ]
              },
              "trackCount": {
                "type": "integer",
                "minimum": 1
              },
              "displayedDuration": {
                "type": "string"
              },
              "embedUrl": {
                "type": "string",
                "format": "uri",
                "pattern": "^https://"
              },
              "kind": {
                "enum": [
                  "album",
                  "track"
                ],
                "description": "Optional selection kind. Legacy music entries without this field are albums."
              }
            }
          },
          "statusText": {
            "type": "string"
          }
        }
      }
    }
  }
}
