service

package
v0.1.34 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Deprecated: This package is deprecated as of 2025-10-01 and will be removed in 3 months. Please migrate to github.com/tendant/simple-content/pkg/simplecontent which provides:

  • Unified content operations (UploadContent, UploadDerivedContent)
  • Better error handling with typed errors
  • Cleaner API with fewer steps
  • Full documentation in pkg/simplecontent/service.go

See MIGRATION_FROM_LEGACY.md for migration guide.

Deprecated: This package is deprecated as of 2025-10-01 and will be removed in 3 months. Please migrate to github.com/tendant/simple-content/pkg/simplecontent which provides:

  • Unified content operations (UploadContent, UploadDerivedContent)
  • Better error handling with typed errors
  • Cleaner API with fewer steps
  • Full documentation in pkg/simplecontent/service.go

See MIGRATION_FROM_LEGACY.md for migration guide.

Deprecated: This package is deprecated as of 2025-10-01 and will be removed in 3 months. Please migrate to github.com/tendant/simple-content/pkg/simplecontent which provides:

  • Unified content operations (UploadContent, UploadDerivedContent)
  • Better error handling with typed errors
  • Cleaner API with fewer steps
  • Full documentation in pkg/simplecontent/service.go

See MIGRATION_FROM_LEGACY.md for migration guide.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateObjectKey added in v0.0.7

func GenerateObjectKey(contentID, objectID uuid.UUID, contentMetadata *model.ContentMetadata) string

GenerateObjectKey creates an object key based on content ID, object ID and content metadata

func GetLatestVersionObject added in v0.0.7

func GetLatestVersionObject(objects []*model.Object) *model.Object

GetLatestVersionObject returns the object with the highest version number from a slice of objects. If there are multiple objects with the same highest version, it returns the first one found.

Types

type ContentService

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

ContentService handles content-related operations

func NewContentService

func NewContentService(
	contentRepo repository.ContentRepository,
	metadataRepo repository.ContentMetadataRepository,
) *ContentService

NewContentService creates a new content service

func (*ContentService) CreateContent

func (s *ContentService) CreateContent(
	ctx context.Context,
	params CreateContentParams,
) (*model.Content, error)

CreateContent creates a new content

func (*ContentService) CreateDerivedContent

func (s *ContentService) CreateDerivedContent(
	ctx context.Context,
	params CreateDerivedContentParams,
) (*model.Content, error)

CreateDerivedContent creates a new content derived from an existing content

func (*ContentService) CreateDerivedContentRelationship added in v0.0.12

func (s *ContentService) CreateDerivedContentRelationship(ctx context.Context, params CreateDerivedRelationshipParams) error

func (*ContentService) DeleteContent

func (s *ContentService) DeleteContent(
	ctx context.Context,
	params DeleteContentParams,
) error

DeleteContent deletes a content

func (*ContentService) GetContent

func (s *ContentService) GetContent(ctx context.Context, id uuid.UUID) (*model.Content, error)

GetContent retrieves a content by ID

func (*ContentService) GetContentMetadata

func (s *ContentService) GetContentMetadata(ctx context.Context, contentID uuid.UUID) (*model.ContentMetadata, error)

GetContentMetadata retrieves metadata for a content

func (*ContentService) ListContent added in v0.0.7

func (s *ContentService) ListContent(
	ctx context.Context,
	params ListContentParams,
) ([]*model.Content, error)

ListContent lists all content for an owner and tenant

func (*ContentService) ListDerivedContent added in v0.0.12

func (s *ContentService) ListDerivedContent(
	ctx context.Context,
	params repository.ListDerivedContentParams,
) ([]*domain.DerivedContent, error)

ListDerivedContent retrieves derived content based on the provided parameters

func (*ContentService) SetContentMetadata

func (s *ContentService) SetContentMetadata(
	ctx context.Context,
	params SetContentMetadataParams,
) error

SetContentMetadata sets metadata for a content

func (*ContentService) UpdateContent

func (s *ContentService) UpdateContent(
	ctx context.Context,
	params UpdateContentParams,
) error

UpdateContent updates a content

type CreateContentParams added in v0.0.7

type CreateContentParams struct {
	OwnerID        uuid.UUID
	TenantID       uuid.UUID
	Title          string
	Description    string
	DocumentType   string
	DerivationType string
}

CreateContentParams contains parameters for creating new content

type CreateDerivedContentParams added in v0.0.7

type CreateDerivedContentParams struct {
	ParentID       uuid.UUID
	OwnerID        uuid.UUID
	TenantID       uuid.UUID
	Category       string
	DerivationType string
	Metadata       map[string]interface{}
}

CreateDerivedContentParams contains parameters for creating derived content

type CreateDerivedRelationshipParams added in v0.0.12

type CreateDerivedRelationshipParams struct {
	ParentID           uuid.UUID
	DerivedContentID   uuid.UUID
	DerivationType     string
	DerivationParams   map[string]interface{}
	ProcessingMetadata map[string]interface{}
}

type CreateObjectParams added in v0.0.7

type CreateObjectParams struct {
	ContentID          uuid.UUID
	StorageBackendName string
	Version            int
	ObjectKey          string
}

CreateObjectParams contains parameters for creating an object

type DeleteContentParams added in v0.0.7

type DeleteContentParams struct {
	ID uuid.UUID
}

DeleteContentParams contains parameters for deleting content

type GetObjectByObjectKeyAndStorageBackendNameParams added in v0.0.8

type GetObjectByObjectKeyAndStorageBackendNameParams struct {
	StorageBackendName string
	ObjectKey          string
}

GetObjectByObjectKeyAndStorageBackendNameParams contains parameters for looking up object by object key and storage backend name

type ListContentParams added in v0.0.7

type ListContentParams struct {
	OwnerID  uuid.UUID
	TenantID uuid.UUID
}

ListContentParams contains parameters for listing content

type ObjectService

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

ObjectService handles object-related operations

func NewObjectService

func NewObjectService(
	objectRepo repository.ObjectRepository,
	objectMetadataRepo repository.ObjectMetadataRepository,
	contentRepo repository.ContentRepository,
	contentMetadataRepo repository.ContentMetadataRepository,
) *ObjectService

NewObjectService creates a new object service

func (*ObjectService) CreateObject

func (s *ObjectService) CreateObject(
	ctx context.Context,
	params CreateObjectParams,
) (*model.Object, error)

CreateObject creates a new object for a content

func (*ObjectService) DeleteObject

func (s *ObjectService) DeleteObject(ctx context.Context, id uuid.UUID) error

DeleteObject deletes an object

func (*ObjectService) DownloadObject

func (s *ObjectService) DownloadObject(ctx context.Context, id uuid.UUID) (io.ReadCloser, error)

DownloadObject downloads an object

func (*ObjectService) GetBackend

func (s *ObjectService) GetBackend(name string) (storage.Backend, error)

GetBackend returns a storage backend by name

func (*ObjectService) GetDownloadURL

func (s *ObjectService) GetDownloadURL(ctx context.Context, id uuid.UUID) (string, error)

GetDownloadURL gets a URL for downloading an object

func (*ObjectService) GetObject

func (s *ObjectService) GetObject(ctx context.Context, id uuid.UUID) (*model.Object, error)

GetObject retrieves an object by ID

func (*ObjectService) GetObjectByObjectKeyAndStorageBackendName added in v0.0.8

func (s *ObjectService) GetObjectByObjectKeyAndStorageBackendName(ctx context.Context, params GetObjectByObjectKeyAndStorageBackendNameParams) (uuid.UUID, error)

GetObjectByObjectKeyAndStorageBackendName looks for object by object_key and storage_backend_name and returns the object UUID if found, nil if not exists

func (*ObjectService) GetObjectMetaFromStorage added in v0.0.5

func (s *ObjectService) GetObjectMetaFromStorage(ctx context.Context, objectID uuid.UUID) (*storage.ObjectMeta, error)

GetObjectMetaFromStorage retrieves metadata for an object directly from the storage backend This is useful when the upload happens client-side and we need to update our metadata

func (*ObjectService) GetObjectMetaFromStorageByObjectKeyAndStorageBackendName added in v0.0.9

func (s *ObjectService) GetObjectMetaFromStorageByObjectKeyAndStorageBackendName(ctx context.Context, objectKey string, storageBackendName string) (*storage.ObjectMeta, error)

GetObjectMetaFromStorageByObjectKeyAndStorageBackendName retrieves metadata for an object directly from the storage backend This is useful when the upload happens client-side and we need to update our metadata

func (*ObjectService) GetObjectMetadata

func (s *ObjectService) GetObjectMetadata(ctx context.Context, objectID uuid.UUID) (map[string]interface{}, error)

GetObjectMetadata retrieves metadata for an object

func (*ObjectService) GetObjectsByContentID

func (s *ObjectService) GetObjectsByContentID(ctx context.Context, contentID uuid.UUID) ([]*model.Object, error)

GetObjectsByContentID retrieves objects by content ID

func (*ObjectService) GetPreviewURL added in v0.0.6

func (s *ObjectService) GetPreviewURL(ctx context.Context, id uuid.UUID) (string, error)

GetPreviewURL gets a URL for previewing an object

func (*ObjectService) GetUploadURL

func (s *ObjectService) GetUploadURL(ctx context.Context, id uuid.UUID) (string, error)

GetUploadURL gets a URL for uploading an object

func (*ObjectService) RegisterBackend

func (s *ObjectService) RegisterBackend(name string, backend storage.Backend)

RegisterBackend registers a storage backend

func (*ObjectService) SetObjectMetadata

func (s *ObjectService) SetObjectMetadata(ctx context.Context, objectID uuid.UUID, metadata map[string]interface{}) error

SetObjectMetadata sets metadata for an object

func (*ObjectService) UpdateObject

func (s *ObjectService) UpdateObject(ctx context.Context, object *model.Object) error

UpdateObject updates an object

func (*ObjectService) UpdateObjectMetaFromStorage added in v0.0.5

func (s *ObjectService) UpdateObjectMetaFromStorage(ctx context.Context, objectID uuid.UUID) (model.ObjectMetadata, error)

UpdateObjectMetaFromStorage updates object metadata using information retrieved from the storage backend This is useful after a client-side upload to update our metadata and object status

func (*ObjectService) UploadObject

func (s *ObjectService) UploadObject(ctx context.Context, id uuid.UUID, reader io.Reader) error

UploadObject uploads an object

func (*ObjectService) UploadObjectWithMetadata added in v0.0.11

func (s *ObjectService) UploadObjectWithMetadata(ctx context.Context, reader io.Reader, params UploadObjectWithMetadataParams) error

type SetContentMetadataParams added in v0.0.7

type SetContentMetadataParams struct {
	ContentID      uuid.UUID
	ContentType    string
	Title          string
	Description    string
	Tags           []string
	FileName       string
	FileSize       int64
	CreatedBy      string
	CustomMetadata map[string]interface{}
}

SetContentMetadataParams contains parameters for setting content metadata

type StorageBackendService

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

StorageBackendService handles storage backend operations

func NewStorageBackendService

func NewStorageBackendService(
	storageBackendRepo repository.StorageBackendRepository,
) *StorageBackendService

NewStorageBackendService creates a new storage backend service

func (*StorageBackendService) CreateStorageBackend

func (s *StorageBackendService) CreateStorageBackend(
	ctx context.Context,
	name string,
	backendType string,
	config map[string]interface{},
) (*domain.StorageBackend, error)

CreateStorageBackend creates a new storage backend

func (*StorageBackendService) DeleteStorageBackend

func (s *StorageBackendService) DeleteStorageBackend(ctx context.Context, name string) error

DeleteStorageBackend deletes a storage backend

func (*StorageBackendService) GetStorageBackend

func (s *StorageBackendService) GetStorageBackend(ctx context.Context, name string) (*domain.StorageBackend, error)

GetStorageBackend retrieves a storage backend by name

func (*StorageBackendService) ListStorageBackends

func (s *StorageBackendService) ListStorageBackends(ctx context.Context) ([]*domain.StorageBackend, error)

ListStorageBackends lists all storage backends

func (*StorageBackendService) UpdateStorageBackend

func (s *StorageBackendService) UpdateStorageBackend(ctx context.Context, backend *domain.StorageBackend) error

UpdateStorageBackend updates a storage backend

type UpdateContentParams added in v0.0.7

type UpdateContentParams struct {
	Content *model.Content
}

UpdateContentParams contains parameters for updating content

type UploadObjectWithMetadataParams added in v0.0.11

type UploadObjectWithMetadataParams struct {
	ObjectID uuid.UUID
	MimeType string
}

Jump to

Keyboard shortcuts

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