mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-04-17 17:58:55 +00:00
refactor: use a base dto class
This gives all dto classes a common super class for usage of the type system. Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
parent
0955bf048d
commit
c6bb8f62e8
20 changed files with 86 additions and 43 deletions
src
auth
frontend-config
groups
history
media
monitoring
notes
alias-create.dto.tsalias-update.dto.tsalias.dto.tsnote-metadata.dto.tsnote-permissions.dto.tsnote.dto.tsnote.media-deletion.dto.ts
revisions
users
utils
|
@ -1,11 +1,13 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import { IsDate, IsOptional, IsString } from 'class-validator';
|
||||
|
||||
export class AuthTokenDto {
|
||||
import { BaseDto } from '../utils/base.dto.';
|
||||
|
||||
export class AuthTokenDto extends BaseDto {
|
||||
@IsString()
|
||||
label: string;
|
||||
@IsString()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
@ -15,6 +15,7 @@ import {
|
|||
import { URL } from 'url';
|
||||
|
||||
import { ServerVersion } from '../monitoring/server-status.dto';
|
||||
import { BaseDto } from '../utils/base.dto.';
|
||||
|
||||
export enum AuthProviderType {
|
||||
LOCAL = 'local',
|
||||
|
@ -43,7 +44,7 @@ export type AuthProviderTypeWithoutCustomName =
|
|||
| AuthProviderType.DROPBOX
|
||||
| AuthProviderType.GOOGLE;
|
||||
|
||||
export class AuthProviderWithoutCustomNameDto {
|
||||
export class AuthProviderWithoutCustomNameDto extends BaseDto {
|
||||
/**
|
||||
* The type of the auth provider.
|
||||
*/
|
||||
|
@ -51,7 +52,7 @@ export class AuthProviderWithoutCustomNameDto {
|
|||
type: AuthProviderTypeWithoutCustomName;
|
||||
}
|
||||
|
||||
export class AuthProviderWithCustomNameDto {
|
||||
export class AuthProviderWithCustomNameDto extends BaseDto {
|
||||
/**
|
||||
* The type of the auth provider.
|
||||
*/
|
||||
|
@ -77,7 +78,7 @@ export type AuthProviderDto =
|
|||
| AuthProviderWithCustomNameDto
|
||||
| AuthProviderWithoutCustomNameDto;
|
||||
|
||||
export class BrandingDto {
|
||||
export class BrandingDto extends BaseDto {
|
||||
/**
|
||||
* The name to be displayed next to the HedgeDoc logo
|
||||
* @example ACME Corp
|
||||
|
@ -95,7 +96,7 @@ export class BrandingDto {
|
|||
logo?: URL;
|
||||
}
|
||||
|
||||
export class SpecialUrlsDto {
|
||||
export class SpecialUrlsDto extends BaseDto {
|
||||
/**
|
||||
* A link to the privacy notice
|
||||
* @example https://md.example.com/n/privacy
|
||||
|
@ -121,7 +122,7 @@ export class SpecialUrlsDto {
|
|||
imprint?: URL;
|
||||
}
|
||||
|
||||
export class IframeCommunicationDto {
|
||||
export class IframeCommunicationDto extends BaseDto {
|
||||
/**
|
||||
* The origin under which the editor page will be served
|
||||
* @example https://md.example.com
|
||||
|
@ -139,7 +140,7 @@ export class IframeCommunicationDto {
|
|||
rendererOrigin?: URL;
|
||||
}
|
||||
|
||||
export class FrontendConfigDto {
|
||||
export class FrontendConfigDto extends BaseDto {
|
||||
/**
|
||||
* Is anonymous usage of the instance allowed?
|
||||
*/
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsBoolean, IsString } from 'class-validator';
|
||||
|
||||
export class GroupInfoDto {
|
||||
import { BaseDto } from '../utils/base.dto.';
|
||||
|
||||
export class GroupInfoDto extends BaseDto {
|
||||
/**
|
||||
* Name of the group
|
||||
* @example "superheroes"
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import { IsBoolean, IsDate, IsString } from 'class-validator';
|
||||
|
||||
export class HistoryEntryImportDto {
|
||||
import { BaseDto } from '../utils/base.dto.';
|
||||
|
||||
export class HistoryEntryImportDto extends BaseDto {
|
||||
/**
|
||||
* ID or Alias of the note
|
||||
*/
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsBoolean } from 'class-validator';
|
||||
|
||||
export class HistoryEntryUpdateDto {
|
||||
import { BaseDto } from '../utils/base.dto.';
|
||||
|
||||
export class HistoryEntryUpdateDto extends BaseDto {
|
||||
/**
|
||||
* True if the note should be pinned
|
||||
*/
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsArray, IsBoolean, IsDate, IsString } from 'class-validator';
|
||||
|
||||
export class HistoryEntryDto {
|
||||
import { BaseDto } from '../utils/base.dto.';
|
||||
|
||||
export class HistoryEntryDto extends BaseDto {
|
||||
/**
|
||||
* ID or Alias of the note
|
||||
*/
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsString } from 'class-validator';
|
||||
|
||||
export class MediaUploadUrlDto {
|
||||
import { BaseDto } from '../utils/base.dto.';
|
||||
|
||||
export class MediaUploadUrlDto extends BaseDto {
|
||||
@IsString()
|
||||
@ApiProperty()
|
||||
link: string;
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsDate, IsOptional, IsString } from 'class-validator';
|
||||
|
||||
export class MediaUploadDto {
|
||||
import { BaseDto } from '../utils/base.dto.';
|
||||
|
||||
export class MediaUploadDto extends BaseDto {
|
||||
/**
|
||||
* The link to the media file.
|
||||
* @example "https://example.com/uploads/testfile123.jpg"
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
import { BaseDto } from '../utils/base.dto.';
|
||||
|
||||
export class ServerVersion {
|
||||
@ApiProperty()
|
||||
major: number;
|
||||
|
@ -18,7 +20,7 @@ export class ServerVersion {
|
|||
commit?: string;
|
||||
}
|
||||
|
||||
export class ServerStatusDto {
|
||||
export class ServerStatusDto extends BaseDto {
|
||||
@ApiProperty()
|
||||
serverVersion: ServerVersion;
|
||||
@ApiProperty()
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsString } from 'class-validator';
|
||||
|
||||
export class AliasCreateDto {
|
||||
import { BaseDto } from '../utils/base.dto.';
|
||||
|
||||
export class AliasCreateDto extends BaseDto {
|
||||
/**
|
||||
* The note id or alias, which identifies the note the alias should be added to
|
||||
*/
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsBoolean } from 'class-validator';
|
||||
|
||||
export class AliasUpdateDto {
|
||||
import { BaseDto } from '../utils/base.dto.';
|
||||
|
||||
export class AliasUpdateDto extends BaseDto {
|
||||
/**
|
||||
* Whether the alias should become the primary alias or not
|
||||
*/
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsBoolean, IsString } from 'class-validator';
|
||||
|
||||
export class AliasDto {
|
||||
import { BaseDto } from '../utils/base.dto.';
|
||||
|
||||
export class AliasDto extends BaseDto {
|
||||
/**
|
||||
* The name of the alias
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
@ -14,9 +14,10 @@ import {
|
|||
} from 'class-validator';
|
||||
|
||||
import { UserInfoDto } from '../users/user-info.dto';
|
||||
import { BaseDto } from '../utils/base.dto.';
|
||||
import { NotePermissionsDto } from './note-permissions.dto';
|
||||
|
||||
export class NoteMetadataDto {
|
||||
export class NoteMetadataDto extends BaseDto {
|
||||
/**
|
||||
* ID of the note
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
@ -12,7 +12,9 @@ import {
|
|||
ValidateNested,
|
||||
} from 'class-validator';
|
||||
|
||||
export class NoteUserPermissionEntryDto {
|
||||
import { BaseDto } from '../utils/base.dto.';
|
||||
|
||||
export class NoteUserPermissionEntryDto extends BaseDto {
|
||||
/**
|
||||
* Username of the User this permission applies to
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
@ -7,9 +7,10 @@ import { ApiProperty } from '@nestjs/swagger';
|
|||
import { IsArray, IsString, ValidateNested } from 'class-validator';
|
||||
|
||||
import { EditDto } from '../revisions/edit.dto';
|
||||
import { BaseDto } from '../utils/base.dto.';
|
||||
import { NoteMetadataDto } from './note-metadata.dto';
|
||||
|
||||
export class NoteDto {
|
||||
export class NoteDto extends BaseDto {
|
||||
/**
|
||||
* Markdown content of the note
|
||||
* @example "# I am a heading"
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsBoolean } from 'class-validator';
|
||||
|
||||
export class NoteMediaDeletionDto {
|
||||
import { BaseDto } from '../utils/base.dto.';
|
||||
|
||||
export class NoteMediaDeletionDto extends BaseDto {
|
||||
/**
|
||||
* Should the associated mediaUploads be keept
|
||||
* @default false
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
@ -7,8 +7,9 @@ import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|||
import { IsDate, IsNumber, IsOptional, IsString, Min } from 'class-validator';
|
||||
|
||||
import { UserInfoDto } from '../users/user-info.dto';
|
||||
import { BaseDto } from '../utils/base.dto.';
|
||||
|
||||
export class EditDto {
|
||||
export class EditDto extends BaseDto {
|
||||
/**
|
||||
* Username of the user who authored this section
|
||||
* Is `null` if the user is anonymous
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsDate, IsNumber, IsString } from 'class-validator';
|
||||
|
||||
import { BaseDto } from '../utils/base.dto.';
|
||||
import { Revision } from './revision.entity';
|
||||
|
||||
export class RevisionDto {
|
||||
export class RevisionDto extends BaseDto {
|
||||
/**
|
||||
* ID of this revision
|
||||
* @example 13
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsString } from 'class-validator';
|
||||
|
||||
export class UserInfoDto {
|
||||
import { BaseDto } from '../utils/base.dto.';
|
||||
|
||||
export class UserInfoDto extends BaseDto {
|
||||
/**
|
||||
* The username
|
||||
* @example "john.smith"
|
||||
|
|
10
src/utils/base.dto..ts
Normal file
10
src/utils/base.dto..ts
Normal file
|
@ -0,0 +1,10 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
/**
|
||||
* The base class for all DTOs.
|
||||
*/
|
||||
export abstract class BaseDto {}
|
Loading…
Add table
Reference in a new issue