mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-20 08:01:35 +00:00
6c6dfbc121
* flow dev * vscode flow extension improvements
19 lines
623 B
TypeScript
19 lines
623 B
TypeScript
import type { OpenFlow } from '$lib/gen'
|
|
import { dfs } from './dfs'
|
|
import type { FlowState } from './flowState'
|
|
import { charsToNumber, numberToChars } from './idUtils'
|
|
|
|
// Computes the next available id
|
|
export function nextId(flowState: FlowState, fullFlow: OpenFlow): string {
|
|
const allIds = dfs(fullFlow.value.modules, (fm) => fm.id)
|
|
const max = allIds.concat(Object.keys(flowState)).reduce((acc, key) => {
|
|
if (key === 'failure' || key.includes('branch') || key.includes('loop')) {
|
|
return acc
|
|
} else {
|
|
const num = charsToNumber(key)
|
|
return Math.max(acc, num + 1)
|
|
}
|
|
}, 0)
|
|
return numberToChars(max)
|
|
}
|