@budibase/server 2.6.19-alpha.30 → 2.6.19-alpha.34
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/builder/assets/{index.8469b14c.css → index.a96c516c.css} +1 -1
- package/builder/assets/{index.3dd3d237.js → index.b6e30d5b.js} +3 -3
- package/builder/index.html +2 -2
- package/dist/automation.js +148 -90
- package/dist/automation.js.map +3 -3
- package/dist/index.js +234 -164
- package/dist/index.js.map +3 -3
- package/dist/query.js +27 -13
- package/dist/query.js.map +2 -2
- package/package.json +9 -8
- package/src/automations/logging/index.ts +21 -0
- package/src/environment.ts +1 -0
- package/src/middleware/builder.ts +22 -13
- package/src/threads/automation.ts +49 -28
- package/src/threads/index.ts +9 -3
- package/src/threads/utils.ts +2 -0
- package/src/utilities/fileSystem/app.ts +14 -4
package/dist/index.js
CHANGED
|
@@ -3368,9 +3368,76 @@ var init_users3 = __esm({
|
|
|
3368
3368
|
// ../backend-core/src/redis/redlockImpl.ts
|
|
3369
3369
|
var redlockImpl_exports = {};
|
|
3370
3370
|
__export(redlockImpl_exports, {
|
|
3371
|
-
doWithLock: () => doWithLock
|
|
3371
|
+
doWithLock: () => doWithLock,
|
|
3372
|
+
newRedlock: () => newRedlock
|
|
3372
3373
|
});
|
|
3373
|
-
|
|
3374
|
+
async function getClient(type, opts) {
|
|
3375
|
+
if (type === "custom" /* CUSTOM */) {
|
|
3376
|
+
return newRedlock(opts);
|
|
3377
|
+
}
|
|
3378
|
+
if (environment_default.isTest() && type !== "try_once" /* TRY_ONCE */) {
|
|
3379
|
+
return newRedlock(OPTIONS.TEST);
|
|
3380
|
+
}
|
|
3381
|
+
switch (type) {
|
|
3382
|
+
case "try_once" /* TRY_ONCE */: {
|
|
3383
|
+
return newRedlock(OPTIONS.TRY_ONCE);
|
|
3384
|
+
}
|
|
3385
|
+
case "try_twice" /* TRY_TWICE */: {
|
|
3386
|
+
return newRedlock(OPTIONS.TRY_TWICE);
|
|
3387
|
+
}
|
|
3388
|
+
case "default" /* DEFAULT */: {
|
|
3389
|
+
return newRedlock(OPTIONS.DEFAULT);
|
|
3390
|
+
}
|
|
3391
|
+
case "delay_500" /* DELAY_500 */: {
|
|
3392
|
+
return newRedlock(OPTIONS.DELAY_500);
|
|
3393
|
+
}
|
|
3394
|
+
default: {
|
|
3395
|
+
throw new Error(`Could not get redlock client: ${type}`);
|
|
3396
|
+
}
|
|
3397
|
+
}
|
|
3398
|
+
}
|
|
3399
|
+
async function newRedlock(opts = {}) {
|
|
3400
|
+
let options2 = { ...OPTIONS.DEFAULT, ...opts };
|
|
3401
|
+
const redisWrapper = await getLockClient();
|
|
3402
|
+
const client3 = redisWrapper.getClient();
|
|
3403
|
+
return new import_redlock.default([client3], options2);
|
|
3404
|
+
}
|
|
3405
|
+
function getLockName(opts) {
|
|
3406
|
+
const prefix = opts.systemLock ? "system" : getTenantId();
|
|
3407
|
+
let name = `lock:${prefix}_${opts.name}`;
|
|
3408
|
+
if (opts.resource) {
|
|
3409
|
+
name = name + `_${opts.resource}`;
|
|
3410
|
+
}
|
|
3411
|
+
return name;
|
|
3412
|
+
}
|
|
3413
|
+
async function doWithLock(opts, task) {
|
|
3414
|
+
const redlock = await getClient(opts.type, opts.customOptions);
|
|
3415
|
+
let lock;
|
|
3416
|
+
try {
|
|
3417
|
+
const name = getLockName(opts);
|
|
3418
|
+
lock = await redlock.lock(name, opts.ttl);
|
|
3419
|
+
const result = await task();
|
|
3420
|
+
return { executed: true, result };
|
|
3421
|
+
} catch (e) {
|
|
3422
|
+
console.warn("lock error");
|
|
3423
|
+
if (e.name === "LockError") {
|
|
3424
|
+
if (opts.type === "try_once" /* TRY_ONCE */) {
|
|
3425
|
+
return { executed: false };
|
|
3426
|
+
} else {
|
|
3427
|
+
console.error(e);
|
|
3428
|
+
throw e;
|
|
3429
|
+
}
|
|
3430
|
+
} else {
|
|
3431
|
+
console.error(e);
|
|
3432
|
+
throw e;
|
|
3433
|
+
}
|
|
3434
|
+
} finally {
|
|
3435
|
+
if (lock) {
|
|
3436
|
+
await lock.unlock();
|
|
3437
|
+
}
|
|
3438
|
+
}
|
|
3439
|
+
}
|
|
3440
|
+
var import_redlock, OPTIONS;
|
|
3374
3441
|
var init_redlockImpl = __esm({
|
|
3375
3442
|
"../backend-core/src/redis/redlockImpl.ts"() {
|
|
3376
3443
|
import_redlock = __toESM(require("redlock"));
|
|
@@ -3378,33 +3445,14 @@ var init_redlockImpl = __esm({
|
|
|
3378
3445
|
init_src();
|
|
3379
3446
|
init_context2();
|
|
3380
3447
|
init_environment2();
|
|
3381
|
-
getClient = async (type, opts) => {
|
|
3382
|
-
if (type === "custom" /* CUSTOM */) {
|
|
3383
|
-
return newRedlock(opts);
|
|
3384
|
-
}
|
|
3385
|
-
if (environment_default.isTest() && type !== "try_once" /* TRY_ONCE */) {
|
|
3386
|
-
return newRedlock(OPTIONS.TEST);
|
|
3387
|
-
}
|
|
3388
|
-
switch (type) {
|
|
3389
|
-
case "try_once" /* TRY_ONCE */: {
|
|
3390
|
-
return newRedlock(OPTIONS.TRY_ONCE);
|
|
3391
|
-
}
|
|
3392
|
-
case "default" /* DEFAULT */: {
|
|
3393
|
-
return newRedlock(OPTIONS.DEFAULT);
|
|
3394
|
-
}
|
|
3395
|
-
case "delay_500" /* DELAY_500 */: {
|
|
3396
|
-
return newRedlock(OPTIONS.DELAY_500);
|
|
3397
|
-
}
|
|
3398
|
-
default: {
|
|
3399
|
-
throw new Error(`Could not get redlock client: ${type}`);
|
|
3400
|
-
}
|
|
3401
|
-
}
|
|
3402
|
-
};
|
|
3403
3448
|
OPTIONS = {
|
|
3404
3449
|
TRY_ONCE: {
|
|
3405
3450
|
// immediately throws an error if the lock is already held
|
|
3406
3451
|
retryCount: 0
|
|
3407
3452
|
},
|
|
3453
|
+
TRY_TWICE: {
|
|
3454
|
+
retryCount: 1
|
|
3455
|
+
},
|
|
3408
3456
|
TEST: {
|
|
3409
3457
|
// higher retry count in unit tests
|
|
3410
3458
|
// due to high contention.
|
|
@@ -3431,44 +3479,6 @@ var init_redlockImpl = __esm({
|
|
|
3431
3479
|
retryDelay: 500
|
|
3432
3480
|
}
|
|
3433
3481
|
};
|
|
3434
|
-
newRedlock = async (opts = {}) => {
|
|
3435
|
-
let options2 = { ...OPTIONS.DEFAULT, ...opts };
|
|
3436
|
-
const redisWrapper = await getLockClient();
|
|
3437
|
-
const client3 = redisWrapper.getClient();
|
|
3438
|
-
return new import_redlock.default([client3], options2);
|
|
3439
|
-
};
|
|
3440
|
-
doWithLock = async (opts, task) => {
|
|
3441
|
-
const redlock = await getClient(opts.type, opts.customOptions);
|
|
3442
|
-
let lock;
|
|
3443
|
-
try {
|
|
3444
|
-
const prefix = opts.systemLock ? "system" : getTenantId();
|
|
3445
|
-
let name = `lock:${prefix}_${opts.name}`;
|
|
3446
|
-
if (opts.resource) {
|
|
3447
|
-
name = name + `_${opts.resource}`;
|
|
3448
|
-
}
|
|
3449
|
-
lock = await redlock.lock(name, opts.ttl);
|
|
3450
|
-
const result = await task();
|
|
3451
|
-
return { executed: true, result };
|
|
3452
|
-
} catch (e) {
|
|
3453
|
-
console.warn("lock error");
|
|
3454
|
-
if (e.name === "LockError") {
|
|
3455
|
-
if (opts.type === "try_once" /* TRY_ONCE */) {
|
|
3456
|
-
console.warn(e);
|
|
3457
|
-
return { executed: false };
|
|
3458
|
-
} else {
|
|
3459
|
-
console.error(e);
|
|
3460
|
-
throw e;
|
|
3461
|
-
}
|
|
3462
|
-
} else {
|
|
3463
|
-
console.error(e);
|
|
3464
|
-
throw e;
|
|
3465
|
-
}
|
|
3466
|
-
} finally {
|
|
3467
|
-
if (lock) {
|
|
3468
|
-
await lock.unlock();
|
|
3469
|
-
}
|
|
3470
|
-
}
|
|
3471
|
-
};
|
|
3472
3482
|
}
|
|
3473
3483
|
});
|
|
3474
3484
|
|
|
@@ -3648,6 +3658,7 @@ var init_logger = __esm({
|
|
|
3648
3658
|
}
|
|
3649
3659
|
const mergingObject = {
|
|
3650
3660
|
err: error2,
|
|
3661
|
+
pid: process.pid,
|
|
3651
3662
|
...contextObject
|
|
3652
3663
|
};
|
|
3653
3664
|
if (objects.length) {
|
|
@@ -9078,10 +9089,10 @@ function doesHaveBasePermission(permType, permLevel, rolesHierarchy) {
|
|
|
9078
9089
|
...new Set(rolesHierarchy.map((role) => role.permissionId))
|
|
9079
9090
|
];
|
|
9080
9091
|
const builtins = Object.values(BUILTIN_PERMISSIONS);
|
|
9081
|
-
let
|
|
9092
|
+
let permissions = flatten(
|
|
9082
9093
|
builtins.filter((builtin) => basePermissions.indexOf(builtin._id) !== -1).map((builtin) => builtin.permissions)
|
|
9083
9094
|
);
|
|
9084
|
-
for (let permission of
|
|
9095
|
+
for (let permission of permissions) {
|
|
9085
9096
|
if (permission.type === permType && getAllowedLevels(permission.level).indexOf(permLevel) !== -1) {
|
|
9086
9097
|
return true;
|
|
9087
9098
|
}
|
|
@@ -12063,6 +12074,7 @@ var init_environment3 = __esm({
|
|
|
12063
12074
|
ENABLE_ANALYTICS: process.env.ENABLE_ANALYTICS,
|
|
12064
12075
|
SELF_HOSTED: process.env.SELF_HOSTED,
|
|
12065
12076
|
HTTP_MB_LIMIT: process.env.HTTP_MB_LIMIT,
|
|
12077
|
+
FORKED_PROCESS_NAME: process.env.FORKED_PROCESS_NAME || "main",
|
|
12066
12078
|
// old
|
|
12067
12079
|
CLIENT_ID: process.env.CLIENT_ID,
|
|
12068
12080
|
_set(key, value) {
|
|
@@ -12296,10 +12308,11 @@ var init_clientLibrary = __esm({
|
|
|
12296
12308
|
});
|
|
12297
12309
|
|
|
12298
12310
|
// src/utilities/fileSystem/app.ts
|
|
12299
|
-
var import_path7, NODE_MODULES_PATH, createApp, deleteApp, getComponentLibraryManifest;
|
|
12311
|
+
var import_fs6, import_path7, NODE_MODULES_PATH, createApp, deleteApp, getComponentLibraryManifest;
|
|
12300
12312
|
var init_app7 = __esm({
|
|
12301
12313
|
"src/utilities/fileSystem/app.ts"() {
|
|
12302
12314
|
init_budibaseDir();
|
|
12315
|
+
import_fs6 = __toESM(require("fs"));
|
|
12303
12316
|
import_path7 = require("path");
|
|
12304
12317
|
init_constants4();
|
|
12305
12318
|
init_clientLibrary();
|
|
@@ -12317,9 +12330,19 @@ var init_app7 = __esm({
|
|
|
12317
12330
|
const appId = context_exports.getAppId();
|
|
12318
12331
|
const filename = "manifest.json";
|
|
12319
12332
|
if (environment_default2.isDev() || environment_default2.isTest()) {
|
|
12320
|
-
const
|
|
12321
|
-
|
|
12322
|
-
|
|
12333
|
+
const paths = [
|
|
12334
|
+
(0, import_path7.join)(TOP_LEVEL_PATH, "packages/client", filename),
|
|
12335
|
+
(0, import_path7.join)(process.cwd(), "client", filename)
|
|
12336
|
+
];
|
|
12337
|
+
for (let path6 of paths) {
|
|
12338
|
+
if (import_fs6.default.existsSync(path6)) {
|
|
12339
|
+
delete require.cache[require.resolve(path6)];
|
|
12340
|
+
return require(path6);
|
|
12341
|
+
}
|
|
12342
|
+
}
|
|
12343
|
+
throw new Error(
|
|
12344
|
+
`Unable to find ${filename} in development environment (may need to build).`
|
|
12345
|
+
);
|
|
12323
12346
|
}
|
|
12324
12347
|
if (!appId) {
|
|
12325
12348
|
throw new Error("No app ID found - cannot get component libraries");
|
|
@@ -12349,19 +12372,19 @@ var init_app7 = __esm({
|
|
|
12349
12372
|
async function getPluginImpl(path5, plugin) {
|
|
12350
12373
|
var _a2;
|
|
12351
12374
|
const hash2 = (_a2 = plugin.schema) == null ? void 0 : _a2.hash;
|
|
12352
|
-
if (!
|
|
12353
|
-
|
|
12375
|
+
if (!import_fs7.default.existsSync(path5)) {
|
|
12376
|
+
import_fs7.default.mkdirSync(path5);
|
|
12354
12377
|
}
|
|
12355
12378
|
const filename = (0, import_path8.join)(path5, plugin.name);
|
|
12356
12379
|
const metadataName = `${filename}.bbmetadata`;
|
|
12357
|
-
if (
|
|
12358
|
-
const currentHash =
|
|
12380
|
+
if (import_fs7.default.existsSync(filename)) {
|
|
12381
|
+
const currentHash = import_fs7.default.readFileSync(metadataName, "utf8");
|
|
12359
12382
|
if (currentHash === hash2) {
|
|
12360
12383
|
return require(filename);
|
|
12361
12384
|
} else {
|
|
12362
12385
|
console.log(`Updating plugin: ${plugin.name}`);
|
|
12363
12386
|
delete require.cache[require.resolve(filename)];
|
|
12364
|
-
|
|
12387
|
+
import_fs7.default.unlinkSync(filename);
|
|
12365
12388
|
}
|
|
12366
12389
|
}
|
|
12367
12390
|
const pluginKey = objectStore_exports2.getPluginJSKey(plugin);
|
|
@@ -12369,15 +12392,15 @@ async function getPluginImpl(path5, plugin) {
|
|
|
12369
12392
|
objectStore_exports2.ObjectStoreBuckets.PLUGINS,
|
|
12370
12393
|
pluginKey
|
|
12371
12394
|
);
|
|
12372
|
-
|
|
12373
|
-
|
|
12395
|
+
import_fs7.default.writeFileSync(filename, pluginJs);
|
|
12396
|
+
import_fs7.default.writeFileSync(metadataName, hash2);
|
|
12374
12397
|
return require(filename);
|
|
12375
12398
|
}
|
|
12376
|
-
var
|
|
12399
|
+
var import_fs7, import_path8, DATASOURCE_PATH, AUTOMATION_PATH, getPluginMetadata, getDatasourcePlugin, getAutomationPlugin;
|
|
12377
12400
|
var init_plugin5 = __esm({
|
|
12378
12401
|
"src/utilities/fileSystem/plugin.ts"() {
|
|
12379
12402
|
init_budibaseDir();
|
|
12380
|
-
|
|
12403
|
+
import_fs7 = __toESM(require("fs"));
|
|
12381
12404
|
import_path8 = require("path");
|
|
12382
12405
|
init_src2();
|
|
12383
12406
|
DATASOURCE_PATH = (0, import_path8.join)(budibaseTempDir2(), "datasource");
|
|
@@ -12385,8 +12408,8 @@ var init_plugin5 = __esm({
|
|
|
12385
12408
|
getPluginMetadata = async (path5) => {
|
|
12386
12409
|
let metadata = {};
|
|
12387
12410
|
try {
|
|
12388
|
-
const pkg2 =
|
|
12389
|
-
const schema =
|
|
12411
|
+
const pkg2 = import_fs7.default.readFileSync((0, import_path8.join)(path5, "package.json"), "utf8");
|
|
12412
|
+
const schema = import_fs7.default.readFileSync((0, import_path8.join)(path5, "schema.json"), "utf8");
|
|
12390
12413
|
metadata.schema = JSON.parse(schema);
|
|
12391
12414
|
metadata.package = JSON.parse(pkg2);
|
|
12392
12415
|
if (!metadata.package.name || !metadata.package.version || !metadata.package.description) {
|
|
@@ -13654,21 +13677,21 @@ __export(version_exports, {
|
|
|
13654
13677
|
getLicenseVersion: () => getLicenseVersion,
|
|
13655
13678
|
getProVersion: () => getProVersion
|
|
13656
13679
|
});
|
|
13657
|
-
var
|
|
13680
|
+
var import_fs8, import_path9, getLicenseVersion, getProVersion;
|
|
13658
13681
|
var init_version2 = __esm({
|
|
13659
13682
|
"../pro/packages/pro/src/constants/version.ts"() {
|
|
13660
13683
|
init_src2();
|
|
13661
|
-
|
|
13684
|
+
import_fs8 = __toESM(require("fs"));
|
|
13662
13685
|
import_path9 = __toESM(require("path"));
|
|
13663
13686
|
getLicenseVersion = () => {
|
|
13664
13687
|
if (environment_default.isDev()) {
|
|
13665
13688
|
const DEV_VER_FILENAME = "dev-version.txt";
|
|
13666
13689
|
const verFile = import_path9.default.join(objectStore_exports2.budibaseTempDir(), DEV_VER_FILENAME);
|
|
13667
|
-
if (
|
|
13668
|
-
return
|
|
13690
|
+
if (import_fs8.default.existsSync(verFile)) {
|
|
13691
|
+
return import_fs8.default.readFileSync(verFile, "utf8");
|
|
13669
13692
|
} else {
|
|
13670
13693
|
const devVer = utils_exports2.newid();
|
|
13671
|
-
|
|
13694
|
+
import_fs8.default.writeFileSync(verFile, devVer);
|
|
13672
13695
|
return devVer;
|
|
13673
13696
|
}
|
|
13674
13697
|
} else {
|
|
@@ -14114,21 +14137,21 @@ function getOfflineLicense() {
|
|
|
14114
14137
|
}
|
|
14115
14138
|
}
|
|
14116
14139
|
function getOfflineLicenseFromDisk() {
|
|
14117
|
-
if (
|
|
14118
|
-
const token =
|
|
14140
|
+
if (import_fs9.default.existsSync(LICENSE_FILE_PATH)) {
|
|
14141
|
+
const token = import_fs9.default.readFileSync(LICENSE_FILE_PATH, { encoding: "utf-8" });
|
|
14119
14142
|
return import_jsonwebtoken.default.verify(token, PUBLIC_KEY, { algorithms: ["RS256"] });
|
|
14120
14143
|
}
|
|
14121
14144
|
}
|
|
14122
14145
|
function writeOfflineLicenseToDisk(signedLicense) {
|
|
14123
|
-
|
|
14146
|
+
import_fs9.default.writeFileSync(LICENSE_FILE_PATH, signedLicense, { encoding: "utf-8" });
|
|
14124
14147
|
}
|
|
14125
14148
|
function deleteOfflineLicense() {
|
|
14126
|
-
|
|
14149
|
+
import_fs9.default.rmSync(LICENSE_FILE_PATH, { force: true });
|
|
14127
14150
|
}
|
|
14128
|
-
var
|
|
14151
|
+
var import_fs9, import_path10, import_os2, import_jsonwebtoken, SUB_DIRECTORY, DIRECTORY, OFFLINE_LICENSE_FILE, LICENSE_FILE_PATH, PUBLIC_KEY;
|
|
14129
14152
|
var init_offline = __esm({
|
|
14130
14153
|
"../pro/packages/pro/src/sdk/licensing/licenses/offline.ts"() {
|
|
14131
|
-
|
|
14154
|
+
import_fs9 = __toESM(require("fs"));
|
|
14132
14155
|
import_path10 = require("path");
|
|
14133
14156
|
import_os2 = require("os");
|
|
14134
14157
|
import_jsonwebtoken = __toESM(require("jsonwebtoken"));
|
|
@@ -14137,8 +14160,8 @@ var init_offline = __esm({
|
|
|
14137
14160
|
DIRECTORY = (0, import_path10.join)((0, import_os2.tmpdir)(), SUB_DIRECTORY);
|
|
14138
14161
|
OFFLINE_LICENSE_FILE = "offline_license.txt";
|
|
14139
14162
|
LICENSE_FILE_PATH = (0, import_path10.join)(DIRECTORY, OFFLINE_LICENSE_FILE);
|
|
14140
|
-
if (!
|
|
14141
|
-
|
|
14163
|
+
if (!import_fs9.default.existsSync(DIRECTORY)) {
|
|
14164
|
+
import_fs9.default.mkdirSync(DIRECTORY);
|
|
14142
14165
|
}
|
|
14143
14166
|
PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvz3jePLCFBXZ19c8Dpkv\nXtSgOhKFOcvQdo/LV0KJRUzQWDPWuO4ILtBtnqhjtIzZH4CH0qCYBet5L6Qr4CM1\nl2HXiAD1Q2rlHNW9wDaYyKb1F5f+v4RyqCAyzlkwRdksmkLeECTboojNnmRCrE3C\n8suunQP5bEScqEY2kclqzSf8e6xqMzPUg3mL/pNa1iEv7TuLbU9nJfgR36l0WmZY\n94fWnSaT8OSXSqcxsaByf06gfS3HAoTJNc7eqz1Hf9fUORQGPUAnFK8cT3SfdA36\nd/o3ZWE1TTj1zYwlCLN5qRKr3hU8nC3xEYNEbkB9SfTRaOq9Q7P8WmfLkoCPm3pR\nmwIDAQAB\n-----END PUBLIC KEY-----\n";
|
|
14144
14167
|
}
|
|
@@ -15593,12 +15616,12 @@ var init_groups6 = __esm({
|
|
|
15593
15616
|
|
|
15594
15617
|
// ../pro/packages/pro/src/utilities/fileSystem.ts
|
|
15595
15618
|
function loadJSFile(directory, name) {
|
|
15596
|
-
return
|
|
15619
|
+
return import_fs10.default.readFileSync((0, import_path11.join)(directory, name), "utf8");
|
|
15597
15620
|
}
|
|
15598
|
-
var
|
|
15621
|
+
var import_fs10, import_path11;
|
|
15599
15622
|
var init_fileSystem2 = __esm({
|
|
15600
15623
|
"../pro/packages/pro/src/utilities/fileSystem.ts"() {
|
|
15601
|
-
|
|
15624
|
+
import_fs10 = __toESM(require("fs"));
|
|
15602
15625
|
import_path11 = require("path");
|
|
15603
15626
|
}
|
|
15604
15627
|
});
|
|
@@ -18567,8 +18590,8 @@ async function runBackup(trigger3, tenantId, appId, opts) {
|
|
|
18567
18590
|
}
|
|
18568
18591
|
});
|
|
18569
18592
|
await updateMetadata2("complete" /* COMPLETE */, { filename, contents });
|
|
18570
|
-
if (
|
|
18571
|
-
|
|
18593
|
+
if (import_fs11.default.existsSync(tarPath)) {
|
|
18594
|
+
import_fs11.default.rmSync(tarPath);
|
|
18572
18595
|
}
|
|
18573
18596
|
} catch (err) {
|
|
18574
18597
|
logging_exports.logAlert("App backup error", err);
|
|
@@ -18626,14 +18649,14 @@ async function exportProcessor(job, opts) {
|
|
|
18626
18649
|
});
|
|
18627
18650
|
});
|
|
18628
18651
|
}
|
|
18629
|
-
var
|
|
18652
|
+
var import_fs11;
|
|
18630
18653
|
var init_processing = __esm({
|
|
18631
18654
|
"../pro/packages/pro/src/sdk/backups/processing.ts"() {
|
|
18632
18655
|
init_src2();
|
|
18633
18656
|
init_backup5();
|
|
18634
18657
|
init_src();
|
|
18635
18658
|
init_queue4();
|
|
18636
|
-
|
|
18659
|
+
import_fs11 = __toESM(require("fs"));
|
|
18637
18660
|
}
|
|
18638
18661
|
});
|
|
18639
18662
|
|
|
@@ -19316,15 +19339,15 @@ async function downloadBackup(ctx) {
|
|
|
19316
19339
|
const backupId = ctx.params.backupId;
|
|
19317
19340
|
const { metadata, path: path5 } = await backups_default.downloadAppBackup(backupId);
|
|
19318
19341
|
ctx.attachment(`backup-${metadata.timestamp}.tar.gz`);
|
|
19319
|
-
ctx.body =
|
|
19342
|
+
ctx.body = import_fs12.default.createReadStream(path5);
|
|
19320
19343
|
}
|
|
19321
|
-
var
|
|
19344
|
+
var import_fs12;
|
|
19322
19345
|
var init_backups3 = __esm({
|
|
19323
19346
|
"../pro/packages/pro/src/api/controllers/apps/backups.ts"() {
|
|
19324
19347
|
init_src();
|
|
19325
19348
|
init_sdk2();
|
|
19326
19349
|
init_src2();
|
|
19327
|
-
|
|
19350
|
+
import_fs12 = __toESM(require("fs"));
|
|
19328
19351
|
}
|
|
19329
19352
|
});
|
|
19330
19353
|
|
|
@@ -21867,13 +21890,21 @@ async function updateAppUpdatedAt(ctx) {
|
|
|
21867
21890
|
}
|
|
21868
21891
|
await db_exports.doWithDB(appId, async (db2) => {
|
|
21869
21892
|
var _a2;
|
|
21870
|
-
|
|
21871
|
-
|
|
21872
|
-
|
|
21873
|
-
|
|
21874
|
-
|
|
21875
|
-
|
|
21876
|
-
|
|
21893
|
+
try {
|
|
21894
|
+
const metadata = await db2.get(DocumentType2.APP_METADATA);
|
|
21895
|
+
metadata.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
21896
|
+
metadata.updatedBy = getGlobalIDFromUserMetadataID2((_a2 = ctx.user) == null ? void 0 : _a2.userId);
|
|
21897
|
+
const response2 = await db2.put(metadata);
|
|
21898
|
+
metadata._rev = response2.rev;
|
|
21899
|
+
await cache_exports.app.invalidateAppMetadata(appId, metadata);
|
|
21900
|
+
await setDebounce(appId, DEBOUNCE_TIME_SEC);
|
|
21901
|
+
} catch (err) {
|
|
21902
|
+
if ((err == null ? void 0 : err.status) === 409) {
|
|
21903
|
+
return;
|
|
21904
|
+
} else {
|
|
21905
|
+
throw err;
|
|
21906
|
+
}
|
|
21907
|
+
}
|
|
21877
21908
|
});
|
|
21878
21909
|
}
|
|
21879
21910
|
async function builder(ctx) {
|
|
@@ -24371,13 +24402,17 @@ var init_threads = __esm({
|
|
|
24371
24402
|
this.count = opts.count ? opts.count : 1;
|
|
24372
24403
|
this.disableThreading = this.shouldDisableThreading();
|
|
24373
24404
|
if (!this.disableThreading) {
|
|
24405
|
+
console.debug(
|
|
24406
|
+
`[${environment_default2.FORKED_PROCESS_NAME}] initialising worker farm type=${type}`
|
|
24407
|
+
);
|
|
24374
24408
|
const workerOpts = {
|
|
24375
24409
|
autoStart: true,
|
|
24376
24410
|
maxConcurrentWorkers: this.count,
|
|
24377
24411
|
workerOptions: {
|
|
24378
24412
|
env: {
|
|
24379
24413
|
...process.env,
|
|
24380
|
-
FORKED_PROCESS: "1"
|
|
24414
|
+
FORKED_PROCESS: "1",
|
|
24415
|
+
FORKED_PROCESS_NAME: type
|
|
24381
24416
|
}
|
|
24382
24417
|
}
|
|
24383
24418
|
};
|
|
@@ -24387,6 +24422,10 @@ var init_threads = __esm({
|
|
|
24387
24422
|
}
|
|
24388
24423
|
this.workers = (0, import_worker_farm.default)(workerOpts, typeToFile(type), ["execute"]);
|
|
24389
24424
|
_Thread.workerRefs.push(this.workers);
|
|
24425
|
+
} else {
|
|
24426
|
+
console.debug(
|
|
24427
|
+
`[${environment_default2.FORKED_PROCESS_NAME}] skipping worker farm type=${type}`
|
|
24428
|
+
);
|
|
24390
24429
|
}
|
|
24391
24430
|
}
|
|
24392
24431
|
shouldDisableThreading() {
|
|
@@ -24398,9 +24437,7 @@ var init_threads = __esm({
|
|
|
24398
24437
|
function fire(worker) {
|
|
24399
24438
|
worker.execute(job, (err, response2) => {
|
|
24400
24439
|
if (err && err.type === "TimeoutError") {
|
|
24401
|
-
reject(
|
|
24402
|
-
new Error(`Query response time exceeded ${timeout2}ms timeout.`)
|
|
24403
|
-
);
|
|
24440
|
+
reject(new Error(`Thread timeout exceeded ${timeout2}ms timeout.`));
|
|
24404
24441
|
} else if (err) {
|
|
24405
24442
|
reject(err);
|
|
24406
24443
|
} else {
|
|
@@ -24737,8 +24774,10 @@ function makeVariableKey(queryId, variable) {
|
|
|
24737
24774
|
}
|
|
24738
24775
|
function threadSetup() {
|
|
24739
24776
|
if (environment_default2.isTest() || environment_default2.DISABLE_THREADING || !environment_default2.isInThread()) {
|
|
24777
|
+
console.debug(`[${environment_default2.FORKED_PROCESS_NAME}] thread setup skipped`);
|
|
24740
24778
|
return;
|
|
24741
24779
|
}
|
|
24780
|
+
console.debug(`[${environment_default2.FORKED_PROCESS_NAME}] thread setup running`);
|
|
24742
24781
|
init10();
|
|
24743
24782
|
}
|
|
24744
24783
|
async function checkCacheForDynamicVariable(queryId, variable) {
|
|
@@ -24840,7 +24879,7 @@ async function exportDB(dbName, opts = {}) {
|
|
|
24840
24879
|
return db_exports.doWithDB(dbName, async (db2) => {
|
|
24841
24880
|
if (opts == null ? void 0 : opts.exportPath) {
|
|
24842
24881
|
const path5 = opts == null ? void 0 : opts.exportPath;
|
|
24843
|
-
const writeStream =
|
|
24882
|
+
const writeStream = import_fs13.default.createWriteStream(path5);
|
|
24844
24883
|
await db2.dump(writeStream, exportOpts);
|
|
24845
24884
|
return path5;
|
|
24846
24885
|
} else {
|
|
@@ -24875,7 +24914,7 @@ async function exportApp(appId, config) {
|
|
|
24875
24914
|
ObjectStoreBuckets2.APPS,
|
|
24876
24915
|
(0, import_path12.join)(appPath, path5)
|
|
24877
24916
|
);
|
|
24878
|
-
|
|
24917
|
+
import_fs13.default.writeFileSync((0, import_path12.join)(tmpPath, path5), contents);
|
|
24879
24918
|
}
|
|
24880
24919
|
} else {
|
|
24881
24920
|
tmpPath = await objectStore_exports2.retrieveDirectory(
|
|
@@ -24885,13 +24924,13 @@ async function exportApp(appId, config) {
|
|
|
24885
24924
|
}
|
|
24886
24925
|
}
|
|
24887
24926
|
const downloadedPath = (0, import_path12.join)(tmpPath, appPath);
|
|
24888
|
-
if (
|
|
24889
|
-
const allFiles =
|
|
24927
|
+
if (import_fs13.default.existsSync(downloadedPath)) {
|
|
24928
|
+
const allFiles = import_fs13.default.readdirSync(downloadedPath);
|
|
24890
24929
|
for (let file of allFiles) {
|
|
24891
24930
|
const path5 = (0, import_path12.join)(downloadedPath, file);
|
|
24892
|
-
|
|
24931
|
+
import_fs13.default.renameSync(path5, (0, import_path12.join)(downloadedPath, "..", file));
|
|
24893
24932
|
}
|
|
24894
|
-
|
|
24933
|
+
import_fs13.default.rmdirSync(downloadedPath);
|
|
24895
24934
|
}
|
|
24896
24935
|
const dbPath = (0, import_path12.join)(tmpPath, DB_EXPORT_FILE);
|
|
24897
24936
|
await exportDB(appId, {
|
|
@@ -24899,8 +24938,8 @@ async function exportApp(appId, config) {
|
|
|
24899
24938
|
exportPath: dbPath
|
|
24900
24939
|
});
|
|
24901
24940
|
if (config == null ? void 0 : config.tar) {
|
|
24902
|
-
const tarPath = tarFilesToTmp(tmpPath,
|
|
24903
|
-
|
|
24941
|
+
const tarPath = tarFilesToTmp(tmpPath, import_fs13.default.readdirSync(tmpPath));
|
|
24942
|
+
import_fs13.default.rmSync(tmpPath, { recursive: true, force: true });
|
|
24904
24943
|
return tarPath;
|
|
24905
24944
|
} else {
|
|
24906
24945
|
return tmpPath;
|
|
@@ -24914,7 +24953,7 @@ async function streamExportApp(appId, excludeRows) {
|
|
|
24914
24953
|
});
|
|
24915
24954
|
return streamFile(tmpPath);
|
|
24916
24955
|
}
|
|
24917
|
-
var
|
|
24956
|
+
var import_fs13, import_path12, uuid3, tar3, MemoryStream2;
|
|
24918
24957
|
var init_exports2 = __esm({
|
|
24919
24958
|
"src/sdk/app/backups/exports.ts"() {
|
|
24920
24959
|
init_src2();
|
|
@@ -24923,7 +24962,7 @@ var init_exports2 = __esm({
|
|
|
24923
24962
|
init_constants4();
|
|
24924
24963
|
init_utils9();
|
|
24925
24964
|
init_constants7();
|
|
24926
|
-
|
|
24965
|
+
import_fs13 = __toESM(require("fs"));
|
|
24927
24966
|
import_path12 = require("path");
|
|
24928
24967
|
init_environment3();
|
|
24929
24968
|
uuid3 = require("uuid/v4");
|
|
@@ -25004,16 +25043,16 @@ async function getTemplateStream(template) {
|
|
|
25004
25043
|
throw new Error("Cannot import a non-text based file.");
|
|
25005
25044
|
}
|
|
25006
25045
|
if (template.file) {
|
|
25007
|
-
return
|
|
25046
|
+
return import_fs14.default.createReadStream(template.file.path);
|
|
25008
25047
|
} else if (template.key) {
|
|
25009
25048
|
const [type, name] = template.key.split("/");
|
|
25010
25049
|
const tmpPath = await downloadTemplate(type, name);
|
|
25011
|
-
return
|
|
25050
|
+
return import_fs14.default.createReadStream((0, import_path13.join)(tmpPath, name, "db", "dump.txt"));
|
|
25012
25051
|
}
|
|
25013
25052
|
}
|
|
25014
25053
|
function untarFile(file) {
|
|
25015
25054
|
const tmpPath = (0, import_path13.join)(budibaseTempDir2(), uuid4());
|
|
25016
|
-
|
|
25055
|
+
import_fs14.default.mkdirSync(tmpPath);
|
|
25017
25056
|
tar4.extract({
|
|
25018
25057
|
sync: true,
|
|
25019
25058
|
cwd: tmpPath,
|
|
@@ -25022,20 +25061,20 @@ function untarFile(file) {
|
|
|
25022
25061
|
return tmpPath;
|
|
25023
25062
|
}
|
|
25024
25063
|
function getGlobalDBFile(tmpPath) {
|
|
25025
|
-
return
|
|
25064
|
+
return import_fs14.default.readFileSync((0, import_path13.join)(tmpPath, GLOBAL_DB_EXPORT_FILE), "utf8");
|
|
25026
25065
|
}
|
|
25027
25066
|
function getListOfAppsInMulti(tmpPath) {
|
|
25028
|
-
return
|
|
25067
|
+
return import_fs14.default.readdirSync(tmpPath).filter((dir) => dir !== GLOBAL_DB_EXPORT_FILE);
|
|
25029
25068
|
}
|
|
25030
25069
|
async function importApp(appId, db2, template) {
|
|
25031
25070
|
var _a2, _b2;
|
|
25032
25071
|
let prodAppId = db_exports.getProdAppID(appId);
|
|
25033
25072
|
let dbStream;
|
|
25034
25073
|
const isTar = template.file && ((_b2 = (_a2 = template == null ? void 0 : template.file) == null ? void 0 : _a2.type) == null ? void 0 : _b2.endsWith("gzip"));
|
|
25035
|
-
const isDirectory = template.file &&
|
|
25074
|
+
const isDirectory = template.file && import_fs14.default.lstatSync(template.file.path).isDirectory();
|
|
25036
25075
|
if (template.file && (isTar || isDirectory)) {
|
|
25037
25076
|
const tmpPath = isTar ? untarFile(template.file) : template.file.path;
|
|
25038
|
-
const contents =
|
|
25077
|
+
const contents = import_fs14.default.readdirSync(tmpPath);
|
|
25039
25078
|
if (contents.length) {
|
|
25040
25079
|
let promises = [];
|
|
25041
25080
|
let excludedFiles = [GLOBAL_DB_EXPORT_FILE, DB_EXPORT_FILE];
|
|
@@ -25045,7 +25084,7 @@ async function importApp(appId, db2, template) {
|
|
|
25045
25084
|
continue;
|
|
25046
25085
|
}
|
|
25047
25086
|
filename = (0, import_path13.join)(prodAppId, filename);
|
|
25048
|
-
if (
|
|
25087
|
+
if (import_fs14.default.lstatSync(path5).isDirectory()) {
|
|
25049
25088
|
promises.push(
|
|
25050
25089
|
objectStore_exports2.uploadDirectory(ObjectStoreBuckets2.APPS, path5, filename)
|
|
25051
25090
|
);
|
|
@@ -25061,7 +25100,7 @@ async function importApp(appId, db2, template) {
|
|
|
25061
25100
|
}
|
|
25062
25101
|
await Promise.all(promises);
|
|
25063
25102
|
}
|
|
25064
|
-
dbStream =
|
|
25103
|
+
dbStream = import_fs14.default.createReadStream((0, import_path13.join)(tmpPath, DB_EXPORT_FILE));
|
|
25065
25104
|
} else {
|
|
25066
25105
|
dbStream = await getTemplateStream(template);
|
|
25067
25106
|
}
|
|
@@ -25073,7 +25112,7 @@ async function importApp(appId, db2, template) {
|
|
|
25073
25112
|
await updateAutomations(prodAppId, db2);
|
|
25074
25113
|
return ok;
|
|
25075
25114
|
}
|
|
25076
|
-
var import_path13,
|
|
25115
|
+
var import_path13, import_fs14, uuid4, tar4;
|
|
25077
25116
|
var init_imports = __esm({
|
|
25078
25117
|
"src/sdk/app/backups/imports.ts"() {
|
|
25079
25118
|
init_src2();
|
|
@@ -25083,7 +25122,7 @@ var init_imports = __esm({
|
|
|
25083
25122
|
init_fileSystem();
|
|
25084
25123
|
init_constants4();
|
|
25085
25124
|
import_path13 = require("path");
|
|
25086
|
-
|
|
25125
|
+
import_fs14 = __toESM(require("fs"));
|
|
25087
25126
|
init_sdk3();
|
|
25088
25127
|
init_src();
|
|
25089
25128
|
uuid4 = require("uuid/v4");
|
|
@@ -37486,10 +37525,26 @@ var init_AutomationEmitter = __esm({
|
|
|
37486
37525
|
});
|
|
37487
37526
|
|
|
37488
37527
|
// src/automations/logging/index.ts
|
|
37528
|
+
function sanitiseResults(results) {
|
|
37529
|
+
const message = `[removed] - max results size of ${MAX_LOG_SIZE_MB}MB exceeded`;
|
|
37530
|
+
for (let step of results.steps) {
|
|
37531
|
+
step.inputs = {
|
|
37532
|
+
message
|
|
37533
|
+
};
|
|
37534
|
+
step.outputs = {
|
|
37535
|
+
message,
|
|
37536
|
+
success: step.outputs.success
|
|
37537
|
+
};
|
|
37538
|
+
}
|
|
37539
|
+
}
|
|
37489
37540
|
async function storeLog2(automation, results) {
|
|
37490
37541
|
if (environment_default2.DISABLE_AUTOMATION_LOGS) {
|
|
37491
37542
|
return;
|
|
37492
37543
|
}
|
|
37544
|
+
const bytes = (0, import_object_sizeof.default)(results);
|
|
37545
|
+
if (bytes / MB_IN_BYTES > MAX_LOG_SIZE_MB) {
|
|
37546
|
+
sanitiseResults(results);
|
|
37547
|
+
}
|
|
37493
37548
|
await automations_exports.logs.storeLog(automation, results);
|
|
37494
37549
|
}
|
|
37495
37550
|
async function checkAppMetadata(apps2) {
|
|
@@ -37514,17 +37569,21 @@ async function checkAppMetadata(apps2) {
|
|
|
37514
37569
|
}
|
|
37515
37570
|
return apps2;
|
|
37516
37571
|
}
|
|
37572
|
+
var import_object_sizeof, MAX_LOG_SIZE_MB, MB_IN_BYTES;
|
|
37517
37573
|
var init_logging3 = __esm({
|
|
37518
37574
|
"src/automations/logging/index.ts"() {
|
|
37519
37575
|
init_environment3();
|
|
37520
37576
|
init_src4();
|
|
37521
37577
|
init_src2();
|
|
37578
|
+
import_object_sizeof = __toESM(require("object-sizeof"));
|
|
37579
|
+
MAX_LOG_SIZE_MB = 5;
|
|
37580
|
+
MB_IN_BYTES = 1024 * 1024;
|
|
37522
37581
|
}
|
|
37523
37582
|
});
|
|
37524
37583
|
|
|
37525
37584
|
// src/threads/automation.ts
|
|
37526
|
-
function getLoopIterations(loopStep
|
|
37527
|
-
|
|
37585
|
+
function getLoopIterations(loopStep) {
|
|
37586
|
+
let binding = loopStep.inputs.binding;
|
|
37528
37587
|
if (!binding) {
|
|
37529
37588
|
return 0;
|
|
37530
37589
|
}
|
|
@@ -37558,7 +37617,7 @@ function executeSynchronously(job) {
|
|
|
37558
37617
|
});
|
|
37559
37618
|
});
|
|
37560
37619
|
}
|
|
37561
|
-
var import_string_templates8, import_fp8, FILTER_STEP_ID, LOOP_STEP_ID, CRON_STEP_ID, STOPPED_STATUS, Orchestrator, removeStalled;
|
|
37620
|
+
var import_string_templates8, import_fp8, import_perf_hooks2, FILTER_STEP_ID, LOOP_STEP_ID, CRON_STEP_ID, STOPPED_STATUS, Orchestrator, removeStalled;
|
|
37562
37621
|
var init_automation4 = __esm({
|
|
37563
37622
|
"src/threads/automation.ts"() {
|
|
37564
37623
|
init_utils18();
|
|
@@ -37574,6 +37633,7 @@ var init_automation4 = __esm({
|
|
|
37574
37633
|
init_src2();
|
|
37575
37634
|
import_string_templates8 = __toESM(require_src2());
|
|
37576
37635
|
import_fp8 = require("lodash/fp");
|
|
37636
|
+
import_perf_hooks2 = require("perf_hooks");
|
|
37577
37637
|
init_utils20();
|
|
37578
37638
|
init_environment3();
|
|
37579
37639
|
utils_default.threadSetup();
|
|
@@ -37585,7 +37645,6 @@ var init_automation4 = __esm({
|
|
|
37585
37645
|
constructor(job) {
|
|
37586
37646
|
let automation = job.data.automation;
|
|
37587
37647
|
let triggerOutput = job.data.event;
|
|
37588
|
-
let timeout2 = job.data.event.timeout;
|
|
37589
37648
|
const metadata = triggerOutput.metadata;
|
|
37590
37649
|
this._chainCount = metadata ? metadata.automationChainCount : 0;
|
|
37591
37650
|
this._appId = triggerOutput.appId;
|
|
@@ -37719,7 +37778,7 @@ var init_automation4 = __esm({
|
|
|
37719
37778
|
});
|
|
37720
37779
|
}
|
|
37721
37780
|
async execute() {
|
|
37722
|
-
var _a2;
|
|
37781
|
+
var _a2, _b2;
|
|
37723
37782
|
this._context.env = await getEnvironmentVariables2();
|
|
37724
37783
|
let automation = this._automation;
|
|
37725
37784
|
let stopped = false;
|
|
@@ -37738,6 +37797,7 @@ var init_automation4 = __esm({
|
|
|
37738
37797
|
return;
|
|
37739
37798
|
}
|
|
37740
37799
|
}
|
|
37800
|
+
const start2 = import_perf_hooks2.performance.now();
|
|
37741
37801
|
for (let step of automation.definition.steps) {
|
|
37742
37802
|
if (timeoutFlag) {
|
|
37743
37803
|
break;
|
|
@@ -37756,20 +37816,16 @@ var init_automation4 = __esm({
|
|
|
37756
37816
|
}
|
|
37757
37817
|
if (loopStep) {
|
|
37758
37818
|
input = await (0, import_string_templates8.processObject)(loopStep.inputs, this._context);
|
|
37759
|
-
iterations = getLoopIterations(loopStep
|
|
37819
|
+
iterations = getLoopIterations(loopStep);
|
|
37760
37820
|
}
|
|
37761
37821
|
for (let index2 = 0; index2 < iterations; index2++) {
|
|
37762
37822
|
let originalStepInput = (0, import_fp8.cloneDeep)(step.inputs);
|
|
37763
37823
|
if (loopStep && input.binding) {
|
|
37764
|
-
let newInput = await (0, import_string_templates8.processObject)(
|
|
37765
|
-
loopStep.inputs,
|
|
37766
|
-
(0, import_fp8.cloneDeep)(this._context)
|
|
37767
|
-
);
|
|
37768
37824
|
let tempOutput = { items: loopSteps, iterations: iterationCount };
|
|
37769
37825
|
try {
|
|
37770
|
-
|
|
37826
|
+
loopStep.inputs.binding = typecastForLooping(
|
|
37771
37827
|
loopStep,
|
|
37772
|
-
|
|
37828
|
+
loopStep.inputs
|
|
37773
37829
|
);
|
|
37774
37830
|
} catch (err) {
|
|
37775
37831
|
this.updateContextAndOutput(loopStepNumber, step, tempOutput, {
|
|
@@ -37782,7 +37838,7 @@ var init_automation4 = __esm({
|
|
|
37782
37838
|
}
|
|
37783
37839
|
let item = [];
|
|
37784
37840
|
if (typeof loopStep.inputs.binding === "string" && loopStep.inputs.option === "String") {
|
|
37785
|
-
item = stringSplit(
|
|
37841
|
+
item = stringSplit(loopStep.inputs.binding);
|
|
37786
37842
|
} else if (Array.isArray(loopStep.inputs.binding)) {
|
|
37787
37843
|
item = loopStep.inputs.binding;
|
|
37788
37844
|
}
|
|
@@ -37925,7 +37981,21 @@ var init_automation4 = __esm({
|
|
|
37925
37981
|
loopSteps = [];
|
|
37926
37982
|
}
|
|
37927
37983
|
}
|
|
37928
|
-
|
|
37984
|
+
const end2 = import_perf_hooks2.performance.now();
|
|
37985
|
+
const executionTime = end2 - start2;
|
|
37986
|
+
console.info(`Execution time: ${executionTime} milliseconds`, {
|
|
37987
|
+
_logKey: "automation",
|
|
37988
|
+
executionTime
|
|
37989
|
+
});
|
|
37990
|
+
try {
|
|
37991
|
+
await storeLog2(this._automation, this.executionOutput);
|
|
37992
|
+
} catch (e) {
|
|
37993
|
+
if (e.status === 413 && ((_b2 = e.request) == null ? void 0 : _b2.data)) {
|
|
37994
|
+
delete e.request.data;
|
|
37995
|
+
e.request.data = { message: "removed due to large size" };
|
|
37996
|
+
}
|
|
37997
|
+
logging_exports.logAlert("Error writing automation log", e);
|
|
37998
|
+
}
|
|
37929
37999
|
if (isProdAppID2(this._appId) && isRecurring(automation) && metadata) {
|
|
37930
38000
|
await this.updateMetadata(metadata);
|
|
37931
38001
|
}
|
|
@@ -41003,7 +41073,7 @@ function fetchLevels(ctx) {
|
|
|
41003
41073
|
async function fetch40(ctx) {
|
|
41004
41074
|
const db2 = context_exports.getAppDB();
|
|
41005
41075
|
const dbRoles = await getAllDBRoles(db2);
|
|
41006
|
-
let
|
|
41076
|
+
let permissions = {};
|
|
41007
41077
|
for (let role of dbRoles) {
|
|
41008
41078
|
if (!role.permissions) {
|
|
41009
41079
|
continue;
|
|
@@ -41016,11 +41086,11 @@ async function fetch40(ctx) {
|
|
|
41016
41086
|
const levels = Array.isArray(levelArr) ? levelArr : [levelArr];
|
|
41017
41087
|
const perms = {};
|
|
41018
41088
|
levels.forEach((level) => perms[level] = roleId);
|
|
41019
|
-
|
|
41089
|
+
permissions[resource] = perms;
|
|
41020
41090
|
}
|
|
41021
41091
|
}
|
|
41022
41092
|
const finalPermissions = {};
|
|
41023
|
-
for (let [resource, permission] of Object.entries(
|
|
41093
|
+
for (let [resource, permission] of Object.entries(permissions)) {
|
|
41024
41094
|
const basePerms = getBasePermissions(resource);
|
|
41025
41095
|
finalPermissions[resource] = Object.assign(basePerms, permission);
|
|
41026
41096
|
}
|
|
@@ -41035,7 +41105,7 @@ async function getResourcePerms(ctx) {
|
|
|
41035
41105
|
})
|
|
41036
41106
|
);
|
|
41037
41107
|
const rolesList = body2.rows.map((row2) => row2.doc);
|
|
41038
|
-
let
|
|
41108
|
+
let permissions = {};
|
|
41039
41109
|
for (let level of SUPPORTED_LEVELS) {
|
|
41040
41110
|
for (let role of rolesList) {
|
|
41041
41111
|
const rolePerms = roles_exports.checkForRoleResourceArray(
|
|
@@ -41043,11 +41113,11 @@ async function getResourcePerms(ctx) {
|
|
|
41043
41113
|
resourceId
|
|
41044
41114
|
);
|
|
41045
41115
|
if (rolePerms && rolePerms[resourceId] && rolePerms[resourceId].indexOf(level) !== -1) {
|
|
41046
|
-
|
|
41116
|
+
permissions[level] = roles_exports.getExternalRoleID(role._id);
|
|
41047
41117
|
}
|
|
41048
41118
|
}
|
|
41049
41119
|
}
|
|
41050
|
-
ctx.body = Object.assign(getBasePermissions(resourceId),
|
|
41120
|
+
ctx.body = Object.assign(getBasePermissions(resourceId), permissions);
|
|
41051
41121
|
}
|
|
41052
41122
|
async function addPermission(ctx) {
|
|
41053
41123
|
ctx.body = await updatePermissionOnRole(
|
|
@@ -42910,7 +42980,7 @@ async function prepareUpload({ s3Key, bucket, metadata, file }) {
|
|
|
42910
42980
|
key: response2.Key
|
|
42911
42981
|
};
|
|
42912
42982
|
}
|
|
42913
|
-
var import_string_templates10, import_aws_sdk4,
|
|
42983
|
+
var import_string_templates10, import_aws_sdk4, import_fs15, uuid6, send2, toggleBetaUiFeature, serveBuilder, uploadFile, deleteObjects, serveApp, serveBuilderPreview, serveClientLibrary, getSignedUploadURL;
|
|
42914
42984
|
var init_static = __esm({
|
|
42915
42985
|
"src/api/controllers/static/index.ts"() {
|
|
42916
42986
|
init_centralPath();
|
|
@@ -42921,7 +42991,7 @@ var init_static = __esm({
|
|
|
42921
42991
|
init_utils9();
|
|
42922
42992
|
init_src2();
|
|
42923
42993
|
import_aws_sdk4 = __toESM(require("aws-sdk"));
|
|
42924
|
-
|
|
42994
|
+
import_fs15 = __toESM(require("fs"));
|
|
42925
42995
|
init_sdk3();
|
|
42926
42996
|
init_src4();
|
|
42927
42997
|
require("svelte/register");
|
|
@@ -42937,8 +43007,8 @@ var init_static = __esm({
|
|
|
42937
43007
|
return;
|
|
42938
43008
|
}
|
|
42939
43009
|
let builderPath = resolve(TOP_LEVEL_PATH, "new_design_ui");
|
|
42940
|
-
if (!
|
|
42941
|
-
|
|
43010
|
+
if (!import_fs15.default.existsSync(builderPath)) {
|
|
43011
|
+
import_fs15.default.mkdirSync(builderPath);
|
|
42942
43012
|
}
|
|
42943
43013
|
await objectStore_exports2.downloadTarballDirect(
|
|
42944
43014
|
"https://cdn.budi.live/beta:design_ui/new_ui.tar.gz",
|
|
@@ -44437,7 +44507,7 @@ function watch() {
|
|
|
44437
44507
|
usePolling: true,
|
|
44438
44508
|
interval: 250
|
|
44439
44509
|
}).on("all", async (event, path5) => {
|
|
44440
|
-
if (!(path5 == null ? void 0 : path5.endsWith(".tar.gz")) || !
|
|
44510
|
+
if (!(path5 == null ? void 0 : path5.endsWith(".tar.gz")) || !import_fs16.default.existsSync(path5)) {
|
|
44441
44511
|
return;
|
|
44442
44512
|
}
|
|
44443
44513
|
await tenancy.doInTenant(constants_exports.DEFAULT_TENANT_ID, async () => {
|
|
@@ -44453,13 +44523,13 @@ function watch() {
|
|
|
44453
44523
|
});
|
|
44454
44524
|
});
|
|
44455
44525
|
}
|
|
44456
|
-
var import_path15, import_chokidar,
|
|
44526
|
+
var import_path15, import_chokidar, import_fs16;
|
|
44457
44527
|
var init_watch = __esm({
|
|
44458
44528
|
"src/watch.ts"() {
|
|
44459
44529
|
import_path15 = __toESM(require("path"));
|
|
44460
44530
|
init_environment3();
|
|
44461
44531
|
import_chokidar = __toESM(require("chokidar"));
|
|
44462
|
-
|
|
44532
|
+
import_fs16 = __toESM(require("fs"));
|
|
44463
44533
|
init_src2();
|
|
44464
44534
|
init_plugins5();
|
|
44465
44535
|
}
|
|
@@ -44515,7 +44585,7 @@ async function startup(app2, server2) {
|
|
|
44515
44585
|
shutdown9(server2);
|
|
44516
44586
|
}
|
|
44517
44587
|
}
|
|
44518
|
-
if (environment_default2.SELF_HOSTED && !environment_default2.MULTI_TENANCY && environment_default2.PLUGINS_DIR &&
|
|
44588
|
+
if (environment_default2.SELF_HOSTED && !environment_default2.MULTI_TENANCY && environment_default2.PLUGINS_DIR && import_fs17.default.existsSync(environment_default2.PLUGINS_DIR)) {
|
|
44519
44589
|
watch();
|
|
44520
44590
|
}
|
|
44521
44591
|
await installation_exports.checkInstallVersion();
|
|
@@ -44550,14 +44620,14 @@ async function startup(app2, server2) {
|
|
|
44550
44620
|
}
|
|
44551
44621
|
}
|
|
44552
44622
|
}
|
|
44553
|
-
var
|
|
44623
|
+
var import_fs17, STARTUP_RAN;
|
|
44554
44624
|
var init_startup = __esm({
|
|
44555
44625
|
"src/startup.ts"() {
|
|
44556
44626
|
init_environment3();
|
|
44557
44627
|
init_redis4();
|
|
44558
44628
|
init_workerRequests();
|
|
44559
44629
|
init_src2();
|
|
44560
|
-
|
|
44630
|
+
import_fs17 = __toESM(require("fs"));
|
|
44561
44631
|
init_watch();
|
|
44562
44632
|
init_automations8();
|
|
44563
44633
|
init_fileSystem();
|