{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/codehooks/refs/heads/main/json-schema/codehooks-queue-job-schema.json",
  "title": "Codehooks Queue Job",
  "description": "A job in the Codehooks asynchronous queue system. Jobs are enqueued to named topics and processed by registered worker functions.",
  "type": "object",
  "properties": {
    "_id": {
      "type": "string",
      "description": "Unique identifier of the enqueued job."
    },
    "topic": {
      "type": "string",
      "description": "The queue topic name the job belongs to."
    },
    "payload": {
      "type": "object",
      "additionalProperties": true,
      "description": "The job payload data to be processed by the worker function."
    },
    "status": {
      "type": "string",
      "enum": ["pending", "processing", "completed", "failed"],
      "description": "The current processing status of the job."
    },
    "createdAt": {
      "type": "string",
      "format": "date-time",
      "description": "Timestamp when the job was enqueued."
    },
    "completedAt": {
      "type": "string",
      "format": "date-time",
      "description": "Timestamp when the job finished processing."
    }
  },
  "required": ["_id", "topic", "payload"],
  "additionalProperties": true,
  "examples": [
    {
      "_id": "job-64a1b2c3d4e5f600",
      "topic": "send-email",
      "payload": {
        "to": "user@example.com",
        "subject": "Welcome",
        "body": "Hello and welcome!"
      },
      "status": "pending",
      "createdAt": "2025-06-01T12:00:00.000Z"
    }
  ]
}
