Documentation
¶
Index ¶
- type BaseFlow
- func (f *BaseFlow) AddAfterHook(stepID string, hook HookFunc) Flow
- func (f *BaseFlow) AddBeforeHook(stepID string, hook HookFunc) Flow
- func (f *BaseFlow) AddStep(step *Step) Flow
- func (f *BaseFlow) Execute(ctx context.Context, data map[string]interface{}) (*FlowResult, error)
- func (f *BaseFlow) ID() string
- func (f *BaseFlow) Name() string
- func (f *BaseFlow) Steps() []*Step
- type Flow
- type FlowBuilder
- type FlowContext
- func (fc *FlowContext) AddError(err string)
- func (fc *FlowContext) ClearErrors()
- func (fc *FlowContext) Clone() *FlowContext
- func (fc *FlowContext) Context() context.Context
- func (fc *FlowContext) CurrentStep() string
- func (fc *FlowContext) Duration() time.Duration
- func (fc *FlowContext) FlowID() string
- func (fc *FlowContext) Get(key string) (interface{}, bool)
- func (fc *FlowContext) GetBool(key string) bool
- func (fc *FlowContext) GetData() map[string]interface{}
- func (fc *FlowContext) GetErrors() []string
- func (fc *FlowContext) GetInt(key string) int
- func (fc *FlowContext) GetMetadata(key string) (interface{}, bool)
- func (fc *FlowContext) GetString(key string) string
- func (fc *FlowContext) HasErrors() bool
- func (fc *FlowContext) MergeData(data map[string]interface{})
- func (fc *FlowContext) OrgID() string
- func (fc *FlowContext) SessionID() string
- func (fc *FlowContext) Set(key string, value interface{})
- func (fc *FlowContext) SetCurrentStep(stepID string)
- func (fc *FlowContext) SetData(data map[string]interface{})
- func (fc *FlowContext) SetMetadata(key string, value interface{})
- func (fc *FlowContext) SetOrgID(orgID string)
- func (fc *FlowContext) SetSessionID(sessionID string)
- func (fc *FlowContext) SetUserID(userID string)
- func (fc *FlowContext) StartTime() time.Time
- func (fc *FlowContext) UserID() string
- type FlowResult
- type HookFunc
- type Registry
- func (r *Registry) Clear()
- func (r *Registry) Count() int
- func (r *Registry) Exists(id string) bool
- func (r *Registry) Get(id string) (Flow, error)
- func (r *Registry) List() []Flow
- func (r *Registry) ListIDs() []string
- func (r *Registry) Register(flow Flow) error
- func (r *Registry) Unregister(id string) error
- type SignupFlow
- type Step
- type StepHandler
- type StepResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseFlow ¶
type BaseFlow struct {
// contains filtered or unexported fields
}
BaseFlow provides a basic implementation of the Flow interface
func (*BaseFlow) AddAfterHook ¶
AddAfterHook adds a hook to run after a specific step
func (*BaseFlow) AddBeforeHook ¶
AddBeforeHook adds a hook to run before a specific step
type Flow ¶
type Flow interface {
// ID returns the unique identifier for this flow
ID() string
// Name returns the human-readable name for this flow
Name() string
// Execute runs the flow with the given context and data
Execute(ctx context.Context, data map[string]interface{}) (*FlowResult, error)
// Steps returns all steps in this flow
Steps() []*Step
// AddStep adds a step to the flow
AddStep(step *Step) Flow
// AddBeforeHook adds a hook to run before a specific step
AddBeforeHook(stepID string, hook HookFunc) Flow
// AddAfterHook adds a hook to run after a specific step
AddAfterHook(stepID string, hook HookFunc) Flow
}
Flow represents a customizable authentication flow
type FlowBuilder ¶
type FlowBuilder struct {
// contains filtered or unexported fields
}
FlowBuilder provides a fluent interface for building flows
func NewFlowBuilder ¶
func NewFlowBuilder(id, name string) *FlowBuilder
NewFlowBuilder creates a new flow builder
func (*FlowBuilder) After ¶
func (b *FlowBuilder) After(stepID string, hook HookFunc) *FlowBuilder
After adds an after hook for the specified step
func (*FlowBuilder) Before ¶
func (b *FlowBuilder) Before(stepID string, hook HookFunc) *FlowBuilder
Before adds a before hook for the specified step
func (*FlowBuilder) Step ¶
func (b *FlowBuilder) Step(id, name, stepType string, required bool, config map[string]interface{}, handler StepHandler) *FlowBuilder
Step adds a step to the flow being built
type FlowContext ¶
type FlowContext struct {
// contains filtered or unexported fields
}
FlowContext provides execution context for flows with state management
func NewFlowContext ¶
func NewFlowContext(ctx context.Context, flowID string) *FlowContext
NewFlowContext creates a new flow context
func (*FlowContext) AddError ¶
func (fc *FlowContext) AddError(err string)
AddError adds an error to the context
func (*FlowContext) ClearErrors ¶
func (fc *FlowContext) ClearErrors()
ClearErrors removes all errors
func (*FlowContext) Clone ¶
func (fc *FlowContext) Clone() *FlowContext
Clone creates a copy of the flow context
func (*FlowContext) Context ¶
func (fc *FlowContext) Context() context.Context
Context returns the underlying context.Context
func (*FlowContext) CurrentStep ¶
func (fc *FlowContext) CurrentStep() string
CurrentStep returns the current step ID
func (*FlowContext) Duration ¶
func (fc *FlowContext) Duration() time.Duration
Duration returns how long the flow has been running
func (*FlowContext) Get ¶
func (fc *FlowContext) Get(key string) (interface{}, bool)
Get retrieves a value from the flow data
func (*FlowContext) GetBool ¶
func (fc *FlowContext) GetBool(key string) bool
GetBool retrieves a boolean value from the flow data
func (*FlowContext) GetData ¶
func (fc *FlowContext) GetData() map[string]interface{}
GetData returns a copy of all flow data
func (*FlowContext) GetErrors ¶
func (fc *FlowContext) GetErrors() []string
GetErrors returns all errors
func (*FlowContext) GetInt ¶
func (fc *FlowContext) GetInt(key string) int
GetInt retrieves an integer value from the flow data
func (*FlowContext) GetMetadata ¶
func (fc *FlowContext) GetMetadata(key string) (interface{}, bool)
GetMetadata retrieves a metadata value
func (*FlowContext) GetString ¶
func (fc *FlowContext) GetString(key string) string
GetString retrieves a string value from the flow data
func (*FlowContext) HasErrors ¶
func (fc *FlowContext) HasErrors() bool
HasErrors returns true if there are any errors
func (*FlowContext) MergeData ¶
func (fc *FlowContext) MergeData(data map[string]interface{})
MergeData merges new data into existing flow data
func (*FlowContext) SessionID ¶
func (fc *FlowContext) SessionID() string
SessionID returns the session ID
func (*FlowContext) Set ¶
func (fc *FlowContext) Set(key string, value interface{})
Set stores a value in the flow data
func (*FlowContext) SetCurrentStep ¶
func (fc *FlowContext) SetCurrentStep(stepID string)
SetCurrentStep sets the current step ID
func (*FlowContext) SetData ¶
func (fc *FlowContext) SetData(data map[string]interface{})
SetData replaces all flow data
func (*FlowContext) SetMetadata ¶
func (fc *FlowContext) SetMetadata(key string, value interface{})
SetMetadata stores a metadata value
func (*FlowContext) SetOrgID ¶
func (fc *FlowContext) SetOrgID(orgID string)
SetOrgID sets the organization ID
func (*FlowContext) SetSessionID ¶
func (fc *FlowContext) SetSessionID(sessionID string)
SetSessionID sets the session ID
func (*FlowContext) SetUserID ¶
func (fc *FlowContext) SetUserID(userID string)
SetUserID sets the user ID
func (*FlowContext) StartTime ¶
func (fc *FlowContext) StartTime() time.Time
StartTime returns when the flow context was created
type FlowResult ¶
type FlowResult struct {
Success bool `json:"success"`
Data map[string]interface{} `json:"data"`
Errors []string `json:"errors,omitempty"`
NextStep string `json:"next_step,omitempty"`
Completed bool `json:"completed"`
}
FlowResult represents the result of executing a flow
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages all available flows in the system
func (*Registry) Unregister ¶
Unregister removes a flow from the registry
type SignupFlow ¶
type SignupFlow struct {
*BaseFlow
// contains filtered or unexported fields
}
SignupFlow implements the user registration flow
func NewSignupFlow ¶
func NewSignupFlow(userService *user.Service, sessionService *session.Service) *SignupFlow
NewSignupFlow creates a new signup flow
type Step ¶
type Step struct {
ID string `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
Required bool `json:"required"`
Config map[string]interface{} `json:"config"`
BeforeHooks []HookFunc `json:"-"`
AfterHooks []HookFunc `json:"-"`
Handler StepHandler `json:"-"`
}
Step represents a single step in an authentication flow
type StepHandler ¶
type StepHandler func(ctx context.Context, step *Step, data map[string]interface{}) (*StepResult, error)
StepHandler defines the function signature for step handlers