@hexabot-ai/agentic 3.1.2-beta.0 → 3.1.2-beta.2
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/cjs/dsl.types.js +2 -1
- package/dist/cjs/utils/naming.js +4 -4
- package/dist/cjs/workflow-compiler.js +0 -2
- package/dist/cjs/workflow-values.js +29 -4
- package/dist/esm/dsl.types.js +2 -1
- package/dist/esm/utils/naming.js +1 -1
- package/dist/esm/workflow-compiler.js +0 -2
- package/dist/esm/workflow-values.js +29 -4
- package/dist/types/dsl.types.d.ts.map +1 -1
- package/dist/types/utils/naming.d.ts +1 -0
- package/dist/types/utils/naming.d.ts.map +1 -1
- package/dist/types/workflow-compiler.d.ts.map +1 -1
- package/dist/types/workflow-values.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/workflow-values.test.ts +19 -0
- package/src/dsl.types.ts +5 -1
- package/src/utils/naming.ts +1 -1
- package/src/workflow-compiler.ts +0 -3
- package/src/workflow-values.ts +48 -5
package/dist/cjs/dsl.types.js
CHANGED
|
@@ -14,6 +14,7 @@ const jsonata_1 = __importDefault(require("jsonata"));
|
|
|
14
14
|
const yaml_1 = require("yaml");
|
|
15
15
|
const zod_1 = require("zod");
|
|
16
16
|
const base_binding_1 = require("./bindings/base-binding");
|
|
17
|
+
const naming_1 = require("./utils/naming");
|
|
17
18
|
exports.ExpressionStringSchema = zod_1.z
|
|
18
19
|
.string()
|
|
19
20
|
.regex(/^=/, 'Expression strings must start with "="')
|
|
@@ -234,7 +235,7 @@ exports.WorkflowDefinitionSchema = zod_1.z.strictObject({
|
|
|
234
235
|
inputs: InputsSchema.optional(),
|
|
235
236
|
context: zod_1.z.record(zod_1.z.string(), exports.JsonValueSchema).optional(),
|
|
236
237
|
defaults: DefaultsSchema.optional(),
|
|
237
|
-
defs: zod_1.z.record(zod_1.z.string(), exports.DefDefinitionSchema),
|
|
238
|
+
defs: zod_1.z.record(zod_1.z.string().regex(naming_1.SNAKE_CASE_REGEX, 'Name must be snake_case'), exports.DefDefinitionSchema),
|
|
238
239
|
flow: zod_1.z.array(exports.FlowStepSchema),
|
|
239
240
|
outputs: zod_1.z.record(zod_1.z.string(), exports.ExpressionStringSchema),
|
|
240
241
|
});
|
package/dist/cjs/utils/naming.js
CHANGED
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
* Full terms: see LICENSE.md.
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.isSnakeCaseName = void 0;
|
|
8
|
+
exports.isSnakeCaseName = exports.SNAKE_CASE_REGEX = void 0;
|
|
9
9
|
exports.assertSnakeCaseName = assertSnakeCaseName;
|
|
10
10
|
exports.toSnakeCase = toSnakeCase;
|
|
11
|
-
|
|
11
|
+
exports.SNAKE_CASE_REGEX = /^[a-z0-9]+(?:_[a-z0-9]+)*$/;
|
|
12
12
|
/**
|
|
13
13
|
* Verifies that names follow the snake_case convention required by the system.
|
|
14
14
|
*
|
|
@@ -17,7 +17,7 @@ const SNAKE_CASE_REGEX = /^[a-z0-9]+(?:_[a-z0-9]+)+$/;
|
|
|
17
17
|
* @throws Error when the name is not snake_case.
|
|
18
18
|
*/
|
|
19
19
|
function assertSnakeCaseName(name, entity) {
|
|
20
|
-
if (!SNAKE_CASE_REGEX.test(name)) {
|
|
20
|
+
if (!exports.SNAKE_CASE_REGEX.test(name)) {
|
|
21
21
|
throw new Error(`${entity} name must be snake_case with at least one underscore. Received: "${name}"`);
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -27,7 +27,7 @@ function assertSnakeCaseName(name, entity) {
|
|
|
27
27
|
* @param value - Text to evaluate.
|
|
28
28
|
* @returns `true` when the value is snake_case; otherwise `false`.
|
|
29
29
|
*/
|
|
30
|
-
const isSnakeCaseName = (value) => SNAKE_CASE_REGEX.test(value);
|
|
30
|
+
const isSnakeCaseName = (value) => exports.SNAKE_CASE_REGEX.test(value);
|
|
31
31
|
exports.isSnakeCaseName = isSnakeCaseName;
|
|
32
32
|
/**
|
|
33
33
|
* Converts arbitrary text into snake_case for use in workflow entities.
|
|
@@ -9,7 +9,6 @@ exports.compileWorkflow = void 0;
|
|
|
9
9
|
const zod_1 = require("zod");
|
|
10
10
|
const base_binding_1 = require("./bindings/base-binding");
|
|
11
11
|
const dsl_types_1 = require("./dsl.types");
|
|
12
|
-
const naming_1 = require("./utils/naming");
|
|
13
12
|
const workflow_event_emitter_1 = require("./workflow-event-emitter");
|
|
14
13
|
const workflow_values_1 = require("./workflow-values");
|
|
15
14
|
/** Build a stable identifier for a step using its path and label. */
|
|
@@ -103,7 +102,6 @@ const compileTasks = (definition, options) => {
|
|
|
103
102
|
}
|
|
104
103
|
assertActionsBound(taskDefinitions, options.actions);
|
|
105
104
|
for (const [taskName, task] of Object.entries(taskDefinitions)) {
|
|
106
|
-
(0, naming_1.assertSnakeCaseName)(taskName, 'action');
|
|
107
105
|
const action = options.actions[task.action];
|
|
108
106
|
const settingsPayload = (0, workflow_values_1.mergeSettings)(defaultSettings, task.settings);
|
|
109
107
|
const parsedSettings = action.parseSettings(settingsPayload);
|
|
@@ -12,6 +12,30 @@ exports.mergeSettings = exports.evaluateMapping = exports.evaluateValue = export
|
|
|
12
12
|
const jsonata_1 = __importDefault(require("jsonata"));
|
|
13
13
|
/** Basic object guard that rejects arrays and null. */
|
|
14
14
|
const isPlainObject = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
15
|
+
const resolveNestedExpressions = async (value, scope, seen = new WeakSet()) => {
|
|
16
|
+
if (typeof value === 'string' && value.startsWith('=')) {
|
|
17
|
+
return (0, exports.evaluateValue)((0, exports.compileValue)(value), scope);
|
|
18
|
+
}
|
|
19
|
+
if (Array.isArray(value)) {
|
|
20
|
+
if (seen.has(value)) {
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
seen.add(value);
|
|
24
|
+
return Promise.all(value.map((entry) => resolveNestedExpressions(entry, scope, seen)));
|
|
25
|
+
}
|
|
26
|
+
if (isPlainObject(value)) {
|
|
27
|
+
if (seen.has(value)) {
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
30
|
+
seen.add(value);
|
|
31
|
+
const entries = await Promise.all(Object.entries(value).map(async ([key, entry]) => [
|
|
32
|
+
key,
|
|
33
|
+
await resolveNestedExpressions(entry, scope, seen),
|
|
34
|
+
]));
|
|
35
|
+
return Object.fromEntries(entries);
|
|
36
|
+
}
|
|
37
|
+
return value;
|
|
38
|
+
};
|
|
15
39
|
const registerJsonataFunctions = (expression, registry) => {
|
|
16
40
|
if (!registry) {
|
|
17
41
|
return;
|
|
@@ -68,10 +92,11 @@ const evaluateMapping = async (mapping, scope) => {
|
|
|
68
92
|
if (!mapping) {
|
|
69
93
|
return {};
|
|
70
94
|
}
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
95
|
+
const entries = await Promise.all(Object.entries(mapping).map(async ([key, compiled]) => [
|
|
96
|
+
key,
|
|
97
|
+
await resolveNestedExpressions(await (0, exports.evaluateValue)(compiled, scope), scope),
|
|
98
|
+
]));
|
|
99
|
+
const result = Object.fromEntries(entries);
|
|
75
100
|
return result;
|
|
76
101
|
};
|
|
77
102
|
exports.evaluateMapping = evaluateMapping;
|
package/dist/esm/dsl.types.js
CHANGED
|
@@ -7,6 +7,7 @@ import jsonata from 'jsonata';
|
|
|
7
7
|
import { parse as parseYaml } from 'yaml';
|
|
8
8
|
import { z } from 'zod';
|
|
9
9
|
import { validateAndResolveBindings } from './bindings/base-binding';
|
|
10
|
+
import { SNAKE_CASE_REGEX } from './utils/naming';
|
|
10
11
|
export const ExpressionStringSchema = z
|
|
11
12
|
.string()
|
|
12
13
|
.regex(/^=/, 'Expression strings must start with "="')
|
|
@@ -227,7 +228,7 @@ export const WorkflowDefinitionSchema = z.strictObject({
|
|
|
227
228
|
inputs: InputsSchema.optional(),
|
|
228
229
|
context: z.record(z.string(), JsonValueSchema).optional(),
|
|
229
230
|
defaults: DefaultsSchema.optional(),
|
|
230
|
-
defs: z.record(z.string(), DefDefinitionSchema),
|
|
231
|
+
defs: z.record(z.string().regex(SNAKE_CASE_REGEX, 'Name must be snake_case'), DefDefinitionSchema),
|
|
231
232
|
flow: z.array(FlowStepSchema),
|
|
232
233
|
outputs: z.record(z.string(), ExpressionStringSchema),
|
|
233
234
|
});
|
package/dist/esm/utils/naming.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Copyright (c) 2025 Hexastack.
|
|
4
4
|
* Full terms: see LICENSE.md.
|
|
5
5
|
*/
|
|
6
|
-
const SNAKE_CASE_REGEX = /^[a-z0-9]+(?:_[a-z0-9]+)
|
|
6
|
+
export const SNAKE_CASE_REGEX = /^[a-z0-9]+(?:_[a-z0-9]+)*$/;
|
|
7
7
|
/**
|
|
8
8
|
* Verifies that names follow the snake_case convention required by the system.
|
|
9
9
|
*
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
import { z } from 'zod';
|
|
7
7
|
import { mountTaskBindings, validateAndResolveBindings, } from './bindings/base-binding';
|
|
8
8
|
import { extractTaskDefinitions as extractTaskDefinitionsFromDefs } from './dsl.types';
|
|
9
|
-
import { assertSnakeCaseName } from './utils/naming';
|
|
10
9
|
import { StepType } from './workflow-event-emitter';
|
|
11
10
|
import { compileValue, mergeSettings, } from './workflow-values';
|
|
12
11
|
/** Build a stable identifier for a step using its path and label. */
|
|
@@ -100,7 +99,6 @@ const compileTasks = (definition, options) => {
|
|
|
100
99
|
}
|
|
101
100
|
assertActionsBound(taskDefinitions, options.actions);
|
|
102
101
|
for (const [taskName, task] of Object.entries(taskDefinitions)) {
|
|
103
|
-
assertSnakeCaseName(taskName, 'action');
|
|
104
102
|
const action = options.actions[task.action];
|
|
105
103
|
const settingsPayload = mergeSettings(defaultSettings, task.settings);
|
|
106
104
|
const parsedSettings = action.parseSettings(settingsPayload);
|
|
@@ -6,6 +6,30 @@
|
|
|
6
6
|
import jsonata from 'jsonata';
|
|
7
7
|
/** Basic object guard that rejects arrays and null. */
|
|
8
8
|
const isPlainObject = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
9
|
+
const resolveNestedExpressions = async (value, scope, seen = new WeakSet()) => {
|
|
10
|
+
if (typeof value === 'string' && value.startsWith('=')) {
|
|
11
|
+
return evaluateValue(compileValue(value), scope);
|
|
12
|
+
}
|
|
13
|
+
if (Array.isArray(value)) {
|
|
14
|
+
if (seen.has(value)) {
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
seen.add(value);
|
|
18
|
+
return Promise.all(value.map((entry) => resolveNestedExpressions(entry, scope, seen)));
|
|
19
|
+
}
|
|
20
|
+
if (isPlainObject(value)) {
|
|
21
|
+
if (seen.has(value)) {
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
seen.add(value);
|
|
25
|
+
const entries = await Promise.all(Object.entries(value).map(async ([key, entry]) => [
|
|
26
|
+
key,
|
|
27
|
+
await resolveNestedExpressions(entry, scope, seen),
|
|
28
|
+
]));
|
|
29
|
+
return Object.fromEntries(entries);
|
|
30
|
+
}
|
|
31
|
+
return value;
|
|
32
|
+
};
|
|
9
33
|
const registerJsonataFunctions = (expression, registry) => {
|
|
10
34
|
if (!registry) {
|
|
11
35
|
return;
|
|
@@ -60,10 +84,11 @@ export const evaluateMapping = async (mapping, scope) => {
|
|
|
60
84
|
if (!mapping) {
|
|
61
85
|
return {};
|
|
62
86
|
}
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
87
|
+
const entries = await Promise.all(Object.entries(mapping).map(async ([key, compiled]) => [
|
|
88
|
+
key,
|
|
89
|
+
await resolveNestedExpressions(await evaluateValue(compiled, scope), scope),
|
|
90
|
+
]));
|
|
91
|
+
const result = Object.fromEntries(entries);
|
|
67
92
|
return result;
|
|
68
93
|
};
|
|
69
94
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dsl.types.d.ts","sourceRoot":"","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,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E,MAAM,MAAM,gCAAgC,GAAG;IAC7C,iBAAiB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,gCAAgC,CAAC,CAAC;CAC5D,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAChC;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,kBAAkB,CAAA;CAAE,GAC3C;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAmCzC,eAAO,MAAM,gBAAgB,GAC3B,YAAY,aAAa,KACxB,UAAU,IAAI,cAA+C,CAAC;AAEjE,eAAO,MAAM,sBAAsB,GAAI,MAAM,cAAc,KAAG,eAOtD,CAAC;AAST,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,GAAG,OAAO,EACvB,OAAO,CAAC,EAAE,uBAAuB,GAChC,wBAAwB,CAkD1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"naming.d.ts","sourceRoot":"","sources":["../../../src/utils/naming.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"naming.d.ts","sourceRoot":"","sources":["../../../src/utils/naming.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,gBAAgB,QAA+B,CAAC;AAE7D,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,UAAU,GAAG,WAAW,CAAC;AAEjE;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,cAAc,GACrB,IAAI,CAMN;AAED;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAAI,OAAO,MAAM,KAAG,OAClB,CAAC;AAE/B;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAWjD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-compiler.d.ts","sourceRoot":"","sources":["../../src/workflow-compiler.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAMlE,OAAO,KAAK,EAIV,kBAAkB,EACnB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"workflow-compiler.d.ts","sourceRoot":"","sources":["../../src/workflow-compiler.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAMlE,OAAO,KAAK,EAIV,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAGrB,OAAO,KAAK,EAIV,gBAAgB,EAIjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAGL,KAAK,mBAAmB,EACzB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,MAAM,sBAAsB,GAAG,mBAAmB,GAAG;IACzD,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,YAAY,CAAC,EAAE,kBAAkB,CAAC;CACnC,CAAC;AA8PF,+EAA+E;AAC/E,eAAO,MAAM,eAAe,GAC1B,YAAY,kBAAkB,EAC9B,SAAS,sBAAsB,KAC9B,gBAcF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-values.d.ts","sourceRoot":"","sources":["../../src/workflow-values.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAc,KAAK,EAAE,MAAM,SAAS,CAAC;AAGjD,OAAO,KAAK,EAAa,QAAQ,EAAE,MAAM,aAAa,C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mBAAmB,KAC5B,aASF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,GACxB,UAAU,aAAa,EACvB,OAAO,eAAe,KACrB,OAAO,CAAC,OAAO,CAgBjB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,GAC1B,SAAS,eAAe,GAAG,SAAS,EACpC,OAAO,eAAe,KACrB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAiBjC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,aAAa,GACxB,OAAO,OAAO,CAAC,QAAQ,CAAC,EACxB,WAAW,OAAO,CAAC,QAAQ,CAAC,KAC3B,OAAO,CAAC,QAAQ,CAsBlB,CAAC"}
|
package/package.json
CHANGED
|
@@ -73,6 +73,25 @@ describe('workflow values', () => {
|
|
|
73
73
|
});
|
|
74
74
|
});
|
|
75
75
|
|
|
76
|
+
it('evaluates nested expressions inside literal objects', async () => {
|
|
77
|
+
const mapping = {
|
|
78
|
+
headers: compileValue({
|
|
79
|
+
nestedFiled: '=$input.headerValue',
|
|
80
|
+
}),
|
|
81
|
+
};
|
|
82
|
+
const values = await evaluateMapping(mapping, {
|
|
83
|
+
input: { headerValue: 'Bearer token-value' },
|
|
84
|
+
context: new TestContext().state,
|
|
85
|
+
output: {},
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
expect(values).toEqual({
|
|
89
|
+
headers: {
|
|
90
|
+
nestedFiled: 'Bearer token-value',
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
|
|
76
95
|
it('handles missing mappings and deep merges settings', async () => {
|
|
77
96
|
await expect(
|
|
78
97
|
evaluateMapping(undefined, {
|
package/src/dsl.types.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { z } from 'zod';
|
|
|
10
10
|
|
|
11
11
|
import type { BindingKindSchemas } from './bindings/base-binding';
|
|
12
12
|
import { validateAndResolveBindings } from './bindings/base-binding';
|
|
13
|
+
import { SNAKE_CASE_REGEX } from './utils/naming';
|
|
13
14
|
|
|
14
15
|
export const ExpressionStringSchema = z
|
|
15
16
|
.string()
|
|
@@ -330,7 +331,10 @@ export const WorkflowDefinitionSchema = z.strictObject({
|
|
|
330
331
|
inputs: InputsSchema.optional(),
|
|
331
332
|
context: z.record(z.string(), JsonValueSchema).optional(),
|
|
332
333
|
defaults: DefaultsSchema.optional(),
|
|
333
|
-
defs: z.record(
|
|
334
|
+
defs: z.record(
|
|
335
|
+
z.string().regex(SNAKE_CASE_REGEX, 'Name must be snake_case'),
|
|
336
|
+
DefDefinitionSchema,
|
|
337
|
+
),
|
|
334
338
|
flow: z.array(FlowStepSchema),
|
|
335
339
|
outputs: z.record(z.string(), ExpressionStringSchema),
|
|
336
340
|
});
|
package/src/utils/naming.ts
CHANGED
package/src/workflow-compiler.ts
CHANGED
|
@@ -20,7 +20,6 @@ import type {
|
|
|
20
20
|
WorkflowDefinition,
|
|
21
21
|
} from './dsl.types';
|
|
22
22
|
import { extractTaskDefinitions as extractTaskDefinitionsFromDefs } from './dsl.types';
|
|
23
|
-
import { assertSnakeCaseName } from './utils/naming';
|
|
24
23
|
import { StepType } from './workflow-event-emitter';
|
|
25
24
|
import type {
|
|
26
25
|
CompiledMapping,
|
|
@@ -168,8 +167,6 @@ const compileTasks = (
|
|
|
168
167
|
assertActionsBound(taskDefinitions, options.actions);
|
|
169
168
|
|
|
170
169
|
for (const [taskName, task] of Object.entries(taskDefinitions)) {
|
|
171
|
-
assertSnakeCaseName(taskName, 'action');
|
|
172
|
-
|
|
173
170
|
const action = options.actions[task.action];
|
|
174
171
|
const settingsPayload = mergeSettings(defaultSettings, task.settings);
|
|
175
172
|
const parsedSettings = action.parseSettings(settingsPayload);
|
package/src/workflow-values.ts
CHANGED
|
@@ -35,6 +35,44 @@ export type CompileValueOptions = {
|
|
|
35
35
|
/** Basic object guard that rejects arrays and null. */
|
|
36
36
|
const isPlainObject = (value: unknown): value is Record<string, unknown> =>
|
|
37
37
|
typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
38
|
+
const resolveNestedExpressions = async (
|
|
39
|
+
value: unknown,
|
|
40
|
+
scope: EvaluationScope,
|
|
41
|
+
seen: WeakSet<object> = new WeakSet(),
|
|
42
|
+
): Promise<unknown> => {
|
|
43
|
+
if (typeof value === 'string' && value.startsWith('=')) {
|
|
44
|
+
return evaluateValue(compileValue(value), scope);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (Array.isArray(value)) {
|
|
48
|
+
if (seen.has(value)) {
|
|
49
|
+
return value;
|
|
50
|
+
}
|
|
51
|
+
seen.add(value);
|
|
52
|
+
|
|
53
|
+
return Promise.all(
|
|
54
|
+
value.map((entry) => resolveNestedExpressions(entry, scope, seen)),
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (isPlainObject(value)) {
|
|
59
|
+
if (seen.has(value)) {
|
|
60
|
+
return value;
|
|
61
|
+
}
|
|
62
|
+
seen.add(value);
|
|
63
|
+
|
|
64
|
+
const entries = await Promise.all(
|
|
65
|
+
Object.entries(value).map(async ([key, entry]) => [
|
|
66
|
+
key,
|
|
67
|
+
await resolveNestedExpressions(entry, scope, seen),
|
|
68
|
+
]),
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
return Object.fromEntries(entries);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return value;
|
|
75
|
+
};
|
|
38
76
|
const registerJsonataFunctions = (
|
|
39
77
|
expression: Expression,
|
|
40
78
|
registry?: JsonataFunctionRegistry,
|
|
@@ -118,11 +156,16 @@ export const evaluateMapping = async (
|
|
|
118
156
|
return {};
|
|
119
157
|
}
|
|
120
158
|
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
159
|
+
const entries = await Promise.all(
|
|
160
|
+
Object.entries(mapping).map(async ([key, compiled]) => [
|
|
161
|
+
key,
|
|
162
|
+
await resolveNestedExpressions(
|
|
163
|
+
await evaluateValue(compiled, scope),
|
|
164
|
+
scope,
|
|
165
|
+
),
|
|
166
|
+
]),
|
|
167
|
+
);
|
|
168
|
+
const result: Record<string, unknown> = Object.fromEntries(entries);
|
|
126
169
|
|
|
127
170
|
return result;
|
|
128
171
|
};
|