{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/softsync-ai/json-schema/softsync-ai-portal-definition-schema.json",
  "title": "PortalDefinition",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/softsync-ai-portals-api-openapi.yml#/components/schemas/PortalDefinition",
  "type": "object",
  "properties": {
    "title": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200
    },
    "brand": {
      "allOf": [
        {
          "$ref": "#/$defs/PortalBrand"
        }
      ]
    },
    "contactTableId": {
      "type": "string",
      "minLength": 1,
      "maxLength": 64
    },
    "enabled": {
      "type": "boolean"
    },
    "pages": {
      "minItems": 1,
      "maxItems": 20,
      "type": "array",
      "items": {
        "$ref": "#/$defs/PortalPage"
      }
    },
    "website": {
      "type": [
        "string",
        "null"
      ],
      "maxLength": 500,
      "format": "uri"
    }
  },
  "required": [
    "title",
    "enabled",
    "pages"
  ],
  "$defs": {
    "PortalAction": {
      "type": "object",
      "properties": {
        "label": {
          "type": "string",
          "minLength": 1,
          "maxLength": 60
        },
        "pageKey": {
          "type": "string",
          "maxLength": 40
        },
        "answer": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9_]{0,40}$"
        }
      },
      "required": [
        "label",
        "pageKey",
        "answer"
      ],
      "additionalProperties": false
    },
    "PortalBrand": {
      "type": "object",
      "properties": {
        "display": {
          "$ref": "#/$defs/PortalBrandDisplay"
        },
        "name": {
          "type": "string",
          "maxLength": 120
        },
        "logo": {
          "type": "string",
          "maxLength": 500
        }
      },
      "required": [
        "display"
      ],
      "additionalProperties": false
    },
    "PortalBrandDisplay": {
      "type": "string",
      "enum": [
        "workspace",
        "custom",
        "hidden"
      ]
    },
    "PortalFilter": {
      "type": "object",
      "properties": {
        "fieldId": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64
        },
        "equals": {
          "anyOf": [
            {
              "type": "string",
              "maxLength": 500
            },
            {
              "type": "number"
            },
            {
              "type": "boolean"
            }
          ]
        }
      },
      "required": [
        "fieldId",
        "equals"
      ],
      "additionalProperties": false
    },
    "PortalPage": {
      "type": "object",
      "properties": {
        "key": {
          "type": "string",
          "pattern": "^[a-z0-9][a-z0-9-]{0,39}$"
        },
        "title": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "description": {
          "type": "string",
          "maxLength": 1000
        },
        "kind": {
          "$ref": "#/$defs/PortalPageKind"
        },
        "tableId": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64
        },
        "path": {
          "maxItems": 4,
          "type": "array",
          "items": {
            "$ref": "#/$defs/PortalStep"
          }
        },
        "where": {
          "maxItems": 10,
          "type": "array",
          "items": {
            "$ref": "#/$defs/PortalFilter"
          }
        },
        "groupIds": {
          "maxItems": 20,
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          }
        },
        "fieldIds": {
          "maxItems": 50,
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          }
        },
        "editFieldIds": {
          "maxItems": 50,
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          }
        },
        "uploadFieldIds": {
          "maxItems": 10,
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          }
        },
        "documentTemplateIds": {
          "maxItems": 20,
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          }
        },
        "layout": {
          "allOf": [
            {
              "$ref": "#/$defs/PortalPageLayout"
            }
          ]
        },
        "topicFieldId": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64
        },
        "sort": {
          "type": "object",
          "properties": {
            "fieldId": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            },
            "direction": {
              "$ref": "#/$defs/PortalSortDirection"
            }
          },
          "required": [
            "fieldId",
            "direction"
          ],
          "additionalProperties": false
        },
        "imageFieldId": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64
        },
        "search": {
          "type": "boolean"
        },
        "resourceId": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64
        },
        "action": {
          "allOf": [
            {
              "$ref": "#/$defs/PortalAction"
            }
          ]
        }
      },
      "required": [
        "key",
        "title",
        "kind"
      ],
      "additionalProperties": false
    },
    "PortalPageKind": {
      "type": "string",
      "enum": [
        "records",
        "form",
        "booking"
      ]
    },
    "PortalPageLayout": {
      "type": "string",
      "enum": [
        "list",
        "articles"
      ]
    },
    "PortalSortDirection": {
      "type": "string",
      "enum": [
        "asc",
        "desc"
      ]
    },
    "PortalStep": {
      "type": "object",
      "properties": {
        "fieldId": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64
        },
        "reverse": {
          "type": "boolean"
        },
        "tableId": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64
        }
      },
      "required": [
        "fieldId"
      ],
      "additionalProperties": false
    }
  }
}