Skip to content

Commit

Permalink
tinkering to address slackapi#354
Browse files Browse the repository at this point in the history
  • Loading branch information
marks committed Dec 22, 2019
1 parent e8bb742 commit 6a94f91
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,14 +411,15 @@ export default class App {
// Set body and payload (this value will eventually conform to AnyMiddlewareArgs)
// NOTE: the following doesn't work because... distributive?
// const listenerArgs: Partial<AnyMiddlewareArgs> = {
const listenerArgs: Pick<AnyMiddlewareArgs, 'body' | 'payload'> & {
const listenerArgs: Pick<AnyMiddlewareArgs, 'body' | 'payload' | 'client'> & {
/** Say function might be set below */
say?: SayFn
/** Respond function might be set below */
respond?: RespondFn,
/** Ack function might be set below */
ack?: AckFn<any>,
} = {
client: this.client,
body: bodyArg,
payload:
(type === IncomingEventType.Event) ?
Expand Down
2 changes: 2 additions & 0 deletions src/types/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { InteractiveMessage } from './interactive-message';
import { DialogSubmitAction, DialogValidation } from './dialog-action';
import { MessageAction } from './message-action';
import { SayFn, SayArguments, RespondFn, AckFn } from '../utilities';
import { WebClient } from '@slack/web-api';

/**
* All known actions from Slack's Block Kit interactive components, message actions, dialogs, and legacy interactive
Expand Down Expand Up @@ -45,6 +46,7 @@ export interface SlackActionMiddlewareArgs<Action extends SlackAction = SlackAct
say: Action extends Exclude<SlackAction, DialogSubmitAction> ? SayFn : never;
respond: RespondFn;
ack: ActionAckFn<Action>;
client: WebClient;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/types/command/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { StringIndexed } from '../helpers';
import { SayFn, RespondFn, RespondArguments, AckFn } from '../utilities';
import { WebClient } from '@slack/web-api';

/**
* Arguments which listeners and middleware receive to process a slash command from Slack.
Expand All @@ -11,6 +12,7 @@ export interface SlackCommandMiddlewareArgs {
say: SayFn;
respond: RespondFn;
ack: AckFn<string | RespondArguments>;
client: WebClient;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/types/events/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export * from './base-events';
import { SlackEvent, BasicSlackEvent } from './base-events';
import { StringIndexed } from '../helpers';
import { SayFn } from '../utilities';
import { WebClient } from '@slack/web-api';

/**
* Arguments which listeners and middleware receive to process an event from Slack's Events API.
Expand All @@ -12,6 +13,7 @@ export interface SlackEventMiddlewareArgs<EventType extends string = string> {
message: EventType extends 'message' ? this['payload'] : never;
body: EnvelopedEvent<this['payload']>;
say: WhenEventHasChannelContext<this['payload'], SayFn>;
client: WebClient;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/types/options/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Option } from '@slack/types';
import { StringIndexed, XOR } from '../helpers';
import { AckFn } from '../utilities';
import { WebClient } from '@slack/web-api';

/**
* Arguments which listeners and middleware receive to process an options request from Slack
Expand All @@ -10,6 +11,7 @@ export interface SlackOptionsMiddlewareArgs<Source extends OptionsSource = Optio
body: this['payload'];
options: this['payload'];
ack: OptionsAckFn<Source>;
client: WebClient;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/types/view/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { StringIndexed } from '../helpers';
import { RespondArguments, AckFn } from '../utilities';
import { WebClient } from '@slack/web-api';

/**
* Known view action types
Expand All @@ -14,6 +15,7 @@ export interface SlackViewMiddlewareArgs<ViewActionType extends SlackViewAction
view: this['payload'];
body: ViewActionType;
ack: AckFn<string | RespondArguments>;
client: WebClient;
}

interface PlainTextElementOutput {
Expand Down

0 comments on commit 6a94f91

Please sign in to comment.