Compare commits

...

14 Commits

Author SHA1 Message Date
ac850adfcf issue #
- 팔로우 DTO 구현 중
2025-12-17 23:50:37 +09:00
geonhee-min
b4525bd13d 1.0.23 2025-12-17 09:49:47 +09:00
geonhee-min
963c78c35a issue #
- 커스텀 데코레이터, class-validator 적용
2025-12-17 09:49:42 +09:00
geonhee-min
0a23cb071c 1.0.22 2025-12-17 08:44:49 +09:00
geonhee-min
5fbcaca39b issue #
- SchedulerDTO export type 이슈 수정
2025-12-17 08:44:43 +09:00
geonhee-min
c746f4e29c 1.0.21 2025-12-16 16:52:52 +09:00
geonhee-min
624c871d7f issue #
- BaseRequest/Response export
2025-12-16 16:52:44 +09:00
geonhee-min
adec968612 1.0.20 2025-12-16 16:25:11 +09:00
geonhee-min
290d87ff1c issue #
- class-transform 적용
2025-12-16 16:25:02 +09:00
geonhee-min
70ae2c3fad 1.0.19 2025-12-16 15:17:27 +09:00
geonhee-min
b04f1c057a issue #
- ScheduleListResponseDTO data 타입 오류 수정
2025-12-16 15:17:20 +09:00
geonhee-min
81e16eec34 1.0.18 2025-12-16 15:14:13 +09:00
geonhee-min
87542664cc issue #
- ScheduleCreateRequestDTO type 타입 수정
2025-12-16 15:14:06 +09:00
geonhee-min
636e01aea7 issue #
- ScheduleCreateRequestDTO content 누락 수정
2025-12-16 15:13:25 +09:00
17 changed files with 211 additions and 51 deletions

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "@baekyangdan/core-utils",
"version": "1.0.17",
"version": "1.0.23",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@baekyangdan/core-utils",
"version": "1.0.17",
"version": "1.0.23",
"license": "ISC",
"dependencies": {
"@swc/core": "^1.15.5",

View File

@@ -1,6 +1,6 @@
{
"name": "@baekyangdan/core-utils",
"version": "1.0.17",
"version": "1.0.23",
"description": "Common Repo",
"main": "dist/index.js",
"types": "dist/index.d.ts",

View 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);
}
}
}

View 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 })
);
}

View 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}`
})
);
}

View 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[]>;

View File

@@ -1,33 +1,36 @@
export { BaseRequestDTO as BaseRequest } from './base/base-request.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';

View File

@@ -1,19 +1,23 @@
import { BaseRequestDTO } from '@BaseRequestDTO';
import { Type as TransformType } from 'class-transformer';
import { IsArray, IsDateString, IsIn, IsString } from 'class-validator';
import { TypeArray } from 'src/scheduler/type/schedule/ScheduleType';
import { TypeArray, type Type } from 'src/scheduler/type/schedule/ScheduleType';
export class ScheduleCreateRequestDTO extends BaseRequestDTO {
@IsString()
name!: string;
@IsDateString()
startDate!: string;
@IsString()
content!: string;
@IsDateString()
endDate!: string;
@TransformType(() => Date)
startDate!: Date;
@TransformType(() => Date)
endDate!: Date;
@IsIn(TypeArray)
type!: string;
type!: Type;
@IsString()
style!: string;

View File

@@ -1,23 +1,74 @@
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 type ScheduleDetail = {
id: string;
name: string;
startDate: Date;
endDate: Date;
status: Status;
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;
isDeleted: boolean;
type: Type;
createdAt: string;
owner: string;
style: string;
startTime: string;
endTime: 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;
}
export type ScheduleDetailResponseDTO = BaseResponseDTO<ScheduleDetail>;

View File

@@ -1,20 +1,24 @@
import { BaseRequestDTO } from '@BaseRequestDTO';
import { IsArray, IsDateString, IsIn, IsNumberString, IsString, ValidateIf } from 'class-validator';
import { Type } from 'class-transformer';
import { IsArray, IsDate, IsIn, IsNumberString, IsString, ValidateIf } from 'class-validator';
import { StatusArray } from 'src/scheduler/type/schedule/ScheduleStatus';
import { TypeArray } from 'src/scheduler/type/schedule/ScheduleType';
export class ScheduleListRequestDTO extends BaseRequestDTO {
@ValidateIf(o => o.date !== undefined)
@IsDateString()
date?: string;
@Type(() => Date)
@IsDate()
date?: Date;
@ValidateIf(o => o.startDate !== undefined)
@IsDateString()
startDate?: string;
@Type(() => Date)
@IsDate()
startDate?: Date;
@ValidateIf(o => o.endDate !== undefined)
@IsDateString()
endDate?: string;
@Type(() => Date)
@IsDate()
endDate?: Date;
@ValidateIf(o => o.styleList !== undefined)
@IsArray()

View File

@@ -1,15 +1,41 @@
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 type ScheduleList = {
name: string;
id: string;
startDate: Date;
endDate: Date;
type: Type;
style: string;
status: Status;
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;
}
export type ScheduleListResponseDTO = BaseResponseDTO<ScheduleList>;
export type ScheduleListResponseDTO = BaseResponseDTO<ScheduleList[]>;

View 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).`
}
}