UNPKG

@atomist/automation-client

Version:

Atomist API for software low-level client

134 lines 4.43 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const decoratorSupport_1 = require("./internal/metadata/decoratorSupport"); const string_1 = require("./internal/util/string"); /** * Decorator for parameters. Adds to object properties */ function Parameter(details = {}) { return (target, propertyKey) => { decoratorSupport_1.declareParameter(target, propertyKey, details); }; } exports.Parameter = Parameter; /** * Map a local field to some other configuration item in a different system */ function MappedParameter(uri, required = true) { return (target, name) => { decoratorSupport_1.declareMappedParameter(target, name, uri, required); }; } exports.MappedParameter = MappedParameter; /** * Declare a secret an automation wants to use */ function Secret(uri) { return (target, name) => { decoratorSupport_1.declareSecret(target, name, uri); }; } exports.Secret = Secret; /** * Inject a config value from the automation-client configuration */ function Value(pathOrValue) { return (target, name) => { if (typeof pathOrValue === "string") { decoratorSupport_1.declareValue(target, name, { path: pathOrValue, }); } else { decoratorSupport_1.declareValue(target, name, pathOrValue); } }; } exports.Value = Value; /** * Decorator for a command handler class. Implements HandleCommand * @param {string} description * @param {string[] | string} intent * @return {(obj: any) => any} * @constructor */ function CommandHandler(description, ...intent) { return (obj) => { decoratorSupport_1.declareCommandHandler(obj, description, false, intent); }; } exports.CommandHandler = CommandHandler; /** * Decorator for a configurable command handler class. Implements HandleCommand * @param {string} description * @param {string[] | string} intent * @return {(obj: any) => any} * @constructor */ function ConfigurableCommandHandler(description, options) { const intent = options.intent ? string_1.toStringArray(options.intent) : []; const autoSubmit = options.autoSubmit ? options.autoSubmit : false; return (obj) => { decoratorSupport_1.declareCommandHandler(obj, description, autoSubmit, intent); }; } exports.ConfigurableCommandHandler = ConfigurableCommandHandler; /** * Decorator for a parameter class that doesn't contain handler logic * @return {(obj: any) => any} * @constructor */ function Parameters() { return (obj) => { decoratorSupport_1.declareParameters(obj); }; } exports.Parameters = Parameters; function EventHandler(description, subscription) { return (obj) => { decoratorSupport_1.declareEventHandler(obj, description, subscription); }; } exports.EventHandler = EventHandler; /** * Decorator for tags. Sets tags on the class */ function Tags(...tags) { return (target) => { decoratorSupport_1.declareTags(target, tags); }; } exports.Tags = Tags; exports.MappedParameters = { GitHubOwner: "atomist://github/repository/owner", GitHubOwnerWithUser: "atomist://github/repository/owner?user=true", GitHubRepository: "atomist://github/repository", GitHubAllRepositories: "atomist://github/repository?all=true", GitHubRepositoryProvider: "atomist://github/repository/provider", GitHubWebHookUrl: "atomist://github_webhook_url", GitHubUrl: "atomist://github_url", GitHubApiUrl: "atomist://github_api_url", GitHubUserLogin: "atomist://github/username", /** @deprecated no alternative available */ GitHubDefaultRepositoryVisibility: "atomist://github/default_repo_visibility", SlackChannel: "atomist://slack/channel", SlackChannelName: "atomist://slack/channel_name", SlackTeam: "atomist://slack/team", SlackUser: "atomist://slack/user", SlackUserName: "atomist://slack/user_name", AtomistWebhookUrlBase: "atomist://base_webhook_url", }; exports.Secrets = { OrgToken: "github://org_token", UserToken: "github://user_token", userToken: (scopeOrScopes) => { const scopes = string_1.toStringArray(scopeOrScopes); if (scopes && scopes.length > 0) { return `${exports.Secrets.UserToken}?scopes=${scopes.join(",")}`; } else { return exports.Secrets.UserToken; } }, }; //# sourceMappingURL=decorators.js.map