Skip to content

Commit

Permalink
type: re-export types
Browse files Browse the repository at this point in the history
  • Loading branch information
chentsulin committed Jun 17, 2020
1 parent 7a89283 commit 7ee49fc
Show file tree
Hide file tree
Showing 30 changed files with 1,272 additions and 1,002 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ module.exports = {
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-var-requires': 'warn',
'@typescript-eslint/ban-types': 'warn',
'@typescript-eslint/no-non-null-assertion': 'off',
},
overrides: [
{
Expand Down
16 changes: 11 additions & 5 deletions packages/bottender/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import bottender from './bottender';
import * as LineTypes from './line/LineTypes';
import * as MessengerTypes from './messenger/MessengerTypes';
import * as SlackTypes from './slack/SlackTypes';
import * as TelegramTypes from './telegram/TelegramTypes';
import * as ViberTypes from './viber/ViberTypes';
import * as WhatsappTypes from './whatsapp/WhatsappTypes';

export { bottender };
Expand Down Expand Up @@ -38,7 +43,7 @@ export { default as FacebookBaseConnector } from './messenger/FacebookBaseConnec
export { default as MessengerConnector } from './messenger/MessengerConnector';
export { default as MessengerContext } from './messenger/MessengerContext';
export { default as MessengerEvent } from './messenger/MessengerEvent';
export { MessengerTypes } from 'messaging-api-messenger';
export { MessengerTypes };

/* WhatsApp */
export { default as WhatsappBot } from './whatsapp/WhatsappBot';
Expand All @@ -52,28 +57,29 @@ export { default as LineBot } from './line/LineBot';
export { default as LineConnector } from './line/LineConnector';
export { default as LineContext } from './line/LineContext';
export { default as LineEvent } from './line/LineEvent';
export { LineTypes, LineNotify } from 'messaging-api-line';
export { LineNotify } from 'messaging-api-line';
export { LineTypes };

/* Slack */
export { default as SlackBot } from './slack/SlackBot';
export { default as SlackConnector } from './slack/SlackConnector';
export { default as SlackContext } from './slack/SlackContext';
export { default as SlackEvent } from './slack/SlackEvent';
export { SlackTypes } from 'messaging-api-slack';
export { SlackTypes };

/* Telegram */
export { default as TelegramBot } from './telegram/TelegramBot';
export { default as TelegramConnector } from './telegram/TelegramConnector';
export { default as TelegramContext } from './telegram/TelegramContext';
export { default as TelegramEvent } from './telegram/TelegramEvent';
export { TelegramTypes } from 'messaging-api-telegram';
export { TelegramTypes };

/* Viber */
export { default as ViberBot } from './viber/ViberBot';
export { default as ViberConnector } from './viber/ViberConnector';
export { default as ViberContext } from './viber/ViberContext';
export { default as ViberEvent } from './viber/ViberEvent';
export { ViberTypes } from 'messaging-api-viber';
export { ViberTypes };

/* Types */
export * from './types';
Expand Down
6 changes: 2 additions & 4 deletions packages/bottender/src/line/LineBot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ import { LineClient } from 'messaging-api-line';
import Bot, { OnRequest } from '../bot/Bot';
import SessionStore from '../session/SessionStore';

import LineConnector, {
LineConnectorOptions,
LineRequestBody,
} from './LineConnector';
import LineConnector, { LineConnectorOptions } from './LineConnector';
import LineContext from './LineContext';
import LineEvent from './LineEvent';
import { LineRequestBody } from './LineTypes';

export default class LineBot extends Bot<
LineRequestBody,
Expand Down
13 changes: 2 additions & 11 deletions packages/bottender/src/line/LineConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,8 @@ import { Connector } from '../bot/Connector';
import { RequestContext } from '../types';

import LineContext from './LineContext';
import LineEvent, { LineRawEvent } from './LineEvent';

export type LineRequestBody = {
destination: string;
events: LineRawEvent[];
};

type LineRequestContext = RequestContext<
LineRequestBody,
{ 'x-line-signature'?: string }
>;
import LineEvent from './LineEvent';
import { LineRawEvent, LineRequestBody, LineRequestContext } from './LineTypes';

type CommonConnectorOptions = {
getConfig?: GetConfigFunction;
Expand Down
7 changes: 4 additions & 3 deletions packages/bottender/src/line/LineContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ import chunk from 'lodash/chunk';
import invariant from 'invariant';
import warning from 'warning';
import { JsonObject } from 'type-fest';
import { Line, LineClient, LineTypes } from 'messaging-api-line';
import { Line, LineClient } from 'messaging-api-line';

import Context from '../context/Context';
import Session from '../session/Session';
import { RequestContext } from '../types';

import LineEvent from './LineEvent';
import * as LineTypes from './LineTypes';

type Options = {
export type LineContextOptions = {
client: LineClient;
event: LineEvent;
session?: Session | null;
Expand Down Expand Up @@ -45,7 +46,7 @@ class LineContext extends Context<LineClient, LineEvent> {
shouldBatch,
sendMethod,
emitter,
}: Options) {
}: LineContextOptions) {
super({ client, event, session, initialState, requestContext, emitter });
this._shouldBatch = shouldBatch || false;
this._sendMethod = sendMethod || 'reply';
Expand Down
Loading

0 comments on commit 7ee49fc

Please sign in to comment.