Documentation
¶
Overview ¶
Package contentref defines the reference vocabulary every ContentKit package and port shares: a tenant-scoped reference to host-owned content and the identity of a generic taxonomy record.
Index ¶
- Variables
- func IDAt(t time.Time) string
- func NewID() string
- func ValidateID(id string) error
- type ContentKey
- type ContentRef
- func (r ContentRef) Content() ContentRef
- func (r ContentRef) Equal(o ContentRef) bool
- func (r ContentRef) Key() ContentKey
- func (r ContentRef) String() string
- func (r ContentRef) Validate() error
- func (r ContentRef) Version() string
- func (r ContentRef) WithVersion(contentVersionID string) ContentRef
- type IDError
- type TaxonomyID
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidID = errors.New("contentref: content_id must be a canonical lowercase UUIDv7")
ErrInvalidID is a content id that is not a canonical UUIDv7.
Functions ¶
func IDAt ¶ added in v0.45.0
IDAt returns a UUIDv7 whose timestamp is t (millisecond precision) and whose remaining 74 bits are random. Backfills derive ids from each legacy row's created_at so the new ids keep the legacy order.
func ValidateID ¶ added in v0.45.0
ValidateID accepts only a canonical content id: 36 characters, lowercase hex, version 7, RFC 9562 variant. A content id names a media folder and a search/signal key, and is never reused: time-ordered UUIDs cannot repeat after a host's database or sequence is reset.
Types ¶
type ContentKey ¶
type ContentKey struct {
TenantID string
ContentKind string
ContentID string
ContentVersionID string
}
ContentKey is the comparable form of a ContentRef; ContentVersionID is "" for the work. Storage keys use the same encoding.
func (ContentKey) Ref ¶
func (k ContentKey) Ref() ContentRef
Ref converts the key back into a reference.
type ContentRef ¶
type ContentRef struct {
TenantID string `json:"tenant_id"`
ContentKind string `json:"content_kind"`
ContentID string `json:"content_id"`
ContentVersionID *string `json:"content_version_id,omitempty"`
}
ContentRef identifies host-owned content: the work (a gallery, a video, a listing) or, when ContentVersionID is set, one selectable version of it. The host owns the meaning of ContentKind and the ids; ContentKit stores them opaquely, except that ContentID must be a canonical UUIDv7 (ValidateID). A language is never part of the reference.
func New ¶
func New(tenantID, contentKind, contentID string) ContentRef
New returns a reference to the work itself. Every ContentKit entry point validates it; Parse validates it at construction.
func NewVersion ¶
func NewVersion(tenantID, contentKind, contentID, contentVersionID string) ContentRef
NewVersion returns a reference to one version of the work.
func Parse ¶ added in v0.45.0
func Parse(tenantID, contentKind, contentID string) (ContentRef, error)
Parse returns a validated reference to the work.
func (ContentRef) Content ¶
func (r ContentRef) Content() ContentRef
Content returns the work-level reference.
func (ContentRef) Equal ¶
func (r ContentRef) Equal(o ContentRef) bool
Equal reports whether both references name the same content and version.
func (ContentRef) Key ¶
func (r ContentRef) Key() ContentKey
Key returns the comparable form used for map keys and equality.
func (ContentRef) String ¶
func (r ContentRef) String() string
func (ContentRef) Validate ¶
func (r ContentRef) Validate() error
Validate requires a tenant, kind and a UUIDv7 id (ErrInvalidID); a set version must be non-empty.
func (ContentRef) Version ¶
func (r ContentRef) Version() string
Version returns the version id, "" for the work itself.
func (ContentRef) WithVersion ¶
func (r ContentRef) WithVersion(contentVersionID string) ContentRef
WithVersion returns the reference scoped to contentVersionID ("" = the work).
type IDError ¶ added in v0.45.0
type IDError struct{ ID string }
IDError is a rejected content id; errors.Is(err, ErrInvalidID) holds.
type TaxonomyID ¶
type TaxonomyID string
TaxonomyID identifies a generic ContentKit catalog record (tag, artist, series, creator, character, voice actor). Until the taxonomy module lands, taxonomy records are indexed and referenced through ContentRef with the taxonomy kind as ContentKind and the TaxonomyID as ContentID.