@budibase/backend-core 2.13.5 → 2.13.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +39 -23
- package/dist/index.js.map +4 -4
- package/dist/index.js.meta.json +1 -1
- package/dist/package.json +4 -4
- package/dist/plugins.js.meta.json +1 -1
- package/dist/src/cache/appMetadata.js.map +1 -1
- package/dist/src/constants/db.d.ts +1 -3
- package/dist/src/constants/db.js.map +1 -1
- package/dist/src/context/Context.d.ts +1 -1
- package/dist/src/context/Context.js.map +1 -1
- package/dist/src/context/identity.d.ts +3 -3
- package/dist/src/context/mainContext.d.ts +7 -7
- package/dist/src/context/mainContext.js +3 -0
- package/dist/src/context/mainContext.js.map +1 -1
- package/dist/src/db/couch/DatabaseImpl.d.ts +3 -3
- package/dist/src/db/couch/DatabaseImpl.js +0 -3
- package/dist/src/db/couch/DatabaseImpl.js.map +1 -1
- package/dist/src/db/db.d.ts +3 -4
- package/dist/src/db/db.js +2 -14
- package/dist/src/db/db.js.map +1 -1
- package/dist/src/db/views.d.ts +7 -7
- package/dist/src/db/views.js +4 -5
- package/dist/src/db/views.js.map +1 -1
- package/dist/src/index.d.ts +8 -8
- package/dist/src/users/db.js +1 -1
- package/dist/src/users/db.js.map +1 -1
- package/dist/src/users/users.js.map +1 -1
- package/dist/src/utils/utils.d.ts +1 -0
- package/dist/src/utils/utils.js +16 -1
- package/dist/src/utils/utils.js.map +1 -1
- package/package.json +4 -4
- package/src/cache/appMetadata.ts +1 -1
- package/src/constants/db.ts +1 -1
- package/src/context/Context.ts +1 -1
- package/src/context/mainContext.ts +13 -10
- package/src/db/couch/DatabaseImpl.ts +5 -6
- package/src/db/db.ts +3 -13
- package/src/db/views.ts +22 -23
- package/src/users/db.ts +4 -6
- package/src/users/users.ts +1 -1
- package/src/utils/tests/utils.spec.ts +13 -0
- package/src/utils/utils.ts +14 -0
package/dist/index.js
CHANGED
|
@@ -751,12 +751,20 @@ var init_user3 = __esm({
|
|
|
751
751
|
}
|
|
752
752
|
});
|
|
753
753
|
|
|
754
|
+
// ../types/src/documents/account/flag.ts
|
|
755
|
+
var init_flag = __esm({
|
|
756
|
+
"../types/src/documents/account/flag.ts"() {
|
|
757
|
+
"use strict";
|
|
758
|
+
}
|
|
759
|
+
});
|
|
760
|
+
|
|
754
761
|
// ../types/src/documents/account/index.ts
|
|
755
762
|
var init_account3 = __esm({
|
|
756
763
|
"../types/src/documents/account/index.ts"() {
|
|
757
764
|
"use strict";
|
|
758
765
|
init_account2();
|
|
759
766
|
init_user3();
|
|
767
|
+
init_flag();
|
|
760
768
|
}
|
|
761
769
|
});
|
|
762
770
|
|
|
@@ -1341,6 +1349,13 @@ var init_attachment = __esm({
|
|
|
1341
1349
|
}
|
|
1342
1350
|
});
|
|
1343
1351
|
|
|
1352
|
+
// ../types/src/api/web/app/user.ts
|
|
1353
|
+
var init_user8 = __esm({
|
|
1354
|
+
"../types/src/api/web/app/user.ts"() {
|
|
1355
|
+
"use strict";
|
|
1356
|
+
}
|
|
1357
|
+
});
|
|
1358
|
+
|
|
1344
1359
|
// ../types/src/api/web/app/index.ts
|
|
1345
1360
|
var init_app4 = __esm({
|
|
1346
1361
|
"../types/src/api/web/app/index.ts"() {
|
|
@@ -1353,6 +1368,7 @@ var init_app4 = __esm({
|
|
|
1353
1368
|
init_table4();
|
|
1354
1369
|
init_permission();
|
|
1355
1370
|
init_attachment();
|
|
1371
|
+
init_user8();
|
|
1356
1372
|
}
|
|
1357
1373
|
});
|
|
1358
1374
|
|
|
@@ -2207,9 +2223,6 @@ var init_DatabaseImpl = __esm({
|
|
|
2207
2223
|
DatabaseImpl = class _DatabaseImpl {
|
|
2208
2224
|
constructor(dbName, opts, connection) {
|
|
2209
2225
|
this.couchInfo = getCouchInfo();
|
|
2210
|
-
if (dbName == null) {
|
|
2211
|
-
throw new Error("Database name cannot be undefined.");
|
|
2212
|
-
}
|
|
2213
2226
|
this.name = dbName;
|
|
2214
2227
|
this.pouchOpts = opts || {};
|
|
2215
2228
|
if (connection) {
|
|
@@ -2404,16 +2417,10 @@ var init_couch = __esm({
|
|
|
2404
2417
|
function getDB(dbName, opts) {
|
|
2405
2418
|
return new DatabaseImpl(dbName, opts);
|
|
2406
2419
|
}
|
|
2407
|
-
async function doWithDB(dbName, cb, opts
|
|
2420
|
+
async function doWithDB(dbName, cb, opts) {
|
|
2408
2421
|
const db = getDB(dbName, opts);
|
|
2409
2422
|
return await cb(db);
|
|
2410
2423
|
}
|
|
2411
|
-
function allDbs() {
|
|
2412
|
-
if (!environment_default.isTest()) {
|
|
2413
|
-
throw new Error("Cannot be used outside test environment.");
|
|
2414
|
-
}
|
|
2415
|
-
return [...dbList];
|
|
2416
|
-
}
|
|
2417
2424
|
async function directCouchAllDbs(queryString) {
|
|
2418
2425
|
let couchPath = "/_all_dbs";
|
|
2419
2426
|
if (queryString) {
|
|
@@ -2425,13 +2432,10 @@ async function directCouchFind(dbName, opts) {
|
|
|
2425
2432
|
const json = await directCouchQuery(`${dbName}/_find`, "POST", opts);
|
|
2426
2433
|
return { rows: json.docs, bookmark: json.bookmark };
|
|
2427
2434
|
}
|
|
2428
|
-
var dbList;
|
|
2429
2435
|
var init_db3 = __esm({
|
|
2430
2436
|
"src/db/db.ts"() {
|
|
2431
2437
|
"use strict";
|
|
2432
|
-
init_environment2();
|
|
2433
2438
|
init_couch();
|
|
2434
|
-
dbList = /* @__PURE__ */ new Set();
|
|
2435
2439
|
}
|
|
2436
2440
|
});
|
|
2437
2441
|
|
|
@@ -2632,6 +2636,9 @@ function getAuditLogsDB() {
|
|
|
2632
2636
|
}
|
|
2633
2637
|
function getAppDB(opts) {
|
|
2634
2638
|
const appId = getAppId();
|
|
2639
|
+
if (!appId) {
|
|
2640
|
+
throw new Error("Unable to retrieve app DB - no app ID.");
|
|
2641
|
+
}
|
|
2635
2642
|
return getDB(appId, opts);
|
|
2636
2643
|
}
|
|
2637
2644
|
function getProdAppDB(opts) {
|
|
@@ -3753,7 +3760,7 @@ async function removeDeprecated(db, viewName) {
|
|
|
3753
3760
|
try {
|
|
3754
3761
|
const designDoc = await db.get(DESIGN_DB);
|
|
3755
3762
|
for (let deprecatedNames of DeprecatedViews[viewName]) {
|
|
3756
|
-
delete designDoc.views[deprecatedNames];
|
|
3763
|
+
delete designDoc.views?.[deprecatedNames];
|
|
3757
3764
|
}
|
|
3758
3765
|
await db.put(designDoc);
|
|
3759
3766
|
} catch (err) {
|
|
@@ -3860,9 +3867,7 @@ var init_views = __esm({
|
|
|
3860
3867
|
queryView = async (viewName, params2, db, createFunc, opts) => {
|
|
3861
3868
|
const response = await queryViewRaw(viewName, params2, db, createFunc, opts);
|
|
3862
3869
|
const rows = response.rows;
|
|
3863
|
-
const docs = rows.map(
|
|
3864
|
-
(row) => params2.include_docs ? row.doc : row.value
|
|
3865
|
-
);
|
|
3870
|
+
const docs = rows.map((row) => params2.include_docs ? row.doc : row.value);
|
|
3866
3871
|
if (opts?.arrayResponse) {
|
|
3867
3872
|
return docs;
|
|
3868
3873
|
} else {
|
|
@@ -4660,7 +4665,6 @@ __export(db_exports, {
|
|
|
4660
4665
|
StaticDatabases: () => StaticDatabases,
|
|
4661
4666
|
UNICODE_MAX: () => UNICODE_MAX,
|
|
4662
4667
|
ViewName: () => ViewName,
|
|
4663
|
-
allDbs: () => allDbs,
|
|
4664
4668
|
baseGlobalDBName: () => baseGlobalDBName,
|
|
4665
4669
|
checkErrorCode: () => checkErrorCode,
|
|
4666
4670
|
closePouchDB: () => closePouchDB,
|
|
@@ -7344,6 +7348,7 @@ __export(utils_exports3, {
|
|
|
7344
7348
|
compare: () => compare,
|
|
7345
7349
|
getAppIdFromCtx: () => getAppIdFromCtx,
|
|
7346
7350
|
getCookie: () => getCookie,
|
|
7351
|
+
hasCircularStructure: () => hasCircularStructure,
|
|
7347
7352
|
hash: () => hash,
|
|
7348
7353
|
isAudited: () => isAudited,
|
|
7349
7354
|
isClient: () => isClient,
|
|
@@ -7516,6 +7521,19 @@ function timeout(timeMs) {
|
|
|
7516
7521
|
function isAudited(event) {
|
|
7517
7522
|
return !!AuditedEventFriendlyName[event];
|
|
7518
7523
|
}
|
|
7524
|
+
function hasCircularStructure(json) {
|
|
7525
|
+
if (typeof json !== "object") {
|
|
7526
|
+
return false;
|
|
7527
|
+
}
|
|
7528
|
+
try {
|
|
7529
|
+
JSON.stringify(json);
|
|
7530
|
+
} catch (err) {
|
|
7531
|
+
if (err instanceof Error && err?.message.includes("circular structure")) {
|
|
7532
|
+
return true;
|
|
7533
|
+
}
|
|
7534
|
+
}
|
|
7535
|
+
return false;
|
|
7536
|
+
}
|
|
7519
7537
|
|
|
7520
7538
|
// src/utils/stringUtils.ts
|
|
7521
7539
|
function validEmail(value) {
|
|
@@ -10195,11 +10213,9 @@ var UserDB = class _UserDB {
|
|
|
10195
10213
|
include_docs: true,
|
|
10196
10214
|
keys: userIds
|
|
10197
10215
|
});
|
|
10198
|
-
const usersToDelete = allDocsResponse.rows.map(
|
|
10199
|
-
|
|
10200
|
-
|
|
10201
|
-
}
|
|
10202
|
-
);
|
|
10216
|
+
const usersToDelete = allDocsResponse.rows.map((user) => {
|
|
10217
|
+
return user.doc;
|
|
10218
|
+
});
|
|
10203
10219
|
const toDelete = usersToDelete.map((user) => ({
|
|
10204
10220
|
...user,
|
|
10205
10221
|
_deleted: true
|