@budibase/shared-core 2.30.2 → 2.30.3

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
@@ -69,8 +69,11 @@ export declare const search: (docs: Record<string, any>[], query: RowSearchParam
69
69
  * Performs a client-side search on an array of data
70
70
  * @param docs the data
71
71
  * @param query the JSON query
72
+ * @param findInDoc optional fn when trying to extract a value
73
+ * from custom doc type e.g. Google Sheets
74
+ *
72
75
  */
73
- export declare const runQuery: (docs: Record<string, any>[], query: SearchFilters) => Record<string, any>[];
76
+ export declare const runQuery: (docs: Record<string, any>[], query: SearchFilters, findInDoc?: Function) => Record<string, any>[];
74
77
  /**
75
78
  * Performs a client-side sort from the equivalent server-side lucene sort
76
79
  * parameters.
package/dist/index.js CHANGED
@@ -10030,6 +10030,7 @@ __export(src_exports, {
10030
10030
  ValidSnippetNameRegex: () => ValidSnippetNameRegex,
10031
10031
  canBeDisplayColumn: () => canBeDisplayColumn,
10032
10032
  canBeSortColumn: () => canBeSortColumn,
10033
+ canHaveDefaultColumn: () => canHaveDefaultColumn,
10033
10034
  dataFilters: () => filters_exports,
10034
10035
  findDuplicateInternalColumns: () => findDuplicateInternalColumns,
10035
10036
  helpers: () => helpers_exports,
@@ -10850,7 +10851,7 @@ var search = (docs, query) => {
10850
10851
  }
10851
10852
  return response;
10852
10853
  };
10853
- var runQuery = (docs, query) => {
10854
+ var runQuery = (docs, query, findInDoc = deepGet) => {
10854
10855
  if (!docs || !Array.isArray(docs)) {
10855
10856
  return [];
10856
10857
  }
@@ -10864,7 +10865,7 @@ var runQuery = (docs, query) => {
10864
10865
  }
10865
10866
  const match = (type, test) => (doc) => {
10866
10867
  for (const [key, testValue] of Object.entries(query[type] || {})) {
10867
- const valueToCheck = isLogicalSearchOperator(type) ? doc : deepGet(doc, removeKeyNumbering(key));
10868
+ const valueToCheck = isLogicalSearchOperator(type) ? doc : findInDoc(doc, removeKeyNumbering(key));
10868
10869
  const result = test(valueToCheck, testValue);
10869
10870
  if (query.allOr && result) {
10870
10871
  return true;
@@ -11403,12 +11404,36 @@ var allowSortColumnByType = {
11403
11404
  ["bb_reference" /* BB_REFERENCE */]: false,
11404
11405
  ["bb_reference_single" /* BB_REFERENCE_SINGLE */]: false
11405
11406
  };
11407
+ var allowDefaultColumnByType = {
11408
+ ["number" /* NUMBER */]: true,
11409
+ ["json" /* JSON */]: true,
11410
+ ["datetime" /* DATETIME */]: true,
11411
+ ["longform" /* LONGFORM */]: true,
11412
+ ["string" /* STRING */]: true,
11413
+ ["options" /* OPTIONS */]: false,
11414
+ ["auto" /* AUTO */]: false,
11415
+ ["internal" /* INTERNAL */]: false,
11416
+ ["barcodeqr" /* BARCODEQR */]: false,
11417
+ ["bigint" /* BIGINT */]: false,
11418
+ ["boolean" /* BOOLEAN */]: false,
11419
+ ["formula" /* FORMULA */]: false,
11420
+ ["attachment" /* ATTACHMENTS */]: false,
11421
+ ["attachment_single" /* ATTACHMENT_SINGLE */]: false,
11422
+ ["signature_single" /* SIGNATURE_SINGLE */]: false,
11423
+ ["array" /* ARRAY */]: false,
11424
+ ["link" /* LINK */]: false,
11425
+ ["bb_reference" /* BB_REFERENCE */]: false,
11426
+ ["bb_reference_single" /* BB_REFERENCE_SINGLE */]: false
11427
+ };
11406
11428
  function canBeDisplayColumn(type) {
11407
11429
  return !!allowDisplayColumnByType[type];
11408
11430
  }
11409
11431
  function canBeSortColumn(type) {
11410
11432
  return !!allowSortColumnByType[type];
11411
11433
  }
11434
+ function canHaveDefaultColumn(type) {
11435
+ return !!allowDefaultColumnByType[type];
11436
+ }
11412
11437
  function findDuplicateInternalColumns(table) {
11413
11438
  const casedKeys = Object.keys(table.schema);
11414
11439
  const uncasedKeys = casedKeys.map((colName) => colName.toLowerCase());
@@ -11453,6 +11478,7 @@ function findDuplicateInternalColumns(table) {
11453
11478
  ValidSnippetNameRegex,
11454
11479
  canBeDisplayColumn,
11455
11480
  canBeSortColumn,
11481
+ canHaveDefaultColumn,
11456
11482
  dataFilters,
11457
11483
  findDuplicateInternalColumns,
11458
11484
  helpers,