Merge pull request #14286 from Budibase/chore/unify-row-format-values

Unify types
This commit is contained in:
Adria Navarro 2024-08-01 10:38:36 +02:00 committed by GitHub
commit fddf93c005
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 17 additions and 18 deletions

View File

@ -9,7 +9,10 @@ import { Constants } from "@budibase/frontend-core"
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
@ -307,9 +310,3 @@ export const DatasourceTypes = {
GRAPH: "Graph",
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(
headers: string[],
@ -46,14 +48,8 @@ export function jsonWithSchema(schema: TableSchema, rows: Row[]) {
return JSON.stringify({ schema: newSchema, rows }, undefined, 2)
}
export enum Format {
CSV = "csv",
JSON = "json",
JSON_WITH_SCHEMA = "jsonWithSchema",
}
export function isFormat(format: any): format is Format {
return Object.values(Format).includes(format as Format)
export function isFormat(format: any): format is RowExportFormat {
return Object.values(RowExportFormat).includes(format as RowExportFormat)
}
export function parseCsvExport<T>(value: string) {

View File

@ -1,5 +1,5 @@
import { Expectations, TestAPI } from "./base"
import { Row, View, ViewCalculation } from "@budibase/types"
import { Row, RowExportFormat, View, ViewCalculation } from "@budibase/types"
export class LegacyViewAPI extends TestAPI {
get = async (
@ -24,7 +24,7 @@ export class LegacyViewAPI extends TestAPI {
export = async (
viewName: string,
format: "json" | "csv" | "jsonWithSchema",
format: `${RowExportFormat}`,
expectations?: Expectations
) => {
const response = await this._requestRaw("get", `/api/views/export`, {

View File

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