kopia lustrzana https://github.com/activitypub-js/activitypub-models
add ModelType enum
rodzic
403da396d9
commit
4017e23e84
|
@ -1,6 +1,11 @@
|
|||
import { Link } from "../models/Link.model";
|
||||
import {ASObject} from "../models/asObject/ASObject.model";
|
||||
|
||||
export enum ModelType {
|
||||
Object = 'Object',
|
||||
Activity = 'Activity'
|
||||
}
|
||||
|
||||
// TODO: implement
|
||||
export type Image = 'placeholder';
|
||||
export type Article = 'placeholder';
|
||||
|
|
|
@ -11,9 +11,10 @@ export interface ModelBaseAPWithContext {
|
|||
export class ASBase<T> {
|
||||
public fields: T & ModelBaseAPWithContext;
|
||||
|
||||
constructor(fields: T) {
|
||||
constructor(type: string, fields: T) {
|
||||
// TODO: make recursive copy
|
||||
this.fields = {
|
||||
type,
|
||||
...fields,
|
||||
} as T & ModelBaseAPWithContext;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import {ASBase} from "../ASBase.model";
|
||||
import {IntransitiveActivityFields} from './IntransitiveActivity.types';
|
||||
import {ModelType} from "../../common/common.types";
|
||||
|
||||
/**
|
||||
* Instances of IntransitiveActivity are a subtype of
|
||||
|
@ -10,6 +11,6 @@ import {IntransitiveActivityFields} from './IntransitiveActivity.types';
|
|||
*/
|
||||
export class IntransitiveActivity extends ASBase<IntransitiveActivityFields>{
|
||||
constructor(fields: IntransitiveActivityFields) {
|
||||
super(fields);
|
||||
super(ModelType.Activity, fields);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
import {ASBase} from "../ASBase.model";
|
||||
import { ActivityFields } from "./Activity.types";
|
||||
import {ModelType} from "../../common/common.types";
|
||||
|
||||
/**
|
||||
* An Activity is a subtype of Object that describes some form of action that may happen,
|
||||
|
@ -11,6 +12,6 @@ import { ActivityFields } from "./Activity.types";
|
|||
*/
|
||||
export class Activity extends ASBase<ActivityFields>{
|
||||
constructor(fields: ActivityFields) {
|
||||
super(fields);
|
||||
super(ModelType.Activity, fields);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
import {ASBase} from "../ASBase.model";
|
||||
import { ASObjectFields } from "./ASObject.types";
|
||||
import {ModelType} from "../../common/common.types";
|
||||
|
||||
/**
|
||||
* Describes an object of any kind. The Object type serves as the base type for most of
|
||||
|
@ -10,6 +11,6 @@ import { ASObjectFields } from "./ASObject.types";
|
|||
*/
|
||||
export class ASObject extends ASBase<ASObjectFields>{
|
||||
constructor(fields: ASObjectFields) {
|
||||
super(fields);
|
||||
super(ModelType.Object, fields);
|
||||
}
|
||||
}
|
Ładowanie…
Reference in New Issue