Smart Flows Session

Session

Smart Flow Session Module

Manages session persistence and state management, handling CRUD operations for sessions, flows, and component states

Session.create() ⇒ Promise<SessionCreateResult>

Creates or updates a Smart Flow session

Returns: Promise<SessionCreateResult> - Object containing the session and metadata

Session.get() ⇒ Promise<FlowSessionTable>

Retrieves the current session or creates a new one

Returns: Promise<FlowSessionTable> - The current session
Throws:

  • Error If session retrieval fails

Session.getComponent(flowId, component) ⇒ Promise<FlowComponentTable>

Retrieves a component's state from the database

Returns: Promise<FlowComponentTable> - The component's session data

ParamTypeDescription
flowIdnumberThe ID of the flow
componentSmartFlowComponentThe component to retrieve

Session.getFlow(flowId) ⇒ Promise<FlowTable>

Retrieves or initializes a flow

Returns: Promise<FlowTable> - The flow data

ParamTypeDescription
flowIdnumberThe ID of the flow

Session.getSessionActivity() ⇒ Promise<{activeTime: number, lastActive: number, isReturningUser: boolean}>

Retrieves the current session activity metrics with recalculation

Returns: Promise<{activeTime: number, lastActive: number, isReturningUser: boolean}> - Session activity data

Session.init() ⇒ Promise<SmartFlowSessionModule>

Initializes the Smart Flow session and calculates user activity metrics

Returns: Promise<SmartFlowSessionModule> - The initialized Session module

Session.remove([excludeId]) ⇒ Promise<void>

Removes session(s) from the database

ParamTypeDescription
[excludeId]stringOptional ID of session to exclude from deletion

Session.removeComponent(flowId, component) ⇒ Promise<void>

Removes a component from the database

ParamTypeDescription
flowIdnumberThe ID of the flow
componentSmartFlowComponentThe component to remove

Session.removeFlow(flowId) ⇒ Promise<void>

Removes a flow and its components from the database

ParamTypeDescription
flowIdnumberThe ID of the flow to remove

Session.save(session) ⇒ Promise<FlowSessionTable>

Saves session changes to the database

Returns: Promise<FlowSessionTable> - The updated session

ParamTypeDescription
sessionFlowSessionTableThe session to save

Session.saveComponent(flowId, component, state) ⇒ Promise<FlowComponentTable>

Saves component state changes to the database

Returns: Promise<FlowComponentTable> - The updated component session
Throws:

  • Error If flowId or component.id is invalid
ParamTypeDescription
flowIdnumberThe ID of the flow
componentSmartFlowComponentThe component to update
stateobjectThe state changes to save

Session.saveFlow(flowId, state) ⇒ Promise<FlowTable>

Saves flow state changes to the database

Returns: Promise<FlowTable> - The updated flow

ParamTypeDescription
flowIdnumberThe ID of the flow
statePartial<FlowTable>The state changes to save

Session.update([session]) ⇒ Promise<FlowSessionTable>

Updates an existing session or creates a new one

Returns: Promise<FlowSessionTable> - The updated or new session

ParamTypeDescription
[session]FlowSessionTableOptional session to update

SessionCreateResult : Array

Tuple containing the session and associated metadata

Properties

NameTypeDescription
sessionFlowSessionTableThe session object
metaFlowSessionMetaThe session metadata