@naturalcycles/nodejs-lib
Version:
Standard library for Node.js
35 lines (34 loc) • 1.25 kB
TypeScript
import { AnyObject, CommonLogger, CommonLogLevel } from '@naturalcycles/js-lib';
import { SlackAttachmentField, SlackMessage, SlackServiceCfg } from './slack.service.model';
/**
* 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>>);
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;
logChannel?: string;
warnChannel?: string;
errorChannel?: string;
}): CommonLogger;
}
export declare function slackDefaultMessagePrefixHook(msg: SlackMessage): string[];