@budibase/backend-core 2.13.5 → 2.13.7
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 +55 -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 +7 -4
- package/dist/src/db/couch/DatabaseImpl.js +20 -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 +28 -7
- 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) {
|
|
@@ -2269,6 +2282,22 @@ var init_DatabaseImpl = __esm({
|
|
|
2269
2282
|
}
|
|
2270
2283
|
return this.updateOutput(() => db.get(id));
|
|
2271
2284
|
}
|
|
2285
|
+
async getMultiple(ids, opts) {
|
|
2286
|
+
ids = [...new Set(ids)];
|
|
2287
|
+
const response = await this.allDocs({
|
|
2288
|
+
keys: ids,
|
|
2289
|
+
include_docs: true
|
|
2290
|
+
});
|
|
2291
|
+
const NOT_FOUND = "not_found";
|
|
2292
|
+
const rows = response.rows.filter((row) => row.error !== NOT_FOUND);
|
|
2293
|
+
const someMissing = rows.length !== response.rows.length;
|
|
2294
|
+
if (!opts?.allowMissing && someMissing) {
|
|
2295
|
+
const missing = response.rows.filter((row) => row.error === NOT_FOUND);
|
|
2296
|
+
const missingIds = missing.map((row) => row.key).join(", ");
|
|
2297
|
+
throw new Error(`Unable to get documents: ${missingIds}`);
|
|
2298
|
+
}
|
|
2299
|
+
return rows.map((row) => row.doc);
|
|
2300
|
+
}
|
|
2272
2301
|
async remove(idOrDoc, rev) {
|
|
2273
2302
|
const db = await this.checkSetup();
|
|
2274
2303
|
let _id;
|
|
@@ -2404,16 +2433,10 @@ var init_couch = __esm({
|
|
|
2404
2433
|
function getDB(dbName, opts) {
|
|
2405
2434
|
return new DatabaseImpl(dbName, opts);
|
|
2406
2435
|
}
|
|
2407
|
-
async function doWithDB(dbName, cb, opts
|
|
2436
|
+
async function doWithDB(dbName, cb, opts) {
|
|
2408
2437
|
const db = getDB(dbName, opts);
|
|
2409
2438
|
return await cb(db);
|
|
2410
2439
|
}
|
|
2411
|
-
function allDbs() {
|
|
2412
|
-
if (!environment_default.isTest()) {
|
|
2413
|
-
throw new Error("Cannot be used outside test environment.");
|
|
2414
|
-
}
|
|
2415
|
-
return [...dbList];
|
|
2416
|
-
}
|
|
2417
2440
|
async function directCouchAllDbs(queryString) {
|
|
2418
2441
|
let couchPath = "/_all_dbs";
|
|
2419
2442
|
if (queryString) {
|
|
@@ -2425,13 +2448,10 @@ async function directCouchFind(dbName, opts) {
|
|
|
2425
2448
|
const json = await directCouchQuery(`${dbName}/_find`, "POST", opts);
|
|
2426
2449
|
return { rows: json.docs, bookmark: json.bookmark };
|
|
2427
2450
|
}
|
|
2428
|
-
var dbList;
|
|
2429
2451
|
var init_db3 = __esm({
|
|
2430
2452
|
"src/db/db.ts"() {
|
|
2431
2453
|
"use strict";
|
|
2432
|
-
init_environment2();
|
|
2433
2454
|
init_couch();
|
|
2434
|
-
dbList = /* @__PURE__ */ new Set();
|
|
2435
2455
|
}
|
|
2436
2456
|
});
|
|
2437
2457
|
|
|
@@ -2632,6 +2652,9 @@ function getAuditLogsDB() {
|
|
|
2632
2652
|
}
|
|
2633
2653
|
function getAppDB(opts) {
|
|
2634
2654
|
const appId = getAppId();
|
|
2655
|
+
if (!appId) {
|
|
2656
|
+
throw new Error("Unable to retrieve app DB - no app ID.");
|
|
2657
|
+
}
|
|
2635
2658
|
return getDB(appId, opts);
|
|
2636
2659
|
}
|
|
2637
2660
|
function getProdAppDB(opts) {
|
|
@@ -3753,7 +3776,7 @@ async function removeDeprecated(db, viewName) {
|
|
|
3753
3776
|
try {
|
|
3754
3777
|
const designDoc = await db.get(DESIGN_DB);
|
|
3755
3778
|
for (let deprecatedNames of DeprecatedViews[viewName]) {
|
|
3756
|
-
delete designDoc.views[deprecatedNames];
|
|
3779
|
+
delete designDoc.views?.[deprecatedNames];
|
|
3757
3780
|
}
|
|
3758
3781
|
await db.put(designDoc);
|
|
3759
3782
|
} catch (err) {
|
|
@@ -3860,9 +3883,7 @@ var init_views = __esm({
|
|
|
3860
3883
|
queryView = async (viewName, params2, db, createFunc, opts) => {
|
|
3861
3884
|
const response = await queryViewRaw(viewName, params2, db, createFunc, opts);
|
|
3862
3885
|
const rows = response.rows;
|
|
3863
|
-
const docs = rows.map(
|
|
3864
|
-
(row) => params2.include_docs ? row.doc : row.value
|
|
3865
|
-
);
|
|
3886
|
+
const docs = rows.map((row) => params2.include_docs ? row.doc : row.value);
|
|
3866
3887
|
if (opts?.arrayResponse) {
|
|
3867
3888
|
return docs;
|
|
3868
3889
|
} else {
|
|
@@ -4660,7 +4681,6 @@ __export(db_exports, {
|
|
|
4660
4681
|
StaticDatabases: () => StaticDatabases,
|
|
4661
4682
|
UNICODE_MAX: () => UNICODE_MAX,
|
|
4662
4683
|
ViewName: () => ViewName,
|
|
4663
|
-
allDbs: () => allDbs,
|
|
4664
4684
|
baseGlobalDBName: () => baseGlobalDBName,
|
|
4665
4685
|
checkErrorCode: () => checkErrorCode,
|
|
4666
4686
|
closePouchDB: () => closePouchDB,
|
|
@@ -7344,6 +7364,7 @@ __export(utils_exports3, {
|
|
|
7344
7364
|
compare: () => compare,
|
|
7345
7365
|
getAppIdFromCtx: () => getAppIdFromCtx,
|
|
7346
7366
|
getCookie: () => getCookie,
|
|
7367
|
+
hasCircularStructure: () => hasCircularStructure,
|
|
7347
7368
|
hash: () => hash,
|
|
7348
7369
|
isAudited: () => isAudited,
|
|
7349
7370
|
isClient: () => isClient,
|
|
@@ -7516,6 +7537,19 @@ function timeout(timeMs) {
|
|
|
7516
7537
|
function isAudited(event) {
|
|
7517
7538
|
return !!AuditedEventFriendlyName[event];
|
|
7518
7539
|
}
|
|
7540
|
+
function hasCircularStructure(json) {
|
|
7541
|
+
if (typeof json !== "object") {
|
|
7542
|
+
return false;
|
|
7543
|
+
}
|
|
7544
|
+
try {
|
|
7545
|
+
JSON.stringify(json);
|
|
7546
|
+
} catch (err) {
|
|
7547
|
+
if (err instanceof Error && err?.message.includes("circular structure")) {
|
|
7548
|
+
return true;
|
|
7549
|
+
}
|
|
7550
|
+
}
|
|
7551
|
+
return false;
|
|
7552
|
+
}
|
|
7519
7553
|
|
|
7520
7554
|
// src/utils/stringUtils.ts
|
|
7521
7555
|
function validEmail(value) {
|
|
@@ -10195,11 +10229,9 @@ var UserDB = class _UserDB {
|
|
|
10195
10229
|
include_docs: true,
|
|
10196
10230
|
keys: userIds
|
|
10197
10231
|
});
|
|
10198
|
-
const usersToDelete = allDocsResponse.rows.map(
|
|
10199
|
-
|
|
10200
|
-
|
|
10201
|
-
}
|
|
10202
|
-
);
|
|
10232
|
+
const usersToDelete = allDocsResponse.rows.map((user) => {
|
|
10233
|
+
return user.doc;
|
|
10234
|
+
});
|
|
10203
10235
|
const toDelete = usersToDelete.map((user) => ({
|
|
10204
10236
|
...user,
|
|
10205
10237
|
_deleted: true
|