Skip to main content
This release is a pre-release — the latest non-prerelease version of @fedify/fedify is 1.2.3. Jump to this version

@fedify/fedify@1.3.0-dev.477+5c1eaa6b
Built and signed on GitHub Actions

An ActivityPub/fediverse server framework

This package works with Node.js, Deno, Bun
This package works with Node.js
This package works with Deno
This package works with Bun
JSR Score
100%
Published
a week ago (1.3.0-dev.477+5c1eaa6b)
class Activity
extends Object

An Activity is a subtype of Object that describes some form of action that may happen, is currently happening, or has already happened. The Activity type itself serves as an abstract base type for all types of activities. It is important to note that the Activity type itself does not carry any specific semantics about the kind of action being taken.

Constructors

new
Activity(
values: { id?: URL | null; attachments?: ()[]; attribution?: ; attributions?: ()[]; audience?:
Object
| URL
| null
; audiences?: (Object | URL)[]; content?: ; contents?: ((string | LanguageString))[]; contexts?: ()[]; name?: ; names?: ((string | LanguageString))[]; endTime?: Temporal.Instant | null; generators?: ()[]; icon?:
Image
| URL
| null
; icons?: (Image | URL)[]; image?:
Image
| URL
| null
; images?: (Image | URL)[]; replyTarget?:
Object
| Link
| URL
| null
; replyTargets?: ()[]; location?:
Object
| Link
| URL
| null
; locations?: ()[]; preview?:
Link
| Object
| URL
| null
; previews?: ()[]; published?: Temporal.Instant | null; replies?:
Collection
| URL
| null
; startTime?: Temporal.Instant | null; summary?: ; summaries?: ((string | LanguageString))[]; tags?: ()[]; updated?: Temporal.Instant | null; url?:
URL
| Link
| null
; urls?: ((URL | Link))[]; to?:
Object
| URL
| null
; tos?: (Object | URL)[]; bto?:
Object
| URL
| null
; btos?: (Object | URL)[]; cc?:
Object
| URL
| null
; ccs?: (Object | URL)[]; bcc?:
Object
| URL
| null
; bccs?: (Object | URL)[]; mediaType?: string | null; duration?: Temporal.Duration | null; sensitive?: boolean | null; source?: Source | null; proof?: ; proofs?: (DataIntegrityProof | URL)[]; actor?: ; actors?: ()[]; object?:
Object
| URL
| null
; objects?: (Object | URL)[]; target?:
Object
| URL
| null
; targets?: (Object | URL)[]; result?:
Object
| URL
| null
; results?: (Object | URL)[]; origin?:
Object
| URL
| null
; origins?: (Object | URL)[]; instrument?:
Object
| URL
| null
; instruments?: (Object | URL)[]; }
,
unnamed 1?: { documentLoader?: DocumentLoader; contextLoader?: DocumentLoader; },
)

Constructs a new instance of Activity with the given values.

Properties

readonly
actorId: URL | null

Similar to Activity.getActor, but returns its @id URL instead of the object itself.

readonly
actorIds: URL[]

Similar to Activity.getActors, but returns their @ids instead of the objects themselves.

readonly
instrumentId: URL | null

Similar to Activity.getInstrument, but returns its @id URL instead of the object itself.

readonly
instrumentIds: URL[]

Similar to Activity.getInstruments, but returns their @ids instead of the objects themselves.

readonly
objectId: URL | null

Similar to Activity.getObject, but returns its @id URL instead of the object itself.

readonly
objectIds: URL[]

Similar to Activity.getObjects, but returns their @ids instead of the objects themselves.

readonly
originId: URL | null

Similar to Activity.getOrigin, but returns its @id URL instead of the object itself.

readonly
originIds: URL[]

Similar to Activity.getOrigins, but returns their @ids instead of the objects themselves.

readonly
resultId: URL | null

Similar to Activity.getResult, but returns its @id URL instead of the object itself.

readonly
resultIds: URL[]

Similar to Activity.getResults, but returns their @ids instead of the objects themselves.

readonly
targetId: URL | null

Similar to Activity.getTarget, but returns its @id URL instead of the object itself.

readonly
targetIds: URL[]

Similar to Activity.getTargets, but returns their @ids instead of the objects themselves.

Methods

[Symbol.for("nodejs.util.inspect.custom")](
_depth: number,
options: unknown,
inspect: (
value: unknown,
options: unknown,
) => string
,
): string
protected
_getCustomInspectProxy(): Record<string, unknown>
clone(
values?: { id?: URL | null; attachments?: ()[]; attribution?: ; attributions?: ()[]; audience?:
Object
| URL
| null
; audiences?: (Object | URL)[]; content?: ; contents?: ((string | LanguageString))[]; contexts?: ()[]; name?: ; names?: ((string | LanguageString))[]; endTime?: Temporal.Instant | null; generators?: ()[]; icon?:
Image
| URL
| null
; icons?: (Image | URL)[]; image?:
Image
| URL
| null
; images?: (Image | URL)[]; replyTarget?:
Object
| Link
| URL
| null
; replyTargets?: ()[]; location?:
Object
| Link
| URL
| null
; locations?: ()[]; preview?:
Link
| Object
| URL
| null
; previews?: ()[]; published?: Temporal.Instant | null; replies?:
Collection
| URL
| null
; startTime?: Temporal.Instant | null; summary?: ; summaries?: ((string | LanguageString))[]; tags?: ()[]; updated?: Temporal.Instant | null; url?:
URL
| Link
| null
; urls?: ((URL | Link))[]; to?:
Object
| URL
| null
; tos?: (Object | URL)[]; bto?:
Object
| URL
| null
; btos?: (Object | URL)[]; cc?:
Object
| URL
| null
; ccs?: (Object | URL)[]; bcc?:
Object
| URL
| null
; bccs?: (Object | URL)[]; mediaType?: string | null; duration?: Temporal.Duration | null; sensitive?: boolean | null; source?: Source | null; proof?: ; proofs?: (DataIntegrityProof | URL)[]; actor?: ; actors?: ()[]; object?:
Object
| URL
| null
; objects?: (Object | URL)[]; target?:
Object
| URL
| null
; targets?: (Object | URL)[]; result?:
Object
| URL
| null
; results?: (Object | URL)[]; origin?:
Object
| URL
| null
; origins?: (Object | URL)[]; instrument?:
Object
| URL
| null
; instruments?: (Object | URL)[]; }
,
options?: { documentLoader?: DocumentLoader; contextLoader?: DocumentLoader; },
): Activity

Clones this instance, optionally updating it with the given values.

getActor(options?: { documentLoader?: DocumentLoader; contextLoader?: DocumentLoader; suppressError?: boolean; }): Promise<>

Describes one or more entities that either performed or are expected to perform the activity. Any single activity can have multiple actors. The actor MAY be specified using an indirect Link.

getActors(options?: { documentLoader?: DocumentLoader; contextLoader?: DocumentLoader; suppressError?: boolean; }): AsyncIterable<>

Describes one or more entities that either performed or are expected to perform the activity. Any single activity can have multiple actors. The actor MAY be specified using an indirect Link.

getInstrument(options?: { documentLoader?: DocumentLoader; contextLoader?: DocumentLoader; suppressError?: boolean; }): Promise<Object | null>

Identifies one or more objects used (or to be used) in the completion of an Activity.

getInstruments(options?: { documentLoader?: DocumentLoader; contextLoader?: DocumentLoader; suppressError?: boolean; }): AsyncIterable<Object>

Identifies one or more objects used (or to be used) in the completion of an Activity.

getObject(options?: { documentLoader?: DocumentLoader; contextLoader?: DocumentLoader; suppressError?: boolean; }): Promise<Object | null>

When used within an Activity, describes the direct object of the activity. For instance, in the activity "John added a movie to his wishlist", the object of the activity is the movie added.

getObjects(options?: { documentLoader?: DocumentLoader; contextLoader?: DocumentLoader; suppressError?: boolean; }): AsyncIterable<Object>

When used within an Activity, describes the direct object of the activity. For instance, in the activity "John added a movie to his wishlist", the object of the activity is the movie added.

getOrigin(options?: { documentLoader?: DocumentLoader; contextLoader?: DocumentLoader; suppressError?: boolean; }): Promise<Object | null>

Describes an indirect object of the activity from which the activity is directed. The precise meaning of the origin is the object of the English preposition "from". For instance, in the activity "John moved an item to List B from List A", the origin of the activity is "List A".

getOrigins(options?: { documentLoader?: DocumentLoader; contextLoader?: DocumentLoader; suppressError?: boolean; }): AsyncIterable<Object>

Describes an indirect object of the activity from which the activity is directed. The precise meaning of the origin is the object of the English preposition "from". For instance, in the activity "John moved an item to List B from List A", the origin of the activity is "List A".

getResult(options?: { documentLoader?: DocumentLoader; contextLoader?: DocumentLoader; suppressError?: boolean; }): Promise<Object | null>

Describes the result of the activity. For instance, if a particular action results in the creation of a new resource, the result property can be used to describe that new resource.

getResults(options?: { documentLoader?: DocumentLoader; contextLoader?: DocumentLoader; suppressError?: boolean; }): AsyncIterable<Object>

Describes the result of the activity. For instance, if a particular action results in the creation of a new resource, the result property can be used to describe that new resource.

getTarget(options?: { documentLoader?: DocumentLoader; contextLoader?: DocumentLoader; suppressError?: boolean; }): Promise<Object | null>

Describes the indirect object, or target, of the activity. The precise meaning of the target is largely dependent on the type of action being described but will often be the object of the English preposition "to". For instance, in the activity "John added a movie to his wishlist", the target of the activity is John's wishlist. An activity can have more than one target.

getTargets(options?: { documentLoader?: DocumentLoader; contextLoader?: DocumentLoader; suppressError?: boolean; }): AsyncIterable<Object>

Describes the indirect object, or target, of the activity. The precise meaning of the target is largely dependent on the type of action being described but will often be the object of the English preposition "to". For instance, in the activity "John added a movie to his wishlist", the target of the activity is John's wishlist. An activity can have more than one target.

toJsonLd(options?: { format?: "compact" | "expand"; contextLoader?: DocumentLoader; context?:
string
| Record<string, string>
| (string | Record<string, string>)[]
; }
): Promise<unknown>

Converts this object to a JSON-LD structure.

Static Properties

readonly
typeId: URL

The type URI of Activity: https://www.w3.org/ns/activitystreams#Activity.

Static Methods

fromJsonLd(
json: unknown,
options?: { documentLoader?: DocumentLoader; contextLoader?: DocumentLoader; },
): Promise<Activity>

Converts a JSON-LD structure to an object of this type.

Add Package

deno add jsr:@fedify/fedify

Import symbol

import { Activity } from "@fedify/fedify";

---- OR ----

Import directly with a jsr specifier

import { Activity } from "jsr:@fedify/fedify";

Add Package

npx jsr add @fedify/fedify

Import symbol

import { Activity } from "@fedify/fedify";

Add Package

yarn dlx jsr add @fedify/fedify

Import symbol

import { Activity } from "@fedify/fedify";

Add Package

pnpm dlx jsr add @fedify/fedify

Import symbol

import { Activity } from "@fedify/fedify";

Add Package

bunx jsr add @fedify/fedify

Import symbol

import { Activity } from "@fedify/fedify";