diff --git a/src/common/common.types.ts b/src/common/common.types.ts index 89dc2be..7cae212 100644 --- a/src/common/common.types.ts +++ b/src/common/common.types.ts @@ -1,4 +1,3 @@ -import { Link } from "../models/Link.model"; import {ASObject} from "../models/asObject/ASObject.model"; export enum ASModelType { @@ -29,6 +28,8 @@ export type Relationship = 'placeholder'; export type Tombstone = 'placeholder'; export type Video = 'placeholder'; export type Mention = 'placeholder'; +export type Link = 'placeholder'; +export type Collection = 'placeholder'; export type AnyASObject = ASObject | Article | Audio | Document | Event | Image | Note | Page | Place | Profile | Relationship | Tombstone | Video; export type DateTime = string; export type Duration = string; @@ -44,6 +45,7 @@ export type ToValue = string | AnyASObject | Link; export type BtoValue = string | AnyASObject | Link; export type CcValue = string | AnyASObject | Link; export type BccValue = string | AnyASObject | Link; +export type GeneratorValue = string | ASObject | Link; export type ObjectValue = string | AnyASObject | Link; export type AttributedToValue = string | AnyASObject | Link | Mention; export type TagValue = string | AnyASObject | Link | Mention; diff --git a/src/models/ASBase.model.ts b/src/models/ASBase.model.ts index 51ecd00..d7cb0f5 100644 --- a/src/models/ASBase.model.ts +++ b/src/models/ASBase.model.ts @@ -11,10 +11,9 @@ export interface ModelBaseAPWithContext { export class ASBase { public fields: T & ModelBaseAPWithContext; - constructor(type: string, fields: T) { + constructor(fields: T) { // TODO: make recursive copy this.fields = { - type, ...fields, } as T & ModelBaseAPWithContext; } diff --git a/src/models/ASCollectionBase.model.ts b/src/models/ASCollectionBase.model.ts deleted file mode 100644 index b180cbd..0000000 --- a/src/models/ASCollectionBase.model.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { ASObject, ASObjectFields } from "./asObject/ASObject.model"; - -// TODO: types -// https://www.w3.org/TR/activitystreams-core/#collection -export interface ASCollectionBaseFields extends ASObjectFields { - totalItems?: any; - first?: any; - last?: any; - current?: any; -} - -export class ASCollectionBase extends ASObject { - constructor(fields: ASCollectionBaseFields) { - super(fields); - } -} \ No newline at end of file diff --git a/src/models/Actor.model.ts b/src/models/Actor.model.ts deleted file mode 100644 index c8a4c51..0000000 --- a/src/models/Actor.model.ts +++ /dev/null @@ -1,22 +0,0 @@ -import {ASBase} from "./ASBase.model"; -import {ASObjectFields} from "./asObject/ASObject.model"; - -export enum ActorTypes { - Application = 'Application', - Group = 'Group', - Organization = 'Organization', - Person = 'Person', - Service = 'Service' -} - -// TODO: types -// https://www.w3.org/TR/activitystreams-core/#actors -export interface ActorFields extends ASObjectFields { - type?: any | ActorTypes; // ? -} - -export class Actor extends ASBase{ - constructor(fields: ActorFields) { - super(fields); - } -} \ No newline at end of file diff --git a/src/models/Collection.model.ts b/src/models/Collection.model.ts deleted file mode 100644 index 62215f0..0000000 --- a/src/models/Collection.model.ts +++ /dev/null @@ -1,13 +0,0 @@ -import {ASCollectionBase, ASCollectionBaseFields} from "./ASCollectionBase.model"; - -// TODO: types -// https://www.w3.org/TR/activitystreams-core/#collection -export interface CollectionFields extends ASCollectionBaseFields { - items?: any; // Objects? Links? -} - -export class Collection extends ASCollectionBase { - constructor(fields: CollectionFields) { - super(fields); - } -} \ No newline at end of file diff --git a/src/models/CollectionPage.model.ts b/src/models/CollectionPage.model.ts deleted file mode 100644 index 9600804..0000000 --- a/src/models/CollectionPage.model.ts +++ /dev/null @@ -1,18 +0,0 @@ -import {ASCollectionBase, ASCollectionBaseFields} from "./ASCollectionBase.model"; - -// TODO: types -// https://www.w3.org/TR/activitystreams-core/#collection -export interface CollectionPageFields extends ASCollectionBaseFields { - partOf?: any; - first?: any; - next?: any; - prev?: any; - last?: any; - current?: any; -} - -export class CollectionPage extends ASCollectionBase { - constructor(fields: CollectionPageFields) { - super(fields); - } -} \ No newline at end of file diff --git a/src/models/OrderedCollection.model.ts b/src/models/OrderedCollection.model.ts deleted file mode 100644 index da2b291..0000000 --- a/src/models/OrderedCollection.model.ts +++ /dev/null @@ -1,14 +0,0 @@ -import {ASCollectionBase, ASCollectionBaseFields} from "./ASCollectionBase.model"; - -// TODO: types -// https://www.w3.org/TR/activitystreams-core/#collection -export interface OrderedCollectionFields extends ASCollectionBaseFields { - orderedItems?: any; // Objects? Links? -} - -// TODO: sort method? -export class OrderedCollection extends ASCollectionBase { - constructor(fields: OrderedCollectionFields) { - super(fields); - } -} \ No newline at end of file diff --git a/src/models/OrderedCollectionPage.model.ts b/src/models/OrderedCollectionPage.model.ts deleted file mode 100644 index 8df62c9..0000000 --- a/src/models/OrderedCollectionPage.model.ts +++ /dev/null @@ -1,14 +0,0 @@ -import {CollectionPage, CollectionPageFields} from "./CollectionPage.model"; - -// TODO: types -// TODO: is it correct? -// https://www.w3.org/TR/activitystreams-core/#collection -export interface OrderedCollectionPageFields extends CollectionPageFields { - startIndex?: any; -} - -export class OrderedCollectionPage extends CollectionPage { - constructor(fields: OrderedCollectionPageFields) { - super(fields); - } -} \ No newline at end of file diff --git a/src/models/activity/Activity.model.ts b/src/models/activity/Activity.model.ts index 4a7e6b7..e2e5c8b 100644 --- a/src/models/activity/Activity.model.ts +++ b/src/models/activity/Activity.model.ts @@ -12,6 +12,9 @@ import {ASModelType} from "../../common/common.types"; */ export class Activity extends ASBase{ constructor(fields: ActivityFields) { - super(ASModelType.Activity, fields); + super({ + type: ASModelType.Activity, + ...fields + }) } } \ No newline at end of file diff --git a/src/models/application/Application.model.ts b/src/models/application/Application.model.ts index 5785a09..3721d25 100644 --- a/src/models/application/Application.model.ts +++ b/src/models/application/Application.model.ts @@ -9,6 +9,9 @@ import {ApplicationFields} from "./Application.types"; */ export class Application extends ASBase{ constructor(fields: ApplicationFields) { - super(ASModelType.Application, fields); + super({ + type: ASModelType.Application, + ...fields + }) } } \ No newline at end of file diff --git a/src/models/article/Article.model.ts b/src/models/article/Article.model.ts index 250f042..cefcef3 100644 --- a/src/models/article/Article.model.ts +++ b/src/models/article/Article.model.ts @@ -9,6 +9,9 @@ import {ArticleFields} from "./Article.types"; */ export class Article extends ASBase{ constructor(fields: ArticleFields) { - super(ASModelType.Article, fields); + super({ + type: ASModelType.Article, + ...fields + }) } } \ No newline at end of file diff --git a/src/models/asEvent/ASEvent.model.ts b/src/models/asEvent/ASEvent.model.ts index f87d6de..ec6b66f 100644 --- a/src/models/asEvent/ASEvent.model.ts +++ b/src/models/asEvent/ASEvent.model.ts @@ -9,6 +9,9 @@ import {ASEventFields} from "./ASEvent.types"; */ export class ASEvent extends ASBase{ constructor(fields: ASEventFields) { - super(ASModelType.Event, fields); + super({ + type: ASModelType.Event, + ...fields + }) } } \ No newline at end of file diff --git a/src/models/asObject/ASObject.model.ts b/src/models/asObject/ASObject.model.ts index b6c10ad..d26a657 100644 --- a/src/models/asObject/ASObject.model.ts +++ b/src/models/asObject/ASObject.model.ts @@ -11,6 +11,9 @@ import {ASModelType} from "../../common/common.types"; */ export class ASObject extends ASBase{ constructor(fields: ASObjectFields) { - super(ASModelType.Object, fields); + super({ + type: ASModelType.Object, + ...fields + }) } } \ No newline at end of file diff --git a/src/models/asObject/ASObject.types.ts b/src/models/asObject/ASObject.types.ts index 615e6dd..f518982 100644 --- a/src/models/asObject/ASObject.types.ts +++ b/src/models/asObject/ASObject.types.ts @@ -1,6 +1,3 @@ -import {Link} from "../Link.model"; -import {Collection} from "../Collection.model"; -import { ASObject } from "./ASObject.model"; import { DateTime, Duration, @@ -18,10 +15,10 @@ import { BccValue, AttributedToValue, TagValue, + GeneratorValue, + Collection, } from "../../common/common.types"; -// TODO: types -// https://www.w3.org/TR/activitystreams-core/#object export interface ASObjectFields { /** * Provides the globally unique identifier for @@ -158,7 +155,7 @@ export interface ASObjectFields { * * {@link https://www.w3.org/ns/activitystreams#generator Docs} */ - generator?: (string | ASObject | Link); + generator?: GeneratorValue; /** * Indicates an entity (or entities) that describes an icon for this object. diff --git a/src/models/document/Document.model.ts b/src/models/document/Document.model.ts index 1957303..0939f0b 100644 --- a/src/models/document/Document.model.ts +++ b/src/models/document/Document.model.ts @@ -9,6 +9,9 @@ import {DocumentFields} from "./Document.types"; */ export class Document extends ASBase{ constructor(fields: DocumentFields) { - super(ASModelType.Document, fields); + super({ + type: ASModelType.Document, + ...fields + }) } } \ No newline at end of file diff --git a/src/models/group/Group.model.ts b/src/models/group/Group.model.ts index 995de73..b1f0602 100644 --- a/src/models/group/Group.model.ts +++ b/src/models/group/Group.model.ts @@ -9,6 +9,9 @@ import {GroupFields} from "./Group.types"; */ export class Group extends ASBase{ constructor(fields: GroupFields) { - super(ASModelType.Group, fields); + super({ + type: ASModelType.Group, + ...fields + }) } } \ No newline at end of file diff --git a/src/models/intransitiveActivity/IntransitiveActivity.model.ts b/src/models/intransitiveActivity/IntransitiveActivity.model.ts index 0394637..0688a8d 100644 --- a/src/models/intransitiveActivity/IntransitiveActivity.model.ts +++ b/src/models/intransitiveActivity/IntransitiveActivity.model.ts @@ -11,6 +11,9 @@ import {ASModelType} from "../../common/common.types"; */ export class IntransitiveActivity extends ASBase{ constructor(fields: IntransitiveActivityFields) { - super(ASModelType.Activity, fields); + super({ + type: ASModelType.Activity, + ...fields + }) } } \ No newline at end of file diff --git a/src/models/note/Note.model.ts b/src/models/note/Note.model.ts index 8a25c81..a1fd475 100644 --- a/src/models/note/Note.model.ts +++ b/src/models/note/Note.model.ts @@ -9,6 +9,9 @@ import {NoteFields} from "./Note.types"; */ export class Note extends ASBase{ constructor(fields: NoteFields) { - super(ASModelType.Note, fields); + super({ + type: ASModelType.Note, + ...fields + }) } } \ No newline at end of file diff --git a/src/models/organization/Organization.model.ts b/src/models/organization/Organization.model.ts index 6774f1e..b454862 100644 --- a/src/models/organization/Organization.model.ts +++ b/src/models/organization/Organization.model.ts @@ -9,6 +9,9 @@ import {OrganizationFields} from "./Organization.types"; */ export class Organization extends ASBase{ constructor(fields: OrganizationFields) { - super(ASModelType.Organization, fields); + super({ + type: ASModelType.Organization, + ...fields + }) } } \ No newline at end of file diff --git a/src/models/person/Person.model.ts b/src/models/person/Person.model.ts index e89fcd9..0781df4 100644 --- a/src/models/person/Person.model.ts +++ b/src/models/person/Person.model.ts @@ -9,6 +9,9 @@ import {PersonFields} from "./Person.types"; */ export class Person extends ASBase{ constructor(fields: PersonFields) { - super(ASModelType.Person, fields); + super({ + type: ASModelType.Person, + ...fields + }) } } \ No newline at end of file diff --git a/src/models/service/Service.model.ts b/src/models/service/Service.model.ts index cbef18d..52147a8 100644 --- a/src/models/service/Service.model.ts +++ b/src/models/service/Service.model.ts @@ -9,6 +9,9 @@ import {ServiceFields} from "./Service.types"; */ export class Service extends ASBase{ constructor(fields: ServiceFields) { - super(ASModelType.Article, fields); + super({ + type: ASModelType.Service, + ...fields + }) } } \ No newline at end of file