diff --git a/src/common/common.types.ts b/src/common/common.types.ts index 1012ab0..8944646 100644 --- a/src/common/common.types.ts +++ b/src/common/common.types.ts @@ -23,8 +23,14 @@ export enum ASModelType { Profile = 'Profile', Link = 'Link', Mention = 'Mention', + Collection = 'Collection', + CollectionPage = 'CollectionPage', + OrderedCollection = 'OrderedCollection', + OrderedCollectionPage = 'OrderedCollectionPage', } +export type Modify = Omit & R; + // TODO: implement export type Image = 'placeholder'; export type Article = 'placeholder'; @@ -40,9 +46,12 @@ export type Tombstone = 'placeholder'; export type Video = 'placeholder'; export type Mention = 'placeholder'; export type Link = 'placeholder'; +export type OrderedCollection = 'placeholder'; export type Collection = 'placeholder'; -export type AnyCollection = Collection; -export type AnyASObject = ASObject | Article | Audio | Document | Event | Image | Note | Page | Place | Profile | Relationship | Tombstone | Video; +export type CollectionPage = 'placeholder'; +export type OrderedCollectionPage = 'placeholder'; +export type AnyCollection = Collection | OrderedCollection; +export type AnyASObject = ASObject | Article | Audio | Document | Event | Image | Note | Page | Place | Profile | Relationship | Tombstone | Video | AnyCollection; export type DateTime = string; export type LanguageTag = string; export type MediaType = string; @@ -61,7 +70,7 @@ export type EndTimeValue = DateTime; export type StartTimeValue = DateTime; export type PublishedValue = DateTime; export type UpdatedValue = DateTime; -export type RepliesValue = AnyCollection | string; +export type RepliesValue = string | AnyCollection; export type RelationshipValue = string | AnyASObject; export type IconValue = string | Image | Link; export type ImageValue = string | Image | Link; @@ -100,4 +109,20 @@ export type HrefValue = string; export type HreflangValue = LanguageTag; export type RelValue = string; export type HeightValue = number; -export type WidthValue = number; \ No newline at end of file +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/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/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..4c339cb --- /dev/null +++ b/src/models/orderedCollection/OrderedCollection.types.ts @@ -0,0 +1,42 @@ +import { + Modify, + OrderedCollectionCurrentValue, + OrderedCollectionFirstValue, OrderedCollectionItemsValue, + OrderedCollectionLastValue +} from "../../common/common.types"; +import {CollectionFields} from "../collection/Collection.types"; + +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..8535795 --- /dev/null +++ b/src/models/orderedCollectionPage/OrderedCollectionPage.types.ts @@ -0,0 +1,45 @@ +import {OrderedCollectionFields} from "../orderedCollection/OrderedCollection.types"; +import { + Modify, + OrderedCollectionPageNextValue, + OrderedCollectionPagePartOfValue, + OrderedCollectionPagePrevValue, + StartIndexValue +} from "../../common/common.types"; +import {CollectionPageFields} from "../collectionPage/CollectionPage.types"; + +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; +}