@budibase/backend-core 2.13.0 → 2.13.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/index.js +93 -25
- package/dist/index.js.map +4 -4
- package/dist/index.js.meta.json +1 -1
- package/dist/package.json +4 -4
- package/dist/plugins.js.meta.json +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/queue/inMemoryQueue.d.ts +1 -1
- package/dist/src/queue/inMemoryQueue.js +1 -1
- package/dist/src/queue/inMemoryQueue.js.map +1 -1
- package/dist/src/queue/queue.js +16 -3
- package/dist/src/queue/queue.js.map +1 -1
- package/dist/src/redis/redis.js +2 -4
- package/dist/src/redis/redis.js.map +1 -1
- package/dist/src/redis/utils.d.ts +5 -4
- package/dist/src/redis/utils.js +24 -20
- package/dist/src/redis/utils.js.map +1 -1
- package/dist/src/utils/Duration.d.ts +30 -0
- package/dist/src/utils/Duration.js +48 -0
- package/dist/src/utils/Duration.js.map +1 -0
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/index.js +1 -0
- package/dist/src/utils/index.js.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +1 -0
- package/src/queue/inMemoryQueue.ts +1 -1
- package/src/queue/queue.ts +17 -4
- package/src/redis/redis.ts +3 -3
- package/src/redis/utils.ts +25 -18
- package/src/utils/Duration.ts +49 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/tests/Duration.spec.ts +19 -0
package/dist/index.js
CHANGED
|
@@ -2722,10 +2722,11 @@ __export(utils_exports, {
|
|
|
2722
2722
|
SEPARATOR: () => SEPARATOR2,
|
|
2723
2723
|
SelectableDatabase: () => SelectableDatabase,
|
|
2724
2724
|
addDbPrefix: () => addDbPrefix,
|
|
2725
|
+
getRedisConnectionDetails: () => getRedisConnectionDetails,
|
|
2725
2726
|
getRedisOptions: () => getRedisOptions,
|
|
2726
2727
|
removeDbPrefix: () => removeDbPrefix
|
|
2727
2728
|
});
|
|
2728
|
-
function
|
|
2729
|
+
function getRedisConnectionDetails() {
|
|
2729
2730
|
let password = environment_default.REDIS_PASSWORD;
|
|
2730
2731
|
let url = environment_default.REDIS_URL.split("//");
|
|
2731
2732
|
url = url.length > 1 ? url[1] : url[0];
|
|
@@ -2737,25 +2738,33 @@ function getRedisOptions() {
|
|
|
2737
2738
|
url = url[0];
|
|
2738
2739
|
}
|
|
2739
2740
|
const [host, port] = url.split(":");
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
const opts = {
|
|
2745
|
-
connectTimeout: CONNECT_TIMEOUT_MS
|
|
2741
|
+
return {
|
|
2742
|
+
host,
|
|
2743
|
+
password,
|
|
2744
|
+
port: parseInt(port)
|
|
2746
2745
|
};
|
|
2746
|
+
}
|
|
2747
|
+
function getRedisOptions() {
|
|
2748
|
+
const { host, password, port } = getRedisConnectionDetails();
|
|
2749
|
+
let redisOpts = {
|
|
2750
|
+
connectTimeout: CONNECT_TIMEOUT_MS,
|
|
2751
|
+
port,
|
|
2752
|
+
host,
|
|
2753
|
+
password
|
|
2754
|
+
};
|
|
2755
|
+
let opts = redisOpts;
|
|
2747
2756
|
if (environment_default.REDIS_CLUSTERED) {
|
|
2748
|
-
opts
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
+
opts = {
|
|
2758
|
+
connectTimeout: CONNECT_TIMEOUT_MS,
|
|
2759
|
+
redisOptions: {
|
|
2760
|
+
...redisOpts,
|
|
2761
|
+
tls: {}
|
|
2762
|
+
},
|
|
2763
|
+
slotsRefreshTimeout: SLOT_REFRESH_MS,
|
|
2764
|
+
dnsLookup: (address, callback) => callback(null, address)
|
|
2765
|
+
};
|
|
2757
2766
|
}
|
|
2758
|
-
return
|
|
2767
|
+
return opts;
|
|
2759
2768
|
}
|
|
2760
2769
|
function addDbPrefix(db, key) {
|
|
2761
2770
|
if (key.includes(db)) {
|
|
@@ -2801,7 +2810,7 @@ var init_utils2 = __esm({
|
|
|
2801
2810
|
SelectableDatabase = /* @__PURE__ */ ((SelectableDatabase2) => {
|
|
2802
2811
|
SelectableDatabase2[SelectableDatabase2["DEFAULT"] = 0] = "DEFAULT";
|
|
2803
2812
|
SelectableDatabase2[SelectableDatabase2["SOCKET_IO"] = 1] = "SOCKET_IO";
|
|
2804
|
-
SelectableDatabase2[SelectableDatabase2["
|
|
2813
|
+
SelectableDatabase2[SelectableDatabase2["RATE_LIMITING"] = 2] = "RATE_LIMITING";
|
|
2805
2814
|
SelectableDatabase2[SelectableDatabase2["UNUSED_2"] = 3] = "UNUSED_2";
|
|
2806
2815
|
SelectableDatabase2[SelectableDatabase2["UNUSED_3"] = 4] = "UNUSED_3";
|
|
2807
2816
|
SelectableDatabase2[SelectableDatabase2["UNUSED_4"] = 5] = "UNUSED_4";
|
|
@@ -2901,11 +2910,10 @@ function init2(selectDb = DEFAULT_SELECT_DB) {
|
|
|
2901
2910
|
if (client) {
|
|
2902
2911
|
client.disconnect();
|
|
2903
2912
|
}
|
|
2904
|
-
const {
|
|
2913
|
+
const { host, port } = getRedisConnectionDetails();
|
|
2914
|
+
const opts = getRedisOptions();
|
|
2905
2915
|
if (CLUSTERED) {
|
|
2906
2916
|
client = new RedisCore.Cluster([{ host, port }], opts);
|
|
2907
|
-
} else if (redisProtocolUrl) {
|
|
2908
|
-
client = new RedisCore(redisProtocolUrl);
|
|
2909
2917
|
} else {
|
|
2910
2918
|
client = new RedisCore(opts);
|
|
2911
2919
|
}
|
|
@@ -5611,6 +5619,8 @@ __export(src_exports, {
|
|
|
5611
5619
|
DEFAULT_TENANT_ID: () => DEFAULT_TENANT_ID,
|
|
5612
5620
|
DeprecatedViews: () => DeprecatedViews,
|
|
5613
5621
|
DocumentType: () => DocumentType,
|
|
5622
|
+
Duration: () => Duration,
|
|
5623
|
+
DurationType: () => DurationType,
|
|
5614
5624
|
EmailUnavailableError: () => EmailUnavailableError,
|
|
5615
5625
|
ErrorCode: () => ErrorCode,
|
|
5616
5626
|
FeatureDisabledError: () => FeatureDisabledError,
|
|
@@ -7328,6 +7338,8 @@ var import_events2 = __toESM(require("events"));
|
|
|
7328
7338
|
// src/utils/index.ts
|
|
7329
7339
|
var utils_exports3 = {};
|
|
7330
7340
|
__export(utils_exports3, {
|
|
7341
|
+
Duration: () => Duration,
|
|
7342
|
+
DurationType: () => DurationType,
|
|
7331
7343
|
clearCookie: () => clearCookie,
|
|
7332
7344
|
compare: () => compare,
|
|
7333
7345
|
getAppIdFromCtx: () => getAppIdFromCtx,
|
|
@@ -7512,6 +7524,51 @@ function validEmail(value) {
|
|
|
7512
7524
|
);
|
|
7513
7525
|
}
|
|
7514
7526
|
|
|
7527
|
+
// src/utils/Duration.ts
|
|
7528
|
+
var DurationType = /* @__PURE__ */ ((DurationType2) => {
|
|
7529
|
+
DurationType2["MILLISECONDS"] = "milliseconds";
|
|
7530
|
+
DurationType2["SECONDS"] = "seconds";
|
|
7531
|
+
DurationType2["MINUTES"] = "minutes";
|
|
7532
|
+
DurationType2["HOURS"] = "hours";
|
|
7533
|
+
DurationType2["DAYS"] = "days";
|
|
7534
|
+
return DurationType2;
|
|
7535
|
+
})(DurationType || {});
|
|
7536
|
+
var conversion = {
|
|
7537
|
+
milliseconds: 1,
|
|
7538
|
+
seconds: 1e3,
|
|
7539
|
+
minutes: 60 * 1e3,
|
|
7540
|
+
hours: 60 * 60 * 1e3,
|
|
7541
|
+
days: 24 * 60 * 60 * 1e3
|
|
7542
|
+
};
|
|
7543
|
+
var Duration = class _Duration {
|
|
7544
|
+
static convert(from, to, duration) {
|
|
7545
|
+
const milliseconds = duration * conversion[from];
|
|
7546
|
+
return milliseconds / conversion[to];
|
|
7547
|
+
}
|
|
7548
|
+
static from(from, duration) {
|
|
7549
|
+
return {
|
|
7550
|
+
to: (to) => {
|
|
7551
|
+
return _Duration.convert(from, to, duration);
|
|
7552
|
+
},
|
|
7553
|
+
toMs: () => {
|
|
7554
|
+
return _Duration.convert(from, "milliseconds" /* MILLISECONDS */, duration);
|
|
7555
|
+
}
|
|
7556
|
+
};
|
|
7557
|
+
}
|
|
7558
|
+
static fromSeconds(duration) {
|
|
7559
|
+
return _Duration.from("seconds" /* SECONDS */, duration);
|
|
7560
|
+
}
|
|
7561
|
+
static fromMinutes(duration) {
|
|
7562
|
+
return _Duration.from("minutes" /* MINUTES */, duration);
|
|
7563
|
+
}
|
|
7564
|
+
static fromHours(duration) {
|
|
7565
|
+
return _Duration.from("hours" /* HOURS */, duration);
|
|
7566
|
+
}
|
|
7567
|
+
static fromDays(duration) {
|
|
7568
|
+
return _Duration.from("days" /* DAYS */, duration);
|
|
7569
|
+
}
|
|
7570
|
+
};
|
|
7571
|
+
|
|
7515
7572
|
// src/queue/inMemoryQueue.ts
|
|
7516
7573
|
function newJob(queue, message) {
|
|
7517
7574
|
return {
|
|
@@ -7527,7 +7584,7 @@ var InMemoryQueue = class {
|
|
|
7527
7584
|
* @param opts This is not used by the in memory queue as there is no real use
|
|
7528
7585
|
* case when in memory, but is the same API as Bull
|
|
7529
7586
|
*/
|
|
7530
|
-
constructor(name, opts
|
|
7587
|
+
constructor(name, opts) {
|
|
7531
7588
|
this._name = name;
|
|
7532
7589
|
this._opts = opts;
|
|
7533
7590
|
this._messages = [];
|
|
@@ -7749,7 +7806,9 @@ function logging(queue, jobQueue) {
|
|
|
7749
7806
|
|
|
7750
7807
|
// src/queue/queue.ts
|
|
7751
7808
|
init_timers2();
|
|
7752
|
-
var
|
|
7809
|
+
var QUEUE_LOCK_MS = Duration.fromMinutes(5).toMs();
|
|
7810
|
+
var QUEUE_LOCK_RENEW_INTERNAL_MS = Duration.fromSeconds(30).toMs();
|
|
7811
|
+
var CLEANUP_PERIOD_MS = Duration.fromSeconds(60).toMs();
|
|
7753
7812
|
var QUEUES = [];
|
|
7754
7813
|
var cleanupInterval;
|
|
7755
7814
|
async function cleanup2() {
|
|
@@ -7758,8 +7817,15 @@ async function cleanup2() {
|
|
|
7758
7817
|
}
|
|
7759
7818
|
}
|
|
7760
7819
|
function createQueue(jobQueue, opts = {}) {
|
|
7761
|
-
const
|
|
7762
|
-
const queueConfig =
|
|
7820
|
+
const redisOpts = getRedisOptions();
|
|
7821
|
+
const queueConfig = {
|
|
7822
|
+
redis: redisOpts,
|
|
7823
|
+
settings: {
|
|
7824
|
+
maxStalledCount: 0,
|
|
7825
|
+
lockDuration: QUEUE_LOCK_MS,
|
|
7826
|
+
lockRenewTime: QUEUE_LOCK_RENEW_INTERNAL_MS
|
|
7827
|
+
}
|
|
7828
|
+
};
|
|
7763
7829
|
let queue;
|
|
7764
7830
|
if (!environment_default.isTest()) {
|
|
7765
7831
|
queue = new import_bull.default(jobQueue, queueConfig);
|
|
@@ -12765,6 +12831,8 @@ var init8 = (opts = {}) => {
|
|
|
12765
12831
|
DEFAULT_TENANT_ID,
|
|
12766
12832
|
DeprecatedViews,
|
|
12767
12833
|
DocumentType,
|
|
12834
|
+
Duration,
|
|
12835
|
+
DurationType,
|
|
12768
12836
|
EmailUnavailableError,
|
|
12769
12837
|
ErrorCode,
|
|
12770
12838
|
FeatureDisabledError,
|