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 { Link } from "../models/Link.model";
|
||||||
import {ASObject} from "../models/asObject/ASObject.model";
|
import {ASObject} from "../models/asObject/ASObject.model";
|
||||||
|
|
||||||
|
export enum ModelType {
|
||||||
|
Object = 'Object',
|
||||||
|
Activity = 'Activity'
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: implement
|
// TODO: implement
|
||||||
export type Image = 'placeholder';
|
export type Image = 'placeholder';
|
||||||
export type Article = 'placeholder';
|
export type Article = 'placeholder';
|
||||||
|
|
|
@ -11,9 +11,10 @@ export interface ModelBaseAPWithContext {
|
||||||
export class ASBase<T> {
|
export class ASBase<T> {
|
||||||
public fields: T & ModelBaseAPWithContext;
|
public fields: T & ModelBaseAPWithContext;
|
||||||
|
|
||||||
constructor(fields: T) {
|
constructor(type: string, fields: T) {
|
||||||
// TODO: make recursive copy
|
// TODO: make recursive copy
|
||||||
this.fields = {
|
this.fields = {
|
||||||
|
type,
|
||||||
...fields,
|
...fields,
|
||||||
} as T & ModelBaseAPWithContext;
|
} as T & ModelBaseAPWithContext;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import {ASBase} from "../ASBase.model";
|
import {ASBase} from "../ASBase.model";
|
||||||
import {IntransitiveActivityFields} from './IntransitiveActivity.types';
|
import {IntransitiveActivityFields} from './IntransitiveActivity.types';
|
||||||
|
import {ModelType} from "../../common/common.types";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instances of IntransitiveActivity are a subtype of
|
* Instances of IntransitiveActivity are a subtype of
|
||||||
|
@ -10,6 +11,6 @@ import {IntransitiveActivityFields} from './IntransitiveActivity.types';
|
||||||
*/
|
*/
|
||||||
export class IntransitiveActivity extends ASBase<IntransitiveActivityFields>{
|
export class IntransitiveActivity extends ASBase<IntransitiveActivityFields>{
|
||||||
constructor(fields: IntransitiveActivityFields) {
|
constructor(fields: IntransitiveActivityFields) {
|
||||||
super(fields);
|
super(ModelType.Activity, fields);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
import {ASBase} from "../ASBase.model";
|
import {ASBase} from "../ASBase.model";
|
||||||
import { ActivityFields } from "./Activity.types";
|
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,
|
* 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>{
|
export class Activity extends ASBase<ActivityFields>{
|
||||||
constructor(fields: ActivityFields) {
|
constructor(fields: ActivityFields) {
|
||||||
super(fields);
|
super(ModelType.Activity, fields);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
import {ASBase} from "../ASBase.model";
|
import {ASBase} from "../ASBase.model";
|
||||||
import { ASObjectFields } from "./ASObject.types";
|
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
|
* 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>{
|
export class ASObject extends ASBase<ASObjectFields>{
|
||||||
constructor(fields: ASObjectFields) {
|
constructor(fields: ASObjectFields) {
|
||||||
super(fields);
|
super(ModelType.Object, fields);
|
||||||
}
|
}
|
||||||
}
|
}
|
Ładowanie…
Reference in New Issue