MCPcopy
hub / github.com/triggerdotdev/trigger.dev / Slack

Class Slack

integrations/slack/src/index.ts:49–173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47};
48
49export class Slack implements TriggerIntegration {
50 // @internal
51 private _options: SlackIntegrationOptions;
52 // @internal
53 private _client?: WebClient;
54 // @internal
55 private _io?: IO;
56 // @internal
57 private _connectionKey?: string;
58
59 constructor(private options: SlackIntegrationOptions) {
60 this._options = options;
61 }
62
63 get authSource() {
64 return "HOSTED" as const;
65 }
66
67 get id() {
68 return this.options.id;
69 }
70
71 get metadata() {
72 return { id: "slack", name: "Slack.com" };
73 }
74
75 cloneForRun(io: IO, connectionKey: string, auth?: ConnectionAuth) {
76 const slack = new Slack(this._options);
77 slack._io = io;
78 slack._connectionKey = connectionKey;
79 if (!auth) {
80 throw new Error("No auth");
81 }
82 slack._client = new WebClient(auth.accessToken);
83 return slack;
84 }
85
86 runTask<T, TResult extends Json<T> | void>(
87 key: IntegrationTaskKey,
88 callback: (client: WebClient, task: IOTask, io: IO) => Promise<TResult>,
89 options?: RunTaskOptions,
90 errorCallback?: RunTaskErrorCallback
91 ): Promise<TResult> {
92 if (!this._io) throw new Error("No IO");
93 if (!this._connectionKey) throw new Error("No connection key");
94
95 return this._io.runTask(
96 key,
97 (task, io) => {
98 if (!this._client) throw new Error("No client");
99 return callback(this._client, task, io);
100 },
101 {
102 icon: "slack",
103 retry: retry.standardBackoff,
104 ...(options ?? {}),
105 connectionKey: this._connectionKey,
106 },

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…