sessions / Exports / SessionImpl
Class: SessionImpl
Improved Session Implementation
Uses state machine pattern and pure functions for better maintainability
Implements
Table of contents
Constructors
Properties
Methods
- createNewChat
- getChat
- getAllChats
- switchToChat
- removeChat
- getActiveChat
- pause
- resume
- archive
- terminate
- save
- load
- getState
- updateConfig
- getStats
Constructors
constructor
• new SessionImpl(userId
, config?
): SessionImpl
Parameters
Name | Type |
---|---|
userId | string |
config | SessionConfig |
Returns
Defined in
packages/sessions/src/session/session-impl.ts:47
Properties
metadata
• Readonly
metadata: SessionMetadata
Implementation of
Defined in
packages/sessions/src/session/session-impl.ts:40
config
• Readonly
config: SessionConfig
Implementation of
Defined in
packages/sessions/src/session/session-impl.ts:41
Methods
createNewChat
▸ createNewChat(config?
): Promise
<ChatInstance
>
Parameters
Name | Type |
---|---|
config? | ChatConfig |
Returns
Promise
<ChatInstance
>
Implementation of
Defined in
packages/sessions/src/session/session-impl.ts:67
getChat
▸ getChat(chatId
): undefined
| ChatInstance
Parameters
Name | Type |
---|---|
chatId | string |
Returns
undefined
| ChatInstance
Implementation of
Defined in
packages/sessions/src/session/session-impl.ts:94
getAllChats
▸ getAllChats(): ChatInstance
[]
Returns
Implementation of
Defined in
packages/sessions/src/session/session-impl.ts:98
switchToChat
▸ switchToChat(chatId
): Promise
<void
>
Parameters
Name | Type |
---|---|
chatId | string |
Returns
Promise
<void
>
Implementation of
Defined in
packages/sessions/src/session/session-impl.ts:102
removeChat
▸ removeChat(chatId
): Promise
<void
>
Parameters
Name | Type |
---|---|
chatId | string |
Returns
Promise
<void
>
Implementation of
Defined in
packages/sessions/src/session/session-impl.ts:114
getActiveChat
▸ getActiveChat(): undefined
| ChatInstance
Returns
undefined
| ChatInstance
Implementation of
Defined in
packages/sessions/src/session/session-impl.ts:139
pause
▸ pause(): Promise
<void
>
Returns
Promise
<void
>
Implementation of
Defined in
packages/sessions/src/session/session-impl.ts:147
resume
▸ resume(): Promise
<void
>
Returns
Promise
<void
>
Implementation of
Defined in
packages/sessions/src/session/session-impl.ts:152
archive
▸ archive(): Promise
<void
>
Returns
Promise
<void
>
Implementation of
Defined in
packages/sessions/src/session/session-impl.ts:164
terminate
▸ terminate(): Promise
<void
>
Returns
Promise
<void
>
Implementation of
Defined in
packages/sessions/src/session/session-impl.ts:169
save
▸ save(): Promise
<void
>
Returns
Promise
<void
>
Implementation of
Defined in
packages/sessions/src/session/session-impl.ts:181
load
▸ load(): Promise
<void
>
Returns
Promise
<void
>
Implementation of
Defined in
packages/sessions/src/session/session-impl.ts:186
getState
▸ getState(): SessionState
Returns
SessionState
Implementation of
Defined in
packages/sessions/src/session/session-impl.ts:191
updateConfig
▸ updateConfig(config
): void
Parameters
Name | Type |
---|---|
config | Partial <SessionConfig > |
Returns
void
Implementation of
Defined in
packages/sessions/src/session/session-impl.ts:195
getStats
▸ getStats(): SessionStats