@budibase/backend-core 2.9.19-alpha.0 → 2.9.19
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 +324 -266
- 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 +1 -1
- 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/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/tests/core/utilities/testContainerUtils.ts +1 -1
- package/__mocks__/aws-sdk.ts +0 -18
- package/jest-testcontainers-config.js +0 -8
- package/jest.config.ts +0 -35
- package/scripts/build.js +0 -6
- package/scripts/test.sh +0 -13
- package/tsconfig.build.json +0 -29
- package/tsconfig.json +0 -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({
|
|
@@ -690,13 +712,6 @@ var init_permissions = __esm({
|
|
|
690
712
|
}
|
|
691
713
|
});
|
|
692
714
|
|
|
693
|
-
// ../types/src/sdk/row.ts
|
|
694
|
-
var init_row = __esm({
|
|
695
|
-
"../types/src/sdk/row.ts"() {
|
|
696
|
-
"use strict";
|
|
697
|
-
}
|
|
698
|
-
});
|
|
699
|
-
|
|
700
715
|
// ../types/src/sdk/index.ts
|
|
701
716
|
var init_sdk = __esm({
|
|
702
717
|
"../types/src/sdk/index.ts"() {
|
|
@@ -722,7 +737,6 @@ var init_sdk = __esm({
|
|
|
722
737
|
init_cli();
|
|
723
738
|
init_websocket();
|
|
724
739
|
init_permissions();
|
|
725
|
-
init_row();
|
|
726
740
|
}
|
|
727
741
|
});
|
|
728
742
|
|
|
@@ -952,7 +966,7 @@ var init_document = __esm({
|
|
|
952
966
|
});
|
|
953
967
|
|
|
954
968
|
// ../types/src/documents/app/row.ts
|
|
955
|
-
var
|
|
969
|
+
var init_row = __esm({
|
|
956
970
|
"../types/src/documents/app/row.ts"() {
|
|
957
971
|
"use strict";
|
|
958
972
|
}
|
|
@@ -1007,7 +1021,7 @@ var init_app3 = __esm({
|
|
|
1007
1021
|
init_screen2();
|
|
1008
1022
|
init_view2();
|
|
1009
1023
|
init_document();
|
|
1010
|
-
|
|
1024
|
+
init_row();
|
|
1011
1025
|
init_user4();
|
|
1012
1026
|
init_backup2();
|
|
1013
1027
|
init_webhook();
|
|
@@ -1287,7 +1301,7 @@ var init_datasource3 = __esm({
|
|
|
1287
1301
|
});
|
|
1288
1302
|
|
|
1289
1303
|
// ../types/src/api/web/app/row.ts
|
|
1290
|
-
var
|
|
1304
|
+
var init_row2 = __esm({
|
|
1291
1305
|
"../types/src/api/web/app/row.ts"() {
|
|
1292
1306
|
"use strict";
|
|
1293
1307
|
}
|
|
@@ -1320,7 +1334,7 @@ var init_app4 = __esm({
|
|
|
1320
1334
|
"use strict";
|
|
1321
1335
|
init_backup3();
|
|
1322
1336
|
init_datasource3();
|
|
1323
|
-
|
|
1337
|
+
init_row2();
|
|
1324
1338
|
init_view3();
|
|
1325
1339
|
init_rows2();
|
|
1326
1340
|
init_table4();
|
|
@@ -1413,13 +1427,6 @@ var init_pagination = __esm({
|
|
|
1413
1427
|
}
|
|
1414
1428
|
});
|
|
1415
1429
|
|
|
1416
|
-
// ../types/src/api/web/searchFilter.ts
|
|
1417
|
-
var init_searchFilter = __esm({
|
|
1418
|
-
"../types/src/api/web/searchFilter.ts"() {
|
|
1419
|
-
"use strict";
|
|
1420
|
-
}
|
|
1421
|
-
});
|
|
1422
|
-
|
|
1423
1430
|
// ../types/src/api/web/index.ts
|
|
1424
1431
|
var init_web = __esm({
|
|
1425
1432
|
"../types/src/api/web/index.ts"() {
|
|
@@ -1434,7 +1441,6 @@ var init_web = __esm({
|
|
|
1434
1441
|
init_app4();
|
|
1435
1442
|
init_global2();
|
|
1436
1443
|
init_pagination();
|
|
1437
|
-
init_searchFilter();
|
|
1438
1444
|
}
|
|
1439
1445
|
});
|
|
1440
1446
|
|
|
@@ -1866,15 +1872,12 @@ var init_environment2 = __esm({
|
|
|
1866
1872
|
});
|
|
1867
1873
|
|
|
1868
1874
|
// src/context/Context.ts
|
|
1869
|
-
var import_async_hooks, Context;
|
|
1875
|
+
var import_async_hooks, _Context, Context;
|
|
1870
1876
|
var init_Context = __esm({
|
|
1871
1877
|
"src/context/Context.ts"() {
|
|
1872
1878
|
"use strict";
|
|
1873
1879
|
import_async_hooks = require("async_hooks");
|
|
1874
|
-
|
|
1875
|
-
static {
|
|
1876
|
-
this.storage = new import_async_hooks.AsyncLocalStorage();
|
|
1877
|
-
}
|
|
1880
|
+
_Context = class _Context {
|
|
1878
1881
|
static run(context, func) {
|
|
1879
1882
|
return _Context.storage.run(context, () => func());
|
|
1880
1883
|
}
|
|
@@ -1882,6 +1885,8 @@ var init_Context = __esm({
|
|
|
1882
1885
|
return _Context.storage.getStore();
|
|
1883
1886
|
}
|
|
1884
1887
|
};
|
|
1888
|
+
_Context.storage = new import_async_hooks.AsyncLocalStorage();
|
|
1889
|
+
Context = _Context;
|
|
1885
1890
|
}
|
|
1886
1891
|
});
|
|
1887
1892
|
|
|
@@ -1923,7 +1928,7 @@ function getProdAppID(appId) {
|
|
|
1923
1928
|
return `${APP_PREFIX}${rest}`;
|
|
1924
1929
|
}
|
|
1925
1930
|
function extractAppUUID(id) {
|
|
1926
|
-
const split = id
|
|
1931
|
+
const split = (id == null ? void 0 : id.split("_")) || [];
|
|
1927
1932
|
return split.length ? split[split.length - 1] : null;
|
|
1928
1933
|
}
|
|
1929
1934
|
var NO_APP_ERROR, getDevAppID;
|
|
@@ -1943,17 +1948,18 @@ var init_connections = __esm({
|
|
|
1943
1948
|
"use strict";
|
|
1944
1949
|
init_environment2();
|
|
1945
1950
|
getCouchInfo = (connection) => {
|
|
1951
|
+
var _a, _b;
|
|
1946
1952
|
const urlInfo = getUrlInfo(connection);
|
|
1947
1953
|
let username;
|
|
1948
1954
|
let password;
|
|
1949
|
-
if (urlInfo.auth
|
|
1955
|
+
if ((_a = urlInfo.auth) == null ? void 0 : _a.username) {
|
|
1950
1956
|
username = urlInfo.auth.username;
|
|
1951
1957
|
} else if (environment_default.COUCH_DB_USERNAME) {
|
|
1952
1958
|
username = environment_default.COUCH_DB_USERNAME;
|
|
1953
1959
|
} else if (!environment_default.isTest()) {
|
|
1954
1960
|
throw new Error("CouchDB username not set");
|
|
1955
1961
|
}
|
|
1956
|
-
if (urlInfo.auth
|
|
1962
|
+
if ((_b = urlInfo.auth) == null ? void 0 : _b.password) {
|
|
1957
1963
|
password = urlInfo.auth.password;
|
|
1958
1964
|
} else if (environment_default.COUCH_DB_PASSWORD) {
|
|
1959
1965
|
password = environment_default.COUCH_DB_PASSWORD;
|
|
@@ -2212,7 +2218,8 @@ var init_DatabaseImpl = __esm({
|
|
|
2212
2218
|
return this.instanceNano || _DatabaseImpl.nano;
|
|
2213
2219
|
}
|
|
2214
2220
|
async checkSetup() {
|
|
2215
|
-
|
|
2221
|
+
var _a;
|
|
2222
|
+
let shouldCreate = !((_a = this.pouchOpts) == null ? void 0 : _a.skip_setup);
|
|
2216
2223
|
let exists2 = await this.exists();
|
|
2217
2224
|
if (!shouldCreate && !exists2) {
|
|
2218
2225
|
throw new Error("DB does not exist");
|
|
@@ -2276,7 +2283,7 @@ var init_DatabaseImpl = __esm({
|
|
|
2276
2283
|
document.createdAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
2277
2284
|
}
|
|
2278
2285
|
document.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
2279
|
-
if (opts
|
|
2286
|
+
if ((opts == null ? void 0 : opts.force) && document._id) {
|
|
2280
2287
|
try {
|
|
2281
2288
|
const existing = await this.get(document._id);
|
|
2282
2289
|
if (existing) {
|
|
@@ -2440,7 +2447,7 @@ function isMultiTenant() {
|
|
|
2440
2447
|
}
|
|
2441
2448
|
function isTenantIdSet() {
|
|
2442
2449
|
const context = Context.get();
|
|
2443
|
-
return !!context
|
|
2450
|
+
return !!(context == null ? void 0 : context.tenantId);
|
|
2444
2451
|
}
|
|
2445
2452
|
function isTenancyEnabled() {
|
|
2446
2453
|
return environment_default.MULTI_TENANCY;
|
|
@@ -2539,7 +2546,7 @@ async function doInIdentityContext(identity, task) {
|
|
|
2539
2546
|
function getIdentity() {
|
|
2540
2547
|
try {
|
|
2541
2548
|
const context = Context.get();
|
|
2542
|
-
return context
|
|
2549
|
+
return context == null ? void 0 : context.identity;
|
|
2543
2550
|
} catch (e) {
|
|
2544
2551
|
}
|
|
2545
2552
|
}
|
|
@@ -2548,7 +2555,7 @@ function getTenantId() {
|
|
|
2548
2555
|
return DEFAULT_TENANT_ID;
|
|
2549
2556
|
}
|
|
2550
2557
|
const context = Context.get();
|
|
2551
|
-
const tenantId = context
|
|
2558
|
+
const tenantId = context == null ? void 0 : context.tenantId;
|
|
2552
2559
|
if (!tenantId) {
|
|
2553
2560
|
throw new Error("Tenant id not found");
|
|
2554
2561
|
}
|
|
@@ -2556,11 +2563,11 @@ function getTenantId() {
|
|
|
2556
2563
|
}
|
|
2557
2564
|
function getAutomationId() {
|
|
2558
2565
|
const context = Context.get();
|
|
2559
|
-
return context
|
|
2566
|
+
return context == null ? void 0 : context.automationId;
|
|
2560
2567
|
}
|
|
2561
2568
|
function getAppId() {
|
|
2562
2569
|
const context = Context.get();
|
|
2563
|
-
const foundId = context
|
|
2570
|
+
const foundId = context == null ? void 0 : context.appId;
|
|
2564
2571
|
if (!foundId && environment_default.isTest() && TEST_APP_ID) {
|
|
2565
2572
|
return TEST_APP_ID;
|
|
2566
2573
|
} else {
|
|
@@ -2595,7 +2602,7 @@ function getGlobalDB() {
|
|
|
2595
2602
|
if (!context || environment_default.MULTI_TENANCY && !context.tenantId) {
|
|
2596
2603
|
throw new Error("Global DB not found");
|
|
2597
2604
|
}
|
|
2598
|
-
return getDB(baseGlobalDBName(context
|
|
2605
|
+
return getDB(baseGlobalDBName(context == null ? void 0 : context.tenantId));
|
|
2599
2606
|
}
|
|
2600
2607
|
function getAuditLogsDB() {
|
|
2601
2608
|
if (!getTenantId()) {
|
|
@@ -2623,7 +2630,7 @@ function getDevAppDB(opts) {
|
|
|
2623
2630
|
}
|
|
2624
2631
|
function isScim() {
|
|
2625
2632
|
const context = Context.get();
|
|
2626
|
-
const scimCall = context
|
|
2633
|
+
const scimCall = context == null ? void 0 : context.isScim;
|
|
2627
2634
|
return !!scimCall;
|
|
2628
2635
|
}
|
|
2629
2636
|
var TEST_APP_ID, getProdAppId;
|
|
@@ -3474,7 +3481,7 @@ function getGlobalUserParams(globalId, otherProps = {}) {
|
|
|
3474
3481
|
if (!globalId) {
|
|
3475
3482
|
globalId = "";
|
|
3476
3483
|
}
|
|
3477
|
-
const startkey = otherProps
|
|
3484
|
+
const startkey = otherProps == null ? void 0 : otherProps.startkey;
|
|
3478
3485
|
return {
|
|
3479
3486
|
...otherProps,
|
|
3480
3487
|
// need to include this incase pagination
|
|
@@ -3607,7 +3614,10 @@ async function getAllApps({
|
|
|
3607
3614
|
} else {
|
|
3608
3615
|
const response = await Promise.allSettled(appPromises);
|
|
3609
3616
|
const apps = response.filter(
|
|
3610
|
-
(result) =>
|
|
3617
|
+
(result) => {
|
|
3618
|
+
var _a;
|
|
3619
|
+
return result.status === "fulfilled" && ((_a = result.value) == null ? void 0 : _a.state) !== "invalid" /* INVALID */;
|
|
3620
|
+
}
|
|
3611
3621
|
).map(({ value }) => value);
|
|
3612
3622
|
if (!all) {
|
|
3613
3623
|
return apps.filter((app) => {
|
|
@@ -3669,7 +3679,7 @@ function pagination(data, pageSize, {
|
|
|
3669
3679
|
const hasNextPage = data.length > pageSize;
|
|
3670
3680
|
let nextPage = void 0;
|
|
3671
3681
|
if (!getKey) {
|
|
3672
|
-
getKey = (doc) => property ? doc
|
|
3682
|
+
getKey = (doc) => property ? doc == null ? void 0 : doc[property] : doc == null ? void 0 : doc._id;
|
|
3673
3683
|
}
|
|
3674
3684
|
if (hasNextPage) {
|
|
3675
3685
|
nextPage = getKey(data[pageSize]);
|
|
@@ -3820,7 +3830,7 @@ var init_views = __esm({
|
|
|
3820
3830
|
const docs = rows.map(
|
|
3821
3831
|
(row) => params2.include_docs ? row.doc : row.value
|
|
3822
3832
|
);
|
|
3823
|
-
if (opts
|
|
3833
|
+
if (opts == null ? void 0 : opts.arrayResponse) {
|
|
3824
3834
|
return docs;
|
|
3825
3835
|
} else {
|
|
3826
3836
|
return docs.length <= 1 ? docs[0] : docs;
|
|
@@ -4043,34 +4053,38 @@ async function fullSearch(dbName, index2, query, params2) {
|
|
|
4043
4053
|
const rows = await recursiveSearch(dbName, index2, query, params2);
|
|
4044
4054
|
return { rows };
|
|
4045
4055
|
}
|
|
4046
|
-
var import_node_fetch2, QUERY_START_REGEX, QueryBuilder;
|
|
4056
|
+
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;
|
|
4047
4057
|
var init_lucene = __esm({
|
|
4048
4058
|
"src/db/lucene.ts"() {
|
|
4049
4059
|
"use strict";
|
|
4050
4060
|
import_node_fetch2 = __toESM(require("node-fetch"));
|
|
4051
4061
|
init_couch();
|
|
4052
4062
|
QUERY_START_REGEX = /\d[0-9]*:/g;
|
|
4053
|
-
|
|
4054
|
-
#dbName;
|
|
4055
|
-
#index;
|
|
4056
|
-
#query;
|
|
4057
|
-
#limit;
|
|
4058
|
-
#sort;
|
|
4059
|
-
#bookmark;
|
|
4060
|
-
#sortOrder;
|
|
4061
|
-
#sortType;
|
|
4062
|
-
#includeDocs;
|
|
4063
|
-
#version;
|
|
4064
|
-
#indexBuilder;
|
|
4065
|
-
#noEscaping = false;
|
|
4066
|
-
#skip;
|
|
4067
|
-
static {
|
|
4068
|
-
this.maxLimit = 200;
|
|
4069
|
-
}
|
|
4063
|
+
_QueryBuilder = class _QueryBuilder {
|
|
4070
4064
|
constructor(dbName, index2, base) {
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4065
|
+
/**
|
|
4066
|
+
* Lucene queries do not support pagination and use bookmarks instead.
|
|
4067
|
+
* For the given builder, walk through pages using bookmarks until the desired
|
|
4068
|
+
* page has been met.
|
|
4069
|
+
*/
|
|
4070
|
+
__privateAdd(this, _skipItems);
|
|
4071
|
+
__privateAdd(this, _execute);
|
|
4072
|
+
__privateAdd(this, _dbName, void 0);
|
|
4073
|
+
__privateAdd(this, _index, void 0);
|
|
4074
|
+
__privateAdd(this, _query, void 0);
|
|
4075
|
+
__privateAdd(this, _limit, void 0);
|
|
4076
|
+
__privateAdd(this, _sort, void 0);
|
|
4077
|
+
__privateAdd(this, _bookmark, void 0);
|
|
4078
|
+
__privateAdd(this, _sortOrder, void 0);
|
|
4079
|
+
__privateAdd(this, _sortType, void 0);
|
|
4080
|
+
__privateAdd(this, _includeDocs, void 0);
|
|
4081
|
+
__privateAdd(this, _version, void 0);
|
|
4082
|
+
__privateAdd(this, _indexBuilder, void 0);
|
|
4083
|
+
__privateAdd(this, _noEscaping, false);
|
|
4084
|
+
__privateAdd(this, _skip, void 0);
|
|
4085
|
+
__privateSet(this, _dbName, dbName);
|
|
4086
|
+
__privateSet(this, _index, index2);
|
|
4087
|
+
__privateSet(this, _query, {
|
|
4074
4088
|
allOr: false,
|
|
4075
4089
|
string: {},
|
|
4076
4090
|
fuzzy: {},
|
|
@@ -4084,124 +4098,124 @@ var init_lucene = __esm({
|
|
|
4084
4098
|
notContains: {},
|
|
4085
4099
|
containsAny: {},
|
|
4086
4100
|
...base
|
|
4087
|
-
};
|
|
4088
|
-
this
|
|
4089
|
-
this
|
|
4090
|
-
this
|
|
4091
|
-
this
|
|
4101
|
+
});
|
|
4102
|
+
__privateSet(this, _limit, 50);
|
|
4103
|
+
__privateSet(this, _sortOrder, "ascending");
|
|
4104
|
+
__privateSet(this, _sortType, "string");
|
|
4105
|
+
__privateSet(this, _includeDocs, true);
|
|
4092
4106
|
}
|
|
4093
4107
|
disableEscaping() {
|
|
4094
|
-
this
|
|
4108
|
+
__privateSet(this, _noEscaping, true);
|
|
4095
4109
|
return this;
|
|
4096
4110
|
}
|
|
4097
4111
|
setIndexBuilder(builderFn) {
|
|
4098
|
-
this
|
|
4112
|
+
__privateSet(this, _indexBuilder, builderFn);
|
|
4099
4113
|
return this;
|
|
4100
4114
|
}
|
|
4101
4115
|
setVersion(version) {
|
|
4102
4116
|
if (version != null) {
|
|
4103
|
-
this
|
|
4117
|
+
__privateSet(this, _version, version);
|
|
4104
4118
|
}
|
|
4105
4119
|
return this;
|
|
4106
4120
|
}
|
|
4107
4121
|
setTable(tableId) {
|
|
4108
|
-
this
|
|
4122
|
+
__privateGet(this, _query).equal.tableId = tableId;
|
|
4109
4123
|
return this;
|
|
4110
4124
|
}
|
|
4111
4125
|
setLimit(limit) {
|
|
4112
4126
|
if (limit != null) {
|
|
4113
|
-
this
|
|
4127
|
+
__privateSet(this, _limit, limit);
|
|
4114
4128
|
}
|
|
4115
4129
|
return this;
|
|
4116
4130
|
}
|
|
4117
4131
|
setSort(sort) {
|
|
4118
4132
|
if (sort != null) {
|
|
4119
|
-
this
|
|
4133
|
+
__privateSet(this, _sort, sort);
|
|
4120
4134
|
}
|
|
4121
4135
|
return this;
|
|
4122
4136
|
}
|
|
4123
4137
|
setSortOrder(sortOrder) {
|
|
4124
4138
|
if (sortOrder != null) {
|
|
4125
|
-
this
|
|
4139
|
+
__privateSet(this, _sortOrder, sortOrder);
|
|
4126
4140
|
}
|
|
4127
4141
|
return this;
|
|
4128
4142
|
}
|
|
4129
4143
|
setSortType(sortType) {
|
|
4130
4144
|
if (sortType != null) {
|
|
4131
|
-
this
|
|
4145
|
+
__privateSet(this, _sortType, sortType);
|
|
4132
4146
|
}
|
|
4133
4147
|
return this;
|
|
4134
4148
|
}
|
|
4135
4149
|
setBookmark(bookmark) {
|
|
4136
4150
|
if (bookmark != null) {
|
|
4137
|
-
this
|
|
4151
|
+
__privateSet(this, _bookmark, bookmark);
|
|
4138
4152
|
}
|
|
4139
4153
|
return this;
|
|
4140
4154
|
}
|
|
4141
4155
|
setSkip(skip) {
|
|
4142
|
-
this
|
|
4156
|
+
__privateSet(this, _skip, skip);
|
|
4143
4157
|
return this;
|
|
4144
4158
|
}
|
|
4145
4159
|
excludeDocs() {
|
|
4146
|
-
this
|
|
4160
|
+
__privateSet(this, _includeDocs, false);
|
|
4147
4161
|
return this;
|
|
4148
4162
|
}
|
|
4149
4163
|
includeDocs() {
|
|
4150
|
-
this
|
|
4164
|
+
__privateSet(this, _includeDocs, true);
|
|
4151
4165
|
return this;
|
|
4152
4166
|
}
|
|
4153
4167
|
addString(key, partial) {
|
|
4154
|
-
this
|
|
4168
|
+
__privateGet(this, _query).string[key] = partial;
|
|
4155
4169
|
return this;
|
|
4156
4170
|
}
|
|
4157
4171
|
addFuzzy(key, fuzzy) {
|
|
4158
|
-
this
|
|
4172
|
+
__privateGet(this, _query).fuzzy[key] = fuzzy;
|
|
4159
4173
|
return this;
|
|
4160
4174
|
}
|
|
4161
4175
|
addRange(key, low, high) {
|
|
4162
|
-
this
|
|
4176
|
+
__privateGet(this, _query).range[key] = {
|
|
4163
4177
|
low,
|
|
4164
4178
|
high
|
|
4165
4179
|
};
|
|
4166
4180
|
return this;
|
|
4167
4181
|
}
|
|
4168
4182
|
addEqual(key, value) {
|
|
4169
|
-
this
|
|
4183
|
+
__privateGet(this, _query).equal[key] = value;
|
|
4170
4184
|
return this;
|
|
4171
4185
|
}
|
|
4172
4186
|
addNotEqual(key, value) {
|
|
4173
|
-
this
|
|
4187
|
+
__privateGet(this, _query).notEqual[key] = value;
|
|
4174
4188
|
return this;
|
|
4175
4189
|
}
|
|
4176
4190
|
addEmpty(key, value) {
|
|
4177
|
-
this
|
|
4191
|
+
__privateGet(this, _query).empty[key] = value;
|
|
4178
4192
|
return this;
|
|
4179
4193
|
}
|
|
4180
4194
|
addNotEmpty(key, value) {
|
|
4181
|
-
this
|
|
4195
|
+
__privateGet(this, _query).notEmpty[key] = value;
|
|
4182
4196
|
return this;
|
|
4183
4197
|
}
|
|
4184
4198
|
addOneOf(key, value) {
|
|
4185
|
-
this
|
|
4199
|
+
__privateGet(this, _query).oneOf[key] = value;
|
|
4186
4200
|
return this;
|
|
4187
4201
|
}
|
|
4188
4202
|
addContains(key, value) {
|
|
4189
|
-
this
|
|
4203
|
+
__privateGet(this, _query).contains[key] = value;
|
|
4190
4204
|
return this;
|
|
4191
4205
|
}
|
|
4192
4206
|
addNotContains(key, value) {
|
|
4193
|
-
this
|
|
4207
|
+
__privateGet(this, _query).notContains[key] = value;
|
|
4194
4208
|
return this;
|
|
4195
4209
|
}
|
|
4196
4210
|
addContainsAny(key, value) {
|
|
4197
|
-
this
|
|
4211
|
+
__privateGet(this, _query).containsAny[key] = value;
|
|
4198
4212
|
return this;
|
|
4199
4213
|
}
|
|
4200
4214
|
setAllOr() {
|
|
4201
|
-
this
|
|
4215
|
+
__privateGet(this, _query).allOr = true;
|
|
4202
4216
|
}
|
|
4203
4217
|
handleSpaces(input) {
|
|
4204
|
-
if (this
|
|
4218
|
+
if (__privateGet(this, _noEscaping)) {
|
|
4205
4219
|
return input;
|
|
4206
4220
|
} else {
|
|
4207
4221
|
return input.replace(/ /g, "_");
|
|
@@ -4215,12 +4229,12 @@ var init_lucene = __esm({
|
|
|
4215
4229
|
* @returns {string|*}
|
|
4216
4230
|
*/
|
|
4217
4231
|
preprocess(value, { escape, lowercase, wrap, type } = {}) {
|
|
4218
|
-
const hasVersion = !!this
|
|
4232
|
+
const hasVersion = !!__privateGet(this, _version);
|
|
4219
4233
|
const originalType = typeof value;
|
|
4220
4234
|
if (value && lowercase) {
|
|
4221
4235
|
value = value.toLowerCase ? value.toLowerCase() : value;
|
|
4222
4236
|
}
|
|
4223
|
-
if (!this
|
|
4237
|
+
if (!__privateGet(this, _noEscaping) && escape && originalType === "string") {
|
|
4224
4238
|
value = `${value}`.replace(/[ \/#+\-&|!(){}\]^"~*?:\\]/g, "\\$&");
|
|
4225
4239
|
}
|
|
4226
4240
|
if (originalType === "string" && !isNaN(value) && !type) {
|
|
@@ -4232,7 +4246,7 @@ var init_lucene = __esm({
|
|
|
4232
4246
|
}
|
|
4233
4247
|
isMultiCondition() {
|
|
4234
4248
|
let count = 0;
|
|
4235
|
-
for (let filters of Object.values(this
|
|
4249
|
+
for (let filters of Object.values(__privateGet(this, _query))) {
|
|
4236
4250
|
if (typeof filters === "object") {
|
|
4237
4251
|
count += Object.keys(filters).length;
|
|
4238
4252
|
}
|
|
@@ -4258,13 +4272,13 @@ var init_lucene = __esm({
|
|
|
4258
4272
|
}
|
|
4259
4273
|
buildSearchQuery() {
|
|
4260
4274
|
const builder = this;
|
|
4261
|
-
let allOr = this
|
|
4275
|
+
let allOr = __privateGet(this, _query) && __privateGet(this, _query).allOr;
|
|
4262
4276
|
let query = allOr ? "" : "*:*";
|
|
4263
4277
|
const allPreProcessingOpts = { escape: true, lowercase: true, wrap: true };
|
|
4264
4278
|
let tableId;
|
|
4265
|
-
if (this
|
|
4266
|
-
tableId = this
|
|
4267
|
-
delete this
|
|
4279
|
+
if (__privateGet(this, _query).equal.tableId) {
|
|
4280
|
+
tableId = __privateGet(this, _query).equal.tableId;
|
|
4281
|
+
delete __privateGet(this, _query).equal.tableId;
|
|
4268
4282
|
}
|
|
4269
4283
|
const equal = (key, value) => {
|
|
4270
4284
|
if (!value && value !== 0) {
|
|
@@ -4338,19 +4352,19 @@ var init_lucene = __esm({
|
|
|
4338
4352
|
continue;
|
|
4339
4353
|
}
|
|
4340
4354
|
if (built.length > 0 || query.length > 0) {
|
|
4341
|
-
const mode = opts
|
|
4355
|
+
const mode = (opts == null ? void 0 : opts.mode) ? opts.mode : allOr ? "OR" : "AND";
|
|
4342
4356
|
built += ` ${mode} `;
|
|
4343
4357
|
}
|
|
4344
4358
|
built += expression;
|
|
4345
4359
|
}
|
|
4346
|
-
if (opts
|
|
4360
|
+
if (opts == null ? void 0 : opts.returnBuilt) {
|
|
4347
4361
|
return built;
|
|
4348
4362
|
} else {
|
|
4349
4363
|
query += built;
|
|
4350
4364
|
}
|
|
4351
4365
|
}
|
|
4352
|
-
if (this
|
|
4353
|
-
build(this
|
|
4366
|
+
if (__privateGet(this, _query).string) {
|
|
4367
|
+
build(__privateGet(this, _query).string, (key, value) => {
|
|
4354
4368
|
if (!value) {
|
|
4355
4369
|
return null;
|
|
4356
4370
|
}
|
|
@@ -4362,8 +4376,8 @@ var init_lucene = __esm({
|
|
|
4362
4376
|
return `${key}:${value}*`;
|
|
4363
4377
|
});
|
|
4364
4378
|
}
|
|
4365
|
-
if (this
|
|
4366
|
-
build(this
|
|
4379
|
+
if (__privateGet(this, _query).range) {
|
|
4380
|
+
build(__privateGet(this, _query).range, (key, value) => {
|
|
4367
4381
|
if (!value) {
|
|
4368
4382
|
return null;
|
|
4369
4383
|
}
|
|
@@ -4378,14 +4392,14 @@ var init_lucene = __esm({
|
|
|
4378
4392
|
return `${key}:[${low} TO ${high}]`;
|
|
4379
4393
|
});
|
|
4380
4394
|
}
|
|
4381
|
-
if (this
|
|
4382
|
-
build(this
|
|
4395
|
+
if (__privateGet(this, _query).fuzzy) {
|
|
4396
|
+
build(__privateGet(this, _query).fuzzy, fuzzy);
|
|
4383
4397
|
}
|
|
4384
|
-
if (this
|
|
4385
|
-
build(this
|
|
4398
|
+
if (__privateGet(this, _query).equal) {
|
|
4399
|
+
build(__privateGet(this, _query).equal, equal);
|
|
4386
4400
|
}
|
|
4387
|
-
if (this
|
|
4388
|
-
build(this
|
|
4401
|
+
if (__privateGet(this, _query).notEqual) {
|
|
4402
|
+
build(__privateGet(this, _query).notEqual, (key, value) => {
|
|
4389
4403
|
if (!value) {
|
|
4390
4404
|
return null;
|
|
4391
4405
|
}
|
|
@@ -4395,23 +4409,23 @@ var init_lucene = __esm({
|
|
|
4395
4409
|
return `!${key}:${builder.preprocess(value, allPreProcessingOpts)}`;
|
|
4396
4410
|
});
|
|
4397
4411
|
}
|
|
4398
|
-
if (this
|
|
4399
|
-
build(this
|
|
4412
|
+
if (__privateGet(this, _query).empty) {
|
|
4413
|
+
build(__privateGet(this, _query).empty, (key) => `(*:* -${key}:["" TO *])`);
|
|
4400
4414
|
}
|
|
4401
|
-
if (this
|
|
4402
|
-
build(this
|
|
4415
|
+
if (__privateGet(this, _query).notEmpty) {
|
|
4416
|
+
build(__privateGet(this, _query).notEmpty, (key) => `${key}:["" TO *]`);
|
|
4403
4417
|
}
|
|
4404
|
-
if (this
|
|
4405
|
-
build(this
|
|
4418
|
+
if (__privateGet(this, _query).oneOf) {
|
|
4419
|
+
build(__privateGet(this, _query).oneOf, oneOf);
|
|
4406
4420
|
}
|
|
4407
|
-
if (this
|
|
4408
|
-
build(this
|
|
4421
|
+
if (__privateGet(this, _query).contains) {
|
|
4422
|
+
build(__privateGet(this, _query).contains, contains);
|
|
4409
4423
|
}
|
|
4410
|
-
if (this
|
|
4411
|
-
build(this.compressFilters(this
|
|
4424
|
+
if (__privateGet(this, _query).notContains) {
|
|
4425
|
+
build(this.compressFilters(__privateGet(this, _query).notContains), notContains);
|
|
4412
4426
|
}
|
|
4413
|
-
if (this
|
|
4414
|
-
build(this
|
|
4427
|
+
if (__privateGet(this, _query).containsAny) {
|
|
4428
|
+
build(__privateGet(this, _query).containsAny, containsAny);
|
|
4415
4429
|
}
|
|
4416
4430
|
if (tableId) {
|
|
4417
4431
|
query = this.isMultiCondition() ? `(${query})` : query;
|
|
@@ -4423,63 +4437,75 @@ var init_lucene = __esm({
|
|
|
4423
4437
|
buildSearchBody() {
|
|
4424
4438
|
let body2 = {
|
|
4425
4439
|
q: this.buildSearchQuery(),
|
|
4426
|
-
limit: Math.min(this
|
|
4427
|
-
include_docs: this
|
|
4440
|
+
limit: Math.min(__privateGet(this, _limit), _QueryBuilder.maxLimit),
|
|
4441
|
+
include_docs: __privateGet(this, _includeDocs)
|
|
4428
4442
|
};
|
|
4429
|
-
if (this
|
|
4430
|
-
body2.bookmark = this
|
|
4443
|
+
if (__privateGet(this, _bookmark)) {
|
|
4444
|
+
body2.bookmark = __privateGet(this, _bookmark);
|
|
4431
4445
|
}
|
|
4432
|
-
if (this
|
|
4433
|
-
const order = this
|
|
4434
|
-
const type = `<${this
|
|
4435
|
-
body2.sort = `${order}${this.handleSpaces(this
|
|
4446
|
+
if (__privateGet(this, _sort)) {
|
|
4447
|
+
const order = __privateGet(this, _sortOrder) === "descending" ? "-" : "";
|
|
4448
|
+
const type = `<${__privateGet(this, _sortType)}>`;
|
|
4449
|
+
body2.sort = `${order}${this.handleSpaces(__privateGet(this, _sort))}${type}`;
|
|
4436
4450
|
}
|
|
4437
4451
|
return body2;
|
|
4438
4452
|
}
|
|
4439
4453
|
async run() {
|
|
4440
|
-
if (this
|
|
4441
|
-
await this
|
|
4454
|
+
if (__privateGet(this, _skip)) {
|
|
4455
|
+
await __privateMethod(this, _skipItems, skipItems_fn).call(this, __privateGet(this, _skip));
|
|
4442
4456
|
}
|
|
4443
|
-
return await this
|
|
4457
|
+
return await __privateMethod(this, _execute, execute_fn).call(this);
|
|
4444
4458
|
}
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
|
|
4466
|
-
|
|
4467
|
-
|
|
4468
|
-
|
|
4469
|
-
const
|
|
4470
|
-
|
|
4471
|
-
|
|
4459
|
+
};
|
|
4460
|
+
_dbName = new WeakMap();
|
|
4461
|
+
_index = new WeakMap();
|
|
4462
|
+
_query = new WeakMap();
|
|
4463
|
+
_limit = new WeakMap();
|
|
4464
|
+
_sort = new WeakMap();
|
|
4465
|
+
_bookmark = new WeakMap();
|
|
4466
|
+
_sortOrder = new WeakMap();
|
|
4467
|
+
_sortType = new WeakMap();
|
|
4468
|
+
_includeDocs = new WeakMap();
|
|
4469
|
+
_version = new WeakMap();
|
|
4470
|
+
_indexBuilder = new WeakMap();
|
|
4471
|
+
_noEscaping = new WeakMap();
|
|
4472
|
+
_skip = new WeakMap();
|
|
4473
|
+
_skipItems = new WeakSet();
|
|
4474
|
+
skipItems_fn = async function(skip) {
|
|
4475
|
+
const prevIncludeDocs = __privateGet(this, _includeDocs);
|
|
4476
|
+
const prevLimit = __privateGet(this, _limit);
|
|
4477
|
+
this.excludeDocs();
|
|
4478
|
+
let skipRemaining = skip;
|
|
4479
|
+
let iterationFetched = 0;
|
|
4480
|
+
do {
|
|
4481
|
+
const toSkip = Math.min(_QueryBuilder.maxLimit, skipRemaining);
|
|
4482
|
+
this.setLimit(toSkip);
|
|
4483
|
+
const { bookmark, rows } = await __privateMethod(this, _execute, execute_fn).call(this);
|
|
4484
|
+
this.setBookmark(bookmark);
|
|
4485
|
+
iterationFetched = rows.length;
|
|
4486
|
+
skipRemaining -= rows.length;
|
|
4487
|
+
} while (skipRemaining > 0 && iterationFetched > 0);
|
|
4488
|
+
__privateSet(this, _includeDocs, prevIncludeDocs);
|
|
4489
|
+
__privateSet(this, _limit, prevLimit);
|
|
4490
|
+
};
|
|
4491
|
+
_execute = new WeakSet();
|
|
4492
|
+
execute_fn = async function() {
|
|
4493
|
+
const { url, cookie } = getCouchInfo();
|
|
4494
|
+
const fullPath = `${url}/${__privateGet(this, _dbName)}/_design/database/_search/${__privateGet(this, _index)}`;
|
|
4495
|
+
const body2 = this.buildSearchBody();
|
|
4496
|
+
try {
|
|
4497
|
+
return await runQuery(fullPath, body2, cookie);
|
|
4498
|
+
} catch (err) {
|
|
4499
|
+
if (err.status === 404 && __privateGet(this, _indexBuilder)) {
|
|
4500
|
+
await __privateGet(this, _indexBuilder).call(this);
|
|
4472
4501
|
return await runQuery(fullPath, body2, cookie);
|
|
4473
|
-
}
|
|
4474
|
-
|
|
4475
|
-
await this.#indexBuilder();
|
|
4476
|
-
return await runQuery(fullPath, body2, cookie);
|
|
4477
|
-
} else {
|
|
4478
|
-
throw err;
|
|
4479
|
-
}
|
|
4502
|
+
} else {
|
|
4503
|
+
throw err;
|
|
4480
4504
|
}
|
|
4481
4505
|
}
|
|
4482
4506
|
};
|
|
4507
|
+
_QueryBuilder.maxLimit = 200;
|
|
4508
|
+
QueryBuilder = _QueryBuilder;
|
|
4483
4509
|
}
|
|
4484
4510
|
});
|
|
4485
4511
|
|
|
@@ -4558,9 +4584,10 @@ var init_searchIndexes2 = __esm({
|
|
|
4558
4584
|
|
|
4559
4585
|
// src/db/errors.ts
|
|
4560
4586
|
function checkErrorCode(error, code) {
|
|
4587
|
+
var _a;
|
|
4561
4588
|
const stringCode = code.toString();
|
|
4562
4589
|
if (typeof error === "object") {
|
|
4563
|
-
return error.status === code || error.message
|
|
4590
|
+
return error.status === code || ((_a = error.message) == null ? void 0 : _a.includes(stringCode));
|
|
4564
4591
|
} else if (typeof error === "number") {
|
|
4565
4592
|
return error === code;
|
|
4566
4593
|
} else if (typeof error === "string") {
|
|
@@ -4811,12 +4838,12 @@ var init_objectStore = __esm({
|
|
|
4811
4838
|
streamUpload = async (bucketName, filename, stream2, extra = {}) => {
|
|
4812
4839
|
const objectStore = ObjectStore(bucketName);
|
|
4813
4840
|
await makeSureBucketExists(objectStore, bucketName);
|
|
4814
|
-
if (filename
|
|
4841
|
+
if (filename == null ? void 0 : filename.endsWith(".js")) {
|
|
4815
4842
|
extra = {
|
|
4816
4843
|
...extra,
|
|
4817
4844
|
ContentType: "application/javascript"
|
|
4818
4845
|
};
|
|
4819
|
-
} else if (filename
|
|
4846
|
+
} else if (filename == null ? void 0 : filename.endsWith(".svg")) {
|
|
4820
4847
|
extra = {
|
|
4821
4848
|
...extra,
|
|
4822
4849
|
ContentType: "image"
|
|
@@ -4932,6 +4959,7 @@ var init_objectStore = __esm({
|
|
|
4932
4959
|
return objectStore.deleteObjects(params2).promise();
|
|
4933
4960
|
};
|
|
4934
4961
|
deleteFolder = async (bucketName, folder) => {
|
|
4962
|
+
var _a, _b, _c;
|
|
4935
4963
|
bucketName = sanitizeBucket(bucketName);
|
|
4936
4964
|
folder = sanitizeKey(folder);
|
|
4937
4965
|
const client = ObjectStore(bucketName);
|
|
@@ -4940,7 +4968,7 @@ var init_objectStore = __esm({
|
|
|
4940
4968
|
Prefix: folder
|
|
4941
4969
|
};
|
|
4942
4970
|
const existingObjectsResponse = await client.listObjects(listParams).promise();
|
|
4943
|
-
if (existingObjectsResponse.Contents
|
|
4971
|
+
if (((_a = existingObjectsResponse.Contents) == null ? void 0 : _a.length) === 0) {
|
|
4944
4972
|
return;
|
|
4945
4973
|
}
|
|
4946
4974
|
const deleteParams = {
|
|
@@ -4949,11 +4977,11 @@ var init_objectStore = __esm({
|
|
|
4949
4977
|
Objects: []
|
|
4950
4978
|
}
|
|
4951
4979
|
};
|
|
4952
|
-
existingObjectsResponse.Contents
|
|
4980
|
+
(_b = existingObjectsResponse.Contents) == null ? void 0 : _b.forEach((content) => {
|
|
4953
4981
|
deleteParams.Delete.Objects.push({ Key: content.Key });
|
|
4954
4982
|
});
|
|
4955
4983
|
const deleteResponse = await client.deleteObjects(deleteParams).promise();
|
|
4956
|
-
if (deleteResponse.Deleted
|
|
4984
|
+
if (((_c = deleteResponse.Deleted) == null ? void 0 : _c.length) === 1e3) {
|
|
4957
4985
|
return deleteFolder(bucketName, folder);
|
|
4958
4986
|
}
|
|
4959
4987
|
};
|
|
@@ -5230,7 +5258,7 @@ function getFullPath(fileName) {
|
|
|
5230
5258
|
}
|
|
5231
5259
|
function getSingleFileMaxSizeInfo(totalMaxSize) {
|
|
5232
5260
|
const regex = /(\d+)([A-Za-z])/;
|
|
5233
|
-
const match = totalMaxSize
|
|
5261
|
+
const match = totalMaxSize == null ? void 0 : totalMaxSize.match(regex);
|
|
5234
5262
|
if (!match) {
|
|
5235
5263
|
console.warn(`totalMaxSize does not have a valid value`, {
|
|
5236
5264
|
totalMaxSize
|
|
@@ -5262,9 +5290,9 @@ function localFileDestination() {
|
|
|
5262
5290
|
const fileInfo = getSingleFileMaxSizeInfo(environment_default.ROLLING_LOG_MAX_SIZE);
|
|
5263
5291
|
const outFile = rfs.createStream(logsFileName, {
|
|
5264
5292
|
// As we have a rolling size, we want to half the max size
|
|
5265
|
-
size: fileInfo
|
|
5293
|
+
size: fileInfo == null ? void 0 : fileInfo.size,
|
|
5266
5294
|
path: logsPath,
|
|
5267
|
-
maxFiles: fileInfo
|
|
5295
|
+
maxFiles: (fileInfo == null ? void 0 : fileInfo.totalHistoryFiles) || 1,
|
|
5268
5296
|
immutable: true,
|
|
5269
5297
|
history: budibaseLogsHistoryFileName,
|
|
5270
5298
|
initialRotation: false
|
|
@@ -5339,8 +5367,8 @@ var init_logger = __esm({
|
|
|
5339
5367
|
tenantId: getTenantId2(),
|
|
5340
5368
|
appId: getAppId2(),
|
|
5341
5369
|
automationId: getAutomationId2(),
|
|
5342
|
-
identityId: identity
|
|
5343
|
-
identityType: identity
|
|
5370
|
+
identityId: identity == null ? void 0 : identity._id,
|
|
5371
|
+
identityType: identity == null ? void 0 : identity.type,
|
|
5344
5372
|
correlationId: getId()
|
|
5345
5373
|
};
|
|
5346
5374
|
const mergingObject = {
|
|
@@ -5404,30 +5432,30 @@ var init_logger = __esm({
|
|
|
5404
5432
|
pinoInstance = destinations.length ? (0, import_pino.default)(pinoOptions, import_pino.default.multistream(destinations)) : (0, import_pino.default)(pinoOptions);
|
|
5405
5433
|
console.log = (...arg) => {
|
|
5406
5434
|
const [obj, msg] = getLogParams2(arg);
|
|
5407
|
-
pinoInstance
|
|
5435
|
+
pinoInstance == null ? void 0 : pinoInstance.info(obj, msg);
|
|
5408
5436
|
};
|
|
5409
5437
|
console.info = (...arg) => {
|
|
5410
5438
|
const [obj, msg] = getLogParams2(arg);
|
|
5411
|
-
pinoInstance
|
|
5439
|
+
pinoInstance == null ? void 0 : pinoInstance.info(obj, msg);
|
|
5412
5440
|
};
|
|
5413
5441
|
console.warn = (...arg) => {
|
|
5414
5442
|
const [obj, msg] = getLogParams2(arg);
|
|
5415
|
-
pinoInstance
|
|
5443
|
+
pinoInstance == null ? void 0 : pinoInstance.warn(obj, msg);
|
|
5416
5444
|
};
|
|
5417
5445
|
console.error = (...arg) => {
|
|
5418
5446
|
const [obj, msg] = getLogParams2(arg);
|
|
5419
|
-
pinoInstance
|
|
5447
|
+
pinoInstance == null ? void 0 : pinoInstance.error(obj, msg);
|
|
5420
5448
|
};
|
|
5421
5449
|
console.trace = (...arg) => {
|
|
5422
5450
|
const [obj, msg] = getLogParams2(arg);
|
|
5423
5451
|
if (!obj.err) {
|
|
5424
5452
|
obj.err = new Error();
|
|
5425
5453
|
}
|
|
5426
|
-
pinoInstance
|
|
5454
|
+
pinoInstance == null ? void 0 : pinoInstance.trace(obj, msg);
|
|
5427
5455
|
};
|
|
5428
5456
|
console.debug = (...arg) => {
|
|
5429
5457
|
const [obj, msg] = getLogParams2(arg);
|
|
5430
|
-
pinoInstance
|
|
5458
|
+
pinoInstance == null ? void 0 : pinoInstance.debug(obj, msg);
|
|
5431
5459
|
};
|
|
5432
5460
|
const getTenantId2 = () => {
|
|
5433
5461
|
let tenantId;
|
|
@@ -5710,6 +5738,7 @@ var isUserInAppTenant = (appId, user) => {
|
|
|
5710
5738
|
};
|
|
5711
5739
|
var ALL_STRATEGIES = Object.values(TenantResolutionStrategy);
|
|
5712
5740
|
var getTenantIDFromCtx = (ctx, opts) => {
|
|
5741
|
+
var _a;
|
|
5713
5742
|
if (!isMultiTenant()) {
|
|
5714
5743
|
return DEFAULT_TENANT_ID;
|
|
5715
5744
|
}
|
|
@@ -5723,15 +5752,16 @@ var getTenantIDFromCtx = (ctx, opts) => {
|
|
|
5723
5752
|
opts.excludeStrategies = [];
|
|
5724
5753
|
}
|
|
5725
5754
|
const isAllowed = (strategy) => {
|
|
5726
|
-
|
|
5755
|
+
var _a2, _b;
|
|
5756
|
+
if ((_a2 = opts.excludeStrategies) == null ? void 0 : _a2.includes(strategy)) {
|
|
5727
5757
|
return false;
|
|
5728
5758
|
}
|
|
5729
|
-
if (opts.includeStrategies
|
|
5759
|
+
if ((_b = opts.includeStrategies) == null ? void 0 : _b.includes(strategy)) {
|
|
5730
5760
|
return true;
|
|
5731
5761
|
}
|
|
5732
5762
|
};
|
|
5733
5763
|
if (isAllowed("user" /* USER */)) {
|
|
5734
|
-
const userTenantId = ctx.user
|
|
5764
|
+
const userTenantId = (_a = ctx.user) == null ? void 0 : _a.tenantId;
|
|
5735
5765
|
if (userTenantId) {
|
|
5736
5766
|
return userTenantId;
|
|
5737
5767
|
}
|
|
@@ -6299,7 +6329,7 @@ async function put(db, doc, writeRateMs = DEFAULT_WRITE_RATE_MS) {
|
|
|
6299
6329
|
logWarn(`Ignoring redlock conflict in write-through cache`);
|
|
6300
6330
|
}
|
|
6301
6331
|
}
|
|
6302
|
-
cacheItem = makeCacheItem(output, updateDb ? null : cacheItem
|
|
6332
|
+
cacheItem = makeCacheItem(output, updateDb ? null : cacheItem == null ? void 0 : cacheItem.lastWrite);
|
|
6303
6333
|
if (output._id) {
|
|
6304
6334
|
await cache.store(makeCacheKey(db, output._id), cacheItem);
|
|
6305
6335
|
}
|
|
@@ -6391,6 +6421,7 @@ async function getSettingsConfig() {
|
|
|
6391
6421
|
async function getPlatformUrl(opts = {
|
|
6392
6422
|
tenantAware: true
|
|
6393
6423
|
}) {
|
|
6424
|
+
var _a;
|
|
6394
6425
|
let platformUrl = environment_default.PLATFORM_URL || "http://localhost:10000";
|
|
6395
6426
|
if (!environment_default.SELF_HOSTED && environment_default.MULTI_TENANCY && opts.tenantAware) {
|
|
6396
6427
|
const tenantId = getTenantId();
|
|
@@ -6398,11 +6429,11 @@ async function getPlatformUrl(opts = {
|
|
|
6398
6429
|
platformUrl = platformUrl.replace("://", `://${tenantId}.`);
|
|
6399
6430
|
}
|
|
6400
6431
|
} else if (environment_default.SELF_HOSTED) {
|
|
6401
|
-
const config = opts
|
|
6432
|
+
const config = (opts == null ? void 0 : opts.config) ? opts.config : (
|
|
6402
6433
|
// direct to db to prevent infinite loop
|
|
6403
|
-
(await getConfig("settings" /* SETTINGS */))
|
|
6434
|
+
(_a = await getConfig("settings" /* SETTINGS */)) == null ? void 0 : _a.config
|
|
6404
6435
|
);
|
|
6405
|
-
if (config
|
|
6436
|
+
if (config == null ? void 0 : config.platformUrl) {
|
|
6406
6437
|
platformUrl = config.platformUrl;
|
|
6407
6438
|
}
|
|
6408
6439
|
}
|
|
@@ -6416,13 +6447,14 @@ var analyticsEnabled = async (opts) => {
|
|
|
6416
6447
|
"analyticsEnabled" /* ANALYTICS_ENABLED */,
|
|
6417
6448
|
86400 /* ONE_DAY */,
|
|
6418
6449
|
async () => {
|
|
6419
|
-
|
|
6450
|
+
var _a;
|
|
6451
|
+
const config = (opts == null ? void 0 : opts.config) ? opts.config : (
|
|
6420
6452
|
// direct to db to prevent infinite loop
|
|
6421
|
-
(await getConfig("settings" /* SETTINGS */))
|
|
6453
|
+
(_a = await getConfig("settings" /* SETTINGS */)) == null ? void 0 : _a.config
|
|
6422
6454
|
);
|
|
6423
|
-
if (config
|
|
6455
|
+
if ((config == null ? void 0 : config.analyticsEnabled) === false) {
|
|
6424
6456
|
return false;
|
|
6425
|
-
} else if (config
|
|
6457
|
+
} else if ((config == null ? void 0 : config.analyticsEnabled) === true) {
|
|
6426
6458
|
return true;
|
|
6427
6459
|
}
|
|
6428
6460
|
}
|
|
@@ -6442,7 +6474,7 @@ async function getGoogleConfigDoc() {
|
|
|
6442
6474
|
}
|
|
6443
6475
|
async function getGoogleConfig() {
|
|
6444
6476
|
const config = await getGoogleConfigDoc();
|
|
6445
|
-
return config
|
|
6477
|
+
return config == null ? void 0 : config.config;
|
|
6446
6478
|
}
|
|
6447
6479
|
async function getGoogleDatasourceConfig() {
|
|
6448
6480
|
if (!environment_default.SELF_HOSTED) {
|
|
@@ -6470,11 +6502,13 @@ async function getOIDCConfigDoc() {
|
|
|
6470
6502
|
return getConfig("oidc" /* OIDC */);
|
|
6471
6503
|
}
|
|
6472
6504
|
async function getOIDCConfig() {
|
|
6473
|
-
|
|
6474
|
-
|
|
6505
|
+
var _a;
|
|
6506
|
+
const config = (_a = await getOIDCConfigDoc()) == null ? void 0 : _a.config;
|
|
6507
|
+
return (config == null ? void 0 : config.configs) && config.configs[0];
|
|
6475
6508
|
}
|
|
6476
6509
|
async function getOIDCConfigById(configId) {
|
|
6477
|
-
|
|
6510
|
+
var _a;
|
|
6511
|
+
const config = (_a = await getConfig("oidc" /* OIDC */)) == null ? void 0 : _a.config;
|
|
6478
6512
|
return config && config.configs.filter((c) => c.uuid === configId)[0];
|
|
6479
6513
|
}
|
|
6480
6514
|
async function getSMTPConfigDoc() {
|
|
@@ -6501,7 +6535,7 @@ async function getSMTPConfig(isAutomation) {
|
|
|
6501
6535
|
}
|
|
6502
6536
|
async function getSCIMConfig() {
|
|
6503
6537
|
const config = await getConfig("scim" /* SCIM */);
|
|
6504
|
-
return config
|
|
6538
|
+
return config == null ? void 0 : config.config;
|
|
6505
6539
|
}
|
|
6506
6540
|
|
|
6507
6541
|
// src/events/index.ts
|
|
@@ -6916,7 +6950,7 @@ async function getAppIdFromCtx(ctx) {
|
|
|
6916
6950
|
appId = confirmAppId(await resolveAppUrl(ctx));
|
|
6917
6951
|
}
|
|
6918
6952
|
const referer = ctx.request.headers.referer;
|
|
6919
|
-
if (!appId && referer
|
|
6953
|
+
if (!appId && (referer == null ? void 0 : referer.includes(BUILDER_APP_PREFIX))) {
|
|
6920
6954
|
const refererId = parseAppIdFromUrl(ctx.request.headers.referer);
|
|
6921
6955
|
appId = confirmAppId(refererId);
|
|
6922
6956
|
}
|
|
@@ -7135,6 +7169,7 @@ function handleStalled(queue, removeStalledCb) {
|
|
|
7135
7169
|
});
|
|
7136
7170
|
}
|
|
7137
7171
|
function getLogParams(eventType, event, opts = {}, extra = {}) {
|
|
7172
|
+
var _a, _b, _c;
|
|
7138
7173
|
const message = `[BULL] ${eventType}=${event}`;
|
|
7139
7174
|
const err = opts.error;
|
|
7140
7175
|
const bullLog = {
|
|
@@ -7142,11 +7177,11 @@ function getLogParams(eventType, event, opts = {}, extra = {}) {
|
|
|
7142
7177
|
eventType,
|
|
7143
7178
|
event,
|
|
7144
7179
|
job: opts.job,
|
|
7145
|
-
jobId: opts.jobId || opts.job
|
|
7180
|
+
jobId: opts.jobId || ((_a = opts.job) == null ? void 0 : _a.id),
|
|
7146
7181
|
...extra
|
|
7147
7182
|
};
|
|
7148
7183
|
let automationLog;
|
|
7149
|
-
if (opts.job
|
|
7184
|
+
if ((_c = (_b = opts.job) == null ? void 0 : _b.data) == null ? void 0 : _c.automation) {
|
|
7150
7185
|
automationLog = {
|
|
7151
7186
|
_logKey: "automation",
|
|
7152
7187
|
trigger: opts.job ? opts.job.data.automation.definition.trigger.event : void 0
|
|
@@ -7161,9 +7196,11 @@ var EventTypeMap = {
|
|
|
7161
7196
|
["systemEventQueue" /* SYSTEM_EVENT_QUEUE */]: "system-event" /* SYSTEM_EVENT */
|
|
7162
7197
|
};
|
|
7163
7198
|
function logging(queue, jobQueue) {
|
|
7199
|
+
var _a;
|
|
7164
7200
|
const eventType = EventTypeMap[jobQueue];
|
|
7165
7201
|
function doInJobContext(job, task) {
|
|
7166
|
-
|
|
7202
|
+
var _a2;
|
|
7203
|
+
const appId = (_a2 = job.data.event) == null ? void 0 : _a2.appId;
|
|
7167
7204
|
if (appId) {
|
|
7168
7205
|
return doInContext(appId, task);
|
|
7169
7206
|
} else {
|
|
@@ -7177,7 +7214,7 @@ function logging(queue, jobQueue) {
|
|
|
7177
7214
|
}).on("error" /* ERROR */, (error) => {
|
|
7178
7215
|
console.error(...getLogParams(eventType, "error" /* ERROR */, { error }));
|
|
7179
7216
|
});
|
|
7180
|
-
if (process.env.NODE_DEBUG
|
|
7217
|
+
if ((_a = process.env.NODE_DEBUG) == null ? void 0 : _a.includes("bull")) {
|
|
7181
7218
|
queue.on("waiting" /* WAITING */, (jobId) => {
|
|
7182
7219
|
console.info(...getLogParams(eventType, "waiting" /* WAITING */, { jobId }));
|
|
7183
7220
|
}).on("active" /* ACTIVE */, async (job, jobPromise) => {
|
|
@@ -7247,7 +7284,7 @@ function createQueue(jobQueue, opts = {}) {
|
|
|
7247
7284
|
} else {
|
|
7248
7285
|
queue = new inMemoryQueue_default(jobQueue, queueConfig);
|
|
7249
7286
|
}
|
|
7250
|
-
addListeners(queue, jobQueue, opts
|
|
7287
|
+
addListeners(queue, jobQueue, opts == null ? void 0 : opts.removeStalledCb);
|
|
7251
7288
|
QUEUES.push(queue);
|
|
7252
7289
|
if (!cleanupInterval && !environment_default.isTest()) {
|
|
7253
7290
|
cleanupInterval = set(cleanup2, CLEANUP_PERIOD_MS);
|
|
@@ -7272,10 +7309,7 @@ async function shutdown2() {
|
|
|
7272
7309
|
|
|
7273
7310
|
// src/events/processors/AuditLogsProcessor.ts
|
|
7274
7311
|
init_environment2();
|
|
7275
|
-
var
|
|
7276
|
-
static {
|
|
7277
|
-
this.auditLogsEnabled = false;
|
|
7278
|
-
}
|
|
7312
|
+
var _AuditLogsProcessor = class _AuditLogsProcessor {
|
|
7279
7313
|
// can't use constructor as need to return promise
|
|
7280
7314
|
static init(fn) {
|
|
7281
7315
|
_AuditLogsProcessor.auditLogsEnabled = true;
|
|
@@ -7327,9 +7361,12 @@ var AuditLogsProcessor = class _AuditLogsProcessor {
|
|
|
7327
7361
|
async identifyGroup(group, timestamp) {
|
|
7328
7362
|
}
|
|
7329
7363
|
shutdown() {
|
|
7330
|
-
|
|
7364
|
+
var _a;
|
|
7365
|
+
(_a = _AuditLogsProcessor.auditLogQueue) == null ? void 0 : _a.close();
|
|
7331
7366
|
}
|
|
7332
7367
|
};
|
|
7368
|
+
_AuditLogsProcessor.auditLogsEnabled = false;
|
|
7369
|
+
var AuditLogsProcessor = _AuditLogsProcessor;
|
|
7333
7370
|
|
|
7334
7371
|
// src/events/processors/Processors.ts
|
|
7335
7372
|
var Processor = class {
|
|
@@ -7544,7 +7581,7 @@ var bulkGetGlobalUsersById = async (userIds, opts) => {
|
|
|
7544
7581
|
keys: userIds,
|
|
7545
7582
|
include_docs: true
|
|
7546
7583
|
})).rows.map((row) => row.doc);
|
|
7547
|
-
if (opts
|
|
7584
|
+
if (opts == null ? void 0 : opts.cleanup) {
|
|
7548
7585
|
users = removeUserPassword(users);
|
|
7549
7586
|
}
|
|
7550
7587
|
return users;
|
|
@@ -7565,7 +7602,7 @@ var bulkUpdateGlobalUsers = async (users) => {
|
|
|
7565
7602
|
async function getById(id, opts) {
|
|
7566
7603
|
const db = getGlobalDB();
|
|
7567
7604
|
let user = await db.get(id);
|
|
7568
|
-
if (opts
|
|
7605
|
+
if (opts == null ? void 0 : opts.cleanup) {
|
|
7569
7606
|
user = removeUserPassword(user);
|
|
7570
7607
|
}
|
|
7571
7608
|
return user;
|
|
@@ -7582,7 +7619,7 @@ var getGlobalUserByEmail = async (email, opts) => {
|
|
|
7582
7619
|
throw new Error(`Multiple users found with email address: ${email}`);
|
|
7583
7620
|
}
|
|
7584
7621
|
let user = response;
|
|
7585
|
-
if (opts
|
|
7622
|
+
if (opts == null ? void 0 : opts.cleanup) {
|
|
7586
7623
|
user = removeUserPassword(user);
|
|
7587
7624
|
}
|
|
7588
7625
|
return user;
|
|
@@ -7600,7 +7637,7 @@ var searchGlobalUsersByApp = async (appId, opts, getOpts) => {
|
|
|
7600
7637
|
response = [];
|
|
7601
7638
|
}
|
|
7602
7639
|
let users = Array.isArray(response) ? response : [response];
|
|
7603
|
-
if (getOpts
|
|
7640
|
+
if (getOpts == null ? void 0 : getOpts.cleanup) {
|
|
7604
7641
|
users = removeUserPassword(users);
|
|
7605
7642
|
}
|
|
7606
7643
|
return users;
|
|
@@ -7630,10 +7667,10 @@ var searchGlobalUsersByAppAccess = async (appId, opts) => {
|
|
|
7630
7667
|
$regex: "^us_"
|
|
7631
7668
|
}
|
|
7632
7669
|
},
|
|
7633
|
-
limit: opts
|
|
7670
|
+
limit: (opts == null ? void 0 : opts.limit) || 50
|
|
7634
7671
|
};
|
|
7635
7672
|
const resp = await directCouchFind(getGlobalDBName(), searchOptions);
|
|
7636
|
-
return resp
|
|
7673
|
+
return resp == null ? void 0 : resp.rows;
|
|
7637
7674
|
};
|
|
7638
7675
|
var getGlobalUserByAppPage = (appId, user) => {
|
|
7639
7676
|
if (!user) {
|
|
@@ -7656,7 +7693,7 @@ var searchGlobalUsersByEmail = async (email, opts, getOpts) => {
|
|
|
7656
7693
|
response = [];
|
|
7657
7694
|
}
|
|
7658
7695
|
let users = Array.isArray(response) ? response : [response];
|
|
7659
|
-
if (getOpts
|
|
7696
|
+
if (getOpts == null ? void 0 : getOpts.cleanup) {
|
|
7660
7697
|
users = removeUserPassword(users);
|
|
7661
7698
|
}
|
|
7662
7699
|
return users;
|
|
@@ -8007,12 +8044,13 @@ __export(users_exports2, {
|
|
|
8007
8044
|
isGlobalBuilder: () => isGlobalBuilder
|
|
8008
8045
|
});
|
|
8009
8046
|
function isBuilder(user, appId) {
|
|
8047
|
+
var _a, _b, _c;
|
|
8010
8048
|
if (!user) {
|
|
8011
8049
|
return false;
|
|
8012
8050
|
}
|
|
8013
|
-
if (user.builder
|
|
8051
|
+
if ((_a = user.builder) == null ? void 0 : _a.global) {
|
|
8014
8052
|
return true;
|
|
8015
|
-
} else if (appId && user.builder
|
|
8053
|
+
} else if (appId && ((_c = (_b = user.builder) == null ? void 0 : _b.apps) == null ? void 0 : _c.includes(getProdAppID2(appId)))) {
|
|
8016
8054
|
return true;
|
|
8017
8055
|
}
|
|
8018
8056
|
return false;
|
|
@@ -8030,24 +8068,27 @@ function isAdminOrBuilder(user, appId) {
|
|
|
8030
8068
|
return isBuilder(user, appId) || isAdmin(user);
|
|
8031
8069
|
}
|
|
8032
8070
|
function hasAppBuilderPermissions(user) {
|
|
8071
|
+
var _a, _b, _c;
|
|
8033
8072
|
if (!user) {
|
|
8034
8073
|
return false;
|
|
8035
8074
|
}
|
|
8036
|
-
const appLength = user.builder
|
|
8037
|
-
const isGlobalBuilder3 = !!user.builder
|
|
8075
|
+
const appLength = (_b = (_a = user.builder) == null ? void 0 : _a.apps) == null ? void 0 : _b.length;
|
|
8076
|
+
const isGlobalBuilder3 = !!((_c = user.builder) == null ? void 0 : _c.global);
|
|
8038
8077
|
return !isGlobalBuilder3 && appLength != null && appLength > 0;
|
|
8039
8078
|
}
|
|
8040
8079
|
function hasBuilderPermissions(user) {
|
|
8080
|
+
var _a;
|
|
8041
8081
|
if (!user) {
|
|
8042
8082
|
return false;
|
|
8043
8083
|
}
|
|
8044
|
-
return user.builder
|
|
8084
|
+
return ((_a = user.builder) == null ? void 0 : _a.global) || hasAppBuilderPermissions(user);
|
|
8045
8085
|
}
|
|
8046
8086
|
function hasAdminPermissions(user) {
|
|
8087
|
+
var _a;
|
|
8047
8088
|
if (!user) {
|
|
8048
8089
|
return false;
|
|
8049
8090
|
}
|
|
8050
|
-
return !!user.admin
|
|
8091
|
+
return !!((_a = user.admin) == null ? void 0 : _a.global);
|
|
8051
8092
|
}
|
|
8052
8093
|
|
|
8053
8094
|
// src/users/utils.ts
|
|
@@ -8120,7 +8161,7 @@ var unassignAppRoleEvents = async (user, roles, existingRoles) => {
|
|
|
8120
8161
|
};
|
|
8121
8162
|
var handleAppRoleEvents = async (user, existingUser) => {
|
|
8122
8163
|
const roles = user.roles;
|
|
8123
|
-
const existingRoles = existingUser
|
|
8164
|
+
const existingRoles = existingUser == null ? void 0 : existingUser.roles;
|
|
8124
8165
|
await assignAppRoleEvents(user, roles, existingRoles);
|
|
8125
8166
|
await unassignAppRoleEvents(user, roles, existingRoles);
|
|
8126
8167
|
};
|
|
@@ -8172,7 +8213,7 @@ var isRemovingAdmin = (user, existingUser) => {
|
|
|
8172
8213
|
return isRemovingPermission(user, existingUser, hasAdminPermissions2);
|
|
8173
8214
|
};
|
|
8174
8215
|
var isOnboardingComplete = (user, existingUser) => {
|
|
8175
|
-
return !existingUser
|
|
8216
|
+
return !(existingUser == null ? void 0 : existingUser.onboardedAt) && typeof user.onboardedAt === "string";
|
|
8176
8217
|
};
|
|
8177
8218
|
var isAddingPermission = (user, existingUser, hasPermission) => {
|
|
8178
8219
|
if (!hasPermission(user)) {
|
|
@@ -8229,7 +8270,7 @@ async function getSessionsForUser(userId) {
|
|
|
8229
8270
|
}
|
|
8230
8271
|
async function invalidateSessions(userId, opts = {}) {
|
|
8231
8272
|
try {
|
|
8232
|
-
const reason = opts
|
|
8273
|
+
const reason = (opts == null ? void 0 : opts.reason) || "unknown";
|
|
8233
8274
|
let sessionIds = opts.sessionIds || [];
|
|
8234
8275
|
let sessionKeys;
|
|
8235
8276
|
if (sessionIds.length === 0) {
|
|
@@ -8406,6 +8447,7 @@ var UserDB = class _UserDB {
|
|
|
8406
8447
|
return user;
|
|
8407
8448
|
}
|
|
8408
8449
|
static async save(user, opts = {}) {
|
|
8450
|
+
var _a, _b;
|
|
8409
8451
|
if (opts.hashPassword == null) {
|
|
8410
8452
|
opts.hashPassword = true;
|
|
8411
8453
|
}
|
|
@@ -8418,7 +8460,7 @@ var UserDB = class _UserDB {
|
|
|
8418
8460
|
if (!email && !_id) {
|
|
8419
8461
|
throw new Error("_id or email is required");
|
|
8420
8462
|
}
|
|
8421
|
-
if (user.builder
|
|
8463
|
+
if (((_b = (_a = user.builder) == null ? void 0 : _a.apps) == null ? void 0 : _b.length) && !await _UserDB.features.isAppBuildersEnabled()) {
|
|
8422
8464
|
throw new Error("Unable to update app builders, please check license");
|
|
8423
8465
|
}
|
|
8424
8466
|
let dbUser;
|
|
@@ -8446,10 +8488,10 @@ var UserDB = class _UserDB {
|
|
|
8446
8488
|
return _UserDB.quotas.addUsers(change, async () => {
|
|
8447
8489
|
await validateUniqueUser(email, tenantId);
|
|
8448
8490
|
let builtUser = await _UserDB.buildUser(user, opts, tenantId, dbUser);
|
|
8449
|
-
if (opts.currentUserId && opts.currentUserId === dbUser
|
|
8491
|
+
if (opts.currentUserId && opts.currentUserId === (dbUser == null ? void 0 : dbUser._id)) {
|
|
8450
8492
|
builtUser = cleanseUserObject(builtUser, dbUser);
|
|
8451
8493
|
}
|
|
8452
|
-
if (!dbUser && roles
|
|
8494
|
+
if (!dbUser && (roles == null ? void 0 : roles.length)) {
|
|
8453
8495
|
builtUser.roles = { ...roles };
|
|
8454
8496
|
}
|
|
8455
8497
|
let groupPromises = [];
|
|
@@ -8728,8 +8770,8 @@ var identifyUser = async (user, account, timestamp) => {
|
|
|
8728
8770
|
if (isSSOUser(user)) {
|
|
8729
8771
|
providerType = user.providerType;
|
|
8730
8772
|
}
|
|
8731
|
-
const accountHolder = account
|
|
8732
|
-
const verified2 = account && account
|
|
8773
|
+
const accountHolder = (account == null ? void 0 : account.budibaseUserId) === user._id || false;
|
|
8774
|
+
const verified2 = account && (account == null ? void 0 : account.budibaseUserId) === user._id ? account.verified : false;
|
|
8733
8775
|
const installationId = await getInstallationId();
|
|
8734
8776
|
const hosting = account ? account.hosting : getHostingFromEnv();
|
|
8735
8777
|
const environment2 = getDeploymentEnvironment();
|
|
@@ -8888,7 +8930,7 @@ var clearEvents = async () => {
|
|
|
8888
8930
|
};
|
|
8889
8931
|
var isBackfillingEvent = async (event) => {
|
|
8890
8932
|
const backfill = await getBackfillMetadata();
|
|
8891
|
-
const events2 = backfill
|
|
8933
|
+
const events2 = backfill == null ? void 0 : backfill.eventWhitelist;
|
|
8892
8934
|
if (events2 && events2.includes(event)) {
|
|
8893
8935
|
return true;
|
|
8894
8936
|
} else {
|
|
@@ -9232,11 +9274,12 @@ var auth_default = {
|
|
|
9232
9274
|
// src/events/publishers/automation.ts
|
|
9233
9275
|
init_src();
|
|
9234
9276
|
async function created3(automation, timestamp) {
|
|
9277
|
+
var _a, _b, _c, _d;
|
|
9235
9278
|
const properties = {
|
|
9236
9279
|
appId: automation.appId,
|
|
9237
9280
|
automationId: automation._id,
|
|
9238
|
-
triggerId: automation.definition
|
|
9239
|
-
triggerType: automation.definition
|
|
9281
|
+
triggerId: (_b = (_a = automation.definition) == null ? void 0 : _a.trigger) == null ? void 0 : _b.id,
|
|
9282
|
+
triggerType: (_d = (_c = automation.definition) == null ? void 0 : _c.trigger) == null ? void 0 : _d.stepId,
|
|
9240
9283
|
audited: {
|
|
9241
9284
|
name: automation.name
|
|
9242
9285
|
}
|
|
@@ -9244,20 +9287,22 @@ async function created3(automation, timestamp) {
|
|
|
9244
9287
|
await publishEvent("automation:created" /* AUTOMATION_CREATED */, properties, timestamp);
|
|
9245
9288
|
}
|
|
9246
9289
|
async function triggerUpdated(automation) {
|
|
9290
|
+
var _a, _b, _c, _d;
|
|
9247
9291
|
const properties = {
|
|
9248
9292
|
appId: automation.appId,
|
|
9249
9293
|
automationId: automation._id,
|
|
9250
|
-
triggerId: automation.definition
|
|
9251
|
-
triggerType: automation.definition
|
|
9294
|
+
triggerId: (_b = (_a = automation.definition) == null ? void 0 : _a.trigger) == null ? void 0 : _b.id,
|
|
9295
|
+
triggerType: (_d = (_c = automation.definition) == null ? void 0 : _c.trigger) == null ? void 0 : _d.stepId
|
|
9252
9296
|
};
|
|
9253
9297
|
await publishEvent("automation:trigger:updated" /* AUTOMATION_TRIGGER_UPDATED */, properties);
|
|
9254
9298
|
}
|
|
9255
9299
|
async function deleted3(automation) {
|
|
9300
|
+
var _a, _b, _c, _d;
|
|
9256
9301
|
const properties = {
|
|
9257
9302
|
appId: automation.appId,
|
|
9258
9303
|
automationId: automation._id,
|
|
9259
|
-
triggerId: automation.definition
|
|
9260
|
-
triggerType: automation.definition
|
|
9304
|
+
triggerId: (_b = (_a = automation.definition) == null ? void 0 : _a.trigger) == null ? void 0 : _b.id,
|
|
9305
|
+
triggerType: (_d = (_c = automation.definition) == null ? void 0 : _c.trigger) == null ? void 0 : _d.stepId,
|
|
9261
9306
|
audited: {
|
|
9262
9307
|
name: automation.name
|
|
9263
9308
|
}
|
|
@@ -9265,11 +9310,12 @@ async function deleted3(automation) {
|
|
|
9265
9310
|
await publishEvent("automation:deleted" /* AUTOMATION_DELETED */, properties);
|
|
9266
9311
|
}
|
|
9267
9312
|
async function tested(automation) {
|
|
9313
|
+
var _a, _b, _c, _d;
|
|
9268
9314
|
const properties = {
|
|
9269
9315
|
appId: automation.appId,
|
|
9270
9316
|
automationId: automation._id,
|
|
9271
|
-
triggerId: automation.definition
|
|
9272
|
-
triggerType: automation.definition
|
|
9317
|
+
triggerId: (_b = (_a = automation.definition) == null ? void 0 : _a.trigger) == null ? void 0 : _b.id,
|
|
9318
|
+
triggerType: (_d = (_c = automation.definition) == null ? void 0 : _c.trigger) == null ? void 0 : _d.stepId
|
|
9273
9319
|
};
|
|
9274
9320
|
await publishEvent("automation:tested" /* AUTOMATION_TESTED */, properties);
|
|
9275
9321
|
}
|
|
@@ -9280,11 +9326,12 @@ var run = async (count, timestamp) => {
|
|
|
9280
9326
|
await publishEvent("automations:run" /* AUTOMATIONS_RUN */, properties, timestamp);
|
|
9281
9327
|
};
|
|
9282
9328
|
async function stepCreated(automation, step, timestamp) {
|
|
9329
|
+
var _a, _b, _c, _d;
|
|
9283
9330
|
const properties = {
|
|
9284
9331
|
appId: automation.appId,
|
|
9285
9332
|
automationId: automation._id,
|
|
9286
|
-
triggerId: automation.definition
|
|
9287
|
-
triggerType: automation.definition
|
|
9333
|
+
triggerId: (_b = (_a = automation.definition) == null ? void 0 : _a.trigger) == null ? void 0 : _b.id,
|
|
9334
|
+
triggerType: (_d = (_c = automation.definition) == null ? void 0 : _c.trigger) == null ? void 0 : _d.stepId,
|
|
9288
9335
|
stepId: step.id,
|
|
9289
9336
|
stepType: step.stepId,
|
|
9290
9337
|
audited: {
|
|
@@ -9294,11 +9341,12 @@ async function stepCreated(automation, step, timestamp) {
|
|
|
9294
9341
|
await publishEvent("automation:step:created" /* AUTOMATION_STEP_CREATED */, properties, timestamp);
|
|
9295
9342
|
}
|
|
9296
9343
|
async function stepDeleted(automation, step) {
|
|
9344
|
+
var _a, _b, _c, _d;
|
|
9297
9345
|
const properties = {
|
|
9298
9346
|
appId: automation.appId,
|
|
9299
9347
|
automationId: automation._id,
|
|
9300
|
-
triggerId: automation.definition
|
|
9301
|
-
triggerType: automation.definition
|
|
9348
|
+
triggerId: (_b = (_a = automation.definition) == null ? void 0 : _a.trigger) == null ? void 0 : _b.id,
|
|
9349
|
+
triggerType: (_d = (_c = automation.definition) == null ? void 0 : _c.trigger) == null ? void 0 : _d.stepId,
|
|
9302
9350
|
stepId: step.id,
|
|
9303
9351
|
stepType: step.stepId,
|
|
9304
9352
|
audited: {
|
|
@@ -9585,23 +9633,25 @@ var role_default = {
|
|
|
9585
9633
|
// src/events/publishers/screen.ts
|
|
9586
9634
|
init_src();
|
|
9587
9635
|
async function created8(screen, timestamp) {
|
|
9636
|
+
var _a;
|
|
9588
9637
|
const properties = {
|
|
9589
9638
|
layoutId: screen.layoutId,
|
|
9590
9639
|
screenId: screen._id,
|
|
9591
9640
|
roleId: screen.routing.roleId,
|
|
9592
9641
|
audited: {
|
|
9593
|
-
name: screen.routing
|
|
9642
|
+
name: (_a = screen.routing) == null ? void 0 : _a.route
|
|
9594
9643
|
}
|
|
9595
9644
|
};
|
|
9596
9645
|
await publishEvent("screen:created" /* SCREEN_CREATED */, properties, timestamp);
|
|
9597
9646
|
}
|
|
9598
9647
|
async function deleted8(screen) {
|
|
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:deleted" /* SCREEN_DELETED */, properties);
|
|
@@ -10672,7 +10722,7 @@ var BUILTIN_ROLE_NAME_ARRAY = Object.values(BUILTIN_ROLES).map(
|
|
|
10672
10722
|
(role) => role.name
|
|
10673
10723
|
);
|
|
10674
10724
|
function isBuiltin(role) {
|
|
10675
|
-
return BUILTIN_ROLE_ID_ARRAY.some((builtin) => role
|
|
10725
|
+
return BUILTIN_ROLE_ID_ARRAY.some((builtin) => role == null ? void 0 : role.includes(builtin));
|
|
10676
10726
|
}
|
|
10677
10727
|
function builtinRoleToNumber(id) {
|
|
10678
10728
|
if (!id) {
|
|
@@ -10699,7 +10749,7 @@ async function roleToNumber(id) {
|
|
|
10699
10749
|
}
|
|
10700
10750
|
const hierarchy = await getUserRoleHierarchy(id);
|
|
10701
10751
|
for (let role of hierarchy) {
|
|
10702
|
-
if (isBuiltin(role
|
|
10752
|
+
if (isBuiltin(role == null ? void 0 : role.inherits)) {
|
|
10703
10753
|
return builtinRoleToNumber(role.inherits) + 1;
|
|
10704
10754
|
}
|
|
10705
10755
|
}
|
|
@@ -10732,7 +10782,7 @@ async function getRole(roleId, opts) {
|
|
|
10732
10782
|
role = Object.assign(role, dbRole);
|
|
10733
10783
|
role._id = getExternalRoleID(role._id, role.version);
|
|
10734
10784
|
} catch (err) {
|
|
10735
|
-
if (!isBuiltin(roleId) && opts
|
|
10785
|
+
if (!isBuiltin(roleId) && (opts == null ? void 0 : opts.defaultPublic)) {
|
|
10736
10786
|
return (0, import_cloneDeep2.default)(BUILTIN_ROLES.PUBLIC);
|
|
10737
10787
|
}
|
|
10738
10788
|
if (Object.keys(role).length === 0) {
|
|
@@ -10855,7 +10905,7 @@ var AccessController = class {
|
|
|
10855
10905
|
});
|
|
10856
10906
|
this.userHierarchies[userRoleId] = roleIds;
|
|
10857
10907
|
}
|
|
10858
|
-
return roleIds
|
|
10908
|
+
return (roleIds == null ? void 0 : roleIds.indexOf(tryingRoleId)) !== -1;
|
|
10859
10909
|
}
|
|
10860
10910
|
async checkScreensAccess(screens, userRoleId) {
|
|
10861
10911
|
let accessibleScreens = [];
|
|
@@ -10876,7 +10926,7 @@ var AccessController = class {
|
|
|
10876
10926
|
}
|
|
10877
10927
|
};
|
|
10878
10928
|
function getDBRoleID(roleName) {
|
|
10879
|
-
if (roleName
|
|
10929
|
+
if (roleName == null ? void 0 : roleName.startsWith("role" /* ROLE */)) {
|
|
10880
10930
|
return roleName;
|
|
10881
10931
|
}
|
|
10882
10932
|
return prefixRoleID(roleName);
|
|
@@ -11135,7 +11185,8 @@ async function authenticate2(details, requireLocalAccount = true, done, saveUser
|
|
|
11135
11185
|
return done(null, ssoUser);
|
|
11136
11186
|
}
|
|
11137
11187
|
async function getProfilePictureUrl(user, details) {
|
|
11138
|
-
|
|
11188
|
+
var _a;
|
|
11189
|
+
const pictureUrl = (_a = details.profile) == null ? void 0 : _a._json.picture;
|
|
11139
11190
|
if (pictureUrl) {
|
|
11140
11191
|
const response = await (0, import_node_fetch5.default)(pictureUrl);
|
|
11141
11192
|
if (response.status === 200) {
|
|
@@ -11666,7 +11717,7 @@ function authenticated_default(noAuthPatterns = [], opts = {
|
|
|
11666
11717
|
user = await getUser(userId, session.tenantId);
|
|
11667
11718
|
}
|
|
11668
11719
|
user.csrfToken = session.csrfToken;
|
|
11669
|
-
if (session
|
|
11720
|
+
if ((session == null ? void 0 : session.lastAccessedAt) < timeMinusOneMinute()) {
|
|
11670
11721
|
await updateSessionTTL(session);
|
|
11671
11722
|
}
|
|
11672
11723
|
authenticated = true;
|
|
@@ -11708,9 +11759,9 @@ function authenticated_default(noAuthPatterns = [], opts = {
|
|
|
11708
11759
|
} catch (err) {
|
|
11709
11760
|
console.error(`Auth Error: ${err.message}`);
|
|
11710
11761
|
console.error(err);
|
|
11711
|
-
if (err
|
|
11762
|
+
if ((err == null ? void 0 : err.name) === "JsonWebTokenError") {
|
|
11712
11763
|
clearCookie(ctx, "budibase:auth" /* Auth */);
|
|
11713
|
-
} else if (err
|
|
11764
|
+
} else if ((err == null ? void 0 : err.code) === "invalid_api_key" /* INVALID_API_KEY */) {
|
|
11714
11765
|
ctx.throw(403, err.message);
|
|
11715
11766
|
}
|
|
11716
11767
|
if (opts && opts.publicAllowed || publicEndpoint) {
|
|
@@ -11777,6 +11828,7 @@ var INCLUDED_CONTENT_TYPES = [
|
|
|
11777
11828
|
function csrf_default(opts = { noCsrfPatterns: [] }) {
|
|
11778
11829
|
const noCsrfOptions = buildMatcherRegex(opts.noCsrfPatterns);
|
|
11779
11830
|
return async (ctx, next) => {
|
|
11831
|
+
var _a;
|
|
11780
11832
|
const found = matches(ctx, noCsrfOptions);
|
|
11781
11833
|
if (found) {
|
|
11782
11834
|
return next();
|
|
@@ -11791,7 +11843,7 @@ function csrf_default(opts = { noCsrfPatterns: [] }) {
|
|
|
11791
11843
|
if (ctx.internal) {
|
|
11792
11844
|
return next();
|
|
11793
11845
|
}
|
|
11794
|
-
const userToken = ctx.user
|
|
11846
|
+
const userToken = (_a = ctx.user) == null ? void 0 : _a.csrfToken;
|
|
11795
11847
|
if (!userToken) {
|
|
11796
11848
|
return next();
|
|
11797
11849
|
}
|
|
@@ -11851,7 +11903,10 @@ function pinoSettings() {
|
|
|
11851
11903
|
logger,
|
|
11852
11904
|
genReqId: correlator2.getId,
|
|
11853
11905
|
autoLogging: {
|
|
11854
|
-
ignore: (req) =>
|
|
11906
|
+
ignore: (req) => {
|
|
11907
|
+
var _a;
|
|
11908
|
+
return !!((_a = req.url) == null ? void 0 : _a.includes("/health"));
|
|
11909
|
+
}
|
|
11855
11910
|
},
|
|
11856
11911
|
serializers: {
|
|
11857
11912
|
req: (req) => {
|
|
@@ -11922,7 +11977,8 @@ var errorHandling_default = errorHandling;
|
|
|
11922
11977
|
|
|
11923
11978
|
// src/middleware/querystringToBody.ts
|
|
11924
11979
|
function querystringToBody_default(ctx, next) {
|
|
11925
|
-
|
|
11980
|
+
var _a;
|
|
11981
|
+
const queryString = (_a = ctx.request.query) == null ? void 0 : _a.query;
|
|
11926
11982
|
if (ctx.request.method.toLowerCase() !== "get") {
|
|
11927
11983
|
ctx.throw(
|
|
11928
11984
|
500,
|
|
@@ -11952,11 +12008,12 @@ __export(joi_validator_exports, {
|
|
|
11952
12008
|
var import_joi = __toESM(require("joi"));
|
|
11953
12009
|
function validate(schema, property) {
|
|
11954
12010
|
return (ctx, next) => {
|
|
12011
|
+
var _a;
|
|
11955
12012
|
if (!schema) {
|
|
11956
12013
|
return next();
|
|
11957
12014
|
}
|
|
11958
12015
|
let params2 = null;
|
|
11959
|
-
let reqProp = ctx.request
|
|
12016
|
+
let reqProp = (_a = ctx.request) == null ? void 0 : _a[property];
|
|
11960
12017
|
if (ctx[property] != null) {
|
|
11961
12018
|
params2 = ctx[property];
|
|
11962
12019
|
} else if (reqProp != null) {
|
|
@@ -12095,6 +12152,7 @@ async function updateUserOAuth(userId, oAuthConfig) {
|
|
|
12095
12152
|
}
|
|
12096
12153
|
}
|
|
12097
12154
|
async function platformLogout(opts) {
|
|
12155
|
+
var _a;
|
|
12098
12156
|
const ctx = opts.ctx;
|
|
12099
12157
|
const userId = opts.userId;
|
|
12100
12158
|
const keepActiveSession = opts.keepActiveSession;
|
|
@@ -12111,7 +12169,7 @@ async function platformLogout(opts) {
|
|
|
12111
12169
|
}
|
|
12112
12170
|
const sessionIds = sessions.map(({ sessionId }) => sessionId);
|
|
12113
12171
|
await invalidateSessions(userId, { sessionIds, reason: "logout" });
|
|
12114
|
-
await auth_default.logout(ctx.user
|
|
12172
|
+
await auth_default.logout((_a = ctx.user) == null ? void 0 : _a.email);
|
|
12115
12173
|
await invalidateUser(userId);
|
|
12116
12174
|
}
|
|
12117
12175
|
|
|
@@ -12227,7 +12285,7 @@ function validateAutomation(schema) {
|
|
|
12227
12285
|
runJoi(validator, schema);
|
|
12228
12286
|
}
|
|
12229
12287
|
function validate2(schema) {
|
|
12230
|
-
switch (schema
|
|
12288
|
+
switch (schema == null ? void 0 : schema.type) {
|
|
12231
12289
|
case "component" /* COMPONENT */:
|
|
12232
12290
|
validateComponent(schema);
|
|
12233
12291
|
break;
|
|
@@ -12291,7 +12349,7 @@ async function lookup(address) {
|
|
|
12291
12349
|
}
|
|
12292
12350
|
async function refreshBlacklist() {
|
|
12293
12351
|
const blacklist = environment_default.BLACKLIST_IPS;
|
|
12294
|
-
const list = blacklist
|
|
12352
|
+
const list = (blacklist == null ? void 0 : blacklist.split(",")) || [];
|
|
12295
12353
|
let final = [];
|
|
12296
12354
|
for (let addr of list) {
|
|
12297
12355
|
const trimmed = addr.trim();
|
|
@@ -12308,7 +12366,7 @@ async function isBlacklisted(address) {
|
|
|
12308
12366
|
if (!blackListArray) {
|
|
12309
12367
|
await refreshBlacklist();
|
|
12310
12368
|
}
|
|
12311
|
-
if (blackListArray
|
|
12369
|
+
if ((blackListArray == null ? void 0 : blackListArray.length) === 0) {
|
|
12312
12370
|
return false;
|
|
12313
12371
|
}
|
|
12314
12372
|
let ips;
|
|
@@ -12317,7 +12375,7 @@ async function isBlacklisted(address) {
|
|
|
12317
12375
|
} else {
|
|
12318
12376
|
ips = [address];
|
|
12319
12377
|
}
|
|
12320
|
-
return !!blackListArray
|
|
12378
|
+
return !!(blackListArray == null ? void 0 : blackListArray.find((addr) => ips.includes(addr)));
|
|
12321
12379
|
}
|
|
12322
12380
|
|
|
12323
12381
|
// src/docUpdates/index.ts
|