diff --git a/packages/server/src/api/controllers/table/external.ts b/packages/server/src/api/controllers/table/external.ts index 75318a3462..49dbc855f7 100644 --- a/packages/server/src/api/controllers/table/external.ts +++ b/packages/server/src/api/controllers/table/external.ts @@ -16,6 +16,7 @@ import { context, events } from "@budibase/backend-core" import { isRows, isSchema, parse } from "../../../utilities/schema" import { BulkImportRequest, + BulkImportResponse, Datasource, FieldSchema, ManyToManyRelationshipFieldMetadata, @@ -386,7 +387,7 @@ export async function destroy(ctx: UserCtx) { return tableToDelete } -export async function bulkImport(ctx: UserCtx) { +export async function bulkImport(ctx: UserCtx) { const table = await sdk.tables.getTable(ctx.params.tableId) const { rows } = ctx.request.body const schema = table.schema diff --git a/packages/server/src/api/controllers/table/index.ts b/packages/server/src/api/controllers/table/index.ts index 4e63686bcb..8d81e6d168 100644 --- a/packages/server/src/api/controllers/table/index.ts +++ b/packages/server/src/api/controllers/table/index.ts @@ -9,6 +9,7 @@ import { isExternalTable, isSQL } from "../../../integrations/utils" import { events } from "@budibase/backend-core" import { BulkImportRequest, + BulkImportResponse, FetchTablesResponse, SaveTableRequest, SaveTableResponse, @@ -98,7 +99,7 @@ export async function destroy(ctx: UserCtx) { builderSocket?.emitTableDeletion(ctx, deletedTable) } -export async function bulkImport(ctx: UserCtx) { +export async function bulkImport(ctx: UserCtx) { const tableId = ctx.params.tableId let tableBefore = await sdk.tables.getTable(tableId) let tableAfter = await pickApi({ tableId }).bulkImport(ctx) diff --git a/packages/server/src/api/controllers/table/internal.ts b/packages/server/src/api/controllers/table/internal.ts index 11be19a8a7..3d957b8771 100644 --- a/packages/server/src/api/controllers/table/internal.ts +++ b/packages/server/src/api/controllers/table/internal.ts @@ -11,6 +11,7 @@ import { import { runStaticFormulaChecks } from "./bulkFormula" import { BulkImportRequest, + BulkImportResponse, RenameColumn, SaveTableRequest, SaveTableResponse, @@ -207,7 +208,7 @@ export async function destroy(ctx: any) { return tableToDelete } -export async function bulkImport(ctx: UserCtx) { +export async function bulkImport(ctx: UserCtx) { const table = await sdk.tables.getTable(ctx.params.tableId) const { rows, identifierFields } = ctx.request.body await handleDataImport(ctx.user, table, rows, identifierFields) diff --git a/packages/server/src/api/routes/tests/table.spec.ts b/packages/server/src/api/routes/tests/table.spec.ts index f8f78561dd..ded54729b9 100644 --- a/packages/server/src/api/routes/tests/table.spec.ts +++ b/packages/server/src/api/routes/tests/table.spec.ts @@ -5,6 +5,7 @@ import { RelationshipType, Table, ViewCalculation, + AutoFieldSubTypes, } from "@budibase/types" import { checkBuilderEndpoint } from "./utilities/TestFunctions" import * as setup from "./utilities" @@ -196,7 +197,7 @@ describe("/tables", () => { autoId: { name: "id", type: FieldType.NUMBER, - subtype: "autoID", + subtype: AutoFieldSubTypes.AUTO_ID, autocolumn: true, constraints: { type: "number", diff --git a/packages/server/src/tests/utilities/api/row.ts b/packages/server/src/tests/utilities/api/row.ts index ce95bf2835..bb880bb7da 100644 --- a/packages/server/src/tests/utilities/api/row.ts +++ b/packages/server/src/tests/utilities/api/row.ts @@ -4,8 +4,8 @@ import { Row, ValidateResponse, ExportRowsRequest, - ImportRowsRequest, - ImportRowsResponse, + BulkImportRequest, + BulkImportResponse, } from "@budibase/types" import TestConfiguration from "../TestConfiguration" import { TestAPI } from "./base" @@ -127,9 +127,9 @@ export class RowAPI extends TestAPI { bulkImport = async ( tableId: string, - body: ImportRowsRequest, + body: BulkImportRequest, { expectStatus } = { expectStatus: 200 } - ): Promise => { + ): Promise => { let request = this.request .post(`/api/tables/${tableId}/import`) .send(body) diff --git a/packages/types/src/api/web/app/table.ts b/packages/types/src/api/web/app/table.ts index 8fb0297a9e..cb5faaa9ea 100644 --- a/packages/types/src/api/web/app/table.ts +++ b/packages/types/src/api/web/app/table.ts @@ -29,3 +29,7 @@ export interface BulkImportRequest { rows: Row[] identifierFields?: Array } + +export interface BulkImportResponse { + message: string +}