{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/samva-dev/json-schema/samva-dev-publish-extension-version-response-schema.json",
  "title": "PublishExtensionVersionResponse",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/samva-dev-extensions-api-openapi.yml#/components/schemas/PublishExtensionVersionResponse",
  "type": "object",
  "properties": {
    "extension": {
      "$ref": "#/$defs/Extension"
    },
    "version": {
      "$ref": "#/$defs/ExtensionVersion"
    }
  },
  "required": [
    "extension",
    "version"
  ],
  "additionalProperties": false,
  "$defs": {
    "Extension": {
      "type": "object",
      "properties": {
        "id": {
          "$ref": "#/$defs/ExtensionId"
        },
        "name": {
          "type": "string"
        },
        "displayName": {
          "type": "string"
        },
        "description": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "runtime": {
          "type": "string",
          "enum": [
            "hosted",
            "webhook"
          ]
        },
        "latestVersion": {
          "$ref": "#/$defs/ExtensionVersionRef"
        },
        "createdAt": {
          "type": "string"
        },
        "updatedAt": {
          "type": "string"
        }
      },
      "required": [
        "id",
        "name",
        "displayName",
        "description",
        "runtime",
        "latestVersion",
        "createdAt",
        "updatedAt"
      ],
      "additionalProperties": false
    },
    "ExtensionBundle": {
      "type": "object",
      "properties": {
        "sha256": {
          "type": "string"
        },
        "sizeBytes": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        }
      },
      "required": [
        "sha256",
        "sizeBytes"
      ],
      "additionalProperties": false
    },
    "ExtensionId": {
      "type": "string",
      "pattern": "^ext_[0-9a-hjkmnp-tv-z]{16,24}$",
      "x-samva-brand": "ExtensionId"
    },
    "ExtensionVersion": {
      "type": "object",
      "properties": {
        "id": {
          "$ref": "#/$defs/ExtensionVersionId"
        },
        "version": {
          "type": "string"
        },
        "runtime": {
          "type": "string",
          "enum": [
            "hosted",
            "webhook"
          ]
        },
        "bundle": {
          "anyOf": [
            {
              "$ref": "#/$defs/ExtensionBundle"
            },
            {
              "type": "null"
            }
          ]
        },
        "publishedAt": {
          "type": "string"
        },
        "manifest": {
          "type": "object",
          "properties": {
            "name": {
              "type": "string",
              "pattern": "^[a-z][a-z0-9-]{1,62}[a-z0-9]$"
            },
            "displayName": {
              "type": "string",
              "minLength": 1,
              "maxLength": 80,
              "x-samva-string-checks": [
                {
                  "id": "effect/schema/isMaxLength",
                  "payload": {
                    "maxLength": 80
                  }
                }
              ]
            },
            "description": {
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 500,
                  "x-samva-string-checks": [
                    {
                      "id": "effect/schema/isMaxLength",
                      "payload": {
                        "maxLength": 500
                      }
                    }
                  ]
                },
                {
                  "type": "null"
                }
              ]
            },
            "version": {
              "type": "string",
              "pattern": "^\\d{1,6}\\.\\d{1,6}\\.\\d{1,6}(?:-[0-9A-Za-z.-]{1,64})?$"
            },
            "runtime": {
              "type": "string",
              "enum": [
                "hosted",
                "webhook"
              ]
            },
            "events": {
              "type": "array",
              "items": {
                "type": "string",
                "enum": [
                  "mailbox.message.received",
                  "mailbox.message.sent",
                  "mailbox.action.pending_approval",
                  "mailbox.action.resolved",
                  "mailbox.message.quarantined",
                  "mailbox.message.released",
                  "mailbox.message.discarded"
                ]
              },
              "minItems": 1
            },
            "permissions": {
              "type": "array",
              "items": {
                "type": "string",
                "enum": [
                  "read",
                  "update",
                  "send",
                  "quarantine.read"
                ]
              }
            }
          },
          "required": [
            "name",
            "displayName",
            "version",
            "runtime",
            "events",
            "permissions"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "id",
        "version",
        "runtime",
        "bundle",
        "publishedAt",
        "manifest"
      ],
      "additionalProperties": false
    },
    "ExtensionVersionId": {
      "type": "string",
      "pattern": "^extver_[0-9a-hjkmnp-tv-z]{16,24}$",
      "x-samva-brand": "ExtensionVersionId"
    },
    "ExtensionVersionRef": {
      "type": "object",
      "properties": {
        "id": {
          "$ref": "#/$defs/ExtensionVersionId"
        },
        "version": {
          "type": "string"
        }
      },
      "required": [
        "id",
        "version"
      ],
      "additionalProperties": false
    }
  }
}