feat: add version parsing function to extract version from DSL content

This commit is contained in:
yessenia 2026-03-03 19:06:37 +08:00
parent 2dba133d4d
commit 39f4e205a8

View File

@ -9,6 +9,7 @@ type GraphPayload = {
} }
type DslPayload = { type DslPayload = {
version?: string | number
workflow?: { workflow?: {
graph?: GraphPayload 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 = { type UsedCountFormatOptions = {
precision?: number precision?: number
rounding?: 'round' | 'floor' rounding?: 'round' | 'floor'