From a45af37b5d6d7c18fd6d578ceefdff21ba33a55e Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Sun, 9 Mar 2025 21:18:05 -0600 Subject: [PATCH] feat(templates): add utility functions for template variable generation - Implement new utility functions in template processing - Add support for generating UUID, timestamp, and random port - Extend template variable processing capabilities --- packages/server/src/templates/processors.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/server/src/templates/processors.ts b/packages/server/src/templates/processors.ts index 322f11b9e..505ccc33b 100644 --- a/packages/server/src/templates/processors.ts +++ b/packages/server/src/templates/processors.ts @@ -84,6 +84,18 @@ function processValue( const length = Number.parseInt(varName.split(":")[1], 10) || 8; return generateHash(length); } + if (varName === "uuid") { + return crypto.randomUUID(); + } + + if (varName === "timestamp") { + return Date.now().toString(); + } + + if (varName === "randomPort") { + return Math.floor(Math.random() * 65535).toString(); + } + // If not a utility function, try to get from variables return variables[varName] || match; });