Open bneigher opened 1 year ago
Thanks for posting this.
I love the idea of exposing the WebClient instance, for sure! Do you have an idea for how the API could look like?
it's similar, but why not just allow for a getter like follows:
Just expose client
instance on the class, where class is the WebClient. in this way we can just use all of the sdk modules like so:
import { Injectable } from '@nestjs/common'
import { SlackService } from 'nestjs-slack'
@Injectable()
export class MyService {
constructor(
private slackService: SlackService
) {}
async myFunction(email) {
const userResponse = await this.slackService.client.users.lookupByEmail(<>) // .client
return userResponse.user
}
I can see about making a MR if you think this approach is OK
I think all that needs to change is making client public actually:
export declare class SlackService<C = Channels> {
private readonly options: SlackConfig;
public readonly client: WebClient; // <-- HERE
private readonly log: LogSync;
constructor(options: SlackConfig, client: WebClient | null, log: LogSync | null);
sendText(text: string, opts?: Omit<SlackMessageOptions<C>, 'text' | 'blocks'>): Promise<void>;
sendBlocks(blocks: Readonly<SlackBlockDto>[], opts?: Omit<SlackMessageOptions<C>, 'blocks'>): Promise<void>;
postMessage(req: SlackMessageOptions<C>): Promise<void>;
private runApiRequest;
private runWebhookRequest;
private runStdoutRequest;
private runGoogleLoggingRequest;
}
I like it! Let's try and see how that would look :)
Would love to see a MR/PR :)
@cobraz 🙏
I think the double ^^
in your package.json is preventing me from installing the module directly from the repo:
❯ npm i --save https://github.com/bjerkio/nestjs-slack.git
npm ERR! code 1
npm ERR! git dep preparation failed
npm ERR! command /Users/benneigher/.nvm/versions/node/v18.12.1/bin/node /Users/benneigher/.nvm/versions/node/v18.12.1/lib/node_modules/npm/bin/npm-cli.js install --force --cache=/Users/benneigher/.npm --prefer-offline=false --prefer-online=false --offline=false --no-progress --no-save --no-audit --include=dev --include=peer --include=optional --no-package-lock-only --no-dry-run
npm ERR! npm WARN using --force Recommended protections disabled.
npm ERR! npm ERR! code EINVALIDTAGNAME
npm ERR! npm ERR! Invalid tag name "^^9.0.0" of package "@nestjs/platform-express@^^9.0.0": Tags may not have any characters that encodeURIComponent encodes.
npm ERR!
npm ERR! npm ERR! A complete log of this run can be found in:
npm ERR! npm ERR! /Users/benneigher/.npm/_logs/2023-01-31T19_28_09_518Z-debug-0.log
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/benneigher/.npm/_logs/2023-01-31T19_27_59_836Z-debug-0.log
Specifically this line in package.json @nestjs/platform-express@^^9.0.0
alternatively -- if you published a new release to npm I will be out of your hair! Putting together a release and would prefer using the nestjs module over the slack sdk manually. much appreciated 🙏
+1 on publish a new version
Hello, just wondering if it's possible to add a getter to the
SlackService
to allow the application to get a hold of the WebClient instance? I want to use it to make calls to users apis (lookupByEmail
for example)Doesn't seem to be a way to do this without installing
@slack/web-api
and making an external instance of the WebClientLove the repo!