@cotestdev/ai-runner 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents/logger.d.ts.map +1 -0
- package/dist/agents/logger.js.map +1 -0
- package/dist/agents/playwright-executor.d.ts.map +1 -0
- package/dist/agents/playwright-executor.js.map +1 -0
- package/dist/agents/tools/playwright-backend-adapter.d.ts.map +1 -0
- package/dist/agents/tools/playwright-backend-adapter.js.map +1 -0
- package/dist/agents/types.d.ts.map +1 -0
- package/dist/{core-infra/src → agents}/types.js.map +1 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js.map +1 -0
- package/dist/runner.d.ts.map +1 -0
- package/dist/runner.js.map +1 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/playwright-groups.d.ts.map +1 -0
- package/dist/tools/playwright-groups.js.map +1 -0
- package/dist/types/external.d.ts.map +1 -0
- package/dist/types/external.js.map +1 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +2 -7
- package/playwright.config.ts +38 -0
- package/src/agents/logger.ts +20 -0
- package/src/agents/playwright-executor.ts +252 -0
- package/src/agents/tools/playwright-backend-adapter.ts +134 -0
- package/src/agents/tools/playwright-mcp-types.d.ts +71 -0
- package/src/agents/types.ts +80 -0
- package/src/index.ts +27 -0
- package/src/runner.ts +224 -0
- package/src/tools/index.ts +48 -0
- package/src/tools/playwright-groups.ts +54 -0
- package/src/types/external.ts +7 -0
- package/src/types/index.ts +118 -0
- package/tests/agent/test-heal-agent.spec.ts +54 -0
- package/tsconfig.json +26 -0
- package/dist/ai-runner/src/agents/logger.d.ts.map +0 -1
- package/dist/ai-runner/src/agents/logger.js.map +0 -1
- package/dist/ai-runner/src/agents/playwright-executor.d.ts.map +0 -1
- package/dist/ai-runner/src/agents/playwright-executor.js.map +0 -1
- package/dist/ai-runner/src/agents/tools/playwright-backend-adapter.d.ts.map +0 -1
- package/dist/ai-runner/src/agents/tools/playwright-backend-adapter.js.map +0 -1
- package/dist/ai-runner/src/agents/types.d.ts.map +0 -1
- package/dist/ai-runner/src/agents/types.js.map +0 -1
- package/dist/ai-runner/src/index.d.ts.map +0 -1
- package/dist/ai-runner/src/index.js.map +0 -1
- package/dist/ai-runner/src/runner.d.ts.map +0 -1
- package/dist/ai-runner/src/runner.js.map +0 -1
- package/dist/ai-runner/src/tools/index.d.ts.map +0 -1
- package/dist/ai-runner/src/tools/index.js.map +0 -1
- package/dist/ai-runner/src/tools/playwright-groups.d.ts.map +0 -1
- package/dist/ai-runner/src/tools/playwright-groups.js.map +0 -1
- package/dist/ai-runner/src/types/external.d.ts.map +0 -1
- package/dist/ai-runner/src/types/external.js.map +0 -1
- package/dist/ai-runner/src/types/index.d.ts.map +0 -1
- package/dist/ai-runner/src/types/index.js.map +0 -1
- package/dist/core-infra/src/directory-validator.d.ts +0 -29
- package/dist/core-infra/src/directory-validator.d.ts.map +0 -1
- package/dist/core-infra/src/directory-validator.js +0 -91
- package/dist/core-infra/src/directory-validator.js.map +0 -1
- package/dist/core-infra/src/index.d.ts +0 -14
- package/dist/core-infra/src/index.d.ts.map +0 -1
- package/dist/core-infra/src/index.js +0 -44
- package/dist/core-infra/src/index.js.map +0 -1
- package/dist/core-infra/src/mcp/file-mcp-manager.d.ts +0 -14
- package/dist/core-infra/src/mcp/file-mcp-manager.d.ts.map +0 -1
- package/dist/core-infra/src/mcp/file-mcp-manager.js +0 -46
- package/dist/core-infra/src/mcp/file-mcp-manager.js.map +0 -1
- package/dist/core-infra/src/mcp/index.d.ts +0 -21
- package/dist/core-infra/src/mcp/index.d.ts.map +0 -1
- package/dist/core-infra/src/mcp/index.js +0 -17
- package/dist/core-infra/src/mcp/index.js.map +0 -1
- package/dist/core-infra/src/mcp/mcp-client.d.ts +0 -128
- package/dist/core-infra/src/mcp/mcp-client.d.ts.map +0 -1
- package/dist/core-infra/src/mcp/mcp-client.js +0 -163
- package/dist/core-infra/src/mcp/mcp-client.js.map +0 -1
- package/dist/core-infra/src/mcp/mcp-manager.d.ts +0 -21
- package/dist/core-infra/src/mcp/mcp-manager.d.ts.map +0 -1
- package/dist/core-infra/src/mcp/mcp-manager.js +0 -99
- package/dist/core-infra/src/mcp/mcp-manager.js.map +0 -1
- package/dist/core-infra/src/mcp/playwright-mcp-manager.d.ts +0 -19
- package/dist/core-infra/src/mcp/playwright-mcp-manager.d.ts.map +0 -1
- package/dist/core-infra/src/mcp/playwright-mcp-manager.js +0 -121
- package/dist/core-infra/src/mcp/playwright-mcp-manager.js.map +0 -1
- package/dist/core-infra/src/model.d.ts +0 -13
- package/dist/core-infra/src/model.d.ts.map +0 -1
- package/dist/core-infra/src/model.js +0 -191
- package/dist/core-infra/src/model.js.map +0 -1
- package/dist/core-infra/src/repositories/BaseRepository.d.ts +0 -69
- package/dist/core-infra/src/repositories/BaseRepository.d.ts.map +0 -1
- package/dist/core-infra/src/repositories/BaseRepository.js +0 -213
- package/dist/core-infra/src/repositories/BaseRepository.js.map +0 -1
- package/dist/core-infra/src/repositories/DirectoryRepository.d.ts +0 -70
- package/dist/core-infra/src/repositories/DirectoryRepository.d.ts.map +0 -1
- package/dist/core-infra/src/repositories/DirectoryRepository.js +0 -336
- package/dist/core-infra/src/repositories/DirectoryRepository.js.map +0 -1
- package/dist/core-infra/src/repositories/ExplorationRepository.d.ts +0 -34
- package/dist/core-infra/src/repositories/ExplorationRepository.d.ts.map +0 -1
- package/dist/core-infra/src/repositories/ExplorationRepository.js +0 -54
- package/dist/core-infra/src/repositories/ExplorationRepository.js.map +0 -1
- package/dist/core-infra/src/repositories/FileRepository.d.ts +0 -56
- package/dist/core-infra/src/repositories/FileRepository.d.ts.map +0 -1
- package/dist/core-infra/src/repositories/FileRepository.js +0 -132
- package/dist/core-infra/src/repositories/FileRepository.js.map +0 -1
- package/dist/core-infra/src/repositories/ModelConfigRepository.d.ts +0 -38
- package/dist/core-infra/src/repositories/ModelConfigRepository.d.ts.map +0 -1
- package/dist/core-infra/src/repositories/ModelConfigRepository.js +0 -59
- package/dist/core-infra/src/repositories/ModelConfigRepository.js.map +0 -1
- package/dist/core-infra/src/repositories/ProjectRepository.d.ts +0 -32
- package/dist/core-infra/src/repositories/ProjectRepository.d.ts.map +0 -1
- package/dist/core-infra/src/repositories/ProjectRepository.js +0 -67
- package/dist/core-infra/src/repositories/ProjectRepository.js.map +0 -1
- package/dist/core-infra/src/repositories/SettingsRepository.d.ts +0 -19
- package/dist/core-infra/src/repositories/SettingsRepository.d.ts.map +0 -1
- package/dist/core-infra/src/repositories/SettingsRepository.js +0 -72
- package/dist/core-infra/src/repositories/SettingsRepository.js.map +0 -1
- package/dist/core-infra/src/repositories/TableDataRepository.d.ts +0 -22
- package/dist/core-infra/src/repositories/TableDataRepository.d.ts.map +0 -1
- package/dist/core-infra/src/repositories/TableDataRepository.js +0 -33
- package/dist/core-infra/src/repositories/TableDataRepository.js.map +0 -1
- package/dist/core-infra/src/repositories/TestCaseRepository.d.ts +0 -120
- package/dist/core-infra/src/repositories/TestCaseRepository.d.ts.map +0 -1
- package/dist/core-infra/src/repositories/TestCaseRepository.js +0 -463
- package/dist/core-infra/src/repositories/TestCaseRepository.js.map +0 -1
- package/dist/core-infra/src/repositories/TestPlanRepository.d.ts +0 -35
- package/dist/core-infra/src/repositories/TestPlanRepository.d.ts.map +0 -1
- package/dist/core-infra/src/repositories/TestPlanRepository.js +0 -80
- package/dist/core-infra/src/repositories/TestPlanRepository.js.map +0 -1
- package/dist/core-infra/src/repositories/TestResultRepository.d.ts +0 -30
- package/dist/core-infra/src/repositories/TestResultRepository.d.ts.map +0 -1
- package/dist/core-infra/src/repositories/TestResultRepository.js +0 -54
- package/dist/core-infra/src/repositories/TestResultRepository.js.map +0 -1
- package/dist/core-infra/src/repositories/index.d.ts +0 -17
- package/dist/core-infra/src/repositories/index.d.ts.map +0 -1
- package/dist/core-infra/src/repositories/index.js +0 -31
- package/dist/core-infra/src/repositories/index.js.map +0 -1
- package/dist/core-infra/src/storageService.d.ts +0 -131
- package/dist/core-infra/src/storageService.d.ts.map +0 -1
- package/dist/core-infra/src/storageService.js +0 -304
- package/dist/core-infra/src/storageService.js.map +0 -1
- package/dist/core-infra/src/types.d.ts +0 -219
- package/dist/core-infra/src/types.d.ts.map +0 -1
- package/dist/core-infra/src/types.js +0 -3
- /package/dist/{ai-runner/src/agents → agents}/logger.d.ts +0 -0
- /package/dist/{ai-runner/src/agents → agents}/logger.js +0 -0
- /package/dist/{ai-runner/src/agents → agents}/playwright-executor.d.ts +0 -0
- /package/dist/{ai-runner/src/agents → agents}/playwright-executor.js +0 -0
- /package/dist/{ai-runner/src/agents → agents}/tools/playwright-backend-adapter.d.ts +0 -0
- /package/dist/{ai-runner/src/agents → agents}/tools/playwright-backend-adapter.js +0 -0
- /package/dist/{ai-runner/src/agents → agents}/types.d.ts +0 -0
- /package/dist/{ai-runner/src/agents → agents}/types.js +0 -0
- /package/dist/{ai-runner/src/index.d.ts → index.d.ts} +0 -0
- /package/dist/{ai-runner/src/index.js → index.js} +0 -0
- /package/dist/{ai-runner/src/runner.d.ts → runner.d.ts} +0 -0
- /package/dist/{ai-runner/src/runner.js → runner.js} +0 -0
- /package/dist/{ai-runner/src/tools → tools}/index.d.ts +0 -0
- /package/dist/{ai-runner/src/tools → tools}/index.js +0 -0
- /package/dist/{ai-runner/src/tools → tools}/playwright-groups.d.ts +0 -0
- /package/dist/{ai-runner/src/tools → tools}/playwright-groups.js +0 -0
- /package/dist/{ai-runner/src/types → types}/external.d.ts +0 -0
- /package/dist/{ai-runner/src/types → types}/external.js +0 -0
- /package/dist/{ai-runner/src/types → types}/index.d.ts +0 -0
- /package/dist/{ai-runner/src/types → types}/index.js +0 -0
|
@@ -1,336 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DirectoryRepository = void 0;
|
|
4
|
-
const BaseRepository_1 = require("./BaseRepository");
|
|
5
|
-
const path_1 = require("path");
|
|
6
|
-
const fs_1 = require("fs");
|
|
7
|
-
const directory_validator_1 = require("../directory-validator");
|
|
8
|
-
/**
|
|
9
|
-
* DirectoryRepository handles all storage operations for test case directories
|
|
10
|
-
* Manages the hierarchical organization of test cases (up to 3 levels)
|
|
11
|
-
* Each directory can have an info.json file with metadata (description, createdAt, etc.)
|
|
12
|
-
*/
|
|
13
|
-
class DirectoryRepository extends BaseRepository_1.BaseRepository {
|
|
14
|
-
constructor(projectId) {
|
|
15
|
-
super((0, path_1.join)("projects", projectId, 'tests'));
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Create a new directory at the specified path
|
|
19
|
-
* @param path - Directory path like 'folder1' or 'folder1/subfolder' (max 3 levels)
|
|
20
|
-
* @param info - Directory metadata
|
|
21
|
-
*/
|
|
22
|
-
createDirectory(path, info) {
|
|
23
|
-
// Validate path
|
|
24
|
-
const validation = (0, directory_validator_1.validateDirectoryPath)(path);
|
|
25
|
-
if (!validation.valid) {
|
|
26
|
-
throw new Error(validation.error);
|
|
27
|
-
}
|
|
28
|
-
const fullPath = (0, path_1.join)(this.getBaseDir(), path);
|
|
29
|
-
// Check if directory already exists
|
|
30
|
-
if ((0, fs_1.existsSync)(fullPath)) {
|
|
31
|
-
throw new Error(`Directory already exists: ${path}`);
|
|
32
|
-
}
|
|
33
|
-
// Create directory
|
|
34
|
-
(0, fs_1.mkdirSync)(fullPath, { recursive: true });
|
|
35
|
-
// Create directory info
|
|
36
|
-
const directoryInfo = {
|
|
37
|
-
id: `dir_${Date.now()}`,
|
|
38
|
-
name: path.split('/').pop() || path,
|
|
39
|
-
description: info.description,
|
|
40
|
-
createdAt: Date.now(),
|
|
41
|
-
updatedAt: Date.now(),
|
|
42
|
-
};
|
|
43
|
-
// Save info.json
|
|
44
|
-
this.saveDirectoryInfo(path, directoryInfo);
|
|
45
|
-
return directoryInfo;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Get directory info from info.json
|
|
49
|
-
*/
|
|
50
|
-
getDirectoryInfo(path) {
|
|
51
|
-
const infoPath = (0, path_1.join)(this.getBaseDir(), path, 'info.json');
|
|
52
|
-
if (!(0, fs_1.existsSync)(infoPath)) {
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
try {
|
|
56
|
-
const content = (0, fs_1.readFileSync)(infoPath, 'utf-8');
|
|
57
|
-
return JSON.parse(content);
|
|
58
|
-
}
|
|
59
|
-
catch {
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Update directory metadata
|
|
65
|
-
*/
|
|
66
|
-
updateDirectoryInfo(path, updates) {
|
|
67
|
-
const existing = this.getDirectoryInfo(path);
|
|
68
|
-
if (!existing) {
|
|
69
|
-
throw new Error(`Directory does not exist: ${path}`);
|
|
70
|
-
}
|
|
71
|
-
const updated = {
|
|
72
|
-
...existing,
|
|
73
|
-
...updates,
|
|
74
|
-
updatedAt: Date.now(),
|
|
75
|
-
};
|
|
76
|
-
this.saveDirectoryInfo(path, updated);
|
|
77
|
-
return updated;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Delete a directory (must be empty)
|
|
81
|
-
*/
|
|
82
|
-
deleteDirectory(path) {
|
|
83
|
-
const fullPath = (0, path_1.join)(this.getBaseDir(), path);
|
|
84
|
-
if (!(0, fs_1.existsSync)(fullPath)) {
|
|
85
|
-
throw new Error(`Directory does not exist: ${path}`);
|
|
86
|
-
}
|
|
87
|
-
// Delete the directory
|
|
88
|
-
(0, fs_1.rmSync)(fullPath, { recursive: true, force: true });
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Rename a directory
|
|
92
|
-
*/
|
|
93
|
-
renameDirectory(oldPath, newName) {
|
|
94
|
-
// Validate new name
|
|
95
|
-
const nameValidation = (0, directory_validator_1.validateDirectoryName)(newName);
|
|
96
|
-
if (!nameValidation.valid) {
|
|
97
|
-
throw new Error(nameValidation.error);
|
|
98
|
-
}
|
|
99
|
-
const oldFullPath = (0, path_1.join)(this.getBaseDir(), oldPath);
|
|
100
|
-
const parentPath = oldPath.split('/').slice(0, -1).join('/');
|
|
101
|
-
const newPath = parentPath ? `${parentPath}/${newName}` : newName;
|
|
102
|
-
const newFullPath = (0, path_1.join)(this.getBaseDir(), newPath);
|
|
103
|
-
if (!(0, fs_1.existsSync)(oldFullPath)) {
|
|
104
|
-
throw new Error(`Directory does not exist: ${oldPath}`);
|
|
105
|
-
}
|
|
106
|
-
if ((0, fs_1.existsSync)(newFullPath)) {
|
|
107
|
-
throw new Error(`Directory already exists: ${newPath}`);
|
|
108
|
-
}
|
|
109
|
-
// Rename directory
|
|
110
|
-
(0, fs_1.renameSync)(oldFullPath, newFullPath);
|
|
111
|
-
// Update all test cases in the renamed directory and its subdirectories
|
|
112
|
-
this.updateTestPathsRecursively(newFullPath, oldPath, newPath);
|
|
113
|
-
// Update info.json
|
|
114
|
-
const dirInfo = this.getDirectoryInfo(newPath);
|
|
115
|
-
if (dirInfo) {
|
|
116
|
-
dirInfo.name = newName;
|
|
117
|
-
dirInfo.updatedAt = Date.now();
|
|
118
|
-
this.saveDirectoryInfo(newPath, dirInfo);
|
|
119
|
-
}
|
|
120
|
-
return dirInfo || { id: '', name: newName, createdAt: Date.now(), updatedAt: Date.now() };
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Build the complete directory tree with tests
|
|
124
|
-
* This is the main method to get the hierarchical structure
|
|
125
|
-
*/
|
|
126
|
-
buildDirectoryTree(basePath = '') {
|
|
127
|
-
const fullPath = (0, path_1.join)(this.getBaseDir(), basePath);
|
|
128
|
-
// Ensure directory exists
|
|
129
|
-
if (!(0, fs_1.existsSync)(fullPath)) {
|
|
130
|
-
(0, fs_1.mkdirSync)(fullPath, { recursive: true });
|
|
131
|
-
}
|
|
132
|
-
const pathParts = basePath ? basePath.split('/') : [];
|
|
133
|
-
const name = pathParts.length > 0 ? pathParts[pathParts.length - 1] : 'root';
|
|
134
|
-
const infoData = basePath ? this.getDirectoryInfo(basePath) : null;
|
|
135
|
-
const info = infoData || undefined;
|
|
136
|
-
const tree = {
|
|
137
|
-
path: basePath,
|
|
138
|
-
name,
|
|
139
|
-
info,
|
|
140
|
-
children: [],
|
|
141
|
-
tests: [],
|
|
142
|
-
};
|
|
143
|
-
try {
|
|
144
|
-
const items = (0, fs_1.readdirSync)(fullPath);
|
|
145
|
-
for (const item of items) {
|
|
146
|
-
const itemPath = (0, path_1.join)(fullPath, item);
|
|
147
|
-
const stat = (0, fs_1.statSync)(itemPath);
|
|
148
|
-
if (stat.isDirectory() && item !== 'info.json') {
|
|
149
|
-
const subPath = basePath ? `${basePath}/${item}` : item;
|
|
150
|
-
// Check depth (max 3 levels)
|
|
151
|
-
if (subPath.split('/').length <= 3) {
|
|
152
|
-
tree.children.push(this.buildDirectoryTree(subPath));
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
// Load test files (only .json files that are test cases)
|
|
157
|
-
for (const item of items) {
|
|
158
|
-
if (item.endsWith('.json') && item !== 'info.json') {
|
|
159
|
-
const testPath = (0, path_1.join)(fullPath, item);
|
|
160
|
-
try {
|
|
161
|
-
const content = (0, fs_1.readFileSync)(testPath, 'utf-8');
|
|
162
|
-
const testCase = JSON.parse(content);
|
|
163
|
-
// Only add tests that belong to this directory (no path or matching path)
|
|
164
|
-
if (testCase.path === basePath) {
|
|
165
|
-
tree.tests.push(testCase);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
catch {
|
|
169
|
-
// Skip invalid test files
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
// Sort children by name
|
|
174
|
-
tree.children.sort((a, b) => a.name.localeCompare(b.name));
|
|
175
|
-
// Sort tests by creation date (newest first)
|
|
176
|
-
tree.tests.sort((a, b) => b.createdAt - a.createdAt);
|
|
177
|
-
}
|
|
178
|
-
catch {
|
|
179
|
-
// Return empty tree if unable to read directory
|
|
180
|
-
}
|
|
181
|
-
return tree;
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Get all directories at a specific level (flat list)
|
|
185
|
-
*/
|
|
186
|
-
getDirectoriesAtPath(path = '') {
|
|
187
|
-
const fullPath = (0, path_1.join)(this.getBaseDir(), path);
|
|
188
|
-
if (!(0, fs_1.existsSync)(fullPath)) {
|
|
189
|
-
return [];
|
|
190
|
-
}
|
|
191
|
-
const directories = [];
|
|
192
|
-
try {
|
|
193
|
-
const items = (0, fs_1.readdirSync)(fullPath);
|
|
194
|
-
for (const item of items) {
|
|
195
|
-
const itemPath = (0, path_1.join)(fullPath, item);
|
|
196
|
-
const stat = (0, fs_1.statSync)(itemPath);
|
|
197
|
-
if (stat.isDirectory() && item !== 'info.json') {
|
|
198
|
-
const subPath = path ? `${path}/${item}` : item;
|
|
199
|
-
const info = this.getDirectoryInfo(subPath);
|
|
200
|
-
if (info) {
|
|
201
|
-
directories.push(info);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
catch {
|
|
207
|
-
// Return empty array if unable to read directory
|
|
208
|
-
}
|
|
209
|
-
return directories.sort((a, b) => a.name.localeCompare(b.name));
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Check if a path is valid (exists and is a directory)
|
|
213
|
-
*/
|
|
214
|
-
isValidDirectory(path) {
|
|
215
|
-
const fullPath = (0, path_1.join)(this.getBaseDir(), path);
|
|
216
|
-
return (0, fs_1.existsSync)(fullPath) && (0, fs_1.statSync)(fullPath).isDirectory();
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Move a directory to a new parent directory
|
|
220
|
-
* @param sourcePath - The current directory path
|
|
221
|
-
* @param targetParentPath - The target parent directory path (or empty string for root)
|
|
222
|
-
*/
|
|
223
|
-
moveDirectory(sourcePath, targetParentPath) {
|
|
224
|
-
const sourceFullPath = (0, path_1.join)(this.getBaseDir(), sourcePath);
|
|
225
|
-
const directoryName = sourcePath.split('/').pop() || sourcePath;
|
|
226
|
-
// Validate paths
|
|
227
|
-
if (!(0, fs_1.existsSync)(sourceFullPath)) {
|
|
228
|
-
throw new Error(`Source directory does not exist: ${sourcePath}`);
|
|
229
|
-
}
|
|
230
|
-
const targetPath = targetParentPath ? `${targetParentPath}/${directoryName}` : directoryName;
|
|
231
|
-
const targetFullPath = (0, path_1.join)(this.getBaseDir(), targetPath);
|
|
232
|
-
// Check if target already exists
|
|
233
|
-
if ((0, fs_1.existsSync)(targetFullPath)) {
|
|
234
|
-
throw new Error(`Target path already exists: ${targetPath}`);
|
|
235
|
-
}
|
|
236
|
-
// Validate target path
|
|
237
|
-
const pathValidation = (0, directory_validator_1.validateDirectoryPath)(targetPath);
|
|
238
|
-
if (!pathValidation.valid) {
|
|
239
|
-
throw new Error(pathValidation.error);
|
|
240
|
-
}
|
|
241
|
-
// Ensure target parent directory exists
|
|
242
|
-
const targetParentFullPath = (0, path_1.dirname)(targetFullPath);
|
|
243
|
-
if (!(0, fs_1.existsSync)(targetParentFullPath)) {
|
|
244
|
-
(0, fs_1.mkdirSync)(targetParentFullPath, { recursive: true });
|
|
245
|
-
}
|
|
246
|
-
// Move the directory
|
|
247
|
-
(0, fs_1.renameSync)(sourceFullPath, targetFullPath);
|
|
248
|
-
// Update all test cases in the moved directory and its subdirectories
|
|
249
|
-
this.updateTestPathsRecursively(targetFullPath, sourcePath, targetPath);
|
|
250
|
-
// Get the directory info
|
|
251
|
-
const dirInfo = this.getDirectoryInfo(targetPath);
|
|
252
|
-
return dirInfo || { id: '', name: directoryName, createdAt: Date.now(), updatedAt: Date.now() };
|
|
253
|
-
}
|
|
254
|
-
/**
|
|
255
|
-
* Recursively update the path field in all test case JSON files
|
|
256
|
-
* @param dirFullPath - Full filesystem path to the directory
|
|
257
|
-
* @param oldBasePath - Old logical path (e.g., 'folder1/subfolder')
|
|
258
|
-
* @param newBasePath - New logical path (e.g., 'folder2/subfolder')
|
|
259
|
-
*/
|
|
260
|
-
updateTestPathsRecursively(dirFullPath, oldBasePath, newBasePath) {
|
|
261
|
-
if (!(0, fs_1.existsSync)(dirFullPath)) {
|
|
262
|
-
return;
|
|
263
|
-
}
|
|
264
|
-
try {
|
|
265
|
-
const items = (0, fs_1.readdirSync)(dirFullPath);
|
|
266
|
-
for (const item of items) {
|
|
267
|
-
const itemPath = (0, path_1.join)(dirFullPath, item);
|
|
268
|
-
const stat = (0, fs_1.statSync)(itemPath);
|
|
269
|
-
if (stat.isDirectory() && item !== 'info.json') {
|
|
270
|
-
// Recursively update subdirectories
|
|
271
|
-
this.updateTestPathsRecursively(itemPath, oldBasePath, newBasePath);
|
|
272
|
-
}
|
|
273
|
-
else if (item.endsWith('.json') && item !== 'info.json') {
|
|
274
|
-
// Update test case file
|
|
275
|
-
try {
|
|
276
|
-
const content = (0, fs_1.readFileSync)(itemPath, 'utf-8');
|
|
277
|
-
const testCase = JSON.parse(content);
|
|
278
|
-
// Update the path field if it starts with the old base path
|
|
279
|
-
if (testCase.path && testCase.path.startsWith(oldBasePath)) {
|
|
280
|
-
const relativePath = testCase.path.substring(oldBasePath.length);
|
|
281
|
-
testCase.path = newBasePath + relativePath;
|
|
282
|
-
// Save the updated test case
|
|
283
|
-
(0, fs_1.writeFileSync)(itemPath, JSON.stringify(testCase, null, 2), 'utf-8');
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
catch (error) {
|
|
287
|
-
console.error(`Failed to update test case ${item}:`, error);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
catch (error) {
|
|
293
|
-
console.error(`Failed to update test paths in ${dirFullPath}:`, error);
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
/**
|
|
297
|
-
* Move a test case to a different directory
|
|
298
|
-
* @param testId - The test case ID
|
|
299
|
-
* @param sourceDir - The current directory path
|
|
300
|
-
* @param targetDir - The target directory path
|
|
301
|
-
*/
|
|
302
|
-
moveTestCase(testId, sourceDir, targetDir) {
|
|
303
|
-
const sourceFile = (0, path_1.join)(this.getBaseDir(), sourceDir, `${testId}.json`);
|
|
304
|
-
const targetFile = (0, path_1.join)(this.getBaseDir(), targetDir, `${testId}.json`);
|
|
305
|
-
// Check if source file exists
|
|
306
|
-
if (!(0, fs_1.existsSync)(sourceFile)) {
|
|
307
|
-
throw new Error(`Test case file does not exist: ${sourceFile}`);
|
|
308
|
-
}
|
|
309
|
-
// Check if target directory exists
|
|
310
|
-
const targetDirFullPath = (0, path_1.join)(this.getBaseDir(), targetDir);
|
|
311
|
-
if (!(0, fs_1.existsSync)(targetDirFullPath)) {
|
|
312
|
-
throw new Error(`Target directory does not exist: ${targetDir}`);
|
|
313
|
-
}
|
|
314
|
-
// Check if file already exists in target
|
|
315
|
-
if ((0, fs_1.existsSync)(targetFile)) {
|
|
316
|
-
throw new Error(`Test case already exists in target directory`);
|
|
317
|
-
}
|
|
318
|
-
// Move the file
|
|
319
|
-
(0, fs_1.renameSync)(sourceFile, targetFile);
|
|
320
|
-
return true;
|
|
321
|
-
}
|
|
322
|
-
/**
|
|
323
|
-
* Save directory info to info.json
|
|
324
|
-
*/
|
|
325
|
-
saveDirectoryInfo(path, info) {
|
|
326
|
-
const infoPath = (0, path_1.join)(this.getBaseDir(), path, 'info.json');
|
|
327
|
-
// Ensure parent directory exists
|
|
328
|
-
const dir = (0, path_1.dirname)(infoPath);
|
|
329
|
-
if (!(0, fs_1.existsSync)(dir)) {
|
|
330
|
-
(0, fs_1.mkdirSync)(dir, { recursive: true });
|
|
331
|
-
}
|
|
332
|
-
(0, fs_1.writeFileSync)(infoPath, JSON.stringify(info, null, 2), 'utf-8');
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
exports.DirectoryRepository = DirectoryRepository;
|
|
336
|
-
//# sourceMappingURL=DirectoryRepository.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DirectoryRepository.js","sour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QAAQ,GAAG,IAAA,WAAI,EAAC,IAAI,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;QAE5D,iCAAiC;QACjC,MAAM,GAAG,GAAG,IAAA,cAAO,EAAC,QAAQ,CAAC,CAAC;QAC9B,IAAI,CAAC,IAAA,eAAU,EAAC,GAAG,CAAC,EAAE,CAAC;YACrB,IAAA,cAAS,EAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACtC,CAAC;QAED,IAAA,kBAAa,EAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IAClE,CAAC;CACF;AA7XD,kDA6XC"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { BaseRepository } from './BaseRepository';
|
|
2
|
-
import { ExplorationRecord } from '../types';
|
|
3
|
-
/**
|
|
4
|
-
* ExplorationRepository handles all storage operations for exploration records
|
|
5
|
-
* Responsible for managing web exploration and test generation history
|
|
6
|
-
*/
|
|
7
|
-
export declare class ExplorationRepository extends BaseRepository {
|
|
8
|
-
constructor(projectId: string);
|
|
9
|
-
/**
|
|
10
|
-
* Save an exploration record
|
|
11
|
-
*/
|
|
12
|
-
saveExplorationRecord(record: ExplorationRecord): Promise<void>;
|
|
13
|
-
/**
|
|
14
|
-
* Load an exploration record by ID
|
|
15
|
-
*/
|
|
16
|
-
loadExplorationRecord(recordId: string): Promise<ExplorationRecord | null>;
|
|
17
|
-
/**
|
|
18
|
-
* List all exploration records sorted by start time (newest first)
|
|
19
|
-
*/
|
|
20
|
-
listExplorationRecords(): Promise<ExplorationRecord[]>;
|
|
21
|
-
/**
|
|
22
|
-
* Update an exploration record
|
|
23
|
-
*/
|
|
24
|
-
updateExplorationRecord(record: ExplorationRecord): Promise<void>;
|
|
25
|
-
/**
|
|
26
|
-
* Delete an exploration record
|
|
27
|
-
*/
|
|
28
|
-
deleteExplorationRecord(recordId: string): Promise<void>;
|
|
29
|
-
/**
|
|
30
|
-
* Get exploration records for a specific URL
|
|
31
|
-
*/
|
|
32
|
-
getRecordsByUrl(url: string): Promise<ExplorationRecord[]>;
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=ExplorationRepository.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ExplorationRepository.d.ts","sourceRoot":"","sources":["../../../../../core-infra/src/repositories/ExplorationRepository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C;;;GAGG;AACH,qBAAa,qBAAsB,SAAQ,cAAc;gBACzC,SAAS,EAAE,MAAM;IAI/B;;OAEG;IACG,qBAAqB,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAIrE;;OAEG;IACG,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAIhF;;OAEG;IACG,sBAAsB,IAAI,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAK5D;;OAEG;IACG,uBAAuB,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvE;;OAEG;IACG,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9D;;OAEG;IACG,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;CAIjE"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ExplorationRepository = void 0;
|
|
4
|
-
const path_1 = require("path");
|
|
5
|
-
const BaseRepository_1 = require("./BaseRepository");
|
|
6
|
-
/**
|
|
7
|
-
* ExplorationRepository handles all storage operations for exploration records
|
|
8
|
-
* Responsible for managing web exploration and test generation history
|
|
9
|
-
*/
|
|
10
|
-
class ExplorationRepository extends BaseRepository_1.BaseRepository {
|
|
11
|
-
constructor(projectId) {
|
|
12
|
-
super((0, path_1.join)("projects", projectId, 'explorations'));
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Save an exploration record
|
|
16
|
-
*/
|
|
17
|
-
async saveExplorationRecord(record) {
|
|
18
|
-
await this.save(record.id, record, 'json');
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Load an exploration record by ID
|
|
22
|
-
*/
|
|
23
|
-
async loadExplorationRecord(recordId) {
|
|
24
|
-
return this.load(recordId, 'json');
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* List all exploration records sorted by start time (newest first)
|
|
28
|
-
*/
|
|
29
|
-
async listExplorationRecords() {
|
|
30
|
-
const records = await this.listAll();
|
|
31
|
-
return records.sort((a, b) => b.startedAt - a.startedAt);
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Update an exploration record
|
|
35
|
-
*/
|
|
36
|
-
async updateExplorationRecord(record) {
|
|
37
|
-
await this.saveExplorationRecord(record);
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Delete an exploration record
|
|
41
|
-
*/
|
|
42
|
-
async deleteExplorationRecord(recordId) {
|
|
43
|
-
await this.delete(recordId, 'json');
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Get exploration records for a specific URL
|
|
47
|
-
*/
|
|
48
|
-
async getRecordsByUrl(url) {
|
|
49
|
-
const records = await this.listExplorationRecords();
|
|
50
|
-
return records.filter(r => r.url === url);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
exports.ExplorationRepository = ExplorationRepository;
|
|
54
|
-
//# sourceMappingURL=ExplorationRepository.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ExplorationRepository.js","sourceRoot":"","sources":["../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AC,CAAC;IAC5C,CAAC;CACF;AAhDD,sDAgDC"}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
export interface FileInfo {
|
|
2
|
-
name: string;
|
|
3
|
-
size: number;
|
|
4
|
-
uploadedAt: string;
|
|
5
|
-
path: string;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* FileRepository - Handles file storage for test cases
|
|
9
|
-
* Each test case has its own files directory
|
|
10
|
-
*/
|
|
11
|
-
export declare class FileRepository {
|
|
12
|
-
private projectId;
|
|
13
|
-
private filesBaseDir;
|
|
14
|
-
constructor(projectId: string);
|
|
15
|
-
/**
|
|
16
|
-
* Ensure base files directory exists
|
|
17
|
-
*/
|
|
18
|
-
private ensureBaseDir;
|
|
19
|
-
/**
|
|
20
|
-
* Get files directory for a specific test case
|
|
21
|
-
*/
|
|
22
|
-
getTestFilesDir(testId: string): string;
|
|
23
|
-
/**
|
|
24
|
-
* Ensure test files directory exists
|
|
25
|
-
*/
|
|
26
|
-
private ensureTestFilesDir;
|
|
27
|
-
/**
|
|
28
|
-
* Save a file for a test case
|
|
29
|
-
*/
|
|
30
|
-
saveFile(testId: string, fileName: string, content: Buffer): FileInfo;
|
|
31
|
-
/**
|
|
32
|
-
* Load a file for a test case
|
|
33
|
-
*/
|
|
34
|
-
loadFile(testId: string, fileName: string): Buffer | null;
|
|
35
|
-
/**
|
|
36
|
-
* List all files for a test case
|
|
37
|
-
*/
|
|
38
|
-
listFiles(testId: string): FileInfo[];
|
|
39
|
-
/**
|
|
40
|
-
* Delete a file for a test case
|
|
41
|
-
*/
|
|
42
|
-
deleteFile(testId: string, fileName: string): boolean;
|
|
43
|
-
/**
|
|
44
|
-
* Delete all files for a test case
|
|
45
|
-
*/
|
|
46
|
-
deleteAllFiles(testId: string): void;
|
|
47
|
-
/**
|
|
48
|
-
* Check if a file exists
|
|
49
|
-
*/
|
|
50
|
-
fileExists(testId: string, fileName: string): boolean;
|
|
51
|
-
/**
|
|
52
|
-
* Get file info
|
|
53
|
-
*/
|
|
54
|
-
getFileInfo(testId: string, fileName: string): FileInfo | null;
|
|
55
|
-
}
|
|
56
|
-
//# sourceMappingURL=FileRepository.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FileRepository.d.ts","sourceRoot":"","sources":["../../../../../core-infra/src/repositories/FileRepository.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;GAGG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,YAAY,CAAS;gBAEjB,SAAS,EAAE,MAAM;IAM7B;;OAEG;IACH,OAAO,CAAC,aAAa;IAMrB;;OAEG;IACH,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAIvC;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAO1B;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,QAAQ;IAerE;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAQzD;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,EAAE;IAmBrC;;OAEG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO;IASrD;;OAEG;IACH,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAQpC;;OAEG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO;IAKrD;;OAEG;IACH,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI;CAc/D"}
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FileRepository = void 0;
|
|
4
|
-
const fs_1 = require("fs");
|
|
5
|
-
const path_1 = require("path");
|
|
6
|
-
const os_1 = require("os");
|
|
7
|
-
const STORAGE_DIR = (0, path_1.join)((0, os_1.homedir)(), '.test_agent');
|
|
8
|
-
/**
|
|
9
|
-
* FileRepository - Handles file storage for test cases
|
|
10
|
-
* Each test case has its own files directory
|
|
11
|
-
*/
|
|
12
|
-
class FileRepository {
|
|
13
|
-
constructor(projectId) {
|
|
14
|
-
this.projectId = projectId;
|
|
15
|
-
this.filesBaseDir = (0, path_1.join)(STORAGE_DIR, 'projects', projectId, 'files');
|
|
16
|
-
this.ensureBaseDir();
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Ensure base files directory exists
|
|
20
|
-
*/
|
|
21
|
-
ensureBaseDir() {
|
|
22
|
-
if (!(0, fs_1.existsSync)(this.filesBaseDir)) {
|
|
23
|
-
(0, fs_1.mkdirSync)(this.filesBaseDir, { recursive: true });
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Get files directory for a specific test case
|
|
28
|
-
*/
|
|
29
|
-
getTestFilesDir(testId) {
|
|
30
|
-
return (0, path_1.join)(this.filesBaseDir, testId);
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Ensure test files directory exists
|
|
34
|
-
*/
|
|
35
|
-
ensureTestFilesDir(testId) {
|
|
36
|
-
const dir = this.getTestFilesDir(testId);
|
|
37
|
-
if (!(0, fs_1.existsSync)(dir)) {
|
|
38
|
-
(0, fs_1.mkdirSync)(dir, { recursive: true });
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Save a file for a test case
|
|
43
|
-
*/
|
|
44
|
-
saveFile(testId, fileName, content) {
|
|
45
|
-
this.ensureTestFilesDir(testId);
|
|
46
|
-
const filePath = (0, path_1.join)(this.getTestFilesDir(testId), fileName);
|
|
47
|
-
(0, fs_1.writeFileSync)(filePath, content);
|
|
48
|
-
const stats = (0, fs_1.statSync)(filePath);
|
|
49
|
-
return {
|
|
50
|
-
name: fileName,
|
|
51
|
-
size: stats.size,
|
|
52
|
-
uploadedAt: new Date().toISOString(),
|
|
53
|
-
path: filePath,
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Load a file for a test case
|
|
58
|
-
*/
|
|
59
|
-
loadFile(testId, fileName) {
|
|
60
|
-
const filePath = (0, path_1.join)(this.getTestFilesDir(testId), fileName);
|
|
61
|
-
if (!(0, fs_1.existsSync)(filePath)) {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
return (0, fs_1.readFileSync)(filePath);
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* List all files for a test case
|
|
68
|
-
*/
|
|
69
|
-
listFiles(testId) {
|
|
70
|
-
const dir = this.getTestFilesDir(testId);
|
|
71
|
-
if (!(0, fs_1.existsSync)(dir)) {
|
|
72
|
-
return [];
|
|
73
|
-
}
|
|
74
|
-
const files = (0, fs_1.readdirSync)(dir);
|
|
75
|
-
return files.map(fileName => {
|
|
76
|
-
const filePath = (0, path_1.join)(dir, fileName);
|
|
77
|
-
const stats = (0, fs_1.statSync)(filePath);
|
|
78
|
-
return {
|
|
79
|
-
name: fileName,
|
|
80
|
-
size: stats.size,
|
|
81
|
-
uploadedAt: stats.mtime.toISOString(),
|
|
82
|
-
path: filePath,
|
|
83
|
-
};
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Delete a file for a test case
|
|
88
|
-
*/
|
|
89
|
-
deleteFile(testId, fileName) {
|
|
90
|
-
const filePath = (0, path_1.join)(this.getTestFilesDir(testId), fileName);
|
|
91
|
-
if (!(0, fs_1.existsSync)(filePath)) {
|
|
92
|
-
return false;
|
|
93
|
-
}
|
|
94
|
-
(0, fs_1.unlinkSync)(filePath);
|
|
95
|
-
return true;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Delete all files for a test case
|
|
99
|
-
*/
|
|
100
|
-
deleteAllFiles(testId) {
|
|
101
|
-
const dir = this.getTestFilesDir(testId);
|
|
102
|
-
if (!(0, fs_1.existsSync)(dir)) {
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
(0, fs_1.rmSync)(dir, { recursive: true });
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Check if a file exists
|
|
109
|
-
*/
|
|
110
|
-
fileExists(testId, fileName) {
|
|
111
|
-
const filePath = (0, path_1.join)(this.getTestFilesDir(testId), fileName);
|
|
112
|
-
return (0, fs_1.existsSync)(filePath);
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Get file info
|
|
116
|
-
*/
|
|
117
|
-
getFileInfo(testId, fileName) {
|
|
118
|
-
const filePath = (0, path_1.join)(this.getTestFilesDir(testId), fileName);
|
|
119
|
-
if (!(0, fs_1.existsSync)(filePath)) {
|
|
120
|
-
return null;
|
|
121
|
-
}
|
|
122
|
-
const stats = (0, fs_1.statSync)(filePath);
|
|
123
|
-
return {
|
|
124
|
-
name: fileName,
|
|
125
|
-
size: stats.size,
|
|
126
|
-
uploadedAt: stats.mtime.toISOString(),
|
|
127
|
-
path: filePath,
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
exports.FileRepository = FileRepository;
|
|
132
|
-
//# sourceMappingURL=FileRepository.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FileRepository.js","sourceRoot":"","sources":["../../../../../core-infra/src/repositories/FileRepository.ts"],"names":[],"mappings":";;;AAAA,2BAAmH;AACnH,+BAA4B;AAC5B,2BAA6B;AAE7B,MAAM,WAAW,GAAG,IAAA,WAAI,EAAC,IAAA,YAAO,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