streams

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2023 License: Apache-2.0 Imports: 8 Imported by: 14

Documentation

Index

Constants

View Source
const TypeCollection = "Collection"
View Source
const TypeCollectionPage = "CollectionPage"
View Source
const TypeOrderedCollection = "OrderedCollection"
View Source
const TypeOrderedCollectionPage = "OrderedCollectionPage"

Variables

This section is empty.

Functions

func UnmarshalItems

func UnmarshalItems(data any) ([]any, bool)

Types

type Cache

type Cache interface {
	Get(string) map[string]any
	Set(string, map[string]any)
	Delete(string)
}

Cache is a simple interace for caching JSON-LD documents. There is a default implementation in the "cache" package, but this can be replaced with any other implementation.

type Collection

type Collection struct {
	Context    Context `json:"@context"`
	Type       string  `json:"type"`
	Summary    string  `json:"summary"`    // A natural language summarization of the object encoded as HTML. Multiple language tagged summaries may be provided.
	TotalItems int     `json:"totalItems"` // A non-negative integer specifying the total number of objects contained by the logical view of the collection. This number might not reflect the actual number of items serialized within the Collection object instance.
	Current    string  `json:"current"`    // In a paged Collection, indicates the page that contains the most recently updated member items.
	First      string  `json:"first"`      // In a paged Collection, indicates the furthest preceeding page of items in the collection.
	Last       string  `json:"last"`       // In a paged Collection, indicates the furthest proceeding page of the collection.
	Items      []any   `json:"items"`      // Identifies the items contained in a collection. The items might be ordered or unordered.
}

Collection is a subtype of Object that represents ordered or unordered sets of Object or Link instances. https://www.w3.org/ns/activitystreams#Collection

func (*Collection) UnmarshalJSON

func (c *Collection) UnmarshalJSON(data []byte) error

func (*Collection) UnmarshalMap

func (c *Collection) UnmarshalMap(data mapof.Any) error

type CollectionPage

type CollectionPage struct {
	Context    Context `json:"@context"`
	Type       string  `json:"type"`
	Summary    string  `json:"summary"`    // A natural language summarization of the object encoded as HTML. Multiple language tagged summaries may be provided.
	TotalItems int     `json:"totalItems"` // A non-negative integer specifying the total number of objects contained by the logical view of the collection. This number might not reflect the actual number of items serialized within the Collection object instance.
	Current    string  `json:"current"`    // In a paged Collection, indicates the page that contains the most recently updated member items.
	First      string  `json:"first"`      // In a paged Collection, indicates the furthest preceeding page of items in the collection.
	Last       string  `json:"last"`       // In a paged Collection, indicates the furthest proceeding page of the collection.
	PartOf     string  `json:"partOf"`     // dentifies the Collection to which a CollectionPage objects items belong.
	Prev       string  `json:"prev"`       // In a paged Collection, identifies the previous page of items.
	Next       string  `json:"next"`       // In a paged Collection, indicates the next page of items.
	Items      []any   `json:"items"`      // Identifies the items contained in a collection. The items might be ordered or unordered.
}

CollectionPage is used to represent distinct subsets of items from a Collection. Refer to the Activity Streams 2.0 Core for a complete description of the CollectionPage object. https://www.w3.org/ns/activitystreams#CollectionPage

func (*CollectionPage) UnmarshalJSON

func (c *CollectionPage) UnmarshalJSON(data []byte) error

func (*CollectionPage) UnmarshalMap

func (c *CollectionPage) UnmarshalMap(data mapof.Any) error

type Context

type Context []ContextEntry

func DefaultContext

func DefaultContext() Context

DefaultContext represents the standard context defined by the W3C

func NewContext

func NewContext(args ...string) Context

func (*Context) Add

func (c *Context) Add(vocabulary string) *ContextEntry

Add puts a new ContextEntry into the list and returns a pointer to it so that additional properties can be set.

func (Context) Head

func (c Context) Head() *ContextEntry

func (Context) IsEmpty

func (c Context) IsEmpty() bool

func (Context) IsEmptyTail

func (c Context) IsEmptyTail() bool

func (Context) Length

func (c Context) Length() int

func (Context) MarshalJSON

func (c Context) MarshalJSON() ([]byte, error)

func (Context) Tail

func (c Context) Tail() Context

func (*Context) UnmarshalJSON

func (c *Context) UnmarshalJSON(data []byte) error

type ContextEntry

type ContextEntry struct {
	Vocabulary string            // The primary vocabulary represented by the context/document.
	Language   string            // The language
	Extensions map[string]string // a map of additional namespaces that are included in this context/document.
}

ContextEntry https://www.w3.org/TR/json-ld/#the-context

func NewContextEntry

func NewContextEntry(vocabulary string) ContextEntry

func (ContextEntry) HasExtensions

func (entry ContextEntry) HasExtensions() bool

func (ContextEntry) IsLanguageDefined

func (entry ContextEntry) IsLanguageDefined() bool

func (ContextEntry) IsVocabularyOnly

func (entry ContextEntry) IsVocabularyOnly() bool

func (ContextEntry) MarshalJSON

func (entry ContextEntry) MarshalJSON() ([]byte, error)

func (*ContextEntry) WithExtension

func (entry *ContextEntry) WithExtension(key string, value string) *ContextEntry

func (*ContextEntry) WithLanguage

func (entry *ContextEntry) WithLanguage(language string) *ContextEntry

type Document

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

Document represents a single ActivityStream document or document fragment. Due to the flexibility of ActivityStreams (and JSON-LD), this may be a data structure such as a `map[string]any`, `[]any`, or a primitive type, like a `string`, `float`, `int` or `bool`.

func NewDocument

func NewDocument(value map[string]any, cache Cache) Document

NewDocument creates a new Document object from a JSON-LD map[string]any

func NewID

func NewID(value string, cache Cache) Document

func NilDocument

func NilDocument() Document

NilDocument returns a new, empty Document.

func (Document) Accuracy

func (document Document) Accuracy() float64

func (Document) Activity

func (document Document) Activity() Document

func (Document) Actor

func (document Document) Actor() Document

func (Document) ActorID

func (document Document) ActorID() string

func (Document) Altitude

func (document Document) Altitude() float64

func (Document) AnyOf

func (document Document) AnyOf() Document

func (Document) AsBool

func (document Document) AsBool() bool

AsBool returns the current object as a floating-point value

func (Document) AsFloat

func (document Document) AsFloat() float64

AsFloat returns the current object as an integer value

func (Document) AsInt

func (document Document) AsInt() int

AsInt returns the current object as an integer value

func (Document) AsObject

func (document Document) AsObject() (Document, error)

AsObject retrieves a JSON-LD document from a remote server, parses is, and returns a Document object.

func (Document) AsString

func (document Document) AsString() string

AsString returns the current object as a string value

func (Document) AsTime

func (document Document) AsTime() time.Time

AsTime returns the current object as a time value

func (Document) Attachment

func (document Document) Attachment() Document

func (Document) AttributedTo

func (document Document) AttributedTo() Document

func (Document) Audience

func (document Document) Audience() Document

func (Document) Bcc

func (document Document) Bcc() Document

func (Document) Bto

func (document Document) Bto() Document

func (Document) Cc

func (document Document) Cc() Document

func (Document) Closed

func (document Document) Closed() Document

func (Document) Content

func (document Document) Content() string

func (Document) Context

func (document Document) Context() Document

func (Document) Current

func (document Document) Current() Document

func (Document) Deleted

func (document Document) Deleted() time.Time

func (Document) Describes

func (document Document) Describes() Document

func (Document) Duration

func (document Document) Duration() string

TODO: Implement Durations per https://www.w3.org/TR/activitystreams-vocabulary/#dfn-duration

func (Document) EndTime

func (document Document) EndTime() time.Time

func (Document) First

func (document Document) First() Document

func (Document) FormerType

func (document Document) FormerType() string

func (Document) Generator

func (document Document) Generator() Document

func (Document) Get

func (document Document) Get(key string) Document

Get returns a sub-property of the current document

func (Document) Head

func (document Document) Head() Document

Head returns the first object in a slice. For all other document types, it returns the current document.

func (Document) Height

func (document Document) Height() int

func (Document) Href

func (document Document) Href() string

func (Document) Hreflang

func (document Document) Hreflang() string

func (Document) ID

func (document Document) ID() string

func (Document) Icon

func (document Document) Icon() Document

func (Document) IconURL

func (document Document) IconURL() string

func (Document) Image

func (document Document) Image() Document

func (Document) ImageURL

func (document Document) ImageURL() string

func (Document) InReplyTo

func (document Document) InReplyTo() Document

func (Document) Instrument

func (document Document) Instrument() Document

func (Document) IsArray

func (document Document) IsArray() bool

func (Document) IsBool

func (document Document) IsBool() bool

func (Document) IsEmptyTail

func (document Document) IsEmptyTail() bool

IsEmpty return TRUE if the current object is empty

func (Document) IsFloat

func (document Document) IsFloat() bool

func (Document) IsInt

func (document Document) IsInt() bool

func (Document) IsInt64

func (document Document) IsInt64() bool

func (Document) IsNil

func (document Document) IsNil() bool

func (Document) IsObject

func (document Document) IsObject() bool

func (Document) IsString

func (document Document) IsString() bool

func (Document) Items

func (document Document) Items() Document

func (Document) Last

func (document Document) Last() Document

func (Document) Latitude

func (document Document) Latitude() float64

func (Document) Location

func (document Document) Location() Document

func (Document) Longitude

func (document Document) Longitude() float64

func (Document) MarshalJSON

func (document Document) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface, and provides a custom marshalling into JSON -- essentially just aiming the marshaller at the Document's value.

func (Document) MediaType

func (document Document) MediaType() string

func (Document) Name

func (document Document) Name() string

TODO: Re-Implement Language Maps

func (Document) Next

func (document Document) Next() Document

func (Document) Object

func (document Document) Object() Document

func (Document) ObjectID

func (document Document) ObjectID() string

func (Document) OneOf

func (document Document) OneOf() Document

func (Document) Origin

func (document Document) Origin() Document

func (Document) PartOf

func (document Document) PartOf() Document

func (Document) Prev

func (document Document) Prev() Document

func (Document) Preview

func (document Document) Preview() Document

func (Document) Published

func (document Document) Published() time.Time

func (Document) Radius

func (document Document) Radius() float64

func (Document) Rel

func (document Document) Rel() Document

Rel is expected to be a string, but this function returns a document because it may contain multiple values (rel:["canonical", "preview"])

func (Document) Relationship

func (document Document) Relationship() string

func (Document) Replies

func (document Document) Replies() Document

func (Document) Result

func (document Document) Result() Document

func (Document) StartIndex

func (document Document) StartIndex() int

func (Document) StartTime

func (document Document) StartTime() time.Time

func (Document) Subject

func (document Document) Subject() Document

func (Document) Summary

func (document Document) Summary() string

// TODO: Implement Language Maps

func (Document) Tag

func (document Document) Tag() Document

func (Document) Tail

func (document Document) Tail() Document

Tail returns all records after the first in a slice. For all other document types, it returns a nil document.

func (Document) Target

func (document Document) Target() Document

func (Document) TargetID

func (document Document) TargetID() string

func (Document) To

func (document Document) To() Document

func (Document) TotalItems

func (document Document) TotalItems() int

func (Document) Type

func (document Document) Type() string

func (Document) URL

func (document Document) URL() string

func (Document) Units

func (document Document) Units() string

func (*Document) UnmarshalJSON

func (document *Document) UnmarshalJSON(bytes []byte) error

UnmarshalJSON implements the json.Unmarshaller interface, and provides a custom un-marshalling from JSON -- essentially just aiming the unmashaller at the Document's value

func (Document) Updated

func (document Document) Updated() time.Time

func (Document) Url

func (document Document) Url() Document

TODO: HIGH: Special handling for URL properties strings => {href: <string>} https://www.w3.org/TR/activitystreams-vocabulary/#dfn-url

func (Document) Value

func (document Document) Value() any

Value returns the generic data stored in this Document

func (Document) Width

func (document Document) Width() int

type OrderedCollection

type OrderedCollection struct {
	Context      Context `json:"@context"`
	Type         string  `json:"type"`
	Summary      string  `json:"summary"`      // A natural language summarization of the object encoded as HTML. Multiple language tagged summaries may be provided.
	TotalItems   int     `json:"totalItems"`   // A non-negative integer specifying the total number of objects contained by the logical view of the collection. This number might not reflect the actual number of items serialized within the Collection object instance.
	OrderedItems []any   `json:"orderedItems"` // Identifies the items contained in a collection. The items might be ordered or unordered.
	Current      string  `json:"current"`      // In a paged Collection, indicates the page that contains the most recently updated member items.
	First        string  `json:"first"`        // In a paged Collection, indicates the furthest preceeding page of items in the collection.
	Last         string  `json:"last"`         // In a paged Collection, indicates the furthest proceeding page of the collection.
}

OrderedCollection is a subtype of Collection in which members of the logical collection are assumed to always be strictly ordered. https://www.w3.org/ns/activitystreams#OrderedCollection

func (*OrderedCollection) UnmarshalJSON

func (c *OrderedCollection) UnmarshalJSON(data []byte) error

func (*OrderedCollection) UnmarshalMap

func (c *OrderedCollection) UnmarshalMap(data mapof.Any) error

type OrderedCollectionPage

type OrderedCollectionPage struct {
	Context      Context `json:"@context"`
	Type         string  `json:"type"`
	Summary      string  `json:"summary"`      // A natural language summarization of the object encoded as HTML. Multiple language tagged summaries may be provided.
	TotalItems   int     `json:"totalItems"`   // A non-negative integer specifying the total number of objects contained by the logical view of the collection. This number might not reflect the actual number of items serialized within the Collection object instance.
	Current      string  `json:"current"`      // In a paged Collection, indicates the page that contains the most recently updated member items.
	First        string  `json:"first"`        // In a paged Collection, indicates the furthest preceeding page of items in the collection.
	Last         string  `json:"last"`         // In a paged Collection, indicates the furthest proceeding page of the collection.
	StartIndex   int     `json:"startIndex"`   // A non-negative integer value identifying the relative position within the logical view of a strictly ordered collection.
	PartOf       string  `json:"partOf"`       // dentifies the Collection to which a CollectionPage objects items belong.
	Prev         string  `json:"prev"`         // In a paged Collection, identifies the previous page of items.
	Next         string  `json:"next"`         // In a paged Collection, indicates the next page of items.
	OrderedItems []any   `json:"orderedItems"` // Identifies the items contained in a collection. The items might be ordered or unordered.
}

OrderedCollectionPage is used to represent ordered subsets of items from an OrderedCollection. Refer to the Activity Streams 2.0 Core for a complete description of the OrderedCollectionPage object. https://www.w3.org/ns/activitystreams#OrderedCollectionPage

func (*OrderedCollectionPage) UnmarshalJSON

func (c *OrderedCollectionPage) UnmarshalJSON(data []byte) error

func (*OrderedCollectionPage) UnmarshalMap

func (c *OrderedCollectionPage) UnmarshalMap(data mapof.Any) error

Jump to

Keyboard shortcuts

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