refactor(environment): rename urls payload to data
- replace hardcoded URL keys with a generic key-value data map - align backend DTOs, MCP schemas, and service import/export mapping - update environment UI forms to edit JSON data instead of fixed fields
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { ApiProperty } from "@nestjs/swagger";
|
||||
import { IsNotEmpty, IsObject, IsString } from "class-validator";
|
||||
import { EnvironmentUrls } from "../environment.entity";
|
||||
import { EnvironmentData } from "../environment.entity";
|
||||
|
||||
export class CreateEnvironmentDto {
|
||||
@ApiProperty({ example: "liquio-diia-stg" })
|
||||
@@ -9,13 +9,13 @@ export class CreateEnvironmentDto {
|
||||
name: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: "Map of URL identifiers to URL strings",
|
||||
description: "Generic key-value map for environment metadata",
|
||||
example: {
|
||||
id_url: "https://id-liquio-diia-stg.kitsoft.ua/",
|
||||
cabinet_url: "https://cabinet-liquio-diia-stg.kitsoft.ua/",
|
||||
admin_url: "https://admin-liquio-diia-stg.kitsoft.ua/",
|
||||
id: "https://id-liquio-diia-stg.kitsoft.ua/",
|
||||
cabinet: "https://cabinet-liquio-diia-stg.kitsoft.ua/",
|
||||
feature_flag: "enabled",
|
||||
},
|
||||
})
|
||||
@IsObject()
|
||||
urls: EnvironmentUrls;
|
||||
data: EnvironmentData;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
IsString,
|
||||
IsUUID,
|
||||
} from "class-validator";
|
||||
import { EnvironmentUrls } from "../environment.entity";
|
||||
import { EnvironmentData } from "../environment.entity";
|
||||
|
||||
export class EnvironmentExportDto {
|
||||
@ApiPropertyOptional()
|
||||
@@ -27,5 +27,5 @@ export class EnvironmentExportDto {
|
||||
|
||||
@ApiProperty()
|
||||
@IsObject()
|
||||
urls: EnvironmentUrls;
|
||||
data: EnvironmentData;
|
||||
}
|
||||
|
||||
@@ -6,10 +6,7 @@ import {
|
||||
UpdateDateColumn,
|
||||
} from "typeorm";
|
||||
|
||||
export interface EnvironmentUrls {
|
||||
id_url?: string;
|
||||
cabinet_url?: string;
|
||||
admin_url?: string;
|
||||
export interface EnvironmentData {
|
||||
[key: string]: string | undefined;
|
||||
}
|
||||
|
||||
@@ -22,7 +19,7 @@ export class EnvironmentEntity {
|
||||
name: string;
|
||||
|
||||
@Column("simple-json")
|
||||
urls: EnvironmentUrls;
|
||||
data: EnvironmentData;
|
||||
|
||||
@CreateDateColumn()
|
||||
createdAt: Date;
|
||||
|
||||
@@ -71,7 +71,7 @@ export class EnvironmentService {
|
||||
kind: "environment",
|
||||
id: env.id,
|
||||
name: env.name,
|
||||
urls: env.urls,
|
||||
data: env.data,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -79,18 +79,18 @@ export class EnvironmentService {
|
||||
if (dto.id) {
|
||||
const existing = await this.repo.findOneBy({ id: dto.id });
|
||||
if (existing) {
|
||||
Object.assign(existing, { name: dto.name, urls: dto.urls });
|
||||
Object.assign(existing, { name: dto.name, data: dto.data });
|
||||
return this.repo.save(existing);
|
||||
}
|
||||
return this.repo.save(
|
||||
this.repo.create({ id: dto.id, name: dto.name, urls: dto.urls }),
|
||||
this.repo.create({ id: dto.id, name: dto.name, data: dto.data }),
|
||||
);
|
||||
}
|
||||
const byName = await this.repo.findOneBy({ name: dto.name });
|
||||
if (byName) {
|
||||
Object.assign(byName, { urls: dto.urls });
|
||||
Object.assign(byName, { data: dto.data });
|
||||
return this.repo.save(byName);
|
||||
}
|
||||
return this.repo.save(this.repo.create({ name: dto.name, urls: dto.urls }));
|
||||
return this.repo.save(this.repo.create({ name: dto.name, data: dto.data }));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user