{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "contract": {
      "type": "string",
      "const": "PageDefinition"
    },
    "pageId": {
      "type": "string",
      "minLength": 1,
      "maxLength": 256
    },
    "ownerRepo": {
      "type": "string",
      "minLength": 1,
      "maxLength": 256
    },
    "title": {
      "anyOf": [
        {
          "type": "string",
          "minLength": 1
        },
        {
          "type": "object",
          "propertyNames": {
            "type": "string",
            "pattern": "^[a-z]{2,3}(?:-[A-Z][a-z]{3})?(?:-[A-Z]{2}|-\\d{3})?$"
          },
          "additionalProperties": {
            "type": "string",
            "minLength": 1
          }
        }
      ]
    },
    "pageType": {
      "type": "string",
      "enum": [
        "page",
        "workspace",
        "view",
        "record",
        "action",
        "overlay",
        "agent",
        "process",
        "log",
        "chat",
        "preview",
        "api",
        "enhanced",
        "agent-chat",
        "agent-config",
        "agent-log",
        "design-board",
        "global-design-board",
        "iframe"
      ]
    },
    "ownership": {
      "type": "object",
      "properties": {
        "teamId": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        },
        "creatorRef": {
          "type": "object",
          "properties": {
            "kind": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "version": {
              "anyOf": [
                {
                  "type": "integer",
                  "exclusiveMinimum": 0,
                  "maximum": 9007199254740991
                },
                {
                  "type": "string",
                  "minLength": 1
                }
              ]
            },
            "ownerRepo": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            }
          },
          "required": [
            "kind",
            "id"
          ],
          "additionalProperties": false
        },
        "studioId": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        },
        "builtIn": {
          "type": "boolean"
        }
      },
      "required": [
        "builtIn"
      ],
      "additionalProperties": false
    },
    "record": {
      "type": "object",
      "properties": {
        "createdTimestamp": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "updatedTimestamp": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "deleted": {
          "default": false,
          "type": "boolean"
        }
      },
      "required": [
        "deleted"
      ],
      "additionalProperties": false
    },
    "surface": {
      "type": "string",
      "enum": [
        "page",
        "workspace",
        "view",
        "record",
        "action",
        "overlay",
        "agent"
      ]
    },
    "routeId": {
      "type": "string",
      "minLength": 1,
      "maxLength": 256
    },
    "routePath": {
      "type": "string",
      "pattern": "^\\/(?!\\/)"
    },
    "legacyRoutePolicy": {
      "type": "object",
      "properties": {
        "contract": {
          "type": "string",
          "const": "LegacyRoutePolicy"
        },
        "schemaVersion": {
          "type": "number",
          "const": 1
        },
        "fallback": {
          "type": "string",
          "enum": [
            "allowed",
            "forbidden"
          ]
        },
        "restoration": {
          "type": "string",
          "enum": [
            "allowed",
            "forbidden"
          ]
        }
      },
      "required": [
        "contract",
        "schemaVersion",
        "fallback",
        "restoration"
      ],
      "additionalProperties": false
    },
    "rendererKey": {
      "type": "string",
      "minLength": 1,
      "maxLength": 256
    },
    "capabilityRef": {
      "type": "object",
      "properties": {
        "kind": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        },
        "id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        },
        "version": {
          "anyOf": [
            {
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 9007199254740991
            },
            {
              "type": "string",
              "minLength": 1
            }
          ]
        },
        "ownerRepo": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        }
      },
      "required": [
        "kind",
        "id"
      ],
      "additionalProperties": false
    },
    "capabilityRefs": {
      "default": [],
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "kind": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256
          },
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256
          },
          "version": {
            "anyOf": [
              {
                "type": "integer",
                "exclusiveMinimum": 0,
                "maximum": 9007199254740991
              },
              {
                "type": "string",
                "minLength": 1
              }
            ]
          },
          "ownerRepo": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256
          }
        },
        "required": [
          "kind",
          "id"
        ],
        "additionalProperties": false
      }
    },
    "workflowRef": {
      "type": "object",
      "properties": {
        "kind": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        },
        "id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        },
        "version": {
          "anyOf": [
            {
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 9007199254740991
            },
            {
              "type": "string",
              "minLength": 1
            }
          ]
        },
        "ownerRepo": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        }
      },
      "required": [
        "kind",
        "id"
      ],
      "additionalProperties": false
    },
    "binding": {
      "type": "object",
      "properties": {
        "sourceRef": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        },
        "ontologyId": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        },
        "projectionRef": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        },
        "stateRef": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        }
      },
      "additionalProperties": false
    },
    "access": {
      "type": "object",
      "properties": {
        "actions": {
          "default": [],
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "read",
              "write",
              "execute",
              "manage-permissions"
            ]
          }
        }
      },
      "required": [
        "actions"
      ],
      "additionalProperties": false
    },
    "input": {
      "type": "object",
      "properties": {
        "schemaRef": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        }
      },
      "required": [
        "schemaRef"
      ],
      "additionalProperties": false
    },
    "rendererConfig": {
      "type": "object",
      "properties": {
        "schemaRef": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        },
        "value": {
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {
            "$ref": "#/$defs/__schema0"
          }
        }
      },
      "required": [
        "schemaRef",
        "value"
      ],
      "additionalProperties": false
    },
    "navigation": {
      "type": "object",
      "properties": {
        "label": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1
            },
            {
              "type": "object",
              "propertyNames": {
                "type": "string",
                "pattern": "^[a-z]{2,3}(?:-[A-Z][a-z]{3})?(?:-[A-Z]{2}|-\\d{3})?$"
              },
              "additionalProperties": {
                "type": "string",
                "minLength": 1
              }
            }
          ]
        },
        "iconRef": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        },
        "parentPageId": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        },
        "order": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        },
        "hidden": {
          "default": false,
          "type": "boolean"
        },
        "pinned": {
          "default": false,
          "type": "boolean"
        }
      },
      "required": [
        "label",
        "hidden",
        "pinned"
      ],
      "additionalProperties": false
    },
    "visibility": {
      "type": "object",
      "properties": {
        "authenticated": {
          "default": true,
          "type": "boolean"
        },
        "permissionAllOf": {
          "default": [],
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256
          }
        },
        "permissionAnyOf": {
          "default": [],
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256
          }
        },
        "featureFlags": {
          "default": [],
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256
          }
        },
        "productContexts": {
          "minItems": 1,
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "studio",
              "kernel"
            ]
          }
        }
      },
      "required": [
        "authenticated",
        "permissionAllOf",
        "permissionAnyOf",
        "featureFlags",
        "productContexts"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "contract",
    "pageId",
    "ownerRepo",
    "title",
    "pageType",
    "ownership",
    "record",
    "surface",
    "routeId",
    "routePath",
    "rendererKey",
    "capabilityRef",
    "capabilityRefs",
    "binding",
    "access",
    "rendererConfig",
    "navigation",
    "visibility"
  ],
  "additionalProperties": false,
  "$defs": {
    "__schema0": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "number"
        },
        {
          "type": "boolean"
        },
        {
          "type": "null"
        },
        {
          "type": "array",
          "items": {
            "$ref": "#/$defs/__schema0"
          }
        },
        {
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {
            "$ref": "#/$defs/__schema0"
          }
        }
      ]
    }
  },
  "$id": "https://schemas.infmonkeys.com/contracts/page-definition.schema.json",
  "title": "page-definition"
}
