Types
This commit is contained in:
parent
7394a7cd64
commit
9da9935c95
|
@ -62,6 +62,7 @@ import {
|
||||||
User,
|
User,
|
||||||
UserRoles,
|
UserRoles,
|
||||||
View,
|
View,
|
||||||
|
WithRequired,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
|
|
||||||
import API from "./api"
|
import API from "./api"
|
||||||
|
@ -794,17 +795,19 @@ class TestConfiguration {
|
||||||
|
|
||||||
async createDatasource(config?: {
|
async createDatasource(config?: {
|
||||||
datasource: Datasource
|
datasource: Datasource
|
||||||
}): Promise<Datasource & Required<Pick<Datasource, "_id">>> {
|
}): Promise<WithRequired<Datasource, "_id">> {
|
||||||
config = config || basicDatasource()
|
config = config || basicDatasource()
|
||||||
const response = await this.api.datasource.create(config.datasource)
|
const response = await this.api.datasource.create(config.datasource)
|
||||||
this.datasource = response
|
this.datasource = response
|
||||||
return { ...this.datasource, _id: this.datasource!._id! }
|
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)
|
const response = await this.api.datasource.update(datasource)
|
||||||
this.datasource = response
|
this.datasource = response
|
||||||
return this.datasource!
|
return { ...this.datasource, _id: this.datasource!._id! }
|
||||||
}
|
}
|
||||||
|
|
||||||
async restDatasource(cfg?: any) {
|
async restDatasource(cfg?: any) {
|
||||||
|
@ -819,6 +822,7 @@ class TestConfiguration {
|
||||||
|
|
||||||
async dynamicVariableDatasource() {
|
async dynamicVariableDatasource() {
|
||||||
let datasource = await this.restDatasource()
|
let datasource = await this.restDatasource()
|
||||||
|
|
||||||
const basedOnQuery = await this.createQuery({
|
const basedOnQuery = await this.createQuery({
|
||||||
...basicQuery(datasource._id!),
|
...basicQuery(datasource._id!),
|
||||||
fields: {
|
fields: {
|
||||||
|
|
|
@ -12,7 +12,7 @@ export class DatasourceAPI extends TestAPI {
|
||||||
super(config)
|
super(config)
|
||||||
}
|
}
|
||||||
|
|
||||||
create = async <B extends boolean>(
|
create = async <B extends boolean = false>(
|
||||||
config: Datasource,
|
config: Datasource,
|
||||||
{
|
{
|
||||||
expectStatus,
|
expectStatus,
|
||||||
|
|
|
@ -7,3 +7,5 @@ export type ISO8601 = string
|
||||||
export type RequiredKeys<T> = {
|
export type RequiredKeys<T> = {
|
||||||
[K in keyof Required<T>]: T[K]
|
[K in keyof Required<T>]: T[K]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type WithRequired<T, K extends keyof T> = T & Required<Pick<T, K>>
|
||||||
|
|
Loading…
Reference in New Issue