openapi: 3.1.0
info:
  title: Greg Notion Hook API
  version: 1.0.0
  description: |
    Watches Notion spec pages and emits spec.emitted events to the Ambient 
    Access Layer. Implements Greg charter invariants for reference-only emission.
  contact:
    name: Kovach Enterprises
    email: igor@kovachenterprises.com
servers:
  - url: https://gc-greg-hook.iholt.workers.dev
    description: Production
paths:
  /webhook:
    post:
      operationId: handleWebhook
      summary: Receive Notion webhook
      description: Process page update notification with debounce
      security:
        - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NotionWebhook'
      responses:
        '200':
          description: Webhook processed or debounced
  /poll:
    get:
      operationId: pollPages
      summary: Poll all tracked pages
      description: Manually trigger a poll of all 10 tracked Notion pages
      security:
        - bearerAuth: []
      responses:
        '200':
          description: Poll results
  /pages:
    get:
      operationId: listPages
      summary: List tracked Notion pages
      responses:
        '200':
          description: List of tracked page URLs
  /health:
    get:
      operationId: healthCheck
      summary: Health check
      responses:
        '200':
          description: Service healthy
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
  schemas:
    NotionWebhook:
      type: object
      properties:
        page_id:
          type: string
        revision_id:
          type: string
        timestamp:
          type: string
          format: date-time
