1
0
Fork 0
mirror of synced 2024-07-03 21:40:55 +12:00

Comments on PR - some small changes.

This commit is contained in:
mike12345567 2024-01-24 12:33:29 +00:00
parent 907e3396f9
commit 35a3d663ba
7 changed files with 658 additions and 46 deletions

View file

@ -97,9 +97,7 @@
$: schemaReadOnly = !responseSuccess
$: variablesReadOnly = !responseSuccess
$: showVariablesTab = shouldShowVariables(dynamicVariables, variablesReadOnly)
$: hasSchema =
Object.keys(schema || {}).length !== 0 ||
Object.keys(query?.schema || {}).length !== 0
$: hasSchema = Object.keys(schema || {}).length !== 0
$: runtimeUrlQueries = readableToRuntimeMap(mergedBindings, breakQs)

View file

@ -7,7 +7,7 @@ import { invalidateDynamicVariables } from "../../../threads/utils"
import env from "../../../environment"
import { events, context, utils, constants } from "@budibase/backend-core"
import sdk from "../../../sdk"
import { QueryEvent } from "../../../threads/definitions"
import { QueryEvent, QueryResponse } from "../../../threads/definitions"
import {
ConfigType,
Query,
@ -168,7 +168,7 @@ export async function preview(ctx: UserCtx) {
},
}
const { rows, keys, info, extra } = (await Runner.run(inputs)) as any
const { rows, keys, info, extra } = await Runner.run<QueryResponse>(inputs)
const previewSchema: Record<string, QuerySchema> = {}
const makeQuerySchema = (type: FieldType, name: string): QuerySchema => ({
type,
@ -203,8 +203,8 @@ export async function preview(ctx: UserCtx) {
// if existing schema, update to include any previous schema keys
if (existingSchema) {
for (let key of Object.keys(previewSchema)) {
if (existingSchema[key]?.type) {
previewSchema[key] = existingSchema[key].type
if (existingSchema[key]) {
previewSchema[key] = existingSchema[key]
}
}
}
@ -267,7 +267,9 @@ async function execute(
schema: query.schema,
}
const { rows, pagination, extra, info } = (await Runner.run(inputs)) as any
const { rows, pagination, extra, info } = await Runner.run<QueryResponse>(
inputs
)
// remove the raw from execution incase transformer being used to hide data
if (extra?.raw) {
delete extra.raw

View file

@ -5,7 +5,7 @@ import { getQueryParams, isProdAppID } from "../../../db/utils"
import { BaseQueryVerbs } from "../../../constants"
import { Query, QuerySchema } from "@budibase/types"
function updateSchema(query: Query) {
function updateSchema(query: Query): Query {
if (!query.schema) {
return query
}
@ -21,7 +21,7 @@ function updateSchema(query: Query) {
return query
}
function updateSchemas(queries: Query[]) {
function updateSchemas(queries: Query[]): Query[] {
return queries.map(query => updateSchema(query))
}

View file

@ -1,4 +1,4 @@
import { QuerySchema } from "@budibase/types"
import { QuerySchema, Row } from "@budibase/types"
export type WorkerCallback = (error: any, response?: any) => void
@ -16,6 +16,14 @@ export interface QueryEvent {
schema?: Record<string, QuerySchema | string>
}
export interface QueryResponse {
rows: Row[]
keys: string[]
info: any
extra: any
pagination: any
}
export interface QueryVariable {
queryId: string
name: string

View file

@ -74,7 +74,7 @@ export class Thread {
)
}
run(job: AutomationJob | QueryEvent) {
run<T>(job: AutomationJob | QueryEvent): Promise<T> {
const timeout = this.timeoutMs
return new Promise((resolve, reject) => {
function fire(worker: any) {

View file

@ -1,7 +1,12 @@
import { default as threadUtils } from "./utils"
threadUtils.threadSetup()
import { WorkerCallback, QueryEvent, QueryVariable } from "./definitions"
import {
WorkerCallback,
QueryEvent,
QueryVariable,
QueryResponse,
} from "./definitions"
import ScriptRunner from "../utilities/scriptRunner"
import { getIntegration } from "../integrations"
import { processStringSync } from "@budibase/string-templates"
@ -9,7 +14,7 @@ import { context, cache, auth } from "@budibase/backend-core"
import { getGlobalIDFromUserMetadataID } from "../db/utils"
import sdk from "../sdk"
import { cloneDeep } from "lodash/fp"
import { SourceName, Query } from "@budibase/types"
import { Query } from "@budibase/types"
import { isSQL } from "../integrations/utils"
import { interpolateSQL } from "../integrations/queries/sql"
@ -53,7 +58,7 @@ class QueryRunner {
this.hasDynamicVariables = false
}
async execute(): Promise<any> {
async execute(): Promise<QueryResponse> {
let { datasource, fields, queryVerb, transformer, schema } = this
let datasourceClone = cloneDeep(datasource)
let fieldsClone = cloneDeep(fields)

661
yarn.lock

File diff suppressed because it is too large Load diff