From 2557b9674bf216e38ca5e6f5eed17f5de5adf58a Mon Sep 17 00:00:00 2001 From: tenorok Date: Sun, 17 Dec 2017 20:51:14 +0300 Subject: [PATCH] d.ts for wechat --- broid-wechat/lib/core/Adapter.d.ts | 31 ++++++++++++++++++++++++ broid-wechat/lib/core/Parser.d.ts | 18 ++++++++++++++ broid-wechat/lib/core/WebHookServer.d.ts | 16 ++++++++++++ broid-wechat/lib/core/index.d.ts | 2 ++ broid-wechat/lib/core/interfaces.d.ts | 11 +++++++++ broid-wechat/lib/test/Parser.d.ts | 0 broid-wechat/yarn.lock | 16 +++++------- 7 files changed, 84 insertions(+), 10 deletions(-) create mode 100644 broid-wechat/lib/core/Adapter.d.ts create mode 100644 broid-wechat/lib/core/Parser.d.ts create mode 100644 broid-wechat/lib/core/WebHookServer.d.ts create mode 100644 broid-wechat/lib/core/index.d.ts create mode 100644 broid-wechat/lib/core/interfaces.d.ts create mode 100644 broid-wechat/lib/test/Parser.d.ts diff --git a/broid-wechat/lib/core/Adapter.d.ts b/broid-wechat/lib/core/Adapter.d.ts new file mode 100644 index 00000000..1f7fd9c9 --- /dev/null +++ b/broid-wechat/lib/core/Adapter.d.ts @@ -0,0 +1,31 @@ +/// +/// +import { ISendParameters } from '@broid/schemas'; +import * as Promise from 'bluebird'; +import { Router } from 'express'; +import { Observable } from 'rxjs/Rx'; +import { IAdapterOptions } from './interfaces'; +export declare class Adapter { + serviceID: string; + private appID; + private appSecret; + private client; + private connected; + private emitter; + private logLevel; + private logger; + private parser; + private router; + private webhookServer; + constructor(obj: IAdapterOptions); + serviceId(): string; + serviceName(): string; + connect(): Observable; + disconnect(): Promise; + listen(): Observable; + users(): Promise; + getRouter(): Router | null; + send(data: ISendParameters): Promise; + private uploadFile(url, fType, file); + private setupRouter(); +} diff --git a/broid-wechat/lib/core/Parser.d.ts b/broid-wechat/lib/core/Parser.d.ts new file mode 100644 index 00000000..28d33ff9 --- /dev/null +++ b/broid-wechat/lib/core/Parser.d.ts @@ -0,0 +1,18 @@ +/// +import { IActivityStream } from '@broid/schemas'; +import * as Promise from 'bluebird'; +export declare class Parser { + generatorName: string; + serviceID: string; + private logger; + private userCache; + private wechatClient; + constructor(serviceName: string, wechatClient: any, serviceID: string, logLevel: string); + validate(event: object | null): Promise; + parse(event: object): Promise; + private getUserName(openid); + private createActivityStream(normalized); + private parseImage(normalized); + private parseText(normalized); + private parseMultiMedia(normalized, messageType, mediaType); +} diff --git a/broid-wechat/lib/core/WebHookServer.d.ts b/broid-wechat/lib/core/WebHookServer.d.ts new file mode 100644 index 00000000..84748296 --- /dev/null +++ b/broid-wechat/lib/core/WebHookServer.d.ts @@ -0,0 +1,16 @@ +/// +/// +import * as Promise from 'bluebird'; +import * as express from 'express'; +import { IAdapterHTTPOptions } from './interfaces'; +export declare class WebHookServer { + private express; + private host; + private httpClient; + private logger; + private port; + constructor(options: IAdapterHTTPOptions, router: express.Router, logLevel: string); + listen(): void; + close(): Promise; + private setupExpress(router); +} diff --git a/broid-wechat/lib/core/index.d.ts b/broid-wechat/lib/core/index.d.ts new file mode 100644 index 00000000..6485757c --- /dev/null +++ b/broid-wechat/lib/core/index.d.ts @@ -0,0 +1,2 @@ +import { Adapter } from './Adapter'; +export = Adapter; diff --git a/broid-wechat/lib/core/interfaces.d.ts b/broid-wechat/lib/core/interfaces.d.ts new file mode 100644 index 00000000..d1066d67 --- /dev/null +++ b/broid-wechat/lib/core/interfaces.d.ts @@ -0,0 +1,11 @@ +export interface IAdapterHTTPOptions { + host: string; + port: number; +} +export interface IAdapterOptions { + appID: string; + appSecret: string; + serviceID?: string; + logLevel?: string; + http?: IAdapterHTTPOptions; +} diff --git a/broid-wechat/lib/test/Parser.d.ts b/broid-wechat/lib/test/Parser.d.ts new file mode 100644 index 00000000..e69de29b diff --git a/broid-wechat/yarn.lock b/broid-wechat/yarn.lock index 7af1722f..1d9db5f6 100644 --- a/broid-wechat/yarn.lock +++ b/broid-wechat/yarn.lock @@ -1169,13 +1169,13 @@ debug-log@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/debug-log/-/debug-log-1.0.1.tgz#2307632d4c04382b8df8a32f70b895046d52745f" -debug@2, debug@2.6.3, debug@^2.1.1, debug@^2.1.3: +debug@2, debug@2.6.3, debug@^2.1.1, debug@^2.1.3, debug@^2.6.0: version "2.6.3" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.3.tgz#0f7eb8c30965ec08c72accfa0130c8b79984141d" dependencies: ms "0.7.2" -debug@2.6.1, debug@^2.2.0, debug@^2.6.0: +debug@2.6.1, debug@^2.2.0: version "2.6.1" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.1.tgz#79855090ba2c4e3115cc7d8769491d58f0491351" dependencies: @@ -3783,11 +3783,7 @@ uuid@^2.0.1: version "2.0.3" resolved "https://registry.yarnpkg.com/uuid/-/uuid-2.0.3.tgz#67e2e863797215530dff318e5bf9dcebfd47b21a" -uuid@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.0.1.tgz#6544bba2dfda8c1cf17e629a3a305e2bb1fee6c1" - -uuid@^3.1.0: +uuid@^3.0.0, uuid@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.1.0.tgz#3dd3d3e790abc24d7b0d3a034ffababe28ebbc04" @@ -3819,9 +3815,9 @@ watch@^1.0.1: exec-sh "^0.2.0" minimist "^1.2.0" -"wechat-api@git+https://git@github.com/node-webot/wechat-api.git#295ad45e199ef93610c4d3a9350de6992a932d8c": - version "1.32.0" - resolved "git+https://git@github.com/node-webot/wechat-api.git#295ad45e199ef93610c4d3a9350de6992a932d8c" +wechat-api@^1.35.0: + version "1.35.1" + resolved "https://registry.yarnpkg.com/wechat-api/-/wechat-api-1.35.1.tgz#cd639bc1729ecb5d80a6ac92064c24d8ed8ee65b" dependencies: formstream ">=1.0.0" urllib "2.21.0"