{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "catalogSchemaVersion": {
      "const": "1.0.0"
    },
    "catalogVersion": {
      "type": "string",
      "minLength": 1
    },
    "generatedAt": {
      "type": "string",
      "format": "date-time"
    },
    "lastVerifiedAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "exampleOnly": {
      "type": "boolean"
    },
    "generatorVersion": {
      "type": "string",
      "minLength": 1
    },
    "requiredSourceIds": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      },
      "minItems": 1,
      "uniqueItems": true
    },
    "sourceHealth": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "sourceId": {
            "type": "string",
            "minLength": 1
          },
          "lastVerifiedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "status": {
            "enum": [
              "ok",
              "failed",
              "unverified"
            ]
          }
        },
        "required": [
          "sourceId",
          "lastVerifiedAt",
          "status"
        ],
        "additionalProperties": false
      },
      "minItems": 1
    },
    "entries": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/entry"
      }
    },
    "zones": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "label": {
            "type": "string"
          },
          "source": {
            "$ref": "#/$defs/provenance"
          }
        },
        "required": [
          "id",
          "label",
          "source"
        ],
        "additionalProperties": false
      }
    },
    "plans": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "service": {
            "type": "string",
            "minLength": 1
          },
          "zoneId": {
            "type": [
              "string",
              "null"
            ]
          },
          "attributes": {
            "type": "object"
          },
          "source": {
            "$ref": "#/$defs/provenance"
          }
        },
        "required": [
          "id",
          "service",
          "zoneId",
          "attributes",
          "source"
        ],
        "additionalProperties": false
      }
    }
  },
  "required": [
    "catalogSchemaVersion",
    "catalogVersion",
    "generatedAt",
    "lastVerifiedAt",
    "exampleOnly",
    "generatorVersion",
    "requiredSourceIds",
    "sourceHealth",
    "entries",
    "zones",
    "plans"
  ],
  "additionalProperties": false,
  "$defs": {
    "entry": {
      "type": "object",
      "properties": {
        "typeId": {
          "type": "string",
          "minLength": 1
        },
        "displayName": {
          "type": "string"
        },
        "aliases": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "lifecycle": {
          "enum": [
            "active",
            "deprecated",
            "removed",
            "unverified"
          ]
        },
        "scope": {
          "enum": [
            "zone",
            "region",
            "global",
            "service-specific",
            "unknown"
          ]
        },
        "sources": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/provenance"
          },
          "minItems": 1
        },
        "upstreamSchema": {
          "type": "object",
          "properties": {
            "sourceId": {
              "type": "string",
              "minLength": 1
            },
            "providerAddress": {
              "type": [
                "string",
                "null"
              ]
            },
            "providerVersion": {
              "type": [
                "string",
                "null"
              ]
            },
            "resourceSchemaVersion": {
              "type": [
                "integer",
                "null"
              ]
            },
            "formatVersion": {
              "type": [
                "string",
                "null"
              ]
            },
            "digest": {
              "type": [
                "string",
                "null"
              ]
            },
            "locator": {
              "type": "string",
              "minLength": 1
            }
          },
          "required": [
            "sourceId",
            "providerAddress",
            "providerVersion",
            "resourceSchemaVersion",
            "formatVersion",
            "digest",
            "locator"
          ],
          "additionalProperties": false
        },
        "attributes": {
          "type": "object",
          "additionalProperties": {
            "type": "object",
            "properties": {
              "sourcePath": {
                "type": "string",
                "minLength": 1
              },
              "valueType": {
                "type": "string",
                "minLength": 1
              },
              "sensitive": {
                "type": "boolean"
              },
              "computed": {
                "type": "boolean"
              }
            },
            "required": [
              "sourcePath",
              "valueType",
              "sensitive",
              "computed"
            ],
            "additionalProperties": false
          }
        },
        "capabilities": {
          "type": "object",
          "properties": {
            "enumeration": {
              "enum": [
                "supported",
                "unsupported",
                "needs-verification"
              ]
            },
            "readonlySafe": {
              "enum": [
                "verified",
                "unsafe",
                "needs-verification"
              ]
            },
            "relations": {
              "enum": [
                "verified",
                "generic",
                "needs-review"
              ]
            }
          },
          "required": [
            "enumeration",
            "readonlySafe",
            "relations"
          ],
          "additionalProperties": false
        },
        "icon": {
          "type": "object",
          "properties": {
            "assetId": {
              "type": "string",
              "minLength": 1
            },
            "fallback": {
              "type": "string",
              "minLength": 1
            },
            "licenseId": {
              "type": "string",
              "minLength": 1
            },
            "redistribution": {
              "enum": [
                "allowed",
                "restricted",
                "needs-review"
              ]
            }
          },
          "required": [
            "assetId",
            "fallback",
            "licenseId",
            "redistribution"
          ],
          "additionalProperties": false
        },
        "relationRuleRefs": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        }
      },
      "required": [
        "typeId",
        "displayName",
        "aliases",
        "lifecycle",
        "scope",
        "sources",
        "upstreamSchema",
        "attributes",
        "capabilities",
        "icon",
        "relationRuleRefs"
      ],
      "additionalProperties": false
    },
    "provenance": {
      "type": "object",
      "properties": {
        "sourceId": {
          "type": "string",
          "minLength": 1
        },
        "sourceUrl": {
          "type": "string",
          "format": "uri"
        },
        "retrievedAt": {
          "type": "string",
          "format": "date-time"
        },
        "schemaVersion": {
          "type": "string",
          "minLength": 1
        },
        "locator": {
          "type": "string"
        }
      },
      "required": [
        "sourceId",
        "sourceUrl",
        "retrievedAt",
        "schemaVersion",
        "locator"
      ],
      "additionalProperties": false
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "exampleOnly": {
            "const": false
          }
        }
      },
      "then": {
        "properties": {
          "lastVerifiedAt": {
            "type": "string",
            "format": "date-time"
          },
          "entries": {
            "items": {
              "properties": {
                "upstreamSchema": {
                  "properties": {
                    "digest": {
                      "type": "string",
                      "pattern": "^sha256:[0-9a-f]{64}$"
                    }
                  },
                  "allOf": [
                    {
                      "if": {
                        "properties": {
                          "providerAddress": {
                            "type": "string"
                          }
                        }
                      },
                      "then": {
                        "properties": {
                          "providerVersion": {
                            "type": "string",
                            "minLength": 1
                          },
                          "resourceSchemaVersion": {
                            "type": "integer"
                          },
                          "formatVersion": {
                            "type": "string",
                            "minLength": 1
                          }
                        }
                      }
                    }
                  ]
                },
                "sources": {
                  "items": {
                    "properties": {
                      "schemaVersion": {
                        "type": "string",
                        "minLength": 1,
                        "not": {
                          "const": "example-not-extracted"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  ]
}