Skip to content

Commit a1fb1a9

Browse files
author
nicosammito
committed
feat: rename errors to diagnostics for improved clarity in validation results
1 parent 452d372 commit a1fb1a9

6 files changed

Lines changed: 20 additions & 20 deletions

File tree

src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {createSystem, createVirtualTypeScriptEnvironment, VirtualTypeScriptEnvir
1717
export interface ValidationResult {
1818
isValid: boolean;
1919
returnType: string;
20-
errors: Array<{
20+
diagnostics: Array<{
2121
message: string;
2222
code: number;
2323
severity: "error" | "warning";

src/validation/getFlowValidation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,6 @@ export const getFlowValidation = (
131131
return {
132132
isValid: !errors.some(e => e?.severity === "error"),
133133
returnType: "void",
134-
errors,
134+
diagnostics: errors,
135135
};
136136
};

src/validation/getNodeValidation.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ export const getNodeValidation = (
3030
return {
3131
isValid: false,
3232
returnType: "any",
33-
errors: [{message: `Function ${node.id} not found`, code: 404, severity: "error"}],
33+
diagnostics: [{message: `Function ${node.id} not found`, code: 404, severity: "error"}],
3434
};
3535
}
3636

3737
const params = (node.parameters?.nodes as NodeParameter[]) || [];
38-
const scopeErrors: ValidationResult["errors"] = [];
38+
const scopeErrors: ValidationResult["diagnostics"] = [];
3939

4040
// 1. Parameter scope validation
4141
for (const param of params) {
@@ -56,7 +56,7 @@ export const getNodeValidation = (
5656
return {
5757
isValid: false,
5858
returnType: "any",
59-
errors: scopeErrors,
59+
diagnostics: scopeErrors,
6060
};
6161
}
6262

@@ -121,6 +121,6 @@ export const getNodeValidation = (
121121
return {
122122
isValid: !errors.some(e => e.severity === "error"),
123123
returnType: inferredType,
124-
errors,
124+
diagnostics: errors,
125125
};
126126
};

src/validation/getValueValidation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ export const getValueValidation = (
4141
return {
4242
isValid: !errors.some(e => e.severity === "error"),
4343
returnType: "void",
44-
errors,
44+
diagnostics: errors,
4545
};
4646
};

test/flowValidation.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ describe('getFlowValidation - Integrationstest', () => {
6767
const result = getFlowValidation(flow, FUNCTION_SIGNATURES, DATA_TYPES);
6868

6969
expect(result.isValid).toBe(true);
70-
expect(result.errors).toHaveLength(0);
70+
expect(result.diagnostics).toHaveLength(0);
7171
});
7272

7373
it('sollte einen komplexen Flow mit verschachtelten Scopes und Generics validieren', () => {
@@ -110,7 +110,7 @@ describe('getFlowValidation - Integrationstest', () => {
110110
const result = getFlowValidation(flow, FUNCTION_SIGNATURES, DATA_TYPES);
111111

112112
expect(result.isValid).toBe(true);
113-
expect(result.errors).toHaveLength(0);
113+
expect(result.diagnostics).toHaveLength(0);
114114
});
115115

116116
});

test/nodeValidation.test.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('getNodeValidation', () => {
2424
}, FUNCTION_SIGNATURES, DATA_TYPES);
2525
expect(result.isValid).toBe(true);
2626
expect(result.returnType).toBeDefined();
27-
expect(result.errors.filter(e => e.severity === 'error').length).toBe(0);
27+
expect(result.diagnostics.filter(e => e.severity === 'error').length).toBe(0);
2828
})
2929

3030
it('2', () => {
@@ -88,7 +88,7 @@ describe('getNodeValidation', () => {
8888

8989
expect(result.isValid).toBe(true);
9090
expect(result.returnType).toBeDefined();
91-
expect(result.errors.filter(e => e.severity === 'error').length).toBe(0);
91+
expect(result.diagnostics.filter(e => e.severity === 'error').length).toBe(0);
9292
})
9393

9494
it('3', () => {
@@ -113,7 +113,7 @@ describe('getNodeValidation', () => {
113113

114114
expect(result.isValid).toBe(false);
115115
expect(result.returnType).toBeDefined();
116-
expect(result.errors.filter(e => e.severity === 'error').length).toBeGreaterThan(0);
116+
expect(result.diagnostics.filter(e => e.severity === 'error').length).toBeGreaterThan(0);
117117
})
118118

119119
it('4', () => {
@@ -180,7 +180,7 @@ describe('getNodeValidation', () => {
180180

181181
expect(result.isValid).toBe(true);
182182
expect(result.returnType).toBeDefined();
183-
expect(result.errors.filter(e => e.severity === 'error').length).toBe(0);
183+
expect(result.diagnostics.filter(e => e.severity === 'error').length).toBe(0);
184184
})
185185

186186
it('5', () => {
@@ -253,7 +253,7 @@ describe('getNodeValidation', () => {
253253

254254
expect(result.isValid).toBe(true);
255255
expect(result.returnType).toBeDefined();
256-
expect(result.errors.filter(e => e.severity === 'error').length).toBe(0);
256+
expect(result.diagnostics.filter(e => e.severity === 'error').length).toBe(0);
257257
})
258258

259259
it('6', () => {
@@ -321,7 +321,7 @@ describe('getNodeValidation', () => {
321321

322322
expect(result.isValid).toBe(true);
323323
expect(result.returnType).toBeDefined();
324-
expect(result.errors.filter(e => e.severity === 'error').length).toBe(0);
324+
expect(result.diagnostics.filter(e => e.severity === 'error').length).toBe(0);
325325
})
326326

327327
it('7', () => {
@@ -365,7 +365,7 @@ describe('getNodeValidation', () => {
365365
expect(result.isValid).toBe(true);
366366
expect(result.returnType).toBe("number");
367367
expect(result.returnType).toBeDefined();
368-
expect(result.errors.filter(e => e.severity === 'error').length).toBe(0);
368+
expect(result.diagnostics.filter(e => e.severity === 'error').length).toBe(0);
369369
})
370370

371371
it('8', () => {
@@ -408,7 +408,7 @@ describe('getNodeValidation', () => {
408408

409409
expect(result.isValid).toBe(false);
410410
expect(result.returnType).toBeDefined();
411-
expect(result.errors.filter(e => e.severity === 'error').length).toBeGreaterThan(0);
411+
expect(result.diagnostics.filter(e => e.severity === 'error').length).toBeGreaterThan(0);
412412
})
413413

414414
it('9', () => {
@@ -451,7 +451,7 @@ describe('getNodeValidation', () => {
451451

452452
expect(result.isValid).toBe(true);
453453
expect(result.returnType).toBeDefined();
454-
expect(result.errors.filter(e => e.severity === 'error').length).toBe(0);
454+
expect(result.diagnostics.filter(e => e.severity === 'error').length).toBe(0);
455455
})
456456

457457
it('10', () => {
@@ -513,7 +513,7 @@ describe('getNodeValidation', () => {
513513

514514
expect(result.isValid).toBe(true);
515515
expect(result.returnType).toBeDefined();
516-
expect(result.errors.filter(e => e.severity === 'error').length).toBe(0);
516+
expect(result.diagnostics.filter(e => e.severity === 'error').length).toBe(0);
517517
})
518518

519519
it('11', () => {
@@ -583,7 +583,7 @@ describe('getNodeValidation', () => {
583583

584584
expect(result.isValid).toBe(true);
585585
expect(result.returnType).toBeDefined();
586-
expect(result.errors.filter(e => e.severity === 'error').length).toBe(0);
586+
expect(result.diagnostics.filter(e => e.severity === 'error').length).toBe(0);
587587
})
588588

589589
});

0 commit comments

Comments
 (0)