diff --git a/src/common/common.types.ts b/src/common/common.types.ts index 6ac0c38..23c93f6 100644 --- a/src/common/common.types.ts +++ b/src/common/common.types.ts @@ -20,6 +20,8 @@ export enum ASModelType { Relationship = 'Relationship', Question = 'Question', Tombstone = 'Tombstone', + Profile = 'Profile', + Link = 'Link', } // TODO: implement @@ -41,13 +43,15 @@ 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 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 ContentValue = string; export type ContentMapValue = Record; -export type MediaTypeValue = string; +export type MediaTypeValue = MediaType; export type NameValue = string; export type NameMapValue = Record; export type SummaryValue = string; @@ -90,4 +94,9 @@ export type UnitsValue = 'cm' | 'feet' | 'inches' | 'km' | 'm' | 'miles' | strin export type ClosedValue = string | AnyASObject | Link | DateTime | boolean; export type FormerTypeValue = string; export type DeletedValue = DateTime; -export type DescribesValue = string | AnyASObject; \ No newline at end of file +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; \ 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 aaa3261..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?: string; - 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/asObject/ASObject.types.ts b/src/models/asObject/ASObject.types.ts index a27d4a1..76e99e3 100644 --- a/src/models/asObject/ASObject.types.ts +++ b/src/models/asObject/ASObject.types.ts @@ -92,7 +92,6 @@ export interface ASObjectFields { */ contentMap?: ContentMapValue; - // TODO: make type as MIME Media Type /** * 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. diff --git a/src/models/link/Link.model.ts b/src/models/link/Link.model.ts new file mode 100644 index 0000000..5995dd1 --- /dev/null +++ b/src/models/link/Link.model.ts @@ -0,0 +1,12 @@ +import {ASBase} from "../ASBase.model"; +import { LinkFields } from "./Link.types"; +import {ASModelType} from "../../common/common.types"; + +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/profile/Profile.model.ts b/src/models/profile/Profile.model.ts index 4f0747a..8ed4159 100644 --- a/src/models/profile/Profile.model.ts +++ b/src/models/profile/Profile.model.ts @@ -3,16 +3,16 @@ 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. + * 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#Tombstone Docs} + * {@link https://www.w3.org/ns/activitystreams#Profile Docs} */ -export class Tombstone extends ASBase{ +export class Profile extends ASBase{ constructor(fields: ProfileFields) { super({ - type: ASModelType.Tombstone, + type: ASModelType.Profile, ...fields }) }