@budibase/backend-core 2.29.23 → 2.29.25
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 +42 -12
- package/dist/index.js.map +2 -2
- 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/db/couch/DatabaseImpl.d.ts +3 -0
- package/dist/src/db/couch/DatabaseImpl.js +30 -4
- package/dist/src/db/couch/DatabaseImpl.js.map +1 -1
- package/dist/src/db/instrumentation.d.ts +3 -0
- package/dist/src/db/instrumentation.js +6 -0
- package/dist/src/db/instrumentation.js.map +1 -1
- package/dist/src/platform/users.js +1 -4
- package/dist/src/platform/users.js.map +1 -1
- package/package.json +4 -4
- package/src/db/couch/DatabaseImpl.ts +39 -10
- package/src/db/instrumentation.ts +10 -0
- package/src/platform/users.ts +5 -8
package/dist/index.js
CHANGED
|
@@ -55378,7 +55378,7 @@ var runQuery = (docs, query) => {
|
|
|
55378
55378
|
if (Array.isArray(docValue)) {
|
|
55379
55379
|
return docValue.length === 0;
|
|
55380
55380
|
}
|
|
55381
|
-
if (typeof docValue === "object") {
|
|
55381
|
+
if (docValue && typeof docValue === "object") {
|
|
55382
55382
|
return Object.keys(docValue).length === 0;
|
|
55383
55383
|
}
|
|
55384
55384
|
return docValue == null;
|
|
@@ -56464,6 +56464,12 @@ var DDInstrumentedDatabase = class {
|
|
|
56464
56464
|
return this.db.remove(id, rev);
|
|
56465
56465
|
});
|
|
56466
56466
|
}
|
|
56467
|
+
bulkRemove(documents, opts) {
|
|
56468
|
+
return import_dd_trace.default.trace("db.bulkRemove", (span) => {
|
|
56469
|
+
span?.addTags({ db_name: this.name, num_docs: documents.length });
|
|
56470
|
+
return this.db.bulkRemove(documents, opts);
|
|
56471
|
+
});
|
|
56472
|
+
}
|
|
56467
56473
|
put(document, opts) {
|
|
56468
56474
|
return import_dd_trace.default.trace("db.put", (span) => {
|
|
56469
56475
|
span?.addTags({ db_name: this.name, doc_id: document._id });
|
|
@@ -59578,11 +59584,11 @@ var CouchDBError = class extends Error {
|
|
|
59578
59584
|
const statusCode = info.status || info.statusCode || 500;
|
|
59579
59585
|
this.status = statusCode;
|
|
59580
59586
|
this.statusCode = statusCode;
|
|
59581
|
-
this.reason = info.reason;
|
|
59587
|
+
this.reason = info.reason || "Unknown";
|
|
59582
59588
|
this.name = info.name;
|
|
59583
|
-
this.errid = info.errid;
|
|
59584
|
-
this.description = info.description;
|
|
59585
|
-
this.error = info.error;
|
|
59589
|
+
this.errid = info.errid || "Unknown";
|
|
59590
|
+
this.description = info.description || "Unknown";
|
|
59591
|
+
this.error = info.error || "Not found";
|
|
59586
59592
|
}
|
|
59587
59593
|
};
|
|
59588
59594
|
function DatabaseWithConnection(dbName, connection, opts) {
|
|
@@ -59716,6 +59722,33 @@ var DatabaseImpl = class _DatabaseImpl {
|
|
|
59716
59722
|
return () => db.destroy(_id, _rev);
|
|
59717
59723
|
});
|
|
59718
59724
|
}
|
|
59725
|
+
async bulkRemove(documents, opts) {
|
|
59726
|
+
const response = await this.performCall((db) => {
|
|
59727
|
+
return () => db.bulk({
|
|
59728
|
+
docs: documents.map((doc) => ({
|
|
59729
|
+
...doc,
|
|
59730
|
+
_deleted: true
|
|
59731
|
+
}))
|
|
59732
|
+
});
|
|
59733
|
+
});
|
|
59734
|
+
if (opts?.silenceErrors) {
|
|
59735
|
+
return;
|
|
59736
|
+
}
|
|
59737
|
+
let errorFound = false;
|
|
59738
|
+
let errorMessage = "Unable to bulk remove documents: ";
|
|
59739
|
+
for (let res of response) {
|
|
59740
|
+
if (res.error) {
|
|
59741
|
+
errorFound = true;
|
|
59742
|
+
errorMessage += res.error;
|
|
59743
|
+
}
|
|
59744
|
+
}
|
|
59745
|
+
if (errorFound) {
|
|
59746
|
+
throw new CouchDBError(errorMessage, {
|
|
59747
|
+
name: this.name,
|
|
59748
|
+
status: 400
|
|
59749
|
+
});
|
|
59750
|
+
}
|
|
59751
|
+
}
|
|
59719
59752
|
async post(document, opts) {
|
|
59720
59753
|
if (!document._id) {
|
|
59721
59754
|
document._id = newid();
|
|
@@ -60524,13 +60557,10 @@ async function removeUser(user) {
|
|
|
60524
60557
|
keys: keys2,
|
|
60525
60558
|
include_docs: true
|
|
60526
60559
|
});
|
|
60527
|
-
|
|
60528
|
-
|
|
60529
|
-
|
|
60530
|
-
|
|
60531
|
-
};
|
|
60532
|
-
});
|
|
60533
|
-
await db.bulkDocs(toDelete);
|
|
60560
|
+
await db.bulkRemove(
|
|
60561
|
+
userDocs.rows.map((row) => row.doc),
|
|
60562
|
+
{ silenceErrors: true }
|
|
60563
|
+
);
|
|
60534
60564
|
}
|
|
60535
60565
|
|
|
60536
60566
|
// src/platform/tenants.ts
|