UNPKG

@appium/typedoc-plugin-appium

Version:

TypeDoc plugin for Appium & its extensions

97 lines 3.17 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CommandReflection = exports.HTTP_METHOD_EXECUTE = exports.NAME_EXECUTE_ROUTE = void 0; const typedoc_1 = require("typedoc"); const guards_1 = require("../../guards"); const kind_1 = require("./kind"); /** * Execute Methods all have the same route. */ exports.NAME_EXECUTE_ROUTE = '/session/:sessionId/execute'; /** * Execute methods all have the same HTTP method. */ exports.HTTP_METHOD_EXECUTE = 'POST'; /** * A reflection containing data about a single command or execute method. * * Methods may be invoked directly by Handlebars templates. */ class CommandReflection extends typedoc_1.DeclarationReflection { /** * Sets props depending on type of `data` * @param data Command or execute method data * @param parent Always a {@linkcode ExtensionReflection} * @param route Route, if not an execute method */ constructor(data, parent, route) { let name; let kind; let script; let httpMethod; // common data const { requiredParams, optionalParams, comment, methodRefl: refl, commentSource, parameters, signature, examples, command, } = data; // kind-specific data if ((0, guards_1.isExecMethodData)(data)) { script = name = data.script; kind = kind_1.AppiumPluginReflectionKind.ExecuteMethod; route = exports.NAME_EXECUTE_ROUTE; httpMethod = exports.HTTP_METHOD_EXECUTE; } else { if (!route) { throw new TypeError('"route" arg is required for a non-execute-method command'); } name = command; kind = kind_1.AppiumPluginReflectionKind.Command; httpMethod = data.httpMethod; } super(name, kind, parent); this.data = data; this.route = route; this.httpMethod = httpMethod; this.requiredParams = requiredParams ?? []; this.optionalParams = optionalParams ?? []; this.script = script; this.refl = refl; this.commentSource = commentSource; this.parameters = parameters; this.signature = signature; this.examples = examples; this.comment = comment; } /** * If `true`, this command contains one or more examples * * Used by templates */ get hasExample() { return Boolean(this.examples?.length); } /** * If `true`, this command has optional parameters * * Used by templates */ get hasOptionalParams() { return Boolean(this.optionalParams.length); } /** * If `true`, this command has required parameters * * Used by templates */ get hasRequiredParams() { return Boolean(this.requiredParams.length); } /** * If `true`, this command contains data about an execute method * * Used by templates */ get isExecuteMethod() { return this.kindOf(kind_1.AppiumPluginReflectionKind.ExecuteMethod); } } exports.CommandReflection = CommandReflection; //# sourceMappingURL=command.js.map