kopia lustrzana https://github.com/activitypub-js/activitypub-models
clean up
rodzic
591d8634c4
commit
2dac530504
|
@ -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;
|
||||
|
|
|
@ -11,10 +11,9 @@ export interface ModelBaseAPWithContext {
|
|||
export class ASBase<T> {
|
||||
public fields: T & ModelBaseAPWithContext;
|
||||
|
||||
constructor(type: string, fields: T) {
|
||||
constructor(fields: T) {
|
||||
// TODO: make recursive copy
|
||||
this.fields = {
|
||||
type,
|
||||
...fields,
|
||||
} as T & ModelBaseAPWithContext;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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<ActorFields>{
|
||||
constructor(fields: ActorFields) {
|
||||
super(fields);
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -12,6 +12,9 @@ import {ASModelType} from "../../common/common.types";
|
|||
*/
|
||||
export class Activity extends ASBase<ActivityFields>{
|
||||
constructor(fields: ActivityFields) {
|
||||
super(ASModelType.Activity, fields);
|
||||
super({
|
||||
type: ASModelType.Activity,
|
||||
...fields
|
||||
})
|
||||
}
|
||||
}
|
|
@ -9,6 +9,9 @@ import {ApplicationFields} from "./Application.types";
|
|||
*/
|
||||
export class Application extends ASBase<ApplicationFields>{
|
||||
constructor(fields: ApplicationFields) {
|
||||
super(ASModelType.Application, fields);
|
||||
super({
|
||||
type: ASModelType.Application,
|
||||
...fields
|
||||
})
|
||||
}
|
||||
}
|
|
@ -9,6 +9,9 @@ import {ArticleFields} from "./Article.types";
|
|||
*/
|
||||
export class Article extends ASBase<ArticleFields>{
|
||||
constructor(fields: ArticleFields) {
|
||||
super(ASModelType.Article, fields);
|
||||
super({
|
||||
type: ASModelType.Article,
|
||||
...fields
|
||||
})
|
||||
}
|
||||
}
|
|
@ -9,6 +9,9 @@ import {ASEventFields} from "./ASEvent.types";
|
|||
*/
|
||||
export class ASEvent extends ASBase<ASEventFields>{
|
||||
constructor(fields: ASEventFields) {
|
||||
super(ASModelType.Event, fields);
|
||||
super({
|
||||
type: ASModelType.Event,
|
||||
...fields
|
||||
})
|
||||
}
|
||||
}
|
|
@ -11,6 +11,9 @@ import {ASModelType} from "../../common/common.types";
|
|||
*/
|
||||
export class ASObject extends ASBase<ASObjectFields>{
|
||||
constructor(fields: ASObjectFields) {
|
||||
super(ASModelType.Object, fields);
|
||||
super({
|
||||
type: ASModelType.Object,
|
||||
...fields
|
||||
})
|
||||
}
|
||||
}
|
|
@ -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.
|
||||
|
|
|
@ -9,6 +9,9 @@ import {DocumentFields} from "./Document.types";
|
|||
*/
|
||||
export class Document extends ASBase<DocumentFields>{
|
||||
constructor(fields: DocumentFields) {
|
||||
super(ASModelType.Document, fields);
|
||||
super({
|
||||
type: ASModelType.Document,
|
||||
...fields
|
||||
})
|
||||
}
|
||||
}
|
|
@ -9,6 +9,9 @@ import {GroupFields} from "./Group.types";
|
|||
*/
|
||||
export class Group extends ASBase<GroupFields>{
|
||||
constructor(fields: GroupFields) {
|
||||
super(ASModelType.Group, fields);
|
||||
super({
|
||||
type: ASModelType.Group,
|
||||
...fields
|
||||
})
|
||||
}
|
||||
}
|
|
@ -11,6 +11,9 @@ import {ASModelType} from "../../common/common.types";
|
|||
*/
|
||||
export class IntransitiveActivity extends ASBase<IntransitiveActivityFields>{
|
||||
constructor(fields: IntransitiveActivityFields) {
|
||||
super(ASModelType.Activity, fields);
|
||||
super({
|
||||
type: ASModelType.Activity,
|
||||
...fields
|
||||
})
|
||||
}
|
||||
}
|
|
@ -9,6 +9,9 @@ import {NoteFields} from "./Note.types";
|
|||
*/
|
||||
export class Note extends ASBase<NoteFields>{
|
||||
constructor(fields: NoteFields) {
|
||||
super(ASModelType.Note, fields);
|
||||
super({
|
||||
type: ASModelType.Note,
|
||||
...fields
|
||||
})
|
||||
}
|
||||
}
|
|
@ -9,6 +9,9 @@ import {OrganizationFields} from "./Organization.types";
|
|||
*/
|
||||
export class Organization extends ASBase<OrganizationFields>{
|
||||
constructor(fields: OrganizationFields) {
|
||||
super(ASModelType.Organization, fields);
|
||||
super({
|
||||
type: ASModelType.Organization,
|
||||
...fields
|
||||
})
|
||||
}
|
||||
}
|
|
@ -9,6 +9,9 @@ import {PersonFields} from "./Person.types";
|
|||
*/
|
||||
export class Person extends ASBase<PersonFields>{
|
||||
constructor(fields: PersonFields) {
|
||||
super(ASModelType.Person, fields);
|
||||
super({
|
||||
type: ASModelType.Person,
|
||||
...fields
|
||||
})
|
||||
}
|
||||
}
|
|
@ -9,6 +9,9 @@ import {ServiceFields} from "./Service.types";
|
|||
*/
|
||||
export class Service extends ASBase<ServiceFields>{
|
||||
constructor(fields: ServiceFields) {
|
||||
super(ASModelType.Article, fields);
|
||||
super({
|
||||
type: ASModelType.Service,
|
||||
...fields
|
||||
})
|
||||
}
|
||||
}
|
Ładowanie…
Reference in New Issue