Add Profile and Tombstone types. Refactor ASObject types

pull/1/head
SiRanWeb 2022-10-30 17:59:13 +03:00
rodzic 29dcbc67ad
commit edbe1b0990
6 zmienionych plików z 117 dodań i 15 usunięć

Wyświetl plik

@ -19,6 +19,7 @@ export enum ASModelType {
Place = 'Place',
Relationship = 'Relationship',
Question = 'Question',
Tombstone = 'Tombstone',
}
// TODO: implement
@ -37,10 +38,25 @@ export type Video = 'placeholder';
export type Mention = 'placeholder';
export type Link = '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 DateTime = string;
export type Duration = string;
export type UrlValue = string | Link;
export type IdValue = string;
export type TypeValue = string;
export type ContentValue = string;
export type ContentMapValue = Record<string, string>;
export type MediaTypeValue = string;
export type NameValue = string;
export type NameMapValue = Record<string, string>;
export type SummaryValue = string;
export type SummaryMapValue = Record<string, string>;
export type EndTimeValue = DateTime;
export type StartTimeValue = DateTime;
export type PublishedValue = DateTime;
export type UpdatedValue = DateTime;
export type RepliesValue = AnyCollection | string;
export type RelationshipValue = string | AnyASObject;
export type IconValue = string | Image | Link;
export type ImageValue = string | Image | Link;
@ -71,4 +87,7 @@ 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 ClosedValue = string | AnyASObject | Link | DateTime | boolean;
export type FormerTypeValue = string;
export type DeletedValue = DateTime;
export type DescribesValue = string | AnyASObject;

Wyświetl plik

@ -17,6 +17,14 @@ import {
TagValue,
GeneratorValue,
Collection,
IdValue,
TypeValue,
ContentValue,
ContentMapValue,
MediaTypeValue,
NameValue,
NameMapValue,
EndTimeValue, StartTimeValue, PublishedValue, RepliesValue, SummaryValue, SummaryMapValue, UpdatedValue,
} from "../../common/common.types";
export interface ASObjectFields {
@ -26,7 +34,7 @@ export interface ASObjectFields {
*
* {@link https://www.w3.org/TR/activitystreams-vocabulary/#dfn-object Docs (@id)}
*/
id?: string;
id?: IdValue;
/**
* Identifies the {@link https://www.w3.org/TR/activitystreams-vocabulary/#dfn-object Object}
@ -34,7 +42,7 @@ export interface ASObjectFields {
*
* {@link https://www.w3.org/TR/activitystreams-vocabulary/#dfn-object Docs (@type)}
*/
type?: string | string[];
type?: TypeValue | TypeValue[];
/**
* Identifies resources attached or related to an object that potentially requires special handling.
@ -72,7 +80,7 @@ export interface ASObjectFields {
*
* {@link https://www.w3.org/ns/activitystreams#content Docs}
*/
content?: string;
content?: ContentValue;
/**
* The content or textual representation of the Object encoded as a JSON string.
@ -82,7 +90,7 @@ export interface ASObjectFields {
*
* {@link https://www.w3.org/ns/activitystreams#content Docs}
*/
contentMap?: Record<string, string | undefined>;
contentMap?: ContentMapValue;
// TODO: make type as MIME Media Type
/**
@ -92,7 +100,7 @@ export interface ASObjectFields {
*
* {@link https://www.w3.org/ns/activitystreams#mediaType Docs}
*/
mediaType?: string;
mediaType?: MediaTypeValue;
// TODO: only name or nameMap at one time
@ -103,7 +111,7 @@ export interface ASObjectFields {
*
* {@link https://www.w3.org/ns/activitystreams#name Docs}
*/
name?: string;
name?: NameValue;
/**
* A simple, human-readable, plain-text name for the object.
@ -112,7 +120,7 @@ export interface ASObjectFields {
*
* {@link https://www.w3.org/ns/activitystreams#name Docs}
*/
nameMap?: Record<string, string | undefined>;
nameMap?: NameMapValue;
/**
* The date and time describing the actual or expected ending time of the object.
@ -130,7 +138,7 @@ export interface ASObjectFields {
* 2020-08-08T08:30:11
* 2020-08-08
*/
endTime?: DateTime;
endTime?: EndTimeValue;
/**
* The date and time describing the actual or expected starting time of the object.
@ -148,7 +156,7 @@ export interface ASObjectFields {
* 2020-08-08T08:30:11
* 2020-08-08
*/
startTime?: DateTime;
startTime?: StartTimeValue;
/**
* Identifies the entity (e.g. an application) that generated the object.
@ -209,14 +217,14 @@ export interface ASObjectFields {
* 2020-08-08T08:30:11
* 2020-08-08
*/
published?: DateTime;
published?: PublishedValue;
/**
* Identifies a Collection containing objects considered to be responses to this object.
*
* {@link https://www.w3.org/ns/activitystreams#replies Docs}
*/
replies?: Collection;
replies?: RepliesValue;
// TODO: only summary or summaryMap at one time
@ -227,7 +235,7 @@ export interface ASObjectFields {
*
* {@link https://www.w3.org/ns/activitystreams#summary Docs}
*/
summary?: string;
summary?: SummaryValue;
/**
* A natural language summarization of the object encoded as HTML.
@ -236,7 +244,7 @@ export interface ASObjectFields {
*
* {@link https://www.w3.org/ns/activitystreams#summary Docs}
*/
summaryMap?: Record<string, string | undefined>;
summaryMap?: SummaryMapValue;
/**
* One or more "tags" that have been associated with an objects. A tag can be any kind of Object.
@ -261,7 +269,7 @@ export interface ASObjectFields {
* 2020-08-08T08:30:11
* 2020-08-08
*/
updated?: DateTime;
updated?: UpdatedValue;
/**
* Identifies one or more links to representations of the object.

Wyświetl plik

@ -0,0 +1,19 @@
import {ASBase} from "../ASBase.model";
import {ASModelType} from "../../common/common.types";
import {ProfileFields} from "./Profile.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<ProfileFields>{
constructor(fields: ProfileFields) {
super({
type: ASModelType.Tombstone,
...fields
})
}
}

Wyświetl plik

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

Wyświetl plik

@ -0,0 +1,19 @@
import {ASBase} from "../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<TombstoneFields>{
constructor(fields: TombstoneFields) {
super({
type: ASModelType.Tombstone,
...fields
})
}
}

Wyświetl plik

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