refactor: fix lint errors across server and client
- replace any types with explicit types in scenario file listing, import/export and mcp upload code - type test server addresses and list callbacks, drop unused vars - document why e2e export keeps the archiver import-require form - remove unused scenario files total state in the client - require clean lint in both packages in CLAUDE.md
This commit is contained in:
1 parent
35293e372b
commit
965f262c0f
9 files changed
+41
-27
No files matched your search
@@ -1407,12 +1407,12 @@ export class McpService {
|
||||
};
|
||||
}
|
||||
|
||||
// Create a mock Multer file object for the service
|
||||
// Build the subset of a Multer file object the service uses
|
||||
const file = {
|
||||
buffer,
|
||||
originalname: name,
|
||||
mimetype: mimeType || "application/octet-stream",
|
||||
} as any;
|
||||
};
|
||||
|
||||
// Call the service method
|
||||
const result = await this.scenarioService.uploadFile(
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
import { Injectable } from "@nestjs/common";
|
||||
// archiver is a CommonJS `export =` function without a `default` export, and
|
||||
// esModuleInterop is off, so TypeScript's import-require form is the one that works
|
||||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||
import archiver = require("archiver");
|
||||
import { resolveUsedSnippetAliases } from "../common/snippet-usage";
|
||||
import { SnippetService } from "../snippet/snippet.service";
|
||||
|
||||
@@ -25,7 +25,7 @@ import { CreateScenarioStepDto } from "./dto/create-scenario-step.dto";
|
||||
import { CreateScenarioDto } from "./dto/create-scenario.dto";
|
||||
import { ScenarioQueryDto } from "./dto/pagination-query.dto";
|
||||
import { RunsQueryDto } from "./dto/runs-query.dto";
|
||||
import { ExportEntity } from "./dto/scenario-export.dto";
|
||||
import { ExportEntity, ScenarioExportDto } from "./dto/scenario-export.dto";
|
||||
import { UpdateScenarioStepDto } from "./dto/update-scenario-step.dto";
|
||||
import { UpdateScenarioDto } from "./dto/update-scenario.dto";
|
||||
import { ScenarioService } from "./scenario.service";
|
||||
@@ -52,7 +52,9 @@ export class ScenarioController {
|
||||
@ApiOperation({ summary: "Import a scenario from an export payload (single object or array)" })
|
||||
@ApiResponse({ status: 201, description: "Scenario imported" })
|
||||
importScenario(@Body() payload: unknown) {
|
||||
return this.scenarioService.importScenario(payload as any);
|
||||
return this.scenarioService.importScenario(
|
||||
payload as ScenarioExportDto | ExportEntity[],
|
||||
);
|
||||
}
|
||||
|
||||
@Get()
|
||||
@@ -157,7 +159,7 @@ export class ScenarioController {
|
||||
const parts = (entities as ExportEntity[]).map((entity) => {
|
||||
const label = kindLabels[entity.kind ?? ""] ?? entity.kind ?? "Entity";
|
||||
const comment = `# --- ${label}: ${
|
||||
(entity as any).name ?? (entity as any).id ?? ""
|
||||
entity.name ?? entity.id ?? ""
|
||||
} ---`;
|
||||
return `${comment}\n${yamlStringify(entity)}`;
|
||||
});
|
||||
|
||||
@@ -21,7 +21,10 @@ import {
|
||||
import type { AppConfig, TraceMode } from "../config/app.config";
|
||||
import { CredentialEntity } from "../credential/credential.entity";
|
||||
import { EnvironmentEntity } from "../environment/environment.entity";
|
||||
import { FileStorageService } from "../file/file-storage.service";
|
||||
import {
|
||||
FileMetadata,
|
||||
FileStorageService,
|
||||
} from "../file/file-storage.service";
|
||||
import { ScenarioFileEntity } from "../file/scenario-file.entity";
|
||||
import { ScenarioRunFileEntity } from "../file/scenario-run-file.entity";
|
||||
import { SnippetEntity } from "../snippet/snippet.entity";
|
||||
@@ -83,6 +86,12 @@ function stepsSnapshot(steps: ScenarioStepEntity[]): ScenarioStepSnapshot[] {
|
||||
}));
|
||||
}
|
||||
|
||||
/** File metadata as returned by the scenario/run file listing endpoints. */
|
||||
export interface FileListResult {
|
||||
items: Omit<FileMetadata, "path">[];
|
||||
total: number;
|
||||
}
|
||||
|
||||
export type UsedSnippet = SnippetEntity & {
|
||||
/** Version pinned via `runSnippet("alias@N")`, or null for the latest. */
|
||||
pinnedVersion: number | null;
|
||||
@@ -941,9 +950,9 @@ export class ScenarioService implements OnModuleInit {
|
||||
|
||||
async uploadFile(
|
||||
scenarioId: string,
|
||||
file: MulterFile,
|
||||
file: Pick<MulterFile, "buffer" | "originalname" | "mimetype">,
|
||||
expiresAtStr?: string,
|
||||
): Promise<any> {
|
||||
): Promise<Omit<FileMetadata, "path" | "sha256">> {
|
||||
// Verify scenario exists
|
||||
await this.findOne(scenarioId);
|
||||
|
||||
@@ -990,7 +999,7 @@ export class ScenarioService implements OnModuleInit {
|
||||
scenarioId: string,
|
||||
limit?: number,
|
||||
offset?: number,
|
||||
): Promise<any> {
|
||||
): Promise<FileListResult> {
|
||||
// Verify scenario exists
|
||||
await this.findOne(scenarioId);
|
||||
|
||||
@@ -1088,7 +1097,7 @@ export class ScenarioService implements OnModuleInit {
|
||||
runId: string,
|
||||
limit?: number,
|
||||
offset?: number,
|
||||
): Promise<any> {
|
||||
): Promise<FileListResult> {
|
||||
// Verify scenario and run exist
|
||||
await this.findOne(scenarioId);
|
||||
const run = await this.runRepo.findOneBy({ id: runId, scenarioId });
|
||||
|
||||
Reference in new issue
Block a user