{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://owlie.com/docs/schemas/connectors/pack.schema.json",
  "title": "Owlie connector pack (format 1)",
  "description": "One major version of a connector as one JSON value (format 1): the form a connector is imported and exported in. Beyond this schema a pack is refused when its manifest exceeds 512 KiB (524288 bytes) of JSON, or any file path or manifest key is __proto__, constructor or prototype.",
  "type": "object",
  "required": ["format", "connector", "manifest", "files"],
  "properties": {
    "format": {
      "type": "number",
      "const": 1
    },
    "connector": {
      "type": "object",
      "required": ["key", "version", "name", "sdk", "kind"],
      "properties": {
        "key": {
          "type": "string",
          "minLength": 1,
          "pattern": "^[a-z0-9][a-z0-9_-]*$"
        },
        "version": {
          "type": "integer",
          "minimum": 1
        },
        "name": {
          "type": "string",
          "minLength": 1
        },
        "sdk": {
          "type": "string",
          "minLength": 1
        },
        "kind": {
          "anyOf": [
            {
              "type": "string",
              "const": "http"
            },
            {
              "type": "string",
              "const": "scim"
            },
            {
              "type": "string",
              "const": "ldap"
            },
            {
              "type": "string",
              "const": "sql"
            },
            {
              "type": "string",
              "const": "flat-file"
            }
          ]
        }
      },
      "additionalProperties": false
    },
    "manifest": {
      "description": "The connector's manifest, exactly as manifest.json holds it. Its key, version and name must equal connector's, and its kind (absent means http) must equal connector.kind.",
      "allOf": [
        {
          "$ref": "https://owlie.com/docs/schemas/connectors/manifest.schema.json"
        }
      ]
    },
    "files": {
      "type": "object",
      "patternProperties": {
        "^.*$": {
          "type": "string"
        }
      },
      "description": "The connector's source files by path, relative to the connector directory. Allowed roots: README.md, CHANGELOG.md, definition.json, handlers/, lib/, fixtures/, scripts/. Extensions: .ts, .json, .md, .ps1. Paths use forward slashes, have no empty, \".\" or \"..\" segment and no segment starting with __owlie_, and are never *.test.ts. PowerShell lives only at scripts/<name>.ps1, and scripts/ holds nothing else. A file under handlers/ is a canonical handler module: handlers/<entity>/<method>.ts, handlers/<entity>/op/<name>.ts, handlers/grants/<grant kind>/<add|remove>.ts, handlers/connection/<op>.ts or handlers/notification/send.ts. An ldap, scim, sql or flat-file connector carries definition.json, and its manifest must be exactly what its engine derives from it; an http connector carries none. Caps: at most 512 files, 512 KiB (524288 bytes) per file and 4 MiB (4194304 bytes) in total, measured in UTF-8.",
      "maxProperties": 512
    },
    "provenance": {
      "type": "object",
      "properties": {
        "source": {
          "type": "string"
        },
        "revision": {
          "type": "string"
        },
        "exported_at": {
          "type": "string"
        }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false
}
