29 lines
660 B
TypeScript
29 lines
660 B
TypeScript
|
type ValueGetter = () => string;
|
||
|
|
||
|
export class SCIMMeta {
|
||
|
public resourceType: string;
|
||
|
public created: Date;
|
||
|
public lastModified: Date;
|
||
|
public version: string;
|
||
|
private id: ValueGetter;
|
||
|
|
||
|
constructor(resourceType: string, id: ValueGetter) {
|
||
|
this.id = id;
|
||
|
this.resourceType = resourceType;
|
||
|
const now = Date.now();
|
||
|
this.created = new Date(now);
|
||
|
this.lastModified = new Date(now);
|
||
|
}
|
||
|
|
||
|
public get location(): string {
|
||
|
return `/${this.resourceType}s/${this.id()}`;
|
||
|
}
|
||
|
|
||
|
public toJSON() {
|
||
|
return {
|
||
|
...this,
|
||
|
location: this.location,
|
||
|
};
|
||
|
}
|
||
|
}
|