@budibase/server 2.7.16-alpha.0 → 2.7.16-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/builder/assets/{index.55a50076.js → index.0d7ff400.js} +301 -301
- package/builder/index.html +1 -1
- package/dist/automation.js +459 -460
- package/dist/automation.js.map +3 -3
- package/dist/index.js +671 -672
- package/dist/index.js.map +3 -3
- package/dist/query.js +700 -701
- package/dist/query.js.map +3 -3
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -11,8 +11,8 @@ var __commonJS = (cb, mod) => function __require() {
|
|
|
11
11
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
12
12
|
};
|
|
13
13
|
var __export = (target, all) => {
|
|
14
|
-
for (var
|
|
15
|
-
__defProp(target,
|
|
14
|
+
for (var name2 in all)
|
|
15
|
+
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
16
16
|
};
|
|
17
17
|
var __copyProps = (to, from, except, desc) => {
|
|
18
18
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
@@ -563,13 +563,13 @@ var init_plan = __esm({
|
|
|
563
563
|
var isStaticQuota, isMonthlyQuota, isConstantQuota;
|
|
564
564
|
var init_quota = __esm({
|
|
565
565
|
"../types/src/sdk/licensing/quota.ts"() {
|
|
566
|
-
isStaticQuota = (quotaType, usageType,
|
|
566
|
+
isStaticQuota = (quotaType, usageType, name2) => {
|
|
567
567
|
return quotaType === "usage" /* USAGE */ && usageType === "static" /* STATIC */;
|
|
568
568
|
};
|
|
569
|
-
isMonthlyQuota = (quotaType, usageType,
|
|
569
|
+
isMonthlyQuota = (quotaType, usageType, name2) => {
|
|
570
570
|
return quotaType === "usage" /* USAGE */ && usageType === "monthly" /* MONTHLY */;
|
|
571
571
|
};
|
|
572
|
-
isConstantQuota = (quotaType,
|
|
572
|
+
isConstantQuota = (quotaType, name2) => {
|
|
573
573
|
return quotaType === "constant" /* CONSTANT */;
|
|
574
574
|
};
|
|
575
575
|
}
|
|
@@ -679,8 +679,8 @@ var init_locks = __esm({
|
|
|
679
679
|
var isDocument;
|
|
680
680
|
var init_db = __esm({
|
|
681
681
|
"../types/src/sdk/db.ts"() {
|
|
682
|
-
isDocument = (
|
|
683
|
-
return typeof
|
|
682
|
+
isDocument = (doc2) => {
|
|
683
|
+
return typeof doc2 === "object" && doc2._id && doc2._rev;
|
|
684
684
|
};
|
|
685
685
|
}
|
|
686
686
|
});
|
|
@@ -1980,12 +1980,12 @@ function getPouchDB(dbName, opts) {
|
|
|
1980
1980
|
checkInitialised();
|
|
1981
1981
|
const db2 = new Pouch(dbName, opts);
|
|
1982
1982
|
const dbPut = db2.put;
|
|
1983
|
-
db2.put = async (
|
|
1984
|
-
if (!
|
|
1985
|
-
|
|
1983
|
+
db2.put = async (doc2, options2 = {}) => {
|
|
1984
|
+
if (!doc2.createdAt) {
|
|
1985
|
+
doc2.createdAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
1986
1986
|
}
|
|
1987
|
-
|
|
1988
|
-
return dbPut(
|
|
1987
|
+
doc2.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
1988
|
+
return dbPut(doc2, options2);
|
|
1989
1989
|
};
|
|
1990
1990
|
db2.exists = async () => {
|
|
1991
1991
|
const info = await db2.info();
|
|
@@ -2155,7 +2155,7 @@ var init_DatabaseImpl = __esm({
|
|
|
2155
2155
|
}
|
|
2156
2156
|
return this.updateOutput(() => db2.get(id));
|
|
2157
2157
|
}
|
|
2158
|
-
async remove(idOrDoc,
|
|
2158
|
+
async remove(idOrDoc, rev2) {
|
|
2159
2159
|
const db2 = await this.checkSetup();
|
|
2160
2160
|
let _id;
|
|
2161
2161
|
let _rev;
|
|
@@ -2164,7 +2164,7 @@ var init_DatabaseImpl = __esm({
|
|
|
2164
2164
|
_rev = idOrDoc._rev;
|
|
2165
2165
|
} else {
|
|
2166
2166
|
_id = idOrDoc;
|
|
2167
|
-
_rev =
|
|
2167
|
+
_rev = rev2;
|
|
2168
2168
|
}
|
|
2169
2169
|
if (!_id || !_rev) {
|
|
2170
2170
|
throw new Error("Unable to remove doc without a valid _id and _rev.");
|
|
@@ -3440,18 +3440,18 @@ async function newRedlock(opts = {}) {
|
|
|
3440
3440
|
}
|
|
3441
3441
|
function getLockName(opts) {
|
|
3442
3442
|
const prefix = opts.systemLock ? "system" : getTenantId();
|
|
3443
|
-
let
|
|
3443
|
+
let name2 = `lock:${prefix}_${opts.name}`;
|
|
3444
3444
|
if (opts.resource) {
|
|
3445
|
-
|
|
3445
|
+
name2 = name2 + `_${opts.resource}`;
|
|
3446
3446
|
}
|
|
3447
|
-
return
|
|
3447
|
+
return name2;
|
|
3448
3448
|
}
|
|
3449
3449
|
async function doWithLock(opts, task) {
|
|
3450
3450
|
const redlock = await getClient(opts.type, opts.customOptions);
|
|
3451
3451
|
let lock;
|
|
3452
3452
|
try {
|
|
3453
|
-
const
|
|
3454
|
-
lock = await redlock.lock(
|
|
3453
|
+
const name2 = getLockName(opts);
|
|
3454
|
+
lock = await redlock.lock(name2, opts.ttl);
|
|
3455
3455
|
const result = await task();
|
|
3456
3456
|
return { executed: true, result };
|
|
3457
3457
|
} catch (e) {
|
|
@@ -4078,8 +4078,8 @@ var init_ids = __esm({
|
|
|
4078
4078
|
generateDevInfoID = (userId) => {
|
|
4079
4079
|
return `${"devinfo" /* DEV_INFO */}${SEPARATOR}${userId}`;
|
|
4080
4080
|
};
|
|
4081
|
-
generatePluginID = (
|
|
4082
|
-
return `${"plg" /* PLUGIN */}${SEPARATOR}${
|
|
4081
|
+
generatePluginID = (name2) => {
|
|
4082
|
+
return `${"plg" /* PLUGIN */}${SEPARATOR}${name2}`;
|
|
4083
4083
|
};
|
|
4084
4084
|
}
|
|
4085
4085
|
});
|
|
@@ -4169,8 +4169,8 @@ var init_params = __esm({
|
|
|
4169
4169
|
isDatasourceId = (id) => {
|
|
4170
4170
|
return id && id.startsWith(`${"datasource" /* DATASOURCE */}${SEPARATOR}`);
|
|
4171
4171
|
};
|
|
4172
|
-
getPluginParams = (
|
|
4173
|
-
return getDocParams("plg" /* PLUGIN */,
|
|
4172
|
+
getPluginParams = (pluginId2, otherProps = {}) => {
|
|
4173
|
+
return getDocParams("plg" /* PLUGIN */, pluginId2, otherProps);
|
|
4174
4174
|
};
|
|
4175
4175
|
}
|
|
4176
4176
|
});
|
|
@@ -4307,7 +4307,7 @@ function pagination(data2, pageSize, {
|
|
|
4307
4307
|
const hasNextPage = data2.length > pageSize;
|
|
4308
4308
|
let nextPage = void 0;
|
|
4309
4309
|
if (!getKey) {
|
|
4310
|
-
getKey = (
|
|
4310
|
+
getKey = (doc2) => property ? doc2 == null ? void 0 : doc2[property] : doc2 == null ? void 0 : doc2._id;
|
|
4311
4311
|
}
|
|
4312
4312
|
if (hasNextPage) {
|
|
4313
4313
|
nextPage = getKey(data2[pageSize]);
|
|
@@ -4525,8 +4525,8 @@ var init_Replication = __esm({
|
|
|
4525
4525
|
* @param {String} source - the DB you want to replicate or rollback to
|
|
4526
4526
|
* @param {String} target - the DB you want to replicate to, or rollback from
|
|
4527
4527
|
*/
|
|
4528
|
-
constructor({ source, target }) {
|
|
4529
|
-
this.source = getPouchDB(
|
|
4528
|
+
constructor({ source: source2, target }) {
|
|
4529
|
+
this.source = getPouchDB(source2);
|
|
4530
4530
|
this.target = getPouchDB(target);
|
|
4531
4531
|
}
|
|
4532
4532
|
close() {
|
|
@@ -4561,8 +4561,8 @@ var init_Replication = __esm({
|
|
|
4561
4561
|
}
|
|
4562
4562
|
appReplicateOpts() {
|
|
4563
4563
|
return {
|
|
4564
|
-
filter: (
|
|
4565
|
-
return
|
|
4564
|
+
filter: (doc2) => {
|
|
4565
|
+
return doc2._id !== "app_metadata" /* APP_METADATA */;
|
|
4566
4566
|
}
|
|
4567
4567
|
};
|
|
4568
4568
|
}
|
|
@@ -4743,9 +4743,9 @@ var init_lucene = __esm({
|
|
|
4743
4743
|
__privateSet(this, _indexBuilder, builderFn);
|
|
4744
4744
|
return this;
|
|
4745
4745
|
}
|
|
4746
|
-
setVersion(
|
|
4747
|
-
if (
|
|
4748
|
-
__privateSet(this, _version,
|
|
4746
|
+
setVersion(version2) {
|
|
4747
|
+
if (version2 != null) {
|
|
4748
|
+
__privateSet(this, _version, version2);
|
|
4749
4749
|
}
|
|
4750
4750
|
return this;
|
|
4751
4751
|
}
|
|
@@ -5329,36 +5329,36 @@ async function populateFromDB2(appId) {
|
|
|
5329
5329
|
{ skip_setup: true }
|
|
5330
5330
|
);
|
|
5331
5331
|
}
|
|
5332
|
-
function isInvalid(
|
|
5333
|
-
return !
|
|
5332
|
+
function isInvalid(metadata2) {
|
|
5333
|
+
return !metadata2 || metadata2.state === AppState.INVALID;
|
|
5334
5334
|
}
|
|
5335
5335
|
async function getAppMetadata(appId) {
|
|
5336
5336
|
const client3 = await getAppClient();
|
|
5337
|
-
let
|
|
5338
|
-
if (!
|
|
5337
|
+
let metadata2 = await client3.get(appId);
|
|
5338
|
+
if (!metadata2) {
|
|
5339
5339
|
let expiry = EXPIRY_SECONDS2;
|
|
5340
5340
|
try {
|
|
5341
|
-
|
|
5341
|
+
metadata2 = await populateFromDB2(appId);
|
|
5342
5342
|
} catch (err) {
|
|
5343
5343
|
if (err && err.status === 404) {
|
|
5344
|
-
|
|
5344
|
+
metadata2 = { state: AppState.INVALID };
|
|
5345
5345
|
expiry = void 0;
|
|
5346
5346
|
} else {
|
|
5347
5347
|
throw err;
|
|
5348
5348
|
}
|
|
5349
5349
|
}
|
|
5350
|
-
if (isInvalid(
|
|
5350
|
+
if (isInvalid(metadata2)) {
|
|
5351
5351
|
const temp = await client3.get(appId);
|
|
5352
5352
|
if (temp) {
|
|
5353
|
-
|
|
5353
|
+
metadata2 = temp;
|
|
5354
5354
|
}
|
|
5355
5355
|
}
|
|
5356
|
-
await client3.store(appId,
|
|
5356
|
+
await client3.store(appId, metadata2, expiry);
|
|
5357
5357
|
}
|
|
5358
|
-
if (isInvalid(
|
|
5358
|
+
if (isInvalid(metadata2)) {
|
|
5359
5359
|
throw { status: 404, message: "No app metadata found" };
|
|
5360
5360
|
}
|
|
5361
|
-
return
|
|
5361
|
+
return metadata2;
|
|
5362
5362
|
}
|
|
5363
5363
|
async function invalidateAppMetadata(appId, newMetadata) {
|
|
5364
5364
|
if (!appId) {
|
|
@@ -5397,18 +5397,18 @@ async function getCache() {
|
|
|
5397
5397
|
function makeCacheKey(db2, key) {
|
|
5398
5398
|
return db2.name + key;
|
|
5399
5399
|
}
|
|
5400
|
-
function makeCacheItem(
|
|
5401
|
-
return { doc, lastWrite: lastWrite || Date.now() };
|
|
5400
|
+
function makeCacheItem(doc2, lastWrite = null) {
|
|
5401
|
+
return { doc: doc2, lastWrite: lastWrite || Date.now() };
|
|
5402
5402
|
}
|
|
5403
|
-
async function put(db2,
|
|
5403
|
+
async function put(db2, doc2, writeRateMs = DEFAULT_WRITE_RATE_MS) {
|
|
5404
5404
|
const cache3 = await getCache();
|
|
5405
|
-
const key =
|
|
5405
|
+
const key = doc2._id;
|
|
5406
5406
|
let cacheItem;
|
|
5407
5407
|
if (key) {
|
|
5408
5408
|
cacheItem = await cache3.get(makeCacheKey(db2, key));
|
|
5409
5409
|
}
|
|
5410
5410
|
const updateDb = !cacheItem || cacheItem.lastWrite < Date.now() - writeRateMs;
|
|
5411
|
-
let output =
|
|
5411
|
+
let output = doc2;
|
|
5412
5412
|
if (updateDb) {
|
|
5413
5413
|
const lockResponse = await doWithLock(
|
|
5414
5414
|
{
|
|
@@ -5421,13 +5421,13 @@ async function put(db2, doc, writeRateMs = DEFAULT_WRITE_RATE_MS) {
|
|
|
5421
5421
|
const writeDb = async (toWrite) => {
|
|
5422
5422
|
const response2 = await db2.put(toWrite, { force: true });
|
|
5423
5423
|
output = {
|
|
5424
|
-
...
|
|
5424
|
+
...doc2,
|
|
5425
5425
|
_id: response2.id,
|
|
5426
5426
|
_rev: response2.rev
|
|
5427
5427
|
};
|
|
5428
5428
|
};
|
|
5429
5429
|
try {
|
|
5430
|
-
await writeDb(
|
|
5430
|
+
await writeDb(doc2);
|
|
5431
5431
|
} catch (err) {
|
|
5432
5432
|
if (err.status !== 409) {
|
|
5433
5433
|
throw err;
|
|
@@ -5452,23 +5452,23 @@ async function get2(db2, id) {
|
|
|
5452
5452
|
const cacheKey = makeCacheKey(db2, id);
|
|
5453
5453
|
let cacheItem = await cache3.get(cacheKey);
|
|
5454
5454
|
if (!cacheItem) {
|
|
5455
|
-
const
|
|
5456
|
-
cacheItem = makeCacheItem(
|
|
5455
|
+
const doc2 = await db2.get(id);
|
|
5456
|
+
cacheItem = makeCacheItem(doc2);
|
|
5457
5457
|
await cache3.store(cacheKey, cacheItem);
|
|
5458
5458
|
}
|
|
5459
5459
|
return cacheItem.doc;
|
|
5460
5460
|
}
|
|
5461
|
-
async function remove(db2, docOrId,
|
|
5461
|
+
async function remove(db2, docOrId, rev2) {
|
|
5462
5462
|
const cache3 = await getCache();
|
|
5463
5463
|
if (!docOrId) {
|
|
5464
5464
|
throw new Error("No ID/Rev provided.");
|
|
5465
5465
|
}
|
|
5466
5466
|
const id = typeof docOrId === "string" ? docOrId : docOrId._id;
|
|
5467
|
-
|
|
5467
|
+
rev2 = typeof docOrId === "string" ? rev2 : docOrId._rev;
|
|
5468
5468
|
try {
|
|
5469
5469
|
await cache3.delete(makeCacheKey(db2, id));
|
|
5470
5470
|
} finally {
|
|
5471
|
-
await db2.remove(id,
|
|
5471
|
+
await db2.remove(id, rev2);
|
|
5472
5472
|
}
|
|
5473
5473
|
}
|
|
5474
5474
|
var DEFAULT_WRITE_RATE_MS, CACHE, Writethrough;
|
|
@@ -5486,14 +5486,14 @@ var init_writethrough = __esm({
|
|
|
5486
5486
|
this.db = db2;
|
|
5487
5487
|
this.writeRateMs = writeRateMs;
|
|
5488
5488
|
}
|
|
5489
|
-
async put(
|
|
5490
|
-
return put(this.db,
|
|
5489
|
+
async put(doc2) {
|
|
5490
|
+
return put(this.db, doc2, this.writeRateMs);
|
|
5491
5491
|
}
|
|
5492
5492
|
async get(id) {
|
|
5493
5493
|
return get2(this.db, id);
|
|
5494
5494
|
}
|
|
5495
|
-
async remove(docOrId,
|
|
5496
|
-
return remove(this.db, docOrId,
|
|
5495
|
+
async remove(docOrId, rev2) {
|
|
5496
|
+
return remove(this.db, docOrId, rev2);
|
|
5497
5497
|
}
|
|
5498
5498
|
};
|
|
5499
5499
|
}
|
|
@@ -5992,7 +5992,7 @@ var init_LoggingProcessor = __esm({
|
|
|
5992
5992
|
});
|
|
5993
5993
|
|
|
5994
5994
|
// ../backend-core/src/utils/hashing.ts
|
|
5995
|
-
async function
|
|
5995
|
+
async function hash2(data2) {
|
|
5996
5996
|
const salt = await bcrypt.genSalt(SALT_ROUNDS);
|
|
5997
5997
|
return bcrypt.hash(data2, salt);
|
|
5998
5998
|
}
|
|
@@ -6106,14 +6106,14 @@ function isValidInternalAPIKey(apiKey) {
|
|
|
6106
6106
|
}
|
|
6107
6107
|
return false;
|
|
6108
6108
|
}
|
|
6109
|
-
function getCookie(ctx,
|
|
6110
|
-
const cookie = ctx.cookies.get(
|
|
6109
|
+
function getCookie(ctx, name2) {
|
|
6110
|
+
const cookie = ctx.cookies.get(name2);
|
|
6111
6111
|
if (!cookie) {
|
|
6112
6112
|
return cookie;
|
|
6113
6113
|
}
|
|
6114
6114
|
return openJwt(cookie);
|
|
6115
6115
|
}
|
|
6116
|
-
function setCookie(ctx, value,
|
|
6116
|
+
function setCookie(ctx, value, name2 = "builder", opts = { sign: true }) {
|
|
6117
6117
|
if (value && opts && opts.sign) {
|
|
6118
6118
|
value = jwt.sign(value, environment_default.JWT_SECRET);
|
|
6119
6119
|
}
|
|
@@ -6126,10 +6126,10 @@ function setCookie(ctx, value, name = "builder", opts = { sign: true }) {
|
|
|
6126
6126
|
if (environment_default.COOKIE_DOMAIN) {
|
|
6127
6127
|
config.domain = environment_default.COOKIE_DOMAIN;
|
|
6128
6128
|
}
|
|
6129
|
-
ctx.cookies.set(
|
|
6129
|
+
ctx.cookies.set(name2, value, config);
|
|
6130
6130
|
}
|
|
6131
|
-
function clearCookie(ctx,
|
|
6132
|
-
setCookie(ctx, null,
|
|
6131
|
+
function clearCookie(ctx, name2) {
|
|
6132
|
+
setCookie(ctx, null, name2);
|
|
6133
6133
|
}
|
|
6134
6134
|
function isClient(ctx) {
|
|
6135
6135
|
return ctx.headers["x-budibase-type" /* TYPE */] === "client";
|
|
@@ -6177,7 +6177,7 @@ __export(utils_exports2, {
|
|
|
6177
6177
|
compare: () => compare,
|
|
6178
6178
|
getAppIdFromCtx: () => getAppIdFromCtx,
|
|
6179
6179
|
getCookie: () => getCookie,
|
|
6180
|
-
hash: () =>
|
|
6180
|
+
hash: () => hash2,
|
|
6181
6181
|
isAudited: () => isAudited,
|
|
6182
6182
|
isClient: () => isClient,
|
|
6183
6183
|
isPublicApiRequest: () => isPublicApiRequest,
|
|
@@ -6220,8 +6220,8 @@ var init_inMemoryQueue = __esm({
|
|
|
6220
6220
|
* @param {object|null} opts This is not used by the in memory queue as there is no real use
|
|
6221
6221
|
* case when in memory, but is the same API as Bull
|
|
6222
6222
|
*/
|
|
6223
|
-
constructor(
|
|
6224
|
-
this._name =
|
|
6223
|
+
constructor(name2, opts = null) {
|
|
6224
|
+
this._name = name2;
|
|
6225
6225
|
this._opts = opts;
|
|
6226
6226
|
this._messages = [];
|
|
6227
6227
|
this._emitter = new import_events2.default.EventEmitter();
|
|
@@ -6718,13 +6718,13 @@ var init_installation = __esm({
|
|
|
6718
6718
|
}
|
|
6719
6719
|
);
|
|
6720
6720
|
};
|
|
6721
|
-
updateVersion = async (
|
|
6721
|
+
updateVersion = async (version2) => {
|
|
6722
6722
|
try {
|
|
6723
6723
|
await doWithDB(
|
|
6724
6724
|
StaticDatabases.PLATFORM_INFO.name,
|
|
6725
6725
|
async (platformDb) => {
|
|
6726
6726
|
const install = await getInstall();
|
|
6727
|
-
install.version =
|
|
6727
|
+
install.version = version2;
|
|
6728
6728
|
await platformDb.put(install);
|
|
6729
6729
|
await bustCache("installation" /* INSTALLATION */);
|
|
6730
6730
|
}
|
|
@@ -6840,13 +6840,13 @@ var init_identification2 = __esm({
|
|
|
6840
6840
|
const id = installId;
|
|
6841
6841
|
const type = "installation" /* INSTALLATION */;
|
|
6842
6842
|
const hosting = getHostingFromEnv();
|
|
6843
|
-
const
|
|
6843
|
+
const version2 = environment_default.VERSION;
|
|
6844
6844
|
const environment3 = getDeploymentEnvironment();
|
|
6845
6845
|
const group2 = {
|
|
6846
6846
|
id,
|
|
6847
6847
|
type,
|
|
6848
6848
|
hosting,
|
|
6849
|
-
version,
|
|
6849
|
+
version: version2,
|
|
6850
6850
|
environment: environment3
|
|
6851
6851
|
};
|
|
6852
6852
|
await identifyGroup(group2, timestamp);
|
|
@@ -7026,10 +7026,10 @@ var init_backfill2 = __esm({
|
|
|
7026
7026
|
init_generic();
|
|
7027
7027
|
init_generic();
|
|
7028
7028
|
start = async (events2) => {
|
|
7029
|
-
const
|
|
7029
|
+
const metadata2 = {
|
|
7030
7030
|
eventWhitelist: events2
|
|
7031
7031
|
};
|
|
7032
|
-
return saveBackfillMetadata(
|
|
7032
|
+
return saveBackfillMetadata(metadata2);
|
|
7033
7033
|
};
|
|
7034
7034
|
recordEvent2 = async (event, properties) => {
|
|
7035
7035
|
const eventKey2 = getEventKey(event, properties);
|
|
@@ -7384,11 +7384,11 @@ var init_app5 = __esm({
|
|
|
7384
7384
|
});
|
|
7385
7385
|
|
|
7386
7386
|
// ../backend-core/src/events/publishers/auth.ts
|
|
7387
|
-
async function login(
|
|
7387
|
+
async function login(source2, email) {
|
|
7388
7388
|
const identity = await identification_default.getCurrentIdentity();
|
|
7389
7389
|
const properties = {
|
|
7390
7390
|
userId: identity.id,
|
|
7391
|
-
source,
|
|
7391
|
+
source: source2,
|
|
7392
7392
|
audited: {
|
|
7393
7393
|
email
|
|
7394
7394
|
}
|
|
@@ -8268,9 +8268,9 @@ var init_view3 = __esm({
|
|
|
8268
8268
|
});
|
|
8269
8269
|
|
|
8270
8270
|
// ../backend-core/src/events/publishers/installation.ts
|
|
8271
|
-
async function versionChecked(
|
|
8271
|
+
async function versionChecked(version2) {
|
|
8272
8272
|
const properties = {
|
|
8273
|
-
currentVersion:
|
|
8273
|
+
currentVersion: version2
|
|
8274
8274
|
};
|
|
8275
8275
|
await publishEvent("installation:version:checked" /* INSTALLATION_VERSION_CHECKED */, properties);
|
|
8276
8276
|
}
|
|
@@ -8513,13 +8513,13 @@ async function appBackupRestored(backup) {
|
|
|
8513
8513
|
};
|
|
8514
8514
|
await publishEvent("app:backup:restored" /* APP_BACKUP_RESTORED */, properties);
|
|
8515
8515
|
}
|
|
8516
|
-
async function appBackupTriggered(appId, backupId, type, trigger3,
|
|
8516
|
+
async function appBackupTriggered(appId, backupId, type, trigger3, name2) {
|
|
8517
8517
|
const properties = {
|
|
8518
8518
|
appId,
|
|
8519
8519
|
backupId,
|
|
8520
8520
|
type,
|
|
8521
8521
|
trigger: trigger3,
|
|
8522
|
-
name
|
|
8522
|
+
name: name2
|
|
8523
8523
|
};
|
|
8524
8524
|
await publishEvent("app:backup:triggered" /* APP_BACKUP_TRIGGERED */, properties);
|
|
8525
8525
|
}
|
|
@@ -8536,16 +8536,16 @@ var init_backup4 = __esm({
|
|
|
8536
8536
|
});
|
|
8537
8537
|
|
|
8538
8538
|
// ../backend-core/src/events/publishers/environmentVariable.ts
|
|
8539
|
-
async function created14(
|
|
8539
|
+
async function created14(name2, environments) {
|
|
8540
8540
|
const properties = {
|
|
8541
|
-
name,
|
|
8541
|
+
name: name2,
|
|
8542
8542
|
environments
|
|
8543
8543
|
};
|
|
8544
8544
|
await publishEvent("environment_variable:created" /* ENVIRONMENT_VARIABLE_CREATED */, properties);
|
|
8545
8545
|
}
|
|
8546
|
-
async function deleted14(
|
|
8546
|
+
async function deleted14(name2) {
|
|
8547
8547
|
const properties = {
|
|
8548
|
-
name
|
|
8548
|
+
name: name2
|
|
8549
8549
|
};
|
|
8550
8550
|
await publishEvent("environment_variable:deleted" /* ENVIRONMENT_VARIABLE_DELETED */, properties);
|
|
8551
8551
|
}
|
|
@@ -8746,8 +8746,8 @@ var init_migrations2 = __esm({
|
|
|
8746
8746
|
const lengthStatement = length > 1 ? `[${count}/${length}]` : "";
|
|
8747
8747
|
const db2 = getDB(dbName);
|
|
8748
8748
|
try {
|
|
8749
|
-
const
|
|
8750
|
-
if (
|
|
8749
|
+
const doc2 = await getMigrationsDoc(db2);
|
|
8750
|
+
if (doc2[migrationName]) {
|
|
8751
8751
|
if (options2.force && options2.force[migrationType] && options2.force[migrationType].includes(migrationName)) {
|
|
8752
8752
|
log2(`[Migration: ${migrationName}] [DB: ${dbName}] Forcing`);
|
|
8753
8753
|
} else {
|
|
@@ -8759,9 +8759,9 @@ var init_migrations2 = __esm({
|
|
|
8759
8759
|
`[Migration: ${migrationName}] [DB: ${dbName}] Running ${lengthStatement}`
|
|
8760
8760
|
);
|
|
8761
8761
|
if (migration.preventRetry) {
|
|
8762
|
-
|
|
8763
|
-
const response2 = await db2.put(
|
|
8764
|
-
|
|
8762
|
+
doc2[migrationName] = Date.now();
|
|
8763
|
+
const response2 = await db2.put(doc2);
|
|
8764
|
+
doc2._rev = response2.rev;
|
|
8765
8765
|
}
|
|
8766
8766
|
if (migrationType === "app" /* APP */) {
|
|
8767
8767
|
await doInAppContext(db2.name, async () => {
|
|
@@ -8772,8 +8772,8 @@ var init_migrations2 = __esm({
|
|
|
8772
8772
|
}
|
|
8773
8773
|
log2(`[Migration: ${migrationName}] [DB: ${dbName}] Complete`);
|
|
8774
8774
|
}
|
|
8775
|
-
|
|
8776
|
-
await db2.put(
|
|
8775
|
+
doc2[migrationName] = Date.now();
|
|
8776
|
+
await db2.put(doc2);
|
|
8777
8777
|
} catch (err) {
|
|
8778
8778
|
console.error(
|
|
8779
8779
|
`[Migration: ${migrationName}] [DB: ${dbName}] Error: `,
|
|
@@ -9060,7 +9060,7 @@ var init_users4 = __esm({
|
|
|
9060
9060
|
let userList, property = "_id", getKey;
|
|
9061
9061
|
if (appId) {
|
|
9062
9062
|
userList = await searchGlobalUsersByApp(appId, opts);
|
|
9063
|
-
getKey = (
|
|
9063
|
+
getKey = (doc2) => getGlobalUserByAppPage(appId, doc2);
|
|
9064
9064
|
} else if (email) {
|
|
9065
9065
|
userList = await searchGlobalUsersByEmail(email, opts);
|
|
9066
9066
|
property = "email";
|
|
@@ -9466,10 +9466,10 @@ var init_roles = __esm({
|
|
|
9466
9466
|
BUILTIN_IDS.PUBLIC
|
|
9467
9467
|
];
|
|
9468
9468
|
Role2 = class {
|
|
9469
|
-
constructor(id,
|
|
9469
|
+
constructor(id, name2, permissionId) {
|
|
9470
9470
|
this.permissions = {};
|
|
9471
9471
|
this._id = id;
|
|
9472
|
-
this.name =
|
|
9472
|
+
this.name = name2;
|
|
9473
9473
|
this.permissionId = permissionId;
|
|
9474
9474
|
}
|
|
9475
9475
|
addInheritance(inherits) {
|
|
@@ -9835,12 +9835,12 @@ async function syncUser(user2, details) {
|
|
|
9835
9835
|
if (details.profile) {
|
|
9836
9836
|
const profile = details.profile;
|
|
9837
9837
|
if (profile.name) {
|
|
9838
|
-
const
|
|
9839
|
-
if (
|
|
9840
|
-
firstName =
|
|
9838
|
+
const name2 = profile.name;
|
|
9839
|
+
if (name2.givenName) {
|
|
9840
|
+
firstName = name2.givenName;
|
|
9841
9841
|
}
|
|
9842
|
-
if (
|
|
9843
|
-
lastName =
|
|
9842
|
+
if (name2.familyName) {
|
|
9843
|
+
lastName = name2.familyName;
|
|
9844
9844
|
}
|
|
9845
9845
|
}
|
|
9846
9846
|
pictureUrl = await getProfilePictureUrl(user2, details);
|
|
@@ -10435,7 +10435,7 @@ function authenticated_default(noAuthPatterns = [], opts = {
|
|
|
10435
10435
|
const noAuthOptions = noAuthPatterns ? buildMatcherRegex(noAuthPatterns) : [];
|
|
10436
10436
|
return async (ctx, next) => {
|
|
10437
10437
|
let publicEndpoint = false;
|
|
10438
|
-
const
|
|
10438
|
+
const version2 = ctx.request.headers["x-budibase-api-version" /* API_VER */];
|
|
10439
10439
|
const found = matches(ctx, noAuthOptions);
|
|
10440
10440
|
if (found) {
|
|
10441
10441
|
publicEndpoint = true;
|
|
@@ -10498,7 +10498,7 @@ function authenticated_default(noAuthPatterns = [], opts = {
|
|
|
10498
10498
|
if (!authenticated) {
|
|
10499
10499
|
authenticated = false;
|
|
10500
10500
|
}
|
|
10501
|
-
finalise(ctx, { authenticated, user: user2, internal, version, publicEndpoint });
|
|
10501
|
+
finalise(ctx, { authenticated, user: user2, internal, version: version2, publicEndpoint });
|
|
10502
10502
|
if (user2 && user2.email) {
|
|
10503
10503
|
return doInUserContext(user2, ctx, next);
|
|
10504
10504
|
} else {
|
|
@@ -10513,7 +10513,7 @@ function authenticated_default(noAuthPatterns = [], opts = {
|
|
|
10513
10513
|
ctx.throw(403, err.message);
|
|
10514
10514
|
}
|
|
10515
10515
|
if (opts && opts.publicAllowed || publicEndpoint) {
|
|
10516
|
-
finalise(ctx, { authenticated: false, version, publicEndpoint });
|
|
10516
|
+
finalise(ctx, { authenticated: false, version: version2, publicEndpoint });
|
|
10517
10517
|
return next();
|
|
10518
10518
|
} else {
|
|
10519
10519
|
ctx.throw(err.status || 403, err);
|
|
@@ -11327,7 +11327,7 @@ var init_objectStore = __esm({
|
|
|
11327
11327
|
filename,
|
|
11328
11328
|
path: path5,
|
|
11329
11329
|
type,
|
|
11330
|
-
metadata
|
|
11330
|
+
metadata: metadata2
|
|
11331
11331
|
}) => {
|
|
11332
11332
|
const extension = filename.split(".").pop();
|
|
11333
11333
|
const fileBytes = import_fs4.default.readFileSync(path5);
|
|
@@ -11343,13 +11343,13 @@ var init_objectStore = __esm({
|
|
|
11343
11343
|
Body: fileBytes,
|
|
11344
11344
|
ContentType: contentType
|
|
11345
11345
|
};
|
|
11346
|
-
if (
|
|
11347
|
-
for (let key of Object.keys(
|
|
11348
|
-
if (!
|
|
11349
|
-
delete
|
|
11346
|
+
if (metadata2 && typeof metadata2 === "object") {
|
|
11347
|
+
for (let key of Object.keys(metadata2)) {
|
|
11348
|
+
if (!metadata2[key] || typeof metadata2[key] !== "string") {
|
|
11349
|
+
delete metadata2[key];
|
|
11350
11350
|
}
|
|
11351
11351
|
}
|
|
11352
|
-
config.Metadata =
|
|
11352
|
+
config.Metadata = metadata2;
|
|
11353
11353
|
}
|
|
11354
11354
|
return objectStore.upload(config).promise();
|
|
11355
11355
|
};
|
|
@@ -11503,12 +11503,12 @@ var init_objectStore = __esm({
|
|
|
11503
11503
|
return deleteFolder(bucketName, folder);
|
|
11504
11504
|
}
|
|
11505
11505
|
};
|
|
11506
|
-
uploadDirectory = async (bucketName, localPath,
|
|
11506
|
+
uploadDirectory = async (bucketName, localPath, bucketPath2) => {
|
|
11507
11507
|
bucketName = sanitizeBucket(bucketName);
|
|
11508
11508
|
let uploads = [];
|
|
11509
|
-
const
|
|
11510
|
-
for (let file of
|
|
11511
|
-
const path5 = sanitizeKey((0, import_path3.join)(
|
|
11509
|
+
const files2 = import_fs4.default.readdirSync(localPath, { withFileTypes: true });
|
|
11510
|
+
for (let file of files2) {
|
|
11511
|
+
const path5 = sanitizeKey((0, import_path3.join)(bucketPath2, file.name));
|
|
11512
11512
|
const local = (0, import_path3.join)(localPath, file.name);
|
|
11513
11513
|
if (file.isDirectory()) {
|
|
11514
11514
|
uploads.push(uploadDirectory(bucketName, local, path5));
|
|
@@ -11517,7 +11517,7 @@ var init_objectStore = __esm({
|
|
|
11517
11517
|
}
|
|
11518
11518
|
}
|
|
11519
11519
|
await Promise.all(uploads);
|
|
11520
|
-
return
|
|
11520
|
+
return files2;
|
|
11521
11521
|
};
|
|
11522
11522
|
downloadTarballDirect = async (url, path5, headers = {}) => {
|
|
11523
11523
|
path5 = sanitizeKey(path5);
|
|
@@ -11591,12 +11591,12 @@ var init_app6 = __esm({
|
|
|
11591
11591
|
init_environment2();
|
|
11592
11592
|
init_objectStore();
|
|
11593
11593
|
init_cloudfront();
|
|
11594
|
-
clientLibraryUrl = (appId,
|
|
11594
|
+
clientLibraryUrl = (appId, version2) => {
|
|
11595
11595
|
if (environment_default.isProd()) {
|
|
11596
11596
|
let file = `${sanitizeKey(appId)}/budibase-client.js`;
|
|
11597
11597
|
if (environment_default.CLOUDFRONT_CDN) {
|
|
11598
|
-
if (
|
|
11599
|
-
file += `?v=${
|
|
11598
|
+
if (version2) {
|
|
11599
|
+
file += `?v=${version2}`;
|
|
11600
11600
|
}
|
|
11601
11601
|
return getUrl(file);
|
|
11602
11602
|
} else {
|
|
@@ -11624,8 +11624,8 @@ var init_global3 = __esm({
|
|
|
11624
11624
|
init_context2();
|
|
11625
11625
|
init_objectStore();
|
|
11626
11626
|
init_cloudfront();
|
|
11627
|
-
getGlobalFileUrl = (type,
|
|
11628
|
-
let file = getGlobalFileS3Key(type,
|
|
11627
|
+
getGlobalFileUrl = (type, name2, etag) => {
|
|
11628
|
+
let file = getGlobalFileS3Key(type, name2);
|
|
11629
11629
|
if (environment_default.CLOUDFRONT_CDN) {
|
|
11630
11630
|
if (etag) {
|
|
11631
11631
|
file = `${file}?etag=${etag}`;
|
|
@@ -11635,8 +11635,8 @@ var init_global3 = __esm({
|
|
|
11635
11635
|
return getPresignedUrl(environment_default.GLOBAL_BUCKET_NAME, file);
|
|
11636
11636
|
}
|
|
11637
11637
|
};
|
|
11638
|
-
getGlobalFileS3Key = (type,
|
|
11639
|
-
let file = `${type}/${
|
|
11638
|
+
getGlobalFileS3Key = (type, name2) => {
|
|
11639
|
+
let file = `${type}/${name2}`;
|
|
11640
11640
|
if (environment_default.MULTI_TENANCY) {
|
|
11641
11641
|
const tenantId = getTenantId();
|
|
11642
11642
|
file = `${tenantId}/${file}`;
|
|
@@ -11686,11 +11686,11 @@ var init_plugins = __esm({
|
|
|
11686
11686
|
return getPluginS3Key(plugin, "plugin.min.js");
|
|
11687
11687
|
};
|
|
11688
11688
|
getPluginIconKey = (plugin) => {
|
|
11689
|
-
const
|
|
11690
|
-
if (!
|
|
11689
|
+
const iconFileName2 = plugin.iconUrl ? "icon.svg" : plugin.iconFileName;
|
|
11690
|
+
if (!iconFileName2) {
|
|
11691
11691
|
return;
|
|
11692
11692
|
}
|
|
11693
|
-
return getPluginS3Key(plugin,
|
|
11693
|
+
return getPluginS3Key(plugin, iconFileName2);
|
|
11694
11694
|
};
|
|
11695
11695
|
getPluginS3Key = (plugin, fileName) => {
|
|
11696
11696
|
const s3Key = getPluginS3Dir(plugin.name);
|
|
@@ -12311,9 +12311,9 @@ var init_filesystem = __esm({
|
|
|
12311
12311
|
if (!import_fs5.default.existsSync(startPath)) {
|
|
12312
12312
|
return;
|
|
12313
12313
|
}
|
|
12314
|
-
const
|
|
12315
|
-
for (let i = 0, len =
|
|
12316
|
-
const filename = (0, import_path6.join)(startPath,
|
|
12314
|
+
const files2 = import_fs5.default.readdirSync(startPath);
|
|
12315
|
+
for (let i = 0, len = files2.length; i < len; i++) {
|
|
12316
|
+
const filename = (0, import_path6.join)(startPath, files2[i]);
|
|
12317
12317
|
const stat = import_fs5.default.lstatSync(filename);
|
|
12318
12318
|
if (stat.isDirectory()) {
|
|
12319
12319
|
return findFileRec(filename, filter2);
|
|
@@ -12501,7 +12501,7 @@ var init_app7 = __esm({
|
|
|
12501
12501
|
// src/utilities/fileSystem/plugin.ts
|
|
12502
12502
|
async function getPluginImpl(path5, plugin) {
|
|
12503
12503
|
var _a2;
|
|
12504
|
-
const
|
|
12504
|
+
const hash3 = (_a2 = plugin.schema) == null ? void 0 : _a2.hash;
|
|
12505
12505
|
if (!import_fs8.default.existsSync(path5)) {
|
|
12506
12506
|
import_fs8.default.mkdirSync(path5);
|
|
12507
12507
|
}
|
|
@@ -12509,7 +12509,7 @@ async function getPluginImpl(path5, plugin) {
|
|
|
12509
12509
|
const metadataName = `${filename}.bbmetadata`;
|
|
12510
12510
|
if (import_fs8.default.existsSync(filename)) {
|
|
12511
12511
|
const currentHash = import_fs8.default.readFileSync(metadataName, "utf8");
|
|
12512
|
-
if (currentHash ===
|
|
12512
|
+
if (currentHash === hash3) {
|
|
12513
12513
|
return require(filename);
|
|
12514
12514
|
} else {
|
|
12515
12515
|
console.log(`Updating plugin: ${plugin.name}`);
|
|
@@ -12523,7 +12523,7 @@ async function getPluginImpl(path5, plugin) {
|
|
|
12523
12523
|
pluginKey
|
|
12524
12524
|
);
|
|
12525
12525
|
import_fs8.default.writeFileSync(filename, pluginJs);
|
|
12526
|
-
import_fs8.default.writeFileSync(metadataName,
|
|
12526
|
+
import_fs8.default.writeFileSync(metadataName, hash3);
|
|
12527
12527
|
return require(filename);
|
|
12528
12528
|
}
|
|
12529
12529
|
var import_fs8, import_path9, DATASOURCE_PATH, AUTOMATION_PATH, getPluginMetadata, getDatasourcePlugin, getAutomationPlugin;
|
|
@@ -12536,13 +12536,13 @@ var init_plugin5 = __esm({
|
|
|
12536
12536
|
DATASOURCE_PATH = (0, import_path9.join)(budibaseTempDir2(), "datasource");
|
|
12537
12537
|
AUTOMATION_PATH = (0, import_path9.join)(budibaseTempDir2(), "automation");
|
|
12538
12538
|
getPluginMetadata = async (path5) => {
|
|
12539
|
-
let
|
|
12539
|
+
let metadata2 = {};
|
|
12540
12540
|
try {
|
|
12541
12541
|
const pkg2 = import_fs8.default.readFileSync((0, import_path9.join)(path5, "package.json"), "utf8");
|
|
12542
12542
|
const schema = import_fs8.default.readFileSync((0, import_path9.join)(path5, "schema.json"), "utf8");
|
|
12543
|
-
|
|
12544
|
-
|
|
12545
|
-
if (!
|
|
12543
|
+
metadata2.schema = JSON.parse(schema);
|
|
12544
|
+
metadata2.package = JSON.parse(pkg2);
|
|
12545
|
+
if (!metadata2.package.name || !metadata2.package.version || !metadata2.package.description) {
|
|
12546
12546
|
throw new Error(
|
|
12547
12547
|
"package.json is missing one of 'name', 'version' or 'description'."
|
|
12548
12548
|
);
|
|
@@ -12552,7 +12552,7 @@ var init_plugin5 = __esm({
|
|
|
12552
12552
|
`Unable to process schema.json/package.json in plugin. ${err.message}`
|
|
12553
12553
|
);
|
|
12554
12554
|
}
|
|
12555
|
-
return { metadata, directory: path5 };
|
|
12555
|
+
return { metadata: metadata2, directory: path5 };
|
|
12556
12556
|
};
|
|
12557
12557
|
getDatasourcePlugin = async (plugin) => {
|
|
12558
12558
|
return getPluginImpl(DATASOURCE_PATH, plugin);
|
|
@@ -12569,9 +12569,9 @@ var init_template = __esm({
|
|
|
12569
12569
|
"src/utilities/fileSystem/template.ts"() {
|
|
12570
12570
|
init_constants4();
|
|
12571
12571
|
init_src2();
|
|
12572
|
-
downloadTemplate = async (type,
|
|
12572
|
+
downloadTemplate = async (type, name2) => {
|
|
12573
12573
|
const DEFAULT_TEMPLATES_BUCKET2 = "prod-budi-templates.s3-eu-west-1.amazonaws.com";
|
|
12574
|
-
const templateUrl = `https://${DEFAULT_TEMPLATES_BUCKET2}/templates/${type}/${
|
|
12574
|
+
const templateUrl = `https://${DEFAULT_TEMPLATES_BUCKET2}/templates/${type}/${name2}.tar.gz`;
|
|
12575
12575
|
return objectStore_exports2.downloadTarball(
|
|
12576
12576
|
templateUrl,
|
|
12577
12577
|
ObjectStoreBuckets2.TEMPLATES,
|
|
@@ -12940,11 +12940,11 @@ var init_utils10 = __esm({
|
|
|
12940
12940
|
}
|
|
12941
12941
|
usage.monthly.current = usage.monthly[currentMonth];
|
|
12942
12942
|
};
|
|
12943
|
-
getBreakdownName = (
|
|
12944
|
-
if (!id || !
|
|
12943
|
+
getBreakdownName = (name2, id) => {
|
|
12944
|
+
if (!id || !name2) {
|
|
12945
12945
|
return;
|
|
12946
12946
|
}
|
|
12947
|
-
switch (
|
|
12947
|
+
switch (name2) {
|
|
12948
12948
|
case "automations" /* AUTOMATIONS */:
|
|
12949
12949
|
return "automations" /* AUTOMATIONS */;
|
|
12950
12950
|
case "queries" /* QUERIES */:
|
|
@@ -13006,17 +13006,17 @@ var init_quotas2 = __esm({
|
|
|
13006
13006
|
delete usage.usageQuota.developers;
|
|
13007
13007
|
return usage;
|
|
13008
13008
|
};
|
|
13009
|
-
setUsage = async (value,
|
|
13010
|
-
return setAllUsage(
|
|
13009
|
+
setUsage = async (value, name2, type) => {
|
|
13010
|
+
return setAllUsage(name2, type, { total: value });
|
|
13011
13011
|
};
|
|
13012
|
-
setUsagePerApp = async (appValues,
|
|
13012
|
+
setUsagePerApp = async (appValues, name2, type) => {
|
|
13013
13013
|
const db2 = getDB2();
|
|
13014
13014
|
let quotaUsage = await getQuotaUsage();
|
|
13015
13015
|
const total = Object.values(appValues).reduce((sum, num) => sum + num, 0);
|
|
13016
13016
|
for (let [appId, value] of Object.entries(appValues)) {
|
|
13017
13017
|
quotaUsage = coreUsageUpdate(
|
|
13018
13018
|
quotaUsage,
|
|
13019
|
-
|
|
13019
|
+
name2,
|
|
13020
13020
|
type,
|
|
13021
13021
|
{
|
|
13022
13022
|
total,
|
|
@@ -13031,8 +13031,8 @@ var init_quotas2 = __esm({
|
|
|
13031
13031
|
quotaUsage._rev = response2.rev;
|
|
13032
13032
|
return quotaUsage;
|
|
13033
13033
|
};
|
|
13034
|
-
setBreakdown = (monthUsage,
|
|
13035
|
-
const breakdownName = getBreakdownName(
|
|
13034
|
+
setBreakdown = (monthUsage, name2, id, values) => {
|
|
13035
|
+
const breakdownName = getBreakdownName(name2, id);
|
|
13036
13036
|
if (!breakdownName || !(values == null ? void 0 : values.breakdown)) {
|
|
13037
13037
|
return monthUsage;
|
|
13038
13038
|
}
|
|
@@ -13041,7 +13041,7 @@ var init_quotas2 = __esm({
|
|
|
13041
13041
|
}
|
|
13042
13042
|
if (!monthUsage.breakdown[breakdownName]) {
|
|
13043
13043
|
monthUsage.breakdown[breakdownName] = {
|
|
13044
|
-
parent:
|
|
13044
|
+
parent: name2,
|
|
13045
13045
|
values: {}
|
|
13046
13046
|
};
|
|
13047
13047
|
}
|
|
@@ -13049,14 +13049,14 @@ var init_quotas2 = __esm({
|
|
|
13049
13049
|
breakdown.values[id] = values.breakdown;
|
|
13050
13050
|
return monthUsage;
|
|
13051
13051
|
};
|
|
13052
|
-
setAppUsageValue = (quotaUsage,
|
|
13052
|
+
setAppUsageValue = (quotaUsage, name2, type, opts = {}, values) => {
|
|
13053
13053
|
var _a2;
|
|
13054
13054
|
let appId;
|
|
13055
13055
|
try {
|
|
13056
13056
|
appId = db_exports.getProdAppID((opts == null ? void 0 : opts.appId) || context_exports.getAppId());
|
|
13057
13057
|
} catch (err) {
|
|
13058
13058
|
}
|
|
13059
|
-
if (!appId || !values.app || !APP_QUOTA_NAMES.includes(
|
|
13059
|
+
if (!appId || !values.app || !APP_QUOTA_NAMES.includes(name2)) {
|
|
13060
13060
|
return quotaUsage;
|
|
13061
13061
|
}
|
|
13062
13062
|
if (!((_a2 = quotaUsage.apps) == null ? void 0 : _a2[appId])) {
|
|
@@ -13068,11 +13068,11 @@ var init_quotas2 = __esm({
|
|
|
13068
13068
|
const appUsage = quotaUsage.apps[appId];
|
|
13069
13069
|
switch (type) {
|
|
13070
13070
|
case "static" /* STATIC */:
|
|
13071
|
-
appUsage.usageQuota[
|
|
13071
|
+
appUsage.usageQuota[name2] = values.app;
|
|
13072
13072
|
break;
|
|
13073
13073
|
case "monthly" /* MONTHLY */:
|
|
13074
13074
|
const currentMonth = getCurrentMonthString();
|
|
13075
|
-
const monthlyName =
|
|
13075
|
+
const monthlyName = name2;
|
|
13076
13076
|
let monthUsage = appUsage.monthly[currentMonth];
|
|
13077
13077
|
if (!monthUsage) {
|
|
13078
13078
|
appUsage.monthly[currentMonth] = generateNewMonthlyQuotas();
|
|
@@ -13086,9 +13086,9 @@ var init_quotas2 = __esm({
|
|
|
13086
13086
|
}
|
|
13087
13087
|
return quotaUsage;
|
|
13088
13088
|
};
|
|
13089
|
-
getAppUsageValue = (quotaUsage, type,
|
|
13089
|
+
getAppUsageValue = (quotaUsage, type, name2, id) => {
|
|
13090
13090
|
var _a2, _b2, _c, _d, _e;
|
|
13091
|
-
if (!APP_QUOTA_NAMES.includes(
|
|
13091
|
+
if (!APP_QUOTA_NAMES.includes(name2)) {
|
|
13092
13092
|
return {};
|
|
13093
13093
|
}
|
|
13094
13094
|
let appId;
|
|
@@ -13102,13 +13102,13 @@ var init_quotas2 = __esm({
|
|
|
13102
13102
|
const appUsage = quotaUsage.apps[appId];
|
|
13103
13103
|
switch (type) {
|
|
13104
13104
|
case "static" /* STATIC */:
|
|
13105
|
-
if ((_a2 = appUsage.usageQuota) == null ? void 0 : _a2[
|
|
13106
|
-
return { app: appUsage.usageQuota[
|
|
13105
|
+
if ((_a2 = appUsage.usageQuota) == null ? void 0 : _a2[name2]) {
|
|
13106
|
+
return { app: appUsage.usageQuota[name2] };
|
|
13107
13107
|
}
|
|
13108
13108
|
break;
|
|
13109
13109
|
case "monthly" /* MONTHLY */:
|
|
13110
13110
|
const currentMonth = getCurrentMonthString();
|
|
13111
|
-
const monthlyName =
|
|
13111
|
+
const monthlyName = name2;
|
|
13112
13112
|
if (!((_c = (_b2 = appUsage.monthly) == null ? void 0 : _b2[currentMonth]) == null ? void 0 : _c[monthlyName])) {
|
|
13113
13113
|
break;
|
|
13114
13114
|
}
|
|
@@ -13123,68 +13123,68 @@ var init_quotas2 = __esm({
|
|
|
13123
13123
|
}
|
|
13124
13124
|
return { app: 0 };
|
|
13125
13125
|
};
|
|
13126
|
-
setStaticTriggers = (
|
|
13126
|
+
setStaticTriggers = (name2, quotaUsage, triggers) => {
|
|
13127
13127
|
if (!quotaUsage.usageQuota.triggers) {
|
|
13128
13128
|
quotaUsage.usageQuota.triggers = {};
|
|
13129
13129
|
}
|
|
13130
13130
|
if (triggers) {
|
|
13131
|
-
quotaUsage.usageQuota.triggers[
|
|
13131
|
+
quotaUsage.usageQuota.triggers[name2] = triggers;
|
|
13132
13132
|
}
|
|
13133
13133
|
};
|
|
13134
|
-
setMonthlyTriggers = (
|
|
13134
|
+
setMonthlyTriggers = (name2, currentMonth, quotaUsage, triggers) => {
|
|
13135
13135
|
if (!quotaUsage.monthly[currentMonth].triggers) {
|
|
13136
13136
|
quotaUsage.monthly[currentMonth].triggers = {};
|
|
13137
13137
|
}
|
|
13138
13138
|
if (triggers) {
|
|
13139
|
-
quotaUsage.monthly[currentMonth].triggers[
|
|
13139
|
+
quotaUsage.monthly[currentMonth].triggers[name2] = triggers;
|
|
13140
13140
|
}
|
|
13141
13141
|
};
|
|
13142
|
-
coreUsageUpdate = (quotaUsage,
|
|
13142
|
+
coreUsageUpdate = (quotaUsage, name2, type, values, opts = {}) => {
|
|
13143
13143
|
if (type === "static" /* STATIC */) {
|
|
13144
|
-
|
|
13145
|
-
quotaUsage.usageQuota[
|
|
13146
|
-
setStaticTriggers(
|
|
13144
|
+
name2 = name2;
|
|
13145
|
+
quotaUsage.usageQuota[name2] = values.total;
|
|
13146
|
+
setStaticTriggers(name2, quotaUsage, values.triggers);
|
|
13147
13147
|
} else if (type === "monthly" /* MONTHLY */) {
|
|
13148
|
-
|
|
13148
|
+
name2 = name2;
|
|
13149
13149
|
const currentMonth = getCurrentMonthString();
|
|
13150
|
-
quotaUsage.monthly[currentMonth][
|
|
13151
|
-
setMonthlyTriggers(
|
|
13150
|
+
quotaUsage.monthly[currentMonth][name2] = values.total;
|
|
13151
|
+
setMonthlyTriggers(name2, currentMonth, quotaUsage, values.triggers);
|
|
13152
13152
|
} else {
|
|
13153
13153
|
throw new Error(`Invalid usage type: ${type}`);
|
|
13154
13154
|
}
|
|
13155
|
-
return setAppUsageValue(quotaUsage,
|
|
13155
|
+
return setAppUsageValue(quotaUsage, name2, type, opts, values);
|
|
13156
13156
|
};
|
|
13157
|
-
setAllUsage = async (
|
|
13157
|
+
setAllUsage = async (name2, type, values, opts = {}) => {
|
|
13158
13158
|
const db2 = getDB2();
|
|
13159
13159
|
let quotaUsage = await getQuotaUsage();
|
|
13160
|
-
quotaUsage = coreUsageUpdate(quotaUsage,
|
|
13160
|
+
quotaUsage = coreUsageUpdate(quotaUsage, name2, type, values, opts);
|
|
13161
13161
|
const response2 = await db2.put(quotaUsage);
|
|
13162
13162
|
quotaUsage._rev = response2.rev;
|
|
13163
13163
|
return quotaUsage;
|
|
13164
13164
|
};
|
|
13165
|
-
getCurrentUsageValues = async (type,
|
|
13165
|
+
getCurrentUsageValues = async (type, name2, id) => {
|
|
13166
13166
|
const quotaUsage = await getQuotaUsage();
|
|
13167
13167
|
let total = 0, appValues = {};
|
|
13168
13168
|
switch (type) {
|
|
13169
13169
|
case "static" /* STATIC */:
|
|
13170
|
-
if (quotaUsage.usageQuota[
|
|
13171
|
-
const staticName =
|
|
13170
|
+
if (quotaUsage.usageQuota[name2]) {
|
|
13171
|
+
const staticName = name2;
|
|
13172
13172
|
total = quotaUsage.usageQuota[staticName];
|
|
13173
|
-
appValues = getAppUsageValue(quotaUsage, type,
|
|
13173
|
+
appValues = getAppUsageValue(quotaUsage, type, name2, id);
|
|
13174
13174
|
}
|
|
13175
13175
|
break;
|
|
13176
13176
|
case "monthly" /* MONTHLY */:
|
|
13177
13177
|
const currentMonth = getCurrentMonthString();
|
|
13178
|
-
const monthlyName =
|
|
13178
|
+
const monthlyName = name2;
|
|
13179
13179
|
if (quotaUsage.monthly[currentMonth][monthlyName]) {
|
|
13180
13180
|
total = quotaUsage.monthly[currentMonth][monthlyName];
|
|
13181
|
-
appValues = getAppUsageValue(quotaUsage, type,
|
|
13181
|
+
appValues = getAppUsageValue(quotaUsage, type, name2, id);
|
|
13182
13182
|
}
|
|
13183
13183
|
break;
|
|
13184
13184
|
default:
|
|
13185
13185
|
throw new Error(`Invalid usage type: ${type}`);
|
|
13186
13186
|
}
|
|
13187
|
-
if (APP_QUOTA_NAMES.includes(
|
|
13187
|
+
if (APP_QUOTA_NAMES.includes(name2) && !(appValues.app || appValues.breakdown)) {
|
|
13188
13188
|
appValues.app = appValues.app || 0;
|
|
13189
13189
|
appValues.breakdown = appValues.breakdown || 0;
|
|
13190
13190
|
}
|
|
@@ -13406,9 +13406,9 @@ async function getGroupUsers(groupId, params2) {
|
|
|
13406
13406
|
createGroupUserLookupView,
|
|
13407
13407
|
{ arrayResponse: true }
|
|
13408
13408
|
);
|
|
13409
|
-
const users2 = userDocs.map((
|
|
13410
|
-
_id:
|
|
13411
|
-
email:
|
|
13409
|
+
const users2 = userDocs.map((doc2) => ({
|
|
13410
|
+
_id: doc2.userId,
|
|
13411
|
+
email: doc2.email
|
|
13412
13412
|
})) || [];
|
|
13413
13413
|
return users2;
|
|
13414
13414
|
}
|
|
@@ -13497,12 +13497,12 @@ async function destroy3(groupId, revision) {
|
|
|
13497
13497
|
await cleanupUsers(group2);
|
|
13498
13498
|
return resp;
|
|
13499
13499
|
}
|
|
13500
|
-
async function getByName(
|
|
13500
|
+
async function getByName(name2) {
|
|
13501
13501
|
try {
|
|
13502
13502
|
const groups = await db_exports.directCouchFind(tenancy.getGlobalDBName(), {
|
|
13503
13503
|
selector: {
|
|
13504
13504
|
name: {
|
|
13505
|
-
$regex: `^(?i)${
|
|
13505
|
+
$regex: `^(?i)${name2}$`
|
|
13506
13506
|
}
|
|
13507
13507
|
},
|
|
13508
13508
|
limit: 1
|
|
@@ -13829,11 +13829,11 @@ var init_version2 = __esm({
|
|
|
13829
13829
|
}
|
|
13830
13830
|
};
|
|
13831
13831
|
getProVersion = () => {
|
|
13832
|
-
const
|
|
13833
|
-
if (!
|
|
13832
|
+
const version2 = environment_default.VERSION;
|
|
13833
|
+
if (!version2) {
|
|
13834
13834
|
throw new Error("No budibase pro version was specified");
|
|
13835
13835
|
}
|
|
13836
|
-
return
|
|
13836
|
+
return version2;
|
|
13837
13837
|
};
|
|
13838
13838
|
}
|
|
13839
13839
|
});
|
|
@@ -13977,15 +13977,15 @@ async function fetchAppBackups(appId, opts = {}) {
|
|
|
13977
13977
|
}
|
|
13978
13978
|
return pageData;
|
|
13979
13979
|
}
|
|
13980
|
-
async function storeAppBackupMetadata(
|
|
13980
|
+
async function storeAppBackupMetadata(metadata2, opts = {}) {
|
|
13981
13981
|
const db2 = tenancy.getGlobalDB();
|
|
13982
|
-
const prodAppId = db_exports.getProdAppID(
|
|
13983
|
-
let _id = generateAppBackupID(prodAppId,
|
|
13982
|
+
const prodAppId = db_exports.getProdAppID(metadata2.appId);
|
|
13983
|
+
let _id = generateAppBackupID(prodAppId, metadata2.timestamp);
|
|
13984
13984
|
const appBackupDoc = {
|
|
13985
|
-
...
|
|
13985
|
+
...metadata2,
|
|
13986
13986
|
_id,
|
|
13987
13987
|
appId: prodAppId,
|
|
13988
|
-
name:
|
|
13988
|
+
name: metadata2.name
|
|
13989
13989
|
};
|
|
13990
13990
|
if (opts.filename) {
|
|
13991
13991
|
appBackupDoc.filename = opts.filename;
|
|
@@ -13994,18 +13994,18 @@ async function storeAppBackupMetadata(metadata, opts = {}) {
|
|
|
13994
13994
|
appBackupDoc._id = opts.docId;
|
|
13995
13995
|
appBackupDoc._rev = opts.docRev;
|
|
13996
13996
|
}
|
|
13997
|
-
if (
|
|
13997
|
+
if (metadata2.createdBy) {
|
|
13998
13998
|
appBackupDoc.createdBy = db_exports.getGlobalIDFromUserMetadataID(
|
|
13999
|
-
|
|
13999
|
+
metadata2.createdBy
|
|
14000
14000
|
);
|
|
14001
14001
|
}
|
|
14002
14002
|
return await db2.put(appBackupDoc);
|
|
14003
14003
|
}
|
|
14004
|
-
async function updateAppBackupMetadata(backupId,
|
|
14004
|
+
async function updateAppBackupMetadata(backupId, name2) {
|
|
14005
14005
|
const db2 = tenancy.getGlobalDB();
|
|
14006
|
-
const
|
|
14007
|
-
|
|
14008
|
-
return await db2.put(
|
|
14006
|
+
const metadata2 = await db2.get(backupId);
|
|
14007
|
+
metadata2.name = name2;
|
|
14008
|
+
return await db2.put(metadata2);
|
|
14009
14009
|
}
|
|
14010
14010
|
async function deleteAppBackupMetadata(backupId) {
|
|
14011
14011
|
const db2 = tenancy.getGlobalDB();
|
|
@@ -14040,9 +14040,9 @@ __export(environmentVariables_exports, {
|
|
|
14040
14040
|
function getEnvVarID() {
|
|
14041
14041
|
return StaticDatabases.GLOBAL.docs.environmentVariables;
|
|
14042
14042
|
}
|
|
14043
|
-
function getCacheEnvVarID(
|
|
14043
|
+
function getCacheEnvVarID(rev2) {
|
|
14044
14044
|
const tenantId = tenancy.getTenantId();
|
|
14045
|
-
return `${tenantId}/${getEnvVarID()}/${
|
|
14045
|
+
return `${tenantId}/${getEnvVarID()}/${rev2 || ""}`;
|
|
14046
14046
|
}
|
|
14047
14047
|
async function get5() {
|
|
14048
14048
|
const id = getEnvVarID();
|
|
@@ -14082,14 +14082,14 @@ async function get5() {
|
|
|
14082
14082
|
cache.set(cacheKey, finalDoc);
|
|
14083
14083
|
return finalDoc;
|
|
14084
14084
|
}
|
|
14085
|
-
async function update(
|
|
14085
|
+
async function update(doc2) {
|
|
14086
14086
|
const id = getEnvVarID();
|
|
14087
14087
|
const db2 = tenancy.getGlobalDB();
|
|
14088
14088
|
return await db2.put({
|
|
14089
|
-
_id:
|
|
14090
|
-
_rev:
|
|
14089
|
+
_id: doc2._id || id,
|
|
14090
|
+
_rev: doc2._rev || void 0,
|
|
14091
14091
|
variables: encryption_exports.encrypt(
|
|
14092
|
-
JSON.stringify(
|
|
14092
|
+
JSON.stringify(doc2.variables),
|
|
14093
14093
|
encryption_exports.SecretOption.ENCRYPTION
|
|
14094
14094
|
)
|
|
14095
14095
|
});
|
|
@@ -14572,14 +14572,14 @@ var init_quotas5 = __esm({
|
|
|
14572
14572
|
init_db7();
|
|
14573
14573
|
init_src2();
|
|
14574
14574
|
init_quotas3();
|
|
14575
|
-
increment = (
|
|
14576
|
-
return tryIncrement(1,
|
|
14575
|
+
increment = (name2, type, opts) => {
|
|
14576
|
+
return tryIncrement(1, name2, type, opts);
|
|
14577
14577
|
};
|
|
14578
|
-
incrementMany = (change,
|
|
14579
|
-
return tryIncrement(change,
|
|
14578
|
+
incrementMany = (change, name2, type, opts) => {
|
|
14579
|
+
return tryIncrement(change, name2, type, opts);
|
|
14580
14580
|
};
|
|
14581
|
-
tryIncrement = async (change,
|
|
14582
|
-
await updateUsage(change,
|
|
14581
|
+
tryIncrement = async (change, name2, type, opts = {}) => {
|
|
14582
|
+
await updateUsage(change, name2, type, {
|
|
14583
14583
|
dryRun: true,
|
|
14584
14584
|
suppressErrorLog: opts.suppressErrorLog,
|
|
14585
14585
|
id: opts.id
|
|
@@ -14588,7 +14588,7 @@ var init_quotas5 = __esm({
|
|
|
14588
14588
|
if (opts.fn) {
|
|
14589
14589
|
result = await opts.fn();
|
|
14590
14590
|
}
|
|
14591
|
-
await updateUsage(change,
|
|
14591
|
+
await updateUsage(change, name2, type, {
|
|
14592
14592
|
dryRun: false,
|
|
14593
14593
|
valueFn: opts.valueFn,
|
|
14594
14594
|
suppressErrorLog: opts.suppressErrorLog,
|
|
@@ -14596,32 +14596,32 @@ var init_quotas5 = __esm({
|
|
|
14596
14596
|
});
|
|
14597
14597
|
return result;
|
|
14598
14598
|
};
|
|
14599
|
-
decrement = (
|
|
14600
|
-
return updateUsage(-1,
|
|
14599
|
+
decrement = (name2, type, opts = {}) => {
|
|
14600
|
+
return updateUsage(-1, name2, type, opts);
|
|
14601
14601
|
};
|
|
14602
|
-
decrementMany = (change,
|
|
14603
|
-
return updateUsage(-change,
|
|
14602
|
+
decrementMany = (change, name2, type, opts = {}) => {
|
|
14603
|
+
return updateUsage(-change, name2, type, opts);
|
|
14604
14604
|
};
|
|
14605
|
-
set2 = async (
|
|
14606
|
-
return quotas_exports.setUsage(value,
|
|
14605
|
+
set2 = async (name2, type, value) => {
|
|
14606
|
+
return quotas_exports.setUsage(value, name2, type);
|
|
14607
14607
|
};
|
|
14608
|
-
getExistingTriggers = (type,
|
|
14608
|
+
getExistingTriggers = (type, name2, quotaUsage) => {
|
|
14609
14609
|
if (type == "static" /* STATIC */) {
|
|
14610
14610
|
const triggers = quotaUsage.usageQuota.triggers;
|
|
14611
|
-
return triggers ? triggers[
|
|
14611
|
+
return triggers ? triggers[name2] || {} : {};
|
|
14612
14612
|
} else {
|
|
14613
14613
|
const currentMonthString = quotas_exports.utils.getCurrentMonthString();
|
|
14614
14614
|
const triggers = quotaUsage.monthly[currentMonthString].triggers;
|
|
14615
|
-
return triggers ? triggers[
|
|
14615
|
+
return triggers ? triggers[name2] || {} : {};
|
|
14616
14616
|
}
|
|
14617
14617
|
};
|
|
14618
|
-
triggerQuota2 = async (
|
|
14618
|
+
triggerQuota2 = async (name2, quota, percentage, resetDate) => {
|
|
14619
14619
|
try {
|
|
14620
14620
|
await redlockImpl_exports.doWithLock(
|
|
14621
14621
|
{
|
|
14622
14622
|
type: "try_once" /* TRY_ONCE */,
|
|
14623
14623
|
name: "trigger_quota" /* TRIGGER_QUOTA */,
|
|
14624
|
-
resource:
|
|
14624
|
+
resource: name2,
|
|
14625
14625
|
// use the quota name for extra uniqueness on the lock
|
|
14626
14626
|
ttl: 1e4
|
|
14627
14627
|
// auto expire after 10 seconds
|
|
@@ -14641,10 +14641,10 @@ var init_quotas5 = __esm({
|
|
|
14641
14641
|
logging_exports.logAlert("Error triggering quota", e);
|
|
14642
14642
|
}
|
|
14643
14643
|
};
|
|
14644
|
-
checkTriggers = async (type,
|
|
14644
|
+
checkTriggers = async (type, name2, totalValue, quota) => {
|
|
14645
14645
|
const usage = await getQuotaUsage();
|
|
14646
14646
|
const resetDate = type === "monthly" /* MONTHLY */ ? usage.quotaReset : void 0;
|
|
14647
|
-
const triggers = await getExistingTriggers(type,
|
|
14647
|
+
const triggers = await getExistingTriggers(type, name2, usage);
|
|
14648
14648
|
const quotaTriggers = quota.triggers;
|
|
14649
14649
|
let percentage = totalValue / quota.value * 100;
|
|
14650
14650
|
if (percentage > 100) {
|
|
@@ -14660,7 +14660,7 @@ var init_quotas5 = __esm({
|
|
|
14660
14660
|
const isAtTrigger = percentage === triggerPercentage;
|
|
14661
14661
|
const sendNotification = !nextIsTriggered || isAtTrigger;
|
|
14662
14662
|
if (sendNotification) {
|
|
14663
|
-
await triggerQuota2(
|
|
14663
|
+
await triggerQuota2(name2, quota, percentage, resetDate);
|
|
14664
14664
|
}
|
|
14665
14665
|
}
|
|
14666
14666
|
} else {
|
|
@@ -14669,23 +14669,23 @@ var init_quotas5 = __esm({
|
|
|
14669
14669
|
}
|
|
14670
14670
|
return triggers;
|
|
14671
14671
|
};
|
|
14672
|
-
updateUsage = async (usageChange,
|
|
14672
|
+
updateUsage = async (usageChange, name2, type, opts = {}) => {
|
|
14673
14673
|
let appId = null;
|
|
14674
14674
|
try {
|
|
14675
14675
|
appId = context_exports.getAppId();
|
|
14676
14676
|
} catch (err) {
|
|
14677
14677
|
}
|
|
14678
|
-
const isAppQuota = APP_QUOTA_NAMES.includes(
|
|
14678
|
+
const isAppQuota = APP_QUOTA_NAMES.includes(name2);
|
|
14679
14679
|
if (isAppQuota && !appId) {
|
|
14680
14680
|
throw new Error("App context required for quota update");
|
|
14681
14681
|
}
|
|
14682
14682
|
try {
|
|
14683
|
-
const licensedQuota = await getLicensedQuota("usage" /* USAGE */,
|
|
14683
|
+
const licensedQuota = await getLicensedQuota("usage" /* USAGE */, name2, type);
|
|
14684
14684
|
let {
|
|
14685
14685
|
total: totalValue,
|
|
14686
14686
|
app: appValue,
|
|
14687
14687
|
breakdown: breakdownValue
|
|
14688
|
-
} = await quotas_exports.getCurrentUsageValues(type,
|
|
14688
|
+
} = await quotas_exports.getCurrentUsageValues(type, name2, opts.id);
|
|
14689
14689
|
totalValue += usageChange;
|
|
14690
14690
|
if (appValue != null) {
|
|
14691
14691
|
appValue += usageChange;
|
|
@@ -14695,7 +14695,7 @@ var init_quotas5 = __esm({
|
|
|
14695
14695
|
}
|
|
14696
14696
|
let triggers = {};
|
|
14697
14697
|
if (!opts.dryRun) {
|
|
14698
|
-
triggers = await checkTriggers(type,
|
|
14698
|
+
triggers = await checkTriggers(type, name2, totalValue, licensedQuota);
|
|
14699
14699
|
}
|
|
14700
14700
|
if (licensedQuota.value !== quotas_exports2.UNLIMITED && totalValue > licensedQuota.value && usageChange > 0) {
|
|
14701
14701
|
throw new UsageLimitError(
|
|
@@ -14718,7 +14718,7 @@ var init_quotas5 = __esm({
|
|
|
14718
14718
|
appValue = totalValue;
|
|
14719
14719
|
}
|
|
14720
14720
|
await quotas_exports.setAllUsage(
|
|
14721
|
-
|
|
14721
|
+
name2,
|
|
14722
14722
|
type,
|
|
14723
14723
|
{
|
|
14724
14724
|
total: totalValue,
|
|
@@ -14730,30 +14730,30 @@ var init_quotas5 = __esm({
|
|
|
14730
14730
|
);
|
|
14731
14731
|
} catch (err) {
|
|
14732
14732
|
if (!opts.suppressErrorLog) {
|
|
14733
|
-
console.error(`Error updating usage quotas for ${
|
|
14733
|
+
console.error(`Error updating usage quotas for ${name2}`, err);
|
|
14734
14734
|
}
|
|
14735
14735
|
throw err;
|
|
14736
14736
|
}
|
|
14737
14737
|
};
|
|
14738
|
-
getLicensedQuota = async (quotaType,
|
|
14738
|
+
getLicensedQuota = async (quotaType, name2, usageType) => {
|
|
14739
14739
|
const license = await cache_exports2.getCachedLicense();
|
|
14740
14740
|
if (!license) {
|
|
14741
14741
|
const tenantId = tenancy.getTenantId();
|
|
14742
14742
|
throw new Error("License not found for tenant id " + tenantId);
|
|
14743
14743
|
}
|
|
14744
|
-
if (usageType && isStaticQuota(quotaType, usageType,
|
|
14745
|
-
return license.quotas[quotaType][usageType][
|
|
14746
|
-
} else if (usageType && isMonthlyQuota(quotaType, usageType,
|
|
14747
|
-
return license.quotas[quotaType][usageType][
|
|
14748
|
-
} else if (isConstantQuota(quotaType,
|
|
14749
|
-
return license.quotas[quotaType][
|
|
14744
|
+
if (usageType && isStaticQuota(quotaType, usageType, name2)) {
|
|
14745
|
+
return license.quotas[quotaType][usageType][name2];
|
|
14746
|
+
} else if (usageType && isMonthlyQuota(quotaType, usageType, name2)) {
|
|
14747
|
+
return license.quotas[quotaType][usageType][name2];
|
|
14748
|
+
} else if (isConstantQuota(quotaType, name2)) {
|
|
14749
|
+
return license.quotas[quotaType][name2];
|
|
14750
14750
|
} else {
|
|
14751
14751
|
throw new Error("Invalid quota type");
|
|
14752
14752
|
}
|
|
14753
14753
|
};
|
|
14754
|
-
usageLimitIsExceeded = async (
|
|
14754
|
+
usageLimitIsExceeded = async (name2, type) => {
|
|
14755
14755
|
try {
|
|
14756
|
-
await updateUsage(1,
|
|
14756
|
+
await updateUsage(1, name2, type, { dryRun: true });
|
|
14757
14757
|
return false;
|
|
14758
14758
|
} catch (e) {
|
|
14759
14759
|
if (e.code === "usage_limit_exceeded" /* USAGE_LIMIT_EXCEEDED */) {
|
|
@@ -15292,7 +15292,7 @@ async function getLogsByView(startDate, endDate, viewParams = {}) {
|
|
|
15292
15292
|
async function writeLog(automation, results) {
|
|
15293
15293
|
const db2 = context_exports.getProdAppDB();
|
|
15294
15294
|
const automationId = automation._id;
|
|
15295
|
-
const
|
|
15295
|
+
const name2 = automation.name;
|
|
15296
15296
|
const status2 = getStatus2(results);
|
|
15297
15297
|
const isoDate = (/* @__PURE__ */ new Date()).toISOString();
|
|
15298
15298
|
const id = generateAutomationLogID(isoDate, status2, automationId);
|
|
@@ -15301,7 +15301,7 @@ async function writeLog(automation, results) {
|
|
|
15301
15301
|
...results,
|
|
15302
15302
|
automationId,
|
|
15303
15303
|
status: status2,
|
|
15304
|
-
automationName:
|
|
15304
|
+
automationName: name2,
|
|
15305
15305
|
createdAt: isoDate,
|
|
15306
15306
|
_id: id
|
|
15307
15307
|
};
|
|
@@ -15311,13 +15311,13 @@ async function writeLog(automation, results) {
|
|
|
15311
15311
|
async function updateAppMetadataWithErrors(logIds, { clearing } = { clearing: false }) {
|
|
15312
15312
|
const db2 = context_exports.getProdAppDB();
|
|
15313
15313
|
await backOff(async () => {
|
|
15314
|
-
const
|
|
15314
|
+
const metadata2 = await db2.get(db_exports.DocumentType.APP_METADATA);
|
|
15315
15315
|
for (let logId of logIds) {
|
|
15316
15316
|
const parts = logId.split(db_exports.SEPARATOR);
|
|
15317
15317
|
const autoId = `${parts[parts.length - 3]}${db_exports.SEPARATOR}${parts[parts.length - 2]}`;
|
|
15318
15318
|
let errors = {};
|
|
15319
|
-
if (
|
|
15320
|
-
errors =
|
|
15319
|
+
if (metadata2.automationErrors) {
|
|
15320
|
+
errors = metadata2.automationErrors;
|
|
15321
15321
|
}
|
|
15322
15322
|
if (!Array.isArray(errors[autoId])) {
|
|
15323
15323
|
errors[autoId] = [];
|
|
@@ -15331,10 +15331,10 @@ async function updateAppMetadataWithErrors(logIds, { clearing } = { clearing: fa
|
|
|
15331
15331
|
if (errors[autoId].length === 0) {
|
|
15332
15332
|
delete errors[autoId];
|
|
15333
15333
|
}
|
|
15334
|
-
|
|
15334
|
+
metadata2.automationErrors = errors;
|
|
15335
15335
|
}
|
|
15336
|
-
await db2.put(
|
|
15337
|
-
await cache_exports.app.invalidateAppMetadata(
|
|
15336
|
+
await db2.put(metadata2);
|
|
15337
|
+
await cache_exports.app.invalidateAppMetadata(metadata2.appId, metadata2);
|
|
15338
15338
|
}, "Failed to update app metadata with automation log error");
|
|
15339
15339
|
}
|
|
15340
15340
|
async function getExpiredLogs() {
|
|
@@ -15356,16 +15356,16 @@ async function clearOldHistory() {
|
|
|
15356
15356
|
if (!expired.data || expired.data.length === 0) {
|
|
15357
15357
|
return;
|
|
15358
15358
|
}
|
|
15359
|
-
const toDelete = expired.data.map((
|
|
15360
|
-
_id:
|
|
15361
|
-
_rev:
|
|
15359
|
+
const toDelete = expired.data.map((doc2) => ({
|
|
15360
|
+
_id: doc2.id,
|
|
15361
|
+
_rev: doc2.value.rev,
|
|
15362
15362
|
_deleted: true
|
|
15363
15363
|
}));
|
|
15364
|
-
const errorLogIds = expired.data.filter((
|
|
15365
|
-
const parts =
|
|
15364
|
+
const errorLogIds = expired.data.filter((doc2) => {
|
|
15365
|
+
const parts = doc2.id.split(db_exports.SEPARATOR);
|
|
15366
15366
|
const status2 = parts[parts.length - 1];
|
|
15367
15367
|
return status2 === "error" /* ERROR */;
|
|
15368
|
-
}).map((
|
|
15368
|
+
}).map((doc2) => doc2.id);
|
|
15369
15369
|
await db2.bulkDocs(toDelete);
|
|
15370
15370
|
if (errorLogIds.length) {
|
|
15371
15371
|
await updateAppMetadataWithErrors(errorLogIds, { clearing: true });
|
|
@@ -15585,10 +15585,10 @@ async function get6(id) {
|
|
|
15585
15585
|
async function getBulk2(ids, opts = { enriched: true }) {
|
|
15586
15586
|
return await groups_exports.getBulk(ids, opts);
|
|
15587
15587
|
}
|
|
15588
|
-
async function guardNameAvailility(
|
|
15589
|
-
const existingGroup = await groups_exports.getByName(
|
|
15588
|
+
async function guardNameAvailility(name2) {
|
|
15589
|
+
const existingGroup = await groups_exports.getByName(name2);
|
|
15590
15590
|
if (existingGroup) {
|
|
15591
|
-
throw new GroupNameUnavailableError(
|
|
15591
|
+
throw new GroupNameUnavailableError(name2);
|
|
15592
15592
|
}
|
|
15593
15593
|
}
|
|
15594
15594
|
async function save4(group2) {
|
|
@@ -15747,8 +15747,8 @@ var init_groups6 = __esm({
|
|
|
15747
15747
|
});
|
|
15748
15748
|
|
|
15749
15749
|
// ../pro/packages/pro/src/utilities/fileSystem.ts
|
|
15750
|
-
function loadJSFile(
|
|
15751
|
-
return import_fs11.default.readFileSync((0, import_path12.join)(
|
|
15750
|
+
function loadJSFile(directory2, name2) {
|
|
15751
|
+
return import_fs11.default.readFileSync((0, import_path12.join)(directory2, name2), "utf8");
|
|
15752
15752
|
}
|
|
15753
15753
|
var import_fs11, import_path12;
|
|
15754
15754
|
var init_fileSystem2 = __esm({
|
|
@@ -15766,8 +15766,8 @@ __export(plugins_exports, {
|
|
|
15766
15766
|
storePlugin: () => storePlugin
|
|
15767
15767
|
});
|
|
15768
15768
|
async function storePlugin(metadata, directory, source) {
|
|
15769
|
-
const
|
|
15770
|
-
const version = metadata.package.version, name = metadata.package.name, description = metadata.package.description,
|
|
15769
|
+
const db = tenancy.getGlobalDB();
|
|
15770
|
+
const version = metadata.package.version, name = metadata.package.name, description = metadata.package.description, hash = metadata.schema.hash;
|
|
15771
15771
|
const bucketPath = objectStore_exports2.getPluginS3Dir(name);
|
|
15772
15772
|
const files = await objectStore_exports2.uploadDirectory(
|
|
15773
15773
|
objectStore_exports2.ObjectStoreBuckets.PLUGINS,
|
|
@@ -15782,8 +15782,7 @@ async function storePlugin(metadata, directory, source) {
|
|
|
15782
15782
|
if (metadata.schema.type === "datasource" /* DATASOURCE */) {
|
|
15783
15783
|
const js = loadJSFile(directory, jsFile.name);
|
|
15784
15784
|
try {
|
|
15785
|
-
;
|
|
15786
|
-
(0, eval)(js);
|
|
15785
|
+
eval(js);
|
|
15787
15786
|
} catch (err) {
|
|
15788
15787
|
const message = (err == null ? void 0 : err.message) ? err.message : JSON.stringify(err);
|
|
15789
15788
|
throw new Error(`JS invalid: ${message}`);
|
|
@@ -15793,7 +15792,7 @@ async function storePlugin(metadata, directory, source) {
|
|
|
15793
15792
|
const pluginId = db_exports.generatePluginID(name);
|
|
15794
15793
|
let rev;
|
|
15795
15794
|
try {
|
|
15796
|
-
const existing = await
|
|
15795
|
+
const existing = await db.get(pluginId);
|
|
15797
15796
|
rev = existing._rev;
|
|
15798
15797
|
} catch (err) {
|
|
15799
15798
|
rev = void 0;
|
|
@@ -15804,7 +15803,7 @@ async function storePlugin(metadata, directory, source) {
|
|
|
15804
15803
|
...metadata,
|
|
15805
15804
|
name,
|
|
15806
15805
|
version,
|
|
15807
|
-
hash
|
|
15806
|
+
hash,
|
|
15808
15807
|
description
|
|
15809
15808
|
};
|
|
15810
15809
|
if (iconFileName) {
|
|
@@ -15816,8 +15815,8 @@ async function storePlugin(metadata, directory, source) {
|
|
|
15816
15815
|
source
|
|
15817
15816
|
};
|
|
15818
15817
|
}
|
|
15819
|
-
const
|
|
15820
|
-
const response2 = await
|
|
15818
|
+
const write = async () => {
|
|
15819
|
+
const response2 = await db.put(doc);
|
|
15821
15820
|
await events_exports.plugin.imported(doc);
|
|
15822
15821
|
return {
|
|
15823
15822
|
...doc,
|
|
@@ -15825,21 +15824,21 @@ async function storePlugin(metadata, directory, source) {
|
|
|
15825
15824
|
};
|
|
15826
15825
|
};
|
|
15827
15826
|
if (!rev) {
|
|
15828
|
-
return await addPlugin(
|
|
15827
|
+
return await addPlugin(write);
|
|
15829
15828
|
} else {
|
|
15830
|
-
return await
|
|
15829
|
+
return await write();
|
|
15831
15830
|
}
|
|
15832
15831
|
}
|
|
15833
|
-
async function deletePlugin(
|
|
15832
|
+
async function deletePlugin(pluginId2) {
|
|
15834
15833
|
const db2 = tenancy.getGlobalDB();
|
|
15835
15834
|
try {
|
|
15836
|
-
const plugin = await db2.get(
|
|
15837
|
-
const
|
|
15835
|
+
const plugin = await db2.get(pluginId2);
|
|
15836
|
+
const bucketPath2 = objectStore_exports2.getPluginS3Dir(plugin.name);
|
|
15838
15837
|
await objectStore_exports2.deleteFolder(
|
|
15839
15838
|
objectStore_exports2.ObjectStoreBuckets.PLUGINS,
|
|
15840
|
-
|
|
15839
|
+
bucketPath2
|
|
15841
15840
|
);
|
|
15842
|
-
await db2.remove(
|
|
15841
|
+
await db2.remove(pluginId2, plugin._rev);
|
|
15843
15842
|
await events_exports.plugin.deleted(plugin);
|
|
15844
15843
|
await removePlugin();
|
|
15845
15844
|
} catch (err) {
|
|
@@ -15873,12 +15872,12 @@ function isEncryptionKeyAvailable() {
|
|
|
15873
15872
|
return !!environment_default.ENCRYPTION_KEY;
|
|
15874
15873
|
}
|
|
15875
15874
|
async function fetch10() {
|
|
15876
|
-
const
|
|
15877
|
-
return Object.keys(
|
|
15875
|
+
const doc2 = await environmentVariables_exports.get();
|
|
15876
|
+
return Object.keys(doc2.variables);
|
|
15878
15877
|
}
|
|
15879
15878
|
async function fetchValues(environment3) {
|
|
15880
|
-
const
|
|
15881
|
-
const decrypted =
|
|
15879
|
+
const doc2 = await environmentVariables_exports.get();
|
|
15880
|
+
const decrypted = doc2.variables;
|
|
15882
15881
|
const output = {};
|
|
15883
15882
|
for (let [key, value] of Object.entries(decrypted)) {
|
|
15884
15883
|
switch (environment3) {
|
|
@@ -15900,9 +15899,9 @@ async function changeValues(cb) {
|
|
|
15900
15899
|
"User does not have access to environment variables feature."
|
|
15901
15900
|
);
|
|
15902
15901
|
}
|
|
15903
|
-
const
|
|
15904
|
-
|
|
15905
|
-
await environmentVariables_exports.update(
|
|
15902
|
+
const doc2 = await environmentVariables_exports.get();
|
|
15903
|
+
doc2.variables = cb(doc2.variables);
|
|
15904
|
+
await environmentVariables_exports.update(doc2);
|
|
15906
15905
|
}
|
|
15907
15906
|
async function update2(varName, value) {
|
|
15908
15907
|
const checkName = isValid(varName);
|
|
@@ -15953,15 +15952,15 @@ var init_environmentVariables6 = __esm({
|
|
|
15953
15952
|
function generateAuditLogID(timestamp) {
|
|
15954
15953
|
return `${"al" /* AUDIT_LOG */}${SEPARATOR}${timestamp}${SEPARATOR}${utils_exports2.newid()}`;
|
|
15955
15954
|
}
|
|
15956
|
-
async function save5(
|
|
15957
|
-
if (!
|
|
15958
|
-
|
|
15955
|
+
async function save5(doc2) {
|
|
15956
|
+
if (!doc2._id) {
|
|
15957
|
+
doc2._id = generateAuditLogID(doc2.timestamp);
|
|
15959
15958
|
}
|
|
15960
15959
|
try {
|
|
15961
15960
|
const db2 = context_exports.getAuditLogsDB();
|
|
15962
|
-
const response2 = await db2.put(
|
|
15961
|
+
const response2 = await db2.put(doc2);
|
|
15963
15962
|
return {
|
|
15964
|
-
...
|
|
15963
|
+
...doc2,
|
|
15965
15964
|
_rev: response2.rev
|
|
15966
15965
|
};
|
|
15967
15966
|
} catch (err) {
|
|
@@ -15989,9 +15988,9 @@ function dump(params2) {
|
|
|
15989
15988
|
const db2 = context_exports.getAuditLogsDB();
|
|
15990
15989
|
const stream3 = new MemoryStream();
|
|
15991
15990
|
const promise = db2.dump(stream3, {
|
|
15992
|
-
filter: (
|
|
15991
|
+
filter: (doc2) => {
|
|
15993
15992
|
var _a2;
|
|
15994
|
-
const auditLog =
|
|
15993
|
+
const auditLog = doc2;
|
|
15995
15994
|
if (!((_a2 = auditLog._id) == null ? void 0 : _a2.startsWith("al" /* AUDIT_LOG */))) {
|
|
15996
15995
|
return false;
|
|
15997
15996
|
}
|
|
@@ -16009,7 +16008,7 @@ function dump(params2) {
|
|
|
16009
16008
|
allMatched = allMatched && auditLog.timestamp >= params2.startDate && auditLog.timestamp <= params2.endDate;
|
|
16010
16009
|
}
|
|
16011
16010
|
if (params2.fullSearch) {
|
|
16012
|
-
const json2 = JSON.stringify(
|
|
16011
|
+
const json2 = JSON.stringify(doc2);
|
|
16013
16012
|
allMatched = allMatched && json2.includes(params2.fullSearch);
|
|
16014
16013
|
}
|
|
16015
16014
|
return allMatched;
|
|
@@ -16020,8 +16019,8 @@ function dump(params2) {
|
|
|
16020
16019
|
const json2 = JSON.parse(Buffer.from(data2).toString());
|
|
16021
16020
|
if (Array.isArray(json2.docs)) {
|
|
16022
16021
|
let str = "";
|
|
16023
|
-
for (let
|
|
16024
|
-
str += JSON.stringify(
|
|
16022
|
+
for (let doc2 of json2.docs) {
|
|
16023
|
+
str += JSON.stringify(doc2) + "\n";
|
|
16025
16024
|
}
|
|
16026
16025
|
returnStream.write(str);
|
|
16027
16026
|
}
|
|
@@ -16046,8 +16045,8 @@ var init_auditLogs4 = __esm({
|
|
|
16046
16045
|
var require_Helper = __commonJS({
|
|
16047
16046
|
"../string-templates/src/helpers/Helper.js"(exports2, module2) {
|
|
16048
16047
|
var Helper = class {
|
|
16049
|
-
constructor(
|
|
16050
|
-
this.name =
|
|
16048
|
+
constructor(name2, fn2, useValueFallback = true) {
|
|
16049
|
+
this.name = name2;
|
|
16051
16050
|
this.fn = fn2;
|
|
16052
16051
|
this.useValueFallback = useValueFallback;
|
|
16053
16052
|
}
|
|
@@ -16216,18 +16215,18 @@ var require_external = __commonJS({
|
|
|
16216
16215
|
exports2.externalCollections = EXTERNAL_FUNCTION_COLLECTIONS;
|
|
16217
16216
|
exports2.addedHelpers = ADDED_HELPERS;
|
|
16218
16217
|
exports2.registerAll = (handlebars) => {
|
|
16219
|
-
for (let [
|
|
16220
|
-
handlebars.registerHelper(
|
|
16218
|
+
for (let [name2, helper] of Object.entries(ADDED_HELPERS)) {
|
|
16219
|
+
handlebars.registerHelper(name2, helper);
|
|
16221
16220
|
}
|
|
16222
16221
|
let externalNames = [];
|
|
16223
16222
|
for (let collection of EXTERNAL_FUNCTION_COLLECTIONS) {
|
|
16224
16223
|
let hbsHelperInfo = helpers[collection]();
|
|
16225
16224
|
for (let entry of Object.entries(hbsHelperInfo)) {
|
|
16226
|
-
const
|
|
16227
|
-
if (HelperFunctionBuiltin.indexOf(
|
|
16225
|
+
const name2 = entry[0];
|
|
16226
|
+
if (HelperFunctionBuiltin.indexOf(name2) !== -1 || externalNames.indexOf(name2) !== -1) {
|
|
16228
16227
|
continue;
|
|
16229
16228
|
}
|
|
16230
|
-
externalNames.push(
|
|
16229
|
+
externalNames.push(name2);
|
|
16231
16230
|
}
|
|
16232
16231
|
helpers[collection]({
|
|
16233
16232
|
handlebars
|
|
@@ -16236,11 +16235,11 @@ var require_external = __commonJS({
|
|
|
16236
16235
|
exports2.externalHelperNames = externalNames.concat(Object.keys(ADDED_HELPERS));
|
|
16237
16236
|
};
|
|
16238
16237
|
exports2.unregisterAll = (handlebars) => {
|
|
16239
|
-
for (let
|
|
16240
|
-
handlebars.unregisterHelper(
|
|
16238
|
+
for (let name2 of Object.keys(ADDED_HELPERS)) {
|
|
16239
|
+
handlebars.unregisterHelper(name2);
|
|
16241
16240
|
}
|
|
16242
|
-
for (let
|
|
16243
|
-
handlebars.unregisterHelper(
|
|
16241
|
+
for (let name2 of module2.exports.externalHelperNames) {
|
|
16242
|
+
handlebars.unregisterHelper(name2);
|
|
16244
16243
|
}
|
|
16245
16244
|
exports2.externalHelperNames = [];
|
|
16246
16245
|
};
|
|
@@ -16354,12 +16353,12 @@ var require_javascript = __commonJS({
|
|
|
16354
16353
|
throw new Error("JS disabled in environment.");
|
|
16355
16354
|
}
|
|
16356
16355
|
try {
|
|
16357
|
-
const
|
|
16356
|
+
const js2 = `function run(){${atob(handlebars)}};run();`;
|
|
16358
16357
|
const sandboxContext = {
|
|
16359
16358
|
$: (path5) => getContextValue(path5, cloneDeep18(context)),
|
|
16360
16359
|
helpers: getHelperList()
|
|
16361
16360
|
};
|
|
16362
|
-
const res = { data: runJS(
|
|
16361
|
+
const res = { data: runJS(js2, sandboxContext) };
|
|
16363
16362
|
return `{{${LITERAL_MARKER} js_result-${JSON.stringify(res)}}}`;
|
|
16364
16363
|
} catch (error2) {
|
|
16365
16364
|
return "Error while executing JS";
|
|
@@ -16472,8 +16471,8 @@ var require_preprocessor = __commonJS({
|
|
|
16472
16471
|
FINALISE: "finalise"
|
|
16473
16472
|
};
|
|
16474
16473
|
var Preprocessor = class {
|
|
16475
|
-
constructor(
|
|
16476
|
-
this.name =
|
|
16474
|
+
constructor(name2, fn2) {
|
|
16475
|
+
this.name = name2;
|
|
16477
16476
|
this.fn = fn2;
|
|
16478
16477
|
}
|
|
16479
16478
|
process(fullString, statement, opts) {
|
|
@@ -16537,8 +16536,8 @@ var require_postprocessor = __commonJS({
|
|
|
16537
16536
|
CONVERT_LITERALS: "convert-literals"
|
|
16538
16537
|
};
|
|
16539
16538
|
var Postprocessor = class {
|
|
16540
|
-
constructor(
|
|
16541
|
-
this.name =
|
|
16539
|
+
constructor(name2, fn2) {
|
|
16540
|
+
this.name = name2;
|
|
16542
16541
|
this.fn = fn2;
|
|
16543
16542
|
}
|
|
16544
16543
|
process(statement) {
|
|
@@ -18180,10 +18179,10 @@ var require_src = __commonJS({
|
|
|
18180
18179
|
};
|
|
18181
18180
|
module2.exports.convertToJS = (hbs) => {
|
|
18182
18181
|
const blocks = exports2.findHBSBlocks(hbs);
|
|
18183
|
-
let
|
|
18182
|
+
let js2 = "return `", prevBlock = null;
|
|
18184
18183
|
const variables = {};
|
|
18185
18184
|
if (blocks.length === 0) {
|
|
18186
|
-
|
|
18185
|
+
js2 += hbs;
|
|
18187
18186
|
}
|
|
18188
18187
|
let count = 1;
|
|
18189
18188
|
for (let block of blocks) {
|
|
@@ -18195,15 +18194,15 @@ var require_src = __commonJS({
|
|
|
18195
18194
|
prevBlock = block;
|
|
18196
18195
|
const { variable, value } = convertHBSBlock(block, count++);
|
|
18197
18196
|
variables[variable] = value;
|
|
18198
|
-
|
|
18197
|
+
js2 += `${stringPart.split()}\${${variable}}`;
|
|
18199
18198
|
}
|
|
18200
18199
|
let varBlock = "";
|
|
18201
18200
|
for (let [variable, value] of Object.entries(variables)) {
|
|
18202
18201
|
varBlock += `const ${variable} = ${value};
|
|
18203
18202
|
`;
|
|
18204
18203
|
}
|
|
18205
|
-
|
|
18206
|
-
return `${varBlock}${
|
|
18204
|
+
js2 += "`;";
|
|
18205
|
+
return `${varBlock}${js2}`;
|
|
18207
18206
|
};
|
|
18208
18207
|
}
|
|
18209
18208
|
});
|
|
@@ -18230,12 +18229,12 @@ var require_src2 = __commonJS({
|
|
|
18230
18229
|
if (!process.env.NO_JS) {
|
|
18231
18230
|
const { VM: VM2 } = require("vm2");
|
|
18232
18231
|
const { setJSRunner } = require_javascript();
|
|
18233
|
-
setJSRunner((
|
|
18232
|
+
setJSRunner((js2, context) => {
|
|
18234
18233
|
const vm = new VM2({
|
|
18235
18234
|
sandbox: context,
|
|
18236
18235
|
timeout: 1e3
|
|
18237
18236
|
});
|
|
18238
|
-
return vm.run(
|
|
18237
|
+
return vm.run(js2);
|
|
18239
18238
|
});
|
|
18240
18239
|
}
|
|
18241
18240
|
}
|
|
@@ -18329,12 +18328,12 @@ async function auditLogsEnabled() {
|
|
|
18329
18328
|
const license = await licensing_exports.cache.getCachedLicense();
|
|
18330
18329
|
return license.features.includes("auditLogs" /* AUDIT_LOGS */);
|
|
18331
18330
|
}
|
|
18332
|
-
function getEventFriendlyName(event,
|
|
18331
|
+
function getEventFriendlyName(event, metadata2) {
|
|
18333
18332
|
const friendly = AuditedEventFriendlyName[event];
|
|
18334
18333
|
if (!friendly) {
|
|
18335
18334
|
throw new Error("No friendly name found.");
|
|
18336
18335
|
}
|
|
18337
|
-
let processed = processStringSync(friendly,
|
|
18336
|
+
let processed = processStringSync(friendly, metadata2);
|
|
18338
18337
|
if (processed.includes(`""`)) {
|
|
18339
18338
|
processed = removeTemplateStrings(friendly);
|
|
18340
18339
|
}
|
|
@@ -18356,29 +18355,29 @@ var init_utils11 = __esm({
|
|
|
18356
18355
|
});
|
|
18357
18356
|
|
|
18358
18357
|
// ../pro/packages/pro/src/sdk/auditLogs/auditLogs.ts
|
|
18359
|
-
async function
|
|
18358
|
+
async function write2(event, metadata2, opts) {
|
|
18360
18359
|
if (!await auditLogsEnabled() || !utils_exports2.isAudited(event)) {
|
|
18361
18360
|
return;
|
|
18362
18361
|
}
|
|
18363
|
-
const friendly = getEventFriendlyName(event,
|
|
18362
|
+
const friendly = getEventFriendlyName(event, metadata2);
|
|
18364
18363
|
let date = /* @__PURE__ */ new Date();
|
|
18365
18364
|
if (opts == null ? void 0 : opts.timestamp) {
|
|
18366
18365
|
date = new Date(opts.timestamp);
|
|
18367
18366
|
}
|
|
18368
|
-
const
|
|
18367
|
+
const doc2 = {
|
|
18369
18368
|
timestamp: date.toISOString(),
|
|
18370
18369
|
event,
|
|
18371
18370
|
name: friendly,
|
|
18372
18371
|
userId: (opts == null ? void 0 : opts.userId) || AuditLogSystemUser,
|
|
18373
18372
|
metadata: {
|
|
18374
|
-
...
|
|
18373
|
+
...metadata2,
|
|
18375
18374
|
...opts == null ? void 0 : opts.hostInfo
|
|
18376
18375
|
}
|
|
18377
18376
|
};
|
|
18378
18377
|
const fallback = {};
|
|
18379
18378
|
try {
|
|
18380
18379
|
if (opts == null ? void 0 : opts.appId) {
|
|
18381
|
-
|
|
18380
|
+
doc2.appId = db_exports.getProdAppID(opts.appId);
|
|
18382
18381
|
const appMetadata = await cache_exports.app.getAppMetadata(opts.appId);
|
|
18383
18382
|
fallback.appName = appMetadata.name;
|
|
18384
18383
|
}
|
|
@@ -18392,8 +18391,8 @@ async function write(event, metadata, opts) {
|
|
|
18392
18391
|
err
|
|
18393
18392
|
);
|
|
18394
18393
|
}
|
|
18395
|
-
|
|
18396
|
-
return await save5(
|
|
18394
|
+
doc2.fallback = fallback;
|
|
18395
|
+
return await save5(doc2);
|
|
18397
18396
|
}
|
|
18398
18397
|
async function enrich(logs) {
|
|
18399
18398
|
const allUserIds = logs.map((log2) => log2.userId);
|
|
@@ -18465,7 +18464,7 @@ __export(auditLogs_exports2, {
|
|
|
18465
18464
|
definitions: () => definitions,
|
|
18466
18465
|
download: () => download,
|
|
18467
18466
|
fetch: () => fetch11,
|
|
18468
|
-
write: () =>
|
|
18467
|
+
write: () => write2
|
|
18469
18468
|
});
|
|
18470
18469
|
var init_auditLogs6 = __esm({
|
|
18471
18470
|
"../pro/packages/pro/src/sdk/auditLogs/index.ts"() {
|
|
@@ -18488,8 +18487,8 @@ var init_queue4 = __esm({
|
|
|
18488
18487
|
});
|
|
18489
18488
|
|
|
18490
18489
|
// ../pro/packages/pro/src/sdk/backups/backup.ts
|
|
18491
|
-
async function storeAppBackupMetadata2(
|
|
18492
|
-
return backups_exports.storeAppBackupMetadata(
|
|
18490
|
+
async function storeAppBackupMetadata2(metadata2, opts = {}) {
|
|
18491
|
+
return backups_exports.storeAppBackupMetadata(metadata2, opts);
|
|
18493
18492
|
}
|
|
18494
18493
|
function getTimestamps(status2) {
|
|
18495
18494
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -18503,7 +18502,7 @@ function getTimestamps(status2) {
|
|
|
18503
18502
|
return { timestamp, createdAt: timestamp };
|
|
18504
18503
|
}
|
|
18505
18504
|
}
|
|
18506
|
-
async function updateBackupStatus(id,
|
|
18505
|
+
async function updateBackupStatus(id, rev2, status2, contents, filename) {
|
|
18507
18506
|
const backup = await getAppBackup(id);
|
|
18508
18507
|
return await backups_exports.storeAppBackupMetadata(
|
|
18509
18508
|
{
|
|
@@ -18513,10 +18512,10 @@ async function updateBackupStatus(id, rev, status2, contents, filename) {
|
|
|
18513
18512
|
status: status2,
|
|
18514
18513
|
type: "backup" /* BACKUP */
|
|
18515
18514
|
},
|
|
18516
|
-
{ filename, docId: id, docRev:
|
|
18515
|
+
{ filename, docId: id, docRev: rev2 }
|
|
18517
18516
|
);
|
|
18518
18517
|
}
|
|
18519
|
-
async function updateRestoreStatus(id,
|
|
18518
|
+
async function updateRestoreStatus(id, rev2, status2) {
|
|
18520
18519
|
const restore = await getAppBackup(id);
|
|
18521
18520
|
return await backups_exports.storeAppBackupMetadata(
|
|
18522
18521
|
{
|
|
@@ -18526,7 +18525,7 @@ async function updateRestoreStatus(id, rev, status2) {
|
|
|
18526
18525
|
type: "restore" /* RESTORE */,
|
|
18527
18526
|
trigger: "manual" /* MANUAL */
|
|
18528
18527
|
},
|
|
18529
|
-
{ docId: id, docRev:
|
|
18528
|
+
{ docId: id, docRev: rev2 }
|
|
18530
18529
|
);
|
|
18531
18530
|
}
|
|
18532
18531
|
async function getAppBackup(backupId) {
|
|
@@ -18536,11 +18535,11 @@ async function updateAppBackup(backupId, backupName) {
|
|
|
18536
18535
|
return backups_exports.updateAppBackupMetadata(backupId, backupName);
|
|
18537
18536
|
}
|
|
18538
18537
|
async function deleteAppBackup(backupId) {
|
|
18539
|
-
const
|
|
18540
|
-
if (
|
|
18538
|
+
const metadata2 = await backups_exports.getAppBackupMetadata(backupId);
|
|
18539
|
+
if (metadata2.filename) {
|
|
18541
18540
|
await objectStore_exports2.deleteFile(
|
|
18542
18541
|
objectStore_exports2.ObjectStoreBuckets.BACKUPS,
|
|
18543
|
-
|
|
18542
|
+
metadata2.filename
|
|
18544
18543
|
);
|
|
18545
18544
|
}
|
|
18546
18545
|
return backups_exports.deleteAppBackupMetadata(backupId);
|
|
@@ -18549,15 +18548,15 @@ async function fetchAppBackups2(appId, opts) {
|
|
|
18549
18548
|
return backups_exports.fetchAppBackups(appId, opts);
|
|
18550
18549
|
}
|
|
18551
18550
|
async function downloadAppBackup(backupId) {
|
|
18552
|
-
const
|
|
18553
|
-
if (!
|
|
18551
|
+
const metadata2 = await backups_exports.getAppBackupMetadata(backupId);
|
|
18552
|
+
if (!metadata2.filename) {
|
|
18554
18553
|
throw new Error("Backup incomplete - cannot download.");
|
|
18555
18554
|
}
|
|
18556
18555
|
const path5 = await objectStore_exports2.retrieveToTmp(
|
|
18557
18556
|
objectStore_exports2.ObjectStoreBuckets.BACKUPS,
|
|
18558
|
-
|
|
18557
|
+
metadata2.filename
|
|
18559
18558
|
);
|
|
18560
|
-
return { metadata, path: path5 };
|
|
18559
|
+
return { metadata: metadata2, path: path5 };
|
|
18561
18560
|
}
|
|
18562
18561
|
async function triggerAppBackup(appId, trigger3, opts = {}) {
|
|
18563
18562
|
let backup;
|
|
@@ -18596,7 +18595,7 @@ async function triggerAppBackup(appId, trigger3, opts = {}) {
|
|
|
18596
18595
|
return backup.id;
|
|
18597
18596
|
}
|
|
18598
18597
|
async function triggerAppRestore(appId, backupId, nameForBackup, createdBy) {
|
|
18599
|
-
const
|
|
18598
|
+
const metadata2 = await getAppBackup(backupId);
|
|
18600
18599
|
let restore;
|
|
18601
18600
|
try {
|
|
18602
18601
|
restore = await storeAppBackupMetadata2({
|
|
@@ -18623,7 +18622,7 @@ async function triggerAppRestore(appId, backupId, nameForBackup, createdBy) {
|
|
|
18623
18622
|
createdBy
|
|
18624
18623
|
}
|
|
18625
18624
|
});
|
|
18626
|
-
return { restoreId: restore.id, metadata };
|
|
18625
|
+
return { restoreId: restore.id, metadata: metadata2 };
|
|
18627
18626
|
}
|
|
18628
18627
|
var pkg, backup_default2;
|
|
18629
18628
|
var init_backup5 = __esm({
|
|
@@ -18736,7 +18735,7 @@ async function importProcessor(job, opts) {
|
|
|
18736
18735
|
const tenantId = tenancy.getTenantIDFromAppID(appId);
|
|
18737
18736
|
return tenancy.doInTenant(tenantId, async () => {
|
|
18738
18737
|
const devAppId = db_exports.getDevAppID(appId);
|
|
18739
|
-
const { rev } = await backup_default2.updateRestoreStatus(
|
|
18738
|
+
const { rev: rev2 } = await backup_default2.updateRestoreStatus(
|
|
18740
18739
|
data2.docId,
|
|
18741
18740
|
data2.docRev,
|
|
18742
18741
|
"started" /* STARTED */
|
|
@@ -18761,23 +18760,23 @@ async function importProcessor(job, opts) {
|
|
|
18761
18760
|
logging_exports.logAlert("App restore error", err);
|
|
18762
18761
|
status2 = "failed" /* FAILED */;
|
|
18763
18762
|
}
|
|
18764
|
-
await backup_default2.updateRestoreStatus(data2.docId,
|
|
18763
|
+
await backup_default2.updateRestoreStatus(data2.docId, rev2, status2);
|
|
18765
18764
|
});
|
|
18766
18765
|
}
|
|
18767
18766
|
async function exportProcessor(job, opts) {
|
|
18768
18767
|
const data2 = job.data;
|
|
18769
|
-
const appId = data2.appId, trigger3 = data2.export.trigger,
|
|
18768
|
+
const appId = data2.appId, trigger3 = data2.export.trigger, name2 = data2.export.name;
|
|
18770
18769
|
const tenantId = tenancy.getTenantIDFromAppID(appId);
|
|
18771
18770
|
await tenancy.doInTenant(tenantId, async () => {
|
|
18772
|
-
const { rev } = await backup_default2.updateBackupStatus(
|
|
18771
|
+
const { rev: rev2 } = await backup_default2.updateBackupStatus(
|
|
18773
18772
|
data2.docId,
|
|
18774
18773
|
data2.docRev,
|
|
18775
18774
|
"started" /* STARTED */
|
|
18776
18775
|
);
|
|
18777
18776
|
return runBackup(trigger3, tenantId, appId, {
|
|
18778
18777
|
processing: opts,
|
|
18779
|
-
doc: { id: data2.docId, rev },
|
|
18780
|
-
name
|
|
18778
|
+
doc: { id: data2.docId, rev: rev2 },
|
|
18779
|
+
name: name2
|
|
18781
18780
|
});
|
|
18782
18781
|
});
|
|
18783
18782
|
}
|
|
@@ -19125,9 +19124,9 @@ var init_groups7 = __esm({
|
|
|
19125
19124
|
ctx.body = { data: await fetch9() };
|
|
19126
19125
|
};
|
|
19127
19126
|
destroy4 = async (ctx) => {
|
|
19128
|
-
const { id, rev } = ctx.params;
|
|
19127
|
+
const { id, rev: rev2 } = ctx.params;
|
|
19129
19128
|
try {
|
|
19130
|
-
await remove2(id,
|
|
19129
|
+
await remove2(id, rev2);
|
|
19131
19130
|
ctx.body = { message: "Group deleted successfully" };
|
|
19132
19131
|
} catch (err) {
|
|
19133
19132
|
ctx.throw(err.status, err);
|
|
@@ -19173,13 +19172,13 @@ async function fetch13(ctx) {
|
|
|
19173
19172
|
};
|
|
19174
19173
|
}
|
|
19175
19174
|
async function create3(ctx) {
|
|
19176
|
-
const { name, production, development } = ctx.request.body;
|
|
19177
|
-
await environmentVariables_exports2.update(
|
|
19175
|
+
const { name: name2, production, development } = ctx.request.body;
|
|
19176
|
+
await environmentVariables_exports2.update(name2, { production, development });
|
|
19178
19177
|
const environments = ["production" /* PRODUCTION */];
|
|
19179
19178
|
if (production !== development) {
|
|
19180
19179
|
environments.push("development" /* DEVELOPMENT */);
|
|
19181
19180
|
}
|
|
19182
|
-
await events_exports.environmentVariable.created(
|
|
19181
|
+
await events_exports.environmentVariable.created(name2, environments);
|
|
19183
19182
|
ctx.status = 200;
|
|
19184
19183
|
}
|
|
19185
19184
|
async function update4(ctx) {
|
|
@@ -19469,8 +19468,8 @@ async function downloadBackup(ctx) {
|
|
|
19469
19468
|
const appId = ctx.params.appId;
|
|
19470
19469
|
await checkAppID(ctx, appId);
|
|
19471
19470
|
const backupId = ctx.params.backupId;
|
|
19472
|
-
const { metadata, path: path5 } = await backups_default.downloadAppBackup(backupId);
|
|
19473
|
-
ctx.attachment(`backup-${
|
|
19471
|
+
const { metadata: metadata2, path: path5 } = await backups_default.downloadAppBackup(backupId);
|
|
19472
|
+
ctx.attachment(`backup-${metadata2.timestamp}.tar.gz`);
|
|
19474
19473
|
ctx.body = import_fs13.default.createReadStream(path5);
|
|
19475
19474
|
}
|
|
19476
19475
|
var import_fs13;
|
|
@@ -19612,8 +19611,8 @@ var init_schedules2 = __esm({
|
|
|
19612
19611
|
});
|
|
19613
19612
|
|
|
19614
19613
|
// ../pro/packages/pro/src/api/controllers/global/scim/users.ts
|
|
19615
|
-
function tryGetQueryAsNumber(ctx,
|
|
19616
|
-
const value = ctx.request.query[
|
|
19614
|
+
function tryGetQueryAsNumber(ctx, name2) {
|
|
19615
|
+
const value = ctx.request.query[name2];
|
|
19617
19616
|
if (value === void 0) {
|
|
19618
19617
|
return void 0;
|
|
19619
19618
|
}
|
|
@@ -20005,11 +20004,11 @@ var init_filters = __esm({
|
|
|
20005
20004
|
return docs;
|
|
20006
20005
|
}
|
|
20007
20006
|
query3 = cleanupQuery(query3);
|
|
20008
|
-
const match = (type, failFn) => (
|
|
20007
|
+
const match = (type, failFn) => (doc2) => {
|
|
20009
20008
|
const filters = Object.entries(query3[type] || {});
|
|
20010
20009
|
for (let i = 0; i < filters.length; i++) {
|
|
20011
20010
|
const [key, testValue] = filters[i];
|
|
20012
|
-
const docValue = deepGet(
|
|
20011
|
+
const docValue = deepGet(doc2, removeKeyNumbering2(key));
|
|
20013
20012
|
if (failFn(docValue, testValue)) {
|
|
20014
20013
|
return false;
|
|
20015
20014
|
}
|
|
@@ -20070,8 +20069,8 @@ var init_filters = __esm({
|
|
|
20070
20069
|
return testValue == null ? void 0 : testValue.every((item) => docValue == null ? void 0 : docValue.includes(item));
|
|
20071
20070
|
}
|
|
20072
20071
|
);
|
|
20073
|
-
const docMatch = (
|
|
20074
|
-
return stringMatch(
|
|
20072
|
+
const docMatch = (doc2) => {
|
|
20073
|
+
return stringMatch(doc2) && fuzzyMatch(doc2) && rangeMatch(doc2) && equalMatch(doc2) && notEqualMatch(doc2) && emptyMatch(doc2) && notEmptyMatch(doc2) && oneOf(doc2) && contains(doc2) && containsAny(doc2) && notContains(doc2);
|
|
20075
20074
|
};
|
|
20076
20075
|
return docs.filter(docMatch);
|
|
20077
20076
|
};
|
|
@@ -20758,20 +20757,20 @@ async function createLinkView() {
|
|
|
20758
20757
|
const db2 = context_exports.getAppDB();
|
|
20759
20758
|
const designDoc = await db2.get("_design/database");
|
|
20760
20759
|
const view2 = {
|
|
20761
|
-
map: function(
|
|
20762
|
-
if (
|
|
20763
|
-
let doc1 =
|
|
20764
|
-
let
|
|
20760
|
+
map: function(doc2) {
|
|
20761
|
+
if (doc2.type === "link") {
|
|
20762
|
+
let doc1 = doc2.doc1;
|
|
20763
|
+
let doc22 = doc2.doc2;
|
|
20765
20764
|
emit([doc1.tableId, doc1.rowId], {
|
|
20766
|
-
id:
|
|
20765
|
+
id: doc22.rowId,
|
|
20767
20766
|
thisId: doc1.rowId,
|
|
20768
20767
|
fieldName: doc1.fieldName
|
|
20769
20768
|
});
|
|
20770
|
-
if (doc1.tableId !==
|
|
20771
|
-
emit([
|
|
20769
|
+
if (doc1.tableId !== doc22.tableId) {
|
|
20770
|
+
emit([doc22.tableId, doc22.rowId], {
|
|
20772
20771
|
id: doc1.rowId,
|
|
20773
|
-
thisId:
|
|
20774
|
-
fieldName:
|
|
20772
|
+
thisId: doc22.rowId,
|
|
20773
|
+
fieldName: doc22.fieldName
|
|
20775
20774
|
});
|
|
20776
20775
|
}
|
|
20777
20776
|
}
|
|
@@ -20817,7 +20816,7 @@ async function searchIndex(indexName, fnString) {
|
|
|
20817
20816
|
async function createAllSearchIndex() {
|
|
20818
20817
|
await searchIndex(
|
|
20819
20818
|
"rows" /* ROWS */,
|
|
20820
|
-
function(
|
|
20819
|
+
function(doc2) {
|
|
20821
20820
|
function idx(input, prev) {
|
|
20822
20821
|
for (let key of Object.keys(input)) {
|
|
20823
20822
|
let idxKey = prev != null ? `${prev}.${key}` : key;
|
|
@@ -20840,9 +20839,9 @@ async function createAllSearchIndex() {
|
|
|
20840
20839
|
}
|
|
20841
20840
|
}
|
|
20842
20841
|
}
|
|
20843
|
-
if (
|
|
20844
|
-
index("default",
|
|
20845
|
-
idx(
|
|
20842
|
+
if (doc2._id.startsWith("ro_")) {
|
|
20843
|
+
index("default", doc2._id);
|
|
20844
|
+
idx(doc2);
|
|
20846
20845
|
}
|
|
20847
20846
|
}.toString()
|
|
20848
20847
|
);
|
|
@@ -21163,11 +21162,11 @@ var init_LinkController = __esm({
|
|
|
21163
21162
|
);
|
|
21164
21163
|
}
|
|
21165
21164
|
}
|
|
21166
|
-
let toDeleteDocs = thisFieldLinkDocs.filter((
|
|
21167
|
-
let correctDoc =
|
|
21165
|
+
let toDeleteDocs = thisFieldLinkDocs.filter((doc2) => {
|
|
21166
|
+
let correctDoc = doc2.doc1.fieldName === fieldName ? doc2.doc2 : doc2.doc1;
|
|
21168
21167
|
return rowField.indexOf(correctDoc.rowId) === -1;
|
|
21169
|
-
}).map((
|
|
21170
|
-
return { ...
|
|
21168
|
+
}).map((doc2) => {
|
|
21169
|
+
return { ...doc2, _deleted: true };
|
|
21171
21170
|
});
|
|
21172
21171
|
operations.push(...toDeleteDocs);
|
|
21173
21172
|
delete row2[fieldName];
|
|
@@ -21188,9 +21187,9 @@ var init_LinkController = __esm({
|
|
|
21188
21187
|
if (linkDocs.length === 0) {
|
|
21189
21188
|
return null;
|
|
21190
21189
|
}
|
|
21191
|
-
const toDelete = linkDocs.map((
|
|
21190
|
+
const toDelete = linkDocs.map((doc2) => {
|
|
21192
21191
|
return {
|
|
21193
|
-
...
|
|
21192
|
+
...doc2,
|
|
21194
21193
|
_deleted: true
|
|
21195
21194
|
};
|
|
21196
21195
|
});
|
|
@@ -21211,9 +21210,9 @@ var init_LinkController = __esm({
|
|
|
21211
21210
|
return correctFieldName === fieldName;
|
|
21212
21211
|
});
|
|
21213
21212
|
await this._db.bulkDocs(
|
|
21214
|
-
toDelete.map((
|
|
21213
|
+
toDelete.map((doc2) => {
|
|
21215
21214
|
return {
|
|
21216
|
-
...
|
|
21215
|
+
...doc2,
|
|
21217
21216
|
_deleted: true
|
|
21218
21217
|
};
|
|
21219
21218
|
})
|
|
@@ -21311,9 +21310,9 @@ var init_LinkController = __esm({
|
|
|
21311
21310
|
if (linkDocs.length === 0) {
|
|
21312
21311
|
return null;
|
|
21313
21312
|
}
|
|
21314
|
-
const toDelete = linkDocs.map((
|
|
21313
|
+
const toDelete = linkDocs.map((doc2) => {
|
|
21315
21314
|
return {
|
|
21316
|
-
...
|
|
21315
|
+
...doc2,
|
|
21317
21316
|
_deleted: true
|
|
21318
21317
|
};
|
|
21319
21318
|
});
|
|
@@ -21797,10 +21796,10 @@ async function cleanupAttachments(table2, {
|
|
|
21797
21796
|
return;
|
|
21798
21797
|
}
|
|
21799
21798
|
}
|
|
21800
|
-
let
|
|
21799
|
+
let files2 = [];
|
|
21801
21800
|
function addFiles(row3, key) {
|
|
21802
21801
|
if (row3[key]) {
|
|
21803
|
-
|
|
21802
|
+
files2 = files2.concat(row3[key].map((attachment) => attachment.key));
|
|
21804
21803
|
}
|
|
21805
21804
|
}
|
|
21806
21805
|
const schemaToUse = oldTable ? oldTable.schema : table2.schema;
|
|
@@ -21811,15 +21810,15 @@ async function cleanupAttachments(table2, {
|
|
|
21811
21810
|
if (rows2 && oldTable && !table2.schema[key]) {
|
|
21812
21811
|
rows2.forEach((row3) => addFiles(row3, key));
|
|
21813
21812
|
} else if (oldRow && row2) {
|
|
21814
|
-
|
|
21813
|
+
files2 = files2.concat(getRemovedAttachmentKeys(oldRow, row2, key));
|
|
21815
21814
|
} else if (row2) {
|
|
21816
21815
|
addFiles(row2, key);
|
|
21817
21816
|
} else if (rows2) {
|
|
21818
21817
|
rows2.forEach((row3) => addFiles(row3, key));
|
|
21819
21818
|
}
|
|
21820
21819
|
}
|
|
21821
|
-
if (
|
|
21822
|
-
await objectStore_exports2.deleteFiles(ObjectStoreBuckets2.APPS,
|
|
21820
|
+
if (files2.length > 0) {
|
|
21821
|
+
await objectStore_exports2.deleteFiles(ObjectStoreBuckets2.APPS, files2);
|
|
21823
21822
|
}
|
|
21824
21823
|
}
|
|
21825
21824
|
var cloneDeep3, BASE_AUTO_ID;
|
|
@@ -21841,17 +21840,17 @@ var init_rowProcessor = __esm({
|
|
|
21841
21840
|
// src/utilities/users.ts
|
|
21842
21841
|
async function getFullUser(ctx, userId) {
|
|
21843
21842
|
const global = await getGlobalUser(userId);
|
|
21844
|
-
let
|
|
21843
|
+
let metadata2 = {};
|
|
21845
21844
|
delete global._id;
|
|
21846
21845
|
delete global._rev;
|
|
21847
21846
|
try {
|
|
21848
21847
|
const db2 = context_exports.getAppDB();
|
|
21849
|
-
|
|
21848
|
+
metadata2 = await db2.get(userId);
|
|
21850
21849
|
} catch (err) {
|
|
21851
21850
|
}
|
|
21852
|
-
delete
|
|
21851
|
+
delete metadata2.csrfToken;
|
|
21853
21852
|
return {
|
|
21854
|
-
...
|
|
21853
|
+
...metadata2,
|
|
21855
21854
|
...global,
|
|
21856
21855
|
roleId: global.roleId || roles_exports.BUILTIN_ROLE_IDS.PUBLIC,
|
|
21857
21856
|
tableId: InternalTables.USER_METADATA,
|
|
@@ -21911,11 +21910,11 @@ async function fetchSelf(ctx) {
|
|
|
21911
21910
|
if (user2.roleId === PUBLIC_ROLE) {
|
|
21912
21911
|
response2 = {};
|
|
21913
21912
|
} else if (err.status === 404) {
|
|
21914
|
-
const
|
|
21913
|
+
const metadata2 = {
|
|
21915
21914
|
...user2,
|
|
21916
21915
|
_id: userId
|
|
21917
21916
|
};
|
|
21918
|
-
const dbResp = await db2.put(
|
|
21917
|
+
const dbResp = await db2.put(metadata2);
|
|
21919
21918
|
user2._rev = dbResp.rev;
|
|
21920
21919
|
response2 = user2;
|
|
21921
21920
|
} else {
|
|
@@ -22071,12 +22070,12 @@ async function updateAppUpdatedAt(ctx) {
|
|
|
22071
22070
|
await db_exports.doWithDB(appId, async (db2) => {
|
|
22072
22071
|
var _a2;
|
|
22073
22072
|
try {
|
|
22074
|
-
const
|
|
22075
|
-
|
|
22076
|
-
|
|
22077
|
-
const response2 = await db2.put(
|
|
22078
|
-
|
|
22079
|
-
await cache_exports.app.invalidateAppMetadata(appId,
|
|
22073
|
+
const metadata2 = await db2.get(DocumentType2.APP_METADATA);
|
|
22074
|
+
metadata2.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
22075
|
+
metadata2.updatedBy = getGlobalIDFromUserMetadataID2((_a2 = ctx.user) == null ? void 0 : _a2.userId);
|
|
22076
|
+
const response2 = await db2.put(metadata2);
|
|
22077
|
+
metadata2._rev = response2.rev;
|
|
22078
|
+
await cache_exports.app.invalidateAppMetadata(appId, metadata2);
|
|
22080
22079
|
await setDebounce(appId, DEBOUNCE_TIME_SEC);
|
|
22081
22080
|
} catch (err) {
|
|
22082
22081
|
if ((err == null ? void 0 : err.status) === 409) {
|
|
@@ -22669,14 +22668,14 @@ async function getViews() {
|
|
|
22669
22668
|
const response2 = [];
|
|
22670
22669
|
if (environment_default2.SELF_HOSTED) {
|
|
22671
22670
|
const designDoc = await db2.get("_design/database");
|
|
22672
|
-
for (let
|
|
22671
|
+
for (let name2 of Object.keys(designDoc.views)) {
|
|
22673
22672
|
const viewNames = Object.values(ViewName3);
|
|
22674
|
-
if (viewNames.indexOf(
|
|
22673
|
+
if (viewNames.indexOf(name2) !== -1) {
|
|
22675
22674
|
continue;
|
|
22676
22675
|
}
|
|
22677
22676
|
response2.push({
|
|
22678
|
-
name,
|
|
22679
|
-
...designDoc.views[
|
|
22677
|
+
name: name2,
|
|
22678
|
+
...designDoc.views[name2]
|
|
22680
22679
|
});
|
|
22681
22680
|
}
|
|
22682
22681
|
} else {
|
|
@@ -22793,9 +22792,9 @@ async function clearColumns(table2, columnNames) {
|
|
|
22793
22792
|
})
|
|
22794
22793
|
);
|
|
22795
22794
|
return await db2.bulkDocs(
|
|
22796
|
-
rows2.rows.map(({ doc }) => {
|
|
22797
|
-
columnNames.forEach((colName) => delete
|
|
22798
|
-
return
|
|
22795
|
+
rows2.rows.map(({ doc: doc2 }) => {
|
|
22796
|
+
columnNames.forEach((colName) => delete doc2[colName]);
|
|
22797
|
+
return doc2;
|
|
22799
22798
|
})
|
|
22800
22799
|
);
|
|
22801
22800
|
}
|
|
@@ -22815,7 +22814,7 @@ async function checkForColumnUpdates(oldTable, updatedTable) {
|
|
|
22815
22814
|
include_docs: true
|
|
22816
22815
|
})
|
|
22817
22816
|
);
|
|
22818
|
-
const rawRows = rows2.rows.map(({ doc }) =>
|
|
22817
|
+
const rawRows = rows2.rows.map(({ doc: doc2 }) => doc2);
|
|
22819
22818
|
updatedRows = rawRows.map((row2) => {
|
|
22820
22819
|
row2 = (0, import_fp.cloneDeep)(row2);
|
|
22821
22820
|
if (rename) {
|
|
@@ -22885,18 +22884,18 @@ async function handleDataImport(user2, table2, rows2, identifierFields = []) {
|
|
|
22885
22884
|
include_docs: true
|
|
22886
22885
|
})
|
|
22887
22886
|
);
|
|
22888
|
-
allDocs.rows.map((existingRow) => existingRow.doc).forEach((
|
|
22887
|
+
allDocs.rows.map((existingRow) => existingRow.doc).forEach((doc2) => {
|
|
22889
22888
|
finalData.forEach((finalItem) => {
|
|
22890
22889
|
let match = true;
|
|
22891
22890
|
for (const field of identifierFields) {
|
|
22892
|
-
if (finalItem[field] !==
|
|
22891
|
+
if (finalItem[field] !== doc2[field]) {
|
|
22893
22892
|
match = false;
|
|
22894
22893
|
break;
|
|
22895
22894
|
}
|
|
22896
22895
|
}
|
|
22897
22896
|
if (match) {
|
|
22898
|
-
finalItem._id =
|
|
22899
|
-
finalItem._rev =
|
|
22897
|
+
finalItem._id = doc2._id;
|
|
22898
|
+
finalItem._rev = doc2._rev;
|
|
22900
22899
|
}
|
|
22901
22900
|
});
|
|
22902
22901
|
});
|
|
@@ -24327,44 +24326,44 @@ function checkSlashesInUrl2(url) {
|
|
|
24327
24326
|
async function updateEntityMetadata(type, entityId, updateFn) {
|
|
24328
24327
|
const db2 = context_exports.getAppDB();
|
|
24329
24328
|
const id = generateMetadataID(type, entityId);
|
|
24330
|
-
let
|
|
24329
|
+
let rev2, metadata2;
|
|
24331
24330
|
try {
|
|
24332
24331
|
const oldMetadata = await db2.get(id);
|
|
24333
|
-
|
|
24334
|
-
|
|
24332
|
+
rev2 = oldMetadata._rev;
|
|
24333
|
+
metadata2 = updateFn(oldMetadata);
|
|
24335
24334
|
} catch (err) {
|
|
24336
|
-
|
|
24337
|
-
|
|
24335
|
+
rev2 = null;
|
|
24336
|
+
metadata2 = updateFn({});
|
|
24338
24337
|
}
|
|
24339
|
-
|
|
24340
|
-
if (
|
|
24341
|
-
|
|
24338
|
+
metadata2._id = id;
|
|
24339
|
+
if (rev2) {
|
|
24340
|
+
metadata2._rev = rev2;
|
|
24342
24341
|
}
|
|
24343
|
-
const response2 = await db2.put(
|
|
24342
|
+
const response2 = await db2.put(metadata2);
|
|
24344
24343
|
return {
|
|
24345
|
-
...
|
|
24344
|
+
...metadata2,
|
|
24346
24345
|
_id: id,
|
|
24347
24346
|
_rev: response2.rev
|
|
24348
24347
|
};
|
|
24349
24348
|
}
|
|
24350
|
-
async function saveEntityMetadata(type, entityId,
|
|
24349
|
+
async function saveEntityMetadata(type, entityId, metadata2) {
|
|
24351
24350
|
return updateEntityMetadata(type, entityId, () => {
|
|
24352
|
-
return
|
|
24351
|
+
return metadata2;
|
|
24353
24352
|
});
|
|
24354
24353
|
}
|
|
24355
24354
|
async function deleteEntityMetadata(type, entityId) {
|
|
24356
24355
|
const db2 = context_exports.getAppDB();
|
|
24357
24356
|
const id = generateMetadataID(type, entityId);
|
|
24358
|
-
let
|
|
24357
|
+
let rev2;
|
|
24359
24358
|
try {
|
|
24360
|
-
const
|
|
24361
|
-
if (
|
|
24362
|
-
|
|
24359
|
+
const metadata2 = await db2.get(id);
|
|
24360
|
+
if (metadata2) {
|
|
24361
|
+
rev2 = metadata2._rev;
|
|
24363
24362
|
}
|
|
24364
24363
|
} catch (err) {
|
|
24365
24364
|
}
|
|
24366
|
-
if (id &&
|
|
24367
|
-
await db2.remove(id,
|
|
24365
|
+
if (id && rev2) {
|
|
24366
|
+
await db2.remove(id, rev2);
|
|
24368
24367
|
}
|
|
24369
24368
|
}
|
|
24370
24369
|
function escapeDangerousCharacters(string) {
|
|
@@ -25038,7 +25037,7 @@ __export(exports_exports, {
|
|
|
25038
25037
|
exportDB: () => exportDB,
|
|
25039
25038
|
streamExportApp: () => streamExportApp
|
|
25040
25039
|
});
|
|
25041
|
-
function tarFilesToTmp(tmpDir,
|
|
25040
|
+
function tarFilesToTmp(tmpDir, files2) {
|
|
25042
25041
|
const fileName = `${uuid3()}.tar.gz`;
|
|
25043
25042
|
const exportFile = (0, import_path13.join)(budibaseTempDir2(), fileName);
|
|
25044
25043
|
import_tar2.default.create(
|
|
@@ -25049,7 +25048,7 @@ function tarFilesToTmp(tmpDir, files) {
|
|
|
25049
25048
|
noDirRecurse: false,
|
|
25050
25049
|
cwd: tmpDir
|
|
25051
25050
|
},
|
|
25052
|
-
|
|
25051
|
+
files2
|
|
25053
25052
|
);
|
|
25054
25053
|
return exportFile;
|
|
25055
25054
|
}
|
|
@@ -25085,7 +25084,7 @@ function defineFilter(excludeRows, excludeLogs) {
|
|
|
25085
25084
|
if (excludeLogs) {
|
|
25086
25085
|
ids.push(AUTOMATION_LOG_PREFIX);
|
|
25087
25086
|
}
|
|
25088
|
-
return (
|
|
25087
|
+
return (doc2) => !ids.map((key) => doc2._id.includes(key)).reduce((prev, curr) => prev || curr);
|
|
25089
25088
|
}
|
|
25090
25089
|
async function exportApp(appId, config) {
|
|
25091
25090
|
const prodAppId = db_exports.getProdAppID(appId);
|
|
@@ -25244,9 +25243,9 @@ async function getTemplateStream(template) {
|
|
|
25244
25243
|
if (template.file) {
|
|
25245
25244
|
return import_fs15.default.createReadStream(template.file.path);
|
|
25246
25245
|
} else if (template.key) {
|
|
25247
|
-
const [type,
|
|
25248
|
-
const tmpPath = await downloadTemplate(type,
|
|
25249
|
-
return import_fs15.default.createReadStream((0, import_path14.join)(tmpPath,
|
|
25246
|
+
const [type, name2] = template.key.split("/");
|
|
25247
|
+
const tmpPath = await downloadTemplate(type, name2);
|
|
25248
|
+
return import_fs15.default.createReadStream((0, import_path14.join)(tmpPath, name2, "db", "dump.txt"));
|
|
25250
25249
|
}
|
|
25251
25250
|
}
|
|
25252
25251
|
function untarFile(file) {
|
|
@@ -25577,18 +25576,18 @@ function finaliseExternalTables(tables, entities) {
|
|
|
25577
25576
|
let finalTables = {};
|
|
25578
25577
|
const errors = {};
|
|
25579
25578
|
const tableIds = Object.values(tables).map((table2) => table2._id);
|
|
25580
|
-
for (let [
|
|
25579
|
+
for (let [name2, table2] of Object.entries(tables)) {
|
|
25581
25580
|
const schemaFields = Object.keys(table2.schema);
|
|
25582
25581
|
if (table2.primary == null || table2.primary.length === 0) {
|
|
25583
|
-
errors[
|
|
25582
|
+
errors[name2] = "no_key" /* NO_KEY */;
|
|
25584
25583
|
continue;
|
|
25585
25584
|
} else if (schemaFields.find(
|
|
25586
25585
|
(field) => invalidColumns.includes(field)
|
|
25587
25586
|
)) {
|
|
25588
|
-
errors[
|
|
25587
|
+
errors[name2] = "invalid_column" /* INVALID_COLUMN */;
|
|
25589
25588
|
continue;
|
|
25590
25589
|
}
|
|
25591
|
-
finalTables[
|
|
25590
|
+
finalTables[name2] = copyExistingPropsOver(name2, table2, entities, tableIds);
|
|
25592
25591
|
}
|
|
25593
25592
|
finalTables = Object.entries(finalTables).sort(([a], [b]) => a.localeCompare(b)).reduce((r, [k, v]) => ({ ...r, [k]: v }), {});
|
|
25594
25593
|
return { tables: finalTables, errors };
|
|
@@ -27486,21 +27485,21 @@ var init_mongodb = __esm({
|
|
|
27486
27485
|
const collection = db2.collection(query3.extra.collection);
|
|
27487
27486
|
let response2 = [];
|
|
27488
27487
|
if (((_a2 = query3.extra) == null ? void 0 : _a2.actionType) === "pipeline") {
|
|
27489
|
-
for await (const
|
|
27488
|
+
for await (const doc2 of collection.aggregate(
|
|
27490
27489
|
query3.steps.map(({ key, value }) => {
|
|
27491
27490
|
let temp = {};
|
|
27492
27491
|
temp[key] = JSON.parse(value.value);
|
|
27493
27492
|
return this.createObjectIds(temp);
|
|
27494
27493
|
})
|
|
27495
27494
|
)) {
|
|
27496
|
-
response2.push(
|
|
27495
|
+
response2.push(doc2);
|
|
27497
27496
|
}
|
|
27498
27497
|
} else {
|
|
27499
27498
|
const stages = query3.json;
|
|
27500
|
-
for await (const
|
|
27499
|
+
for await (const doc2 of collection.aggregate(
|
|
27501
27500
|
stages ? this.createObjectIds(stages) : []
|
|
27502
27501
|
)) {
|
|
27503
|
-
response2.push(
|
|
27502
|
+
response2.push(doc2);
|
|
27504
27503
|
}
|
|
27505
27504
|
}
|
|
27506
27505
|
return response2;
|
|
@@ -27811,9 +27810,9 @@ var init_couchdb = __esm({
|
|
|
27811
27810
|
});
|
|
27812
27811
|
}
|
|
27813
27812
|
async delete(query3) {
|
|
27814
|
-
const
|
|
27813
|
+
const doc2 = await this.query("get", "Cannot find doc to be deleted", query3);
|
|
27815
27814
|
return this.query("remove", "Error deleting couchDB document", {
|
|
27816
|
-
json:
|
|
27815
|
+
json: doc2
|
|
27817
27816
|
});
|
|
27818
27817
|
}
|
|
27819
27818
|
};
|
|
@@ -27999,7 +27998,7 @@ var init_microsoftSqlServer = __esm({
|
|
|
27999
27998
|
throw "Unable to get list of tables in database";
|
|
28000
27999
|
}
|
|
28001
28000
|
const schema = this.config.schema || DEFAULT_SCHEMA;
|
|
28002
|
-
const tableNames = tableInfo.filter((record) => record.TABLE_SCHEMA === schema).map((record) => record.TABLE_NAME).filter((
|
|
28001
|
+
const tableNames = tableInfo.filter((record) => record.TABLE_SCHEMA === schema).map((record) => record.TABLE_NAME).filter((name2) => this.MASTER_TABLES.indexOf(name2) === -1);
|
|
28003
28002
|
const tables = {};
|
|
28004
28003
|
for (let tableName of tableNames) {
|
|
28005
28004
|
const definition26 = await this.runSQL(this.getDefinitionSQL(tableName));
|
|
@@ -28014,16 +28013,16 @@ var init_microsoftSqlServer = __esm({
|
|
|
28014
28013
|
const requiredColumns = columns.filter((col) => col.IS_NULLABLE === "NO").map((col) => col.COLUMN_NAME);
|
|
28015
28014
|
let schema2 = {};
|
|
28016
28015
|
for (let def of definition26) {
|
|
28017
|
-
const
|
|
28018
|
-
if (typeof
|
|
28016
|
+
const name2 = def.COLUMN_NAME;
|
|
28017
|
+
if (typeof name2 !== "string") {
|
|
28019
28018
|
continue;
|
|
28020
28019
|
}
|
|
28021
28020
|
const hasDefault = def.COLUMN_DEFAULT;
|
|
28022
|
-
const isAuto = !!autoColumns.find((col) => col ===
|
|
28023
|
-
const required = !!requiredColumns.find((col) => col ===
|
|
28024
|
-
schema2[
|
|
28021
|
+
const isAuto = !!autoColumns.find((col) => col === name2);
|
|
28022
|
+
const required = !!requiredColumns.find((col) => col === name2);
|
|
28023
|
+
schema2[name2] = {
|
|
28025
28024
|
autocolumn: isAuto,
|
|
28026
|
-
name,
|
|
28025
|
+
name: name2,
|
|
28027
28026
|
constraints: {
|
|
28028
28027
|
presence: required && !isAuto && !hasDefault
|
|
28029
28028
|
},
|
|
@@ -28045,7 +28044,7 @@ var init_microsoftSqlServer = __esm({
|
|
|
28045
28044
|
async queryTableNames() {
|
|
28046
28045
|
let tableInfo = await this.runSQL(this.TABLES_SQL);
|
|
28047
28046
|
const schema = this.config.schema || DEFAULT_SCHEMA;
|
|
28048
|
-
return tableInfo.filter((record) => record.TABLE_SCHEMA === schema).map((record) => record.TABLE_NAME).filter((
|
|
28047
|
+
return tableInfo.filter((record) => record.TABLE_SCHEMA === schema).map((record) => record.TABLE_NAME).filter((name2) => this.MASTER_TABLES.indexOf(name2) === -1);
|
|
28049
28048
|
}
|
|
28050
28049
|
async getTableNames() {
|
|
28051
28050
|
await this.connect();
|
|
@@ -29474,13 +29473,13 @@ var init_googlesheets = __esm({
|
|
|
29474
29473
|
}
|
|
29475
29474
|
return rowObject;
|
|
29476
29475
|
}
|
|
29477
|
-
async createTable(
|
|
29478
|
-
if (!
|
|
29476
|
+
async createTable(name2) {
|
|
29477
|
+
if (!name2) {
|
|
29479
29478
|
throw new Error("Must provide name for new sheet.");
|
|
29480
29479
|
}
|
|
29481
29480
|
try {
|
|
29482
29481
|
await this.connect();
|
|
29483
|
-
return await this.client.addSheet({ title:
|
|
29482
|
+
return await this.client.addSheet({ title: name2, headerValues: [name2] });
|
|
29484
29483
|
} catch (err) {
|
|
29485
29484
|
console.error("Error creating new table in google sheets", err);
|
|
29486
29485
|
throw err;
|
|
@@ -29806,7 +29805,7 @@ var init_firebase = __esm({
|
|
|
29806
29805
|
snapshot = await collectionRef.get();
|
|
29807
29806
|
}
|
|
29808
29807
|
const result = [];
|
|
29809
|
-
snapshot.forEach((
|
|
29808
|
+
snapshot.forEach((doc2) => result.push(doc2.data()));
|
|
29810
29809
|
return result;
|
|
29811
29810
|
} catch (err) {
|
|
29812
29811
|
console.error("Error querying Firestore", err);
|
|
@@ -30468,13 +30467,13 @@ var init_oracle = __esm({
|
|
|
30468
30467
|
});
|
|
30469
30468
|
|
|
30470
30469
|
// src/integrations/index.ts
|
|
30471
|
-
async function getDefinition(
|
|
30472
|
-
const definition26 = DEFINITIONS2[
|
|
30470
|
+
async function getDefinition(source2) {
|
|
30471
|
+
const definition26 = DEFINITIONS2[source2];
|
|
30473
30472
|
if (definition26) {
|
|
30474
30473
|
return definition26;
|
|
30475
30474
|
}
|
|
30476
30475
|
const allDefinitions = await getDefinitions();
|
|
30477
|
-
return allDefinitions[
|
|
30476
|
+
return allDefinitions[source2];
|
|
30478
30477
|
}
|
|
30479
30478
|
async function getDefinitions() {
|
|
30480
30479
|
const pluginSchemas = {};
|
|
@@ -30810,10 +30809,10 @@ __export(webhook_exports2, {
|
|
|
30810
30809
|
function isWebhookID(id) {
|
|
30811
30810
|
return id.startsWith(db_exports.DocumentType.WEBHOOK);
|
|
30812
30811
|
}
|
|
30813
|
-
function newDoc(
|
|
30812
|
+
function newDoc(name2, type, target) {
|
|
30814
30813
|
return {
|
|
30815
30814
|
live: true,
|
|
30816
|
-
name,
|
|
30815
|
+
name: name2,
|
|
30817
30816
|
action: {
|
|
30818
30817
|
type,
|
|
30819
30818
|
target
|
|
@@ -30831,12 +30830,12 @@ async function save8(webhook) {
|
|
|
30831
30830
|
webhook._rev = response2.rev;
|
|
30832
30831
|
return webhook;
|
|
30833
30832
|
}
|
|
30834
|
-
async function destroy7(id,
|
|
30833
|
+
async function destroy7(id, rev2) {
|
|
30835
30834
|
const db2 = context_exports.getAppDB();
|
|
30836
30835
|
if (!id || !isWebhookID(id)) {
|
|
30837
30836
|
throw new Error("Provided webhook ID is not valid.");
|
|
30838
30837
|
}
|
|
30839
|
-
return await db2.remove(id,
|
|
30838
|
+
return await db2.remove(id, rev2);
|
|
30840
30839
|
}
|
|
30841
30840
|
var init_webhook3 = __esm({
|
|
30842
30841
|
"src/sdk/app/automations/webhook.ts"() {
|
|
@@ -30900,9 +30899,9 @@ async function syncUsersToApp(appId, users2, groups) {
|
|
|
30900
30899
|
if (roleId === roles_exports.BUILTIN_ROLE_IDS.PUBLIC) {
|
|
30901
30900
|
roleId = void 0;
|
|
30902
30901
|
}
|
|
30903
|
-
let
|
|
30902
|
+
let metadata2;
|
|
30904
30903
|
try {
|
|
30905
|
-
|
|
30904
|
+
metadata2 = await db2.get(metadataId);
|
|
30906
30905
|
} catch (err) {
|
|
30907
30906
|
if (err.status !== 404) {
|
|
30908
30907
|
throw err;
|
|
@@ -30910,19 +30909,19 @@ async function syncUsersToApp(appId, users2, groups) {
|
|
|
30910
30909
|
if (!roleId) {
|
|
30911
30910
|
continue;
|
|
30912
30911
|
} else if (!deletedUser) {
|
|
30913
|
-
|
|
30912
|
+
metadata2 = {
|
|
30914
30913
|
tableId: InternalTables.USER_METADATA
|
|
30915
30914
|
};
|
|
30916
30915
|
}
|
|
30917
30916
|
}
|
|
30918
30917
|
if (deletedUser || !roleId) {
|
|
30919
|
-
await db2.remove(
|
|
30918
|
+
await db2.remove(metadata2);
|
|
30920
30919
|
continue;
|
|
30921
30920
|
}
|
|
30922
30921
|
if (roleId) {
|
|
30923
|
-
|
|
30922
|
+
metadata2.roleId = roleId;
|
|
30924
30923
|
}
|
|
30925
|
-
let combined = sdk_default.users.combineMetadataAndUser(ctxUser,
|
|
30924
|
+
let combined = sdk_default.users.combineMetadataAndUser(ctxUser, metadata2);
|
|
30926
30925
|
if (combined) {
|
|
30927
30926
|
await db2.put(combined);
|
|
30928
30927
|
}
|
|
@@ -30979,7 +30978,7 @@ async function syncApp(appId, opts) {
|
|
|
30979
30978
|
try {
|
|
30980
30979
|
const replOpts = replication.appReplicateOpts();
|
|
30981
30980
|
if (opts == null ? void 0 : opts.automationOnly) {
|
|
30982
|
-
replOpts.filter = (
|
|
30981
|
+
replOpts.filter = (doc2) => doc2._id.startsWith(db_exports.DocumentType.AUTOMATION);
|
|
30983
30982
|
}
|
|
30984
30983
|
await replication.replicate(replOpts);
|
|
30985
30984
|
} catch (err) {
|
|
@@ -31206,9 +31205,9 @@ __export(utils_exports8, {
|
|
|
31206
31205
|
rawUserMetadata: () => rawUserMetadata,
|
|
31207
31206
|
syncGlobalUsers: () => syncGlobalUsers
|
|
31208
31207
|
});
|
|
31209
|
-
function combineMetadataAndUser(user2,
|
|
31208
|
+
function combineMetadataAndUser(user2, metadata2) {
|
|
31210
31209
|
const metadataId = generateUserMetadataID2(user2._id);
|
|
31211
|
-
const found = Array.isArray(
|
|
31210
|
+
const found = Array.isArray(metadata2) ? metadata2.find((doc2) => doc2._id === metadataId) : metadata2;
|
|
31212
31211
|
if (user2.roleId == null || user2.roleId === roles_exports.BUILTIN_ROLE_IDS.PUBLIC) {
|
|
31213
31212
|
if (found == null ? void 0 : found._id) {
|
|
31214
31213
|
return { ...found, _deleted: true };
|
|
@@ -31253,16 +31252,16 @@ async function syncGlobalUsers() {
|
|
|
31253
31252
|
}
|
|
31254
31253
|
const resp = await Promise.all([getGlobalUsers(), rawUserMetadata(db2)]);
|
|
31255
31254
|
const users2 = resp[0];
|
|
31256
|
-
const
|
|
31255
|
+
const metadata2 = resp[1];
|
|
31257
31256
|
const toWrite = [];
|
|
31258
31257
|
for (let user2 of users2) {
|
|
31259
|
-
const combined = combineMetadataAndUser(user2,
|
|
31258
|
+
const combined = combineMetadataAndUser(user2, metadata2);
|
|
31260
31259
|
if (combined) {
|
|
31261
31260
|
toWrite.push(combined);
|
|
31262
31261
|
}
|
|
31263
31262
|
}
|
|
31264
31263
|
let foundEmails = [];
|
|
31265
|
-
for (let data2 of
|
|
31264
|
+
for (let data2 of metadata2) {
|
|
31266
31265
|
if (!data2._id) {
|
|
31267
31266
|
continue;
|
|
31268
31267
|
}
|
|
@@ -31555,10 +31554,10 @@ var init_client2 = __esm({
|
|
|
31555
31554
|
// src/api/controllers/user.ts
|
|
31556
31555
|
async function fetchMetadata(ctx) {
|
|
31557
31556
|
const global = await getGlobalUsers();
|
|
31558
|
-
const
|
|
31557
|
+
const metadata2 = await sdk_default.users.rawUserMetadata();
|
|
31559
31558
|
const users2 = [];
|
|
31560
31559
|
for (let user2 of global) {
|
|
31561
|
-
const info =
|
|
31560
|
+
const info = metadata2.find((meta) => meta._id.includes(user2._id));
|
|
31562
31561
|
users2.push({
|
|
31563
31562
|
...user2,
|
|
31564
31563
|
...info,
|
|
@@ -31580,11 +31579,11 @@ async function updateMetadata(ctx) {
|
|
|
31580
31579
|
const db2 = context_exports.getAppDB();
|
|
31581
31580
|
const user2 = ctx.request.body;
|
|
31582
31581
|
delete user2.roles;
|
|
31583
|
-
const
|
|
31582
|
+
const metadata2 = {
|
|
31584
31583
|
tableId: InternalTables.USER_METADATA,
|
|
31585
31584
|
...user2
|
|
31586
31585
|
};
|
|
31587
|
-
ctx.body = await db2.put(
|
|
31586
|
+
ctx.body = await db2.put(metadata2);
|
|
31588
31587
|
}
|
|
31589
31588
|
async function destroyMetadata(ctx) {
|
|
31590
31589
|
const db2 = context_exports.getAppDB();
|
|
@@ -31609,14 +31608,14 @@ async function setFlag(ctx) {
|
|
|
31609
31608
|
}
|
|
31610
31609
|
const flagDocId = generateUserFlagID(userId);
|
|
31611
31610
|
const db2 = context_exports.getAppDB();
|
|
31612
|
-
let
|
|
31611
|
+
let doc2;
|
|
31613
31612
|
try {
|
|
31614
|
-
|
|
31613
|
+
doc2 = await db2.get(flagDocId);
|
|
31615
31614
|
} catch (err) {
|
|
31616
|
-
|
|
31615
|
+
doc2 = { _id: flagDocId };
|
|
31617
31616
|
}
|
|
31618
|
-
|
|
31619
|
-
await db2.put(
|
|
31617
|
+
doc2[flag] = value || true;
|
|
31618
|
+
await db2.put(doc2);
|
|
31620
31619
|
ctx.body = { message: "Flag set successfully" };
|
|
31621
31620
|
}
|
|
31622
31621
|
async function getFlags(ctx) {
|
|
@@ -31624,13 +31623,13 @@ async function getFlags(ctx) {
|
|
|
31624
31623
|
const userId = (_a2 = ctx.user) == null ? void 0 : _a2._id;
|
|
31625
31624
|
const docId = generateUserFlagID(userId);
|
|
31626
31625
|
const db2 = context_exports.getAppDB();
|
|
31627
|
-
let
|
|
31626
|
+
let doc2;
|
|
31628
31627
|
try {
|
|
31629
|
-
|
|
31628
|
+
doc2 = await db2.get(docId);
|
|
31630
31629
|
} catch (err) {
|
|
31631
|
-
|
|
31630
|
+
doc2 = { _id: docId };
|
|
31632
31631
|
}
|
|
31633
|
-
ctx.body =
|
|
31632
|
+
ctx.body = doc2;
|
|
31634
31633
|
}
|
|
31635
31634
|
var init_user10 = __esm({
|
|
31636
31635
|
"src/api/controllers/user.ts"() {
|
|
@@ -32027,16 +32026,16 @@ async function fetch17(type) {
|
|
|
32027
32026
|
return plugins2;
|
|
32028
32027
|
}
|
|
32029
32028
|
}
|
|
32030
|
-
async function processUploaded(plugin,
|
|
32029
|
+
async function processUploaded(plugin, source2) {
|
|
32031
32030
|
var _a2, _b2;
|
|
32032
|
-
const { metadata, directory } = await fileUpload(plugin);
|
|
32033
|
-
plugin_exports.validate(
|
|
32034
|
-
if (!environment_default2.SELF_HOSTED && ((_a2 =
|
|
32031
|
+
const { metadata: metadata2, directory: directory2 } = await fileUpload(plugin);
|
|
32032
|
+
plugin_exports.validate(metadata2 == null ? void 0 : metadata2.schema);
|
|
32033
|
+
if (!environment_default2.SELF_HOSTED && ((_a2 = metadata2 == null ? void 0 : metadata2.schema) == null ? void 0 : _a2.type) !== "component" /* COMPONENT */) {
|
|
32035
32034
|
throw new Error("Only component plugins are supported outside of self-host");
|
|
32036
32035
|
}
|
|
32037
|
-
const
|
|
32038
|
-
(_b2 = clientAppSocket) == null ? void 0 : _b2.emit("plugin-update", { name:
|
|
32039
|
-
return
|
|
32036
|
+
const doc2 = await sdk_exports.plugins.storePlugin(metadata2, directory2, source2);
|
|
32037
|
+
(_b2 = clientAppSocket) == null ? void 0 : _b2.emit("plugin-update", { name: doc2.name, hash: doc2.hash });
|
|
32038
|
+
return doc2;
|
|
32040
32039
|
}
|
|
32041
32040
|
var init_plugins4 = __esm({
|
|
32042
32041
|
"src/sdk/plugins/plugins.ts"() {
|
|
@@ -32386,7 +32385,7 @@ async function runView(view, calculation, group, data) {
|
|
|
32386
32385
|
_rev: void 0
|
|
32387
32386
|
}))
|
|
32388
32387
|
);
|
|
32389
|
-
let fn = (
|
|
32388
|
+
let fn = (doc2, emit2) => emit2(doc2._id);
|
|
32390
32389
|
eval("fn = " + ((_a2 = view == null ? void 0 : view.map) == null ? void 0 : _a2.replace("function (doc)", "function (doc, emit)")));
|
|
32391
32390
|
const queryFns = {
|
|
32392
32391
|
meta: view.meta,
|
|
@@ -33014,7 +33013,7 @@ function cleanupConfig(config, table2) {
|
|
|
33014
33013
|
const fieldNames = Object.entries(table2.schema).filter((schema) => primaryOptions.find((val) => val === schema[1].type)).map(([fieldName]) => fieldName);
|
|
33015
33014
|
const iterateObject = (obj) => {
|
|
33016
33015
|
for (let [field, value] of Object.entries(obj)) {
|
|
33017
|
-
if (fieldNames.find((
|
|
33016
|
+
if (fieldNames.find((name2) => name2 === field) && isRowId(value)) {
|
|
33018
33017
|
obj[field] = convertRowId(value);
|
|
33019
33018
|
}
|
|
33020
33019
|
}
|
|
@@ -34785,7 +34784,7 @@ var init_internal2 = __esm({
|
|
|
34785
34784
|
|
|
34786
34785
|
// src/api/controllers/datasource.ts
|
|
34787
34786
|
function getErrorTables(errors, errorType) {
|
|
34788
|
-
return Object.entries(errors).filter((entry) => entry[1] === errorType).map(([
|
|
34787
|
+
return Object.entries(errors).filter((entry) => entry[1] === errorType).map(([name2]) => name2);
|
|
34789
34788
|
}
|
|
34790
34789
|
function updateError(error2, newError, tables) {
|
|
34791
34790
|
if (!error2) {
|
|
@@ -34985,9 +34984,9 @@ async function update7(ctx) {
|
|
|
34985
34984
|
await events_exports.datasource.updated(datasource2);
|
|
34986
34985
|
datasource2._rev = response2.rev;
|
|
34987
34986
|
if (datasource2.source && !isBudibaseSource) {
|
|
34988
|
-
const
|
|
34989
|
-
if (
|
|
34990
|
-
await
|
|
34987
|
+
const source2 = await getIntegration(datasource2.source);
|
|
34988
|
+
if (source2 && source2.pool) {
|
|
34989
|
+
await source2.pool.end();
|
|
34991
34990
|
}
|
|
34992
34991
|
}
|
|
34993
34992
|
ctx.status = 200;
|
|
@@ -35025,9 +35024,9 @@ async function save13(ctx) {
|
|
|
35025
35024
|
await events_exports.datasource.created(datasource2);
|
|
35026
35025
|
datasource2._rev = dbResp.rev;
|
|
35027
35026
|
if (datasource2.source) {
|
|
35028
|
-
const
|
|
35029
|
-
if (
|
|
35030
|
-
await
|
|
35027
|
+
const source2 = await getIntegration(datasource2.source);
|
|
35028
|
+
if (source2 && source2.pool) {
|
|
35029
|
+
await source2.pool.end();
|
|
35031
35030
|
}
|
|
35032
35031
|
}
|
|
35033
35032
|
const response2 = {
|
|
@@ -35186,7 +35185,7 @@ var init_base2 = __esm({
|
|
|
35186
35185
|
})(MethodToVerb || {});
|
|
35187
35186
|
ImportSource = class {
|
|
35188
35187
|
constructor() {
|
|
35189
|
-
this.constructQuery = (datasourceId,
|
|
35188
|
+
this.constructQuery = (datasourceId, name2, method, path5, url, queryString, headers = {}, parameters = [], body2 = void 0) => {
|
|
35190
35189
|
const readable = true;
|
|
35191
35190
|
const queryVerb = this.verbFromMethod(method);
|
|
35192
35191
|
const transformer = "return data";
|
|
@@ -35207,7 +35206,7 @@ var init_base2 = __esm({
|
|
|
35207
35206
|
const requestBody = JSON.stringify(body2, null, 2);
|
|
35208
35207
|
const query3 = {
|
|
35209
35208
|
datasourceId,
|
|
35210
|
-
name,
|
|
35209
|
+
name: name2,
|
|
35211
35210
|
parameters,
|
|
35212
35211
|
fields: {
|
|
35213
35212
|
headers,
|
|
@@ -35324,9 +35323,9 @@ var init_openapi2 = __esm({
|
|
|
35324
35323
|
return new import_url2.URL(`${scheme}://${host}${basePath}`);
|
|
35325
35324
|
};
|
|
35326
35325
|
this.getInfo = async () => {
|
|
35327
|
-
const
|
|
35326
|
+
const name2 = this.document.info.title || "Swagger Import";
|
|
35328
35327
|
return {
|
|
35329
|
-
name
|
|
35328
|
+
name: name2
|
|
35330
35329
|
};
|
|
35331
35330
|
};
|
|
35332
35331
|
this.getQueries = async (datasourceId) => {
|
|
@@ -35342,7 +35341,7 @@ var init_openapi2 = __esm({
|
|
|
35342
35341
|
}
|
|
35343
35342
|
const operation = opOrParams;
|
|
35344
35343
|
const methodName = key;
|
|
35345
|
-
const
|
|
35344
|
+
const name2 = operation.operationId || path5;
|
|
35346
35345
|
let queryString = "";
|
|
35347
35346
|
const headers = {};
|
|
35348
35347
|
let requestBody = void 0;
|
|
@@ -35387,7 +35386,7 @@ var init_openapi2 = __esm({
|
|
|
35387
35386
|
}
|
|
35388
35387
|
const query3 = this.constructQuery(
|
|
35389
35388
|
datasourceId,
|
|
35390
|
-
|
|
35389
|
+
name2,
|
|
35391
35390
|
methodName,
|
|
35392
35391
|
path5,
|
|
35393
35392
|
url,
|
|
@@ -35479,9 +35478,9 @@ var init_openapi3 = __esm({
|
|
|
35479
35478
|
}
|
|
35480
35479
|
};
|
|
35481
35480
|
this.getInfo = async () => {
|
|
35482
|
-
const
|
|
35481
|
+
const name2 = this.document.info.title || "OpenAPI Import";
|
|
35483
35482
|
return {
|
|
35484
|
-
name
|
|
35483
|
+
name: name2
|
|
35485
35484
|
};
|
|
35486
35485
|
};
|
|
35487
35486
|
this.getQueries = async (datasourceId) => {
|
|
@@ -35508,7 +35507,7 @@ var init_openapi3 = __esm({
|
|
|
35508
35507
|
}
|
|
35509
35508
|
const operation = opOrParams;
|
|
35510
35509
|
const methodName = key;
|
|
35511
|
-
const
|
|
35510
|
+
const name2 = operation.operationId || path5;
|
|
35512
35511
|
let queryString = "";
|
|
35513
35512
|
const headers = {};
|
|
35514
35513
|
let requestBody = getRequestBody(operation);
|
|
@@ -35547,7 +35546,7 @@ var init_openapi3 = __esm({
|
|
|
35547
35546
|
}
|
|
35548
35547
|
const query3 = this.constructQuery(
|
|
35549
35548
|
datasourceId,
|
|
35550
|
-
|
|
35549
|
+
name2,
|
|
35551
35550
|
methodName,
|
|
35552
35551
|
path5,
|
|
35553
35552
|
url,
|
|
@@ -35628,7 +35627,7 @@ var init_curl = __esm({
|
|
|
35628
35627
|
};
|
|
35629
35628
|
this.getQueries = async (datasourceId) => {
|
|
35630
35629
|
const url = this.getUrl();
|
|
35631
|
-
const
|
|
35630
|
+
const name2 = url.pathname;
|
|
35632
35631
|
const path5 = url.origin + url.pathname;
|
|
35633
35632
|
const method = this.curl.method;
|
|
35634
35633
|
const queryString = url.search;
|
|
@@ -35640,7 +35639,7 @@ var init_curl = __esm({
|
|
|
35640
35639
|
}
|
|
35641
35640
|
const query3 = this.constructQuery(
|
|
35642
35641
|
datasourceId,
|
|
35643
|
-
|
|
35642
|
+
name2,
|
|
35644
35643
|
method,
|
|
35645
35644
|
path5,
|
|
35646
35645
|
void 0,
|
|
@@ -35672,9 +35671,9 @@ var init_import = __esm({
|
|
|
35672
35671
|
RestImporter = class {
|
|
35673
35672
|
constructor(data2) {
|
|
35674
35673
|
this.init = async () => {
|
|
35675
|
-
for (let
|
|
35676
|
-
if (await
|
|
35677
|
-
this.source =
|
|
35674
|
+
for (let source2 of this.sources) {
|
|
35675
|
+
if (await source2.isSupported(this.data)) {
|
|
35676
|
+
this.source = source2;
|
|
35678
35677
|
break;
|
|
35679
35678
|
}
|
|
35680
35679
|
}
|
|
@@ -37867,7 +37866,7 @@ function rowEmission({
|
|
|
37867
37866
|
appId,
|
|
37868
37867
|
row: row2,
|
|
37869
37868
|
table: table2,
|
|
37870
|
-
metadata
|
|
37869
|
+
metadata: metadata2
|
|
37871
37870
|
}) {
|
|
37872
37871
|
let event = {
|
|
37873
37872
|
row: row2,
|
|
@@ -37881,8 +37880,8 @@ function rowEmission({
|
|
|
37881
37880
|
if (row2 == null ? void 0 : row2._rev) {
|
|
37882
37881
|
event.revision = row2._rev;
|
|
37883
37882
|
}
|
|
37884
|
-
if (
|
|
37885
|
-
event.metadata =
|
|
37883
|
+
if (metadata2) {
|
|
37884
|
+
event.metadata = metadata2;
|
|
37886
37885
|
}
|
|
37887
37886
|
emitter2.emit(eventName, event);
|
|
37888
37887
|
}
|
|
@@ -37891,7 +37890,7 @@ function tableEmission({
|
|
|
37891
37890
|
eventName,
|
|
37892
37891
|
appId,
|
|
37893
37892
|
table: table2,
|
|
37894
|
-
metadata
|
|
37893
|
+
metadata: metadata2
|
|
37895
37894
|
}) {
|
|
37896
37895
|
const tableId = table2 == null ? void 0 : table2._id;
|
|
37897
37896
|
const inputTable = table2;
|
|
@@ -37907,8 +37906,8 @@ function tableEmission({
|
|
|
37907
37906
|
if (table2 == null ? void 0 : table2._rev) {
|
|
37908
37907
|
event.revision = table2._rev;
|
|
37909
37908
|
}
|
|
37910
|
-
if (
|
|
37911
|
-
event.metadata =
|
|
37909
|
+
if (metadata2) {
|
|
37910
|
+
event.metadata = metadata2;
|
|
37912
37911
|
}
|
|
37913
37912
|
emitter2.emit(eventName, event);
|
|
37914
37913
|
}
|
|
@@ -38085,11 +38084,11 @@ async function storeLog2(automation, results) {
|
|
|
38085
38084
|
}
|
|
38086
38085
|
async function checkAppMetadata(apps2) {
|
|
38087
38086
|
const maxStartDate = await automations_exports.logs.oldestLogDate();
|
|
38088
|
-
for (let
|
|
38089
|
-
if (!
|
|
38087
|
+
for (let metadata2 of apps2) {
|
|
38088
|
+
if (!metadata2.automationErrors) {
|
|
38090
38089
|
continue;
|
|
38091
38090
|
}
|
|
38092
|
-
for (let [key, errors] of Object.entries(
|
|
38091
|
+
for (let [key, errors] of Object.entries(metadata2.automationErrors)) {
|
|
38093
38092
|
const updated9 = [];
|
|
38094
38093
|
for (let error2 of errors) {
|
|
38095
38094
|
if (!error2) {
|
|
@@ -38100,7 +38099,7 @@ async function checkAppMetadata(apps2) {
|
|
|
38100
38099
|
updated9.push(error2);
|
|
38101
38100
|
}
|
|
38102
38101
|
}
|
|
38103
|
-
|
|
38102
|
+
metadata2.automationErrors[key] = updated9;
|
|
38104
38103
|
}
|
|
38105
38104
|
}
|
|
38106
38105
|
return apps2;
|
|
@@ -38188,8 +38187,8 @@ var init_automation4 = __esm({
|
|
|
38188
38187
|
constructor(job) {
|
|
38189
38188
|
let automation = job.data.automation;
|
|
38190
38189
|
let triggerOutput = job.data.event;
|
|
38191
|
-
const
|
|
38192
|
-
this._chainCount =
|
|
38190
|
+
const metadata2 = triggerOutput.metadata;
|
|
38191
|
+
this._chainCount = metadata2 ? metadata2.automationChainCount : 0;
|
|
38193
38192
|
this._appId = triggerOutput.appId;
|
|
38194
38193
|
this._job = job;
|
|
38195
38194
|
const triggerStepId = automation.definition.trigger.stepId;
|
|
@@ -38219,16 +38218,16 @@ var init_automation4 = __esm({
|
|
|
38219
38218
|
async getMetadata() {
|
|
38220
38219
|
const metadataId = generateAutomationMetadataID(this._automation._id);
|
|
38221
38220
|
const db2 = context_exports.getAppDB();
|
|
38222
|
-
let
|
|
38221
|
+
let metadata2;
|
|
38223
38222
|
try {
|
|
38224
|
-
|
|
38223
|
+
metadata2 = await db2.get(metadataId);
|
|
38225
38224
|
} catch (err) {
|
|
38226
|
-
|
|
38225
|
+
metadata2 = {
|
|
38227
38226
|
_id: metadataId,
|
|
38228
38227
|
errorCount: 0
|
|
38229
38228
|
};
|
|
38230
38229
|
}
|
|
38231
|
-
return
|
|
38230
|
+
return metadata2;
|
|
38232
38231
|
}
|
|
38233
38232
|
async stopCron(reason) {
|
|
38234
38233
|
if (!this._job.opts.repeat) {
|
|
@@ -38251,34 +38250,34 @@ var init_automation4 = __esm({
|
|
|
38251
38250
|
);
|
|
38252
38251
|
await storeLog2(automation, this.executionOutput);
|
|
38253
38252
|
}
|
|
38254
|
-
async checkIfShouldStop(
|
|
38255
|
-
if (!
|
|
38253
|
+
async checkIfShouldStop(metadata2) {
|
|
38254
|
+
if (!metadata2.errorCount || !this._job.opts.repeat) {
|
|
38256
38255
|
return false;
|
|
38257
38256
|
}
|
|
38258
|
-
if (
|
|
38257
|
+
if (metadata2.errorCount >= MAX_AUTOMATION_RECURRING_ERRORS) {
|
|
38259
38258
|
await this.stopCron("errors");
|
|
38260
38259
|
return true;
|
|
38261
38260
|
}
|
|
38262
38261
|
return false;
|
|
38263
38262
|
}
|
|
38264
|
-
async updateMetadata(
|
|
38263
|
+
async updateMetadata(metadata2) {
|
|
38265
38264
|
const output = this.executionOutput, automation = this._automation;
|
|
38266
38265
|
if (!output || !isRecurring(automation)) {
|
|
38267
38266
|
return;
|
|
38268
38267
|
}
|
|
38269
|
-
const count =
|
|
38268
|
+
const count = metadata2.errorCount;
|
|
38270
38269
|
const isError = isErrorInOutput(output);
|
|
38271
38270
|
if (!count && !isError) {
|
|
38272
38271
|
return;
|
|
38273
38272
|
}
|
|
38274
38273
|
if (isError) {
|
|
38275
|
-
|
|
38274
|
+
metadata2.errorCount = count ? count + 1 : 1;
|
|
38276
38275
|
} else {
|
|
38277
|
-
|
|
38276
|
+
metadata2.errorCount = 0;
|
|
38278
38277
|
}
|
|
38279
38278
|
const db2 = context_exports.getAppDB();
|
|
38280
38279
|
try {
|
|
38281
|
-
await db2.put(
|
|
38280
|
+
await db2.put(metadata2);
|
|
38282
38281
|
} catch (err) {
|
|
38283
38282
|
logging_exports.logAlertWithInfo(
|
|
38284
38283
|
"Failed to write automation metadata",
|
|
@@ -38329,13 +38328,13 @@ var init_automation4 = __esm({
|
|
|
38329
38328
|
let stepCount = 0;
|
|
38330
38329
|
let loopStepNumber = void 0;
|
|
38331
38330
|
let loopSteps = [];
|
|
38332
|
-
let
|
|
38331
|
+
let metadata2;
|
|
38333
38332
|
let timeoutFlag = false;
|
|
38334
38333
|
let wasLoopStep = false;
|
|
38335
38334
|
let timeout2 = this._job.data.event.timeout;
|
|
38336
38335
|
if (isProdAppID2(this._appId) && isRecurring(automation)) {
|
|
38337
|
-
|
|
38338
|
-
const shouldStop = await this.checkIfShouldStop(
|
|
38336
|
+
metadata2 = await this.getMetadata();
|
|
38337
|
+
const shouldStop = await this.checkIfShouldStop(metadata2);
|
|
38339
38338
|
if (shouldStop) {
|
|
38340
38339
|
return;
|
|
38341
38340
|
}
|
|
@@ -38539,8 +38538,8 @@ var init_automation4 = __esm({
|
|
|
38539
38538
|
}
|
|
38540
38539
|
logging_exports.logAlert("Error writing automation log", e);
|
|
38541
38540
|
}
|
|
38542
|
-
if (isProdAppID2(this._appId) && isRecurring(automation) &&
|
|
38543
|
-
await this.updateMetadata(
|
|
38541
|
+
if (isProdAppID2(this._appId) && isRecurring(automation) && metadata2) {
|
|
38542
|
+
await this.updateMetadata(metadata2);
|
|
38544
38543
|
}
|
|
38545
38544
|
return this.executionOutput;
|
|
38546
38545
|
}
|
|
@@ -38633,15 +38632,15 @@ async function updateTestHistory(appId, automation, history) {
|
|
|
38633
38632
|
return updateEntityMetadata(
|
|
38634
38633
|
"automationTestHistory" /* AUTOMATION_TEST_HISTORY */,
|
|
38635
38634
|
automation._id,
|
|
38636
|
-
(
|
|
38637
|
-
if (
|
|
38638
|
-
|
|
38635
|
+
(metadata2) => {
|
|
38636
|
+
if (metadata2 && Array.isArray(metadata2.history)) {
|
|
38637
|
+
metadata2.history.push(history);
|
|
38639
38638
|
} else {
|
|
38640
|
-
|
|
38639
|
+
metadata2 = {
|
|
38641
38640
|
history: [history]
|
|
38642
38641
|
};
|
|
38643
38642
|
}
|
|
38644
|
-
return
|
|
38643
|
+
return metadata2;
|
|
38645
38644
|
}
|
|
38646
38645
|
);
|
|
38647
38646
|
}
|
|
@@ -38683,8 +38682,8 @@ async function clearMetadata() {
|
|
|
38683
38682
|
include_docs: true
|
|
38684
38683
|
})
|
|
38685
38684
|
)).rows.map((row2) => row2.doc);
|
|
38686
|
-
for (let
|
|
38687
|
-
|
|
38685
|
+
for (let metadata2 of automationMetadata) {
|
|
38686
|
+
metadata2._deleted = true;
|
|
38688
38687
|
}
|
|
38689
38688
|
await db2.bulkDocs(automationMetadata);
|
|
38690
38689
|
}
|
|
@@ -38890,14 +38889,14 @@ function checkAppUrl(ctx, apps2, url, currentAppId) {
|
|
|
38890
38889
|
ctx.throw(400, "App URL is already in use.");
|
|
38891
38890
|
}
|
|
38892
38891
|
}
|
|
38893
|
-
function checkAppName(ctx, apps2,
|
|
38894
|
-
if (!
|
|
38892
|
+
function checkAppName(ctx, apps2, name2, currentAppId) {
|
|
38893
|
+
if (!name2) {
|
|
38895
38894
|
ctx.throw(400, "Name is required");
|
|
38896
38895
|
}
|
|
38897
38896
|
if (currentAppId) {
|
|
38898
38897
|
apps2 = apps2.filter((app2) => app2.appId !== currentAppId);
|
|
38899
38898
|
}
|
|
38900
|
-
if (apps2.some((app2) => app2.name ===
|
|
38899
|
+
if (apps2.some((app2) => app2.name === name2)) {
|
|
38901
38900
|
ctx.throw(400, "App name is already in use.");
|
|
38902
38901
|
}
|
|
38903
38902
|
}
|
|
@@ -38983,9 +38982,9 @@ async function fetchAppPackage(ctx) {
|
|
|
38983
38982
|
}
|
|
38984
38983
|
async function performAppCreate(ctx) {
|
|
38985
38984
|
const apps2 = await db_exports.getAllApps({ dev: true });
|
|
38986
|
-
const
|
|
38987
|
-
checkAppName(ctx, apps2,
|
|
38988
|
-
const url = sdk_default.applications.getAppUrl({ name, url: possibleUrl });
|
|
38985
|
+
const name2 = ctx.request.body.name, possibleUrl = ctx.request.body.url;
|
|
38986
|
+
checkAppName(ctx, apps2, name2);
|
|
38987
|
+
const url = sdk_default.applications.getAppUrl({ name: name2, url: possibleUrl });
|
|
38989
38988
|
checkAppUrl(ctx, apps2, url);
|
|
38990
38989
|
const { useTemplate, templateKey, templateString } = ctx.request.body;
|
|
38991
38990
|
const instanceConfig = {
|
|
@@ -39008,7 +39007,7 @@ async function performAppCreate(ctx) {
|
|
|
39008
39007
|
type: "app",
|
|
39009
39008
|
version: environment_default.VERSION,
|
|
39010
39009
|
componentLibraries: ["@budibase/standard-components"],
|
|
39011
|
-
name,
|
|
39010
|
+
name: name2,
|
|
39012
39011
|
url,
|
|
39013
39012
|
template: templateKey,
|
|
39014
39013
|
instance,
|
|
@@ -39018,7 +39017,7 @@ async function performAppCreate(ctx) {
|
|
|
39018
39017
|
status: AppStatus.DEV,
|
|
39019
39018
|
navigation: {
|
|
39020
39019
|
navigation: "Top",
|
|
39021
|
-
title:
|
|
39020
|
+
title: name2,
|
|
39022
39021
|
navWidth: "Large",
|
|
39023
39022
|
navBackground: "var(--spectrum-global-color-gray-100)",
|
|
39024
39023
|
links: [
|
|
@@ -39117,11 +39116,11 @@ async function create6(ctx) {
|
|
|
39117
39116
|
}
|
|
39118
39117
|
async function update8(ctx) {
|
|
39119
39118
|
const apps2 = await db_exports.getAllApps({ dev: true });
|
|
39120
|
-
const
|
|
39121
|
-
if (
|
|
39122
|
-
checkAppName(ctx, apps2,
|
|
39119
|
+
const name2 = ctx.request.body.name, possibleUrl = ctx.request.body.url;
|
|
39120
|
+
if (name2) {
|
|
39121
|
+
checkAppName(ctx, apps2, name2, ctx.params.appId);
|
|
39123
39122
|
}
|
|
39124
|
-
const url = sdk_default.applications.getAppUrl({ name, url: possibleUrl });
|
|
39123
|
+
const url = sdk_default.applications.getAppUrl({ name: name2, url: possibleUrl });
|
|
39125
39124
|
if (url) {
|
|
39126
39125
|
checkAppUrl(ctx, apps2, url, ctx.params.appId);
|
|
39127
39126
|
ctx.request.body.url = url;
|
|
@@ -39265,14 +39264,14 @@ async function migrateAppNavigation() {
|
|
|
39265
39264
|
screen.width = (layout2 == null ? void 0 : layout2.props.width) || "Large";
|
|
39266
39265
|
await db2.put(screen);
|
|
39267
39266
|
}
|
|
39268
|
-
const { name, customTheme } = existing;
|
|
39267
|
+
const { name: name2, customTheme } = existing;
|
|
39269
39268
|
const layout = layouts == null ? void 0 : layouts.find(
|
|
39270
39269
|
(layout2) => layout2._id === BASE_LAYOUT_PROP_IDS.PRIVATE
|
|
39271
39270
|
);
|
|
39272
39271
|
if (layout && !existing.navigation) {
|
|
39273
39272
|
let navigationSettings = {
|
|
39274
39273
|
navigation: "Top",
|
|
39275
|
-
title:
|
|
39274
|
+
title: name2,
|
|
39276
39275
|
navWidth: "Large",
|
|
39277
39276
|
navBackground: (customTheme == null ? void 0 : customTheme.navBackground) || "var(--spectrum-global-color-gray-50)",
|
|
39278
39277
|
navTextColor: (customTheme == null ? void 0 : customTheme.navTextColor) || "var(--spectrum-global-color-gray-800)"
|
|
@@ -39280,7 +39279,7 @@ async function migrateAppNavigation() {
|
|
|
39280
39279
|
if (layout) {
|
|
39281
39280
|
navigationSettings.hideLogo = layout.props.hideLogo;
|
|
39282
39281
|
navigationSettings.hideTitle = layout.props.hideTitle;
|
|
39283
|
-
navigationSettings.title = layout.props.title ||
|
|
39282
|
+
navigationSettings.title = layout.props.title || name2;
|
|
39284
39283
|
navigationSettings.logoUrl = layout.props.logoUrl;
|
|
39285
39284
|
navigationSettings.links = layout.props.links;
|
|
39286
39285
|
navigationSettings.navigation = layout.props.navigation || "Top";
|
|
@@ -40696,14 +40695,14 @@ async function clearLogError(ctx) {
|
|
|
40696
40695
|
const { automationId, appId } = ctx.request.body;
|
|
40697
40696
|
await context_exports.doInAppContext(appId, async () => {
|
|
40698
40697
|
const db2 = context_exports.getProdAppDB();
|
|
40699
|
-
const
|
|
40698
|
+
const metadata2 = await db2.get(DocumentType2.APP_METADATA);
|
|
40700
40699
|
if (!automationId) {
|
|
40701
|
-
delete
|
|
40702
|
-
} else if (
|
|
40703
|
-
delete
|
|
40700
|
+
delete metadata2.automationErrors;
|
|
40701
|
+
} else if (metadata2.automationErrors && metadata2.automationErrors[automationId]) {
|
|
40702
|
+
delete metadata2.automationErrors[automationId];
|
|
40704
40703
|
}
|
|
40705
|
-
await db2.put(
|
|
40706
|
-
await cache_exports.app.invalidateAppMetadata(
|
|
40704
|
+
await db2.put(metadata2);
|
|
40705
|
+
await cache_exports.app.invalidateAppMetadata(metadata2.appId, metadata2);
|
|
40707
40706
|
ctx.body = { message: `Error logs cleared.` };
|
|
40708
40707
|
});
|
|
40709
40708
|
}
|
|
@@ -41057,7 +41056,7 @@ async function find12(ctx) {
|
|
|
41057
41056
|
}
|
|
41058
41057
|
async function save20(ctx) {
|
|
41059
41058
|
const db2 = context_exports.getAppDB();
|
|
41060
|
-
let { _id, name, inherits, permissionId } = ctx.request.body;
|
|
41059
|
+
let { _id, name: name2, inherits, permissionId } = ctx.request.body;
|
|
41061
41060
|
let isCreate = false;
|
|
41062
41061
|
if (!_id) {
|
|
41063
41062
|
_id = generateRoleID2();
|
|
@@ -41065,7 +41064,7 @@ async function save20(ctx) {
|
|
|
41065
41064
|
} else if (roles_exports.isBuiltin(_id)) {
|
|
41066
41065
|
ctx.throw(400, "Cannot update builtin roles.");
|
|
41067
41066
|
}
|
|
41068
|
-
const role = new roles_exports.Role(_id,
|
|
41067
|
+
const role = new roles_exports.Role(_id, name2, permissionId).addInheritance(inherits);
|
|
41069
41068
|
if (ctx.request.body._rev) {
|
|
41070
41069
|
role._rev = ctx.request.body._rev;
|
|
41071
41070
|
}
|
|
@@ -41175,10 +41174,10 @@ async function getBuilderMainDoc() {
|
|
|
41175
41174
|
};
|
|
41176
41175
|
}
|
|
41177
41176
|
}
|
|
41178
|
-
async function setBuilderMainDoc(
|
|
41179
|
-
|
|
41177
|
+
async function setBuilderMainDoc(doc2) {
|
|
41178
|
+
doc2._id = KEYS_DOC;
|
|
41180
41179
|
const db2 = tenancy.getGlobalDB();
|
|
41181
|
-
return db2.put(
|
|
41180
|
+
return db2.put(doc2);
|
|
41182
41181
|
}
|
|
41183
41182
|
async function fetch36(ctx) {
|
|
41184
41183
|
try {
|
|
@@ -41250,10 +41249,10 @@ async function fetch37(ctx) {
|
|
|
41250
41249
|
}
|
|
41251
41250
|
}
|
|
41252
41251
|
async function downloadTemplate2(ctx) {
|
|
41253
|
-
const { type, name } = ctx.params;
|
|
41254
|
-
await downloadTemplate(type,
|
|
41252
|
+
const { type, name: name2 } = ctx.params;
|
|
41253
|
+
await downloadTemplate(type, name2);
|
|
41255
41254
|
ctx.body = {
|
|
41256
|
-
message: `template ${type}:${
|
|
41255
|
+
message: `template ${type}:${name2} downloaded successfully.`
|
|
41257
41256
|
};
|
|
41258
41257
|
}
|
|
41259
41258
|
var import_node_fetch17, DEFAULT_TEMPLATES_BUCKET;
|
|
@@ -42066,11 +42065,11 @@ async function revert(ctx) {
|
|
|
42066
42065
|
}
|
|
42067
42066
|
}
|
|
42068
42067
|
async function getBudibaseVersion(ctx) {
|
|
42069
|
-
const
|
|
42068
|
+
const version2 = environment_default.VERSION;
|
|
42070
42069
|
ctx.body = {
|
|
42071
|
-
version
|
|
42070
|
+
version: version2
|
|
42072
42071
|
};
|
|
42073
|
-
await events_exports.installation.versionChecked(
|
|
42072
|
+
await events_exports.installation.versionChecked(version2);
|
|
42074
42073
|
}
|
|
42075
42074
|
var import_node_fetch18;
|
|
42076
42075
|
var init_dev = __esm({
|
|
@@ -42243,17 +42242,17 @@ var init_appUrls = __esm({
|
|
|
42243
42242
|
init_src2();
|
|
42244
42243
|
init_sdk3();
|
|
42245
42244
|
run27 = async (appDb) => {
|
|
42246
|
-
let
|
|
42245
|
+
let metadata2;
|
|
42247
42246
|
try {
|
|
42248
|
-
|
|
42247
|
+
metadata2 = await appDb.get(db_exports.DocumentType.APP_METADATA);
|
|
42249
42248
|
} catch (e) {
|
|
42250
42249
|
console.error("Error retrieving app metadata. Skipping", e);
|
|
42251
42250
|
return;
|
|
42252
42251
|
}
|
|
42253
|
-
if (!
|
|
42254
|
-
|
|
42255
|
-
console.log(`Adding url to app: ${
|
|
42256
|
-
await appDb.put(
|
|
42252
|
+
if (!metadata2.url) {
|
|
42253
|
+
metadata2.url = sdk_default.applications.getAppUrl({ name: metadata2.name });
|
|
42254
|
+
console.log(`Adding url to app: ${metadata2.url}`);
|
|
42255
|
+
await appDb.put(metadata2);
|
|
42257
42256
|
}
|
|
42258
42257
|
};
|
|
42259
42258
|
}
|
|
@@ -43195,9 +43194,9 @@ var init_migrations6 = __esm({
|
|
|
43195
43194
|
});
|
|
43196
43195
|
|
|
43197
43196
|
// src/api/controllers/plugin/utils.ts
|
|
43198
|
-
async function downloadUnzipTarball(url,
|
|
43197
|
+
async function downloadUnzipTarball(url, name2, headers = {}) {
|
|
43199
43198
|
try {
|
|
43200
|
-
const path5 = createTempFolder(
|
|
43199
|
+
const path5 = createTempFolder(name2);
|
|
43201
43200
|
await objectStore_exports2.downloadTarballDirect(url, path5, headers);
|
|
43202
43201
|
return path5;
|
|
43203
43202
|
} catch (e) {
|
|
@@ -43220,7 +43219,7 @@ async function request2(url, headers, err) {
|
|
|
43220
43219
|
}
|
|
43221
43220
|
return response2.json();
|
|
43222
43221
|
}
|
|
43223
|
-
async function githubUpload(url,
|
|
43222
|
+
async function githubUpload(url, name2 = "", token = "") {
|
|
43224
43223
|
var _a2;
|
|
43225
43224
|
let githubUrl = url;
|
|
43226
43225
|
if (!githubUrl.includes("https://github.com/")) {
|
|
@@ -43239,7 +43238,7 @@ async function githubUpload(url, name = "", token = "") {
|
|
|
43239
43238
|
headers,
|
|
43240
43239
|
"Repository not found"
|
|
43241
43240
|
);
|
|
43242
|
-
const pluginName = pluginDetails.name ||
|
|
43241
|
+
const pluginName = pluginDetails.name || name2;
|
|
43243
43242
|
const pluginLatestReleaseUrl = (pluginDetails == null ? void 0 : pluginDetails["releases_url"]) ? pluginDetails == null ? void 0 : pluginDetails["releases_url"].replace("{/id}", "/latest") : void 0;
|
|
43244
43243
|
if (!pluginLatestReleaseUrl) {
|
|
43245
43244
|
throw new Error("Github release not found");
|
|
@@ -43281,10 +43280,10 @@ var init_github = __esm({
|
|
|
43281
43280
|
});
|
|
43282
43281
|
|
|
43283
43282
|
// src/api/controllers/plugin/npm.ts
|
|
43284
|
-
async function npmUpload(url,
|
|
43283
|
+
async function npmUpload(url, name2, headers = {}) {
|
|
43285
43284
|
var _a2, _b2, _c;
|
|
43286
43285
|
let npmTarballUrl = url;
|
|
43287
|
-
let pluginName =
|
|
43286
|
+
let pluginName = name2;
|
|
43288
43287
|
if (!npmTarballUrl.includes("https://www.npmjs.com") && !npmTarballUrl.includes("https://registry.npmjs.org")) {
|
|
43289
43288
|
throw new Error("The plugin origin must be from NPM");
|
|
43290
43289
|
}
|
|
@@ -43329,11 +43328,11 @@ var init_npm = __esm({
|
|
|
43329
43328
|
});
|
|
43330
43329
|
|
|
43331
43330
|
// src/api/controllers/plugin/url.ts
|
|
43332
|
-
async function urlUpload(url,
|
|
43331
|
+
async function urlUpload(url, name2 = "", headers = {}) {
|
|
43333
43332
|
if (!url.includes(".tar.gz")) {
|
|
43334
43333
|
throw new Error("Plugin must be compressed into a gzipped tarball.");
|
|
43335
43334
|
}
|
|
43336
|
-
const path5 = await downloadUnzipTarball(url,
|
|
43335
|
+
const path5 = await downloadUnzipTarball(url, name2, headers);
|
|
43337
43336
|
return await getPluginMetadata(path5);
|
|
43338
43337
|
}
|
|
43339
43338
|
var init_url = __esm({
|
|
@@ -43359,8 +43358,8 @@ async function upload2(ctx) {
|
|
|
43359
43358
|
try {
|
|
43360
43359
|
let docs = [];
|
|
43361
43360
|
for (let plugin of plugins2) {
|
|
43362
|
-
const
|
|
43363
|
-
docs.push(
|
|
43361
|
+
const doc2 = await sdk_default.plugins.processUploaded(plugin, "File Upload" /* FILE */);
|
|
43362
|
+
docs.push(doc2);
|
|
43364
43363
|
}
|
|
43365
43364
|
ctx.body = {
|
|
43366
43365
|
message: "Plugin(s) uploaded successfully",
|
|
@@ -43373,42 +43372,42 @@ async function upload2(ctx) {
|
|
|
43373
43372
|
}
|
|
43374
43373
|
async function create8(ctx) {
|
|
43375
43374
|
var _a2, _b2;
|
|
43376
|
-
const { source, url, headers, githubToken } = ctx.request.body;
|
|
43375
|
+
const { source: source2, url, headers, githubToken } = ctx.request.body;
|
|
43377
43376
|
try {
|
|
43378
|
-
let
|
|
43379
|
-
let
|
|
43380
|
-
let
|
|
43381
|
-
switch (
|
|
43377
|
+
let metadata2;
|
|
43378
|
+
let directory2;
|
|
43379
|
+
let name2 = "PLUGIN_" + Math.floor(1e5 + Math.random() * 9e5);
|
|
43380
|
+
switch (source2) {
|
|
43382
43381
|
case "NPM" /* NPM */:
|
|
43383
|
-
const { metadata: metadataNpm, directory: directoryNpm } = await npmUpload(url,
|
|
43384
|
-
|
|
43385
|
-
|
|
43382
|
+
const { metadata: metadataNpm, directory: directoryNpm } = await npmUpload(url, name2);
|
|
43383
|
+
metadata2 = metadataNpm;
|
|
43384
|
+
directory2 = directoryNpm;
|
|
43386
43385
|
break;
|
|
43387
43386
|
case "Github" /* GITHUB */:
|
|
43388
|
-
const { metadata: metadataGithub, directory: directoryGithub } = await githubUpload(url,
|
|
43389
|
-
|
|
43390
|
-
|
|
43387
|
+
const { metadata: metadataGithub, directory: directoryGithub } = await githubUpload(url, name2, githubToken);
|
|
43388
|
+
metadata2 = metadataGithub;
|
|
43389
|
+
directory2 = directoryGithub;
|
|
43391
43390
|
break;
|
|
43392
43391
|
case "URL" /* URL */:
|
|
43393
43392
|
const headersObj = headers || {};
|
|
43394
|
-
const { metadata: metadataUrl, directory: directoryUrl } = await urlUpload(url,
|
|
43395
|
-
|
|
43396
|
-
|
|
43393
|
+
const { metadata: metadataUrl, directory: directoryUrl } = await urlUpload(url, name2, headersObj);
|
|
43394
|
+
metadata2 = metadataUrl;
|
|
43395
|
+
directory2 = directoryUrl;
|
|
43397
43396
|
break;
|
|
43398
43397
|
}
|
|
43399
|
-
plugin_exports.validate(
|
|
43400
|
-
if (!environment_default2.SELF_HOSTED && ((_a2 =
|
|
43398
|
+
plugin_exports.validate(metadata2 == null ? void 0 : metadata2.schema);
|
|
43399
|
+
if (!environment_default2.SELF_HOSTED && ((_a2 = metadata2 == null ? void 0 : metadata2.schema) == null ? void 0 : _a2.type) !== "component" /* COMPONENT */) {
|
|
43401
43400
|
throw new Error(
|
|
43402
43401
|
"Only component plugins are supported outside of self-host"
|
|
43403
43402
|
);
|
|
43404
43403
|
}
|
|
43405
|
-
const
|
|
43406
|
-
(_b2 = clientAppSocket) == null ? void 0 : _b2.emit("plugins-update", { name, hash:
|
|
43404
|
+
const doc2 = await sdk_exports.plugins.storePlugin(metadata2, directory2, source2);
|
|
43405
|
+
(_b2 = clientAppSocket) == null ? void 0 : _b2.emit("plugins-update", { name: name2, hash: doc2.hash });
|
|
43407
43406
|
ctx.body = {
|
|
43408
43407
|
message: "Plugin uploaded successfully",
|
|
43409
|
-
plugins: [
|
|
43408
|
+
plugins: [doc2]
|
|
43410
43409
|
};
|
|
43411
|
-
ctx.body = { plugin:
|
|
43410
|
+
ctx.body = { plugin: doc2 };
|
|
43412
43411
|
} catch (err) {
|
|
43413
43412
|
const errMsg = (err == null ? void 0 : err.message) ? err == null ? void 0 : err.message : err;
|
|
43414
43413
|
ctx.throw(400, `Failed to import plugin: ${errMsg}`);
|
|
@@ -43418,9 +43417,9 @@ async function fetch44(ctx) {
|
|
|
43418
43417
|
ctx.body = await sdk_default.plugins.fetch();
|
|
43419
43418
|
}
|
|
43420
43419
|
async function destroy22(ctx) {
|
|
43421
|
-
const { pluginId } = ctx.params;
|
|
43420
|
+
const { pluginId: pluginId2 } = ctx.params;
|
|
43422
43421
|
try {
|
|
43423
|
-
await sdk_exports.plugins.deletePlugin(
|
|
43422
|
+
await sdk_exports.plugins.deletePlugin(pluginId2);
|
|
43424
43423
|
ctx.body = { message: `Plugin ${ctx.params.pluginId} deleted.` };
|
|
43425
43424
|
} catch (err) {
|
|
43426
43425
|
ctx.throw(400, err.message);
|
|
@@ -43515,10 +43514,10 @@ var init_ops2 = __esm({
|
|
|
43515
43514
|
});
|
|
43516
43515
|
|
|
43517
43516
|
// src/api/controllers/static/index.ts
|
|
43518
|
-
async function prepareUpload({ s3Key, bucket, metadata, file }) {
|
|
43517
|
+
async function prepareUpload({ s3Key, bucket, metadata: metadata2, file }) {
|
|
43519
43518
|
const response2 = await objectStore_exports2.upload({
|
|
43520
43519
|
bucket,
|
|
43521
|
-
metadata,
|
|
43520
|
+
metadata: metadata2,
|
|
43522
43521
|
filename: s3Key,
|
|
43523
43522
|
path: file.path,
|
|
43524
43523
|
type: file.type
|
|
@@ -43575,8 +43574,8 @@ var init_static = __esm({
|
|
|
43575
43574
|
await send2(ctx, ctx.file, { root: builderPath });
|
|
43576
43575
|
};
|
|
43577
43576
|
uploadFile = async function(ctx) {
|
|
43578
|
-
let
|
|
43579
|
-
const uploads =
|
|
43577
|
+
let files2 = ctx.request.files.file.length > 1 ? Array.from(ctx.request.files.file) : [ctx.request.files.file];
|
|
43578
|
+
const uploads = files2.map(async (file) => {
|
|
43580
43579
|
const fileExtension = [...file.name.split(".")].pop();
|
|
43581
43580
|
const processedFileName = `${uuid5.v4()}.${fileExtension}`;
|
|
43582
43581
|
return prepareUpload({
|
|
@@ -43781,13 +43780,13 @@ function search6(docs, value, key = "name") {
|
|
|
43781
43780
|
}
|
|
43782
43781
|
value = value.toLowerCase();
|
|
43783
43782
|
const filtered2 = [];
|
|
43784
|
-
for (let
|
|
43785
|
-
if (typeof
|
|
43783
|
+
for (let doc2 of docs) {
|
|
43784
|
+
if (typeof doc2[key] !== "string") {
|
|
43786
43785
|
continue;
|
|
43787
43786
|
}
|
|
43788
|
-
const toTest =
|
|
43787
|
+
const toTest = doc2[key].toLowerCase();
|
|
43789
43788
|
if (toTest.startsWith(value)) {
|
|
43790
|
-
filtered2.push(
|
|
43789
|
+
filtered2.push(doc2);
|
|
43791
43790
|
}
|
|
43792
43791
|
}
|
|
43793
43792
|
return filtered2;
|
|
@@ -43825,9 +43824,9 @@ async function setResponseApp(ctx) {
|
|
|
43825
43824
|
}
|
|
43826
43825
|
}
|
|
43827
43826
|
async function search7(ctx, next) {
|
|
43828
|
-
const { name } = ctx.request.body;
|
|
43827
|
+
const { name: name2 } = ctx.request.body;
|
|
43829
43828
|
const apps2 = await db_exports.getAllApps({ all: true });
|
|
43830
|
-
ctx.body = search6(apps2,
|
|
43829
|
+
ctx.body = search6(apps2, name2);
|
|
43831
43830
|
await next();
|
|
43832
43831
|
}
|
|
43833
43832
|
async function create9(ctx, next) {
|
|
@@ -43935,29 +43934,29 @@ var init_Endpoint = __esm({
|
|
|
43935
43934
|
});
|
|
43936
43935
|
|
|
43937
43936
|
// src/api/routes/public/applications.ts
|
|
43938
|
-
var nameValidator2, applicationValidator2, read2,
|
|
43937
|
+
var nameValidator2, applicationValidator2, read2, write3, applications_default3;
|
|
43939
43938
|
var init_applications3 = __esm({
|
|
43940
43939
|
"src/api/routes/public/applications.ts"() {
|
|
43941
43940
|
init_applications2();
|
|
43942
43941
|
init_Endpoint();
|
|
43943
43942
|
({ nameValidator: nameValidator2, applicationValidator: applicationValidator2 } = (init_validators(), __toCommonJS(validators_exports)));
|
|
43944
43943
|
read2 = [];
|
|
43945
|
-
|
|
43946
|
-
|
|
43944
|
+
write3 = [];
|
|
43945
|
+
write3.push(
|
|
43947
43946
|
new Endpoint_default("post", "/applications", applications_default2.create).addMiddleware(
|
|
43948
43947
|
applicationValidator2()
|
|
43949
43948
|
)
|
|
43950
43949
|
);
|
|
43951
|
-
|
|
43950
|
+
write3.push(
|
|
43952
43951
|
new Endpoint_default("put", "/applications/:appId", applications_default2.update).addMiddleware(
|
|
43953
43952
|
applicationValidator2()
|
|
43954
43953
|
)
|
|
43955
43954
|
);
|
|
43956
|
-
|
|
43957
|
-
|
|
43955
|
+
write3.push(new Endpoint_default("delete", "/applications/:appId", applications_default2.destroy));
|
|
43956
|
+
write3.push(
|
|
43958
43957
|
new Endpoint_default("post", "/applications/:appId/unpublish", applications_default2.unpublish)
|
|
43959
43958
|
);
|
|
43960
|
-
|
|
43959
|
+
write3.push(
|
|
43961
43960
|
new Endpoint_default("post", "/applications/:appId/publish", applications_default2.publish)
|
|
43962
43961
|
);
|
|
43963
43962
|
read2.push(new Endpoint_default("get", "/applications/:appId", applications_default2.read));
|
|
@@ -43966,7 +43965,7 @@ var init_applications3 = __esm({
|
|
|
43966
43965
|
nameValidator2()
|
|
43967
43966
|
)
|
|
43968
43967
|
);
|
|
43969
|
-
applications_default3 = { read: read2, write:
|
|
43968
|
+
applications_default3 = { read: read2, write: write3 };
|
|
43970
43969
|
}
|
|
43971
43970
|
});
|
|
43972
43971
|
|
|
@@ -44176,8 +44175,8 @@ var init_metrics2 = __esm({
|
|
|
44176
44175
|
// src/api/controllers/public/queries.ts
|
|
44177
44176
|
async function search8(ctx, next) {
|
|
44178
44177
|
await fetch23(ctx);
|
|
44179
|
-
const { name } = ctx.request.body;
|
|
44180
|
-
ctx.body = search6(ctx.body,
|
|
44178
|
+
const { name: name2 } = ctx.request.body;
|
|
44179
|
+
ctx.body = search6(ctx.body, name2);
|
|
44181
44180
|
await next();
|
|
44182
44181
|
}
|
|
44183
44182
|
async function execute3(ctx, next) {
|
|
@@ -44197,21 +44196,21 @@ var init_queries5 = __esm({
|
|
|
44197
44196
|
});
|
|
44198
44197
|
|
|
44199
44198
|
// src/api/routes/public/queries.ts
|
|
44200
|
-
var read4,
|
|
44199
|
+
var read4, write4, queries_default3;
|
|
44201
44200
|
var init_queries6 = __esm({
|
|
44202
44201
|
"src/api/routes/public/queries.ts"() {
|
|
44203
44202
|
init_queries5();
|
|
44204
44203
|
init_Endpoint();
|
|
44205
44204
|
init_validators();
|
|
44206
44205
|
read4 = [];
|
|
44207
|
-
|
|
44208
|
-
|
|
44206
|
+
write4 = [];
|
|
44207
|
+
write4.push(new Endpoint_default("post", "/queries/:queryId", queries_default2.execute));
|
|
44209
44208
|
read4.push(
|
|
44210
44209
|
new Endpoint_default("post", "/queries/search", queries_default2.search).addMiddleware(
|
|
44211
44210
|
nameValidator()
|
|
44212
44211
|
)
|
|
44213
44212
|
);
|
|
44214
|
-
queries_default3 = { read: read4, write:
|
|
44213
|
+
queries_default3 = { read: read4, write: write4 };
|
|
44215
44214
|
}
|
|
44216
44215
|
});
|
|
44217
44216
|
|
|
@@ -44229,9 +44228,9 @@ function fixTable(table2, params2) {
|
|
|
44229
44228
|
return table2;
|
|
44230
44229
|
}
|
|
44231
44230
|
async function search9(ctx, next) {
|
|
44232
|
-
const { name } = ctx.request.body;
|
|
44231
|
+
const { name: name2 } = ctx.request.body;
|
|
44233
44232
|
await fetch29(ctx);
|
|
44234
|
-
ctx.body = search6(ctx.body,
|
|
44233
|
+
ctx.body = search6(ctx.body, name2);
|
|
44235
44234
|
await next();
|
|
44236
44235
|
}
|
|
44237
44236
|
async function create10(ctx, next) {
|
|
@@ -44271,32 +44270,32 @@ var init_tables3 = __esm({
|
|
|
44271
44270
|
});
|
|
44272
44271
|
|
|
44273
44272
|
// src/api/routes/public/tables.ts
|
|
44274
|
-
var read6,
|
|
44273
|
+
var read6, write5, tables_default3;
|
|
44275
44274
|
var init_tables4 = __esm({
|
|
44276
44275
|
"src/api/routes/public/tables.ts"() {
|
|
44277
44276
|
init_tables3();
|
|
44278
44277
|
init_Endpoint();
|
|
44279
44278
|
init_validators();
|
|
44280
44279
|
read6 = [];
|
|
44281
|
-
|
|
44282
|
-
|
|
44280
|
+
write5 = [];
|
|
44281
|
+
write5.push(
|
|
44283
44282
|
new Endpoint_default("post", "/tables", tables_default2.create).addMiddleware(
|
|
44284
44283
|
tableValidator()
|
|
44285
44284
|
)
|
|
44286
44285
|
);
|
|
44287
|
-
|
|
44286
|
+
write5.push(
|
|
44288
44287
|
new Endpoint_default("put", "/tables/:tableId", tables_default2.update).addMiddleware(
|
|
44289
44288
|
tableValidator()
|
|
44290
44289
|
)
|
|
44291
44290
|
);
|
|
44292
|
-
|
|
44291
|
+
write5.push(new Endpoint_default("delete", "/tables/:tableId", tables_default2.destroy));
|
|
44293
44292
|
read6.push(new Endpoint_default("get", "/tables/:tableId", tables_default2.read));
|
|
44294
44293
|
read6.push(
|
|
44295
44294
|
new Endpoint_default("post", "/tables/search", tables_default2.search).addMiddleware(
|
|
44296
44295
|
nameValidator()
|
|
44297
44296
|
)
|
|
44298
44297
|
);
|
|
44299
|
-
tables_default3 = { read: read6, write:
|
|
44298
|
+
tables_default3 = { read: read6, write: write5 };
|
|
44300
44299
|
}
|
|
44301
44300
|
});
|
|
44302
44301
|
|
|
@@ -44375,19 +44374,19 @@ var init_rows7 = __esm({
|
|
|
44375
44374
|
});
|
|
44376
44375
|
|
|
44377
44376
|
// src/api/routes/public/rows.ts
|
|
44378
|
-
var read8,
|
|
44377
|
+
var read8, write6, rows_default4;
|
|
44379
44378
|
var init_rows8 = __esm({
|
|
44380
44379
|
"src/api/routes/public/rows.ts"() {
|
|
44381
44380
|
init_rows7();
|
|
44382
44381
|
init_Endpoint();
|
|
44383
44382
|
init_validators();
|
|
44384
44383
|
read8 = [];
|
|
44385
|
-
|
|
44386
|
-
|
|
44387
|
-
|
|
44384
|
+
write6 = [];
|
|
44385
|
+
write6.push(new Endpoint_default("post", "/tables/:tableId/rows", rows_default3.create));
|
|
44386
|
+
write6.push(
|
|
44388
44387
|
new Endpoint_default("put", "/tables/:tableId/rows/:rowId", rows_default3.update)
|
|
44389
44388
|
);
|
|
44390
|
-
|
|
44389
|
+
write6.push(
|
|
44391
44390
|
new Endpoint_default("delete", "/tables/:tableId/rows/:rowId", rows_default3.destroy)
|
|
44392
44391
|
);
|
|
44393
44392
|
read8.push(new Endpoint_default("get", "/tables/:tableId/rows/:rowId", rows_default3.read));
|
|
@@ -44398,7 +44397,7 @@ var init_rows8 = __esm({
|
|
|
44398
44397
|
rows_default3.search
|
|
44399
44398
|
).addMiddleware(externalSearchValidator())
|
|
44400
44399
|
);
|
|
44401
|
-
rows_default4 = { read: read8, write:
|
|
44400
|
+
rows_default4 = { read: read8, write: write6 };
|
|
44402
44401
|
}
|
|
44403
44402
|
});
|
|
44404
44403
|
|
|
@@ -44419,9 +44418,9 @@ function getUser2(ctx, userId) {
|
|
|
44419
44418
|
return readGlobalUser(ctx);
|
|
44420
44419
|
}
|
|
44421
44420
|
async function search11(ctx, next) {
|
|
44422
|
-
const { name } = ctx.request.body;
|
|
44421
|
+
const { name: name2 } = ctx.request.body;
|
|
44423
44422
|
const users2 = await allGlobalUsers(ctx);
|
|
44424
|
-
ctx.body = search6(users2,
|
|
44423
|
+
ctx.body = search6(users2, name2, "email");
|
|
44425
44424
|
await next();
|
|
44426
44425
|
}
|
|
44427
44426
|
async function create12(ctx, next) {
|
|
@@ -44475,24 +44474,24 @@ var init_users14 = __esm({
|
|
|
44475
44474
|
});
|
|
44476
44475
|
|
|
44477
44476
|
// src/api/routes/public/users.ts
|
|
44478
|
-
var read10,
|
|
44477
|
+
var read10, write7, users_default3;
|
|
44479
44478
|
var init_users15 = __esm({
|
|
44480
44479
|
"src/api/routes/public/users.ts"() {
|
|
44481
44480
|
init_users14();
|
|
44482
44481
|
init_Endpoint();
|
|
44483
44482
|
init_validators();
|
|
44484
44483
|
read10 = [];
|
|
44485
|
-
|
|
44486
|
-
|
|
44487
|
-
|
|
44488
|
-
|
|
44484
|
+
write7 = [];
|
|
44485
|
+
write7.push(new Endpoint_default("post", "/users", users_default2.create));
|
|
44486
|
+
write7.push(new Endpoint_default("put", "/users/:userId", users_default2.update));
|
|
44487
|
+
write7.push(new Endpoint_default("delete", "/users/:userId", users_default2.destroy));
|
|
44489
44488
|
read10.push(new Endpoint_default("get", "/users/:userId", users_default2.read));
|
|
44490
44489
|
read10.push(
|
|
44491
44490
|
new Endpoint_default("post", "/users/search", users_default2.search).addMiddleware(
|
|
44492
44491
|
nameValidator()
|
|
44493
44492
|
)
|
|
44494
44493
|
);
|
|
44495
|
-
users_default3 = { read: read10, write:
|
|
44494
|
+
users_default3 = { read: read10, write: write7 };
|
|
44496
44495
|
}
|
|
44497
44496
|
});
|
|
44498
44497
|
|
|
@@ -45064,9 +45063,9 @@ function watch() {
|
|
|
45064
45063
|
await tenancy.doInTenant(constants_exports.DEFAULT_TENANT_ID, async () => {
|
|
45065
45064
|
try {
|
|
45066
45065
|
const split = path5.split("/");
|
|
45067
|
-
const
|
|
45066
|
+
const name2 = split[split.length - 1];
|
|
45068
45067
|
console.log("Importing plugin:", path5);
|
|
45069
|
-
await plugins_default.processUploaded({ name, path: path5 });
|
|
45068
|
+
await plugins_default.processUploaded({ name: name2, path: path5 });
|
|
45070
45069
|
} catch (err) {
|
|
45071
45070
|
const message = (err == null ? void 0 : err.message) ? err == null ? void 0 : err.message : err;
|
|
45072
45071
|
console.error("Failed to import plugin:", message);
|