diff --git a/prisma/launcher.schema.prisma b/prisma/launcher.schema.prisma index a6b2776..fd9cfac 100644 --- a/prisma/launcher.schema.prisma +++ b/prisma/launcher.schema.prisma @@ -69,7 +69,7 @@ model LauncherSshKey { } -model LauncherCommonSetting { +model LauncherSetting { id String @id @default(uuid()) @db.Uuid key String @unique name String @@ -82,5 +82,5 @@ model LauncherCommonSetting { updatedAt DateTime @updatedAt @map("updated_at") @db.Timestamptz(3) @@index([type, isActive]) - @@map("launcher_common_settings") + @@map("launcher_settings") } diff --git a/prisma/migrations/20260708094000_rename_launcher_common_settings/migration.sql b/prisma/migrations/20260708094000_rename_launcher_common_settings/migration.sql new file mode 100644 index 0000000..d38de64 --- /dev/null +++ b/prisma/migrations/20260708094000_rename_launcher_common_settings/migration.sql @@ -0,0 +1,3 @@ +ALTER TABLE IF EXISTS "launcher_common_settings" RENAME TO "launcher_settings"; + +COMMENT ON TABLE "launcher_settings" IS '런처 소스, 빌드 환경 등 내부 설정'; diff --git a/src/launcher/dto.ts b/src/launcher/dto.ts index 68f5b68..44fb2ec 100644 --- a/src/launcher/dto.ts +++ b/src/launcher/dto.ts @@ -279,59 +279,3 @@ export class UpdateLauncherBuildEnvDto { @Type(() => LauncherBuildEnvVariableDto) variables!: LauncherBuildEnvVariableDto[]; } - -export class CreateLauncherCommonSettingDto { - @IsString() - key!: string; - - @IsString() - name!: string; - - @IsString() - type!: string; - - @IsString() - value!: string; - - @IsOptional() - @IsString() - description?: string; - - @IsOptional() - @IsBoolean() - isActive?: boolean; - - @IsOptional() - @IsBoolean() - isSecret?: boolean; -} - -export class UpdateLauncherCommonSettingDto { - @IsOptional() - @IsString() - key?: string; - - @IsOptional() - @IsString() - name?: string; - - @IsOptional() - @IsString() - type?: string; - - @IsOptional() - @IsString() - value?: string; - - @IsOptional() - @IsString() - description?: string; - - @IsOptional() - @IsBoolean() - isActive?: boolean; - - @IsOptional() - @IsBoolean() - isSecret?: boolean; -} diff --git a/src/launcher/launcher.controller.ts b/src/launcher/launcher.controller.ts index a4a2052..9a496ee 100644 --- a/src/launcher/launcher.controller.ts +++ b/src/launcher/launcher.controller.ts @@ -1,6 +1,6 @@ import { Body, Controller, Delete, Get, Param, Patch, Post, Put, Query } from '@nestjs/common'; -import { CreateLauncherAppLinkDto, CreateLauncherBuildJobDto, CreateLauncherCommonSettingDto, CreateLauncherVersionDto, UpdateLauncherSourceDto, LinkLauncherVersionSourceDto, MoveLauncherAppLinkDto, UpdateLauncherAppLinkDto, UpdateLauncherBuildEnvDto, UpdateLauncherCommonSettingDto, UpdateLauncherUserAppPermissionsDto, DeployLauncherBackendDto, ListLauncherBuildJobsQuery } from './dto'; +import { CreateLauncherAppLinkDto, CreateLauncherBuildJobDto, CreateLauncherVersionDto, UpdateLauncherSourceDto, LinkLauncherVersionSourceDto, MoveLauncherAppLinkDto, UpdateLauncherAppLinkDto, UpdateLauncherBuildEnvDto, UpdateLauncherUserAppPermissionsDto, DeployLauncherBackendDto, ListLauncherBuildJobsQuery } from './dto'; import { LauncherService } from './launcher.service'; @Controller('launcher') @@ -58,31 +58,6 @@ export class LauncherController { return this.launcherService.createBuildJob(body); } - - - @Get('common-settings') - listCommonSettings() { - return this.launcherService.listCommonSettings(); - } - - @Post('common-settings') - createCommonSetting(@Body() body: CreateLauncherCommonSettingDto) { - return this.launcherService.createCommonSetting(body); - } - - @Patch('common-settings/:id') - updateCommonSetting( - @Param('id') id: string, - @Body() body: UpdateLauncherCommonSettingDto, - ) { - return this.launcherService.updateCommonSetting(id, body); - } - - @Delete('common-settings/:id') - deleteCommonSetting(@Param('id') id: string) { - return this.launcherService.deleteCommonSetting(id); - } - @Get('app-links') listAppLinks() { return this.launcherService.listAppLinks(); diff --git a/src/launcher/launcher.service.ts b/src/launcher/launcher.service.ts index c3b1e6b..17e9750 100644 --- a/src/launcher/launcher.service.ts +++ b/src/launcher/launcher.service.ts @@ -13,7 +13,6 @@ import { PrismaService } from '../prisma/prisma.service'; import { CreateLauncherAppLinkDto, CreateLauncherBuildJobDto, - CreateLauncherCommonSettingDto, CreateLauncherVersionDto, DeployLauncherBackendDto, ListLauncherBuildJobsQuery, @@ -21,7 +20,6 @@ import { LinkLauncherVersionSourceDto, UpdateLauncherAppLinkDto, UpdateLauncherBuildEnvDto, - UpdateLauncherCommonSettingDto, UpdateLauncherUserAppPermissionsDto, } from './dto'; @@ -76,51 +74,6 @@ export class LauncherService { return rows.map(mapLauncherVersionRow); } - - listCommonSettings() { - return this.launcherPrisma.launcherCommonSetting.findMany({ - orderBy: [{ isActive: 'desc' }, { type: 'asc' }, { name: 'asc' }], - }); - } - - async createCommonSetting(body: CreateLauncherCommonSettingDto) { - const setting = await this.launcherPrisma.launcherCommonSetting.create({ - data: { - key: body.key.trim(), - name: body.name.trim(), - type: body.type.trim(), - value: body.value.trim(), - description: body.description?.trim() || null, - isActive: body.isActive ?? true, - isSecret: body.isSecret ?? false, - }, - }); - - return { setting }; - } - - async updateCommonSetting(id: string, body: UpdateLauncherCommonSettingDto) { - const setting = await this.launcherPrisma.launcherCommonSetting.update({ - where: { id }, - data: { - key: body.key === undefined ? undefined : body.key.trim(), - name: body.name === undefined ? undefined : body.name.trim(), - type: body.type === undefined ? undefined : body.type.trim(), - value: body.value === undefined ? undefined : body.value.trim(), - description: body.description === undefined ? undefined : body.description.trim() || null, - isActive: body.isActive, - isSecret: body.isSecret, - }, - }); - - return { setting }; - } - - async deleteCommonSetting(id: string) { - await this.launcherPrisma.launcherCommonSetting.delete({ where: { id } }); - return { deleted: true }; - } - async getSource() { const source = await this.getSourceSettings(); return { source }; @@ -136,35 +89,35 @@ export class LauncherService { const dockerfile = body.dockerfile?.trim() || 'Dockerfile'; const writes = isBackend ? [ - this.upsertCommonSettingByKey( + this.upsertLauncherSettingByKey( LAUNCHER_SOURCE_SETTING_KEYS.backendRepository, '런처 백엔드 소스 저장소', 'source', repository, '런처 백엔드 컨테이너 빌드에 사용할 저장소', ), - this.upsertCommonSettingByKey( + this.upsertLauncherSettingByKey( LAUNCHER_SOURCE_SETTING_KEYS.backendBranch, '런처 백엔드 소스 브랜치', 'source', branch, '런처 백엔드 컨테이너 빌드 기준 브랜치', ), - this.upsertCommonSettingByKey( + this.upsertLauncherSettingByKey( LAUNCHER_SOURCE_SETTING_KEYS.backendCommitSha, '런처 백엔드 소스 커밋', 'source', commitSha, '비워두면 브랜치 최신 커밋 기준', ), - this.upsertCommonSettingByKey( + this.upsertLauncherSettingByKey( LAUNCHER_SOURCE_SETTING_KEYS.backendImage, '런처 백엔드 이미지', 'source', image, '런처 백엔드 컨테이너 이미지 이름', ), - this.upsertCommonSettingByKey( + this.upsertLauncherSettingByKey( LAUNCHER_SOURCE_SETTING_KEYS.backendDockerfile, '런처 백엔드 Dockerfile', 'source', @@ -172,21 +125,21 @@ export class LauncherService { '런처 백엔드 빌드에 사용할 Dockerfile 경로', ), ] : [ - this.upsertCommonSettingByKey( + this.upsertLauncherSettingByKey( LAUNCHER_SOURCE_SETTING_KEYS.repository, '런처 소스 저장소', 'source', repository, '런처 클라이언트 빌드에 사용할 저장소', ), - this.upsertCommonSettingByKey( + this.upsertLauncherSettingByKey( LAUNCHER_SOURCE_SETTING_KEYS.branch, '런처 소스 브랜치', 'source', branch, '런처 클라이언트 빌드 기준 브랜치', ), - this.upsertCommonSettingByKey( + this.upsertLauncherSettingByKey( LAUNCHER_SOURCE_SETTING_KEYS.commitSha, '런처 소스 커밋', 'source', @@ -209,7 +162,7 @@ export class LauncherService { } private async getSourceSettings() { - const rows = await this.launcherPrisma.launcherCommonSetting.findMany({ + const rows = await this.launcherPrisma.launcherSetting.findMany({ where: { key: { in: [ @@ -256,7 +209,7 @@ export class LauncherService { private async getLauncherClientBuildEnv() { - const rows = await this.launcherPrisma.launcherCommonSetting.findMany({ + const rows = await this.launcherPrisma.launcherSetting.findMany({ where: { key: { startsWith: LAUNCHER_BUILD_ENV_PREFIX, @@ -283,7 +236,7 @@ export class LauncherService { .filter((row) => row.key); } - private upsertCommonSettingByKey( + private upsertLauncherSettingByKey( key: string, name: string, type: string, @@ -291,7 +244,7 @@ export class LauncherService { description: string, isSecret = false, ) { - return this.launcherPrisma.launcherCommonSetting.upsert({ + return this.launcherPrisma.launcherSetting.upsert({ where: { key }, create: { key, @@ -322,7 +275,7 @@ export class LauncherService { async updateBuildEnv(body: UpdateLauncherBuildEnvDto) { const variables = normalizeBuildEnvVariables(body.variables ?? []); const nextKeys = new Set(variables.map((variable) => variable.key)); - const existing = await this.launcherPrisma.launcherCommonSetting.findMany({ + const existing = await this.launcherPrisma.launcherSetting.findMany({ where: { key: { startsWith: LAUNCHER_BUILD_ENV_PREFIX, @@ -333,8 +286,8 @@ export class LauncherService { await this.launcherPrisma.$transaction([ ...existing .filter((setting) => !nextKeys.has(setting.key.slice(LAUNCHER_BUILD_ENV_PREFIX.length))) - .map((setting) => this.launcherPrisma.launcherCommonSetting.delete({ where: { id: setting.id } })), - ...variables.map((variable) => this.upsertCommonSettingByKey( + .map((setting) => this.launcherPrisma.launcherSetting.delete({ where: { id: setting.id } })), + ...variables.map((variable) => this.upsertLauncherSettingByKey( `${LAUNCHER_BUILD_ENV_PREFIX}${variable.key}`, variable.key, 'launcher-build-env',