@budibase/backend-core 2.9.30-alpha.0 → 2.9.30-alpha.2
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 +292 -339
- package/dist/index.js.map +4 -4
- package/dist/index.js.meta.json +1 -1
- package/dist/package.json +4 -4
- package/dist/plugins.js +1 -1
- package/dist/plugins.js.map +2 -2
- package/dist/plugins.js.meta.json +1 -1
- package/dist/src/{featureFlags → features}/index.d.ts +1 -0
- package/dist/src/features/installation.d.ts +1 -0
- package/dist/src/index.d.ts +2 -1
- package/dist/tests.js +217 -264
- package/dist/tests.js.map +4 -4
- package/dist/tests.js.meta.json +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -29,28 +29,6 @@ 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
|
-
};
|
|
54
32
|
|
|
55
33
|
// ../types/src/sdk/automations/index.ts
|
|
56
34
|
var init_automations = __esm({
|
|
@@ -705,13 +683,19 @@ var init_permissions = __esm({
|
|
|
705
683
|
PermissionType2["WEBHOOK"] = "webhook";
|
|
706
684
|
PermissionType2["BUILDER"] = "builder";
|
|
707
685
|
PermissionType2["GLOBAL_BUILDER"] = "globalBuilder";
|
|
708
|
-
PermissionType2["VIEW"] = "view";
|
|
709
686
|
PermissionType2["QUERY"] = "query";
|
|
710
687
|
return PermissionType2;
|
|
711
688
|
})(PermissionType || {});
|
|
712
689
|
}
|
|
713
690
|
});
|
|
714
691
|
|
|
692
|
+
// ../types/src/sdk/row.ts
|
|
693
|
+
var init_row = __esm({
|
|
694
|
+
"../types/src/sdk/row.ts"() {
|
|
695
|
+
"use strict";
|
|
696
|
+
}
|
|
697
|
+
});
|
|
698
|
+
|
|
715
699
|
// ../types/src/sdk/index.ts
|
|
716
700
|
var init_sdk = __esm({
|
|
717
701
|
"../types/src/sdk/index.ts"() {
|
|
@@ -737,6 +721,7 @@ var init_sdk = __esm({
|
|
|
737
721
|
init_cli();
|
|
738
722
|
init_websocket();
|
|
739
723
|
init_permissions();
|
|
724
|
+
init_row();
|
|
740
725
|
}
|
|
741
726
|
});
|
|
742
727
|
|
|
@@ -966,7 +951,7 @@ var init_document = __esm({
|
|
|
966
951
|
});
|
|
967
952
|
|
|
968
953
|
// ../types/src/documents/app/row.ts
|
|
969
|
-
var
|
|
954
|
+
var init_row2 = __esm({
|
|
970
955
|
"../types/src/documents/app/row.ts"() {
|
|
971
956
|
"use strict";
|
|
972
957
|
}
|
|
@@ -1021,7 +1006,7 @@ var init_app3 = __esm({
|
|
|
1021
1006
|
init_screen2();
|
|
1022
1007
|
init_view2();
|
|
1023
1008
|
init_document();
|
|
1024
|
-
|
|
1009
|
+
init_row2();
|
|
1025
1010
|
init_user4();
|
|
1026
1011
|
init_backup2();
|
|
1027
1012
|
init_webhook();
|
|
@@ -1301,7 +1286,7 @@ var init_datasource3 = __esm({
|
|
|
1301
1286
|
});
|
|
1302
1287
|
|
|
1303
1288
|
// ../types/src/api/web/app/row.ts
|
|
1304
|
-
var
|
|
1289
|
+
var init_row3 = __esm({
|
|
1305
1290
|
"../types/src/api/web/app/row.ts"() {
|
|
1306
1291
|
"use strict";
|
|
1307
1292
|
}
|
|
@@ -1334,7 +1319,7 @@ var init_app4 = __esm({
|
|
|
1334
1319
|
"use strict";
|
|
1335
1320
|
init_backup3();
|
|
1336
1321
|
init_datasource3();
|
|
1337
|
-
|
|
1322
|
+
init_row3();
|
|
1338
1323
|
init_view3();
|
|
1339
1324
|
init_rows2();
|
|
1340
1325
|
init_table4();
|
|
@@ -1880,12 +1865,15 @@ var init_environment2 = __esm({
|
|
|
1880
1865
|
});
|
|
1881
1866
|
|
|
1882
1867
|
// src/context/Context.ts
|
|
1883
|
-
var import_async_hooks,
|
|
1868
|
+
var import_async_hooks, Context;
|
|
1884
1869
|
var init_Context = __esm({
|
|
1885
1870
|
"src/context/Context.ts"() {
|
|
1886
1871
|
"use strict";
|
|
1887
1872
|
import_async_hooks = require("async_hooks");
|
|
1888
|
-
|
|
1873
|
+
Context = class _Context {
|
|
1874
|
+
static {
|
|
1875
|
+
this.storage = new import_async_hooks.AsyncLocalStorage();
|
|
1876
|
+
}
|
|
1889
1877
|
static run(context, func) {
|
|
1890
1878
|
return _Context.storage.run(context, () => func());
|
|
1891
1879
|
}
|
|
@@ -1893,8 +1881,6 @@ var init_Context = __esm({
|
|
|
1893
1881
|
return _Context.storage.getStore();
|
|
1894
1882
|
}
|
|
1895
1883
|
};
|
|
1896
|
-
_Context.storage = new import_async_hooks.AsyncLocalStorage();
|
|
1897
|
-
Context = _Context;
|
|
1898
1884
|
}
|
|
1899
1885
|
});
|
|
1900
1886
|
|
|
@@ -1936,7 +1922,7 @@ function getProdAppID(appId) {
|
|
|
1936
1922
|
return `${APP_PREFIX}${rest}`;
|
|
1937
1923
|
}
|
|
1938
1924
|
function extractAppUUID(id) {
|
|
1939
|
-
const split =
|
|
1925
|
+
const split = id?.split("_") || [];
|
|
1940
1926
|
return split.length ? split[split.length - 1] : null;
|
|
1941
1927
|
}
|
|
1942
1928
|
var NO_APP_ERROR, getDevAppID;
|
|
@@ -1956,18 +1942,17 @@ var init_connections = __esm({
|
|
|
1956
1942
|
"use strict";
|
|
1957
1943
|
init_environment2();
|
|
1958
1944
|
getCouchInfo = (connection) => {
|
|
1959
|
-
var _a, _b;
|
|
1960
1945
|
const urlInfo = getUrlInfo(connection);
|
|
1961
1946
|
let username;
|
|
1962
1947
|
let password;
|
|
1963
|
-
if (
|
|
1948
|
+
if (urlInfo.auth?.username) {
|
|
1964
1949
|
username = urlInfo.auth.username;
|
|
1965
1950
|
} else if (environment_default.COUCH_DB_USERNAME) {
|
|
1966
1951
|
username = environment_default.COUCH_DB_USERNAME;
|
|
1967
1952
|
} else if (!environment_default.isTest()) {
|
|
1968
1953
|
throw new Error("CouchDB username not set");
|
|
1969
1954
|
}
|
|
1970
|
-
if (
|
|
1955
|
+
if (urlInfo.auth?.password) {
|
|
1971
1956
|
password = urlInfo.auth.password;
|
|
1972
1957
|
} else if (environment_default.COUCH_DB_PASSWORD) {
|
|
1973
1958
|
password = environment_default.COUCH_DB_PASSWORD;
|
|
@@ -2226,8 +2211,7 @@ var init_DatabaseImpl = __esm({
|
|
|
2226
2211
|
return this.instanceNano || _DatabaseImpl.nano;
|
|
2227
2212
|
}
|
|
2228
2213
|
async checkSetup() {
|
|
2229
|
-
|
|
2230
|
-
let shouldCreate = !((_a = this.pouchOpts) == null ? void 0 : _a.skip_setup);
|
|
2214
|
+
let shouldCreate = !this.pouchOpts?.skip_setup;
|
|
2231
2215
|
let exists2 = await this.exists();
|
|
2232
2216
|
if (!shouldCreate && !exists2) {
|
|
2233
2217
|
throw new Error("DB does not exist");
|
|
@@ -2303,7 +2287,7 @@ var init_DatabaseImpl = __esm({
|
|
|
2303
2287
|
document.createdAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
2304
2288
|
}
|
|
2305
2289
|
document.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
2306
|
-
if (
|
|
2290
|
+
if (opts?.force && document._id) {
|
|
2307
2291
|
try {
|
|
2308
2292
|
const existing = await this.get(document._id);
|
|
2309
2293
|
if (existing) {
|
|
@@ -2467,7 +2451,7 @@ function isMultiTenant() {
|
|
|
2467
2451
|
}
|
|
2468
2452
|
function isTenantIdSet() {
|
|
2469
2453
|
const context = Context.get();
|
|
2470
|
-
return !!
|
|
2454
|
+
return !!context?.tenantId;
|
|
2471
2455
|
}
|
|
2472
2456
|
function isTenancyEnabled() {
|
|
2473
2457
|
return environment_default.MULTI_TENANCY;
|
|
@@ -2566,7 +2550,7 @@ async function doInIdentityContext(identity, task) {
|
|
|
2566
2550
|
function getIdentity() {
|
|
2567
2551
|
try {
|
|
2568
2552
|
const context = Context.get();
|
|
2569
|
-
return context
|
|
2553
|
+
return context?.identity;
|
|
2570
2554
|
} catch (e) {
|
|
2571
2555
|
}
|
|
2572
2556
|
}
|
|
@@ -2575,7 +2559,7 @@ function getTenantId() {
|
|
|
2575
2559
|
return DEFAULT_TENANT_ID;
|
|
2576
2560
|
}
|
|
2577
2561
|
const context = Context.get();
|
|
2578
|
-
const tenantId = context
|
|
2562
|
+
const tenantId = context?.tenantId;
|
|
2579
2563
|
if (!tenantId) {
|
|
2580
2564
|
throw new Error("Tenant id not found");
|
|
2581
2565
|
}
|
|
@@ -2583,11 +2567,11 @@ function getTenantId() {
|
|
|
2583
2567
|
}
|
|
2584
2568
|
function getAutomationId() {
|
|
2585
2569
|
const context = Context.get();
|
|
2586
|
-
return context
|
|
2570
|
+
return context?.automationId;
|
|
2587
2571
|
}
|
|
2588
2572
|
function getAppId() {
|
|
2589
2573
|
const context = Context.get();
|
|
2590
|
-
const foundId = context
|
|
2574
|
+
const foundId = context?.appId;
|
|
2591
2575
|
if (!foundId && environment_default.isTest() && TEST_APP_ID) {
|
|
2592
2576
|
return TEST_APP_ID;
|
|
2593
2577
|
} else {
|
|
@@ -2622,7 +2606,7 @@ function getGlobalDB() {
|
|
|
2622
2606
|
if (!context || environment_default.MULTI_TENANCY && !context.tenantId) {
|
|
2623
2607
|
throw new Error("Global DB not found");
|
|
2624
2608
|
}
|
|
2625
|
-
return getDB(baseGlobalDBName(context
|
|
2609
|
+
return getDB(baseGlobalDBName(context?.tenantId));
|
|
2626
2610
|
}
|
|
2627
2611
|
function getAuditLogsDB() {
|
|
2628
2612
|
if (!getTenantId()) {
|
|
@@ -2650,7 +2634,7 @@ function getDevAppDB(opts) {
|
|
|
2650
2634
|
}
|
|
2651
2635
|
function isScim() {
|
|
2652
2636
|
const context = Context.get();
|
|
2653
|
-
const scimCall = context
|
|
2637
|
+
const scimCall = context?.isScim;
|
|
2654
2638
|
return !!scimCall;
|
|
2655
2639
|
}
|
|
2656
2640
|
var TEST_APP_ID, getProdAppId;
|
|
@@ -3501,7 +3485,7 @@ function getGlobalUserParams(globalId, otherProps = {}) {
|
|
|
3501
3485
|
if (!globalId) {
|
|
3502
3486
|
globalId = "";
|
|
3503
3487
|
}
|
|
3504
|
-
const startkey = otherProps
|
|
3488
|
+
const startkey = otherProps?.startkey;
|
|
3505
3489
|
return {
|
|
3506
3490
|
...otherProps,
|
|
3507
3491
|
// need to include this incase pagination
|
|
@@ -3634,10 +3618,7 @@ async function getAllApps({
|
|
|
3634
3618
|
} else {
|
|
3635
3619
|
const response = await Promise.allSettled(appPromises);
|
|
3636
3620
|
const apps = response.filter(
|
|
3637
|
-
(result) =>
|
|
3638
|
-
var _a;
|
|
3639
|
-
return result.status === "fulfilled" && ((_a = result.value) == null ? void 0 : _a.state) !== "invalid" /* INVALID */;
|
|
3640
|
-
}
|
|
3621
|
+
(result) => result.status === "fulfilled" && result.value?.state !== "invalid" /* INVALID */
|
|
3641
3622
|
).map(({ value }) => value);
|
|
3642
3623
|
if (!all) {
|
|
3643
3624
|
return apps.filter((app) => {
|
|
@@ -3699,7 +3680,7 @@ function pagination(data, pageSize, {
|
|
|
3699
3680
|
const hasNextPage = data.length > pageSize;
|
|
3700
3681
|
let nextPage = void 0;
|
|
3701
3682
|
if (!getKey) {
|
|
3702
|
-
getKey = (doc) => property ? doc
|
|
3683
|
+
getKey = (doc) => property ? doc?.[property] : doc?._id;
|
|
3703
3684
|
}
|
|
3704
3685
|
if (hasNextPage) {
|
|
3705
3686
|
nextPage = getKey(data[pageSize]);
|
|
@@ -3850,7 +3831,7 @@ var init_views = __esm({
|
|
|
3850
3831
|
const docs = rows.map(
|
|
3851
3832
|
(row) => params2.include_docs ? row.doc : row.value
|
|
3852
3833
|
);
|
|
3853
|
-
if (opts
|
|
3834
|
+
if (opts?.arrayResponse) {
|
|
3854
3835
|
return docs;
|
|
3855
3836
|
} else {
|
|
3856
3837
|
return docs.length <= 1 ? docs[0] : docs;
|
|
@@ -4073,7 +4054,7 @@ async function fullSearch(dbName, index2, query, params2) {
|
|
|
4073
4054
|
const rows = await recursiveSearch(dbName, index2, query, params2);
|
|
4074
4055
|
return { rows };
|
|
4075
4056
|
}
|
|
4076
|
-
var import_node_fetch2, QUERY_START_REGEX,
|
|
4057
|
+
var import_node_fetch2, QUERY_START_REGEX, QueryBuilder;
|
|
4077
4058
|
var init_lucene = __esm({
|
|
4078
4059
|
"src/db/lucene.ts"() {
|
|
4079
4060
|
"use strict";
|
|
@@ -4081,31 +4062,27 @@ var init_lucene = __esm({
|
|
|
4081
4062
|
init_couch();
|
|
4082
4063
|
init_src();
|
|
4083
4064
|
QUERY_START_REGEX = /\d[0-9]*:/g;
|
|
4084
|
-
|
|
4065
|
+
QueryBuilder = class _QueryBuilder {
|
|
4066
|
+
#dbName;
|
|
4067
|
+
#index;
|
|
4068
|
+
#query;
|
|
4069
|
+
#limit;
|
|
4070
|
+
#sort;
|
|
4071
|
+
#bookmark;
|
|
4072
|
+
#sortOrder;
|
|
4073
|
+
#sortType;
|
|
4074
|
+
#includeDocs;
|
|
4075
|
+
#version;
|
|
4076
|
+
#indexBuilder;
|
|
4077
|
+
#noEscaping = false;
|
|
4078
|
+
#skip;
|
|
4079
|
+
static {
|
|
4080
|
+
this.maxLimit = 200;
|
|
4081
|
+
}
|
|
4085
4082
|
constructor(dbName, index2, base) {
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
* page has been met.
|
|
4090
|
-
*/
|
|
4091
|
-
__privateAdd(this, _skipItems);
|
|
4092
|
-
__privateAdd(this, _execute);
|
|
4093
|
-
__privateAdd(this, _dbName, void 0);
|
|
4094
|
-
__privateAdd(this, _index, void 0);
|
|
4095
|
-
__privateAdd(this, _query, void 0);
|
|
4096
|
-
__privateAdd(this, _limit, void 0);
|
|
4097
|
-
__privateAdd(this, _sort, void 0);
|
|
4098
|
-
__privateAdd(this, _bookmark, void 0);
|
|
4099
|
-
__privateAdd(this, _sortOrder, void 0);
|
|
4100
|
-
__privateAdd(this, _sortType, void 0);
|
|
4101
|
-
__privateAdd(this, _includeDocs, void 0);
|
|
4102
|
-
__privateAdd(this, _version, void 0);
|
|
4103
|
-
__privateAdd(this, _indexBuilder, void 0);
|
|
4104
|
-
__privateAdd(this, _noEscaping, false);
|
|
4105
|
-
__privateAdd(this, _skip, void 0);
|
|
4106
|
-
__privateSet(this, _dbName, dbName);
|
|
4107
|
-
__privateSet(this, _index, index2);
|
|
4108
|
-
__privateSet(this, _query, {
|
|
4083
|
+
this.#dbName = dbName;
|
|
4084
|
+
this.#index = index2;
|
|
4085
|
+
this.#query = {
|
|
4109
4086
|
allOr: false,
|
|
4110
4087
|
onEmptyFilter: "all" /* RETURN_ALL */,
|
|
4111
4088
|
string: {},
|
|
@@ -4120,127 +4097,127 @@ var init_lucene = __esm({
|
|
|
4120
4097
|
notContains: {},
|
|
4121
4098
|
containsAny: {},
|
|
4122
4099
|
...base
|
|
4123
|
-
}
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4100
|
+
};
|
|
4101
|
+
this.#limit = 50;
|
|
4102
|
+
this.#sortOrder = "ascending";
|
|
4103
|
+
this.#sortType = "string";
|
|
4104
|
+
this.#includeDocs = true;
|
|
4128
4105
|
}
|
|
4129
4106
|
disableEscaping() {
|
|
4130
|
-
|
|
4107
|
+
this.#noEscaping = true;
|
|
4131
4108
|
return this;
|
|
4132
4109
|
}
|
|
4133
4110
|
setIndexBuilder(builderFn) {
|
|
4134
|
-
|
|
4111
|
+
this.#indexBuilder = builderFn;
|
|
4135
4112
|
return this;
|
|
4136
4113
|
}
|
|
4137
4114
|
setVersion(version) {
|
|
4138
4115
|
if (version != null) {
|
|
4139
|
-
|
|
4116
|
+
this.#version = version;
|
|
4140
4117
|
}
|
|
4141
4118
|
return this;
|
|
4142
4119
|
}
|
|
4143
4120
|
setTable(tableId) {
|
|
4144
|
-
|
|
4121
|
+
this.#query.equal.tableId = tableId;
|
|
4145
4122
|
return this;
|
|
4146
4123
|
}
|
|
4147
4124
|
setLimit(limit) {
|
|
4148
4125
|
if (limit != null) {
|
|
4149
|
-
|
|
4126
|
+
this.#limit = limit;
|
|
4150
4127
|
}
|
|
4151
4128
|
return this;
|
|
4152
4129
|
}
|
|
4153
4130
|
setSort(sort) {
|
|
4154
4131
|
if (sort != null) {
|
|
4155
|
-
|
|
4132
|
+
this.#sort = sort;
|
|
4156
4133
|
}
|
|
4157
4134
|
return this;
|
|
4158
4135
|
}
|
|
4159
4136
|
setSortOrder(sortOrder) {
|
|
4160
4137
|
if (sortOrder != null) {
|
|
4161
|
-
|
|
4138
|
+
this.#sortOrder = sortOrder;
|
|
4162
4139
|
}
|
|
4163
4140
|
return this;
|
|
4164
4141
|
}
|
|
4165
4142
|
setSortType(sortType) {
|
|
4166
4143
|
if (sortType != null) {
|
|
4167
|
-
|
|
4144
|
+
this.#sortType = sortType;
|
|
4168
4145
|
}
|
|
4169
4146
|
return this;
|
|
4170
4147
|
}
|
|
4171
4148
|
setBookmark(bookmark) {
|
|
4172
4149
|
if (bookmark != null) {
|
|
4173
|
-
|
|
4150
|
+
this.#bookmark = bookmark;
|
|
4174
4151
|
}
|
|
4175
4152
|
return this;
|
|
4176
4153
|
}
|
|
4177
4154
|
setSkip(skip) {
|
|
4178
|
-
|
|
4155
|
+
this.#skip = skip;
|
|
4179
4156
|
return this;
|
|
4180
4157
|
}
|
|
4181
4158
|
excludeDocs() {
|
|
4182
|
-
|
|
4159
|
+
this.#includeDocs = false;
|
|
4183
4160
|
return this;
|
|
4184
4161
|
}
|
|
4185
4162
|
includeDocs() {
|
|
4186
|
-
|
|
4163
|
+
this.#includeDocs = true;
|
|
4187
4164
|
return this;
|
|
4188
4165
|
}
|
|
4189
4166
|
addString(key, partial) {
|
|
4190
|
-
|
|
4167
|
+
this.#query.string[key] = partial;
|
|
4191
4168
|
return this;
|
|
4192
4169
|
}
|
|
4193
4170
|
addFuzzy(key, fuzzy) {
|
|
4194
|
-
|
|
4171
|
+
this.#query.fuzzy[key] = fuzzy;
|
|
4195
4172
|
return this;
|
|
4196
4173
|
}
|
|
4197
4174
|
addRange(key, low, high) {
|
|
4198
|
-
|
|
4175
|
+
this.#query.range[key] = {
|
|
4199
4176
|
low,
|
|
4200
4177
|
high
|
|
4201
4178
|
};
|
|
4202
4179
|
return this;
|
|
4203
4180
|
}
|
|
4204
4181
|
addEqual(key, value) {
|
|
4205
|
-
|
|
4182
|
+
this.#query.equal[key] = value;
|
|
4206
4183
|
return this;
|
|
4207
4184
|
}
|
|
4208
4185
|
addNotEqual(key, value) {
|
|
4209
|
-
|
|
4186
|
+
this.#query.notEqual[key] = value;
|
|
4210
4187
|
return this;
|
|
4211
4188
|
}
|
|
4212
4189
|
addEmpty(key, value) {
|
|
4213
|
-
|
|
4190
|
+
this.#query.empty[key] = value;
|
|
4214
4191
|
return this;
|
|
4215
4192
|
}
|
|
4216
4193
|
addNotEmpty(key, value) {
|
|
4217
|
-
|
|
4194
|
+
this.#query.notEmpty[key] = value;
|
|
4218
4195
|
return this;
|
|
4219
4196
|
}
|
|
4220
4197
|
addOneOf(key, value) {
|
|
4221
|
-
|
|
4198
|
+
this.#query.oneOf[key] = value;
|
|
4222
4199
|
return this;
|
|
4223
4200
|
}
|
|
4224
4201
|
addContains(key, value) {
|
|
4225
|
-
|
|
4202
|
+
this.#query.contains[key] = value;
|
|
4226
4203
|
return this;
|
|
4227
4204
|
}
|
|
4228
4205
|
addNotContains(key, value) {
|
|
4229
|
-
|
|
4206
|
+
this.#query.notContains[key] = value;
|
|
4230
4207
|
return this;
|
|
4231
4208
|
}
|
|
4232
4209
|
addContainsAny(key, value) {
|
|
4233
|
-
|
|
4210
|
+
this.#query.containsAny[key] = value;
|
|
4234
4211
|
return this;
|
|
4235
4212
|
}
|
|
4236
4213
|
setAllOr() {
|
|
4237
|
-
|
|
4214
|
+
this.#query.allOr = true;
|
|
4238
4215
|
}
|
|
4239
4216
|
setOnEmptyFilter(value) {
|
|
4240
|
-
|
|
4217
|
+
this.#query.onEmptyFilter = value;
|
|
4241
4218
|
}
|
|
4242
4219
|
handleSpaces(input) {
|
|
4243
|
-
if (
|
|
4220
|
+
if (this.#noEscaping) {
|
|
4244
4221
|
return input;
|
|
4245
4222
|
} else {
|
|
4246
4223
|
return input.replace(/ /g, "_");
|
|
@@ -4254,12 +4231,12 @@ var init_lucene = __esm({
|
|
|
4254
4231
|
* @returns {string|*}
|
|
4255
4232
|
*/
|
|
4256
4233
|
preprocess(value, { escape, lowercase, wrap, type } = {}) {
|
|
4257
|
-
const hasVersion = !!
|
|
4234
|
+
const hasVersion = !!this.#version;
|
|
4258
4235
|
const originalType = typeof value;
|
|
4259
4236
|
if (value && lowercase) {
|
|
4260
4237
|
value = value.toLowerCase ? value.toLowerCase() : value;
|
|
4261
4238
|
}
|
|
4262
|
-
if (!
|
|
4239
|
+
if (!this.#noEscaping && escape && originalType === "string") {
|
|
4263
4240
|
value = `${value}`.replace(/[ \/#+\-&|!(){}\]^"~*?:\\]/g, "\\$&");
|
|
4264
4241
|
}
|
|
4265
4242
|
if (originalType === "string" && !isNaN(value) && !type) {
|
|
@@ -4271,7 +4248,7 @@ var init_lucene = __esm({
|
|
|
4271
4248
|
}
|
|
4272
4249
|
isMultiCondition() {
|
|
4273
4250
|
let count = 0;
|
|
4274
|
-
for (let filters of Object.values(
|
|
4251
|
+
for (let filters of Object.values(this.#query)) {
|
|
4275
4252
|
if (typeof filters === "object") {
|
|
4276
4253
|
count += Object.keys(filters).length;
|
|
4277
4254
|
}
|
|
@@ -4296,16 +4273,15 @@ var init_lucene = __esm({
|
|
|
4296
4273
|
return final;
|
|
4297
4274
|
}
|
|
4298
4275
|
buildSearchQuery() {
|
|
4299
|
-
var _a;
|
|
4300
4276
|
const builder = this;
|
|
4301
|
-
let allOr =
|
|
4277
|
+
let allOr = this.#query && this.#query.allOr;
|
|
4302
4278
|
let query = allOr ? "" : "*:*";
|
|
4303
4279
|
let allFiltersEmpty = true;
|
|
4304
4280
|
const allPreProcessingOpts = { escape: true, lowercase: true, wrap: true };
|
|
4305
4281
|
let tableId = "";
|
|
4306
|
-
if (
|
|
4307
|
-
tableId =
|
|
4308
|
-
delete
|
|
4282
|
+
if (this.#query.equal.tableId) {
|
|
4283
|
+
tableId = this.#query.equal.tableId;
|
|
4284
|
+
delete this.#query.equal.tableId;
|
|
4309
4285
|
}
|
|
4310
4286
|
const equal = (key, value) => {
|
|
4311
4287
|
if (!value && value !== 0) {
|
|
@@ -4379,7 +4355,7 @@ var init_lucene = __esm({
|
|
|
4379
4355
|
continue;
|
|
4380
4356
|
}
|
|
4381
4357
|
if (built.length > 0 || query.length > 0) {
|
|
4382
|
-
const mode =
|
|
4358
|
+
const mode = opts?.mode ? opts.mode : allOr ? "OR" : "AND";
|
|
4383
4359
|
built += ` ${mode} `;
|
|
4384
4360
|
}
|
|
4385
4361
|
built += expression;
|
|
@@ -4387,14 +4363,14 @@ var init_lucene = __esm({
|
|
|
4387
4363
|
allFiltersEmpty = false;
|
|
4388
4364
|
}
|
|
4389
4365
|
}
|
|
4390
|
-
if (opts
|
|
4366
|
+
if (opts?.returnBuilt) {
|
|
4391
4367
|
return built;
|
|
4392
4368
|
} else {
|
|
4393
4369
|
query += built;
|
|
4394
4370
|
}
|
|
4395
4371
|
}
|
|
4396
|
-
if (
|
|
4397
|
-
build(
|
|
4372
|
+
if (this.#query.string) {
|
|
4373
|
+
build(this.#query.string, (key, value) => {
|
|
4398
4374
|
if (!value) {
|
|
4399
4375
|
return null;
|
|
4400
4376
|
}
|
|
@@ -4406,8 +4382,8 @@ var init_lucene = __esm({
|
|
|
4406
4382
|
return `${key}:${value}*`;
|
|
4407
4383
|
});
|
|
4408
4384
|
}
|
|
4409
|
-
if (
|
|
4410
|
-
build(
|
|
4385
|
+
if (this.#query.range) {
|
|
4386
|
+
build(this.#query.range, (key, value) => {
|
|
4411
4387
|
if (!value) {
|
|
4412
4388
|
return null;
|
|
4413
4389
|
}
|
|
@@ -4422,14 +4398,14 @@ var init_lucene = __esm({
|
|
|
4422
4398
|
return `${key}:[${low} TO ${high}]`;
|
|
4423
4399
|
});
|
|
4424
4400
|
}
|
|
4425
|
-
if (
|
|
4426
|
-
build(
|
|
4401
|
+
if (this.#query.fuzzy) {
|
|
4402
|
+
build(this.#query.fuzzy, fuzzy);
|
|
4427
4403
|
}
|
|
4428
|
-
if (
|
|
4429
|
-
build(
|
|
4404
|
+
if (this.#query.equal) {
|
|
4405
|
+
build(this.#query.equal, equal);
|
|
4430
4406
|
}
|
|
4431
|
-
if (
|
|
4432
|
-
build(
|
|
4407
|
+
if (this.#query.notEqual) {
|
|
4408
|
+
build(this.#query.notEqual, (key, value) => {
|
|
4433
4409
|
if (!value) {
|
|
4434
4410
|
return null;
|
|
4435
4411
|
}
|
|
@@ -4439,23 +4415,23 @@ var init_lucene = __esm({
|
|
|
4439
4415
|
return `!${key}:${builder.preprocess(value, allPreProcessingOpts)}`;
|
|
4440
4416
|
});
|
|
4441
4417
|
}
|
|
4442
|
-
if (
|
|
4443
|
-
build(
|
|
4418
|
+
if (this.#query.empty) {
|
|
4419
|
+
build(this.#query.empty, (key) => `(*:* -${key}:["" TO *])`);
|
|
4444
4420
|
}
|
|
4445
|
-
if (
|
|
4446
|
-
build(
|
|
4421
|
+
if (this.#query.notEmpty) {
|
|
4422
|
+
build(this.#query.notEmpty, (key) => `${key}:["" TO *]`);
|
|
4447
4423
|
}
|
|
4448
|
-
if (
|
|
4449
|
-
build(
|
|
4424
|
+
if (this.#query.oneOf) {
|
|
4425
|
+
build(this.#query.oneOf, oneOf);
|
|
4450
4426
|
}
|
|
4451
|
-
if (
|
|
4452
|
-
build(
|
|
4427
|
+
if (this.#query.contains) {
|
|
4428
|
+
build(this.#query.contains, contains);
|
|
4453
4429
|
}
|
|
4454
|
-
if (
|
|
4455
|
-
build(this.compressFilters(
|
|
4430
|
+
if (this.#query.notContains) {
|
|
4431
|
+
build(this.compressFilters(this.#query.notContains), notContains);
|
|
4456
4432
|
}
|
|
4457
|
-
if (
|
|
4458
|
-
build(
|
|
4433
|
+
if (this.#query.containsAny) {
|
|
4434
|
+
build(this.#query.containsAny, containsAny);
|
|
4459
4435
|
}
|
|
4460
4436
|
if (tableId) {
|
|
4461
4437
|
query = this.isMultiCondition() ? `(${query})` : query;
|
|
@@ -4463,9 +4439,9 @@ var init_lucene = __esm({
|
|
|
4463
4439
|
build({ tableId }, equal);
|
|
4464
4440
|
}
|
|
4465
4441
|
if (allFiltersEmpty) {
|
|
4466
|
-
if (
|
|
4442
|
+
if (this.#query.onEmptyFilter === "none" /* RETURN_NONE */) {
|
|
4467
4443
|
return "";
|
|
4468
|
-
} else if (
|
|
4444
|
+
} else if (this.#query?.allOr) {
|
|
4469
4445
|
return query.replace("()", "(*:*)");
|
|
4470
4446
|
}
|
|
4471
4447
|
}
|
|
@@ -4474,75 +4450,63 @@ var init_lucene = __esm({
|
|
|
4474
4450
|
buildSearchBody() {
|
|
4475
4451
|
let body2 = {
|
|
4476
4452
|
q: this.buildSearchQuery(),
|
|
4477
|
-
limit: Math.min(
|
|
4478
|
-
include_docs:
|
|
4453
|
+
limit: Math.min(this.#limit, _QueryBuilder.maxLimit),
|
|
4454
|
+
include_docs: this.#includeDocs
|
|
4479
4455
|
};
|
|
4480
|
-
if (
|
|
4481
|
-
body2.bookmark =
|
|
4456
|
+
if (this.#bookmark) {
|
|
4457
|
+
body2.bookmark = this.#bookmark;
|
|
4482
4458
|
}
|
|
4483
|
-
if (
|
|
4484
|
-
const order =
|
|
4485
|
-
const type = `<${
|
|
4486
|
-
body2.sort = `${order}${this.handleSpaces(
|
|
4459
|
+
if (this.#sort) {
|
|
4460
|
+
const order = this.#sortOrder === "descending" ? "-" : "";
|
|
4461
|
+
const type = `<${this.#sortType}>`;
|
|
4462
|
+
body2.sort = `${order}${this.handleSpaces(this.#sort)}${type}`;
|
|
4487
4463
|
}
|
|
4488
4464
|
return body2;
|
|
4489
4465
|
}
|
|
4490
4466
|
async run() {
|
|
4491
|
-
if (
|
|
4492
|
-
await
|
|
4467
|
+
if (this.#skip) {
|
|
4468
|
+
await this.#skipItems(this.#skip);
|
|
4493
4469
|
}
|
|
4494
|
-
return await
|
|
4470
|
+
return await this.#execute();
|
|
4495
4471
|
}
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
const
|
|
4521
|
-
this.
|
|
4522
|
-
|
|
4523
|
-
skipRemaining -= rows.length;
|
|
4524
|
-
} while (skipRemaining > 0 && iterationFetched > 0);
|
|
4525
|
-
__privateSet(this, _includeDocs, prevIncludeDocs);
|
|
4526
|
-
__privateSet(this, _limit, prevLimit);
|
|
4527
|
-
};
|
|
4528
|
-
_execute = new WeakSet();
|
|
4529
|
-
execute_fn = async function() {
|
|
4530
|
-
const { url, cookie } = getCouchInfo();
|
|
4531
|
-
const fullPath = `${url}/${__privateGet(this, _dbName)}/_design/database/_search/${__privateGet(this, _index)}`;
|
|
4532
|
-
const body2 = this.buildSearchBody();
|
|
4533
|
-
try {
|
|
4534
|
-
return await runQuery(fullPath, body2, cookie);
|
|
4535
|
-
} catch (err) {
|
|
4536
|
-
if (err.status === 404 && __privateGet(this, _indexBuilder)) {
|
|
4537
|
-
await __privateGet(this, _indexBuilder).call(this);
|
|
4472
|
+
/**
|
|
4473
|
+
* Lucene queries do not support pagination and use bookmarks instead.
|
|
4474
|
+
* For the given builder, walk through pages using bookmarks until the desired
|
|
4475
|
+
* page has been met.
|
|
4476
|
+
*/
|
|
4477
|
+
async #skipItems(skip) {
|
|
4478
|
+
const prevIncludeDocs = this.#includeDocs;
|
|
4479
|
+
const prevLimit = this.#limit;
|
|
4480
|
+
this.excludeDocs();
|
|
4481
|
+
let skipRemaining = skip;
|
|
4482
|
+
let iterationFetched = 0;
|
|
4483
|
+
do {
|
|
4484
|
+
const toSkip = Math.min(_QueryBuilder.maxLimit, skipRemaining);
|
|
4485
|
+
this.setLimit(toSkip);
|
|
4486
|
+
const { bookmark, rows } = await this.#execute();
|
|
4487
|
+
this.setBookmark(bookmark);
|
|
4488
|
+
iterationFetched = rows.length;
|
|
4489
|
+
skipRemaining -= rows.length;
|
|
4490
|
+
} while (skipRemaining > 0 && iterationFetched > 0);
|
|
4491
|
+
this.#includeDocs = prevIncludeDocs;
|
|
4492
|
+
this.#limit = prevLimit;
|
|
4493
|
+
}
|
|
4494
|
+
async #execute() {
|
|
4495
|
+
const { url, cookie } = getCouchInfo();
|
|
4496
|
+
const fullPath = `${url}/${this.#dbName}/_design/database/_search/${this.#index}`;
|
|
4497
|
+
const body2 = this.buildSearchBody();
|
|
4498
|
+
try {
|
|
4538
4499
|
return await runQuery(fullPath, body2, cookie);
|
|
4539
|
-
}
|
|
4540
|
-
|
|
4500
|
+
} catch (err) {
|
|
4501
|
+
if (err.status === 404 && this.#indexBuilder) {
|
|
4502
|
+
await this.#indexBuilder();
|
|
4503
|
+
return await runQuery(fullPath, body2, cookie);
|
|
4504
|
+
} else {
|
|
4505
|
+
throw err;
|
|
4506
|
+
}
|
|
4541
4507
|
}
|
|
4542
4508
|
}
|
|
4543
4509
|
};
|
|
4544
|
-
_QueryBuilder.maxLimit = 200;
|
|
4545
|
-
QueryBuilder = _QueryBuilder;
|
|
4546
4510
|
}
|
|
4547
4511
|
});
|
|
4548
4512
|
|
|
@@ -4621,10 +4585,9 @@ var init_searchIndexes2 = __esm({
|
|
|
4621
4585
|
|
|
4622
4586
|
// src/db/errors.ts
|
|
4623
4587
|
function checkErrorCode(error, code) {
|
|
4624
|
-
var _a;
|
|
4625
4588
|
const stringCode = code.toString();
|
|
4626
4589
|
if (typeof error === "object") {
|
|
4627
|
-
return error.status === code ||
|
|
4590
|
+
return error.status === code || error.message?.includes(stringCode);
|
|
4628
4591
|
} else if (typeof error === "number") {
|
|
4629
4592
|
return error === code;
|
|
4630
4593
|
} else if (typeof error === "string") {
|
|
@@ -4875,12 +4838,12 @@ var init_objectStore = __esm({
|
|
|
4875
4838
|
streamUpload = async (bucketName, filename, stream2, extra = {}) => {
|
|
4876
4839
|
const objectStore = ObjectStore(bucketName);
|
|
4877
4840
|
await makeSureBucketExists(objectStore, bucketName);
|
|
4878
|
-
if (filename
|
|
4841
|
+
if (filename?.endsWith(".js")) {
|
|
4879
4842
|
extra = {
|
|
4880
4843
|
...extra,
|
|
4881
4844
|
ContentType: "application/javascript"
|
|
4882
4845
|
};
|
|
4883
|
-
} else if (filename
|
|
4846
|
+
} else if (filename?.endsWith(".svg")) {
|
|
4884
4847
|
extra = {
|
|
4885
4848
|
...extra,
|
|
4886
4849
|
ContentType: "image"
|
|
@@ -4996,7 +4959,6 @@ var init_objectStore = __esm({
|
|
|
4996
4959
|
return objectStore.deleteObjects(params2).promise();
|
|
4997
4960
|
};
|
|
4998
4961
|
deleteFolder = async (bucketName, folder) => {
|
|
4999
|
-
var _a, _b, _c;
|
|
5000
4962
|
bucketName = sanitizeBucket(bucketName);
|
|
5001
4963
|
folder = sanitizeKey(folder);
|
|
5002
4964
|
const client = ObjectStore(bucketName);
|
|
@@ -5005,7 +4967,7 @@ var init_objectStore = __esm({
|
|
|
5005
4967
|
Prefix: folder
|
|
5006
4968
|
};
|
|
5007
4969
|
const existingObjectsResponse = await client.listObjects(listParams).promise();
|
|
5008
|
-
if (
|
|
4970
|
+
if (existingObjectsResponse.Contents?.length === 0) {
|
|
5009
4971
|
return;
|
|
5010
4972
|
}
|
|
5011
4973
|
const deleteParams = {
|
|
@@ -5014,11 +4976,11 @@ var init_objectStore = __esm({
|
|
|
5014
4976
|
Objects: []
|
|
5015
4977
|
}
|
|
5016
4978
|
};
|
|
5017
|
-
|
|
4979
|
+
existingObjectsResponse.Contents?.forEach((content) => {
|
|
5018
4980
|
deleteParams.Delete.Objects.push({ Key: content.Key });
|
|
5019
4981
|
});
|
|
5020
4982
|
const deleteResponse = await client.deleteObjects(deleteParams).promise();
|
|
5021
|
-
if (
|
|
4983
|
+
if (deleteResponse.Deleted?.length === 1e3) {
|
|
5022
4984
|
return deleteFolder(bucketName, folder);
|
|
5023
4985
|
}
|
|
5024
4986
|
};
|
|
@@ -5295,7 +5257,7 @@ function getFullPath(fileName) {
|
|
|
5295
5257
|
}
|
|
5296
5258
|
function getSingleFileMaxSizeInfo(totalMaxSize) {
|
|
5297
5259
|
const regex = /(\d+)([A-Za-z])/;
|
|
5298
|
-
const match = totalMaxSize
|
|
5260
|
+
const match = totalMaxSize?.match(regex);
|
|
5299
5261
|
if (!match) {
|
|
5300
5262
|
console.warn(`totalMaxSize does not have a valid value`, {
|
|
5301
5263
|
totalMaxSize
|
|
@@ -5327,9 +5289,9 @@ function localFileDestination() {
|
|
|
5327
5289
|
const fileInfo = getSingleFileMaxSizeInfo(environment_default.ROLLING_LOG_MAX_SIZE);
|
|
5328
5290
|
const outFile = rfs.createStream(logsFileName, {
|
|
5329
5291
|
// As we have a rolling size, we want to half the max size
|
|
5330
|
-
size: fileInfo
|
|
5292
|
+
size: fileInfo?.size,
|
|
5331
5293
|
path: logsPath,
|
|
5332
|
-
maxFiles:
|
|
5294
|
+
maxFiles: fileInfo?.totalHistoryFiles || 1,
|
|
5333
5295
|
immutable: true,
|
|
5334
5296
|
history: budibaseLogsHistoryFileName,
|
|
5335
5297
|
initialRotation: false
|
|
@@ -5404,8 +5366,8 @@ var init_logger = __esm({
|
|
|
5404
5366
|
tenantId: getTenantId2(),
|
|
5405
5367
|
appId: getAppId2(),
|
|
5406
5368
|
automationId: getAutomationId2(),
|
|
5407
|
-
identityId: identity
|
|
5408
|
-
identityType: identity
|
|
5369
|
+
identityId: identity?._id,
|
|
5370
|
+
identityType: identity?.type,
|
|
5409
5371
|
correlationId: getId()
|
|
5410
5372
|
};
|
|
5411
5373
|
const mergingObject = {
|
|
@@ -5469,30 +5431,30 @@ var init_logger = __esm({
|
|
|
5469
5431
|
pinoInstance = destinations.length ? (0, import_pino.default)(pinoOptions, import_pino.default.multistream(destinations)) : (0, import_pino.default)(pinoOptions);
|
|
5470
5432
|
console.log = (...arg) => {
|
|
5471
5433
|
const [obj, msg] = getLogParams2(arg);
|
|
5472
|
-
pinoInstance
|
|
5434
|
+
pinoInstance?.info(obj, msg);
|
|
5473
5435
|
};
|
|
5474
5436
|
console.info = (...arg) => {
|
|
5475
5437
|
const [obj, msg] = getLogParams2(arg);
|
|
5476
|
-
pinoInstance
|
|
5438
|
+
pinoInstance?.info(obj, msg);
|
|
5477
5439
|
};
|
|
5478
5440
|
console.warn = (...arg) => {
|
|
5479
5441
|
const [obj, msg] = getLogParams2(arg);
|
|
5480
|
-
pinoInstance
|
|
5442
|
+
pinoInstance?.warn(obj, msg);
|
|
5481
5443
|
};
|
|
5482
5444
|
console.error = (...arg) => {
|
|
5483
5445
|
const [obj, msg] = getLogParams2(arg);
|
|
5484
|
-
pinoInstance
|
|
5446
|
+
pinoInstance?.error(obj, msg);
|
|
5485
5447
|
};
|
|
5486
5448
|
console.trace = (...arg) => {
|
|
5487
5449
|
const [obj, msg] = getLogParams2(arg);
|
|
5488
5450
|
if (!obj.err) {
|
|
5489
5451
|
obj.err = new Error();
|
|
5490
5452
|
}
|
|
5491
|
-
pinoInstance
|
|
5453
|
+
pinoInstance?.trace(obj, msg);
|
|
5492
5454
|
};
|
|
5493
5455
|
console.debug = (...arg) => {
|
|
5494
5456
|
const [obj, msg] = getLogParams2(arg);
|
|
5495
|
-
pinoInstance
|
|
5457
|
+
pinoInstance?.debug(obj, msg);
|
|
5496
5458
|
};
|
|
5497
5459
|
const getTenantId2 = () => {
|
|
5498
5460
|
let tenantId;
|
|
@@ -5622,7 +5584,8 @@ __export(src_exports, {
|
|
|
5622
5584
|
env: () => environment_default,
|
|
5623
5585
|
errors: () => errors_exports,
|
|
5624
5586
|
events: () => events_exports,
|
|
5625
|
-
featureFlags: () =>
|
|
5587
|
+
featureFlags: () => features_exports,
|
|
5588
|
+
features: () => installation_exports2,
|
|
5626
5589
|
getPublicError: () => getPublicError,
|
|
5627
5590
|
init: () => init8,
|
|
5628
5591
|
installation: () => installation_exports,
|
|
@@ -5775,7 +5738,6 @@ var isUserInAppTenant = (appId, user) => {
|
|
|
5775
5738
|
};
|
|
5776
5739
|
var ALL_STRATEGIES = Object.values(TenantResolutionStrategy);
|
|
5777
5740
|
var getTenantIDFromCtx = (ctx, opts) => {
|
|
5778
|
-
var _a;
|
|
5779
5741
|
if (!isMultiTenant()) {
|
|
5780
5742
|
return DEFAULT_TENANT_ID;
|
|
5781
5743
|
}
|
|
@@ -5789,16 +5751,15 @@ var getTenantIDFromCtx = (ctx, opts) => {
|
|
|
5789
5751
|
opts.excludeStrategies = [];
|
|
5790
5752
|
}
|
|
5791
5753
|
const isAllowed = (strategy) => {
|
|
5792
|
-
|
|
5793
|
-
if ((_a2 = opts.excludeStrategies) == null ? void 0 : _a2.includes(strategy)) {
|
|
5754
|
+
if (opts.excludeStrategies?.includes(strategy)) {
|
|
5794
5755
|
return false;
|
|
5795
5756
|
}
|
|
5796
|
-
if (
|
|
5757
|
+
if (opts.includeStrategies?.includes(strategy)) {
|
|
5797
5758
|
return true;
|
|
5798
5759
|
}
|
|
5799
5760
|
};
|
|
5800
5761
|
if (isAllowed("user" /* USER */)) {
|
|
5801
|
-
const userTenantId =
|
|
5762
|
+
const userTenantId = ctx.user?.tenantId;
|
|
5802
5763
|
if (userTenantId) {
|
|
5803
5764
|
return userTenantId;
|
|
5804
5765
|
}
|
|
@@ -6366,7 +6327,7 @@ async function put(db, doc, writeRateMs = DEFAULT_WRITE_RATE_MS) {
|
|
|
6366
6327
|
logWarn(`Ignoring redlock conflict in write-through cache`);
|
|
6367
6328
|
}
|
|
6368
6329
|
}
|
|
6369
|
-
cacheItem = makeCacheItem(output, updateDb ? null : cacheItem
|
|
6330
|
+
cacheItem = makeCacheItem(output, updateDb ? null : cacheItem?.lastWrite);
|
|
6370
6331
|
if (output._id) {
|
|
6371
6332
|
await cache.store(makeCacheKey(db, output._id), cacheItem);
|
|
6372
6333
|
}
|
|
@@ -6458,7 +6419,6 @@ async function getSettingsConfig() {
|
|
|
6458
6419
|
async function getPlatformUrl(opts = {
|
|
6459
6420
|
tenantAware: true
|
|
6460
6421
|
}) {
|
|
6461
|
-
var _a;
|
|
6462
6422
|
let platformUrl = environment_default.PLATFORM_URL || "http://localhost:10000";
|
|
6463
6423
|
if (!environment_default.SELF_HOSTED && environment_default.MULTI_TENANCY && opts.tenantAware) {
|
|
6464
6424
|
const tenantId = getTenantId();
|
|
@@ -6466,11 +6426,11 @@ async function getPlatformUrl(opts = {
|
|
|
6466
6426
|
platformUrl = platformUrl.replace("://", `://${tenantId}.`);
|
|
6467
6427
|
}
|
|
6468
6428
|
} else if (environment_default.SELF_HOSTED) {
|
|
6469
|
-
const config =
|
|
6429
|
+
const config = opts?.config ? opts.config : (
|
|
6470
6430
|
// direct to db to prevent infinite loop
|
|
6471
|
-
(
|
|
6431
|
+
(await getConfig("settings" /* SETTINGS */))?.config
|
|
6472
6432
|
);
|
|
6473
|
-
if (config
|
|
6433
|
+
if (config?.platformUrl) {
|
|
6474
6434
|
platformUrl = config.platformUrl;
|
|
6475
6435
|
}
|
|
6476
6436
|
}
|
|
@@ -6484,14 +6444,13 @@ var analyticsEnabled = async (opts) => {
|
|
|
6484
6444
|
"analyticsEnabled" /* ANALYTICS_ENABLED */,
|
|
6485
6445
|
86400 /* ONE_DAY */,
|
|
6486
6446
|
async () => {
|
|
6487
|
-
|
|
6488
|
-
const config = (opts == null ? void 0 : opts.config) ? opts.config : (
|
|
6447
|
+
const config = opts?.config ? opts.config : (
|
|
6489
6448
|
// direct to db to prevent infinite loop
|
|
6490
|
-
(
|
|
6449
|
+
(await getConfig("settings" /* SETTINGS */))?.config
|
|
6491
6450
|
);
|
|
6492
|
-
if (
|
|
6451
|
+
if (config?.analyticsEnabled === false) {
|
|
6493
6452
|
return false;
|
|
6494
|
-
} else if (
|
|
6453
|
+
} else if (config?.analyticsEnabled === true) {
|
|
6495
6454
|
return true;
|
|
6496
6455
|
}
|
|
6497
6456
|
}
|
|
@@ -6511,7 +6470,7 @@ async function getGoogleConfigDoc() {
|
|
|
6511
6470
|
}
|
|
6512
6471
|
async function getGoogleConfig() {
|
|
6513
6472
|
const config = await getGoogleConfigDoc();
|
|
6514
|
-
return config
|
|
6473
|
+
return config?.config;
|
|
6515
6474
|
}
|
|
6516
6475
|
async function getGoogleDatasourceConfig() {
|
|
6517
6476
|
if (!environment_default.SELF_HOSTED) {
|
|
@@ -6539,13 +6498,11 @@ async function getOIDCConfigDoc() {
|
|
|
6539
6498
|
return getConfig("oidc" /* OIDC */);
|
|
6540
6499
|
}
|
|
6541
6500
|
async function getOIDCConfig() {
|
|
6542
|
-
|
|
6543
|
-
|
|
6544
|
-
return (config == null ? void 0 : config.configs) && config.configs[0];
|
|
6501
|
+
const config = (await getOIDCConfigDoc())?.config;
|
|
6502
|
+
return config?.configs && config.configs[0];
|
|
6545
6503
|
}
|
|
6546
6504
|
async function getOIDCConfigById(configId) {
|
|
6547
|
-
|
|
6548
|
-
const config = (_a = await getConfig("oidc" /* OIDC */)) == null ? void 0 : _a.config;
|
|
6505
|
+
const config = (await getConfig("oidc" /* OIDC */))?.config;
|
|
6549
6506
|
return config && config.configs.filter((c) => c.uuid === configId)[0];
|
|
6550
6507
|
}
|
|
6551
6508
|
async function getSMTPConfigDoc() {
|
|
@@ -6572,7 +6529,7 @@ async function getSMTPConfig(isAutomation) {
|
|
|
6572
6529
|
}
|
|
6573
6530
|
async function getSCIMConfig() {
|
|
6574
6531
|
const config = await getConfig("scim" /* SCIM */);
|
|
6575
|
-
return config
|
|
6532
|
+
return config?.config;
|
|
6576
6533
|
}
|
|
6577
6534
|
|
|
6578
6535
|
// src/events/index.ts
|
|
@@ -6987,7 +6944,7 @@ async function getAppIdFromCtx(ctx) {
|
|
|
6987
6944
|
appId = confirmAppId(await resolveAppUrl(ctx));
|
|
6988
6945
|
}
|
|
6989
6946
|
const referer = ctx.request.headers.referer;
|
|
6990
|
-
if (!appId &&
|
|
6947
|
+
if (!appId && referer?.includes(BUILDER_APP_PREFIX)) {
|
|
6991
6948
|
const refererId = parseAppIdFromUrl(ctx.request.headers.referer);
|
|
6992
6949
|
appId = confirmAppId(refererId);
|
|
6993
6950
|
}
|
|
@@ -7206,7 +7163,6 @@ function handleStalled(queue, removeStalledCb) {
|
|
|
7206
7163
|
});
|
|
7207
7164
|
}
|
|
7208
7165
|
function getLogParams(eventType, event, opts = {}, extra = {}) {
|
|
7209
|
-
var _a, _b, _c;
|
|
7210
7166
|
const message = `[BULL] ${eventType}=${event}`;
|
|
7211
7167
|
const err = opts.error;
|
|
7212
7168
|
const bullLog = {
|
|
@@ -7214,11 +7170,11 @@ function getLogParams(eventType, event, opts = {}, extra = {}) {
|
|
|
7214
7170
|
eventType,
|
|
7215
7171
|
event,
|
|
7216
7172
|
job: opts.job,
|
|
7217
|
-
jobId: opts.jobId ||
|
|
7173
|
+
jobId: opts.jobId || opts.job?.id,
|
|
7218
7174
|
...extra
|
|
7219
7175
|
};
|
|
7220
7176
|
let automationLog;
|
|
7221
|
-
if (
|
|
7177
|
+
if (opts.job?.data?.automation) {
|
|
7222
7178
|
automationLog = {
|
|
7223
7179
|
_logKey: "automation",
|
|
7224
7180
|
trigger: opts.job ? opts.job.data.automation.definition.trigger.event : void 0
|
|
@@ -7233,11 +7189,9 @@ var EventTypeMap = {
|
|
|
7233
7189
|
["systemEventQueue" /* SYSTEM_EVENT_QUEUE */]: "system-event" /* SYSTEM_EVENT */
|
|
7234
7190
|
};
|
|
7235
7191
|
function logging(queue, jobQueue) {
|
|
7236
|
-
var _a;
|
|
7237
7192
|
const eventType = EventTypeMap[jobQueue];
|
|
7238
7193
|
function doInJobContext(job, task) {
|
|
7239
|
-
|
|
7240
|
-
const appId = (_a2 = job.data.event) == null ? void 0 : _a2.appId;
|
|
7194
|
+
const appId = job.data.event?.appId;
|
|
7241
7195
|
if (appId) {
|
|
7242
7196
|
return doInContext(appId, task);
|
|
7243
7197
|
} else {
|
|
@@ -7251,7 +7205,7 @@ function logging(queue, jobQueue) {
|
|
|
7251
7205
|
}).on("error" /* ERROR */, (error) => {
|
|
7252
7206
|
console.error(...getLogParams(eventType, "error" /* ERROR */, { error }));
|
|
7253
7207
|
});
|
|
7254
|
-
if (
|
|
7208
|
+
if (process.env.NODE_DEBUG?.includes("bull")) {
|
|
7255
7209
|
queue.on("waiting" /* WAITING */, (jobId) => {
|
|
7256
7210
|
console.info(...getLogParams(eventType, "waiting" /* WAITING */, { jobId }));
|
|
7257
7211
|
}).on("active" /* ACTIVE */, async (job, jobPromise) => {
|
|
@@ -7321,7 +7275,7 @@ function createQueue(jobQueue, opts = {}) {
|
|
|
7321
7275
|
} else {
|
|
7322
7276
|
queue = new inMemoryQueue_default(jobQueue, queueConfig);
|
|
7323
7277
|
}
|
|
7324
|
-
addListeners(queue, jobQueue, opts
|
|
7278
|
+
addListeners(queue, jobQueue, opts?.removeStalledCb);
|
|
7325
7279
|
QUEUES.push(queue);
|
|
7326
7280
|
if (!cleanupInterval && !environment_default.isTest()) {
|
|
7327
7281
|
cleanupInterval = set(cleanup2, CLEANUP_PERIOD_MS);
|
|
@@ -7346,7 +7300,10 @@ async function shutdown2() {
|
|
|
7346
7300
|
|
|
7347
7301
|
// src/events/processors/AuditLogsProcessor.ts
|
|
7348
7302
|
init_environment2();
|
|
7349
|
-
var
|
|
7303
|
+
var AuditLogsProcessor = class _AuditLogsProcessor {
|
|
7304
|
+
static {
|
|
7305
|
+
this.auditLogsEnabled = false;
|
|
7306
|
+
}
|
|
7350
7307
|
// can't use constructor as need to return promise
|
|
7351
7308
|
static init(fn) {
|
|
7352
7309
|
_AuditLogsProcessor.auditLogsEnabled = true;
|
|
@@ -7398,12 +7355,9 @@ var _AuditLogsProcessor = class _AuditLogsProcessor {
|
|
|
7398
7355
|
async identifyGroup(group, timestamp) {
|
|
7399
7356
|
}
|
|
7400
7357
|
shutdown() {
|
|
7401
|
-
|
|
7402
|
-
(_a = _AuditLogsProcessor.auditLogQueue) == null ? void 0 : _a.close();
|
|
7358
|
+
_AuditLogsProcessor.auditLogQueue?.close();
|
|
7403
7359
|
}
|
|
7404
7360
|
};
|
|
7405
|
-
_AuditLogsProcessor.auditLogsEnabled = false;
|
|
7406
|
-
var AuditLogsProcessor = _AuditLogsProcessor;
|
|
7407
7361
|
|
|
7408
7362
|
// src/events/processors/Processors.ts
|
|
7409
7363
|
var Processor = class {
|
|
@@ -7618,7 +7572,7 @@ var bulkGetGlobalUsersById = async (userIds, opts) => {
|
|
|
7618
7572
|
keys: userIds,
|
|
7619
7573
|
include_docs: true
|
|
7620
7574
|
})).rows.map((row) => row.doc);
|
|
7621
|
-
if (opts
|
|
7575
|
+
if (opts?.cleanup) {
|
|
7622
7576
|
users = removeUserPassword(users);
|
|
7623
7577
|
}
|
|
7624
7578
|
return users;
|
|
@@ -7639,7 +7593,7 @@ var bulkUpdateGlobalUsers = async (users) => {
|
|
|
7639
7593
|
async function getById(id, opts) {
|
|
7640
7594
|
const db = getGlobalDB();
|
|
7641
7595
|
let user = await db.get(id);
|
|
7642
|
-
if (opts
|
|
7596
|
+
if (opts?.cleanup) {
|
|
7643
7597
|
user = removeUserPassword(user);
|
|
7644
7598
|
}
|
|
7645
7599
|
return user;
|
|
@@ -7656,7 +7610,7 @@ var getGlobalUserByEmail = async (email, opts) => {
|
|
|
7656
7610
|
throw new Error(`Multiple users found with email address: ${email}`);
|
|
7657
7611
|
}
|
|
7658
7612
|
let user = response;
|
|
7659
|
-
if (opts
|
|
7613
|
+
if (opts?.cleanup) {
|
|
7660
7614
|
user = removeUserPassword(user);
|
|
7661
7615
|
}
|
|
7662
7616
|
return user;
|
|
@@ -7674,7 +7628,7 @@ var searchGlobalUsersByApp = async (appId, opts, getOpts) => {
|
|
|
7674
7628
|
response = [];
|
|
7675
7629
|
}
|
|
7676
7630
|
let users = Array.isArray(response) ? response : [response];
|
|
7677
|
-
if (getOpts
|
|
7631
|
+
if (getOpts?.cleanup) {
|
|
7678
7632
|
users = removeUserPassword(users);
|
|
7679
7633
|
}
|
|
7680
7634
|
return users;
|
|
@@ -7704,10 +7658,10 @@ var searchGlobalUsersByAppAccess = async (appId, opts) => {
|
|
|
7704
7658
|
$regex: "^us_"
|
|
7705
7659
|
}
|
|
7706
7660
|
},
|
|
7707
|
-
limit:
|
|
7661
|
+
limit: opts?.limit || 50
|
|
7708
7662
|
};
|
|
7709
7663
|
const resp = await directCouchFind(getGlobalDBName(), searchOptions);
|
|
7710
|
-
return resp
|
|
7664
|
+
return resp?.rows;
|
|
7711
7665
|
};
|
|
7712
7666
|
var getGlobalUserByAppPage = (appId, user) => {
|
|
7713
7667
|
if (!user) {
|
|
@@ -7730,7 +7684,7 @@ var searchGlobalUsersByEmail = async (email, opts, getOpts) => {
|
|
|
7730
7684
|
response = [];
|
|
7731
7685
|
}
|
|
7732
7686
|
let users = Array.isArray(response) ? response : [response];
|
|
7733
|
-
if (getOpts
|
|
7687
|
+
if (getOpts?.cleanup) {
|
|
7734
7688
|
users = removeUserPassword(users);
|
|
7735
7689
|
}
|
|
7736
7690
|
return users;
|
|
@@ -8081,13 +8035,12 @@ __export(users_exports2, {
|
|
|
8081
8035
|
isGlobalBuilder: () => isGlobalBuilder
|
|
8082
8036
|
});
|
|
8083
8037
|
function isBuilder(user, appId) {
|
|
8084
|
-
var _a, _b, _c;
|
|
8085
8038
|
if (!user) {
|
|
8086
8039
|
return false;
|
|
8087
8040
|
}
|
|
8088
|
-
if (
|
|
8041
|
+
if (user.builder?.global) {
|
|
8089
8042
|
return true;
|
|
8090
|
-
} else if (appId &&
|
|
8043
|
+
} else if (appId && user.builder?.apps?.includes(getProdAppID2(appId))) {
|
|
8091
8044
|
return true;
|
|
8092
8045
|
}
|
|
8093
8046
|
return false;
|
|
@@ -8105,27 +8058,24 @@ function isAdminOrBuilder(user, appId) {
|
|
|
8105
8058
|
return isBuilder(user, appId) || isAdmin(user);
|
|
8106
8059
|
}
|
|
8107
8060
|
function hasAppBuilderPermissions(user) {
|
|
8108
|
-
var _a, _b, _c;
|
|
8109
8061
|
if (!user) {
|
|
8110
8062
|
return false;
|
|
8111
8063
|
}
|
|
8112
|
-
const appLength =
|
|
8113
|
-
const isGlobalBuilder3 = !!
|
|
8064
|
+
const appLength = user.builder?.apps?.length;
|
|
8065
|
+
const isGlobalBuilder3 = !!user.builder?.global;
|
|
8114
8066
|
return !isGlobalBuilder3 && appLength != null && appLength > 0;
|
|
8115
8067
|
}
|
|
8116
8068
|
function hasBuilderPermissions(user) {
|
|
8117
|
-
var _a;
|
|
8118
8069
|
if (!user) {
|
|
8119
8070
|
return false;
|
|
8120
8071
|
}
|
|
8121
|
-
return
|
|
8072
|
+
return user.builder?.global || hasAppBuilderPermissions(user);
|
|
8122
8073
|
}
|
|
8123
8074
|
function hasAdminPermissions(user) {
|
|
8124
|
-
var _a;
|
|
8125
8075
|
if (!user) {
|
|
8126
8076
|
return false;
|
|
8127
8077
|
}
|
|
8128
|
-
return !!
|
|
8078
|
+
return !!user.admin?.global;
|
|
8129
8079
|
}
|
|
8130
8080
|
|
|
8131
8081
|
// src/users/utils.ts
|
|
@@ -8198,7 +8148,7 @@ var unassignAppRoleEvents = async (user, roles, existingRoles) => {
|
|
|
8198
8148
|
};
|
|
8199
8149
|
var handleAppRoleEvents = async (user, existingUser) => {
|
|
8200
8150
|
const roles = user.roles;
|
|
8201
|
-
const existingRoles = existingUser
|
|
8151
|
+
const existingRoles = existingUser?.roles;
|
|
8202
8152
|
await assignAppRoleEvents(user, roles, existingRoles);
|
|
8203
8153
|
await unassignAppRoleEvents(user, roles, existingRoles);
|
|
8204
8154
|
};
|
|
@@ -8250,7 +8200,7 @@ var isRemovingAdmin = (user, existingUser) => {
|
|
|
8250
8200
|
return isRemovingPermission(user, existingUser, hasAdminPermissions2);
|
|
8251
8201
|
};
|
|
8252
8202
|
var isOnboardingComplete = (user, existingUser) => {
|
|
8253
|
-
return !
|
|
8203
|
+
return !existingUser?.onboardedAt && typeof user.onboardedAt === "string";
|
|
8254
8204
|
};
|
|
8255
8205
|
var isAddingPermission = (user, existingUser, hasPermission) => {
|
|
8256
8206
|
if (!hasPermission(user)) {
|
|
@@ -8307,7 +8257,7 @@ async function getSessionsForUser(userId) {
|
|
|
8307
8257
|
}
|
|
8308
8258
|
async function invalidateSessions(userId, opts = {}) {
|
|
8309
8259
|
try {
|
|
8310
|
-
const reason =
|
|
8260
|
+
const reason = opts?.reason || "unknown";
|
|
8311
8261
|
let sessionIds = opts.sessionIds || [];
|
|
8312
8262
|
let sessionKeys;
|
|
8313
8263
|
if (sessionIds.length === 0) {
|
|
@@ -8484,7 +8434,6 @@ var UserDB = class _UserDB {
|
|
|
8484
8434
|
return user;
|
|
8485
8435
|
}
|
|
8486
8436
|
static async save(user, opts = {}) {
|
|
8487
|
-
var _a, _b;
|
|
8488
8437
|
if (opts.hashPassword == null) {
|
|
8489
8438
|
opts.hashPassword = true;
|
|
8490
8439
|
}
|
|
@@ -8497,7 +8446,7 @@ var UserDB = class _UserDB {
|
|
|
8497
8446
|
if (!email && !_id) {
|
|
8498
8447
|
throw new Error("_id or email is required");
|
|
8499
8448
|
}
|
|
8500
|
-
if (
|
|
8449
|
+
if (user.builder?.apps?.length && !await _UserDB.features.isAppBuildersEnabled()) {
|
|
8501
8450
|
throw new Error("Unable to update app builders, please check license");
|
|
8502
8451
|
}
|
|
8503
8452
|
let dbUser;
|
|
@@ -8525,10 +8474,10 @@ var UserDB = class _UserDB {
|
|
|
8525
8474
|
return _UserDB.quotas.addUsers(change, async () => {
|
|
8526
8475
|
await validateUniqueUser(email, tenantId);
|
|
8527
8476
|
let builtUser = await _UserDB.buildUser(user, opts, tenantId, dbUser);
|
|
8528
|
-
if (opts.currentUserId && opts.currentUserId ===
|
|
8477
|
+
if (opts.currentUserId && opts.currentUserId === dbUser?._id) {
|
|
8529
8478
|
builtUser = cleanseUserObject(builtUser, dbUser);
|
|
8530
8479
|
}
|
|
8531
|
-
if (!dbUser &&
|
|
8480
|
+
if (!dbUser && roles?.length) {
|
|
8532
8481
|
builtUser.roles = { ...roles };
|
|
8533
8482
|
}
|
|
8534
8483
|
let groupPromises = [];
|
|
@@ -8807,8 +8756,8 @@ var identifyUser = async (user, account, timestamp) => {
|
|
|
8807
8756
|
if (isSSOUser(user)) {
|
|
8808
8757
|
providerType = user.providerType;
|
|
8809
8758
|
}
|
|
8810
|
-
const accountHolder =
|
|
8811
|
-
const verified2 = account &&
|
|
8759
|
+
const accountHolder = account?.budibaseUserId === user._id || false;
|
|
8760
|
+
const verified2 = account && account?.budibaseUserId === user._id ? account.verified : false;
|
|
8812
8761
|
const installationId = await getInstallationId();
|
|
8813
8762
|
const hosting = account ? account.hosting : getHostingFromEnv();
|
|
8814
8763
|
const environment2 = getDeploymentEnvironment();
|
|
@@ -8967,7 +8916,7 @@ var clearEvents = async () => {
|
|
|
8967
8916
|
};
|
|
8968
8917
|
var isBackfillingEvent = async (event) => {
|
|
8969
8918
|
const backfill = await getBackfillMetadata();
|
|
8970
|
-
const events2 = backfill
|
|
8919
|
+
const events2 = backfill?.eventWhitelist;
|
|
8971
8920
|
if (events2 && events2.includes(event)) {
|
|
8972
8921
|
return true;
|
|
8973
8922
|
} else {
|
|
@@ -9311,12 +9260,11 @@ var auth_default = {
|
|
|
9311
9260
|
// src/events/publishers/automation.ts
|
|
9312
9261
|
init_src();
|
|
9313
9262
|
async function created3(automation, timestamp) {
|
|
9314
|
-
var _a, _b, _c, _d;
|
|
9315
9263
|
const properties = {
|
|
9316
9264
|
appId: automation.appId,
|
|
9317
9265
|
automationId: automation._id,
|
|
9318
|
-
triggerId:
|
|
9319
|
-
triggerType:
|
|
9266
|
+
triggerId: automation.definition?.trigger?.id,
|
|
9267
|
+
triggerType: automation.definition?.trigger?.stepId,
|
|
9320
9268
|
audited: {
|
|
9321
9269
|
name: automation.name
|
|
9322
9270
|
}
|
|
@@ -9324,22 +9272,20 @@ async function created3(automation, timestamp) {
|
|
|
9324
9272
|
await publishEvent("automation:created" /* AUTOMATION_CREATED */, properties, timestamp);
|
|
9325
9273
|
}
|
|
9326
9274
|
async function triggerUpdated(automation) {
|
|
9327
|
-
var _a, _b, _c, _d;
|
|
9328
9275
|
const properties = {
|
|
9329
9276
|
appId: automation.appId,
|
|
9330
9277
|
automationId: automation._id,
|
|
9331
|
-
triggerId:
|
|
9332
|
-
triggerType:
|
|
9278
|
+
triggerId: automation.definition?.trigger?.id,
|
|
9279
|
+
triggerType: automation.definition?.trigger?.stepId
|
|
9333
9280
|
};
|
|
9334
9281
|
await publishEvent("automation:trigger:updated" /* AUTOMATION_TRIGGER_UPDATED */, properties);
|
|
9335
9282
|
}
|
|
9336
9283
|
async function deleted3(automation) {
|
|
9337
|
-
var _a, _b, _c, _d;
|
|
9338
9284
|
const properties = {
|
|
9339
9285
|
appId: automation.appId,
|
|
9340
9286
|
automationId: automation._id,
|
|
9341
|
-
triggerId:
|
|
9342
|
-
triggerType:
|
|
9287
|
+
triggerId: automation.definition?.trigger?.id,
|
|
9288
|
+
triggerType: automation.definition?.trigger?.stepId,
|
|
9343
9289
|
audited: {
|
|
9344
9290
|
name: automation.name
|
|
9345
9291
|
}
|
|
@@ -9347,12 +9293,11 @@ async function deleted3(automation) {
|
|
|
9347
9293
|
await publishEvent("automation:deleted" /* AUTOMATION_DELETED */, properties);
|
|
9348
9294
|
}
|
|
9349
9295
|
async function tested(automation) {
|
|
9350
|
-
var _a, _b, _c, _d;
|
|
9351
9296
|
const properties = {
|
|
9352
9297
|
appId: automation.appId,
|
|
9353
9298
|
automationId: automation._id,
|
|
9354
|
-
triggerId:
|
|
9355
|
-
triggerType:
|
|
9299
|
+
triggerId: automation.definition?.trigger?.id,
|
|
9300
|
+
triggerType: automation.definition?.trigger?.stepId
|
|
9356
9301
|
};
|
|
9357
9302
|
await publishEvent("automation:tested" /* AUTOMATION_TESTED */, properties);
|
|
9358
9303
|
}
|
|
@@ -9363,12 +9308,11 @@ var run = async (count, timestamp) => {
|
|
|
9363
9308
|
await publishEvent("automations:run" /* AUTOMATIONS_RUN */, properties, timestamp);
|
|
9364
9309
|
};
|
|
9365
9310
|
async function stepCreated(automation, step, timestamp) {
|
|
9366
|
-
var _a, _b, _c, _d;
|
|
9367
9311
|
const properties = {
|
|
9368
9312
|
appId: automation.appId,
|
|
9369
9313
|
automationId: automation._id,
|
|
9370
|
-
triggerId:
|
|
9371
|
-
triggerType:
|
|
9314
|
+
triggerId: automation.definition?.trigger?.id,
|
|
9315
|
+
triggerType: automation.definition?.trigger?.stepId,
|
|
9372
9316
|
stepId: step.id,
|
|
9373
9317
|
stepType: step.stepId,
|
|
9374
9318
|
audited: {
|
|
@@ -9378,12 +9322,11 @@ async function stepCreated(automation, step, timestamp) {
|
|
|
9378
9322
|
await publishEvent("automation:step:created" /* AUTOMATION_STEP_CREATED */, properties, timestamp);
|
|
9379
9323
|
}
|
|
9380
9324
|
async function stepDeleted(automation, step) {
|
|
9381
|
-
var _a, _b, _c, _d;
|
|
9382
9325
|
const properties = {
|
|
9383
9326
|
appId: automation.appId,
|
|
9384
9327
|
automationId: automation._id,
|
|
9385
|
-
triggerId:
|
|
9386
|
-
triggerType:
|
|
9328
|
+
triggerId: automation.definition?.trigger?.id,
|
|
9329
|
+
triggerType: automation.definition?.trigger?.stepId,
|
|
9387
9330
|
stepId: step.id,
|
|
9388
9331
|
stepType: step.stepId,
|
|
9389
9332
|
audited: {
|
|
@@ -9670,25 +9613,23 @@ var role_default = {
|
|
|
9670
9613
|
// src/events/publishers/screen.ts
|
|
9671
9614
|
init_src();
|
|
9672
9615
|
async function created8(screen, timestamp) {
|
|
9673
|
-
var _a;
|
|
9674
9616
|
const properties = {
|
|
9675
9617
|
layoutId: screen.layoutId,
|
|
9676
9618
|
screenId: screen._id,
|
|
9677
9619
|
roleId: screen.routing.roleId,
|
|
9678
9620
|
audited: {
|
|
9679
|
-
name:
|
|
9621
|
+
name: screen.routing?.route
|
|
9680
9622
|
}
|
|
9681
9623
|
};
|
|
9682
9624
|
await publishEvent("screen:created" /* SCREEN_CREATED */, properties, timestamp);
|
|
9683
9625
|
}
|
|
9684
9626
|
async function deleted8(screen) {
|
|
9685
|
-
var _a;
|
|
9686
9627
|
const properties = {
|
|
9687
9628
|
layoutId: screen.layoutId,
|
|
9688
9629
|
screenId: screen._id,
|
|
9689
9630
|
roleId: screen.routing.roleId,
|
|
9690
9631
|
audited: {
|
|
9691
|
-
name:
|
|
9632
|
+
name: screen.routing?.route
|
|
9692
9633
|
}
|
|
9693
9634
|
};
|
|
9694
9635
|
await publishEvent("screen:deleted" /* SCREEN_DELETED */, properties);
|
|
@@ -10624,8 +10565,7 @@ var BUILTIN_PERMISSIONS = {
|
|
|
10624
10565
|
name: "Read only",
|
|
10625
10566
|
permissions: [
|
|
10626
10567
|
new Permission("query" /* QUERY */, "read" /* READ */),
|
|
10627
|
-
new Permission("table" /* TABLE */, "read" /* READ */)
|
|
10628
|
-
new Permission("view" /* VIEW */, "read" /* READ */)
|
|
10568
|
+
new Permission("table" /* TABLE */, "read" /* READ */)
|
|
10629
10569
|
]
|
|
10630
10570
|
},
|
|
10631
10571
|
WRITE: {
|
|
@@ -10634,7 +10574,6 @@ var BUILTIN_PERMISSIONS = {
|
|
|
10634
10574
|
permissions: [
|
|
10635
10575
|
new Permission("query" /* QUERY */, "write" /* WRITE */),
|
|
10636
10576
|
new Permission("table" /* TABLE */, "write" /* WRITE */),
|
|
10637
|
-
new Permission("view" /* VIEW */, "read" /* READ */),
|
|
10638
10577
|
new Permission("automation" /* AUTOMATION */, "execute" /* EXECUTE */)
|
|
10639
10578
|
]
|
|
10640
10579
|
},
|
|
@@ -10645,7 +10584,6 @@ var BUILTIN_PERMISSIONS = {
|
|
|
10645
10584
|
new Permission("table" /* TABLE */, "write" /* WRITE */),
|
|
10646
10585
|
new Permission("user" /* USER */, "read" /* READ */),
|
|
10647
10586
|
new Permission("automation" /* AUTOMATION */, "execute" /* EXECUTE */),
|
|
10648
|
-
new Permission("view" /* VIEW */, "read" /* READ */),
|
|
10649
10587
|
new Permission("webhook" /* WEBHOOK */, "read" /* READ */)
|
|
10650
10588
|
]
|
|
10651
10589
|
},
|
|
@@ -10656,7 +10594,6 @@ var BUILTIN_PERMISSIONS = {
|
|
|
10656
10594
|
new Permission("table" /* TABLE */, "admin" /* ADMIN */),
|
|
10657
10595
|
new Permission("user" /* USER */, "admin" /* ADMIN */),
|
|
10658
10596
|
new Permission("automation" /* AUTOMATION */, "admin" /* ADMIN */),
|
|
10659
|
-
new Permission("view" /* VIEW */, "admin" /* ADMIN */),
|
|
10660
10597
|
new Permission("webhook" /* WEBHOOK */, "read" /* READ */),
|
|
10661
10598
|
new Permission("query" /* QUERY */, "admin" /* ADMIN */)
|
|
10662
10599
|
]
|
|
@@ -10759,7 +10696,7 @@ var BUILTIN_ROLE_NAME_ARRAY = Object.values(BUILTIN_ROLES).map(
|
|
|
10759
10696
|
(role) => role.name
|
|
10760
10697
|
);
|
|
10761
10698
|
function isBuiltin(role) {
|
|
10762
|
-
return BUILTIN_ROLE_ID_ARRAY.some((builtin) => role
|
|
10699
|
+
return BUILTIN_ROLE_ID_ARRAY.some((builtin) => role?.includes(builtin));
|
|
10763
10700
|
}
|
|
10764
10701
|
function builtinRoleToNumber(id) {
|
|
10765
10702
|
if (!id) {
|
|
@@ -10786,7 +10723,7 @@ async function roleToNumber(id) {
|
|
|
10786
10723
|
}
|
|
10787
10724
|
const hierarchy = await getUserRoleHierarchy(id);
|
|
10788
10725
|
for (let role of hierarchy) {
|
|
10789
|
-
if (isBuiltin(role
|
|
10726
|
+
if (isBuiltin(role?.inherits)) {
|
|
10790
10727
|
return builtinRoleToNumber(role.inherits) + 1;
|
|
10791
10728
|
}
|
|
10792
10729
|
}
|
|
@@ -10819,7 +10756,7 @@ async function getRole(roleId, opts) {
|
|
|
10819
10756
|
role = Object.assign(role, dbRole);
|
|
10820
10757
|
role._id = getExternalRoleID(role._id, role.version);
|
|
10821
10758
|
} catch (err) {
|
|
10822
|
-
if (!isBuiltin(roleId) &&
|
|
10759
|
+
if (!isBuiltin(roleId) && opts?.defaultPublic) {
|
|
10823
10760
|
return (0, import_cloneDeep2.default)(BUILTIN_ROLES.PUBLIC);
|
|
10824
10761
|
}
|
|
10825
10762
|
if (Object.keys(role).length === 0) {
|
|
@@ -10942,7 +10879,7 @@ var AccessController = class {
|
|
|
10942
10879
|
});
|
|
10943
10880
|
this.userHierarchies[userRoleId] = roleIds;
|
|
10944
10881
|
}
|
|
10945
|
-
return
|
|
10882
|
+
return roleIds?.indexOf(tryingRoleId) !== -1;
|
|
10946
10883
|
}
|
|
10947
10884
|
async checkScreensAccess(screens, userRoleId) {
|
|
10948
10885
|
let accessibleScreens = [];
|
|
@@ -10963,7 +10900,7 @@ var AccessController = class {
|
|
|
10963
10900
|
}
|
|
10964
10901
|
};
|
|
10965
10902
|
function getDBRoleID(roleName) {
|
|
10966
|
-
if (roleName
|
|
10903
|
+
if (roleName?.startsWith("role" /* ROLE */)) {
|
|
10967
10904
|
return roleName;
|
|
10968
10905
|
}
|
|
10969
10906
|
return prefixRoleID(roleName);
|
|
@@ -10975,16 +10912,39 @@ function getExternalRoleID(roleId, version) {
|
|
|
10975
10912
|
return roleId;
|
|
10976
10913
|
}
|
|
10977
10914
|
|
|
10978
|
-
// src/
|
|
10979
|
-
var
|
|
10980
|
-
__export(
|
|
10915
|
+
// src/features/index.ts
|
|
10916
|
+
var features_exports = {};
|
|
10917
|
+
__export(features_exports, {
|
|
10981
10918
|
TenantFeatureFlag: () => TenantFeatureFlag,
|
|
10982
10919
|
buildFeatureFlags: () => buildFeatureFlags,
|
|
10983
10920
|
getTenantFeatureFlags: () => getTenantFeatureFlags,
|
|
10984
|
-
isEnabled: () => isEnabled
|
|
10921
|
+
isEnabled: () => isEnabled,
|
|
10922
|
+
processFeatureEnvVar: () => processFeatureEnvVar
|
|
10985
10923
|
});
|
|
10986
10924
|
init_environment2();
|
|
10987
10925
|
init_context2();
|
|
10926
|
+
|
|
10927
|
+
// src/features/installation.ts
|
|
10928
|
+
var installation_exports2 = {};
|
|
10929
|
+
__export(installation_exports2, {
|
|
10930
|
+
processFeatureEnvVar: () => processFeatureEnvVar
|
|
10931
|
+
});
|
|
10932
|
+
function processFeatureEnvVar(fullList, featureList) {
|
|
10933
|
+
let list;
|
|
10934
|
+
if (!featureList) {
|
|
10935
|
+
list = fullList;
|
|
10936
|
+
} else {
|
|
10937
|
+
list = featureList.split(",");
|
|
10938
|
+
}
|
|
10939
|
+
for (let feature of list) {
|
|
10940
|
+
if (!fullList.includes(feature)) {
|
|
10941
|
+
throw new Error(`Feature: ${feature} is not an allowed option`);
|
|
10942
|
+
}
|
|
10943
|
+
}
|
|
10944
|
+
return list;
|
|
10945
|
+
}
|
|
10946
|
+
|
|
10947
|
+
// src/features/index.ts
|
|
10988
10948
|
function buildFeatureFlags() {
|
|
10989
10949
|
if (!environment_default.TENANT_FEATURE_FLAGS) {
|
|
10990
10950
|
return;
|
|
@@ -11222,8 +11182,7 @@ async function authenticate2(details, requireLocalAccount = true, done, saveUser
|
|
|
11222
11182
|
return done(null, ssoUser);
|
|
11223
11183
|
}
|
|
11224
11184
|
async function getProfilePictureUrl(user, details) {
|
|
11225
|
-
|
|
11226
|
-
const pictureUrl = (_a = details.profile) == null ? void 0 : _a._json.picture;
|
|
11185
|
+
const pictureUrl = details.profile?._json.picture;
|
|
11227
11186
|
if (pictureUrl) {
|
|
11228
11187
|
const response = await (0, import_node_fetch5.default)(pictureUrl);
|
|
11229
11188
|
if (response.status === 200) {
|
|
@@ -11754,7 +11713,7 @@ function authenticated_default(noAuthPatterns = [], opts = {
|
|
|
11754
11713
|
user = await getUser(userId, session.tenantId);
|
|
11755
11714
|
}
|
|
11756
11715
|
user.csrfToken = session.csrfToken;
|
|
11757
|
-
if (
|
|
11716
|
+
if (session?.lastAccessedAt < timeMinusOneMinute()) {
|
|
11758
11717
|
await updateSessionTTL(session);
|
|
11759
11718
|
}
|
|
11760
11719
|
authenticated = true;
|
|
@@ -11796,9 +11755,9 @@ function authenticated_default(noAuthPatterns = [], opts = {
|
|
|
11796
11755
|
} catch (err) {
|
|
11797
11756
|
console.error(`Auth Error: ${err.message}`);
|
|
11798
11757
|
console.error(err);
|
|
11799
|
-
if (
|
|
11758
|
+
if (err?.name === "JsonWebTokenError") {
|
|
11800
11759
|
clearCookie(ctx, "budibase:auth" /* Auth */);
|
|
11801
|
-
} else if (
|
|
11760
|
+
} else if (err?.code === "invalid_api_key" /* INVALID_API_KEY */) {
|
|
11802
11761
|
ctx.throw(403, err.message);
|
|
11803
11762
|
}
|
|
11804
11763
|
if (opts && opts.publicAllowed || publicEndpoint) {
|
|
@@ -11865,7 +11824,6 @@ var INCLUDED_CONTENT_TYPES = [
|
|
|
11865
11824
|
function csrf_default(opts = { noCsrfPatterns: [] }) {
|
|
11866
11825
|
const noCsrfOptions = buildMatcherRegex(opts.noCsrfPatterns);
|
|
11867
11826
|
return async (ctx, next) => {
|
|
11868
|
-
var _a;
|
|
11869
11827
|
const found = matches(ctx, noCsrfOptions);
|
|
11870
11828
|
if (found) {
|
|
11871
11829
|
return next();
|
|
@@ -11880,7 +11838,7 @@ function csrf_default(opts = { noCsrfPatterns: [] }) {
|
|
|
11880
11838
|
if (ctx.internal) {
|
|
11881
11839
|
return next();
|
|
11882
11840
|
}
|
|
11883
|
-
const userToken =
|
|
11841
|
+
const userToken = ctx.user?.csrfToken;
|
|
11884
11842
|
if (!userToken) {
|
|
11885
11843
|
return next();
|
|
11886
11844
|
}
|
|
@@ -11940,10 +11898,7 @@ function pinoSettings() {
|
|
|
11940
11898
|
logger,
|
|
11941
11899
|
genReqId: correlator2.getId,
|
|
11942
11900
|
autoLogging: {
|
|
11943
|
-
ignore: (req) =>
|
|
11944
|
-
var _a;
|
|
11945
|
-
return !!((_a = req.url) == null ? void 0 : _a.includes("/health"));
|
|
11946
|
-
}
|
|
11901
|
+
ignore: (req) => !!req.url?.includes("/health")
|
|
11947
11902
|
},
|
|
11948
11903
|
serializers: {
|
|
11949
11904
|
req: (req) => {
|
|
@@ -12014,8 +11969,7 @@ var errorHandling_default = errorHandling;
|
|
|
12014
11969
|
|
|
12015
11970
|
// src/middleware/querystringToBody.ts
|
|
12016
11971
|
function querystringToBody_default(ctx, next) {
|
|
12017
|
-
|
|
12018
|
-
const queryString = (_a = ctx.request.query) == null ? void 0 : _a.query;
|
|
11972
|
+
const queryString = ctx.request.query?.query;
|
|
12019
11973
|
if (ctx.request.method.toLowerCase() !== "get") {
|
|
12020
11974
|
ctx.throw(
|
|
12021
11975
|
500,
|
|
@@ -12045,12 +11999,11 @@ __export(joi_validator_exports, {
|
|
|
12045
11999
|
var import_joi = __toESM(require("joi"));
|
|
12046
12000
|
function validate(schema, property) {
|
|
12047
12001
|
return (ctx, next) => {
|
|
12048
|
-
var _a;
|
|
12049
12002
|
if (!schema) {
|
|
12050
12003
|
return next();
|
|
12051
12004
|
}
|
|
12052
12005
|
let params2 = null;
|
|
12053
|
-
let reqProp =
|
|
12006
|
+
let reqProp = ctx.request?.[property];
|
|
12054
12007
|
if (ctx[property] != null) {
|
|
12055
12008
|
params2 = ctx[property];
|
|
12056
12009
|
} else if (reqProp != null) {
|
|
@@ -12189,7 +12142,6 @@ async function updateUserOAuth(userId, oAuthConfig) {
|
|
|
12189
12142
|
}
|
|
12190
12143
|
}
|
|
12191
12144
|
async function platformLogout(opts) {
|
|
12192
|
-
var _a;
|
|
12193
12145
|
const ctx = opts.ctx;
|
|
12194
12146
|
const userId = opts.userId;
|
|
12195
12147
|
const keepActiveSession = opts.keepActiveSession;
|
|
@@ -12206,7 +12158,7 @@ async function platformLogout(opts) {
|
|
|
12206
12158
|
}
|
|
12207
12159
|
const sessionIds = sessions.map(({ sessionId }) => sessionId);
|
|
12208
12160
|
await invalidateSessions(userId, { sessionIds, reason: "logout" });
|
|
12209
|
-
await auth_default.logout(
|
|
12161
|
+
await auth_default.logout(ctx.user?.email);
|
|
12210
12162
|
await invalidateUser(userId);
|
|
12211
12163
|
}
|
|
12212
12164
|
|
|
@@ -12322,7 +12274,7 @@ function validateAutomation(schema) {
|
|
|
12322
12274
|
runJoi(validator, schema);
|
|
12323
12275
|
}
|
|
12324
12276
|
function validate2(schema) {
|
|
12325
|
-
switch (schema
|
|
12277
|
+
switch (schema?.type) {
|
|
12326
12278
|
case "component" /* COMPONENT */:
|
|
12327
12279
|
validateComponent(schema);
|
|
12328
12280
|
break;
|
|
@@ -12386,7 +12338,7 @@ async function lookup(address) {
|
|
|
12386
12338
|
}
|
|
12387
12339
|
async function refreshBlacklist() {
|
|
12388
12340
|
const blacklist = environment_default.BLACKLIST_IPS;
|
|
12389
|
-
const list =
|
|
12341
|
+
const list = blacklist?.split(",") || [];
|
|
12390
12342
|
let final = [];
|
|
12391
12343
|
for (let addr of list) {
|
|
12392
12344
|
const trimmed = addr.trim();
|
|
@@ -12403,7 +12355,7 @@ async function isBlacklisted(address) {
|
|
|
12403
12355
|
if (!blackListArray) {
|
|
12404
12356
|
await refreshBlacklist();
|
|
12405
12357
|
}
|
|
12406
|
-
if (
|
|
12358
|
+
if (blackListArray?.length === 0) {
|
|
12407
12359
|
return false;
|
|
12408
12360
|
}
|
|
12409
12361
|
let ips;
|
|
@@ -12412,7 +12364,7 @@ async function isBlacklisted(address) {
|
|
|
12412
12364
|
} else {
|
|
12413
12365
|
ips = [address];
|
|
12414
12366
|
}
|
|
12415
|
-
return !!
|
|
12367
|
+
return !!blackListArray?.find((addr) => ips.includes(addr));
|
|
12416
12368
|
}
|
|
12417
12369
|
|
|
12418
12370
|
// src/docUpdates/index.ts
|
|
@@ -12558,6 +12510,7 @@ var init8 = (opts = {}) => {
|
|
|
12558
12510
|
errors,
|
|
12559
12511
|
events,
|
|
12560
12512
|
featureFlags,
|
|
12513
|
+
features,
|
|
12561
12514
|
getPublicError,
|
|
12562
12515
|
init,
|
|
12563
12516
|
installation,
|