diff --git a/web/utils/template.ts b/web/utils/template.ts index f041d6c150..bf864c7b6b 100644 --- a/web/utils/template.ts +++ b/web/utils/template.ts @@ -9,6 +9,7 @@ type GraphPayload = { } type DslPayload = { + version?: string | number workflow?: { graph?: GraphPayload } @@ -42,6 +43,21 @@ export const parseGraphFromDsl = (dslContent: string): ParsedGraph => { } } +export const parseDslVersionFromDsl = (dslContent: string): string | null => { + if (!dslContent) + return null + + try { + const data = yamlLoad(dslContent) as DslPayload + if (data?.version === undefined || data?.version === null) + return null + return String(data.version) + } + catch { + return null + } +} + type UsedCountFormatOptions = { precision?: number rounding?: 'round' | 'floor'