kopia lustrzana https://github.com/activitypub-js/activitypub-models
Add Place, Question and Relationship types
rodzic
a7ff21a4ef
commit
29dcbc67ad
|
@ -16,6 +16,9 @@ export enum ASModelType {
|
|||
Image = 'Image',
|
||||
Page = 'Page',
|
||||
Video = 'Video',
|
||||
Place = 'Place',
|
||||
Relationship = 'Relationship',
|
||||
Question = 'Question',
|
||||
}
|
||||
|
||||
// TODO: implement
|
||||
|
@ -38,6 +41,7 @@ export type AnyASObject = ASObject | Article | Audio | Document | Event | Image
|
|||
export type DateTime = string;
|
||||
export type Duration = string;
|
||||
export type UrlValue = string | Link;
|
||||
export type RelationshipValue = string | AnyASObject;
|
||||
export type IconValue = string | Image | Link;
|
||||
export type ImageValue = string | Image | Link;
|
||||
export type AttachmentValue = string | AnyASObject | Link;
|
||||
|
@ -58,3 +62,13 @@ export type TargetValue = string | AnyASObject | Link;
|
|||
export type ResultValue = string | AnyASObject | Link;
|
||||
export type OriginValue = string | AnyASObject | Link;
|
||||
export type InstrumentValue = string | AnyASObject | Link;
|
||||
export type OneOfValue = string | AnyASObject | Link;
|
||||
export type AnyOfValue = string | AnyASObject | Link;
|
||||
export type SubjectValue = string | AnyASObject | Link;
|
||||
export type AccuracyValue = number;
|
||||
export type AltitudeValue = number;
|
||||
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;
|
|
@ -0,0 +1,19 @@
|
|||
import {ASBase} from "../ASBase.model";
|
||||
import {ASModelType} from "../../common/common.types";
|
||||
import {PlaceFields} from "./Place.types";
|
||||
|
||||
/**
|
||||
* Represents a logical or physical location. See
|
||||
* {@link https://www.w3.org/TR/activitystreams-vocabulary/#places 5.3 Representing Places}
|
||||
* for additional information.
|
||||
*
|
||||
* {@link https://www.w3.org/ns/activitystreams#Place Docs}
|
||||
*/
|
||||
export class Place extends ASBase<PlaceFields>{
|
||||
constructor(fields: PlaceFields) {
|
||||
super({
|
||||
type: ASModelType.Place,
|
||||
...fields
|
||||
})
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
import {ASObjectFields} from "../asObject/ASObject.types";
|
||||
import {
|
||||
AccuracyValue,
|
||||
AltitudeValue,
|
||||
LatitudeValue,
|
||||
LongitudeValue,
|
||||
RadiusValue,
|
||||
UnitsValue
|
||||
} from "../../common/common.types";
|
||||
|
||||
|
||||
export interface PlaceFields extends ASObjectFields {
|
||||
|
||||
/**
|
||||
* Indicates the accuracy of position coordinates on a Place objects.
|
||||
* Expressed in properties of percentage. e.g. "94.0" means "94.0% accurate".
|
||||
*
|
||||
* {@link https://www.w3.org/ns/activitystreams#accuracy Docs}
|
||||
*/
|
||||
accuracy?: AccuracyValue;
|
||||
|
||||
/**
|
||||
* Indicates the altitude of a place. The measurement units is indicated using the "units" property.
|
||||
* If units is not specified, the default is assumed to be "m" indicating "meters".
|
||||
*
|
||||
* {@link https://www.w3.org/ns/activitystreams#altitude Docs}
|
||||
*/
|
||||
altitude?: AltitudeValue;
|
||||
|
||||
/**
|
||||
* The latitude of a place
|
||||
*
|
||||
* {@link https://www.w3.org/ns/activitystreams#latitude Docs}
|
||||
*/
|
||||
latitude?: LatitudeValue;
|
||||
|
||||
/**
|
||||
* The longitude of a place
|
||||
*
|
||||
* {@link https://www.w3.org/ns/activitystreams#longitude Docs}
|
||||
*/
|
||||
longitude?: LongitudeValue;
|
||||
|
||||
/**
|
||||
* The radius from the given latitude and longitude for a Place.
|
||||
* The units are expressed by the "units" property. If units is not specified,
|
||||
* the default is assumed to be "m" indicating "meters".
|
||||
*
|
||||
* {@link https://www.w3.org/ns/activitystreams#radius Docs}
|
||||
*/
|
||||
radius?: RadiusValue;
|
||||
|
||||
/**
|
||||
* Specifies the measurement units for the radius and altitude properties
|
||||
* on a Place object. If not specified, the default is assumed to be "m" for "meters".
|
||||
*
|
||||
* {@link https://www.w3.org/ns/activitystreams#units Docs}
|
||||
*/
|
||||
units?: UnitsValue;
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
import {ASBase} from "../ASBase.model";
|
||||
import {ASModelType} from "../../common/common.types";
|
||||
import {QuestionFields} from "./Question.types";
|
||||
|
||||
/**
|
||||
* Represents a question being asked. Question objects are an extension
|
||||
* of IntransitiveActivity. That is, the Question object is an Activity,
|
||||
* but the direct object is the question itself, and therefore it would
|
||||
* not contain an object property.
|
||||
*
|
||||
* Either of the anyOf and oneOf properties MAY be used to express possible
|
||||
* answers, but a Question object MUST NOT have both properties.
|
||||
*
|
||||
* {@link https://www.w3.org/ns/activitystreams#Question Docs}
|
||||
*/
|
||||
export class Question extends ASBase<QuestionFields>{
|
||||
constructor(fields: QuestionFields) {
|
||||
super({
|
||||
type: ASModelType.Question,
|
||||
...fields
|
||||
})
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
import {IntransitiveActivityFields} from "../intransitiveActivity/IntransitiveActivity.types";
|
||||
import {AnyOfValue, ClosedValue, OneOfValue} from "../../common/common.types";
|
||||
|
||||
export interface QuestionFields extends IntransitiveActivityFields {
|
||||
|
||||
// TODO: only oneOf or anyOf at one time
|
||||
/**
|
||||
* Identifies an exclusive option for a Question.
|
||||
* Use of oneOf implies that the Question can have only a single answer.
|
||||
* To indicate that a Question can have multiple answers, use anyOf.
|
||||
*
|
||||
* {@link https://www.w3.org/ns/activitystreams#oneOf Docs}
|
||||
*/
|
||||
oneOf?: OneOfValue[];
|
||||
|
||||
/**
|
||||
* Identifies an inclusive option for a Question.
|
||||
* Use of anyOf implies that the Question can have multiple answers.
|
||||
* To indicate that a Question can have only one answer, use oneOf.
|
||||
*
|
||||
* {@link https://www.w3.org/ns/activitystreams#anyOf Docs}
|
||||
*/
|
||||
anyOf?: AnyOfValue[];
|
||||
|
||||
/**
|
||||
* Indicates that a question has been closed, and answers are no longer accepted.
|
||||
*
|
||||
* {@link https://www.w3.org/ns/activitystreams#closed Docs}
|
||||
*/
|
||||
closed?: ClosedValue;
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
import {ASBase} from "../ASBase.model";
|
||||
import {ASModelType} from "../../common/common.types";
|
||||
import {RelationshipFields} from "./Relationship.types";
|
||||
|
||||
/**
|
||||
* Describes a relationship between two individuals. The subject and
|
||||
* object properties are used to identify the connected individuals.
|
||||
* See {@link https://www.w3.org/TR/activitystreams-vocabulary/#connections 5.2 Representing Relationships Between Entities}
|
||||
* for additional information.
|
||||
*
|
||||
* {@link https://www.w3.org/ns/activitystreams#Relationship Docs}
|
||||
*/
|
||||
export class Relationship extends ASBase<RelationshipFields>{
|
||||
constructor(fields: RelationshipFields) {
|
||||
super({
|
||||
type: ASModelType.Relationship,
|
||||
...fields
|
||||
})
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
import {ASObjectFields} from "../asObject/ASObject.types";
|
||||
import {SubjectValue, ObjectValue, RelationshipValue} from "../../common/common.types";
|
||||
|
||||
export interface RelationshipFields extends ASObjectFields {
|
||||
|
||||
/**
|
||||
* On a Relationship object, the subject property identifies one of the connected individuals.
|
||||
* For instance, for a Relationship object describing "John is related to Sally",
|
||||
* subject would refer to John.
|
||||
*
|
||||
* {@link https://www.w3.org/ns/activitystreams#subject Docs}
|
||||
*/
|
||||
subject?: SubjectValue;
|
||||
|
||||
/**
|
||||
* When used within a Relationship describes the entity to which the subject is related.
|
||||
*
|
||||
* {@link https://www.w3.org/ns/activitystreams#object Docs}
|
||||
*/
|
||||
object?: ObjectValue | ObjectValue[];
|
||||
|
||||
/**
|
||||
* On a Relationship object, the relationship property
|
||||
* identifies the kind of relationship that exists between subject and object.
|
||||
*
|
||||
* {@link https://www.w3.org/ns/activitystreams#relationship Docs}
|
||||
*/
|
||||
relationship?: RelationshipValue;
|
||||
}
|
Ładowanie…
Reference in New Issue