{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://aap.mobileappster.co.uk/aap.schema.json",
  "title": "Application Announcement Protocol (AAP) Feed",
  "description": "AAP is a decentralized discovery and metadata publication protocol for applications.",
  "type": "object",
  "additionalProperties": false,
  "required": ["name", "description", "url", "applications"],
  "properties": {
    "name": {
      "type": "string",
      "minLength": 1,
      "description": "The name of the service/feed."
    },
    "description": {
      "type": "string",
      "minLength": 1,
      "description": "Description of the feed."
    },
    "url": {
      "type": "string",
      "format": "uri",
      "description": "The URL to the HTML website corresponding to the feed."
    },
    "iconUrl": {
      "type": "string",
      "format": "uri",
      "description": "Square image (gif, jpeg, png, svg, webp) that can be displayed on the channel."
    },
    "categories": {
      "type": "array",
      "description": "Categories for the overall service.",
      "items": { "type": "string" }
    },
    "aapVersion": {
      "type": "string",
      "description": "Protocol version (e.g. 1.0).",
      "pattern": "^[0-9]+(\\.[0-9]+)*$"
    },
    "languageCode": {
      "type": "string",
      "description": "IANA language codes (BCP 47 / language tags).",
      "pattern": "^[A-Za-z]{2,3}(-[A-Za-z0-9]{2,8})*$"
    },
    "copyright": {
      "type": "string",
      "description": "Copyright notice for content in the feed."
    },
    "owner": {
      "type": "string",
      "description": "Name of the individual or organization responsible for this feed."
    },
    "supportUrl": {
      "type": "string",
      "format": "uri",
      "description": "Link to support website for the overall feed."
    },
    "supportEmail": {
      "type": "string",
      "format": "email",
      "description": "Support contact email for the overall feed."
    },
    "horizontalFeatureImageUrl": {
      "type": "string",
      "format": "uri",
      "description": "16:9 rectangle image."
    },
    "verticalFeatureImageUrl": {
      "type": "string",
      "format": "uri",
      "description": "9:16 rectangle image."
    },
    "didId": {
      "type": "string",
      "description": "Decentralized ID of the feed owner (did:web:...)."
    },
    "total": {
      "type": "integer",
      "minimum": 0,
      "description": "Total applications in the list."
    },
    "count": {
      "type": "integer",
      "minimum": 0,
      "description": "Applications in current file."
    },
    "next": {
      "type": "string",
      "format": "uri",
      "description": "URL for the next page of results."
    },
    "previous": {
      "type": "string",
      "format": "uri",
      "description": "URL for the previous page of results."
    },
    "sort": {
      "type": "string",
      "description": "Sorting order (e.g., updatedDate_desc)."
    },
    "custom": {
      "type": "object",
      "description": "Custom extensions. Each entry requires a label and a value; value may be any JSON type.",
      "additionalProperties": {
        "type": "object",
        "additionalProperties": false,
        "required": ["label", "value"],
        "properties": {
          "label": { "type": "string", "minLength": 1 },
          "value": {}
        }
      }
    },
    "applications": {
      "type": "array",
      "description": "Array of application entries. SHOULD be ordered by updatedDate descending.",
      "items": { "$ref": "#/$defs/application" }
    }
  },
  "$defs": {
    "application": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name", "description", "url", "guid"],
      "properties": {
        "name": { "type": "string", "minLength": 1, "description": "The name of the application." },
        "description": { "type": "string", "minLength": 1, "description": "Short description of the application." },
        "url": { "type": "string", "format": "uri", "description": "Main URL to run or install the application itself." },
        "guid": {
          "type": "string",
          "description": "Stable identifier. MUST be globally unique. SHOULD be a URI under a domain the publisher controls."
        },

        "iconUrl": { "type": "string", "format": "uri", "description": "Square image (gif, jpeg, png, svg, webp) that can be displayed against the application." },
        "categories": { "type": "array", "items": { "type": "string" }, "description": "Categories for this application." },

        "lifecycleCode": { "$ref": "#/$defs/lifecycleCode" },
        "supportCode": { "$ref": "#/$defs/supportCode" },
        "availabilityCode": { "$ref": "#/$defs/availabilityCode" },
        "distributionCode": { "$ref": "#/$defs/distributionCode" },
        "platformCode": { "$ref": "#/$defs/platformCode" },

        "tags": { "type": "array", "items": { "type": "string" }, "description": "Application capabilities tags." },
        "keywords": { "type": "array", "items": { "type": "string" }, "description": "Keywords for classification." },

        "horizontalFeatureImageUrl": { "type": "string", "format": "uri", "description": "16:9 feature image." },
        "verticalFeatureImageUrl": { "type": "string", "format": "uri", "description": "9:16 feature image." },
        "screenshotUrls": { "type": "array", "items": { "type": "string", "format": "uri" }, "description": "URLs to application screenshots." },

        "owner": { "type": "string", "description": "Name of the application creator/owner." },
        "size": { "type": "integer", "minimum": 0, "description": "Size in bytes." },
        "license": { "type": "string", "description": "Software license (e.g., MIT)." },

        "publisher": { "type": "string", "description": "Individual or company name." },
        "publisherUrl": { "type": "string", "format": "uri", "description": "Unique URL for the publisher." },
        "publisherDid": { "type": "string", "description": "Publisher decentralized ID." },

        "sourceUrl": { "type": "string", "format": "uri", "description": "Code repository URL." },
        "docsUrl": { "type": "string", "format": "uri", "description": "Documentation URL." },
        "supportUrl": { "type": "string", "format": "uri", "description": "Support assistance URL." },
        "promptUrl": { "type": "string", "format": "uri", "description": "AI prompt path if applicable." },
        "commentsUrl": { "type": "string", "format": "uri", "description": "User discussion URL." },
        "ratingUrl": { "type": "string", "format": "uri", "description": "Reviews/Rating URL." },
        "privacyUrl": { "type": "string", "format": "uri", "description": "Privacy policy URL." },
        "termsUrl": { "type": "string", "format": "uri", "description": "Terms and conditions URL." },

        "changelog": { "type": "string", "description": "Text list of changes." },
        "changelogUrl": { "type": "string", "format": "uri", "description": "URL to list of changes." },

        "supportEmail": { "type": "string", "format": "email", "description": "Support contact email." },

        "targets": {
          "type": "array",
          "items": { "type": "string" },
          "description": "Specific operating systems, runtimes, devices, environments, or host platforms supported."
        },

        "updatedDate": { "type": "string", "format": "date-time", "description": "Last metadata change date (ISO 8601)." },
        "createdDate": { "type": "string", "format": "date-time", "description": "First release date (ISO 8601)." },
        "version": { "type": "string", "description": "Current application version number." },

        "languageCode": {
          "type": "string",
          "description": "IANA language codes (BCP 47 / language tags).",
          "pattern": "^[A-Za-z]{2,3}(-[A-Za-z0-9]{2,8})*$"
        },
        "copyright": { "type": "string", "description": "Application copyright notice." },

        "ageScheme": { "type": "string", "description": "Rating scheme (e.g. PEGI)." },
        "ageValue": { "type": "string", "description": "Specific age rating value." },
        "brandColor": {
          "type": "string",
          "description": "Hex value indicating the brand's color.",
          "pattern": "^#(?:[0-9a-fA-F]{3}){1,2}$"
        },
        "contentDescriptors": { "type": "array", "items": { "type": "string" }, "description": "Content descriptors (e.g., [\"Violence\"])." },

        "checksum": {
          "type": "string",
          "description": "Hash (e.g. sha256:...).",
          "pattern": "^[A-Za-z0-9]+:[A-Fa-f0-9]+$"
        },

        "permissionCodes": {
          "type": "array",
          "items": { "type": "string" },
          "description": "W3C permissions registry identifiers."
        },

        "capabilities": { "type": "array", "items": { "type": "string" }, "description": "Capabilities (e.g., [\"pwa\", \"offline\"])." },
        "requirements": { "type": "array", "items": { "type": "string" }, "description": "Prerequisites (e.g., [\"iOS 15+\", \"Python 3.9\"])." },

        "localization": {
          "type": "array",
          "description": "Localized application objects. Must not contain the localization key.",
          "items": { "$ref": "#/$defs/localizationItem" }
        },
        "versions": {
          "type": "array",
          "description": "Archive of previous versions. Must not contain the versions key.",
          "items": { "$ref": "#/$defs/versionItem" }
        }
      }
    },

    "localizationItem": {
      "type": "object",
      "additionalProperties": false,
      "required": ["languageCode", "url", "name"],
      "properties": {
        "languageCode": {
          "type": "string",
          "description": "IANA language codes (BCP 47 / language tags).",
          "pattern": "^[A-Za-z]{2,3}(-[A-Za-z0-9]{2,8})*$"
        },
        "url": { "type": "string", "format": "uri" },
        "name": { "type": "string", "minLength": 1 },

        "description": { "type": "string" },
        "iconUrl": { "type": "string", "format": "uri" },
        "categories": { "type": "array", "items": { "type": "string" } },
        "tags": { "type": "array", "items": { "type": "string" } },
        "keywords": { "type": "array", "items": { "type": "string" } },
        "horizontalFeatureImageUrl": { "type": "string", "format": "uri" },
        "verticalFeatureImageUrl": { "type": "string", "format": "uri" },
        "screenshotUrls": { "type": "array", "items": { "type": "string", "format": "uri" } },
        "owner": { "type": "string" },
        "publisher": { "type": "string" },
        "publisherUrl": { "type": "string", "format": "uri" },
        "docsUrl": { "type": "string", "format": "uri" },
        "supportUrl": { "type": "string", "format": "uri" },
        "supportEmail": { "type": "string", "format": "email" },
        "privacyUrl": { "type": "string", "format": "uri" },
        "termsUrl": { "type": "string", "format": "uri" },
        "changelog": { "type": "string" },
        "changelogUrl": { "type": "string", "format": "uri" }
      },
      "allOf": [
        { "not": { "required": ["localization"] } },
        { "not": { "required": ["versions"] } }
      ]
    },

    "versionItem": {
      "type": "object",
      "additionalProperties": false,
      "required": ["version", "url", "name"],
      "properties": {
        "version": { "type": "string", "minLength": 1 },
        "url": { "type": "string", "format": "uri" },
        "name": { "type": "string", "minLength": 1 },

        "description": { "type": "string" },
        "guid": { "type": "string" },
        "iconUrl": { "type": "string", "format": "uri" },
        "categories": { "type": "array", "items": { "type": "string" } },

        "lifecycleCode": { "$ref": "#/$defs/lifecycleCode" },
        "supportCode": { "$ref": "#/$defs/supportCode" },
        "availabilityCode": { "$ref": "#/$defs/availabilityCode" },
        "distributionCode": { "$ref": "#/$defs/distributionCode" },
        "platformCode": { "$ref": "#/$defs/platformCode" },

        "tags": { "type": "array", "items": { "type": "string" } },
        "keywords": { "type": "array", "items": { "type": "string" } },
        "sourceUrl": { "type": "string", "format": "uri" },
        "docsUrl": { "type": "string", "format": "uri" },
        "supportUrl": { "type": "string", "format": "uri" },
        "supportEmail": { "type": "string", "format": "email" },
        "privacyUrl": { "type": "string", "format": "uri" },
        "termsUrl": { "type": "string", "format": "uri" },
        "changelog": { "type": "string" },
        "changelogUrl": { "type": "string", "format": "uri" },
        "checksum": { "type": "string", "pattern": "^[A-Za-z0-9]+:[A-Fa-f0-9]+$" }
      },
      "allOf": [
        { "not": { "required": ["localization"] } },
        { "not": { "required": ["versions"] } }
      ]
    },

    "lifecycleCode": {
      "type": "string",
      "description": "Defines the maturity and lifecycle stage of the application.",
      "enum": [
        "planned",
        "announcement",
        "development",
        "experimental",
        "alpha",
        "beta",
        "preview",
        "releaseCandidate",
        "active",
        "maintenance",
        "legacy",
        "deprecated",
        "endOfLife",
        "discontinued",
        "withdrawn",
        "archived",
        "forked",
        "abandoned"
      ]
    },

    "supportCode": {
      "type": "string",
      "description": "Defines the level and source of maintenance or support available.",
      "enum": [
        "supported",
        "community",
        "limited",
        "maintenanceOnly",
        "unsupported",
        "unverified",
        "certified"
      ]
    },

    "availabilityCode": {
      "type": "string",
      "description": "Defines whether and how the application can currently be accessed or used.",
      "enum": [
        "public",
        "private",
        "inviteOnly",
        "restricted",
        "pending",
        "suspended",
        "disabled",
        "offline",
        "quarantined",
        "withdrawn"
      ]
    },

    "distributionCode": {
      "type": "string",
      "description": "Defines how the application is distributed, hosted, or maintained.",
      "enum": [
        "primary",
        "mirrored",
        "fork",
        "communityFork",
        "vendorHosted",
        "selfHosted",
        "thirdPartyHosted",
        "aggregated"
      ]
    },

    "platformCode": {
      "type": "string",
      "description": "The primary environment or interaction model the application is designed for.",
      "enum": [
        "web",
        "mobile",
        "desktop",
        "server",
        "cli",
        "api",
        "library",
        "extension",
        "embedded",
        "console",
        "vr-ar",
        "ai-agent",
        "hybrid"
      ]
    }
  }
}