Skip to content

Commit

Permalink
chore(core/react): improve typing for CoreBot and add for NodeApp
Browse files Browse the repository at this point in the history
  • Loading branch information
dpinol committed Jul 29, 2019
1 parent 694ef53 commit 8a18cd5
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 12 deletions.
31 changes: 21 additions & 10 deletions packages/botonic-core/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,30 @@ export declare function storeCaseRating(
rating: number
): Promise<any>

interface BotOptions {
routes: Routes
locales: Locales
integrations?: { [id: string]: any }
theme?: string
/** The plugin configurations */
plugins?: { [id: string]: any }
appId?: string
defaultTyping?: number
defaultDelay?: number
}
type Routes = Route[] | ((_: { input: Input; session: Session }) => Route[])

export class CoreBot {
constructor(_: {
routes: Routes
locales: Locales
integrations?: { [id: string]: any }
theme?: string
plugins?: { [id: string]: any }
appId?: string
defaultTyping?: number
defaultDelay?: number
})
routes: Routes
locales: Locales;
integrations?: {[id: string]: any};
theme?: string;
/** The instantiated plugin instances */
plugins: { [id: string]: any};
defaultTyping : number;
defaultDelay : number;

constructor(options: BotOptions)

getString(stringID: string, session: Session): string

Expand Down
22 changes: 20 additions & 2 deletions packages/botonic-react/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Input, Locales, Routes, Session } from '@botonic/core';
import * as React from 'react'
import * as core from '@botonic/core'

Expand Down Expand Up @@ -47,6 +48,23 @@ export class Title extends React.Component<any, any> {}
export class Subtitle extends React.Component<any, any> {}
export class Element extends React.Component<any, any> {}

export class NodeApp {
constructor(options: core.BotOptions);

renderNode(args): string;

input(_: {
input: Input
session?: Session
lastRoutePath: string
}): {
input: Input
response: React.ReactNode
session: Session
lastRoutePath: string
}
}

// Parameters of the actions' botonicInit method
export interface ActionInitInput {
input: core.Input
Expand All @@ -57,7 +75,7 @@ export interface ActionInitInput {
}

export class BotonicInputTester {
constructor(app: core.CoreBot)
constructor(app: NodeApp)

text(
inp: string,
Expand All @@ -73,7 +91,7 @@ export class BotonicInputTester {
}

export class BotonicOutputTester {
constructor(app: core.CoreBot)
constructor(app: NodeApp)

text(out: string, replies?: any): Promise<string>
}
Expand Down

0 comments on commit 8a18cd5

Please sign in to comment.