@budibase/backend-core 2.13.48 → 2.13.51
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 +638 -764
- package/dist/index.js.map +4 -4
- package/dist/index.js.meta.json +1 -1
- package/dist/package.json +5 -5
- package/dist/src/db/couch/DatabaseImpl.d.ts +1 -2
- package/dist/src/db/couch/DatabaseImpl.js +1 -3
- package/dist/src/db/couch/DatabaseImpl.js.map +1 -1
- package/dist/src/db/db.js +1 -2
- package/dist/src/db/db.js.map +1 -1
- package/dist/src/logging/pino/logger.js +0 -6
- package/dist/src/logging/pino/logger.js.map +1 -1
- package/dist/src/queue/inMemoryQueue.js +1 -0
- package/dist/src/queue/inMemoryQueue.js.map +1 -1
- package/dist/src/queue/queue.js +1 -1
- package/dist/src/queue/queue.js.map +1 -1
- package/dist/src/redis/redis.js +7 -6
- package/dist/src/redis/redis.js.map +1 -1
- package/dist/src/timers/timers.d.ts +2 -1
- package/dist/src/timers/timers.js +3 -0
- package/dist/src/timers/timers.js.map +1 -1
- package/package.json +5 -5
- package/src/db/couch/DatabaseImpl.ts +1 -3
- package/src/db/db.ts +1 -2
- package/src/logging/pino/logger.ts +0 -6
- package/src/queue/inMemoryQueue.ts +1 -0
- package/src/queue/queue.ts +1 -1
- package/src/redis/redis.ts +7 -14
- package/src/timers/timers.ts +5 -1
- package/dist/src/db/instrumentation.d.ts +0 -28
- package/dist/src/db/instrumentation.js +0 -118
- package/dist/src/db/instrumentation.js.map +0 -1
- package/src/db/instrumentation.ts +0 -159
package/dist/index.js
CHANGED
|
@@ -2905,124 +2905,6 @@ var init_newid = __esm({
|
|
|
2905
2905
|
}
|
|
2906
2906
|
});
|
|
2907
2907
|
|
|
2908
|
-
// src/db/instrumentation.ts
|
|
2909
|
-
var import_dd_trace, DDInstrumentedDatabase;
|
|
2910
|
-
var init_instrumentation = __esm({
|
|
2911
|
-
"src/db/instrumentation.ts"() {
|
|
2912
|
-
"use strict";
|
|
2913
|
-
import_dd_trace = __toESM(require("dd-trace"));
|
|
2914
|
-
DDInstrumentedDatabase = class {
|
|
2915
|
-
constructor(db, resource) {
|
|
2916
|
-
this.db = db;
|
|
2917
|
-
this.resource = resource;
|
|
2918
|
-
}
|
|
2919
|
-
get name() {
|
|
2920
|
-
return this.db.name;
|
|
2921
|
-
}
|
|
2922
|
-
exists() {
|
|
2923
|
-
return import_dd_trace.default.trace("exists", { resource: this.resource }, (span) => {
|
|
2924
|
-
span?.addTags({ db_name: this.name });
|
|
2925
|
-
return this.db.exists();
|
|
2926
|
-
});
|
|
2927
|
-
}
|
|
2928
|
-
checkSetup() {
|
|
2929
|
-
return import_dd_trace.default.trace("checkSetup", { resource: this.resource }, (span) => {
|
|
2930
|
-
span?.addTags({ db_name: this.name });
|
|
2931
|
-
return this.db.checkSetup();
|
|
2932
|
-
});
|
|
2933
|
-
}
|
|
2934
|
-
get(id) {
|
|
2935
|
-
return import_dd_trace.default.trace("get", { resource: this.resource }, (span) => {
|
|
2936
|
-
span?.addTags({ db_name: this.name, doc_id: id });
|
|
2937
|
-
return this.db.get(id);
|
|
2938
|
-
});
|
|
2939
|
-
}
|
|
2940
|
-
getMultiple(ids, opts) {
|
|
2941
|
-
return import_dd_trace.default.trace("getMultiple", { resource: this.resource }, (span) => {
|
|
2942
|
-
span?.addTags({
|
|
2943
|
-
db_name: this.name,
|
|
2944
|
-
num_docs: ids.length,
|
|
2945
|
-
allow_missing: opts?.allowMissing
|
|
2946
|
-
});
|
|
2947
|
-
return this.db.getMultiple(ids, opts);
|
|
2948
|
-
});
|
|
2949
|
-
}
|
|
2950
|
-
remove(id, rev) {
|
|
2951
|
-
return import_dd_trace.default.trace("remove", { resource: this.resource }, (span) => {
|
|
2952
|
-
span?.addTags({ db_name: this.name, doc_id: id });
|
|
2953
|
-
return this.db.remove(id, rev);
|
|
2954
|
-
});
|
|
2955
|
-
}
|
|
2956
|
-
put(document, opts) {
|
|
2957
|
-
return import_dd_trace.default.trace("put", { resource: this.resource }, (span) => {
|
|
2958
|
-
span?.addTags({ db_name: this.name, doc_id: document._id });
|
|
2959
|
-
return this.db.put(document, opts);
|
|
2960
|
-
});
|
|
2961
|
-
}
|
|
2962
|
-
bulkDocs(documents) {
|
|
2963
|
-
return import_dd_trace.default.trace("bulkDocs", { resource: this.resource }, (span) => {
|
|
2964
|
-
span?.addTags({ db_name: this.name, num_docs: documents.length });
|
|
2965
|
-
return this.db.bulkDocs(documents);
|
|
2966
|
-
});
|
|
2967
|
-
}
|
|
2968
|
-
allDocs(params2) {
|
|
2969
|
-
return import_dd_trace.default.trace("allDocs", { resource: this.resource }, (span) => {
|
|
2970
|
-
span?.addTags({ db_name: this.name });
|
|
2971
|
-
return this.db.allDocs(params2);
|
|
2972
|
-
});
|
|
2973
|
-
}
|
|
2974
|
-
query(viewName, params2) {
|
|
2975
|
-
return import_dd_trace.default.trace("query", { resource: this.resource }, (span) => {
|
|
2976
|
-
span?.addTags({ db_name: this.name, view_name: viewName });
|
|
2977
|
-
return this.db.query(viewName, params2);
|
|
2978
|
-
});
|
|
2979
|
-
}
|
|
2980
|
-
destroy() {
|
|
2981
|
-
return import_dd_trace.default.trace("destroy", { resource: this.resource }, (span) => {
|
|
2982
|
-
span?.addTags({ db_name: this.name });
|
|
2983
|
-
return this.db.destroy();
|
|
2984
|
-
});
|
|
2985
|
-
}
|
|
2986
|
-
compact() {
|
|
2987
|
-
return import_dd_trace.default.trace("compact", { resource: this.resource }, (span) => {
|
|
2988
|
-
span?.addTags({ db_name: this.name });
|
|
2989
|
-
return this.db.compact();
|
|
2990
|
-
});
|
|
2991
|
-
}
|
|
2992
|
-
dump(stream2, opts) {
|
|
2993
|
-
return import_dd_trace.default.trace("dump", { resource: this.resource }, (span) => {
|
|
2994
|
-
span?.addTags({ db_name: this.name });
|
|
2995
|
-
return this.db.dump(stream2, opts);
|
|
2996
|
-
});
|
|
2997
|
-
}
|
|
2998
|
-
load(...args) {
|
|
2999
|
-
return import_dd_trace.default.trace("load", { resource: this.resource }, (span) => {
|
|
3000
|
-
span?.addTags({ db_name: this.name });
|
|
3001
|
-
return this.db.load(...args);
|
|
3002
|
-
});
|
|
3003
|
-
}
|
|
3004
|
-
createIndex(...args) {
|
|
3005
|
-
return import_dd_trace.default.trace("createIndex", { resource: this.resource }, (span) => {
|
|
3006
|
-
span?.addTags({ db_name: this.name });
|
|
3007
|
-
return this.db.createIndex(...args);
|
|
3008
|
-
});
|
|
3009
|
-
}
|
|
3010
|
-
deleteIndex(...args) {
|
|
3011
|
-
return import_dd_trace.default.trace("deleteIndex", { resource: this.resource }, (span) => {
|
|
3012
|
-
span?.addTags({ db_name: this.name });
|
|
3013
|
-
return this.db.deleteIndex(...args);
|
|
3014
|
-
});
|
|
3015
|
-
}
|
|
3016
|
-
getIndexes(...args) {
|
|
3017
|
-
return import_dd_trace.default.trace("getIndexes", { resource: this.resource }, (span) => {
|
|
3018
|
-
span?.addTags({ db_name: this.name });
|
|
3019
|
-
return this.db.getIndexes(...args);
|
|
3020
|
-
});
|
|
3021
|
-
}
|
|
3022
|
-
};
|
|
3023
|
-
}
|
|
3024
|
-
});
|
|
3025
|
-
|
|
3026
2908
|
// src/db/couch/DatabaseImpl.ts
|
|
3027
2909
|
function buildNano(couchInfo) {
|
|
3028
2910
|
return (0, import_nano.default)({
|
|
@@ -3036,8 +2918,7 @@ function buildNano(couchInfo) {
|
|
|
3036
2918
|
});
|
|
3037
2919
|
}
|
|
3038
2920
|
function DatabaseWithConnection(dbName, connection, opts) {
|
|
3039
|
-
|
|
3040
|
-
return new DDInstrumentedDatabase(db, "couchdb");
|
|
2921
|
+
return new DatabaseImpl(dbName, opts, connection);
|
|
3041
2922
|
}
|
|
3042
2923
|
var import_nano, DatabaseImpl;
|
|
3043
2924
|
var init_DatabaseImpl = __esm({
|
|
@@ -3049,7 +2930,6 @@ var init_DatabaseImpl = __esm({
|
|
|
3049
2930
|
init_utils2();
|
|
3050
2931
|
init_pouchDB();
|
|
3051
2932
|
init_newid();
|
|
3052
|
-
init_instrumentation();
|
|
3053
2933
|
DatabaseImpl = class _DatabaseImpl {
|
|
3054
2934
|
constructor(dbName, opts, connection) {
|
|
3055
2935
|
this.couchInfo = getCouchInfo();
|
|
@@ -3266,7 +3146,7 @@ var init_couch = __esm({
|
|
|
3266
3146
|
|
|
3267
3147
|
// src/db/db.ts
|
|
3268
3148
|
function getDB(dbName, opts) {
|
|
3269
|
-
return new
|
|
3149
|
+
return new DatabaseImpl(dbName, opts);
|
|
3270
3150
|
}
|
|
3271
3151
|
async function doWithDB(dbName, cb, opts) {
|
|
3272
3152
|
const db = getDB(dbName, opts);
|
|
@@ -3287,7 +3167,6 @@ var init_db3 = __esm({
|
|
|
3287
3167
|
"src/db/db.ts"() {
|
|
3288
3168
|
"use strict";
|
|
3289
3169
|
init_couch();
|
|
3290
|
-
init_instrumentation();
|
|
3291
3170
|
}
|
|
3292
3171
|
});
|
|
3293
3172
|
|
|
@@ -3711,529 +3590,152 @@ var init_utils3 = __esm({
|
|
|
3711
3590
|
}
|
|
3712
3591
|
});
|
|
3713
3592
|
|
|
3714
|
-
// src/
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
}
|
|
3720
|
-
function
|
|
3721
|
-
|
|
3722
|
-
if (idx !== -1) {
|
|
3723
|
-
intervals.splice(idx, 1);
|
|
3724
|
-
}
|
|
3725
|
-
clearInterval(interval);
|
|
3726
|
-
}
|
|
3727
|
-
function cleanup() {
|
|
3728
|
-
for (let interval of intervals) {
|
|
3729
|
-
clearInterval(interval);
|
|
3730
|
-
}
|
|
3731
|
-
intervals = [];
|
|
3593
|
+
// src/logging/correlation/correlation.ts
|
|
3594
|
+
var correlation_exports = {};
|
|
3595
|
+
__export(correlation_exports, {
|
|
3596
|
+
getId: () => getId,
|
|
3597
|
+
setHeader: () => setHeader
|
|
3598
|
+
});
|
|
3599
|
+
function getId() {
|
|
3600
|
+
return correlator.getId();
|
|
3732
3601
|
}
|
|
3733
|
-
var
|
|
3734
|
-
var
|
|
3735
|
-
"src/
|
|
3602
|
+
var correlator, setHeader;
|
|
3603
|
+
var init_correlation = __esm({
|
|
3604
|
+
"src/logging/correlation/correlation.ts"() {
|
|
3736
3605
|
"use strict";
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
};
|
|
3744
|
-
ExecutionTimeTracker = class _ExecutionTimeTracker {
|
|
3745
|
-
constructor(limitMs) {
|
|
3746
|
-
this.limitMs = limitMs;
|
|
3747
|
-
this.totalTimeMs = 0;
|
|
3748
|
-
}
|
|
3749
|
-
static withLimit(limitMs) {
|
|
3750
|
-
return new _ExecutionTimeTracker(limitMs);
|
|
3751
|
-
}
|
|
3752
|
-
track(f) {
|
|
3753
|
-
this.checkLimit();
|
|
3754
|
-
const start2 = process.hrtime.bigint();
|
|
3755
|
-
try {
|
|
3756
|
-
return f();
|
|
3757
|
-
} finally {
|
|
3758
|
-
const end2 = process.hrtime.bigint();
|
|
3759
|
-
this.totalTimeMs += Number(end2 - start2) / 1e6;
|
|
3760
|
-
this.checkLimit();
|
|
3761
|
-
}
|
|
3762
|
-
}
|
|
3763
|
-
checkLimit() {
|
|
3764
|
-
if (this.totalTimeMs > this.limitMs) {
|
|
3765
|
-
throw new ExecutionTimeoutError(
|
|
3766
|
-
`Execution time limit of ${this.limitMs}ms exceeded: ${this.totalTimeMs}ms`
|
|
3767
|
-
);
|
|
3768
|
-
}
|
|
3606
|
+
init_constants4();
|
|
3607
|
+
correlator = require("correlation-id");
|
|
3608
|
+
setHeader = (headers) => {
|
|
3609
|
+
const correlationId = correlator.getId();
|
|
3610
|
+
if (correlationId) {
|
|
3611
|
+
headers["x-budibase-correlation-id" /* CORRELATION_ID */] = correlationId;
|
|
3769
3612
|
}
|
|
3770
3613
|
};
|
|
3771
3614
|
}
|
|
3772
3615
|
});
|
|
3773
3616
|
|
|
3774
|
-
// src/
|
|
3775
|
-
var
|
|
3776
|
-
|
|
3777
|
-
ExecutionTimeTracker: () => ExecutionTimeTracker,
|
|
3778
|
-
ExecutionTimeoutError: () => ExecutionTimeoutError,
|
|
3779
|
-
cleanup: () => cleanup,
|
|
3780
|
-
clear: () => clear,
|
|
3781
|
-
set: () => set
|
|
3782
|
-
});
|
|
3783
|
-
var init_timers2 = __esm({
|
|
3784
|
-
"src/timers/index.ts"() {
|
|
3617
|
+
// src/logging/correlation/index.ts
|
|
3618
|
+
var init_correlation2 = __esm({
|
|
3619
|
+
"src/logging/correlation/index.ts"() {
|
|
3785
3620
|
"use strict";
|
|
3786
|
-
|
|
3621
|
+
init_correlation();
|
|
3787
3622
|
}
|
|
3788
3623
|
});
|
|
3789
3624
|
|
|
3790
|
-
// src/
|
|
3791
|
-
function
|
|
3792
|
-
return
|
|
3793
|
-
}
|
|
3794
|
-
function connectionError(selectDb, timeout2, err) {
|
|
3795
|
-
if (CLOSED) {
|
|
3796
|
-
return;
|
|
3797
|
-
}
|
|
3798
|
-
pickClient(selectDb).disconnect();
|
|
3799
|
-
CLOSED = true;
|
|
3800
|
-
clearTimeout(timeout2);
|
|
3801
|
-
CONNECTED = false;
|
|
3802
|
-
console.error("Redis connection failed - " + err);
|
|
3803
|
-
setTimeout(() => {
|
|
3804
|
-
init2();
|
|
3805
|
-
}, RETRY_PERIOD_MS);
|
|
3625
|
+
// src/objectStore/utils.ts
|
|
3626
|
+
function budibaseTempDir() {
|
|
3627
|
+
return bbTmp;
|
|
3806
3628
|
}
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
);
|
|
3629
|
+
var import_path, import_os, import_fs2, ObjectStoreBuckets, bbTmp;
|
|
3630
|
+
var init_utils4 = __esm({
|
|
3631
|
+
"src/objectStore/utils.ts"() {
|
|
3632
|
+
"use strict";
|
|
3633
|
+
import_path = require("path");
|
|
3634
|
+
import_os = require("os");
|
|
3635
|
+
import_fs2 = __toESM(require("fs"));
|
|
3636
|
+
init_environment2();
|
|
3637
|
+
ObjectStoreBuckets = {
|
|
3638
|
+
BACKUPS: environment_default.BACKUPS_BUCKET_NAME,
|
|
3639
|
+
APPS: environment_default.APPS_BUCKET_NAME,
|
|
3640
|
+
TEMPLATES: environment_default.TEMPLATES_BUCKET_NAME,
|
|
3641
|
+
GLOBAL: environment_default.GLOBAL_BUCKET_NAME,
|
|
3642
|
+
PLUGINS: environment_default.PLUGIN_BUCKET_NAME
|
|
3643
|
+
};
|
|
3644
|
+
bbTmp = (0, import_path.join)((0, import_os.tmpdir)(), ".budibase");
|
|
3645
|
+
try {
|
|
3646
|
+
import_fs2.default.mkdirSync(bbTmp);
|
|
3647
|
+
} catch (e) {
|
|
3648
|
+
if (e.code !== "EEXIST") {
|
|
3649
|
+
throw e;
|
|
3650
|
+
}
|
|
3825
3651
|
}
|
|
3826
|
-
}, STARTUP_TIMEOUT_MS);
|
|
3827
|
-
if (client) {
|
|
3828
|
-
client.disconnect();
|
|
3829
|
-
}
|
|
3830
|
-
const { host, port } = getRedisConnectionDetails();
|
|
3831
|
-
const opts = getRedisOptions();
|
|
3832
|
-
if (CLUSTERED) {
|
|
3833
|
-
client = new RedisCore.Cluster([{ host, port }], opts);
|
|
3834
|
-
} else {
|
|
3835
|
-
client = new RedisCore(opts);
|
|
3836
3652
|
}
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3653
|
+
});
|
|
3654
|
+
|
|
3655
|
+
// src/cache/appMetadata.ts
|
|
3656
|
+
var appMetadata_exports = {};
|
|
3657
|
+
__export(appMetadata_exports, {
|
|
3658
|
+
AppState: () => AppState,
|
|
3659
|
+
getAppMetadata: () => getAppMetadata,
|
|
3660
|
+
invalidateAppMetadata: () => invalidateAppMetadata
|
|
3661
|
+
});
|
|
3662
|
+
async function populateFromDB(appId) {
|
|
3663
|
+
return doWithDB(
|
|
3664
|
+
appId,
|
|
3665
|
+
(db) => {
|
|
3666
|
+
return db.get("app_metadata" /* APP_METADATA */);
|
|
3667
|
+
},
|
|
3668
|
+
{ skip_setup: true }
|
|
3669
|
+
);
|
|
3851
3670
|
}
|
|
3852
|
-
function
|
|
3853
|
-
return
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3671
|
+
function isInvalid(metadata) {
|
|
3672
|
+
return !metadata || metadata.state === "invalid" /* INVALID */;
|
|
3673
|
+
}
|
|
3674
|
+
async function getAppMetadata(appId) {
|
|
3675
|
+
const client = await getAppClient();
|
|
3676
|
+
let metadata = await client.get(appId);
|
|
3677
|
+
if (!metadata) {
|
|
3678
|
+
let expiry = EXPIRY_SECONDS;
|
|
3679
|
+
try {
|
|
3680
|
+
metadata = await populateFromDB(appId);
|
|
3681
|
+
} catch (err) {
|
|
3682
|
+
if (err && err.status === 404) {
|
|
3683
|
+
metadata = { state: "invalid" /* INVALID */ };
|
|
3684
|
+
expiry = void 0;
|
|
3685
|
+
} else {
|
|
3686
|
+
throw err;
|
|
3687
|
+
}
|
|
3859
3688
|
}
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3689
|
+
if (isInvalid(metadata)) {
|
|
3690
|
+
const temp = await client.get(appId);
|
|
3691
|
+
if (temp) {
|
|
3692
|
+
metadata = temp;
|
|
3864
3693
|
}
|
|
3865
|
-
}
|
|
3866
|
-
|
|
3694
|
+
}
|
|
3695
|
+
await client.store(appId, metadata, expiry);
|
|
3696
|
+
}
|
|
3697
|
+
return metadata;
|
|
3867
3698
|
}
|
|
3868
|
-
function
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
reject(err);
|
|
3878
|
-
});
|
|
3879
|
-
stream2.on("end", async () => {
|
|
3880
|
-
const keysArray = Array.from(outputKeys);
|
|
3881
|
-
try {
|
|
3882
|
-
let getPromises = [];
|
|
3883
|
-
for (let key of keysArray) {
|
|
3884
|
-
getPromises.push(client.get(key));
|
|
3885
|
-
}
|
|
3886
|
-
const jsonArray = await Promise.all(getPromises);
|
|
3887
|
-
resolve(
|
|
3888
|
-
keysArray.map((key) => ({
|
|
3889
|
-
key: removeDbPrefix(key),
|
|
3890
|
-
value: JSON.parse(jsonArray.shift())
|
|
3891
|
-
}))
|
|
3892
|
-
);
|
|
3893
|
-
} catch (err) {
|
|
3894
|
-
reject(err);
|
|
3895
|
-
}
|
|
3896
|
-
});
|
|
3897
|
-
});
|
|
3699
|
+
async function invalidateAppMetadata(appId, newMetadata) {
|
|
3700
|
+
if (!appId) {
|
|
3701
|
+
throw "Cannot invalidate if no app ID provided.";
|
|
3702
|
+
}
|
|
3703
|
+
const client = await getAppClient();
|
|
3704
|
+
await client.delete(appId);
|
|
3705
|
+
if (newMetadata) {
|
|
3706
|
+
await client.store(appId, newMetadata, EXPIRY_SECONDS);
|
|
3707
|
+
}
|
|
3898
3708
|
}
|
|
3899
|
-
var
|
|
3900
|
-
var
|
|
3901
|
-
"src/
|
|
3709
|
+
var AppState, EXPIRY_SECONDS;
|
|
3710
|
+
var init_appMetadata = __esm({
|
|
3711
|
+
"src/cache/appMetadata.ts"() {
|
|
3902
3712
|
"use strict";
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
} catch (err) {
|
|
3911
|
-
console.log("Mock redis unavailable");
|
|
3912
|
-
}
|
|
3913
|
-
}
|
|
3914
|
-
RETRY_PERIOD_MS = 2e3;
|
|
3915
|
-
STARTUP_TIMEOUT_MS = 5e3;
|
|
3916
|
-
CLUSTERED = environment_default.REDIS_CLUSTERED;
|
|
3917
|
-
DEFAULT_SELECT_DB = 0 /* DEFAULT */;
|
|
3918
|
-
CLOSED = false;
|
|
3919
|
-
CLIENTS = {};
|
|
3920
|
-
CONNECTED = false;
|
|
3921
|
-
if (environment_default.MOCK_REDIS) {
|
|
3922
|
-
CONNECTED = true;
|
|
3923
|
-
}
|
|
3924
|
-
RedisWrapper = class {
|
|
3925
|
-
constructor(db, selectDb = null) {
|
|
3926
|
-
this._db = db;
|
|
3927
|
-
this._select = selectDb || DEFAULT_SELECT_DB;
|
|
3928
|
-
}
|
|
3929
|
-
getClient() {
|
|
3930
|
-
return pickClient(this._select);
|
|
3931
|
-
}
|
|
3932
|
-
async init() {
|
|
3933
|
-
CLOSED = false;
|
|
3934
|
-
init2(this._select);
|
|
3935
|
-
await waitForConnection(this._select);
|
|
3936
|
-
if (this._select && !environment_default.isTest()) {
|
|
3937
|
-
this.getClient().select(this._select);
|
|
3938
|
-
}
|
|
3939
|
-
return this;
|
|
3940
|
-
}
|
|
3941
|
-
async finish() {
|
|
3942
|
-
CLOSED = true;
|
|
3943
|
-
this.getClient().disconnect();
|
|
3944
|
-
}
|
|
3945
|
-
async scan(key = "") {
|
|
3946
|
-
const db = this._db;
|
|
3947
|
-
key = `${db}${SEPARATOR2}${key}`;
|
|
3948
|
-
let stream2;
|
|
3949
|
-
if (CLUSTERED) {
|
|
3950
|
-
let node = this.getClient().nodes("master");
|
|
3951
|
-
stream2 = node[0].scanStream({ match: key + "*", count: 100 });
|
|
3952
|
-
} else {
|
|
3953
|
-
stream2 = this.getClient().scanStream({ match: key + "*", count: 100 });
|
|
3954
|
-
}
|
|
3955
|
-
return promisifyStream(stream2, this.getClient());
|
|
3956
|
-
}
|
|
3957
|
-
async keys(pattern) {
|
|
3958
|
-
const db = this._db;
|
|
3959
|
-
return this.getClient().keys(addDbPrefix(db, pattern));
|
|
3960
|
-
}
|
|
3961
|
-
async exists(key) {
|
|
3962
|
-
const db = this._db;
|
|
3963
|
-
return await this.getClient().exists(addDbPrefix(db, key));
|
|
3964
|
-
}
|
|
3965
|
-
async get(key) {
|
|
3966
|
-
const db = this._db;
|
|
3967
|
-
let response = await this.getClient().get(addDbPrefix(db, key));
|
|
3968
|
-
if (response != null && response.key) {
|
|
3969
|
-
response.key = key;
|
|
3970
|
-
}
|
|
3971
|
-
try {
|
|
3972
|
-
return JSON.parse(response);
|
|
3973
|
-
} catch (err) {
|
|
3974
|
-
return response;
|
|
3975
|
-
}
|
|
3976
|
-
}
|
|
3977
|
-
async bulkGet(keys2) {
|
|
3978
|
-
const db = this._db;
|
|
3979
|
-
if (keys2.length === 0) {
|
|
3980
|
-
return {};
|
|
3981
|
-
}
|
|
3982
|
-
const prefixedKeys = keys2.map((key) => addDbPrefix(db, key));
|
|
3983
|
-
let response = await this.getClient().mget(prefixedKeys);
|
|
3984
|
-
if (Array.isArray(response)) {
|
|
3985
|
-
let final = {};
|
|
3986
|
-
let count = 0;
|
|
3987
|
-
for (let result of response) {
|
|
3988
|
-
if (result) {
|
|
3989
|
-
let parsed;
|
|
3990
|
-
try {
|
|
3991
|
-
parsed = JSON.parse(result);
|
|
3992
|
-
} catch (err) {
|
|
3993
|
-
parsed = result;
|
|
3994
|
-
}
|
|
3995
|
-
final[keys2[count]] = parsed;
|
|
3996
|
-
}
|
|
3997
|
-
count++;
|
|
3998
|
-
}
|
|
3999
|
-
return final;
|
|
4000
|
-
} else {
|
|
4001
|
-
throw new Error(`Invalid response: ${response}`);
|
|
4002
|
-
}
|
|
4003
|
-
}
|
|
4004
|
-
async store(key, value, expirySeconds = null) {
|
|
4005
|
-
const db = this._db;
|
|
4006
|
-
if (typeof value === "object") {
|
|
4007
|
-
value = JSON.stringify(value);
|
|
4008
|
-
}
|
|
4009
|
-
const prefixedKey = addDbPrefix(db, key);
|
|
4010
|
-
await this.getClient().set(prefixedKey, value);
|
|
4011
|
-
if (expirySeconds) {
|
|
4012
|
-
await this.getClient().expire(prefixedKey, expirySeconds);
|
|
4013
|
-
}
|
|
4014
|
-
}
|
|
4015
|
-
async getTTL(key) {
|
|
4016
|
-
const db = this._db;
|
|
4017
|
-
const prefixedKey = addDbPrefix(db, key);
|
|
4018
|
-
return this.getClient().ttl(prefixedKey);
|
|
4019
|
-
}
|
|
4020
|
-
async setExpiry(key, expirySeconds) {
|
|
4021
|
-
const db = this._db;
|
|
4022
|
-
const prefixedKey = addDbPrefix(db, key);
|
|
4023
|
-
await this.getClient().expire(prefixedKey, expirySeconds);
|
|
4024
|
-
}
|
|
4025
|
-
async delete(key) {
|
|
4026
|
-
const db = this._db;
|
|
4027
|
-
await this.getClient().del(addDbPrefix(db, key));
|
|
4028
|
-
}
|
|
4029
|
-
async clear() {
|
|
4030
|
-
let items = await this.scan();
|
|
4031
|
-
await Promise.all(items.map((obj) => this.delete(obj.key)));
|
|
4032
|
-
}
|
|
4033
|
-
};
|
|
4034
|
-
redis_default = RedisWrapper;
|
|
3713
|
+
init_init();
|
|
3714
|
+
init_db4();
|
|
3715
|
+
AppState = /* @__PURE__ */ ((AppState2) => {
|
|
3716
|
+
AppState2["INVALID"] = "invalid";
|
|
3717
|
+
return AppState2;
|
|
3718
|
+
})(AppState || {});
|
|
3719
|
+
EXPIRY_SECONDS = 3600;
|
|
4035
3720
|
}
|
|
4036
3721
|
});
|
|
4037
3722
|
|
|
4038
|
-
// src/
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
getCacheClient: () => getCacheClient,
|
|
4043
|
-
getInviteClient: () => getInviteClient,
|
|
4044
|
-
getLockClient: () => getLockClient,
|
|
4045
|
-
getPasswordResetClient: () => getPasswordResetClient,
|
|
4046
|
-
getSessionClient: () => getSessionClient,
|
|
4047
|
-
getSocketClient: () => getSocketClient,
|
|
4048
|
-
getUserClient: () => getUserClient,
|
|
4049
|
-
getWritethroughClient: () => getWritethroughClient,
|
|
4050
|
-
init: () => init3,
|
|
4051
|
-
shutdown: () => shutdown
|
|
4052
|
-
});
|
|
4053
|
-
async function init3() {
|
|
4054
|
-
userClient = await new redis_default("users" /* USER_CACHE */).init();
|
|
4055
|
-
sessionClient = await new redis_default("session" /* SESSIONS */).init();
|
|
4056
|
-
appClient = await new redis_default("appMetadata" /* APP_METADATA */).init();
|
|
4057
|
-
cacheClient = await new redis_default("data_cache" /* GENERIC_CACHE */).init();
|
|
4058
|
-
lockClient = await new redis_default("locks" /* LOCKS */).init();
|
|
4059
|
-
writethroughClient = await new redis_default("writeThrough" /* WRITE_THROUGH */).init();
|
|
4060
|
-
inviteClient = await new redis_default("invitation" /* INVITATIONS */).init();
|
|
4061
|
-
passwordResetClient = await new redis_default("pwReset" /* PW_RESETS */).init();
|
|
4062
|
-
socketClient = await new redis_default(
|
|
4063
|
-
"socket_io" /* SOCKET_IO */,
|
|
4064
|
-
1 /* SOCKET_IO */
|
|
4065
|
-
).init();
|
|
3723
|
+
// src/docIds/ids.ts
|
|
3724
|
+
function generateRowID(tableId, id) {
|
|
3725
|
+
id = id || newid();
|
|
3726
|
+
return `${"ro" /* ROW */}${SEPARATOR}${tableId}${SEPARATOR}${id}`;
|
|
4066
3727
|
}
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
await userClient.finish();
|
|
4070
|
-
if (sessionClient)
|
|
4071
|
-
await sessionClient.finish();
|
|
4072
|
-
if (appClient)
|
|
4073
|
-
await appClient.finish();
|
|
4074
|
-
if (cacheClient)
|
|
4075
|
-
await cacheClient.finish();
|
|
4076
|
-
if (writethroughClient)
|
|
4077
|
-
await writethroughClient.finish();
|
|
4078
|
-
if (lockClient)
|
|
4079
|
-
await lockClient.finish();
|
|
4080
|
-
if (inviteClient)
|
|
4081
|
-
await inviteClient.finish();
|
|
4082
|
-
if (passwordResetClient)
|
|
4083
|
-
await passwordResetClient.finish();
|
|
4084
|
-
if (socketClient)
|
|
4085
|
-
await socketClient.finish();
|
|
3728
|
+
function generateWorkspaceID() {
|
|
3729
|
+
return `${"workspace" /* WORKSPACE */}${SEPARATOR}${newid()}`;
|
|
4086
3730
|
}
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
await init3();
|
|
4090
|
-
}
|
|
4091
|
-
return userClient;
|
|
3731
|
+
function generateGlobalUserID(id) {
|
|
3732
|
+
return `${"us" /* USER */}${SEPARATOR}${id || newid()}`;
|
|
4092
3733
|
}
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
await init3();
|
|
4096
|
-
}
|
|
4097
|
-
return sessionClient;
|
|
3734
|
+
function isGlobalUserID(id) {
|
|
3735
|
+
return isGlobalUserIDRegex.test(id);
|
|
4098
3736
|
}
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
await init3();
|
|
4102
|
-
}
|
|
4103
|
-
return appClient;
|
|
4104
|
-
}
|
|
4105
|
-
async function getCacheClient() {
|
|
4106
|
-
if (!cacheClient) {
|
|
4107
|
-
await init3();
|
|
4108
|
-
}
|
|
4109
|
-
return cacheClient;
|
|
4110
|
-
}
|
|
4111
|
-
async function getWritethroughClient() {
|
|
4112
|
-
if (!writethroughClient) {
|
|
4113
|
-
await init3();
|
|
4114
|
-
}
|
|
4115
|
-
return writethroughClient;
|
|
4116
|
-
}
|
|
4117
|
-
async function getLockClient() {
|
|
4118
|
-
if (!lockClient) {
|
|
4119
|
-
await init3();
|
|
4120
|
-
}
|
|
4121
|
-
return lockClient;
|
|
4122
|
-
}
|
|
4123
|
-
async function getSocketClient() {
|
|
4124
|
-
if (!socketClient) {
|
|
4125
|
-
await init3();
|
|
4126
|
-
}
|
|
4127
|
-
return socketClient;
|
|
4128
|
-
}
|
|
4129
|
-
async function getInviteClient() {
|
|
4130
|
-
if (!inviteClient) {
|
|
4131
|
-
await init3();
|
|
4132
|
-
}
|
|
4133
|
-
return inviteClient;
|
|
4134
|
-
}
|
|
4135
|
-
async function getPasswordResetClient() {
|
|
4136
|
-
if (!passwordResetClient) {
|
|
4137
|
-
await init3();
|
|
4138
|
-
}
|
|
4139
|
-
return passwordResetClient;
|
|
4140
|
-
}
|
|
4141
|
-
var userClient, sessionClient, appClient, cacheClient, writethroughClient, lockClient, socketClient, inviteClient, passwordResetClient;
|
|
4142
|
-
var init_init = __esm({
|
|
4143
|
-
"src/redis/init.ts"() {
|
|
4144
|
-
"use strict";
|
|
4145
|
-
init_redis();
|
|
4146
|
-
init_utils3();
|
|
4147
|
-
process.on("exit", async () => {
|
|
4148
|
-
await shutdown();
|
|
4149
|
-
});
|
|
4150
|
-
}
|
|
4151
|
-
});
|
|
4152
|
-
|
|
4153
|
-
// src/cache/appMetadata.ts
|
|
4154
|
-
var appMetadata_exports = {};
|
|
4155
|
-
__export(appMetadata_exports, {
|
|
4156
|
-
AppState: () => AppState,
|
|
4157
|
-
getAppMetadata: () => getAppMetadata,
|
|
4158
|
-
invalidateAppMetadata: () => invalidateAppMetadata
|
|
4159
|
-
});
|
|
4160
|
-
async function populateFromDB(appId) {
|
|
4161
|
-
return doWithDB(
|
|
4162
|
-
appId,
|
|
4163
|
-
(db) => {
|
|
4164
|
-
return db.get("app_metadata" /* APP_METADATA */);
|
|
4165
|
-
},
|
|
4166
|
-
{ skip_setup: true }
|
|
4167
|
-
);
|
|
4168
|
-
}
|
|
4169
|
-
function isInvalid(metadata) {
|
|
4170
|
-
return !metadata || metadata.state === "invalid" /* INVALID */;
|
|
4171
|
-
}
|
|
4172
|
-
async function getAppMetadata(appId) {
|
|
4173
|
-
const client = await getAppClient();
|
|
4174
|
-
let metadata = await client.get(appId);
|
|
4175
|
-
if (!metadata) {
|
|
4176
|
-
let expiry = EXPIRY_SECONDS;
|
|
4177
|
-
try {
|
|
4178
|
-
metadata = await populateFromDB(appId);
|
|
4179
|
-
} catch (err) {
|
|
4180
|
-
if (err && err.status === 404) {
|
|
4181
|
-
metadata = { state: "invalid" /* INVALID */ };
|
|
4182
|
-
expiry = void 0;
|
|
4183
|
-
} else {
|
|
4184
|
-
throw err;
|
|
4185
|
-
}
|
|
4186
|
-
}
|
|
4187
|
-
if (isInvalid(metadata)) {
|
|
4188
|
-
const temp = await client.get(appId);
|
|
4189
|
-
if (temp) {
|
|
4190
|
-
metadata = temp;
|
|
4191
|
-
}
|
|
4192
|
-
}
|
|
4193
|
-
await client.store(appId, metadata, expiry);
|
|
4194
|
-
}
|
|
4195
|
-
return metadata;
|
|
4196
|
-
}
|
|
4197
|
-
async function invalidateAppMetadata(appId, newMetadata) {
|
|
4198
|
-
if (!appId) {
|
|
4199
|
-
throw "Cannot invalidate if no app ID provided.";
|
|
4200
|
-
}
|
|
4201
|
-
const client = await getAppClient();
|
|
4202
|
-
await client.delete(appId);
|
|
4203
|
-
if (newMetadata) {
|
|
4204
|
-
await client.store(appId, newMetadata, EXPIRY_SECONDS);
|
|
4205
|
-
}
|
|
4206
|
-
}
|
|
4207
|
-
var AppState, EXPIRY_SECONDS;
|
|
4208
|
-
var init_appMetadata = __esm({
|
|
4209
|
-
"src/cache/appMetadata.ts"() {
|
|
4210
|
-
"use strict";
|
|
4211
|
-
init_init();
|
|
4212
|
-
init_db4();
|
|
4213
|
-
AppState = /* @__PURE__ */ ((AppState2) => {
|
|
4214
|
-
AppState2["INVALID"] = "invalid";
|
|
4215
|
-
return AppState2;
|
|
4216
|
-
})(AppState || {});
|
|
4217
|
-
EXPIRY_SECONDS = 3600;
|
|
4218
|
-
}
|
|
4219
|
-
});
|
|
4220
|
-
|
|
4221
|
-
// src/docIds/ids.ts
|
|
4222
|
-
function generateRowID(tableId, id) {
|
|
4223
|
-
id = id || newid();
|
|
4224
|
-
return `${"ro" /* ROW */}${SEPARATOR}${tableId}${SEPARATOR}${id}`;
|
|
4225
|
-
}
|
|
4226
|
-
function generateWorkspaceID() {
|
|
4227
|
-
return `${"workspace" /* WORKSPACE */}${SEPARATOR}${newid()}`;
|
|
4228
|
-
}
|
|
4229
|
-
function generateGlobalUserID(id) {
|
|
4230
|
-
return `${"us" /* USER */}${SEPARATOR}${id || newid()}`;
|
|
4231
|
-
}
|
|
4232
|
-
function isGlobalUserID(id) {
|
|
4233
|
-
return isGlobalUserIDRegex.test(id);
|
|
4234
|
-
}
|
|
4235
|
-
function generateUserMetadataID(globalId) {
|
|
4236
|
-
return generateRowID("ta_users" /* USER_METADATA */, globalId);
|
|
3737
|
+
function generateUserMetadataID(globalId) {
|
|
3738
|
+
return generateRowID("ta_users" /* USER_METADATA */, globalId);
|
|
4237
3739
|
}
|
|
4238
3740
|
function getGlobalIDFromUserMetadataID(id) {
|
|
4239
3741
|
const prefix = `${"ro" /* ROW */}${SEPARATOR}${"ta_users" /* USER_METADATA */}${SEPARATOR}`;
|
|
@@ -4548,7 +4050,7 @@ function pagination(data, pageSize, {
|
|
|
4548
4050
|
nextPage
|
|
4549
4051
|
};
|
|
4550
4052
|
}
|
|
4551
|
-
var
|
|
4053
|
+
var init_utils5 = __esm({
|
|
4552
4054
|
"src/db/utils.ts"() {
|
|
4553
4055
|
"use strict";
|
|
4554
4056
|
init_environment2();
|
|
@@ -5563,7 +5065,7 @@ var init_db4 = __esm({
|
|
|
5563
5065
|
"use strict";
|
|
5564
5066
|
init_couch();
|
|
5565
5067
|
init_db3();
|
|
5566
|
-
|
|
5068
|
+
init_utils5();
|
|
5567
5069
|
init_views();
|
|
5568
5070
|
init_conversions();
|
|
5569
5071
|
init_Replication();
|
|
@@ -5575,68 +5077,6 @@ var init_db4 = __esm({
|
|
|
5575
5077
|
}
|
|
5576
5078
|
});
|
|
5577
5079
|
|
|
5578
|
-
// src/logging/correlation/correlation.ts
|
|
5579
|
-
var correlation_exports = {};
|
|
5580
|
-
__export(correlation_exports, {
|
|
5581
|
-
getId: () => getId,
|
|
5582
|
-
setHeader: () => setHeader
|
|
5583
|
-
});
|
|
5584
|
-
function getId() {
|
|
5585
|
-
return correlator.getId();
|
|
5586
|
-
}
|
|
5587
|
-
var correlator, setHeader;
|
|
5588
|
-
var init_correlation = __esm({
|
|
5589
|
-
"src/logging/correlation/correlation.ts"() {
|
|
5590
|
-
"use strict";
|
|
5591
|
-
init_constants4();
|
|
5592
|
-
correlator = require("correlation-id");
|
|
5593
|
-
setHeader = (headers) => {
|
|
5594
|
-
const correlationId = correlator.getId();
|
|
5595
|
-
if (correlationId) {
|
|
5596
|
-
headers["x-budibase-correlation-id" /* CORRELATION_ID */] = correlationId;
|
|
5597
|
-
}
|
|
5598
|
-
};
|
|
5599
|
-
}
|
|
5600
|
-
});
|
|
5601
|
-
|
|
5602
|
-
// src/logging/correlation/index.ts
|
|
5603
|
-
var init_correlation2 = __esm({
|
|
5604
|
-
"src/logging/correlation/index.ts"() {
|
|
5605
|
-
"use strict";
|
|
5606
|
-
init_correlation();
|
|
5607
|
-
}
|
|
5608
|
-
});
|
|
5609
|
-
|
|
5610
|
-
// src/objectStore/utils.ts
|
|
5611
|
-
function budibaseTempDir() {
|
|
5612
|
-
return bbTmp;
|
|
5613
|
-
}
|
|
5614
|
-
var import_path, import_os, import_fs2, ObjectStoreBuckets, bbTmp;
|
|
5615
|
-
var init_utils5 = __esm({
|
|
5616
|
-
"src/objectStore/utils.ts"() {
|
|
5617
|
-
"use strict";
|
|
5618
|
-
import_path = require("path");
|
|
5619
|
-
import_os = require("os");
|
|
5620
|
-
import_fs2 = __toESM(require("fs"));
|
|
5621
|
-
init_environment2();
|
|
5622
|
-
ObjectStoreBuckets = {
|
|
5623
|
-
BACKUPS: environment_default.BACKUPS_BUCKET_NAME,
|
|
5624
|
-
APPS: environment_default.APPS_BUCKET_NAME,
|
|
5625
|
-
TEMPLATES: environment_default.TEMPLATES_BUCKET_NAME,
|
|
5626
|
-
GLOBAL: environment_default.GLOBAL_BUCKET_NAME,
|
|
5627
|
-
PLUGINS: environment_default.PLUGIN_BUCKET_NAME
|
|
5628
|
-
};
|
|
5629
|
-
bbTmp = (0, import_path.join)((0, import_os.tmpdir)(), ".budibase");
|
|
5630
|
-
try {
|
|
5631
|
-
import_fs2.default.mkdirSync(bbTmp);
|
|
5632
|
-
} catch (e) {
|
|
5633
|
-
if (e.code !== "EEXIST") {
|
|
5634
|
-
throw e;
|
|
5635
|
-
}
|
|
5636
|
-
}
|
|
5637
|
-
}
|
|
5638
|
-
});
|
|
5639
|
-
|
|
5640
5080
|
// src/objectStore/objectStore.ts
|
|
5641
5081
|
function sanitizeKey(input) {
|
|
5642
5082
|
return sanitize(sanitizeBucket(input)).replace(/\\/g, "/");
|
|
@@ -5945,7 +5385,7 @@ var init_objectStore = __esm({
|
|
|
5945
5385
|
import_path2 = require("path");
|
|
5946
5386
|
import_fs3 = __toESM(require("fs"));
|
|
5947
5387
|
init_environment2();
|
|
5948
|
-
|
|
5388
|
+
init_utils4();
|
|
5949
5389
|
import_uuid2 = require("uuid");
|
|
5950
5390
|
init_db4();
|
|
5951
5391
|
sanitize = require("sanitize-s3-objectkey");
|
|
@@ -6203,7 +5643,7 @@ var init_objectStore2 = __esm({
|
|
|
6203
5643
|
"src/objectStore/index.ts"() {
|
|
6204
5644
|
"use strict";
|
|
6205
5645
|
init_objectStore();
|
|
6206
|
-
|
|
5646
|
+
init_utils4();
|
|
6207
5647
|
init_buckets();
|
|
6208
5648
|
}
|
|
6209
5649
|
});
|
|
@@ -6291,7 +5731,7 @@ var init_system2 = __esm({
|
|
|
6291
5731
|
});
|
|
6292
5732
|
|
|
6293
5733
|
// src/logging/pino/logger.ts
|
|
6294
|
-
var import_pino, import_pino_pretty,
|
|
5734
|
+
var import_pino, import_pino_pretty, pinoInstance, isPlainObject2, isError2, isMessage2, getLogParams3, logger;
|
|
6295
5735
|
var init_logger = __esm({
|
|
6296
5736
|
"src/logging/pino/logger.ts"() {
|
|
6297
5737
|
"use strict";
|
|
@@ -6300,8 +5740,6 @@ var init_logger = __esm({
|
|
|
6300
5740
|
init_environment2();
|
|
6301
5741
|
init_context2();
|
|
6302
5742
|
init_correlation2();
|
|
6303
|
-
import_dd_trace2 = __toESM(require("dd-trace"));
|
|
6304
|
-
import_ext = require("dd-trace/ext");
|
|
6305
5743
|
init_system2();
|
|
6306
5744
|
if (!environment_default.DISABLE_PINO_LOGGER) {
|
|
6307
5745
|
let isPlainObject = function(obj) {
|
|
@@ -6335,10 +5773,6 @@ var init_logger = __esm({
|
|
|
6335
5773
|
identityType: identity?.type,
|
|
6336
5774
|
correlationId: getId()
|
|
6337
5775
|
};
|
|
6338
|
-
const span = import_dd_trace2.default.scope().active();
|
|
6339
|
-
if (span) {
|
|
6340
|
-
import_dd_trace2.default.inject(span.context(), import_ext.formats.LOG, contextObject);
|
|
6341
|
-
}
|
|
6342
5776
|
const mergingObject = {
|
|
6343
5777
|
err: error,
|
|
6344
5778
|
pid: process.pid,
|
|
@@ -6419,91 +5853,530 @@ var init_logger = __esm({
|
|
|
6419
5853
|
if (!obj.err) {
|
|
6420
5854
|
obj.err = new Error();
|
|
6421
5855
|
}
|
|
6422
|
-
pinoInstance?.trace(obj, msg);
|
|
6423
|
-
};
|
|
6424
|
-
console.debug = (...arg) => {
|
|
6425
|
-
const [obj, msg] = getLogParams2(arg);
|
|
6426
|
-
pinoInstance?.debug(obj, msg);
|
|
6427
|
-
};
|
|
6428
|
-
const getTenantId2 = () => {
|
|
6429
|
-
let tenantId;
|
|
6430
|
-
try {
|
|
6431
|
-
tenantId = getTenantId();
|
|
6432
|
-
} catch (e) {
|
|
5856
|
+
pinoInstance?.trace(obj, msg);
|
|
5857
|
+
};
|
|
5858
|
+
console.debug = (...arg) => {
|
|
5859
|
+
const [obj, msg] = getLogParams2(arg);
|
|
5860
|
+
pinoInstance?.debug(obj, msg);
|
|
5861
|
+
};
|
|
5862
|
+
const getTenantId2 = () => {
|
|
5863
|
+
let tenantId;
|
|
5864
|
+
try {
|
|
5865
|
+
tenantId = getTenantId();
|
|
5866
|
+
} catch (e) {
|
|
5867
|
+
}
|
|
5868
|
+
return tenantId;
|
|
5869
|
+
};
|
|
5870
|
+
const getAppId2 = () => {
|
|
5871
|
+
let appId;
|
|
5872
|
+
try {
|
|
5873
|
+
appId = getAppId();
|
|
5874
|
+
} catch (e) {
|
|
5875
|
+
}
|
|
5876
|
+
return appId;
|
|
5877
|
+
};
|
|
5878
|
+
const getAutomationId2 = () => {
|
|
5879
|
+
let appId;
|
|
5880
|
+
try {
|
|
5881
|
+
appId = getAutomationId();
|
|
5882
|
+
} catch (e) {
|
|
5883
|
+
}
|
|
5884
|
+
return appId;
|
|
5885
|
+
};
|
|
5886
|
+
const getIdentity3 = () => {
|
|
5887
|
+
let identity;
|
|
5888
|
+
try {
|
|
5889
|
+
identity = getIdentity();
|
|
5890
|
+
} catch (e) {
|
|
5891
|
+
}
|
|
5892
|
+
return identity;
|
|
5893
|
+
};
|
|
5894
|
+
}
|
|
5895
|
+
logger = pinoInstance;
|
|
5896
|
+
}
|
|
5897
|
+
});
|
|
5898
|
+
|
|
5899
|
+
// src/logging/alerts.ts
|
|
5900
|
+
function isSuppressed(e) {
|
|
5901
|
+
return e && e["suppressAlert"];
|
|
5902
|
+
}
|
|
5903
|
+
function logAlert(message, e) {
|
|
5904
|
+
if (e && NonErrors.includes(e.name) && isSuppressed(e)) {
|
|
5905
|
+
return;
|
|
5906
|
+
}
|
|
5907
|
+
console.error(`bb-alert: ${message}`, e);
|
|
5908
|
+
}
|
|
5909
|
+
function logAlertWithInfo(message, db, id, error) {
|
|
5910
|
+
message = `${message} - db: ${db} - doc: ${id} - error: `;
|
|
5911
|
+
logAlert(message, error);
|
|
5912
|
+
}
|
|
5913
|
+
function logWarn(message, e) {
|
|
5914
|
+
console.warn(`bb-warn: ${message}`, e);
|
|
5915
|
+
}
|
|
5916
|
+
var NonErrors;
|
|
5917
|
+
var init_alerts = __esm({
|
|
5918
|
+
"src/logging/alerts.ts"() {
|
|
5919
|
+
"use strict";
|
|
5920
|
+
NonErrors = ["AccountError"];
|
|
5921
|
+
}
|
|
5922
|
+
});
|
|
5923
|
+
|
|
5924
|
+
// src/logging/index.ts
|
|
5925
|
+
var logging_exports = {};
|
|
5926
|
+
__export(logging_exports, {
|
|
5927
|
+
correlation: () => correlation_exports,
|
|
5928
|
+
logAlert: () => logAlert,
|
|
5929
|
+
logAlertWithInfo: () => logAlertWithInfo,
|
|
5930
|
+
logWarn: () => logWarn,
|
|
5931
|
+
logger: () => logger,
|
|
5932
|
+
system: () => system_exports
|
|
5933
|
+
});
|
|
5934
|
+
var init_logging = __esm({
|
|
5935
|
+
"src/logging/index.ts"() {
|
|
5936
|
+
"use strict";
|
|
5937
|
+
init_correlation();
|
|
5938
|
+
init_logger();
|
|
5939
|
+
init_alerts();
|
|
5940
|
+
init_system2();
|
|
5941
|
+
}
|
|
5942
|
+
});
|
|
5943
|
+
|
|
5944
|
+
// src/timers/timers.ts
|
|
5945
|
+
function set(callback, period) {
|
|
5946
|
+
const interval = setInterval(callback, period);
|
|
5947
|
+
intervals.push(interval);
|
|
5948
|
+
return interval;
|
|
5949
|
+
}
|
|
5950
|
+
function clear(interval) {
|
|
5951
|
+
const idx = intervals.indexOf(interval);
|
|
5952
|
+
if (idx !== -1) {
|
|
5953
|
+
intervals.splice(idx, 1);
|
|
5954
|
+
}
|
|
5955
|
+
clearInterval(interval);
|
|
5956
|
+
}
|
|
5957
|
+
function cleanup() {
|
|
5958
|
+
for (let interval of intervals) {
|
|
5959
|
+
clearInterval(interval);
|
|
5960
|
+
}
|
|
5961
|
+
intervals = [];
|
|
5962
|
+
}
|
|
5963
|
+
var intervals, ExecutionTimeoutError, ExecutionTimeTracker;
|
|
5964
|
+
var init_timers = __esm({
|
|
5965
|
+
"src/timers/timers.ts"() {
|
|
5966
|
+
"use strict";
|
|
5967
|
+
intervals = [];
|
|
5968
|
+
ExecutionTimeoutError = class extends Error {
|
|
5969
|
+
constructor() {
|
|
5970
|
+
super(...arguments);
|
|
5971
|
+
this.name = "ExecutionTimeoutError";
|
|
5972
|
+
}
|
|
5973
|
+
};
|
|
5974
|
+
ExecutionTimeTracker = class _ExecutionTimeTracker {
|
|
5975
|
+
constructor(limitMs) {
|
|
5976
|
+
this.limitMs = limitMs;
|
|
5977
|
+
this.totalTimeMs = 0;
|
|
5978
|
+
}
|
|
5979
|
+
static withLimit(limitMs) {
|
|
5980
|
+
return new _ExecutionTimeTracker(limitMs);
|
|
5981
|
+
}
|
|
5982
|
+
track(f) {
|
|
5983
|
+
this.checkLimit();
|
|
5984
|
+
const start2 = process.hrtime.bigint();
|
|
5985
|
+
try {
|
|
5986
|
+
return f();
|
|
5987
|
+
} finally {
|
|
5988
|
+
const end2 = process.hrtime.bigint();
|
|
5989
|
+
this.totalTimeMs += Number(end2 - start2) / 1e6;
|
|
5990
|
+
this.checkLimit();
|
|
5991
|
+
}
|
|
5992
|
+
}
|
|
5993
|
+
get elapsedMS() {
|
|
5994
|
+
return this.totalTimeMs;
|
|
5995
|
+
}
|
|
5996
|
+
checkLimit() {
|
|
5997
|
+
if (this.totalTimeMs > this.limitMs) {
|
|
5998
|
+
throw new ExecutionTimeoutError(
|
|
5999
|
+
`Execution time limit of ${this.limitMs}ms exceeded: ${this.totalTimeMs}ms`
|
|
6000
|
+
);
|
|
6001
|
+
}
|
|
6002
|
+
}
|
|
6003
|
+
};
|
|
6004
|
+
}
|
|
6005
|
+
});
|
|
6006
|
+
|
|
6007
|
+
// src/timers/index.ts
|
|
6008
|
+
var timers_exports = {};
|
|
6009
|
+
__export(timers_exports, {
|
|
6010
|
+
ExecutionTimeTracker: () => ExecutionTimeTracker,
|
|
6011
|
+
ExecutionTimeoutError: () => ExecutionTimeoutError,
|
|
6012
|
+
cleanup: () => cleanup,
|
|
6013
|
+
clear: () => clear,
|
|
6014
|
+
set: () => set
|
|
6015
|
+
});
|
|
6016
|
+
var init_timers2 = __esm({
|
|
6017
|
+
"src/timers/index.ts"() {
|
|
6018
|
+
"use strict";
|
|
6019
|
+
init_timers();
|
|
6020
|
+
}
|
|
6021
|
+
});
|
|
6022
|
+
|
|
6023
|
+
// src/redis/redis.ts
|
|
6024
|
+
function pickClient(selectDb) {
|
|
6025
|
+
return CLIENTS[selectDb];
|
|
6026
|
+
}
|
|
6027
|
+
function connectionError(timeout2, err) {
|
|
6028
|
+
if (CLOSED) {
|
|
6029
|
+
return;
|
|
6030
|
+
}
|
|
6031
|
+
CLOSED = true;
|
|
6032
|
+
clearTimeout(timeout2);
|
|
6033
|
+
CONNECTED = false;
|
|
6034
|
+
logAlert("Redis connection failed", err);
|
|
6035
|
+
setTimeout(() => {
|
|
6036
|
+
init2();
|
|
6037
|
+
}, RETRY_PERIOD_MS);
|
|
6038
|
+
}
|
|
6039
|
+
function init2(selectDb = DEFAULT_SELECT_DB) {
|
|
6040
|
+
const RedisCore = environment_default.MOCK_REDIS && MockRedis ? MockRedis : import_ioredis.default;
|
|
6041
|
+
let timeout2;
|
|
6042
|
+
CLOSED = false;
|
|
6043
|
+
let client = pickClient(selectDb);
|
|
6044
|
+
if (client && CONNECTED) {
|
|
6045
|
+
return;
|
|
6046
|
+
}
|
|
6047
|
+
if (environment_default.MOCK_REDIS) {
|
|
6048
|
+
CLIENTS[selectDb] = new RedisCore(getRedisOptions());
|
|
6049
|
+
}
|
|
6050
|
+
timeout2 = setTimeout(() => {
|
|
6051
|
+
if (!CONNECTED) {
|
|
6052
|
+
connectionError(timeout2, "Did not successfully connect in timeout");
|
|
6053
|
+
}
|
|
6054
|
+
}, STARTUP_TIMEOUT_MS);
|
|
6055
|
+
if (client) {
|
|
6056
|
+
client.disconnect();
|
|
6057
|
+
}
|
|
6058
|
+
const { host, port } = getRedisConnectionDetails();
|
|
6059
|
+
const opts = getRedisOptions();
|
|
6060
|
+
if (CLUSTERED) {
|
|
6061
|
+
client = new RedisCore.Cluster([{ host, port }], opts);
|
|
6062
|
+
} else {
|
|
6063
|
+
client = new RedisCore(opts);
|
|
6064
|
+
}
|
|
6065
|
+
client.on("end", (err) => {
|
|
6066
|
+
if (environment_default.isTest()) {
|
|
6067
|
+
return;
|
|
6068
|
+
}
|
|
6069
|
+
connectionError(timeout2, err);
|
|
6070
|
+
});
|
|
6071
|
+
client.on("error", (err) => {
|
|
6072
|
+
connectionError(timeout2, err);
|
|
6073
|
+
});
|
|
6074
|
+
client.on("connect", () => {
|
|
6075
|
+
console.log(`Connected to Redis DB: ${selectDb}`);
|
|
6076
|
+
clearTimeout(timeout2);
|
|
6077
|
+
CONNECTED = true;
|
|
6078
|
+
});
|
|
6079
|
+
CLIENTS[selectDb] = client;
|
|
6080
|
+
}
|
|
6081
|
+
function waitForConnection(selectDb = DEFAULT_SELECT_DB) {
|
|
6082
|
+
return new Promise((resolve) => {
|
|
6083
|
+
if (pickClient(selectDb) == null) {
|
|
6084
|
+
init2();
|
|
6085
|
+
} else if (CONNECTED) {
|
|
6086
|
+
resolve("");
|
|
6087
|
+
return;
|
|
6088
|
+
}
|
|
6089
|
+
const interval = set(() => {
|
|
6090
|
+
if (CONNECTED) {
|
|
6091
|
+
clear(interval);
|
|
6092
|
+
resolve("");
|
|
6093
|
+
}
|
|
6094
|
+
}, 500);
|
|
6095
|
+
});
|
|
6096
|
+
}
|
|
6097
|
+
function promisifyStream(stream2, client) {
|
|
6098
|
+
return new Promise((resolve, reject) => {
|
|
6099
|
+
const outputKeys = /* @__PURE__ */ new Set();
|
|
6100
|
+
stream2.on("data", (keys2) => {
|
|
6101
|
+
keys2.forEach((key) => {
|
|
6102
|
+
outputKeys.add(key);
|
|
6103
|
+
});
|
|
6104
|
+
});
|
|
6105
|
+
stream2.on("error", (err) => {
|
|
6106
|
+
reject(err);
|
|
6107
|
+
});
|
|
6108
|
+
stream2.on("end", async () => {
|
|
6109
|
+
const keysArray = Array.from(outputKeys);
|
|
6110
|
+
try {
|
|
6111
|
+
let getPromises = [];
|
|
6112
|
+
for (let key of keysArray) {
|
|
6113
|
+
getPromises.push(client.get(key));
|
|
6114
|
+
}
|
|
6115
|
+
const jsonArray = await Promise.all(getPromises);
|
|
6116
|
+
resolve(
|
|
6117
|
+
keysArray.map((key) => ({
|
|
6118
|
+
key: removeDbPrefix(key),
|
|
6119
|
+
value: JSON.parse(jsonArray.shift())
|
|
6120
|
+
}))
|
|
6121
|
+
);
|
|
6122
|
+
} catch (err) {
|
|
6123
|
+
reject(err);
|
|
6124
|
+
}
|
|
6125
|
+
});
|
|
6126
|
+
});
|
|
6127
|
+
}
|
|
6128
|
+
var import_ioredis, MockRedis, RETRY_PERIOD_MS, STARTUP_TIMEOUT_MS, CLUSTERED, DEFAULT_SELECT_DB, CLOSED, CLIENTS, CONNECTED, RedisWrapper, redis_default;
|
|
6129
|
+
var init_redis = __esm({
|
|
6130
|
+
"src/redis/redis.ts"() {
|
|
6131
|
+
"use strict";
|
|
6132
|
+
init_environment2();
|
|
6133
|
+
import_ioredis = __toESM(require("ioredis"));
|
|
6134
|
+
init_utils3();
|
|
6135
|
+
init_logging();
|
|
6136
|
+
init_timers2();
|
|
6137
|
+
if (environment_default.MOCK_REDIS) {
|
|
6138
|
+
try {
|
|
6139
|
+
MockRedis = require("ioredis-mock");
|
|
6140
|
+
} catch (err) {
|
|
6141
|
+
console.log("Mock redis unavailable");
|
|
6142
|
+
}
|
|
6143
|
+
}
|
|
6144
|
+
RETRY_PERIOD_MS = 2e3;
|
|
6145
|
+
STARTUP_TIMEOUT_MS = 5e3;
|
|
6146
|
+
CLUSTERED = environment_default.REDIS_CLUSTERED;
|
|
6147
|
+
DEFAULT_SELECT_DB = 0 /* DEFAULT */;
|
|
6148
|
+
CLOSED = false;
|
|
6149
|
+
CLIENTS = {};
|
|
6150
|
+
CONNECTED = false;
|
|
6151
|
+
if (environment_default.MOCK_REDIS) {
|
|
6152
|
+
CONNECTED = true;
|
|
6153
|
+
}
|
|
6154
|
+
RedisWrapper = class {
|
|
6155
|
+
constructor(db, selectDb = null) {
|
|
6156
|
+
this._db = db;
|
|
6157
|
+
this._select = selectDb || DEFAULT_SELECT_DB;
|
|
6158
|
+
}
|
|
6159
|
+
getClient() {
|
|
6160
|
+
return pickClient(this._select);
|
|
6161
|
+
}
|
|
6162
|
+
async init() {
|
|
6163
|
+
CLOSED = false;
|
|
6164
|
+
init2(this._select);
|
|
6165
|
+
await waitForConnection(this._select);
|
|
6166
|
+
if (this._select && !environment_default.isTest()) {
|
|
6167
|
+
this.getClient().select(this._select);
|
|
6168
|
+
}
|
|
6169
|
+
return this;
|
|
6170
|
+
}
|
|
6171
|
+
async finish() {
|
|
6172
|
+
CLOSED = true;
|
|
6173
|
+
this.getClient().disconnect();
|
|
6174
|
+
}
|
|
6175
|
+
async scan(key = "") {
|
|
6176
|
+
const db = this._db;
|
|
6177
|
+
key = `${db}${SEPARATOR2}${key}`;
|
|
6178
|
+
let stream2;
|
|
6179
|
+
if (CLUSTERED) {
|
|
6180
|
+
let node = this.getClient().nodes("master");
|
|
6181
|
+
stream2 = node[0].scanStream({ match: key + "*", count: 100 });
|
|
6182
|
+
} else {
|
|
6183
|
+
stream2 = this.getClient().scanStream({ match: key + "*", count: 100 });
|
|
6184
|
+
}
|
|
6185
|
+
return promisifyStream(stream2, this.getClient());
|
|
6186
|
+
}
|
|
6187
|
+
async keys(pattern) {
|
|
6188
|
+
const db = this._db;
|
|
6189
|
+
return this.getClient().keys(addDbPrefix(db, pattern));
|
|
6190
|
+
}
|
|
6191
|
+
async exists(key) {
|
|
6192
|
+
const db = this._db;
|
|
6193
|
+
return await this.getClient().exists(addDbPrefix(db, key));
|
|
6194
|
+
}
|
|
6195
|
+
async get(key) {
|
|
6196
|
+
const db = this._db;
|
|
6197
|
+
let response = await this.getClient().get(addDbPrefix(db, key));
|
|
6198
|
+
if (response != null && response.key) {
|
|
6199
|
+
response.key = key;
|
|
6433
6200
|
}
|
|
6434
|
-
return tenantId;
|
|
6435
|
-
};
|
|
6436
|
-
const getAppId2 = () => {
|
|
6437
|
-
let appId;
|
|
6438
6201
|
try {
|
|
6439
|
-
|
|
6440
|
-
} catch (
|
|
6202
|
+
return JSON.parse(response);
|
|
6203
|
+
} catch (err) {
|
|
6204
|
+
return response;
|
|
6441
6205
|
}
|
|
6442
|
-
|
|
6443
|
-
|
|
6444
|
-
|
|
6445
|
-
|
|
6446
|
-
|
|
6447
|
-
appId = getAutomationId();
|
|
6448
|
-
} catch (e) {
|
|
6206
|
+
}
|
|
6207
|
+
async bulkGet(keys2) {
|
|
6208
|
+
const db = this._db;
|
|
6209
|
+
if (keys2.length === 0) {
|
|
6210
|
+
return {};
|
|
6449
6211
|
}
|
|
6450
|
-
|
|
6451
|
-
|
|
6452
|
-
|
|
6453
|
-
|
|
6454
|
-
|
|
6455
|
-
|
|
6456
|
-
|
|
6212
|
+
const prefixedKeys = keys2.map((key) => addDbPrefix(db, key));
|
|
6213
|
+
let response = await this.getClient().mget(prefixedKeys);
|
|
6214
|
+
if (Array.isArray(response)) {
|
|
6215
|
+
let final = {};
|
|
6216
|
+
let count = 0;
|
|
6217
|
+
for (let result of response) {
|
|
6218
|
+
if (result) {
|
|
6219
|
+
let parsed;
|
|
6220
|
+
try {
|
|
6221
|
+
parsed = JSON.parse(result);
|
|
6222
|
+
} catch (err) {
|
|
6223
|
+
parsed = result;
|
|
6224
|
+
}
|
|
6225
|
+
final[keys2[count]] = parsed;
|
|
6226
|
+
}
|
|
6227
|
+
count++;
|
|
6228
|
+
}
|
|
6229
|
+
return final;
|
|
6230
|
+
} else {
|
|
6231
|
+
throw new Error(`Invalid response: ${response}`);
|
|
6457
6232
|
}
|
|
6458
|
-
|
|
6459
|
-
|
|
6460
|
-
|
|
6461
|
-
|
|
6233
|
+
}
|
|
6234
|
+
async store(key, value, expirySeconds = null) {
|
|
6235
|
+
const db = this._db;
|
|
6236
|
+
if (typeof value === "object") {
|
|
6237
|
+
value = JSON.stringify(value);
|
|
6238
|
+
}
|
|
6239
|
+
const prefixedKey = addDbPrefix(db, key);
|
|
6240
|
+
await this.getClient().set(prefixedKey, value);
|
|
6241
|
+
if (expirySeconds) {
|
|
6242
|
+
await this.getClient().expire(prefixedKey, expirySeconds);
|
|
6243
|
+
}
|
|
6244
|
+
}
|
|
6245
|
+
async getTTL(key) {
|
|
6246
|
+
const db = this._db;
|
|
6247
|
+
const prefixedKey = addDbPrefix(db, key);
|
|
6248
|
+
return this.getClient().ttl(prefixedKey);
|
|
6249
|
+
}
|
|
6250
|
+
async setExpiry(key, expirySeconds) {
|
|
6251
|
+
const db = this._db;
|
|
6252
|
+
const prefixedKey = addDbPrefix(db, key);
|
|
6253
|
+
await this.getClient().expire(prefixedKey, expirySeconds);
|
|
6254
|
+
}
|
|
6255
|
+
async delete(key) {
|
|
6256
|
+
const db = this._db;
|
|
6257
|
+
await this.getClient().del(addDbPrefix(db, key));
|
|
6258
|
+
}
|
|
6259
|
+
async clear() {
|
|
6260
|
+
let items = await this.scan();
|
|
6261
|
+
await Promise.all(items.map((obj) => this.delete(obj.key)));
|
|
6262
|
+
}
|
|
6263
|
+
};
|
|
6264
|
+
redis_default = RedisWrapper;
|
|
6462
6265
|
}
|
|
6463
6266
|
});
|
|
6464
6267
|
|
|
6465
|
-
// src/
|
|
6466
|
-
|
|
6467
|
-
|
|
6268
|
+
// src/redis/init.ts
|
|
6269
|
+
var init_exports = {};
|
|
6270
|
+
__export(init_exports, {
|
|
6271
|
+
getAppClient: () => getAppClient,
|
|
6272
|
+
getCacheClient: () => getCacheClient,
|
|
6273
|
+
getInviteClient: () => getInviteClient,
|
|
6274
|
+
getLockClient: () => getLockClient,
|
|
6275
|
+
getPasswordResetClient: () => getPasswordResetClient,
|
|
6276
|
+
getSessionClient: () => getSessionClient,
|
|
6277
|
+
getSocketClient: () => getSocketClient,
|
|
6278
|
+
getUserClient: () => getUserClient,
|
|
6279
|
+
getWritethroughClient: () => getWritethroughClient,
|
|
6280
|
+
init: () => init3,
|
|
6281
|
+
shutdown: () => shutdown
|
|
6282
|
+
});
|
|
6283
|
+
async function init3() {
|
|
6284
|
+
userClient = await new redis_default("users" /* USER_CACHE */).init();
|
|
6285
|
+
sessionClient = await new redis_default("session" /* SESSIONS */).init();
|
|
6286
|
+
appClient = await new redis_default("appMetadata" /* APP_METADATA */).init();
|
|
6287
|
+
cacheClient = await new redis_default("data_cache" /* GENERIC_CACHE */).init();
|
|
6288
|
+
lockClient = await new redis_default("locks" /* LOCKS */).init();
|
|
6289
|
+
writethroughClient = await new redis_default("writeThrough" /* WRITE_THROUGH */).init();
|
|
6290
|
+
inviteClient = await new redis_default("invitation" /* INVITATIONS */).init();
|
|
6291
|
+
passwordResetClient = await new redis_default("pwReset" /* PW_RESETS */).init();
|
|
6292
|
+
socketClient = await new redis_default(
|
|
6293
|
+
"socket_io" /* SOCKET_IO */,
|
|
6294
|
+
1 /* SOCKET_IO */
|
|
6295
|
+
).init();
|
|
6468
6296
|
}
|
|
6469
|
-
function
|
|
6470
|
-
if (
|
|
6471
|
-
|
|
6297
|
+
async function shutdown() {
|
|
6298
|
+
if (userClient)
|
|
6299
|
+
await userClient.finish();
|
|
6300
|
+
if (sessionClient)
|
|
6301
|
+
await sessionClient.finish();
|
|
6302
|
+
if (appClient)
|
|
6303
|
+
await appClient.finish();
|
|
6304
|
+
if (cacheClient)
|
|
6305
|
+
await cacheClient.finish();
|
|
6306
|
+
if (writethroughClient)
|
|
6307
|
+
await writethroughClient.finish();
|
|
6308
|
+
if (lockClient)
|
|
6309
|
+
await lockClient.finish();
|
|
6310
|
+
if (inviteClient)
|
|
6311
|
+
await inviteClient.finish();
|
|
6312
|
+
if (passwordResetClient)
|
|
6313
|
+
await passwordResetClient.finish();
|
|
6314
|
+
if (socketClient)
|
|
6315
|
+
await socketClient.finish();
|
|
6316
|
+
}
|
|
6317
|
+
async function getUserClient() {
|
|
6318
|
+
if (!userClient) {
|
|
6319
|
+
await init3();
|
|
6472
6320
|
}
|
|
6473
|
-
|
|
6321
|
+
return userClient;
|
|
6474
6322
|
}
|
|
6475
|
-
function
|
|
6476
|
-
|
|
6477
|
-
|
|
6323
|
+
async function getSessionClient() {
|
|
6324
|
+
if (!sessionClient) {
|
|
6325
|
+
await init3();
|
|
6326
|
+
}
|
|
6327
|
+
return sessionClient;
|
|
6478
6328
|
}
|
|
6479
|
-
function
|
|
6480
|
-
|
|
6329
|
+
async function getAppClient() {
|
|
6330
|
+
if (!appClient) {
|
|
6331
|
+
await init3();
|
|
6332
|
+
}
|
|
6333
|
+
return appClient;
|
|
6481
6334
|
}
|
|
6482
|
-
|
|
6483
|
-
|
|
6484
|
-
|
|
6485
|
-
"use strict";
|
|
6486
|
-
NonErrors = ["AccountError"];
|
|
6335
|
+
async function getCacheClient() {
|
|
6336
|
+
if (!cacheClient) {
|
|
6337
|
+
await init3();
|
|
6487
6338
|
}
|
|
6488
|
-
|
|
6489
|
-
|
|
6490
|
-
|
|
6491
|
-
|
|
6492
|
-
|
|
6493
|
-
|
|
6494
|
-
|
|
6495
|
-
|
|
6496
|
-
|
|
6497
|
-
|
|
6498
|
-
|
|
6499
|
-
}
|
|
6500
|
-
|
|
6501
|
-
|
|
6339
|
+
return cacheClient;
|
|
6340
|
+
}
|
|
6341
|
+
async function getWritethroughClient() {
|
|
6342
|
+
if (!writethroughClient) {
|
|
6343
|
+
await init3();
|
|
6344
|
+
}
|
|
6345
|
+
return writethroughClient;
|
|
6346
|
+
}
|
|
6347
|
+
async function getLockClient() {
|
|
6348
|
+
if (!lockClient) {
|
|
6349
|
+
await init3();
|
|
6350
|
+
}
|
|
6351
|
+
return lockClient;
|
|
6352
|
+
}
|
|
6353
|
+
async function getSocketClient() {
|
|
6354
|
+
if (!socketClient) {
|
|
6355
|
+
await init3();
|
|
6356
|
+
}
|
|
6357
|
+
return socketClient;
|
|
6358
|
+
}
|
|
6359
|
+
async function getInviteClient() {
|
|
6360
|
+
if (!inviteClient) {
|
|
6361
|
+
await init3();
|
|
6362
|
+
}
|
|
6363
|
+
return inviteClient;
|
|
6364
|
+
}
|
|
6365
|
+
async function getPasswordResetClient() {
|
|
6366
|
+
if (!passwordResetClient) {
|
|
6367
|
+
await init3();
|
|
6368
|
+
}
|
|
6369
|
+
return passwordResetClient;
|
|
6370
|
+
}
|
|
6371
|
+
var userClient, sessionClient, appClient, cacheClient, writethroughClient, lockClient, socketClient, inviteClient, passwordResetClient;
|
|
6372
|
+
var init_init = __esm({
|
|
6373
|
+
"src/redis/init.ts"() {
|
|
6502
6374
|
"use strict";
|
|
6503
|
-
|
|
6504
|
-
|
|
6505
|
-
|
|
6506
|
-
|
|
6375
|
+
init_redis();
|
|
6376
|
+
init_utils3();
|
|
6377
|
+
process.on("exit", async () => {
|
|
6378
|
+
await shutdown();
|
|
6379
|
+
});
|
|
6507
6380
|
}
|
|
6508
6381
|
});
|
|
6509
6382
|
|
|
@@ -8164,7 +8037,8 @@ function newJob(queue, message) {
|
|
|
8164
8037
|
return {
|
|
8165
8038
|
timestamp: Date.now(),
|
|
8166
8039
|
queue,
|
|
8167
|
-
data: message
|
|
8040
|
+
data: message,
|
|
8041
|
+
opts: {}
|
|
8168
8042
|
};
|
|
8169
8043
|
}
|
|
8170
8044
|
var InMemoryQueue = class {
|
|
@@ -8432,7 +8306,7 @@ function createQueue(jobQueue, opts = {}) {
|
|
|
8432
8306
|
if (!cleanupInterval && !environment_default.isTest()) {
|
|
8433
8307
|
cleanupInterval = set(cleanup2, CLEANUP_PERIOD_MS);
|
|
8434
8308
|
cleanup2().catch((err) => {
|
|
8435
|
-
console.error(`Unable to cleanup
|
|
8309
|
+
console.error(`Unable to cleanup ${jobQueue} initially - ${err}`);
|
|
8436
8310
|
});
|
|
8437
8311
|
}
|
|
8438
8312
|
return queue;
|