@chen-rmag/core-infra 1.0.0
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/README.md +46 -0
- package/dist/ProjectContextManager.d.ts +30 -0
- package/dist/ProjectContextManager.js +41 -0
- package/dist/directory-validator.d.ts +28 -0
- package/dist/directory-validator.js +90 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +44 -0
- package/dist/mcp/file-mcp-manager.d.ts +13 -0
- package/dist/mcp/file-mcp-manager.js +45 -0
- package/dist/mcp/index.d.ts +20 -0
- package/dist/mcp/index.js +16 -0
- package/dist/mcp/mcp-client.d.ts +127 -0
- package/dist/mcp/mcp-client.js +165 -0
- package/dist/mcp/mcp-manager.d.ts +20 -0
- package/dist/mcp/mcp-manager.js +98 -0
- package/dist/mcp/playwright-mcp-manager.d.ts +18 -0
- package/dist/mcp/playwright-mcp-manager.js +115 -0
- package/dist/model.d.ts +10 -0
- package/dist/model.js +207 -0
- package/dist/repositories/BaseRepository.d.ts +68 -0
- package/dist/repositories/BaseRepository.js +212 -0
- package/dist/repositories/DirectoryRepository.d.ts +69 -0
- package/dist/repositories/DirectoryRepository.js +335 -0
- package/dist/repositories/ExplorationRepository.d.ts +33 -0
- package/dist/repositories/ExplorationRepository.js +53 -0
- package/dist/repositories/FileRepository.d.ts +55 -0
- package/dist/repositories/FileRepository.js +131 -0
- package/dist/repositories/ModelConfigRepository.d.ts +33 -0
- package/dist/repositories/ModelConfigRepository.js +51 -0
- package/dist/repositories/ProjectRepository.d.ts +31 -0
- package/dist/repositories/ProjectRepository.js +66 -0
- package/dist/repositories/SettingsRepository.d.ts +18 -0
- package/dist/repositories/SettingsRepository.js +71 -0
- package/dist/repositories/TableDataRepository.d.ts +21 -0
- package/dist/repositories/TableDataRepository.js +32 -0
- package/dist/repositories/TestCaseRepository.d.ts +120 -0
- package/dist/repositories/TestCaseRepository.js +463 -0
- package/dist/repositories/TestPlanRepository.d.ts +34 -0
- package/dist/repositories/TestPlanRepository.js +79 -0
- package/dist/repositories/TestResultRepository.d.ts +29 -0
- package/dist/repositories/TestResultRepository.js +53 -0
- package/dist/repositories/index.d.ts +16 -0
- package/dist/repositories/index.js +30 -0
- package/dist/storageService.d.ts +129 -0
- package/dist/storageService.js +297 -0
- package/dist/types.d.ts +217 -0
- package/dist/types.js +2 -0
- package/package.json +32 -0
- package/src/directory-validator.ts +98 -0
- package/src/index.ts +26 -0
- package/src/mcp/file-mcp-manager.ts +50 -0
- package/src/mcp/index.ts +35 -0
- package/src/mcp/mcp-client.ts +209 -0
- package/src/mcp/mcp-manager.ts +118 -0
- package/src/mcp/playwright-mcp-manager.ts +127 -0
- package/src/model.ts +234 -0
- package/src/repositories/BaseRepository.ts +193 -0
- package/src/repositories/DirectoryRepository.ts +393 -0
- package/src/repositories/ExplorationRepository.ts +57 -0
- package/src/repositories/FileRepository.ts +153 -0
- package/src/repositories/ModelConfigRepository.ts +55 -0
- package/src/repositories/ProjectRepository.ts +70 -0
- package/src/repositories/SettingsRepository.ts +38 -0
- package/src/repositories/TableDataRepository.ts +33 -0
- package/src/repositories/TestCaseRepository.ts +521 -0
- package/src/repositories/TestPlanRepository.ts +89 -0
- package/src/repositories/TestResultRepository.ts +56 -0
- package/src/repositories/index.ts +17 -0
- package/src/storageService.ts +404 -0
- package/src/types.ts +246 -0
- package/tsconfig.json +19 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
// Test-related types
|
|
2
|
+
export interface TestStep {
|
|
3
|
+
id: string;
|
|
4
|
+
description: string; // Step description only, no associated script
|
|
5
|
+
status?: "running" | "success" | "error"; // Execution status
|
|
6
|
+
error?: string; // Error message if failed
|
|
7
|
+
isBreakpoint?: boolean; // Whether this step has a breakpoint (persisted to storage)
|
|
8
|
+
isAI?: boolean;
|
|
9
|
+
reusedTestIds?: string[]; // IDs of reusable test cases
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// Table data types for data-driven testing
|
|
13
|
+
export interface TableData {
|
|
14
|
+
testId: string;
|
|
15
|
+
columns: string[]; // Column names (field names)
|
|
16
|
+
rows: Record<string, string>[]; // Each row is a map of column name to value
|
|
17
|
+
createdAt: number;
|
|
18
|
+
updatedAt: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Test case type enumeration
|
|
22
|
+
export type TestCaseType = 'functional' | 'ui' | 'edge';
|
|
23
|
+
|
|
24
|
+
// Test case priority enumeration
|
|
25
|
+
export type TestCasePriority = 'high' | 'medium' | 'low';
|
|
26
|
+
|
|
27
|
+
export interface TestParameter {
|
|
28
|
+
key: string;
|
|
29
|
+
value: string;
|
|
30
|
+
description: string;
|
|
31
|
+
}
|
|
32
|
+
export interface TestCase {
|
|
33
|
+
id: string;
|
|
34
|
+
name: string;
|
|
35
|
+
description: string;
|
|
36
|
+
url: string;
|
|
37
|
+
steps: TestStep[];
|
|
38
|
+
playwrightScript?: string; // Generated Playwright script for the entire test case
|
|
39
|
+
createdAt: number;
|
|
40
|
+
updatedAt: number;
|
|
41
|
+
status: 'draft' | 'ready' | 'completed';
|
|
42
|
+
path: string; // Directory path relative to tests folder, e.g., 'category1/subcategory' or empty for root
|
|
43
|
+
creator?: 'user' | 'ai'; // Creator of the test: 'user' for manually created, 'ai' for AI-generated
|
|
44
|
+
table?: TableData; // Associated table data rows for data-driven tests
|
|
45
|
+
type?: TestCaseType; // Type of test case: 'functional' | 'ui' | 'error'
|
|
46
|
+
reusable?: boolean; // Whether this test case can be reused as a step in other tests
|
|
47
|
+
dependencies?: string[]; // IDs of test cases that this test depends on
|
|
48
|
+
priority?: TestCasePriority; // Priority of the test case: 'high' | 'medium' | 'low'
|
|
49
|
+
parameters?: TestParameter[]; // Parameters of a reusable test case
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Supported language codes for localization and AI prompts
|
|
53
|
+
export type LanguageCode = 'en-US' | 'zh-CN';
|
|
54
|
+
|
|
55
|
+
// Directory structure types
|
|
56
|
+
export interface DirectoryInfo {
|
|
57
|
+
id: string;
|
|
58
|
+
name: string; // Folder display name
|
|
59
|
+
description?: string;
|
|
60
|
+
createdAt: number;
|
|
61
|
+
updatedAt: number;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface TestDirectory {
|
|
65
|
+
path: string; // e.g., '', 'category1', 'category1/sub'
|
|
66
|
+
name: string; // Display name of current level
|
|
67
|
+
info?: DirectoryInfo; // Metadata from info.json if exists
|
|
68
|
+
children: TestDirectory[]; // Subdirectories
|
|
69
|
+
tests: TestCase[]; // Test cases at this level (leaf nodes only)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Model Configuration types
|
|
73
|
+
export type ModelProvider = 'openai' | 'anthropic' | 'mistral' | 'ollama' | 'openrouter';
|
|
74
|
+
|
|
75
|
+
export interface ModelConfig {
|
|
76
|
+
id: string;
|
|
77
|
+
name: string;
|
|
78
|
+
provider: ModelProvider;
|
|
79
|
+
modelName: string;
|
|
80
|
+
apiKey?: string;
|
|
81
|
+
baseURL?: string;
|
|
82
|
+
temperature?: number;
|
|
83
|
+
maxTokens?: number;
|
|
84
|
+
timeout?: number;
|
|
85
|
+
isDefault?: boolean;
|
|
86
|
+
createdAt: number;
|
|
87
|
+
updatedAt: number;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// AI Agent types (combined with ModelConfig)
|
|
91
|
+
|
|
92
|
+
export interface AutomationJob {
|
|
93
|
+
id: string;
|
|
94
|
+
name: string;
|
|
95
|
+
url: string;
|
|
96
|
+
status: 'idle' | 'exploring' | 'generating' | 'completed' | 'error';
|
|
97
|
+
progress: number; // 0-100
|
|
98
|
+
generatedTests: TestCase[];
|
|
99
|
+
insights: string[];
|
|
100
|
+
startedAt?: number;
|
|
101
|
+
completedAt?: number;
|
|
102
|
+
error?: string;
|
|
103
|
+
depth?: number; // exploration depth
|
|
104
|
+
maxTests?: number;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Exploration Record types
|
|
108
|
+
export interface ExplorationRecord {
|
|
109
|
+
id: string;
|
|
110
|
+
url: string;
|
|
111
|
+
status: 'pending' | 'running' | 'completed' | 'error';
|
|
112
|
+
progress: number; // 0-100
|
|
113
|
+
currentPhase: string;
|
|
114
|
+
generatedTests: number;
|
|
115
|
+
testIds: string[]; // IDs of generated tests
|
|
116
|
+
config: {
|
|
117
|
+
modelConfigId: string;
|
|
118
|
+
modelName: string;
|
|
119
|
+
maxSteps: number;
|
|
120
|
+
maxTests: number;
|
|
121
|
+
exploreDepth: number;
|
|
122
|
+
explorationScope?: string; // User-defined scope limitation
|
|
123
|
+
customData?: Array<{ key: string; value: string }>; // Custom test data
|
|
124
|
+
language?: LanguageCode; // Language code for AI prompts (e.g., 'en-US', 'zh-CN')
|
|
125
|
+
};
|
|
126
|
+
interactions: Array<{
|
|
127
|
+
round: number;
|
|
128
|
+
type: 'exploration' | 'analysis' | 'generation';
|
|
129
|
+
phase: string;
|
|
130
|
+
message: string;
|
|
131
|
+
timestamp: number;
|
|
132
|
+
}>;
|
|
133
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
134
|
+
artifacts?: any; // ExplorationArtifacts from web-explorer/types.ts
|
|
135
|
+
startedAt: number;
|
|
136
|
+
completedAt?: number;
|
|
137
|
+
error?: string;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Settings
|
|
141
|
+
export interface MCPServer {
|
|
142
|
+
name: string;
|
|
143
|
+
endpoint: string;
|
|
144
|
+
capabilities: string[];
|
|
145
|
+
connected: boolean;
|
|
146
|
+
tools?: string[];
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export interface BrowserCapabilities {
|
|
150
|
+
browsers: ('chromium' | 'firefox' | 'webkit')[];
|
|
151
|
+
headless: boolean;
|
|
152
|
+
viewport?: { width: number; height: number };
|
|
153
|
+
deviceScaleFactor?: number;
|
|
154
|
+
locale?: string;
|
|
155
|
+
timezone?: string;
|
|
156
|
+
}
|
|
157
|
+
export interface AppSettings {
|
|
158
|
+
theme: 'light' | 'dark';
|
|
159
|
+
aiModel: ModelConfig;
|
|
160
|
+
defaultBrowser: 'chromium' | 'firefox' | 'webkit';
|
|
161
|
+
headlessMode: boolean;
|
|
162
|
+
autoSave: boolean;
|
|
163
|
+
maxParallelTests: number;
|
|
164
|
+
screenshots: {
|
|
165
|
+
enabled: boolean;
|
|
166
|
+
captureOnError: boolean;
|
|
167
|
+
captureOnStep: boolean;
|
|
168
|
+
};
|
|
169
|
+
timeouts: {
|
|
170
|
+
navigation: number;
|
|
171
|
+
action: number;
|
|
172
|
+
assertion: number;
|
|
173
|
+
};
|
|
174
|
+
mcpSettings?: {
|
|
175
|
+
endpoint: string;
|
|
176
|
+
useStdio: boolean;
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// Test result types
|
|
181
|
+
export interface TestResult {
|
|
182
|
+
id: string;
|
|
183
|
+
testId: string;
|
|
184
|
+
status: 'passed' | 'failed' | 'skipped';
|
|
185
|
+
duration: number; // milliseconds
|
|
186
|
+
executedAt: number;
|
|
187
|
+
error?: string;
|
|
188
|
+
summary: {
|
|
189
|
+
total: number;
|
|
190
|
+
passed: number;
|
|
191
|
+
failed: number;
|
|
192
|
+
skipped: number;
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export interface ToolCallInfo {
|
|
197
|
+
toolCall?: ToolCall;
|
|
198
|
+
content: string;
|
|
199
|
+
status?: 'success' | 'error';
|
|
200
|
+
stepId?: string;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export type ToolCall = {
|
|
204
|
+
name: string;
|
|
205
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
206
|
+
args: Record<string, any>;
|
|
207
|
+
id?: string;
|
|
208
|
+
content?: string;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
// Project Management types
|
|
212
|
+
export interface Project {
|
|
213
|
+
id: string;
|
|
214
|
+
name: string;
|
|
215
|
+
description: string;
|
|
216
|
+
createdAt: number;
|
|
217
|
+
updatedAt?: number;
|
|
218
|
+
isActive: boolean;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// Test Plan types
|
|
222
|
+
export interface TestPlanItem {
|
|
223
|
+
type: 'test' | 'directory';
|
|
224
|
+
id: string; // testId or directory path
|
|
225
|
+
name: string;
|
|
226
|
+
path?: string; // for test cases
|
|
227
|
+
directoryPath?: string; // for directories
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export interface TestPlan {
|
|
231
|
+
id: string;
|
|
232
|
+
name: string;
|
|
233
|
+
description: string;
|
|
234
|
+
projectId: string;
|
|
235
|
+
testIds: string[]; // List of all test IDs
|
|
236
|
+
createdAt: number;
|
|
237
|
+
updatedAt: number;
|
|
238
|
+
status: 'ready' | 'running' | 'completed' | 'failed' | 'partial' | 'stopped';
|
|
239
|
+
lastExecutedAt?: number;
|
|
240
|
+
maxConcurrency?: number;
|
|
241
|
+
browsers?: Array<'chromium' | 'firefox' | 'webkit'>;
|
|
242
|
+
scheduledAt?: number;
|
|
243
|
+
passedIds?: string[];
|
|
244
|
+
failedIds?: string[];
|
|
245
|
+
skippedIds?: string[];
|
|
246
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"lib": ["ES2020"],
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"outDir": "./dist",
|
|
8
|
+
"rootDir": "./src",
|
|
9
|
+
"strict": true,
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"forceConsistentCasingInFileNames": true,
|
|
13
|
+
"moduleResolution": "node",
|
|
14
|
+
"resolveJsonModule": true,
|
|
15
|
+
"allowSyntheticDefaultImports": true
|
|
16
|
+
},
|
|
17
|
+
"include": ["src/**/*"],
|
|
18
|
+
"exclude": ["node_modules", "dist"]
|
|
19
|
+
}
|