{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/softsync-ai/json-schema/softsync-ai-formula-check-result-schema.json",
  "title": "FormulaCheckResult",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/softsync-ai-objects-api-openapi.yml#/components/schemas/FormulaCheckResult",
  "type": "object",
  "properties": {
    "stored": {
      "type": "string",
      "description": "The formula with references by id, as saved"
    },
    "display": {
      "type": "string",
      "description": "The formula with references by name"
    },
    "resultType": {
      "type": "string",
      "description": "number, text, date, boolean… or list:<type>"
    },
    "diagnostics": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/FormulaDiagnosticDto"
      }
    },
    "samples": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/FormulaSampleDto"
      }
    },
    "hidden": {
      "type": "boolean",
      "description": "True when the formula reads fields you may not see, so no values are shown"
    }
  },
  "required": [
    "stored",
    "display",
    "resultType",
    "diagnostics",
    "samples",
    "hidden"
  ],
  "$defs": {
    "FormulaDiagnosticDto": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string",
          "description": "FORMULA_SYNTAX, FORMULA_UNKNOWN_REF, …"
        },
        "severity": {
          "type": "string",
          "enum": [
            "error",
            "warning",
            "info"
          ]
        },
        "message": {
          "type": "string",
          "description": "English fallback; clients translate by code"
        },
        "params": {
          "type": "object",
          "additionalProperties": true
        }
      },
      "required": [
        "code",
        "severity",
        "message"
      ]
    },
    "FormulaSampleDto": {
      "type": "object",
      "properties": {
        "record": {
          "$ref": "#/$defs/RecordDataDto"
        },
        "value": {
          "type": [
            "object",
            "null"
          ],
          "description": "The value the field would store"
        }
      },
      "required": [
        "record",
        "value"
      ]
    },
    "RecordDataBasicDto": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "data": {
          "type": "object",
          "description": "Raw data keyed by field ID"
        },
        "metadata": {
          "$ref": "#/$defs/RecordMetadata"
        },
        "createdAt": {
          "format": "date-time",
          "type": "string"
        },
        "updatedAt": {
          "format": "date-time",
          "type": "string"
        },
        "lastInteractionAt": {
          "type": [
            "object",
            "null"
          ]
        },
        "lastSentAt": {
          "type": [
            "object",
            "null"
          ],
          "description": "When we last wrote to them, on any channel"
        },
        "lastReceivedAt": {
          "type": [
            "object",
            "null"
          ],
          "description": "When they last wrote to us, on any channel"
        },
        "isDeleted": {
          "type": "boolean",
          "default": false
        },
        "table": {
          "type": "string"
        },
        "workspace": {
          "type": "string"
        },
        "createdBy": {
          "type": "string"
        }
      },
      "required": [
        "id",
        "data",
        "createdAt",
        "updatedAt",
        "table",
        "workspace"
      ]
    },
    "RecordDataDto": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "data": {
          "type": "object",
          "description": "Raw data keyed by field ID"
        },
        "metadata": {
          "$ref": "#/$defs/RecordMetadata"
        },
        "createdAt": {
          "format": "date-time",
          "type": "string"
        },
        "updatedAt": {
          "format": "date-time",
          "type": "string"
        },
        "lastInteractionAt": {
          "type": [
            "object",
            "null"
          ]
        },
        "lastSentAt": {
          "type": [
            "object",
            "null"
          ],
          "description": "When we last wrote to them, on any channel"
        },
        "lastReceivedAt": {
          "type": [
            "object",
            "null"
          ],
          "description": "When they last wrote to us, on any channel"
        },
        "isDeleted": {
          "type": "boolean",
          "default": false
        },
        "tableId": {
          "type": "string"
        },
        "workspaceId": {
          "type": "string",
          "description": "The organization the record is in. Set only when searching across organizations."
        },
        "groupIds": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "relations": {
          "type": "object",
          "description": "Populated relations - map of field ID to related records",
          "additionalProperties": {
            "type": "array",
            "items": {
              "$ref": "#/$defs/RelatedRecordDto"
            }
          }
        },
        "users": {
          "type": "object",
          "description": "Populated users - map of field ID to user info",
          "additionalProperties": {
            "type": "array",
            "items": {
              "$ref": "#/$defs/UserInfoDto"
            }
          }
        },
        "createdBy": {
          "$ref": "#/$defs/UserInfoDto"
        }
      },
      "required": [
        "id",
        "data",
        "createdAt",
        "updatedAt",
        "tableId",
        "groupIds"
      ]
    },
    "RecordMetadata": {
      "type": "object",
      "properties": {
        "viewOrders": {
          "type": "object",
          "additionalProperties": {
            "type": "number"
          },
          "description": "Orders in different views (viewId -> order)"
        },
        "avatarUrl": {
          "type": "string",
          "description": "Avatar file path stored in record metadata"
        },
        "formulaOverrides": {
          "description": "Calculated-default fields a person typed over; they are no longer recalculated",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "ruleIssues": {
          "type": "array",
          "items": {
            "type": "object"
          },
          "description": "Rules this record breaks, saved by a change that may not be refused (e.g. a public booking). Cleared by the next save that passes."
        },
        "source": {
          "type": "object",
          "additionalProperties": true,
          "description": "The feature that made this record when no person did (a booking page, a form…)"
        }
      }
    },
    "RelatedRecordDto": {
      "type": "object",
      "properties": {
        "tableId": {
          "type": "string"
        },
        "record": {
          "description": "Basic record data",
          "allOf": [
            {
              "$ref": "#/$defs/RecordDataBasicDto"
            }
          ]
        }
      },
      "required": [
        "tableId",
        "record"
      ]
    },
    "UserInfoDto": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "email": {
          "type": "string"
        },
        "firstName": {
          "type": "string"
        },
        "lastName": {
          "type": "string"
        },
        "avatarUrl": {
          "type": "string"
        }
      },
      "required": [
        "id",
        "email"
      ]
    }
  }
}