@exaudeus/workrail 0.0.17 → 0.0.19
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/LICENSE +21 -0
- package/README.md +9 -9
- package/dist/application/app.d.ts +0 -7
- package/dist/application/app.js +1 -18
- package/dist/application/services/enhanced-error-service.d.ts +0 -64
- package/dist/application/services/enhanced-error-service.js +11 -82
- package/dist/application/services/validation-engine.d.ts +0 -65
- package/dist/application/services/validation-engine.js +5 -91
- package/dist/application/services/workflow-service.d.ts +0 -11
- package/dist/application/services/workflow-service.js +0 -17
- package/dist/application/use-cases/get-next-step.d.ts +0 -9
- package/dist/application/use-cases/get-next-step.js +0 -9
- package/dist/application/use-cases/get-workflow.d.ts +0 -9
- package/dist/application/use-cases/get-workflow.js +0 -17
- package/dist/application/use-cases/list-workflows.d.ts +0 -9
- package/dist/application/use-cases/list-workflows.js +0 -9
- package/dist/application/use-cases/validate-step-output.d.ts +0 -9
- package/dist/application/use-cases/validate-step-output.js +0 -9
- package/dist/application/use-cases/validate-workflow-json.d.ts +0 -12
- package/dist/application/use-cases/validate-workflow-json.js +0 -21
- package/dist/application/validation.d.ts +0 -1
- package/dist/application/validation.js +6 -5
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +7 -12
- package/dist/container.d.ts +0 -11
- package/dist/container.js +0 -6
- package/dist/core/error-handler.d.ts +0 -43
- package/dist/core/error-handler.js +0 -65
- package/dist/domain/index.d.ts +0 -1
- package/dist/domain/index.js +16 -4
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -2
- package/dist/infrastructure/index.d.ts +0 -1
- package/dist/infrastructure/index.js +16 -4
- package/dist/infrastructure/rpc/handler.d.ts +0 -9
- package/dist/infrastructure/rpc/handler.js +3 -16
- package/dist/infrastructure/rpc/index.d.ts +0 -1
- package/dist/infrastructure/rpc/index.js +15 -3
- package/dist/infrastructure/rpc/server.d.ts +0 -1
- package/dist/infrastructure/rpc/server.js +0 -3
- package/dist/infrastructure/storage/caching-workflow-storage.d.ts +0 -4
- package/dist/infrastructure/storage/caching-workflow-storage.js +2 -9
- package/dist/infrastructure/storage/file-workflow-storage.d.ts +0 -28
- package/dist/infrastructure/storage/file-workflow-storage.js +14 -57
- package/dist/infrastructure/storage/git-workflow-storage.d.ts +0 -14
- package/dist/infrastructure/storage/git-workflow-storage.js +19 -51
- package/dist/infrastructure/storage/in-memory-storage.d.ts +0 -6
- package/dist/infrastructure/storage/in-memory-storage.js +0 -7
- package/dist/infrastructure/storage/index.d.ts +0 -1
- package/dist/infrastructure/storage/index.js +19 -7
- package/dist/infrastructure/storage/multi-directory-workflow-storage.d.ts +0 -18
- package/dist/infrastructure/storage/multi-directory-workflow-storage.js +7 -36
- package/dist/infrastructure/storage/plugin-workflow-storage.d.ts +0 -43
- package/dist/infrastructure/storage/plugin-workflow-storage.js +17 -78
- package/dist/infrastructure/storage/remote-workflow-storage.d.ts +0 -10
- package/dist/infrastructure/storage/remote-workflow-storage.js +6 -39
- package/dist/infrastructure/storage/schema-validating-workflow-storage.d.ts +0 -5
- package/dist/infrastructure/storage/schema-validating-workflow-storage.js +7 -12
- package/dist/infrastructure/storage/storage.d.ts +0 -14
- package/dist/infrastructure/storage/storage.js +2 -21
- package/dist/mcp-server.d.ts +0 -1
- package/dist/mcp-server.js +2 -14
- package/dist/tools/mcp_initialize.d.ts +0 -1
- package/dist/tools/mcp_initialize.js +2 -9
- package/dist/tools/mcp_shutdown.d.ts +0 -1
- package/dist/tools/mcp_shutdown.js +0 -1
- package/dist/tools/mcp_tools_list.d.ts +0 -1
- package/dist/tools/mcp_tools_list.js +0 -1
- package/dist/types/mcp-types.d.ts +0 -1
- package/dist/types/mcp-types.js +0 -8
- package/dist/types/server.d.ts +0 -1
- package/dist/types/server.js +0 -1
- package/dist/types/storage.d.ts +0 -20
- package/dist/types/storage.js +0 -4
- package/dist/types/workflow-types.d.ts +0 -1
- package/dist/types/workflow-types.js +0 -3
- package/dist/utils/condition-evaluator.d.ts +0 -15
- package/dist/utils/condition-evaluator.js +0 -24
- package/dist/utils/config.d.ts +0 -55
- package/dist/utils/config.js +0 -84
- package/dist/utils/storage-security.d.ts +0 -62
- package/dist/utils/storage-security.js +6 -62
- package/dist/validation/request-validator.d.ts +0 -1
- package/dist/validation/request-validator.js +6 -6
- package/dist/validation/response-validator.d.ts +0 -1
- package/dist/validation/response-validator.js +4 -21
- package/dist/validation/schemas.d.ts +0 -5
- package/dist/validation/schemas.js +0 -5
- package/package.json +7 -14
- package/spec/mcp-protocol-handshake.md +4 -3
- package/workflows/coding-task-workflow.json +32 -0
- package/workflows/document-creation-workflow.json +235 -0
- package/workflows/exploration-workflow.json +254 -0
- package/workflows/presentation-creation.json +71 -0
- package/workflows/systemic-bug-investigation.json +65 -27
- package/workflows/systemic-bug-investigation.json.bak +196 -0
- package/dist/mcp-server-simple.js +0 -391
- package/dist/types/session-types.d.ts +0 -354
- package/dist/types/session-types.d.ts.map +0 -1
- package/dist/types/session-types.js +0 -89
- package/dist/types/session-types.js.map +0 -1
- package/workflows/example-agent-role-workflow.json +0 -83
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Etienne Beaulac
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# Workflow Orchestration Server
|
|
1
|
+
# WorkRail: A Workflow Orchestration Server for MCP
|
|
2
2
|
|
|
3
3
|
> **Reliable, test-driven workflow execution for AI coding assistants – powered by Clean Architecture**
|
|
4
4
|
|
|
5
|
-
[]()
|
|
6
6
|
[]()
|
|
7
7
|
[](https://modelcontextprotocol.org)
|
|
8
8
|
|
|
@@ -108,7 +108,7 @@ Add this to your `claude_desktop_config.json`:
|
|
|
108
108
|
```json
|
|
109
109
|
{
|
|
110
110
|
"mcpServers": {
|
|
111
|
-
"
|
|
111
|
+
"workrail": {
|
|
112
112
|
"command": "npx",
|
|
113
113
|
"args": [
|
|
114
114
|
"-y",
|
|
@@ -124,10 +124,10 @@ Add this to your `claude_desktop_config.json`:
|
|
|
124
124
|
```json
|
|
125
125
|
{
|
|
126
126
|
"mcpServers": {
|
|
127
|
-
"
|
|
127
|
+
"workrail": {
|
|
128
128
|
"command": "node",
|
|
129
129
|
"args": [
|
|
130
|
-
"/path/to/your/
|
|
130
|
+
"/path/to/your/mcp/packages/workrail/dist/mcp-server.js"
|
|
131
131
|
]
|
|
132
132
|
}
|
|
133
133
|
}
|
|
@@ -144,7 +144,7 @@ For manual installation, add this to your User Settings (JSON) or `.vscode/mcp.j
|
|
|
144
144
|
{
|
|
145
145
|
"mcp": {
|
|
146
146
|
"servers": {
|
|
147
|
-
"
|
|
147
|
+
"workrail": {
|
|
148
148
|
"command": "npx",
|
|
149
149
|
"args": [
|
|
150
150
|
"-y",
|
|
@@ -162,10 +162,10 @@ For manual installation, add this to your User Settings (JSON) or `.vscode/mcp.j
|
|
|
162
162
|
{
|
|
163
163
|
"mcp": {
|
|
164
164
|
"servers": {
|
|
165
|
-
"
|
|
165
|
+
"workrail": {
|
|
166
166
|
"command": "node",
|
|
167
167
|
"args": [
|
|
168
|
-
"/path/to/your/
|
|
168
|
+
"/path/to/your/mcp/packages/workrail/dist/mcp-server.js"
|
|
169
169
|
]
|
|
170
170
|
}
|
|
171
171
|
}
|
|
@@ -178,7 +178,7 @@ For manual installation, add this to your User Settings (JSON) or `.vscode/mcp.j
|
|
|
178
178
|
## 🗂️ Project Structure (post-refactor)
|
|
179
179
|
|
|
180
180
|
```
|
|
181
|
-
|
|
181
|
+
packages/workrail/
|
|
182
182
|
├─ src/
|
|
183
183
|
│ ├─ domain/ # Pure entities & errors (no dependencies)
|
|
184
184
|
│ ├─ application/ # Use-cases, services, ValidationEngine (depends on domain)
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Lightweight mediator that maps JSON-RPC method names to handler functions.
|
|
3
|
-
* It delegates parameter validation to an injected validator and remains
|
|
4
|
-
* agnostic of transport concerns.
|
|
5
|
-
*/
|
|
6
1
|
export type MethodHandler = (params: any) => Promise<any> | any;
|
|
7
2
|
export interface MethodValidator {
|
|
8
3
|
validate(method: string, params: any): void;
|
|
@@ -12,7 +7,6 @@ export declare class ApplicationMediator {
|
|
|
12
7
|
private readonly validateFn;
|
|
13
8
|
constructor(validator: MethodValidator);
|
|
14
9
|
register(method: string, handler: MethodHandler): void;
|
|
15
|
-
/** Execute a method after validation. */
|
|
16
10
|
execute(method: string, params: any): Promise<any>;
|
|
17
11
|
private responseValidate?;
|
|
18
12
|
setResponseValidator(fn: (method: string, result: any) => void): void;
|
|
@@ -29,4 +23,3 @@ export declare const METHOD_NAMES: {
|
|
|
29
23
|
};
|
|
30
24
|
export type MethodName = typeof METHOD_NAMES[keyof typeof METHOD_NAMES];
|
|
31
25
|
export declare function buildWorkflowApplication(workflowService: WorkflowService, validator?: MethodValidator): ApplicationMediator;
|
|
32
|
-
//# sourceMappingURL=app.d.ts.map
|
package/dist/application/app.js
CHANGED
|
@@ -38,9 +38,8 @@ exports.buildWorkflowApplication = buildWorkflowApplication;
|
|
|
38
38
|
const error_handler_1 = require("../core/error-handler");
|
|
39
39
|
const mcp_types_1 = require("../types/mcp-types");
|
|
40
40
|
class ApplicationMediator {
|
|
41
|
-
handlers = new Map();
|
|
42
|
-
validateFn;
|
|
43
41
|
constructor(validator) {
|
|
42
|
+
this.handlers = new Map();
|
|
44
43
|
this.validateFn = validator.validate.bind(validator);
|
|
45
44
|
}
|
|
46
45
|
register(method, handler) {
|
|
@@ -49,23 +48,18 @@ class ApplicationMediator {
|
|
|
49
48
|
}
|
|
50
49
|
this.handlers.set(method, handler);
|
|
51
50
|
}
|
|
52
|
-
/** Execute a method after validation. */
|
|
53
51
|
async execute(method, params) {
|
|
54
52
|
const handler = this.handlers.get(method);
|
|
55
53
|
if (!handler) {
|
|
56
54
|
throw new error_handler_1.MCPError(mcp_types_1.MCPErrorCodes.METHOD_NOT_FOUND, 'Method not found', { method });
|
|
57
55
|
}
|
|
58
|
-
// Perform validation once
|
|
59
56
|
this.validateFn(method, params);
|
|
60
57
|
const result = await handler(params);
|
|
61
|
-
// Validate output if a response validator is registered
|
|
62
58
|
if (this.responseValidate) {
|
|
63
59
|
this.responseValidate(method, result);
|
|
64
60
|
}
|
|
65
61
|
return result;
|
|
66
62
|
}
|
|
67
|
-
// Optional response validator injection
|
|
68
|
-
responseValidate;
|
|
69
63
|
setResponseValidator(fn) {
|
|
70
64
|
this.responseValidate = fn;
|
|
71
65
|
}
|
|
@@ -88,18 +82,11 @@ exports.METHOD_NAMES = {
|
|
|
88
82
|
};
|
|
89
83
|
function buildWorkflowApplication(workflowService, validator = request_validator_1.requestValidator) {
|
|
90
84
|
const app = new ApplicationMediator(validator);
|
|
91
|
-
// Attach response validator
|
|
92
85
|
app.setResponseValidator((method, result) => response_validator_1.responseValidator.validate(method, result));
|
|
93
|
-
// ------------------------------------------------------------------------
|
|
94
|
-
// Create use-case instances with injected dependencies
|
|
95
|
-
// ------------------------------------------------------------------------
|
|
96
86
|
const listWorkflowsUseCase = (0, list_workflows_1.createListWorkflows)(workflowService);
|
|
97
87
|
const getWorkflowUseCase = (0, get_workflow_1.createGetWorkflow)(workflowService);
|
|
98
88
|
const getNextStepUseCase = (0, get_next_step_1.createGetNextStep)(workflowService);
|
|
99
89
|
const validateStepOutputUseCase = (0, validate_step_output_1.createValidateStepOutput)(workflowService);
|
|
100
|
-
// ------------------------------------------------------------------------
|
|
101
|
-
// Workflow tool methods
|
|
102
|
-
// ------------------------------------------------------------------------
|
|
103
90
|
app.register(exports.METHOD_NAMES.WORKFLOW_LIST, async (_params) => {
|
|
104
91
|
const workflows = await listWorkflowsUseCase();
|
|
105
92
|
return { workflows };
|
|
@@ -113,9 +100,6 @@ function buildWorkflowApplication(workflowService, validator = request_validator
|
|
|
113
100
|
app.register(exports.METHOD_NAMES.WORKFLOW_VALIDATE, async (params) => {
|
|
114
101
|
return validateStepOutputUseCase(params.workflowId, params.stepId, params.output);
|
|
115
102
|
});
|
|
116
|
-
// ------------------------------------------------------------------------
|
|
117
|
-
// System/handshake methods – dynamic imports to avoid circular deps
|
|
118
|
-
// ------------------------------------------------------------------------
|
|
119
103
|
app.register(exports.METHOD_NAMES.INITIALIZE, async (params) => {
|
|
120
104
|
const { initializeHandler } = await Promise.resolve().then(() => __importStar(require('../tools/mcp_initialize')));
|
|
121
105
|
return (await initializeHandler({ id: 0, params, method: 'initialize', jsonrpc: '2.0' })).result;
|
|
@@ -130,4 +114,3 @@ function buildWorkflowApplication(workflowService, validator = request_validator
|
|
|
130
114
|
});
|
|
131
115
|
return app;
|
|
132
116
|
}
|
|
133
|
-
//# sourceMappingURL=app.js.map
|
|
@@ -1,81 +1,17 @@
|
|
|
1
1
|
import { ErrorObject } from 'ajv';
|
|
2
|
-
/**
|
|
3
|
-
* Enhanced Error Service
|
|
4
|
-
*
|
|
5
|
-
* Transforms AJV error objects into extremely specific, user-friendly error messages
|
|
6
|
-
* that provide exact field names, locations, and actionable guidance.
|
|
7
|
-
*
|
|
8
|
-
* Based on comprehensive error structure analysis confirming:
|
|
9
|
-
* - 100% of additionalProperties errors provide exact field names
|
|
10
|
-
* - 82% of errors have meaningful instance paths for location tracking
|
|
11
|
-
* - Complete parameter information for all error types
|
|
12
|
-
*/
|
|
13
2
|
export declare class EnhancedErrorService {
|
|
14
|
-
/**
|
|
15
|
-
* Transform AJV errors into enhanced, user-friendly messages
|
|
16
|
-
* @param errors Array of AJV ErrorObject instances
|
|
17
|
-
* @returns Array of enhanced error messages with specific details
|
|
18
|
-
*/
|
|
19
3
|
static enhanceErrors(errors: ErrorObject[]): string[];
|
|
20
|
-
/**
|
|
21
|
-
* Prioritize errors by severity and importance
|
|
22
|
-
* Critical: additionalProperties, required fields
|
|
23
|
-
* High: type mismatches, pattern violations
|
|
24
|
-
* Medium: array/object constraints
|
|
25
|
-
* Low: schema composition errors
|
|
26
|
-
*/
|
|
27
4
|
private static prioritizeErrors;
|
|
28
|
-
/**
|
|
29
|
-
* Transform a single AJV error into an enhanced message
|
|
30
|
-
*/
|
|
31
5
|
private static transformError;
|
|
32
|
-
/**
|
|
33
|
-
* Convert instancePath to human-readable location description
|
|
34
|
-
*/
|
|
35
6
|
private static getLocationDescription;
|
|
36
|
-
/**
|
|
37
|
-
* Handle additionalProperties errors - our primary target
|
|
38
|
-
* These provide exact field names via params.additionalProperty
|
|
39
|
-
*/
|
|
40
7
|
private static handleAdditionalProperties;
|
|
41
|
-
/**
|
|
42
|
-
* Handle required field errors
|
|
43
|
-
* These provide missing field names via params.missingProperty
|
|
44
|
-
*/
|
|
45
8
|
private static handleRequired;
|
|
46
|
-
/**
|
|
47
|
-
* Handle type mismatch errors
|
|
48
|
-
* These provide expected type via params.type
|
|
49
|
-
*/
|
|
50
9
|
private static handleType;
|
|
51
|
-
/**
|
|
52
|
-
* Handle pattern validation errors
|
|
53
|
-
* These provide the regex pattern via params.pattern
|
|
54
|
-
*/
|
|
55
10
|
private static handlePattern;
|
|
56
|
-
/**
|
|
57
|
-
* Handle minimum items array errors
|
|
58
|
-
*/
|
|
59
11
|
private static handleMinItems;
|
|
60
|
-
/**
|
|
61
|
-
* Handle maximum items array errors
|
|
62
|
-
*/
|
|
63
12
|
private static handleMaxItems;
|
|
64
|
-
/**
|
|
65
|
-
* Handle enum validation errors
|
|
66
|
-
*/
|
|
67
13
|
private static handleEnum;
|
|
68
|
-
/**
|
|
69
|
-
* Handle oneOf schema composition errors
|
|
70
|
-
*/
|
|
71
14
|
private static handleOneOf;
|
|
72
|
-
/**
|
|
73
|
-
* Handle anyOf schema composition errors
|
|
74
|
-
*/
|
|
75
15
|
private static handleAnyOf;
|
|
76
|
-
/**
|
|
77
|
-
* Handle generic/unknown error types
|
|
78
|
-
*/
|
|
79
16
|
private static handleGeneric;
|
|
80
17
|
}
|
|
81
|
-
//# sourceMappingURL=enhanced-error-service.d.ts.map
|
|
@@ -1,51 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EnhancedErrorService = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Enhanced Error Service
|
|
6
|
-
*
|
|
7
|
-
* Transforms AJV error objects into extremely specific, user-friendly error messages
|
|
8
|
-
* that provide exact field names, locations, and actionable guidance.
|
|
9
|
-
*
|
|
10
|
-
* Based on comprehensive error structure analysis confirming:
|
|
11
|
-
* - 100% of additionalProperties errors provide exact field names
|
|
12
|
-
* - 82% of errors have meaningful instance paths for location tracking
|
|
13
|
-
* - Complete parameter information for all error types
|
|
14
|
-
*/
|
|
15
4
|
class EnhancedErrorService {
|
|
16
|
-
/**
|
|
17
|
-
* Transform AJV errors into enhanced, user-friendly messages
|
|
18
|
-
* @param errors Array of AJV ErrorObject instances
|
|
19
|
-
* @returns Array of enhanced error messages with specific details
|
|
20
|
-
*/
|
|
21
5
|
static enhanceErrors(errors) {
|
|
22
6
|
if (!errors || errors.length === 0) {
|
|
23
7
|
return [];
|
|
24
8
|
}
|
|
25
|
-
// Sort errors by priority: Critical -> High -> Medium -> Low
|
|
26
9
|
const prioritizedErrors = this.prioritizeErrors(errors);
|
|
27
10
|
return prioritizedErrors.map(error => this.transformError(error));
|
|
28
11
|
}
|
|
29
|
-
/**
|
|
30
|
-
* Prioritize errors by severity and importance
|
|
31
|
-
* Critical: additionalProperties, required fields
|
|
32
|
-
* High: type mismatches, pattern violations
|
|
33
|
-
* Medium: array/object constraints
|
|
34
|
-
* Low: schema composition errors
|
|
35
|
-
*/
|
|
36
12
|
static prioritizeErrors(errors) {
|
|
37
13
|
const priority = {
|
|
38
|
-
additionalProperties: 1,
|
|
39
|
-
required: 1,
|
|
40
|
-
type: 2,
|
|
41
|
-
pattern: 2,
|
|
42
|
-
minItems: 3,
|
|
43
|
-
maxItems: 3,
|
|
44
|
-
minProperties: 3,
|
|
45
|
-
maxProperties: 3,
|
|
46
|
-
oneOf: 4,
|
|
47
|
-
anyOf: 4,
|
|
48
|
-
allOf: 4,
|
|
14
|
+
additionalProperties: 1,
|
|
15
|
+
required: 1,
|
|
16
|
+
type: 2,
|
|
17
|
+
pattern: 2,
|
|
18
|
+
minItems: 3,
|
|
19
|
+
maxItems: 3,
|
|
20
|
+
minProperties: 3,
|
|
21
|
+
maxProperties: 3,
|
|
22
|
+
oneOf: 4,
|
|
23
|
+
anyOf: 4,
|
|
24
|
+
allOf: 4,
|
|
49
25
|
};
|
|
50
26
|
return errors.sort((a, b) => {
|
|
51
27
|
const aPriority = priority[a.keyword] || 5;
|
|
@@ -53,9 +29,6 @@ class EnhancedErrorService {
|
|
|
53
29
|
return aPriority - bPriority;
|
|
54
30
|
});
|
|
55
31
|
}
|
|
56
|
-
/**
|
|
57
|
-
* Transform a single AJV error into an enhanced message
|
|
58
|
-
*/
|
|
59
32
|
static transformError(error) {
|
|
60
33
|
const location = this.getLocationDescription(error.instancePath);
|
|
61
34
|
switch (error.keyword) {
|
|
@@ -81,16 +54,11 @@ class EnhancedErrorService {
|
|
|
81
54
|
return this.handleGeneric(error, location);
|
|
82
55
|
}
|
|
83
56
|
}
|
|
84
|
-
/**
|
|
85
|
-
* Convert instancePath to human-readable location description
|
|
86
|
-
*/
|
|
87
57
|
static getLocationDescription(instancePath) {
|
|
88
58
|
if (!instancePath || instancePath === '') {
|
|
89
59
|
return 'at root level';
|
|
90
60
|
}
|
|
91
|
-
// Remove leading slash
|
|
92
61
|
const path = instancePath.startsWith('/') ? instancePath.slice(1) : instancePath;
|
|
93
|
-
// Convert paths to human-readable descriptions
|
|
94
62
|
if (path === 'name')
|
|
95
63
|
return "in field 'name'";
|
|
96
64
|
if (path === 'description')
|
|
@@ -99,29 +67,21 @@ class EnhancedErrorService {
|
|
|
99
67
|
return "in field 'version'";
|
|
100
68
|
if (path === 'steps')
|
|
101
69
|
return "in 'steps' array";
|
|
102
|
-
// Handle array indices: /steps/0 -> "in step 1"
|
|
103
70
|
const stepMatch = path.match(/^steps\/(\d+)$/);
|
|
104
71
|
if (stepMatch && stepMatch[1]) {
|
|
105
72
|
return `in step ${parseInt(stepMatch[1]) + 1}`;
|
|
106
73
|
}
|
|
107
|
-
// Handle nested step properties: /steps/0/name -> "in step 1, field 'name'"
|
|
108
74
|
const stepFieldMatch = path.match(/^steps\/(\d+)\/(.+)$/);
|
|
109
75
|
if (stepFieldMatch && stepFieldMatch[1] && stepFieldMatch[2]) {
|
|
110
76
|
const stepNumber = parseInt(stepFieldMatch[1]) + 1;
|
|
111
77
|
const fieldPath = stepFieldMatch[2];
|
|
112
|
-
// Handle validation criteria paths
|
|
113
78
|
if (fieldPath.startsWith('validationCriteria/')) {
|
|
114
79
|
return `in step ${stepNumber}, validation criteria`;
|
|
115
80
|
}
|
|
116
81
|
return `in step ${stepNumber}, field '${fieldPath}'`;
|
|
117
82
|
}
|
|
118
|
-
// Fallback: return cleaned path
|
|
119
83
|
return `at '${path.replace(/\//g, '.')}'`;
|
|
120
84
|
}
|
|
121
|
-
/**
|
|
122
|
-
* Handle additionalProperties errors - our primary target
|
|
123
|
-
* These provide exact field names via params.additionalProperty
|
|
124
|
-
*/
|
|
125
85
|
static handleAdditionalProperties(error, location) {
|
|
126
86
|
const fieldName = error.params?.['additionalProperty'];
|
|
127
87
|
if (!fieldName) {
|
|
@@ -129,10 +89,6 @@ class EnhancedErrorService {
|
|
|
129
89
|
}
|
|
130
90
|
return `Unexpected property '${fieldName}' found ${location}. This property is not defined in the workflow schema. Please remove it or check for typos.`;
|
|
131
91
|
}
|
|
132
|
-
/**
|
|
133
|
-
* Handle required field errors
|
|
134
|
-
* These provide missing field names via params.missingProperty
|
|
135
|
-
*/
|
|
136
92
|
static handleRequired(error, location) {
|
|
137
93
|
const missingField = error.params?.['missingProperty'];
|
|
138
94
|
if (!missingField) {
|
|
@@ -140,10 +96,6 @@ class EnhancedErrorService {
|
|
|
140
96
|
}
|
|
141
97
|
return `Missing required field '${missingField}' ${location}. This field is mandatory and must be provided.`;
|
|
142
98
|
}
|
|
143
|
-
/**
|
|
144
|
-
* Handle type mismatch errors
|
|
145
|
-
* These provide expected type via params.type
|
|
146
|
-
*/
|
|
147
99
|
static handleType(error, location) {
|
|
148
100
|
const expectedType = error.params?.['type'];
|
|
149
101
|
if (!expectedType) {
|
|
@@ -151,10 +103,6 @@ class EnhancedErrorService {
|
|
|
151
103
|
}
|
|
152
104
|
return `Invalid data type ${location}. Expected '${expectedType}' but received a different type.`;
|
|
153
105
|
}
|
|
154
|
-
/**
|
|
155
|
-
* Handle pattern validation errors
|
|
156
|
-
* These provide the regex pattern via params.pattern
|
|
157
|
-
*/
|
|
158
106
|
static handlePattern(error, location) {
|
|
159
107
|
const pattern = error.params?.['pattern'];
|
|
160
108
|
if (!pattern) {
|
|
@@ -162,9 +110,6 @@ class EnhancedErrorService {
|
|
|
162
110
|
}
|
|
163
111
|
return `Value ${location} does not match the required pattern: ${pattern}`;
|
|
164
112
|
}
|
|
165
|
-
/**
|
|
166
|
-
* Handle minimum items array errors
|
|
167
|
-
*/
|
|
168
113
|
static handleMinItems(error, location) {
|
|
169
114
|
const minItems = error.params?.['limit'];
|
|
170
115
|
if (minItems === undefined) {
|
|
@@ -172,9 +117,6 @@ class EnhancedErrorService {
|
|
|
172
117
|
}
|
|
173
118
|
return `Array ${location} must contain at least ${minItems} item(s).`;
|
|
174
119
|
}
|
|
175
|
-
/**
|
|
176
|
-
* Handle maximum items array errors
|
|
177
|
-
*/
|
|
178
120
|
static handleMaxItems(error, location) {
|
|
179
121
|
const maxItems = error.params?.['limit'];
|
|
180
122
|
if (maxItems === undefined) {
|
|
@@ -182,9 +124,6 @@ class EnhancedErrorService {
|
|
|
182
124
|
}
|
|
183
125
|
return `Array ${location} must contain no more than ${maxItems} item(s).`;
|
|
184
126
|
}
|
|
185
|
-
/**
|
|
186
|
-
* Handle enum validation errors
|
|
187
|
-
*/
|
|
188
127
|
static handleEnum(error, location) {
|
|
189
128
|
const allowedValues = error.params?.['allowedValues'];
|
|
190
129
|
if (!allowedValues || !Array.isArray(allowedValues)) {
|
|
@@ -192,24 +131,14 @@ class EnhancedErrorService {
|
|
|
192
131
|
}
|
|
193
132
|
return `Value ${location} must be one of: ${allowedValues.map(v => `'${v}'`).join(', ')}`;
|
|
194
133
|
}
|
|
195
|
-
/**
|
|
196
|
-
* Handle oneOf schema composition errors
|
|
197
|
-
*/
|
|
198
134
|
static handleOneOf(_error, location) {
|
|
199
135
|
return `Value ${location} must match exactly one of the allowed schema patterns. Please check the workflow schema for valid formats.`;
|
|
200
136
|
}
|
|
201
|
-
/**
|
|
202
|
-
* Handle anyOf schema composition errors
|
|
203
|
-
*/
|
|
204
137
|
static handleAnyOf(_error, location) {
|
|
205
138
|
return `Value ${location} must match at least one of the allowed schema patterns. Please check the workflow schema for valid formats.`;
|
|
206
139
|
}
|
|
207
|
-
/**
|
|
208
|
-
* Handle generic/unknown error types
|
|
209
|
-
*/
|
|
210
140
|
static handleGeneric(error, location) {
|
|
211
141
|
return `Validation error ${location}: ${error.message || 'Unknown validation error'}`;
|
|
212
142
|
}
|
|
213
143
|
}
|
|
214
144
|
exports.EnhancedErrorService = EnhancedErrorService;
|
|
215
|
-
//# sourceMappingURL=enhanced-error-service.js.map
|
|
@@ -21,82 +21,17 @@ export interface ValidationResult {
|
|
|
21
21
|
issues: string[];
|
|
22
22
|
suggestions: string[];
|
|
23
23
|
}
|
|
24
|
-
/**
|
|
25
|
-
* ValidationEngine handles step output validation with support for
|
|
26
|
-
* multiple validation rule types. This engine is responsible for
|
|
27
|
-
* evaluating validation criteria against step outputs.
|
|
28
|
-
*/
|
|
29
24
|
export declare class ValidationEngine {
|
|
30
25
|
private ajv;
|
|
31
26
|
private schemaCache;
|
|
32
27
|
constructor();
|
|
33
|
-
/**
|
|
34
|
-
* Compiles a JSON schema with caching for performance.
|
|
35
|
-
*
|
|
36
|
-
* @param schema - The JSON schema to compile
|
|
37
|
-
* @returns Compiled schema validator function
|
|
38
|
-
*/
|
|
39
28
|
private compileSchema;
|
|
40
|
-
/**
|
|
41
|
-
* Evaluates validation criteria (either array or composition format).
|
|
42
|
-
*
|
|
43
|
-
* @param output - The step output to validate
|
|
44
|
-
* @param criteria - Validation criteria to evaluate
|
|
45
|
-
* @param context - Execution context for conditional validation
|
|
46
|
-
* @returns ValidationResult with validation status and issues
|
|
47
|
-
*/
|
|
48
29
|
private evaluateCriteria;
|
|
49
|
-
/**
|
|
50
|
-
* Evaluates an array of validation rules (legacy format).
|
|
51
|
-
*
|
|
52
|
-
* @param output - The step output to validate
|
|
53
|
-
* @param rules - Array of validation rules to apply
|
|
54
|
-
* @param context - Execution context for conditional validation
|
|
55
|
-
* @returns ValidationResult with validation status and issues
|
|
56
|
-
*/
|
|
57
30
|
private evaluateRuleArray;
|
|
58
|
-
/**
|
|
59
|
-
* Evaluates a validation composition with logical operators.
|
|
60
|
-
*
|
|
61
|
-
* @param output - The step output to validate
|
|
62
|
-
* @param composition - The validation composition to evaluate
|
|
63
|
-
* @param context - Execution context for conditional validation
|
|
64
|
-
* @returns Boolean indicating if the composition is valid
|
|
65
|
-
*/
|
|
66
31
|
private evaluateComposition;
|
|
67
|
-
/**
|
|
68
|
-
* Evaluates a single validation criteria (rule or composition).
|
|
69
|
-
*
|
|
70
|
-
* @param output - The step output to validate
|
|
71
|
-
* @param criteria - Single validation criteria to evaluate
|
|
72
|
-
* @param context - Execution context for conditional validation
|
|
73
|
-
* @returns Boolean indicating if the criteria is valid
|
|
74
|
-
*/
|
|
75
32
|
private evaluateSingleCriteria;
|
|
76
|
-
/**
|
|
77
|
-
* Type guard to check if criteria is a ValidationRule.
|
|
78
|
-
*/
|
|
79
33
|
private isValidationRule;
|
|
80
|
-
/**
|
|
81
|
-
* Type guard to check if criteria is a ValidationComposition.
|
|
82
|
-
*/
|
|
83
34
|
private isValidationComposition;
|
|
84
|
-
/**
|
|
85
|
-
* Validates a step output against validation criteria.
|
|
86
|
-
*
|
|
87
|
-
* @param output - The step output to validate
|
|
88
|
-
* @param criteria - Array of validation rules or composition object to apply
|
|
89
|
-
* @param context - Optional context for context-aware validation
|
|
90
|
-
* @returns ValidationResult with validation status and any issues
|
|
91
|
-
*/
|
|
92
35
|
validate(output: string, criteria: ValidationRule[] | ValidationComposition, context?: ConditionContext): Promise<ValidationResult>;
|
|
93
|
-
/**
|
|
94
|
-
* Evaluates a single validation rule against the output.
|
|
95
|
-
*
|
|
96
|
-
* @param output - The step output to validate
|
|
97
|
-
* @param rule - The validation rule to apply
|
|
98
|
-
* @param issues - Array to collect validation issues
|
|
99
|
-
*/
|
|
100
36
|
private evaluateRule;
|
|
101
37
|
}
|
|
102
|
-
//# sourceMappingURL=validation-engine.d.ts.map
|