kopia lustrzana https://github.com/activitypub-js/activitypub-models
Add Link types and refactor
rodzic
edbe1b0990
commit
cab0bccbef
|
@ -20,6 +20,8 @@ export enum ASModelType {
|
||||||
Relationship = 'Relationship',
|
Relationship = 'Relationship',
|
||||||
Question = 'Question',
|
Question = 'Question',
|
||||||
Tombstone = 'Tombstone',
|
Tombstone = 'Tombstone',
|
||||||
|
Profile = 'Profile',
|
||||||
|
Link = 'Link',
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: implement
|
// TODO: implement
|
||||||
|
@ -41,13 +43,15 @@ export type Collection = 'placeholder';
|
||||||
export type AnyCollection = Collection;
|
export type AnyCollection = Collection;
|
||||||
export type AnyASObject = ASObject | Article | Audio | Document | Event | Image | Note | Page | Place | Profile | Relationship | Tombstone | Video;
|
export type AnyASObject = ASObject | Article | Audio | Document | Event | Image | Note | Page | Place | Profile | Relationship | Tombstone | Video;
|
||||||
export type DateTime = string;
|
export type DateTime = string;
|
||||||
|
export type LanguageTag = string;
|
||||||
|
export type MediaType = string;
|
||||||
export type Duration = string;
|
export type Duration = string;
|
||||||
export type UrlValue = string | Link;
|
export type UrlValue = string | Link;
|
||||||
export type IdValue = string;
|
export type IdValue = string;
|
||||||
export type TypeValue = string;
|
export type TypeValue = string;
|
||||||
export type ContentValue = string;
|
export type ContentValue = string;
|
||||||
export type ContentMapValue = Record<string, string>;
|
export type ContentMapValue = Record<string, string>;
|
||||||
export type MediaTypeValue = string;
|
export type MediaTypeValue = MediaType;
|
||||||
export type NameValue = string;
|
export type NameValue = string;
|
||||||
export type NameMapValue = Record<string, string>;
|
export type NameMapValue = Record<string, string>;
|
||||||
export type SummaryValue = string;
|
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 ClosedValue = string | AnyASObject | Link | DateTime | boolean;
|
||||||
export type FormerTypeValue = string;
|
export type FormerTypeValue = string;
|
||||||
export type DeletedValue = DateTime;
|
export type DeletedValue = DateTime;
|
||||||
export type DescribesValue = string | AnyASObject;
|
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;
|
|
@ -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<LinkFields>{
|
|
||||||
constructor(fields: LinkFields) {
|
|
||||||
super(fields);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -92,7 +92,6 @@ export interface ASObjectFields {
|
||||||
*/
|
*/
|
||||||
contentMap?: ContentMapValue;
|
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.
|
* 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.
|
* If not specified, the content property is assumed to contain text/html content.
|
||||||
|
|
|
@ -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<LinkFields>{
|
||||||
|
constructor(fields: LinkFields) {
|
||||||
|
super({
|
||||||
|
type: ASModelType.Link,
|
||||||
|
...fields
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
|
@ -3,16 +3,16 @@ import {ASModelType} from "../../common/common.types";
|
||||||
import {ProfileFields} from "./Profile.types";
|
import {ProfileFields} from "./Profile.types";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Tombstone represents a content object that has been deleted.
|
* A Profile is a content object that describes another Object,
|
||||||
* It can be used in Collections to signify that there used to be an object
|
* typically used to describe Actor Type objects. The describes property
|
||||||
* at this position, but it has been deleted.
|
* 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<ProfileFields>{
|
export class Profile extends ASBase<ProfileFields>{
|
||||||
constructor(fields: ProfileFields) {
|
constructor(fields: ProfileFields) {
|
||||||
super({
|
super({
|
||||||
type: ASModelType.Tombstone,
|
type: ASModelType.Profile,
|
||||||
...fields
|
...fields
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue