Cleanup dead code

This commit is contained in:
Adria Navarro 2024-10-23 16:48:22 +02:00
parent e67352d51b
commit 998d0002b8
1 changed files with 1 additions and 50 deletions

View File

@ -1,56 +1,7 @@
import {
Automation,
AutomationActionStepId,
AutomationBuilderData,
} from "@budibase/types"
import { sdk as coreSdk } from "@budibase/shared-core"
import sdk from "../../../sdk"
import { Automation, AutomationActionStepId } from "@budibase/types"
export function checkForCollectStep(automation: Automation) {
return automation.definition.steps.some(
(step: any) => step.stepId === AutomationActionStepId.COLLECT
)
}
export async function getBuilderData(
automations: Automation[]
): Promise<Record<string, AutomationBuilderData>> {
const tableNameCache: Record<string, string> = {}
async function getTableName(tableId: string) {
if (!tableNameCache[tableId]) {
const table = await sdk.tables.getTable(tableId)
tableNameCache[tableId] = table.name
}
return tableNameCache[tableId]
}
const result: Record<string, AutomationBuilderData> = {}
for (const automation of automations) {
const isRowAction = coreSdk.automations.isRowAction(automation)
if (!isRowAction) {
result[automation._id!] = { displayName: automation.name }
continue
}
const { tableId, rowActionId } = automation.definition.trigger.inputs
if (!tableId || !rowActionId) {
continue
}
const tableName = await getTableName(tableId)
const rowActionName = automation.name
result[automation._id!] = {
displayName: rowActionName,
triggerInfo: {
type: "Automation trigger",
table: { id: tableId, name: tableName },
rowAction: {
id: rowActionId,
name: rowActionName,
},
},
}
}
return result
}