@hexabot-ai/agentic 3.5.0 → 3.6.0-beta.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 +12 -3
- package/dist/cjs/action/abstract-action.js +51 -35
- package/dist/cjs/bindings/base-binding.js +229 -211
- package/dist/cjs/checkpoint.js +1 -1
- package/dist/cjs/context.js +2 -3
- package/dist/cjs/dsl.types.js +44 -90
- package/dist/cjs/errors.js +13 -1
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/resume-payload.js +11 -1
- package/dist/cjs/runner-runtime-control.js +39 -27
- package/dist/cjs/step-executors/conditional-executor.js +2 -7
- package/dist/cjs/step-executors/loop-executor.js +14 -28
- package/dist/cjs/step-executors/parallel-executor.js +14 -25
- package/dist/cjs/step-executors/scope.js +25 -0
- package/dist/cjs/step-executors/skip-helpers.js +26 -34
- package/dist/cjs/step-executors/task-executor.js +58 -69
- package/dist/cjs/utils/flow-steps.js +41 -0
- package/dist/cjs/utils/naming.js +10 -10
- package/dist/cjs/utils/object-path.js +51 -0
- package/dist/cjs/utils/timeout.js +16 -39
- package/dist/cjs/validation-issue.js +14 -1
- package/dist/cjs/workflow-compiler.js +52 -96
- package/dist/cjs/workflow-fingerprint.js +22 -11
- package/dist/cjs/workflow-runner.js +19 -25
- package/dist/cjs/workflow-values.js +9 -7
- package/dist/cjs/workflow.js +44 -103
- package/dist/esm/action/abstract-action.js +51 -35
- package/dist/esm/bindings/base-binding.js +229 -211
- package/dist/esm/checkpoint.js +2 -2
- package/dist/esm/context.js +2 -3
- package/dist/esm/dsl.types.js +42 -88
- package/dist/esm/errors.js +11 -0
- package/dist/esm/index.js +2 -2
- package/dist/esm/resume-payload.js +10 -1
- package/dist/esm/runner-runtime-control.js +39 -27
- package/dist/esm/step-executors/conditional-executor.js +2 -7
- package/dist/esm/step-executors/loop-executor.js +14 -28
- package/dist/esm/step-executors/parallel-executor.js +14 -25
- package/dist/esm/step-executors/scope.js +21 -0
- package/dist/esm/step-executors/skip-helpers.js +27 -35
- package/dist/esm/step-executors/task-executor.js +58 -69
- package/dist/esm/utils/flow-steps.js +37 -0
- package/dist/esm/utils/naming.js +9 -9
- package/dist/esm/utils/object-path.js +46 -0
- package/dist/esm/utils/timeout.js +16 -39
- package/dist/esm/validation-issue.js +11 -0
- package/dist/esm/workflow-compiler.js +50 -95
- package/dist/esm/workflow-fingerprint.js +22 -11
- package/dist/esm/workflow-runner.js +21 -27
- package/dist/esm/workflow-values.js +7 -6
- package/dist/esm/workflow.js +43 -103
- package/dist/types/action/abstract-action.d.ts +7 -1
- package/dist/types/action/abstract-action.d.ts.map +1 -1
- package/dist/types/bindings/base-binding.d.ts +10 -0
- package/dist/types/bindings/base-binding.d.ts.map +1 -1
- package/dist/types/context.d.ts +2 -3
- package/dist/types/context.d.ts.map +1 -1
- package/dist/types/dsl.types.d.ts +7 -12
- package/dist/types/dsl.types.d.ts.map +1 -1
- package/dist/types/errors.d.ts +9 -0
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/resume-payload.d.ts +7 -0
- package/dist/types/resume-payload.d.ts.map +1 -1
- package/dist/types/runner-runtime-control.d.ts.map +1 -1
- package/dist/types/step-executors/conditional-executor.d.ts.map +1 -1
- package/dist/types/step-executors/loop-executor.d.ts +2 -4
- package/dist/types/step-executors/loop-executor.d.ts.map +1 -1
- package/dist/types/step-executors/parallel-executor.d.ts.map +1 -1
- package/dist/types/step-executors/scope.d.ts +12 -0
- package/dist/types/step-executors/scope.d.ts.map +1 -0
- package/dist/types/step-executors/skip-helpers.d.ts +2 -8
- package/dist/types/step-executors/skip-helpers.d.ts.map +1 -1
- package/dist/types/step-executors/task-executor.d.ts.map +1 -1
- package/dist/types/utils/flow-steps.d.ts +16 -0
- package/dist/types/utils/flow-steps.d.ts.map +1 -0
- package/dist/types/utils/naming.d.ts +7 -7
- package/dist/types/utils/naming.d.ts.map +1 -1
- package/dist/types/utils/object-path.d.ts +11 -0
- package/dist/types/utils/object-path.d.ts.map +1 -0
- package/dist/types/utils/timeout.d.ts.map +1 -1
- package/dist/types/validation-issue.d.ts +13 -0
- package/dist/types/validation-issue.d.ts.map +1 -1
- package/dist/types/workflow-compiler.d.ts +15 -1
- package/dist/types/workflow-compiler.d.ts.map +1 -1
- package/dist/types/workflow-fingerprint.d.ts.map +1 -1
- package/dist/types/workflow-runner.d.ts +2 -0
- package/dist/types/workflow-runner.d.ts.map +1 -1
- package/dist/types/workflow-values.d.ts +2 -0
- package/dist/types/workflow-values.d.ts.map +1 -1
- package/dist/types/workflow.d.ts +2 -1
- package/dist/types/workflow.d.ts.map +1 -1
- package/examples/defs-bindings-agent/actions/ai-agent.ts +5 -3
- package/examples/defs-bindings-agent/actions/{caculate-score.ts → calculate-score.ts} +8 -8
- package/examples/defs-bindings-agent/actions/index.ts +2 -2
- package/examples/defs-bindings-agent/workflow.yml +2 -2
- package/examples/full/workflow.yml +20 -15
- package/examples/suspend-resume/workflow.yml +6 -3
- package/package.json +8 -5
- package/src/__tests__/checkpoint.test.ts +6 -1
- package/src/__tests__/resume-payload.test.ts +29 -0
- package/src/__tests__/test-helpers.ts +1 -1
- package/src/__tests__/validation.test.ts +330 -0
- package/src/__tests__/workflow-compiler.test.ts +278 -3
- package/src/__tests__/workflow-definition-path.test.ts +2 -0
- package/src/__tests__/workflow-fingerprint.test.ts +65 -0
- package/src/__tests__/workflow-runner.test.ts +280 -5
- package/src/__tests__/workflow-values.test.ts +13 -0
- package/src/__tests__/workflow.test.ts +4 -2
- package/src/action/__tests__/abstract-action-timing.test.ts +92 -0
- package/src/action/abstract-action.ts +67 -40
- package/src/bindings/base-binding.test.ts +470 -0
- package/src/bindings/base-binding.ts +344 -267
- package/src/checkpoint.ts +2 -4
- package/src/context.ts +2 -3
- package/src/dsl.types.ts +75 -154
- package/src/errors.ts +15 -0
- package/src/index.ts +2 -0
- package/src/resume-payload.ts +13 -3
- package/src/runner-runtime-control.ts +52 -29
- package/src/step-executors/conditional-executor.ts +3 -7
- package/src/step-executors/loop-executor.test.ts +55 -0
- package/src/step-executors/loop-executor.ts +16 -50
- package/src/step-executors/parallel-executor.ts +14 -37
- package/src/step-executors/scope.ts +30 -0
- package/src/step-executors/skip-helpers.test.ts +133 -0
- package/src/step-executors/skip-helpers.ts +43 -76
- package/src/step-executors/task-executor.test.ts +130 -1
- package/src/step-executors/task-executor.ts +109 -79
- package/src/utils/flow-steps.test.ts +121 -0
- package/src/utils/flow-steps.ts +62 -0
- package/src/utils/naming.test.ts +50 -0
- package/src/utils/naming.ts +11 -11
- package/src/utils/object-path.test.ts +70 -0
- package/src/utils/object-path.ts +67 -0
- package/src/utils/timeout.test.ts +152 -0
- package/src/utils/timeout.ts +26 -44
- package/src/validation-issue.test.ts +70 -0
- package/src/validation-issue.ts +27 -0
- package/src/workflow-compiler.ts +118 -180
- package/src/workflow-fingerprint.ts +23 -12
- package/src/workflow-runner.ts +28 -27
- package/src/workflow-values.ts +9 -7
- package/src/workflow.ts +58 -140
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Hexabot — Fair Core License (FCL-1.0-ALv2)
|
|
3
|
+
* Copyright (c) 2026 Hexastack.
|
|
4
|
+
* Full terms: see LICENSE.md.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { WorkflowCancellationError } from '../errors';
|
|
8
|
+
|
|
9
|
+
import { sleep, withTimeout } from './timeout';
|
|
10
|
+
|
|
11
|
+
const never = () => new Promise<never>(() => undefined);
|
|
12
|
+
|
|
13
|
+
describe('withTimeout', () => {
|
|
14
|
+
afterEach(() => {
|
|
15
|
+
jest.useRealTimers();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('settles with the promise when there is neither a timeout nor a signal', async () => {
|
|
19
|
+
jest.useFakeTimers();
|
|
20
|
+
const promise = Promise.resolve('value');
|
|
21
|
+
|
|
22
|
+
await expect(withTimeout(promise)).resolves.toBe('value');
|
|
23
|
+
await expect(withTimeout(promise, 0)).resolves.toBe('value');
|
|
24
|
+
expect(jest.getTimerCount()).toBe(0);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('settles with the promise and detaches the timer and the signal', async () => {
|
|
28
|
+
jest.useFakeTimers();
|
|
29
|
+
const controller = new AbortController();
|
|
30
|
+
const removeListener = jest.spyOn(controller.signal, 'removeEventListener');
|
|
31
|
+
|
|
32
|
+
await expect(
|
|
33
|
+
withTimeout(Promise.resolve('value'), 1_000, controller.signal),
|
|
34
|
+
).resolves.toBe('value');
|
|
35
|
+
expect(jest.getTimerCount()).toBe(0);
|
|
36
|
+
expect(removeListener).toHaveBeenCalledWith('abort', expect.any(Function));
|
|
37
|
+
|
|
38
|
+
const error = new Error('boom');
|
|
39
|
+
await expect(
|
|
40
|
+
withTimeout(Promise.reject(error), 1_000, controller.signal),
|
|
41
|
+
).rejects.toBe(error);
|
|
42
|
+
expect(jest.getTimerCount()).toBe(0);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('rejects once the timeout elapses', async () => {
|
|
46
|
+
jest.useFakeTimers();
|
|
47
|
+
const controller = new AbortController();
|
|
48
|
+
const removeListener = jest.spyOn(controller.signal, 'removeEventListener');
|
|
49
|
+
const result = withTimeout(never(), 50, controller.signal);
|
|
50
|
+
|
|
51
|
+
jest.advanceTimersByTime(50);
|
|
52
|
+
|
|
53
|
+
await expect(result).rejects.toThrow(
|
|
54
|
+
'Step execution exceeded timeout of 50ms',
|
|
55
|
+
);
|
|
56
|
+
expect(removeListener).toHaveBeenCalledWith('abort', expect.any(Function));
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('applies a timeout without a signal', async () => {
|
|
60
|
+
jest.useFakeTimers();
|
|
61
|
+
const late = withTimeout(never(), 50);
|
|
62
|
+
|
|
63
|
+
jest.advanceTimersByTime(50);
|
|
64
|
+
await expect(late).rejects.toThrow(
|
|
65
|
+
'Step execution exceeded timeout of 50ms',
|
|
66
|
+
);
|
|
67
|
+
await expect(withTimeout(Promise.resolve('value'), 50)).resolves.toBe(
|
|
68
|
+
'value',
|
|
69
|
+
);
|
|
70
|
+
expect(jest.getTimerCount()).toBe(0);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('rejects with the abort reason and clears the timeout', async () => {
|
|
74
|
+
jest.useFakeTimers();
|
|
75
|
+
const controller = new AbortController();
|
|
76
|
+
const result = withTimeout(never(), 1_000, controller.signal);
|
|
77
|
+
const reason = new Error('stopped');
|
|
78
|
+
|
|
79
|
+
controller.abort(reason);
|
|
80
|
+
|
|
81
|
+
await expect(result).rejects.toBe(reason);
|
|
82
|
+
expect(jest.getTimerCount()).toBe(0);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('rejects right away when the signal is already aborted', async () => {
|
|
86
|
+
jest.useFakeTimers();
|
|
87
|
+
const controller = new AbortController();
|
|
88
|
+
controller.abort();
|
|
89
|
+
|
|
90
|
+
await expect(
|
|
91
|
+
withTimeout(never(), 1_000, controller.signal),
|
|
92
|
+
).rejects.toBeInstanceOf(WorkflowCancellationError);
|
|
93
|
+
expect(jest.getTimerCount()).toBe(0);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('keeps the first outcome when a later one arrives', async () => {
|
|
97
|
+
const controller = new AbortController();
|
|
98
|
+
let resolve: (value: string) => void = () => undefined;
|
|
99
|
+
const result = withTimeout(
|
|
100
|
+
new Promise<string>((done) => {
|
|
101
|
+
resolve = done;
|
|
102
|
+
}),
|
|
103
|
+
undefined,
|
|
104
|
+
controller.signal,
|
|
105
|
+
);
|
|
106
|
+
const reason = new Error('first');
|
|
107
|
+
|
|
108
|
+
controller.abort(reason);
|
|
109
|
+
resolve('late');
|
|
110
|
+
|
|
111
|
+
await expect(result).rejects.toBe(reason);
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
describe('sleep', () => {
|
|
116
|
+
it('resolves after the duration', async () => {
|
|
117
|
+
jest.useFakeTimers();
|
|
118
|
+
const done = jest.fn();
|
|
119
|
+
const pending = sleep(100).then(done);
|
|
120
|
+
|
|
121
|
+
jest.advanceTimersByTime(99);
|
|
122
|
+
await Promise.resolve();
|
|
123
|
+
expect(done).not.toHaveBeenCalled();
|
|
124
|
+
|
|
125
|
+
jest.advanceTimersByTime(1);
|
|
126
|
+
await pending;
|
|
127
|
+
expect(done).toHaveBeenCalled();
|
|
128
|
+
jest.useRealTimers();
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it('rejects with the abort reason and clears its timer', async () => {
|
|
132
|
+
jest.useFakeTimers();
|
|
133
|
+
const controller = new AbortController();
|
|
134
|
+
const pending = sleep(100, controller.signal);
|
|
135
|
+
const reason = new Error('stopped');
|
|
136
|
+
|
|
137
|
+
controller.abort(reason);
|
|
138
|
+
|
|
139
|
+
await expect(pending).rejects.toBe(reason);
|
|
140
|
+
expect(jest.getTimerCount()).toBe(0);
|
|
141
|
+
jest.useRealTimers();
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it('throws when the signal is already aborted', () => {
|
|
145
|
+
const controller = new AbortController();
|
|
146
|
+
controller.abort();
|
|
147
|
+
|
|
148
|
+
expect(() => sleep(100, controller.signal)).toThrow(
|
|
149
|
+
WorkflowCancellationError,
|
|
150
|
+
);
|
|
151
|
+
});
|
|
152
|
+
});
|
package/src/utils/timeout.ts
CHANGED
|
@@ -57,62 +57,44 @@ export async function withTimeout<T>(
|
|
|
57
57
|
|
|
58
58
|
return new Promise<T>((resolve, reject) => {
|
|
59
59
|
let settled = false;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
reject(
|
|
65
|
-
new Error(`Step execution exceeded timeout of ${timeoutMs}ms`),
|
|
66
|
-
);
|
|
67
|
-
}, timeoutMs)
|
|
68
|
-
: undefined;
|
|
69
|
-
const onAbort = () => {
|
|
60
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
61
|
+
// The first of the promise, the timeout and the abort settles the
|
|
62
|
+
// result; the other two are detached.
|
|
63
|
+
const settle = (finish: () => void) => {
|
|
70
64
|
if (settled) {
|
|
71
65
|
return;
|
|
72
66
|
}
|
|
73
67
|
|
|
74
68
|
settled = true;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
reject(getAbortReason(signal as AbortSignal));
|
|
69
|
+
clearTimeout(timer);
|
|
70
|
+
signal?.removeEventListener('abort', onAbort);
|
|
71
|
+
finish();
|
|
79
72
|
};
|
|
73
|
+
const onAbort = () =>
|
|
74
|
+
settle(() => reject(getAbortReason(signal as AbortSignal)));
|
|
80
75
|
|
|
81
|
-
if (
|
|
82
|
-
|
|
83
|
-
|
|
76
|
+
if (timeoutMs) {
|
|
77
|
+
timer = setTimeout(
|
|
78
|
+
() =>
|
|
79
|
+
settle(() =>
|
|
80
|
+
reject(
|
|
81
|
+
new Error(`Step execution exceeded timeout of ${timeoutMs}ms`),
|
|
82
|
+
),
|
|
83
|
+
),
|
|
84
|
+
timeoutMs,
|
|
85
|
+
);
|
|
86
|
+
}
|
|
84
87
|
|
|
85
|
-
|
|
86
|
-
|
|
88
|
+
if (signal?.aborted) {
|
|
89
|
+
onAbort();
|
|
87
90
|
|
|
88
|
-
|
|
91
|
+
return;
|
|
89
92
|
}
|
|
90
93
|
|
|
94
|
+
signal?.addEventListener('abort', onAbort, { once: true });
|
|
91
95
|
promise.then(
|
|
92
|
-
(value) =>
|
|
93
|
-
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
settled = true;
|
|
98
|
-
if (timer) {
|
|
99
|
-
clearTimeout(timer);
|
|
100
|
-
}
|
|
101
|
-
signal?.removeEventListener('abort', onAbort);
|
|
102
|
-
resolve(value);
|
|
103
|
-
},
|
|
104
|
-
(error) => {
|
|
105
|
-
if (settled) {
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
settled = true;
|
|
110
|
-
if (timer) {
|
|
111
|
-
clearTimeout(timer);
|
|
112
|
-
}
|
|
113
|
-
signal?.removeEventListener('abort', onAbort);
|
|
114
|
-
reject(error);
|
|
115
|
-
},
|
|
96
|
+
(value) => settle(() => resolve(value)),
|
|
97
|
+
(error) => settle(() => reject(error)),
|
|
116
98
|
);
|
|
117
99
|
});
|
|
118
100
|
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Hexabot — Fair Core License (FCL-1.0-ALv2)
|
|
3
|
+
* Copyright (c) 2026 Hexastack.
|
|
4
|
+
* Full terms: see LICENSE.md.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
issueMessages,
|
|
9
|
+
toIssuePath,
|
|
10
|
+
toValidationIssues,
|
|
11
|
+
} from './validation-issue';
|
|
12
|
+
|
|
13
|
+
describe('toIssuePath', () => {
|
|
14
|
+
it('keeps string and number segments only', () => {
|
|
15
|
+
expect(toIssuePath(['flow', 0, Symbol('meta'), 'do'])).toEqual([
|
|
16
|
+
'flow',
|
|
17
|
+
0,
|
|
18
|
+
'do',
|
|
19
|
+
]);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
describe('toValidationIssues', () => {
|
|
24
|
+
const schemaIssues = [
|
|
25
|
+
{ path: ['flow', 0, 'loop', 'while'], message: 'Required' },
|
|
26
|
+
{ path: [], message: 'Expected object' },
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
it('locates schema issues by their path', () => {
|
|
30
|
+
expect(toValidationIssues('schema', schemaIssues)).toEqual([
|
|
31
|
+
{
|
|
32
|
+
code: 'schema',
|
|
33
|
+
message: 'flow.0.loop.while: Required',
|
|
34
|
+
path: ['flow', 0, 'loop', 'while'],
|
|
35
|
+
},
|
|
36
|
+
{ code: 'schema', message: '<root>: Expected object', path: [] },
|
|
37
|
+
]);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('places schema issues under the path of the value the schema checked', () => {
|
|
41
|
+
expect(
|
|
42
|
+
toValidationIssues('binding_settings', schemaIssues, [
|
|
43
|
+
'defs',
|
|
44
|
+
'gpt',
|
|
45
|
+
'settings',
|
|
46
|
+
]),
|
|
47
|
+
).toEqual([
|
|
48
|
+
{
|
|
49
|
+
code: 'binding_settings',
|
|
50
|
+
message: 'defs.gpt.settings.flow.0.loop.while: Required',
|
|
51
|
+
path: ['defs', 'gpt', 'settings', 'flow', 0, 'loop', 'while'],
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
code: 'binding_settings',
|
|
55
|
+
message: 'defs.gpt.settings.<root>: Expected object',
|
|
56
|
+
path: ['defs', 'gpt', 'settings'],
|
|
57
|
+
},
|
|
58
|
+
]);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
describe('issueMessages', () => {
|
|
63
|
+
it('lists the message of each issue', () => {
|
|
64
|
+
expect(
|
|
65
|
+
issueMessages(
|
|
66
|
+
toValidationIssues('schema', [{ path: ['a'], message: 'bad' }]),
|
|
67
|
+
),
|
|
68
|
+
).toEqual(['a: bad']);
|
|
69
|
+
});
|
|
70
|
+
});
|
package/src/validation-issue.ts
CHANGED
|
@@ -36,3 +36,30 @@ export type WorkflowValidationIssue = {
|
|
|
36
36
|
|
|
37
37
|
export const issueMessages = (issues: WorkflowValidationIssue[]): string[] =>
|
|
38
38
|
issues.map((issue) => issue.message);
|
|
39
|
+
|
|
40
|
+
/** The fields of a schema (zod) issue that validation issues are built from. */
|
|
41
|
+
type SchemaIssue = { path: readonly PropertyKey[]; message: string };
|
|
42
|
+
|
|
43
|
+
/** Keep the segments of a schema issue path that can locate a YAML node. */
|
|
44
|
+
export const toIssuePath = (
|
|
45
|
+
path: readonly PropertyKey[],
|
|
46
|
+
): Array<string | number> =>
|
|
47
|
+
path.filter(
|
|
48
|
+
(segment): segment is string | number =>
|
|
49
|
+
typeof segment === 'string' || typeof segment === 'number',
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Turn schema issues into validation issues located under `basePath`, the
|
|
54
|
+
* path of the value the schema checked.
|
|
55
|
+
*/
|
|
56
|
+
export const toValidationIssues = (
|
|
57
|
+
code: WorkflowValidationIssueCode,
|
|
58
|
+
schemaIssues: readonly SchemaIssue[],
|
|
59
|
+
basePath: Array<string | number> = [],
|
|
60
|
+
): WorkflowValidationIssue[] =>
|
|
61
|
+
schemaIssues.map((issue) => ({
|
|
62
|
+
code,
|
|
63
|
+
message: `${[...basePath, issue.path.join('.') || '<root>'].join('.')}: ${issue.message}`,
|
|
64
|
+
path: [...basePath, ...toIssuePath(issue.path)],
|
|
65
|
+
}));
|