{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/cavuno-com/json-schema/cavuno-com-operation-resource-schema.json",
  "title": "OperationResource",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/cavuno-com-blog-authors-api-openapi.yml#/components/schemas/OperationResource",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "description": "Unique identifier for the object."
    },
    "object": {
      "type": "string",
      "enum": [
        "operation"
      ],
      "description": "String representing the object's type. Objects of the same type share the same value."
    },
    "kind": {
      "type": "string",
      "enum": [
        "domains.verify",
        "imports.parse",
        "imports.confirm",
        "subscribers.export",
        "subscribers.import",
        "custom_objects.records_import",
        "exports.generate",
        "candidates.remove",
        "employers.remove"
      ],
      "description": "Operation kind, identifying which workflow the operation runs."
    },
    "state": {
      "type": "string",
      "enum": [
        "pending",
        "running",
        "succeeded",
        "failed",
        "cancelled"
      ],
      "description": "Current state of the operation."
    },
    "progress": {
      "$ref": "#/$defs/OperationProgress"
    },
    "result": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "totalRows": {
          "type": "number"
        },
        "created": {
          "type": "number"
        },
        "updated": {
          "type": "number"
        },
        "failed": {
          "type": "number"
        },
        "errors": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "rowIndex": {
                "type": "number"
              },
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "rowIndex",
              "code",
              "message"
            ]
          }
        }
      },
      "required": [
        "totalRows",
        "created",
        "updated",
        "failed",
        "errors"
      ],
      "description": "A safe workflow result summary when the operation kind publishes one."
    },
    "error": {
      "$ref": "#/$defs/OperationErrorEnvelope"
    },
    "createdAt": {
      "type": "string",
      "description": "Time at which the operation was created. ISO 8601 datetime."
    },
    "updatedAt": {
      "type": "string",
      "description": "Time at which the operation was last updated. ISO 8601 datetime."
    },
    "completedAt": {
      "type": [
        "string",
        "null"
      ],
      "description": "Time at which the operation reached a terminal state, or `null` if it has not yet completed. ISO 8601 datetime."
    },
    "cancelRequested": {
      "type": "boolean",
      "description": "Whether cancellation of the operation has been requested."
    },
    "resource": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "object": {
          "type": "string",
          "enum": [
            "company",
            "domain",
            "import",
            "employer",
            "candidate",
            "custom_object_type"
          ]
        },
        "id": {
          "type": "string"
        }
      },
      "required": [
        "object",
        "id"
      ],
      "description": "Stable product resource affected by the operation, or `null` when no public resource applies."
    }
  },
  "required": [
    "id",
    "object",
    "kind",
    "state",
    "progress",
    "error",
    "createdAt",
    "updatedAt",
    "completedAt",
    "cancelRequested",
    "resource"
  ],
  "$defs": {
    "OperationErrorEnvelope": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "code": {
          "type": "string",
          "description": "Machine-readable error code."
        },
        "message": {
          "type": "string",
          "description": "Human-readable error message."
        }
      },
      "required": [
        "code",
        "message"
      ],
      "description": "Error envelope, populated once the operation reaches `failed`. `null` otherwise."
    },
    "OperationProgress": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "percent": {
          "type": "number",
          "description": "Progress as a percentage between 0 and 100, when the operation reports a percentage."
        },
        "message": {
          "type": "string",
          "description": "Human-readable progress message, when available."
        },
        "processed": {
          "type": "number",
          "description": "Number of items processed so far, when applicable."
        },
        "total": {
          "type": "number",
          "description": "Total number of items to process, when known."
        }
      },
      "description": "Snapshot of the operation's progress, or `null` if the operation does not report progress."
    }
  }
}