@budibase/backend-core 2.9.24-alpha.3 → 2.9.24
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 +330 -267
- 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 +1 -1
- package/dist/plugins.js.map +2 -2
- package/dist/plugins.js.meta.json +1 -1
- package/dist/tests.js +260 -222
- package/dist/tests.js.map +4 -4
- package/dist/tests.js.meta.json +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -29,6 +29,28 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
29
29
|
mod
|
|
30
30
|
));
|
|
31
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
+
var __accessCheck = (obj, member, msg) => {
|
|
33
|
+
if (!member.has(obj))
|
|
34
|
+
throw TypeError("Cannot " + msg);
|
|
35
|
+
};
|
|
36
|
+
var __privateGet = (obj, member, getter) => {
|
|
37
|
+
__accessCheck(obj, member, "read from private field");
|
|
38
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
39
|
+
};
|
|
40
|
+
var __privateAdd = (obj, member, value) => {
|
|
41
|
+
if (member.has(obj))
|
|
42
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
43
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
44
|
+
};
|
|
45
|
+
var __privateSet = (obj, member, value, setter) => {
|
|
46
|
+
__accessCheck(obj, member, "write to private field");
|
|
47
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
48
|
+
return value;
|
|
49
|
+
};
|
|
50
|
+
var __privateMethod = (obj, member, method) => {
|
|
51
|
+
__accessCheck(obj, member, "access private method");
|
|
52
|
+
return method;
|
|
53
|
+
};
|
|
32
54
|
|
|
33
55
|
// ../types/src/sdk/automations/index.ts
|
|
34
56
|
var init_automations = __esm({
|
|
@@ -683,19 +705,13 @@ var init_permissions = __esm({
|
|
|
683
705
|
PermissionType2["WEBHOOK"] = "webhook";
|
|
684
706
|
PermissionType2["BUILDER"] = "builder";
|
|
685
707
|
PermissionType2["GLOBAL_BUILDER"] = "globalBuilder";
|
|
708
|
+
PermissionType2["VIEW"] = "view";
|
|
686
709
|
PermissionType2["QUERY"] = "query";
|
|
687
710
|
return PermissionType2;
|
|
688
711
|
})(PermissionType || {});
|
|
689
712
|
}
|
|
690
713
|
});
|
|
691
714
|
|
|
692
|
-
// ../types/src/sdk/row.ts
|
|
693
|
-
var init_row = __esm({
|
|
694
|
-
"../types/src/sdk/row.ts"() {
|
|
695
|
-
"use strict";
|
|
696
|
-
}
|
|
697
|
-
});
|
|
698
|
-
|
|
699
715
|
// ../types/src/sdk/index.ts
|
|
700
716
|
var init_sdk = __esm({
|
|
701
717
|
"../types/src/sdk/index.ts"() {
|
|
@@ -721,7 +737,6 @@ var init_sdk = __esm({
|
|
|
721
737
|
init_cli();
|
|
722
738
|
init_websocket();
|
|
723
739
|
init_permissions();
|
|
724
|
-
init_row();
|
|
725
740
|
}
|
|
726
741
|
});
|
|
727
742
|
|
|
@@ -951,7 +966,7 @@ var init_document = __esm({
|
|
|
951
966
|
});
|
|
952
967
|
|
|
953
968
|
// ../types/src/documents/app/row.ts
|
|
954
|
-
var
|
|
969
|
+
var init_row = __esm({
|
|
955
970
|
"../types/src/documents/app/row.ts"() {
|
|
956
971
|
"use strict";
|
|
957
972
|
}
|
|
@@ -1006,7 +1021,7 @@ var init_app3 = __esm({
|
|
|
1006
1021
|
init_screen2();
|
|
1007
1022
|
init_view2();
|
|
1008
1023
|
init_document();
|
|
1009
|
-
|
|
1024
|
+
init_row();
|
|
1010
1025
|
init_user4();
|
|
1011
1026
|
init_backup2();
|
|
1012
1027
|
init_webhook();
|
|
@@ -1286,7 +1301,7 @@ var init_datasource3 = __esm({
|
|
|
1286
1301
|
});
|
|
1287
1302
|
|
|
1288
1303
|
// ../types/src/api/web/app/row.ts
|
|
1289
|
-
var
|
|
1304
|
+
var init_row2 = __esm({
|
|
1290
1305
|
"../types/src/api/web/app/row.ts"() {
|
|
1291
1306
|
"use strict";
|
|
1292
1307
|
}
|
|
@@ -1319,7 +1334,7 @@ var init_app4 = __esm({
|
|
|
1319
1334
|
"use strict";
|
|
1320
1335
|
init_backup3();
|
|
1321
1336
|
init_datasource3();
|
|
1322
|
-
|
|
1337
|
+
init_row2();
|
|
1323
1338
|
init_view3();
|
|
1324
1339
|
init_rows2();
|
|
1325
1340
|
init_table4();
|
|
@@ -1412,13 +1427,6 @@ var init_pagination = __esm({
|
|
|
1412
1427
|
}
|
|
1413
1428
|
});
|
|
1414
1429
|
|
|
1415
|
-
// ../types/src/api/web/searchFilter.ts
|
|
1416
|
-
var init_searchFilter = __esm({
|
|
1417
|
-
"../types/src/api/web/searchFilter.ts"() {
|
|
1418
|
-
"use strict";
|
|
1419
|
-
}
|
|
1420
|
-
});
|
|
1421
|
-
|
|
1422
1430
|
// ../types/src/api/web/index.ts
|
|
1423
1431
|
var init_web = __esm({
|
|
1424
1432
|
"../types/src/api/web/index.ts"() {
|
|
@@ -1433,7 +1441,6 @@ var init_web = __esm({
|
|
|
1433
1441
|
init_app4();
|
|
1434
1442
|
init_global2();
|
|
1435
1443
|
init_pagination();
|
|
1436
|
-
init_searchFilter();
|
|
1437
1444
|
}
|
|
1438
1445
|
});
|
|
1439
1446
|
|
|
@@ -1865,15 +1872,12 @@ var init_environment2 = __esm({
|
|
|
1865
1872
|
});
|
|
1866
1873
|
|
|
1867
1874
|
// src/context/Context.ts
|
|
1868
|
-
var import_async_hooks, Context;
|
|
1875
|
+
var import_async_hooks, _Context, Context;
|
|
1869
1876
|
var init_Context = __esm({
|
|
1870
1877
|
"src/context/Context.ts"() {
|
|
1871
1878
|
"use strict";
|
|
1872
1879
|
import_async_hooks = require("async_hooks");
|
|
1873
|
-
|
|
1874
|
-
static {
|
|
1875
|
-
this.storage = new import_async_hooks.AsyncLocalStorage();
|
|
1876
|
-
}
|
|
1880
|
+
_Context = class _Context {
|
|
1877
1881
|
static run(context, func) {
|
|
1878
1882
|
return _Context.storage.run(context, () => func());
|
|
1879
1883
|
}
|
|
@@ -1881,6 +1885,8 @@ var init_Context = __esm({
|
|
|
1881
1885
|
return _Context.storage.getStore();
|
|
1882
1886
|
}
|
|
1883
1887
|
};
|
|
1888
|
+
_Context.storage = new import_async_hooks.AsyncLocalStorage();
|
|
1889
|
+
Context = _Context;
|
|
1884
1890
|
}
|
|
1885
1891
|
});
|
|
1886
1892
|
|
|
@@ -1922,7 +1928,7 @@ function getProdAppID(appId) {
|
|
|
1922
1928
|
return `${APP_PREFIX}${rest}`;
|
|
1923
1929
|
}
|
|
1924
1930
|
function extractAppUUID(id) {
|
|
1925
|
-
const split = id
|
|
1931
|
+
const split = (id == null ? void 0 : id.split("_")) || [];
|
|
1926
1932
|
return split.length ? split[split.length - 1] : null;
|
|
1927
1933
|
}
|
|
1928
1934
|
var NO_APP_ERROR, getDevAppID;
|
|
@@ -1942,17 +1948,18 @@ var init_connections = __esm({
|
|
|
1942
1948
|
"use strict";
|
|
1943
1949
|
init_environment2();
|
|
1944
1950
|
getCouchInfo = (connection) => {
|
|
1951
|
+
var _a, _b;
|
|
1945
1952
|
const urlInfo = getUrlInfo(connection);
|
|
1946
1953
|
let username;
|
|
1947
1954
|
let password;
|
|
1948
|
-
if (urlInfo.auth
|
|
1955
|
+
if ((_a = urlInfo.auth) == null ? void 0 : _a.username) {
|
|
1949
1956
|
username = urlInfo.auth.username;
|
|
1950
1957
|
} else if (environment_default.COUCH_DB_USERNAME) {
|
|
1951
1958
|
username = environment_default.COUCH_DB_USERNAME;
|
|
1952
1959
|
} else if (!environment_default.isTest()) {
|
|
1953
1960
|
throw new Error("CouchDB username not set");
|
|
1954
1961
|
}
|
|
1955
|
-
if (urlInfo.auth
|
|
1962
|
+
if ((_b = urlInfo.auth) == null ? void 0 : _b.password) {
|
|
1956
1963
|
password = urlInfo.auth.password;
|
|
1957
1964
|
} else if (environment_default.COUCH_DB_PASSWORD) {
|
|
1958
1965
|
password = environment_default.COUCH_DB_PASSWORD;
|
|
@@ -2211,7 +2218,8 @@ var init_DatabaseImpl = __esm({
|
|
|
2211
2218
|
return this.instanceNano || _DatabaseImpl.nano;
|
|
2212
2219
|
}
|
|
2213
2220
|
async checkSetup() {
|
|
2214
|
-
|
|
2221
|
+
var _a;
|
|
2222
|
+
let shouldCreate = !((_a = this.pouchOpts) == null ? void 0 : _a.skip_setup);
|
|
2215
2223
|
let exists2 = await this.exists();
|
|
2216
2224
|
if (!shouldCreate && !exists2) {
|
|
2217
2225
|
throw new Error("DB does not exist");
|
|
@@ -2287,7 +2295,7 @@ var init_DatabaseImpl = __esm({
|
|
|
2287
2295
|
document.createdAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
2288
2296
|
}
|
|
2289
2297
|
document.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
2290
|
-
if (opts
|
|
2298
|
+
if ((opts == null ? void 0 : opts.force) && document._id) {
|
|
2291
2299
|
try {
|
|
2292
2300
|
const existing = await this.get(document._id);
|
|
2293
2301
|
if (existing) {
|
|
@@ -2451,7 +2459,7 @@ function isMultiTenant() {
|
|
|
2451
2459
|
}
|
|
2452
2460
|
function isTenantIdSet() {
|
|
2453
2461
|
const context = Context.get();
|
|
2454
|
-
return !!context
|
|
2462
|
+
return !!(context == null ? void 0 : context.tenantId);
|
|
2455
2463
|
}
|
|
2456
2464
|
function isTenancyEnabled() {
|
|
2457
2465
|
return environment_default.MULTI_TENANCY;
|
|
@@ -2550,7 +2558,7 @@ async function doInIdentityContext(identity, task) {
|
|
|
2550
2558
|
function getIdentity() {
|
|
2551
2559
|
try {
|
|
2552
2560
|
const context = Context.get();
|
|
2553
|
-
return context
|
|
2561
|
+
return context == null ? void 0 : context.identity;
|
|
2554
2562
|
} catch (e) {
|
|
2555
2563
|
}
|
|
2556
2564
|
}
|
|
@@ -2559,7 +2567,7 @@ function getTenantId() {
|
|
|
2559
2567
|
return DEFAULT_TENANT_ID;
|
|
2560
2568
|
}
|
|
2561
2569
|
const context = Context.get();
|
|
2562
|
-
const tenantId = context
|
|
2570
|
+
const tenantId = context == null ? void 0 : context.tenantId;
|
|
2563
2571
|
if (!tenantId) {
|
|
2564
2572
|
throw new Error("Tenant id not found");
|
|
2565
2573
|
}
|
|
@@ -2567,11 +2575,11 @@ function getTenantId() {
|
|
|
2567
2575
|
}
|
|
2568
2576
|
function getAutomationId() {
|
|
2569
2577
|
const context = Context.get();
|
|
2570
|
-
return context
|
|
2578
|
+
return context == null ? void 0 : context.automationId;
|
|
2571
2579
|
}
|
|
2572
2580
|
function getAppId() {
|
|
2573
2581
|
const context = Context.get();
|
|
2574
|
-
const foundId = context
|
|
2582
|
+
const foundId = context == null ? void 0 : context.appId;
|
|
2575
2583
|
if (!foundId && environment_default.isTest() && TEST_APP_ID) {
|
|
2576
2584
|
return TEST_APP_ID;
|
|
2577
2585
|
} else {
|
|
@@ -2606,7 +2614,7 @@ function getGlobalDB() {
|
|
|
2606
2614
|
if (!context || environment_default.MULTI_TENANCY && !context.tenantId) {
|
|
2607
2615
|
throw new Error("Global DB not found");
|
|
2608
2616
|
}
|
|
2609
|
-
return getDB(baseGlobalDBName(context
|
|
2617
|
+
return getDB(baseGlobalDBName(context == null ? void 0 : context.tenantId));
|
|
2610
2618
|
}
|
|
2611
2619
|
function getAuditLogsDB() {
|
|
2612
2620
|
if (!getTenantId()) {
|
|
@@ -2634,7 +2642,7 @@ function getDevAppDB(opts) {
|
|
|
2634
2642
|
}
|
|
2635
2643
|
function isScim() {
|
|
2636
2644
|
const context = Context.get();
|
|
2637
|
-
const scimCall = context
|
|
2645
|
+
const scimCall = context == null ? void 0 : context.isScim;
|
|
2638
2646
|
return !!scimCall;
|
|
2639
2647
|
}
|
|
2640
2648
|
var TEST_APP_ID, getProdAppId;
|
|
@@ -3485,7 +3493,7 @@ function getGlobalUserParams(globalId, otherProps = {}) {
|
|
|
3485
3493
|
if (!globalId) {
|
|
3486
3494
|
globalId = "";
|
|
3487
3495
|
}
|
|
3488
|
-
const startkey = otherProps
|
|
3496
|
+
const startkey = otherProps == null ? void 0 : otherProps.startkey;
|
|
3489
3497
|
return {
|
|
3490
3498
|
...otherProps,
|
|
3491
3499
|
// need to include this incase pagination
|
|
@@ -3618,7 +3626,10 @@ async function getAllApps({
|
|
|
3618
3626
|
} else {
|
|
3619
3627
|
const response = await Promise.allSettled(appPromises);
|
|
3620
3628
|
const apps = response.filter(
|
|
3621
|
-
(result) =>
|
|
3629
|
+
(result) => {
|
|
3630
|
+
var _a;
|
|
3631
|
+
return result.status === "fulfilled" && ((_a = result.value) == null ? void 0 : _a.state) !== "invalid" /* INVALID */;
|
|
3632
|
+
}
|
|
3622
3633
|
).map(({ value }) => value);
|
|
3623
3634
|
if (!all) {
|
|
3624
3635
|
return apps.filter((app) => {
|
|
@@ -3680,7 +3691,7 @@ function pagination(data, pageSize, {
|
|
|
3680
3691
|
const hasNextPage = data.length > pageSize;
|
|
3681
3692
|
let nextPage = void 0;
|
|
3682
3693
|
if (!getKey) {
|
|
3683
|
-
getKey = (doc) => property ? doc
|
|
3694
|
+
getKey = (doc) => property ? doc == null ? void 0 : doc[property] : doc == null ? void 0 : doc._id;
|
|
3684
3695
|
}
|
|
3685
3696
|
if (hasNextPage) {
|
|
3686
3697
|
nextPage = getKey(data[pageSize]);
|
|
@@ -3831,7 +3842,7 @@ var init_views = __esm({
|
|
|
3831
3842
|
const docs = rows.map(
|
|
3832
3843
|
(row) => params2.include_docs ? row.doc : row.value
|
|
3833
3844
|
);
|
|
3834
|
-
if (opts
|
|
3845
|
+
if (opts == null ? void 0 : opts.arrayResponse) {
|
|
3835
3846
|
return docs;
|
|
3836
3847
|
} else {
|
|
3837
3848
|
return docs.length <= 1 ? docs[0] : docs;
|
|
@@ -4054,34 +4065,38 @@ async function fullSearch(dbName, index2, query, params2) {
|
|
|
4054
4065
|
const rows = await recursiveSearch(dbName, index2, query, params2);
|
|
4055
4066
|
return { rows };
|
|
4056
4067
|
}
|
|
4057
|
-
var import_node_fetch2, QUERY_START_REGEX, QueryBuilder;
|
|
4068
|
+
var import_node_fetch2, QUERY_START_REGEX, _dbName, _index, _query, _limit, _sort, _bookmark, _sortOrder, _sortType, _includeDocs, _version, _indexBuilder, _noEscaping, _skip, _skipItems, skipItems_fn, _execute, execute_fn, _QueryBuilder, QueryBuilder;
|
|
4058
4069
|
var init_lucene = __esm({
|
|
4059
4070
|
"src/db/lucene.ts"() {
|
|
4060
4071
|
"use strict";
|
|
4061
4072
|
import_node_fetch2 = __toESM(require("node-fetch"));
|
|
4062
4073
|
init_couch();
|
|
4063
4074
|
QUERY_START_REGEX = /\d[0-9]*:/g;
|
|
4064
|
-
|
|
4065
|
-
#dbName;
|
|
4066
|
-
#index;
|
|
4067
|
-
#query;
|
|
4068
|
-
#limit;
|
|
4069
|
-
#sort;
|
|
4070
|
-
#bookmark;
|
|
4071
|
-
#sortOrder;
|
|
4072
|
-
#sortType;
|
|
4073
|
-
#includeDocs;
|
|
4074
|
-
#version;
|
|
4075
|
-
#indexBuilder;
|
|
4076
|
-
#noEscaping = false;
|
|
4077
|
-
#skip;
|
|
4078
|
-
static {
|
|
4079
|
-
this.maxLimit = 200;
|
|
4080
|
-
}
|
|
4075
|
+
_QueryBuilder = class _QueryBuilder {
|
|
4081
4076
|
constructor(dbName, index2, base) {
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4077
|
+
/**
|
|
4078
|
+
* Lucene queries do not support pagination and use bookmarks instead.
|
|
4079
|
+
* For the given builder, walk through pages using bookmarks until the desired
|
|
4080
|
+
* page has been met.
|
|
4081
|
+
*/
|
|
4082
|
+
__privateAdd(this, _skipItems);
|
|
4083
|
+
__privateAdd(this, _execute);
|
|
4084
|
+
__privateAdd(this, _dbName, void 0);
|
|
4085
|
+
__privateAdd(this, _index, void 0);
|
|
4086
|
+
__privateAdd(this, _query, void 0);
|
|
4087
|
+
__privateAdd(this, _limit, void 0);
|
|
4088
|
+
__privateAdd(this, _sort, void 0);
|
|
4089
|
+
__privateAdd(this, _bookmark, void 0);
|
|
4090
|
+
__privateAdd(this, _sortOrder, void 0);
|
|
4091
|
+
__privateAdd(this, _sortType, void 0);
|
|
4092
|
+
__privateAdd(this, _includeDocs, void 0);
|
|
4093
|
+
__privateAdd(this, _version, void 0);
|
|
4094
|
+
__privateAdd(this, _indexBuilder, void 0);
|
|
4095
|
+
__privateAdd(this, _noEscaping, false);
|
|
4096
|
+
__privateAdd(this, _skip, void 0);
|
|
4097
|
+
__privateSet(this, _dbName, dbName);
|
|
4098
|
+
__privateSet(this, _index, index2);
|
|
4099
|
+
__privateSet(this, _query, {
|
|
4085
4100
|
allOr: false,
|
|
4086
4101
|
string: {},
|
|
4087
4102
|
fuzzy: {},
|
|
@@ -4095,124 +4110,124 @@ var init_lucene = __esm({
|
|
|
4095
4110
|
notContains: {},
|
|
4096
4111
|
containsAny: {},
|
|
4097
4112
|
...base
|
|
4098
|
-
};
|
|
4099
|
-
this
|
|
4100
|
-
this
|
|
4101
|
-
this
|
|
4102
|
-
this
|
|
4113
|
+
});
|
|
4114
|
+
__privateSet(this, _limit, 50);
|
|
4115
|
+
__privateSet(this, _sortOrder, "ascending");
|
|
4116
|
+
__privateSet(this, _sortType, "string");
|
|
4117
|
+
__privateSet(this, _includeDocs, true);
|
|
4103
4118
|
}
|
|
4104
4119
|
disableEscaping() {
|
|
4105
|
-
this
|
|
4120
|
+
__privateSet(this, _noEscaping, true);
|
|
4106
4121
|
return this;
|
|
4107
4122
|
}
|
|
4108
4123
|
setIndexBuilder(builderFn) {
|
|
4109
|
-
this
|
|
4124
|
+
__privateSet(this, _indexBuilder, builderFn);
|
|
4110
4125
|
return this;
|
|
4111
4126
|
}
|
|
4112
4127
|
setVersion(version) {
|
|
4113
4128
|
if (version != null) {
|
|
4114
|
-
this
|
|
4129
|
+
__privateSet(this, _version, version);
|
|
4115
4130
|
}
|
|
4116
4131
|
return this;
|
|
4117
4132
|
}
|
|
4118
4133
|
setTable(tableId) {
|
|
4119
|
-
this
|
|
4134
|
+
__privateGet(this, _query).equal.tableId = tableId;
|
|
4120
4135
|
return this;
|
|
4121
4136
|
}
|
|
4122
4137
|
setLimit(limit) {
|
|
4123
4138
|
if (limit != null) {
|
|
4124
|
-
this
|
|
4139
|
+
__privateSet(this, _limit, limit);
|
|
4125
4140
|
}
|
|
4126
4141
|
return this;
|
|
4127
4142
|
}
|
|
4128
4143
|
setSort(sort) {
|
|
4129
4144
|
if (sort != null) {
|
|
4130
|
-
this
|
|
4145
|
+
__privateSet(this, _sort, sort);
|
|
4131
4146
|
}
|
|
4132
4147
|
return this;
|
|
4133
4148
|
}
|
|
4134
4149
|
setSortOrder(sortOrder) {
|
|
4135
4150
|
if (sortOrder != null) {
|
|
4136
|
-
this
|
|
4151
|
+
__privateSet(this, _sortOrder, sortOrder);
|
|
4137
4152
|
}
|
|
4138
4153
|
return this;
|
|
4139
4154
|
}
|
|
4140
4155
|
setSortType(sortType) {
|
|
4141
4156
|
if (sortType != null) {
|
|
4142
|
-
this
|
|
4157
|
+
__privateSet(this, _sortType, sortType);
|
|
4143
4158
|
}
|
|
4144
4159
|
return this;
|
|
4145
4160
|
}
|
|
4146
4161
|
setBookmark(bookmark) {
|
|
4147
4162
|
if (bookmark != null) {
|
|
4148
|
-
this
|
|
4163
|
+
__privateSet(this, _bookmark, bookmark);
|
|
4149
4164
|
}
|
|
4150
4165
|
return this;
|
|
4151
4166
|
}
|
|
4152
4167
|
setSkip(skip) {
|
|
4153
|
-
this
|
|
4168
|
+
__privateSet(this, _skip, skip);
|
|
4154
4169
|
return this;
|
|
4155
4170
|
}
|
|
4156
4171
|
excludeDocs() {
|
|
4157
|
-
this
|
|
4172
|
+
__privateSet(this, _includeDocs, false);
|
|
4158
4173
|
return this;
|
|
4159
4174
|
}
|
|
4160
4175
|
includeDocs() {
|
|
4161
|
-
this
|
|
4176
|
+
__privateSet(this, _includeDocs, true);
|
|
4162
4177
|
return this;
|
|
4163
4178
|
}
|
|
4164
4179
|
addString(key, partial) {
|
|
4165
|
-
this
|
|
4180
|
+
__privateGet(this, _query).string[key] = partial;
|
|
4166
4181
|
return this;
|
|
4167
4182
|
}
|
|
4168
4183
|
addFuzzy(key, fuzzy) {
|
|
4169
|
-
this
|
|
4184
|
+
__privateGet(this, _query).fuzzy[key] = fuzzy;
|
|
4170
4185
|
return this;
|
|
4171
4186
|
}
|
|
4172
4187
|
addRange(key, low, high) {
|
|
4173
|
-
this
|
|
4188
|
+
__privateGet(this, _query).range[key] = {
|
|
4174
4189
|
low,
|
|
4175
4190
|
high
|
|
4176
4191
|
};
|
|
4177
4192
|
return this;
|
|
4178
4193
|
}
|
|
4179
4194
|
addEqual(key, value) {
|
|
4180
|
-
this
|
|
4195
|
+
__privateGet(this, _query).equal[key] = value;
|
|
4181
4196
|
return this;
|
|
4182
4197
|
}
|
|
4183
4198
|
addNotEqual(key, value) {
|
|
4184
|
-
this
|
|
4199
|
+
__privateGet(this, _query).notEqual[key] = value;
|
|
4185
4200
|
return this;
|
|
4186
4201
|
}
|
|
4187
4202
|
addEmpty(key, value) {
|
|
4188
|
-
this
|
|
4203
|
+
__privateGet(this, _query).empty[key] = value;
|
|
4189
4204
|
return this;
|
|
4190
4205
|
}
|
|
4191
4206
|
addNotEmpty(key, value) {
|
|
4192
|
-
this
|
|
4207
|
+
__privateGet(this, _query).notEmpty[key] = value;
|
|
4193
4208
|
return this;
|
|
4194
4209
|
}
|
|
4195
4210
|
addOneOf(key, value) {
|
|
4196
|
-
this
|
|
4211
|
+
__privateGet(this, _query).oneOf[key] = value;
|
|
4197
4212
|
return this;
|
|
4198
4213
|
}
|
|
4199
4214
|
addContains(key, value) {
|
|
4200
|
-
this
|
|
4215
|
+
__privateGet(this, _query).contains[key] = value;
|
|
4201
4216
|
return this;
|
|
4202
4217
|
}
|
|
4203
4218
|
addNotContains(key, value) {
|
|
4204
|
-
this
|
|
4219
|
+
__privateGet(this, _query).notContains[key] = value;
|
|
4205
4220
|
return this;
|
|
4206
4221
|
}
|
|
4207
4222
|
addContainsAny(key, value) {
|
|
4208
|
-
this
|
|
4223
|
+
__privateGet(this, _query).containsAny[key] = value;
|
|
4209
4224
|
return this;
|
|
4210
4225
|
}
|
|
4211
4226
|
setAllOr() {
|
|
4212
|
-
this
|
|
4227
|
+
__privateGet(this, _query).allOr = true;
|
|
4213
4228
|
}
|
|
4214
4229
|
handleSpaces(input) {
|
|
4215
|
-
if (this
|
|
4230
|
+
if (__privateGet(this, _noEscaping)) {
|
|
4216
4231
|
return input;
|
|
4217
4232
|
} else {
|
|
4218
4233
|
return input.replace(/ /g, "_");
|
|
@@ -4226,12 +4241,12 @@ var init_lucene = __esm({
|
|
|
4226
4241
|
* @returns {string|*}
|
|
4227
4242
|
*/
|
|
4228
4243
|
preprocess(value, { escape, lowercase, wrap, type } = {}) {
|
|
4229
|
-
const hasVersion = !!this
|
|
4244
|
+
const hasVersion = !!__privateGet(this, _version);
|
|
4230
4245
|
const originalType = typeof value;
|
|
4231
4246
|
if (value && lowercase) {
|
|
4232
4247
|
value = value.toLowerCase ? value.toLowerCase() : value;
|
|
4233
4248
|
}
|
|
4234
|
-
if (!this
|
|
4249
|
+
if (!__privateGet(this, _noEscaping) && escape && originalType === "string") {
|
|
4235
4250
|
value = `${value}`.replace(/[ \/#+\-&|!(){}\]^"~*?:\\]/g, "\\$&");
|
|
4236
4251
|
}
|
|
4237
4252
|
if (originalType === "string" && !isNaN(value) && !type) {
|
|
@@ -4243,7 +4258,7 @@ var init_lucene = __esm({
|
|
|
4243
4258
|
}
|
|
4244
4259
|
isMultiCondition() {
|
|
4245
4260
|
let count = 0;
|
|
4246
|
-
for (let filters of Object.values(this
|
|
4261
|
+
for (let filters of Object.values(__privateGet(this, _query))) {
|
|
4247
4262
|
if (typeof filters === "object") {
|
|
4248
4263
|
count += Object.keys(filters).length;
|
|
4249
4264
|
}
|
|
@@ -4269,13 +4284,13 @@ var init_lucene = __esm({
|
|
|
4269
4284
|
}
|
|
4270
4285
|
buildSearchQuery() {
|
|
4271
4286
|
const builder = this;
|
|
4272
|
-
let allOr = this
|
|
4287
|
+
let allOr = __privateGet(this, _query) && __privateGet(this, _query).allOr;
|
|
4273
4288
|
let query = allOr ? "" : "*:*";
|
|
4274
4289
|
const allPreProcessingOpts = { escape: true, lowercase: true, wrap: true };
|
|
4275
4290
|
let tableId;
|
|
4276
|
-
if (this
|
|
4277
|
-
tableId = this
|
|
4278
|
-
delete this
|
|
4291
|
+
if (__privateGet(this, _query).equal.tableId) {
|
|
4292
|
+
tableId = __privateGet(this, _query).equal.tableId;
|
|
4293
|
+
delete __privateGet(this, _query).equal.tableId;
|
|
4279
4294
|
}
|
|
4280
4295
|
const equal = (key, value) => {
|
|
4281
4296
|
if (!value && value !== 0) {
|
|
@@ -4349,19 +4364,19 @@ var init_lucene = __esm({
|
|
|
4349
4364
|
continue;
|
|
4350
4365
|
}
|
|
4351
4366
|
if (built.length > 0 || query.length > 0) {
|
|
4352
|
-
const mode = opts
|
|
4367
|
+
const mode = (opts == null ? void 0 : opts.mode) ? opts.mode : allOr ? "OR" : "AND";
|
|
4353
4368
|
built += ` ${mode} `;
|
|
4354
4369
|
}
|
|
4355
4370
|
built += expression;
|
|
4356
4371
|
}
|
|
4357
|
-
if (opts
|
|
4372
|
+
if (opts == null ? void 0 : opts.returnBuilt) {
|
|
4358
4373
|
return built;
|
|
4359
4374
|
} else {
|
|
4360
4375
|
query += built;
|
|
4361
4376
|
}
|
|
4362
4377
|
}
|
|
4363
|
-
if (this
|
|
4364
|
-
build(this
|
|
4378
|
+
if (__privateGet(this, _query).string) {
|
|
4379
|
+
build(__privateGet(this, _query).string, (key, value) => {
|
|
4365
4380
|
if (!value) {
|
|
4366
4381
|
return null;
|
|
4367
4382
|
}
|
|
@@ -4373,8 +4388,8 @@ var init_lucene = __esm({
|
|
|
4373
4388
|
return `${key}:${value}*`;
|
|
4374
4389
|
});
|
|
4375
4390
|
}
|
|
4376
|
-
if (this
|
|
4377
|
-
build(this
|
|
4391
|
+
if (__privateGet(this, _query).range) {
|
|
4392
|
+
build(__privateGet(this, _query).range, (key, value) => {
|
|
4378
4393
|
if (!value) {
|
|
4379
4394
|
return null;
|
|
4380
4395
|
}
|
|
@@ -4389,14 +4404,14 @@ var init_lucene = __esm({
|
|
|
4389
4404
|
return `${key}:[${low} TO ${high}]`;
|
|
4390
4405
|
});
|
|
4391
4406
|
}
|
|
4392
|
-
if (this
|
|
4393
|
-
build(this
|
|
4407
|
+
if (__privateGet(this, _query).fuzzy) {
|
|
4408
|
+
build(__privateGet(this, _query).fuzzy, fuzzy);
|
|
4394
4409
|
}
|
|
4395
|
-
if (this
|
|
4396
|
-
build(this
|
|
4410
|
+
if (__privateGet(this, _query).equal) {
|
|
4411
|
+
build(__privateGet(this, _query).equal, equal);
|
|
4397
4412
|
}
|
|
4398
|
-
if (this
|
|
4399
|
-
build(this
|
|
4413
|
+
if (__privateGet(this, _query).notEqual) {
|
|
4414
|
+
build(__privateGet(this, _query).notEqual, (key, value) => {
|
|
4400
4415
|
if (!value) {
|
|
4401
4416
|
return null;
|
|
4402
4417
|
}
|
|
@@ -4406,23 +4421,23 @@ var init_lucene = __esm({
|
|
|
4406
4421
|
return `!${key}:${builder.preprocess(value, allPreProcessingOpts)}`;
|
|
4407
4422
|
});
|
|
4408
4423
|
}
|
|
4409
|
-
if (this
|
|
4410
|
-
build(this
|
|
4424
|
+
if (__privateGet(this, _query).empty) {
|
|
4425
|
+
build(__privateGet(this, _query).empty, (key) => `(*:* -${key}:["" TO *])`);
|
|
4411
4426
|
}
|
|
4412
|
-
if (this
|
|
4413
|
-
build(this
|
|
4427
|
+
if (__privateGet(this, _query).notEmpty) {
|
|
4428
|
+
build(__privateGet(this, _query).notEmpty, (key) => `${key}:["" TO *]`);
|
|
4414
4429
|
}
|
|
4415
|
-
if (this
|
|
4416
|
-
build(this
|
|
4430
|
+
if (__privateGet(this, _query).oneOf) {
|
|
4431
|
+
build(__privateGet(this, _query).oneOf, oneOf);
|
|
4417
4432
|
}
|
|
4418
|
-
if (this
|
|
4419
|
-
build(this
|
|
4433
|
+
if (__privateGet(this, _query).contains) {
|
|
4434
|
+
build(__privateGet(this, _query).contains, contains);
|
|
4420
4435
|
}
|
|
4421
|
-
if (this
|
|
4422
|
-
build(this.compressFilters(this
|
|
4436
|
+
if (__privateGet(this, _query).notContains) {
|
|
4437
|
+
build(this.compressFilters(__privateGet(this, _query).notContains), notContains);
|
|
4423
4438
|
}
|
|
4424
|
-
if (this
|
|
4425
|
-
build(this
|
|
4439
|
+
if (__privateGet(this, _query).containsAny) {
|
|
4440
|
+
build(__privateGet(this, _query).containsAny, containsAny);
|
|
4426
4441
|
}
|
|
4427
4442
|
if (tableId) {
|
|
4428
4443
|
query = this.isMultiCondition() ? `(${query})` : query;
|
|
@@ -4434,63 +4449,75 @@ var init_lucene = __esm({
|
|
|
4434
4449
|
buildSearchBody() {
|
|
4435
4450
|
let body2 = {
|
|
4436
4451
|
q: this.buildSearchQuery(),
|
|
4437
|
-
limit: Math.min(this
|
|
4438
|
-
include_docs: this
|
|
4452
|
+
limit: Math.min(__privateGet(this, _limit), _QueryBuilder.maxLimit),
|
|
4453
|
+
include_docs: __privateGet(this, _includeDocs)
|
|
4439
4454
|
};
|
|
4440
|
-
if (this
|
|
4441
|
-
body2.bookmark = this
|
|
4455
|
+
if (__privateGet(this, _bookmark)) {
|
|
4456
|
+
body2.bookmark = __privateGet(this, _bookmark);
|
|
4442
4457
|
}
|
|
4443
|
-
if (this
|
|
4444
|
-
const order = this
|
|
4445
|
-
const type = `<${this
|
|
4446
|
-
body2.sort = `${order}${this.handleSpaces(this
|
|
4458
|
+
if (__privateGet(this, _sort)) {
|
|
4459
|
+
const order = __privateGet(this, _sortOrder) === "descending" ? "-" : "";
|
|
4460
|
+
const type = `<${__privateGet(this, _sortType)}>`;
|
|
4461
|
+
body2.sort = `${order}${this.handleSpaces(__privateGet(this, _sort))}${type}`;
|
|
4447
4462
|
}
|
|
4448
4463
|
return body2;
|
|
4449
4464
|
}
|
|
4450
4465
|
async run() {
|
|
4451
|
-
if (this
|
|
4452
|
-
await this
|
|
4466
|
+
if (__privateGet(this, _skip)) {
|
|
4467
|
+
await __privateMethod(this, _skipItems, skipItems_fn).call(this, __privateGet(this, _skip));
|
|
4453
4468
|
}
|
|
4454
|
-
return await this
|
|
4469
|
+
return await __privateMethod(this, _execute, execute_fn).call(this);
|
|
4455
4470
|
}
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
|
|
4466
|
-
|
|
4467
|
-
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
|
|
4479
|
-
|
|
4480
|
-
const
|
|
4481
|
-
|
|
4482
|
-
|
|
4471
|
+
};
|
|
4472
|
+
_dbName = new WeakMap();
|
|
4473
|
+
_index = new WeakMap();
|
|
4474
|
+
_query = new WeakMap();
|
|
4475
|
+
_limit = new WeakMap();
|
|
4476
|
+
_sort = new WeakMap();
|
|
4477
|
+
_bookmark = new WeakMap();
|
|
4478
|
+
_sortOrder = new WeakMap();
|
|
4479
|
+
_sortType = new WeakMap();
|
|
4480
|
+
_includeDocs = new WeakMap();
|
|
4481
|
+
_version = new WeakMap();
|
|
4482
|
+
_indexBuilder = new WeakMap();
|
|
4483
|
+
_noEscaping = new WeakMap();
|
|
4484
|
+
_skip = new WeakMap();
|
|
4485
|
+
_skipItems = new WeakSet();
|
|
4486
|
+
skipItems_fn = async function(skip) {
|
|
4487
|
+
const prevIncludeDocs = __privateGet(this, _includeDocs);
|
|
4488
|
+
const prevLimit = __privateGet(this, _limit);
|
|
4489
|
+
this.excludeDocs();
|
|
4490
|
+
let skipRemaining = skip;
|
|
4491
|
+
let iterationFetched = 0;
|
|
4492
|
+
do {
|
|
4493
|
+
const toSkip = Math.min(_QueryBuilder.maxLimit, skipRemaining);
|
|
4494
|
+
this.setLimit(toSkip);
|
|
4495
|
+
const { bookmark, rows } = await __privateMethod(this, _execute, execute_fn).call(this);
|
|
4496
|
+
this.setBookmark(bookmark);
|
|
4497
|
+
iterationFetched = rows.length;
|
|
4498
|
+
skipRemaining -= rows.length;
|
|
4499
|
+
} while (skipRemaining > 0 && iterationFetched > 0);
|
|
4500
|
+
__privateSet(this, _includeDocs, prevIncludeDocs);
|
|
4501
|
+
__privateSet(this, _limit, prevLimit);
|
|
4502
|
+
};
|
|
4503
|
+
_execute = new WeakSet();
|
|
4504
|
+
execute_fn = async function() {
|
|
4505
|
+
const { url, cookie } = getCouchInfo();
|
|
4506
|
+
const fullPath = `${url}/${__privateGet(this, _dbName)}/_design/database/_search/${__privateGet(this, _index)}`;
|
|
4507
|
+
const body2 = this.buildSearchBody();
|
|
4508
|
+
try {
|
|
4509
|
+
return await runQuery(fullPath, body2, cookie);
|
|
4510
|
+
} catch (err) {
|
|
4511
|
+
if (err.status === 404 && __privateGet(this, _indexBuilder)) {
|
|
4512
|
+
await __privateGet(this, _indexBuilder).call(this);
|
|
4483
4513
|
return await runQuery(fullPath, body2, cookie);
|
|
4484
|
-
}
|
|
4485
|
-
|
|
4486
|
-
await this.#indexBuilder();
|
|
4487
|
-
return await runQuery(fullPath, body2, cookie);
|
|
4488
|
-
} else {
|
|
4489
|
-
throw err;
|
|
4490
|
-
}
|
|
4514
|
+
} else {
|
|
4515
|
+
throw err;
|
|
4491
4516
|
}
|
|
4492
4517
|
}
|
|
4493
4518
|
};
|
|
4519
|
+
_QueryBuilder.maxLimit = 200;
|
|
4520
|
+
QueryBuilder = _QueryBuilder;
|
|
4494
4521
|
}
|
|
4495
4522
|
});
|
|
4496
4523
|
|
|
@@ -4569,9 +4596,10 @@ var init_searchIndexes2 = __esm({
|
|
|
4569
4596
|
|
|
4570
4597
|
// src/db/errors.ts
|
|
4571
4598
|
function checkErrorCode(error, code) {
|
|
4599
|
+
var _a;
|
|
4572
4600
|
const stringCode = code.toString();
|
|
4573
4601
|
if (typeof error === "object") {
|
|
4574
|
-
return error.status === code || error.message
|
|
4602
|
+
return error.status === code || ((_a = error.message) == null ? void 0 : _a.includes(stringCode));
|
|
4575
4603
|
} else if (typeof error === "number") {
|
|
4576
4604
|
return error === code;
|
|
4577
4605
|
} else if (typeof error === "string") {
|
|
@@ -4822,12 +4850,12 @@ var init_objectStore = __esm({
|
|
|
4822
4850
|
streamUpload = async (bucketName, filename, stream2, extra = {}) => {
|
|
4823
4851
|
const objectStore = ObjectStore(bucketName);
|
|
4824
4852
|
await makeSureBucketExists(objectStore, bucketName);
|
|
4825
|
-
if (filename
|
|
4853
|
+
if (filename == null ? void 0 : filename.endsWith(".js")) {
|
|
4826
4854
|
extra = {
|
|
4827
4855
|
...extra,
|
|
4828
4856
|
ContentType: "application/javascript"
|
|
4829
4857
|
};
|
|
4830
|
-
} else if (filename
|
|
4858
|
+
} else if (filename == null ? void 0 : filename.endsWith(".svg")) {
|
|
4831
4859
|
extra = {
|
|
4832
4860
|
...extra,
|
|
4833
4861
|
ContentType: "image"
|
|
@@ -4943,6 +4971,7 @@ var init_objectStore = __esm({
|
|
|
4943
4971
|
return objectStore.deleteObjects(params2).promise();
|
|
4944
4972
|
};
|
|
4945
4973
|
deleteFolder = async (bucketName, folder) => {
|
|
4974
|
+
var _a, _b, _c;
|
|
4946
4975
|
bucketName = sanitizeBucket(bucketName);
|
|
4947
4976
|
folder = sanitizeKey(folder);
|
|
4948
4977
|
const client = ObjectStore(bucketName);
|
|
@@ -4951,7 +4980,7 @@ var init_objectStore = __esm({
|
|
|
4951
4980
|
Prefix: folder
|
|
4952
4981
|
};
|
|
4953
4982
|
const existingObjectsResponse = await client.listObjects(listParams).promise();
|
|
4954
|
-
if (existingObjectsResponse.Contents
|
|
4983
|
+
if (((_a = existingObjectsResponse.Contents) == null ? void 0 : _a.length) === 0) {
|
|
4955
4984
|
return;
|
|
4956
4985
|
}
|
|
4957
4986
|
const deleteParams = {
|
|
@@ -4960,11 +4989,11 @@ var init_objectStore = __esm({
|
|
|
4960
4989
|
Objects: []
|
|
4961
4990
|
}
|
|
4962
4991
|
};
|
|
4963
|
-
existingObjectsResponse.Contents
|
|
4992
|
+
(_b = existingObjectsResponse.Contents) == null ? void 0 : _b.forEach((content) => {
|
|
4964
4993
|
deleteParams.Delete.Objects.push({ Key: content.Key });
|
|
4965
4994
|
});
|
|
4966
4995
|
const deleteResponse = await client.deleteObjects(deleteParams).promise();
|
|
4967
|
-
if (deleteResponse.Deleted
|
|
4996
|
+
if (((_c = deleteResponse.Deleted) == null ? void 0 : _c.length) === 1e3) {
|
|
4968
4997
|
return deleteFolder(bucketName, folder);
|
|
4969
4998
|
}
|
|
4970
4999
|
};
|
|
@@ -5241,7 +5270,7 @@ function getFullPath(fileName) {
|
|
|
5241
5270
|
}
|
|
5242
5271
|
function getSingleFileMaxSizeInfo(totalMaxSize) {
|
|
5243
5272
|
const regex = /(\d+)([A-Za-z])/;
|
|
5244
|
-
const match = totalMaxSize
|
|
5273
|
+
const match = totalMaxSize == null ? void 0 : totalMaxSize.match(regex);
|
|
5245
5274
|
if (!match) {
|
|
5246
5275
|
console.warn(`totalMaxSize does not have a valid value`, {
|
|
5247
5276
|
totalMaxSize
|
|
@@ -5273,9 +5302,9 @@ function localFileDestination() {
|
|
|
5273
5302
|
const fileInfo = getSingleFileMaxSizeInfo(environment_default.ROLLING_LOG_MAX_SIZE);
|
|
5274
5303
|
const outFile = rfs.createStream(logsFileName, {
|
|
5275
5304
|
// As we have a rolling size, we want to half the max size
|
|
5276
|
-
size: fileInfo
|
|
5305
|
+
size: fileInfo == null ? void 0 : fileInfo.size,
|
|
5277
5306
|
path: logsPath,
|
|
5278
|
-
maxFiles: fileInfo
|
|
5307
|
+
maxFiles: (fileInfo == null ? void 0 : fileInfo.totalHistoryFiles) || 1,
|
|
5279
5308
|
immutable: true,
|
|
5280
5309
|
history: budibaseLogsHistoryFileName,
|
|
5281
5310
|
initialRotation: false
|
|
@@ -5350,8 +5379,8 @@ var init_logger = __esm({
|
|
|
5350
5379
|
tenantId: getTenantId2(),
|
|
5351
5380
|
appId: getAppId2(),
|
|
5352
5381
|
automationId: getAutomationId2(),
|
|
5353
|
-
identityId: identity
|
|
5354
|
-
identityType: identity
|
|
5382
|
+
identityId: identity == null ? void 0 : identity._id,
|
|
5383
|
+
identityType: identity == null ? void 0 : identity.type,
|
|
5355
5384
|
correlationId: getId()
|
|
5356
5385
|
};
|
|
5357
5386
|
const mergingObject = {
|
|
@@ -5415,30 +5444,30 @@ var init_logger = __esm({
|
|
|
5415
5444
|
pinoInstance = destinations.length ? (0, import_pino.default)(pinoOptions, import_pino.default.multistream(destinations)) : (0, import_pino.default)(pinoOptions);
|
|
5416
5445
|
console.log = (...arg) => {
|
|
5417
5446
|
const [obj, msg] = getLogParams2(arg);
|
|
5418
|
-
pinoInstance
|
|
5447
|
+
pinoInstance == null ? void 0 : pinoInstance.info(obj, msg);
|
|
5419
5448
|
};
|
|
5420
5449
|
console.info = (...arg) => {
|
|
5421
5450
|
const [obj, msg] = getLogParams2(arg);
|
|
5422
|
-
pinoInstance
|
|
5451
|
+
pinoInstance == null ? void 0 : pinoInstance.info(obj, msg);
|
|
5423
5452
|
};
|
|
5424
5453
|
console.warn = (...arg) => {
|
|
5425
5454
|
const [obj, msg] = getLogParams2(arg);
|
|
5426
|
-
pinoInstance
|
|
5455
|
+
pinoInstance == null ? void 0 : pinoInstance.warn(obj, msg);
|
|
5427
5456
|
};
|
|
5428
5457
|
console.error = (...arg) => {
|
|
5429
5458
|
const [obj, msg] = getLogParams2(arg);
|
|
5430
|
-
pinoInstance
|
|
5459
|
+
pinoInstance == null ? void 0 : pinoInstance.error(obj, msg);
|
|
5431
5460
|
};
|
|
5432
5461
|
console.trace = (...arg) => {
|
|
5433
5462
|
const [obj, msg] = getLogParams2(arg);
|
|
5434
5463
|
if (!obj.err) {
|
|
5435
5464
|
obj.err = new Error();
|
|
5436
5465
|
}
|
|
5437
|
-
pinoInstance
|
|
5466
|
+
pinoInstance == null ? void 0 : pinoInstance.trace(obj, msg);
|
|
5438
5467
|
};
|
|
5439
5468
|
console.debug = (...arg) => {
|
|
5440
5469
|
const [obj, msg] = getLogParams2(arg);
|
|
5441
|
-
pinoInstance
|
|
5470
|
+
pinoInstance == null ? void 0 : pinoInstance.debug(obj, msg);
|
|
5442
5471
|
};
|
|
5443
5472
|
const getTenantId2 = () => {
|
|
5444
5473
|
let tenantId;
|
|
@@ -5721,6 +5750,7 @@ var isUserInAppTenant = (appId, user) => {
|
|
|
5721
5750
|
};
|
|
5722
5751
|
var ALL_STRATEGIES = Object.values(TenantResolutionStrategy);
|
|
5723
5752
|
var getTenantIDFromCtx = (ctx, opts) => {
|
|
5753
|
+
var _a;
|
|
5724
5754
|
if (!isMultiTenant()) {
|
|
5725
5755
|
return DEFAULT_TENANT_ID;
|
|
5726
5756
|
}
|
|
@@ -5734,15 +5764,16 @@ var getTenantIDFromCtx = (ctx, opts) => {
|
|
|
5734
5764
|
opts.excludeStrategies = [];
|
|
5735
5765
|
}
|
|
5736
5766
|
const isAllowed = (strategy) => {
|
|
5737
|
-
|
|
5767
|
+
var _a2, _b;
|
|
5768
|
+
if ((_a2 = opts.excludeStrategies) == null ? void 0 : _a2.includes(strategy)) {
|
|
5738
5769
|
return false;
|
|
5739
5770
|
}
|
|
5740
|
-
if (opts.includeStrategies
|
|
5771
|
+
if ((_b = opts.includeStrategies) == null ? void 0 : _b.includes(strategy)) {
|
|
5741
5772
|
return true;
|
|
5742
5773
|
}
|
|
5743
5774
|
};
|
|
5744
5775
|
if (isAllowed("user" /* USER */)) {
|
|
5745
|
-
const userTenantId = ctx.user
|
|
5776
|
+
const userTenantId = (_a = ctx.user) == null ? void 0 : _a.tenantId;
|
|
5746
5777
|
if (userTenantId) {
|
|
5747
5778
|
return userTenantId;
|
|
5748
5779
|
}
|
|
@@ -6310,7 +6341,7 @@ async function put(db, doc, writeRateMs = DEFAULT_WRITE_RATE_MS) {
|
|
|
6310
6341
|
logWarn(`Ignoring redlock conflict in write-through cache`);
|
|
6311
6342
|
}
|
|
6312
6343
|
}
|
|
6313
|
-
cacheItem = makeCacheItem(output, updateDb ? null : cacheItem
|
|
6344
|
+
cacheItem = makeCacheItem(output, updateDb ? null : cacheItem == null ? void 0 : cacheItem.lastWrite);
|
|
6314
6345
|
if (output._id) {
|
|
6315
6346
|
await cache.store(makeCacheKey(db, output._id), cacheItem);
|
|
6316
6347
|
}
|
|
@@ -6402,6 +6433,7 @@ async function getSettingsConfig() {
|
|
|
6402
6433
|
async function getPlatformUrl(opts = {
|
|
6403
6434
|
tenantAware: true
|
|
6404
6435
|
}) {
|
|
6436
|
+
var _a;
|
|
6405
6437
|
let platformUrl = environment_default.PLATFORM_URL || "http://localhost:10000";
|
|
6406
6438
|
if (!environment_default.SELF_HOSTED && environment_default.MULTI_TENANCY && opts.tenantAware) {
|
|
6407
6439
|
const tenantId = getTenantId();
|
|
@@ -6409,11 +6441,11 @@ async function getPlatformUrl(opts = {
|
|
|
6409
6441
|
platformUrl = platformUrl.replace("://", `://${tenantId}.`);
|
|
6410
6442
|
}
|
|
6411
6443
|
} else if (environment_default.SELF_HOSTED) {
|
|
6412
|
-
const config = opts
|
|
6444
|
+
const config = (opts == null ? void 0 : opts.config) ? opts.config : (
|
|
6413
6445
|
// direct to db to prevent infinite loop
|
|
6414
|
-
(await getConfig("settings" /* SETTINGS */))
|
|
6446
|
+
(_a = await getConfig("settings" /* SETTINGS */)) == null ? void 0 : _a.config
|
|
6415
6447
|
);
|
|
6416
|
-
if (config
|
|
6448
|
+
if (config == null ? void 0 : config.platformUrl) {
|
|
6417
6449
|
platformUrl = config.platformUrl;
|
|
6418
6450
|
}
|
|
6419
6451
|
}
|
|
@@ -6427,13 +6459,14 @@ var analyticsEnabled = async (opts) => {
|
|
|
6427
6459
|
"analyticsEnabled" /* ANALYTICS_ENABLED */,
|
|
6428
6460
|
86400 /* ONE_DAY */,
|
|
6429
6461
|
async () => {
|
|
6430
|
-
|
|
6462
|
+
var _a;
|
|
6463
|
+
const config = (opts == null ? void 0 : opts.config) ? opts.config : (
|
|
6431
6464
|
// direct to db to prevent infinite loop
|
|
6432
|
-
(await getConfig("settings" /* SETTINGS */))
|
|
6465
|
+
(_a = await getConfig("settings" /* SETTINGS */)) == null ? void 0 : _a.config
|
|
6433
6466
|
);
|
|
6434
|
-
if (config
|
|
6467
|
+
if ((config == null ? void 0 : config.analyticsEnabled) === false) {
|
|
6435
6468
|
return false;
|
|
6436
|
-
} else if (config
|
|
6469
|
+
} else if ((config == null ? void 0 : config.analyticsEnabled) === true) {
|
|
6437
6470
|
return true;
|
|
6438
6471
|
}
|
|
6439
6472
|
}
|
|
@@ -6453,7 +6486,7 @@ async function getGoogleConfigDoc() {
|
|
|
6453
6486
|
}
|
|
6454
6487
|
async function getGoogleConfig() {
|
|
6455
6488
|
const config = await getGoogleConfigDoc();
|
|
6456
|
-
return config
|
|
6489
|
+
return config == null ? void 0 : config.config;
|
|
6457
6490
|
}
|
|
6458
6491
|
async function getGoogleDatasourceConfig() {
|
|
6459
6492
|
if (!environment_default.SELF_HOSTED) {
|
|
@@ -6481,11 +6514,13 @@ async function getOIDCConfigDoc() {
|
|
|
6481
6514
|
return getConfig("oidc" /* OIDC */);
|
|
6482
6515
|
}
|
|
6483
6516
|
async function getOIDCConfig() {
|
|
6484
|
-
|
|
6485
|
-
|
|
6517
|
+
var _a;
|
|
6518
|
+
const config = (_a = await getOIDCConfigDoc()) == null ? void 0 : _a.config;
|
|
6519
|
+
return (config == null ? void 0 : config.configs) && config.configs[0];
|
|
6486
6520
|
}
|
|
6487
6521
|
async function getOIDCConfigById(configId) {
|
|
6488
|
-
|
|
6522
|
+
var _a;
|
|
6523
|
+
const config = (_a = await getConfig("oidc" /* OIDC */)) == null ? void 0 : _a.config;
|
|
6489
6524
|
return config && config.configs.filter((c) => c.uuid === configId)[0];
|
|
6490
6525
|
}
|
|
6491
6526
|
async function getSMTPConfigDoc() {
|
|
@@ -6512,7 +6547,7 @@ async function getSMTPConfig(isAutomation) {
|
|
|
6512
6547
|
}
|
|
6513
6548
|
async function getSCIMConfig() {
|
|
6514
6549
|
const config = await getConfig("scim" /* SCIM */);
|
|
6515
|
-
return config
|
|
6550
|
+
return config == null ? void 0 : config.config;
|
|
6516
6551
|
}
|
|
6517
6552
|
|
|
6518
6553
|
// src/events/index.ts
|
|
@@ -6927,7 +6962,7 @@ async function getAppIdFromCtx(ctx) {
|
|
|
6927
6962
|
appId = confirmAppId(await resolveAppUrl(ctx));
|
|
6928
6963
|
}
|
|
6929
6964
|
const referer = ctx.request.headers.referer;
|
|
6930
|
-
if (!appId && referer
|
|
6965
|
+
if (!appId && (referer == null ? void 0 : referer.includes(BUILDER_APP_PREFIX))) {
|
|
6931
6966
|
const refererId = parseAppIdFromUrl(ctx.request.headers.referer);
|
|
6932
6967
|
appId = confirmAppId(refererId);
|
|
6933
6968
|
}
|
|
@@ -7146,6 +7181,7 @@ function handleStalled(queue, removeStalledCb) {
|
|
|
7146
7181
|
});
|
|
7147
7182
|
}
|
|
7148
7183
|
function getLogParams(eventType, event, opts = {}, extra = {}) {
|
|
7184
|
+
var _a, _b, _c;
|
|
7149
7185
|
const message = `[BULL] ${eventType}=${event}`;
|
|
7150
7186
|
const err = opts.error;
|
|
7151
7187
|
const bullLog = {
|
|
@@ -7153,11 +7189,11 @@ function getLogParams(eventType, event, opts = {}, extra = {}) {
|
|
|
7153
7189
|
eventType,
|
|
7154
7190
|
event,
|
|
7155
7191
|
job: opts.job,
|
|
7156
|
-
jobId: opts.jobId || opts.job
|
|
7192
|
+
jobId: opts.jobId || ((_a = opts.job) == null ? void 0 : _a.id),
|
|
7157
7193
|
...extra
|
|
7158
7194
|
};
|
|
7159
7195
|
let automationLog;
|
|
7160
|
-
if (opts.job
|
|
7196
|
+
if ((_c = (_b = opts.job) == null ? void 0 : _b.data) == null ? void 0 : _c.automation) {
|
|
7161
7197
|
automationLog = {
|
|
7162
7198
|
_logKey: "automation",
|
|
7163
7199
|
trigger: opts.job ? opts.job.data.automation.definition.trigger.event : void 0
|
|
@@ -7172,9 +7208,11 @@ var EventTypeMap = {
|
|
|
7172
7208
|
["systemEventQueue" /* SYSTEM_EVENT_QUEUE */]: "system-event" /* SYSTEM_EVENT */
|
|
7173
7209
|
};
|
|
7174
7210
|
function logging(queue, jobQueue) {
|
|
7211
|
+
var _a;
|
|
7175
7212
|
const eventType = EventTypeMap[jobQueue];
|
|
7176
7213
|
function doInJobContext(job, task) {
|
|
7177
|
-
|
|
7214
|
+
var _a2;
|
|
7215
|
+
const appId = (_a2 = job.data.event) == null ? void 0 : _a2.appId;
|
|
7178
7216
|
if (appId) {
|
|
7179
7217
|
return doInContext(appId, task);
|
|
7180
7218
|
} else {
|
|
@@ -7188,7 +7226,7 @@ function logging(queue, jobQueue) {
|
|
|
7188
7226
|
}).on("error" /* ERROR */, (error) => {
|
|
7189
7227
|
console.error(...getLogParams(eventType, "error" /* ERROR */, { error }));
|
|
7190
7228
|
});
|
|
7191
|
-
if (process.env.NODE_DEBUG
|
|
7229
|
+
if ((_a = process.env.NODE_DEBUG) == null ? void 0 : _a.includes("bull")) {
|
|
7192
7230
|
queue.on("waiting" /* WAITING */, (jobId) => {
|
|
7193
7231
|
console.info(...getLogParams(eventType, "waiting" /* WAITING */, { jobId }));
|
|
7194
7232
|
}).on("active" /* ACTIVE */, async (job, jobPromise) => {
|
|
@@ -7258,7 +7296,7 @@ function createQueue(jobQueue, opts = {}) {
|
|
|
7258
7296
|
} else {
|
|
7259
7297
|
queue = new inMemoryQueue_default(jobQueue, queueConfig);
|
|
7260
7298
|
}
|
|
7261
|
-
addListeners(queue, jobQueue, opts
|
|
7299
|
+
addListeners(queue, jobQueue, opts == null ? void 0 : opts.removeStalledCb);
|
|
7262
7300
|
QUEUES.push(queue);
|
|
7263
7301
|
if (!cleanupInterval && !environment_default.isTest()) {
|
|
7264
7302
|
cleanupInterval = set(cleanup2, CLEANUP_PERIOD_MS);
|
|
@@ -7283,10 +7321,7 @@ async function shutdown2() {
|
|
|
7283
7321
|
|
|
7284
7322
|
// src/events/processors/AuditLogsProcessor.ts
|
|
7285
7323
|
init_environment2();
|
|
7286
|
-
var
|
|
7287
|
-
static {
|
|
7288
|
-
this.auditLogsEnabled = false;
|
|
7289
|
-
}
|
|
7324
|
+
var _AuditLogsProcessor = class _AuditLogsProcessor {
|
|
7290
7325
|
// can't use constructor as need to return promise
|
|
7291
7326
|
static init(fn) {
|
|
7292
7327
|
_AuditLogsProcessor.auditLogsEnabled = true;
|
|
@@ -7338,9 +7373,12 @@ var AuditLogsProcessor = class _AuditLogsProcessor {
|
|
|
7338
7373
|
async identifyGroup(group, timestamp) {
|
|
7339
7374
|
}
|
|
7340
7375
|
shutdown() {
|
|
7341
|
-
|
|
7376
|
+
var _a;
|
|
7377
|
+
(_a = _AuditLogsProcessor.auditLogQueue) == null ? void 0 : _a.close();
|
|
7342
7378
|
}
|
|
7343
7379
|
};
|
|
7380
|
+
_AuditLogsProcessor.auditLogsEnabled = false;
|
|
7381
|
+
var AuditLogsProcessor = _AuditLogsProcessor;
|
|
7344
7382
|
|
|
7345
7383
|
// src/events/processors/Processors.ts
|
|
7346
7384
|
var Processor = class {
|
|
@@ -7555,7 +7593,7 @@ var bulkGetGlobalUsersById = async (userIds, opts) => {
|
|
|
7555
7593
|
keys: userIds,
|
|
7556
7594
|
include_docs: true
|
|
7557
7595
|
})).rows.map((row) => row.doc);
|
|
7558
|
-
if (opts
|
|
7596
|
+
if (opts == null ? void 0 : opts.cleanup) {
|
|
7559
7597
|
users = removeUserPassword(users);
|
|
7560
7598
|
}
|
|
7561
7599
|
return users;
|
|
@@ -7576,7 +7614,7 @@ var bulkUpdateGlobalUsers = async (users) => {
|
|
|
7576
7614
|
async function getById(id, opts) {
|
|
7577
7615
|
const db = getGlobalDB();
|
|
7578
7616
|
let user = await db.get(id);
|
|
7579
|
-
if (opts
|
|
7617
|
+
if (opts == null ? void 0 : opts.cleanup) {
|
|
7580
7618
|
user = removeUserPassword(user);
|
|
7581
7619
|
}
|
|
7582
7620
|
return user;
|
|
@@ -7593,7 +7631,7 @@ var getGlobalUserByEmail = async (email, opts) => {
|
|
|
7593
7631
|
throw new Error(`Multiple users found with email address: ${email}`);
|
|
7594
7632
|
}
|
|
7595
7633
|
let user = response;
|
|
7596
|
-
if (opts
|
|
7634
|
+
if (opts == null ? void 0 : opts.cleanup) {
|
|
7597
7635
|
user = removeUserPassword(user);
|
|
7598
7636
|
}
|
|
7599
7637
|
return user;
|
|
@@ -7611,7 +7649,7 @@ var searchGlobalUsersByApp = async (appId, opts, getOpts) => {
|
|
|
7611
7649
|
response = [];
|
|
7612
7650
|
}
|
|
7613
7651
|
let users = Array.isArray(response) ? response : [response];
|
|
7614
|
-
if (getOpts
|
|
7652
|
+
if (getOpts == null ? void 0 : getOpts.cleanup) {
|
|
7615
7653
|
users = removeUserPassword(users);
|
|
7616
7654
|
}
|
|
7617
7655
|
return users;
|
|
@@ -7641,10 +7679,10 @@ var searchGlobalUsersByAppAccess = async (appId, opts) => {
|
|
|
7641
7679
|
$regex: "^us_"
|
|
7642
7680
|
}
|
|
7643
7681
|
},
|
|
7644
|
-
limit: opts
|
|
7682
|
+
limit: (opts == null ? void 0 : opts.limit) || 50
|
|
7645
7683
|
};
|
|
7646
7684
|
const resp = await directCouchFind(getGlobalDBName(), searchOptions);
|
|
7647
|
-
return resp
|
|
7685
|
+
return resp == null ? void 0 : resp.rows;
|
|
7648
7686
|
};
|
|
7649
7687
|
var getGlobalUserByAppPage = (appId, user) => {
|
|
7650
7688
|
if (!user) {
|
|
@@ -7667,7 +7705,7 @@ var searchGlobalUsersByEmail = async (email, opts, getOpts) => {
|
|
|
7667
7705
|
response = [];
|
|
7668
7706
|
}
|
|
7669
7707
|
let users = Array.isArray(response) ? response : [response];
|
|
7670
|
-
if (getOpts
|
|
7708
|
+
if (getOpts == null ? void 0 : getOpts.cleanup) {
|
|
7671
7709
|
users = removeUserPassword(users);
|
|
7672
7710
|
}
|
|
7673
7711
|
return users;
|
|
@@ -8018,12 +8056,13 @@ __export(users_exports2, {
|
|
|
8018
8056
|
isGlobalBuilder: () => isGlobalBuilder
|
|
8019
8057
|
});
|
|
8020
8058
|
function isBuilder(user, appId) {
|
|
8059
|
+
var _a, _b, _c;
|
|
8021
8060
|
if (!user) {
|
|
8022
8061
|
return false;
|
|
8023
8062
|
}
|
|
8024
|
-
if (user.builder
|
|
8063
|
+
if ((_a = user.builder) == null ? void 0 : _a.global) {
|
|
8025
8064
|
return true;
|
|
8026
|
-
} else if (appId && user.builder
|
|
8065
|
+
} else if (appId && ((_c = (_b = user.builder) == null ? void 0 : _b.apps) == null ? void 0 : _c.includes(getProdAppID2(appId)))) {
|
|
8027
8066
|
return true;
|
|
8028
8067
|
}
|
|
8029
8068
|
return false;
|
|
@@ -8041,24 +8080,27 @@ function isAdminOrBuilder(user, appId) {
|
|
|
8041
8080
|
return isBuilder(user, appId) || isAdmin(user);
|
|
8042
8081
|
}
|
|
8043
8082
|
function hasAppBuilderPermissions(user) {
|
|
8083
|
+
var _a, _b, _c;
|
|
8044
8084
|
if (!user) {
|
|
8045
8085
|
return false;
|
|
8046
8086
|
}
|
|
8047
|
-
const appLength = user.builder
|
|
8048
|
-
const isGlobalBuilder3 = !!user.builder
|
|
8087
|
+
const appLength = (_b = (_a = user.builder) == null ? void 0 : _a.apps) == null ? void 0 : _b.length;
|
|
8088
|
+
const isGlobalBuilder3 = !!((_c = user.builder) == null ? void 0 : _c.global);
|
|
8049
8089
|
return !isGlobalBuilder3 && appLength != null && appLength > 0;
|
|
8050
8090
|
}
|
|
8051
8091
|
function hasBuilderPermissions(user) {
|
|
8092
|
+
var _a;
|
|
8052
8093
|
if (!user) {
|
|
8053
8094
|
return false;
|
|
8054
8095
|
}
|
|
8055
|
-
return user.builder
|
|
8096
|
+
return ((_a = user.builder) == null ? void 0 : _a.global) || hasAppBuilderPermissions(user);
|
|
8056
8097
|
}
|
|
8057
8098
|
function hasAdminPermissions(user) {
|
|
8099
|
+
var _a;
|
|
8058
8100
|
if (!user) {
|
|
8059
8101
|
return false;
|
|
8060
8102
|
}
|
|
8061
|
-
return !!user.admin
|
|
8103
|
+
return !!((_a = user.admin) == null ? void 0 : _a.global);
|
|
8062
8104
|
}
|
|
8063
8105
|
|
|
8064
8106
|
// src/users/utils.ts
|
|
@@ -8131,7 +8173,7 @@ var unassignAppRoleEvents = async (user, roles, existingRoles) => {
|
|
|
8131
8173
|
};
|
|
8132
8174
|
var handleAppRoleEvents = async (user, existingUser) => {
|
|
8133
8175
|
const roles = user.roles;
|
|
8134
|
-
const existingRoles = existingUser
|
|
8176
|
+
const existingRoles = existingUser == null ? void 0 : existingUser.roles;
|
|
8135
8177
|
await assignAppRoleEvents(user, roles, existingRoles);
|
|
8136
8178
|
await unassignAppRoleEvents(user, roles, existingRoles);
|
|
8137
8179
|
};
|
|
@@ -8183,7 +8225,7 @@ var isRemovingAdmin = (user, existingUser) => {
|
|
|
8183
8225
|
return isRemovingPermission(user, existingUser, hasAdminPermissions2);
|
|
8184
8226
|
};
|
|
8185
8227
|
var isOnboardingComplete = (user, existingUser) => {
|
|
8186
|
-
return !existingUser
|
|
8228
|
+
return !(existingUser == null ? void 0 : existingUser.onboardedAt) && typeof user.onboardedAt === "string";
|
|
8187
8229
|
};
|
|
8188
8230
|
var isAddingPermission = (user, existingUser, hasPermission) => {
|
|
8189
8231
|
if (!hasPermission(user)) {
|
|
@@ -8240,7 +8282,7 @@ async function getSessionsForUser(userId) {
|
|
|
8240
8282
|
}
|
|
8241
8283
|
async function invalidateSessions(userId, opts = {}) {
|
|
8242
8284
|
try {
|
|
8243
|
-
const reason = opts
|
|
8285
|
+
const reason = (opts == null ? void 0 : opts.reason) || "unknown";
|
|
8244
8286
|
let sessionIds = opts.sessionIds || [];
|
|
8245
8287
|
let sessionKeys;
|
|
8246
8288
|
if (sessionIds.length === 0) {
|
|
@@ -8417,6 +8459,7 @@ var UserDB = class _UserDB {
|
|
|
8417
8459
|
return user;
|
|
8418
8460
|
}
|
|
8419
8461
|
static async save(user, opts = {}) {
|
|
8462
|
+
var _a, _b;
|
|
8420
8463
|
if (opts.hashPassword == null) {
|
|
8421
8464
|
opts.hashPassword = true;
|
|
8422
8465
|
}
|
|
@@ -8429,7 +8472,7 @@ var UserDB = class _UserDB {
|
|
|
8429
8472
|
if (!email && !_id) {
|
|
8430
8473
|
throw new Error("_id or email is required");
|
|
8431
8474
|
}
|
|
8432
|
-
if (user.builder
|
|
8475
|
+
if (((_b = (_a = user.builder) == null ? void 0 : _a.apps) == null ? void 0 : _b.length) && !await _UserDB.features.isAppBuildersEnabled()) {
|
|
8433
8476
|
throw new Error("Unable to update app builders, please check license");
|
|
8434
8477
|
}
|
|
8435
8478
|
let dbUser;
|
|
@@ -8457,10 +8500,10 @@ var UserDB = class _UserDB {
|
|
|
8457
8500
|
return _UserDB.quotas.addUsers(change, async () => {
|
|
8458
8501
|
await validateUniqueUser(email, tenantId);
|
|
8459
8502
|
let builtUser = await _UserDB.buildUser(user, opts, tenantId, dbUser);
|
|
8460
|
-
if (opts.currentUserId && opts.currentUserId === dbUser
|
|
8503
|
+
if (opts.currentUserId && opts.currentUserId === (dbUser == null ? void 0 : dbUser._id)) {
|
|
8461
8504
|
builtUser = cleanseUserObject(builtUser, dbUser);
|
|
8462
8505
|
}
|
|
8463
|
-
if (!dbUser && roles
|
|
8506
|
+
if (!dbUser && (roles == null ? void 0 : roles.length)) {
|
|
8464
8507
|
builtUser.roles = { ...roles };
|
|
8465
8508
|
}
|
|
8466
8509
|
let groupPromises = [];
|
|
@@ -8739,8 +8782,8 @@ var identifyUser = async (user, account, timestamp) => {
|
|
|
8739
8782
|
if (isSSOUser(user)) {
|
|
8740
8783
|
providerType = user.providerType;
|
|
8741
8784
|
}
|
|
8742
|
-
const accountHolder = account
|
|
8743
|
-
const verified2 = account && account
|
|
8785
|
+
const accountHolder = (account == null ? void 0 : account.budibaseUserId) === user._id || false;
|
|
8786
|
+
const verified2 = account && (account == null ? void 0 : account.budibaseUserId) === user._id ? account.verified : false;
|
|
8744
8787
|
const installationId = await getInstallationId();
|
|
8745
8788
|
const hosting = account ? account.hosting : getHostingFromEnv();
|
|
8746
8789
|
const environment2 = getDeploymentEnvironment();
|
|
@@ -8899,7 +8942,7 @@ var clearEvents = async () => {
|
|
|
8899
8942
|
};
|
|
8900
8943
|
var isBackfillingEvent = async (event) => {
|
|
8901
8944
|
const backfill = await getBackfillMetadata();
|
|
8902
|
-
const events2 = backfill
|
|
8945
|
+
const events2 = backfill == null ? void 0 : backfill.eventWhitelist;
|
|
8903
8946
|
if (events2 && events2.includes(event)) {
|
|
8904
8947
|
return true;
|
|
8905
8948
|
} else {
|
|
@@ -9243,11 +9286,12 @@ var auth_default = {
|
|
|
9243
9286
|
// src/events/publishers/automation.ts
|
|
9244
9287
|
init_src();
|
|
9245
9288
|
async function created3(automation, timestamp) {
|
|
9289
|
+
var _a, _b, _c, _d;
|
|
9246
9290
|
const properties = {
|
|
9247
9291
|
appId: automation.appId,
|
|
9248
9292
|
automationId: automation._id,
|
|
9249
|
-
triggerId: automation.definition
|
|
9250
|
-
triggerType: automation.definition
|
|
9293
|
+
triggerId: (_b = (_a = automation.definition) == null ? void 0 : _a.trigger) == null ? void 0 : _b.id,
|
|
9294
|
+
triggerType: (_d = (_c = automation.definition) == null ? void 0 : _c.trigger) == null ? void 0 : _d.stepId,
|
|
9251
9295
|
audited: {
|
|
9252
9296
|
name: automation.name
|
|
9253
9297
|
}
|
|
@@ -9255,20 +9299,22 @@ async function created3(automation, timestamp) {
|
|
|
9255
9299
|
await publishEvent("automation:created" /* AUTOMATION_CREATED */, properties, timestamp);
|
|
9256
9300
|
}
|
|
9257
9301
|
async function triggerUpdated(automation) {
|
|
9302
|
+
var _a, _b, _c, _d;
|
|
9258
9303
|
const properties = {
|
|
9259
9304
|
appId: automation.appId,
|
|
9260
9305
|
automationId: automation._id,
|
|
9261
|
-
triggerId: automation.definition
|
|
9262
|
-
triggerType: automation.definition
|
|
9306
|
+
triggerId: (_b = (_a = automation.definition) == null ? void 0 : _a.trigger) == null ? void 0 : _b.id,
|
|
9307
|
+
triggerType: (_d = (_c = automation.definition) == null ? void 0 : _c.trigger) == null ? void 0 : _d.stepId
|
|
9263
9308
|
};
|
|
9264
9309
|
await publishEvent("automation:trigger:updated" /* AUTOMATION_TRIGGER_UPDATED */, properties);
|
|
9265
9310
|
}
|
|
9266
9311
|
async function deleted3(automation) {
|
|
9312
|
+
var _a, _b, _c, _d;
|
|
9267
9313
|
const properties = {
|
|
9268
9314
|
appId: automation.appId,
|
|
9269
9315
|
automationId: automation._id,
|
|
9270
|
-
triggerId: automation.definition
|
|
9271
|
-
triggerType: automation.definition
|
|
9316
|
+
triggerId: (_b = (_a = automation.definition) == null ? void 0 : _a.trigger) == null ? void 0 : _b.id,
|
|
9317
|
+
triggerType: (_d = (_c = automation.definition) == null ? void 0 : _c.trigger) == null ? void 0 : _d.stepId,
|
|
9272
9318
|
audited: {
|
|
9273
9319
|
name: automation.name
|
|
9274
9320
|
}
|
|
@@ -9276,11 +9322,12 @@ async function deleted3(automation) {
|
|
|
9276
9322
|
await publishEvent("automation:deleted" /* AUTOMATION_DELETED */, properties);
|
|
9277
9323
|
}
|
|
9278
9324
|
async function tested(automation) {
|
|
9325
|
+
var _a, _b, _c, _d;
|
|
9279
9326
|
const properties = {
|
|
9280
9327
|
appId: automation.appId,
|
|
9281
9328
|
automationId: automation._id,
|
|
9282
|
-
triggerId: automation.definition
|
|
9283
|
-
triggerType: automation.definition
|
|
9329
|
+
triggerId: (_b = (_a = automation.definition) == null ? void 0 : _a.trigger) == null ? void 0 : _b.id,
|
|
9330
|
+
triggerType: (_d = (_c = automation.definition) == null ? void 0 : _c.trigger) == null ? void 0 : _d.stepId
|
|
9284
9331
|
};
|
|
9285
9332
|
await publishEvent("automation:tested" /* AUTOMATION_TESTED */, properties);
|
|
9286
9333
|
}
|
|
@@ -9291,11 +9338,12 @@ var run = async (count, timestamp) => {
|
|
|
9291
9338
|
await publishEvent("automations:run" /* AUTOMATIONS_RUN */, properties, timestamp);
|
|
9292
9339
|
};
|
|
9293
9340
|
async function stepCreated(automation, step, timestamp) {
|
|
9341
|
+
var _a, _b, _c, _d;
|
|
9294
9342
|
const properties = {
|
|
9295
9343
|
appId: automation.appId,
|
|
9296
9344
|
automationId: automation._id,
|
|
9297
|
-
triggerId: automation.definition
|
|
9298
|
-
triggerType: automation.definition
|
|
9345
|
+
triggerId: (_b = (_a = automation.definition) == null ? void 0 : _a.trigger) == null ? void 0 : _b.id,
|
|
9346
|
+
triggerType: (_d = (_c = automation.definition) == null ? void 0 : _c.trigger) == null ? void 0 : _d.stepId,
|
|
9299
9347
|
stepId: step.id,
|
|
9300
9348
|
stepType: step.stepId,
|
|
9301
9349
|
audited: {
|
|
@@ -9305,11 +9353,12 @@ async function stepCreated(automation, step, timestamp) {
|
|
|
9305
9353
|
await publishEvent("automation:step:created" /* AUTOMATION_STEP_CREATED */, properties, timestamp);
|
|
9306
9354
|
}
|
|
9307
9355
|
async function stepDeleted(automation, step) {
|
|
9356
|
+
var _a, _b, _c, _d;
|
|
9308
9357
|
const properties = {
|
|
9309
9358
|
appId: automation.appId,
|
|
9310
9359
|
automationId: automation._id,
|
|
9311
|
-
triggerId: automation.definition
|
|
9312
|
-
triggerType: automation.definition
|
|
9360
|
+
triggerId: (_b = (_a = automation.definition) == null ? void 0 : _a.trigger) == null ? void 0 : _b.id,
|
|
9361
|
+
triggerType: (_d = (_c = automation.definition) == null ? void 0 : _c.trigger) == null ? void 0 : _d.stepId,
|
|
9313
9362
|
stepId: step.id,
|
|
9314
9363
|
stepType: step.stepId,
|
|
9315
9364
|
audited: {
|
|
@@ -9596,23 +9645,25 @@ var role_default = {
|
|
|
9596
9645
|
// src/events/publishers/screen.ts
|
|
9597
9646
|
init_src();
|
|
9598
9647
|
async function created8(screen, timestamp) {
|
|
9648
|
+
var _a;
|
|
9599
9649
|
const properties = {
|
|
9600
9650
|
layoutId: screen.layoutId,
|
|
9601
9651
|
screenId: screen._id,
|
|
9602
9652
|
roleId: screen.routing.roleId,
|
|
9603
9653
|
audited: {
|
|
9604
|
-
name: screen.routing
|
|
9654
|
+
name: (_a = screen.routing) == null ? void 0 : _a.route
|
|
9605
9655
|
}
|
|
9606
9656
|
};
|
|
9607
9657
|
await publishEvent("screen:created" /* SCREEN_CREATED */, properties, timestamp);
|
|
9608
9658
|
}
|
|
9609
9659
|
async function deleted8(screen) {
|
|
9660
|
+
var _a;
|
|
9610
9661
|
const properties = {
|
|
9611
9662
|
layoutId: screen.layoutId,
|
|
9612
9663
|
screenId: screen._id,
|
|
9613
9664
|
roleId: screen.routing.roleId,
|
|
9614
9665
|
audited: {
|
|
9615
|
-
name: screen.routing
|
|
9666
|
+
name: (_a = screen.routing) == null ? void 0 : _a.route
|
|
9616
9667
|
}
|
|
9617
9668
|
};
|
|
9618
9669
|
await publishEvent("screen:deleted" /* SCREEN_DELETED */, properties);
|
|
@@ -10548,7 +10599,8 @@ var BUILTIN_PERMISSIONS = {
|
|
|
10548
10599
|
name: "Read only",
|
|
10549
10600
|
permissions: [
|
|
10550
10601
|
new Permission("query" /* QUERY */, "read" /* READ */),
|
|
10551
|
-
new Permission("table" /* TABLE */, "read" /* READ */)
|
|
10602
|
+
new Permission("table" /* TABLE */, "read" /* READ */),
|
|
10603
|
+
new Permission("view" /* VIEW */, "read" /* READ */)
|
|
10552
10604
|
]
|
|
10553
10605
|
},
|
|
10554
10606
|
WRITE: {
|
|
@@ -10557,6 +10609,7 @@ var BUILTIN_PERMISSIONS = {
|
|
|
10557
10609
|
permissions: [
|
|
10558
10610
|
new Permission("query" /* QUERY */, "write" /* WRITE */),
|
|
10559
10611
|
new Permission("table" /* TABLE */, "write" /* WRITE */),
|
|
10612
|
+
new Permission("view" /* VIEW */, "read" /* READ */),
|
|
10560
10613
|
new Permission("automation" /* AUTOMATION */, "execute" /* EXECUTE */)
|
|
10561
10614
|
]
|
|
10562
10615
|
},
|
|
@@ -10567,6 +10620,7 @@ var BUILTIN_PERMISSIONS = {
|
|
|
10567
10620
|
new Permission("table" /* TABLE */, "write" /* WRITE */),
|
|
10568
10621
|
new Permission("user" /* USER */, "read" /* READ */),
|
|
10569
10622
|
new Permission("automation" /* AUTOMATION */, "execute" /* EXECUTE */),
|
|
10623
|
+
new Permission("view" /* VIEW */, "read" /* READ */),
|
|
10570
10624
|
new Permission("webhook" /* WEBHOOK */, "read" /* READ */)
|
|
10571
10625
|
]
|
|
10572
10626
|
},
|
|
@@ -10577,6 +10631,7 @@ var BUILTIN_PERMISSIONS = {
|
|
|
10577
10631
|
new Permission("table" /* TABLE */, "admin" /* ADMIN */),
|
|
10578
10632
|
new Permission("user" /* USER */, "admin" /* ADMIN */),
|
|
10579
10633
|
new Permission("automation" /* AUTOMATION */, "admin" /* ADMIN */),
|
|
10634
|
+
new Permission("view" /* VIEW */, "admin" /* ADMIN */),
|
|
10580
10635
|
new Permission("webhook" /* WEBHOOK */, "read" /* READ */),
|
|
10581
10636
|
new Permission("query" /* QUERY */, "admin" /* ADMIN */)
|
|
10582
10637
|
]
|
|
@@ -10679,7 +10734,7 @@ var BUILTIN_ROLE_NAME_ARRAY = Object.values(BUILTIN_ROLES).map(
|
|
|
10679
10734
|
(role) => role.name
|
|
10680
10735
|
);
|
|
10681
10736
|
function isBuiltin(role) {
|
|
10682
|
-
return BUILTIN_ROLE_ID_ARRAY.some((builtin) => role
|
|
10737
|
+
return BUILTIN_ROLE_ID_ARRAY.some((builtin) => role == null ? void 0 : role.includes(builtin));
|
|
10683
10738
|
}
|
|
10684
10739
|
function builtinRoleToNumber(id) {
|
|
10685
10740
|
if (!id) {
|
|
@@ -10706,7 +10761,7 @@ async function roleToNumber(id) {
|
|
|
10706
10761
|
}
|
|
10707
10762
|
const hierarchy = await getUserRoleHierarchy(id);
|
|
10708
10763
|
for (let role of hierarchy) {
|
|
10709
|
-
if (isBuiltin(role
|
|
10764
|
+
if (isBuiltin(role == null ? void 0 : role.inherits)) {
|
|
10710
10765
|
return builtinRoleToNumber(role.inherits) + 1;
|
|
10711
10766
|
}
|
|
10712
10767
|
}
|
|
@@ -10739,7 +10794,7 @@ async function getRole(roleId, opts) {
|
|
|
10739
10794
|
role = Object.assign(role, dbRole);
|
|
10740
10795
|
role._id = getExternalRoleID(role._id, role.version);
|
|
10741
10796
|
} catch (err) {
|
|
10742
|
-
if (!isBuiltin(roleId) && opts
|
|
10797
|
+
if (!isBuiltin(roleId) && (opts == null ? void 0 : opts.defaultPublic)) {
|
|
10743
10798
|
return (0, import_cloneDeep2.default)(BUILTIN_ROLES.PUBLIC);
|
|
10744
10799
|
}
|
|
10745
10800
|
if (Object.keys(role).length === 0) {
|
|
@@ -10862,7 +10917,7 @@ var AccessController = class {
|
|
|
10862
10917
|
});
|
|
10863
10918
|
this.userHierarchies[userRoleId] = roleIds;
|
|
10864
10919
|
}
|
|
10865
|
-
return roleIds
|
|
10920
|
+
return (roleIds == null ? void 0 : roleIds.indexOf(tryingRoleId)) !== -1;
|
|
10866
10921
|
}
|
|
10867
10922
|
async checkScreensAccess(screens, userRoleId) {
|
|
10868
10923
|
let accessibleScreens = [];
|
|
@@ -10883,7 +10938,7 @@ var AccessController = class {
|
|
|
10883
10938
|
}
|
|
10884
10939
|
};
|
|
10885
10940
|
function getDBRoleID(roleName) {
|
|
10886
|
-
if (roleName
|
|
10941
|
+
if (roleName == null ? void 0 : roleName.startsWith("role" /* ROLE */)) {
|
|
10887
10942
|
return roleName;
|
|
10888
10943
|
}
|
|
10889
10944
|
return prefixRoleID(roleName);
|
|
@@ -11142,7 +11197,8 @@ async function authenticate2(details, requireLocalAccount = true, done, saveUser
|
|
|
11142
11197
|
return done(null, ssoUser);
|
|
11143
11198
|
}
|
|
11144
11199
|
async function getProfilePictureUrl(user, details) {
|
|
11145
|
-
|
|
11200
|
+
var _a;
|
|
11201
|
+
const pictureUrl = (_a = details.profile) == null ? void 0 : _a._json.picture;
|
|
11146
11202
|
if (pictureUrl) {
|
|
11147
11203
|
const response = await (0, import_node_fetch5.default)(pictureUrl);
|
|
11148
11204
|
if (response.status === 200) {
|
|
@@ -11673,7 +11729,7 @@ function authenticated_default(noAuthPatterns = [], opts = {
|
|
|
11673
11729
|
user = await getUser(userId, session.tenantId);
|
|
11674
11730
|
}
|
|
11675
11731
|
user.csrfToken = session.csrfToken;
|
|
11676
|
-
if (session
|
|
11732
|
+
if ((session == null ? void 0 : session.lastAccessedAt) < timeMinusOneMinute()) {
|
|
11677
11733
|
await updateSessionTTL(session);
|
|
11678
11734
|
}
|
|
11679
11735
|
authenticated = true;
|
|
@@ -11715,9 +11771,9 @@ function authenticated_default(noAuthPatterns = [], opts = {
|
|
|
11715
11771
|
} catch (err) {
|
|
11716
11772
|
console.error(`Auth Error: ${err.message}`);
|
|
11717
11773
|
console.error(err);
|
|
11718
|
-
if (err
|
|
11774
|
+
if ((err == null ? void 0 : err.name) === "JsonWebTokenError") {
|
|
11719
11775
|
clearCookie(ctx, "budibase:auth" /* Auth */);
|
|
11720
|
-
} else if (err
|
|
11776
|
+
} else if ((err == null ? void 0 : err.code) === "invalid_api_key" /* INVALID_API_KEY */) {
|
|
11721
11777
|
ctx.throw(403, err.message);
|
|
11722
11778
|
}
|
|
11723
11779
|
if (opts && opts.publicAllowed || publicEndpoint) {
|
|
@@ -11784,6 +11840,7 @@ var INCLUDED_CONTENT_TYPES = [
|
|
|
11784
11840
|
function csrf_default(opts = { noCsrfPatterns: [] }) {
|
|
11785
11841
|
const noCsrfOptions = buildMatcherRegex(opts.noCsrfPatterns);
|
|
11786
11842
|
return async (ctx, next) => {
|
|
11843
|
+
var _a;
|
|
11787
11844
|
const found = matches(ctx, noCsrfOptions);
|
|
11788
11845
|
if (found) {
|
|
11789
11846
|
return next();
|
|
@@ -11798,7 +11855,7 @@ function csrf_default(opts = { noCsrfPatterns: [] }) {
|
|
|
11798
11855
|
if (ctx.internal) {
|
|
11799
11856
|
return next();
|
|
11800
11857
|
}
|
|
11801
|
-
const userToken = ctx.user
|
|
11858
|
+
const userToken = (_a = ctx.user) == null ? void 0 : _a.csrfToken;
|
|
11802
11859
|
if (!userToken) {
|
|
11803
11860
|
return next();
|
|
11804
11861
|
}
|
|
@@ -11858,7 +11915,10 @@ function pinoSettings() {
|
|
|
11858
11915
|
logger,
|
|
11859
11916
|
genReqId: correlator2.getId,
|
|
11860
11917
|
autoLogging: {
|
|
11861
|
-
ignore: (req) =>
|
|
11918
|
+
ignore: (req) => {
|
|
11919
|
+
var _a;
|
|
11920
|
+
return !!((_a = req.url) == null ? void 0 : _a.includes("/health"));
|
|
11921
|
+
}
|
|
11862
11922
|
},
|
|
11863
11923
|
serializers: {
|
|
11864
11924
|
req: (req) => {
|
|
@@ -11929,7 +11989,8 @@ var errorHandling_default = errorHandling;
|
|
|
11929
11989
|
|
|
11930
11990
|
// src/middleware/querystringToBody.ts
|
|
11931
11991
|
function querystringToBody_default(ctx, next) {
|
|
11932
|
-
|
|
11992
|
+
var _a;
|
|
11993
|
+
const queryString = (_a = ctx.request.query) == null ? void 0 : _a.query;
|
|
11933
11994
|
if (ctx.request.method.toLowerCase() !== "get") {
|
|
11934
11995
|
ctx.throw(
|
|
11935
11996
|
500,
|
|
@@ -11959,11 +12020,12 @@ __export(joi_validator_exports, {
|
|
|
11959
12020
|
var import_joi = __toESM(require("joi"));
|
|
11960
12021
|
function validate(schema, property) {
|
|
11961
12022
|
return (ctx, next) => {
|
|
12023
|
+
var _a;
|
|
11962
12024
|
if (!schema) {
|
|
11963
12025
|
return next();
|
|
11964
12026
|
}
|
|
11965
12027
|
let params2 = null;
|
|
11966
|
-
let reqProp = ctx.request
|
|
12028
|
+
let reqProp = (_a = ctx.request) == null ? void 0 : _a[property];
|
|
11967
12029
|
if (ctx[property] != null) {
|
|
11968
12030
|
params2 = ctx[property];
|
|
11969
12031
|
} else if (reqProp != null) {
|
|
@@ -12102,6 +12164,7 @@ async function updateUserOAuth(userId, oAuthConfig) {
|
|
|
12102
12164
|
}
|
|
12103
12165
|
}
|
|
12104
12166
|
async function platformLogout(opts) {
|
|
12167
|
+
var _a;
|
|
12105
12168
|
const ctx = opts.ctx;
|
|
12106
12169
|
const userId = opts.userId;
|
|
12107
12170
|
const keepActiveSession = opts.keepActiveSession;
|
|
@@ -12118,7 +12181,7 @@ async function platformLogout(opts) {
|
|
|
12118
12181
|
}
|
|
12119
12182
|
const sessionIds = sessions.map(({ sessionId }) => sessionId);
|
|
12120
12183
|
await invalidateSessions(userId, { sessionIds, reason: "logout" });
|
|
12121
|
-
await auth_default.logout(ctx.user
|
|
12184
|
+
await auth_default.logout((_a = ctx.user) == null ? void 0 : _a.email);
|
|
12122
12185
|
await invalidateUser(userId);
|
|
12123
12186
|
}
|
|
12124
12187
|
|
|
@@ -12234,7 +12297,7 @@ function validateAutomation(schema) {
|
|
|
12234
12297
|
runJoi(validator, schema);
|
|
12235
12298
|
}
|
|
12236
12299
|
function validate2(schema) {
|
|
12237
|
-
switch (schema
|
|
12300
|
+
switch (schema == null ? void 0 : schema.type) {
|
|
12238
12301
|
case "component" /* COMPONENT */:
|
|
12239
12302
|
validateComponent(schema);
|
|
12240
12303
|
break;
|
|
@@ -12298,7 +12361,7 @@ async function lookup(address) {
|
|
|
12298
12361
|
}
|
|
12299
12362
|
async function refreshBlacklist() {
|
|
12300
12363
|
const blacklist = environment_default.BLACKLIST_IPS;
|
|
12301
|
-
const list = blacklist
|
|
12364
|
+
const list = (blacklist == null ? void 0 : blacklist.split(",")) || [];
|
|
12302
12365
|
let final = [];
|
|
12303
12366
|
for (let addr of list) {
|
|
12304
12367
|
const trimmed = addr.trim();
|
|
@@ -12315,7 +12378,7 @@ async function isBlacklisted(address) {
|
|
|
12315
12378
|
if (!blackListArray) {
|
|
12316
12379
|
await refreshBlacklist();
|
|
12317
12380
|
}
|
|
12318
|
-
if (blackListArray
|
|
12381
|
+
if ((blackListArray == null ? void 0 : blackListArray.length) === 0) {
|
|
12319
12382
|
return false;
|
|
12320
12383
|
}
|
|
12321
12384
|
let ips;
|
|
@@ -12324,7 +12387,7 @@ async function isBlacklisted(address) {
|
|
|
12324
12387
|
} else {
|
|
12325
12388
|
ips = [address];
|
|
12326
12389
|
}
|
|
12327
|
-
return !!blackListArray
|
|
12390
|
+
return !!(blackListArray == null ? void 0 : blackListArray.find((addr) => ips.includes(addr)));
|
|
12328
12391
|
}
|
|
12329
12392
|
|
|
12330
12393
|
// src/docUpdates/index.ts
|