Also rename LuceneUtils -> QueryUtils

This commit is contained in:
Sam Rose 2024-06-12 15:04:56 +01:00
parent bc8791e91e
commit 6363965a8b
No known key found for this signature in database
11 changed files with 23 additions and 23 deletions

View File

@ -41,7 +41,7 @@
EditorModes, EditorModes,
} from "components/common/CodeEditor" } from "components/common/CodeEditor"
import FilterBuilder from "components/design/settings/controls/FilterEditor/FilterBuilder.svelte" import FilterBuilder from "components/design/settings/controls/FilterEditor/FilterBuilder.svelte"
import { LuceneUtils, Utils } from "@budibase/frontend-core" import { QueryUtils, Utils } from "@budibase/frontend-core"
import { import {
getSchemaForDatasourcePlus, getSchemaForDatasourcePlus,
getEnvironmentBindings, getEnvironmentBindings,
@ -343,7 +343,7 @@
} }
function saveFilters(key) { function saveFilters(key) {
const filters = LuceneUtils.buildQuery(tempFilters) const filters = QueryUtils.buildQuery(tempFilters)
const defKey = `${key}-def` const defKey = `${key}-def`
onChange({ detail: filters }, key) onChange({ detail: filters }, key)
// need to store the builder definition in the automation // need to store the builder definition in the automation

View File

@ -8,7 +8,7 @@
} from "@budibase/bbui" } from "@budibase/bbui"
import download from "downloadjs" import download from "downloadjs"
import { API } from "api" import { API } from "api"
import { LuceneUtils } from "@budibase/frontend-core" import { QueryUtils } from "@budibase/frontend-core"
import { utils } from "@budibase/shared-core" import { utils } from "@budibase/shared-core"
import { ROW_EXPORT_FORMATS } from "constants/backend" import { ROW_EXPORT_FORMATS } from "constants/backend"
@ -49,7 +49,7 @@
exportFormat = Array.isArray(options) ? options[0]?.key : [] exportFormat = Array.isArray(options) ? options[0]?.key : []
} }
$: luceneFilter = LuceneUtils.buildQuery(appliedFilters) $: luceneFilter = QueryUtils.buildQuery(appliedFilters)
$: exportOpDisplay = buildExportOpDisplay( $: exportOpDisplay = buildExportOpDisplay(
sorting, sorting,
filterDisplay, filterDisplay,

View File

@ -12,7 +12,7 @@
import { dndzone } from "svelte-dnd-action" import { dndzone } from "svelte-dnd-action"
import { generate } from "shortid" import { generate } from "shortid"
import DrawerBindableInput from "components/common/bindings/DrawerBindableInput.svelte" import DrawerBindableInput from "components/common/bindings/DrawerBindableInput.svelte"
import { LuceneUtils, Constants } from "@budibase/frontend-core" import { QueryUtils, Constants } from "@budibase/frontend-core"
import { selectedComponent, componentStore } from "stores/builder" import { selectedComponent, componentStore } from "stores/builder"
import { getComponentForSetting } from "components/design/settings/componentSettings" import { getComponentForSetting } from "components/design/settings/componentSettings"
import PropertyControl from "components/design/settings/controls/PropertyControl.svelte" import PropertyControl from "components/design/settings/controls/PropertyControl.svelte"
@ -119,7 +119,7 @@
} }
const getOperatorOptions = condition => { const getOperatorOptions = condition => {
return LuceneUtils.getValidOperatorsForType({ type: condition.valueType }) return QueryUtils.getValidOperatorsForType({ type: condition.valueType })
} }
const onOperatorChange = (condition, newOperator) => { const onOperatorChange = (condition, newOperator) => {
@ -138,7 +138,7 @@
condition.referenceValue = null condition.referenceValue = null
// Ensure a valid operator is set // Ensure a valid operator is set
const validOperators = LuceneUtils.getValidOperatorsForType({ const validOperators = QueryUtils.getValidOperatorsForType({
type: newType, type: newType,
}).map(x => x.value) }).map(x => x.value)
if (!validOperators.includes(condition.operator)) { if (!validOperators.includes(condition.operator)) {

View File

@ -1,7 +1,7 @@
<script> <script>
import { getContext } from "svelte" import { getContext } from "svelte"
import { Pagination, ProgressCircle } from "@budibase/bbui" import { Pagination, ProgressCircle } from "@budibase/bbui"
import { fetchData, LuceneUtils } from "@budibase/frontend-core" import { fetchData, QueryUtils } from "@budibase/frontend-core"
export let dataSource export let dataSource
export let filter export let filter
@ -19,7 +19,7 @@
// We need to manage our lucene query manually as we want to allow components // We need to manage our lucene query manually as we want to allow components
// to extend it // to extend it
$: defaultQuery = LuceneUtils.buildQuery(filter) $: defaultQuery = QueryUtils.buildQuery(filter)
$: query = extendQuery(defaultQuery, queryExtensions) $: query = extendQuery(defaultQuery, queryExtensions)
$: fetch = createFetch(dataSource) $: fetch = createFetch(dataSource)
$: fetch.update({ $: fetch.update({

View File

@ -3,7 +3,7 @@
import { getContext, onDestroy } from "svelte" import { getContext, onDestroy } from "svelte"
import { ModalContent, Modal } from "@budibase/bbui" import { ModalContent, Modal } from "@budibase/bbui"
import FilterModal from "./FilterModal.svelte" import FilterModal from "./FilterModal.svelte"
import { LuceneUtils } from "@budibase/frontend-core" import { QueryUtils } from "@budibase/frontend-core"
import Button from "../Button.svelte" import Button from "../Button.svelte"
export let dataProvider export let dataProvider
@ -36,7 +36,7 @@
// Add query extension to data provider // Add query extension to data provider
$: { $: {
if (filters?.length) { if (filters?.length) {
const queryExtension = LuceneUtils.buildQuery(filters) const queryExtension = QueryUtils.buildQuery(filters)
addExtension?.($component.id, queryExtension) addExtension?.($component.id, queryExtension)
} else { } else {
removeExtension?.($component.id) removeExtension?.($component.id)

View File

@ -31,7 +31,7 @@ import { enrichButtonActions } from "./utils/buttonActions.js"
import { processStringSync, makePropSafe } from "@budibase/string-templates" import { processStringSync, makePropSafe } from "@budibase/string-templates"
import { import {
fetchData, fetchData,
LuceneUtils, QueryUtils,
Constants, Constants,
RowUtils, RowUtils,
memo, memo,
@ -65,7 +65,7 @@ export default {
getAction, getAction,
fetchDatasourceSchema, fetchDatasourceSchema,
fetchData, fetchData,
LuceneUtils, QueryUtils,
ContextScopes: Constants.ContextScopes, ContextScopes: Constants.ContextScopes,
getAPIKey, getAPIKey,
enrichButtonActions, enrichButtonActions,

View File

@ -1,4 +1,4 @@
import { LuceneUtils } from "@budibase/frontend-core" import { QueryUtils } from "@budibase/frontend-core"
export const getActiveConditions = conditions => { export const getActiveConditions = conditions => {
if (!conditions?.length) { if (!conditions?.length) {
@ -33,8 +33,8 @@ export const getActiveConditions = conditions => {
value: condition.referenceValue, value: condition.referenceValue,
} }
const query = LuceneUtils.buildQuery([luceneCondition]) const query = QueryUtils.buildQuery([luceneCondition])
const result = LuceneUtils.runQuery([luceneCondition], query) const result = QueryUtils.runQuery([luceneCondition], query)
return result.length > 0 return result.length > 0
}) })
} }

View File

@ -13,7 +13,7 @@
} from "@budibase/bbui" } from "@budibase/bbui"
import { FieldType, SearchFilterOperator } from "@budibase/types" import { FieldType, SearchFilterOperator } from "@budibase/types"
import { generate } from "shortid" import { generate } from "shortid"
import { LuceneUtils, Constants } from "@budibase/frontend-core" import { QueryUtils, Constants } from "@budibase/frontend-core"
import { getContext } from "svelte" import { getContext } from "svelte"
import FilterUsers from "./FilterUsers.svelte" import FilterUsers from "./FilterUsers.svelte"
import { getFields } from "../utils/searchFields" import { getFields } from "../utils/searchFields"
@ -112,7 +112,7 @@
return [] return []
} }
return LuceneUtils.getValidOperatorsForType( return QueryUtils.getValidOperatorsForType(
filter, filter,
filter.field || filter.name, filter.field || filter.name,
datasource datasource

View File

@ -1,9 +1,9 @@
import { writable, derived, get } from "svelte/store" import { writable, derived, get } from "svelte/store"
import { cloneDeep } from "lodash/fp" import { cloneDeep } from "lodash/fp"
import { LuceneUtils } from "../utils" import { QueryUtils } from "../utils"
import { convertJSONSchemaToTableSchema } from "../utils/json" import { convertJSONSchemaToTableSchema } from "../utils/json"
const { buildQuery, luceneLimit, runQuery, luceneSort } = LuceneUtils const { buildQuery, luceneLimit, runQuery, luceneSort } = QueryUtils
/** /**
* Parent class which handles the implementation of fetching data from an * Parent class which handles the implementation of fetching data from an

View File

@ -1,7 +1,7 @@
import { get } from "svelte/store" import { get } from "svelte/store"
import DataFetch from "./DataFetch.js" import DataFetch from "./DataFetch.js"
import { TableNames } from "../constants" import { TableNames } from "../constants"
import { LuceneUtils } from "../utils" import { QueryUtils } from "../utils"
export default class UserFetch extends DataFetch { export default class UserFetch extends DataFetch {
constructor(opts) { constructor(opts) {
@ -33,7 +33,7 @@ export default class UserFetch extends DataFetch {
let finalQuery let finalQuery
// convert old format to new one - we now allow use of the lucene format // convert old format to new one - we now allow use of the lucene format
const { appId, paginated, ...rest } = query const { appId, paginated, ...rest } = query
if (!LuceneUtils.hasFilters(query) && rest.email != null) { if (!QueryUtils.hasFilters(query) && rest.email != null) {
finalQuery = { string: { email: rest.email } } finalQuery = { string: { email: rest.email } }
} else { } else {
finalQuery = rest finalQuery = rest

View File

@ -1,4 +1,4 @@
export { dataFilters as LuceneUtils } from "@budibase/shared-core" export { dataFilters as QueryUtils } from "@budibase/shared-core"
export * as JSONUtils from "./json" export * as JSONUtils from "./json"
export * as CookieUtils from "./cookies" export * as CookieUtils from "./cookies"
export * as RoleUtils from "./roles" export * as RoleUtils from "./roles"