{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "$schema": {
      "type": "string"
    },
    "apiUrl": {
      "type": "string",
      "format": "uri"
    },
    "organization": {
      "type": "string",
      "minLength": 1
    },
    "project": {
      "type": "string",
      "minLength": 1
    },
    "environment": {
      "default": "test",
      "type": "string",
      "enum": ["test", "live"]
    },
    "calendar": {
      "type": "object",
      "properties": {
        "timeZone": {
          "type": "string",
          "minLength": 1,
          "maxLength": 100
        }
      },
      "required": ["timeZone"],
      "additionalProperties": false
    },
    "discover": {
      "type": "object",
      "properties": {
        "quests": {
          "default": [],
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "questTypes": {
          "default": [],
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "provider": {
          "default": "workers-ai",
          "type": "string",
          "enum": ["workers-ai"]
        }
      },
      "additionalProperties": false
    },
    "app": {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "kind": {
              "type": "string",
              "const": "static"
            },
            "directory": {
              "type": "string",
              "minLength": 1,
              "maxLength": 512
            },
            "routing": {
              "default": "legacy",
              "type": "string",
              "enum": ["legacy", "transparent"]
            },
            "devScript": {
              "type": "string",
              "pattern": "^[\\w:-]+$"
            },
            "checkScript": {
              "type": "string",
              "pattern": "^[\\w:-]+$"
            },
            "buildScript": {
              "type": "string",
              "pattern": "^[\\w:-]+$"
            }
          },
          "required": [
            "kind",
            "directory",
            "devScript",
            "checkScript",
            "buildScript"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "type": "string",
              "const": "worker"
            },
            "directory": {
              "type": "string",
              "minLength": 1,
              "maxLength": 512
            },
            "assetsDirectory": {
              "type": "string",
              "minLength": 1,
              "maxLength": 512
            },
            "routing": {
              "default": "legacy",
              "type": "string",
              "enum": ["legacy", "transparent"]
            },
            "devScript": {
              "type": "string",
              "pattern": "^[\\w:-]+$"
            },
            "checkScript": {
              "type": "string",
              "pattern": "^[\\w:-]+$"
            },
            "buildScript": {
              "type": "string",
              "pattern": "^[\\w:-]+$"
            },
            "runWorkerFirst": {
              "default": false,
              "type": "boolean"
            },
            "main": {
              "type": "string",
              "minLength": 1,
              "maxLength": 512
            },
            "compatibilityDate": {
              "type": "string",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
            },
            "compatibilityFlags": {
              "default": [],
              "maxItems": 50,
              "type": "array",
              "items": {
                "type": "string",
                "minLength": 1
              }
            },
            "vars": {
              "default": {},
              "type": "object",
              "propertyNames": {
                "type": "string",
                "pattern": "^[A-Za-z_][A-Za-z0-9_]*$"
              },
              "additionalProperties": {
                "type": "string"
              }
            },
            "secrets": {
              "default": {},
              "type": "object",
              "propertyNames": {
                "type": "string",
                "pattern": "^[A-Z_][A-Z0-9_]{0,63}$"
              },
              "additionalProperties": {
                "type": "object",
                "properties": {
                  "description": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500
                  },
                  "required": {
                    "default": true,
                    "type": "boolean"
                  }
                },
                "required": ["description"],
                "additionalProperties": false
              }
            },
            "storage": {
              "type": "object",
              "properties": {
                "kv": {
                  "default": {},
                  "type": "object",
                  "propertyNames": {
                    "type": "string",
                    "pattern": "^[A-Z_][A-Z0-9_]{0,63}$"
                  },
                  "additionalProperties": {
                    "type": "object",
                    "properties": {
                      "description": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 500
                      }
                    },
                    "required": ["description"],
                    "additionalProperties": false
                  }
                },
                "sql": {
                  "default": {},
                  "type": "object",
                  "propertyNames": {
                    "type": "string",
                    "pattern": "^[A-Z_][A-Z0-9_]{0,63}$"
                  },
                  "additionalProperties": {
                    "type": "object",
                    "properties": {
                      "description": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 500
                      },
                      "migrations": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 512
                      }
                    },
                    "required": ["description"],
                    "additionalProperties": false
                  }
                }
              },
              "additionalProperties": false
            },
            "schedules": {
              "maxItems": 10,
              "type": "array",
              "items": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "name": {
                        "type": "string",
                        "pattern": "^[a-z][a-z0-9-]{0,63}$"
                      },
                      "path": {
                        "type": "string",
                        "minLength": 2,
                        "maxLength": 512
                      },
                      "description": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 500
                      },
                      "every": {
                        "type": "string",
                        "pattern": "^[1-9]\\d{0,3}[mhd]$"
                      }
                    },
                    "required": ["name", "path", "description", "every"],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "name": {
                        "type": "string",
                        "pattern": "^[a-z][a-z0-9-]{0,63}$"
                      },
                      "path": {
                        "type": "string",
                        "minLength": 2,
                        "maxLength": 512
                      },
                      "description": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 500
                      },
                      "cron": {
                        "type": "string",
                        "maxLength": 120
                      }
                    },
                    "required": ["name", "path", "description", "cron"],
                    "additionalProperties": false
                  }
                ]
              }
            }
          },
          "required": [
            "kind",
            "directory",
            "devScript",
            "checkScript",
            "buildScript",
            "main",
            "compatibilityDate"
          ],
          "additionalProperties": false
        }
      ]
    },
    "questTypes": {
      "default": [],
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "entry": {
            "type": "string",
            "minLength": 1
          },
          "exportName": {
            "type": "string"
          },
          "provider": {
            "type": "string",
            "enum": ["workers-ai"]
          }
        },
        "required": ["entry"],
        "additionalProperties": false
      }
    },
    "engagement": {
      "default": [],
      "maxItems": 50,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "entry": {
            "type": "string",
            "minLength": 1
          },
          "exportName": {
            "type": "string"
          }
        },
        "required": ["entry"],
        "additionalProperties": false
      }
    },
    "trackers": {
      "default": [],
      "maxItems": 50,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "entry": {
            "type": "string",
            "minLength": 1
          },
          "exportName": {
            "type": "string"
          }
        },
        "required": ["entry"],
        "additionalProperties": false
      }
    },
    "leaderboards": {
      "default": [],
      "maxItems": 50,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "entry": {
            "type": "string",
            "minLength": 1
          },
          "exportName": {
            "type": "string"
          }
        },
        "required": ["entry"],
        "additionalProperties": false
      }
    },
    "referrals": {
      "default": [],
      "maxItems": 50,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "entry": {
            "type": "string",
            "minLength": 1
          },
          "exportName": {
            "type": "string"
          }
        },
        "required": ["entry"],
        "additionalProperties": false
      }
    },
    "badges": {
      "default": [],
      "maxItems": 100,
      "type": "array",
      "items": {
        "anyOf": [
          {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 120
              },
              "description": {
                "default": "",
                "type": "string",
                "maxLength": 1000
              },
              "image": {
                "type": "string",
                "maxLength": 2048,
                "format": "uri"
              },
              "key": {
                "type": "string",
                "minLength": 1,
                "maxLength": 100,
                "pattern": "^[a-zA-Z0-9_-]+$"
              }
            },
            "required": ["name", "image", "key"],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "entry": {
                "type": "string",
                "minLength": 1
              },
              "exportName": {
                "type": "string"
              }
            },
            "required": ["entry"],
            "additionalProperties": false
          }
        ]
      }
    },
    "pointLedgers": {
      "default": [],
      "maxItems": 50,
      "type": "array",
      "items": {
        "anyOf": [
          {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 120
              },
              "description": {
                "default": "",
                "type": "string",
                "maxLength": 1000
              },
              "key": {
                "type": "string",
                "minLength": 1,
                "maxLength": 100,
                "pattern": "^[a-zA-Z0-9_-]+$"
              }
            },
            "required": ["name", "key"],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "entry": {
                "type": "string",
                "minLength": 1
              },
              "exportName": {
                "type": "string"
              }
            },
            "required": ["entry"],
            "additionalProperties": false
          }
        ]
      }
    },
    "offers": {
      "default": [],
      "maxItems": 100,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "entry": {
            "type": "string",
            "minLength": 1
          },
          "exportName": {
            "type": "string"
          }
        },
        "required": ["entry"],
        "additionalProperties": false
      }
    },
    "dashboards": {
      "default": [],
      "maxItems": 100,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "entry": {
            "type": "string",
            "minLength": 1
          },
          "exportName": {
            "type": "string"
          }
        },
        "required": ["entry"],
        "additionalProperties": false
      }
    },
    "images": {
      "default": [],
      "maxItems": 10,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "pattern": "^[a-zA-Z0-9_-]+$"
          },
          "path": {
            "type": "string",
            "minLength": 1
          }
        },
        "required": ["key", "path"],
        "additionalProperties": false
      }
    },
    "collections": {
      "default": [],
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "pattern": "^[a-zA-Z0-9_-]+$"
          },
          "title": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "description": {
            "type": "string",
            "maxLength": 4000
          },
          "image": {
            "type": "string",
            "maxLength": 2000
          },
          "imageAlt": {
            "type": "string",
            "maxLength": 500
          }
        },
        "required": ["key", "title"],
        "additionalProperties": false
      }
    },
    "supportedInteractions": {
      "minItems": 1,
      "type": "array",
      "items": {
        "type": "string",
        "enum": ["photo", "quiz", "text", "url", "claim", "staff", "automatic"]
      }
    },
    "quests": {
      "default": [],
      "maxItems": 1000,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "entry": {
            "type": "string",
            "minLength": 1
          },
          "exportName": {
            "type": "string"
          },
          "settings": {
            "default": {},
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {}
          },
          "settingRenames": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {
              "type": "string"
            }
          },
          "provider": {
            "type": "string",
            "enum": ["workers-ai"]
          }
        },
        "required": ["entry"],
        "additionalProperties": false
      }
    }
  },
  "required": ["apiUrl", "organization", "project"],
  "additionalProperties": false
}
