Add Collection, CollectionPage, OrderedCollection and OrderedCollectionPage types

pull/1/head
SiRanWeb 2022-10-30 23:19:59 +03:00
rodzic 84a8dc7396
commit 6b9dacb046
9 zmienionych plików z 263 dodań i 4 usunięć

Wyświetl plik

@ -23,8 +23,14 @@ export enum ASModelType {
Profile = 'Profile',
Link = 'Link',
Mention = 'Mention',
Collection = 'Collection',
CollectionPage = 'CollectionPage',
OrderedCollection = 'OrderedCollection',
OrderedCollectionPage = 'OrderedCollectionPage',
}
export type Modify<T, R> = Omit<T, keyof R> & 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;
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;

Wyświetl plik

@ -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<CollectionFields>{
constructor(fields: CollectionFields) {
super({
type: ASModelType.Collection,
...fields
})
}
}

Wyświetl plik

@ -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[];
}

Wyświetl plik

@ -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<CollectionPageFields>{
constructor(fields: CollectionPageFields) {
super({
type: ASModelType.CollectionPage,
...fields
})
}
}

Wyświetl plik

@ -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;
}

Wyświetl plik

@ -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<OrderedCollectionFields>{
constructor(fields: OrderedCollectionFields) {
super({
type: ASModelType.OrderedCollection,
...fields
})
}
}

Wyświetl plik

@ -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<CollectionFields, {
/**
* In a paged OrderedCollection, indicates the page that contains
* the most recently updated member items.
*
* {@link https://www.w3.org/ns/activitystreams#current Docs}
*/
current?: OrderedCollectionCurrentValue;
/**
* In a paged OrderedCollection, indicates the furthest proceeding
* page of items in the collection.
*
* {@link https://www.w3.org/ns/activitystreams#first Docs}
*/
first?: OrderedCollectionFirstValue;
/**
* In a paged OrderedCollection, indicates the furthest proceeding
* page of the collection.
*
* {@link https://www.w3.org/ns/activitystreams#last Docs}
*/
last?: OrderedCollectionLastValue;
/**
* Identifies the items contained in a collection.
* The items might be ordered or unordered.
*
* {@link https://www.w3.org/ns/activitystreams#items Docs}
*/
items?: OrderedCollectionItemsValue[];
}> {}

Wyświetl plik

@ -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<OrderedCollectionPageFields>{
constructor(fields: OrderedCollectionPageFields) {
super({
type: ASModelType.OrderedCollectionPage,
...fields
})
}
}

Wyświetl plik

@ -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<CollectionPageFields, {
/**
* Identifies the OrderedCollection to which a OrderedCollectionPage objects items belong.
*
* {@link https://www.w3.org/ns/activitystreams#partOf Docs}
*/
partOf?: OrderedCollectionPagePartOfValue;
/**
* In a paged OrderedCollection, indicates the next page of items.
*
* {@link https://www.w3.org/ns/activitystreams#next Docs}
*/
next?: OrderedCollectionPageNextValue;
/**
* In a paged OrderedCollection, identifies the previous page of items.
*
* {@link https://www.w3.org/ns/activitystreams#prev Docs}
*/
prev?: OrderedCollectionPagePrevValue;
}> {
/**
* 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;
}