@@ -225,7 +225,7 @@ export interface Campaign {
225
225
template_name : string
226
226
}
227
227
228
- export interface SessionUser {
228
+ export interface SessionUser < TExtraData = any > {
229
229
id : string
230
230
// login
231
231
username ?: string
@@ -234,7 +234,7 @@ export interface SessionUser {
234
234
// whatsapp, telegram,...
235
235
provider : ProviderType
236
236
// The provider's user id
237
- extra_data ?: any
237
+ extra_data ?: TExtraData
238
238
imp_id ?: string
239
239
provider_id ?: string
240
240
locale : string
@@ -253,7 +253,7 @@ export interface SessionBot {
253
253
name ?: string
254
254
}
255
255
256
- export interface Session {
256
+ export interface Session < TExtraData = any > {
257
257
bot : SessionBot
258
258
__retries : number
259
259
_access_token : string
@@ -263,7 +263,7 @@ export interface Session {
263
263
last_session ?: any
264
264
organization_id : string
265
265
organization : string
266
- user : SessionUser
266
+ user : SessionUser < TExtraData >
267
267
// after handoff
268
268
_botonic_action ?: BotonicActionType
269
269
_hubtype_case_status ?: CaseStatusType
@@ -314,14 +314,18 @@ export interface Route {
314
314
315
315
export type Routes < R = Route > = R [ ] | ( ( _ : BotRequest ) => R [ ] )
316
316
317
- export interface BotRequest {
317
+ export interface BotRequest < TExtraData = any > {
318
318
input : Input
319
319
lastRoutePath : RoutePath
320
- session : Session
320
+ session : Session < TExtraData >
321
321
}
322
322
323
- export interface BotContext < T extends ResolvedPlugins = ResolvedPlugins >
324
- extends BotRequest {
323
+ export interface BotContext <
324
+ TPlugins extends ResolvedPlugins = ResolvedPlugins ,
325
+ TExtraData = any ,
326
+ > extends BotRequest < TExtraData > {
327
+ // TODO: remove getString function?
328
+ getString : ( stringId : string ) => string
325
329
getUserCountry : ( ) => string
326
330
getUserLocale : ( ) => string
327
331
getSystemLocale : ( ) => string
@@ -331,7 +335,7 @@ export interface BotContext<T extends ResolvedPlugins = ResolvedPlugins>
331
335
defaultDelay : number
332
336
defaultTyping : number
333
337
params : Record < string , string >
334
- plugins : T
338
+ plugins : TPlugins
335
339
}
336
340
337
341
/** The response of the bot for the triggered actions, which can be
@@ -342,13 +346,17 @@ export interface BotResponse extends BotRequest {
342
346
response : any
343
347
}
344
348
345
- export type PluginPreRequest < T extends ResolvedPlugins = ResolvedPlugins > =
346
- BotContext < T >
349
+ export type PluginPreRequest <
350
+ TPlugins extends ResolvedPlugins = ResolvedPlugins ,
351
+ TExtraData = any ,
352
+ > = BotContext < TPlugins , TExtraData >
347
353
348
- export type PluginPostRequest < T extends ResolvedPlugins = ResolvedPlugins > =
349
- BotContext < T > & {
350
- response : string | null
351
- }
354
+ export type PluginPostRequest <
355
+ TPlugins extends ResolvedPlugins = ResolvedPlugins ,
356
+ TExtraData = any ,
357
+ > = BotContext < TPlugins , TExtraData > & {
358
+ response : string | null
359
+ }
352
360
353
361
export interface Plugin {
354
362
post ?( request : PluginPostRequest ) : void | Promise < void >
0 commit comments