{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "formatVersion": {
      "type": "number",
      "const": 1
    },
    "experienceId": {
      "type": "string",
      "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,95}$"
    },
    "revision": {
      "type": "integer",
      "exclusiveMinimum": 0,
      "maximum": 9007199254740991
    },
    "baseRevision": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "minHostVersion": {
      "default": "0.1.0",
      "type": "string",
      "pattern": "^\\d+\\.\\d+\\.\\d+$"
    },
    "title": {
      "type": "string",
      "minLength": 1,
      "maxLength": 100
    },
    "subtitle": {
      "type": "string",
      "maxLength": 300
    },
    "offline": {
      "type": "object",
      "properties": {
        "mode": {
          "type": "string",
          "enum": [
            "full",
            "partial",
            "none"
          ]
        },
        "summary": {
          "type": "string",
          "minLength": 1,
          "maxLength": 300
        }
      },
      "required": [
        "mode",
        "summary"
      ],
      "additionalProperties": false
    },
    "credentialRequirements": {
      "maxItems": 50,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "credentialId": {
            "type": "string",
            "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,95}$"
          },
          "label": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80
          },
          "origin": {
            "type": "string",
            "format": "uri"
          },
          "purpose": {
            "type": "string",
            "minLength": 1,
            "maxLength": 300
          },
          "required": {
            "default": true,
            "type": "boolean"
          }
        },
        "required": [
          "credentialId",
          "label",
          "origin",
          "purpose"
        ],
        "additionalProperties": false
      }
    },
    "icon": {
      "default": "sparkles",
      "type": "string",
      "maxLength": 40
    },
    "iconAsset": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200
    },
    "tint": {
      "default": "#C8F279",
      "type": "string",
      "pattern": "^#[a-fA-F0-9]{6}$"
    },
    "runtime": {
      "type": "string",
      "enum": [
        "native",
        "web"
      ]
    },
    "tables": {
      "default": [],
      "maxItems": 100,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,95}$"
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "fields": {
            "minItems": 1,
            "maxItems": 100,
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,95}$"
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "string",
                    "number",
                    "boolean",
                    "date",
                    "image",
                    "json",
                    "reference"
                  ]
                },
                "required": {
                  "default": false,
                  "type": "boolean"
                },
                "references": {
                  "type": "string",
                  "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,95}$"
                }
              },
              "required": [
                "name",
                "type"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "id",
          "name",
          "fields"
        ],
        "additionalProperties": false
      }
    },
    "seeds": {
      "default": [],
      "maxItems": 2000,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "tableId": {
            "type": "string",
            "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,95}$"
          },
          "id": {
            "type": "string",
            "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,95}$"
          },
          "values": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {
              "$ref": "#/$defs/__schema0"
            }
          }
        },
        "required": [
          "tableId",
          "id",
          "values"
        ],
        "additionalProperties": false
      }
    },
    "dataBindings": {
      "default": [],
      "maxItems": 200,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "tableId": {
            "type": "string",
            "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,95}$"
          },
          "access": {
            "type": "string",
            "enum": [
              "read",
              "write"
            ]
          }
        },
        "required": [
          "tableId",
          "access"
        ],
        "additionalProperties": false
      }
    },
    "capabilities": {
      "default": [],
      "maxItems": 100,
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 300
      }
    },
    "connections": {
      "default": [],
      "maxItems": 50,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,95}$"
          },
          "kind": {
            "default": "http",
            "type": "string",
            "enum": [
              "http",
              "openai.vision",
              "dropbox"
            ]
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "method": {
            "default": "GET",
            "type": "string",
            "enum": [
              "GET",
              "POST",
              "PUT",
              "PATCH",
              "DELETE"
            ]
          },
          "credentialId": {
            "type": "string",
            "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,95}$"
          },
          "credentialHeader": {
            "default": "Authorization",
            "type": "string",
            "pattern": "^[A-Za-z0-9-]+$"
          },
          "credentialPrefix": {
            "default": "Bearer ",
            "type": "string",
            "maxLength": 30
          },
          "headers": {
            "default": {},
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {
              "type": "string"
            }
          },
          "body": {
            "$ref": "#/$defs/__schema0"
          },
          "responsePath": {
            "type": "string"
          },
          "saveToTableId": {
            "type": "string",
            "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,95}$"
          },
          "fieldMapping": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {
              "type": "string"
            }
          },
          "model": {
            "type": "string"
          },
          "prompt": {
            "type": "string",
            "maxLength": 20000
          },
          "responseSchema": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {
              "$ref": "#/$defs/__schema0"
            }
          }
        },
        "required": [
          "id",
          "url"
        ],
        "additionalProperties": false
      }
    },
    "native": {
      "type": "object",
      "properties": {
        "root": {
          "$ref": "#/$defs/__schema1"
        }
      },
      "required": [
        "root"
      ],
      "additionalProperties": false
    },
    "web": {
      "type": "object",
      "properties": {
        "entry": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "entry"
      ],
      "additionalProperties": false
    },
    "assets": {
      "default": [],
      "maxItems": 500,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "path": {
            "type": "string",
            "minLength": 1,
            "maxLength": 240,
            "pattern": "^[A-Za-z0-9_./-]+$"
          },
          "mediaType": {
            "type": "string",
            "minLength": 1
          },
          "data": {
            "type": "string",
            "maxLength": 36700160
          },
          "sha256": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$"
          }
        },
        "required": [
          "path",
          "mediaType",
          "data",
          "sha256"
        ],
        "additionalProperties": false
      }
    },
    "releaseNotes": {
      "default": "",
      "type": "string",
      "maxLength": 4000
    }
  },
  "required": [
    "formatVersion",
    "experienceId",
    "revision",
    "title",
    "runtime"
  ],
  "additionalProperties": false,
  "$defs": {
    "__schema0": {
      "anyOf": [
        {
          "type": "null"
        },
        {
          "type": "boolean"
        },
        {
          "type": "number"
        },
        {
          "type": "string"
        },
        {
          "type": "array",
          "items": {
            "$ref": "#/$defs/__schema0"
          }
        },
        {
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {
            "$ref": "#/$defs/__schema0"
          }
        }
      ]
    },
    "__schema1": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,95}$"
        },
        "type": {
          "type": "string",
          "enum": [
            "stack",
            "grid",
            "text",
            "image",
            "metric",
            "chart",
            "list",
            "form",
            "button",
            "flashcards",
            "matching",
            "chess",
            "map",
            "camera",
            "aiPhoto",
            "scores",
            "journal",
            "checklist",
            "motion",
            "scanner",
            "connection",
            "inbox"
          ]
        },
        "props": {
          "default": {},
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {
            "$ref": "#/$defs/__schema0"
          }
        },
        "children": {
          "maxItems": 100,
          "type": "array",
          "items": {
            "$ref": "#/$defs/__schema1"
          }
        },
        "action": {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "enum": [
                "insert",
                "update",
                "delete",
                "navigate",
                "request",
                "notify",
                "capture",
                "analyze",
                "setState",
                "downloadMap"
              ]
            },
            "tableId": {
              "type": "string",
              "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,95}$"
            },
            "recordId": {
              "type": "string"
            },
            "requestId": {
              "type": "string",
              "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,95}$"
            },
            "target": {
              "type": "string"
            },
            "values": {
              "type": "object",
              "propertyNames": {
                "type": "string"
              },
              "additionalProperties": {
                "$ref": "#/$defs/__schema0"
              }
            },
            "message": {
              "type": "string"
            }
          },
          "required": [
            "type"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "id",
        "type"
      ],
      "additionalProperties": false
    }
  }
}
