Skip to content

Add evaluatedInputsJson and evaluatedOutputsJson to GetDecisionInstanceResponse Dto #553

@jwulf

Description

@jwulf

In the application we need to expose Json-parsed key:value objects for these two for convenience.

We can put something like this in a custom JsonParser passed to the callApiEndpoint:

let transformedInput = {}
if (response.evaluatedInputs && Array.isArray(response.evaluatedInputs)) {
	transformedInput = response.evaluatedInputs.reduce(
		(acc: any, input: any) => {
			// Use inputName as key (lowercase for consistency)
			const key = input.inputName.toLowerCase()

			// Parse inputValue - it might be JSON-escaped or a plain value
			let parsedValue = input.inputValue
			try {
				// Try to parse as JSON first (handles escaped strings and numbers)
				parsedValue = JSON.parse(input.inputValue)
			} catch {
				// If JSON parsing fails, try to convert numbers
				if (
					typeof input.inputValue === 'string' &&
					!isNaN(Number(input.inputValue))
				) {
					parsedValue = Number(input.inputValue)
				} else {
					// Keep as string if all parsing fails
					parsedValue = input.inputValue
				}
			}
			acc[key] = parsedValue
			return acc
		},
		{}
	)
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions