{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://catalog.lintel.tools/schemas/schemastore/utam-page-object/versions/current.json",
  "title": "UI Test Automation Model Page Object",
  "x-lintel": {
    "source": "https://www.schemastore.org/utam-page-object.json",
    "sourceSha256": "bd48d1bd8edc73c20876d1e7e71d4d0703686d0d8780af14d52944ee8e8e8401",
    "fileMatch": [
      "*.utam.json",
      ".utam.json"
    ],
    "parsers": [
      "json"
    ]
  },
  "type": "object",
  "properties": {
    "interface": {
      "type": "boolean"
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "interface": {
            "const": false
          }
        }
      },
      "then": {
        "$ref": "#/$defs/pageObject"
      }
    },
    {
      "if": {
        "properties": {
          "interface": {
            "const": true
          }
        },
        "required": [
          "interface"
        ],
        "type": "object"
      },
      "then": {
        "$ref": "#/$defs/pageObjectInterface"
      }
    }
  ],
  "$defs": {
    "pageObject": {
      "type": "object",
      "dependentRequired": {
        "selector": [
          "root"
        ],
        "root": [
          "selector"
        ],
        "profile": [
          "implements"
        ]
      },
      "title": "Page Object",
      "description": "An object representing a page or a UI element in a web page",
      "properties": {
        "description": {
          "$ref": "#/$defs/rootDescription"
        },
        "root": {
          "$ref": "#/$defs/root"
        },
        "selector": {
          "$ref": "#/$defs/selector"
        },
        "exposeRootElement": {
          "$ref": "#/$defs/exposeRootElement"
        },
        "type": {
          "$ref": "#/$defs/type"
        },
        "implements": {
          "description": "reference to the interface implemented by the page object",
          "type": "string"
        },
        "profile": {
          "title": "Page Object Profile",
          "description": "list of profiles that can use this page object implementation.",
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": {
              "type": "array",
              "contains": {
                "type": "string"
              }
            }
          }
        },
        "platform": {
          "title": "Page Object Platform",
          "description": "Declares the page context type (WebView or native).",
          "enum": [
            "web",
            "native"
          ],
          "default": "web"
        },
        "beforeLoad": {
          "title": "Preload Criteria",
          "description": "The beforeLoad array sets the criteria to be satisfied before the load method completes. If you don't specify a beforeLoad array, the load method finds a root element for a regular page object, or waits for the root element to be present for a root page object), by default.",
          "type": [
            "array"
          ],
          "items": {
            "allOf": [
              {
                "$ref": "#/$defs/predicateStatement"
              },
              {
                "properties": {
                  "element": {
                    "type": "string",
                    "enum": [
                      "document",
                      "root",
                      "navigation"
                    ]
                  }
                }
              }
            ]
          }
        },
        "elements": {
          "$ref": "#/$defs/elementsArray"
        },
        "methods": {
          "title": "Methods",
          "description": "An array of methods performing actions on this page object's elements.",
          "type": "array",
          "items": {
            "$ref": "#/$defs/composeMethod"
          }
        },
        "shadow": {
          "title": "Shadow Boundary",
          "description": "A shadow boundary at the root of the page object.",
          "type": "object",
          "properties": {
            "elements": {
              "$ref": "#/$defs/elementsArray"
            }
          },
          "default": {
            "elements": []
          }
        },
        "metadata": {
          "$ref": "#/$defs/metadata"
        }
      },
      "additionalProperties": false
    },
    "pageObjectInterface": {
      "type": "object",
      "properties": {
        "interface": {
          "description": "Indicates that this page object describes an interface.",
          "type": "boolean",
          "default": false
        },
        "root": {
          "$ref": "#/$defs/root"
        },
        "exposeRootElement": {
          "$ref": "#/$defs/exposeRootElement"
        },
        "type": {
          "$ref": "#/$defs/type"
        },
        "methods": {
          "title": "Interface Methods",
          "description": "An array of method declarations that page objects implementing this interface must define.",
          "type": "array",
          "items": {
            "$ref": "#/$defs/interfaceMethod"
          }
        },
        "description": {
          "$ref": "#/$defs/rootDescription"
        },
        "metadata": {
          "$ref": "#/$defs/metadata"
        }
      },
      "title": "Page Object Interface",
      "description": "An interface to abstract page object APIs for page objects with similar structure and function.",
      "additionalProperties": false
    },
    "element": {
      "title": "Element",
      "description": "An interface to abstract page object APIs for page objects with similar structure and function.",
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "type": {
          "type": [
            "string",
            "array"
          ],
          "prefixItems": [
            {
              "enum": [
                "actionable",
                "clickable",
                "editable",
                "draggable",
                "touchable"
              ]
            }
          ]
        },
        "selector": {
          "$ref": "#/$defs/selector"
        },
        "nullable": {
          "type": "boolean"
        },
        "shadow": {
          "type": "object",
          "properties": {
            "elements": {
              "$ref": "#/$defs/elementsArray"
            }
          }
        },
        "elements": {
          "$ref": "#/$defs/elementsArray"
        },
        "public": {
          "type": "boolean"
        },
        "filter": {
          "$ref": "#/$defs/filter"
        },
        "description": {
          "$ref": "#/$defs/methodDescription"
        },
        "wait": {
          "type": "boolean",
          "default": true
        },
        "load": {
          "type": "boolean",
          "default": true
        }
      },
      "required": [
        "name"
      ],
      "additionalProperties": false
    },
    "elementsArray": {
      "title": "Elements",
      "description": "A nested tree of element objects.",
      "type": "array",
      "items": {
        "$ref": "#/$defs/element"
      }
    },
    "selector": {
      "$defs": {
        "args": {
          "description": "Parameters to the methods that access this element or its nested elements.",
          "type": "array",
          "items": {
            "$ref": "#/$defs/arg"
          }
        },
        "returnAll": {
          "description": "Returns a list of elements",
          "type": "boolean",
          "default": true
        }
      },
      "title": "Selector",
      "description": "An object that locates an element or a list of elements at run time.",
      "type": "object",
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "css": {
              "description": "Standard CSS selector.",
              "type": "string"
            },
            "args": {
              "$ref": "#/$defs/selector/$defs/args"
            },
            "returnAll": {
              "$ref": "#/$defs/selector/$defs/returnAll"
            }
          },
          "required": [
            "css"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "accessid": {
              "description": "Accessibility ID selector, a unique identifier for a UI element for Mobile Platform only.",
              "type": "string"
            },
            "args": {
              "$ref": "#/$defs/selector/$defs/args"
            },
            "returnAll": {
              "$ref": "#/$defs/selector/$defs/returnAll"
            }
          },
          "required": [
            "accessid"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "classchain": {
              "description": "Class chain selector, a unique identifier for a window element from the root of the page for iOS platform only.",
              "type": "string"
            },
            "args": {
              "$ref": "#/$defs/selector/$defs/args"
            },
            "returnAll": {
              "$ref": "#/$defs/selector/$defs/returnAll"
            }
          },
          "required": [
            "classchain"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "uiautomator": {
              "description": "A UIAutomator selector to enable search through UiSelectors for Android platform only",
              "type": "string"
            },
            "args": {
              "$ref": "#/$defs/selector/$defs/args"
            },
            "returnAll": {
              "$ref": "#/$defs/selector/$defs/returnAll"
            }
          },
          "required": [
            "uiautomator"
          ],
          "additionalProperties": false
        }
      ]
    },
    "pageObjectType": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "description": "URI-like type value of the page object"
        }
      },
      "required": [
        "type"
      ],
      "additionalProperties": false
    },
    "filter": {
      "type": "object",
      "properties": {
        "args": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/arg"
          }
        },
        "apply": {
          "type": "string"
        },
        "matcher": {
          "$ref": "#/$defs/matcher"
        },
        "findFirst": {
          "description": "Return only the first match result.",
          "type": "boolean",
          "default": true
        }
      },
      "additionalProperties": false
    },
    "matcher": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "isTrue",
            "isFalse",
            "notNull",
            "stringContains",
            "stringEquals"
          ]
        },
        "args": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/arg"
          }
        }
      },
      "additionalProperties": false
    },
    "interfaceMethod": {
      "title": "Interface Method",
      "description": "A declarative, interface method definition.",
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "args": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/arg"
          }
        },
        "returnType": {
          "type": [
            "string",
            "array"
          ],
          "prefixItems": [
            {
              "enum": [
                "actionable",
                "clickable",
                "editable",
                "draggable",
                "touchable"
              ]
            }
          ]
        },
        "returnAll": {
          "type": "boolean",
          "default": false
        },
        "description": {
          "$ref": "#/$defs/methodDescription"
        }
      },
      "required": [
        "name"
      ],
      "dependentRequired": {
        "returnAll": [
          "returnType"
        ]
      },
      "additionalProperties": false
    },
    "composeMethod": {
      "title": "Method",
      "description": "A method definition, composed of element actions.",
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "args": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/arg"
          }
        },
        "compose": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/action",
            "type": "object"
          }
        },
        "description": {
          "$ref": "#/$defs/methodDescription"
        }
      },
      "required": [
        "name",
        "compose"
      ],
      "additionalProperties": false
    },
    "action": {
      "type": "object",
      "title": "Element Action",
      "description": "An action to be performed on an element.",
      "allOf": [
        {
          "if": {
            "required": [
              "apply"
            ]
          },
          "then": {
            "not": {
              "required": [
                "applyExternal"
              ]
            }
          }
        },
        {
          "if": {
            "required": [
              "applyExternal"
            ]
          },
          "then": {
            "properties": {
              "applyExternal": {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string"
                  },
                  "invoke": {
                    "type": "string"
                  },
                  "args": {
                    "type": "array",
                    "items": {
                      "$ref": "#/$defs/arg"
                    }
                  }
                },
                "required": [
                  "type",
                  "invoke"
                ],
                "additionalProperties": false
              }
            },
            "required": [
              "applyExternal"
            ],
            "not": {
              "required": [
                "apply"
              ]
            },
            "type": "object"
          }
        }
      ],
      "properties": {
        "element": {
          "type": "string"
        },
        "apply": {
          "type": "string"
        },
        "applyExternal": {
          "type": "object"
        },
        "args": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/arg"
          }
        },
        "matcher": {
          "$ref": "#/$defs/matcher",
          "type": "object"
        },
        "chain": {
          "type": "boolean"
        },
        "returnType": {
          "type": "string",
          "default": "void"
        },
        "returnAll": {
          "type": "boolean",
          "default": false
        }
      },
      "additionalProperties": false
    },
    "arg": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "type": {
          "type": "string",
          "enum": [
            "string",
            "boolean",
            "number",
            "elementReference",
            "argumentReference",
            "function",
            "locator",
            "frame",
            "pageObject",
            "rootPageObject"
          ]
        },
        "value": {
          "type": [
            "integer",
            "string",
            "boolean",
            "number",
            "object"
          ]
        },
        "predicate": {
          "type": "array"
        },
        "args": {
          "description": "element reference can have nested literal args (hardcoded values for its getter)",
          "type": "array",
          "items": {
            "$ref": "#/$defs/arg"
          }
        },
        "description": {
          "type": "string"
        }
      },
      "oneOf": [
        {
          "properties": {
            "type": {
              "type": "string",
              "enum": [
                "string",
                "boolean",
                "number",
                "locator",
                "pageObject",
                "rootPageObject",
                "frame",
                "argumentReference"
              ]
            },
            "name": {
              "type": [
                "string"
              ]
            }
          },
          "required": [
            "type",
            "name"
          ],
          "type": "object"
        },
        {
          "properties": {
            "type": {
              "type": "string",
              "enum": [
                "locator",
                "elementReference",
                "pageObject",
                "rootPageObject"
              ]
            },
            "value": {
              "anyOf": [
                {
                  "type": [
                    "integer",
                    "string",
                    "boolean",
                    "number"
                  ]
                },
                {
                  "$ref": "#/$defs/selector",
                  "type": "object"
                },
                {
                  "$ref": "#/$defs/pageObjectType",
                  "type": "object"
                }
              ]
            }
          },
          "required": [
            "value"
          ],
          "type": "object"
        },
        {
          "properties": {
            "type": {
              "const": "function"
            },
            "name": {
              "type": "string"
            },
            "predicate": {
              "type": [
                "array"
              ],
              "items": {
                "$ref": "#/$defs/predicateStatement"
              }
            }
          },
          "required": [
            "type",
            "predicate"
          ],
          "type": "object"
        }
      ],
      "additionalProperties": false
    },
    "predicateStatement": {
      "$ref": "#/$defs/action"
    },
    "root": {
      "type": "boolean",
      "default": false
    },
    "exposeRootElement": {
      "type": "boolean",
      "default": true
    },
    "name": {
      "type": "string"
    },
    "type": {
      "type": [
        "string",
        "array"
      ],
      "prefixItems": [
        {
          "enum": [
            "actionable",
            "clickable",
            "editable",
            "draggable",
            "touchable"
          ]
        }
      ]
    },
    "shadow": {
      "type": "object",
      "title": "Shadow Root",
      "description": "A shadow boundary at the root of the page object.",
      "properties": {
        "elements": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/element"
          }
        }
      },
      "default": {
        "elements": []
      }
    },
    "elements": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/element"
      }
    },
    "methods": {
      "type": "array"
    },
    "rootDescription": {
      "title": "Root element description",
      "description": "summary of the functionality and use cases",
      "type": [
        "object",
        "string"
      ],
      "properties": {
        "text": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "author": {
          "type": "string"
        },
        "deprecated": {
          "type": "string"
        }
      },
      "required": [
        "text"
      ],
      "additionalProperties": false
    },
    "metadata": {
      "title": "Page Object Metadata",
      "description": "track miscellaneous information for the page object",
      "type": [
        "object"
      ],
      "properties": {
        "status": {
          "type": "string"
        },
        "teamOwner": {
          "type": "string"
        }
      },
      "additionalProperties": false
    },
    "methodDescription": {
      "title": "Method description",
      "description": "summary at the method or element level",
      "type": [
        "object",
        "string"
      ],
      "properties": {
        "text": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "return": {
          "type": "string"
        },
        "throws": {
          "type": "string"
        },
        "deprecated": {
          "type": "string"
        }
      },
      "required": [
        "text"
      ],
      "additionalProperties": false
    }
  }
}
