UNPKG

@auto-it/slack

Version:
81 lines 3.31 kB
import { RestEndpointMethodTypes } from "@octokit/rest"; import { HttpsProxyAgent } from "https-proxy-agent"; import { Auto, IPlugin, InteractiveInit } from "@auto-it/core"; import * as t from "io-ts"; declare type ReleaseResponse = RestEndpointMethodTypes["repos"]["createRelease"]["response"]; /** Transform markdown into slack friendly text */ export declare const sanitizeMarkdown: (markdown: string) => string; interface FileUpload { /** special identifier to upload file */ type: "file"; /** the language the file is */ language: string; /** the code in the file */ code: string; } interface Block { /** Type of slack block */ type: "header" | "divider" | "section" | "context"; /** Blocks config */ [params: string]: unknown; } declare type Messages = [Block[], ...Array<Block[] | FileUpload>]; /** Convert the sanitized markdown to slack blocks */ export declare function convertToBlocks(slackMarkdown: string, withFiles?: boolean): Messages; declare const pluginOptions: t.UnionC<[t.IntersectionC<[t.PartialC<{ /** Channels to post */ channel: t.StringC; }>, t.PartialC<{ /** URL of the slack to post to */ url: t.StringC; /** Who to bother when posting to the channel */ atTarget: t.UnionC<[t.StringC, t.BooleanC]>; /** Allow users to opt into having prereleases posted to slack */ publishPreRelease: t.BooleanC; /** Additional Title to add at the start of the slack message */ title: t.StringC; /** Username to post the message as */ username: t.StringC; /** Image url to use as the message's avatar */ iconUrl: t.StringC; /** Emoji code to use as the message's avatar */ iconEmoji: t.StringC; }>]>, t.IntersectionC<[t.TypeC<{ /** Marks we are gonna use app auth */ auth: t.LiteralC<"app">; /** Channels to post */ channels: t.ArrayC<t.StringC>; }>, t.PartialC<{ /** URL of the slack to post to */ url: t.StringC; /** Who to bother when posting to the channel */ atTarget: t.UnionC<[t.StringC, t.BooleanC]>; /** Allow users to opt into having prereleases posted to slack */ publishPreRelease: t.BooleanC; /** Additional Title to add at the start of the slack message */ title: t.StringC; /** Username to post the message as */ username: t.StringC; /** Image url to use as the message's avatar */ iconUrl: t.StringC; /** Emoji code to use as the message's avatar */ iconEmoji: t.StringC; }>]>]>; export declare type ISlackPluginOptions = t.TypeOf<typeof pluginOptions>; /** Post your release notes to Slack during `auto release` */ export default class SlackPlugin implements IPlugin { /** The name of the plugin */ name: string; /** The options of the plugin */ readonly options: ISlackPluginOptions; /** Initialize the plugin with it's options */ constructor(options?: ISlackPluginOptions | string); /** Custom initialization for this plugin */ init(initializer: InteractiveInit): void; /** Tap into auto plugin points. */ apply(auto: Auto): void; /** Post the release notes to slack */ createPost(auto: Auto, header: string, releaseNotes: string, releases: ReleaseResponse[], agent: HttpsProxyAgent | undefined): Promise<void>; } export {}; //# sourceMappingURL=index.d.ts.map