entity

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnauthorized     = errors.New("unauthorized")
	ErrForbidden        = errors.New("access denied")
	ErrInvalidToken     = errors.New("invalid token")
	ErrTokenExpired     = errors.New("token expired")
	ErrMissingToken     = errors.New("missing authorization token")
	ErrUnknownIssuer    = errors.New("unknown token issuer")
	ErrInsufficientRole = errors.New("insufficient role permissions")
)

Authentication and Authorization errors.

View Source
var (
	ErrMissingWorkspaceID = errors.New("missing workspace ID")
	ErrMissingTenantID    = errors.New("missing tenant ID")
	ErrMissingUserID      = errors.New("missing user ID")
	ErrInvalidWorkspaceID = errors.New("invalid workspace ID format")
	ErrInvalidTenantID    = errors.New("invalid tenant ID format")
	ErrInvalidUserID      = errors.New("invalid user ID format")
)

Context errors.

View Source
var (
	ErrSystemRoleNotFound = errors.New("system role not found")
	ErrSystemRoleExists   = errors.New("user already has a system role")
	ErrInvalidSystemRole  = errors.New("invalid system role")
)

System Role errors.

View Source
var (
	ErrTenantMemberNotFound    = errors.New("tenant member not found")
	ErrTenantMemberExists      = errors.New("user is already a member of this tenant")
	ErrTenantAccessDenied      = errors.New("tenant access denied")
	ErrInvalidTenantRole       = errors.New("invalid tenant role")
	ErrCannotRemoveTenantOwner = errors.New("cannot remove tenant owner")
)

Tenant Member errors.

View Source
var (
	ErrTenantNotFound           = errors.New("tenant not found")
	ErrTenantAlreadyExists      = errors.New("tenant already exists")
	ErrInvalidTenantCode        = errors.New("invalid tenant code")
	ErrInvalidTenantStatus      = errors.New("invalid tenant status")
	ErrCannotModifySystemTenant = errors.New("cannot modify system tenant")
)

Tenant errors.

View Source
var (
	ErrWorkspaceNotFound           = errors.New("workspace not found")
	ErrWorkspaceAlreadyExists      = errors.New("workspace already exists")
	ErrWorkspaceAccessDenied       = errors.New("workspace access denied")
	ErrWorkspaceSuspended          = errors.New("workspace is suspended")
	ErrWorkspaceArchived           = errors.New("workspace is archived")
	ErrSystemWorkspaceExists       = errors.New("system workspace already exists for this tenant")
	ErrGlobalWorkspaceExists       = errors.New("global system workspace already exists")
	ErrInvalidWorkspaceType        = errors.New("invalid workspace type")
	ErrInvalidWorkspaceStatus      = errors.New("invalid workspace status")
	ErrCannotArchiveSystem         = errors.New("cannot archive system workspace")
	ErrCannotModifySystemWorkspace = errors.New("cannot modify system workspace status")
	ErrInvalidWorkspaceCode        = errors.New("invalid workspace code")
	ErrWorkspaceCodeExists         = errors.New("workspace code already exists in this tenant")
)

Workspace errors.

View Source
var (
	ErrUserNotFound      = errors.New("user not found")
	ErrUserAlreadyExists = errors.New("user already exists")
	ErrUserSuspended     = errors.New("user is suspended")
	ErrUserNotInvited    = errors.New("user has not been invited to the system")
	ErrInvalidUserStatus = errors.New("invalid user status")
	ErrEmailAlreadyInUse = errors.New("email already in use")
	ErrInvalidEmail      = errors.New("invalid email format")
)

User errors.

View Source
var (
	ErrMemberNotFound          = errors.New("workspace member not found")
	ErrMemberAlreadyExists     = errors.New("user is already a member of this workspace")
	ErrMembershipPending       = errors.New("membership is pending")
	ErrCannotRemoveOwner       = errors.New("cannot remove workspace owner")
	ErrInvalidRole             = errors.New("invalid workspace role")
	ErrInvalidMembershipStatus = errors.New("invalid membership status")
)

Workspace Member errors.

View Source
var (
	ErrFolderNotFound      = errors.New("folder not found")
	ErrFolderAlreadyExists = errors.New("folder with this name already exists")
	ErrFolderHasChildren   = errors.New("folder has child folders")
	ErrFolderHasTemplates  = errors.New("folder contains templates")
	ErrInvalidParentFolder = errors.New("invalid parent folder")
	ErrCircularReference   = errors.New("circular folder reference detected")
)

Folder errors.

View Source
var (
	ErrTagNotFound      = errors.New("tag not found")
	ErrTagAlreadyExists = errors.New("tag with this name already exists")
	ErrTagInUse         = errors.New("tag is in use by templates")
	ErrInvalidTagColor  = errors.New("invalid tag color format")
)

Tag errors.

View Source
var (
	ErrInjectableNotFound         = errors.New("injectable definition not found")
	ErrInjectableAlreadyExists    = errors.New("injectable with this key already exists")
	ErrInjectableInUse            = errors.New("injectable is in use by templates")
	ErrInvalidInjectableKey       = errors.New("invalid injectable key")
	ErrInvalidDataType            = errors.New("invalid injectable data type")
	ErrInvalidInjectableSource    = errors.New("must specify either injectable definition ID or system key, not both")
	ErrTemplateInjectableNotFound = errors.New("template injectable not found")
	ErrOnlyTextTypeAllowed        = errors.New("only TEXT type injectables can be created by workspaces")
	ErrWorkspaceIDRequired        = errors.New("workspace ID is required for this injectable")
	ErrCannotModifyGlobal         = errors.New("cannot modify global injectable definitions")
)

Injectable Definition errors.

View Source
var (
	ErrSystemInjectableNotFound = errors.New("system injectable not found in registry")
	ErrInvalidScopeType         = errors.New("invalid scope type")
	ErrTenantIDRequired         = errors.New("tenant ID is required for TENANT scope")
	ErrAssignmentNotFound       = errors.New("system injectable assignment not found")
)

System Injectable errors.

View Source
var (
	ErrDocumentTypeNotFound        = errors.New("document type not found")
	ErrDocumentTypeCodeExists      = errors.New("document type with this code already exists")
	ErrDocumentTypeCodeImmutable   = errors.New("document type code cannot be modified")
	ErrDocumentTypeAlreadyAssigned = errors.New("workspace already has a template for this document type")
	ErrDocumentTypeHasTemplates    = errors.New("document type is assigned to templates")
	ErrCannotModifyGlobalType      = errors.New("cannot modify global document type")
)

Document Type errors.

View Source
var (
	ErrTemplateNotFound      = errors.New("template not found")
	ErrTemplateAlreadyExists = errors.New("template with this title already exists")
	ErrTemplateNotResolved   = errors.New("no published template found for the given tenant, workspace and document type codes")
)

Template errors.

View Source
var (
	ErrVersionNotFound                 = errors.New("template version not found")
	ErrVersionAlreadyExists            = errors.New("version number already exists for this template")
	ErrVersionNameExists               = errors.New("version name already exists for this template")
	ErrVersionAlreadyPublished         = errors.New("version is already published")
	ErrVersionNotPublished             = errors.New("version is not published")
	ErrCannotEditPublished             = errors.New("cannot edit published version")
	ErrCannotEditArchived              = errors.New("cannot edit archived version")
	ErrCannotEditScheduled             = errors.New("cannot edit scheduled version")
	ErrNoPublishedVersion              = errors.New("template has no published version")
	ErrCannotArchiveWithoutReplacement = errors.New("cannot schedule archive without scheduled replacement")
	ErrInvalidVersionStatus            = errors.New("invalid version status")
	ErrInvalidVersionNumber            = errors.New("invalid version number")
	ErrScheduledTimeInPast             = errors.New("scheduled time must be in the future")
	ErrInvalidContentStructure         = errors.New("invalid template content structure")
	ErrMissingRequiredVariable         = errors.New("missing required template variable")
	ErrVersionInjectableNotFound       = errors.New("version injectable not found")
	ErrContentValidationFailed         = errors.New("content validation failed")
	ErrMissingRequiredContent          = errors.New("content structure is required for publishing")
	ErrVersionDoesNotBelongToTemplate  = errors.New("version does not belong to the specified template")
	ErrScheduledTimeConflict           = errors.New("another version is already scheduled at this time")
)

Template Version errors.

View Source
var (
	ErrValidationFailed = errors.New("validation failed")
	ErrInvalidUUID      = errors.New("invalid UUID format")
	ErrRequiredField    = errors.New("required field is missing")
	ErrFieldTooLong     = errors.New("field exceeds maximum length")
	ErrFieldTooShort    = errors.New("field is below minimum length")
)

Validation errors.

View Source
var (
	ErrDatabaseConnection = errors.New("database connection error")
	ErrDatabaseQuery      = errors.New("database query error")
	ErrOptimisticLock     = errors.New("optimistic lock conflict - record was modified")
	ErrRecordNotFound     = errors.New("record not found")
)

Database errors.

View Source
var (
	ErrInvalidAccessEntityType = errors.New("invalid access entity type")
)

Access History errors.

View Source
var (
	ErrLLMServiceUnavailable = errors.New("AI generation service is temporarily unavailable")
)

LLM Service errors.

View Source
var (
	ErrNoMapperRegistered = errors.New("no mapper registered in registry")
)

Document Generation errors.

View Source
var (
	ErrRendererBusy = errors.New("PDF renderer is at capacity, try again shortly")
)

Renderer capacity errors.

Functions

func IntPtr

func IntPtr(i int) *int

IntPtr returns a pointer to the given int.

func NormalizeTagName

func NormalizeTagName(input string) string

NormalizeTagName normalizes a tag name for consistency. Transformations applied:

  • Trims whitespace
  • Converts to lowercase
  • Removes diacritics (á→a, ñ→n)
  • Replaces spaces with underscores
  • Allows only a-z, 0-9, _, -
  • Collapses multiple underscores
  • Removes leading/trailing underscores
  • Limits to 50 characters

func StringPtr

func StringPtr(s string) *string

StringPtr returns a pointer to the given string.

Types

type AccessEntityType

type AccessEntityType string

AccessEntityType represents the type of entity being accessed.

const (
	AccessEntityTypeTenant    AccessEntityType = "TENANT"
	AccessEntityTypeWorkspace AccessEntityType = "WORKSPACE"
)

func (AccessEntityType) IsValid

func (t AccessEntityType) IsValid() bool

IsValid checks if the entity type is valid.

type ContentValidationError

type ContentValidationError struct {
	Errors   []ContentValidationItem
	Warnings []ContentValidationItem
}

ContentValidationError wraps multiple validation errors from content validation.

func (*ContentValidationError) Error

func (e *ContentValidationError) Error() string

Error implements the error interface.

func (*ContentValidationError) HasErrors

func (e *ContentValidationError) HasErrors() bool

HasErrors returns true if there are validation errors.

func (*ContentValidationError) HasWarnings

func (e *ContentValidationError) HasWarnings() bool

HasWarnings returns true if there are validation warnings.

type ContentValidationItem

type ContentValidationItem struct {
	Code    string
	Path    string
	Message string
}

ContentValidationItem represents a single validation error or warning.

type DocumentType

type DocumentType struct {
	ID          string     `json:"id"`
	TenantID    string     `json:"tenantId"`
	Code        string     `json:"code"`        // Immutable, unique per tenant
	Name        I18nText   `json:"name"`        // {"en": "...", "es": "..."}
	Description I18nText   `json:"description"` // Optional
	IsGlobal    bool       `json:"isGlobal"`    // True if from SYS tenant (read-only for other tenants)
	CreatedAt   time.Time  `json:"createdAt"`
	UpdatedAt   *time.Time `json:"updatedAt,omitempty"`
}

DocumentType represents a tenant-scoped document classification. Templates can be assigned to a document type for categorization. Each workspace can have at most one template per document type.

func NewDocumentType

func NewDocumentType(tenantID, code string, name, description I18nText) *DocumentType

NewDocumentType creates a new document type.

func (*DocumentType) GetDescription

func (d *DocumentType) GetDescription(locale string) string

GetDescription returns the description for the given locale with fallback.

func (*DocumentType) GetName

func (d *DocumentType) GetName(locale string) string

GetName returns the name for the given locale with fallback to "en" or first available.

func (*DocumentType) Validate

func (d *DocumentType) Validate() error

Validate checks if the document type data is valid.

type DocumentTypeListItem

type DocumentTypeListItem struct {
	ID             string     `json:"id"`
	TenantID       string     `json:"tenantId"`
	Code           string     `json:"code"`
	Name           I18nText   `json:"name"`
	Description    I18nText   `json:"description"`
	IsGlobal       bool       `json:"isGlobal"`       // True if from SYS tenant
	TemplatesCount int        `json:"templatesCount"` // Number of templates using this type
	CreatedAt      time.Time  `json:"createdAt"`
	UpdatedAt      *time.Time `json:"updatedAt,omitempty"`
}

DocumentTypeListItem represents a document type in list views.

type DocumentTypeTemplateInfo

type DocumentTypeTemplateInfo struct {
	ID            string `json:"id"`
	Title         string `json:"title"`
	WorkspaceID   string `json:"workspaceId"`
	WorkspaceName string `json:"workspaceName"`
}

DocumentTypeTemplateInfo represents basic template info for document type context.

type DocumentTypeWithTemplates

type DocumentTypeWithTemplates struct {
	DocumentType *DocumentType
	Templates    []*DocumentTypeTemplateInfo
}

DocumentTypeWithTemplates represents a document type with its assigned templates.

type Folder

type Folder struct {
	ID          string     `json:"id"`
	WorkspaceID string     `json:"workspaceId"`
	ParentID    *string    `json:"parentId,omitempty"` // NULL for root folders
	Name        string     `json:"name"`
	Path        string     `json:"path"` // Materialized path for efficient hierarchical queries
	CreatedAt   time.Time  `json:"createdAt"`
	UpdatedAt   *time.Time `json:"updatedAt,omitempty"`
}

Folder represents a hierarchical container for organizing templates.

func NewFolder

func NewFolder(workspaceID string, parentID *string, name string) *Folder

NewFolder creates a new folder.

func (*Folder) IsRoot

func (f *Folder) IsRoot() bool

IsRoot returns true if this is a root folder (no parent).

func (*Folder) Validate

func (f *Folder) Validate() error

Validate checks if the folder data is valid.

type FolderTree

type FolderTree struct {
	Folder
	Children []*FolderTree `json:"children,omitempty"`
}

FolderTree represents a folder with its children for tree display.

func BuildFolderTree

func BuildFolderTree(folders []*Folder) []*FolderTree

BuildFolderTree builds a tree structure from a flat list of folders.

func NewFolderTree

func NewFolderTree(folder *Folder) *FolderTree

NewFolderTree creates a folder tree node.

func (*FolderTree) AddChild

func (ft *FolderTree) AddChild(child *FolderTree)

AddChild adds a child folder to the tree.

type FolderWithCounts

type FolderWithCounts struct {
	Folder
	ChildFolderCount int `json:"childFolderCount"`
	TemplateCount    int `json:"templateCount"`
}

FolderWithCounts represents a folder with item counts.

type FormatConfig

type FormatConfig struct {
	// Default is the default format to apply if none is selected.
	Default string `json:"default"`
	// Options is the list of available format patterns for user selection.
	Options []string `json:"options"`
}

FormatConfig defines formatting options for an injector. Used by the frontend to display available format options and by the system to apply formatting to resolved values.

type I18nText

type I18nText map[string]string

I18nText represents internationalized text as map[lang]text. Example: {"en": "Contract", "es": "Contrato"}

type InjectableDataType

type InjectableDataType string

InjectableDataType represents the data type of an injectable variable.

const (
	InjectableDataTypeText     InjectableDataType = "TEXT"
	InjectableDataTypeNumber   InjectableDataType = "NUMBER"
	InjectableDataTypeDate     InjectableDataType = "DATE"
	InjectableDataTypeCurrency InjectableDataType = "CURRENCY"
	InjectableDataTypeBoolean  InjectableDataType = "BOOLEAN"
	InjectableDataTypeImage    InjectableDataType = "IMAGE"
	InjectableDataTypeTable    InjectableDataType = "TABLE"
	InjectableDataTypeList     InjectableDataType = "LIST"
)

func (InjectableDataType) IsValid

func (i InjectableDataType) IsValid() bool

IsValid checks if the injectable data type is valid.

type InjectableDefinition

type InjectableDefinition struct {
	ID           string               `json:"id"`
	WorkspaceID  *string              `json:"workspaceId,omitempty"` // NULL for global definitions
	Key          string               `json:"key"`                   // Technical key (e.g., customer_name)
	Label        string               `json:"label"`                 // Human-readable name
	Description  string               `json:"description,omitempty"`
	DataType     InjectableDataType   `json:"dataType"`
	SourceType   InjectableSourceType `json:"sourceType"`             // INTERNAL (system-calculated) or EXTERNAL (user input)
	Metadata     map[string]any       `json:"metadata"`               // Flexible configuration (format options, etc.)
	FormatConfig *FormatConfig        `json:"formatConfig,omitempty"` // Formatting options for this injectable
	Group        *string              `json:"group,omitempty"`        // Group key for organizing in the editor (system injectables only)
	DefaultValue *string              `json:"defaultValue,omitempty"` // Default value for workspace injectables
	IsActive     bool                 `json:"isActive"`               // Enable/disable injectable
	IsDeleted    bool                 `json:"isDeleted"`              // Soft delete flag
	CreatedAt    time.Time            `json:"createdAt"`
	UpdatedAt    *time.Time           `json:"updatedAt,omitempty"`
}

InjectableDefinition represents a variable that can be injected into templates.

func NewInjectableDefinition

func NewInjectableDefinition(workspaceID *string, key, label string, dataType InjectableDataType) *InjectableDefinition

NewInjectableDefinition creates a new injectable definition.

func (*InjectableDefinition) IsGlobal

func (i *InjectableDefinition) IsGlobal() bool

IsGlobal returns true if this is a global definition (available to all workspaces).

func (*InjectableDefinition) Validate

func (i *InjectableDefinition) Validate() error

Validate checks if the injectable definition data is valid.

func (*InjectableDefinition) ValidateForWorkspace

func (i *InjectableDefinition) ValidateForWorkspace() error

ValidateForWorkspace validates injectable for workspace-owned creation (TEXT type only).

type InjectableScopeType

type InjectableScopeType string

InjectableScopeType represents the scope level for a system injectable assignment.

const (
	InjectableScopePublic    InjectableScopeType = "PUBLIC"
	InjectableScopeTenant    InjectableScopeType = "TENANT"
	InjectableScopeWorkspace InjectableScopeType = "WORKSPACE"
)

func (InjectableScopeType) IsValid

func (s InjectableScopeType) IsValid() bool

IsValid checks if the scope type is valid.

type InjectableSourceType

type InjectableSourceType string

InjectableSourceType indicates whether an injectable's value is calculated internally by the system or provided from an external source.

const (
	InjectableSourceTypeInternal InjectableSourceType = "INTERNAL"
	InjectableSourceTypeExternal InjectableSourceType = "EXTERNAL"
)

func (InjectableSourceType) IsValid

func (i InjectableSourceType) IsValid() bool

IsValid checks if the injectable source type is valid.

type InjectableValue

type InjectableValue struct {
	// contains filtered or unexported fields
}

InjectableValue is the typed value returned by an injector. Only allows: string, number (float64), bool, time.Time, TableValue, ListValue.

func BoolValue

func BoolValue(b bool) InjectableValue

BoolValue creates an InjectableValue of type bool.

func ImageValue

func ImageValue(url string) InjectableValue

ImageValue creates an InjectableValue of type image (URL string).

func ListValueData

func ListValueData(l *ListValue) InjectableValue

ListValueData creates an InjectableValue of type list.

func NumberValue

func NumberValue(n float64) InjectableValue

NumberValue creates an InjectableValue of type number.

func StringValue

func StringValue(s string) InjectableValue

StringValue creates an InjectableValue of type string.

func TableValueData

func TableValueData(t *TableValue) InjectableValue

TableValueData creates an InjectableValue of type table.

func TimeValue

func TimeValue(t time.Time) InjectableValue

TimeValue creates an InjectableValue of type time.

func (InjectableValue) AsAny

func (v InjectableValue) AsAny() any

AsAny returns the value as any (for rendering).

func (InjectableValue) Bool

func (v InjectableValue) Bool() (bool, bool)

Bool returns the value as bool. ok=false if not a bool.

func (InjectableValue) List

func (v InjectableValue) List() (*ListValue, bool)

List returns the value as *ListValue. ok=false if not a list.

func (InjectableValue) Number

func (v InjectableValue) Number() (float64, bool)

Number returns the value as float64. ok=false if not a number.

func (InjectableValue) String

func (v InjectableValue) String() (string, bool)

String returns the value as string. ok=false if not a string.

func (InjectableValue) Table

func (v InjectableValue) Table() (*TableValue, bool)

Table returns the value as *TableValue. ok=false if not a table.

func (InjectableValue) Time

func (v InjectableValue) Time() (time.Time, bool)

Time returns the value as time.Time. ok=false if not a time.

func (InjectableValue) Type

func (v InjectableValue) Type() ValueType

Type returns the type of the value.

type InjectorContext

type InjectorContext struct {
	// contains filtered or unexported fields
}

InjectorContext encapsulates context data with thread-safe access.

func NewInjectorContext

func NewInjectorContext(
	externalID, templateID, transactionalID string,
	op string,
	headers map[string]string,
	payload any,
) *InjectorContext

NewInjectorContext creates a new InjectorContext instance.

func NewInjectorContextWithCodes

func NewInjectorContextWithCodes(
	externalID, templateID, transactionalID string,
	op string,
	tenantCode, workspaceCode string,
	headers map[string]string,
	payload any,
) *InjectorContext

NewInjectorContextWithCodes creates a new InjectorContext with tenant/workspace codes.

func (*InjectorContext) ExternalID

func (c *InjectorContext) ExternalID() string

ExternalID returns the external ID of the request.

func (*InjectorContext) GetHeaders

func (c *InjectorContext) GetHeaders() map[string]string

GetHeaders returns a copy of all headers.

func (*InjectorContext) GetResolved

func (c *InjectorContext) GetResolved(code string) (any, bool)

GetResolved returns the resolved value of another injector.

func (*InjectorContext) GetSelectedFormats

func (c *InjectorContext) GetSelectedFormats() map[string]string

GetSelectedFormats returns a copy of all selected formats.

func (*InjectorContext) Header

func (c *InjectorContext) Header(key string) string

Header returns the value of a specific header (case-insensitive).

func (*InjectorContext) InitData

func (c *InjectorContext) InitData() any

InitData returns the initialization data.

func (*InjectorContext) Operation

func (c *InjectorContext) Operation() string

Operation returns the operation type.

func (*InjectorContext) RequestPayload

func (c *InjectorContext) RequestPayload() any

RequestPayload returns the request payload.

func (*InjectorContext) SelectedFormat

func (c *InjectorContext) SelectedFormat(code string) string

SelectedFormat returns the format selected by user for a specific injector. Returns empty string if no format is selected.

func (*InjectorContext) SetInitData

func (c *InjectorContext) SetInitData(data any)

SetInitData stores the initialization data (internal use by resolver).

func (*InjectorContext) SetResolved

func (c *InjectorContext) SetResolved(code string, value any)

SetResolved stores the resolved value of an injector (internal use by resolver).

func (*InjectorContext) SetSelectedFormats

func (c *InjectorContext) SetSelectedFormats(formats map[string]string)

SetSelectedFormats stores the selected formats (internal use by resolver).

func (*InjectorContext) SetTenantCode

func (c *InjectorContext) SetTenantCode(code string)

SetTenantCode sets the tenant code (internal use).

func (*InjectorContext) SetWorkspaceCode

func (c *InjectorContext) SetWorkspaceCode(code string)

SetWorkspaceCode sets the workspace code (internal use).

func (*InjectorContext) TemplateID

func (c *InjectorContext) TemplateID() string

TemplateID returns the template ID.

func (*InjectorContext) TenantCode

func (c *InjectorContext) TenantCode() string

TenantCode returns the tenant code.

func (*InjectorContext) TransactionalID

func (c *InjectorContext) TransactionalID() string

TransactionalID returns the transactional ID.

func (*InjectorContext) WorkspaceCode

func (c *InjectorContext) WorkspaceCode() string

WorkspaceCode returns the workspace code.

type InjectorResult

type InjectorResult struct {
	Value    InjectableValue
	Metadata map[string]any // optional, for logging/debug
}

InjectorResult is the result of resolving an injector.

type ListItem

type ListItem struct {
	Value    *InjectableValue `json:"value,omitempty"`
	Children []ListItem       `json:"children,omitempty"`
}

ListItem represents a single item in a list, optionally with nested children.

func ListItemNested

func ListItemNested(value InjectableValue, children ...ListItem) ListItem

ListItemNested creates a ListItem with children.

func ListItemValue

func ListItemValue(value InjectableValue) ListItem

ListItemValue creates a ListItem with a value (helper for nested items).

type ListSchema

type ListSchema struct {
	Symbol      ListSymbol        `json:"symbol"`
	HeaderLabel map[string]string `json:"headerLabel,omitempty"`
}

ListSchema exposes the default configuration of a list injector to the frontend.

type ListStyles

type ListStyles struct {
	FontFamily *string `json:"fontFamily,omitempty"`
	FontSize   *int    `json:"fontSize,omitempty"`
	FontWeight *string `json:"fontWeight,omitempty"`
	TextColor  *string `json:"textColor,omitempty"`
	TextAlign  *string `json:"textAlign,omitempty"`
}

ListStyles defines styling options for list header or items.

type ListSymbol

type ListSymbol string

ListSymbol represents the marker/numbering style for a list.

const (
	ListSymbolBullet ListSymbol = "bullet" // • (default)
	ListSymbolNumber ListSymbol = "number" // 1. 2. 3.
	ListSymbolDash   ListSymbol = "dash"   // –
	ListSymbolRoman  ListSymbol = "roman"  // i. ii. iii.
	ListSymbolLetter ListSymbol = "letter" // a) b) c)
)

func (ListSymbol) IsValid

func (s ListSymbol) IsValid() bool

IsValid checks if the list symbol is valid.

type ListValue

type ListValue struct {
	Symbol       ListSymbol        `json:"symbol"`
	Items        []ListItem        `json:"items"`
	HeaderLabel  map[string]string `json:"headerLabel,omitempty"` // i18n: {"en":"Title","es":"Título"}
	HeaderStyles *ListStyles       `json:"headerStyles,omitempty"`
	ItemStyles   *ListStyles       `json:"itemStyles,omitempty"`
}

ListValue represents a complete injectable list with items and styling.

func NewListValue

func NewListValue() *ListValue

NewListValue creates a new empty ListValue with bullet symbol.

func (*ListValue) AddItem

func (l *ListValue) AddItem(value InjectableValue) *ListValue

AddItem adds a simple text item to the list.

func (*ListValue) AddNestedItem

func (l *ListValue) AddNestedItem(value InjectableValue, children ...ListItem) *ListValue

AddNestedItem adds an item with children to the list.

func (*ListValue) WithHeaderLabel

func (l *ListValue) WithHeaderLabel(labels map[string]string) *ListValue

WithHeaderLabel sets the i18n header label.

func (*ListValue) WithHeaderStyles

func (l *ListValue) WithHeaderStyles(styles ListStyles) *ListValue

WithHeaderStyles sets the header styles.

func (*ListValue) WithItemStyles

func (l *ListValue) WithItemStyles(styles ListStyles) *ListValue

WithItemStyles sets the item styles.

func (*ListValue) WithSymbol

func (l *ListValue) WithSymbol(symbol ListSymbol) *ListValue

WithSymbol sets the list symbol style.

type MemberWithUser

type MemberWithUser struct {
	WorkspaceMember
	User *User `json:"user"`
}

MemberWithUser represents a workspace member with full user details.

type MembershipStatus

type MembershipStatus string

MembershipStatus represents the status of a workspace membership.

const (
	MembershipStatusPending MembershipStatus = "PENDING"
	MembershipStatusActive  MembershipStatus = "ACTIVE"
)

func (MembershipStatus) IsValid

func (m MembershipStatus) IsValid() bool

IsValid checks if the membership status is valid.

type MissingInjectablesError

type MissingInjectablesError struct {
	MissingCodes []string
}

MissingInjectablesError indicates that required injectables are not available.

func (*MissingInjectablesError) Error

func (e *MissingInjectablesError) Error() string

Error implements the error interface.

type SystemInjectableAssignment

type SystemInjectableAssignment struct {
	ID            string              `json:"id"`
	InjectableKey string              `json:"injectableKey"`
	ScopeType     InjectableScopeType `json:"scopeType"`
	TenantID      *string             `json:"tenantId,omitempty"`
	TenantName    *string             `json:"tenantName,omitempty"`
	WorkspaceID   *string             `json:"workspaceId,omitempty"`
	WorkspaceName *string             `json:"workspaceName,omitempty"`
	IsActive      bool                `json:"isActive"`
	CreatedAt     time.Time           `json:"createdAt"`
}

SystemInjectableAssignment represents the assignment of a system injector to a scope.

func (*SystemInjectableAssignment) Validate

func (a *SystemInjectableAssignment) Validate() error

Validate checks if the assignment data is valid.

type SystemInjectableInfo

type SystemInjectableInfo struct {
	Key         string             `json:"key"`
	Label       map[string]string  `json:"label"`
	Description map[string]string  `json:"description"`
	DataType    InjectableDataType `json:"dataType"`
	Group       *string            `json:"group,omitempty"`
	IsActive    bool               `json:"isActive"`
	IsPublic    bool               `json:"isPublic"`
}

SystemInjectableInfo represents a system injector with its active state. Used for listing all available system injectors.

type SystemRole

type SystemRole string

SystemRole represents a user's role at the platform level.

const (
	SystemRoleSuperAdmin    SystemRole = "SUPERADMIN"
	SystemRolePlatformAdmin SystemRole = "PLATFORM_ADMIN"
)

func (SystemRole) HasPermission

func (s SystemRole) HasPermission(required SystemRole) bool

HasPermission checks if this role has at least the required role's permissions.

func (SystemRole) IsValid

func (s SystemRole) IsValid() bool

IsValid checks if the system role is valid.

func (SystemRole) Weight

func (s SystemRole) Weight() int

Weight returns the numeric weight of the role for permission comparisons. Higher weight = more permissions.

type SystemRoleAssignment

type SystemRoleAssignment struct {
	ID        string     `json:"id"`
	UserID    string     `json:"userId"`
	Role      SystemRole `json:"role"`
	GrantedBy *string    `json:"grantedBy,omitempty"`
	CreatedAt time.Time  `json:"createdAt"`
}

SystemRoleAssignment represents a user's system-level role assignment.

func NewSystemRoleAssignment

func NewSystemRoleAssignment(userID string, role SystemRole, grantedBy *string) *SystemRoleAssignment

NewSystemRoleAssignment creates a new system role assignment.

func (*SystemRoleAssignment) HasPermission

func (s *SystemRoleAssignment) HasPermission(required SystemRole) bool

HasPermission checks if the assignment has at least the required role.

func (*SystemRoleAssignment) Validate

func (s *SystemRoleAssignment) Validate() error

Validate checks if the system role assignment data is valid.

type SystemRoleWithUser

type SystemRoleWithUser struct {
	SystemRoleAssignment
	User *User `json:"user"`
}

SystemRoleWithUser represents a system role assignment with full user details.

type TableCell

type TableCell struct {
	Value   *InjectableValue `json:"value,omitempty"`   // cell content
	Colspan int              `json:"colspan,omitempty"` // number of columns to span
	Rowspan int              `json:"rowspan,omitempty"` // number of rows to span
}

TableCell represents a single cell in a table row.

func Cell

func Cell(value InjectableValue) TableCell

Cell creates a simple TableCell with a value.

func CellWithSpan

func CellWithSpan(value InjectableValue, colspan, rowspan int) TableCell

CellWithSpan creates a TableCell with colspan and/or rowspan.

func EmptyCell

func EmptyCell() TableCell

EmptyCell creates an empty TableCell (used for merged cell placeholders).

type TableColumn

type TableColumn struct {
	Key      string            `json:"key"`              // unique column identifier
	Labels   map[string]string `json:"labels"`           // i18n labels: {"es":"Nombre","en":"Name"}
	DataType ValueType         `json:"dataType"`         // expected cell value type
	Width    *string           `json:"width,omitempty"`  // e.g., "100px", "20%"
	Format   *string           `json:"format,omitempty"` // format string for the column
}

TableColumn defines a column in a dynamic table.

type TableRow

type TableRow struct {
	Cells []TableCell `json:"cells"`
}

TableRow represents a row of cells in a table.

type TableStyles

type TableStyles struct {
	FontFamily *string `json:"fontFamily,omitempty"` // e.g., "Arial", "Times New Roman"
	FontSize   *int    `json:"fontSize,omitempty"`   // in pixels
	FontWeight *string `json:"fontWeight,omitempty"` // "normal", "bold"
	TextColor  *string `json:"textColor,omitempty"`  // e.g., "#333333"
	TextAlign  *string `json:"textAlign,omitempty"`  // "left", "center", "right"
	Background *string `json:"background,omitempty"` // e.g., "#f5f5f5" (primarily for headers)
}

TableStyles defines styling options for table headers and body content.

type TableValue

type TableValue struct {
	Columns      []TableColumn `json:"columns"`
	Rows         []TableRow    `json:"rows"`
	HeaderStyles *TableStyles  `json:"headerStyles,omitempty"`
	BodyStyles   *TableStyles  `json:"bodyStyles,omitempty"`
}

TableValue represents a complete table with columns, rows, and styling.

func NewTableValue

func NewTableValue() *TableValue

NewTableValue creates a new empty TableValue.

func (*TableValue) AddColumn

func (t *TableValue) AddColumn(key string, labels map[string]string, dataType ValueType) *TableValue

AddColumn adds a column to the table with the given key, i18n labels, and data type.

func (*TableValue) AddColumnWithFormat

func (t *TableValue) AddColumnWithFormat(key string, labels map[string]string, dataType ValueType, format string) *TableValue

AddColumnWithFormat adds a column with a specified format.

func (*TableValue) AddColumnWithWidth

func (t *TableValue) AddColumnWithWidth(key string, labels map[string]string, dataType ValueType, width string) *TableValue

AddColumnWithWidth adds a column with a specified width.

func (*TableValue) AddRow

func (t *TableValue) AddRow(cells ...TableCell) *TableValue

AddRow adds a row of cells to the table.

func (*TableValue) WithBodyStyles

func (t *TableValue) WithBodyStyles(styles TableStyles) *TableValue

WithBodyStyles sets the body styles for the table.

func (*TableValue) WithHeaderStyles

func (t *TableValue) WithHeaderStyles(styles TableStyles) *TableValue

WithHeaderStyles sets the header styles for the table.

type Tag

type Tag struct {
	ID          string     `json:"id"`
	WorkspaceID string     `json:"workspaceId"`
	Name        string     `json:"name"`
	Color       string     `json:"color"` // Hex format: #RRGGBB
	CreatedAt   time.Time  `json:"createdAt"`
	UpdatedAt   *time.Time `json:"updatedAt,omitempty"`
}

Tag represents a cross-cutting label for categorizing templates.

func NewTag

func NewTag(workspaceID, name, color string) *Tag

NewTag creates a new tag with a default color if not provided.

func (*Tag) Validate

func (t *Tag) Validate() error

Validate checks if the tag data is valid.

type TagWithCount

type TagWithCount struct {
	Tag
	TemplateCount int `json:"templateCount"`
}

TagWithCount represents a tag with its template usage count. Used for tag listings with statistics.

type Template

type Template struct {
	ID              string     `json:"id"`
	WorkspaceID     string     `json:"workspaceId"`
	FolderID        *string    `json:"folderId,omitempty"`
	DocumentTypeID  *string    `json:"documentTypeId,omitempty"`
	Title           string     `json:"title"`
	IsPublicLibrary bool       `json:"isPublicLibrary"`
	CreatedAt       time.Time  `json:"createdAt"`
	UpdatedAt       *time.Time `json:"updatedAt,omitempty"`
}

Template represents a document blueprint (metadata only, content is in TemplateVersion).

func NewTemplate

func NewTemplate(workspaceID string, folderID *string, title string) *Template

NewTemplate creates a new template.

func (*Template) Validate

func (t *Template) Validate() error

Validate checks if the template data is valid.

type TemplateListItem

type TemplateListItem struct {
	ID                     string     `json:"id"`
	WorkspaceID            string     `json:"workspaceId"`
	FolderID               *string    `json:"folderId,omitempty"`
	DocumentTypeID         *string    `json:"documentTypeId,omitempty"`
	DocumentTypeCode       *string    `json:"documentTypeCode,omitempty"`
	Title                  string     `json:"title"`
	IsPublicLibrary        bool       `json:"isPublicLibrary"`
	Tags                   []*Tag     `json:"tags"`
	HasPublishedVersion    bool       `json:"hasPublishedVersion"`
	VersionCount           int        `json:"versionCount"`
	ScheduledVersionCount  int        `json:"scheduledVersionCount"`
	PublishedVersionNumber *int       `json:"publishedVersionNumber,omitempty"`
	CreatedAt              time.Time  `json:"createdAt"`
	UpdatedAt              *time.Time `json:"updatedAt,omitempty"`
}

TemplateListItem represents a template in list views (without version details).

type TemplateTag

type TemplateTag struct {
	TemplateID string `json:"templateId"`
	TagID      string `json:"tagId"`
}

TemplateTag represents the many-to-many relationship between templates and tags.

type TemplateVersion

type TemplateVersion struct {
	ID                 string          `json:"id"`
	TemplateID         string          `json:"templateId"`
	VersionNumber      int             `json:"versionNumber"`
	Name               string          `json:"name"`
	Description        *string         `json:"description,omitempty"`
	ContentStructure   json.RawMessage `json:"contentStructure,omitempty"`
	Status             VersionStatus   `json:"status"`
	ScheduledPublishAt *time.Time      `json:"scheduledPublishAt,omitempty"`
	ScheduledArchiveAt *time.Time      `json:"scheduledArchiveAt,omitempty"`
	PublishedAt        *time.Time      `json:"publishedAt,omitempty"`
	ArchivedAt         *time.Time      `json:"archivedAt,omitempty"`
	PublishedBy        *string         `json:"publishedBy,omitempty"`
	ArchivedBy         *string         `json:"archivedBy,omitempty"`
	CreatedBy          *string         `json:"createdBy,omitempty"`
	CreatedAt          time.Time       `json:"createdAt"`
	UpdatedAt          *time.Time      `json:"updatedAt,omitempty"`
}

TemplateVersion represents a specific version of a template with content and lifecycle management.

func NewTemplateVersion

func NewTemplateVersion(templateID string, versionNumber int, name string, createdBy *string) *TemplateVersion

NewTemplateVersion creates a new template version with DRAFT status.

func (*TemplateVersion) Archive

func (tv *TemplateVersion) Archive(userID string)

Archive changes the version status to ARCHIVED.

func (*TemplateVersion) CanArchive

func (tv *TemplateVersion) CanArchive() error

CanArchive returns an error if the version cannot be archived.

func (*TemplateVersion) CanEdit

func (tv *TemplateVersion) CanEdit() error

CanEdit returns an error if the version cannot be edited.

func (*TemplateVersion) CanPublish

func (tv *TemplateVersion) CanPublish() error

CanPublish returns an error if the version cannot be published.

func (*TemplateVersion) CanSchedulePublish

func (tv *TemplateVersion) CanSchedulePublish(publishAt time.Time) error

CanSchedulePublish returns an error if the version cannot be scheduled for publication.

func (*TemplateVersion) CancelSchedule

func (tv *TemplateVersion) CancelSchedule() error

CancelSchedule removes any scheduled publication or archive.

func (*TemplateVersion) IsArchived

func (tv *TemplateVersion) IsArchived() bool

IsArchived returns true if the version has been archived.

func (*TemplateVersion) IsDraft

func (tv *TemplateVersion) IsDraft() bool

IsDraft returns true if the version is in draft status.

func (*TemplateVersion) IsPublished

func (tv *TemplateVersion) IsPublished() bool

IsPublished returns true if the version is currently published.

func (*TemplateVersion) IsScheduled

func (tv *TemplateVersion) IsScheduled() bool

IsScheduled returns true if the version is scheduled for publication.

func (*TemplateVersion) Publish

func (tv *TemplateVersion) Publish(userID string)

Publish changes the version status to PUBLISHED.

func (*TemplateVersion) ScheduleArchive

func (tv *TemplateVersion) ScheduleArchive(archiveAt time.Time) error

ScheduleArchive sets the scheduled archive time (only for PUBLISHED versions).

func (*TemplateVersion) SchedulePublish

func (tv *TemplateVersion) SchedulePublish(publishAt time.Time) error

SchedulePublish sets the scheduled publication time.

func (*TemplateVersion) Validate

func (tv *TemplateVersion) Validate() error

Validate checks if the template version data is valid.

type TemplateVersionInjectable

type TemplateVersionInjectable struct {
	ID                     string    `json:"id"`
	TemplateVersionID      string    `json:"templateVersionId"`
	InjectableDefinitionID *string   `json:"injectableDefinitionId,omitempty"` // For workspace injectables
	SystemInjectableKey    *string   `json:"systemInjectableKey,omitempty"`    // For system injectables (month_now, etc)
	IsRequired             bool      `json:"isRequired"`
	DefaultValue           *string   `json:"defaultValue,omitempty"`
	CreatedAt              time.Time `json:"createdAt"`
}

TemplateVersionInjectable represents the configuration of a variable within a specific template version. It can reference either a workspace injectable (via InjectableDefinitionID) or a system injectable (via SystemInjectableKey), but not both.

func NewTemplateVersionInjectable

func NewTemplateVersionInjectable(templateVersionID, injectableDefID string, isRequired bool, defaultValue *string) *TemplateVersionInjectable

NewTemplateVersionInjectable creates a new template version injectable configuration for workspace injectables.

func NewTemplateVersionInjectableFromSystemKey

func NewTemplateVersionInjectableFromSystemKey(templateVersionID, systemKey string) *TemplateVersionInjectable

NewTemplateVersionInjectableFromSystemKey creates a new template version injectable for system injectables.

func (*TemplateVersionInjectable) GetKey

func (tvi *TemplateVersionInjectable) GetKey() string

GetKey returns the injectable key (either from definition or system key).

func (*TemplateVersionInjectable) IsSystemInjectable

func (tvi *TemplateVersionInjectable) IsSystemInjectable() bool

IsSystemInjectable returns true if this references a system injectable.

func (*TemplateVersionInjectable) Validate

func (tvi *TemplateVersionInjectable) Validate() error

Validate checks if the template version injectable data is valid. Either InjectableDefinitionID or SystemInjectableKey must be set, but not both.

type TemplateVersionListItem

type TemplateVersionListItem struct {
	ID                 string        `json:"id"`
	TemplateID         string        `json:"templateId"`
	VersionNumber      int           `json:"versionNumber"`
	Name               string        `json:"name"`
	Description        *string       `json:"description,omitempty"`
	Status             VersionStatus `json:"status"`
	ScheduledPublishAt *time.Time    `json:"scheduledPublishAt,omitempty"`
	ScheduledArchiveAt *time.Time    `json:"scheduledArchiveAt,omitempty"`
	PublishedAt        *time.Time    `json:"publishedAt,omitempty"`
	CreatedAt          time.Time     `json:"createdAt"`
	UpdatedAt          *time.Time    `json:"updatedAt,omitempty"`
}

TemplateVersionListItem represents a template version in list views (without full content).

type TemplateVersionWithDetails

type TemplateVersionWithDetails struct {
	TemplateVersion
	Injectables []*VersionInjectableWithDefinition `json:"injectables,omitempty"`
}

TemplateVersionWithDetails represents a template version with all its related data.

type TemplateWithAllVersions

type TemplateWithAllVersions struct {
	Template
	Versions     []*TemplateVersionWithDetails `json:"versions,omitempty"`
	Tags         []*Tag                        `json:"tags,omitempty"`
	Folder       *Folder                       `json:"folder,omitempty"`
	DocumentType *DocumentType                 `json:"documentType,omitempty"`
}

TemplateWithAllVersions represents a template with all its versions.

type TemplateWithDetails

type TemplateWithDetails struct {
	Template
	PublishedVersion *TemplateVersionWithDetails `json:"publishedVersion,omitempty"`
	Tags             []*Tag                      `json:"tags,omitempty"`
	Folder           *Folder                     `json:"folder,omitempty"`
}

TemplateWithDetails represents a template with its published version and metadata.

type Tenant

type Tenant struct {
	ID          string         `json:"id"`
	Name        string         `json:"name"`
	Code        string         `json:"code"`
	Description string         `json:"description,omitempty"`
	IsSystem    bool           `json:"isSystem"`
	Status      TenantStatus   `json:"status"`
	Settings    TenantSettings `json:"settings"`
	CreatedAt   time.Time      `json:"createdAt"`
	UpdatedAt   *time.Time     `json:"updatedAt,omitempty"`
}

Tenant represents a jurisdiction, country, or major business unit. It groups multiple workspaces together and provides regional configuration. The system tenant (IsSystem=true) is a special tenant that holds global templates.

func NewTenant

func NewTenant(name, code, description string, settings TenantSettings) *Tenant

NewTenant creates a new tenant with the given name, code and description.

func (*Tenant) Validate

func (t *Tenant) Validate() error

Validate checks if the tenant data is valid.

type TenantMember

type TenantMember struct {
	ID               string           `json:"id"`
	TenantID         string           `json:"tenantId"`
	UserID           string           `json:"userId"`
	Role             TenantRole       `json:"role"`
	MembershipStatus MembershipStatus `json:"membershipStatus"`
	GrantedBy        *string          `json:"grantedBy,omitempty"`
	CreatedAt        time.Time        `json:"createdAt"`
}

TenantMember represents a user's membership in a tenant with a specific role.

func NewTenantMember

func NewTenantMember(tenantID, userID string, role TenantRole, grantedBy *string) *TenantMember

NewTenantMember creates a new active tenant membership.

func (*TenantMember) HasPermission

func (t *TenantMember) HasPermission(required TenantRole) bool

HasPermission checks if the member has at least the required role.

func (*TenantMember) IsActive

func (t *TenantMember) IsActive() bool

IsActive returns true if the tenant membership is active.

func (*TenantMember) Validate

func (t *TenantMember) Validate() error

Validate checks if the tenant member data is valid.

type TenantMemberWithUser

type TenantMemberWithUser struct {
	TenantMember
	User *User `json:"user"`
}

TenantMemberWithUser represents a tenant member with full user details.

type TenantRole

type TenantRole string

TenantRole represents a user's role within a specific tenant.

const (
	TenantRoleOwner TenantRole = "TENANT_OWNER"
	TenantRoleAdmin TenantRole = "TENANT_ADMIN"
)

func (TenantRole) HasPermission

func (t TenantRole) HasPermission(required TenantRole) bool

HasPermission checks if this role has at least the required role's permissions.

func (TenantRole) IsValid

func (t TenantRole) IsValid() bool

IsValid checks if the tenant role is valid.

func (TenantRole) Weight

func (t TenantRole) Weight() int

Weight returns the numeric weight of the role for permission comparisons. Higher weight = more permissions.

type TenantSettings

type TenantSettings struct {
	Currency   string `json:"currency,omitempty"`
	Timezone   string `json:"timezone,omitempty"`
	DateFormat string `json:"dateFormat,omitempty"`
	Locale     string `json:"locale,omitempty"`
}

TenantSettings holds tenant-specific regional configuration.

type TenantStatus

type TenantStatus string

TenantStatus represents the status of a tenant.

const (
	TenantStatusActive    TenantStatus = "ACTIVE"
	TenantStatusSuspended TenantStatus = "SUSPENDED"
	TenantStatusArchived  TenantStatus = "ARCHIVED"
)

func (TenantStatus) IsValid

func (t TenantStatus) IsValid() bool

IsValid checks if the tenant status is valid.

type TenantWithRole

type TenantWithRole struct {
	Tenant         *Tenant    `json:"tenant"`
	Role           TenantRole `json:"role"`
	LastAccessedAt *time.Time `json:"lastAccessedAt,omitempty"`
}

TenantWithRole represents a tenant with the user's role in it.

type User

type User struct {
	ID                 string     `json:"id"`
	Email              string     `json:"email"`
	ExternalIdentityID *string    `json:"externalIdentityId,omitempty"` // OIDC sub claim
	FullName           string     `json:"fullName,omitempty"`
	Status             UserStatus `json:"status"`
	CreatedAt          time.Time  `json:"createdAt"`
}

User represents a shadow user record that mirrors external IdP accounts. Authentication is delegated to the OIDC provider; this record is for internal role management and audit trails.

func NewUser

func NewUser(email, fullName string) *User

NewUser creates a new user with INVITED status.

func (*User) Activate

func (u *User) Activate(externalID string)

Activate activates the user and links to IdP.

func (*User) CanAccess

func (u *User) CanAccess() error

CanAccess returns an error if the user cannot access resources.

func (*User) IsActive

func (u *User) IsActive() bool

IsActive returns true if the user is active.

func (*User) IsLinkedToIdP

func (u *User) IsLinkedToIdP() bool

IsLinkedToIdP returns true if the user has logged in via IdP.

func (*User) Validate

func (u *User) Validate() error

Validate checks if the user data is valid.

type UserAccessHistory

type UserAccessHistory struct {
	ID         string           `json:"id"`
	UserID     string           `json:"userId"`
	EntityType AccessEntityType `json:"entityType"`
	EntityID   string           `json:"entityId"`
	AccessedAt time.Time        `json:"accessedAt"`
}

UserAccessHistory represents a record of user's recent access to a resource.

func NewUserAccessHistory

func NewUserAccessHistory(userID string, entityType AccessEntityType, entityID string) *UserAccessHistory

NewUserAccessHistory creates a new access history record.

func (*UserAccessHistory) Validate

func (h *UserAccessHistory) Validate() error

Validate checks if the access history record is valid.

type UserStatus

type UserStatus string

UserStatus represents the status of a user account.

const (
	UserStatusInvited   UserStatus = "INVITED"
	UserStatusActive    UserStatus = "ACTIVE"
	UserStatusSuspended UserStatus = "SUSPENDED"
)

func (UserStatus) IsValid

func (u UserStatus) IsValid() bool

IsValid checks if the user status is valid.

type ValueType

type ValueType int

ValueType indicates the type of an injectable value.

const (
	// ValueTypeString represents a string value.
	ValueTypeString ValueType = iota
	// ValueTypeNumber represents a numeric value (float64).
	ValueTypeNumber
	// ValueTypeBool represents a boolean value.
	ValueTypeBool
	// ValueTypeTime represents a time.Time value.
	ValueTypeTime
	// ValueTypeTable represents a table value with columns and rows.
	ValueTypeTable
	// ValueTypeImage represents an image URL value.
	ValueTypeImage
	// ValueTypeList represents a list value with items and styling.
	ValueTypeList
)

type VersionInjectableWithDefinition

type VersionInjectableWithDefinition struct {
	TemplateVersionInjectable
	Definition *InjectableDefinition `json:"definition"`
}

VersionInjectableWithDefinition combines a template version injectable with its definition.

type VersionStatus

type VersionStatus string

VersionStatus represents the lifecycle status of a template version.

const (
	VersionStatusDraft     VersionStatus = "DRAFT"
	VersionStatusScheduled VersionStatus = "SCHEDULED"
	VersionStatusPublished VersionStatus = "PUBLISHED"
	VersionStatusArchived  VersionStatus = "ARCHIVED"
)

func (VersionStatus) CanTransitionTo

func (v VersionStatus) CanTransitionTo(target VersionStatus) bool

CanTransitionTo checks if transition to target status is allowed.

func (VersionStatus) IsValid

func (v VersionStatus) IsValid() bool

IsValid checks if the version status is valid.

func (VersionStatus) String

func (v VersionStatus) String() string

String returns the string representation of the version status.

type Workspace

type Workspace struct {
	ID             string          `json:"id"`
	TenantID       *string         `json:"tenantId,omitempty"` // NULL for global workspace
	Code           string          `json:"code"`
	Name           string          `json:"name"`
	Type           WorkspaceType   `json:"type"`
	Status         WorkspaceStatus `json:"status"`
	CreatedAt      time.Time       `json:"createdAt"`
	UpdatedAt      *time.Time      `json:"updatedAt,omitempty"`
	LastAccessedAt *time.Time      `json:"-"` // Access metadata, not persisted
}

Workspace is the root operational entity where all work happens. Every resource (templates, documents, users) belongs to a workspace.

func NewWorkspace

func NewWorkspace(tenantID *string, name string, wsType WorkspaceType) *Workspace

NewWorkspace creates a new workspace with default status ACTIVE.

func (*Workspace) CanAccess

func (w *Workspace) CanAccess() error

CanAccess returns true if the workspace can be accessed (active status).

func (*Workspace) IsActive

func (w *Workspace) IsActive() bool

IsActive returns true if the workspace is active.

func (*Workspace) IsGlobal

func (w *Workspace) IsGlobal() bool

IsGlobal returns true if this is a global workspace (no tenant).

func (*Workspace) IsSystem

func (w *Workspace) IsSystem() bool

IsSystem returns true if this is a system workspace.

func (*Workspace) Validate

func (w *Workspace) Validate() error

Validate checks if the workspace data is valid.

type WorkspaceMember

type WorkspaceMember struct {
	ID               string           `json:"id"`
	WorkspaceID      string           `json:"workspaceId"`
	UserID           string           `json:"userId"`
	Role             WorkspaceRole    `json:"role"`
	MembershipStatus MembershipStatus `json:"membershipStatus"`
	InvitedBy        *string          `json:"invitedBy,omitempty"`
	JoinedAt         *time.Time       `json:"joinedAt,omitempty"`
	CreatedAt        time.Time        `json:"createdAt"`
}

WorkspaceMember represents a user's membership in a workspace with a specific role.

func NewActiveMember

func NewActiveMember(workspaceID, userID string, role WorkspaceRole) *WorkspaceMember

NewActiveMember creates an immediately active membership.

func NewWorkspaceMember

func NewWorkspaceMember(workspaceID, userID string, role WorkspaceRole, invitedBy *string) *WorkspaceMember

NewWorkspaceMember creates a new pending membership.

func (*WorkspaceMember) Activate

func (m *WorkspaceMember) Activate()

Activate activates a pending membership.

func (*WorkspaceMember) HasPermission

func (m *WorkspaceMember) HasPermission(required WorkspaceRole) bool

HasPermission checks if the member has at least the required role.

func (*WorkspaceMember) IsActive

func (m *WorkspaceMember) IsActive() bool

IsActive returns true if the membership is active.

func (*WorkspaceMember) Validate

func (m *WorkspaceMember) Validate() error

Validate checks if the membership data is valid.

type WorkspaceRole

type WorkspaceRole string

WorkspaceRole represents a user's role within a workspace.

const (
	WorkspaceRoleOwner    WorkspaceRole = "OWNER"
	WorkspaceRoleAdmin    WorkspaceRole = "ADMIN"
	WorkspaceRoleEditor   WorkspaceRole = "EDITOR"
	WorkspaceRoleOperator WorkspaceRole = "OPERATOR"
	WorkspaceRoleViewer   WorkspaceRole = "VIEWER"
)

func (WorkspaceRole) HasPermission

func (w WorkspaceRole) HasPermission(required WorkspaceRole) bool

HasPermission checks if this role has at least the required role's permissions.

func (WorkspaceRole) IsValid

func (w WorkspaceRole) IsValid() bool

IsValid checks if the workspace role is valid.

func (WorkspaceRole) Weight

func (w WorkspaceRole) Weight() int

Weight returns the numeric weight of the role for permission comparisons. Higher weight = more permissions.

type WorkspaceStatus

type WorkspaceStatus string

WorkspaceStatus represents the status of a workspace.

const (
	WorkspaceStatusActive    WorkspaceStatus = "ACTIVE"
	WorkspaceStatusSuspended WorkspaceStatus = "SUSPENDED"
	WorkspaceStatusArchived  WorkspaceStatus = "ARCHIVED"
)

func (WorkspaceStatus) IsValid

func (w WorkspaceStatus) IsValid() bool

IsValid checks if the workspace status is valid.

type WorkspaceTagsCache

type WorkspaceTagsCache struct {
	TagID         string    `json:"tagId"`
	WorkspaceID   string    `json:"workspaceId"`
	TagName       string    `json:"tagName"`
	TagColor      string    `json:"tagColor"`
	TemplateCount int       `json:"templateCount"`
	TagCreatedAt  time.Time `json:"tagCreatedAt"`
}

WorkspaceTagsCache represents cached tag data for quick access. Mirrors the organizer.workspace_tags_cache table.

type WorkspaceType

type WorkspaceType string

WorkspaceType represents the type of workspace.

const (
	WorkspaceTypeSystem WorkspaceType = "SYSTEM"
	WorkspaceTypeClient WorkspaceType = "CLIENT"
)

func (WorkspaceType) IsValid

func (w WorkspaceType) IsValid() bool

IsValid checks if the workspace type is valid.

type WorkspaceWithRole

type WorkspaceWithRole struct {
	Workspace
	Role WorkspaceRole `json:"role"`
}

WorkspaceWithRole represents a workspace with the user's role in it. Used for listing workspaces a user has access to.

Directories

Path Synopsis
Package portabledoc defines types for the Portable Document Format (PDF-JSON).
Package portabledoc defines types for the Portable Document Format (PDF-JSON).

Jump to

Keyboard shortcuts

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