mirror of
https://github.com/ashim-hq/ashim
synced 2026-04-21 13:37:52 +00:00
- Delete 3 dead files: use-batch-processor.ts, use-i18n.ts, smart-crop.ts (AI package) - Remove dead getJobProgress function and unused runPythonScript wrapper - Remove 6 unused imports across API and web apps - Remove unused shared types (ImageFormat, AppConfig, ApiError, HealthResponse, JobProgress) and constants (SUPPORTED_INPUT_FORMATS/OUTPUT_FORMATS, DEFAULT_OUTPUT_FORMAT) - Remove unused store method (setOriginalBlobUrl) and clean AI package re-exports - Add test infrastructure: vitest config, unit/integration/e2e tests, fixtures, screenshots - Add Docker test infrastructure: Dockerfile.test, docker-compose.test.yml - Add download_models.py for pre-baking AI model weights in Docker - Add filename sanitization utility (apps/api/src/lib/filename.ts) - Update .gitignore to exclude coverage/, *.tsbuildinfo, .superpowers/, test artifacts - Update .dockerignore to exclude test/coverage/IDE artifacts from builds - Update docs: remove smart crop from AI docs (uses Sharp directly), update bridge docs
32 lines
992 B
TypeScript
32 lines
992 B
TypeScript
import { mkdir, rm } from "node:fs/promises";
|
|
import { join } from "node:path";
|
|
import { env } from "../config.js";
|
|
|
|
/**
|
|
* Create a workspace directory structure for a processing job.
|
|
* Returns the workspace root path.
|
|
*/
|
|
export async function createWorkspace(jobId: string): Promise<string> {
|
|
const root = getWorkspacePath(jobId);
|
|
await mkdir(join(root, "input"), { recursive: true });
|
|
await mkdir(join(root, "output"), { recursive: true });
|
|
return root;
|
|
}
|
|
|
|
/**
|
|
* Get the workspace root path for a job.
|
|
*/
|
|
export function getWorkspacePath(jobId: string): string {
|
|
if (jobId.includes("..") || jobId.includes("/") || jobId.includes("\\") || jobId.includes("\0")) {
|
|
throw new Error("Invalid job ID");
|
|
}
|
|
return join(env.WORKSPACE_PATH, jobId);
|
|
}
|
|
|
|
/**
|
|
* Remove the entire workspace directory for a job.
|
|
*/
|
|
export async function cleanupWorkspace(jobId: string): Promise<void> {
|
|
const root = getWorkspacePath(jobId);
|
|
await rm(root, { recursive: true, force: true });
|
|
}
|