@budibase/backend-core 2.9.21-alpha.2 → 2.9.23
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 +342 -267
- package/dist/index.js.map +4 -4
- package/dist/index.js.meta.json +1 -1
- package/dist/package.json +7 -7
- package/dist/plugins.js +1 -1
- package/dist/plugins.js.map +2 -2
- package/dist/plugins.js.meta.json +1 -1
- package/dist/src/db/couch/DatabaseImpl.d.ts +2 -1
- package/dist/tests.js +272 -222
- package/dist/tests.js.map +4 -4
- package/dist/tests.js.meta.json +1 -1
- package/package.json +7 -7
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");
|
|
@@ -2244,6 +2252,18 @@ var init_DatabaseImpl = __esm({
|
|
|
2244
2252
|
}
|
|
2245
2253
|
return this.updateOutput(() => db.get(id));
|
|
2246
2254
|
}
|
|
2255
|
+
async docExists(docId) {
|
|
2256
|
+
const db = await this.checkSetup();
|
|
2257
|
+
let _rev, exists2;
|
|
2258
|
+
try {
|
|
2259
|
+
const { etag } = await db.head(docId);
|
|
2260
|
+
_rev = etag;
|
|
2261
|
+
exists2 = true;
|
|
2262
|
+
} catch (err) {
|
|
2263
|
+
exists2 = false;
|
|
2264
|
+
}
|
|
2265
|
+
return { _rev, exists: exists2 };
|
|
2266
|
+
}
|
|
2247
2267
|
async remove(idOrDoc, rev) {
|
|
2248
2268
|
const db = await this.checkSetup();
|
|
2249
2269
|
let _id;
|
|
@@ -2275,7 +2295,7 @@ var init_DatabaseImpl = __esm({
|
|
|
2275
2295
|
document.createdAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
2276
2296
|
}
|
|
2277
2297
|
document.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
2278
|
-
if (opts
|
|
2298
|
+
if ((opts == null ? void 0 : opts.force) && document._id) {
|
|
2279
2299
|
try {
|
|
2280
2300
|
const existing = await this.get(document._id);
|
|
2281
2301
|
if (existing) {
|
|
@@ -2439,7 +2459,7 @@ function isMultiTenant() {
|
|
|
2439
2459
|
}
|
|
2440
2460
|
function isTenantIdSet() {
|
|
2441
2461
|
const context = Context.get();
|
|
2442
|
-
return !!context
|
|
2462
|
+
return !!(context == null ? void 0 : context.tenantId);
|
|
2443
2463
|
}
|
|
2444
2464
|
function isTenancyEnabled() {
|
|
2445
2465
|
return environment_default.MULTI_TENANCY;
|
|
@@ -2538,7 +2558,7 @@ async function doInIdentityContext(identity, task) {
|
|
|
2538
2558
|
function getIdentity() {
|
|
2539
2559
|
try {
|
|
2540
2560
|
const context = Context.get();
|
|
2541
|
-
return context
|
|
2561
|
+
return context == null ? void 0 : context.identity;
|
|
2542
2562
|
} catch (e) {
|
|
2543
2563
|
}
|
|
2544
2564
|
}
|
|
@@ -2547,7 +2567,7 @@ function getTenantId() {
|
|
|
2547
2567
|
return DEFAULT_TENANT_ID;
|
|
2548
2568
|
}
|
|
2549
2569
|
const context = Context.get();
|
|
2550
|
-
const tenantId = context
|
|
2570
|
+
const tenantId = context == null ? void 0 : context.tenantId;
|
|
2551
2571
|
if (!tenantId) {
|
|
2552
2572
|
throw new Error("Tenant id not found");
|
|
2553
2573
|
}
|
|
@@ -2555,11 +2575,11 @@ function getTenantId() {
|
|
|
2555
2575
|
}
|
|
2556
2576
|
function getAutomationId() {
|
|
2557
2577
|
const context = Context.get();
|
|
2558
|
-
return context
|
|
2578
|
+
return context == null ? void 0 : context.automationId;
|
|
2559
2579
|
}
|
|
2560
2580
|
function getAppId() {
|
|
2561
2581
|
const context = Context.get();
|
|
2562
|
-
const foundId = context
|
|
2582
|
+
const foundId = context == null ? void 0 : context.appId;
|
|
2563
2583
|
if (!foundId && environment_default.isTest() && TEST_APP_ID) {
|
|
2564
2584
|
return TEST_APP_ID;
|
|
2565
2585
|
} else {
|
|
@@ -2594,7 +2614,7 @@ function getGlobalDB() {
|
|
|
2594
2614
|
if (!context || environment_default.MULTI_TENANCY && !context.tenantId) {
|
|
2595
2615
|
throw new Error("Global DB not found");
|
|
2596
2616
|
}
|
|
2597
|
-
return getDB(baseGlobalDBName(context
|
|
2617
|
+
return getDB(baseGlobalDBName(context == null ? void 0 : context.tenantId));
|
|
2598
2618
|
}
|
|
2599
2619
|
function getAuditLogsDB() {
|
|
2600
2620
|
if (!getTenantId()) {
|
|
@@ -2622,7 +2642,7 @@ function getDevAppDB(opts) {
|
|
|
2622
2642
|
}
|
|
2623
2643
|
function isScim() {
|
|
2624
2644
|
const context = Context.get();
|
|
2625
|
-
const scimCall = context
|
|
2645
|
+
const scimCall = context == null ? void 0 : context.isScim;
|
|
2626
2646
|
return !!scimCall;
|
|
2627
2647
|
}
|
|
2628
2648
|
var TEST_APP_ID, getProdAppId;
|
|
@@ -3473,7 +3493,7 @@ function getGlobalUserParams(globalId, otherProps = {}) {
|
|
|
3473
3493
|
if (!globalId) {
|
|
3474
3494
|
globalId = "";
|
|
3475
3495
|
}
|
|
3476
|
-
const startkey = otherProps
|
|
3496
|
+
const startkey = otherProps == null ? void 0 : otherProps.startkey;
|
|
3477
3497
|
return {
|
|
3478
3498
|
...otherProps,
|
|
3479
3499
|
// need to include this incase pagination
|
|
@@ -3606,7 +3626,10 @@ async function getAllApps({
|
|
|
3606
3626
|
} else {
|
|
3607
3627
|
const response = await Promise.allSettled(appPromises);
|
|
3608
3628
|
const apps = response.filter(
|
|
3609
|
-
(result) =>
|
|
3629
|
+
(result) => {
|
|
3630
|
+
var _a;
|
|
3631
|
+
return result.status === "fulfilled" && ((_a = result.value) == null ? void 0 : _a.state) !== "invalid" /* INVALID */;
|
|
3632
|
+
}
|
|
3610
3633
|
).map(({ value }) => value);
|
|
3611
3634
|
if (!all) {
|
|
3612
3635
|
return apps.filter((app) => {
|
|
@@ -3668,7 +3691,7 @@ function pagination(data, pageSize, {
|
|
|
3668
3691
|
const hasNextPage = data.length > pageSize;
|
|
3669
3692
|
let nextPage = void 0;
|
|
3670
3693
|
if (!getKey) {
|
|
3671
|
-
getKey = (doc) => property ? doc
|
|
3694
|
+
getKey = (doc) => property ? doc == null ? void 0 : doc[property] : doc == null ? void 0 : doc._id;
|
|
3672
3695
|
}
|
|
3673
3696
|
if (hasNextPage) {
|
|
3674
3697
|
nextPage = getKey(data[pageSize]);
|
|
@@ -3819,7 +3842,7 @@ var init_views = __esm({
|
|
|
3819
3842
|
const docs = rows.map(
|
|
3820
3843
|
(row) => params2.include_docs ? row.doc : row.value
|
|
3821
3844
|
);
|
|
3822
|
-
if (opts
|
|
3845
|
+
if (opts == null ? void 0 : opts.arrayResponse) {
|
|
3823
3846
|
return docs;
|
|
3824
3847
|
} else {
|
|
3825
3848
|
return docs.length <= 1 ? docs[0] : docs;
|
|
@@ -4042,34 +4065,38 @@ async function fullSearch(dbName, index2, query, params2) {
|
|
|
4042
4065
|
const rows = await recursiveSearch(dbName, index2, query, params2);
|
|
4043
4066
|
return { rows };
|
|
4044
4067
|
}
|
|
4045
|
-
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;
|
|
4046
4069
|
var init_lucene = __esm({
|
|
4047
4070
|
"src/db/lucene.ts"() {
|
|
4048
4071
|
"use strict";
|
|
4049
4072
|
import_node_fetch2 = __toESM(require("node-fetch"));
|
|
4050
4073
|
init_couch();
|
|
4051
4074
|
QUERY_START_REGEX = /\d[0-9]*:/g;
|
|
4052
|
-
|
|
4053
|
-
#dbName;
|
|
4054
|
-
#index;
|
|
4055
|
-
#query;
|
|
4056
|
-
#limit;
|
|
4057
|
-
#sort;
|
|
4058
|
-
#bookmark;
|
|
4059
|
-
#sortOrder;
|
|
4060
|
-
#sortType;
|
|
4061
|
-
#includeDocs;
|
|
4062
|
-
#version;
|
|
4063
|
-
#indexBuilder;
|
|
4064
|
-
#noEscaping = false;
|
|
4065
|
-
#skip;
|
|
4066
|
-
static {
|
|
4067
|
-
this.maxLimit = 200;
|
|
4068
|
-
}
|
|
4075
|
+
_QueryBuilder = class _QueryBuilder {
|
|
4069
4076
|
constructor(dbName, index2, base) {
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
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, {
|
|
4073
4100
|
allOr: false,
|
|
4074
4101
|
string: {},
|
|
4075
4102
|
fuzzy: {},
|
|
@@ -4083,124 +4110,124 @@ var init_lucene = __esm({
|
|
|
4083
4110
|
notContains: {},
|
|
4084
4111
|
containsAny: {},
|
|
4085
4112
|
...base
|
|
4086
|
-
};
|
|
4087
|
-
this
|
|
4088
|
-
this
|
|
4089
|
-
this
|
|
4090
|
-
this
|
|
4113
|
+
});
|
|
4114
|
+
__privateSet(this, _limit, 50);
|
|
4115
|
+
__privateSet(this, _sortOrder, "ascending");
|
|
4116
|
+
__privateSet(this, _sortType, "string");
|
|
4117
|
+
__privateSet(this, _includeDocs, true);
|
|
4091
4118
|
}
|
|
4092
4119
|
disableEscaping() {
|
|
4093
|
-
this
|
|
4120
|
+
__privateSet(this, _noEscaping, true);
|
|
4094
4121
|
return this;
|
|
4095
4122
|
}
|
|
4096
4123
|
setIndexBuilder(builderFn) {
|
|
4097
|
-
this
|
|
4124
|
+
__privateSet(this, _indexBuilder, builderFn);
|
|
4098
4125
|
return this;
|
|
4099
4126
|
}
|
|
4100
4127
|
setVersion(version) {
|
|
4101
4128
|
if (version != null) {
|
|
4102
|
-
this
|
|
4129
|
+
__privateSet(this, _version, version);
|
|
4103
4130
|
}
|
|
4104
4131
|
return this;
|
|
4105
4132
|
}
|
|
4106
4133
|
setTable(tableId) {
|
|
4107
|
-
this
|
|
4134
|
+
__privateGet(this, _query).equal.tableId = tableId;
|
|
4108
4135
|
return this;
|
|
4109
4136
|
}
|
|
4110
4137
|
setLimit(limit) {
|
|
4111
4138
|
if (limit != null) {
|
|
4112
|
-
this
|
|
4139
|
+
__privateSet(this, _limit, limit);
|
|
4113
4140
|
}
|
|
4114
4141
|
return this;
|
|
4115
4142
|
}
|
|
4116
4143
|
setSort(sort) {
|
|
4117
4144
|
if (sort != null) {
|
|
4118
|
-
this
|
|
4145
|
+
__privateSet(this, _sort, sort);
|
|
4119
4146
|
}
|
|
4120
4147
|
return this;
|
|
4121
4148
|
}
|
|
4122
4149
|
setSortOrder(sortOrder) {
|
|
4123
4150
|
if (sortOrder != null) {
|
|
4124
|
-
this
|
|
4151
|
+
__privateSet(this, _sortOrder, sortOrder);
|
|
4125
4152
|
}
|
|
4126
4153
|
return this;
|
|
4127
4154
|
}
|
|
4128
4155
|
setSortType(sortType) {
|
|
4129
4156
|
if (sortType != null) {
|
|
4130
|
-
this
|
|
4157
|
+
__privateSet(this, _sortType, sortType);
|
|
4131
4158
|
}
|
|
4132
4159
|
return this;
|
|
4133
4160
|
}
|
|
4134
4161
|
setBookmark(bookmark) {
|
|
4135
4162
|
if (bookmark != null) {
|
|
4136
|
-
this
|
|
4163
|
+
__privateSet(this, _bookmark, bookmark);
|
|
4137
4164
|
}
|
|
4138
4165
|
return this;
|
|
4139
4166
|
}
|
|
4140
4167
|
setSkip(skip) {
|
|
4141
|
-
this
|
|
4168
|
+
__privateSet(this, _skip, skip);
|
|
4142
4169
|
return this;
|
|
4143
4170
|
}
|
|
4144
4171
|
excludeDocs() {
|
|
4145
|
-
this
|
|
4172
|
+
__privateSet(this, _includeDocs, false);
|
|
4146
4173
|
return this;
|
|
4147
4174
|
}
|
|
4148
4175
|
includeDocs() {
|
|
4149
|
-
this
|
|
4176
|
+
__privateSet(this, _includeDocs, true);
|
|
4150
4177
|
return this;
|
|
4151
4178
|
}
|
|
4152
4179
|
addString(key, partial) {
|
|
4153
|
-
this
|
|
4180
|
+
__privateGet(this, _query).string[key] = partial;
|
|
4154
4181
|
return this;
|
|
4155
4182
|
}
|
|
4156
4183
|
addFuzzy(key, fuzzy) {
|
|
4157
|
-
this
|
|
4184
|
+
__privateGet(this, _query).fuzzy[key] = fuzzy;
|
|
4158
4185
|
return this;
|
|
4159
4186
|
}
|
|
4160
4187
|
addRange(key, low, high) {
|
|
4161
|
-
this
|
|
4188
|
+
__privateGet(this, _query).range[key] = {
|
|
4162
4189
|
low,
|
|
4163
4190
|
high
|
|
4164
4191
|
};
|
|
4165
4192
|
return this;
|
|
4166
4193
|
}
|
|
4167
4194
|
addEqual(key, value) {
|
|
4168
|
-
this
|
|
4195
|
+
__privateGet(this, _query).equal[key] = value;
|
|
4169
4196
|
return this;
|
|
4170
4197
|
}
|
|
4171
4198
|
addNotEqual(key, value) {
|
|
4172
|
-
this
|
|
4199
|
+
__privateGet(this, _query).notEqual[key] = value;
|
|
4173
4200
|
return this;
|
|
4174
4201
|
}
|
|
4175
4202
|
addEmpty(key, value) {
|
|
4176
|
-
this
|
|
4203
|
+
__privateGet(this, _query).empty[key] = value;
|
|
4177
4204
|
return this;
|
|
4178
4205
|
}
|
|
4179
4206
|
addNotEmpty(key, value) {
|
|
4180
|
-
this
|
|
4207
|
+
__privateGet(this, _query).notEmpty[key] = value;
|
|
4181
4208
|
return this;
|
|
4182
4209
|
}
|
|
4183
4210
|
addOneOf(key, value) {
|
|
4184
|
-
this
|
|
4211
|
+
__privateGet(this, _query).oneOf[key] = value;
|
|
4185
4212
|
return this;
|
|
4186
4213
|
}
|
|
4187
4214
|
addContains(key, value) {
|
|
4188
|
-
this
|
|
4215
|
+
__privateGet(this, _query).contains[key] = value;
|
|
4189
4216
|
return this;
|
|
4190
4217
|
}
|
|
4191
4218
|
addNotContains(key, value) {
|
|
4192
|
-
this
|
|
4219
|
+
__privateGet(this, _query).notContains[key] = value;
|
|
4193
4220
|
return this;
|
|
4194
4221
|
}
|
|
4195
4222
|
addContainsAny(key, value) {
|
|
4196
|
-
this
|
|
4223
|
+
__privateGet(this, _query).containsAny[key] = value;
|
|
4197
4224
|
return this;
|
|
4198
4225
|
}
|
|
4199
4226
|
setAllOr() {
|
|
4200
|
-
this
|
|
4227
|
+
__privateGet(this, _query).allOr = true;
|
|
4201
4228
|
}
|
|
4202
4229
|
handleSpaces(input) {
|
|
4203
|
-
if (this
|
|
4230
|
+
if (__privateGet(this, _noEscaping)) {
|
|
4204
4231
|
return input;
|
|
4205
4232
|
} else {
|
|
4206
4233
|
return input.replace(/ /g, "_");
|
|
@@ -4214,12 +4241,12 @@ var init_lucene = __esm({
|
|
|
4214
4241
|
* @returns {string|*}
|
|
4215
4242
|
*/
|
|
4216
4243
|
preprocess(value, { escape, lowercase, wrap, type } = {}) {
|
|
4217
|
-
const hasVersion = !!this
|
|
4244
|
+
const hasVersion = !!__privateGet(this, _version);
|
|
4218
4245
|
const originalType = typeof value;
|
|
4219
4246
|
if (value && lowercase) {
|
|
4220
4247
|
value = value.toLowerCase ? value.toLowerCase() : value;
|
|
4221
4248
|
}
|
|
4222
|
-
if (!this
|
|
4249
|
+
if (!__privateGet(this, _noEscaping) && escape && originalType === "string") {
|
|
4223
4250
|
value = `${value}`.replace(/[ \/#+\-&|!(){}\]^"~*?:\\]/g, "\\$&");
|
|
4224
4251
|
}
|
|
4225
4252
|
if (originalType === "string" && !isNaN(value) && !type) {
|
|
@@ -4231,7 +4258,7 @@ var init_lucene = __esm({
|
|
|
4231
4258
|
}
|
|
4232
4259
|
isMultiCondition() {
|
|
4233
4260
|
let count = 0;
|
|
4234
|
-
for (let filters of Object.values(this
|
|
4261
|
+
for (let filters of Object.values(__privateGet(this, _query))) {
|
|
4235
4262
|
if (typeof filters === "object") {
|
|
4236
4263
|
count += Object.keys(filters).length;
|
|
4237
4264
|
}
|
|
@@ -4257,13 +4284,13 @@ var init_lucene = __esm({
|
|
|
4257
4284
|
}
|
|
4258
4285
|
buildSearchQuery() {
|
|
4259
4286
|
const builder = this;
|
|
4260
|
-
let allOr = this
|
|
4287
|
+
let allOr = __privateGet(this, _query) && __privateGet(this, _query).allOr;
|
|
4261
4288
|
let query = allOr ? "" : "*:*";
|
|
4262
4289
|
const allPreProcessingOpts = { escape: true, lowercase: true, wrap: true };
|
|
4263
4290
|
let tableId;
|
|
4264
|
-
if (this
|
|
4265
|
-
tableId = this
|
|
4266
|
-
delete this
|
|
4291
|
+
if (__privateGet(this, _query).equal.tableId) {
|
|
4292
|
+
tableId = __privateGet(this, _query).equal.tableId;
|
|
4293
|
+
delete __privateGet(this, _query).equal.tableId;
|
|
4267
4294
|
}
|
|
4268
4295
|
const equal = (key, value) => {
|
|
4269
4296
|
if (!value && value !== 0) {
|
|
@@ -4337,19 +4364,19 @@ var init_lucene = __esm({
|
|
|
4337
4364
|
continue;
|
|
4338
4365
|
}
|
|
4339
4366
|
if (built.length > 0 || query.length > 0) {
|
|
4340
|
-
const mode = opts
|
|
4367
|
+
const mode = (opts == null ? void 0 : opts.mode) ? opts.mode : allOr ? "OR" : "AND";
|
|
4341
4368
|
built += ` ${mode} `;
|
|
4342
4369
|
}
|
|
4343
4370
|
built += expression;
|
|
4344
4371
|
}
|
|
4345
|
-
if (opts
|
|
4372
|
+
if (opts == null ? void 0 : opts.returnBuilt) {
|
|
4346
4373
|
return built;
|
|
4347
4374
|
} else {
|
|
4348
4375
|
query += built;
|
|
4349
4376
|
}
|
|
4350
4377
|
}
|
|
4351
|
-
if (this
|
|
4352
|
-
build(this
|
|
4378
|
+
if (__privateGet(this, _query).string) {
|
|
4379
|
+
build(__privateGet(this, _query).string, (key, value) => {
|
|
4353
4380
|
if (!value) {
|
|
4354
4381
|
return null;
|
|
4355
4382
|
}
|
|
@@ -4361,8 +4388,8 @@ var init_lucene = __esm({
|
|
|
4361
4388
|
return `${key}:${value}*`;
|
|
4362
4389
|
});
|
|
4363
4390
|
}
|
|
4364
|
-
if (this
|
|
4365
|
-
build(this
|
|
4391
|
+
if (__privateGet(this, _query).range) {
|
|
4392
|
+
build(__privateGet(this, _query).range, (key, value) => {
|
|
4366
4393
|
if (!value) {
|
|
4367
4394
|
return null;
|
|
4368
4395
|
}
|
|
@@ -4377,14 +4404,14 @@ var init_lucene = __esm({
|
|
|
4377
4404
|
return `${key}:[${low} TO ${high}]`;
|
|
4378
4405
|
});
|
|
4379
4406
|
}
|
|
4380
|
-
if (this
|
|
4381
|
-
build(this
|
|
4407
|
+
if (__privateGet(this, _query).fuzzy) {
|
|
4408
|
+
build(__privateGet(this, _query).fuzzy, fuzzy);
|
|
4382
4409
|
}
|
|
4383
|
-
if (this
|
|
4384
|
-
build(this
|
|
4410
|
+
if (__privateGet(this, _query).equal) {
|
|
4411
|
+
build(__privateGet(this, _query).equal, equal);
|
|
4385
4412
|
}
|
|
4386
|
-
if (this
|
|
4387
|
-
build(this
|
|
4413
|
+
if (__privateGet(this, _query).notEqual) {
|
|
4414
|
+
build(__privateGet(this, _query).notEqual, (key, value) => {
|
|
4388
4415
|
if (!value) {
|
|
4389
4416
|
return null;
|
|
4390
4417
|
}
|
|
@@ -4394,23 +4421,23 @@ var init_lucene = __esm({
|
|
|
4394
4421
|
return `!${key}:${builder.preprocess(value, allPreProcessingOpts)}`;
|
|
4395
4422
|
});
|
|
4396
4423
|
}
|
|
4397
|
-
if (this
|
|
4398
|
-
build(this
|
|
4424
|
+
if (__privateGet(this, _query).empty) {
|
|
4425
|
+
build(__privateGet(this, _query).empty, (key) => `(*:* -${key}:["" TO *])`);
|
|
4399
4426
|
}
|
|
4400
|
-
if (this
|
|
4401
|
-
build(this
|
|
4427
|
+
if (__privateGet(this, _query).notEmpty) {
|
|
4428
|
+
build(__privateGet(this, _query).notEmpty, (key) => `${key}:["" TO *]`);
|
|
4402
4429
|
}
|
|
4403
|
-
if (this
|
|
4404
|
-
build(this
|
|
4430
|
+
if (__privateGet(this, _query).oneOf) {
|
|
4431
|
+
build(__privateGet(this, _query).oneOf, oneOf);
|
|
4405
4432
|
}
|
|
4406
|
-
if (this
|
|
4407
|
-
build(this
|
|
4433
|
+
if (__privateGet(this, _query).contains) {
|
|
4434
|
+
build(__privateGet(this, _query).contains, contains);
|
|
4408
4435
|
}
|
|
4409
|
-
if (this
|
|
4410
|
-
build(this.compressFilters(this
|
|
4436
|
+
if (__privateGet(this, _query).notContains) {
|
|
4437
|
+
build(this.compressFilters(__privateGet(this, _query).notContains), notContains);
|
|
4411
4438
|
}
|
|
4412
|
-
if (this
|
|
4413
|
-
build(this
|
|
4439
|
+
if (__privateGet(this, _query).containsAny) {
|
|
4440
|
+
build(__privateGet(this, _query).containsAny, containsAny);
|
|
4414
4441
|
}
|
|
4415
4442
|
if (tableId) {
|
|
4416
4443
|
query = this.isMultiCondition() ? `(${query})` : query;
|
|
@@ -4422,63 +4449,75 @@ var init_lucene = __esm({
|
|
|
4422
4449
|
buildSearchBody() {
|
|
4423
4450
|
let body2 = {
|
|
4424
4451
|
q: this.buildSearchQuery(),
|
|
4425
|
-
limit: Math.min(this
|
|
4426
|
-
include_docs: this
|
|
4452
|
+
limit: Math.min(__privateGet(this, _limit), _QueryBuilder.maxLimit),
|
|
4453
|
+
include_docs: __privateGet(this, _includeDocs)
|
|
4427
4454
|
};
|
|
4428
|
-
if (this
|
|
4429
|
-
body2.bookmark = this
|
|
4455
|
+
if (__privateGet(this, _bookmark)) {
|
|
4456
|
+
body2.bookmark = __privateGet(this, _bookmark);
|
|
4430
4457
|
}
|
|
4431
|
-
if (this
|
|
4432
|
-
const order = this
|
|
4433
|
-
const type = `<${this
|
|
4434
|
-
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}`;
|
|
4435
4462
|
}
|
|
4436
4463
|
return body2;
|
|
4437
4464
|
}
|
|
4438
4465
|
async run() {
|
|
4439
|
-
if (this
|
|
4440
|
-
await this
|
|
4466
|
+
if (__privateGet(this, _skip)) {
|
|
4467
|
+
await __privateMethod(this, _skipItems, skipItems_fn).call(this, __privateGet(this, _skip));
|
|
4441
4468
|
}
|
|
4442
|
-
return await this
|
|
4469
|
+
return await __privateMethod(this, _execute, execute_fn).call(this);
|
|
4443
4470
|
}
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
|
|
4466
|
-
|
|
4467
|
-
|
|
4468
|
-
const
|
|
4469
|
-
|
|
4470
|
-
|
|
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);
|
|
4471
4513
|
return await runQuery(fullPath, body2, cookie);
|
|
4472
|
-
}
|
|
4473
|
-
|
|
4474
|
-
await this.#indexBuilder();
|
|
4475
|
-
return await runQuery(fullPath, body2, cookie);
|
|
4476
|
-
} else {
|
|
4477
|
-
throw err;
|
|
4478
|
-
}
|
|
4514
|
+
} else {
|
|
4515
|
+
throw err;
|
|
4479
4516
|
}
|
|
4480
4517
|
}
|
|
4481
4518
|
};
|
|
4519
|
+
_QueryBuilder.maxLimit = 200;
|
|
4520
|
+
QueryBuilder = _QueryBuilder;
|
|
4482
4521
|
}
|
|
4483
4522
|
});
|
|
4484
4523
|
|
|
@@ -4557,9 +4596,10 @@ var init_searchIndexes2 = __esm({
|
|
|
4557
4596
|
|
|
4558
4597
|
// src/db/errors.ts
|
|
4559
4598
|
function checkErrorCode(error, code) {
|
|
4599
|
+
var _a;
|
|
4560
4600
|
const stringCode = code.toString();
|
|
4561
4601
|
if (typeof error === "object") {
|
|
4562
|
-
return error.status === code || error.message
|
|
4602
|
+
return error.status === code || ((_a = error.message) == null ? void 0 : _a.includes(stringCode));
|
|
4563
4603
|
} else if (typeof error === "number") {
|
|
4564
4604
|
return error === code;
|
|
4565
4605
|
} else if (typeof error === "string") {
|
|
@@ -4810,12 +4850,12 @@ var init_objectStore = __esm({
|
|
|
4810
4850
|
streamUpload = async (bucketName, filename, stream2, extra = {}) => {
|
|
4811
4851
|
const objectStore = ObjectStore(bucketName);
|
|
4812
4852
|
await makeSureBucketExists(objectStore, bucketName);
|
|
4813
|
-
if (filename
|
|
4853
|
+
if (filename == null ? void 0 : filename.endsWith(".js")) {
|
|
4814
4854
|
extra = {
|
|
4815
4855
|
...extra,
|
|
4816
4856
|
ContentType: "application/javascript"
|
|
4817
4857
|
};
|
|
4818
|
-
} else if (filename
|
|
4858
|
+
} else if (filename == null ? void 0 : filename.endsWith(".svg")) {
|
|
4819
4859
|
extra = {
|
|
4820
4860
|
...extra,
|
|
4821
4861
|
ContentType: "image"
|
|
@@ -4931,6 +4971,7 @@ var init_objectStore = __esm({
|
|
|
4931
4971
|
return objectStore.deleteObjects(params2).promise();
|
|
4932
4972
|
};
|
|
4933
4973
|
deleteFolder = async (bucketName, folder) => {
|
|
4974
|
+
var _a, _b, _c;
|
|
4934
4975
|
bucketName = sanitizeBucket(bucketName);
|
|
4935
4976
|
folder = sanitizeKey(folder);
|
|
4936
4977
|
const client = ObjectStore(bucketName);
|
|
@@ -4939,7 +4980,7 @@ var init_objectStore = __esm({
|
|
|
4939
4980
|
Prefix: folder
|
|
4940
4981
|
};
|
|
4941
4982
|
const existingObjectsResponse = await client.listObjects(listParams).promise();
|
|
4942
|
-
if (existingObjectsResponse.Contents
|
|
4983
|
+
if (((_a = existingObjectsResponse.Contents) == null ? void 0 : _a.length) === 0) {
|
|
4943
4984
|
return;
|
|
4944
4985
|
}
|
|
4945
4986
|
const deleteParams = {
|
|
@@ -4948,11 +4989,11 @@ var init_objectStore = __esm({
|
|
|
4948
4989
|
Objects: []
|
|
4949
4990
|
}
|
|
4950
4991
|
};
|
|
4951
|
-
existingObjectsResponse.Contents
|
|
4992
|
+
(_b = existingObjectsResponse.Contents) == null ? void 0 : _b.forEach((content) => {
|
|
4952
4993
|
deleteParams.Delete.Objects.push({ Key: content.Key });
|
|
4953
4994
|
});
|
|
4954
4995
|
const deleteResponse = await client.deleteObjects(deleteParams).promise();
|
|
4955
|
-
if (deleteResponse.Deleted
|
|
4996
|
+
if (((_c = deleteResponse.Deleted) == null ? void 0 : _c.length) === 1e3) {
|
|
4956
4997
|
return deleteFolder(bucketName, folder);
|
|
4957
4998
|
}
|
|
4958
4999
|
};
|
|
@@ -5229,7 +5270,7 @@ function getFullPath(fileName) {
|
|
|
5229
5270
|
}
|
|
5230
5271
|
function getSingleFileMaxSizeInfo(totalMaxSize) {
|
|
5231
5272
|
const regex = /(\d+)([A-Za-z])/;
|
|
5232
|
-
const match = totalMaxSize
|
|
5273
|
+
const match = totalMaxSize == null ? void 0 : totalMaxSize.match(regex);
|
|
5233
5274
|
if (!match) {
|
|
5234
5275
|
console.warn(`totalMaxSize does not have a valid value`, {
|
|
5235
5276
|
totalMaxSize
|
|
@@ -5261,9 +5302,9 @@ function localFileDestination() {
|
|
|
5261
5302
|
const fileInfo = getSingleFileMaxSizeInfo(environment_default.ROLLING_LOG_MAX_SIZE);
|
|
5262
5303
|
const outFile = rfs.createStream(logsFileName, {
|
|
5263
5304
|
// As we have a rolling size, we want to half the max size
|
|
5264
|
-
size: fileInfo
|
|
5305
|
+
size: fileInfo == null ? void 0 : fileInfo.size,
|
|
5265
5306
|
path: logsPath,
|
|
5266
|
-
maxFiles: fileInfo
|
|
5307
|
+
maxFiles: (fileInfo == null ? void 0 : fileInfo.totalHistoryFiles) || 1,
|
|
5267
5308
|
immutable: true,
|
|
5268
5309
|
history: budibaseLogsHistoryFileName,
|
|
5269
5310
|
initialRotation: false
|
|
@@ -5338,8 +5379,8 @@ var init_logger = __esm({
|
|
|
5338
5379
|
tenantId: getTenantId2(),
|
|
5339
5380
|
appId: getAppId2(),
|
|
5340
5381
|
automationId: getAutomationId2(),
|
|
5341
|
-
identityId: identity
|
|
5342
|
-
identityType: identity
|
|
5382
|
+
identityId: identity == null ? void 0 : identity._id,
|
|
5383
|
+
identityType: identity == null ? void 0 : identity.type,
|
|
5343
5384
|
correlationId: getId()
|
|
5344
5385
|
};
|
|
5345
5386
|
const mergingObject = {
|
|
@@ -5403,30 +5444,30 @@ var init_logger = __esm({
|
|
|
5403
5444
|
pinoInstance = destinations.length ? (0, import_pino.default)(pinoOptions, import_pino.default.multistream(destinations)) : (0, import_pino.default)(pinoOptions);
|
|
5404
5445
|
console.log = (...arg) => {
|
|
5405
5446
|
const [obj, msg] = getLogParams2(arg);
|
|
5406
|
-
pinoInstance
|
|
5447
|
+
pinoInstance == null ? void 0 : pinoInstance.info(obj, msg);
|
|
5407
5448
|
};
|
|
5408
5449
|
console.info = (...arg) => {
|
|
5409
5450
|
const [obj, msg] = getLogParams2(arg);
|
|
5410
|
-
pinoInstance
|
|
5451
|
+
pinoInstance == null ? void 0 : pinoInstance.info(obj, msg);
|
|
5411
5452
|
};
|
|
5412
5453
|
console.warn = (...arg) => {
|
|
5413
5454
|
const [obj, msg] = getLogParams2(arg);
|
|
5414
|
-
pinoInstance
|
|
5455
|
+
pinoInstance == null ? void 0 : pinoInstance.warn(obj, msg);
|
|
5415
5456
|
};
|
|
5416
5457
|
console.error = (...arg) => {
|
|
5417
5458
|
const [obj, msg] = getLogParams2(arg);
|
|
5418
|
-
pinoInstance
|
|
5459
|
+
pinoInstance == null ? void 0 : pinoInstance.error(obj, msg);
|
|
5419
5460
|
};
|
|
5420
5461
|
console.trace = (...arg) => {
|
|
5421
5462
|
const [obj, msg] = getLogParams2(arg);
|
|
5422
5463
|
if (!obj.err) {
|
|
5423
5464
|
obj.err = new Error();
|
|
5424
5465
|
}
|
|
5425
|
-
pinoInstance
|
|
5466
|
+
pinoInstance == null ? void 0 : pinoInstance.trace(obj, msg);
|
|
5426
5467
|
};
|
|
5427
5468
|
console.debug = (...arg) => {
|
|
5428
5469
|
const [obj, msg] = getLogParams2(arg);
|
|
5429
|
-
pinoInstance
|
|
5470
|
+
pinoInstance == null ? void 0 : pinoInstance.debug(obj, msg);
|
|
5430
5471
|
};
|
|
5431
5472
|
const getTenantId2 = () => {
|
|
5432
5473
|
let tenantId;
|
|
@@ -5709,6 +5750,7 @@ var isUserInAppTenant = (appId, user) => {
|
|
|
5709
5750
|
};
|
|
5710
5751
|
var ALL_STRATEGIES = Object.values(TenantResolutionStrategy);
|
|
5711
5752
|
var getTenantIDFromCtx = (ctx, opts) => {
|
|
5753
|
+
var _a;
|
|
5712
5754
|
if (!isMultiTenant()) {
|
|
5713
5755
|
return DEFAULT_TENANT_ID;
|
|
5714
5756
|
}
|
|
@@ -5722,15 +5764,16 @@ var getTenantIDFromCtx = (ctx, opts) => {
|
|
|
5722
5764
|
opts.excludeStrategies = [];
|
|
5723
5765
|
}
|
|
5724
5766
|
const isAllowed = (strategy) => {
|
|
5725
|
-
|
|
5767
|
+
var _a2, _b;
|
|
5768
|
+
if ((_a2 = opts.excludeStrategies) == null ? void 0 : _a2.includes(strategy)) {
|
|
5726
5769
|
return false;
|
|
5727
5770
|
}
|
|
5728
|
-
if (opts.includeStrategies
|
|
5771
|
+
if ((_b = opts.includeStrategies) == null ? void 0 : _b.includes(strategy)) {
|
|
5729
5772
|
return true;
|
|
5730
5773
|
}
|
|
5731
5774
|
};
|
|
5732
5775
|
if (isAllowed("user" /* USER */)) {
|
|
5733
|
-
const userTenantId = ctx.user
|
|
5776
|
+
const userTenantId = (_a = ctx.user) == null ? void 0 : _a.tenantId;
|
|
5734
5777
|
if (userTenantId) {
|
|
5735
5778
|
return userTenantId;
|
|
5736
5779
|
}
|
|
@@ -6298,7 +6341,7 @@ async function put(db, doc, writeRateMs = DEFAULT_WRITE_RATE_MS) {
|
|
|
6298
6341
|
logWarn(`Ignoring redlock conflict in write-through cache`);
|
|
6299
6342
|
}
|
|
6300
6343
|
}
|
|
6301
|
-
cacheItem = makeCacheItem(output, updateDb ? null : cacheItem
|
|
6344
|
+
cacheItem = makeCacheItem(output, updateDb ? null : cacheItem == null ? void 0 : cacheItem.lastWrite);
|
|
6302
6345
|
if (output._id) {
|
|
6303
6346
|
await cache.store(makeCacheKey(db, output._id), cacheItem);
|
|
6304
6347
|
}
|
|
@@ -6390,6 +6433,7 @@ async function getSettingsConfig() {
|
|
|
6390
6433
|
async function getPlatformUrl(opts = {
|
|
6391
6434
|
tenantAware: true
|
|
6392
6435
|
}) {
|
|
6436
|
+
var _a;
|
|
6393
6437
|
let platformUrl = environment_default.PLATFORM_URL || "http://localhost:10000";
|
|
6394
6438
|
if (!environment_default.SELF_HOSTED && environment_default.MULTI_TENANCY && opts.tenantAware) {
|
|
6395
6439
|
const tenantId = getTenantId();
|
|
@@ -6397,11 +6441,11 @@ async function getPlatformUrl(opts = {
|
|
|
6397
6441
|
platformUrl = platformUrl.replace("://", `://${tenantId}.`);
|
|
6398
6442
|
}
|
|
6399
6443
|
} else if (environment_default.SELF_HOSTED) {
|
|
6400
|
-
const config = opts
|
|
6444
|
+
const config = (opts == null ? void 0 : opts.config) ? opts.config : (
|
|
6401
6445
|
// direct to db to prevent infinite loop
|
|
6402
|
-
(await getConfig("settings" /* SETTINGS */))
|
|
6446
|
+
(_a = await getConfig("settings" /* SETTINGS */)) == null ? void 0 : _a.config
|
|
6403
6447
|
);
|
|
6404
|
-
if (config
|
|
6448
|
+
if (config == null ? void 0 : config.platformUrl) {
|
|
6405
6449
|
platformUrl = config.platformUrl;
|
|
6406
6450
|
}
|
|
6407
6451
|
}
|
|
@@ -6415,13 +6459,14 @@ var analyticsEnabled = async (opts) => {
|
|
|
6415
6459
|
"analyticsEnabled" /* ANALYTICS_ENABLED */,
|
|
6416
6460
|
86400 /* ONE_DAY */,
|
|
6417
6461
|
async () => {
|
|
6418
|
-
|
|
6462
|
+
var _a;
|
|
6463
|
+
const config = (opts == null ? void 0 : opts.config) ? opts.config : (
|
|
6419
6464
|
// direct to db to prevent infinite loop
|
|
6420
|
-
(await getConfig("settings" /* SETTINGS */))
|
|
6465
|
+
(_a = await getConfig("settings" /* SETTINGS */)) == null ? void 0 : _a.config
|
|
6421
6466
|
);
|
|
6422
|
-
if (config
|
|
6467
|
+
if ((config == null ? void 0 : config.analyticsEnabled) === false) {
|
|
6423
6468
|
return false;
|
|
6424
|
-
} else if (config
|
|
6469
|
+
} else if ((config == null ? void 0 : config.analyticsEnabled) === true) {
|
|
6425
6470
|
return true;
|
|
6426
6471
|
}
|
|
6427
6472
|
}
|
|
@@ -6441,7 +6486,7 @@ async function getGoogleConfigDoc() {
|
|
|
6441
6486
|
}
|
|
6442
6487
|
async function getGoogleConfig() {
|
|
6443
6488
|
const config = await getGoogleConfigDoc();
|
|
6444
|
-
return config
|
|
6489
|
+
return config == null ? void 0 : config.config;
|
|
6445
6490
|
}
|
|
6446
6491
|
async function getGoogleDatasourceConfig() {
|
|
6447
6492
|
if (!environment_default.SELF_HOSTED) {
|
|
@@ -6469,11 +6514,13 @@ async function getOIDCConfigDoc() {
|
|
|
6469
6514
|
return getConfig("oidc" /* OIDC */);
|
|
6470
6515
|
}
|
|
6471
6516
|
async function getOIDCConfig() {
|
|
6472
|
-
|
|
6473
|
-
|
|
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];
|
|
6474
6520
|
}
|
|
6475
6521
|
async function getOIDCConfigById(configId) {
|
|
6476
|
-
|
|
6522
|
+
var _a;
|
|
6523
|
+
const config = (_a = await getConfig("oidc" /* OIDC */)) == null ? void 0 : _a.config;
|
|
6477
6524
|
return config && config.configs.filter((c) => c.uuid === configId)[0];
|
|
6478
6525
|
}
|
|
6479
6526
|
async function getSMTPConfigDoc() {
|
|
@@ -6500,7 +6547,7 @@ async function getSMTPConfig(isAutomation) {
|
|
|
6500
6547
|
}
|
|
6501
6548
|
async function getSCIMConfig() {
|
|
6502
6549
|
const config = await getConfig("scim" /* SCIM */);
|
|
6503
|
-
return config
|
|
6550
|
+
return config == null ? void 0 : config.config;
|
|
6504
6551
|
}
|
|
6505
6552
|
|
|
6506
6553
|
// src/events/index.ts
|
|
@@ -6915,7 +6962,7 @@ async function getAppIdFromCtx(ctx) {
|
|
|
6915
6962
|
appId = confirmAppId(await resolveAppUrl(ctx));
|
|
6916
6963
|
}
|
|
6917
6964
|
const referer = ctx.request.headers.referer;
|
|
6918
|
-
if (!appId && referer
|
|
6965
|
+
if (!appId && (referer == null ? void 0 : referer.includes(BUILDER_APP_PREFIX))) {
|
|
6919
6966
|
const refererId = parseAppIdFromUrl(ctx.request.headers.referer);
|
|
6920
6967
|
appId = confirmAppId(refererId);
|
|
6921
6968
|
}
|
|
@@ -7134,6 +7181,7 @@ function handleStalled(queue, removeStalledCb) {
|
|
|
7134
7181
|
});
|
|
7135
7182
|
}
|
|
7136
7183
|
function getLogParams(eventType, event, opts = {}, extra = {}) {
|
|
7184
|
+
var _a, _b, _c;
|
|
7137
7185
|
const message = `[BULL] ${eventType}=${event}`;
|
|
7138
7186
|
const err = opts.error;
|
|
7139
7187
|
const bullLog = {
|
|
@@ -7141,11 +7189,11 @@ function getLogParams(eventType, event, opts = {}, extra = {}) {
|
|
|
7141
7189
|
eventType,
|
|
7142
7190
|
event,
|
|
7143
7191
|
job: opts.job,
|
|
7144
|
-
jobId: opts.jobId || opts.job
|
|
7192
|
+
jobId: opts.jobId || ((_a = opts.job) == null ? void 0 : _a.id),
|
|
7145
7193
|
...extra
|
|
7146
7194
|
};
|
|
7147
7195
|
let automationLog;
|
|
7148
|
-
if (opts.job
|
|
7196
|
+
if ((_c = (_b = opts.job) == null ? void 0 : _b.data) == null ? void 0 : _c.automation) {
|
|
7149
7197
|
automationLog = {
|
|
7150
7198
|
_logKey: "automation",
|
|
7151
7199
|
trigger: opts.job ? opts.job.data.automation.definition.trigger.event : void 0
|
|
@@ -7160,9 +7208,11 @@ var EventTypeMap = {
|
|
|
7160
7208
|
["systemEventQueue" /* SYSTEM_EVENT_QUEUE */]: "system-event" /* SYSTEM_EVENT */
|
|
7161
7209
|
};
|
|
7162
7210
|
function logging(queue, jobQueue) {
|
|
7211
|
+
var _a;
|
|
7163
7212
|
const eventType = EventTypeMap[jobQueue];
|
|
7164
7213
|
function doInJobContext(job, task) {
|
|
7165
|
-
|
|
7214
|
+
var _a2;
|
|
7215
|
+
const appId = (_a2 = job.data.event) == null ? void 0 : _a2.appId;
|
|
7166
7216
|
if (appId) {
|
|
7167
7217
|
return doInContext(appId, task);
|
|
7168
7218
|
} else {
|
|
@@ -7176,7 +7226,7 @@ function logging(queue, jobQueue) {
|
|
|
7176
7226
|
}).on("error" /* ERROR */, (error) => {
|
|
7177
7227
|
console.error(...getLogParams(eventType, "error" /* ERROR */, { error }));
|
|
7178
7228
|
});
|
|
7179
|
-
if (process.env.NODE_DEBUG
|
|
7229
|
+
if ((_a = process.env.NODE_DEBUG) == null ? void 0 : _a.includes("bull")) {
|
|
7180
7230
|
queue.on("waiting" /* WAITING */, (jobId) => {
|
|
7181
7231
|
console.info(...getLogParams(eventType, "waiting" /* WAITING */, { jobId }));
|
|
7182
7232
|
}).on("active" /* ACTIVE */, async (job, jobPromise) => {
|
|
@@ -7246,7 +7296,7 @@ function createQueue(jobQueue, opts = {}) {
|
|
|
7246
7296
|
} else {
|
|
7247
7297
|
queue = new inMemoryQueue_default(jobQueue, queueConfig);
|
|
7248
7298
|
}
|
|
7249
|
-
addListeners(queue, jobQueue, opts
|
|
7299
|
+
addListeners(queue, jobQueue, opts == null ? void 0 : opts.removeStalledCb);
|
|
7250
7300
|
QUEUES.push(queue);
|
|
7251
7301
|
if (!cleanupInterval && !environment_default.isTest()) {
|
|
7252
7302
|
cleanupInterval = set(cleanup2, CLEANUP_PERIOD_MS);
|
|
@@ -7271,10 +7321,7 @@ async function shutdown2() {
|
|
|
7271
7321
|
|
|
7272
7322
|
// src/events/processors/AuditLogsProcessor.ts
|
|
7273
7323
|
init_environment2();
|
|
7274
|
-
var
|
|
7275
|
-
static {
|
|
7276
|
-
this.auditLogsEnabled = false;
|
|
7277
|
-
}
|
|
7324
|
+
var _AuditLogsProcessor = class _AuditLogsProcessor {
|
|
7278
7325
|
// can't use constructor as need to return promise
|
|
7279
7326
|
static init(fn) {
|
|
7280
7327
|
_AuditLogsProcessor.auditLogsEnabled = true;
|
|
@@ -7326,9 +7373,12 @@ var AuditLogsProcessor = class _AuditLogsProcessor {
|
|
|
7326
7373
|
async identifyGroup(group, timestamp) {
|
|
7327
7374
|
}
|
|
7328
7375
|
shutdown() {
|
|
7329
|
-
|
|
7376
|
+
var _a;
|
|
7377
|
+
(_a = _AuditLogsProcessor.auditLogQueue) == null ? void 0 : _a.close();
|
|
7330
7378
|
}
|
|
7331
7379
|
};
|
|
7380
|
+
_AuditLogsProcessor.auditLogsEnabled = false;
|
|
7381
|
+
var AuditLogsProcessor = _AuditLogsProcessor;
|
|
7332
7382
|
|
|
7333
7383
|
// src/events/processors/Processors.ts
|
|
7334
7384
|
var Processor = class {
|
|
@@ -7543,7 +7593,7 @@ var bulkGetGlobalUsersById = async (userIds, opts) => {
|
|
|
7543
7593
|
keys: userIds,
|
|
7544
7594
|
include_docs: true
|
|
7545
7595
|
})).rows.map((row) => row.doc);
|
|
7546
|
-
if (opts
|
|
7596
|
+
if (opts == null ? void 0 : opts.cleanup) {
|
|
7547
7597
|
users = removeUserPassword(users);
|
|
7548
7598
|
}
|
|
7549
7599
|
return users;
|
|
@@ -7564,7 +7614,7 @@ var bulkUpdateGlobalUsers = async (users) => {
|
|
|
7564
7614
|
async function getById(id, opts) {
|
|
7565
7615
|
const db = getGlobalDB();
|
|
7566
7616
|
let user = await db.get(id);
|
|
7567
|
-
if (opts
|
|
7617
|
+
if (opts == null ? void 0 : opts.cleanup) {
|
|
7568
7618
|
user = removeUserPassword(user);
|
|
7569
7619
|
}
|
|
7570
7620
|
return user;
|
|
@@ -7581,7 +7631,7 @@ var getGlobalUserByEmail = async (email, opts) => {
|
|
|
7581
7631
|
throw new Error(`Multiple users found with email address: ${email}`);
|
|
7582
7632
|
}
|
|
7583
7633
|
let user = response;
|
|
7584
|
-
if (opts
|
|
7634
|
+
if (opts == null ? void 0 : opts.cleanup) {
|
|
7585
7635
|
user = removeUserPassword(user);
|
|
7586
7636
|
}
|
|
7587
7637
|
return user;
|
|
@@ -7599,7 +7649,7 @@ var searchGlobalUsersByApp = async (appId, opts, getOpts) => {
|
|
|
7599
7649
|
response = [];
|
|
7600
7650
|
}
|
|
7601
7651
|
let users = Array.isArray(response) ? response : [response];
|
|
7602
|
-
if (getOpts
|
|
7652
|
+
if (getOpts == null ? void 0 : getOpts.cleanup) {
|
|
7603
7653
|
users = removeUserPassword(users);
|
|
7604
7654
|
}
|
|
7605
7655
|
return users;
|
|
@@ -7629,10 +7679,10 @@ var searchGlobalUsersByAppAccess = async (appId, opts) => {
|
|
|
7629
7679
|
$regex: "^us_"
|
|
7630
7680
|
}
|
|
7631
7681
|
},
|
|
7632
|
-
limit: opts
|
|
7682
|
+
limit: (opts == null ? void 0 : opts.limit) || 50
|
|
7633
7683
|
};
|
|
7634
7684
|
const resp = await directCouchFind(getGlobalDBName(), searchOptions);
|
|
7635
|
-
return resp
|
|
7685
|
+
return resp == null ? void 0 : resp.rows;
|
|
7636
7686
|
};
|
|
7637
7687
|
var getGlobalUserByAppPage = (appId, user) => {
|
|
7638
7688
|
if (!user) {
|
|
@@ -7655,7 +7705,7 @@ var searchGlobalUsersByEmail = async (email, opts, getOpts) => {
|
|
|
7655
7705
|
response = [];
|
|
7656
7706
|
}
|
|
7657
7707
|
let users = Array.isArray(response) ? response : [response];
|
|
7658
|
-
if (getOpts
|
|
7708
|
+
if (getOpts == null ? void 0 : getOpts.cleanup) {
|
|
7659
7709
|
users = removeUserPassword(users);
|
|
7660
7710
|
}
|
|
7661
7711
|
return users;
|
|
@@ -8006,12 +8056,13 @@ __export(users_exports2, {
|
|
|
8006
8056
|
isGlobalBuilder: () => isGlobalBuilder
|
|
8007
8057
|
});
|
|
8008
8058
|
function isBuilder(user, appId) {
|
|
8059
|
+
var _a, _b, _c;
|
|
8009
8060
|
if (!user) {
|
|
8010
8061
|
return false;
|
|
8011
8062
|
}
|
|
8012
|
-
if (user.builder
|
|
8063
|
+
if ((_a = user.builder) == null ? void 0 : _a.global) {
|
|
8013
8064
|
return true;
|
|
8014
|
-
} 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)))) {
|
|
8015
8066
|
return true;
|
|
8016
8067
|
}
|
|
8017
8068
|
return false;
|
|
@@ -8029,24 +8080,27 @@ function isAdminOrBuilder(user, appId) {
|
|
|
8029
8080
|
return isBuilder(user, appId) || isAdmin(user);
|
|
8030
8081
|
}
|
|
8031
8082
|
function hasAppBuilderPermissions(user) {
|
|
8083
|
+
var _a, _b, _c;
|
|
8032
8084
|
if (!user) {
|
|
8033
8085
|
return false;
|
|
8034
8086
|
}
|
|
8035
|
-
const appLength = user.builder
|
|
8036
|
-
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);
|
|
8037
8089
|
return !isGlobalBuilder3 && appLength != null && appLength > 0;
|
|
8038
8090
|
}
|
|
8039
8091
|
function hasBuilderPermissions(user) {
|
|
8092
|
+
var _a;
|
|
8040
8093
|
if (!user) {
|
|
8041
8094
|
return false;
|
|
8042
8095
|
}
|
|
8043
|
-
return user.builder
|
|
8096
|
+
return ((_a = user.builder) == null ? void 0 : _a.global) || hasAppBuilderPermissions(user);
|
|
8044
8097
|
}
|
|
8045
8098
|
function hasAdminPermissions(user) {
|
|
8099
|
+
var _a;
|
|
8046
8100
|
if (!user) {
|
|
8047
8101
|
return false;
|
|
8048
8102
|
}
|
|
8049
|
-
return !!user.admin
|
|
8103
|
+
return !!((_a = user.admin) == null ? void 0 : _a.global);
|
|
8050
8104
|
}
|
|
8051
8105
|
|
|
8052
8106
|
// src/users/utils.ts
|
|
@@ -8119,7 +8173,7 @@ var unassignAppRoleEvents = async (user, roles, existingRoles) => {
|
|
|
8119
8173
|
};
|
|
8120
8174
|
var handleAppRoleEvents = async (user, existingUser) => {
|
|
8121
8175
|
const roles = user.roles;
|
|
8122
|
-
const existingRoles = existingUser
|
|
8176
|
+
const existingRoles = existingUser == null ? void 0 : existingUser.roles;
|
|
8123
8177
|
await assignAppRoleEvents(user, roles, existingRoles);
|
|
8124
8178
|
await unassignAppRoleEvents(user, roles, existingRoles);
|
|
8125
8179
|
};
|
|
@@ -8171,7 +8225,7 @@ var isRemovingAdmin = (user, existingUser) => {
|
|
|
8171
8225
|
return isRemovingPermission(user, existingUser, hasAdminPermissions2);
|
|
8172
8226
|
};
|
|
8173
8227
|
var isOnboardingComplete = (user, existingUser) => {
|
|
8174
|
-
return !existingUser
|
|
8228
|
+
return !(existingUser == null ? void 0 : existingUser.onboardedAt) && typeof user.onboardedAt === "string";
|
|
8175
8229
|
};
|
|
8176
8230
|
var isAddingPermission = (user, existingUser, hasPermission) => {
|
|
8177
8231
|
if (!hasPermission(user)) {
|
|
@@ -8228,7 +8282,7 @@ async function getSessionsForUser(userId) {
|
|
|
8228
8282
|
}
|
|
8229
8283
|
async function invalidateSessions(userId, opts = {}) {
|
|
8230
8284
|
try {
|
|
8231
|
-
const reason = opts
|
|
8285
|
+
const reason = (opts == null ? void 0 : opts.reason) || "unknown";
|
|
8232
8286
|
let sessionIds = opts.sessionIds || [];
|
|
8233
8287
|
let sessionKeys;
|
|
8234
8288
|
if (sessionIds.length === 0) {
|
|
@@ -8405,6 +8459,7 @@ var UserDB = class _UserDB {
|
|
|
8405
8459
|
return user;
|
|
8406
8460
|
}
|
|
8407
8461
|
static async save(user, opts = {}) {
|
|
8462
|
+
var _a, _b;
|
|
8408
8463
|
if (opts.hashPassword == null) {
|
|
8409
8464
|
opts.hashPassword = true;
|
|
8410
8465
|
}
|
|
@@ -8417,7 +8472,7 @@ var UserDB = class _UserDB {
|
|
|
8417
8472
|
if (!email && !_id) {
|
|
8418
8473
|
throw new Error("_id or email is required");
|
|
8419
8474
|
}
|
|
8420
|
-
if (user.builder
|
|
8475
|
+
if (((_b = (_a = user.builder) == null ? void 0 : _a.apps) == null ? void 0 : _b.length) && !await _UserDB.features.isAppBuildersEnabled()) {
|
|
8421
8476
|
throw new Error("Unable to update app builders, please check license");
|
|
8422
8477
|
}
|
|
8423
8478
|
let dbUser;
|
|
@@ -8445,10 +8500,10 @@ var UserDB = class _UserDB {
|
|
|
8445
8500
|
return _UserDB.quotas.addUsers(change, async () => {
|
|
8446
8501
|
await validateUniqueUser(email, tenantId);
|
|
8447
8502
|
let builtUser = await _UserDB.buildUser(user, opts, tenantId, dbUser);
|
|
8448
|
-
if (opts.currentUserId && opts.currentUserId === dbUser
|
|
8503
|
+
if (opts.currentUserId && opts.currentUserId === (dbUser == null ? void 0 : dbUser._id)) {
|
|
8449
8504
|
builtUser = cleanseUserObject(builtUser, dbUser);
|
|
8450
8505
|
}
|
|
8451
|
-
if (!dbUser && roles
|
|
8506
|
+
if (!dbUser && (roles == null ? void 0 : roles.length)) {
|
|
8452
8507
|
builtUser.roles = { ...roles };
|
|
8453
8508
|
}
|
|
8454
8509
|
let groupPromises = [];
|
|
@@ -8727,8 +8782,8 @@ var identifyUser = async (user, account, timestamp) => {
|
|
|
8727
8782
|
if (isSSOUser(user)) {
|
|
8728
8783
|
providerType = user.providerType;
|
|
8729
8784
|
}
|
|
8730
|
-
const accountHolder = account
|
|
8731
|
-
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;
|
|
8732
8787
|
const installationId = await getInstallationId();
|
|
8733
8788
|
const hosting = account ? account.hosting : getHostingFromEnv();
|
|
8734
8789
|
const environment2 = getDeploymentEnvironment();
|
|
@@ -8887,7 +8942,7 @@ var clearEvents = async () => {
|
|
|
8887
8942
|
};
|
|
8888
8943
|
var isBackfillingEvent = async (event) => {
|
|
8889
8944
|
const backfill = await getBackfillMetadata();
|
|
8890
|
-
const events2 = backfill
|
|
8945
|
+
const events2 = backfill == null ? void 0 : backfill.eventWhitelist;
|
|
8891
8946
|
if (events2 && events2.includes(event)) {
|
|
8892
8947
|
return true;
|
|
8893
8948
|
} else {
|
|
@@ -9231,11 +9286,12 @@ var auth_default = {
|
|
|
9231
9286
|
// src/events/publishers/automation.ts
|
|
9232
9287
|
init_src();
|
|
9233
9288
|
async function created3(automation, timestamp) {
|
|
9289
|
+
var _a, _b, _c, _d;
|
|
9234
9290
|
const properties = {
|
|
9235
9291
|
appId: automation.appId,
|
|
9236
9292
|
automationId: automation._id,
|
|
9237
|
-
triggerId: automation.definition
|
|
9238
|
-
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,
|
|
9239
9295
|
audited: {
|
|
9240
9296
|
name: automation.name
|
|
9241
9297
|
}
|
|
@@ -9243,20 +9299,22 @@ async function created3(automation, timestamp) {
|
|
|
9243
9299
|
await publishEvent("automation:created" /* AUTOMATION_CREATED */, properties, timestamp);
|
|
9244
9300
|
}
|
|
9245
9301
|
async function triggerUpdated(automation) {
|
|
9302
|
+
var _a, _b, _c, _d;
|
|
9246
9303
|
const properties = {
|
|
9247
9304
|
appId: automation.appId,
|
|
9248
9305
|
automationId: automation._id,
|
|
9249
|
-
triggerId: automation.definition
|
|
9250
|
-
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
|
|
9251
9308
|
};
|
|
9252
9309
|
await publishEvent("automation:trigger:updated" /* AUTOMATION_TRIGGER_UPDATED */, properties);
|
|
9253
9310
|
}
|
|
9254
9311
|
async function deleted3(automation) {
|
|
9312
|
+
var _a, _b, _c, _d;
|
|
9255
9313
|
const properties = {
|
|
9256
9314
|
appId: automation.appId,
|
|
9257
9315
|
automationId: automation._id,
|
|
9258
|
-
triggerId: automation.definition
|
|
9259
|
-
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,
|
|
9260
9318
|
audited: {
|
|
9261
9319
|
name: automation.name
|
|
9262
9320
|
}
|
|
@@ -9264,11 +9322,12 @@ async function deleted3(automation) {
|
|
|
9264
9322
|
await publishEvent("automation:deleted" /* AUTOMATION_DELETED */, properties);
|
|
9265
9323
|
}
|
|
9266
9324
|
async function tested(automation) {
|
|
9325
|
+
var _a, _b, _c, _d;
|
|
9267
9326
|
const properties = {
|
|
9268
9327
|
appId: automation.appId,
|
|
9269
9328
|
automationId: automation._id,
|
|
9270
|
-
triggerId: automation.definition
|
|
9271
|
-
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
|
|
9272
9331
|
};
|
|
9273
9332
|
await publishEvent("automation:tested" /* AUTOMATION_TESTED */, properties);
|
|
9274
9333
|
}
|
|
@@ -9279,11 +9338,12 @@ var run = async (count, timestamp) => {
|
|
|
9279
9338
|
await publishEvent("automations:run" /* AUTOMATIONS_RUN */, properties, timestamp);
|
|
9280
9339
|
};
|
|
9281
9340
|
async function stepCreated(automation, step, timestamp) {
|
|
9341
|
+
var _a, _b, _c, _d;
|
|
9282
9342
|
const properties = {
|
|
9283
9343
|
appId: automation.appId,
|
|
9284
9344
|
automationId: automation._id,
|
|
9285
|
-
triggerId: automation.definition
|
|
9286
|
-
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,
|
|
9287
9347
|
stepId: step.id,
|
|
9288
9348
|
stepType: step.stepId,
|
|
9289
9349
|
audited: {
|
|
@@ -9293,11 +9353,12 @@ async function stepCreated(automation, step, timestamp) {
|
|
|
9293
9353
|
await publishEvent("automation:step:created" /* AUTOMATION_STEP_CREATED */, properties, timestamp);
|
|
9294
9354
|
}
|
|
9295
9355
|
async function stepDeleted(automation, step) {
|
|
9356
|
+
var _a, _b, _c, _d;
|
|
9296
9357
|
const properties = {
|
|
9297
9358
|
appId: automation.appId,
|
|
9298
9359
|
automationId: automation._id,
|
|
9299
|
-
triggerId: automation.definition
|
|
9300
|
-
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,
|
|
9301
9362
|
stepId: step.id,
|
|
9302
9363
|
stepType: step.stepId,
|
|
9303
9364
|
audited: {
|
|
@@ -9584,23 +9645,25 @@ var role_default = {
|
|
|
9584
9645
|
// src/events/publishers/screen.ts
|
|
9585
9646
|
init_src();
|
|
9586
9647
|
async function created8(screen, timestamp) {
|
|
9648
|
+
var _a;
|
|
9587
9649
|
const properties = {
|
|
9588
9650
|
layoutId: screen.layoutId,
|
|
9589
9651
|
screenId: screen._id,
|
|
9590
9652
|
roleId: screen.routing.roleId,
|
|
9591
9653
|
audited: {
|
|
9592
|
-
name: screen.routing
|
|
9654
|
+
name: (_a = screen.routing) == null ? void 0 : _a.route
|
|
9593
9655
|
}
|
|
9594
9656
|
};
|
|
9595
9657
|
await publishEvent("screen:created" /* SCREEN_CREATED */, properties, timestamp);
|
|
9596
9658
|
}
|
|
9597
9659
|
async function deleted8(screen) {
|
|
9660
|
+
var _a;
|
|
9598
9661
|
const properties = {
|
|
9599
9662
|
layoutId: screen.layoutId,
|
|
9600
9663
|
screenId: screen._id,
|
|
9601
9664
|
roleId: screen.routing.roleId,
|
|
9602
9665
|
audited: {
|
|
9603
|
-
name: screen.routing
|
|
9666
|
+
name: (_a = screen.routing) == null ? void 0 : _a.route
|
|
9604
9667
|
}
|
|
9605
9668
|
};
|
|
9606
9669
|
await publishEvent("screen:deleted" /* SCREEN_DELETED */, properties);
|
|
@@ -10536,7 +10599,8 @@ var BUILTIN_PERMISSIONS = {
|
|
|
10536
10599
|
name: "Read only",
|
|
10537
10600
|
permissions: [
|
|
10538
10601
|
new Permission("query" /* QUERY */, "read" /* READ */),
|
|
10539
|
-
new Permission("table" /* TABLE */, "read" /* READ */)
|
|
10602
|
+
new Permission("table" /* TABLE */, "read" /* READ */),
|
|
10603
|
+
new Permission("view" /* VIEW */, "read" /* READ */)
|
|
10540
10604
|
]
|
|
10541
10605
|
},
|
|
10542
10606
|
WRITE: {
|
|
@@ -10545,6 +10609,7 @@ var BUILTIN_PERMISSIONS = {
|
|
|
10545
10609
|
permissions: [
|
|
10546
10610
|
new Permission("query" /* QUERY */, "write" /* WRITE */),
|
|
10547
10611
|
new Permission("table" /* TABLE */, "write" /* WRITE */),
|
|
10612
|
+
new Permission("view" /* VIEW */, "read" /* READ */),
|
|
10548
10613
|
new Permission("automation" /* AUTOMATION */, "execute" /* EXECUTE */)
|
|
10549
10614
|
]
|
|
10550
10615
|
},
|
|
@@ -10555,6 +10620,7 @@ var BUILTIN_PERMISSIONS = {
|
|
|
10555
10620
|
new Permission("table" /* TABLE */, "write" /* WRITE */),
|
|
10556
10621
|
new Permission("user" /* USER */, "read" /* READ */),
|
|
10557
10622
|
new Permission("automation" /* AUTOMATION */, "execute" /* EXECUTE */),
|
|
10623
|
+
new Permission("view" /* VIEW */, "read" /* READ */),
|
|
10558
10624
|
new Permission("webhook" /* WEBHOOK */, "read" /* READ */)
|
|
10559
10625
|
]
|
|
10560
10626
|
},
|
|
@@ -10565,6 +10631,7 @@ var BUILTIN_PERMISSIONS = {
|
|
|
10565
10631
|
new Permission("table" /* TABLE */, "admin" /* ADMIN */),
|
|
10566
10632
|
new Permission("user" /* USER */, "admin" /* ADMIN */),
|
|
10567
10633
|
new Permission("automation" /* AUTOMATION */, "admin" /* ADMIN */),
|
|
10634
|
+
new Permission("view" /* VIEW */, "admin" /* ADMIN */),
|
|
10568
10635
|
new Permission("webhook" /* WEBHOOK */, "read" /* READ */),
|
|
10569
10636
|
new Permission("query" /* QUERY */, "admin" /* ADMIN */)
|
|
10570
10637
|
]
|
|
@@ -10667,7 +10734,7 @@ var BUILTIN_ROLE_NAME_ARRAY = Object.values(BUILTIN_ROLES).map(
|
|
|
10667
10734
|
(role) => role.name
|
|
10668
10735
|
);
|
|
10669
10736
|
function isBuiltin(role) {
|
|
10670
|
-
return BUILTIN_ROLE_ID_ARRAY.some((builtin) => role
|
|
10737
|
+
return BUILTIN_ROLE_ID_ARRAY.some((builtin) => role == null ? void 0 : role.includes(builtin));
|
|
10671
10738
|
}
|
|
10672
10739
|
function builtinRoleToNumber(id) {
|
|
10673
10740
|
if (!id) {
|
|
@@ -10694,7 +10761,7 @@ async function roleToNumber(id) {
|
|
|
10694
10761
|
}
|
|
10695
10762
|
const hierarchy = await getUserRoleHierarchy(id);
|
|
10696
10763
|
for (let role of hierarchy) {
|
|
10697
|
-
if (isBuiltin(role
|
|
10764
|
+
if (isBuiltin(role == null ? void 0 : role.inherits)) {
|
|
10698
10765
|
return builtinRoleToNumber(role.inherits) + 1;
|
|
10699
10766
|
}
|
|
10700
10767
|
}
|
|
@@ -10727,7 +10794,7 @@ async function getRole(roleId, opts) {
|
|
|
10727
10794
|
role = Object.assign(role, dbRole);
|
|
10728
10795
|
role._id = getExternalRoleID(role._id, role.version);
|
|
10729
10796
|
} catch (err) {
|
|
10730
|
-
if (!isBuiltin(roleId) && opts
|
|
10797
|
+
if (!isBuiltin(roleId) && (opts == null ? void 0 : opts.defaultPublic)) {
|
|
10731
10798
|
return (0, import_cloneDeep2.default)(BUILTIN_ROLES.PUBLIC);
|
|
10732
10799
|
}
|
|
10733
10800
|
if (Object.keys(role).length === 0) {
|
|
@@ -10850,7 +10917,7 @@ var AccessController = class {
|
|
|
10850
10917
|
});
|
|
10851
10918
|
this.userHierarchies[userRoleId] = roleIds;
|
|
10852
10919
|
}
|
|
10853
|
-
return roleIds
|
|
10920
|
+
return (roleIds == null ? void 0 : roleIds.indexOf(tryingRoleId)) !== -1;
|
|
10854
10921
|
}
|
|
10855
10922
|
async checkScreensAccess(screens, userRoleId) {
|
|
10856
10923
|
let accessibleScreens = [];
|
|
@@ -10871,7 +10938,7 @@ var AccessController = class {
|
|
|
10871
10938
|
}
|
|
10872
10939
|
};
|
|
10873
10940
|
function getDBRoleID(roleName) {
|
|
10874
|
-
if (roleName
|
|
10941
|
+
if (roleName == null ? void 0 : roleName.startsWith("role" /* ROLE */)) {
|
|
10875
10942
|
return roleName;
|
|
10876
10943
|
}
|
|
10877
10944
|
return prefixRoleID(roleName);
|
|
@@ -11130,7 +11197,8 @@ async function authenticate2(details, requireLocalAccount = true, done, saveUser
|
|
|
11130
11197
|
return done(null, ssoUser);
|
|
11131
11198
|
}
|
|
11132
11199
|
async function getProfilePictureUrl(user, details) {
|
|
11133
|
-
|
|
11200
|
+
var _a;
|
|
11201
|
+
const pictureUrl = (_a = details.profile) == null ? void 0 : _a._json.picture;
|
|
11134
11202
|
if (pictureUrl) {
|
|
11135
11203
|
const response = await (0, import_node_fetch5.default)(pictureUrl);
|
|
11136
11204
|
if (response.status === 200) {
|
|
@@ -11661,7 +11729,7 @@ function authenticated_default(noAuthPatterns = [], opts = {
|
|
|
11661
11729
|
user = await getUser(userId, session.tenantId);
|
|
11662
11730
|
}
|
|
11663
11731
|
user.csrfToken = session.csrfToken;
|
|
11664
|
-
if (session
|
|
11732
|
+
if ((session == null ? void 0 : session.lastAccessedAt) < timeMinusOneMinute()) {
|
|
11665
11733
|
await updateSessionTTL(session);
|
|
11666
11734
|
}
|
|
11667
11735
|
authenticated = true;
|
|
@@ -11703,9 +11771,9 @@ function authenticated_default(noAuthPatterns = [], opts = {
|
|
|
11703
11771
|
} catch (err) {
|
|
11704
11772
|
console.error(`Auth Error: ${err.message}`);
|
|
11705
11773
|
console.error(err);
|
|
11706
|
-
if (err
|
|
11774
|
+
if ((err == null ? void 0 : err.name) === "JsonWebTokenError") {
|
|
11707
11775
|
clearCookie(ctx, "budibase:auth" /* Auth */);
|
|
11708
|
-
} else if (err
|
|
11776
|
+
} else if ((err == null ? void 0 : err.code) === "invalid_api_key" /* INVALID_API_KEY */) {
|
|
11709
11777
|
ctx.throw(403, err.message);
|
|
11710
11778
|
}
|
|
11711
11779
|
if (opts && opts.publicAllowed || publicEndpoint) {
|
|
@@ -11772,6 +11840,7 @@ var INCLUDED_CONTENT_TYPES = [
|
|
|
11772
11840
|
function csrf_default(opts = { noCsrfPatterns: [] }) {
|
|
11773
11841
|
const noCsrfOptions = buildMatcherRegex(opts.noCsrfPatterns);
|
|
11774
11842
|
return async (ctx, next) => {
|
|
11843
|
+
var _a;
|
|
11775
11844
|
const found = matches(ctx, noCsrfOptions);
|
|
11776
11845
|
if (found) {
|
|
11777
11846
|
return next();
|
|
@@ -11786,7 +11855,7 @@ function csrf_default(opts = { noCsrfPatterns: [] }) {
|
|
|
11786
11855
|
if (ctx.internal) {
|
|
11787
11856
|
return next();
|
|
11788
11857
|
}
|
|
11789
|
-
const userToken = ctx.user
|
|
11858
|
+
const userToken = (_a = ctx.user) == null ? void 0 : _a.csrfToken;
|
|
11790
11859
|
if (!userToken) {
|
|
11791
11860
|
return next();
|
|
11792
11861
|
}
|
|
@@ -11846,7 +11915,10 @@ function pinoSettings() {
|
|
|
11846
11915
|
logger,
|
|
11847
11916
|
genReqId: correlator2.getId,
|
|
11848
11917
|
autoLogging: {
|
|
11849
|
-
ignore: (req) =>
|
|
11918
|
+
ignore: (req) => {
|
|
11919
|
+
var _a;
|
|
11920
|
+
return !!((_a = req.url) == null ? void 0 : _a.includes("/health"));
|
|
11921
|
+
}
|
|
11850
11922
|
},
|
|
11851
11923
|
serializers: {
|
|
11852
11924
|
req: (req) => {
|
|
@@ -11917,7 +11989,8 @@ var errorHandling_default = errorHandling;
|
|
|
11917
11989
|
|
|
11918
11990
|
// src/middleware/querystringToBody.ts
|
|
11919
11991
|
function querystringToBody_default(ctx, next) {
|
|
11920
|
-
|
|
11992
|
+
var _a;
|
|
11993
|
+
const queryString = (_a = ctx.request.query) == null ? void 0 : _a.query;
|
|
11921
11994
|
if (ctx.request.method.toLowerCase() !== "get") {
|
|
11922
11995
|
ctx.throw(
|
|
11923
11996
|
500,
|
|
@@ -11947,11 +12020,12 @@ __export(joi_validator_exports, {
|
|
|
11947
12020
|
var import_joi = __toESM(require("joi"));
|
|
11948
12021
|
function validate(schema, property) {
|
|
11949
12022
|
return (ctx, next) => {
|
|
12023
|
+
var _a;
|
|
11950
12024
|
if (!schema) {
|
|
11951
12025
|
return next();
|
|
11952
12026
|
}
|
|
11953
12027
|
let params2 = null;
|
|
11954
|
-
let reqProp = ctx.request
|
|
12028
|
+
let reqProp = (_a = ctx.request) == null ? void 0 : _a[property];
|
|
11955
12029
|
if (ctx[property] != null) {
|
|
11956
12030
|
params2 = ctx[property];
|
|
11957
12031
|
} else if (reqProp != null) {
|
|
@@ -12090,6 +12164,7 @@ async function updateUserOAuth(userId, oAuthConfig) {
|
|
|
12090
12164
|
}
|
|
12091
12165
|
}
|
|
12092
12166
|
async function platformLogout(opts) {
|
|
12167
|
+
var _a;
|
|
12093
12168
|
const ctx = opts.ctx;
|
|
12094
12169
|
const userId = opts.userId;
|
|
12095
12170
|
const keepActiveSession = opts.keepActiveSession;
|
|
@@ -12106,7 +12181,7 @@ async function platformLogout(opts) {
|
|
|
12106
12181
|
}
|
|
12107
12182
|
const sessionIds = sessions.map(({ sessionId }) => sessionId);
|
|
12108
12183
|
await invalidateSessions(userId, { sessionIds, reason: "logout" });
|
|
12109
|
-
await auth_default.logout(ctx.user
|
|
12184
|
+
await auth_default.logout((_a = ctx.user) == null ? void 0 : _a.email);
|
|
12110
12185
|
await invalidateUser(userId);
|
|
12111
12186
|
}
|
|
12112
12187
|
|
|
@@ -12222,7 +12297,7 @@ function validateAutomation(schema) {
|
|
|
12222
12297
|
runJoi(validator, schema);
|
|
12223
12298
|
}
|
|
12224
12299
|
function validate2(schema) {
|
|
12225
|
-
switch (schema
|
|
12300
|
+
switch (schema == null ? void 0 : schema.type) {
|
|
12226
12301
|
case "component" /* COMPONENT */:
|
|
12227
12302
|
validateComponent(schema);
|
|
12228
12303
|
break;
|
|
@@ -12286,7 +12361,7 @@ async function lookup(address) {
|
|
|
12286
12361
|
}
|
|
12287
12362
|
async function refreshBlacklist() {
|
|
12288
12363
|
const blacklist = environment_default.BLACKLIST_IPS;
|
|
12289
|
-
const list = blacklist
|
|
12364
|
+
const list = (blacklist == null ? void 0 : blacklist.split(",")) || [];
|
|
12290
12365
|
let final = [];
|
|
12291
12366
|
for (let addr of list) {
|
|
12292
12367
|
const trimmed = addr.trim();
|
|
@@ -12303,7 +12378,7 @@ async function isBlacklisted(address) {
|
|
|
12303
12378
|
if (!blackListArray) {
|
|
12304
12379
|
await refreshBlacklist();
|
|
12305
12380
|
}
|
|
12306
|
-
if (blackListArray
|
|
12381
|
+
if ((blackListArray == null ? void 0 : blackListArray.length) === 0) {
|
|
12307
12382
|
return false;
|
|
12308
12383
|
}
|
|
12309
12384
|
let ips;
|
|
@@ -12312,7 +12387,7 @@ async function isBlacklisted(address) {
|
|
|
12312
12387
|
} else {
|
|
12313
12388
|
ips = [address];
|
|
12314
12389
|
}
|
|
12315
|
-
return !!blackListArray
|
|
12390
|
+
return !!(blackListArray == null ? void 0 : blackListArray.find((addr) => ips.includes(addr)));
|
|
12316
12391
|
}
|
|
12317
12392
|
|
|
12318
12393
|
// src/docUpdates/index.ts
|