@budibase/backend-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/index.js CHANGED
@@ -54853,6 +54853,16 @@ var deepGet = (obj, key) => {
54853
54853
  // ../shared-core/src/helpers/cron.ts
54854
54854
  var import_cron_validate = __toESM(require_lib2());
54855
54855
 
54856
+ // ../shared-core/src/helpers/schema.ts
54857
+ var schema_exports = {};
54858
+ __export(schema_exports, {
54859
+ isDeprecatedSingleUserColumn: () => isDeprecatedSingleUserColumn
54860
+ });
54861
+ function isDeprecatedSingleUserColumn(schema) {
54862
+ const result = schema.type === "bb_reference" /* BB_REFERENCE */ && schema.subtype === "user" /* USER */ && schema.constraints?.type !== "array";
54863
+ return result;
54864
+ }
54865
+
54856
54866
  // ../shared-core/src/filters.ts
54857
54867
  var HBS_REGEX = /{{([^{].*?)}}/g;
54858
54868
  var getValidOperatorsForType = (fieldType, field, datasource2) => {
@@ -54876,7 +54886,7 @@ var getValidOperatorsForType = (fieldType, field, datasource2) => {
54876
54886
  Op.In
54877
54887
  ];
54878
54888
  let ops = [];
54879
- const { type, subtype, formulaType } = fieldType;
54889
+ const { type, formulaType } = fieldType;
54880
54890
  if (type === "string" /* STRING */) {
54881
54891
  ops = stringOps;
54882
54892
  } else if (type === "number" /* NUMBER */ || type === "bigint" /* BIGINT */) {
@@ -54893,9 +54903,9 @@ var getValidOperatorsForType = (fieldType, field, datasource2) => {
54893
54903
  ops = numOps;
54894
54904
  } else if (type === "formula" /* FORMULA */ && formulaType === "static" /* STATIC */) {
54895
54905
  ops = stringOps.concat([Op.MoreThan, Op.LessThan]);
54896
- } else if (type === "bb_reference" /* BB_REFERENCE */ && subtype == "user" /* USER */) {
54906
+ } else if (type === "bb_reference_single" /* BB_REFERENCE_SINGLE */ || schema_exports.isDeprecatedSingleUserColumn(fieldType)) {
54897
54907
  ops = [Op.Equals, Op.NotEquals, Op.Empty, Op.NotEmpty, Op.In];
54898
- } else if (type === "bb_reference" /* BB_REFERENCE */ && subtype == "users" /* USERS */) {
54908
+ } else if (type === "bb_reference" /* BB_REFERENCE */) {
54899
54909
  ops = [Op.Contains, Op.NotContains, Op.ContainsAny, Op.Empty, Op.NotEmpty];
54900
54910
  }
54901
54911
  const externalTable = datasource2?.tableId?.includes("datasource_plus");
@@ -55415,7 +55425,8 @@ var allowDisplayColumnByType = {
55415
55425
  ["attachment_single" /* ATTACHMENT_SINGLE */]: false,
55416
55426
  ["link" /* LINK */]: false,
55417
55427
  ["json" /* JSON */]: false,
55418
- ["bb_reference" /* BB_REFERENCE */]: false
55428
+ ["bb_reference" /* BB_REFERENCE */]: false,
55429
+ ["bb_reference_single" /* BB_REFERENCE_SINGLE */]: false
55419
55430
  };
55420
55431
  var allowSortColumnByType = {
55421
55432
  ["string" /* STRING */]: true,
@@ -55434,7 +55445,8 @@ var allowSortColumnByType = {
55434
55445
  ["attachment_single" /* ATTACHMENT_SINGLE */]: false,
55435
55446
  ["array" /* ARRAY */]: false,
55436
55447
  ["link" /* LINK */]: false,
55437
- ["bb_reference" /* BB_REFERENCE */]: false
55448
+ ["bb_reference" /* BB_REFERENCE */]: false,
55449
+ ["bb_reference_single" /* BB_REFERENCE_SINGLE */]: false
55438
55450
  };
55439
55451
 
55440
55452
  // src/constants/misc.ts
@@ -65942,16 +65954,19 @@ function authenticated_default(noAuthPatterns = [], opts = {
65942
65954
  if (!authenticated) {
65943
65955
  authenticated = false;
65944
65956
  }
65945
- if (user) {
65957
+ const isUser = (user2) => {
65958
+ return user2 && user2.email;
65959
+ };
65960
+ if (isUser(user)) {
65946
65961
  import_dd_trace3.default.setUser({
65947
- id: user?._id,
65948
- tenantId: user?.tenantId,
65949
- budibaseAccess: user?.budibaseAccess,
65950
- status: user?.status
65962
+ id: user._id,
65963
+ tenantId: user.tenantId,
65964
+ budibaseAccess: user.budibaseAccess,
65965
+ status: user.status
65951
65966
  });
65952
65967
  }
65953
65968
  finalise(ctx, { authenticated, user, internal, version, publicEndpoint });
65954
- if (user && user.email) {
65969
+ if (isUser(user)) {
65955
65970
  return doInUserContext(user, ctx, next);
65956
65971
  } else {
65957
65972
  return next();