parent
a85d52437b
commit
75332983c2
|
@ -1,26 +1,29 @@
|
|||
import { IsInt, IsString } from 'class-validator';
|
||||
|
||||
/**
|
||||
* Defines a auth object
|
||||
* Defines the repsonse auth.
|
||||
*/
|
||||
export class Auth {
|
||||
/**
|
||||
* access_token - JWT shortterm access token
|
||||
* The access_token - JWT shortterm access token.
|
||||
*/
|
||||
@IsString()
|
||||
access_token: string;
|
||||
|
||||
/**
|
||||
* refresh_token - longterm refresh token (used for requesting new access tokens)
|
||||
* The refresh_token - longterm refresh token (used for requesting new access tokens).
|
||||
*/
|
||||
@IsString()
|
||||
refresh_token: string;
|
||||
|
||||
/**
|
||||
* access_token_expires_at - unix timestamp of access token expiry
|
||||
* The unix timestamp for access the token's expiry.
|
||||
*/
|
||||
@IsInt()
|
||||
access_token_expires_at: number;
|
||||
|
||||
/**
|
||||
* refresh_token_expires_at - unix timestamp of access token expiry
|
||||
* The unix unix timestamp for the access token's expiry.
|
||||
*/
|
||||
@IsInt()
|
||||
refresh_token_expires_at: number;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { IsString } from 'class-validator';
|
||||
|
||||
/**
|
||||
* Defines a empty response object
|
||||
* Defines a empty response object.
|
||||
*/
|
||||
export class ResponseEmpty {
|
||||
@IsString()
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { IsString } from 'class-validator';
|
||||
|
||||
/**
|
||||
* Defines a Logout object
|
||||
* Defines the logout response.
|
||||
*/
|
||||
export class Logout {
|
||||
/**
|
||||
* timestamp of logout
|
||||
* The logout's timestamp.
|
||||
*/
|
||||
@IsString()
|
||||
timestamp: number;
|
||||
|
|
|
@ -1,18 +1,12 @@
|
|||
import {
|
||||
IsInt,
|
||||
|
||||
|
||||
|
||||
IsString
|
||||
} from "class-validator";
|
||||
import { IsInt, IsString } from "class-validator";
|
||||
import { Participant } from '../entities/Participant';
|
||||
|
||||
/**
|
||||
* Defines a participant response.
|
||||
* Defines the participant response.
|
||||
*/
|
||||
export abstract class ResponseParticipant {
|
||||
/**
|
||||
* Autogenerated unique id (primary key).
|
||||
* The participant's id.
|
||||
*/
|
||||
@IsInt()
|
||||
id: number;
|
||||
|
@ -25,7 +19,6 @@ export abstract class ResponseParticipant {
|
|||
|
||||
/**
|
||||
* The participant's middle name.
|
||||
* Optional.
|
||||
*/
|
||||
@IsString()
|
||||
middlename?: string;
|
||||
|
@ -38,18 +31,20 @@ export abstract class ResponseParticipant {
|
|||
|
||||
/**
|
||||
* The participant's phone number.
|
||||
* Optional.
|
||||
*/
|
||||
@IsString()
|
||||
phone?: string;
|
||||
|
||||
/**
|
||||
* The participant's e-mail address.
|
||||
* Optional.
|
||||
*/
|
||||
@IsString()
|
||||
email?: string;
|
||||
|
||||
/**
|
||||
* Creates a ResponseParticipant object from a participant.
|
||||
* @param participant The participant the response shall be build for.
|
||||
*/
|
||||
public constructor(participant: Participant) {
|
||||
this.id = participant.id;
|
||||
this.firstname = participant.firstname;
|
||||
|
|
|
@ -10,11 +10,11 @@ import { PermissionTarget } from '../enums/PermissionTargets';
|
|||
import { ResponsePrincipal } from './ResponsePrincipal';
|
||||
|
||||
/**
|
||||
* Defines a track of given length.
|
||||
* Defines the permission response.
|
||||
*/
|
||||
export class ResponsePermission {
|
||||
/**
|
||||
* Autogenerated unique id (primary key).
|
||||
* The permission's id.
|
||||
*/
|
||||
@IsInt()
|
||||
id: number;;
|
||||
|
@ -40,6 +40,10 @@ export class ResponsePermission {
|
|||
@IsEnum(PermissionAction)
|
||||
action: PermissionAction;
|
||||
|
||||
/**
|
||||
* Creates a ResponsePermission object from a permission.
|
||||
* @param permission The permission the response shall be build for.
|
||||
*/
|
||||
public constructor(permission: Permission) {
|
||||
this.id = permission.id;
|
||||
this.principal = permission.principal.toResponse();
|
||||
|
|
|
@ -4,16 +4,20 @@ import {
|
|||
import { Principal } from '../entities/Principal';
|
||||
|
||||
/**
|
||||
* Defines Principal's response class.
|
||||
* Defines the principal response.
|
||||
*/
|
||||
export abstract class ResponsePrincipal {
|
||||
|
||||
/**
|
||||
* Autogenerated unique id (primary key).
|
||||
* The principal's id.
|
||||
*/
|
||||
@IsInt()
|
||||
id: number;
|
||||
|
||||
/**
|
||||
* Creates a ResponsePrincipal object from a principal.
|
||||
* @param principal The principal the response shall be build for.
|
||||
*/
|
||||
public constructor(principal: Principal) {
|
||||
this.id = principal.id;
|
||||
}
|
||||
|
|
|
@ -7,13 +7,12 @@ import { RunnerGroup } from '../entities/RunnerGroup';
|
|||
import { ResponseParticipant } from './ResponseParticipant';
|
||||
|
||||
/**
|
||||
* Defines RunnerTeam's response class.
|
||||
* Defines the runner response.
|
||||
*/
|
||||
export class ResponseRunner extends ResponseParticipant {
|
||||
|
||||
/**
|
||||
* The runner's currently ran distance in meters.
|
||||
* Optional.
|
||||
*/
|
||||
@IsInt()
|
||||
distance: number;
|
||||
|
@ -24,6 +23,10 @@ export class ResponseRunner extends ResponseParticipant {
|
|||
@IsObject()
|
||||
group: RunnerGroup;
|
||||
|
||||
/**
|
||||
* Creates a ResponseRunner object from a runner.
|
||||
* @param runner The user the response shall be build for.
|
||||
*/
|
||||
public constructor(runner: Runner) {
|
||||
super(runner);
|
||||
this.distance = runner.scans.filter(scan => { scan.valid === true }).reduce((sum, current) => sum + current.distance, 0);
|
||||
|
|
|
@ -1,38 +1,20 @@
|
|||
import {
|
||||
IsInt,
|
||||
|
||||
|
||||
|
||||
IsNotEmpty,
|
||||
|
||||
|
||||
|
||||
IsObject,
|
||||
|
||||
|
||||
|
||||
IsOptional,
|
||||
|
||||
|
||||
|
||||
IsString
|
||||
} from "class-validator";
|
||||
import { IsInt, IsNotEmpty, IsObject, IsOptional, IsString } from "class-validator";
|
||||
import { GroupContact } from '../entities/GroupContact';
|
||||
import { RunnerGroup } from '../entities/RunnerGroup';
|
||||
|
||||
/**
|
||||
* Defines a track of given length.
|
||||
* Defines the runnerGroup response.
|
||||
*/
|
||||
export abstract class ResponseRunnerGroup {
|
||||
/**
|
||||
* Autogenerated unique id (primary key).
|
||||
* The runnerGroup's id.
|
||||
*/
|
||||
@IsInt()
|
||||
@IsNotEmpty()
|
||||
id: number;;
|
||||
|
||||
/**
|
||||
* The groups's name.
|
||||
* The runnerGroup's name.
|
||||
*/
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
|
@ -40,13 +22,16 @@ export abstract class ResponseRunnerGroup {
|
|||
|
||||
|
||||
/**
|
||||
* The group's contact.
|
||||
* Optional.
|
||||
* The runnerGroup's contact.
|
||||
*/
|
||||
@IsObject()
|
||||
@IsOptional()
|
||||
contact?: GroupContact;
|
||||
|
||||
/**
|
||||
* Creates a ResponseRunnerGroup object from a runnerGroup.
|
||||
* @param group The runnerGroup the response shall be build for.
|
||||
*/
|
||||
public constructor(group: RunnerGroup) {
|
||||
this.id = group.id;
|
||||
this.name = group.name;
|
||||
|
|
|
@ -9,25 +9,27 @@ import { RunnerTeam } from '../entities/RunnerTeam';
|
|||
import { ResponseRunnerGroup } from './ResponseRunnerGroup';
|
||||
|
||||
/**
|
||||
* Defines RunnerOrgs's response class.
|
||||
* Defines the runnerOrganisation response.
|
||||
*/
|
||||
export class ResponseRunnerOrganisation extends ResponseRunnerGroup {
|
||||
|
||||
/**
|
||||
* The orgs's address.
|
||||
* Optional.
|
||||
* The runnerOrganisation's address.
|
||||
*/
|
||||
@IsObject()
|
||||
@IsNotEmpty()
|
||||
address?: Address;
|
||||
|
||||
/**
|
||||
* The orgs associated teams.
|
||||
* The runnerOrganisation associated teams.
|
||||
*/
|
||||
@IsArray()
|
||||
teams: RunnerTeam[];
|
||||
|
||||
|
||||
/**
|
||||
* Creates a ResponseRunnerOrganisation object from a runnerOrganisation.
|
||||
* @param org The runnerOrganisation the response shall be build for.
|
||||
*/
|
||||
public constructor(org: RunnerOrganisation) {
|
||||
super(org);
|
||||
this.address = org.address;
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
import {
|
||||
IsNotEmpty,
|
||||
IsObject
|
||||
} from "class-validator";
|
||||
import { IsNotEmpty, IsObject } from "class-validator";
|
||||
import { RunnerOrganisation } from '../entities/RunnerOrganisation';
|
||||
import { RunnerTeam } from '../entities/RunnerTeam';
|
||||
import { ResponseRunnerGroup } from './ResponseRunnerGroup';
|
||||
|
||||
/**
|
||||
* Defines RunnerTeam's response class.
|
||||
* Defines the runnerTeam response.
|
||||
*/
|
||||
export class ResponseRunnerTeam extends ResponseRunnerGroup {
|
||||
|
||||
/**
|
||||
* The team's parent group (organisation).
|
||||
* Optional.
|
||||
* The runnerTeam's parent group (organisation).
|
||||
*/
|
||||
@IsObject()
|
||||
@IsNotEmpty()
|
||||
parentGroup: RunnerOrganisation;
|
||||
|
||||
/**
|
||||
* Creates a ResponseRunnerTeam object from a runnerTeam.
|
||||
* @param team The team the response shall be build for.
|
||||
*/
|
||||
public constructor(team: RunnerTeam) {
|
||||
super(team);
|
||||
this.parentGroup = team.parentGroup;
|
||||
|
|
|
@ -1,16 +1,12 @@
|
|||
import {
|
||||
IsInt,
|
||||
|
||||
IsString
|
||||
} from "class-validator";
|
||||
import { IsInt, IsString } from "class-validator";
|
||||
import { Track } from '../entities/Track';
|
||||
|
||||
/**
|
||||
* Defines a track of given length.
|
||||
* Defines the track response.
|
||||
*/
|
||||
export class ResponseTrack {
|
||||
/**
|
||||
* Autogenerated unique id (primary key).
|
||||
* The track's id.
|
||||
*/
|
||||
@IsInt()
|
||||
id: number;;
|
||||
|
@ -27,6 +23,10 @@ export class ResponseTrack {
|
|||
@IsInt()
|
||||
distance: number;
|
||||
|
||||
/**
|
||||
* Creates a ResponseTrack object from a track.
|
||||
* @param track The track the response shall be build for.
|
||||
*/
|
||||
public constructor(track: Track) {
|
||||
this.id = track.id;
|
||||
this.name = track.name;
|
||||
|
|
|
@ -11,7 +11,7 @@ import { UserGroup } from '../entities/UserGroup';
|
|||
import { ResponsePrincipal } from './ResponsePrincipal';
|
||||
|
||||
/**
|
||||
* Defines a user response.
|
||||
* Defines the user response.
|
||||
*/
|
||||
export class ResponseUser extends ResponsePrincipal {
|
||||
/**
|
||||
|
@ -22,7 +22,6 @@ export class ResponseUser extends ResponsePrincipal {
|
|||
|
||||
/**
|
||||
* The user's middle name.
|
||||
* Optional.
|
||||
*/
|
||||
@IsString()
|
||||
middlename?: string;
|
||||
|
@ -35,52 +34,53 @@ export class ResponseUser extends ResponsePrincipal {
|
|||
|
||||
/**
|
||||
* The user's phone number.
|
||||
* Optional.
|
||||
*/
|
||||
@IsString()
|
||||
phone?: string;
|
||||
|
||||
/**
|
||||
* The user's e-mail address.
|
||||
* Optional.
|
||||
*/
|
||||
@IsString()
|
||||
email?: string;
|
||||
|
||||
/**
|
||||
* The user's username.
|
||||
* Optional.
|
||||
*/
|
||||
@IsString()
|
||||
username?: string;
|
||||
|
||||
/**
|
||||
* is user enabled?
|
||||
* Is user enabled?
|
||||
*/
|
||||
@IsBoolean()
|
||||
enabled: boolean = true;
|
||||
|
||||
/**
|
||||
* profilepic
|
||||
* The user's profile pic.
|
||||
*/
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
profilePic?: string;
|
||||
|
||||
/**
|
||||
* Groups
|
||||
* The groups that the user is a part of.
|
||||
*/
|
||||
@IsArray()
|
||||
@IsOptional()
|
||||
groups: UserGroup[];
|
||||
|
||||
/**
|
||||
* permissions
|
||||
* The user's permissions.
|
||||
*/
|
||||
@IsArray()
|
||||
@IsOptional()
|
||||
permissions: Permission[];
|
||||
|
||||
/**
|
||||
* Creates a ResponseUser object from a user.
|
||||
* @param user The user the response shall be build for.
|
||||
*/
|
||||
public constructor(user: User) {
|
||||
super(user);
|
||||
this.firstname = user.firstname;
|
||||
|
|
|
@ -1,41 +1,37 @@
|
|||
import {
|
||||
IsArray,
|
||||
|
||||
|
||||
IsNotEmpty,
|
||||
|
||||
IsOptional,
|
||||
IsString
|
||||
} from "class-validator";
|
||||
import { IsArray, IsNotEmpty, IsOptional, IsString } from "class-validator";
|
||||
import { Permission } from '../entities/Permission';
|
||||
import { UserGroup } from '../entities/UserGroup';
|
||||
import { ResponsePrincipal } from './ResponsePrincipal';
|
||||
|
||||
/**
|
||||
* Defines a user response.
|
||||
* Defines the userGroup response.
|
||||
*/
|
||||
export class ResponseUserGroup extends ResponsePrincipal {
|
||||
/**
|
||||
* The group's name
|
||||
* The userGroup's name.
|
||||
*/
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* The group's description
|
||||
* The userGroup's description.
|
||||
*/
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
description?: string;
|
||||
|
||||
/**
|
||||
* permissions
|
||||
* The userGroup's permissions.
|
||||
*/
|
||||
@IsArray()
|
||||
@IsOptional()
|
||||
permissions: Permission[];
|
||||
|
||||
/**
|
||||
* Creates a ResponseUserGroup object from a userGroup.
|
||||
* @param group The userGroup the response shall be build for.
|
||||
*/
|
||||
public constructor(group: UserGroup) {
|
||||
super(group);
|
||||
this.name = group.name;
|
||||
|
|
Loading…
Reference in New Issue