docs

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxImageSizeBytes    = 5 * 1024 * 1024   // 5MB per image
	MaxTotalStorageBytes = 100 * 1024 * 1024 // 100MB per entity
	MaxImagesPerPage     = 50
	MaxPagesPerEntity    = 100
)

Variables

View Source
var (
	ErrPageNotFound         = errors.New("page not found")
	ErrImageNotFound        = errors.New("image not found")
	ErrInvalidInput         = errors.New("invalid input")
	ErrStorageLimitExceeded = errors.New("storage limit exceeded")
	ErrImageTooLarge        = errors.New("image exceeds maximum size")
	ErrInvalidImageType     = errors.New("invalid image type")
	ErrMaxPagesExceeded     = errors.New("maximum pages exceeded")
)
View Source
var ValidImageTypes = map[string]bool{
	"image/jpeg": true,
	"image/png":  true,
	"image/gif":  true,
	"image/webp": true,
}

Functions

func ExtractImageIDs

func ExtractImageIDs(content string) []string

ExtractImageIDs extracts image IDs referenced in markdown/HTML content.

Types

type CreatePageInput

type CreatePageInput struct {
	ParentID *string `json:"parent_id,omitempty"`
	Title    string  `json:"title"`
	Emoji    *string `json:"emoji,omitempty"`
	Content  *string `json:"content,omitempty"`
}

type EntityType

type EntityType string
const (
	EntityTypeAsset       EntityType = "asset"
	EntityTypeDataProduct EntityType = "data_product"
)

type Image

type Image struct {
	ID          string    `json:"id"`
	PageID      string    `json:"page_id"`
	Filename    string    `json:"filename"`
	ContentType string    `json:"content_type"`
	SizeBytes   int       `json:"size_bytes"`
	Data        []byte    `json:"-"`
	CreatedAt   time.Time `json:"created_at"`
}

type ImageMeta

type ImageMeta struct {
	ID          string    `json:"id"`
	PageID      string    `json:"page_id"`
	Filename    string    `json:"filename"`
	ContentType string    `json:"content_type"`
	SizeBytes   int       `json:"size_bytes"`
	URL         string    `json:"url"`
	CreatedAt   time.Time `json:"created_at"`
}

type MovePageInput

type MovePageInput struct {
	ParentID *string `json:"parent_id,omitempty"`
	Position int     `json:"position"`
}

type Page

type Page struct {
	ID         string     `json:"id"`
	EntityType EntityType `json:"entity_type"`
	EntityID   string     `json:"entity_id"`
	ParentID   *string    `json:"parent_id,omitempty"`
	Position   int        `json:"position"`
	Title      string     `json:"title"`
	Emoji      *string    `json:"emoji,omitempty"`
	Content    *string    `json:"content,omitempty"`
	CreatedBy  *string    `json:"created_by,omitempty"`
	CreatedAt  time.Time  `json:"created_at"`
	UpdatedAt  time.Time  `json:"updated_at"`

	Children   []*Page `json:"children,omitempty"`
	ImageCount int     `json:"image_count,omitempty"`
}

type PageTree

type PageTree struct {
	Pages      []*Page      `json:"pages"`
	TotalPages int          `json:"total_pages"`
	Stats      StorageStats `json:"stats"`
}

type PostgresRepository

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

func NewPostgresRepository

func NewPostgresRepository(db *pgxpool.Pool) *PostgresRepository

func (*PostgresRepository) CountPageImages

func (r *PostgresRepository) CountPageImages(ctx context.Context, pageID string) (int, error)

func (*PostgresRepository) CountPages

func (r *PostgresRepository) CountPages(ctx context.Context, entityType EntityType, entityID string) (int, error)

func (*PostgresRepository) CreateImage

func (r *PostgresRepository) CreateImage(ctx context.Context, pageID string, input UploadImageInput) (*Image, error)

func (*PostgresRepository) CreatePage

func (r *PostgresRepository) CreatePage(ctx context.Context, entityType EntityType, entityID string, input CreatePageInput, createdBy *string) (*Page, error)

func (*PostgresRepository) DeleteImage

func (r *PostgresRepository) DeleteImage(ctx context.Context, imageID string) error

func (*PostgresRepository) DeletePage

func (r *PostgresRepository) DeletePage(ctx context.Context, pageID string) error

func (*PostgresRepository) GetChildPages

func (r *PostgresRepository) GetChildPages(ctx context.Context, parentID string) ([]*Page, error)

func (*PostgresRepository) GetImage

func (r *PostgresRepository) GetImage(ctx context.Context, imageID string) (*Image, error)

func (*PostgresRepository) GetImageMeta

func (r *PostgresRepository) GetImageMeta(ctx context.Context, imageID string) (*ImageMeta, error)

func (*PostgresRepository) GetImagePageID

func (r *PostgresRepository) GetImagePageID(ctx context.Context, imageID string) (string, error)

func (*PostgresRepository) GetPage

func (r *PostgresRepository) GetPage(ctx context.Context, pageID string) (*Page, error)

func (*PostgresRepository) GetPageEntityInfo

func (r *PostgresRepository) GetPageEntityInfo(ctx context.Context, pageID string) (EntityType, string, error)

func (*PostgresRepository) GetPageTree

func (r *PostgresRepository) GetPageTree(ctx context.Context, entityType EntityType, entityID string) (*PageTree, error)

func (*PostgresRepository) GetRootPages

func (r *PostgresRepository) GetRootPages(ctx context.Context, entityType EntityType, entityID string) ([]*Page, error)

func (*PostgresRepository) GetStorageStats

func (r *PostgresRepository) GetStorageStats(ctx context.Context, entityType EntityType, entityID string) (*StorageStats, error)

func (*PostgresRepository) GetTotalStorageBytes

func (r *PostgresRepository) GetTotalStorageBytes(ctx context.Context, entityType EntityType, entityID string) (int64, error)

func (*PostgresRepository) ListPageImages

func (r *PostgresRepository) ListPageImages(ctx context.Context, pageID string) ([]*ImageMeta, error)

func (*PostgresRepository) MovePage

func (r *PostgresRepository) MovePage(ctx context.Context, pageID string, input MovePageInput) (*Page, error)

func (*PostgresRepository) SearchPages

func (r *PostgresRepository) SearchPages(ctx context.Context, entityType EntityType, entityID string, queryStr string, limit, offset int) ([]*Page, int, error)

func (*PostgresRepository) UpdatePage

func (r *PostgresRepository) UpdatePage(ctx context.Context, pageID string, input UpdatePageInput) (*Page, error)

type Repository

type Repository interface {
	CreatePage(ctx context.Context, entityType EntityType, entityID string, input CreatePageInput, createdBy *string) (*Page, error)
	GetPage(ctx context.Context, pageID string) (*Page, error)
	UpdatePage(ctx context.Context, pageID string, input UpdatePageInput) (*Page, error)
	DeletePage(ctx context.Context, pageID string) error
	MovePage(ctx context.Context, pageID string, input MovePageInput) (*Page, error)

	GetPageTree(ctx context.Context, entityType EntityType, entityID string) (*PageTree, error)
	GetRootPages(ctx context.Context, entityType EntityType, entityID string) ([]*Page, error)
	GetChildPages(ctx context.Context, parentID string) ([]*Page, error)
	SearchPages(ctx context.Context, entityType EntityType, entityID string, query string, limit, offset int) ([]*Page, int, error)
	CountPages(ctx context.Context, entityType EntityType, entityID string) (int, error)

	CreateImage(ctx context.Context, pageID string, input UploadImageInput) (*Image, error)
	GetImage(ctx context.Context, imageID string) (*Image, error)
	GetImageMeta(ctx context.Context, imageID string) (*ImageMeta, error)
	DeleteImage(ctx context.Context, imageID string) error
	ListPageImages(ctx context.Context, pageID string) ([]*ImageMeta, error)
	CountPageImages(ctx context.Context, pageID string) (int, error)

	GetStorageStats(ctx context.Context, entityType EntityType, entityID string) (*StorageStats, error)
	GetTotalStorageBytes(ctx context.Context, entityType EntityType, entityID string) (int64, error)

	GetPageEntityInfo(ctx context.Context, pageID string) (EntityType, string, error)
	GetImagePageID(ctx context.Context, imageID string) (string, error)
}

type Service

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

func NewService

func NewService(repo Repository) *Service

func (*Service) CreatePage

func (s *Service) CreatePage(ctx context.Context, entityType EntityType, entityID string, input CreatePageInput, createdBy *string) (*Page, error)

func (*Service) DeleteImage

func (s *Service) DeleteImage(ctx context.Context, imageID string) error

func (*Service) DeletePage

func (s *Service) DeletePage(ctx context.Context, pageID string) error

func (*Service) GetImage

func (s *Service) GetImage(ctx context.Context, imageID string) (*Image, error)

func (*Service) GetImageEntityInfo

func (s *Service) GetImageEntityInfo(ctx context.Context, imageID string) (EntityType, string, error)

func (*Service) GetPage

func (s *Service) GetPage(ctx context.Context, pageID string) (*Page, error)

func (*Service) GetPageEntityInfo

func (s *Service) GetPageEntityInfo(ctx context.Context, pageID string) (EntityType, string, error)

func (*Service) GetPageTree

func (s *Service) GetPageTree(ctx context.Context, entityType EntityType, entityID string) (*PageTree, error)

func (*Service) GetStorageStats

func (s *Service) GetStorageStats(ctx context.Context, entityType EntityType, entityID string) (*StorageStats, error)

func (*Service) ListPageImages

func (s *Service) ListPageImages(ctx context.Context, pageID string) ([]*ImageMeta, error)

func (*Service) MovePage

func (s *Service) MovePage(ctx context.Context, pageID string, input MovePageInput) (*Page, error)

func (*Service) SearchPages

func (s *Service) SearchPages(ctx context.Context, entityType EntityType, entityID string, query string, limit, offset int) ([]*Page, int, error)

func (*Service) UpdatePage

func (s *Service) UpdatePage(ctx context.Context, pageID string, input UpdatePageInput) (*Page, error)

func (*Service) UploadImage

func (s *Service) UploadImage(ctx context.Context, pageID string, input UploadImageInput) (*ImageMeta, error)

type StorageStats

type StorageStats struct {
	EntityType  EntityType `json:"entity_type"`
	EntityID    string     `json:"entity_id"`
	UsedBytes   int64      `json:"used_bytes"`
	MaxBytes    int64      `json:"max_bytes"`
	ImageCount  int        `json:"image_count"`
	PageCount   int        `json:"page_count"`
	UsedPercent float64    `json:"used_percent"`
}

type UpdatePageInput

type UpdatePageInput struct {
	Title   *string `json:"title,omitempty"`
	Emoji   *string `json:"emoji,omitempty"`
	Content *string `json:"content,omitempty"`
}

type UploadImageInput

type UploadImageInput struct {
	Filename    string
	ContentType string
	Data        []byte
}

Jump to

Keyboard shortcuts

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