Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify types #14286

Merged
merged 6 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions packages/builder/src/constants/backend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -307,9 +310,3 @@ export const DatasourceTypes = {
GRAPH: "Graph",
API: "API",
}

export const ROW_EXPORT_FORMATS = {
CSV: "csv",
JSON: "json",
JSON_WITH_SCHEMA: "jsonWithSchema",
}
14 changes: 5 additions & 9 deletions packages/server/src/api/controllers/view/exporters.ts
Original file line number Diff line number Diff line change
@@ -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[],
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions packages/server/src/tests/utilities/api/legacyView.ts
Original file line number Diff line number Diff line change
@@ -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 (
Expand All @@ -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`, {
Expand Down
6 changes: 6 additions & 0 deletions packages/types/src/sdk/row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,9 @@ export interface SearchResponse<T> {
bookmark?: string | number
totalRows?: number
}

export enum RowExportFormat {
CSV = "csv",
JSON = "json",
JSON_WITH_SCHEMA = "jsonWithSchema",
}
Loading