This commit is contained in:
Adria Navarro 2024-01-29 23:25:12 +01:00
parent 7394a7cd64
commit 9da9935c95
3 changed files with 10 additions and 4 deletions

View File

@ -62,6 +62,7 @@ import {
User,
UserRoles,
View,
WithRequired,
} from "@budibase/types"
import API from "./api"
@ -794,17 +795,19 @@ class TestConfiguration {
async createDatasource(config?: {
datasource: Datasource
}): Promise<Datasource & Required<Pick<Datasource, "_id">>> {
}): Promise<WithRequired<Datasource, "_id">> {
config = config || basicDatasource()
const response = await this.api.datasource.create(config.datasource)
this.datasource = response
return { ...this.datasource, _id: this.datasource!._id! }
}
async updateDatasource(datasource: Datasource): Promise<Datasource> {
async updateDatasource(
datasource: Datasource
): Promise<WithRequired<Datasource, "_id">> {
const response = await this.api.datasource.update(datasource)
this.datasource = response
return this.datasource!
return { ...this.datasource, _id: this.datasource!._id! }
}
async restDatasource(cfg?: any) {
@ -819,6 +822,7 @@ class TestConfiguration {
async dynamicVariableDatasource() {
let datasource = await this.restDatasource()
const basedOnQuery = await this.createQuery({
...basicQuery(datasource._id!),
fields: {

View File

@ -12,7 +12,7 @@ export class DatasourceAPI extends TestAPI {
super(config)
}
create = async <B extends boolean>(
create = async <B extends boolean = false>(
config: Datasource,
{
expectStatus,

View File

@ -7,3 +7,5 @@ export type ISO8601 = string
export type RequiredKeys<T> = {
[K in keyof Required<T>]: T[K]
}
export type WithRequired<T, K extends keyof T> = T & Required<Pick<T, K>>