Add BulkImportResponse as a type after merging Adri's type changes.
This commit is contained in:
parent
789b247879
commit
c76e110350
|
@ -16,6 +16,7 @@ import { context, events } from "@budibase/backend-core"
|
||||||
import { isRows, isSchema, parse } from "../../../utilities/schema"
|
import { isRows, isSchema, parse } from "../../../utilities/schema"
|
||||||
import {
|
import {
|
||||||
BulkImportRequest,
|
BulkImportRequest,
|
||||||
|
BulkImportResponse,
|
||||||
Datasource,
|
Datasource,
|
||||||
FieldSchema,
|
FieldSchema,
|
||||||
ManyToManyRelationshipFieldMetadata,
|
ManyToManyRelationshipFieldMetadata,
|
||||||
|
@ -386,7 +387,7 @@ export async function destroy(ctx: UserCtx) {
|
||||||
return tableToDelete
|
return tableToDelete
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function bulkImport(ctx: UserCtx<BulkImportRequest>) {
|
export async function bulkImport(ctx: UserCtx<BulkImportRequest, BulkImportResponse>) {
|
||||||
const table = await sdk.tables.getTable(ctx.params.tableId)
|
const table = await sdk.tables.getTable(ctx.params.tableId)
|
||||||
const { rows } = ctx.request.body
|
const { rows } = ctx.request.body
|
||||||
const schema = table.schema
|
const schema = table.schema
|
||||||
|
|
|
@ -9,6 +9,7 @@ import { isExternalTable, isSQL } from "../../../integrations/utils"
|
||||||
import { events } from "@budibase/backend-core"
|
import { events } from "@budibase/backend-core"
|
||||||
import {
|
import {
|
||||||
BulkImportRequest,
|
BulkImportRequest,
|
||||||
|
BulkImportResponse,
|
||||||
FetchTablesResponse,
|
FetchTablesResponse,
|
||||||
SaveTableRequest,
|
SaveTableRequest,
|
||||||
SaveTableResponse,
|
SaveTableResponse,
|
||||||
|
@ -98,7 +99,7 @@ export async function destroy(ctx: UserCtx) {
|
||||||
builderSocket?.emitTableDeletion(ctx, deletedTable)
|
builderSocket?.emitTableDeletion(ctx, deletedTable)
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function bulkImport(ctx: UserCtx<BulkImportRequest>) {
|
export async function bulkImport(ctx: UserCtx<BulkImportRequest, BulkImportResponse>) {
|
||||||
const tableId = ctx.params.tableId
|
const tableId = ctx.params.tableId
|
||||||
let tableBefore = await sdk.tables.getTable(tableId)
|
let tableBefore = await sdk.tables.getTable(tableId)
|
||||||
let tableAfter = await pickApi({ tableId }).bulkImport(ctx)
|
let tableAfter = await pickApi({ tableId }).bulkImport(ctx)
|
||||||
|
|
|
@ -11,6 +11,7 @@ import {
|
||||||
import { runStaticFormulaChecks } from "./bulkFormula"
|
import { runStaticFormulaChecks } from "./bulkFormula"
|
||||||
import {
|
import {
|
||||||
BulkImportRequest,
|
BulkImportRequest,
|
||||||
|
BulkImportResponse,
|
||||||
RenameColumn,
|
RenameColumn,
|
||||||
SaveTableRequest,
|
SaveTableRequest,
|
||||||
SaveTableResponse,
|
SaveTableResponse,
|
||||||
|
@ -207,7 +208,7 @@ export async function destroy(ctx: any) {
|
||||||
return tableToDelete
|
return tableToDelete
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function bulkImport(ctx: UserCtx<BulkImportRequest>) {
|
export async function bulkImport(ctx: UserCtx<BulkImportRequest, BulkImportResponse>) {
|
||||||
const table = await sdk.tables.getTable(ctx.params.tableId)
|
const table = await sdk.tables.getTable(ctx.params.tableId)
|
||||||
const { rows, identifierFields } = ctx.request.body
|
const { rows, identifierFields } = ctx.request.body
|
||||||
await handleDataImport(ctx.user, table, rows, identifierFields)
|
await handleDataImport(ctx.user, table, rows, identifierFields)
|
||||||
|
|
|
@ -5,6 +5,7 @@ import {
|
||||||
RelationshipType,
|
RelationshipType,
|
||||||
Table,
|
Table,
|
||||||
ViewCalculation,
|
ViewCalculation,
|
||||||
|
AutoFieldSubTypes,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import { checkBuilderEndpoint } from "./utilities/TestFunctions"
|
import { checkBuilderEndpoint } from "./utilities/TestFunctions"
|
||||||
import * as setup from "./utilities"
|
import * as setup from "./utilities"
|
||||||
|
@ -196,7 +197,7 @@ describe("/tables", () => {
|
||||||
autoId: {
|
autoId: {
|
||||||
name: "id",
|
name: "id",
|
||||||
type: FieldType.NUMBER,
|
type: FieldType.NUMBER,
|
||||||
subtype: "autoID",
|
subtype: AutoFieldSubTypes.AUTO_ID,
|
||||||
autocolumn: true,
|
autocolumn: true,
|
||||||
constraints: {
|
constraints: {
|
||||||
type: "number",
|
type: "number",
|
||||||
|
|
|
@ -4,8 +4,8 @@ import {
|
||||||
Row,
|
Row,
|
||||||
ValidateResponse,
|
ValidateResponse,
|
||||||
ExportRowsRequest,
|
ExportRowsRequest,
|
||||||
ImportRowsRequest,
|
BulkImportRequest,
|
||||||
ImportRowsResponse,
|
BulkImportResponse,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import TestConfiguration from "../TestConfiguration"
|
import TestConfiguration from "../TestConfiguration"
|
||||||
import { TestAPI } from "./base"
|
import { TestAPI } from "./base"
|
||||||
|
@ -127,9 +127,9 @@ export class RowAPI extends TestAPI {
|
||||||
|
|
||||||
bulkImport = async (
|
bulkImport = async (
|
||||||
tableId: string,
|
tableId: string,
|
||||||
body: ImportRowsRequest,
|
body: BulkImportRequest,
|
||||||
{ expectStatus } = { expectStatus: 200 }
|
{ expectStatus } = { expectStatus: 200 }
|
||||||
): Promise<ImportRowsResponse> => {
|
): Promise<BulkImportResponse> => {
|
||||||
let request = this.request
|
let request = this.request
|
||||||
.post(`/api/tables/${tableId}/import`)
|
.post(`/api/tables/${tableId}/import`)
|
||||||
.send(body)
|
.send(body)
|
||||||
|
|
|
@ -29,3 +29,7 @@ export interface BulkImportRequest {
|
||||||
rows: Row[]
|
rows: Row[]
|
||||||
identifierFields?: Array<string>
|
identifierFields?: Array<string>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface BulkImportResponse {
|
||||||
|
message: string
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue