From 6c14777f9cfbe37476ff8303c8b610738f408c7c Mon Sep 17 00:00:00 2001 From: Jon Edvald Date: Wed, 14 Jul 2021 19:55:25 +0200 Subject: [PATCH] fix(templates): uuidv4() helper function was broken Fixes #2487 --- core/src/template-string/functions.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/src/template-string/functions.ts b/core/src/template-string/functions.ts index aaf5367d46..94e78de0c8 100644 --- a/core/src/template-string/functions.ts +++ b/core/src/template-string/functions.ts @@ -6,7 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import uuid from "uuid" +import { v4 as uuidv4 } from "uuid" import { TemplateStringError } from "../exceptions" import { keyBy, mapValues, escapeRegExp, trim, isEmpty, camelCase, kebabCase, isArrayLike } from "lodash" import { joi, JoiDescription } from "../config/common" @@ -188,7 +188,7 @@ const helperFunctionSpecs: TemplateHelperFunction[] = [ outputSchema: joi.string(), exampleArguments: [[]], exampleOutput: "1b9d6bcd-bbfd-4b2d-9b5d-ab8dfbbd4bed", - fn: () => uuid.v4(), + fn: () => uuidv4(), }, { name: "yamlDecode", @@ -252,7 +252,8 @@ export const helperFunctions = keyBy( const examples = spec.exampleArguments.map((args) => { const argsEncoded = args.map((arg) => JSON.stringify(arg)) - const result = spec.exampleOutput || JSON.stringify(spec.fn(...args)) + const exampleValue = JSON.stringify(spec.fn(...args)) + const result = spec.exampleOutput || exampleValue return { template: "${" + `${spec.name}(${argsEncoded.join(", ")})}`, result,