model

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 7, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Approval

type Approval struct {
	ID         uuid.UUID `json:"id"`
	RequestID  uuid.UUID `json:"request_id"`
	CheckerID  string    `json:"checker_id"`
	Decision   Decision  `json:"decision"`
	StageIndex int       `json:"stage_index"`
	Comment    *string   `json:"comment,omitempty"`
	CreatedAt  time.Time `json:"created_at"`
}

type ApprovalStage

type ApprovalStage struct {
	Index               int               `json:"index"`
	Name                string            `json:"name,omitempty"`
	RequiredApprovals   int               `json:"required_approvals"`
	AllowedCheckerRoles json.RawMessage   `json:"allowed_checker_roles,omitempty"`
	AllowedPermissions  json.RawMessage   `json:"allowed_permissions,omitempty"`
	AuthorizationMode   AuthorizationMode `json:"authorization_mode,omitempty"`
	RejectionPolicy     RejectionPolicy   `json:"rejection_policy"`
	MaxCheckers         *int              `json:"max_checkers,omitempty"`
}

type AuditLog

type AuditLog struct {
	ID        uuid.UUID       `json:"id"`
	TenantID  string          `json:"tenant_id"`
	RequestID uuid.UUID       `json:"request_id"`
	Action    string          `json:"action"`
	ActorID   string          `json:"actor_id"`
	Details   json.RawMessage `json:"details,omitempty"`
	CreatedAt time.Time       `json:"created_at"`
}

type AuthorizationHookRequest

type AuthorizationHookRequest struct {
	RequestID   uuid.UUID       `json:"request_id"`
	RequestType string          `json:"request_type"`
	CheckerID   string          `json:"checker_id"`
	MakerID     string          `json:"maker_id"`
	Payload     json.RawMessage `json:"payload"`
}

type AuthorizationHookResponse

type AuthorizationHookResponse struct {
	Allowed bool   `json:"allowed"`
	Reason  string `json:"reason,omitempty"`
}

type AuthorizationMode

type AuthorizationMode string
const (
	AuthModeRole       AuthorizationMode = "role"
	AuthModePermission AuthorizationMode = "permission"
	AuthModeAny        AuthorizationMode = "any"
	AuthModeAll        AuthorizationMode = "all"
)

type Decision

type Decision string
const (
	DecisionApproved Decision = "approved"
	DecisionRejected Decision = "rejected"
)

type Operator

type Operator struct {
	ID                 uuid.UUID `json:"id"`
	Username           string    `json:"username"`
	PasswordHash       string    `json:"-"` // never expose in JSON
	DisplayName        string    `json:"display_name"`
	MustChangePassword bool      `json:"must_change_password"`
	CreatedAt          time.Time `json:"created_at"`
	UpdatedAt          time.Time `json:"updated_at"`
}

Operator represents a console user who can manage policies, webhooks, and other administrative tasks through the Quorum admin console.

type OutboxEntry

type OutboxEntry struct {
	ID            uuid.UUID       `json:"id"`
	RequestID     uuid.UUID       `json:"request_id"`
	WebhookURL    string          `json:"webhook_url"`
	WebhookSecret string          `json:"-"`
	Payload       json.RawMessage `json:"payload"`
	EventType     string          `json:"event_type"`
	Status        string          `json:"status"` // pending, delivered, failed
	Attempts      int             `json:"attempts"`
	MaxRetries    int             `json:"max_retries"`
	LastError     *string         `json:"last_error,omitempty"`
	NextRetryAt   time.Time       `json:"next_retry_at"`
	CreatedAt     time.Time       `json:"created_at"`
	DeliveredAt   *time.Time      `json:"delivered_at,omitempty"`
}

OutboxEntry represents a durable webhook delivery entry in the outbox table.

type Policy

type Policy struct {
	ID                         uuid.UUID       `json:"id"`
	TenantID                   string          `json:"tenant_id"`
	Name                       string          `json:"name"`
	RequestType                string          `json:"request_type"`
	Stages                     []ApprovalStage `json:"stages"`
	IdentityFields             []string        `json:"identity_fields,omitempty"`
	DynamicAuthorizationURL    *string         `json:"dynamic_authorization_url,omitempty"`
	DynamicAuthorizationSecret *string         `json:"-"`
	AutoExpireDuration         *time.Duration  `json:"auto_expire_duration,omitempty"`
	DisplayTemplate            json.RawMessage `json:"display_template,omitempty"`
	CreatedAt                  time.Time       `json:"created_at"`
	UpdatedAt                  time.Time       `json:"updated_at"`
}

func (*Policy) StageAt

func (p *Policy) StageAt(index int) *ApprovalStage

StageAt returns the approval stage at the given index, or nil if out of range.

func (*Policy) TotalStages

func (p *Policy) TotalStages() int

TotalStages returns the number of stages in this policy.

type RejectionPolicy

type RejectionPolicy string
const (
	RejectionPolicyAny       RejectionPolicy = "any"
	RejectionPolicyThreshold RejectionPolicy = "threshold"
)

type Request

type Request struct {
	ID                uuid.UUID       `json:"id"`
	TenantID          string          `json:"tenant_id"`
	IdempotencyKey    *string         `json:"idempotency_key,omitempty"`
	Type              string          `json:"type"`
	Payload           json.RawMessage `json:"payload"`
	Status            RequestStatus   `json:"status"`
	MakerID           string          `json:"maker_id"`
	EligibleReviewers []string        `json:"eligible_reviewers,omitempty"`
	Metadata          json.RawMessage `json:"metadata,omitempty"`
	Fingerprint       *string         `json:"fingerprint,omitempty"`
	CurrentStage      int             `json:"current_stage"`
	ExpiresAt         *time.Time      `json:"expires_at,omitempty"`
	CreatedAt         time.Time       `json:"created_at"`
	UpdatedAt         time.Time       `json:"updated_at"`
	Approvals         []Approval      `json:"approvals,omitempty"`
	ViewerCanAct      *bool           `json:"viewer_can_act,omitempty"`
	TotalStages       *int            `json:"total_stages,omitempty"`
}

type RequestStatus

type RequestStatus string
const (
	StatusPending   RequestStatus = "pending"
	StatusApproved  RequestStatus = "approved"
	StatusRejected  RequestStatus = "rejected"
	StatusCancelled RequestStatus = "cancelled"
	StatusExpired   RequestStatus = "expired"
)

func (RequestStatus) IsTerminal

func (s RequestStatus) IsTerminal() bool

type Tenant

type Tenant struct {
	ID        uuid.UUID `json:"id"`
	Slug      string    `json:"slug"`
	Name      string    `json:"name"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

Tenant represents a registered tenant (application) in the system.

type Webhook

type Webhook struct {
	ID          uuid.UUID `json:"id"`
	TenantID    string    `json:"tenant_id"`
	URL         string    `json:"url"`
	Events      []string  `json:"events"`
	Secret      string    `json:"-"`
	RequestType *string   `json:"request_type,omitempty"`
	Active      bool      `json:"active"`
	CreatedAt   time.Time `json:"created_at"`
}

type WebhookPayload

type WebhookPayload struct {
	Event     string     `json:"event"`
	Request   Request    `json:"request"`
	Approvals []Approval `json:"approvals,omitempty"`
	Timestamp time.Time  `json:"timestamp"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL