@budibase/shared-core 2.33.1 → 2.33.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.
@@ -3,3 +3,4 @@ export * from "./integrations";
3
3
  export * as cron from "./cron";
4
4
  export * as schema from "./schema";
5
5
  export * as views from "./views";
6
+ export * as roles from "./roles";
@@ -0,0 +1,2 @@
1
+ import { Role } from "@budibase/types";
2
+ export declare function checkForRoleInheritanceLoops(roles: Role[]): boolean;
package/dist/index.js CHANGED
@@ -8088,10 +8088,10 @@ var require_lodash = __commonJS({
8088
8088
  }();
8089
8089
  var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout, ctxNow = Date2 && Date2.now !== root.Date.now && Date2.now, ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
8090
8090
  var nativeCeil = Math2.ceil, nativeFloor = Math2.floor, nativeGetSymbols = Object2.getOwnPropertySymbols, nativeIsBuffer = Buffer2 ? Buffer2.isBuffer : undefined2, nativeIsFinite = context.isFinite, nativeJoin = arrayProto.join, nativeKeys = overArg(Object2.keys, Object2), nativeMax = Math2.max, nativeMin = Math2.min, nativeNow = Date2.now, nativeParseInt = context.parseInt, nativeRandom = Math2.random, nativeReverse = arrayProto.reverse;
8091
- var DataView = getNative(context, "DataView"), Map = getNative(context, "Map"), Promise2 = getNative(context, "Promise"), Set2 = getNative(context, "Set"), WeakMap = getNative(context, "WeakMap"), nativeCreate = getNative(Object2, "create");
8091
+ var DataView = getNative(context, "DataView"), Map2 = getNative(context, "Map"), Promise2 = getNative(context, "Promise"), Set2 = getNative(context, "Set"), WeakMap = getNative(context, "WeakMap"), nativeCreate = getNative(Object2, "create");
8092
8092
  var metaMap = WeakMap && new WeakMap();
8093
8093
  var realNames = {};
8094
- var dataViewCtorString = toSource(DataView), mapCtorString = toSource(Map), promiseCtorString = toSource(Promise2), setCtorString = toSource(Set2), weakMapCtorString = toSource(WeakMap);
8094
+ var dataViewCtorString = toSource(DataView), mapCtorString = toSource(Map2), promiseCtorString = toSource(Promise2), setCtorString = toSource(Set2), weakMapCtorString = toSource(WeakMap);
8095
8095
  var symbolProto = Symbol2 ? Symbol2.prototype : undefined2, symbolValueOf = symbolProto ? symbolProto.valueOf : undefined2, symbolToString = symbolProto ? symbolProto.toString : undefined2;
8096
8096
  function lodash(value) {
8097
8097
  if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
@@ -8336,7 +8336,7 @@ var require_lodash = __commonJS({
8336
8336
  this.size = 0;
8337
8337
  this.__data__ = {
8338
8338
  "hash": new Hash(),
8339
- "map": new (Map || ListCache)(),
8339
+ "map": new (Map2 || ListCache)(),
8340
8340
  "string": new Hash()
8341
8341
  };
8342
8342
  }
@@ -8401,7 +8401,7 @@ var require_lodash = __commonJS({
8401
8401
  var data = this.__data__;
8402
8402
  if (data instanceof ListCache) {
8403
8403
  var pairs = data.__data__;
8404
- if (!Map || pairs.length < LARGE_ARRAY_SIZE - 1) {
8404
+ if (!Map2 || pairs.length < LARGE_ARRAY_SIZE - 1) {
8405
8405
  pairs.push([key, value]);
8406
8406
  this.size = ++data.size;
8407
8407
  return this;
@@ -10145,7 +10145,7 @@ var require_lodash = __commonJS({
10145
10145
  return result2;
10146
10146
  };
10147
10147
  var getTag = baseGetTag;
10148
- if (DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag || Map && getTag(new Map()) != mapTag || Promise2 && getTag(Promise2.resolve()) != promiseTag || Set2 && getTag(new Set2()) != setTag || WeakMap && getTag(new WeakMap()) != weakMapTag) {
10148
+ if (DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag || Map2 && getTag(new Map2()) != mapTag || Promise2 && getTag(Promise2.resolve()) != promiseTag || Set2 && getTag(new Set2()) != setTag || WeakMap && getTag(new WeakMap()) != weakMapTag) {
10149
10149
  getTag = function(value) {
10150
10150
  var result2 = baseGetTag(value), Ctor = result2 == objectTag ? value.constructor : undefined2, ctorString = Ctor ? toSource(Ctor) : "";
10151
10151
  if (ctorString) {
@@ -17707,6 +17707,7 @@ __export(helpers_exports, {
17707
17707
  getUserLabel: () => getUserLabel,
17708
17708
  isGoogleSheets: () => isGoogleSheets,
17709
17709
  isSQL: () => isSQL,
17710
+ roles: () => roles_exports,
17710
17711
  schema: () => schema_exports,
17711
17712
  views: () => views_exports,
17712
17713
  withTimeout: () => withTimeout
@@ -17932,6 +17933,48 @@ function basicFields(view, opts) {
17932
17933
  });
17933
17934
  }
17934
17935
 
17936
+ // src/helpers/roles.ts
17937
+ var roles_exports = {};
17938
+ __export(roles_exports, {
17939
+ checkForRoleInheritanceLoops: () => checkForRoleInheritanceLoops
17940
+ });
17941
+ function prefixForCheck(id) {
17942
+ return `${"role" /* ROLE */}${SEPARATOR}${id}`;
17943
+ }
17944
+ function checkForRoleInheritanceLoops(roles) {
17945
+ const roleMap = /* @__PURE__ */ new Map();
17946
+ roles.forEach((role) => {
17947
+ roleMap.set(role._id, role);
17948
+ });
17949
+ const checked = /* @__PURE__ */ new Set();
17950
+ const checking = /* @__PURE__ */ new Set();
17951
+ function hasLoop(roleId) {
17952
+ const prefixed2 = prefixForCheck(roleId);
17953
+ if (checking.has(roleId) || checking.has(prefixed2)) {
17954
+ return true;
17955
+ }
17956
+ if (checked.has(roleId) || checked.has(prefixed2)) {
17957
+ return false;
17958
+ }
17959
+ checking.add(roleId);
17960
+ const role = roleMap.get(prefixed2) || roleMap.get(roleId);
17961
+ if (!role) {
17962
+ checking.delete(roleId);
17963
+ return false;
17964
+ }
17965
+ const inherits = Array.isArray(role.inherits) ? role.inherits : [role.inherits];
17966
+ for (const inheritedId of inherits) {
17967
+ if (inheritedId && hasLoop(inheritedId)) {
17968
+ return true;
17969
+ }
17970
+ }
17971
+ checking.delete(roleId);
17972
+ checked.add(roleId);
17973
+ return false;
17974
+ }
17975
+ return !!roles.find((role) => hasLoop(role._id));
17976
+ }
17977
+
17935
17978
  // src/filters.ts
17936
17979
  var import_lodash2 = __toESM(require_lodash());
17937
17980
  var HBS_REGEX = /{{([^{].*?)}}/g;
@@ -18842,6 +18885,7 @@ var allowDisplayColumnByType = {
18842
18885
  ["number" /* NUMBER */]: true,
18843
18886
  ["datetime" /* DATETIME */]: true,
18844
18887
  ["formula" /* FORMULA */]: true,
18888
+ ["ai" /* AI */]: true,
18845
18889
  ["auto" /* AUTO */]: true,
18846
18890
  ["internal" /* INTERNAL */]: true,
18847
18891
  ["barcodeqr" /* BARCODEQR */]: true,
@@ -18869,6 +18913,7 @@ var allowSortColumnByType = {
18869
18913
  ["boolean" /* BOOLEAN */]: true,
18870
18914
  ["json" /* JSON */]: true,
18871
18915
  ["formula" /* FORMULA */]: false,
18916
+ ["ai" /* AI */]: false,
18872
18917
  ["attachment" /* ATTACHMENTS */]: false,
18873
18918
  ["attachment_single" /* ATTACHMENT_SINGLE */]: false,
18874
18919
  ["signature_single" /* SIGNATURE_SINGLE */]: false,
@@ -18891,6 +18936,7 @@ var allowDefaultColumnByType = {
18891
18936
  ["bigint" /* BIGINT */]: false,
18892
18937
  ["boolean" /* BOOLEAN */]: false,
18893
18938
  ["formula" /* FORMULA */]: false,
18939
+ ["ai" /* AI */]: false,
18894
18940
  ["attachment" /* ATTACHMENTS */]: false,
18895
18941
  ["attachment_single" /* ATTACHMENT_SINGLE */]: false,
18896
18942
  ["signature_single" /* SIGNATURE_SINGLE */]: false,