@@ -229,7 +229,7 @@ export interface Campaign {
229
229
template_name : string
230
230
}
231
231
232
- export interface SessionUser {
232
+ export interface SessionUser < TExtraData = any > {
233
233
id : string
234
234
// login
235
235
username ?: string
@@ -238,7 +238,7 @@ export interface SessionUser {
238
238
// whatsapp, telegram,...
239
239
provider : ProviderType
240
240
// The provider's user id
241
- extra_data ?: any
241
+ extra_data ?: TExtraData
242
242
imp_id ?: string
243
243
provider_id ?: string
244
244
locale : string
@@ -257,7 +257,7 @@ export interface SessionBot {
257
257
name ?: string
258
258
}
259
259
260
- export interface Session {
260
+ export interface Session < TExtraData = any > {
261
261
bot : SessionBot
262
262
__retries : number
263
263
_access_token : string
@@ -267,7 +267,7 @@ export interface Session {
267
267
last_session ?: any
268
268
organization_id : string
269
269
organization : string
270
- user : SessionUser
270
+ user : SessionUser < TExtraData >
271
271
// after handoff
272
272
_botonic_action ?: BotonicActionType
273
273
_hubtype_case_status ?: CaseStatusType
@@ -318,14 +318,16 @@ export interface Route {
318
318
319
319
export type Routes < R = Route > = R [ ] | ( ( _ : BotRequest ) => R [ ] )
320
320
321
- export interface BotRequest {
321
+ export interface BotRequest < TExtraData = any > {
322
322
input : Input
323
323
lastRoutePath : RoutePath
324
- session : Session
324
+ session : Session < TExtraData >
325
325
}
326
326
327
- export interface BotContext < T extends ResolvedPlugins = ResolvedPlugins >
328
- extends BotRequest {
327
+ export interface BotContext <
328
+ TPlugins extends ResolvedPlugins = ResolvedPlugins ,
329
+ TExtraData = any ,
330
+ > extends BotRequest < TExtraData > {
329
331
// TODO: remove getString function?
330
332
getString : ( stringId : string ) => string
331
333
getUserCountry : ( ) => string
@@ -337,7 +339,7 @@ export interface BotContext<T extends ResolvedPlugins = ResolvedPlugins>
337
339
defaultDelay : number
338
340
defaultTyping : number
339
341
params : Record < string , string >
340
- plugins : T
342
+ plugins : TPlugins
341
343
}
342
344
343
345
/** The response of the bot for the triggered actions, which can be
@@ -348,13 +350,17 @@ export interface BotResponse extends BotRequest {
348
350
response : any
349
351
}
350
352
351
- export type PluginPreRequest < T extends ResolvedPlugins = ResolvedPlugins > =
352
- BotContext < T >
353
+ export type PluginPreRequest <
354
+ TPlugins extends ResolvedPlugins = ResolvedPlugins ,
355
+ TExtraData = any ,
356
+ > = BotContext < TPlugins , TExtraData >
353
357
354
- export type PluginPostRequest < T extends ResolvedPlugins = ResolvedPlugins > =
355
- BotContext < T > & {
356
- response : string | null
357
- }
358
+ export type PluginPostRequest <
359
+ TPlugins extends ResolvedPlugins = ResolvedPlugins ,
360
+ TExtraData = any ,
361
+ > = BotContext < TPlugins , TExtraData > & {
362
+ response : string | null
363
+ }
358
364
359
365
export interface Plugin {
360
366
post ?( request : PluginPostRequest ) : void | Promise < void >
0 commit comments