@budibase/backend-core 2.9.29 → 2.9.30-alpha.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/index.js CHANGED
@@ -1427,6 +1427,13 @@ var init_pagination = __esm({
1427
1427
  }
1428
1428
  });
1429
1429
 
1430
+ // ../types/src/api/web/searchFilter.ts
1431
+ var init_searchFilter = __esm({
1432
+ "../types/src/api/web/searchFilter.ts"() {
1433
+ "use strict";
1434
+ }
1435
+ });
1436
+
1430
1437
  // ../types/src/api/web/index.ts
1431
1438
  var init_web = __esm({
1432
1439
  "../types/src/api/web/index.ts"() {
@@ -1441,6 +1448,7 @@ var init_web = __esm({
1441
1448
  init_app4();
1442
1449
  init_global2();
1443
1450
  init_pagination();
1451
+ init_searchFilter();
1444
1452
  }
1445
1453
  });
1446
1454
 
@@ -4071,6 +4079,7 @@ var init_lucene = __esm({
4071
4079
  "use strict";
4072
4080
  import_node_fetch2 = __toESM(require("node-fetch"));
4073
4081
  init_couch();
4082
+ init_src();
4074
4083
  QUERY_START_REGEX = /\d[0-9]*:/g;
4075
4084
  _QueryBuilder = class _QueryBuilder {
4076
4085
  constructor(dbName, index2, base) {
@@ -4098,6 +4107,7 @@ var init_lucene = __esm({
4098
4107
  __privateSet(this, _index, index2);
4099
4108
  __privateSet(this, _query, {
4100
4109
  allOr: false,
4110
+ onEmptyFilter: "all" /* RETURN_ALL */,
4101
4111
  string: {},
4102
4112
  fuzzy: {},
4103
4113
  range: {},
@@ -4226,6 +4236,9 @@ var init_lucene = __esm({
4226
4236
  setAllOr() {
4227
4237
  __privateGet(this, _query).allOr = true;
4228
4238
  }
4239
+ setOnEmptyFilter(value) {
4240
+ __privateGet(this, _query).onEmptyFilter = value;
4241
+ }
4229
4242
  handleSpaces(input) {
4230
4243
  if (__privateGet(this, _noEscaping)) {
4231
4244
  return input;
@@ -4283,11 +4296,13 @@ var init_lucene = __esm({
4283
4296
  return final;
4284
4297
  }
4285
4298
  buildSearchQuery() {
4299
+ var _a;
4286
4300
  const builder = this;
4287
4301
  let allOr = __privateGet(this, _query) && __privateGet(this, _query).allOr;
4288
4302
  let query = allOr ? "" : "*:*";
4303
+ let allFiltersEmpty = true;
4289
4304
  const allPreProcessingOpts = { escape: true, lowercase: true, wrap: true };
4290
- let tableId;
4305
+ let tableId = "";
4291
4306
  if (__privateGet(this, _query).equal.tableId) {
4292
4307
  tableId = __privateGet(this, _query).equal.tableId;
4293
4308
  delete __privateGet(this, _query).equal.tableId;
@@ -4299,7 +4314,7 @@ var init_lucene = __esm({
4299
4314
  return `${key}:${builder.preprocess(value, allPreProcessingOpts)}`;
4300
4315
  };
4301
4316
  const contains = (key, value, mode = "AND") => {
4302
- if (Array.isArray(value) && value.length === 0) {
4317
+ if (!value || Array.isArray(value) && value.length === 0) {
4303
4318
  return null;
4304
4319
  }
4305
4320
  if (!Array.isArray(value)) {
@@ -4368,6 +4383,9 @@ var init_lucene = __esm({
4368
4383
  built += ` ${mode} `;
4369
4384
  }
4370
4385
  built += expression;
4386
+ if (typeof value !== "string" && value != null || typeof value === "string" && value !== tableId && value !== "") {
4387
+ allFiltersEmpty = false;
4388
+ }
4371
4389
  }
4372
4390
  if (opts == null ? void 0 : opts.returnBuilt) {
4373
4391
  return built;
@@ -4444,6 +4462,13 @@ var init_lucene = __esm({
4444
4462
  allOr = false;
4445
4463
  build({ tableId }, equal);
4446
4464
  }
4465
+ if (allFiltersEmpty) {
4466
+ if (__privateGet(this, _query).onEmptyFilter === "none" /* RETURN_NONE */) {
4467
+ return "";
4468
+ } else if ((_a = __privateGet(this, _query)) == null ? void 0 : _a.allOr) {
4469
+ return query.replace("()", "(*:*)");
4470
+ }
4471
+ }
4447
4472
  return query;
4448
4473
  }
4449
4474
  buildSearchBody() {