diff --git a/src/common/common.constants.ts b/src/common/common.constants.ts new file mode 100644 index 0000000..b1d6b3c --- /dev/null +++ b/src/common/common.constants.ts @@ -0,0 +1,3 @@ +export const contexts = { + activityStreamsV2: 'https://www.w3.org/ns/activitystreams' +} \ No newline at end of file diff --git a/src/common/common.types.ts b/src/common/common.types.ts new file mode 100644 index 0000000..961201b --- /dev/null +++ b/src/common/common.types.ts @@ -0,0 +1,128 @@ +import {ASObject} from "../models/asObject/ASObject.model"; +import {Collection} from "../models/collection/Collection.model"; +import {OrderedCollection} from "../models/orderedCollection/OrderedCollection.model"; +import {Article} from "../models/article/Article.model"; +import {Audio} from "../models/audio/Audio.model"; +import {Document} from "../models/document/Document.model"; +import {ASEvent} from "../models/asEvent/ASEvent.model"; +import {Image} from "../models/image/Image.model"; +import {Note} from "../models/note/Note.model"; +import {Page} from "../models/page/Page.model"; +import {Place} from "../models/place/Place.model"; +import {Profile} from "../models/profile/Profile.model"; +import {Relationship} from "../models/relationship/Relationship.model"; +import {Tombstone} from "../models/tombstone/Tombstone.model"; +import {Video} from "../models/video/Video.model"; +import {Link} from "../models/link/Link.model"; +import {Mention} from "../models/mention/Mention.model"; +import {CollectionPage} from "../models/collectionPage/CollectionPage.model"; +import {OrderedCollectionPage} from "../models/orderedCollectionPage/OrderedCollectionPage.model"; + +export enum ASModelType { + Object = 'Object', + Activity = 'Activity', + Application = 'Application', + Article = 'Article', + Document = 'Document', + Event = 'Event', + Group = 'Group', + Note = 'Note', + Organization = 'Organization', + Person = 'Person', + Service = 'Service', + Audio = 'Audio', + Image = 'Image', + Page = 'Page', + Video = 'Video', + Place = 'Place', + Relationship = 'Relationship', + Question = 'Question', + Tombstone = 'Tombstone', + Profile = 'Profile', + Link = 'Link', + Mention = 'Mention', + Collection = 'Collection', + CollectionPage = 'CollectionPage', + OrderedCollection = 'OrderedCollection', + OrderedCollectionPage = 'OrderedCollectionPage', +} + +export type AnyCollection = Collection | OrderedCollection; +export type AnyASObject = ASObject | Article | Audio | Document | ASEvent | Image | Note | Page | Place | Profile | Relationship | Tombstone | Video | AnyCollection; + +export type DateTime = string; +export type LanguageTag = string; +export type MediaType = string; +export type Duration = string; + +export type UrlValue = string | Link; +export type IdValue = string; +export type TypeValue = string; +export type DurationValue = Duration; +export type ContentValue = string; +export type ContentMapValue = Record; +export type MediaTypeValue = MediaType; +export type NameValue = string; +export type NameMapValue = Record; +export type SummaryValue = string; +export type SummaryMapValue = Record; +export type EndTimeValue = DateTime; +export type StartTimeValue = DateTime; +export type PublishedValue = DateTime; +export type UpdatedValue = DateTime; +export type RepliesValue = string | AnyCollection; +export type RelationshipValue = string | AnyASObject; +export type IconValue = string | Image | Link; +export type ImageValue = string | Image | Link; +export type AttachmentValue = string | AnyASObject | Link; +export type AudienceValue = string | AnyASObject | Link; +export type InReplyToValue = string | AnyASObject | Link; +export type LocationValue = string | Place | Link; +export type PreviewValue = string | AnyASObject | Link; +export type ToValue = string | AnyASObject | Link; +export type BtoValue = string | AnyASObject | Link; +export type CcValue = string | AnyASObject | Link; +export type BccValue = string | AnyASObject | Link; +export type GeneratorValue = string | AnyASObject | Link; +export type ObjectValue = string | AnyASObject | Link; +export type AttributedToValue = string | AnyASObject | Link | Mention; +export type TagValue = string | AnyASObject | Link | Mention; +export type ActorValue = string | AnyASObject | Link; +export type TargetValue = string | AnyASObject | Link; +export type ResultValue = string | AnyASObject | Link; +export type OriginValue = string | AnyASObject | Link; +export type InstrumentValue = string | AnyASObject | Link; +export type OneOfValue = string | AnyASObject | Link; +export type AnyOfValue = string | AnyASObject | Link; +export type SubjectValue = string | AnyASObject | Link; +export type AccuracyValue = number; +export type AltitudeValue = number; +export type LatitudeValue = number; +export type LongitudeValue = number; +export type RadiusValue = number; +export type UnitsValue = 'cm' | 'feet' | 'inches' | 'km' | 'm' | 'miles' | string; +export type ClosedValue = string | AnyASObject | Link | DateTime | boolean; +export type FormerTypeValue = string; +export type DeletedValue = DateTime; +export type DescribesValue = string | AnyASObject; +export type HrefValue = string; +export type HreflangValue = LanguageTag; +export type RelValue = string; +export type HeightValue = number; +export type WidthValue = number; +export type TotalItemsValue = number; +export type CollectionCurrentValue = string | CollectionPage | Link; +export type CollectionFirstValue = string | CollectionPage | Link; +export type CollectionLastValue = string | CollectionPage | Link; +export type CollectionItemsValue = string | CollectionPage | Link; +export type CollectionPagePartOfValue = string | Collection | Link; +export type CollectionPageNextValue = string | Collection | Link; +export type CollectionPagePrevValue = string | Collection | Link; +export type OrderedCollectionCurrentValue = string | OrderedCollectionPage | Link; +export type OrderedCollectionFirstValue = string | OrderedCollectionPage | Link; +export type OrderedCollectionLastValue = string | OrderedCollectionPage | Link; +export type OrderedCollectionItemsValue = string | OrderedCollectionPage | Link; +export type OrderedCollectionPagePartOfValue = string | OrderedCollection | Link; +export type OrderedCollectionPageNextValue = string | OrderedCollection | Link; +export type OrderedCollectionPagePrevValue = string | OrderedCollection | Link; +export type StartIndexValue = number; \ No newline at end of file diff --git a/src/common/utils.ts b/src/common/utils.ts new file mode 100644 index 0000000..5852d3b --- /dev/null +++ b/src/common/utils.ts @@ -0,0 +1 @@ +export type Modify = Omit & R; \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 8228f4f..8b13789 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,12 +1 @@ -import { ASObject } from './models/ASObject.model'; -const obj = new ASObject({ - id: 'someId', -}); -const obj2 = new ASObject({ - cc: '123', - content: obj, -}).addContext(); - -console.log(obj2.plain()); -console.log(obj2.json()); diff --git a/src/models/ASCollectionBase.model.ts b/src/models/ASCollectionBase.model.ts deleted file mode 100644 index 048746a..0000000 --- a/src/models/ASCollectionBase.model.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { ASObject, ASObjectFields } from "./ASObject.model"; - -// TODO: types -// https://www.w3.org/TR/activitystreams-core/#collection -export interface ASCollectionBaseFields extends ASObjectFields { - totalItems?: any; - first?: any; - last?: any; - current?: any; -} - -export class ASCollectionBase extends ASObject { - constructor(fields: ASCollectionBaseFields) { - super(fields); - } -} \ No newline at end of file diff --git a/src/models/ASObject.model.ts b/src/models/ASObject.model.ts deleted file mode 100644 index 4ec192d..0000000 --- a/src/models/ASObject.model.ts +++ /dev/null @@ -1,41 +0,0 @@ -import {ASBase} from "./ASBase.model"; - -// TODO: types -// https://www.w3.org/TR/activitystreams-core/#object -export interface ASObjectFields { - /** @remarks Example remark for id */ - id?: any; - - type?: any; - attachment?: any; - attributedTo?: any; - audience?: any; - content?: any; - name?: any; - endTime?: any; - generator?: any; - icon?: any; - image?: any; // Link? - inReplyTo?: any; - location?: any; - preview?: any; - published?: any; - replies?: any; - startTime?: any; - summary?: any; - tag?: any; - updated?: any; - url?: any; - to?: any; - bto?: any; - cc?: any; - bcc?: any; - mediaType?: any; - duration?: any; -} - -export class ASObject extends ASBase{ - constructor(fields: ASObjectFields) { - super(fields); - } -} \ No newline at end of file diff --git a/src/models/Activity.model.ts b/src/models/Activity.model.ts deleted file mode 100644 index dbe93c4..0000000 --- a/src/models/Activity.model.ts +++ /dev/null @@ -1,14 +0,0 @@ -import {ASBase} from "./ASBase.model"; -import {IntransitiveActivityFields} from "./IntransitiveActivity.model"; - -// TODO: types -// https://www.w3.org/TR/activitystreams-core/#activities -export interface ActivityFields extends IntransitiveActivityFields { - object?: any; // Object? -} - -export class Activity extends ASBase{ - constructor(fields: ActivityFields) { - super(fields); - } -} \ No newline at end of file diff --git a/src/models/Actor.model.ts b/src/models/Actor.model.ts deleted file mode 100644 index f1f7cb7..0000000 --- a/src/models/Actor.model.ts +++ /dev/null @@ -1,22 +0,0 @@ -import {ASBase} from "./ASBase.model"; -import {ASObjectFields} from "./ASObject.model"; - -export enum ActorTypes { - Application = 'Application', - Group = 'Group', - Organization = 'Organization', - Person = 'Person', - Service = 'Service' -} - -// TODO: types -// https://www.w3.org/TR/activitystreams-core/#actors -export interface ActorFields extends ASObjectFields { - type?: any | ActorTypes; // ? -} - -export class Actor extends ASBase{ - constructor(fields: ActorFields) { - super(fields); - } -} \ No newline at end of file diff --git a/src/models/Collection.model.ts b/src/models/Collection.model.ts deleted file mode 100644 index 62215f0..0000000 --- a/src/models/Collection.model.ts +++ /dev/null @@ -1,13 +0,0 @@ -import {ASCollectionBase, ASCollectionBaseFields} from "./ASCollectionBase.model"; - -// TODO: types -// https://www.w3.org/TR/activitystreams-core/#collection -export interface CollectionFields extends ASCollectionBaseFields { - items?: any; // Objects? Links? -} - -export class Collection extends ASCollectionBase { - constructor(fields: CollectionFields) { - super(fields); - } -} \ No newline at end of file diff --git a/src/models/CollectionPage.model.ts b/src/models/CollectionPage.model.ts deleted file mode 100644 index 9600804..0000000 --- a/src/models/CollectionPage.model.ts +++ /dev/null @@ -1,18 +0,0 @@ -import {ASCollectionBase, ASCollectionBaseFields} from "./ASCollectionBase.model"; - -// TODO: types -// https://www.w3.org/TR/activitystreams-core/#collection -export interface CollectionPageFields extends ASCollectionBaseFields { - partOf?: any; - first?: any; - next?: any; - prev?: any; - last?: any; - current?: any; -} - -export class CollectionPage extends ASCollectionBase { - constructor(fields: CollectionPageFields) { - super(fields); - } -} \ No newline at end of file diff --git a/src/models/IntransitiveActivity.model.ts b/src/models/IntransitiveActivity.model.ts deleted file mode 100644 index 96baf0d..0000000 --- a/src/models/IntransitiveActivity.model.ts +++ /dev/null @@ -1,18 +0,0 @@ -import {ASBase} from "./ASBase.model"; -import {ASObjectFields} from "./ASObject.model"; - -// TODO: types -// https://www.w3.org/TR/activitystreams-core/#intransitiveactivities -export interface IntransitiveActivityFields extends ASObjectFields { - actor?: any; // Actor? - target?: any; - origin?: any; - result?: any; - instrument?: any; -} - -export class IntransitiveActivity extends ASBase{ - constructor(fields: IntransitiveActivityFields) { - super(fields); - } -} \ No newline at end of file diff --git a/src/models/Link.model.ts b/src/models/Link.model.ts deleted file mode 100644 index fdb1fc0..0000000 --- a/src/models/Link.model.ts +++ /dev/null @@ -1,19 +0,0 @@ -import {ASBase} from "./ASBase.model"; - -// TODO: types -// https://www.w3.org/TR/activitystreams-core/#dfn-link -export interface LinkFields { - id?: any; - name?: any; - hreflang?: any; - mediaType?: any; - rel?: any; - height?: any; - width?: any; -} - -export class Link extends ASBase{ - constructor(fields: LinkFields) { - super(fields); - } -} \ No newline at end of file diff --git a/src/models/OrderedCollection.model.ts b/src/models/OrderedCollection.model.ts deleted file mode 100644 index da2b291..0000000 --- a/src/models/OrderedCollection.model.ts +++ /dev/null @@ -1,14 +0,0 @@ -import {ASCollectionBase, ASCollectionBaseFields} from "./ASCollectionBase.model"; - -// TODO: types -// https://www.w3.org/TR/activitystreams-core/#collection -export interface OrderedCollectionFields extends ASCollectionBaseFields { - orderedItems?: any; // Objects? Links? -} - -// TODO: sort method? -export class OrderedCollection extends ASCollectionBase { - constructor(fields: OrderedCollectionFields) { - super(fields); - } -} \ No newline at end of file diff --git a/src/models/OrderedCollectionPage.model.ts b/src/models/OrderedCollectionPage.model.ts deleted file mode 100644 index 8df62c9..0000000 --- a/src/models/OrderedCollectionPage.model.ts +++ /dev/null @@ -1,14 +0,0 @@ -import {CollectionPage, CollectionPageFields} from "./CollectionPage.model"; - -// TODO: types -// TODO: is it correct? -// https://www.w3.org/TR/activitystreams-core/#collection -export interface OrderedCollectionPageFields extends CollectionPageFields { - startIndex?: any; -} - -export class OrderedCollectionPage extends CollectionPage { - constructor(fields: OrderedCollectionPageFields) { - super(fields); - } -} \ No newline at end of file diff --git a/src/models/activity/Activity.model.ts b/src/models/activity/Activity.model.ts new file mode 100644 index 0000000..fad669b --- /dev/null +++ b/src/models/activity/Activity.model.ts @@ -0,0 +1,20 @@ +import {ASBase} from "../asBase/ASBase.model"; +import { ActivityFields } from "./Activity.types"; +import {ASModelType} from "../../common/common.types"; + +/** + * 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. + * + * {@link https://www.w3.org/ns/activitystreams#Activity Docs} + */ +export class Activity extends ASBase{ + constructor(fields: ActivityFields) { + super({ + type: ASModelType.Activity, + ...fields + }) + } +} \ No newline at end of file diff --git a/src/models/activity/Activity.types.ts b/src/models/activity/Activity.types.ts new file mode 100644 index 0000000..f6c5b8a --- /dev/null +++ b/src/models/activity/Activity.types.ts @@ -0,0 +1,65 @@ +import {ASObjectFields} from "../asObject/ASObject.types"; +import { + ActorValue, + InstrumentValue, + ObjectValue, + OriginValue, + ResultValue, + TargetValue +} from "../../common/common.types"; + +export interface ActivityFields extends ASObjectFields { + + /** + * 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. + * + * {@link https://www.w3.org/ns/activitystreams#actor Docs} + */ + actor?: ActorValue | ActorValue[]; + + /** + * 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. + * + * {@link https://www.w3.org/ns/activitystreams#object Docs} + */ + object?: ObjectValue | ObjectValue[]; + + /** + * 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. + * + * {@link https://www.w3.org/ns/activitystreams#target Docs} + */ + target?: TargetValue | TargetValue[]; + + /** + * 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. + * + * {@link https://www.w3.org/ns/activitystreams#result Docs} + */ + result?: ResultValue | ResultValue[]; + + /** + * 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". + * + * {@link https://www.w3.org/ns/activitystreams#origin Docs} + */ + origin?: OriginValue | OriginValue[]; + + /** + * Identifies one or more objects used (or to be used) + * in the completion of an Activity. + * + * {@link https://www.w3.org/ns/activitystreams#instrument Docs} + */ + instrument?: InstrumentValue | InstrumentValue[]; +} diff --git a/src/models/application/Application.model.ts b/src/models/application/Application.model.ts new file mode 100644 index 0000000..5e7d208 --- /dev/null +++ b/src/models/application/Application.model.ts @@ -0,0 +1,17 @@ +import {ASBase} from "../asBase/ASBase.model"; +import {ASModelType} from "../../common/common.types"; +import {ApplicationFields} from "./Application.types"; + +/** + * Describes a software application + * + * {@link https://www.w3.org/ns/activitystreams#Application Docs} + */ +export class Application extends ASBase{ + constructor(fields: ApplicationFields) { + super({ + type: ASModelType.Application, + ...fields + }) + } +} \ No newline at end of file diff --git a/src/models/application/Application.types.ts b/src/models/application/Application.types.ts new file mode 100644 index 0000000..90b1e83 --- /dev/null +++ b/src/models/application/Application.types.ts @@ -0,0 +1,3 @@ +import {ASObjectFields} from "../asObject/ASObject.types"; + +export interface ApplicationFields extends ASObjectFields {} diff --git a/src/models/article/Article.model.ts b/src/models/article/Article.model.ts new file mode 100644 index 0000000..629627d --- /dev/null +++ b/src/models/article/Article.model.ts @@ -0,0 +1,17 @@ +import {ASBase} from "../asBase/ASBase.model"; +import {ASModelType} from "../../common/common.types"; +import {ArticleFields} from "./Article.types"; + +/** + * Represents any kind of multi-paragraph written work + * + * {@link https://www.w3.org/ns/activitystreams#Article Docs} + */ +export class Article extends ASBase{ + constructor(fields: ArticleFields) { + super({ + type: ASModelType.Article, + ...fields + }) + } +} \ No newline at end of file diff --git a/src/models/article/Article.types.ts b/src/models/article/Article.types.ts new file mode 100644 index 0000000..6faf317 --- /dev/null +++ b/src/models/article/Article.types.ts @@ -0,0 +1,3 @@ +import {ASObjectFields} from "../asObject/ASObject.types"; + +export interface ArticleFields extends ASObjectFields {} diff --git a/src/models/ASBase.model.ts b/src/models/asBase/ASBase.model.ts similarity index 83% rename from src/models/ASBase.model.ts rename to src/models/asBase/ASBase.model.ts index a1c7cda..60d6dcb 100644 --- a/src/models/ASBase.model.ts +++ b/src/models/asBase/ASBase.model.ts @@ -1,3 +1,5 @@ +import { contexts } from "../../common/common.constants"; + // TODO: types // TODO: renaming/refactor export type Context = string | any[]; @@ -17,9 +19,10 @@ export class ASBase { } // TODO: rewrite (better option to handle multiple contexts) - public addContext(context?: Context): this { + // some comment + public setContext(context?: Context): this { this.fields = { - ['@context']: context || 'https://www.w3.org/ns/activitystreams', + ['@context']: context || contexts.activityStreamsV2, ...this.fields } return this; diff --git a/src/models/asEvent/ASEvent.model.ts b/src/models/asEvent/ASEvent.model.ts new file mode 100644 index 0000000..1480f09 --- /dev/null +++ b/src/models/asEvent/ASEvent.model.ts @@ -0,0 +1,17 @@ +import {ASBase} from "../asBase/ASBase.model"; +import {ASModelType} from "../../common/common.types"; +import {ASEventFields} from "./ASEvent.types"; + +/** + * Represents any kind of event + * + * {@link https://www.w3.org/ns/activitystreams#Event Docs} + */ +export class ASEvent extends ASBase{ + constructor(fields: ASEventFields) { + super({ + type: ASModelType.Event, + ...fields + }) + } +} \ No newline at end of file diff --git a/src/models/asEvent/ASEvent.types.ts b/src/models/asEvent/ASEvent.types.ts new file mode 100644 index 0000000..53eea20 --- /dev/null +++ b/src/models/asEvent/ASEvent.types.ts @@ -0,0 +1,3 @@ +import {ASObjectFields} from "../asObject/ASObject.types"; + +export interface ASEventFields extends ASObjectFields {} diff --git a/src/models/asObject/ASObject.model.ts b/src/models/asObject/ASObject.model.ts new file mode 100644 index 0000000..a3e6e31 --- /dev/null +++ b/src/models/asObject/ASObject.model.ts @@ -0,0 +1,19 @@ +import {ASBase} from "../asBase/ASBase.model"; +import { ASObjectFields } from "./ASObject.types"; +import {ASModelType} from "../../common/common.types"; + +/** + * Describes an object of any kind. The Object type serves as the base type for most of + * the other kinds of objects defined in the Activity Vocabulary, + * including other Core types such as Activity, intransitiveActivity, Collection and OrderedCollection. + * + * {@link https://www.w3.org/ns/activitystreams#Object Docs} + */ +export class ASObject extends ASBase{ + constructor(fields: ASObjectFields) { + super({ + type: ASModelType.Object, + ...fields + }) + } +} \ No newline at end of file diff --git a/src/models/asObject/ASObject.types.ts b/src/models/asObject/ASObject.types.ts new file mode 100644 index 0000000..6da34e7 --- /dev/null +++ b/src/models/asObject/ASObject.types.ts @@ -0,0 +1,326 @@ +import { + UrlValue, + IconValue, + ImageValue, + AttachmentValue, + AudienceValue, + InReplyToValue, + LocationValue, + PreviewValue, + ToValue, + BtoValue, + CcValue, + BccValue, + AttributedToValue, + TagValue, + GeneratorValue, + IdValue, + TypeValue, + ContentValue, + ContentMapValue, + MediaTypeValue, + NameValue, + NameMapValue, + EndTimeValue, + StartTimeValue, + PublishedValue, + RepliesValue, + SummaryValue, + SummaryMapValue, + UpdatedValue, + DurationValue, +} from "../../common/common.types"; + +export interface ASObjectFields { + /** + * Provides the globally unique identifier for + * an {@link https://www.w3.org/TR/activitystreams-vocabulary/#dfn-object Object} + * + * {@link https://www.w3.org/TR/activitystreams-vocabulary/#dfn-object Docs (@id)} + */ + id?: IdValue; + + /** + * Identifies the {@link https://www.w3.org/TR/activitystreams-vocabulary/#dfn-object Object} + * type. Multiple values may be specified. + * + * {@link https://www.w3.org/TR/activitystreams-vocabulary/#dfn-object Docs (@type)} + */ + type?: TypeValue | TypeValue[]; + + /** + * Identifies resources attached or related to an object that potentially requires special handling. + * The intent is to provide a model that is at least semantically similar to attachments in email. + * + * {@link https://www.w3.org/ns/activitystreams#attachment Docs} + */ + attachment?: AttachmentValue | AttachmentValue[]; + + + /** + * Identifies one or more entities to which this object is attributed. + * The attributed entities might not be Actors. For instance, + * an object might be attributed to the completion of another activity. + * + * {@link https://www.w3.org/ns/activitystreams#attributedTo Docs} + */ + attributedTo?: AttributedToValue | AttributedToValue[]; + + /** + * Identifies one or more entities that represent the total population of entities + * for which the object can be considered to be relevant. + * + * {@link https://www.w3.org/ns/activitystreams#audience Docs} + */ + audience?: AudienceValue | AudienceValue[]; + + // TODO: only content or contentMap at one time + + /** + * The content or textual representation of the Object encoded as a JSON string. + * By default, the value of content is HTML. The mediaType property can be + * used in the object to indicate a different content type. + * [For multiple language-tagged values use contentMap property]. + * + * {@link https://www.w3.org/ns/activitystreams#content Docs} + */ + content?: ContentValue; + + /** + * The content or textual representation of the Object encoded as a JSON string. + * By default, the value of content is HTML. The mediaType property can be + * used in the object to indicate a different content type. + * [For a single value use content property]. + * + * {@link https://www.w3.org/ns/activitystreams#content Docs} + */ + contentMap?: ContentMapValue; + + /** + * When used on an Object, identifies the MIME media type of the value of the content property. + * If not specified, the content property is assumed to contain text/html content. + * Works different with Link + * + * {@link https://www.w3.org/ns/activitystreams#mediaType Docs} + */ + mediaType?: MediaTypeValue; + + // TODO: only name or nameMap at one time + + /** + * A simple, human-readable, plain-text name for the object. + * HTML markup MUST NOT be included. + * [For multiple language-tagged values use nameMap property] + * + * {@link https://www.w3.org/ns/activitystreams#name Docs} + */ + name?: NameValue; + + /** + * A simple, human-readable, plain-text name for the object. + * HTML markup MUST NOT be included. + * [For a single value use name property] + * + * {@link https://www.w3.org/ns/activitystreams#name Docs} + */ + nameMap?: NameMapValue; + + /** + * The date and time describing the actual or expected ending time of the object. + * When used with an Activity object, for instance, the endTime property specifies + * the moment the activity concluded or is expected to conclude. + * + * Must be provided in {@link https://www.w3schools.blog/xsd-date-and-time-data-types xsd:dateTime} + * + * {@link https://www.w3.org/ns/activitystreams#endTime Docs} + * + * @example + * 2020-08-08T08:30:11-03:00Z + * 2020-08-08T08:30:11-03:00 + * 2020-08-08T08:30:11Z + * 2020-08-08T08:30:11 + * 2020-08-08 + */ + endTime?: EndTimeValue; + + /** + * The date and time describing the actual or expected starting time of the object. + * When used with an Activity object, for instance, the startTime property specifies + * the moment the activity began or is scheduled to begin. + * + * Must be provided in {@link https://www.w3schools.blog/xsd-date-and-time-data-types xsd:dateTime} + * + * {@link https://www.w3.org/ns/activitystreams#startTime Docs} + * + * @example + * 2020-08-08T08:30:11-03:00Z + * 2020-08-08T08:30:11-03:00 + * 2020-08-08T08:30:11Z + * 2020-08-08T08:30:11 + * 2020-08-08 + */ + startTime?: StartTimeValue; + + /** + * Identifies the entity (e.g. an application) that generated the object. + * + * {@link https://www.w3.org/ns/activitystreams#generator Docs} + */ + generator?: GeneratorValue; + + /** + * Indicates an entity (or entities) that describes an icon for this object. + * Unlike image property, the icon should have an aspect ratio of one (horizontal) + * to one (vertical) and should be suitable for presentation at a small size. + * + * {@link https://www.w3.org/ns/activitystreams#icon Docs} + */ + icon?: IconValue | IconValue[]; + + /** + * Indicates an entity that describes an image for this object. + * Unlike the icon property, there are no aspect ratio or display size limitations assumed. + * + * {@link https://www.w3.org/ns/activitystreams#image Docs} + */ + image?: ImageValue | ImageValue[]; + + /** + * Indicates one or more entities for which this object is considered a response. + * + * {@link https://www.w3.org/ns/activitystreams#inReplyTo Docs} + */ + inReplyTo?: InReplyToValue | InReplyToValue[]; + + /** + * Indicates one or more physical or logical locations associated with the object. + * + * {@link https://www.w3.org/ns/activitystreams#location Docs} + */ + location?: LocationValue | LocationValue[]; + + /** + * Identifies an entity that provides a preview of this object. + * + * {@link https://www.w3.org/ns/activitystreams#preview Docs} + */ + preview?: PreviewValue; + + /** + * The date and time at which the object was published. + * + * Must be provided in {@link https://www.w3schools.blog/xsd-date-and-time-data-types xsd:dateTime} + * + * {@link https://www.w3.org/ns/activitystreams#published Docs} + * + * @example + * 2020-08-08T08:30:11-03:00Z + * 2020-08-08T08:30:11-03:00 + * 2020-08-08T08:30:11Z + * 2020-08-08T08:30:11 + * 2020-08-08 + */ + published?: PublishedValue; + + /** + * Identifies a Collection containing objects considered to be responses to this object. + * + * {@link https://www.w3.org/ns/activitystreams#replies Docs} + */ + replies?: RepliesValue; + + // TODO: only summary or summaryMap at one time + + /** + * A natural language summarization of the object encoded as HTML. + * Multiple language tagged summaries MAY be provided. + * [For multiple language-tagged values use summaryMap property] + * + * {@link https://www.w3.org/ns/activitystreams#summary Docs} + */ + summary?: SummaryValue; + + /** + * A natural language summarization of the object encoded as HTML. + * Multiple language tagged summaries MAY be provided. + * [For a single value use summary property] + * + * {@link https://www.w3.org/ns/activitystreams#summary Docs} + */ + summaryMap?: SummaryMapValue; + + /** + * One or more "tags" that have been associated with an objects. A tag can be any kind of Object. + * The key difference between attachment and tag is that the former implies association by + * inclusion, while the latter implies associated by reference. + * + * {@link https://www.w3.org/ns/activitystreams#tag Docs} + */ + tag?: TagValue | TagValue[]; + + /** + * The date and time at which the object was updated. + * + * Must be provided in {@link https://www.w3schools.blog/xsd-date-and-time-data-types xsd:dateTime} + * + * {@link https://www.w3.org/ns/activitystreams#published Docs} + * + * @example + * 2020-08-08T08:30:11-03:00Z + * 2020-08-08T08:30:11-03:00 + * 2020-08-08T08:30:11Z + * 2020-08-08T08:30:11 + * 2020-08-08 + */ + updated?: UpdatedValue; + + /** + * Identifies one or more links to representations of the object. + * + * {@link https://www.w3.org/ns/activitystreams#url Docs} + */ + url?: UrlValue | UrlValue[]; + + /** + * Identifies an entity or entities considered to be part of the public primary audience of an Object. + * + * {@link https://www.w3.org/ns/activitystreams#to Docs} + */ + to?: ToValue | ToValue[]; + + /** + * Identifies an Object that is part of the private primary audience of this Object. + * + * {@link https://www.w3.org/ns/activitystreams#bto Docs} + */ + bto?: BtoValue | BtoValue[]; + + /** + * Identifies an Object that is part of the public secondary audience of this Object. + * + * {@link https://www.w3.org/ns/activitystreams#cc Docs} + */ + cc?: CcValue | CcValue[]; + + /** + * Identifies one or more Objects that are part of the private secondary audience of this Object. + * + * {@link https://www.w3.org/ns/activitystreams#bcc Docs} + */ + bcc?: BccValue | BccValue[]; + + /** + * When the object describes a time-bound resource, such as an audio or video, a meeting, etc., + * the duration property indicates the object's approximate duration. + * + * {@link https://www.w3.org/ns/activitystreams#duration Docs} + * + * Must be provided in {@link http://www.datypic.com/sc/xsd/t-xsd_duration.html xsd:duration} + * + * @example + * PT20M (20 minutes) + * P1DT2H (1 day, 2 hours) + * P2Y6M5DT12H35M30S (2 years, 6 months, 5 days, 12 hours, 35 minutes, 30 seconds) + */ + duration?: DurationValue; +} \ No newline at end of file diff --git a/src/models/audio/Audio.model.ts b/src/models/audio/Audio.model.ts new file mode 100644 index 0000000..ad5e92c --- /dev/null +++ b/src/models/audio/Audio.model.ts @@ -0,0 +1,17 @@ +import {ASBase} from "../asBase/ASBase.model"; +import {ASModelType} from "../../common/common.types"; +import {AudioFields} from "./Audio.types"; + +/** + * Represents an audio document of any kind + * + * {@link https://www.w3.org/ns/activitystreams#Audio Docs} + */ +export class Audio extends ASBase{ + constructor(fields: AudioFields) { + super({ + type: ASModelType.Audio, + ...fields + }) + } +} \ No newline at end of file diff --git a/src/models/audio/Audio.types.ts b/src/models/audio/Audio.types.ts new file mode 100644 index 0000000..f3c52b4 --- /dev/null +++ b/src/models/audio/Audio.types.ts @@ -0,0 +1,3 @@ +import { DocumentFields } from "../document/Document.types"; + +export interface AudioFields extends DocumentFields {} \ No newline at end of file diff --git a/src/models/collection/Collection.model.ts b/src/models/collection/Collection.model.ts new file mode 100644 index 0000000..cc14680 --- /dev/null +++ b/src/models/collection/Collection.model.ts @@ -0,0 +1,18 @@ +import {ASBase} from "../asBase/ASBase.model"; +import {ASModelType} from "../../common/common.types"; +import {CollectionFields} from "./Collection.types"; + +/** + * A Collection is a subtype of Object that represents + * ordered or unordered sets of Object or Link instances. + * + * {@link https://www.w3.org/ns/activitystreams#Collection Docs} + */ +export class Collection extends ASBase{ + constructor(fields: CollectionFields) { + super({ + type: ASModelType.Collection, + ...fields + }) + } +} \ No newline at end of file diff --git a/src/models/collection/Collection.types.ts b/src/models/collection/Collection.types.ts new file mode 100644 index 0000000..cec2570 --- /dev/null +++ b/src/models/collection/Collection.types.ts @@ -0,0 +1,51 @@ +import {ASObjectFields} from "../asObject/ASObject.types"; +import { + CollectionCurrentValue, + CollectionFirstValue, CollectionItemsValue, + CollectionLastValue, + TotalItemsValue +} from "../../common/common.types"; + +export interface CollectionFields extends ASObjectFields { + + /** + * 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. + * + * {@link https://www.w3.org/ns/activitystreams#totalItems Docs} + */ + totalItems?: TotalItemsValue; + + /** + * In a paged Collection, indicates the page that contains + * the most recently updated member items. + * + * {@link https://www.w3.org/ns/activitystreams#current Docs} + */ + current?: CollectionCurrentValue; + + /** + * In a paged Collection,indicates the furthest proceeding + * page of items in the collection. + * + * {@link https://www.w3.org/ns/activitystreams#first Docs} + */ + first?: CollectionFirstValue; + + /** + * In a paged Collection, indicates the furthest proceeding + * page of the collection. + * + * {@link https://www.w3.org/ns/activitystreams#last Docs} + */ + last?: CollectionLastValue; + + /** + * Identifies the items contained in a collection. + * The items might be ordered or unordered. + * + * {@link https://www.w3.org/ns/activitystreams#items Docs} + */ + items?: CollectionItemsValue[]; +} diff --git a/src/models/collectionPage/CollectionPage.model.ts b/src/models/collectionPage/CollectionPage.model.ts new file mode 100644 index 0000000..46a89a3 --- /dev/null +++ b/src/models/collectionPage/CollectionPage.model.ts @@ -0,0 +1,17 @@ +import {ASBase} from "../asBase/ASBase.model"; +import {ASModelType} from "../../common/common.types"; +import {CollectionPageFields} from "./CollectionPage.types"; + +/** + * Used to represent distinct subsets of items from a Collection. + * + * {@link https://www.w3.org/ns/activitystreams#CollectionPage Docs} + */ +export class CollectionPage extends ASBase{ + constructor(fields: CollectionPageFields) { + super({ + type: ASModelType.CollectionPage, + ...fields + }) + } +} \ No newline at end of file diff --git a/src/models/collectionPage/CollectionPage.types.ts b/src/models/collectionPage/CollectionPage.types.ts new file mode 100644 index 0000000..d9427fb --- /dev/null +++ b/src/models/collectionPage/CollectionPage.types.ts @@ -0,0 +1,26 @@ +import {CollectionFields} from "../collection/Collection.types"; +import {CollectionPageNextValue, CollectionPagePartOfValue, CollectionPagePrevValue} from "../../common/common.types"; + +export interface CollectionPageFields extends CollectionFields { + + /** + * Identifies the Collection to which a CollectionPage objects items belong. + * + * {@link https://www.w3.org/ns/activitystreams#partOf Docs} + */ + partOf?: CollectionPagePartOfValue; + + /** + * In a paged Collection, indicates the next page of items. + * + * {@link https://www.w3.org/ns/activitystreams#next Docs} + */ + next?: CollectionPageNextValue; + + /** + * In a paged Collection, identifies the previous page of items. + * + * {@link https://www.w3.org/ns/activitystreams#prev Docs} + */ + prev?: CollectionPagePrevValue; +} diff --git a/src/models/document/Document.model.ts b/src/models/document/Document.model.ts new file mode 100644 index 0000000..cfdd6b5 --- /dev/null +++ b/src/models/document/Document.model.ts @@ -0,0 +1,17 @@ +import {ASBase} from "../asBase/ASBase.model"; +import {ASModelType} from "../../common/common.types"; +import {DocumentFields} from "./Document.types"; + +/** + * Represents a document of any kind + * + * {@link https://www.w3.org/ns/activitystreams#Document Docs} + */ +export class Document extends ASBase{ + constructor(fields: DocumentFields) { + super({ + type: ASModelType.Document, + ...fields + }) + } +} \ No newline at end of file diff --git a/src/models/document/Document.types.ts b/src/models/document/Document.types.ts new file mode 100644 index 0000000..2583559 --- /dev/null +++ b/src/models/document/Document.types.ts @@ -0,0 +1,3 @@ +import {ASObjectFields} from "../asObject/ASObject.types"; + +export interface DocumentFields extends ASObjectFields {} diff --git a/src/models/group/Group.model.ts b/src/models/group/Group.model.ts new file mode 100644 index 0000000..7269e4c --- /dev/null +++ b/src/models/group/Group.model.ts @@ -0,0 +1,17 @@ +import {ASBase} from "../asBase/ASBase.model"; +import {ASModelType} from "../../common/common.types"; +import {GroupFields} from "./Group.types"; + +/** + * Represents a formal or informal collective of Actors + * + * {@link https://www.w3.org/ns/activitystreams#Group Docs} + */ +export class Group extends ASBase{ + constructor(fields: GroupFields) { + super({ + type: ASModelType.Group, + ...fields + }) + } +} \ No newline at end of file diff --git a/src/models/group/Group.types.ts b/src/models/group/Group.types.ts new file mode 100644 index 0000000..8a600d9 --- /dev/null +++ b/src/models/group/Group.types.ts @@ -0,0 +1,3 @@ +import {ASObjectFields} from "../asObject/ASObject.types"; + +export interface GroupFields extends ASObjectFields {} diff --git a/src/models/image/Image.model.ts b/src/models/image/Image.model.ts new file mode 100644 index 0000000..c740e48 --- /dev/null +++ b/src/models/image/Image.model.ts @@ -0,0 +1,17 @@ +import {ASBase} from "../asBase/ASBase.model"; +import {ASModelType} from "../../common/common.types"; +import {ImageFields} from "./Image.types"; + +/** + * An image document of any kind + * + * {@link https://www.w3.org/ns/activitystreams#Image Docs} + */ +export class Image extends ASBase{ + constructor(fields: ImageFields) { + super({ + type: ASModelType.Image, + ...fields + }) + } +} \ No newline at end of file diff --git a/src/models/image/Image.types.ts b/src/models/image/Image.types.ts new file mode 100644 index 0000000..9ae8777 --- /dev/null +++ b/src/models/image/Image.types.ts @@ -0,0 +1,3 @@ +import { DocumentFields } from "../document/Document.types"; + +export interface ImageFields extends DocumentFields {} \ No newline at end of file diff --git a/src/models/intransitiveActivity/IntransitiveActivity.model.ts b/src/models/intransitiveActivity/IntransitiveActivity.model.ts new file mode 100644 index 0000000..98ee428 --- /dev/null +++ b/src/models/intransitiveActivity/IntransitiveActivity.model.ts @@ -0,0 +1,19 @@ +import {ASBase} from "../asBase/ASBase.model"; +import {IntransitiveActivityFields} from './IntransitiveActivity.types'; +import {ASModelType} from "../../common/common.types"; + +/** + * Instances of intransitiveActivity are a subtype of + * Activity representing intransitive actions. The + * object property is therefore inappropriate for these activities. + * + * {@link https://www.w3.org/ns/activitystreams#IntransitiveActivity Docs} + */ +export class IntransitiveActivity extends ASBase{ + constructor(fields: IntransitiveActivityFields) { + super({ + type: ASModelType.Activity, + ...fields + }) + } +} \ No newline at end of file diff --git a/src/models/intransitiveActivity/IntransitiveActivity.types.ts b/src/models/intransitiveActivity/IntransitiveActivity.types.ts new file mode 100644 index 0000000..2c91140 --- /dev/null +++ b/src/models/intransitiveActivity/IntransitiveActivity.types.ts @@ -0,0 +1,3 @@ +import {ActivityFields} from "../activity/Activity.types"; + +export interface IntransitiveActivityFields extends Omit {} diff --git a/src/models/link/Link.model.ts b/src/models/link/Link.model.ts new file mode 100644 index 0000000..28c538e --- /dev/null +++ b/src/models/link/Link.model.ts @@ -0,0 +1,22 @@ +import {ASBase} from "../asBase/ASBase.model"; +import { LinkFields } from "./Link.types"; +import {ASModelType} from "../../common/common.types"; + +/** + * A Link is an indirect, qualified reference to a resource identified by a URL. + * The fundamental model for links is established by [RFC5988]. Many of the properties + * defined by the Activity Vocabulary allow values that are either instances of Object + * or Link. When a Link is used, it establishes a qualified relation connecting the + * subject (the containing object) to the resource identified by the href. Properties + * of the Link are properties of the reference as opposed to properties of the resource. + * + * {@link https://www.w3.org/ns/activitystreams#Link Docs} + */ +export class Link extends ASBase{ + constructor(fields: LinkFields) { + super({ + type: ASModelType.Link, + ...fields + }) + } +} \ No newline at end of file diff --git a/src/models/link/Link.types.ts b/src/models/link/Link.types.ts new file mode 100644 index 0000000..485b7b0 --- /dev/null +++ b/src/models/link/Link.types.ts @@ -0,0 +1,96 @@ +import { + HeightValue, + HreflangValue, + HrefValue, + IdValue, + MediaTypeValue, + NameMapValue, + NameValue, PreviewValue, + RelValue, TypeValue, WidthValue +} from "../../common/common.types"; + +export interface LinkFields { + + /** + * Identifies the {@link https://www.w3.org/TR/activitystreams-vocabulary/#dfn-object Object} + * type. Multiple values may be specified. + * + * {@link https://www.w3.org/TR/activitystreams-vocabulary/#dfn-object Docs (@type)} + */ + type?: TypeValue | TypeValue[]; + + /** + * A simple, human-readable, plain-text name for the object. + * HTML markup MUST NOT be included. + * [For multiple language-tagged values use nameMap property] + * + * {@link https://www.w3.org/ns/activitystreams#name Docs} + */ + name?: NameValue; + + /** + * A simple, human-readable, plain-text name for the object. + * HTML markup MUST NOT be included. + * [For a single value use name property] + * + * {@link https://www.w3.org/ns/activitystreams#name Docs} + */ + nameMap?: NameMapValue; + + /** + * The target resource pointed to by a Link. + * + * {@link https://www.w3.org/ns/activitystreams#href Docs} + */ + href?: HrefValue; + + /** + * Hints as to the language used by the target resource. + * Value MUST be a [BCP47] Language-Tag. + * + * {@link https://www.w3.org/ns/activitystreams#hreflang Docs} + */ + hreflang?: HreflangValue; + + /** + * When used on a Link, identifies the MIME media type of the referenced resource + * + * {@link https://www.w3.org/ns/activitystreams#mediaType Docs} + */ + mediaType?: MediaTypeValue; + + /** + * A link relation associated with a Link. The value MUST conform to both + * the [HTML5] and [RFC5988] "link relation" definitions. In the [HTML5], + * any string not containing the "space" U+0020, "tab" (U+0009), "LF" (U+000A), "FF" (U+000C), "CR" (U+000D) or "," (U+002C) + * characters can be used as a valid link relation. + * + * {@link https://www.w3.org/ns/activitystreams#rel Docs} + */ + rel?: RelValue | RelValue[]; + + /** + * On a Link, specifies a hint as to the rendering height in + * device-independent pixels of the linked resource. + * Type: Non negative integer + * + * {@link https://www.w3.org/ns/activitystreams#height Docs} + */ + height?: HeightValue; + + /** + * On a Link, specifies a hint as to the rendering width in + * device-independent pixels of the linked resource. + * Type: Non negative integer + * + * {@link https://www.w3.org/ns/activitystreams#width Docs} + */ + width?: WidthValue; + + /** + * Identifies an entity that provides a preview of this object. + * + * {@link https://www.w3.org/ns/activitystreams#preview Docs} + */ + preview?: PreviewValue; +} diff --git a/src/models/mention/Mention.model.ts b/src/models/mention/Mention.model.ts new file mode 100644 index 0000000..a46f7b6 --- /dev/null +++ b/src/models/mention/Mention.model.ts @@ -0,0 +1,16 @@ +import {ASBase} from "../asBase/ASBase.model"; +import {MentionFields} from "./Mention.types"; +import {ASModelType} from "../../common/common.types"; +/** + * A specialized Link that represents an @mention. + * + * {@link https://www.w3.org/ns/activitystreams#Mention Docs} + */ +export class Mention extends ASBase{ + constructor(fields: MentionFields) { + super({ + type: ASModelType.Mention, + ...fields + }) + } +} \ No newline at end of file diff --git a/src/models/mention/Mention.types.ts b/src/models/mention/Mention.types.ts new file mode 100644 index 0000000..c25e146 --- /dev/null +++ b/src/models/mention/Mention.types.ts @@ -0,0 +1,3 @@ +import {LinkFields} from "../link/Link.types"; + +export interface MentionFields extends LinkFields {} diff --git a/src/models/note/Note.model.ts b/src/models/note/Note.model.ts new file mode 100644 index 0000000..b25ba62 --- /dev/null +++ b/src/models/note/Note.model.ts @@ -0,0 +1,17 @@ +import {ASBase} from "../asBase/ASBase.model"; +import {ASModelType} from "../../common/common.types"; +import {NoteFields} from "./Note.types"; + +/** + * Represents a short written work typically less than a single paragraph in length. + * + * {@link https://www.w3.org/ns/activitystreams#Note Docs} + */ +export class Note extends ASBase{ + constructor(fields: NoteFields) { + super({ + type: ASModelType.Note, + ...fields + }) + } +} \ No newline at end of file diff --git a/src/models/note/Note.types.ts b/src/models/note/Note.types.ts new file mode 100644 index 0000000..07d2d7b --- /dev/null +++ b/src/models/note/Note.types.ts @@ -0,0 +1,3 @@ +import {ASObjectFields} from "../asObject/ASObject.types"; + +export interface NoteFields extends ASObjectFields {} diff --git a/src/models/orderedCollection/OrderedCollection.model.ts b/src/models/orderedCollection/OrderedCollection.model.ts new file mode 100644 index 0000000..00e314f --- /dev/null +++ b/src/models/orderedCollection/OrderedCollection.model.ts @@ -0,0 +1,18 @@ +import {ASBase} from "../asBase/ASBase.model"; +import {ASModelType} from "../../common/common.types"; +import {OrderedCollectionFields} from "./OrderedCollection.types"; + +/** + * A subtype of Collection in which members of + * the logical collection are assumed to always be strictly ordered. + * + * {@link https://www.w3.org/ns/activitystreams#OrderedCollection Docs} + */ +export class OrderedCollection extends ASBase{ + constructor(fields: OrderedCollectionFields) { + super({ + type: ASModelType.OrderedCollection, + ...fields + }) + } +} \ No newline at end of file diff --git a/src/models/orderedCollection/OrderedCollection.types.ts b/src/models/orderedCollection/OrderedCollection.types.ts new file mode 100644 index 0000000..62f9a19 --- /dev/null +++ b/src/models/orderedCollection/OrderedCollection.types.ts @@ -0,0 +1,42 @@ +import { + OrderedCollectionCurrentValue, + OrderedCollectionFirstValue, OrderedCollectionItemsValue, + OrderedCollectionLastValue +} from "../../common/common.types"; +import {CollectionFields} from "../collection/Collection.types"; +import {Modify} from "../../common/utils"; + +export interface OrderedCollectionFields extends Modify {} diff --git a/src/models/orderedCollectionPage/OrderedCollectionPage.model.ts b/src/models/orderedCollectionPage/OrderedCollectionPage.model.ts new file mode 100644 index 0000000..b53cb95 --- /dev/null +++ b/src/models/orderedCollectionPage/OrderedCollectionPage.model.ts @@ -0,0 +1,17 @@ +import {ASBase} from "../asBase/ASBase.model"; +import {ASModelType} from "../../common/common.types"; +import {OrderedCollectionPageFields} from "./OrderedCollectionPage.types"; + +/** + * Used to represent ordered subsets of items from an OrderedCollection. + * + * {@link https://www.w3.org/ns/activitystreams#OrderedCollectionPage Docs} + */ +export class OrderedCollectionPage extends ASBase{ + constructor(fields: OrderedCollectionPageFields) { + super({ + type: ASModelType.OrderedCollectionPage, + ...fields + }) + } +} \ No newline at end of file diff --git a/src/models/orderedCollectionPage/OrderedCollectionPage.types.ts b/src/models/orderedCollectionPage/OrderedCollectionPage.types.ts new file mode 100644 index 0000000..8e90d22 --- /dev/null +++ b/src/models/orderedCollectionPage/OrderedCollectionPage.types.ts @@ -0,0 +1,47 @@ +import {OrderedCollectionFields} from "../orderedCollection/OrderedCollection.types"; +import { + OrderedCollectionPageNextValue, + OrderedCollectionPagePartOfValue, + OrderedCollectionPagePrevValue, + StartIndexValue +} from "../../common/common.types"; +import {CollectionPageFields} from "../collectionPage/CollectionPage.types"; +import {Modify} from "../../common/utils"; + +interface OmittedCollectionPageFields extends Omit {} + +export interface OrderedCollectionPageFields + extends + OrderedCollectionFields, + Modify { + + /** + * A non-negative integer value identifying the relative position + * within the logical view of a strictly ordered collection. + * + * {@link https://www.w3.org/ns/activitystreams#startIndex Docs} + */ + startIndex?: StartIndexValue; +} diff --git a/src/models/organization/Organization.model.ts b/src/models/organization/Organization.model.ts new file mode 100644 index 0000000..5d00ecc --- /dev/null +++ b/src/models/organization/Organization.model.ts @@ -0,0 +1,17 @@ +import {ASBase} from "../asBase/ASBase.model"; +import {ASModelType} from "../../common/common.types"; +import {OrganizationFields} from "./Organization.types"; + +/** + * Represents an organization + * + * {@link https://www.w3.org/ns/activitystreams#Organization Docs} + */ +export class Organization extends ASBase{ + constructor(fields: OrganizationFields) { + super({ + type: ASModelType.Organization, + ...fields + }) + } +} \ No newline at end of file diff --git a/src/models/organization/Organization.types.ts b/src/models/organization/Organization.types.ts new file mode 100644 index 0000000..7889bd1 --- /dev/null +++ b/src/models/organization/Organization.types.ts @@ -0,0 +1,3 @@ +import {ASObjectFields} from "../asObject/ASObject.types"; + +export interface OrganizationFields extends ASObjectFields {} diff --git a/src/models/page/Page.model.ts b/src/models/page/Page.model.ts new file mode 100644 index 0000000..b322268 --- /dev/null +++ b/src/models/page/Page.model.ts @@ -0,0 +1,17 @@ +import {ASBase} from "../asBase/ASBase.model"; +import {ASModelType} from "../../common/common.types"; +import {PageFields} from "./Page.types"; + +/** + * Represents a Web Page + * + * {@link https://www.w3.org/ns/activitystreams#Page Docs} + */ +export class Page extends ASBase{ + constructor(fields: PageFields) { + super({ + type: ASModelType.Page, + ...fields + }) + } +} \ No newline at end of file diff --git a/src/models/page/Page.types.ts b/src/models/page/Page.types.ts new file mode 100644 index 0000000..fe9258d --- /dev/null +++ b/src/models/page/Page.types.ts @@ -0,0 +1,3 @@ +import { DocumentFields } from "../document/Document.types"; + +export interface PageFields extends DocumentFields {} \ No newline at end of file diff --git a/src/models/person/Person.model.ts b/src/models/person/Person.model.ts new file mode 100644 index 0000000..6671943 --- /dev/null +++ b/src/models/person/Person.model.ts @@ -0,0 +1,17 @@ +import {ASBase} from "../asBase/ASBase.model"; +import {ASModelType} from "../../common/common.types"; +import {PersonFields} from "./Person.types"; + +/** + * Represents an individual person + * + * {@link https://www.w3.org/ns/activitystreams#Person Docs} + */ +export class Person extends ASBase{ + constructor(fields: PersonFields) { + super({ + type: ASModelType.Person, + ...fields + }) + } +} \ No newline at end of file diff --git a/src/models/person/Person.types.ts b/src/models/person/Person.types.ts new file mode 100644 index 0000000..df3a79f --- /dev/null +++ b/src/models/person/Person.types.ts @@ -0,0 +1,3 @@ +import {ASObjectFields} from "../asObject/ASObject.types"; + +export interface PersonFields extends ASObjectFields {} diff --git a/src/models/place/Place.model.ts b/src/models/place/Place.model.ts new file mode 100644 index 0000000..b5420c6 --- /dev/null +++ b/src/models/place/Place.model.ts @@ -0,0 +1,19 @@ +import {ASBase} from "../asBase/ASBase.model"; +import {ASModelType} from "../../common/common.types"; +import {PlaceFields} from "./Place.types"; + +/** + * Represents a logical or physical location. See + * {@link https://www.w3.org/TR/activitystreams-vocabulary/#places 5.3 Representing Places} + * for additional information. + * + * {@link https://www.w3.org/ns/activitystreams#Place Docs} + */ +export class Place extends ASBase{ + constructor(fields: PlaceFields) { + super({ + type: ASModelType.Place, + ...fields + }) + } +} \ No newline at end of file diff --git a/src/models/place/Place.types.ts b/src/models/place/Place.types.ts new file mode 100644 index 0000000..cb6c65e --- /dev/null +++ b/src/models/place/Place.types.ts @@ -0,0 +1,60 @@ +import {ASObjectFields} from "../asObject/ASObject.types"; +import { + AccuracyValue, + AltitudeValue, + LatitudeValue, + LongitudeValue, + RadiusValue, + UnitsValue +} from "../../common/common.types"; + + +export interface PlaceFields extends ASObjectFields { + + /** + * Indicates the accuracy of position coordinates on a Place objects. + * Expressed in properties of percentage. e.g. "94.0" means "94.0% accurate". + * + * {@link https://www.w3.org/ns/activitystreams#accuracy Docs} + */ + accuracy?: AccuracyValue; + + /** + * Indicates the altitude of a place. The measurement units is indicated using the "units" property. + * If units is not specified, the default is assumed to be "m" indicating "meters". + * + * {@link https://www.w3.org/ns/activitystreams#altitude Docs} + */ + altitude?: AltitudeValue; + + /** + * The latitude of a place + * + * {@link https://www.w3.org/ns/activitystreams#latitude Docs} + */ + latitude?: LatitudeValue; + + /** + * The longitude of a place + * + * {@link https://www.w3.org/ns/activitystreams#longitude Docs} + */ + longitude?: LongitudeValue; + + /** + * The radius from the given latitude and longitude for a Place. + * The units are expressed by the "units" property. If units is not specified, + * the default is assumed to be "m" indicating "meters". + * + * {@link https://www.w3.org/ns/activitystreams#radius Docs} + */ + radius?: RadiusValue; + + /** + * Specifies the measurement units for the radius and altitude properties + * on a Place object. If not specified, the default is assumed to be "m" for "meters". + * + * {@link https://www.w3.org/ns/activitystreams#units Docs} + */ + units?: UnitsValue; +} diff --git a/src/models/profile/Profile.model.ts b/src/models/profile/Profile.model.ts new file mode 100644 index 0000000..9dbd4f9 --- /dev/null +++ b/src/models/profile/Profile.model.ts @@ -0,0 +1,19 @@ +import {ASBase} from "../asBase/ASBase.model"; +import {ASModelType} from "../../common/common.types"; +import {ProfileFields} from "./Profile.types"; + +/** + * A Profile is a content object that describes another Object, + * typically used to describe Actor Type objects. The describes property + * is used to reference the object being described by the profile. + * + * {@link https://www.w3.org/ns/activitystreams#Profile Docs} + */ +export class Profile extends ASBase{ + constructor(fields: ProfileFields) { + super({ + type: ASModelType.Profile, + ...fields + }) + } +} \ No newline at end of file diff --git a/src/models/profile/Profile.types.ts b/src/models/profile/Profile.types.ts new file mode 100644 index 0000000..95df778 --- /dev/null +++ b/src/models/profile/Profile.types.ts @@ -0,0 +1,14 @@ + +import {ASObjectFields} from "../asObject/ASObject.types"; +import {DescribesValue} from "../../common/common.types"; + +export interface ProfileFields extends ASObjectFields { + + /** + * On a Profile object, the describes property identifies + * the object described by the Profile. + * + * {@link https://www.w3.org/ns/activitystreams#describes Docs} + */ + describes?: DescribesValue; +} diff --git a/src/models/question/Question.model.ts b/src/models/question/Question.model.ts new file mode 100644 index 0000000..289d02a --- /dev/null +++ b/src/models/question/Question.model.ts @@ -0,0 +1,23 @@ +import {ASBase} from "../asBase/ASBase.model"; +import {ASModelType} from "../../common/common.types"; +import {QuestionFields} from "./Question.types"; + +/** + * Represents a question being asked. Question objects are an extension + * of IntransitiveActivity. That is, the Question object is an Activity, + * but the direct object is the question itself, and therefore it would + * not contain an object property. + * + * Either of the anyOf and oneOf properties MAY be used to express possible + * answers, but a Question object MUST NOT have both properties. + * + * {@link https://www.w3.org/ns/activitystreams#Question Docs} + */ +export class Question extends ASBase{ + constructor(fields: QuestionFields) { + super({ + type: ASModelType.Question, + ...fields + }) + } +} \ No newline at end of file diff --git a/src/models/question/Question.types.ts b/src/models/question/Question.types.ts new file mode 100644 index 0000000..c19d045 --- /dev/null +++ b/src/models/question/Question.types.ts @@ -0,0 +1,31 @@ +import {IntransitiveActivityFields} from "../intransitiveActivity/IntransitiveActivity.types"; +import {AnyOfValue, ClosedValue, OneOfValue} from "../../common/common.types"; + +export interface QuestionFields extends IntransitiveActivityFields { + + // TODO: only oneOf or anyOf at one time + /** + * Identifies an exclusive option for a Question. + * Use of oneOf implies that the Question can have only a single answer. + * To indicate that a Question can have multiple answers, use anyOf. + * + * {@link https://www.w3.org/ns/activitystreams#oneOf Docs} + */ + oneOf?: OneOfValue[]; + + /** + * Identifies an inclusive option for a Question. + * Use of anyOf implies that the Question can have multiple answers. + * To indicate that a Question can have only one answer, use oneOf. + * + * {@link https://www.w3.org/ns/activitystreams#anyOf Docs} + */ + anyOf?: AnyOfValue[]; + + /** + * Indicates that a question has been closed, and answers are no longer accepted. + * + * {@link https://www.w3.org/ns/activitystreams#closed Docs} + */ + closed?: ClosedValue; +} diff --git a/src/models/relationship/Relationship.model.ts b/src/models/relationship/Relationship.model.ts new file mode 100644 index 0000000..b492330 --- /dev/null +++ b/src/models/relationship/Relationship.model.ts @@ -0,0 +1,20 @@ +import {ASBase} from "../asBase/ASBase.model"; +import {ASModelType} from "../../common/common.types"; +import {RelationshipFields} from "./Relationship.types"; + +/** + * Describes a relationship between two individuals. The subject and + * object properties are used to identify the connected individuals. + * See {@link https://www.w3.org/TR/activitystreams-vocabulary/#connections 5.2 Representing Relationships Between Entities} + * for additional information. + * + * {@link https://www.w3.org/ns/activitystreams#Relationship Docs} + */ +export class Relationship extends ASBase{ + constructor(fields: RelationshipFields) { + super({ + type: ASModelType.Relationship, + ...fields + }) + } +} \ No newline at end of file diff --git a/src/models/relationship/Relationship.types.ts b/src/models/relationship/Relationship.types.ts new file mode 100644 index 0000000..64d697a --- /dev/null +++ b/src/models/relationship/Relationship.types.ts @@ -0,0 +1,29 @@ +import {ASObjectFields} from "../asObject/ASObject.types"; +import {SubjectValue, ObjectValue, RelationshipValue} from "../../common/common.types"; + +export interface RelationshipFields extends ASObjectFields { + + /** + * On a Relationship object, the subject property identifies one of the connected individuals. + * For instance, for a Relationship object describing "John is related to Sally", + * subject would refer to John. + * + * {@link https://www.w3.org/ns/activitystreams#subject Docs} + */ + subject?: SubjectValue; + + /** + * When used within a Relationship describes the entity to which the subject is related. + * + * {@link https://www.w3.org/ns/activitystreams#object Docs} + */ + object?: ObjectValue | ObjectValue[]; + + /** + * On a Relationship object, the relationship property + * identifies the kind of relationship that exists between subject and object. + * + * {@link https://www.w3.org/ns/activitystreams#relationship Docs} + */ + relationship?: RelationshipValue; +} diff --git a/src/models/service/Service.model.ts b/src/models/service/Service.model.ts new file mode 100644 index 0000000..b653bdf --- /dev/null +++ b/src/models/service/Service.model.ts @@ -0,0 +1,17 @@ +import {ASBase} from "../asBase/ASBase.model"; +import {ASModelType} from "../../common/common.types"; +import {ServiceFields} from "./Service.types"; + +/** + * Represents a service of any kind + * + * {@link https://www.w3.org/ns/activitystreams#Service Docs} + */ +export class Service extends ASBase{ + constructor(fields: ServiceFields) { + super({ + type: ASModelType.Service, + ...fields + }) + } +} \ No newline at end of file diff --git a/src/models/service/Service.types.ts b/src/models/service/Service.types.ts new file mode 100644 index 0000000..a6d136f --- /dev/null +++ b/src/models/service/Service.types.ts @@ -0,0 +1,3 @@ +import {ASObjectFields} from "../asObject/ASObject.types"; + +export interface ServiceFields extends ASObjectFields {} diff --git a/src/models/tombstone/Tombstone.model.ts b/src/models/tombstone/Tombstone.model.ts new file mode 100644 index 0000000..bd05025 --- /dev/null +++ b/src/models/tombstone/Tombstone.model.ts @@ -0,0 +1,19 @@ +import {ASBase} from "../asBase/ASBase.model"; +import {ASModelType} from "../../common/common.types"; +import {TombstoneFields} from "./Tombstone.types"; + +/** + * A Tombstone represents a content object that has been deleted. + * It can be used in Collections to signify that there used to be an object + * at this position, but it has been deleted. + * + * {@link https://www.w3.org/ns/activitystreams#Tombstone Docs} + */ +export class Tombstone extends ASBase{ + constructor(fields: TombstoneFields) { + super({ + type: ASModelType.Tombstone, + ...fields + }) + } +} \ No newline at end of file diff --git a/src/models/tombstone/Tombstone.types.ts b/src/models/tombstone/Tombstone.types.ts new file mode 100644 index 0000000..85cf959 --- /dev/null +++ b/src/models/tombstone/Tombstone.types.ts @@ -0,0 +1,23 @@ +import {DeletedValue, FormerTypeValue} from "../../common/common.types"; +import {ASObjectFields} from "../asObject/ASObject.types"; + +export interface TombstoneFields extends ASObjectFields { + + /** + * On a Tombstone object, the formerType property identifies + * the type of the object that was deleted. + * + * {@link https://www.w3.org/ns/activitystreams#formerType Docs} + */ + formerType?: FormerTypeValue; + + /** + * On a Tombstone object, the deleted property is a timestamp + * for when the object was deleted. + * + * If time must be specified - use {@link https://www.w3schools.blog/xsd-date-and-time-data-types xsd:dateTime} + * + * {@link https://www.w3.org/ns/activitystreams#deleted Docs} + */ + deleted?: DeletedValue; +} diff --git a/src/models/video/Video.model.ts b/src/models/video/Video.model.ts new file mode 100644 index 0000000..ee61b45 --- /dev/null +++ b/src/models/video/Video.model.ts @@ -0,0 +1,17 @@ +import {ASBase} from "../asBase/ASBase.model"; +import {ASModelType} from "../../common/common.types"; +import {VideoFields} from "./Video.types"; + +/** + * Represents a video document of any kind + * + * {@link https://www.w3.org/ns/activitystreams#Video Docs} + */ +export class Video extends ASBase{ + constructor(fields: VideoFields) { + super({ + type: ASModelType.Video, + ...fields + }) + } +} \ No newline at end of file diff --git a/src/models/video/Video.types.ts b/src/models/video/Video.types.ts new file mode 100644 index 0000000..d498881 --- /dev/null +++ b/src/models/video/Video.types.ts @@ -0,0 +1,3 @@ +import { DocumentFields } from "../document/Document.types"; + +export interface VideoFields extends DocumentFields {} \ No newline at end of file