UNPKG

@naturalcycles/nodejs-lib

Version:
38 lines (37 loc) 1.37 kB
import type { CommonLogger, CommonLogLevel } from '@naturalcycles/js-lib/log'; import type { AnyObject } from '@naturalcycles/js-lib/types'; import type { SlackAttachmentField, SlackMessage, SlackServiceCfg } from './slack.service.model.js'; /** * Has 2 main methods: * * 1. .send({ items: any, channel: ..., ... }) * Low-level method with all possible options available. * * 2. .log(...items: any[]) * Shortcut method to "just log a bunch of things", everything is "by default" there. * * .send method has a shortcut: * .send(string, ctx?: CTX) */ export declare class SlackService<CTX = any> { constructor(cfg: Partial<SlackServiceCfg<CTX>>); private fetcher; cfg: SlackServiceCfg<CTX>; /** * Allows to "log" many things at once, similar to `console.log(one, two, three). */ log(...items: any[]): Promise<void>; send(input: SlackMessage<CTX> | string, ctx?: CTX): Promise<void>; kvToFields(kv: AnyObject): SlackAttachmentField[]; /** * Returns a CommonLogger implementation based on this SlackService instance. */ getCommonLogger(opt: { minLogLevel: CommonLogLevel; debugChannel?: string; logChannel?: string; warnChannel?: string; errorChannel?: string; }): CommonLogger; } export declare function slackDefaultMessagePrefixHook(msg: SlackMessage): string[];