From 71a645064e4ed982f2cd64597cd95d243136fcaa Mon Sep 17 00:00:00 2001 From: Madeline <46743919+MaddyUnderStars@users.noreply.github.com> Date: Fri, 29 Sep 2023 11:33:45 +1000 Subject: [PATCH] type guards --- .prettierrc.json | 11 + package.json | 2 +- src/fields/index.ts | 132 +++- src/index.ts | 4 +- .../activities/accept.interface.ts | 10 +- .../activities/activity.interface.ts | 111 ++- .../activities/add.interface.ts | 8 +- .../activities/announce.interface.ts | 10 +- .../activities/arrive.interface.ts | 10 +- .../activities/block.interface.ts | 9 +- .../activities/create.interface.ts | 10 +- .../activities/delete.interface.ts | 10 +- .../activities/dislike.interface.ts | 10 +- .../activities/flag.interface.ts | 8 +- .../activities/follow.interface.ts | 10 +- .../activities/ignore.interface.ts | 10 +- .../intransitive-activity.interface.ts | 4 +- .../activities/invite.interface.ts | 10 +- .../activities/join.interface.ts | 8 +- .../activities/leave.interface.ts | 8 +- .../activities/like.interface.ts | 8 +- .../activities/listen.interface.ts | 10 +- .../activities/move.interface.ts | 8 +- .../activities/offer.interface.ts | 8 +- .../activities/question.interface.ts | 55 +- .../activities/read.interface.ts | 8 +- .../activities/reject.interface.ts | 10 +- .../activities/remove.interface.ts | 10 +- .../activities/tentative-accept.interface.ts | 10 +- .../activities/tentative-reject.interface.ts | 10 +- .../activities/travel.interface.ts | 10 +- .../activities/undo.interface.ts | 8 +- .../activities/update.interface.ts | 10 +- .../activities/view.interface.ts | 8 +- .../actors/actor.interface.ts | 195 +++-- .../actors/application.interface.ts | 8 +- .../actors/group.interface.ts | 8 +- .../actors/organization.interface.ts | 10 +- .../actors/person.interface.ts | 8 +- .../actors/service.interface.ts | 8 +- .../collections/collection-page.interface.ts | 45 +- .../collections/collection.interface.ts | 86 +-- .../ordered-collection-page.interface.ts | 62 +- .../ordered-collection.interface.ts | 85 +- .../common/article.interface.ts | 8 +- .../common/event.interface.ts | 8 +- src/model-interfaces/common/link.interface.ts | 171 ++-- .../common/mention.interface.ts | 9 +- src/model-interfaces/common/note.interface.ts | 8 +- .../common/object.interface.ts | 729 +++++++++--------- .../common/place.interface.ts | 114 +-- .../common/profile.interface.ts | 23 +- .../common/relationship.interface.ts | 53 +- .../common/tombstone.interface.ts | 41 +- .../documents/audio.interface.ts | 8 +- .../documents/document.interface.ts | 8 +- .../documents/image.interface.ts | 8 +- .../documents/page.interface.ts | 8 +- .../documents/video.interface.ts | 8 +- src/model-interfaces/index.ts | 110 +-- 60 files changed, 1349 insertions(+), 1048 deletions(-) create mode 100644 .prettierrc.json diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..8e34d43 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,11 @@ +{ + "trailingComma": "all", + "tabWidth": 4, + "semi": true, + "arrowParens": "always", + "bracketSameLine": false, + "bracketSpacing": true, + "quoteProps": "as-needed", + "useTabs": true, + "singleQuote": false +} \ No newline at end of file diff --git a/package.json b/package.json index 9effa26..586bf1a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "activitypub-types", - "version": "1.0.4", + "version": "1.1.0", "description": "ActivityPub Typescript types", "main": "./dist/index.js", "scripts": { diff --git a/src/fields/index.ts b/src/fields/index.ts index 263aaa1..fe3f671 100644 --- a/src/fields/index.ts +++ b/src/fields/index.ts @@ -1,27 +1,41 @@ import { - APCollection, - APOrderedCollection, - APObject, - APArticle, - APAudio, - APDocument, - APEvent, - APImage, - APNote, - APPage, - APPlace, - APProfile, - APRelationship, - APTombstone, - APVideo, - APLink, - APCollectionPage, - APOrderedCollectionPage, - APMention, -} from '../model-interfaces'; + APArticle, + APAudio, + APCollection, + APCollectionPage, + APDocument, + APEvent, + APImage, + APLink, + APMention, + APNote, + APObject, + APOrderedCollection, + APOrderedCollectionPage, + APPage, + APPlace, + APProfile, + APRelationship, + APTombstone, + APVideo, +} from "../model-interfaces"; export type AnyCollection = APCollection | APOrderedCollection; -export type AnyAPObject = APObject | APArticle | APAudio | APDocument | APEvent | APImage | APNote | APPage | APPlace | APProfile | APRelationship | APTombstone | APVideo | AnyCollection; +export type AnyAPObject = + | APObject + | APArticle + | APAudio + | APDocument + | APEvent + | APImage + | APNote + | APPage + | APPlace + | APProfile + | APRelationship + | APTombstone + | APVideo + | AnyCollection; export type DateTime = string | Date; export type LanguageTag = string; @@ -74,7 +88,14 @@ export type AltitudeField = number; export type LatitudeField = number; export type LongitudeField = number; export type RadiusField = number; -export type UnitsField = 'cm' | 'feet' | 'inches' | 'km' | 'm' | 'miles' | string; +export type UnitsField = + | "cm" + | "feet" + | "inches" + | "km" + | "m" + | "miles" + | string; export type ClosedField = string | AnyAPObject | APLink | DateTime | boolean; export type FormerTypeField = string; export type DeletedField = DateTime; @@ -92,22 +113,51 @@ export type CollectionItemsField = string | APCollectionPage | APLink; export type CollectionPagePartOfField = string | APCollection | APLink; export type CollectionPageNextField = string | APCollection | APLink; export type CollectionPagePrevField = string | APCollection | APLink; -export type OrderedCollectionCurrentField = string | APOrderedCollectionPage | APLink; -export type OrderedCollectionFirstField = string | APOrderedCollectionPage | APLink; -export type OrderedCollectionLastField = string | APOrderedCollectionPage | APLink; -export type OrderedCollectionItemsField = string | APOrderedCollectionPage | APLink; -export type OrderedCollectionPagePartOfField = string | APOrderedCollection | APLink; -export type OrderedCollectionPageNextField = string | APOrderedCollection | APLink; -export type OrderedCollectionPagePrevField = string | APOrderedCollection | APLink; +export type OrderedCollectionCurrentField = + | string + | APOrderedCollectionPage + | APLink; +export type OrderedCollectionFirstField = + | string + | APOrderedCollectionPage + | APLink; +export type OrderedCollectionLastField = + | string + | APOrderedCollectionPage + | APLink; +export type OrderedCollectionItemsField = + | string + | APOrderedCollectionPage + | APLink; +export type OrderedCollectionPagePartOfField = + | string + | APOrderedCollection + | APLink; +export type OrderedCollectionPageNextField = + | string + | APOrderedCollection + | APLink; +export type OrderedCollectionPagePrevField = + | string + | APOrderedCollection + | APLink; export type StartIndexField = number; export type SourceField = { - content: ContentField, - mediaType?: MediaType, -} + content: ContentField; + mediaType?: MediaType; +}; export type InboxField = string | APOrderedCollection | APLink; export type OutboxField = string | APOrderedCollection | APLink; -export type FollowingField = string | APCollection | APOrderedCollection | APLink; -export type FollowersField = string | APCollection | APOrderedCollection | APLink; +export type FollowingField = + | string + | APCollection + | APOrderedCollection + | APLink; +export type FollowersField = + | string + | APCollection + | APOrderedCollection + | APLink; export type LikedField = string | APCollection | APOrderedCollection | APLink; export type LikesField = string | APCollection | APOrderedCollection | APLink; export type SharesField = string | APCollection | APOrderedCollection | APLink; @@ -121,10 +171,10 @@ export type ProvideClientKeyField = string; export type SignClientKeyField = string; export type SharedInboxField = string; export type EndpointsField = { - proxyUrl?: ProxyUrlField; - oauthAuthorizationEndpoint?: OauthAuthorizationEndpointField; - oauthTokenEndpoint?: OauthTokenEndpointField; - provideClientKey?: ProvideClientKeyField; - signClientKey?: SignClientKeyField; - sharedInbox?: SharedInboxField; -} \ No newline at end of file + proxyUrl?: ProxyUrlField; + oauthAuthorizationEndpoint?: OauthAuthorizationEndpointField; + oauthTokenEndpoint?: OauthTokenEndpointField; + provideClientKey?: ProvideClientKeyField; + signClientKey?: SignClientKeyField; + sharedInbox?: SharedInboxField; +}; diff --git a/src/index.ts b/src/index.ts index 8cbac70..dfb8828 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,2 +1,2 @@ -export * from './fields'; -export * from './model-interfaces'; \ No newline at end of file +export * from "./fields"; +export * from "./model-interfaces"; diff --git a/src/model-interfaces/activities/accept.interface.ts b/src/model-interfaces/activities/accept.interface.ts index 0dbbb7e..ad4b628 100644 --- a/src/model-interfaces/activities/accept.interface.ts +++ b/src/model-interfaces/activities/accept.interface.ts @@ -1,3 +1,9 @@ -import { APActivity } from './activity.interface'; +import { APActivity } from "./activity.interface"; -export type APAccept = APActivity +export type APAccept = APActivity & { type: "Accept" }; + +export const ActivityIsAccept = ( + activity: APActivity, +): activity is APAccept => { + return activity.type == "Accept"; +}; diff --git a/src/model-interfaces/activities/activity.interface.ts b/src/model-interfaces/activities/activity.interface.ts index 225fbb0..836a7cb 100644 --- a/src/model-interfaces/activities/activity.interface.ts +++ b/src/model-interfaces/activities/activity.interface.ts @@ -1,65 +1,64 @@ -import { APObject } from '../common/object.interface'; +import { APObject } from "../common/object.interface"; import { - ActorField, - InstrumentField, - ObjectField, - OriginField, - ResultField, - TargetField -} from '../../fields'; + ActorField, + InstrumentField, + ObjectField, + OriginField, + ResultField, + TargetField, +} from "../../fields"; export interface APActivity extends APObject { + /** + * Describes one or more entities that either performed or are expected to perform the activity. + * Any single activity can have multiple actors. The actor MAY be specified using an indirect Link. + * + * {@link https://www.w3.org/ns/activitystreams#actor Docs} + */ + actor?: ActorField | ActorField[]; - /** - * Describes one or more entities that either performed or are expected to perform the activity. - * Any single activity can have multiple actors. The actor MAY be specified using an indirect Link. - * - * {@link https://www.w3.org/ns/activitystreams#actor Docs} - */ - actor?: ActorField | ActorField[]; + /** + * When used within an Activity, describes the direct object of the activity. + * For instance, in the activity "John added a movie to his wishlist", + * the object of the activity is the movie added. + * + * {@link https://www.w3.org/ns/activitystreams#object Docs} + */ + object?: ObjectField | ObjectField[]; - /** - * When used within an Activity, describes the direct object of the activity. - * For instance, in the activity "John added a movie to his wishlist", - * the object of the activity is the movie added. - * - * {@link https://www.w3.org/ns/activitystreams#object Docs} - */ - object?: ObjectField | ObjectField[]; + /** + * Describes the indirect object, or target, of the activity. The precise meaning of the target is largely dependent + * on the type of action being described but will often be the object of the English preposition "to". + * For instance, in the activity "John added a movie to his wishlist", the target of the activity + * is John's wishlist. An activity can have more than one target. + * + * {@link https://www.w3.org/ns/activitystreams#target Docs} + */ + target?: TargetField | TargetField[]; - /** - * Describes the indirect object, or target, of the activity. The precise meaning of the target is largely dependent - * on the type of action being described but will often be the object of the English preposition "to". - * For instance, in the activity "John added a movie to his wishlist", the target of the activity - * is John's wishlist. An activity can have more than one target. - * - * {@link https://www.w3.org/ns/activitystreams#target Docs} - */ - target?: TargetField | TargetField[]; + /** + * Describes the result of the activity. For instance, if a particular action results + * in the creation of a new resource, the result property can be used to describe that new resource. + * + * {@link https://www.w3.org/ns/activitystreams#result Docs} + */ + result?: ResultField | ResultField[]; - /** - * Describes the result of the activity. For instance, if a particular action results - * in the creation of a new resource, the result property can be used to describe that new resource. - * - * {@link https://www.w3.org/ns/activitystreams#result Docs} - */ - result?: ResultField | ResultField[]; + /** + * Describes an indirect object of the activity from which the activity is directed. + * The precise meaning of the origin is the object of the English preposition "from". + * For instance, in the activity "John moved an item to List B from List A", + * the origin of the activity is "List A". + * + * {@link https://www.w3.org/ns/activitystreams#origin Docs} + */ + origin?: OriginField | OriginField[]; - /** - * Describes an indirect object of the activity from which the activity is directed. - * The precise meaning of the origin is the object of the English preposition "from". - * For instance, in the activity "John moved an item to List B from List A", - * the origin of the activity is "List A". - * - * {@link https://www.w3.org/ns/activitystreams#origin Docs} - */ - origin?: OriginField | OriginField[]; - - /** - * Identifies one or more objects used (or to be used) - * in the completion of an Activity. - * - * {@link https://www.w3.org/ns/activitystreams#instrument Docs} - */ - instrument?: InstrumentField | InstrumentField[]; + /** + * Identifies one or more objects used (or to be used) + * in the completion of an Activity. + * + * {@link https://www.w3.org/ns/activitystreams#instrument Docs} + */ + instrument?: InstrumentField | InstrumentField[]; } diff --git a/src/model-interfaces/activities/add.interface.ts b/src/model-interfaces/activities/add.interface.ts index d7083dd..cf0c2ad 100644 --- a/src/model-interfaces/activities/add.interface.ts +++ b/src/model-interfaces/activities/add.interface.ts @@ -1,3 +1,7 @@ -import { APActivity } from './activity.interface'; +import { APActivity } from "./activity.interface"; -export type APAdd = APActivity +export type APAdd = APActivity & { type: "Add" }; + +export const ActivityIsAdd = (activity: APActivity): activity is APAdd => { + return activity.type == "Add"; +}; diff --git a/src/model-interfaces/activities/announce.interface.ts b/src/model-interfaces/activities/announce.interface.ts index 3804571..8d0bb77 100644 --- a/src/model-interfaces/activities/announce.interface.ts +++ b/src/model-interfaces/activities/announce.interface.ts @@ -1,3 +1,9 @@ -import { APActivity } from './activity.interface'; +import { APActivity } from "./activity.interface"; -export type APAnnounce = APActivity +export type APAnnounce = APActivity & { type: "Announce" }; + +export const ActivityIsAnnounce = ( + activity: APActivity, +): activity is APAnnounce => { + return activity.type == "Announce"; +}; diff --git a/src/model-interfaces/activities/arrive.interface.ts b/src/model-interfaces/activities/arrive.interface.ts index f42cc41..31352d3 100644 --- a/src/model-interfaces/activities/arrive.interface.ts +++ b/src/model-interfaces/activities/arrive.interface.ts @@ -1,3 +1,9 @@ -import { APIntransitiveActivity } from './intransitive-activity.interface'; +import { APIntransitiveActivity } from "./intransitive-activity.interface"; -export type APArrive = APIntransitiveActivity +export type APArrive = APIntransitiveActivity & { type: "Arrive" }; + +export const ActivityIsArrive = ( + activity: APIntransitiveActivity, +): activity is APArrive => { + return activity.type == "Arrive"; +}; diff --git a/src/model-interfaces/activities/block.interface.ts b/src/model-interfaces/activities/block.interface.ts index cc21153..02c3010 100644 --- a/src/model-interfaces/activities/block.interface.ts +++ b/src/model-interfaces/activities/block.interface.ts @@ -1,3 +1,8 @@ -import { APIgnore } from './ignore.interface'; +import { APActivity } from "./activity.interface"; +import { APIgnore } from "./ignore.interface"; -export type APBlock = APIgnore +export type APBlock = APIgnore & { type: "Block" }; + +export const ActivityIsBlock = (activity: APActivity): activity is APBlock => { + return activity.type == "Block"; +}; diff --git a/src/model-interfaces/activities/create.interface.ts b/src/model-interfaces/activities/create.interface.ts index 0c722be..e1939b0 100644 --- a/src/model-interfaces/activities/create.interface.ts +++ b/src/model-interfaces/activities/create.interface.ts @@ -1,3 +1,9 @@ -import { APActivity } from './activity.interface'; +import { APActivity } from "./activity.interface"; -export type APCreate = APActivity +export type APCreate = APActivity & { type: "Create" }; + +export const ActivityIsCreate = ( + activity: APActivity, +): activity is APCreate => { + return activity.type == "Create"; +}; diff --git a/src/model-interfaces/activities/delete.interface.ts b/src/model-interfaces/activities/delete.interface.ts index 43bb148..56a71a2 100644 --- a/src/model-interfaces/activities/delete.interface.ts +++ b/src/model-interfaces/activities/delete.interface.ts @@ -1,3 +1,9 @@ -import { APActivity } from './activity.interface'; +import { APActivity } from "./activity.interface"; -export type APDelete = APActivity +export type APDelete = APActivity & { type: "Delete" }; + +export const ActivityIsDelete = ( + activity: APActivity, +): activity is APDelete => { + return activity.type == "Delete"; +}; diff --git a/src/model-interfaces/activities/dislike.interface.ts b/src/model-interfaces/activities/dislike.interface.ts index de282b2..e7ce179 100644 --- a/src/model-interfaces/activities/dislike.interface.ts +++ b/src/model-interfaces/activities/dislike.interface.ts @@ -1,3 +1,9 @@ -import { APActivity } from './activity.interface'; +import { APActivity } from "./activity.interface"; -export type APDislike = APActivity +export type APDislike = APActivity & { type: "Dislike" }; + +export const ActivityIsDislike = ( + activity: APActivity, +): activity is APDislike => { + return activity.type == "Dislike"; +}; diff --git a/src/model-interfaces/activities/flag.interface.ts b/src/model-interfaces/activities/flag.interface.ts index b89ce00..feee08b 100644 --- a/src/model-interfaces/activities/flag.interface.ts +++ b/src/model-interfaces/activities/flag.interface.ts @@ -1,3 +1,7 @@ -import { APActivity } from './activity.interface'; +import { APActivity } from "./activity.interface"; -export type APFlag = APActivity +export type APFlag = APActivity & { type: "Flag" }; + +export const ActivityIsFlag = (activity: APActivity): activity is APFlag => { + return activity.type == "Flag"; +}; diff --git a/src/model-interfaces/activities/follow.interface.ts b/src/model-interfaces/activities/follow.interface.ts index 3a026d5..2b439d5 100644 --- a/src/model-interfaces/activities/follow.interface.ts +++ b/src/model-interfaces/activities/follow.interface.ts @@ -1,3 +1,9 @@ -import { APActivity } from './activity.interface'; +import { APActivity } from "./activity.interface"; -export type APFollow = APActivity +export type APFollow = APActivity & { type: "Follow" }; + +export const ActivityIsFollow = ( + activity: APActivity, +): activity is APFollow => { + return activity.type == "Follow"; +}; diff --git a/src/model-interfaces/activities/ignore.interface.ts b/src/model-interfaces/activities/ignore.interface.ts index e1b505e..abefcdd 100644 --- a/src/model-interfaces/activities/ignore.interface.ts +++ b/src/model-interfaces/activities/ignore.interface.ts @@ -1,3 +1,9 @@ -import { APActivity } from './activity.interface'; +import { APActivity } from "./activity.interface"; -export type APIgnore = APActivity +export type APIgnore = APActivity & { type: "Ignore" }; + +export const ActivityIsIgnore = ( + activity: APActivity, +): activity is APIgnore => { + return activity.type == "Ignore"; +}; diff --git a/src/model-interfaces/activities/intransitive-activity.interface.ts b/src/model-interfaces/activities/intransitive-activity.interface.ts index a87e32d..8df3a73 100644 --- a/src/model-interfaces/activities/intransitive-activity.interface.ts +++ b/src/model-interfaces/activities/intransitive-activity.interface.ts @@ -1,3 +1,3 @@ -import { APActivity } from './activity.interface'; +import { APActivity } from "./activity.interface"; -export type APIntransitiveActivity = Omit \ No newline at end of file +export type APIntransitiveActivity = Omit; diff --git a/src/model-interfaces/activities/invite.interface.ts b/src/model-interfaces/activities/invite.interface.ts index ec1abd3..8adc52d 100644 --- a/src/model-interfaces/activities/invite.interface.ts +++ b/src/model-interfaces/activities/invite.interface.ts @@ -1,3 +1,9 @@ -import { APOffer } from './offer.interface'; +import { APActivity } from "./activity.interface"; -export type APInvite = APOffer +export type APInvite = APActivity & { type: "Invite" }; + +export const ActivityIsInvite = ( + activity: APActivity, +): activity is APInvite => { + return activity.type == "Invite"; +}; diff --git a/src/model-interfaces/activities/join.interface.ts b/src/model-interfaces/activities/join.interface.ts index 3d840c2..f95cea5 100644 --- a/src/model-interfaces/activities/join.interface.ts +++ b/src/model-interfaces/activities/join.interface.ts @@ -1,3 +1,7 @@ -import { APActivity } from './activity.interface'; +import { APActivity } from "./activity.interface"; -export type APJoin = APActivity +export type APJoin = APActivity & { type: "Join" }; + +export const ActivityIsJoin = (activity: APActivity): activity is APJoin => { + return activity.type == "Join"; +}; diff --git a/src/model-interfaces/activities/leave.interface.ts b/src/model-interfaces/activities/leave.interface.ts index c07a73c..38f9b0c 100644 --- a/src/model-interfaces/activities/leave.interface.ts +++ b/src/model-interfaces/activities/leave.interface.ts @@ -1,3 +1,7 @@ -import { APActivity } from './activity.interface'; +import { APActivity } from "./activity.interface"; -export type APLeave = APActivity +export type APLeave = APActivity & { type: "Leave" }; + +export const ActivityIsLeave = (activity: APActivity): activity is APLeave => { + return activity.type == "Leave"; +}; diff --git a/src/model-interfaces/activities/like.interface.ts b/src/model-interfaces/activities/like.interface.ts index 8b24f69..6c8c46a 100644 --- a/src/model-interfaces/activities/like.interface.ts +++ b/src/model-interfaces/activities/like.interface.ts @@ -1,3 +1,7 @@ -import { APActivity } from './activity.interface'; +import { APActivity } from "./activity.interface"; -export type APLike = APActivity +export type APLike = APActivity & { type: "Like" }; + +export const ActivityIsLike = (activity: APActivity): activity is APLike => { + return activity.type == "Like"; +}; diff --git a/src/model-interfaces/activities/listen.interface.ts b/src/model-interfaces/activities/listen.interface.ts index 2ba0af5..5de2ae9 100644 --- a/src/model-interfaces/activities/listen.interface.ts +++ b/src/model-interfaces/activities/listen.interface.ts @@ -1,3 +1,9 @@ -import { APActivity } from './activity.interface'; +import { APActivity } from "./activity.interface"; -export type APListen = APActivity +export type APListen = APActivity & { type: "Listen" }; + +export const ActivityIsListen = ( + activity: APActivity, +): activity is APListen => { + return activity.type == "Listen"; +}; diff --git a/src/model-interfaces/activities/move.interface.ts b/src/model-interfaces/activities/move.interface.ts index 0d3e3e6..52b94e6 100644 --- a/src/model-interfaces/activities/move.interface.ts +++ b/src/model-interfaces/activities/move.interface.ts @@ -1,3 +1,7 @@ -import { APActivity } from './activity.interface'; +import { APActivity } from "./activity.interface"; -export type APMove = APActivity +export type APMove = APActivity & { type: "Move" }; + +export const ActivityIsMove = (activity: APActivity): activity is APMove => { + return activity.type == "Move"; +}; diff --git a/src/model-interfaces/activities/offer.interface.ts b/src/model-interfaces/activities/offer.interface.ts index e211e30..9e9a7fb 100644 --- a/src/model-interfaces/activities/offer.interface.ts +++ b/src/model-interfaces/activities/offer.interface.ts @@ -1,3 +1,7 @@ -import { APActivity } from './activity.interface'; +import { APActivity } from "./activity.interface"; -export type APOffer = APActivity +export type APOffer = APActivity & { type: "Offer" }; + +export const ActivityIsOffer = (activity: APActivity): activity is APOffer => { + return activity.type == "Offer"; +}; diff --git a/src/model-interfaces/activities/question.interface.ts b/src/model-interfaces/activities/question.interface.ts index 1613763..4abff03 100644 --- a/src/model-interfaces/activities/question.interface.ts +++ b/src/model-interfaces/activities/question.interface.ts @@ -1,30 +1,37 @@ -import {AnyOfField, ClosedField, OneOfField} from '../../fields'; -import { APIntransitiveActivity } from './intransitive-activity.interface'; +import { AnyOfField, ClosedField, OneOfField } from "../../fields"; +import { APIntransitiveActivity } from "./intransitive-activity.interface"; export interface APQuestion extends APIntransitiveActivity { + type: "Question"; - /** - * 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?: OneOfField[]; + /** + * 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?: OneOfField[]; - /** - * 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?: AnyOfField[]; + /** + * 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?: AnyOfField[]; - /** - * Indicates that a question has been closed, and answers are no longer accepted. - * - * {@link https://www.w3.org/ns/activitystreams#closed Docs} - */ - closed?: ClosedField; + /** + * Indicates that a question has been closed, and answers are no longer accepted. + * + * {@link https://www.w3.org/ns/activitystreams#closed Docs} + */ + closed?: ClosedField; } + +export const ActivityIsQuestion = ( + activity: APIntransitiveActivity, +): activity is APQuestion => { + return activity.type == "Question"; +}; diff --git a/src/model-interfaces/activities/read.interface.ts b/src/model-interfaces/activities/read.interface.ts index d43d1c9..8709117 100644 --- a/src/model-interfaces/activities/read.interface.ts +++ b/src/model-interfaces/activities/read.interface.ts @@ -1,3 +1,7 @@ -import { APActivity } from './activity.interface'; +import { APActivity } from "./activity.interface"; -export type APRead = APActivity +export type APRead = APActivity & { type: "Read" }; + +export const ActivityIsRead = (activity: APActivity): activity is APRead => { + return activity.type == "Read"; +}; diff --git a/src/model-interfaces/activities/reject.interface.ts b/src/model-interfaces/activities/reject.interface.ts index 1392e70..441f340 100644 --- a/src/model-interfaces/activities/reject.interface.ts +++ b/src/model-interfaces/activities/reject.interface.ts @@ -1,3 +1,9 @@ -import { APActivity } from './activity.interface'; +import { APActivity } from "./activity.interface"; -export type APReject = APActivity +export type APReject = APActivity & { type: "Reject" }; + +export const ActivityIsReject = ( + activity: APActivity, +): activity is APReject => { + return activity.type == "Reject"; +}; diff --git a/src/model-interfaces/activities/remove.interface.ts b/src/model-interfaces/activities/remove.interface.ts index a8b8ca0..594927d 100644 --- a/src/model-interfaces/activities/remove.interface.ts +++ b/src/model-interfaces/activities/remove.interface.ts @@ -1,3 +1,9 @@ -import { APActivity } from './activity.interface'; +import { APActivity } from "./activity.interface"; -export type APRemove = APActivity +export type APRemove = APActivity & { type: "Remove" }; + +export const ActivityIsRemove = ( + activity: APActivity, +): activity is APRemove => { + return activity.type == "Remove"; +}; diff --git a/src/model-interfaces/activities/tentative-accept.interface.ts b/src/model-interfaces/activities/tentative-accept.interface.ts index 307d1ba..b2ddb3e 100644 --- a/src/model-interfaces/activities/tentative-accept.interface.ts +++ b/src/model-interfaces/activities/tentative-accept.interface.ts @@ -1,3 +1,9 @@ -import { APAccept } from './accept.interface'; +import { APActivity } from "./activity.interface"; -export type APTentativeAccept = APAccept +export type APTentativeAccept = APActivity & { type: "TentativeAccept" }; + +export const ActivityIsTentativeAccept = ( + activity: APActivity, +): activity is APTentativeAccept => { + return activity.type == "TentativeAccept"; +}; diff --git a/src/model-interfaces/activities/tentative-reject.interface.ts b/src/model-interfaces/activities/tentative-reject.interface.ts index 4930b0c..0fefd04 100644 --- a/src/model-interfaces/activities/tentative-reject.interface.ts +++ b/src/model-interfaces/activities/tentative-reject.interface.ts @@ -1,3 +1,9 @@ -import { APReject } from './reject.interface'; +import { APActivity } from "./activity.interface"; -export type APTentativeReject = APReject +export type APTentativeReject = APActivity & { type: "TentativeReject" }; + +export const ActivityIsTentativeReject = ( + activity: APActivity, +): activity is APTentativeReject => { + return activity.type == "TentativeReject"; +}; diff --git a/src/model-interfaces/activities/travel.interface.ts b/src/model-interfaces/activities/travel.interface.ts index 24f74c5..fad3225 100644 --- a/src/model-interfaces/activities/travel.interface.ts +++ b/src/model-interfaces/activities/travel.interface.ts @@ -1,3 +1,9 @@ -import { APIntransitiveActivity } from './intransitive-activity.interface'; +import { APIntransitiveActivity } from "./intransitive-activity.interface"; -export type APTravel = APIntransitiveActivity +export type APTravel = APIntransitiveActivity & { type: "Travel" }; + +export const ActivityIsTravel = ( + activity: APIntransitiveActivity, +): activity is APTravel => { + return activity.type == "Travel"; +}; diff --git a/src/model-interfaces/activities/undo.interface.ts b/src/model-interfaces/activities/undo.interface.ts index b690d67..2d7e7e3 100644 --- a/src/model-interfaces/activities/undo.interface.ts +++ b/src/model-interfaces/activities/undo.interface.ts @@ -1,3 +1,7 @@ -import { APActivity } from './activity.interface'; +import { APActivity } from "./activity.interface"; -export type APUndo = APActivity +export type APUndo = APActivity & { type: "Undo" }; + +export const ActivityIsUndo = (activity: APActivity): activity is APUndo => { + return activity.type == "Undo"; +}; diff --git a/src/model-interfaces/activities/update.interface.ts b/src/model-interfaces/activities/update.interface.ts index 438d338..1223bce 100644 --- a/src/model-interfaces/activities/update.interface.ts +++ b/src/model-interfaces/activities/update.interface.ts @@ -1,3 +1,9 @@ -import { APActivity } from './activity.interface'; +import { APActivity } from "./activity.interface"; -export type APUpdate = APActivity +export type APUpdate = APActivity & { type: "Update" }; + +export const ActivityIsUpdate = ( + activity: APActivity, +): activity is APUpdate => { + return activity.type == "Update"; +}; diff --git a/src/model-interfaces/activities/view.interface.ts b/src/model-interfaces/activities/view.interface.ts index f081845..baed991 100644 --- a/src/model-interfaces/activities/view.interface.ts +++ b/src/model-interfaces/activities/view.interface.ts @@ -1,3 +1,7 @@ -import { APActivity } from './activity.interface'; +import { APActivity } from "./activity.interface"; -export type APView = APActivity +export type APView = APActivity & { type: "View" }; + +export const ActivityIsView = (activity: APActivity): activity is APView => { + return activity.type == "View"; +}; diff --git a/src/model-interfaces/actors/actor.interface.ts b/src/model-interfaces/actors/actor.interface.ts index e615a36..aa3cda8 100644 --- a/src/model-interfaces/actors/actor.interface.ts +++ b/src/model-interfaces/actors/actor.interface.ts @@ -1,111 +1,110 @@ -import { APObject } from '../common/object.interface'; +import { APObject } from "../common/object.interface"; import { - FollowersField, - FollowingField, - InboxField, - LikedField, - OutboxField, - PreferredUsernameMapField, - PreferredUsernameField, - StreamsField, - EndpointsField -} from '../../fields'; + FollowersField, + FollowingField, + InboxField, + LikedField, + OutboxField, + PreferredUsernameMapField, + PreferredUsernameField, + StreamsField, + EndpointsField, +} from "../../fields"; export interface APActor extends APObject { + /* + * The inbox is discovered through the inbox property of an actor's profile. + * The inbox MUST be an OrderedCollection. The inbox stream contains all activities + * received by the actor. The server SHOULD filter content according to the + * requester permission. In general, the owner of an inbox is likely to be + * able to access all of their inbox contents. Depending on access control, + * some other content may be public, whereas other content may require + * authentication for non-owner users, if they can access the inbox at all. + * + * {@link https://www.w3.org/TR/activitypub/#inbox Docs} + */ + inbox: InboxField; - /* - * The inbox is discovered through the inbox property of an actor's profile. - * The inbox MUST be an OrderedCollection. The inbox stream contains all activities - * received by the actor. The server SHOULD filter content according to the - * requester permission. In general, the owner of an inbox is likely to be - * able to access all of their inbox contents. Depending on access control, - * some other content may be public, whereas other content may require - * authentication for non-owner users, if they can access the inbox at all. - * - * {@link https://www.w3.org/TR/activitypub/#inbox Docs} - */ - inbox: InboxField; - - /** - * The outbox is discovered through the outbox property of an actor's profile. - * The outbox MUST be an OrderedCollection. The outbox stream contains activities - * the user has published, subject to the ability of the requester to retrieve the - * activity (that is, the contents of the outbox are filtered by the permissions - * of the person reading it). If a user submits a request without Authorization the - * server should respond with all the Public posts. This could potentially be all - * relevant objects published by the user, though the number of available items is - * left to the discretion of those implementing and deploying the server. - * - * {@link https://www.w3.org/TR/activitypub/#outbox Docs} - */ - outbox: OutboxField; + /** + * The outbox is discovered through the outbox property of an actor's profile. + * The outbox MUST be an OrderedCollection. The outbox stream contains activities + * the user has published, subject to the ability of the requester to retrieve the + * activity (that is, the contents of the outbox are filtered by the permissions + * of the person reading it). If a user submits a request without Authorization the + * server should respond with all the Public posts. This could potentially be all + * relevant objects published by the user, though the number of available items is + * left to the discretion of those implementing and deploying the server. + * + * {@link https://www.w3.org/TR/activitypub/#outbox Docs} + */ + outbox: OutboxField; - /** - * Every actor SHOULD have a collection of following. This is a list of everybody that - * the actor has followed, added as a side effect. The following collection MUST be - * either an OrderedCollection or a Collection and MAY be filtered on privileges of an - * authenticated user or as appropriate when no authentication is given. - * - * {@link https://www.w3.org/TR/activitypub/#following Docs} - */ - following?: FollowingField; + /** + * Every actor SHOULD have a collection of following. This is a list of everybody that + * the actor has followed, added as a side effect. The following collection MUST be + * either an OrderedCollection or a Collection and MAY be filtered on privileges of an + * authenticated user or as appropriate when no authentication is given. + * + * {@link https://www.w3.org/TR/activitypub/#following Docs} + */ + following?: FollowingField; - /** - * Every actor SHOULD have a collection of followers. This is a list of everyone who has - * sent a Follow activity for the actor, added as a side effect. This is where one would - * find a list of all the actors that are following the actor. The followers collection - * MUST be either an OrderedCollection or a Collection and MAY be filtered on privileges - * of an authenticated user or as appropriate when no authentication is given. - * - * NOTE: The follow activity generally is a request to see the objects an actor creates. - * This makes the Followers collection an appropriate default target for delivery of notifications. - * - * {@link https://www.w3.org/TR/activitypub/#followers Docs} - */ - followers?: FollowersField; + /** + * Every actor SHOULD have a collection of followers. This is a list of everyone who has + * sent a Follow activity for the actor, added as a side effect. This is where one would + * find a list of all the actors that are following the actor. The followers collection + * MUST be either an OrderedCollection or a Collection and MAY be filtered on privileges + * of an authenticated user or as appropriate when no authentication is given. + * + * NOTE: The follow activity generally is a request to see the objects an actor creates. + * This makes the Followers collection an appropriate default target for delivery of notifications. + * + * {@link https://www.w3.org/TR/activitypub/#followers Docs} + */ + followers?: FollowersField; - /** - * Every actor MAY have a liked collection. This is a list of every object from all the - * actor's Like activities, added as a side effect. The liked collection MUST be either - * an OrderedCollection or a Collection and MAY be filtered on privileges of an - * authenticated user or as appropriate when no authentication is given. - * - * {@link https://www.w3.org/TR/activitypub/#liked Docs} - */ - liked?: LikedField; + /** + * Every actor MAY have a liked collection. This is a list of every object from all the + * actor's Like activities, added as a side effect. The liked collection MUST be either + * an OrderedCollection or a Collection and MAY be filtered on privileges of an + * authenticated user or as appropriate when no authentication is given. + * + * {@link https://www.w3.org/TR/activitypub/#liked Docs} + */ + liked?: LikedField; - /** - * A list of supplementary Collections which may be of interest. - * - * {@link https://www.w3.org/TR/activitypub/#actors Docs} - */ - streams?: StreamsField | StreamsField[]; + /** + * A list of supplementary Collections which may be of interest. + * + * {@link https://www.w3.org/TR/activitypub/#actors Docs} + */ + streams?: StreamsField | StreamsField[]; - /** - * A short username which may be used to refer to the actor, with no uniqueness guarantees. - * [For multiple language-tagged values use preferredUsernameMap property] - * - * {@link https://www.w3.org/TR/activitypub/#actors Docs} - */ - preferredUsername?: PreferredUsernameField; + /** + * A short username which may be used to refer to the actor, with no uniqueness guarantees. + * [For multiple language-tagged values use preferredUsernameMap property] + * + * {@link https://www.w3.org/TR/activitypub/#actors Docs} + */ + preferredUsername?: PreferredUsernameField; - /** - * A short username which may be used to refer to the actor, with no uniqueness guarantees. - * [For a single value use preferredUsername property] - * - * {@link https://www.w3.org/TR/activitypub/#actors Docs} - */ - preferredUsernameMap?: PreferredUsernameMapField; + /** + * A short username which may be used to refer to the actor, with no uniqueness guarantees. + * [For a single value use preferredUsername property] + * + * {@link https://www.w3.org/TR/activitypub/#actors Docs} + */ + preferredUsernameMap?: PreferredUsernameMapField; - /** - * A json object which maps additional (typically server/domain-wide) endpoints which may - * be useful either for this actor or someone referencing this actor. This mapping may be - * nested inside the actor document as the value or may be a link to a JSON-LD document with - * these properties. - * - * {@link https://www.w3.org/TR/activitypub/#actors Docs} - */ - endpoints?: EndpointsField; + /** + * A json object which maps additional (typically server/domain-wide) endpoints which may + * be useful either for this actor or someone referencing this actor. This mapping may be + * nested inside the actor document as the value or may be a link to a JSON-LD document with + * these properties. + * + * {@link https://www.w3.org/TR/activitypub/#actors Docs} + */ + endpoints?: EndpointsField; /** * The public key of this actor, used to sign activities. @@ -117,5 +116,5 @@ export interface APActor extends APObject { owner: string; /** The RSA public key. */ publicKeyPem: string; - } + }; } diff --git a/src/model-interfaces/actors/application.interface.ts b/src/model-interfaces/actors/application.interface.ts index df50008..a7a0ad2 100644 --- a/src/model-interfaces/actors/application.interface.ts +++ b/src/model-interfaces/actors/application.interface.ts @@ -1,3 +1,7 @@ -import { APActor } from './actor.interface'; +import { APActor } from "./actor.interface"; -export type APApplication = APActor +export type APApplication = APActor & { type: "Application" }; + +export const ActorIsApplication = (actor: APActor): actor is APApplication => { + return actor.type == "Application"; +}; diff --git a/src/model-interfaces/actors/group.interface.ts b/src/model-interfaces/actors/group.interface.ts index 6813fb9..d9ece01 100644 --- a/src/model-interfaces/actors/group.interface.ts +++ b/src/model-interfaces/actors/group.interface.ts @@ -1,3 +1,7 @@ -import { APActor } from './actor.interface'; +import { APActor } from "./actor.interface"; -export type APGroup = APActor +export type APGroup = APActor & { type: "Group" }; + +export const ActorIsGroup = (actor: APActor): actor is APGroup => { + return actor.type == "Group"; +}; diff --git a/src/model-interfaces/actors/organization.interface.ts b/src/model-interfaces/actors/organization.interface.ts index ca5ae31..3a39a3a 100644 --- a/src/model-interfaces/actors/organization.interface.ts +++ b/src/model-interfaces/actors/organization.interface.ts @@ -1,3 +1,9 @@ -import { APActor } from './actor.interface'; +import { APActor } from "./actor.interface"; -export type APOrganization = APActor \ No newline at end of file +export type APOrganization = APActor & { type: "Organization" }; + +export const ActorIsOrganization = ( + actor: APActor, +): actor is APOrganization => { + return actor.type == "Organization"; +}; diff --git a/src/model-interfaces/actors/person.interface.ts b/src/model-interfaces/actors/person.interface.ts index 55749ca..01660cc 100644 --- a/src/model-interfaces/actors/person.interface.ts +++ b/src/model-interfaces/actors/person.interface.ts @@ -1,3 +1,7 @@ -import { APActor } from './actor.interface'; +import { APActor } from "./actor.interface"; -export type APPerson = APActor \ No newline at end of file +export type APPerson = APActor & { type: "Person" }; + +export const ActorIsPerson = (actor: APActor): actor is APPerson => { + return actor.type == "Person"; +}; diff --git a/src/model-interfaces/actors/service.interface.ts b/src/model-interfaces/actors/service.interface.ts index a8620a5..bb436b3 100644 --- a/src/model-interfaces/actors/service.interface.ts +++ b/src/model-interfaces/actors/service.interface.ts @@ -1,3 +1,7 @@ -import { APActor } from './actor.interface'; +import { APActor } from "./actor.interface"; -export type APService = APActor \ No newline at end of file +export type APService = APActor & { type: "Service" }; + +export const ActorIsService = (actor: APActor): actor is APService => { + return actor.type == "Service"; +}; diff --git a/src/model-interfaces/collections/collection-page.interface.ts b/src/model-interfaces/collections/collection-page.interface.ts index ef54571..0cfef3d 100644 --- a/src/model-interfaces/collections/collection-page.interface.ts +++ b/src/model-interfaces/collections/collection-page.interface.ts @@ -1,26 +1,29 @@ -import { APCollection } from './collection.interface'; -import {CollectionPageNextField, CollectionPagePartOfField, CollectionPagePrevField} from '../../fields'; +import { APCollection } from "./collection.interface"; +import { + CollectionPageNextField, + CollectionPagePartOfField, + CollectionPagePrevField, +} from "../../fields"; export interface APCollectionPage extends APCollection { + /** + * Identifies the Collection to which a CollectionPage objects items belong. + * + * {@link https://www.w3.org/ns/activitystreams#partOf Docs} + */ + partOf?: CollectionPagePartOfField; - /** - * Identifies the Collection to which a CollectionPage objects items belong. - * - * {@link https://www.w3.org/ns/activitystreams#partOf Docs} - */ - partOf?: CollectionPagePartOfField; + /** + * In a paged Collection, indicates the next page of items. + * + * {@link https://www.w3.org/ns/activitystreams#next Docs} + */ + next?: CollectionPageNextField; - /** - * In a paged Collection, indicates the next page of items. - * - * {@link https://www.w3.org/ns/activitystreams#next Docs} - */ - next?: CollectionPageNextField; - - /** - * In a paged Collection, identifies the previous page of items. - * - * {@link https://www.w3.org/ns/activitystreams#prev Docs} - */ - prev?: CollectionPagePrevField; + /** + * In a paged Collection, identifies the previous page of items. + * + * {@link https://www.w3.org/ns/activitystreams#prev Docs} + */ + prev?: CollectionPagePrevField; } diff --git a/src/model-interfaces/collections/collection.interface.ts b/src/model-interfaces/collections/collection.interface.ts index 92fa85c..4aa3371 100644 --- a/src/model-interfaces/collections/collection.interface.ts +++ b/src/model-interfaces/collections/collection.interface.ts @@ -1,51 +1,51 @@ -import { APObject } from '../common/object.interface'; +import { APObject } from "../common/object.interface"; import { - CollectionCurrentField, - CollectionFirstField, CollectionItemsField, - CollectionLastField, - TotalItemsField -} from '../../fields'; + CollectionCurrentField, + CollectionFirstField, + CollectionItemsField, + CollectionLastField, + TotalItemsField, +} from "../../fields"; export interface APCollection extends APObject { + /** + * A non-negative integer specifying the total number of objects contained by + * the logical view of the collection. This number might not reflect the actual + * number of items serialized within the Collection object instance. + * + * {@link https://www.w3.org/ns/activitystreams#totalItems Docs} + */ + totalItems?: TotalItemsField; - /** - * A non-negative integer specifying the total number of objects contained by - * the logical view of the collection. This number might not reflect the actual - * number of items serialized within the Collection object instance. - * - * {@link https://www.w3.org/ns/activitystreams#totalItems Docs} - */ - totalItems?: TotalItemsField; + /** + * In a paged Collection, indicates the page that contains + * the most recently updated member items. + * + * {@link https://www.w3.org/ns/activitystreams#current Docs} + */ + current?: CollectionCurrentField; - /** - * In a paged Collection, indicates the page that contains - * the most recently updated member items. - * - * {@link https://www.w3.org/ns/activitystreams#current Docs} - */ - current?: CollectionCurrentField; + /** + * In a paged Collection,indicates the furthest proceeding + * page of items in the collection. + * + * {@link https://www.w3.org/ns/activitystreams#first Docs} + */ + first?: CollectionFirstField; - /** - * In a paged Collection,indicates the furthest proceeding - * page of items in the collection. - * - * {@link https://www.w3.org/ns/activitystreams#first Docs} - */ - first?: CollectionFirstField; + /** + * In a paged Collection, indicates the furthest proceeding + * page of the collection. + * + * {@link https://www.w3.org/ns/activitystreams#last Docs} + */ + last?: CollectionLastField; - /** - * In a paged Collection, indicates the furthest proceeding - * page of the collection. - * - * {@link https://www.w3.org/ns/activitystreams#last Docs} - */ - last?: CollectionLastField; - - /** - * Identifies the items contained in a collection. - * The items might be ordered or unordered. - * - * {@link https://www.w3.org/ns/activitystreams#items Docs} - */ - items?: CollectionItemsField[]; + /** + * Identifies the items contained in a collection. + * The items might be ordered or unordered. + * + * {@link https://www.w3.org/ns/activitystreams#items Docs} + */ + items?: CollectionItemsField[]; } diff --git a/src/model-interfaces/collections/ordered-collection-page.interface.ts b/src/model-interfaces/collections/ordered-collection-page.interface.ts index c4848ef..2e476b3 100644 --- a/src/model-interfaces/collections/ordered-collection-page.interface.ts +++ b/src/model-interfaces/collections/ordered-collection-page.interface.ts @@ -1,38 +1,38 @@ import { - OrderedCollectionPageNextField, - OrderedCollectionPagePartOfField, - OrderedCollectionPagePrevField, - StartIndexField -} from '../../fields'; -import { APOrderedCollection } from './ordered-collection.interface'; + OrderedCollectionPageNextField, + OrderedCollectionPagePartOfField, + OrderedCollectionPagePrevField, + StartIndexField, +} from "../../fields"; +import { APOrderedCollection } from "./ordered-collection.interface"; export interface APOrderedCollectionPage extends APOrderedCollection { - /** - * Identifies the OrderedCollection to which a OrderedCollectionPage objects items belong. - * - * {@link https://www.w3.org/ns/activitystreams#partOf Docs} - */ - partOf?: OrderedCollectionPagePartOfField; + /** + * Identifies the OrderedCollection to which a OrderedCollectionPage objects items belong. + * + * {@link https://www.w3.org/ns/activitystreams#partOf Docs} + */ + partOf?: OrderedCollectionPagePartOfField; - /** - * In a paged OrderedCollection, indicates the next page of items. - * - * {@link https://www.w3.org/ns/activitystreams#next Docs} - */ - next?: OrderedCollectionPageNextField; + /** + * In a paged OrderedCollection, indicates the next page of items. + * + * {@link https://www.w3.org/ns/activitystreams#next Docs} + */ + next?: OrderedCollectionPageNextField; - /** - * In a paged OrderedCollection, identifies the previous page of items. - * - * {@link https://www.w3.org/ns/activitystreams#prev Docs} - */ - prev?: OrderedCollectionPagePrevField; + /** + * In a paged OrderedCollection, identifies the previous page of items. + * + * {@link https://www.w3.org/ns/activitystreams#prev Docs} + */ + prev?: OrderedCollectionPagePrevField; - /** - * A non-negative integer value identifying the relative position - * within the logical view of a strictly ordered collection. - * - * {@link https://www.w3.org/ns/activitystreams#startIndex Docs} - */ - startIndex?: StartIndexField; + /** + * A non-negative integer value identifying the relative position + * within the logical view of a strictly ordered collection. + * + * {@link https://www.w3.org/ns/activitystreams#startIndex Docs} + */ + startIndex?: StartIndexField; } diff --git a/src/model-interfaces/collections/ordered-collection.interface.ts b/src/model-interfaces/collections/ordered-collection.interface.ts index 89b9366..e582937 100644 --- a/src/model-interfaces/collections/ordered-collection.interface.ts +++ b/src/model-interfaces/collections/ordered-collection.interface.ts @@ -1,50 +1,51 @@ import { - OrderedCollectionCurrentField, - OrderedCollectionFirstField, OrderedCollectionItemsField, - OrderedCollectionLastField, TotalItemsField -} from '../../fields'; -import { APObject } from '../common/object.interface'; + OrderedCollectionCurrentField, + OrderedCollectionFirstField, + OrderedCollectionItemsField, + OrderedCollectionLastField, + TotalItemsField, +} from "../../fields"; +import { APObject } from "../common/object.interface"; export interface APOrderedCollection extends APObject { + /** + * A non-negative integer specifying the total number of objects contained by + * the logical view of the collection. This number might not reflect the actual + * number of items serialized within the Collection object instance. + * + * {@link https://www.w3.org/ns/activitystreams#totalItems Docs} + */ + totalItems?: TotalItemsField; - /** - * A non-negative integer specifying the total number of objects contained by - * the logical view of the collection. This number might not reflect the actual - * number of items serialized within the Collection object instance. - * - * {@link https://www.w3.org/ns/activitystreams#totalItems Docs} - */ - totalItems?: TotalItemsField; + /** + * In a paged OrderedCollection, indicates the page that contains + * the most recently updated member items. + * + * {@link https://www.w3.org/ns/activitystreams#current Docs} + */ + current?: OrderedCollectionCurrentField; - /** - * In a paged OrderedCollection, indicates the page that contains - * the most recently updated member items. - * - * {@link https://www.w3.org/ns/activitystreams#current Docs} - */ - current?: OrderedCollectionCurrentField; + /** + * In a paged OrderedCollection, indicates the furthest proceeding + * page of items in the collection. + * + * {@link https://www.w3.org/ns/activitystreams#first Docs} + */ + first?: OrderedCollectionFirstField; - /** - * In a paged OrderedCollection, indicates the furthest proceeding - * page of items in the collection. - * - * {@link https://www.w3.org/ns/activitystreams#first Docs} - */ - first?: OrderedCollectionFirstField; + /** + * In a paged OrderedCollection, indicates the furthest proceeding + * page of the collection. + * + * {@link https://www.w3.org/ns/activitystreams#last Docs} + */ + last?: OrderedCollectionLastField; - /** - * In a paged OrderedCollection, indicates the furthest proceeding - * page of the collection. - * - * {@link https://www.w3.org/ns/activitystreams#last Docs} - */ - last?: OrderedCollectionLastField; - - /** - * Identifies the ordered items contained in a collection. - * The items must be ordered. - * - * {@link https://www.w3.org/ns/activitystreams#orderedItems Docs} - */ - orderedItems?: OrderedCollectionItemsField[]; + /** + * Identifies the ordered items contained in a collection. + * The items must be ordered. + * + * {@link https://www.w3.org/ns/activitystreams#orderedItems Docs} + */ + orderedItems?: OrderedCollectionItemsField[]; } diff --git a/src/model-interfaces/common/article.interface.ts b/src/model-interfaces/common/article.interface.ts index ca4e8ba..ebf9c41 100644 --- a/src/model-interfaces/common/article.interface.ts +++ b/src/model-interfaces/common/article.interface.ts @@ -1,3 +1,7 @@ -import {APObject} from './object.interface'; +import { APObject } from "./object.interface"; -export type APArticle = APObject +export type APArticle = APObject & { type: "Article" }; + +export const ObjectIsArticle = (object: APObject): object is APArticle => { + return object.type == "Article"; +}; diff --git a/src/model-interfaces/common/event.interface.ts b/src/model-interfaces/common/event.interface.ts index 3634e2f..a71864f 100644 --- a/src/model-interfaces/common/event.interface.ts +++ b/src/model-interfaces/common/event.interface.ts @@ -1,3 +1,7 @@ -import {APObject} from './object.interface'; +import { APObject } from "./object.interface"; -export type APEvent = APObject +export type APEvent = APObject & { type: "Event" }; + +export const ObjectIsEvent = (object: APObject): object is APEvent => { + return object.type == "Event"; +}; diff --git a/src/model-interfaces/common/link.interface.ts b/src/model-interfaces/common/link.interface.ts index a49536b..8dd6669 100644 --- a/src/model-interfaces/common/link.interface.ts +++ b/src/model-interfaces/common/link.interface.ts @@ -1,95 +1,102 @@ import { - HeightField, - HreflangField, - HrefField, - MediaTypeField, - NameMapField, - NameField, PreviewField, - RelField, TypeField, WidthField -} from '../../fields'; + HeightField, + HrefField, + HreflangField, + MediaTypeField, + NameField, + NameMapField, + PreviewField, + RelField, + TypeField, + WidthField, +} from "../../fields"; +import { APObject } from "./object.interface"; export interface APLink { + /** + * 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?: TypeField | TypeField[]; - /** - * 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?: TypeField | TypeField[]; + /** + * 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?: NameField; - /** - * 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?: NameField; + /** + * 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?: NameMapField; - /** - * 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?: NameMapField; + /** + * The target resource pointed to by a Link. + * + * {@link https://www.w3.org/ns/activitystreams#href Docs} + */ + href?: HrefField; - /** - * The target resource pointed to by a Link. - * - * {@link https://www.w3.org/ns/activitystreams#href Docs} - */ - href?: HrefField; + /** + * Hints as to the language used by the target resource. + * Field MUST be a [BCP47] Language-Tag. + * + * {@link https://www.w3.org/ns/activitystreams#hreflang Docs} + */ + hreflang?: HreflangField; - /** - * Hints as to the language used by the target resource. - * Field MUST be a [BCP47] Language-Tag. - * - * {@link https://www.w3.org/ns/activitystreams#hreflang Docs} - */ - hreflang?: HreflangField; + /** + * When used on a Link, identifies the MIME media type of the referenced resource + * + * {@link https://www.w3.org/ns/activitystreams#mediaType Docs} + */ + mediaType?: MediaTypeField; - /** - * When used on a Link, identifies the MIME media type of the referenced resource - * - * {@link https://www.w3.org/ns/activitystreams#mediaType Docs} - */ - mediaType?: MediaTypeField; + /** + * 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?: RelField | RelField[]; - /** - * 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?: RelField | RelField[]; + /** + * 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?: HeightField; - /** - * 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?: HeightField; + /** + * 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?: WidthField; - /** - * 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?: WidthField; - - /** - * Identifies an entity that provides a preview of this object. - * - * {@link https://www.w3.org/ns/activitystreams#preview Docs} - */ - preview?: PreviewField; + /** + * Identifies an entity that provides a preview of this object. + * + * {@link https://www.w3.org/ns/activitystreams#preview Docs} + */ + preview?: PreviewField; } + +export const ObjectIsLink = (object: APObject): object is APLink => { + return object.type == "Link"; +}; diff --git a/src/model-interfaces/common/mention.interface.ts b/src/model-interfaces/common/mention.interface.ts index 1ad1837..5181486 100644 --- a/src/model-interfaces/common/mention.interface.ts +++ b/src/model-interfaces/common/mention.interface.ts @@ -1,3 +1,8 @@ -import {APLink} from './link.interface'; +import { APLink } from "./link.interface"; +import { APObject } from "./object.interface"; -export type APMention = APLink +export type APMention = APLink & { type: "Mention" }; + +export const ObjectIsMention = (object: APObject): object is APMention => { + return object.type == "Mention"; +}; diff --git a/src/model-interfaces/common/note.interface.ts b/src/model-interfaces/common/note.interface.ts index ec17b72..d0c27d4 100644 --- a/src/model-interfaces/common/note.interface.ts +++ b/src/model-interfaces/common/note.interface.ts @@ -1,3 +1,7 @@ -import { APObject } from './object.interface'; +import { APObject } from "./object.interface"; -export type APNote = APObject \ No newline at end of file +export type APNote = APObject & { type: "Note" }; + +export const ObjectIsNote = (object: APObject): object is APNote => { + return object.type == "Note"; +}; diff --git a/src/model-interfaces/common/object.interface.ts b/src/model-interfaces/common/object.interface.ts index d6e458a..019df58 100644 --- a/src/model-interfaces/common/object.interface.ts +++ b/src/model-interfaces/common/object.interface.ts @@ -1,366 +1,369 @@ import { - UrlField, - IconField, - ImageField, - AttachmentField, - AudienceField, - InReplyToField, - LocationField, - PreviewField, - ToField, - BtoField, - CcField, - BccField, - AttributedToField, - TagField, - GeneratorField, - IdField, - TypeField, - ContentField, - ContentMapField, - MediaTypeField, - NameField, - NameMapField, - EndTimeField, - StartTimeField, - PublishedField, - RepliesField, - SummaryField, - SummaryMapField, - UpdatedField, - DurationField, SourceField, LikesField, SharesField, ContextField, -} from '../../fields'; + AttachmentField, + AttributedToField, + AudienceField, + BccField, + BtoField, + CcField, + ContentField, + ContentMapField, + ContextField, + DurationField, + EndTimeField, + GeneratorField, + IconField, + IdField, + ImageField, + InReplyToField, + LikesField, + LocationField, + MediaTypeField, + NameField, + NameMapField, + PreviewField, + PublishedField, + RepliesField, + SharesField, + SourceField, + StartTimeField, + SummaryField, + SummaryMapField, + TagField, + ToField, + TypeField, + UpdatedField, + UrlField, +} from "../../fields"; export interface APObject { - /** - * JSON-LD uses the special @context property to define the processing context. - * The Field of the @context property is defined by the [JSON-LD] specification. - * - * {@link https://www.w3.org/TR/activitystreams-core/#jsonld Docs} - */ - '@context'?: ContextField | ContextField[]; - - /** - * Provides the globally unique identifier for - * an {@link https://www.w3.org/TR/activitystreams-vocabulary/#dfn-object Object} - * All objects must have unique global identifier (unless the object is transient, - * in which case the id MAY be omitted). - * - * {@link https://www.w3.org/TR/activitystreams-vocabulary/#dfn-object AS Docs (@id)} - * - * {@link https://www.w3.org/TR/activitypub/#obj-id AP Docs} - */ - id?: IdField; - - /** - * Identifies the {@link https://www.w3.org/TR/activitystreams-vocabulary/#dfn-object Object} - * type. Multiple values may be specified. - * All objects must have type. There is already a bunch of default types presented by this library. - * - * {@link https://www.w3.org/TR/activitystreams-vocabulary/#dfn-object AS Docs (@type)} - * - * {@link https://www.w3.org/TR/activitypub/#obj-id AP Docs} - */ - type?: TypeField | TypeField[]; - - /** - * Identifies resources attached or related to an object that potentially requires special handling. - * The intent is to provide a model that is at least semantically similar to attachments in email. - * - * {@link https://www.w3.org/ns/activitystreams#attachment Docs} - */ - attachment?: AttachmentField | AttachmentField[]; - - - /** - * Identifies one or more entities to which this object is attributed. - * The attributed entities might not be Actors. For instance, - * an object might be attributed to the completion of another activity. - * - * {@link https://www.w3.org/ns/activitystreams#attributedTo Docs} - */ - attributedTo?: AttributedToField | AttributedToField[]; - - /** - * Identifies one or more entities that represent the total population of entities - * for which the object can be considered to be relevant. - * - * {@link https://www.w3.org/ns/activitystreams#audience Docs} - */ - audience?: AudienceField | AudienceField[]; - - /** - * The content or textual representation of the Object encoded as a JSON string. - * By default, the value of content is HTML. The mediaType property can be - * used in the object to indicate a different content type. - * [For multiple language-tagged values use contentMap property] - * - * {@link https://www.w3.org/ns/activitystreams#content Docs} - */ - content?: ContentField; - - /** - * The content or textual representation of the Object encoded as a JSON string. - * By default, the value of content is HTML. The mediaType property can be - * used in the object to indicate a different content type. - * [For a single value use content property] - * - * {@link https://www.w3.org/ns/activitystreams#content Docs} - */ - contentMap?: ContentMapField; - - /** - * 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. - * Works different with Link - * - * {@link https://www.w3.org/ns/activitystreams#mediaType Docs} - */ - mediaType?: MediaTypeField; - - /** - * 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?: NameField; - - /** - * 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?: NameMapField; - - /** - * The date and time describing the actual or expected ending time of the object. - * When used with an Activity object, for instance, the endTime property specifies - * the moment the activity concluded or is expected to conclude. - * - * Must be provided in {@link https://www.w3schools.blog/xsd-date-and-time-data-types xsd:dateTime} - * - * {@link https://www.w3.org/ns/activitystreams#endTime Docs} - * - * @example - * 2020-08-08T08:30:11-03:00Z - * 2020-08-08T08:30:11-03:00 - * 2020-08-08T08:30:11Z - * 2020-08-08T08:30:11 - * 2020-08-08 - */ - endTime?: EndTimeField; - - /** - * The date and time describing the actual or expected starting time of the object. - * When used with an Activity object, for instance, the startTime property specifies - * the moment the activity began or is scheduled to begin. - * - * Must be provided in {@link https://www.w3schools.blog/xsd-date-and-time-data-types xsd:dateTime} - * - * {@link https://www.w3.org/ns/activitystreams#startTime Docs} - * - * @example - * 2020-08-08T08:30:11-03:00Z - * 2020-08-08T08:30:11-03:00 - * 2020-08-08T08:30:11Z - * 2020-08-08T08:30:11 - * 2020-08-08 - */ - startTime?: StartTimeField; - - /** - * Identifies the entity (e.g. an application) that generated the object. - * - * {@link https://www.w3.org/ns/activitystreams#generator Docs} - */ - generator?: GeneratorField; - - /** - * Indicates an entity (or entities) that describes an icon for this object. - * Unlike image property, the icon should have an aspect ratio of one (horizontal) - * to one (vertical) and should be suitable for presentation at a small size. - * - * {@link https://www.w3.org/ns/activitystreams#icon Docs} - */ - icon?: IconField | IconField[]; - - /** - * Indicates an entity that describes an image for this object. - * Unlike the icon property, there are no aspect ratio or display size limitations assumed. - * - * {@link https://www.w3.org/ns/activitystreams#image Docs} - */ - image?: ImageField | ImageField[]; - - /** - * Indicates one or more entities for which this object is considered a response. - * - * {@link https://www.w3.org/ns/activitystreams#inReplyTo Docs} - */ - inReplyTo?: InReplyToField | InReplyToField[]; - - /** - * Indicates one or more physical or logical locations associated with the object. - * - * {@link https://www.w3.org/ns/activitystreams#location Docs} - */ - location?: LocationField | LocationField[]; - - /** - * Identifies an entity that provides a preview of this object. - * - * {@link https://www.w3.org/ns/activitystreams#preview Docs} - */ - preview?: PreviewField; - - /** - * The date and time at which the object was published. - * - * Must be provided in {@link https://www.w3schools.blog/xsd-date-and-time-data-types xsd:dateTime} - * - * {@link https://www.w3.org/ns/activitystreams#published Docs} - * - * @example - * 2020-08-08T08:30:11-03:00Z - * 2020-08-08T08:30:11-03:00 - * 2020-08-08T08:30:11Z - * 2020-08-08T08:30:11 - * 2020-08-08 - */ - published?: PublishedField; - - /** - * Identifies a Collection containing objects considered to be responses to this object. - * - * {@link https://www.w3.org/ns/activitystreams#replies Docs} - */ - replies?: RepliesField; - - /** - * A natural language summarization of the object encoded as HTML. - * Multiple language tagged summaries MAY be provided. - * [For multiple language-tagged values use summaryMap property] - * - * {@link https://www.w3.org/ns/activitystreams#summary Docs} - */ - summary?: SummaryField; - - /** - * A natural language summarization of the object encoded as HTML. - * Multiple language tagged summaries MAY be provided. - * [For a single value use summary property] - * - * {@link https://www.w3.org/ns/activitystreams#summary Docs} - */ - summaryMap?: SummaryMapField; - - /** - * One or more "tags" that have been associated with an objects. A tag can be any kind of Object. - * The key difference between attachment and tag is that the former implies association by - * inclusion, while the latter implies associated by reference. - * - * {@link https://www.w3.org/ns/activitystreams#tag Docs} - */ - tag?: TagField | TagField[]; - - /** - * The date and time at which the object was updated. - * - * Must be provided in {@link https://www.w3schools.blog/xsd-date-and-time-data-types xsd:dateTime} - * - * {@link https://www.w3.org/ns/activitystreams#published Docs} - * - * @example - * 2020-08-08T08:30:11-03:00Z - * 2020-08-08T08:30:11-03:00 - * 2020-08-08T08:30:11Z - * 2020-08-08T08:30:11 - * 2020-08-08 - */ - updated?: UpdatedField; - - /** - * Identifies one or more links to representations of the object. - * - * {@link https://www.w3.org/ns/activitystreams#url Docs} - */ - url?: UrlField | UrlField[]; - - /** - * Identifies an entity or entities considered to be part of the public primary audience of an Object. - * - * {@link https://www.w3.org/ns/activitystreams#to Docs} - */ - to?: ToField | ToField[]; - - /** - * Identifies an Object that is part of the private primary audience of this Object. - * - * {@link https://www.w3.org/ns/activitystreams#bto Docs} - */ - bto?: BtoField | BtoField[]; - - /** - * Identifies an Object that is part of the public secondary audience of this Object. - * - * {@link https://www.w3.org/ns/activitystreams#cc Docs} - */ - cc?: CcField | CcField[]; - - /** - * Identifies one or more Objects that are part of the private secondary audience of this Object. - * - * {@link https://www.w3.org/ns/activitystreams#bcc Docs} - */ - bcc?: BccField | BccField[]; - - /** - * When the object describes a time-bound resource, such as an audio or video, a meeting, etc., - * the duration property indicates the object's approximate duration. - * - * {@link https://www.w3.org/ns/activitystreams#duration Docs} - * - * Must be provided in {@link http://www.datypic.com/sc/xsd/t-xsd_duration.html xsd:duration} - * - * @example - * PT20M (20 minutes) - * P1DT2H (1 day, 2 hours) - * P2Y6M5DT12H35M30S (2 years, 6 months, 5 days, 12 hours, 35 minutes, 30 seconds) - */ - duration?: DurationField; - - /** - * ActivityPub extends the Object by supplying the source property. The source property is intended to - * convey some sort of source from which the content markup was derived, as a form of provenance, or to - * support future editing by clients. In general, clients do the conversion from source to content, not - * the other way around. - * The value of source is itself an object which uses its own content and mediaType fields to supply source information. - * - * {@link https://www.w3.org/TR/activitypub/#source-property Docs} - */ - source?: SourceField; - - /** - * Every object MAY have a "likes" collection. This is a list of all Like activities with this object as - * the object property, added as a side effect. The likes collection MUST be either an OrderedCollection - * or a Collection and MAY be filtered on privileges of an authenticated user or as appropriate when - * no authentication is given. - * - * {@link https://www.w3.org/TR/activitypub/#likes Docs} - */ - likes?: LikesField; - - /** - * Every object MAY have a "shares" collection. This is a list of all Announce activities with this object as - * the object property, added as a side effect. The shares collection MUST be either an OrderedCollection - * or a Collection and MAY be filtered on privileges of an authenticated user or as appropriate when - * no authentication is given. - * - * {@link https://www.w3.org/TR/activitypub/#shares Docs} - */ - shares?: SharesField; -} \ No newline at end of file + /** + * JSON-LD uses the special @context property to define the processing context. + * The Field of the @context property is defined by the [JSON-LD] specification. + * + * {@link https://www.w3.org/TR/activitystreams-core/#jsonld Docs} + */ + "@context"?: ContextField | ContextField[]; + + /** + * Provides the globally unique identifier for + * an {@link https://www.w3.org/TR/activitystreams-vocabulary/#dfn-object Object} + * All objects must have unique global identifier (unless the object is transient, + * in which case the id MAY be omitted). + * + * {@link https://www.w3.org/TR/activitystreams-vocabulary/#dfn-object AS Docs (@id)} + * + * {@link https://www.w3.org/TR/activitypub/#obj-id AP Docs} + */ + id?: IdField; + + /** + * Identifies the {@link https://www.w3.org/TR/activitystreams-vocabulary/#dfn-object Object} + * type. Multiple values may be specified. + * All objects must have type. There is already a bunch of default types presented by this library. + * + * {@link https://www.w3.org/TR/activitystreams-vocabulary/#dfn-object AS Docs (@type)} + * + * {@link https://www.w3.org/TR/activitypub/#obj-id AP Docs} + */ + type?: TypeField | TypeField[]; + + /** + * Identifies resources attached or related to an object that potentially requires special handling. + * The intent is to provide a model that is at least semantically similar to attachments in email. + * + * {@link https://www.w3.org/ns/activitystreams#attachment Docs} + */ + attachment?: AttachmentField | AttachmentField[]; + + /** + * Identifies one or more entities to which this object is attributed. + * The attributed entities might not be Actors. For instance, + * an object might be attributed to the completion of another activity. + * + * {@link https://www.w3.org/ns/activitystreams#attributedTo Docs} + */ + attributedTo?: AttributedToField | AttributedToField[]; + + /** + * Identifies one or more entities that represent the total population of entities + * for which the object can be considered to be relevant. + * + * {@link https://www.w3.org/ns/activitystreams#audience Docs} + */ + audience?: AudienceField | AudienceField[]; + + /** + * The content or textual representation of the Object encoded as a JSON string. + * By default, the value of content is HTML. The mediaType property can be + * used in the object to indicate a different content type. + * [For multiple language-tagged values use contentMap property] + * + * {@link https://www.w3.org/ns/activitystreams#content Docs} + */ + content?: ContentField; + + /** + * The content or textual representation of the Object encoded as a JSON string. + * By default, the value of content is HTML. The mediaType property can be + * used in the object to indicate a different content type. + * [For a single value use content property] + * + * {@link https://www.w3.org/ns/activitystreams#content Docs} + */ + contentMap?: ContentMapField; + + /** + * 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. + * Works different with Link + * + * {@link https://www.w3.org/ns/activitystreams#mediaType Docs} + */ + mediaType?: MediaTypeField; + + /** + * 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?: NameField; + + /** + * 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?: NameMapField; + + /** + * The date and time describing the actual or expected ending time of the object. + * When used with an Activity object, for instance, the endTime property specifies + * the moment the activity concluded or is expected to conclude. + * + * Must be provided in {@link https://www.w3schools.blog/xsd-date-and-time-data-types xsd:dateTime} + * + * {@link https://www.w3.org/ns/activitystreams#endTime Docs} + * + * @example + * 2020-08-08T08:30:11-03:00Z + * 2020-08-08T08:30:11-03:00 + * 2020-08-08T08:30:11Z + * 2020-08-08T08:30:11 + * 2020-08-08 + */ + endTime?: EndTimeField; + + /** + * The date and time describing the actual or expected starting time of the object. + * When used with an Activity object, for instance, the startTime property specifies + * the moment the activity began or is scheduled to begin. + * + * Must be provided in {@link https://www.w3schools.blog/xsd-date-and-time-data-types xsd:dateTime} + * + * {@link https://www.w3.org/ns/activitystreams#startTime Docs} + * + * @example + * 2020-08-08T08:30:11-03:00Z + * 2020-08-08T08:30:11-03:00 + * 2020-08-08T08:30:11Z + * 2020-08-08T08:30:11 + * 2020-08-08 + */ + startTime?: StartTimeField; + + /** + * Identifies the entity (e.g. an application) that generated the object. + * + * {@link https://www.w3.org/ns/activitystreams#generator Docs} + */ + generator?: GeneratorField; + + /** + * Indicates an entity (or entities) that describes an icon for this object. + * Unlike image property, the icon should have an aspect ratio of one (horizontal) + * to one (vertical) and should be suitable for presentation at a small size. + * + * {@link https://www.w3.org/ns/activitystreams#icon Docs} + */ + icon?: IconField | IconField[]; + + /** + * Indicates an entity that describes an image for this object. + * Unlike the icon property, there are no aspect ratio or display size limitations assumed. + * + * {@link https://www.w3.org/ns/activitystreams#image Docs} + */ + image?: ImageField | ImageField[]; + + /** + * Indicates one or more entities for which this object is considered a response. + * + * {@link https://www.w3.org/ns/activitystreams#inReplyTo Docs} + */ + inReplyTo?: InReplyToField | InReplyToField[]; + + /** + * Indicates one or more physical or logical locations associated with the object. + * + * {@link https://www.w3.org/ns/activitystreams#location Docs} + */ + location?: LocationField | LocationField[]; + + /** + * Identifies an entity that provides a preview of this object. + * + * {@link https://www.w3.org/ns/activitystreams#preview Docs} + */ + preview?: PreviewField; + + /** + * The date and time at which the object was published. + * + * Must be provided in {@link https://www.w3schools.blog/xsd-date-and-time-data-types xsd:dateTime} + * + * {@link https://www.w3.org/ns/activitystreams#published Docs} + * + * @example + * 2020-08-08T08:30:11-03:00Z + * 2020-08-08T08:30:11-03:00 + * 2020-08-08T08:30:11Z + * 2020-08-08T08:30:11 + * 2020-08-08 + */ + published?: PublishedField; + + /** + * Identifies a Collection containing objects considered to be responses to this object. + * + * {@link https://www.w3.org/ns/activitystreams#replies Docs} + */ + replies?: RepliesField; + + /** + * A natural language summarization of the object encoded as HTML. + * Multiple language tagged summaries MAY be provided. + * [For multiple language-tagged values use summaryMap property] + * + * {@link https://www.w3.org/ns/activitystreams#summary Docs} + */ + summary?: SummaryField; + + /** + * A natural language summarization of the object encoded as HTML. + * Multiple language tagged summaries MAY be provided. + * [For a single value use summary property] + * + * {@link https://www.w3.org/ns/activitystreams#summary Docs} + */ + summaryMap?: SummaryMapField; + + /** + * One or more "tags" that have been associated with an objects. A tag can be any kind of Object. + * The key difference between attachment and tag is that the former implies association by + * inclusion, while the latter implies associated by reference. + * + * {@link https://www.w3.org/ns/activitystreams#tag Docs} + */ + tag?: TagField | TagField[]; + + /** + * The date and time at which the object was updated. + * + * Must be provided in {@link https://www.w3schools.blog/xsd-date-and-time-data-types xsd:dateTime} + * + * {@link https://www.w3.org/ns/activitystreams#published Docs} + * + * @example + * 2020-08-08T08:30:11-03:00Z + * 2020-08-08T08:30:11-03:00 + * 2020-08-08T08:30:11Z + * 2020-08-08T08:30:11 + * 2020-08-08 + */ + updated?: UpdatedField; + + /** + * Identifies one or more links to representations of the object. + * + * {@link https://www.w3.org/ns/activitystreams#url Docs} + */ + url?: UrlField | UrlField[]; + + /** + * Identifies an entity or entities considered to be part of the public primary audience of an Object. + * + * {@link https://www.w3.org/ns/activitystreams#to Docs} + */ + to?: ToField | ToField[]; + + /** + * Identifies an Object that is part of the private primary audience of this Object. + * + * {@link https://www.w3.org/ns/activitystreams#bto Docs} + */ + bto?: BtoField | BtoField[]; + + /** + * Identifies an Object that is part of the public secondary audience of this Object. + * + * {@link https://www.w3.org/ns/activitystreams#cc Docs} + */ + cc?: CcField | CcField[]; + + /** + * Identifies one or more Objects that are part of the private secondary audience of this Object. + * + * {@link https://www.w3.org/ns/activitystreams#bcc Docs} + */ + bcc?: BccField | BccField[]; + + /** + * When the object describes a time-bound resource, such as an audio or video, a meeting, etc., + * the duration property indicates the object's approximate duration. + * + * {@link https://www.w3.org/ns/activitystreams#duration Docs} + * + * Must be provided in {@link http://www.datypic.com/sc/xsd/t-xsd_duration.html xsd:duration} + * + * @example + * PT20M (20 minutes) + * P1DT2H (1 day, 2 hours) + * P2Y6M5DT12H35M30S (2 years, 6 months, 5 days, 12 hours, 35 minutes, 30 seconds) + */ + duration?: DurationField; + + /** + * ActivityPub extends the Object by supplying the source property. The source property is intended to + * convey some sort of source from which the content markup was derived, as a form of provenance, or to + * support future editing by clients. In general, clients do the conversion from source to content, not + * the other way around. + * The value of source is itself an object which uses its own content and mediaType fields to supply source information. + * + * {@link https://www.w3.org/TR/activitypub/#source-property Docs} + */ + source?: SourceField; + + /** + * Every object MAY have a "likes" collection. This is a list of all Like activities with this object as + * the object property, added as a side effect. The likes collection MUST be either an OrderedCollection + * or a Collection and MAY be filtered on privileges of an authenticated user or as appropriate when + * no authentication is given. + * + * {@link https://www.w3.org/TR/activitypub/#likes Docs} + */ + likes?: LikesField; + + /** + * Every object MAY have a "shares" collection. This is a list of all Announce activities with this object as + * the object property, added as a side effect. The shares collection MUST be either an OrderedCollection + * or a Collection and MAY be filtered on privileges of an authenticated user or as appropriate when + * no authentication is given. + * + * {@link https://www.w3.org/TR/activitypub/#shares Docs} + */ + shares?: SharesField; +} diff --git a/src/model-interfaces/common/place.interface.ts b/src/model-interfaces/common/place.interface.ts index 51ea944..ab71d8b 100644 --- a/src/model-interfaces/common/place.interface.ts +++ b/src/model-interfaces/common/place.interface.ts @@ -1,60 +1,64 @@ -import {APObject} from './object.interface'; import { - AccuracyField, - AltitudeField, - LatitudeField, - LongitudeField, - RadiusField, - UnitsField -} from '../../fields'; - + AccuracyField, + AltitudeField, + LatitudeField, + LongitudeField, + RadiusField, + UnitsField, +} from "../../fields"; +import { APObject } from "./object.interface"; export interface APPlace extends APObject { + type: "Place"; + + /** + * 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?: AccuracyField; + + /** + * 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?: AltitudeField; + + /** + * The latitude of a place + * + * {@link https://www.w3.org/ns/activitystreams#latitude Docs} + */ + latitude?: LatitudeField; - /** - * 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?: AccuracyField; - - /** - * 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?: AltitudeField; - - /** - * The latitude of a place - * - * {@link https://www.w3.org/ns/activitystreams#latitude Docs} - */ - latitude?: LatitudeField; - - /** - * The longitude of a place - * - * {@link https://www.w3.org/ns/activitystreams#longitude Docs} - */ - longitude?: LongitudeField; - - /** - * 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?: RadiusField; - - /** - * 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?: UnitsField; + /** + * The longitude of a place + * + * {@link https://www.w3.org/ns/activitystreams#longitude Docs} + */ + longitude?: LongitudeField; + + /** + * 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?: RadiusField; + + /** + * 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?: UnitsField; } + +export const ObjectIsPlace = (object: APObject): object is APPlace => { + return object.type == "Place"; +}; diff --git a/src/model-interfaces/common/profile.interface.ts b/src/model-interfaces/common/profile.interface.ts index 06da25f..849587a 100644 --- a/src/model-interfaces/common/profile.interface.ts +++ b/src/model-interfaces/common/profile.interface.ts @@ -1,13 +1,18 @@ -import {DescribesField} from '../../fields'; -import { APObject } from './object.interface'; +import { DescribesField } from "../../fields"; +import { APObject } from "./object.interface"; export interface APProfile extends APObject { + type: "Profile"; - /** - * On a Profile object, the describes property identifies - * the object described by the Profile. - * - * {@link https://www.w3.org/ns/activitystreams#describes Docs} - */ - describes?: DescribesField; + /** + * On a Profile object, the describes property identifies + * the object described by the Profile. + * + * {@link https://www.w3.org/ns/activitystreams#describes Docs} + */ + describes?: DescribesField; } + +export const ObjectIsProfile = (object: APObject): object is APProfile => { + return object.type == "Profile"; +}; diff --git a/src/model-interfaces/common/relationship.interface.ts b/src/model-interfaces/common/relationship.interface.ts index 16475f4..c82f091 100644 --- a/src/model-interfaces/common/relationship.interface.ts +++ b/src/model-interfaces/common/relationship.interface.ts @@ -1,29 +1,36 @@ -import {SubjectField, ObjectField, RelationshipField} from '../../fields'; -import { APObject } from './object.interface'; +import { ObjectField, RelationshipField, SubjectField } from "../../fields"; +import { APObject } from "./object.interface"; export interface APRelationship extends APObject { + type: "Relationship"; - /** - * 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?: SubjectField; + /** + * 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?: SubjectField; - /** - * When used within a Relationship describes the entity to which the subject is related. - * - * {@link https://www.w3.org/ns/activitystreams#object Docs} - */ - object?: ObjectField | ObjectField[]; + /** + * When used within a Relationship describes the entity to which the subject is related. + * + * {@link https://www.w3.org/ns/activitystreams#object Docs} + */ + object?: ObjectField | ObjectField[]; - /** - * 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?: RelationshipField; + /** + * 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?: RelationshipField; } + +export const ObjectIsRelationship = ( + object: APObject, +): object is APRelationship => { + return object.type == "Relationship"; +}; diff --git a/src/model-interfaces/common/tombstone.interface.ts b/src/model-interfaces/common/tombstone.interface.ts index 3fd5e4b..4df00fa 100644 --- a/src/model-interfaces/common/tombstone.interface.ts +++ b/src/model-interfaces/common/tombstone.interface.ts @@ -1,23 +1,28 @@ -import {DeletedField, FormerTypeField} from '../../fields'; -import { APObject } from './object.interface'; +import { DeletedField, FormerTypeField } from "../../fields"; +import { APObject } from "./object.interface"; export interface APTombstone extends APObject { + type: "Tombstone"; - /** - * 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?: FormerTypeField; + /** + * 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?: FormerTypeField; - /** - * 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?: DeletedField; + /** + * 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?: DeletedField; } + +export const ObjectIsTombstone = (object: APObject): object is APTombstone => { + return object.type == "Tombstone"; +}; diff --git a/src/model-interfaces/documents/audio.interface.ts b/src/model-interfaces/documents/audio.interface.ts index 4032139..03bca19 100644 --- a/src/model-interfaces/documents/audio.interface.ts +++ b/src/model-interfaces/documents/audio.interface.ts @@ -1,3 +1,7 @@ -import { APDocument } from './document.interface'; +import { APObject } from "../common/object.interface"; -export type APAudio = APDocument \ No newline at end of file +export type APAudio = APObject & { type: "Audio" }; + +export const ObjectIsAudio = (object: APObject): object is APAudio => { + return object.type == "Audio"; +}; diff --git a/src/model-interfaces/documents/document.interface.ts b/src/model-interfaces/documents/document.interface.ts index 6195ef2..6ebfe34 100644 --- a/src/model-interfaces/documents/document.interface.ts +++ b/src/model-interfaces/documents/document.interface.ts @@ -1,3 +1,7 @@ -import {APObject} from '../common/object.interface'; +import { APObject } from "../common/object.interface"; -export type APDocument = APObject +export type APDocument = APObject & { type: "Document" }; + +export const ObjectIsDocument = (object: APObject): object is APDocument => { + return object.type == "Document"; +}; diff --git a/src/model-interfaces/documents/image.interface.ts b/src/model-interfaces/documents/image.interface.ts index 536d175..ba9a6ae 100644 --- a/src/model-interfaces/documents/image.interface.ts +++ b/src/model-interfaces/documents/image.interface.ts @@ -1,3 +1,7 @@ -import { APDocument } from './document.interface'; +import { APObject } from "../common/object.interface"; -export type APImage = APDocument \ No newline at end of file +export type APImage = APObject & { type: "Image" }; + +export const ObjectIsImage = (object: APObject): object is APImage => { + return object.type == "Image"; +}; diff --git a/src/model-interfaces/documents/page.interface.ts b/src/model-interfaces/documents/page.interface.ts index a8fa6e5..cc23623 100644 --- a/src/model-interfaces/documents/page.interface.ts +++ b/src/model-interfaces/documents/page.interface.ts @@ -1,3 +1,7 @@ -import { APDocument } from './document.interface'; +import { APObject } from "../common/object.interface"; -export type APPage = APDocument \ No newline at end of file +export type APPage = APObject & { type: "Page" }; + +export const ObjectIsPage = (object: APObject): object is APPage => { + return object.type == "Page"; +}; diff --git a/src/model-interfaces/documents/video.interface.ts b/src/model-interfaces/documents/video.interface.ts index 205f7e1..fe9af52 100644 --- a/src/model-interfaces/documents/video.interface.ts +++ b/src/model-interfaces/documents/video.interface.ts @@ -1,3 +1,7 @@ -import { APDocument } from './document.interface'; +import { APObject } from "../common/object.interface"; -export type APVideo = APDocument \ No newline at end of file +export type APVideo = APObject & { type: "Video" }; + +export const ObjectIsVideo = (object: APObject): object is APVideo => { + return object.type == "Video"; +}; diff --git a/src/model-interfaces/index.ts b/src/model-interfaces/index.ts index 212e7cc..2cce63b 100644 --- a/src/model-interfaces/index.ts +++ b/src/model-interfaces/index.ts @@ -1,59 +1,59 @@ -export * from './common/article.interface'; -export * from './common/event.interface'; -export * from './common/link.interface'; -export * from './common/mention.interface'; -export * from './common/note.interface'; -export * from './common/object.interface'; -export * from './common/place.interface'; -export * from './common/profile.interface'; -export * from './common/tombstone.interface'; -export * from './common/relationship.interface'; +export * from "./common/article.interface"; +export * from "./common/event.interface"; +export * from "./common/link.interface"; +export * from "./common/mention.interface"; +export * from "./common/note.interface"; +export * from "./common/object.interface"; +export * from "./common/place.interface"; +export * from "./common/profile.interface"; +export * from "./common/tombstone.interface"; +export * from "./common/relationship.interface"; -export * from './activities/activity.interface'; -export * from './activities/intransitive-activity.interface'; -export * from './activities/question.interface'; -export * from './activities/accept.interface'; -export * from './activities/add.interface'; -export * from './activities/announce.interface'; -export * from './activities/arrive.interface'; -export * from './activities/block.interface'; -export * from './activities/create.interface'; -export * from './activities/delete.interface'; -export * from './activities/dislike.interface'; -export * from './activities/flag.interface'; -export * from './activities/follow.interface'; -export * from './activities/ignore.interface'; -export * from './activities/invite.interface'; -export * from './activities/join.interface'; -export * from './activities/leave.interface'; -export * from './activities/like.interface'; -export * from './activities/listen.interface'; -export * from './activities/move.interface'; -export * from './activities/offer.interface'; -export * from './activities/read.interface'; -export * from './activities/reject.interface'; -export * from './activities/remove.interface'; -export * from './activities/tentative-accept.interface'; -export * from './activities/tentative-reject.interface'; -export * from './activities/travel.interface'; -export * from './activities/undo.interface'; -export * from './activities/update.interface'; -export * from './activities/view.interface'; +export * from "./activities/activity.interface"; +export * from "./activities/intransitive-activity.interface"; +export * from "./activities/question.interface"; +export * from "./activities/accept.interface"; +export * from "./activities/add.interface"; +export * from "./activities/announce.interface"; +export * from "./activities/arrive.interface"; +export * from "./activities/block.interface"; +export * from "./activities/create.interface"; +export * from "./activities/delete.interface"; +export * from "./activities/dislike.interface"; +export * from "./activities/flag.interface"; +export * from "./activities/follow.interface"; +export * from "./activities/ignore.interface"; +export * from "./activities/invite.interface"; +export * from "./activities/join.interface"; +export * from "./activities/leave.interface"; +export * from "./activities/like.interface"; +export * from "./activities/listen.interface"; +export * from "./activities/move.interface"; +export * from "./activities/offer.interface"; +export * from "./activities/read.interface"; +export * from "./activities/reject.interface"; +export * from "./activities/remove.interface"; +export * from "./activities/tentative-accept.interface"; +export * from "./activities/tentative-reject.interface"; +export * from "./activities/travel.interface"; +export * from "./activities/undo.interface"; +export * from "./activities/update.interface"; +export * from "./activities/view.interface"; -export * from './actors/actor.interface'; -export * from './actors/application.interface'; -export * from './actors/organization.interface'; -export * from './actors/group.interface'; -export * from './actors/person.interface'; -export * from './actors/service.interface'; +export * from "./actors/actor.interface"; +export * from "./actors/application.interface"; +export * from "./actors/organization.interface"; +export * from "./actors/group.interface"; +export * from "./actors/person.interface"; +export * from "./actors/service.interface"; -export * from './collections/collection.interface'; -export * from './collections/collection-page.interface'; -export * from './collections/ordered-collection.interface'; -export * from './collections/ordered-collection-page.interface'; +export * from "./collections/collection.interface"; +export * from "./collections/collection-page.interface"; +export * from "./collections/ordered-collection.interface"; +export * from "./collections/ordered-collection-page.interface"; -export * from './documents/document.interface'; -export * from './documents/audio.interface'; -export * from './documents/image.interface'; -export * from './documents/page.interface'; -export * from './documents/video.interface'; \ No newline at end of file +export * from "./documents/document.interface"; +export * from "./documents/audio.interface"; +export * from "./documents/image.interface"; +export * from "./documents/page.interface"; +export * from "./documents/video.interface";