@budibase/shared-core 2.25.0 → 2.26.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
@@ -1,4 +1,4 @@
1
- import { Datasource, BBReferenceFieldSubType, FieldType, FormulaType, SearchFilter, SearchFilters, SearchFilterOperator, SortDirection, SortType } from "@budibase/types";
1
+ import { Datasource, BBReferenceFieldSubType, FieldType, FormulaType, SearchFilter, SearchFilters, SearchFilterOperator, SortDirection, SortType, FieldConstraints } from "@budibase/types";
2
2
  /**
3
3
  * Returns the valid operator options for a certain data type
4
4
  */
@@ -6,7 +6,8 @@ export declare const getValidOperatorsForType: (fieldType: {
6
6
  type: FieldType;
7
7
  subtype?: BBReferenceFieldSubType;
8
8
  formulaType?: FormulaType;
9
- }, field: string, datasource: Datasource & {
9
+ constraints?: FieldConstraints;
10
+ }, field?: string, datasource?: Datasource & {
10
11
  tableId: any;
11
12
  }) => {
12
13
  value: string;
@@ -1,3 +1,4 @@
1
1
  export * from "./helpers";
2
2
  export * from "./integrations";
3
3
  export * as cron from "./cron";
4
+ export * as schema from "./schema";
@@ -0,0 +1,2 @@
1
+ import { FieldSchema } from "@budibase/types";
2
+ export declare function isDeprecatedSingleUserColumn(schema: Pick<FieldSchema, "type" | "subtype" | "constraints">): boolean;
package/dist/index.js CHANGED
@@ -4893,7 +4893,8 @@ __export(helpers_exports, {
4893
4893
  getUserInitials: () => getUserInitials,
4894
4894
  getUserLabel: () => getUserLabel,
4895
4895
  isGoogleSheets: () => isGoogleSheets,
4896
- isSQL: () => isSQL
4896
+ isSQL: () => isSQL,
4897
+ schema: () => schema_exports
4897
4898
  });
4898
4899
 
4899
4900
  // src/helpers/helpers.ts
@@ -5015,6 +5016,16 @@ function validate(cronExpression) {
5015
5016
  }
5016
5017
  }
5017
5018
 
5019
+ // src/helpers/schema.ts
5020
+ var schema_exports = {};
5021
+ __export(schema_exports, {
5022
+ isDeprecatedSingleUserColumn: () => isDeprecatedSingleUserColumn
5023
+ });
5024
+ function isDeprecatedSingleUserColumn(schema) {
5025
+ const result = schema.type === "bb_reference" /* BB_REFERENCE */ && schema.subtype === "user" /* USER */ && schema.constraints?.type !== "array";
5026
+ return result;
5027
+ }
5028
+
5018
5029
  // src/filters.ts
5019
5030
  var HBS_REGEX = /{{([^{].*?)}}/g;
5020
5031
  var getValidOperatorsForType = (fieldType, field, datasource) => {
@@ -5038,7 +5049,7 @@ var getValidOperatorsForType = (fieldType, field, datasource) => {
5038
5049
  Op.In
5039
5050
  ];
5040
5051
  let ops = [];
5041
- const { type, subtype, formulaType } = fieldType;
5052
+ const { type, formulaType } = fieldType;
5042
5053
  if (type === "string" /* STRING */) {
5043
5054
  ops = stringOps;
5044
5055
  } else if (type === "number" /* NUMBER */ || type === "bigint" /* BIGINT */) {
@@ -5055,9 +5066,9 @@ var getValidOperatorsForType = (fieldType, field, datasource) => {
5055
5066
  ops = numOps;
5056
5067
  } else if (type === "formula" /* FORMULA */ && formulaType === "static" /* STATIC */) {
5057
5068
  ops = stringOps.concat([Op.MoreThan, Op.LessThan]);
5058
- } else if (type === "bb_reference" /* BB_REFERENCE */ && subtype == "user" /* USER */) {
5069
+ } else if (type === "bb_reference_single" /* BB_REFERENCE_SINGLE */ || schema_exports.isDeprecatedSingleUserColumn(fieldType)) {
5059
5070
  ops = [Op.Equals, Op.NotEquals, Op.Empty, Op.NotEmpty, Op.In];
5060
- } else if (type === "bb_reference" /* BB_REFERENCE */ && subtype == "users" /* USERS */) {
5071
+ } else if (type === "bb_reference" /* BB_REFERENCE */) {
5061
5072
  ops = [Op.Contains, Op.NotContains, Op.ContainsAny, Op.Empty, Op.NotEmpty];
5062
5073
  }
5063
5074
  const externalTable = datasource?.tableId?.includes("datasource_plus");
@@ -5577,7 +5588,8 @@ var allowDisplayColumnByType = {
5577
5588
  ["attachment_single" /* ATTACHMENT_SINGLE */]: false,
5578
5589
  ["link" /* LINK */]: false,
5579
5590
  ["json" /* JSON */]: false,
5580
- ["bb_reference" /* BB_REFERENCE */]: false
5591
+ ["bb_reference" /* BB_REFERENCE */]: false,
5592
+ ["bb_reference_single" /* BB_REFERENCE_SINGLE */]: false
5581
5593
  };
5582
5594
  var allowSortColumnByType = {
5583
5595
  ["string" /* STRING */]: true,
@@ -5596,7 +5608,8 @@ var allowSortColumnByType = {
5596
5608
  ["attachment_single" /* ATTACHMENT_SINGLE */]: false,
5597
5609
  ["array" /* ARRAY */]: false,
5598
5610
  ["link" /* LINK */]: false,
5599
- ["bb_reference" /* BB_REFERENCE */]: false
5611
+ ["bb_reference" /* BB_REFERENCE */]: false,
5612
+ ["bb_reference_single" /* BB_REFERENCE_SINGLE */]: false
5600
5613
  };
5601
5614
  function canBeDisplayColumn(type) {
5602
5615
  return !!allowDisplayColumnByType[type];