This commit is contained in:
Adria Navarro 2024-10-30 17:13:03 +01:00
parent b510d04129
commit 3779c7f6c7
2 changed files with 15 additions and 4 deletions

View File

@ -8,7 +8,7 @@ import {
import * as actions from "../automations/actions" import * as actions from "../automations/actions"
import * as automationUtils from "../automations/automationUtils" import * as automationUtils from "../automations/automationUtils"
import { replaceFakeBindings } from "../automations/loopUtils" import { replaceFakeBindings } from "../automations/loopUtils"
import { dataFilters, helpers } from "@budibase/shared-core" import { dataFilters, helpers, utils } from "@budibase/shared-core"
import { default as AutomationEmitter } from "../events/AutomationEmitter" import { default as AutomationEmitter } from "../events/AutomationEmitter"
import { generateAutomationMetadataID, isProdAppID } from "../db/utils" import { generateAutomationMetadataID, isProdAppID } from "../db/utils"
import { definitions as triggerDefs } from "../automations/triggerInfo" import { definitions as triggerDefs } from "../automations/triggerInfo"
@ -28,6 +28,7 @@ import {
isLogicalSearchOperator, isLogicalSearchOperator,
LoopStep, LoopStep,
UserBindings, UserBindings,
isBasicSearchOperator,
} from "@budibase/types" } from "@budibase/types"
import { AutomationContext, TriggerOutput } from "../definitions/automations" import { AutomationContext, TriggerOutput } from "../definitions/automations"
import { WorkerCallback } from "./definitions" import { WorkerCallback } from "./definitions"
@ -566,7 +567,7 @@ class Orchestrator {
filters[filterKey].conditions = filters[filterKey].conditions.map( filters[filterKey].conditions = filters[filterKey].conditions.map(
condition => recurseSearchFilters(condition) condition => recurseSearchFilters(condition)
) )
} else { } else if (isBasicSearchOperator(filterKey)) {
for (const [field, value] of Object.entries(filters[filterKey])) { for (const [field, value] of Object.entries(filters[filterKey])) {
const fromContext = processStringSync( const fromContext = processStringSync(
field, field,
@ -583,6 +584,9 @@ class Orchestrator {
filters[filterKey][field] = processedVal filters[filterKey][field] = processedVal
} }
} }
} else {
// We want to types to complain if we extend BranchSearchFilters, but not to throw if the request comes with some extra data. It will just be ignored
utils.unreachable(filterKey, { doNotThrow: true })
} }
} }

View File

@ -26,9 +26,16 @@ const FILTER_ALLOWED_KEYS: (keyof SearchFilter)[] = [
export function unreachable( export function unreachable(
value: never, value: never,
message = `No such case in exhaustive switch: ${value}` opts?: {
message?: string
doNotThrow?: boolean
}
) { ) {
throw new Error(message) const message = opts?.message || `No such case in exhaustive switch: ${value}`
const doNotThrow = !!opts?.doNotThrow
if (!doNotThrow) {
throw new Error(message)
}
} }
export async function parallelForeach<T>( export async function parallelForeach<T>(