As required by the Apache license: Please note that all files dated 01/01/2021 & newer have been modified from the original...
Based on:
Includes experimental support for:
npm install activitystrea.ms
const as = require('activitystrea.ms');
// Create a simple object
const doc = await as.object().
name('baz').
content(
as.langmap()
.set('en', 'bar')
.set('fr', 'foo')).
publishedNow().
prettyWrite();
Which produces the output:
{
"@context": "https://www.w3.org/ns/activitystreams",
"@type": "Object",
"contentMap": {
"en": "bar",
"fr": "foo"
},
"name": "baz",
"published": "2015-07-17T00:50:09.889Z"
}
// Create a simple activity
const doc = await as.create().
actor('acct:[email protected]').
object('http://www.example.org/post').
prettyWrite();
Which produces the output:
{
"@context": "https://www.w3.org/ns/activitystreams",
"@type": "Create",
"actor": "acct:[email protected]",
"object": "http://www.example.org/post"
}
You can also use the Node.js stream model for parsing:
const fs = require('fs');
const AS2Stream = as.Stream;
const path = require('path');
const through = require('through2');
fs.createReadStream(path.resolve(__dirname,'test.json'))
.pipe(new AS2Stream())
.pipe(through.obj((obj,encoding,callback) => {
console.log(obj.type);
console.log(obj.name);
}));
And writing:
const as = require('activitystrea.ms');
const through = require('through2');
as.object()
.name('test')
.get()
.pipe(process.stdout);
The API uses a fluent factory pattern for creating AS objects. There are
factory methods for each of the main types of objects defined by the Activity
Streams 2.0 vocabulary. Each takes an optional array of types that will be set
on the object. If the [types]
is unspecified, a default will be assigned
depending on the object being created. Each of the factory methods returns a
builder specific to the kind of object being generated. Once the object has
been built, call the get
method to return the generated object.
as.object([types])
as.activity([types])
as.collection([types])
as.orderedCollection([types])
as.collectionPage([types])
as.orderedCollectionPage([types])
as.link([types])
as.accept([types])
as.tentativeAccept([types])
as.add([types])
as.arrive([types])
as.create([types])
as.delete([types])
as.favorite([types])
as.follow([types])
as.ignore([types])
as.join([types])
as.leave([types])
as.like([types])
as.offer([types])
as.invite([types])
as.reject([types])
as.tentativeReject([types])
as.remove([types])
as.undo([types])
as.update([types])
as.view([types])
as.listen([types])
as.read([types])
as.move([types])
as.travel([types])
as.announce([types])
as.block([types])
as.flag([types])
as.dislike([types])
as.application([types])
as.content([types])
as.group([types])
as.person([types])
as.service([types])
as.article([types])
as.document([types])
as.profile([types])
as.audio([types])
as.image([types])
as.video([types])
as.note([types])
as.page([types])
as.question([types])
as.event([types])
as.place([types])
as.connection([types])
as.mention([types])
as.tombstone([types])
as.interval([types])
as.interval.open([types])
as.interval.closed([types])
as.interval.openClosed([types])
as.interval.closedOpen([types])
as.interval.rightOpen([types])
as.interval.leftClosed([types])
as.interval.rightClosed([types])
as.social.population([types])
as.social.everyone([types])
as.social.public([types])
as.social.private([types])
as.social.direct([types])
as.social.common([types])
as.social.interested([types])
as.social.self([types])
as.social.all([types])
as.social.any([types])
as.social.none([types])
The object returned by get()
is a read-only view of the Activity Stream
object. It will have property methods that are specific to the object's type.
You can export the built object as an ordinary Javascript object using the
export
method. This will generate a JSON-LD compliant Javascript object.
const as = require('activitystrea.ms');
const note = as.note().
name('foo').
content('this is a simple note').
get();
console.log(note.name.valueOf());
console.log(note.content.valueOf());
console.log(note.type);
const as = require('activitystrea.ms');
as.note().
name('foo').
content('this is a simple note').
get().
export((err, obj) => {
if (err) throw err;
// obj is an ordinary javascript object
console.log(obj['@type']);
console.log(obj['name']);
console.log(obj['content']);
});
To serialize the Activity Streams object out as JSON, use the write
,
prettyWrite
, or pipe
methods
const as = require('activitystrea.ms');
const doc = await as.note().
name('foo').
content('this is a simple note').
write();
const as = require('activitystrea.ms');
const doc = await as.note().
name('foo').
content('this is a simple note').
prettyWrite();
const as = require('activitystrea.ms');
const through = require('through2');
as.object()
.name('test')
.get()
.pipe(process.stdout);
Note that The export
, write
, and prettyWrite
methods are all async and return promises.
This is largely because of the JSON-LD processing that's happening under the covers.
The base module.
Returns a new as.models.Object.Builder
instance.
Returns a new as.models.Activity.Builder
instance.
Returns a new as.models.Collection.Builder
instance.
Returns a new as.models.OrderedCollection.Builder
instance.
Returns a new as.models.CollectionPage.Builder
instance.
Returns a new as.models.OrderedCollectionPage.Builder
instance.
Returns a new as.models.Link.Builder
instance.
Returns a new as.models.Activity.Builder
instance generating an http://www.w3.org/ns/activity#Accept
activity.
Returns a new as.models.Activity.Builder
instance generating an http://www.w3.org/ns/activity#TentativeAccept
activity.
Returns a new as.models.Activity.Builder
instance generating an http://www.w3.org/ns/activity#Add
activity.
Returns a new as.models.Activity.Builder
instance generating an http://www.w3.org/ns/activity#Arrive
activity.
Returns a new as.models.Activity.Builder
instance generating an http://www.w3.org/ns/activity#Create
activity.
Returns a new as.models.Activity.Builder
instance generating an http://www.w3.org/ns/activity#Delete
activity.
Returns a new as.models.Activity.Builder
instance generating an http://www.w3.org/ns/activity#Follow
activity.
Returns a new as.models.Activity.Builder
instance generating an http://www.w3.org/ns/activity#Ignore
activity.
Returns a new as.models.Activity.Builder
instance generating an http://www.w3.org/ns/activity#Join
activity.
Returns a new as.models.Activity.Builder
instance generating an http://www.w3.org/ns/activity#Leave
activity.
Returns a new as.models.Activity.Builder
instance generating an http://www.w3.org/ns/activity#Like
activity.
Returns a new as.models.Activity.Builder
instance generating an http://www.w3.org/ns/activity#Offer
activity.
Returns a new as.models.Activity.Builder
instance generating an http://www.w3.org/ns/activity#Invite
activity.
Returns a new as.models.Activity.Builder
instance generating an http://www.w3.org/ns/activity#Reject
activity.
Returns a new as.models.Activity.Builder
instance generating an http://www.w3.org/ns/activity#TentativeReject
activity.
Returns a new as.models.Activity.Builder
instance generating an http://www.w3.org/ns/activity#Remove
activity.
Returns a new as.models.Activity.Builder
instance generating an http://www.w3.org/ns/activity#Undo
activity.
Returns a new as.models.Activity.Builder
instance generating an http://www.w3.org/ns/activity#Update
activity.
Returns a new as.models.Activity.Builder
instance generating an http://www.w3.org/ns/activity#View
activity.
Returns a new as.models.Activity.Builder
instance generating an http://www.w3.org/ns/activity#Listen
activity.
Returns a new as.models.Activity.Builder
instance generating an http://www.w3.org/ns/activity#Read
activity.
Returns a new as.models.Activity.Builder
instance generating an http://www.w3.org/ns/activity#Move
activity.
Returns a new as.models.Activity.Builder
instance generating an http://www.w3.org/ns/activity#Travel
activity.
Returns a new as.models.Activity.Builder
instance generating an http://www.w3.org/ns/activity#Announce
activity.
Returns a new as.models.Activity.Builder
instance generating an http://www.w3.org/ns/activity#Block
activity.
Returns a new as.models.Activity.Builder
instance generating an http://www.w3.org/ns/activity#Flag
activity.
Returns a new as.models.Activity.Builder
instance generating an http://www.w3.org/ns/activity#Dislike
activity.
Returns a new as.models.Object.Builder
instance generating an http://www.w3.org/ns/activity#Application
object.
Returns a new as.models.Object.Builder
instance generating an http://www.w3.org/ns/activity#Group
object.
Returns a new as.models.Object.Builder
instance generating an http://www.w3.org/ns/activity#Person
object.
Returns a new as.models.Object.Builder
instance generating an http://www.w3.org/ns/activity#Service
object.
Returns a new as.models.Object.Builder
instance generating an http://www.w3.org/ns/activity#Organization
object.
Returns a new as.models.Object.Builder
instance generating an http://www.w3.org/ns/activity#Article
object.
Returns a new as.models.Object.Builder
instance generating an http://www.w3.org/ns/activity#Document
object.
Returns a new as.models.Object.Builder
instance generating an http://www.w3.org/ns/activity#Audio
object.
Returns a new as.models.Object.Builder
instance generating an http://www.w3.org/ns/activity#Image
object.
Returns a new as.models.Object.Builder
instance generating an http://www.w3.org/ns/activity#Video
object.
Returns a new as.models.Object.Builder
instance generating an http://www.w3.org/ns/activity#Note
object.
Returns a new as.models.Object.Builder
instance generating an http://www.w3.org/ns/activity#Page
object.
Returns a new as.models.Question.Builder
instance generating an http://www.w3.org/ns/activity#Question
object.
Returns a new as.models.Object.Builder
instance generating an http://www.w3.org/ns/activity#Event
object.
Returns a new as.models.Relationship.Builder
instance generating an http://www.w3.org/ns/activity#Relationship
object.
Returns a new as.models.Profile.Builder
instance generating an http://www.w3.org/ns/activity#Profile
object.
Returns a new as.models.Place.Builder
instance generating an http://www.w3.org/ns/activity#Place
object.
Returns a new as.models.Link.Builder
instance generating an http://www.w3.org/ns/activity#Mention
link.
Returns a new as.models.Tombstone.Builder
instance generating an
http://www.w3.org/ns/activity#Tombstone
object.
Imports the specified JavaScript object obj
, performing JSON-LD expansion as necessary. When the import is complete, the callback
function will be invoked with the imported as.model.Object
as the second argument. If an error occurs, the error will be passed as the first argument to the callback
.
var obj = {
'@context': 'https://www.w3.org/ns/activitystreams',
'@type': 'Person',
name: 'Joe'
};
as.import(obj, (err, imp) => {
if (err) throw err;
console.log(imp.type);
});
Returns a new Node.js Transform Stream that parses JSON input into an appropriate as.models.Object
instance.
const through = require('through2');
const fs = require('fs');
const fsstr = fs.createReadStream('data.json');
fsstr.pipe(new as.Stream())
.pipe(through.obj((chunk,encoding,callback) => {
console.log(chunk.name);
callback();
}));
Express/Connect middleware that parses the request payload as AS2
const app = require('express')();
app.post('/', as.Middleware, (req,res) => {
res.status(200);
res.set({'Content-Type': as.mediaType});
req.body.pipe(res);
});
Set to a constant value of application/activity+json
as.models.Base
is the base class for all objects. It is not intended to be used directly by developers.
expanded
- The underlying JSON-LD expanded JavaScript objectbuilder
- Aas.model.Base.Builder
subclass
Returns the value of the JSON-LD @id
property or underfined
.
Returns the value of the JSON-LD @type
property. If @type
has only a single value, then a single JavaScript string will be returned. If the @type
has multiple values, a JavaScript Array will be returned. If the @type
is not specified, undefined
will be returned.
Returns true if the object has a value for the specified key
Returns the value for the specified key
. The return value will vary based on the property being requested. The return value can be a JavaScript primitive, a as.models.Base
instance, or an Iterable of JavaScript primitives or as.models.Base
instances. Will returned undefined
if the no value is specified for the given key
Exports the object by performing a JSON-LD compaction. If export fails, the promise will reject with the error. If the export succeeds, the promise will resolve with the exported JavaScript object.
const obj = as.object().name('Joe').get();
obj.export((err,exp) => {
if (err) throw err;
console.log(exp.name);
console.log(exp['@type']);
});
Write the object out to a JSON-LD string. If writing fails, the promise will reject with the error. If the write succeeds, the promise will resolve with the JSON-LD string.
const obj = as.object().name('Joe').get();
obj.write((err,string) => {
if (err) throw err;
console.log(string);
});
Write the object out to a JSON-LD string. If writing fails, the promise will reject with the error. If the write succeeds, the promise will resolve with the JSON-LD string.
const obj = as.object().name('Joe').get();
obj.prettyWrite((err,string) => {
if (err) throw err;
console.log(string);
});
Returns a new as.models.Base.Builder
instance that can be used to modify
this object.
Returns a Readable Stream instance that can be used to read this object as a stream of JSON-LD data.
Pipes this objects JSON-LD to the specified writable
const obj = as.person().name('Sally').get();
obj.pipe(process.stdout);
Returns a funtion that can be used to create new as.models.Base.Builder
instances using this object as a template. The new Builder will be pre-filled with the properties already specified on this object.
const templ = as.like().actor('http://example.org/sally').get().template();
templ().object('http://example.org/1').pipe(process.stdout);
templ().object('http://example.org/2').pipe(process.stdout);
The base Builder interface. This is not intended to be used directly by developers. Most of the methods on the Builder instances return a reference back to the Builder itself allowing methods to be chained.
Set the value of the @id
property. Calling this repeatedly will overwrite the previous value.
Set a value for the specified key.
const object = as.object();
object.set('foo', 'bar');
Returns the constructed as.models.Base
instance.
The base class for all Activity Streams 2.0 Object instances. Inherits from as.models.Base
Returns the value of the https://www.w3.org/ns/activitystreams#attachment
property. Will be either undefined
or an Iterable of as.model.Base
instances.
Returns the value of the https://www.w3.org/ns/activitystreams#attributedTo
property. Will be either undefined
or an Iterable of as.model.Base
instances.
Returns the value of the https://www.w3.org/ns/activitystreams#content
property. Will be either undefined
or a as.models.LanguageValue
.
Returns the value of the https://www.w3.org/ns/activitystreams#context
property. Will be either undefined
or an Iterable of as.model.Base
instances.
Returns the value of the https://www.w3.org/ns/activitystreams#name
property. Will be either undefined
or a as.models.LanguageValue
.
Returns the value of the https://www.w3.org/ns/activitystreams#summary
property. Will be either undefined
or a as.models.LanguageValue
.
Returns the value of the https://www.w3.org/ns/activitystreams#endTime
property. Will be either undefined
or a JavaScript Date object.
Returns the value of the https://www.w3.org/ns/activitystreams#published
property. Will be either undefined
or a JavaScript Date object.
Returns the value of the https://www.w3.org/ns/activitystreams#startTime
property. Will be either undefined
or a JavaScript Date object.
Returns the value of the https://www.w3.org/ns/activitystreams#updated
property. Will be either undefined
or a JavaScript Date object.
Returns the value of the https://www.w3.org/ns/activitystreams#generator
property. Will be either undefined
or an Iterable of as.model.Base
instances.
Returns the value of the https://www.w3.org/ns/activitystreams#icon
property. Will be either undefined
or an Iterable of as.model.Base
instances.
Returns the value of the https://www.w3.org/ns/activitystreams#image
property. Will be either undefined
or an Iterable of as.model.Base
instances.
Returns the value of the https://www.w3.org/ns/activitystreams#inReplyTo
property. Will be either undefined
or an Iterable of as.model.Base
instances.
Returns the value of the https://www.w3.org/ns/activitystreams#location
property. Will be either undefined
or an Iterable of as.model.Base
instances.
Returns the value of the https://www.w3.org/ns/activitystreams#preview
property. Will be either undefined
or an Iterable of as.model.Base
instances.
Returns the value of the https://www.w3.org/ns/activitystreams#replies
property. Will be either undefined
or an Iterable of as.model.Base
instances.
Returns the value of the https://www.w3.org/ns/activitystreams#audience
property. Will be either undefined
or an Iterable of as.model.Base
instances.
Returns the value of the https://www.w3.org/ns/activitystreams#tag
property. Will be either undefined
or an Iterable of as.model.Base
instances.
Returns the value of the https://www.w3.org/ns/activitystreams#url
property. Will be either undefined
or an Iterable of as.model.Link
instances.
Returns the value of the https://www.w3.org/ns/activitystreams#to
property. Will be either undefined
or an Iterable of as.model.Base
instances.
Returns the value of the https://www.w3.org/ns/activitystreams#bto
property. Will be either undefined
or an Iterable of as.model.Base
instances.
Returns the value of the https://www.w3.org/ns/activitystreams#cc
property. Will be either undefined
or an Iterable of as.model.Base
instances.
Returns the value of the https://www.w3.org/ns/activitystreams#bcc
property. Will be either undefined
or an Iterable of as.model.Base
instances.
Builder for as.models.Object
instances.
Adds a value to the https://www.w3.org/ns/activitystreams#attachment
property.
Adds a value to the https://www.w3.org/ns/activitystreams#attributedTo
property.
Sets an optional language-tagged value for the https://www.w3.org/ns/activitystreams#content
property. To set
language-tagged values, use the as.langmap
method to create a
LanguageValue.Builder.
as.object()
.content('simple content')
.get();
as.object()
.content(
as.langmap()
.set('default content')
.set('es', 'other content')
)
.get();
Adds a value to the https://www.w3.org/ns/activitystreams#context
property.
Sets an optional language-tagged value for the https://www.w3.org/ns/activitystreams#name
property.
as.object()
.name('simple display name')
.get();
as.object()
.name(
as.langmap()
.set('default display name')
.set('es', 'other display name')
)
.get();
Sets an optional language-tagged value for the https://www.w3.org/ns/activitystreams#summary
property.
as.object()
.summary('simple summary')
.get();
as.object()
.summary(
as.langmap()
.set('default summary')
.set('es', 'other summary')
)
.get();
Sets the value of the https://www.w3.org/ns/activitystreams#endTime
property.
The value must be a JavaScript Date object.
Sets the value of the https://www.w3.org/ns/activitystreams#endTime
property to the current date and time.
Sets the value of the https://www.w3.org/ns/activitystreams#published
property.
The value must be a JavaScript Date object.
Sets the value of the https://www.w3.org/ns/activitystreams#published
property to the current date and time.
Sets the value of the https://www.w3.org/ns/activitystreams#startTime
property.
The value must be a JavaScript Date object.
Sets the value of the https://www.w3.org/ns/activitystreams#startTime
property to the current date and time.
Sets the value of the https://www.w3.org/ns/activitystreams#updated
property.
The value must be a JavaScript Date object.
Sets the value of the https://www.w3.org/ns/activitystreams#updated
property to the current date and time.
Adds a value to the https://www.w3.org/ns/activitystreams#generator
property.
Adds a value to the https://www.w3.org/ns/activitystreams#icon
property.
Adds a value to the https://www.w3.org/ns/activitystreams#image
property.
Adds a value to the https://www.w3.org/ns/activitystreams#inReplyTo
property.
Adds a value to the https://www.w3.org/ns/activitystreams#location
property.
Adds a value to the https://www.w3.org/ns/activitystreams#preview
property.
Adds a value to the https://www.w3.org/ns/activitystreams#replies
property.
Adds a value to the https://www.w3.org/ns/activitystreams#audience
property.
Adds a value to the https://www.w3.org/ns/activitystreams#tag
property.
Adds a value to the https://www.w3.org/ns/activitystreams#url
property.
Adds a value to the https://www.w3.org/ns/activitystreams#to
property.
Adds a value to the https://www.w3.org/ns/activitystreams#bto
property.
Adds a value to the https://www.w3.org/ns/activitystreams#cc
property.
Adds a value to the https://www.w3.org/ns/activitystreams#bcc
property.
Base class for all Activity Streams 2.0 Activity instances. Inherits from as.models.Object
Returns the value of the https://www.w3.org/ns/activitystreams#actor
property. Will be either undefined
or an Iterable of as.model.Base
instances.
Returns the value of the https://www.w3.org/ns/activitystreams#object
property. Will be either undefined
or an Iterable of as.model.Base
instances.
Returns the value of the https://www.w3.org/ns/activitystreams#target
property. Will be either undefined
or an Iterable of as.model.Base
instances.
Returns the value of the https://www.w3.org/ns/activitystreams#result
property. Will be either undefined
or an Iterable of as.model.Base
instances.
Returns the value of the https://www.w3.org/ns/activitystreams#origin
property. Will be either undefined
or an Iterable of as.model.Base
instances.
Returns the value of the https://www.w3.org/ns/activitystreams#instrument
property. Will be either undefined
or an Iterable of as.model.Base
instances.
The base class for all as.models.Activity
builder instances. Inherits from as.models.Object.Builder
Adds a value to the https://www.w3.org/ns/activitystreams#actor
property.
Adds a value to the https://www.w3.org/ns/activitystreams#object
property.
Adds a value to the https://www.w3.org/ns/activitystreams#target
property.
Adds a value to the https://www.w3.org/ns/activitystreams#result
property.
Adds a value to the https://www.w3.org/ns/activitystreams#origin
property.
Adds a value to the https://www.w3.org/ns/activitystreams#instrument
property.
The base class for all Activity Streams 2.0 Collection objects. Inherits from as.models.Object
Returns the value of the https://www.w3.org/ns/activitystreams#totalItems
property. The value will either be undefined
or a numeric integer greater than or equal to zero.
Returns the value of the https://www.w3.org/ns/activitystreams#current
property. The value will either be undefined
or a as.models.Base
instance.
Returns the value of the https://www.w3.org/ns/activitystreams#last
property. The value will either be undefined
or a as.models.Base
instance.
Returns the value of the https://www.w3.org/ns/activitystreams#first
property. The value will either be undefined
or a as.models.Base
instance.
Returns the value of the https://www.w3.org/ns/activitystreams#items
property as an Iterable of as.models.Base
instances.
The base class for all as.models.Collection
builders. Inherits from as.models.Object.Builder
Sets the value of the https://www.w3.org/ns/activitystreams#totalItems
property. The value must be a numeric integer greater than or equal to 0.
Sets the value of the https://www.w3.org/ns/activitystreams#current
property. The value must either be a URL string or a as.models.Link
instance.
Sets the value of the https://www.w3.org/ns/activitystreams#last
property. The value must either be a URL string or a as.models.Link
instance.
Sets the value of the https://www.w3.org/ns/activitystreams#first
property. The value must either be a URL string or a as.models.Link
instance.
Adds a value to the https://www.w3.org/ns/activitystreams#items
property.
The base class for all Activity Streams 2.0 OrderedCollection objects. Inherits from as.models.Collection
The base class for all as.models.OrderedCollection
builders. Inherits from as.models.Collection.Builder
The base class for all as.models.CollectionPage
instances. Inherits from as.models.Collection
Returns the value of the https://www.w3.org/ns/activitystreams#next
property. The value will either be undefined
or a as.models.Base
instance.
Returns the value of the https://www.w3.org/ns/activitystreams#prev
property. The value will either be undefined
or a as.models.Base
instance.
The base class for all as.models.CollectionPage
builders. Inherits from as.models.Collection.Builder
Sets the value of the https://www.w3.org/ns/activitystreams#next
property. The value must either be a URL string or a as.models.Link
instance.
Sets the value of the https://www.w3.org/ns/activitystreams#prev
property. The value must either be a URL string or a as.models.Link
instance.
The base class for all as.models.OrderedCollectionPage
instances. Inherits from both as.models.CollectionPage
and as.models.OrderedCollection
Returns the value of the https://www.w3.org/ns/activitystreams#startIndex
property. The value will either be undefined
or a numeric integer greater than or equal to zero.
Class: as.models.OrderedCollectionPage.Builder > as.models.CollectionPage.Builder, as.models.OrderedCollection.Builder
The base class for all as.models.OrderedCollectionPage
builders. Inherits from both as.models.CollectionPage.Builder
and as.models.OrderedCollection.Builder
.
Sets the value of the https://www.w3.org/ns/activitystreams#startIndex
property. The value must be a numeric integer greater than or equal to zero.
The base class for all Activity Streams 2.0 Links. Inherits from as.models.Base
Returns the value of the https://www.w3.org/ns/activitystreams#href
property. The value will either be undefined
or a URL string.
Returns the value of the https://www.w3.org/ns/activitystreams#rel
property. The value will either be undefined
or an Iterable of strings.
Returns the value of the https://www.w3.org/ns/activitystreams#mediaType
property. The value will either be undefined
or a MIME Media Type.
Returns the value of the https://www.w3.org/ns/activitystreams#name
property as a LanguageValue
.
Returns the value of the https://www.w3.org/ns/activitystreams#hreflang
property. The value will either be undefined
or an RFC 5646 Language Tag.
Returns the value of the https://www.w3.org/ns/activitystreams#height
property.The value will either be undefined
or a numeric integer greater than or equal to zero.
Returns the value of the https://www.w3.org/ns/activitystreams#width
property.The value will either be undefined
or a numeric integer greater than or equal to zero.
Returns the value of the https://www.w3.org/ns/activitystreams#duration
property. The value will either be `undefined, a numeric integer, or an ISO 8601 duration string.
The base class for all as.models.Link
builders. Inherits from as.models.Base.Builder
Specifies the value of the https://www.w3.org/ns/activitystreams#href
property. The value must be a URL string.
Adds a value to the https://www.w3.org/ns/activitystreams#rel
property;
Sets the value of the https://www.w3.org/ns/activitystreams#mediaType
property. The value must be a valid MIME type.
Specifies an optionally language-tagged name.
as.link()
.name('simple display name')
.get();
as.link()
.name(
as.langmap()
.set('default display name')
.set('es', 'other display name')
)
.get();
Sets the value of the https://www.w3.org/ns/activitystreams#hreflang
property.
The value must be an RFC 5646 Language Tag.
Sets the value of the https://www.w3.org/ns/activitystreams#height
property.
The value is a numeric integer greater than or equal to zero.
Sets the value of the https://www.w3.org/ns/activitystreams#width
property.
The value is a numeric integer greater than or equal to zero.
Sets the value of the https://www.w3.org/ns/activitystreams#duration
property.
The value is either a numeric integer indicate a number of seconds, or an
ISO 8601 Duration.
The base class for all Activity Streams 2.0 Place objects. Inherits from as.models.Object
Returns the value of the https://www.w3.org/ns/activitystreams#accuracy
property. The value will either be undefined
or a numeric integer in the range 0 <= n <= 100.
Returns the value of the https://www.w3.org/ns/activitystreams#altitude
property. The value will be either undefined
or a numeric float.
Returns the value of the https://www.w3.org/ns/activitystreams#latitude
property. The value will be either undefined
or a numeric float in the range -90.0 <= n <= 90.0.
Returns the value of the https://www.w3.org/ns/activitystreams#longitude
property. The value will be either undefined
or a numeric float in the range -180.0 <= n <= 180.0.
Returns the value of the https://www.w3.org/ns/activitystreams#radius
property.
The value will be either undefined
or a numeric float greater than or equal to zero.
Returns the value of the https://www.w3.org/ns/activitystreams#units
property. The value will be one of: cm
, feet
, inches
, km
, m
, miles
, or any absolute URI.
The base class for all as.models.Place
builders. Inherits from as.models.Object.Builder
Sets the value of the https://www.w3.org/ns/activitystreams#accuracy
property.
The value is a numeric integer in the range 0 <= n <= 100
Sets the value of the https://www.w3.org/ns/activitystreams#altitude
property. The value is a numeric float.
Sets the value of the https://www.w3.org/ns/activitystreams#latitude
property. The value is a numeric float in the range -90.0 <= n <= 90.0.
Sets the value of the https://www.w3.org/ns/activitystreams#longitude
property. The value is a numeric float in the range -180.0 <= n <= 180.0.
Sets the value of the https://www.w3.org/ns/activitystreams#radius
property. The value is a numeric float greater or equal to 0.0
.
Sets the value of the https://www.w3.org/ns/activitystreams#units
property.
The value must be one of: cm
, feet
, inches
, km
, m
, miles
, or any absolute URI.
The base class for all Activity Streams 2.0 Profile objects. Inherits from as.models.Object
The base class for all as.models.Profile
builders. Inherits from
as.models.Object.Builder
Sets the value of the https://www.w3.org/ns/activitystreams#describes
property.
The base class for all Activity Streams 2.0 Question objects. Inherits from
as.models.Activity
;
Returns the value of the https://www.w3.org/ns/activitystreams#anyOf
property.
The value will either be undefined
or an Iterable of as.models.Base
objects.
Returns the value of the https://www.w3.org/ns/activitystreams#oneOf
property.
The value will either be undefined
or an Iterable of as.models.Base
objects.
The base class for all as.models.Question
builders. Inherits from
as.models.Activity.Builder
;
Adds a value to the https://www.w3.org/ns/activitystreams#anyOf
property.
Adds a value to the https://www.w3.org/ns/activitystreams#oneOf
property.
The base class for all Activity Streams 2.0 Relationship objects. Inherits
from as.models.Object
.
Returns the value of the https://www.w3.org/ns/activitystreams#subject
property. The value will either be undefined
or an as.models.Base
object.
Returns the value of the https://www.w3.org/ns/activitystreams#relationship
property. The value will either be undefined
or an Iterable of as.models.Base
objects.
Returns the value of the https://www.w3.org/ns/activitystreams#object
property. The value will either be undefined
or an Iterable of as.models.Base
objects.
The base class for all as.models.Relationship
builders. Inherits from as.models.Object.Builder
.
Sets the value of the http://ww.w3.org/ns/activitystreams#subject
property.
Adds a value to the https://www.w3.org/ns/activitystreams#relationship
property.
Adds a value to the https://www.w3.org/ns/activitystreams#object
property.
Returns the date and time the object was deleted.
Returns the former type of the object that was deleted.
Sets the date and time the represented object was deleted.
Specifies the former type of the object that was deleted.
Used to encapsulate language tagged properties within an Activity Streams document.
// assuming the default system locale is `en-US`:
const obj = as.object()
.name(
as.langmap()
.set('default display name')
.set('es', 'other display name')
)
.get();
const languagevalue = obj.name;
console.log(languagevalue.get()); // 'default display name'
console.log(languagevalue.get('es')); // 'other display name'
// assuming the default system locale is `sp`:
const obj = as.object()
.name(
as.langmap()
.set('default display name')
.set('es', 'other display name')
)
.get();
const languagevalue = obj.name;
console.log(languagevalue.get()); // 'other display name'
console.log(languagevalue.get('en-US')); // 'default display name'