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