import { ArgumentType } from '@utam/types'; import { Node } from 'jsonc-parser'; import { SupportedArgsType } from '../utils/args'; import { ActionArgument, ElementActionType, ExternalActionType } from '../utils/element-actions'; export type ElementNodeType = 'basic' | 'container' | 'custom' | 'frame'; type ElementContextArgs = Required & Partial; interface RequiredElementContextArgs { name: string; nodeType: ElementNodeType; elementType: string | string[]; } interface OptionalElementContextArgs { isList: boolean; isPublic: boolean; isWait: boolean; hasParentArgs: boolean; } /** * context of an element including its name, type, cardinality and expected parameter types */ export declare class ElementContext { name: string; nodeType: ElementNodeType; elementType: string | string[]; isList: boolean; isPublic: boolean; isWait: boolean; private readonly hasParentArgs; private expectedArgs; get hasArgs(): boolean; constructor(props: ElementContextArgs); /** * expected types of args for an element including selector and filter * @returns array of type names for args */ getExpectedTypes(): ArgumentType[]; /** * set expected args types for an element * @param types set expected args types for an element */ addExpectedArgTypes(types: ArgumentType[]): void; } /** * As we validate nodes, they are added to unique sets to verify no duplicate items. * The result is either a success, or a failure with an error code and parameters for the error string. */ type AddUniqueItemResult = { isUnique: true; } | { isUnique: false; code: number; args: Array; }; /** * traversal context created per each validated Page Object * accumulates information about elements and provides validations across different nodes */ export declare class Context { /** * These aren't really "visited" names, but they can be computed from elements or methods that we visit */ private reservedNames; private visitedElements; private visitedMethods; /** Indicates if the page object was declared as an interface (interface: true in the root scope) */ isInterface: boolean; addUniqueElement(elementContext: ElementContext): AddUniqueItemResult; /** * @param name the method we're adding. * @returns undefined, if no error. Or an object with the code and args to generate the error. */ addUniqueMethod(name: string): AddUniqueItemResult; getElementContext(name: string): ElementContext | undefined; /** * Generate and reserve names for methods that will be generated later, so we can tell which * element was responsible for the collision. * @param elementContext The element we are reserving methods for */ private reserveCollidableNames; } /** * Represents a decorated statement with context information used to validate returnTypes */ export declare class StatementContext { isLast: boolean; isNextStatementChain: boolean; statementNode: Node; constructor(statementNode: Node, isLast: boolean, nextIsChain: boolean); } /** * Traversal context for statements (in compose method or in beforeLoad). This class decorates the statement nodes * object with properties that add some context around the statement. This is used for the validation of the returnType * in statements that can require information about siblings statements (n +/- 1). */ export declare class StatementsContext { statementsContext: StatementContext[]; constructor(statementNodes: Node[]); private isNextStatementChain; } type MethodType = 'beforeLoad' | 'compose'; /** * Validation context of compose or beforeLoad method */ export interface MethodValidationContext { methodName: string; methodType: MethodType; methodArgsMap: Map; methodUsedArgs: Set; } /** * Validation context of "args" array, can be inside element (selector or filter) or method */ export interface ArgsValidationContext { context: Context; structure: string; supports: SupportedArgsType; methodContext?: MethodValidationContext; expectedTypes?: ActionArgument[]; elementContext?: ElementContext; } /** * Validation context of "matcher" object, can be inside element filter or method statement */ export interface MatcherValidationContext { context: Context; structure: string; action?: ElementActionType | ExternalActionType; methodContext?: MethodValidationContext; elementContext?: ElementContext; } /** * Selector validation context, can be inside method (as "apply" parameter) or element */ export interface SelectorValidationContext { context: Context; methodContext?: MethodValidationContext; elementContext?: ElementContext; } /** * Combines Page Object context, structure and position in JSON */ export interface StructureContext { context: Context; structure: string; position?: { offset: number; }; } export {}; //# sourceMappingURL=validation-context.d.ts.map