1
0
Fork 0
mirror of synced 2024-09-20 19:33:10 +12:00

Unify enums

This commit is contained in:
Adria Navarro 2024-07-31 12:20:45 +02:00
parent daff1a46d8
commit 0202db3efe
3 changed files with 15 additions and 16 deletions

View file

@ -9,7 +9,10 @@ import { Constants } from "@budibase/frontend-core"
const { TypeIconMap } = Constants const { TypeIconMap } = Constants
export { RelationshipType } from "@budibase/types" export {
RelationshipType,
RowExportFormat as ROW_EXPORT_FORMATS,
} from "@budibase/types"
export const AUTO_COLUMN_SUB_TYPES = AutoFieldSubType export const AUTO_COLUMN_SUB_TYPES = AutoFieldSubType
@ -307,9 +310,3 @@ export const DatasourceTypes = {
GRAPH: "Graph", GRAPH: "Graph",
API: "API", API: "API",
} }
export const ROW_EXPORT_FORMATS = {
CSV: "csv",
JSON: "json",
JSON_WITH_SCHEMA: "jsonWithSchema",
}

View file

@ -1,4 +1,6 @@
import { Row, TableSchema } from "@budibase/types" import { Row, RowExportFormat, TableSchema } from "@budibase/types"
export { RowExportFormat as Format } from "@budibase/types"
function getHeaders( function getHeaders(
headers: string[], headers: string[],
@ -46,14 +48,8 @@ export function jsonWithSchema(schema: TableSchema, rows: Row[]) {
return JSON.stringify({ schema: newSchema, rows }, undefined, 2) return JSON.stringify({ schema: newSchema, rows }, undefined, 2)
} }
export enum Format { export function isFormat(format: any): format is RowExportFormat {
CSV = "csv", return Object.values(RowExportFormat).includes(format as RowExportFormat)
JSON = "json",
JSON_WITH_SCHEMA = "jsonWithSchema",
}
export function isFormat(format: any): format is Format {
return Object.values(Format).includes(format as Format)
} }
export function parseCsvExport<T>(value: string) { export function parseCsvExport<T>(value: string) {

View file

@ -30,3 +30,9 @@ export interface SearchResponse<T> {
bookmark?: string | number bookmark?: string | number
totalRows?: number totalRows?: number
} }
export enum RowExportFormat {
CSV = "csv",
JSON = "json",
JSON_WITH_SCHEMA = "jsonWithSchema",
}