Compare commits
5 Commits
c746f4e29c
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| ac850adfcf | |||
|
|
b4525bd13d | ||
|
|
963c78c35a | ||
|
|
0a23cb071c | ||
|
|
5fbcaca39b |
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@baekyangdan/core-utils",
|
||||
"version": "1.0.21",
|
||||
"version": "1.0.23",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@baekyangdan/core-utils",
|
||||
"version": "1.0.21",
|
||||
"version": "1.0.23",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@swc/core": "^1.15.5",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@baekyangdan/core-utils",
|
||||
"version": "1.0.21",
|
||||
"version": "1.0.23",
|
||||
"description": "Common Repo",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
|
||||
12
src/scheduler/decorator/composer.ts
Normal file
12
src/scheduler/decorator/composer.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
type Decorator = (target: Object, propertyKey: string | symbol) => void;
|
||||
|
||||
export function composeDecorators(...decorators: Decorator[]): Decorator {
|
||||
return (
|
||||
target: Object,
|
||||
property: string | symbol
|
||||
) => {
|
||||
for (const decorator of decorators) {
|
||||
decorator(target, property);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
src/scheduler/decorator/required-decorator.ts
Normal file
11
src/scheduler/decorator/required-decorator.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { getMessage } from "../type/class-validator/MessageType";
|
||||
import { composeDecorators } from "./composer";
|
||||
import { IsNotEmpty } from "class-validator";
|
||||
|
||||
export function IsRequired() {
|
||||
const notEmptyMessage = getMessage('REQUIRED');
|
||||
|
||||
return composeDecorators(
|
||||
IsNotEmpty({ message: notEmptyMessage })
|
||||
);
|
||||
}
|
||||
23
src/scheduler/decorator/valid-decorator.ts
Normal file
23
src/scheduler/decorator/valid-decorator.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { getMessage } from "../type/class-validator/MessageType";
|
||||
import { composeDecorators } from "./composer";
|
||||
import { IsIn, IsArray } from "class-validator";
|
||||
|
||||
export function IsValid(allowedValues: ReadonlyArray<any>, isArray: boolean = false) {
|
||||
const allowedValuesString = allowedValues.join(', ');
|
||||
|
||||
if (isArray) {
|
||||
return composeDecorators(
|
||||
IsArray({ message: `TYPE: The type of $property must be array.`}),
|
||||
IsIn(allowedValues, {
|
||||
each: true,
|
||||
message: `${getMessage('INVALID_ARRAY')} Valid values: ${allowedValuesString}`
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
return composeDecorators(
|
||||
IsIn(allowedValues, {
|
||||
message: `${getMessage('INVALID')} Valid values: ${allowedValuesString}`
|
||||
})
|
||||
);
|
||||
}
|
||||
16
src/scheduler/http/dto/follow/list/list-response.dto.ts
Normal file
16
src/scheduler/http/dto/follow/list/list-response.dto.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { IsRequired } from "src/scheduler/decorator/required-decorator";
|
||||
import { IsString } from 'class-validator';
|
||||
import { getMessage } from "src/scheduler/type/class-validator/MessageType";
|
||||
import type { BaseResponseDTO } from "../../base/base-response.dto"
|
||||
|
||||
export class FollowList {
|
||||
@IsRequired()
|
||||
@IsString({ message: getMessage('TYPE') })
|
||||
id!: string;
|
||||
|
||||
@IsRequired()
|
||||
@IsString({ message: getMessage('TYPE') })
|
||||
name!: string;
|
||||
}
|
||||
|
||||
export type FollowListResponse = BaseResponseDTO<FollowList[]>;
|
||||
@@ -1,36 +1,36 @@
|
||||
export { BaseRequestDTO as BaseRequest } from './base/base-request.dto';
|
||||
export type { BaseResponseDTO as BaseResponse } from './base/base-response.dto';
|
||||
export { type BaseResponseDTO as BaseResponse } from './base/base-response.dto';
|
||||
|
||||
export { CheckDuplicationRequestDTO as CheckDuplicationRequest } from './account/checkDuplication/check-duplication-request.dto';
|
||||
export type { CheckDuplicationResponseDTO as CheckDuplicationResponse } from './account/checkDuplication/check-duplication-response.dto';
|
||||
export { type CheckDuplicationResponseDTO as CheckDuplicationResponse } from './account/checkDuplication/check-duplication-response.dto';
|
||||
|
||||
export { LoginRequestDTO as LoginRequest } from './account/login/login-request.dto';
|
||||
export type { LoginResponseDTO as LoginResponse } from './account/login/login-response.dto';
|
||||
export { type LoginResponseDTO as LoginResponse } from './account/login/login-response.dto';
|
||||
|
||||
export type { RefreshAccessTokenResponseDTO as RefreshAccessTokenResponse } from './account/refreshAccessToken/refresh-access-token-response.dto';
|
||||
export { type RefreshAccessTokenResponseDTO as RefreshAccessTokenResponse } from './account/refreshAccessToken/refresh-access-token-response.dto';
|
||||
|
||||
export { ResetPasswordRequestDTO as ResetPasswordRequest } from './account/resetPassword/reset-password-request.dto';
|
||||
export type { ResetPasswordResponseDTO as ResetPasswordResponse } from './account/resetPassword/reset-password-response.dto';
|
||||
export { type ResetPasswordResponseDTO as ResetPasswordResponse } from './account/resetPassword/reset-password-response.dto';
|
||||
|
||||
export { SendEmailVerificationCodeRequestDTO as SendEmailVerificationCodeRequest } from './account/sendEmailVerificationCode/send-email-verification-code-request.dto';
|
||||
export type { SendEmailVerificationCodeResponseDTO as SendEmailVerificationCodeResponse } from './account/sendEmailVerificationCode/sned-email-verification-code-response.dto';
|
||||
export { type SendEmailVerificationCodeResponseDTO as SendEmailVerificationCodeResponse } from './account/sendEmailVerificationCode/sned-email-verification-code-response.dto';
|
||||
|
||||
export { SendPasswordResetCodeRequestDTO as SendPasswordResetCodeRequest } from './account/sendPasswordResetCode/send-password-reset-code-request.dto';
|
||||
export type { SendPasswordResetCodeResponseDTO as SendPasswordResetCodeResponse } from './account/sendPasswordResetCode/send-password-reset-code-response.dto';
|
||||
export { type SendPasswordResetCodeResponseDTO as SendPasswordResetCodeResponse } from './account/sendPasswordResetCode/send-password-reset-code-response.dto';
|
||||
|
||||
export { SignupRequestDTO as SignupRequest } from './account/signup/signup-request.dto';
|
||||
export type { SignupResponseDTO as SignupResponse } from './account/signup/signup-response.dto';
|
||||
export { type SignupResponseDTO as SignupResponse } from './account/signup/signup-response.dto';
|
||||
|
||||
export { VerifyEmailVerificationCodeRequestDTO as VerifyEmailVerificationCodeRequest } from './account/verifyEmailVerificationCode/verify-email-verification-code-request.dto';
|
||||
export type { VerifyEmailVerificationCodeResponseDTO as VerifyEmailVerificationCodeResponse } from './account/verifyEmailVerificationCode/verify-email-verification-code-response.dto';
|
||||
export { type VerifyEmailVerificationCodeResponseDTO as VerifyEmailVerificationCodeResponse } from './account/verifyEmailVerificationCode/verify-email-verification-code-response.dto';
|
||||
|
||||
export { VerifyPasswordResetCodeRequestDTO as VerifyPasswordResetCodeRequest } from './account/verifyPasswordResetCode/verify-password-reset-code-request.dto';
|
||||
export type { VerifyPasswordResetCodeResponseDTO as VerifyPasswordResetCodeResponse } from './account/verifyPasswordResetCode/verify-password-reset-code.response.dto';
|
||||
export { type VerifyPasswordResetCodeResponseDTO as VerifyPasswordResetCodeResponse } from './account/verifyPasswordResetCode/verify-password-reset-code.response.dto';
|
||||
|
||||
export { ScheduleCreateRequestDTO as ScheduleCreateRequest } from './schedule/create/create-request.dto';
|
||||
export type { ScheduleCreateResponseDTO as ScheduleCreateResponse } from './schedule/create/create-response.dto';
|
||||
export { type ScheduleCreateResponseDTO as ScheduleCreateResponse } from './schedule/create/create-response.dto';
|
||||
|
||||
export { ScheduleListRequestDTO as ScheduleListRequest } from './schedule/list/list-request.dto';
|
||||
export type { ScheduleListResponseDTO as ScheduleListResponse, ScheduleList } from './schedule/list/list-response.dto';
|
||||
export { type ScheduleListResponseDTO as ScheduleListResponse, ScheduleList } from './schedule/list/list-response.dto';
|
||||
|
||||
export type { ScheduleDetailResponseDTO as ScheduleDetailResponse, ScheduleDetail } from './schedule/detail/detail-response.dto';
|
||||
export { type ScheduleDetailResponseDTO as ScheduleDetailResponse, ScheduleDetail } from './schedule/detail/detail-response.dto';
|
||||
@@ -2,26 +2,72 @@ import type { BaseResponseDTO } from '@BaseResponseDTO';
|
||||
import type { Status } from 'src/scheduler/type/schedule/ScheduleStatus';
|
||||
import type { Type } from 'src/scheduler/type/schedule/ScheduleType';
|
||||
import { Type as TransformType } from 'class-transformer';
|
||||
import { IsRequired } from 'src/scheduler/decorator/required-decorator';
|
||||
import { IsArray, IsBoolean, IsDate, IsOptional, IsString, ValidateIf } from 'class-validator';
|
||||
import { getMessage } from 'src/scheduler/type/class-validator/MessageType';
|
||||
|
||||
export class ScheduleDetail {
|
||||
@IsRequired()
|
||||
@IsString({ message: getMessage('TYPE')})
|
||||
id!: string;
|
||||
|
||||
@IsRequired()
|
||||
@IsString({ message: getMessage('TYPE')})
|
||||
name!: string;
|
||||
|
||||
@IsRequired()
|
||||
@IsString({ message: getMessage('TYPE') })
|
||||
status!: Status;
|
||||
|
||||
@ValidateIf(o => o.content !== undefined && o.content !== null)
|
||||
@IsString({ message: getMessage('TYPE') })
|
||||
content?: string;
|
||||
|
||||
@IsRequired()
|
||||
@IsBoolean({ message: getMessage('TYPE')})
|
||||
isDeleted!: boolean;
|
||||
|
||||
@IsRequired()
|
||||
@IsString({ message: getMessage('TYPE') })
|
||||
type!: Type;
|
||||
|
||||
@IsRequired()
|
||||
@IsString({ message: getMessage('TYPE') })
|
||||
createdAt!: string;
|
||||
|
||||
@IsRequired()
|
||||
@IsString({ message: getMessage('TYPE') })
|
||||
owner!: string;
|
||||
|
||||
@IsRequired()
|
||||
@IsString({ message: getMessage('TYPE') })
|
||||
style!: string;
|
||||
|
||||
@IsRequired()
|
||||
@IsString({ message: getMessage('TYPE') })
|
||||
startTime!: string;
|
||||
|
||||
@IsRequired()
|
||||
@IsString({ message: getMessage('TYPE') })
|
||||
endTime!: string;
|
||||
|
||||
@ValidateIf(o => o.dayList !== undefined && o.dayList !== null)
|
||||
@IsString({ message: getMessage('TYPE') })
|
||||
dayList?: string;
|
||||
participantList?: string;
|
||||
|
||||
@ValidateIf(o => o.participantList !== undefined && o.participantList !== null)
|
||||
@IsArray()
|
||||
@IsString({ each: true, message: getMessage('TYPE') })
|
||||
participantList?: string[];
|
||||
|
||||
@TransformType(() => Date)
|
||||
@IsRequired()
|
||||
@IsDate({ message: getMessage('TYPE') })
|
||||
startDate!: Date;
|
||||
|
||||
@TransformType(() => Date)
|
||||
@IsRequired()
|
||||
@IsDate({ message: getMessage('TYPE') })
|
||||
endDate!: Date;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,18 +2,39 @@ import type { BaseResponseDTO } from '@BaseResponseDTO';
|
||||
import type { Status } from "src/scheduler/type/schedule/ScheduleStatus";
|
||||
import type { Type } from "src/scheduler/type/schedule/ScheduleType";
|
||||
import { Type as TransformType } from 'class-transformer';
|
||||
import { IsDate, IsString } from 'class-validator';
|
||||
import { IsRequired } from 'src/scheduler/decorator/required-decorator';
|
||||
import { getMessage } from 'src/scheduler/type/class-validator/MessageType';
|
||||
|
||||
export class ScheduleList {
|
||||
@IsRequired()
|
||||
@IsString({ message: getMessage('TYPE') })
|
||||
name!: string;
|
||||
|
||||
@IsRequired()
|
||||
@IsString({ message: getMessage('TYPE')})
|
||||
id!: string;
|
||||
|
||||
@IsRequired()
|
||||
@IsString({ message: getMessage('TYPE')})
|
||||
type!: Type;
|
||||
|
||||
@IsRequired()
|
||||
@IsString({ message: getMessage('TYPE')})
|
||||
style!: string;
|
||||
|
||||
@IsRequired()
|
||||
@IsString({ message: getMessage('TYPE')})
|
||||
status!: Status;
|
||||
|
||||
@TransformType(() => Date)
|
||||
@IsRequired()
|
||||
@IsDate()
|
||||
startDate!: Date;
|
||||
|
||||
@TransformType(() => Date)
|
||||
@IsRequired()
|
||||
@IsDate()
|
||||
endDate!: Date;
|
||||
}
|
||||
|
||||
|
||||
10
src/scheduler/type/class-validator/MessageType.ts
Normal file
10
src/scheduler/type/class-validator/MessageType.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
export type MessageType = 'REQUIRED' | 'TYPE' | 'INVALID' | 'INVALID_ARRAY';
|
||||
|
||||
export const getMessage = (type: MessageType) => {
|
||||
switch (type) {
|
||||
case 'REQUIRED': return `REQUIRED: $property is required entity.`;
|
||||
case 'TYPE': return `TYPE: The type of $property is invalid.`;
|
||||
case 'INVALID': return `INVALID: The value of $property($value) is invalid.`;
|
||||
case 'INVALID_ARRAY': return `INVALID_ARRAY: The $property array includes invalid value($value).`
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user