From 9824009e29dd73049b69f3ab8c20f1bdfb323cd7 Mon Sep 17 00:00:00 2001 From: etrex kuo Date: Tue, 24 Mar 2020 00:04:54 +0800 Subject: [PATCH 1/2] chore: hide private member and refine constructor args --- .gitignore | 3 ++ packages/bottender-handlers/src/Handler.ts | 3 ++ packages/bottender/package.json | 5 +++ packages/bottender/src/bot/Bot.ts | 23 ++++++++--- .../bottender/src/cache/MemoryCacheStore.ts | 4 ++ .../bottender/src/cache/RedisCacheStore.ts | 39 +++++++++++-------- packages/bottender/src/console/ConsoleBot.ts | 3 ++ .../bottender/src/console/ConsoleConnector.ts | 17 +++++--- .../bottender/src/console/ConsoleContext.ts | 22 +++++------ .../bottender/src/console/ConsoleEvent.ts | 4 ++ packages/bottender/src/context/Context.ts | 29 ++++++++++---- packages/bottender/src/line/LineBot.ts | 26 +++++++------ packages/bottender/src/line/LineConnector.ts | 7 ++++ packages/bottender/src/line/LineContext.ts | 28 +++++++------ packages/bottender/src/line/LineEvent.ts | 5 +++ .../bottender/src/messenger/MessengerBot.ts | 30 +++++++------- .../src/messenger/MessengerConnector.ts | 15 +++++++ .../src/messenger/MessengerContext.ts | 27 +++++++------ .../bottender/src/messenger/MessengerEvent.ts | 6 +++ packages/bottender/src/server/Server.ts | 7 +++- .../src/session/CacheBasedSessionStore.ts | 5 +++ .../bottender/src/session/FileSessionStore.ts | 6 +++ .../src/session/MemorySessionStore.ts | 3 ++ .../src/session/MongoSessionStore.ts | 9 +++++ .../src/session/RedisSessionStore.ts | 3 ++ packages/bottender/src/slack/SlackBot.ts | 25 +++++++----- .../bottender/src/slack/SlackConnector.ts | 10 +++++ packages/bottender/src/slack/SlackContext.ts | 29 +++++++++----- packages/bottender/src/slack/SlackEvent.ts | 4 ++ .../bottender/src/telegram/TelegramBot.ts | 18 ++++++--- .../src/telegram/TelegramConnector.ts | 6 +++ .../bottender/src/telegram/TelegramContext.ts | 1 + .../bottender/src/telegram/TelegramEvent.ts | 4 ++ .../src/test-utils/ContextSimulator.ts | 17 +++++--- .../src/test-utils/SimulatedContext.ts | 4 ++ packages/bottender/src/viber/ViberBot.ts | 18 +++++---- .../bottender/src/viber/ViberConnector.ts | 7 ++++ packages/bottender/src/viber/ViberEvent.ts | 4 ++ .../bottender/src/whatsapp/TwilioClient.ts | 7 ++++ .../bottender/src/whatsapp/WhatsappBot.ts | 20 ++++++---- .../src/whatsapp/WhatsappConnector.ts | 4 ++ .../bottender/src/whatsapp/WhatsappEvent.ts | 4 ++ 42 files changed, 371 insertions(+), 140 deletions(-) diff --git a/.gitignore b/.gitignore index f9c07c0f7..794973e71 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,6 @@ node_modules/ # Docusaurus i18n website/i18n/* website/translated_docs + + +packages/bottender/docs \ No newline at end of file diff --git a/packages/bottender-handlers/src/Handler.ts b/packages/bottender-handlers/src/Handler.ts index 81e20356b..707a80108 100644 --- a/packages/bottender-handlers/src/Handler.ts +++ b/packages/bottender-handlers/src/Handler.ts @@ -48,10 +48,13 @@ export function matchPattern(pattern: Pattern, text: string): boolean { } export default class Handler { + /** @hidden */ _handlers: PredicateHandler[] = []; + /** @hidden */ _errorHandler: FunctionalHandler | null = null; + /** @hidden */ _unhandledHandler: FunctionalHandler | null = null; on(predicate: ContextPredicate, handler: FunctionalHandler | Builder) { diff --git a/packages/bottender/package.json b/packages/bottender/package.json index ad200faf1..76343c853 100644 --- a/packages/bottender/package.json +++ b/packages/bottender/package.json @@ -102,5 +102,10 @@ ], "engines": { "node": ">=8" + }, + "scripts": { + "typedoc": "yarn typedoc:html && yarn typedoc:json", + "typedoc:html": "typedoc --out docs --exclude \"src/**/__tests__/**/*.ts\" src", + "typedoc:json": "typedoc --json docs/index.json --exclude \"src/**/__tests__/**/*.ts\" src" } } diff --git a/packages/bottender/src/bot/Bot.ts b/packages/bottender/src/bot/Bot.ts index ab010566d..9dbcd43d6 100644 --- a/packages/bottender/src/bot/Bot.ts +++ b/packages/bottender/src/bot/Bot.ts @@ -70,33 +70,46 @@ type RequestHandler = ( ) => void | Promise; export default class Bot { + /** @hidden */ _sessions: SessionStore; + /** @hidden */ _initialized: boolean; + /** @hidden */ _connector: Connector; + /** @hidden */ _handler: Action | null; + /** @hidden */ _errorHandler: Action | null; + /** @hidden */ _initialState: Record = {}; + /** @hidden */ _plugins: Function[] = []; + /** @hidden */ _sync: boolean; + /** @hidden */ _emitter: EventEmitter; - constructor({ - connector, - sessionStore = createMemorySessionStore(), - sync = false, - }: { + /** + * constructor + */ + constructor(options: { connector: Connector; sessionStore?: SessionStore; sync?: boolean; }) { + const { + connector, + sessionStore = createMemorySessionStore(), + sync = false, + } = options this._sessions = sessionStore; this._initialized = false; this._connector = connector; diff --git a/packages/bottender/src/cache/MemoryCacheStore.ts b/packages/bottender/src/cache/MemoryCacheStore.ts index 4d82a1b52..2c0978c37 100644 --- a/packages/bottender/src/cache/MemoryCacheStore.ts +++ b/packages/bottender/src/cache/MemoryCacheStore.ts @@ -4,8 +4,12 @@ import cloneDeep from 'lodash/cloneDeep'; import CacheStore, { CacheValue } from './CacheStore'; export default class MemoryCacheStore implements CacheStore { + /** @hidden */ _lru: LRU; + /** + * constructor + */ constructor(max?: number) { this._lru = new LRU({ max }); } diff --git a/packages/bottender/src/cache/RedisCacheStore.ts b/packages/bottender/src/cache/RedisCacheStore.ts index b20897ed7..c215d6755 100644 --- a/packages/bottender/src/cache/RedisCacheStore.ts +++ b/packages/bottender/src/cache/RedisCacheStore.ts @@ -4,26 +4,33 @@ import isNumber from 'lodash/isNumber'; import CacheStore, { CacheValue } from './CacheStore'; export default class RedisCacheStore implements CacheStore { + /** @hidden */ _redis: IORedis.Redis; + /** @hidden */ _prefix = ''; - /* - Support all of args supported by `ioredis`: - - new Redis() // Connect to 127.0.0.1:6379 - - new Redis(6380) // 127.0.0.1:6380 - - new Redis(6379, '192.168.1.1') // 192.168.1.1:6379 - - new Redis('/tmp/redis.sock') - - new Redis({ - port: 6379, // Redis port - host: '127.0.0.1', // Redis host - family: 4, // 4 (IPv4) or 6 (IPv6) - password: 'auth', - db: 0 - }) - // Connect to 127.0.0.1:6380, db 4, using password "authpassword" - - new Redis('redis://:authpassword@127.0.0.1:6380/4') - */ + /** + * constructor + * Support all of args supported by `ioredis`: + * + * ``` + * new Redis() // Connect to 127.0.0.1:6379 + * new Redis(6380) // 127.0.0.1:6380 + * new Redis(6379, '192.168.1.1') // 192.168.1.1:6379 + * new Redis('/tmp/redis.sock') + * new Redis({ + * port: 6379, // Redis port + * host: '127.0.0.1', // Redis host + * family: 4, // 4 (IPv4) or 6 (IPv6) + * password: 'auth', + * db: 0 + * }) + * + * // Connect to 127.0.0.1:6380, db 4, using password "authpassword" + * new Redis('redis://:authpassword@127.0.0.1:6380/4') + * ``` + */ constructor(...args: any) { this._redis = new IORedis(...args); } diff --git a/packages/bottender/src/console/ConsoleBot.ts b/packages/bottender/src/console/ConsoleBot.ts index 8a921bd10..257a00f58 100644 --- a/packages/bottender/src/console/ConsoleBot.ts +++ b/packages/bottender/src/console/ConsoleBot.ts @@ -13,6 +13,9 @@ export default class ConsoleBot extends Bot< ConsoleClient, ConsoleEvent > { + /** + * constructor + */ constructor({ sessionStore, fallbackMethods, diff --git a/packages/bottender/src/console/ConsoleConnector.ts b/packages/bottender/src/console/ConsoleConnector.ts index 292678fb9..28bd4b116 100644 --- a/packages/bottender/src/console/ConsoleConnector.ts +++ b/packages/bottender/src/console/ConsoleConnector.ts @@ -18,17 +18,24 @@ type ConstructorOptions = { export default class ConsoleConnector implements Connector { + /** @hidden */ _client: ConsoleClient; + /** @hidden */ _fallbackMethods: boolean; + /** @hidden */ _platform: string; - constructor({ - client, - fallbackMethods, - mockPlatform, - }: ConstructorOptions = {}) { + /** + * constructor + */ + constructor(options: ConstructorOptions = {}) { + const { + client, + fallbackMethods, + mockPlatform, + } = options this._client = client || { sendText: (text): void => { process.stdout.write(`Bot > ${text}\n`); diff --git a/packages/bottender/src/console/ConsoleContext.ts b/packages/bottender/src/console/ConsoleContext.ts index b4f42299f..47893dec2 100644 --- a/packages/bottender/src/console/ConsoleContext.ts +++ b/packages/bottender/src/console/ConsoleContext.ts @@ -30,21 +30,21 @@ export default class ConsoleContext extends Context< ConsoleClient, ConsoleEvent > { + /** @hidden */ _fallbackMethods = false; + /** @hidden */ _mockPlatform = 'console'; - constructor({ - client, - event, - session, - initialState, - requestContext, - fallbackMethods, - mockPlatform, - emitter, - }: Options) { - super({ client, event, session, initialState, requestContext, emitter }); + /** + * constructor + */ + constructor(options: Options) { + super(options); + const { + fallbackMethods, + mockPlatform, + } = options this._mockPlatform = mockPlatform; this._fallbackMethods = fallbackMethods; if (fallbackMethods) { diff --git a/packages/bottender/src/console/ConsoleEvent.ts b/packages/bottender/src/console/ConsoleEvent.ts index a850076ae..d9a329fdb 100644 --- a/packages/bottender/src/console/ConsoleEvent.ts +++ b/packages/bottender/src/console/ConsoleEvent.ts @@ -15,8 +15,12 @@ type PayloadEvent = { export type ConsoleRawEvent = MessageEvent | PayloadEvent; export default class ConsoleEvent implements Event { + /** @hidden */ _rawEvent: ConsoleRawEvent; + /** + * constructor + */ constructor(rawEvent: ConsoleRawEvent) { this._rawEvent = rawEvent; } diff --git a/packages/bottender/src/context/Context.ts b/packages/bottender/src/context/Context.ts index 0defba8d9..0534dfbb8 100644 --- a/packages/bottender/src/context/Context.ts +++ b/packages/bottender/src/context/Context.ts @@ -34,34 +34,47 @@ export default abstract class Context { // eslint-disable-next-line @typescript-eslint/no-explicit-any abstract sendText(text: string, options?: Record): any; + /** @hidden */ _isHandled: boolean | null = null; + /** @hidden */ _isSessionWritten = false; + /** @hidden */ _client: C; + /** @hidden */ _event: E; + /** @hidden */ _session: Session | null; + /** @hidden */ _initialState?: Record | null; + /** @hidden */ _requestContext: RequestContext | null; + /** @hidden */ _emitter: EventEmitter | null; + /** @hidden */ _intent: string | null; response: Response; - constructor({ - client, - event, - session, - initialState, - requestContext, - emitter, - }: Options) { + /** + * constructor + */ + constructor(options: Options) { + const { + client, + event, + session, + initialState, + requestContext, + emitter, + } = options this._client = client; this._event = event; this._session = session || null; diff --git a/packages/bottender/src/line/LineBot.ts b/packages/bottender/src/line/LineBot.ts index 474f8bc63..d63fedd79 100644 --- a/packages/bottender/src/line/LineBot.ts +++ b/packages/bottender/src/line/LineBot.ts @@ -11,17 +11,10 @@ export default class LineBot extends Bot< LineClient, LineEvent > { - constructor({ - accessToken, - channelSecret, - sessionStore, - origin, - sync, - mapDestinationToAccessToken, - shouldBatch, - sendMethod, - skipLegacyProfile, - }: { + /** + * constructor + */ + constructor(options: { accessToken: string; channelSecret: string; sessionStore?: SessionStore; @@ -32,6 +25,17 @@ export default class LineBot extends Bot< origin?: string; skipLegacyProfile?: boolean; }) { + const { + accessToken, + channelSecret, + sessionStore, + origin, + sync, + mapDestinationToAccessToken, + shouldBatch, + sendMethod, + skipLegacyProfile, + } = options const connector = new LineConnector({ accessToken, channelSecret, diff --git a/packages/bottender/src/line/LineConnector.ts b/packages/bottender/src/line/LineConnector.ts index 07e693c02..a9fb2357c 100644 --- a/packages/bottender/src/line/LineConnector.ts +++ b/packages/bottender/src/line/LineConnector.ts @@ -40,18 +40,24 @@ type ConstructorOptions = export default class LineConnector implements Connector { + /** @hidden */ _client: LineClient; + /** @hidden */ _channelSecret: string; + /** @hidden */ _skipLegacyProfile: boolean; + /** @hidden */ _mapDestinationToAccessToken: | ((destination: string) => Promise) | null; + /** @hidden */ _shouldBatch: boolean; + /** @hidden */ _sendMethod: string; constructor(options: ConstructorOptions) { @@ -99,6 +105,7 @@ export default class LineConnector typeof skipLegacyProfile === 'boolean' ? skipLegacyProfile : true; } + /** @hidden */ _isWebhookVerifyEvent(event: LineRawEvent): boolean { return ( (event as any).replyToken === '00000000000000000000000000000000' || diff --git a/packages/bottender/src/line/LineContext.ts b/packages/bottender/src/line/LineContext.ts index 3d0a1d607..e1be65958 100644 --- a/packages/bottender/src/line/LineContext.ts +++ b/packages/bottender/src/line/LineContext.ts @@ -25,30 +25,34 @@ type Options = { }; class LineContext extends Context { + /** @hidden */ _customAccessToken: string | null; + /** @hidden */ _isReplied = false; + /** @hidden */ _shouldBatch: boolean; + /** @hidden */ _replyMessages: LineTypes.Message[] = []; + /** @hidden */ _pushMessages: LineTypes.Message[] = []; + /** @hidden */ _sendMethod: string; - constructor({ - client, - event, - session, - initialState, - requestContext, - customAccessToken, - shouldBatch, - sendMethod, - emitter, - }: Options) { - super({ client, event, session, initialState, requestContext, emitter }); + /** + * Constructor + */ + constructor(options: Options) { + super(options); + const { + customAccessToken, + shouldBatch, + sendMethod, + } = options this._customAccessToken = customAccessToken || null; this._shouldBatch = shouldBatch || false; this._sendMethod = sendMethod || 'reply'; diff --git a/packages/bottender/src/line/LineEvent.ts b/packages/bottender/src/line/LineEvent.ts index 60ae27ee2..dde518b29 100644 --- a/packages/bottender/src/line/LineEvent.ts +++ b/packages/bottender/src/line/LineEvent.ts @@ -230,10 +230,15 @@ export type LineRawEvent = | ThingsEvent; export default class LineEvent implements Event { + /** @hidden */ _rawEvent: LineRawEvent; + /** @hidden */ _destination: string | undefined; + /** + * constructor + */ constructor(rawEvent: LineRawEvent, options: LineEventOptions = {}) { this._rawEvent = rawEvent; this._destination = options.destination; diff --git a/packages/bottender/src/messenger/MessengerBot.ts b/packages/bottender/src/messenger/MessengerBot.ts index 0b9e1e4ca..e7cc2e4fb 100644 --- a/packages/bottender/src/messenger/MessengerBot.ts +++ b/packages/bottender/src/messenger/MessengerBot.ts @@ -11,19 +11,10 @@ export default class MessengerBot extends Bot< MessengerClient, MessengerEvent > { - constructor({ - accessToken, - appId, - appSecret, - sessionStore, - sync, - mapPageToAccessToken, - verifyToken, - batchConfig, - origin, - skipAppSecretProof, - skipLegacyProfile, - }: { + /** + * constructor + */ + constructor(options: { accessToken: string; appId: string; appSecret: string; @@ -36,6 +27,19 @@ export default class MessengerBot extends Bot< skipAppSecretProof?: boolean; skipLegacyProfile?: boolean; }) { + const { + accessToken, + appId, + appSecret, + sessionStore, + sync, + mapPageToAccessToken, + verifyToken, + batchConfig, + origin, + skipAppSecretProof, + skipLegacyProfile, + } = options const connector = new MessengerConnector({ accessToken, appId, diff --git a/packages/bottender/src/messenger/MessengerConnector.ts b/packages/bottender/src/messenger/MessengerConnector.ts index 86f082e1e..1b868198e 100644 --- a/packages/bottender/src/messenger/MessengerConnector.ts +++ b/packages/bottender/src/messenger/MessengerConnector.ts @@ -102,22 +102,33 @@ type ConstructorOptions = export default class MessengerConnector implements Connector { + /** @hidden */ _client: MessengerClient; + /** @hidden */ _appId: string; + /** @hidden */ _appSecret: string; + /** @hidden */ _skipLegacyProfile: boolean; + /** @hidden */ _mapPageToAccessToken: ((pageId: string) => Promise) | null = null; + /** @hidden */ _verifyToken: string | null = null; + /** @hidden */ _batchConfig: Record | null = null; + /** @hidden */ _batchQueue: Record | null = null; + /** + * constructor + */ constructor(options: ConstructorOptions) { const { appId, @@ -169,6 +180,7 @@ export default class MessengerConnector } } + /** @hidden */ _getRawEventsFromRequest(body: MessengerRequestBody): MessengerRawEvent[] { if ('entry' in body) { const { entry } = body as EntryRequestBody; @@ -196,6 +208,7 @@ export default class MessengerConnector return [body as MessengerRawEvent]; } + /** @hidden */ _getPageIdFromRawEvent(rawEvent: MessengerRawEvent): string | null { if (rawEvent.message && rawEvent.message.isEcho && rawEvent.sender) { return rawEvent.sender.id; @@ -207,6 +220,7 @@ export default class MessengerConnector return null; } + /** @hidden */ _isStandby(body: MessengerRequestBody): boolean { if (!('entry' in body)) return false; const entry = (body as EntryRequestBody).entry[0]; @@ -214,6 +228,7 @@ export default class MessengerConnector return !!entry.standby; } + /** @hidden */ _profilePicExpired(user: { profilePic: string }): boolean { try { // Facebook CDN returns expiration time in the key `ext` in URL params like: diff --git a/packages/bottender/src/messenger/MessengerContext.ts b/packages/bottender/src/messenger/MessengerContext.ts index 034110af6..5a2f1d28f 100644 --- a/packages/bottender/src/messenger/MessengerContext.ts +++ b/packages/bottender/src/messenger/MessengerContext.ts @@ -28,26 +28,28 @@ type Options = { }; class MessengerContext extends Context { + /** @hidden */ _appId: string | null; + /** @hidden */ _customAccessToken: string | null; + /** @hidden */ _personaId: string | null = null; + /** @hidden */ _batchQueue: Record | null; - constructor({ - appId, - client, - event, - session, - initialState, - requestContext, - customAccessToken, - batchQueue, - emitter, - }: Options) { - super({ client, event, session, initialState, requestContext, emitter }); + /** + * constructor + */ + constructor(options: Options) { + super(options); + const { + appId, + customAccessToken, + batchQueue, + } = options this._customAccessToken = customAccessToken || null; this._batchQueue = batchQueue || null; this._appId = appId || null; @@ -65,6 +67,7 @@ class MessengerContext extends Context { return this._customAccessToken || this._client.accessToken; } + /** @hidden */ _callClientMethod(method: string, args: any[]) { if (this._batchQueue) { return (this._batchQueue as any).push( diff --git a/packages/bottender/src/messenger/MessengerEvent.ts b/packages/bottender/src/messenger/MessengerEvent.ts index 1862461ce..62af0b7cf 100644 --- a/packages/bottender/src/messenger/MessengerEvent.ts +++ b/packages/bottender/src/messenger/MessengerEvent.ts @@ -204,12 +204,18 @@ type MessengerEventOptions = { }; export default class MessengerEvent implements Event { + /** @hidden */ _rawEvent: MessengerRawEvent; + /** @hidden */ _isStandby: boolean; + /** @hidden */ _pageId: string | null; + /** + * constructor + */ constructor( rawEvent: MessengerRawEvent, options: MessengerEventOptions = {} diff --git a/packages/bottender/src/server/Server.ts b/packages/bottender/src/server/Server.ts index fe060c672..bdb81792f 100644 --- a/packages/bottender/src/server/Server.ts +++ b/packages/bottender/src/server/Server.ts @@ -17,11 +17,16 @@ export type ServerOptions = { }; class Server { + /** @hidden */ _channelBots: { webhookPath: string; bot: Bot }[] = []; useConsole: boolean; - constructor({ useConsole = false } = {}) { + /** + * constructor + */ + constructor(options: { useConsole?: boolean } = {}) { + const { useConsole = false } = options this.useConsole = useConsole; } diff --git a/packages/bottender/src/session/CacheBasedSessionStore.ts b/packages/bottender/src/session/CacheBasedSessionStore.ts index f87db6ee1..cf7199b3a 100644 --- a/packages/bottender/src/session/CacheBasedSessionStore.ts +++ b/packages/bottender/src/session/CacheBasedSessionStore.ts @@ -4,11 +4,16 @@ import Session from './Session'; import SessionStore from './SessionStore'; export default class CacheBasedSessionStore implements SessionStore { + /** @hidden */ _cache: CacheStore; // The number of minutes to store the data in the session. + /** @hidden */ _expiresIn: number; + /** + * constructor + */ constructor(cache: CacheStore, expiresIn?: number) { this._cache = cache; this._expiresIn = expiresIn || 0; diff --git a/packages/bottender/src/session/FileSessionStore.ts b/packages/bottender/src/session/FileSessionStore.ts index 12a4a0673..3edaaf39f 100644 --- a/packages/bottender/src/session/FileSessionStore.ts +++ b/packages/bottender/src/session/FileSessionStore.ts @@ -24,11 +24,16 @@ function getDirname(arg: FileOption): string | void { } export default class FileSessionStore implements SessionStore { + /** @hidden */ _jfs: Instance>; // The number of minutes to store the data in the session. + /** @hidden */ _expiresIn: number; + /** + * constructor + */ constructor(arg: FileOption, expiresIn?: number) { this._expiresIn = expiresIn || 0; @@ -113,6 +118,7 @@ export default class FileSessionStore implements SessionStore { return this._jfs; } + /** @hidden */ _expired(sess: Session): boolean { if (!this._expiresIn) { return false; diff --git a/packages/bottender/src/session/MemorySessionStore.ts b/packages/bottender/src/session/MemorySessionStore.ts index e64f64124..72e9a8510 100644 --- a/packages/bottender/src/session/MemorySessionStore.ts +++ b/packages/bottender/src/session/MemorySessionStore.ts @@ -24,6 +24,9 @@ function getMaxSize(arg?: MemoryOption): number | undefined { export default class MemorySessionStore extends CacheBasedSessionStore implements SessionStore { + /** + * constructor + */ constructor(arg?: MemoryOption, expiresIn?: number) { const maxSize = getMaxSize(arg); diff --git a/packages/bottender/src/session/MongoSessionStore.ts b/packages/bottender/src/session/MongoSessionStore.ts index 939637e6a..c17df4210 100644 --- a/packages/bottender/src/session/MongoSessionStore.ts +++ b/packages/bottender/src/session/MongoSessionStore.ts @@ -13,15 +13,22 @@ type MongoOption = }; export default class MongoSessionStore implements SessionStore { + /** @hidden */ _url: string; + /** @hidden */ _collectionName: string; // The number of minutes to store the data in the session. + /** @hidden */ _expiresIn: number; + /** @hidden */ _connection?: Db; + /** + * constructor + */ constructor(options: MongoOption, expiresIn?: number) { if (typeof options === 'string') { this._url = options; @@ -86,6 +93,7 @@ export default class MongoSessionStore implements SessionStore { } } + /** @hidden */ _expired(sess: Session): boolean { if (!this._expiresIn) { return false; @@ -97,6 +105,7 @@ export default class MongoSessionStore implements SessionStore { ); } + /** @hidden */ get _sessions(): Collection { if (this._connection == null) { throw new Error( diff --git a/packages/bottender/src/session/RedisSessionStore.ts b/packages/bottender/src/session/RedisSessionStore.ts index 32dc6e009..dd8c04b1c 100644 --- a/packages/bottender/src/session/RedisSessionStore.ts +++ b/packages/bottender/src/session/RedisSessionStore.ts @@ -16,6 +16,9 @@ type RedisOption = export default class RedisSessionStore extends CacheBasedSessionStore implements SessionStore { + /** + * constructor + */ constructor(arg: RedisOption, expiresIn?: number) { const cache = new RedisCacheStore(arg); super(cache, expiresIn); diff --git a/packages/bottender/src/slack/SlackBot.ts b/packages/bottender/src/slack/SlackBot.ts index 56ae615d3..4563ad9fa 100644 --- a/packages/bottender/src/slack/SlackBot.ts +++ b/packages/bottender/src/slack/SlackBot.ts @@ -12,18 +12,13 @@ export default class SlackBot extends Bot< SlackOAuthClient, SlackEvent > { + /** @hidden */ _accessToken: string; - constructor({ - accessToken, - sessionStore, - sync, - verificationToken, - signingSecret, - origin, - skipLegacyProfile, - includeBotMessages, - }: { + /** + * constructor + */ + constructor(options: { accessToken: string; sessionStore?: SessionStore; sync?: boolean; @@ -33,6 +28,16 @@ export default class SlackBot extends Bot< skipLegacyProfile?: boolean; includeBotMessages?: boolean; }) { + const { + accessToken, + sessionStore, + sync, + verificationToken, + signingSecret, + origin, + skipLegacyProfile, + includeBotMessages, + } = options const connector = new SlackConnector({ accessToken, verificationToken, diff --git a/packages/bottender/src/slack/SlackConnector.ts b/packages/bottender/src/slack/SlackConnector.ts index 369132266..bfe6f8ea4 100644 --- a/packages/bottender/src/slack/SlackConnector.ts +++ b/packages/bottender/src/slack/SlackConnector.ts @@ -60,16 +60,24 @@ type ConstructorOptions = export default class SlackConnector implements Connector { + /** @hidden */ _client: SlackOAuthClient; + /** @hidden */ _verificationToken: string; + /** @hidden */ _signingSecret: string; + /** @hidden */ _skipLegacyProfile: boolean; + /** @hidden */ _includeBotMessages: boolean; + /** + * constructor + */ constructor(options: ConstructorOptions) { const { verificationToken, @@ -116,6 +124,7 @@ export default class SlackConnector this._includeBotMessages = includeBotMessages || false; } + /** @hidden */ _getRawEventFromRequest(body: SlackRequestBody): SlackRawEvent { if ('event' in body) { return body.event as Message; @@ -132,6 +141,7 @@ export default class SlackConnector return (body as any) as Message; } + /** @hidden */ _isBotEventRequest(body: SlackRequestBody): boolean { const rawEvent = this._getRawEventFromRequest(body); return !!( diff --git a/packages/bottender/src/slack/SlackContext.ts b/packages/bottender/src/slack/SlackContext.ts index 0b300b6b7..94b9bf5c5 100644 --- a/packages/bottender/src/slack/SlackContext.ts +++ b/packages/bottender/src/slack/SlackContext.ts @@ -58,16 +58,11 @@ export default class SlackContext extends Context< update: (options: SlackTypes.UpdateViewOptions) => Promise; }; - constructor({ - client, - event, - session, - initialState, - requestContext, - emitter, - }: Options) { - super({ client, event, session, initialState, requestContext, emitter }); - + /** + * constructor + */ + constructor(options: Options) { + super(options); this.chat = { postMessage: this._postMessage.bind(this), postEphemeral: this._postEphemeral.bind(this), @@ -109,6 +104,7 @@ export default class SlackContext extends Context< } // FIXME: this is to fix type checking + /** @hidden */ _getChannelIdFromSession(callerMethodName = ''): string | null { if ( this._session && @@ -157,6 +153,7 @@ export default class SlackContext extends Context< } /** + * @hidden * Sends a message to a channel. * * https://api.slack.com/methods/chat.postMessage @@ -204,6 +201,7 @@ export default class SlackContext extends Context< } /** + * @hidden * Sends an ephemeral message to a user in a channel. * * https://api.slack.com/methods/chat.postEphemeral @@ -233,6 +231,7 @@ export default class SlackContext extends Context< } /** + * @hidden * Updates a message. * * https://api.slack.com/methods/chat.update @@ -242,6 +241,7 @@ export default class SlackContext extends Context< } /** + * @hidden * Deletes a message. * * https://api.slack.com/methods/chat.delete @@ -262,6 +262,7 @@ export default class SlackContext extends Context< } /** + * @hidden * Share a me message into a channel. * * https://api.slack.com/methods/chat.meMessage @@ -279,6 +280,7 @@ export default class SlackContext extends Context< } /** + * @hidden * Retrieve a permalink URL for a specific extant message * * https://api.slack.com/methods/chat.getPermalink @@ -296,6 +298,7 @@ export default class SlackContext extends Context< } /** + * @hidden * Schedules a message to be sent to a channel. * * https://api.slack.com/methods/chat.scheduleMessage @@ -316,6 +319,7 @@ export default class SlackContext extends Context< } /** + * @hidden * Deletes a pending scheduled message from the queue. * * https://api.slack.com/methods/chat.deleteScheduledMessage @@ -338,6 +342,7 @@ export default class SlackContext extends Context< } /** + * @hidden * Returns a list of scheduled messages. * * https://api.slack.com/methods/chat.scheduledMessages.list @@ -349,6 +354,7 @@ export default class SlackContext extends Context< } /** + * @hidden * Open a view for a user. * * https://api.slack.com/methods/views.open @@ -367,6 +373,7 @@ export default class SlackContext extends Context< } /** + * @hidden * Publish a static view for a User. * * https://api.slack.com/methods/views.publish @@ -376,6 +383,7 @@ export default class SlackContext extends Context< } /** + * @hidden * Update an existing view. * * https://api.slack.com/methods/views.update @@ -385,6 +393,7 @@ export default class SlackContext extends Context< } /** + * @hidden * Push a view onto the stack of a root view. * * https://api.slack.com/methods/views.push diff --git a/packages/bottender/src/slack/SlackEvent.ts b/packages/bottender/src/slack/SlackEvent.ts index d73dae72e..15584f3f6 100644 --- a/packages/bottender/src/slack/SlackEvent.ts +++ b/packages/bottender/src/slack/SlackEvent.ts @@ -129,8 +129,12 @@ export type SlackRawEvent = | CommandEvent; export default class SlackEvent implements Event { + /** @hidden */ _rawEvent: SlackRawEvent; + /** + * constructor + */ constructor(rawEvent: SlackRawEvent) { this._rawEvent = rawEvent; } diff --git a/packages/bottender/src/telegram/TelegramBot.ts b/packages/bottender/src/telegram/TelegramBot.ts index 194084edd..f4bfcda14 100644 --- a/packages/bottender/src/telegram/TelegramBot.ts +++ b/packages/bottender/src/telegram/TelegramBot.ts @@ -18,21 +18,27 @@ export default class TelegramBot extends Bot< TelegramClient, TelegramEvent > { + /** @hidden */ _offset: number | null; + /** @hidden */ _shouldGetUpdates: boolean; - constructor({ - accessToken, - sessionStore, - sync, - origin, - }: { + /** + * constructor + */ + constructor(options: { accessToken: string; sessionStore?: SessionStore; sync?: boolean; origin?: string; }) { + const { + accessToken, + sessionStore, + sync, + origin, + } = options const connector = new TelegramConnector({ accessToken, origin }); super({ connector, sessionStore, sync }); diff --git a/packages/bottender/src/telegram/TelegramConnector.ts b/packages/bottender/src/telegram/TelegramConnector.ts index 6172fee52..0bcab1713 100644 --- a/packages/bottender/src/telegram/TelegramConnector.ts +++ b/packages/bottender/src/telegram/TelegramConnector.ts @@ -29,10 +29,15 @@ type ConstructorOptions = export default class TelegramConnector implements Connector { + /** @hidden */ _client: TelegramClient; + /** @hidden */ _skipLegacyProfile: boolean; + /** + * constructor + */ constructor(options: ConstructorOptions) { const { skipLegacyProfile } = options; if ('client' in options) { @@ -55,6 +60,7 @@ export default class TelegramConnector typeof skipLegacyProfile === 'boolean' ? skipLegacyProfile : true; } + /** @hidden */ _getRawEventFromRequest(body: TelegramRequestBody): TelegramRawEvent { return body; } diff --git a/packages/bottender/src/telegram/TelegramContext.ts b/packages/bottender/src/telegram/TelegramContext.ts index b99a27eed..4d5cb10d8 100644 --- a/packages/bottender/src/telegram/TelegramContext.ts +++ b/packages/bottender/src/telegram/TelegramContext.ts @@ -65,6 +65,7 @@ class TelegramContext extends Context { return this.sendText(text, options); } + /** @hidden */ _getChatId(): number | null { if (this._event.isMessage) { return (this._event.message as any).chat.id; diff --git a/packages/bottender/src/telegram/TelegramEvent.ts b/packages/bottender/src/telegram/TelegramEvent.ts index fd0d3ba32..4a1e4e423 100644 --- a/packages/bottender/src/telegram/TelegramEvent.ts +++ b/packages/bottender/src/telegram/TelegramEvent.ts @@ -192,8 +192,12 @@ export type TelegramRawEvent = { }; export default class TelegramEvent implements Event { + /** @hidden */ _rawEvent: TelegramRawEvent; + /** + * constructor + */ constructor(rawEvent: TelegramRawEvent) { this._rawEvent = rawEvent; } diff --git a/packages/bottender/src/test-utils/ContextSimulator.ts b/packages/bottender/src/test-utils/ContextSimulator.ts index d039aabc2..d26ec9371 100644 --- a/packages/bottender/src/test-utils/ContextSimulator.ts +++ b/packages/bottender/src/test-utils/ContextSimulator.ts @@ -3,21 +3,28 @@ import SimulatedContext from './SimulatedContext'; declare let jest: any; class ContextSimulator { + /** @hidden */ _platform: string; + /** @hidden */ _initialState: Record; + /** @hidden */ _mockFn: Function; - constructor({ - platform, - initialState, - mockFn, - }: { + /** + * constructor + */ + constructor(options: { platform: string; initialState?: Record; mockFn?: Function; }) { + const { + platform, + initialState, + mockFn, + } = options this._platform = platform; this._initialState = initialState || {}; this._mockFn = mockFn || jest.fn; diff --git a/packages/bottender/src/test-utils/SimulatedContext.ts b/packages/bottender/src/test-utils/SimulatedContext.ts index 5ade2961a..50b9f2a3f 100644 --- a/packages/bottender/src/test-utils/SimulatedContext.ts +++ b/packages/bottender/src/test-utils/SimulatedContext.ts @@ -5,8 +5,12 @@ export default class SimulatedContext< C extends Client, E extends Event > extends Context { + /** @hidden */ _platform: string; + /** + * constructor + */ constructor(options: any) { super(options); diff --git a/packages/bottender/src/viber/ViberBot.ts b/packages/bottender/src/viber/ViberBot.ts index ee2c3404d..06ee2c4eb 100644 --- a/packages/bottender/src/viber/ViberBot.ts +++ b/packages/bottender/src/viber/ViberBot.ts @@ -11,19 +11,23 @@ export default class ViberBot extends Bot< ViberClient, ViberEvent > { - constructor({ - accessToken, - sender, - sessionStore, - sync, - origin, - }: { + /** + * constructor + */ + constructor(options: { accessToken: string; sender: ViberTypes.Sender; sessionStore?: SessionStore; sync?: boolean; origin?: string; }) { + const { + accessToken, + sender, + sessionStore, + sync, + origin, + } = options; const connector = new ViberConnector({ accessToken, sender, origin }); super({ connector, sessionStore, sync }); } diff --git a/packages/bottender/src/viber/ViberConnector.ts b/packages/bottender/src/viber/ViberConnector.ts index aad5f2557..4adddc0f5 100644 --- a/packages/bottender/src/viber/ViberConnector.ts +++ b/packages/bottender/src/viber/ViberConnector.ts @@ -32,12 +32,18 @@ type ConstructorOptions = export default class ViberConnector implements Connector { + /** @hidden */ _accessToken: string; + /** @hidden */ _client: ViberClient; + /** @hidden */ _skipLegacyProfile: boolean; + /** + * constructor + */ constructor(options: ConstructorOptions) { const { skipLegacyProfile } = options; if ('client' in options) { @@ -65,6 +71,7 @@ export default class ViberConnector typeof skipLegacyProfile === 'boolean' ? skipLegacyProfile : true; } + /** @hidden */ _getRawEventFromRequest(body: ViberRequestBody): ViberRawEvent { return body; } diff --git a/packages/bottender/src/viber/ViberEvent.ts b/packages/bottender/src/viber/ViberEvent.ts index 4bf1d9661..bcbbb9aee 100644 --- a/packages/bottender/src/viber/ViberEvent.ts +++ b/packages/bottender/src/viber/ViberEvent.ts @@ -100,8 +100,12 @@ export type ViberRawEvent = | MessageEvent; export default class ViberEvent implements Event { + /** @hidden */ _rawEvent: ViberRawEvent; + /** + * constructor + */ constructor(rawEvent: ViberRawEvent) { this._rawEvent = rawEvent; } diff --git a/packages/bottender/src/whatsapp/TwilioClient.ts b/packages/bottender/src/whatsapp/TwilioClient.ts index dc7fe346d..abdef6ecc 100644 --- a/packages/bottender/src/whatsapp/TwilioClient.ts +++ b/packages/bottender/src/whatsapp/TwilioClient.ts @@ -31,14 +31,21 @@ export default class TwilioClient { return new TwilioClient(config); } + /** @hidden */ _onRequest: OnRequestFunction | undefined; + /** @hidden */ _axios: AxiosInstance; + /** @hidden */ _authToken: string; + /** @hidden */ _phoneNumber: string; + /** + * constructor + */ constructor(config: ClientConfig) { const twilioOrigin = `https://${config.accountSid}:${config.authToken}@api.twilio.com`; diff --git a/packages/bottender/src/whatsapp/WhatsappBot.ts b/packages/bottender/src/whatsapp/WhatsappBot.ts index a695e5672..5e0a561f5 100644 --- a/packages/bottender/src/whatsapp/WhatsappBot.ts +++ b/packages/bottender/src/whatsapp/WhatsappBot.ts @@ -10,14 +10,10 @@ export default class WhatsappBot extends Bot< TwilioClient, WhatsappEvent > { - constructor({ - accountSid, - authToken, - phoneNumber, - sessionStore, - sync, - origin, - }: { + /** + * constructor + */ + constructor(options: { accountSid: string; authToken: string; phoneNumber: string; @@ -25,6 +21,14 @@ export default class WhatsappBot extends Bot< sync?: boolean; origin?: string; }) { + const { + accountSid, + authToken, + phoneNumber, + sessionStore, + sync, + origin, + } = options; const connector = new WhatsappConnector({ accountSid, authToken, diff --git a/packages/bottender/src/whatsapp/WhatsappConnector.ts b/packages/bottender/src/whatsapp/WhatsappConnector.ts index 0df4fdfa1..8162833ba 100644 --- a/packages/bottender/src/whatsapp/WhatsappConnector.ts +++ b/packages/bottender/src/whatsapp/WhatsappConnector.ts @@ -44,8 +44,12 @@ function getExpectedTwilioSignature( export default class WhatsappConnector implements Connector { + /** @hidden */ _client: TwilioClient; + /** + * constructor + */ constructor(options: ConstructorOptions) { if ('client' in options) { this._client = options.client; diff --git a/packages/bottender/src/whatsapp/WhatsappEvent.ts b/packages/bottender/src/whatsapp/WhatsappEvent.ts index 7760e41a4..d4b8ab389 100644 --- a/packages/bottender/src/whatsapp/WhatsappEvent.ts +++ b/packages/bottender/src/whatsapp/WhatsappEvent.ts @@ -10,8 +10,12 @@ import { } from './WhatsappTypes'; export default class WhatsappEvent implements Event { + /** @hidden */ _rawEvent: WhatsappRawEvent; + /** + * constructor + */ constructor(rawEvent: WhatsappRawEvent) { this._rawEvent = rawEvent; } From c3d78bbc2f0df5169a4cbb1d614e45e6c59a6401 Mon Sep 17 00:00:00 2001 From: etrex kuo Date: Tue, 24 Mar 2020 11:43:51 +0800 Subject: [PATCH 2/2] fix: lint --- package.json | 2 +- packages/bottender/src/bot/Bot.ts | 2 +- packages/bottender/src/console/ConsoleConnector.ts | 6 +----- packages/bottender/src/console/ConsoleContext.ts | 5 +---- packages/bottender/src/context/Context.ts | 2 +- packages/bottender/src/line/LineBot.ts | 2 +- packages/bottender/src/line/LineContext.ts | 6 +----- packages/bottender/src/messenger/MessengerBot.ts | 2 +- packages/bottender/src/messenger/MessengerContext.ts | 6 +----- packages/bottender/src/server/Server.ts | 2 +- packages/bottender/src/slack/SlackBot.ts | 2 +- packages/bottender/src/telegram/TelegramBot.ts | 7 +------ packages/bottender/src/test-utils/ContextSimulator.ts | 6 +----- packages/bottender/src/viber/ViberBot.ts | 8 +------- 14 files changed, 14 insertions(+), 44 deletions(-) diff --git a/package.json b/package.json index eccb01d4a..cba387020 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "compile": "tsc --build tsconfig.build.json", "compile:clean": "tsc --build tsconfig.build.json --clean", "postinstall": "yarn compile", - "lint": "eslint packages examples --ext=js,ts", + "lint": "eslint packages examples --ext=js,ts --ignore-pattern **/docs", "lint:fix": "yarn lint:fix:md && yarn lint --fix", "lint:fix:md": "prettier --write **/*.md", "lint:staged": "lint-staged", diff --git a/packages/bottender/src/bot/Bot.ts b/packages/bottender/src/bot/Bot.ts index 9dbcd43d6..2b85fc6ea 100644 --- a/packages/bottender/src/bot/Bot.ts +++ b/packages/bottender/src/bot/Bot.ts @@ -109,7 +109,7 @@ export default class Bot { connector, sessionStore = createMemorySessionStore(), sync = false, - } = options + } = options; this._sessions = sessionStore; this._initialized = false; this._connector = connector; diff --git a/packages/bottender/src/console/ConsoleConnector.ts b/packages/bottender/src/console/ConsoleConnector.ts index 28bd4b116..b3bf11ae2 100644 --- a/packages/bottender/src/console/ConsoleConnector.ts +++ b/packages/bottender/src/console/ConsoleConnector.ts @@ -31,11 +31,7 @@ export default class ConsoleConnector * constructor */ constructor(options: ConstructorOptions = {}) { - const { - client, - fallbackMethods, - mockPlatform, - } = options + const { client, fallbackMethods, mockPlatform } = options; this._client = client || { sendText: (text): void => { process.stdout.write(`Bot > ${text}\n`); diff --git a/packages/bottender/src/console/ConsoleContext.ts b/packages/bottender/src/console/ConsoleContext.ts index 47893dec2..0e7408321 100644 --- a/packages/bottender/src/console/ConsoleContext.ts +++ b/packages/bottender/src/console/ConsoleContext.ts @@ -41,10 +41,7 @@ export default class ConsoleContext extends Context< */ constructor(options: Options) { super(options); - const { - fallbackMethods, - mockPlatform, - } = options + const { fallbackMethods, mockPlatform } = options; this._mockPlatform = mockPlatform; this._fallbackMethods = fallbackMethods; if (fallbackMethods) { diff --git a/packages/bottender/src/context/Context.ts b/packages/bottender/src/context/Context.ts index 0534dfbb8..3b13a6617 100644 --- a/packages/bottender/src/context/Context.ts +++ b/packages/bottender/src/context/Context.ts @@ -74,7 +74,7 @@ export default abstract class Context { initialState, requestContext, emitter, - } = options + } = options; this._client = client; this._event = event; this._session = session || null; diff --git a/packages/bottender/src/line/LineBot.ts b/packages/bottender/src/line/LineBot.ts index d63fedd79..fc4f74a44 100644 --- a/packages/bottender/src/line/LineBot.ts +++ b/packages/bottender/src/line/LineBot.ts @@ -35,7 +35,7 @@ export default class LineBot extends Bot< shouldBatch, sendMethod, skipLegacyProfile, - } = options + } = options; const connector = new LineConnector({ accessToken, channelSecret, diff --git a/packages/bottender/src/line/LineContext.ts b/packages/bottender/src/line/LineContext.ts index e1be65958..2cd2cc900 100644 --- a/packages/bottender/src/line/LineContext.ts +++ b/packages/bottender/src/line/LineContext.ts @@ -48,11 +48,7 @@ class LineContext extends Context { */ constructor(options: Options) { super(options); - const { - customAccessToken, - shouldBatch, - sendMethod, - } = options + const { customAccessToken, shouldBatch, sendMethod } = options; this._customAccessToken = customAccessToken || null; this._shouldBatch = shouldBatch || false; this._sendMethod = sendMethod || 'reply'; diff --git a/packages/bottender/src/messenger/MessengerBot.ts b/packages/bottender/src/messenger/MessengerBot.ts index e7cc2e4fb..12f898517 100644 --- a/packages/bottender/src/messenger/MessengerBot.ts +++ b/packages/bottender/src/messenger/MessengerBot.ts @@ -39,7 +39,7 @@ export default class MessengerBot extends Bot< origin, skipAppSecretProof, skipLegacyProfile, - } = options + } = options; const connector = new MessengerConnector({ accessToken, appId, diff --git a/packages/bottender/src/messenger/MessengerContext.ts b/packages/bottender/src/messenger/MessengerContext.ts index 5a2f1d28f..9e7530796 100644 --- a/packages/bottender/src/messenger/MessengerContext.ts +++ b/packages/bottender/src/messenger/MessengerContext.ts @@ -45,11 +45,7 @@ class MessengerContext extends Context { */ constructor(options: Options) { super(options); - const { - appId, - customAccessToken, - batchQueue, - } = options + const { appId, customAccessToken, batchQueue } = options; this._customAccessToken = customAccessToken || null; this._batchQueue = batchQueue || null; this._appId = appId || null; diff --git a/packages/bottender/src/server/Server.ts b/packages/bottender/src/server/Server.ts index bdb81792f..bbfa8c9d7 100644 --- a/packages/bottender/src/server/Server.ts +++ b/packages/bottender/src/server/Server.ts @@ -26,7 +26,7 @@ class Server { * constructor */ constructor(options: { useConsole?: boolean } = {}) { - const { useConsole = false } = options + const { useConsole = false } = options; this.useConsole = useConsole; } diff --git a/packages/bottender/src/slack/SlackBot.ts b/packages/bottender/src/slack/SlackBot.ts index 4563ad9fa..df458044c 100644 --- a/packages/bottender/src/slack/SlackBot.ts +++ b/packages/bottender/src/slack/SlackBot.ts @@ -37,7 +37,7 @@ export default class SlackBot extends Bot< origin, skipLegacyProfile, includeBotMessages, - } = options + } = options; const connector = new SlackConnector({ accessToken, verificationToken, diff --git a/packages/bottender/src/telegram/TelegramBot.ts b/packages/bottender/src/telegram/TelegramBot.ts index f4bfcda14..2f4e974f2 100644 --- a/packages/bottender/src/telegram/TelegramBot.ts +++ b/packages/bottender/src/telegram/TelegramBot.ts @@ -33,12 +33,7 @@ export default class TelegramBot extends Bot< sync?: boolean; origin?: string; }) { - const { - accessToken, - sessionStore, - sync, - origin, - } = options + const { accessToken, sessionStore, sync, origin } = options; const connector = new TelegramConnector({ accessToken, origin }); super({ connector, sessionStore, sync }); diff --git a/packages/bottender/src/test-utils/ContextSimulator.ts b/packages/bottender/src/test-utils/ContextSimulator.ts index d26ec9371..e489fa330 100644 --- a/packages/bottender/src/test-utils/ContextSimulator.ts +++ b/packages/bottender/src/test-utils/ContextSimulator.ts @@ -20,11 +20,7 @@ class ContextSimulator { initialState?: Record; mockFn?: Function; }) { - const { - platform, - initialState, - mockFn, - } = options + const { platform, initialState, mockFn } = options; this._platform = platform; this._initialState = initialState || {}; this._mockFn = mockFn || jest.fn; diff --git a/packages/bottender/src/viber/ViberBot.ts b/packages/bottender/src/viber/ViberBot.ts index 06ee2c4eb..28dc3db33 100644 --- a/packages/bottender/src/viber/ViberBot.ts +++ b/packages/bottender/src/viber/ViberBot.ts @@ -21,13 +21,7 @@ export default class ViberBot extends Bot< sync?: boolean; origin?: string; }) { - const { - accessToken, - sender, - sessionStore, - sync, - origin, - } = options; + const { accessToken, sender, sessionStore, sync, origin } = options; const connector = new ViberConnector({ accessToken, sender, origin }); super({ connector, sessionStore, sync }); }