Documentation
¶
Index ¶
Constants ¶
View Source
const LocalWorkspaceID = "00000000-0000-0000-0000-000000000001"
LocalWorkspaceID is the fixed workspace ID used in local (single-tenant) mode.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AttemptLog ¶
type RequestLog ¶
type RequestLog struct {
ID string `json:"id"`
WorkspaceID string `json:"workspace_id"`
ScenarioRunID *string `json:"scenario_run_id,omitempty"`
// ScenarioID is the scenario that drove this request's response, when
// one was resolved (via X-TestPay-Scenario-ID header, active session, or
// workspace default). Nil when the fallback "always succeed" scenario
// fired.
ScenarioID *string `json:"scenario_id,omitempty"`
// MerchantOrderID is the caller's reference pulled from the request body
// (order_id / merchant_order_id / metadata.order_id / notes.reference).
// Empty string when the payload didn't include one.
MerchantOrderID string `json:"merchant_order_id"`
Gateway string `json:"gateway"`
Method string `json:"method"`
Path string `json:"path"`
RequestHeaders map[string]string `json:"request_headers"`
RequestBody map[string]any `json:"request_body"`
ResponseHeaders map[string]string `json:"response_headers"`
ResponseBody map[string]any `json:"response_body"`
ResponseStatus int `json:"response_status"`
DurationMs int `json:"duration_ms"`
ClientIP string `json:"client_ip"`
CreatedAt time.Time `json:"created_at"`
}
type Scenario ¶
type Scenario struct {
ID string `json:"id"`
WorkspaceID string `json:"workspace_id"`
Name string `json:"name"`
Description string `json:"description"`
Gateway string `json:"gateway"`
Steps []Step `json:"steps"`
WebhookDelayMs int `json:"webhook_delay_ms"`
IsDefault bool `json:"is_default"`
CreatedAt time.Time `json:"created_at"`
}
type ScenarioRun ¶
type Session ¶
type Session struct {
ID string `json:"id"`
WorkspaceID string `json:"workspace_id"`
ScenarioID string `json:"scenario_id"`
TTLSeconds int `json:"ttl_seconds"`
ExpiresAt time.Time `json:"expires_at"`
// CallIndex tracks how many live mock calls this session has served.
// mock.go uses it to advance through multi-step scenarios:
// stepIndex = call_index % len(steps)
CallIndex int `json:"call_index"`
CreatedAt time.Time `json:"created_at"`
}
type Store ¶
type Store interface {
// Workspace
CreateWorkspace(ctx context.Context, w *Workspace) error
GetWorkspaceByAPIKey(ctx context.Context, apiKey string) (*Workspace, error)
GetWorkspaceBySlug(ctx context.Context, slug string) (*Workspace, error)
GetWorkspaceByID(ctx context.Context, id string) (*Workspace, error)
UpdateWorkspace(ctx context.Context, w *Workspace) error
// Scenarios
ListScenarios(ctx context.Context, workspaceID string) ([]*Scenario, error)
CreateScenario(ctx context.Context, s *Scenario) error
GetScenario(ctx context.Context, id string) (*Scenario, error)
UpdateScenario(ctx context.Context, s *Scenario) error
DeleteScenario(ctx context.Context, id string) error
GetDefaultScenario(ctx context.Context, workspaceID string) (*Scenario, error)
// ScenarioRuns
CreateScenarioRun(ctx context.Context, r *ScenarioRun) error
UpdateScenarioRun(ctx context.Context, r *ScenarioRun) error
// Sessions
CreateSession(ctx context.Context, s *Session) error
GetActiveSession(ctx context.Context, workspaceID string) (*Session, error)
DeleteSession(ctx context.Context, id string) error
// BumpSessionCallIndex atomically increments the session's call_index and
// returns the PRE-bump value. Used by the mock handler to resolve which
// step of a multi-step scenario the current call corresponds to.
BumpSessionCallIndex(ctx context.Context, sessionID string) (int, error)
// RequestLogs
CreateRequestLog(ctx context.Context, l *RequestLog) error
ListRequestLogs(ctx context.Context, workspaceID string, limit, offset int) ([]*RequestLog, error)
GetRequestLog(ctx context.Context, id string) (*RequestLog, error)
// WebhookLogs
CreateWebhookLog(ctx context.Context, l *WebhookLog) error
UpdateWebhookLog(ctx context.Context, l *WebhookLog) error
GetWebhookLogByRequestID(ctx context.Context, requestLogID string) (*WebhookLog, error)
GetWebhookLog(ctx context.Context, id string) (*WebhookLog, error)
ListWebhookLogs(ctx context.Context, workspaceID string, limit, offset int) ([]*WebhookLog, error)
// Users
CreateUser(ctx context.Context, u *User, passwordHash string) error
GetUserByEmail(ctx context.Context, email string) (*User, string, error)
GetUserByID(ctx context.Context, id string) (*User, error)
UpdateUserLastLogin(ctx context.Context, id string, at time.Time) error
}
type WebhookLog ¶
type WebhookLog struct {
ID string `json:"id"`
RequestLogID string `json:"request_log_id"`
Payload map[string]any `json:"payload"`
TargetURL string `json:"target_url"`
DeliveryStatus string `json:"delivery_status"` // pending | delivered | failed | duplicate
Attempts int `json:"attempts"`
AttemptLogs []AttemptLog `json:"attempt_logs"`
DeliveredAt *time.Time `json:"delivered_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
Click to show internal directories.
Click to hide internal directories.