-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: many type fixes, eslint bump and config migration
- Loading branch information
Showing
15 changed files
with
816 additions
and
458 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 13 additions & 7 deletions
20
kleros-sdk/src/dataMappings/utils/replacePlaceholdersWithValues.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,23 @@ | ||
import mustache from "mustache"; | ||
import { ActionMapping } from "./actionTypes"; | ||
|
||
export const replacePlaceholdersWithValues = (mapping: any, context: Record<string, unknown>) => { | ||
const replace = (obj) => { | ||
export function replacePlaceholdersWithValues( | ||
mapping: ActionMapping, | ||
context: Record<string, unknown> | ||
): ActionMapping | ActionMapping[] { | ||
function replace(obj: ActionMapping): ActionMapping | ActionMapping[] { | ||
if (typeof obj === "string") { | ||
return mustache.render(obj, context); | ||
return mustache.render(obj, context) as unknown as ActionMapping; | ||
} else if (Array.isArray(obj)) { | ||
return obj.map(replace); | ||
return obj.map(replace) as unknown as ActionMapping[]; | ||
} else if (typeof obj === "object" && obj !== null) { | ||
return Object.fromEntries(Object.entries(obj).map(([key, value]) => [key, replace(value)])); | ||
return Object.fromEntries( | ||
Object.entries(obj).map(([key, value]) => [key, replace(value)]) | ||
) as unknown as ActionMapping[]; | ||
} else { | ||
return obj; | ||
} | ||
}; | ||
} | ||
|
||
return replace(mapping); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.