Typings
This commit is contained in:
parent
2fd120c656
commit
819f6f52e3
|
@ -17,7 +17,10 @@ export {
|
|||
|
||||
export const AUTO_COLUMN_SUB_TYPES = AutoFieldSubType
|
||||
|
||||
export const AUTO_COLUMN_DISPLAY_NAMES = {
|
||||
export const AUTO_COLUMN_DISPLAY_NAMES: Record<
|
||||
keyof typeof AUTO_COLUMN_SUB_TYPES,
|
||||
string
|
||||
> = {
|
||||
AUTO_ID: "Auto ID",
|
||||
CREATED_BY: "Created By",
|
||||
CREATED_AT: "Created At",
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { FieldType } from "@budibase/types"
|
||||
import { AutoFieldSubType, Automation, FieldType } from "@budibase/types"
|
||||
import { ActionStepID } from "@/constants/backend/automations"
|
||||
import { TableNames } from "@/constants"
|
||||
import {
|
||||
|
@ -8,8 +8,14 @@ import {
|
|||
isAutoColumnUserRelationship,
|
||||
} from "@/constants/backend"
|
||||
|
||||
export function getAutoColumnInformation(enabled = true) {
|
||||
let info = {}
|
||||
type AutoColumnInformation = Partial<
|
||||
Record<AutoFieldSubType, { enabled: boolean; name: string }>
|
||||
>
|
||||
|
||||
export function getAutoColumnInformation(
|
||||
enabled = true
|
||||
): AutoColumnInformation {
|
||||
const info: AutoColumnInformation = {}
|
||||
for (const [key, subtype] of Object.entries(AUTO_COLUMN_SUB_TYPES)) {
|
||||
// Because it's possible to replicate the functionality of CREATED_AT and
|
||||
// CREATED_BY columns with user column default values, we disable their creation
|
||||
|
@ -19,13 +25,20 @@ export function getAutoColumnInformation(enabled = true) {
|
|||
) {
|
||||
continue
|
||||
}
|
||||
|
||||
info[subtype] = { enabled, name: AUTO_COLUMN_DISPLAY_NAMES[key] }
|
||||
const typedKey = key as keyof typeof AUTO_COLUMN_SUB_TYPES
|
||||
info[subtype] = {
|
||||
enabled,
|
||||
name: AUTO_COLUMN_DISPLAY_NAMES[typedKey],
|
||||
}
|
||||
}
|
||||
return info
|
||||
}
|
||||
|
||||
export function buildAutoColumn(tableName, name, subtype) {
|
||||
export function buildAutoColumn(
|
||||
tableName: string,
|
||||
name: string,
|
||||
subtype: AutoFieldSubType
|
||||
) {
|
||||
let type, constraints
|
||||
switch (subtype) {
|
||||
case AUTO_COLUMN_SUB_TYPES.UPDATED_BY:
|
||||
|
@ -65,7 +78,7 @@ export function buildAutoColumn(tableName, name, subtype) {
|
|||
return base
|
||||
}
|
||||
|
||||
export function checkForCollectStep(automation) {
|
||||
export function checkForCollectStep(automation: Automation) {
|
||||
return automation.definition.steps.some(
|
||||
step => step.stepId === ActionStepID.COLLECT
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue