{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.cuddler.dev/standards/artifact-definitions/cuddler-page-ux-schema/1.0.0/data.schema.json",
  "title": "Cuddler Page UX Data Schema",
  "type": "object",
  "for-ai": [
    {
      "instruction": "Create a Cuddler Page UX document that inventories one or more page definitions with their routes, visible component trees, available actions, assets, references, and annotations.",
      "input": "",
      "output": "Use this schema to generate or validate page UX inventory documents for Portal page restoration and review workflows."
    }
  ],
  "additionalProperties": false,
  "required": [
    "$schema",
    "Meta",
    "Content",
    "Assets",
    "References",
    "Annotations"
  ],
  "properties": {
    "$schema": {
      "type": "string",
      "const": "https://www.cuddler.dev/standards/artifact-definitions/cuddler-page-ux-schema/1.0.0/data.schema.json"
    },
    "Meta": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "DocumentId",
        "DocumentTypeId",
        "SchemaVersion",
        "Title",
        "CreatedAt",
        "UpdatedAt",
        "Authors",
        "ArtifactSpecificationVersion",
        "ArtifactSpecificationUrl",
        "GoverningDocumentRoleUrl",
        "SourceUrl",
        "Status"
      ],
      "properties": {
        "DocumentId": {
          "type": "string",
          "minLength": 1
        },
        "DocumentTypeId": {
          "type": "string",
          "const": "cuddler-page-ux-schema"
        },
        "SchemaVersion": {
          "type": "string",
          "const": "1.0.0"
        },
        "Title": {
          "type": "string",
          "minLength": 1
        },
        "CreatedAt": {
          "type": "string",
          "minLength": 1
        },
        "UpdatedAt": {
          "type": "string",
          "minLength": 1
        },
        "Authors": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "Id",
              "Name"
            ],
            "properties": {
              "Id": {
                "type": "string",
                "minLength": 1
              },
              "Name": {
                "type": "string",
                "minLength": 1
              },
              "Email": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          }
        },
        "ArtifactSpecificationVersion": {
          "type": "string",
          "const": "1.0.0"
        },
        "ArtifactSpecificationUrl": {
          "type": "string",
          "const": "https://www.cuddler.dev/standards/artifact-specification/"
        },
        "GoverningDocumentRoleUrl": {
          "type": "string",
          "const": "https://www.cuddler.dev/standards/document-role/data/"
        },
        "SourceUrl": {
          "type": "string",
          "minLength": 1
        },
        "Status": {
          "type": "string",
          "const": "active"
        }
      }
    },
    "Content": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "Pages"
      ],
      "properties": {
        "Pages": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "Id",
              "Kind",
              "Title",
              "Routes",
              "Components",
              "Actions"
            ],
            "properties": {
              "Id": {
                "type": "string",
                "minLength": 1
              },
              "Kind": {
                "type": "string",
                "enum": [
                  "Redirect",
                  "Workspace",
                  "Collection",
                  "Record",
                  "ActionFlow"
                ]
              },
              "Title": {
                "type": "string",
                "minLength": 1
              },
              "Routes": {
                "type": "array",
                "minItems": 1,
                "items": {
                  "$ref": "#/$defs/route"
                }
              },
              "Components": {
                "type": "array",
                "minItems": 1,
                "items": {
                  "$ref": "#/$defs/component"
                }
              },
              "Actions": {
                "type": "array",
                "items": {
                  "$ref": "#/$defs/action"
                }
              },
              "DataBinding": {
                "oneOf": [
                  {
                    "$ref": "#/$defs/dataBinding"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "Summary": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "RedirectTo": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          }
        }
      }
    },
    "Assets": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "Files"
      ],
      "properties": {
        "Files": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/assetFile"
          }
        }
      }
    },
    "References": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/reference"
      }
    },
    "Annotations": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/annotation"
      }
    }
  },
  "$defs": {
    "nonEmptyString": {
      "type": "string",
      "minLength": 1
    },
    "route": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "Template"
      ],
      "properties": {
        "Template": {
          "$ref": "#/$defs/nonEmptyString"
        }
      }
    },
    "action": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "Id",
        "Label",
        "Kind"
      ],
      "properties": {
        "Id": {
          "$ref": "#/$defs/nonEmptyString"
        },
        "Label": {
          "$ref": "#/$defs/nonEmptyString"
        },
        "Kind": {
          "$ref": "#/$defs/nonEmptyString"
        },
        "TargetRoute": {
          "type": [
            "string",
            "null"
          ],
          "minLength": 1
        },
        "Permission": {
          "type": [
            "string",
            "null"
          ],
          "minLength": 1
        },
        "RequiresConfirmation": {
          "type": "boolean"
        }
      }
    },
    "dataBinding": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "Source"
      ],
      "properties": {
        "Source": {
          "$ref": "#/$defs/nonEmptyString"
        },
        "Entity": {
          "type": [
            "string",
            "null"
          ],
          "minLength": 1
        },
        "Parameters": {
          "type": [
            "object",
            "null"
          ],
          "additionalProperties": {
            "type": "string"
          }
        }
      }
    },
    "assetFile": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "Path",
        "ContentType",
        "Role"
      ],
      "properties": {
        "Path": {
          "$ref": "#/$defs/nonEmptyString"
        },
        "ContentType": {
          "$ref": "#/$defs/nonEmptyString"
        },
        "Role": {
          "$ref": "#/$defs/nonEmptyString"
        }
      }
    },
    "reference": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "Rel",
        "Target"
      ],
      "properties": {
        "Rel": {
          "$ref": "#/$defs/nonEmptyString"
        },
        "Target": {
          "$ref": "#/$defs/nonEmptyString"
        }
      }
    },
    "annotation": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "Name",
        "Value"
      ],
      "properties": {
        "Name": {
          "$ref": "#/$defs/nonEmptyString"
        },
        "Value": {
          "$ref": "#/$defs/nonEmptyString"
        }
      }
    },
    "component": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "ComponentId",
        "ReadOnly",
        "Region",
        "Properties",
        "Children"
      ],
      "properties": {
        "ComponentId": {
          "type": "string",
          "format": "uuid"
        },
        "Region": {
          "type": "string",
          "minLength": 1
        },
        "Properties": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          }
        },
        "Children": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/component"
          }
        },
        "ReadOnly": {
          "type": "boolean"
        }
      }
    }
  }
}
