@budibase/server 2.6.19-alpha.40 → 2.6.19-alpha.42

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.
@@ -1795,7 +1795,6 @@ var init_environment3 = __esm({
1795
1795
  REDIS_URL: process.env.REDIS_URL || "localhost:6379",
1796
1796
  REDIS_PASSWORD: process.env.REDIS_PASSWORD,
1797
1797
  REDIS_CLUSTERED: process.env.REDIS_CLUSTERED,
1798
- MOCK_REDIS: process.env.MOCK_REDIS,
1799
1798
  MINIO_ACCESS_KEY: process.env.MINIO_ACCESS_KEY,
1800
1799
  MINIO_SECRET_KEY: process.env.MINIO_SECRET_KEY,
1801
1800
  AWS_REGION: process.env.AWS_REGION,
@@ -1822,6 +1821,7 @@ var init_environment3 = __esm({
1822
1821
  GLOBAL_BUCKET_NAME: process.env.GLOBAL_BUCKET_NAME || DefaultBucketName.GLOBAL,
1823
1822
  PLUGIN_BUCKET_NAME: process.env.PLUGIN_BUCKET_NAME || DefaultBucketName.PLUGINS,
1824
1823
  USE_COUCH: process.env.USE_COUCH || true,
1824
+ MOCK_REDIS: process.env.MOCK_REDIS,
1825
1825
  DEFAULT_LICENSE: process.env.DEFAULT_LICENSE,
1826
1826
  SERVICE: process.env.SERVICE || "budibase",
1827
1827
  LOG_LEVEL: process.env.LOG_LEVEL || "info",
@@ -2697,7 +2697,7 @@ function getRedisOptions() {
2697
2697
  opts.port = port;
2698
2698
  opts.password = password;
2699
2699
  }
2700
- return { opts, host, port, redisProtocolUrl };
2700
+ return { opts, host, port: parseInt(port), redisProtocolUrl };
2701
2701
  }
2702
2702
  function addDbPrefix(db2, key) {
2703
2703
  if (key.includes(db2)) {
@@ -2806,6 +2806,7 @@ function connectionError(selectDb, timeout2, err) {
2806
2806
  }, RETRY_PERIOD_MS);
2807
2807
  }
2808
2808
  function init2(selectDb = DEFAULT_SELECT_DB) {
2809
+ const RedisCore = environment_default2.MOCK_REDIS ? MockRedis : import_ioredis.default;
2809
2810
  let timeout2;
2810
2811
  CLOSED = false;
2811
2812
  let client3 = pickClient(selectDb);
@@ -2813,7 +2814,7 @@ function init2(selectDb = DEFAULT_SELECT_DB) {
2813
2814
  return;
2814
2815
  }
2815
2816
  if (environment_default2.MOCK_REDIS) {
2816
- CLIENTS[selectDb] = new Redis(getRedisOptions());
2817
+ CLIENTS[selectDb] = new RedisCore(getRedisOptions());
2817
2818
  }
2818
2819
  timeout2 = setTimeout(() => {
2819
2820
  if (!CONNECTED) {
@@ -2829,11 +2830,11 @@ function init2(selectDb = DEFAULT_SELECT_DB) {
2829
2830
  }
2830
2831
  const { redisProtocolUrl, opts, host, port } = getRedisOptions();
2831
2832
  if (CLUSTERED) {
2832
- client3 = new Redis.Cluster([{ host, port }], opts);
2833
+ client3 = new RedisCore.Cluster([{ host, port }], opts);
2833
2834
  } else if (redisProtocolUrl) {
2834
- client3 = new Redis(redisProtocolUrl);
2835
+ client3 = new RedisCore(redisProtocolUrl);
2835
2836
  } else {
2836
- client3 = new Redis(opts);
2837
+ client3 = new RedisCore(opts);
2837
2838
  }
2838
2839
  client3.on("end", (err) => {
2839
2840
  if (environment_default2.isTest()) {
@@ -2897,13 +2898,14 @@ function promisifyStream(stream3, client3) {
2897
2898
  });
2898
2899
  });
2899
2900
  }
2900
- var Redis, RETRY_PERIOD_MS, STARTUP_TIMEOUT_MS, CLUSTERED, DEFAULT_SELECT_DB, CLOSED, CLIENTS, CONNECTED, RedisWrapper, redis_default;
2901
+ var import_ioredis, MockRedis, RETRY_PERIOD_MS, STARTUP_TIMEOUT_MS, CLUSTERED, DEFAULT_SELECT_DB, CLOSED, CLIENTS, CONNECTED, RedisWrapper, redis_default;
2901
2902
  var init_redis = __esm({
2902
2903
  "../backend-core/src/redis/redis.ts"() {
2903
2904
  init_environment3();
2905
+ import_ioredis = __toESM(require("ioredis"));
2904
2906
  init_utils2();
2905
2907
  init_timers2();
2906
- Redis = environment_default2.MOCK_REDIS ? require("ioredis-mock") : require("ioredis");
2908
+ MockRedis = require("ioredis-mock");
2907
2909
  RETRY_PERIOD_MS = 2e3;
2908
2910
  STARTUP_TIMEOUT_MS = 5e3;
2909
2911
  CLUSTERED = environment_default2.REDIS_CLUSTERED;
@@ -11524,6 +11526,7 @@ var init_src2 = __esm({
11524
11526
  init_cache();
11525
11527
  init_objectStore2();
11526
11528
  init_redis2();
11529
+ init_redis2();
11527
11530
  init_redlockImpl();
11528
11531
  init_utils5();
11529
11532
  init_errors3();
@@ -13962,6 +13965,7 @@ var init_users7 = __esm({
13962
13965
 
13963
13966
  // ../pro/packages/pro/src/utilities/delay.ts
13964
13967
  async function backOff(fn2, errMsg) {
13968
+ let error;
13965
13969
  let attempts = 5, success = false, response2, first = true;
13966
13970
  for (; attempts > 0; attempts--) {
13967
13971
  try {
@@ -13973,10 +13977,11 @@ async function backOff(fn2, errMsg) {
13973
13977
  success = true;
13974
13978
  break;
13975
13979
  } catch (err) {
13980
+ error = err;
13976
13981
  }
13977
13982
  }
13978
13983
  if (!success) {
13979
- logging_exports.logAlert(`Failed to backoff`, errMsg);
13984
+ logging_exports.logAlert(`Failed to backoff: ${errMsg}`, error);
13980
13985
  }
13981
13986
  return response2;
13982
13987
  }
@@ -24388,11 +24393,11 @@ var init_firebase = __esm({
24388
24393
  });
24389
24394
 
24390
24395
  // src/integrations/redis.ts
24391
- var import_ioredis, SCHEMA14, RedisIntegration, redis_default2;
24396
+ var import_ioredis2, SCHEMA14, RedisIntegration, redis_default2;
24392
24397
  var init_redis4 = __esm({
24393
24398
  "src/integrations/redis.ts"() {
24394
24399
  init_src();
24395
- import_ioredis = __toESM(require("ioredis"));
24400
+ import_ioredis2 = __toESM(require("ioredis"));
24396
24401
  SCHEMA14 = {
24397
24402
  docs: "https://redis.io/docs/",
24398
24403
  description: "Redis is a caching tool, providing powerful key-value store capabilities.",
@@ -24473,7 +24478,7 @@ var init_redis4 = __esm({
24473
24478
  RedisIntegration = class {
24474
24479
  constructor(config) {
24475
24480
  this.config = config;
24476
- this.client = new import_ioredis.default({
24481
+ this.client = new import_ioredis2.default({
24477
24482
  host: this.config.host,
24478
24483
  port: this.config.port,
24479
24484
  username: this.config.username,
@@ -24537,7 +24542,13 @@ var init_redis4 = __esm({
24537
24542
  }
24538
24543
  const pipeline = this.client.pipeline(pipelineCommands);
24539
24544
  const result = await pipeline.exec();
24540
- return result.map((output) => output[1]);
24545
+ return result == null ? void 0 : result.map((output) => {
24546
+ if (typeof output === "string") {
24547
+ return output;
24548
+ } else if (Array.isArray(output)) {
24549
+ return output[1];
24550
+ }
24551
+ });
24541
24552
  });
24542
24553
  }
24543
24554
  };
@@ -25988,6 +25999,7 @@ var init_redis5 = __esm({
25988
25999
  "src/utilities/redis.ts"() {
25989
26000
  init_src2();
25990
26001
  init_utils13();
26002
+ init_environment();
25991
26003
  }
25992
26004
  });
25993
26005
 
@@ -26359,6 +26371,7 @@ var init_websockets = __esm({
26359
26371
  init_client2();
26360
26372
  init_grid();
26361
26373
  init_builder2();
26374
+ init_environment();
26362
26375
  }
26363
26376
  });
26364
26377
 
@@ -26387,14 +26400,14 @@ async function fetch16(type) {
26387
26400
  }
26388
26401
  }
26389
26402
  async function processUploaded(plugin, source) {
26390
- var _a;
26403
+ var _a, _b;
26391
26404
  const { metadata, directory } = await fileUpload(plugin);
26392
26405
  plugin_exports.validate(metadata == null ? void 0 : metadata.schema);
26393
26406
  if (!environment_default.SELF_HOSTED && ((_a = metadata == null ? void 0 : metadata.schema) == null ? void 0 : _a.type) !== "component" /* COMPONENT */) {
26394
26407
  throw new Error("Only component plugins are supported outside of self-host");
26395
26408
  }
26396
26409
  const doc = await sdk_exports.plugins.storePlugin(metadata, directory, source);
26397
- clientAppSocket.emit("plugin-update", { name: doc.name, hash: doc.hash });
26410
+ (_b = clientAppSocket) == null ? void 0 : _b.emit("plugin-update", { name: doc.name, hash: doc.hash });
26398
26411
  return doc;
26399
26412
  }
26400
26413
  var init_plugins4 = __esm({
@@ -32040,10 +32053,17 @@ function getLoopIterations(loopStep) {
32040
32053
  if (!binding) {
32041
32054
  return 0;
32042
32055
  }
32056
+ const isString = typeof binding === "string";
32057
+ try {
32058
+ if (isString) {
32059
+ binding = JSON.parse(binding);
32060
+ }
32061
+ } catch (err) {
32062
+ }
32043
32063
  if (Array.isArray(binding)) {
32044
32064
  return binding.length;
32045
32065
  }
32046
- if (typeof binding === "string") {
32066
+ if (isString) {
32047
32067
  return stringSplit(binding).length;
32048
32068
  }
32049
32069
  return 0;