{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/eurobase-dev/json-schema/eurobase-dev-source-connection-schema.json",
  "title": "SourceConnection",
  "description": "A GitLab or Forgejo/Gitea repository linked to a workspace (ADR 0120). Never carries the token or the webhook secret.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/eurobase-dev-source-connections-api-openapi.yml#/components/schemas/SourceConnection",
  "type": "object",
  "required": [
    "id",
    "provider",
    "origin",
    "repoPath",
    "defaultBranch",
    "status",
    "credentialScope",
    "credentialExpiresAt",
    "lastDeliveryAt",
    "webhookVerifiedAt",
    "linkedProjectCount"
  ],
  "properties": {
    "id": {
      "type": "string",
      "pattern": "^srcconn_[0-9a-f]{32}$"
    },
    "provider": {
      "type": "string",
      "enum": [
        "gitlab",
        "forgejo"
      ]
    },
    "origin": {
      "type": "string",
      "description": "https origin of the repository host"
    },
    "repoPath": {
      "type": "string"
    },
    "defaultBranch": {
      "type": "string"
    },
    "status": {
      "type": "string",
      "enum": [
        "pending_webhook",
        "active",
        "credential_rejected"
      ],
      "description": "pending_webhook until the first verified push arrives (projects can already bind it); credential_rejected once the provider refused the token."
    },
    "credentialScope": {
      "type": "string",
      "enum": [
        "repository",
        "account"
      ],
      "description": "repository: the token reads only this repository; account: it reads every repository its account can read."
    },
    "credentialExpiresAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "lastDeliveryAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "webhookVerifiedAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "linkedProjectCount": {
      "type": "integer",
      "minimum": 0
    }
  }
}