feat(export-import): add yaml export/import with id upsert for credentials, snippets, and scenarios
- all entities export a kind field (credential/snippet/scenario) for safe type checking on import - import upserts by id: overwrites if id exists, creates with explicit id otherwise - scenario export now includes id and step ids; import deletes old steps before recreating - add GET /:id/export and POST /import endpoints to credential and snippet controllers - add UuidBadge ui component: shortens uuid to first+last 4 hex chars, tooltip, clipboard copy with animated ClipboardCheck icon pop - apply UuidBadge across all entity id display sites (detail pages, card footers, table columns) - add export/import buttons to CredentialsPage, SnippetsPage, CredentialDetailPage, SnippetDetailPage
This commit is contained in:
@@ -110,7 +110,7 @@ export class SessionContextService implements OnModuleDestroy {
|
||||
* Close the context (if open) and delete the session record from DB.
|
||||
* Throws 404 if the session ID does not exist.
|
||||
*/
|
||||
async delete(id: number): Promise<void> {
|
||||
async delete(id: string): Promise<void> {
|
||||
const session = await this.sessionService.findById(id);
|
||||
if (!session) {
|
||||
throw new NotFoundException(`Session ${id} not found`);
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
HttpCode,
|
||||
NotFoundException,
|
||||
Param,
|
||||
ParseIntPipe,
|
||||
ParseUUIDPipe,
|
||||
Query,
|
||||
} from "@nestjs/common";
|
||||
import { ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger";
|
||||
@@ -38,7 +38,7 @@ export class SessionController {
|
||||
@ApiOperation({ summary: "Get a session by ID" })
|
||||
@ApiResponse({ status: 200, description: "Session found" })
|
||||
@ApiResponse({ status: 404, description: "Session not found" })
|
||||
async findOne(@Param("id", ParseIntPipe) id: number) {
|
||||
async findOne(@Param("id", ParseUUIDPipe) id: string) {
|
||||
const session = await this.sessionService.findById(id);
|
||||
if (!session) throw new NotFoundException(`Session ${id} not found`);
|
||||
const {
|
||||
@@ -58,7 +58,7 @@ export class SessionController {
|
||||
@ApiOperation({ summary: "Delete a session by ID (closes it first if open)" })
|
||||
@ApiResponse({ status: 204, description: "Session deleted" })
|
||||
@ApiResponse({ status: 404, description: "Session not found" })
|
||||
async remove(@Param("id", ParseIntPipe) id: number): Promise<void> {
|
||||
async remove(@Param("id", ParseUUIDPipe) id: string): Promise<void> {
|
||||
await this.sessionContextService.delete(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ export type SessionStatus = "open" | "closed";
|
||||
|
||||
@Entity("sessions")
|
||||
export class SessionEntity {
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number;
|
||||
@PrimaryGeneratedColumn("uuid")
|
||||
id: string;
|
||||
|
||||
@Column({ unique: true })
|
||||
sessionName: string;
|
||||
|
||||
@@ -72,7 +72,7 @@ export class SessionService implements OnApplicationBootstrap {
|
||||
return this.repo.findOneBy({ sessionName });
|
||||
}
|
||||
|
||||
findById(id: number): Promise<SessionEntity | null> {
|
||||
findById(id: string): Promise<SessionEntity | null> {
|
||||
return this.repo.findOneBy({ id });
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ export class SessionService implements OnApplicationBootstrap {
|
||||
return { data, total, page, limit };
|
||||
}
|
||||
|
||||
async remove(id: number): Promise<void> {
|
||||
async remove(id: string): Promise<void> {
|
||||
await this.repo.delete(id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user