@budibase/shared-core 2.29.30 → 2.30.1

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.
@@ -113,6 +113,7 @@ export declare enum BpmStatusValue {
113
113
  STARTED = "started",
114
114
  COMPLETING_ACCOUNT_INFO = "completing_account_info",
115
115
  VERIFYING_EMAIL = "verifying_email",
116
- COMPLETED = "completed"
116
+ COMPLETED = "completed",
117
+ FAILED = "failed"
117
118
  }
118
119
  export declare const DEFAULT_BB_DATASOURCE_ID = "datasource_internal_bb_default";
package/dist/index.js CHANGED
@@ -10088,6 +10088,9 @@ var ArrayOperator = /* @__PURE__ */ ((ArrayOperator2) => {
10088
10088
  ArrayOperator2["ONE_OF"] = "oneOf";
10089
10089
  return ArrayOperator2;
10090
10090
  })(ArrayOperator || {});
10091
+ function isLogicalSearchOperator(value) {
10092
+ return value === "$and" /* AND */ || value === "$or" /* OR */;
10093
+ }
10091
10094
 
10092
10095
  // ../types/src/sdk/cli/constants.ts
10093
10096
  var AnalyticsEvent = {
@@ -10380,6 +10383,7 @@ var BpmStatusValue = /* @__PURE__ */ ((BpmStatusValue2) => {
10380
10383
  BpmStatusValue2["COMPLETING_ACCOUNT_INFO"] = "completing_account_info";
10381
10384
  BpmStatusValue2["VERIFYING_EMAIL"] = "verifying_email";
10382
10385
  BpmStatusValue2["COMPLETED"] = "completed";
10386
+ BpmStatusValue2["FAILED"] = "failed";
10383
10387
  return BpmStatusValue2;
10384
10388
  })(BpmStatusValue || {});
10385
10389
  var DEFAULT_BB_DATASOURCE_ID = "datasource_internal_bb_default";
@@ -10790,6 +10794,7 @@ var buildQuery = (filter) => {
10790
10794
  high: value
10791
10795
  };
10792
10796
  }
10797
+ } else if (isLogicalSearchOperator(queryOperator)) {
10793
10798
  } else if (query[queryOperator] && operator !== "onEmptyFilter") {
10794
10799
  if (type === "boolean") {
10795
10800
  if (queryOperator === "equal" && value === false) {
@@ -10859,14 +10864,15 @@ var runQuery = (docs, query) => {
10859
10864
  }
10860
10865
  const match = (type, test) => (doc) => {
10861
10866
  for (const [key, testValue] of Object.entries(query[type] || {})) {
10862
- const result = test(deepGet(doc, removeKeyNumbering(key)), testValue);
10867
+ const valueToCheck = isLogicalSearchOperator(type) ? doc : deepGet(doc, removeKeyNumbering(key));
10868
+ const result = test(valueToCheck, testValue);
10863
10869
  if (query.allOr && result) {
10864
10870
  return true;
10865
10871
  } else if (!query.allOr && !result) {
10866
10872
  return false;
10867
10873
  }
10868
10874
  }
10869
- return true;
10875
+ return !query.allOr;
10870
10876
  };
10871
10877
  const stringMatch = match(
10872
10878
  "string" /* STRING */,
@@ -11021,6 +11027,39 @@ var runQuery = (docs, query) => {
11021
11027
  }
11022
11028
  );
11023
11029
  const containsAny = match("containsAny" /* CONTAINS_ANY */, _contains("some"));
11030
+ const and = match(
11031
+ "$and" /* AND */,
11032
+ (docValue, conditions) => {
11033
+ if (!conditions.length) {
11034
+ return false;
11035
+ }
11036
+ for (const condition of conditions) {
11037
+ const matchesCondition = runQuery([docValue], condition);
11038
+ if (!matchesCondition.length) {
11039
+ return false;
11040
+ }
11041
+ }
11042
+ return true;
11043
+ }
11044
+ );
11045
+ const or = match(
11046
+ "$or" /* OR */,
11047
+ (docValue, conditions) => {
11048
+ if (!conditions.length) {
11049
+ return false;
11050
+ }
11051
+ for (const condition of conditions) {
11052
+ const matchesCondition = runQuery([docValue], {
11053
+ ...condition,
11054
+ allOr: true
11055
+ });
11056
+ if (matchesCondition.length) {
11057
+ return true;
11058
+ }
11059
+ }
11060
+ return false;
11061
+ }
11062
+ );
11024
11063
  const docMatch = (doc) => {
11025
11064
  const filterFunctions = {
11026
11065
  string: stringMatch,
@@ -11033,7 +11072,9 @@ var runQuery = (docs, query) => {
11033
11072
  oneOf,
11034
11073
  contains,
11035
11074
  containsAny,
11036
- notContains
11075
+ notContains,
11076
+ ["$and" /* AND */]: and,
11077
+ ["$or" /* OR */]: or
11037
11078
  };
11038
11079
  const results = Object.entries(query || {}).filter(
11039
11080
  ([key, value]) => !["allOr", "onEmptyFilter"].includes(key) && value && Object.keys(value).length > 0