metadata

package
v0.0.0-...-c54dfb2 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: AGPL-3.0 Imports: 2 Imported by: 2 modules, 16 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package metadata is used for manipulating the cozyMetadata field of the documents.

Index

Constants

View Source
const MetadataVersion = 1

MetadataVersion represents the CozyMetadata version used.

Variables

View Source
var ErrSlugEmpty = errors.New("Slug cannot be empty")

ErrSlugEmpty is returned when an UpdatedByApp entry is created with and empty slug

Functions

This section is empty.

Types

type CozyMetadata

type CozyMetadata struct {
	// Name or identifier for the version of the schema used by this document
	DocTypeVersion string `json:"doctypeVersion"`
	// Version of the cozyMetadata
	MetadataVersion int `json:"metadataVersion"`
	// Tell if the document if part of the favorites
	Favorite bool `json:"favorite,omitempty"`
	// Creation date of the cozy document
	CreatedAt time.Time `json:"createdAt"`
	// Slug of the app or konnector which created the document
	CreatedByApp string `json:"createdByApp,omitempty"`
	// Version identifier of the app
	CreatedByAppVersion string `json:"createdByAppVersion,omitempty"`
	// Last modification date of the cozy document
	UpdatedAt time.Time `json:"updatedAt"`
	// List of objects representing the applications which modified the cozy document
	UpdatedByApps []*UpdatedByAppEntry `json:"updatedByApps,omitempty"`
	// Identifier of the account in io.cozy.accounts (for konnectors)
	SourceAccount string `json:"sourceAccount,omitempty"`
	// Identifier unique to the account targeted by the connector (login most of the time)
	SourceIdentifier string `json:"sourceAccountIdentifier,omitempty"`
}

CozyMetadata holds all the metadata of a document

func New

func New() *CozyMetadata

New initializes a new CozyMetadata structure

func NewWithApp

func NewWithApp(slug, version, doctypeVersion string) (*CozyMetadata, error)

NewWithApp initializes a CozyMetadata with a slug and a version Version is optional

func (*CozyMetadata) ChangeUpdatedAt

func (cm *CozyMetadata) ChangeUpdatedAt()

ChangeUpdatedAt updates the UpdatedAt timestamp

func (*CozyMetadata) Clone

func (cm *CozyMetadata) Clone() *CozyMetadata

Clone clones a CozyMetadata struct

func (*CozyMetadata) EnsureCreatedFields

func (cm *CozyMetadata) EnsureCreatedFields(defaultMetadata *CozyMetadata)

EnsureCreatedFields ensures that empty fields are filled, otherwise use the default metadata values during the creation process

func (*CozyMetadata) UpdatedByApp

func (cm *CozyMetadata) UpdatedByApp(slug, version string) error

UpdatedByApp updates an entry either by updating the struct if the slug/version already exists or by appending a new entry to the list

type UpdatedByAppEntry

type UpdatedByAppEntry struct {
	Slug     string    `json:"slug"`               // Slug of the app
	Date     time.Time `json:"date"`               // Date of the update
	Version  string    `json:"version,omitempty"`  // Version identifier of the app
	Instance string    `json:"instance,omitempty"` // URL of the instance
}

UpdatedByAppEntry represents a modification made by an application to the document

Jump to

Keyboard shortcuts

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