openapi: 3.0.3
info:
  title: EpisodeOps REST API
  version: "1.0.0"
  description: |
    Personal-token authenticated API for episodes and assets.
    Create tokens in **Settings → API tokens** (`/app/settings/api-tokens`).
servers:
  - url: https://YOUR_PROJECT_REF.supabase.co/functions/v1
    description: |
      Replace YOUR_PROJECT_REF with your Supabase project ref (Dashboard → Settings → API → Project URL).
      Edge functions live under `/functions/v1` (e.g. `api-v1-episodes`).
paths:
  /api-v1-episodes:
    get:
      summary: List episodes
      operationId: listEpisodes
      security:
        - bearerAuth: []
      responses:
        "200":
          description: Paginated list of episodes for the token owner
          content:
            application/json:
              schema:
                type: object
                properties:
                  episodes:
                    type: array
                    items:
                      $ref: "#/components/schemas/EpisodeSummary"
        "401":
          description: Missing or invalid token
  /api-v1-episodes/{episodeId}:
    get:
      summary: Get episode with assets
      operationId: getEpisode
      security:
        - bearerAuth: []
      parameters:
        - name: episodeId
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        "200":
          description: Episode detail
          content:
            application/json:
              schema:
                type: object
                properties:
                  episode:
                    $ref: "#/components/schemas/EpisodeDetail"
        "404":
          description: Not found
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: Personal Access Token
  schemas:
    EpisodeSummary:
      type: object
      properties:
        id:
          type: string
          format: uuid
        title:
          type: string
        status:
          type: string
        duration_seconds:
          type: integer
          nullable: true
        created_at:
          type: string
          format: date-time
    EpisodeDetail:
      type: object
      properties:
        id:
          type: string
        title:
          type: string
        status:
          type: string
        duration_seconds:
          type: integer
          nullable: true
        created_at:
          type: string
        assets:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
              type:
                type: string
              content_text:
                type: string
                nullable: true
              content_json:
                nullable: true
