models

package
v0.0.0-...-7aa740b Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaleGender   = Gender("male")
	FemaleGender = Gender("female")
)
View Source
const (
	ResourceModuleType = ResourceStatus("module")
	ResourceAPIType    = ResourceStatus("API")
	ResourceFileType   = ResourceStatus("file")
)

Variables

This section is empty.

Functions

func IsValidLang

func IsValidLang(lang Lang) bool

Types

type Action

type Action string
const (
	ReadAction    Action = "r"
	WriteAction   Action = "w"
	ExecuteAction Action = "x"
	DeleteAction  Action = "d"
)

type Authenticable

type Authenticable struct {
	ID   types.ID
	Role string
}

type ErrorResponse

type ErrorResponse struct {
	Success bool                   `json:"Success"`
	Message string                 `json:"message"`
	Errors  []interface{}          `json:"errors"`
	Meta    map[string]interface{} `json:"meta,omitempty"`
}

func NewErrorResponse

func NewErrorResponse(
	message string,
	errors interface{},
) *ErrorResponse

func (*ErrorResponse) WithMeta

func (e *ErrorResponse) WithMeta(meta map[string]interface{}) *ErrorResponse

type EventFSM

type EventFSM string

type FSM

type FSM struct {
	CurrentState StateFSM
	Transitions  map[StateFSM]map[EventFSM]StateFSM
}

func NewFSM

func NewFSM(initialState StateFSM, transitions map[StateFSM]map[EventFSM]StateFSM) *FSM

func (*FSM) ApplyEventFSM

func (fsm *FSM) ApplyEventFSM(event EventFSM) error

func (*FSM) GetCurrentState

func (fsm *FSM) GetCurrentState() StateFSM

type Gender

type Gender string

func (Gender) IsValid

func (g Gender) IsValid() bool

type Lang

type Lang string
const (
	LangFA Lang = "fa"
	LangEN Lang = "en"
	LangAR Lang = "ar"

	LangDefault Lang = "en"
)

func (Lang) ToLang

func (l Lang) ToLang(rawLang string) Lang

type Permission

type Permission struct {
	Allow RWXD // Allowed actions
	Deny  RWXD // Denied actions
}

Permission describe the rules for accessing resources.

type RWXD

type RWXD struct {
	R bool // ReadAction permission
	W bool // WriteAction permission
	X bool // ExecuteAction permission
	D bool // DeleteAction permission
}

RWXD specifies a set of permissions for resources.

type Resource

type Resource struct {
	ID          types.ID
	Name        string
	Description string
	Type        string // Type of resource (e.g., "module", "file", "API")
	Internal    bool
	CreatedAt   time.Time
	UpdatedAt   time.Time
}

Resource represents a protectable models within the system.

type ResourceStatus

type ResourceStatus string

func (ResourceStatus) IsValid

func (a ResourceStatus) IsValid() bool

type Role

type Role struct {
	ID          types.ID // Unique code for the role
	Name        string   // Name displayed to end users
	Description string   // Overview of the role
	Internal    bool     // Indicates if the role is predefined and unmodifiable
	// GroupID     types.ID    // Group associated with this role
	CreatedAt time.Time // Timestamp for role creation
	UpdatedAt time.Time // Timestamp for the last role update
}

Role represents a stable set of permissions linked to business functions.

type RoleResourcePermission

type RoleResourcePermission struct {
	RoleID      types.ID   // Code of the role
	ResourceID  types.ID   // Code of the resource
	Permissions Permission // Allowed and denied actions
	CreatedAt   time.Time  // Timestamp for permission assignment
	UpdatedAt   time.Time  // Timestamp for the last permission update
}

RoleResourcePermission defines permissions for a role on a specific resource.

type RoleWildCardPermission

type RoleWildCardPermission struct {
	RoleID          types.ID   // Code of the role
	ResourcePattern string     // Resource pattern using wildcards (e.g., "resource.*")
	Priority        int        // Priority of the wildcard permission
	Permissions     Permission // Allowed and denied actions
	CreatedAt       time.Time  // Timestamp for permission assignment
	UpdatedAt       time.Time  // Timestamp for the last permission update
}

RoleWildCardPermission defines permissions for a role on a pattern of resources.

type SR

type SR[T interface{}] struct {
	Success bool                   `json:"success"`
	Message string                 `json:"message"`
	Data    T                      `json:"data"`
	Meta    map[string]interface{} `json:"meta,omitempty"`
}

func ForTestSuccessResponse

func ForTestSuccessResponse[T interface{}]() SR[T]

type StateFSM

type StateFSM string

type SuccessResponse

type SuccessResponse[T any] struct {
	Success bool                   `json:"success"`
	Message string                 `json:"message"`
	Data    T                      `json:"data"`
	Meta    map[string]interface{} `json:"meta,omitempty"`
}

func NewSuccessResponse

func NewSuccessResponse[T any](
	message string,
	data T,
) *SuccessResponse[T]

func (*SuccessResponse[T]) WithMeta

func (e *SuccessResponse[T]) WithMeta(meta map[string]interface{}) *SuccessResponse[T]

Jump to

Keyboard shortcuts

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