resource

package
v1.0.77 Latest Latest
Warning

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

Go to latest
Published: May 3, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContainerRecords           string = "records"
	FieldRecordID              Field  = "id"
	FieldRecordImportTime      Field  = "import_time"
	FieldRecordImportIndex     Field  = "import_index"
	FieldRecordSource          Field  = "source"
	FieldRecordNormalizedURL   Field  = "normalized_url"
	FieldRecordDirectURL       Field  = "direct_url"
	FieldRecordPlatformID      Field  = "platform_id"
	FieldRecordCharacterID     Field  = "character_id"
	FieldRecordName            Field  = "name"
	FieldRecordTitle           Field  = "title"
	FieldRecordCreatorID       Field  = "creator_id"
	FieldRecordTagline         Field  = "tagline"
	FieldRecordCreateTime      Field  = "create_time"
	FieldRecordUpdateTime      Field  = "update_time"
	FieldRecordBookUpdateTime  Field  = "book_update_time"
	FieldGreetingsCount        Field  = "greetings_count"
	FieldRecordHasBook         Field  = "has_book"
	FieldRecordIsFork          Field  = "is_fork"
	FieldRecordSyncTime        Field  = "sync_time"
	FieldRecordSyncStatus      Field  = "sync_status"
	FieldRecordExportTime      Field  = "export_time"
	FieldRecordExportedVersion Field  = "exported_version"
	FieldRecordFavorite        Field  = "favorite"
)

Record container and field constants

View Source
const (
	ContainerCreators      string = "creators"
	FieldCreatorID         Field  = "id"
	FieldCreatorNickname   Field  = "nickname"
	FieldCreatorUsername   Field  = "username"
	FieldCreatorPlatformID Field  = "platform_id"
	FieldCreatorSource     Field  = "source"
)

Creator container and field constants

View Source
const (
	ContainerTags string = "tags"
	FieldTagID    Field  = "id"
	FieldTagName  Field  = "name"
)

Tag container and field constants

Variables

ContentFields is a list of all content field names

Functions

func TagNames

func TagNames(tags []Tag) []string

TagNames extracts the names from a slice of tags

Types

type AuxData

type AuxData struct {
	Favorite bool
}

AuxData contains auxiliary flags like favorite status

type AuxHeader

type AuxHeader struct {
	ID RID
	AuxData
}

AuxHeader is a record header with auxiliary data

type BooleanFilter

type BooleanFilter struct {
	Field Field
	Value bool
}

BooleanFilter represents a boolean filter criterion

type Box

type Box[T any] struct {
	Items     []T
	Timestamp timestamp.Nano
}

Box is a generic container that holds a slice of items with a timestamp

type CID

type CID string

CID is a unique identifier for a creator

var EmptyCID CID = CID("")

EmptyCID represents an empty or invalid creator ID

type ContentFilter

type ContentFilter struct {
	FieldMode Mode
	Fields    []string
	ValueMode Mode
	Values    []string
}

ContentFilter represents a filter for searching within card content fields

type Creator

type Creator struct {
	ID         CID `json:"CID"`
	Nickname   string
	Username   string
	PlatformID string    `json:"CreatorPlatformID"`
	Source     source.ID `json:"CreatorSource"`
}

Creator represents the creator of a character card

type ExportData

type ExportData struct {
	ExportTime      timestamp.Nano
	ExportedVersion timestamp.Nano
}

ExportData contains export-related metadata

type ExportHeader

type ExportHeader struct {
	ID RID
	ExportData
}

ExportHeader is a record header with export data

type Field

type Field = string

Field is an alias for string representing a database field name

const (
	FieldContentDescription             Field = "description"
	FieldContentPersonality             Field = "personality"
	FieldContentScenario                Field = "scenario"
	FieldContentFirstMes                Field = "first_mes"
	FieldContentMesExample              Field = "mes_example"
	FieldContentCreatorNotes            Field = "creator_notes"
	FieldContentSystemPrompt            Field = "system_prompt"
	FieldContentPostHistoryInstructions Field = "post_history_instructions"
	FieldContentAlternateGreetings      Field = "alternate_greetings"
	FieldContentDepthPrompt             Field = "depth_prompt"
)

Content field constants for character card data

type FieldControl

type FieldControl struct {
	Field       Field
	DisplayName string
}

FieldControl represents a filterable field with its display name

type FieldControls

type FieldControls struct {
	TextFields     []FieldControl
	SortableFields []FieldControl
	BooleanFields  []FieldControl
	Sources        []source.ID
	Statuses       []SyncStatus
	ContentFields  []FieldControl
}

FieldControls defines the available filter controls for the UI

type Filter

type Filter struct {
	TextFilter     []TextFilter
	BooleanFilters []BooleanFilter
	SortFilters    []SortFilter
	Sources        []source.ID
	Statuses       []SyncStatus
	ContentFilters []ContentFilter
	TagFilter      TagFilter
}

Filter contains all active filter criteria for querying records

type ImportData

type ImportData struct {
	ImportTime  timestamp.Nano
	ImportIndex int
}

ImportData contains import-related metadata

type ImportHeader

type ImportHeader struct {
	ID RID
	ImportData
}

ImportHeader is a record header with import data

type ImportStatus

type ImportStatus string

ImportStatus represents the result of an import operation

const (
	ImportFailed    ImportStatus = "FAILED"
	ImportSuccess   ImportStatus = "SUCCESS"
	ImportDuplicate ImportStatus = "DUPLICATE"
)

func (ImportStatus) Values

func (ImportStatus) Values() []string

Values returns all possible import status values

type InfoData

type InfoData struct {
	Source         source.ID
	NormalizedURL  string
	DirectURL      string
	PlatformID     string
	CharacterID    string
	Name           string
	Title          string
	Tagline        string
	CreateTime     timestamp.Nano
	UpdateTime     timestamp.Nano
	BookUpdateTime timestamp.Nano
	GreetingsCount int
	IsFork         bool
	Tags           []Tag
}

InfoData contains the core information about a character card

func (*InfoData) LatestUpdateTime

func (r *InfoData) LatestUpdateTime() timestamp.Nano

LatestUpdateTime returns the most recent update timestamp

type InfoHeader

type InfoHeader struct {
	ID RID
	InfoData
}

InfoHeader is a record header with info data

type Mode

type Mode byte

Mode represents the matching mode for filters (ALL or ANY)

const (
	ALL Mode = iota
	ANY
)

type RID

type RID uint64

RID is a unique identifier for a resource record

var EmptyRID RID = RID(0)

EmptyRID represents an empty or invalid resource ID

func (RID) String

func (r RID) String() string

String returns the string representation of the RID

type Record

Record is the main resource record containing all data for a character card

func (*Record) FixIntegrity

func (r *Record) FixIntegrity(sheet *character.Sheet) RecordIntegrity

FixIntegrity attempts to repair inconsistencies between the record and sheet

func (*Record) Integrity

func (r *Record) Integrity() bool

Integrity returns true if all required fields of the record are valid

func (*Record) ToMetadata

func (r *Record) ToMetadata() *models.Metadata

ToMetadata converts the record to a metadata model

type RecordIntegrity

type RecordIntegrity byte

RecordIntegrity represents the integrity state of a record

const (
	OK RecordIntegrity = iota
	FIXED
	BROKEN
)

type SortFilter

type SortFilter struct {
	Field     Field
	Direction SortOrder
}

SortFilter represents a sorting criterion

type SortOrder

type SortOrder byte

SortOrder defines the direction of sorting

const (
	ASCENDING SortOrder = iota
	DESCENDING
)

type SyncData

type SyncData struct {
	SyncTime   timestamp.Nano
	SyncStatus SyncStatus
}

SyncData contains synchronization status and timestamp

type SyncHeader

type SyncHeader struct {
	ID RID
	SyncData
}

SyncHeader is a record header with sync data

type SyncStatus

type SyncStatus string

SyncStatus represents the synchronization status of a record

const (
	SyncFailed    SyncStatus = "FAILED"
	SyncSuccess   SyncStatus = "SUCCESS"
	SyncUnchanged SyncStatus = "UNCHANGED"
	SyncMissing   SyncStatus = "MISSING"
)

func (SyncStatus) Values

func (SyncStatus) Values() []string

Values returns all possible sync status values

type TID

type TID string

TID is a unique identifier for a tag

var EmptyTID TID = TID("")

EmptyTID represents an empty or invalid tag ID

func TagIDs

func TagIDs(tags []Tag) []TID

TagIDs extracts the IDs from a slice of tags

type Tag

type Tag struct {
	ID   TID
	Name string
}

Tag represents a tag associated with a character card

type TagFilter

type TagFilter struct {
	Names []string
	Mode  Mode
}

TagFilter represents a filter for searching by tags

type TextFilter

type TextFilter struct {
	Field     Field
	Value     string
	MatchMode TextMatchMode
}

TextFilter represents a text-based filter criterion

type TextMatchMode

type TextMatchMode struct {
	Regex         bool
	WholeWord     bool
	CaseSensitive bool
}

TextMatchMode defines how text matching should be performed

Jump to

Keyboard shortcuts

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