{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://savvytoolz.com/data/tool-data-processing.schema.json",
  "title": "SavvyToolz tool data-processing disclosure",
  "description": "Schema for the route-level processing profiles and network-dependency disclosures published by SavvyToolz.",
  "type": "object",
  "required": [
    "schemaVersion",
    "documentType",
    "site",
    "canonicalHumanReadableUrl",
    "schemaUrl",
    "lastSourceReview",
    "maintenance",
    "scope",
    "importantQualification",
    "processingProfiles",
    "toolRoutes",
    "providerRequests",
    "siteWideServices",
    "browserStorage",
    "accuracyLimitations"
  ],
  "properties": {
    "$schema": { "type": "string", "format": "uri" },
    "schemaVersion": {
      "type": "string",
      "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$"
    },
    "documentType": { "const": "tool-data-processing-disclosure" },
    "site": { "type": "string", "format": "uri" },
    "canonicalHumanReadableUrl": { "type": "string", "format": "uri" },
    "schemaUrl": { "type": "string", "format": "uri" },
    "lastSourceReview": { "type": "string", "format": "date" },
    "maintenance": {
      "type": "object",
      "required": ["owner", "reviewPolicy", "versioningPolicy"],
      "properties": {
        "owner": { "type": "string", "minLength": 1 },
        "reviewPolicy": { "type": "string", "minLength": 1 },
        "versioningPolicy": { "type": "string", "minLength": 1 }
      },
      "additionalProperties": false
    },
    "scope": { "type": "string", "minLength": 1 },
    "importantQualification": { "type": "string", "minLength": 1 },
    "processingProfiles": {
      "type": "object",
      "minProperties": 1,
      "additionalProperties": {
        "type": "object",
        "required": ["primaryProcessingLocation", "toolSpecificThirdPartyNetworkRequest", "description"],
        "properties": {
          "primaryProcessingLocation": { "type": "string", "minLength": 1 },
          "toolSpecificThirdPartyNetworkRequest": { "type": "boolean" },
          "description": { "type": "string", "minLength": 1 },
          "qualification": { "type": "string" },
          "providerRequestId": { "type": "string" },
          "sameOriginResources": {
            "type": "array",
            "items": { "type": "string", "minLength": 1 },
            "uniqueItems": true
          }
        },
        "allOf": [
          {
            "if": {
              "properties": {
                "toolSpecificThirdPartyNetworkRequest": { "const": true }
              },
              "required": ["toolSpecificThirdPartyNetworkRequest"]
            },
            "then": { "required": ["providerRequestId"] },
            "else": { "not": { "required": ["providerRequestId"] } }
          }
        ],
        "additionalProperties": false
      }
    },
    "toolRoutes": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": ["name", "routes", "profile", "inputTypes"],
        "properties": {
          "name": { "type": "string", "minLength": 1 },
          "routes": {
            "type": "array",
            "minItems": 1,
            "items": { "type": "string", "pattern": "^/en/" },
            "uniqueItems": true
          },
          "profile": { "type": "string", "minLength": 1 },
          "inputTypes": {
            "type": "array",
            "minItems": 1,
            "items": { "type": "string", "minLength": 1 },
            "uniqueItems": true
          },
          "notes": { "type": "string", "minLength": 1 },
          "browserPermissions": {
            "type": "array",
            "items": { "type": "string", "minLength": 1 },
            "uniqueItems": true
          },
          "localStorageKeys": {
            "type": "array",
            "minItems": 1,
            "items": { "type": "string", "minLength": 1 },
            "uniqueItems": true
          }
        },
        "additionalProperties": false
      }
    },
    "providerRequests": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "id",
          "provider",
          "trigger",
          "purpose",
          "applicationFieldsSent",
          "ordinaryNetworkMetadata",
          "documentation"
        ],
        "properties": {
          "id": { "type": "string", "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$" },
          "provider": { "type": "string", "minLength": 1 },
          "endpoint": { "type": "string", "format": "uri" },
          "endpointPattern": { "type": "string", "minLength": 1 },
          "trigger": { "type": "string", "minLength": 1 },
          "purpose": { "type": "string", "minLength": 1 },
          "applicationFieldsSent": {
            "type": "array",
            "items": { "type": "string", "minLength": 1 },
            "uniqueItems": true
          },
          "applicationFieldsNotSent": {
            "type": "array",
            "items": { "type": "string", "minLength": 1 },
            "uniqueItems": true
          },
          "ordinaryNetworkMetadata": { "type": "string", "minLength": 1 },
          "documentation": { "type": "string", "format": "uri" },
          "privacyPolicy": { "type": "string", "format": "uri" }
        },
        "oneOf": [
          {
            "required": ["endpoint"],
            "not": { "required": ["endpointPattern"] }
          },
          {
            "required": ["endpointPattern"],
            "not": { "required": ["endpoint"] }
          }
        ],
        "additionalProperties": false
      }
    },
    "siteWideServices": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "id",
          "provider",
          "service",
          "endpoints",
          "purpose",
          "privacyInformation"
        ],
        "properties": {
          "id": { "type": "string", "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$" },
          "provider": { "type": "string", "minLength": 1 },
          "service": { "type": "string", "minLength": 1 },
          "productionOnly": { "type": "boolean" },
          "measurementId": { "type": "string", "minLength": 1 },
          "endpoints": {
            "type": "array",
            "minItems": 1,
            "items": { "type": "string", "format": "uri" },
            "uniqueItems": true
          },
          "purpose": { "type": "string", "minLength": 1 },
          "explicitEventFieldsAllowlist": {
            "type": "array",
            "items": { "type": "string", "minLength": 1 },
            "uniqueItems": true
          },
          "explicitlySuppressedOrDiscarded": {
            "type": "array",
            "items": { "type": "string", "minLength": 1 },
            "uniqueItems": true
          },
          "configuration": {
            "type": "object",
            "properties": {
              "send_page_view": { "type": "boolean" },
              "allow_google_signals": { "type": "boolean" },
              "allow_ad_personalization_signals": { "type": "boolean" }
            },
            "additionalProperties": false
          },
          "qualification": { "type": "string", "minLength": 1 },
          "applicationFieldsSent": {
            "type": "array",
            "items": { "type": "string", "minLength": 1 },
            "uniqueItems": true
          },
          "applicationFieldsNotSent": {
            "type": "array",
            "items": { "type": "string", "minLength": 1 },
            "uniqueItems": true
          },
          "ordinaryNetworkMetadata": { "type": "string", "minLength": 1 },
          "privacyInformation": { "type": "string", "format": "uri" }
        },
        "additionalProperties": false
      }
    },
    "browserStorage": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": ["scope", "purpose", "mechanism"],
        "properties": {
          "scope": { "type": "string", "minLength": 1 },
          "key": { "type": "string", "minLength": 1 },
          "keys": {
            "type": "array",
            "minItems": 1,
            "items": { "type": "string", "minLength": 1 },
            "uniqueItems": true
          },
          "purpose": { "type": "string", "minLength": 1 },
          "mechanism": { "const": "localStorage" }
        },
        "oneOf": [
          {
            "required": ["key"],
            "not": { "required": ["keys"] }
          },
          {
            "required": ["keys"],
            "not": { "required": ["key"] }
          }
        ],
        "additionalProperties": false
      }
    },
    "accuracyLimitations": {
      "type": "array",
      "minItems": 1,
      "items": { "type": "string", "minLength": 1 },
      "uniqueItems": true
    }
  },
  "additionalProperties": false
}
