{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://my.smartest.website/marketplace/template-contract/v1/schema.json",
  "title": "smartest.website template package v1",
  "description": "Manifest structure. SWC5 also validates file safety, checksums, HTML, relationships, private form destinations, quotas and review status.",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "schema_version": {
      "const": 1
    },
    "id": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9-]{0,59}/[a-z][a-z0-9-]{0,59}$"
    },
    "version": {
      "type": "string",
      "pattern": "^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(-[a-zA-Z0-9][a-zA-Z0-9.-]*)?$"
    },
    "render_mode": {
      "const": "go"
    },
    "engine": {
      "const": "html"
    },
    "locale": {
      "type": "string",
      "pattern": "^[a-z]{2,3}(-[A-Z]{2})?$"
    },
    "pages": {
      "type": "array",
      "minItems": 1,
      "maxItems": 100,
      "items": {
        "$ref": "#/$defs/page"
      }
    },
    "assets": {
      "type": "array",
      "minItems": 0,
      "maxItems": 200,
      "items": {
        "$ref": "#/$defs/asset"
      }
    },
    "collections": {
      "type": "array",
      "minItems": 0,
      "maxItems": 20,
      "items": {
        "$ref": "#/$defs/collection"
      }
    },
    "forms": {
      "type": "array",
      "minItems": 0,
      "maxItems": 20,
      "items": {
        "$ref": "#/$defs/form"
      }
    },
    "navigation": {
      "type": "array",
      "minItems": 0,
      "maxItems": 100,
      "items": {
        "$ref": "#/$defs/navigation"
      }
    },
    "license": {
      "type": "string",
      "minLength": 1,
      "maxLength": 10000
    }
  },
  "required": [
    "schema_version",
    "id",
    "version",
    "render_mode",
    "engine",
    "locale",
    "pages",
    "license"
  ],
  "$defs": {
    "page": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "key": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9-]{0,59}$"
        },
        "slug": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9-]{0,59}$"
        },
        "title": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "description": {
          "type": "string",
          "maxLength": 1000
        },
        "html": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200,
          "pattern": "^[a-zA-Z0-9_-][a-zA-Z0-9_./-]*$"
        },
        "editable": {
          "type": "array",
          "minItems": 0,
          "maxItems": 100,
          "items": {
            "$ref": "#/$defs/editable"
          }
        }
      },
      "required": [
        "key",
        "slug",
        "title",
        "html"
      ]
    },
    "editable": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "key": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9-]{0,59}$"
        },
        "text": {
          "type": "string",
          "minLength": 1,
          "maxLength": 10000
        },
        "type": {
          "const": "text"
        }
      },
      "required": [
        "key",
        "text"
      ]
    },
    "asset": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "path": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200,
          "pattern": "^assets/[a-zA-Z0-9_./-]+$"
        },
        "mime_type": {
          "enum": [
            "text/css",
            "text/javascript",
            "image/svg+xml",
            "image/png",
            "image/jpeg",
            "image/webp",
            "image/avif",
            "image/gif",
            "font/woff2",
            "font/woff",
            "font/ttf",
            "text/plain"
          ]
        },
        "sha256": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        }
      },
      "required": [
        "path",
        "mime_type",
        "sha256"
      ]
    },
    "collection": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "key": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9-]{0,59}$"
        },
        "slug": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9-]{0,59}$"
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 160
        },
        "public": {
          "type": "boolean",
          "default": false
        },
        "fields": {
          "type": "array",
          "minItems": 1,
          "maxItems": 60,
          "items": {
            "$ref": "#/$defs/collectionField"
          }
        }
      },
      "required": [
        "key",
        "slug",
        "name",
        "fields"
      ]
    },
    "collectionField": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9_]{0,59}$"
        },
        "label": {
          "type": "string",
          "minLength": 1,
          "maxLength": 160
        },
        "type": {
          "enum": [
            "text",
            "longtext",
            "number",
            "date",
            "datetime",
            "boolean",
            "email",
            "url",
            "select"
          ]
        },
        "required": {
          "type": "boolean",
          "default": false
        },
        "options": {
          "type": "array",
          "maxItems": 60,
          "uniqueItems": true,
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          }
        }
      },
      "required": [
        "name",
        "label",
        "type"
      ]
    },
    "form": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "key": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9-]{0,59}$"
        },
        "slug": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9-]{0,59}$"
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 160
        },
        "collection": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9-]{0,59}$"
        },
        "fields": {
          "type": "array",
          "minItems": 1,
          "maxItems": 60,
          "items": {
            "$ref": "#/$defs/formField"
          }
        },
        "field_map": {
          "type": "object",
          "minProperties": 1,
          "maxProperties": 60,
          "propertyNames": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_]{0,59}$"
          },
          "additionalProperties": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_]{0,59}$"
          }
        },
        "success_message": {
          "type": "string",
          "minLength": 1,
          "maxLength": 1000
        }
      },
      "required": [
        "key",
        "slug",
        "name",
        "collection",
        "fields",
        "field_map",
        "success_message"
      ]
    },
    "formField": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9_]{0,59}$"
        },
        "label": {
          "type": "string",
          "minLength": 1,
          "maxLength": 160
        },
        "type": {
          "enum": [
            "text",
            "email",
            "tel",
            "number",
            "date",
            "url",
            "textarea",
            "select",
            "checkbox"
          ]
        },
        "required": {
          "type": "boolean",
          "default": false
        },
        "options": {
          "type": "array",
          "maxItems": 60,
          "uniqueItems": true,
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          }
        },
        "max_length": {
          "type": "integer",
          "minimum": 0,
          "maximum": 64000
        }
      },
      "required": [
        "name",
        "label",
        "type"
      ]
    },
    "navigation": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "label": {
          "type": "string",
          "minLength": 1,
          "maxLength": 100
        },
        "page": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9-]{0,59}$"
        }
      },
      "required": [
        "label",
        "page"
      ]
    }
  }
}
