diff --git a/src/common/common.types.ts b/src/common/common.types.ts index c43b453..d77d529 100644 --- a/src/common/common.types.ts +++ b/src/common/common.types.ts @@ -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; @@ -57,4 +61,14 @@ export type ActorValue = string | AnyASObject | Link; export type TargetValue = string | AnyASObject | Link; export type ResultValue = string | AnyASObject | Link; export type OriginValue = string | AnyASObject | Link; -export type InstrumentValue = string | AnyASObject | Link; \ No newline at end of file +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; \ No newline at end of file diff --git a/src/models/place/Place.model.ts b/src/models/place/Place.model.ts new file mode 100644 index 0000000..104bea0 --- /dev/null +++ b/src/models/place/Place.model.ts @@ -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{ + constructor(fields: PlaceFields) { + super({ + type: ASModelType.Place, + ...fields + }) + } +} \ No newline at end of file diff --git a/src/models/place/Place.types.ts b/src/models/place/Place.types.ts new file mode 100644 index 0000000..cb6c65e --- /dev/null +++ b/src/models/place/Place.types.ts @@ -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; +} diff --git a/src/models/question/Question.model.ts b/src/models/question/Question.model.ts new file mode 100644 index 0000000..2b721f3 --- /dev/null +++ b/src/models/question/Question.model.ts @@ -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{ + constructor(fields: QuestionFields) { + super({ + type: ASModelType.Question, + ...fields + }) + } +} \ No newline at end of file diff --git a/src/models/question/Question.types.ts b/src/models/question/Question.types.ts new file mode 100644 index 0000000..c19d045 --- /dev/null +++ b/src/models/question/Question.types.ts @@ -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; +} diff --git a/src/models/relationship/Relationship.model.ts b/src/models/relationship/Relationship.model.ts new file mode 100644 index 0000000..9ff8031 --- /dev/null +++ b/src/models/relationship/Relationship.model.ts @@ -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{ + constructor(fields: RelationshipFields) { + super({ + type: ASModelType.Relationship, + ...fields + }) + } +} \ No newline at end of file diff --git a/src/models/relationship/Relationship.types.ts b/src/models/relationship/Relationship.types.ts new file mode 100644 index 0000000..64d697a --- /dev/null +++ b/src/models/relationship/Relationship.types.ts @@ -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; +}