@budibase/shared-core 2.30.7 → 2.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/filters.d.ts CHANGED
@@ -17,6 +17,7 @@ export declare const getValidOperatorsForType: (fieldType: {
17
17
  * Operators which do not support empty strings as values
18
18
  */
19
19
  export declare const NoEmptyFilterStrings: (keyof SearchQueryFields)[];
20
+ export declare function recurseLogicalOperators(filters: SearchFilters, fn: (f: SearchFilters) => SearchFilters): SearchFilters;
20
21
  /**
21
22
  * Removes any fields that contain empty strings that would cause inconsistent
22
23
  * behaviour with how backend tables are filtered (no value means no filter).
package/dist/index.js CHANGED
@@ -10089,6 +10089,11 @@ var ArrayOperator = /* @__PURE__ */ ((ArrayOperator2) => {
10089
10089
  ArrayOperator2["ONE_OF"] = "oneOf";
10090
10090
  return ArrayOperator2;
10091
10091
  })(ArrayOperator || {});
10092
+ var LogicalOperator = /* @__PURE__ */ ((LogicalOperator2) => {
10093
+ LogicalOperator2["AND"] = "$and";
10094
+ LogicalOperator2["OR"] = "$or";
10095
+ return LogicalOperator2;
10096
+ })(LogicalOperator || {});
10092
10097
  function isLogicalSearchOperator(value) {
10093
10098
  return value === "$and" /* AND */ || value === "$or" /* OR */;
10094
10099
  }
@@ -10402,6 +10407,7 @@ __export(filters_exports, {
10402
10407
  getValidOperatorsForType: () => getValidOperatorsForType,
10403
10408
  hasFilters: () => hasFilters,
10404
10409
  limit: () => limit,
10410
+ recurseLogicalOperators: () => recurseLogicalOperators,
10405
10411
  removeKeyNumbering: () => removeKeyNumbering,
10406
10412
  runQuery: () => runQuery,
10407
10413
  search: () => search,
@@ -10631,6 +10637,16 @@ var NoEmptyFilterStrings = [
10631
10637
  OperatorOptions.ContainsAny.value,
10632
10638
  OperatorOptions.In.value
10633
10639
  ];
10640
+ function recurseLogicalOperators(filters, fn) {
10641
+ for (const logical of Object.values(LogicalOperator)) {
10642
+ if (filters[logical]) {
10643
+ filters[logical].conditions = filters[logical].conditions.map(
10644
+ (condition) => fn(condition)
10645
+ );
10646
+ }
10647
+ }
10648
+ return filters;
10649
+ }
10634
10650
  var cleanupQuery = (query) => {
10635
10651
  if (!query) {
10636
10652
  return query;
@@ -10653,6 +10669,7 @@ var cleanupQuery = (query) => {
10653
10669
  }
10654
10670
  }
10655
10671
  }
10672
+ query = recurseLogicalOperators(query, cleanupQuery);
10656
10673
  return query;
10657
10674
  };
10658
10675
  function isEmptyArray(value) {
@@ -10835,6 +10852,7 @@ function fixupFilterArrays(filters) {
10835
10852
  }
10836
10853
  }
10837
10854
  }
10855
+ recurseLogicalOperators(filters, fixupFilterArrays);
10838
10856
  return filters;
10839
10857
  }
10840
10858
  var search = (docs, query) => {