Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/lib/core/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export class ValueResolver {
}

// Check for Network(...) property access
const networkMatch = expression.match(/^Network\(\)\.(.\w+)$/)
const networkMatch = expression.match(/^Network\(\)\.(\w+)$/)
if (networkMatch) {
const [, property] = networkMatch
const network = context.getNetwork()
Expand Down Expand Up @@ -187,6 +187,8 @@ export class ValueResolver {
return this.resolveJobCompleted(resolvedArgs as JobCompletedValue['arguments'], context)
case 'read-json':
return this.resolveReadJson(resolvedArgs as ReadJsonValue['arguments'])
case 'resolve-json':
return this.resolveJsonValue(resolvedArgs, context)
default:
throw new Error(`Unknown value resolver type: ${(obj as any).type}`)
}
Expand Down Expand Up @@ -513,6 +515,21 @@ export class ValueResolver {
}
}

private async resolveJsonValue(args: any, context: ExecutionContext): Promise<any> {
if (Array.isArray(args)) {
return Promise.all(args.map(v => this.resolveJsonValue(v, context)))
} else if (typeof args === 'object' && args !== null) {
const resolved: Record<string, any> = {}
for (const [k, v] of Object.entries(args)) {
resolved[k] = await this.resolveJsonValue(v, context)
}
return resolved
} else {
// For primitive values, resolve them using the main resolve method
return this.resolve(args, context)
}
}

/**
* Helper to recursively resolve the `arguments` field of any `ValueResolver` object.
* @private
Expand Down
Loading