@budibase/backend-core 2.22.16 → 2.22.19
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 +49 -14
- 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.map +1 -1
- package/dist/plugins.js.meta.json +1 -1
- package/dist/src/constants/db.d.ts +1 -0
- package/dist/src/constants/db.js +2 -1
- package/dist/src/constants/db.js.map +1 -1
- package/dist/src/db/couch/DatabaseImpl.d.ts +1 -0
- package/dist/src/db/couch/DatabaseImpl.js +17 -0
- package/dist/src/db/couch/DatabaseImpl.js.map +1 -1
- package/dist/src/db/couch/connections.d.ts +1 -0
- package/dist/src/db/couch/connections.js +1 -0
- package/dist/src/db/couch/connections.js.map +1 -1
- package/dist/src/db/couch/utils.js +8 -2
- package/dist/src/db/couch/utils.js.map +1 -1
- package/dist/src/db/instrumentation.d.ts +1 -0
- package/dist/src/db/instrumentation.js +6 -0
- package/dist/src/db/instrumentation.js.map +1 -1
- package/dist/src/db/lucene.d.ts +12 -71
- package/dist/src/db/lucene.js +10 -48
- package/dist/src/db/lucene.js.map +1 -1
- package/dist/src/index.d.ts +0 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/users/db.d.ts +2 -1
- package/dist/src/users/db.js +2 -1
- package/dist/src/users/db.js.map +1 -1
- package/package.json +4 -4
- package/src/constants/db.ts +1 -0
- package/src/db/couch/DatabaseImpl.ts +16 -0
- package/src/db/couch/connections.ts +1 -0
- package/src/db/couch/utils.ts +7 -2
- package/src/db/instrumentation.ts +7 -0
- package/src/db/lucene.ts +43 -78
- package/src/db/tests/lucene.spec.ts +47 -15
- package/src/index.ts +0 -1
- package/src/users/db.ts +2 -1
package/dist/index.js
CHANGED
|
@@ -54138,6 +54138,7 @@ __export(src_exports, {
|
|
|
54138
54138
|
NotFoundError: () => NotFoundError,
|
|
54139
54139
|
RedisClient: () => redis_default,
|
|
54140
54140
|
SEPARATOR: () => SEPARATOR,
|
|
54141
|
+
SQLITE_DESIGN_DOC_ID: () => SQLITE_DESIGN_DOC_ID,
|
|
54141
54142
|
StaticDatabases: () => StaticDatabases,
|
|
54142
54143
|
UNICODE_MAX: () => UNICODE_MAX,
|
|
54143
54144
|
UsageLimitError: () => UsageLimitError,
|
|
@@ -54632,6 +54633,7 @@ __export(constants_exports2, {
|
|
|
54632
54633
|
MAX_VALID_DATE: () => MAX_VALID_DATE,
|
|
54633
54634
|
MIN_VALID_DATE: () => MIN_VALID_DATE,
|
|
54634
54635
|
SEPARATOR: () => SEPARATOR,
|
|
54636
|
+
SQLITE_DESIGN_DOC_ID: () => SQLITE_DESIGN_DOC_ID,
|
|
54635
54637
|
StaticDatabases: () => StaticDatabases,
|
|
54636
54638
|
UNICODE_MAX: () => UNICODE_MAX,
|
|
54637
54639
|
UserStatus: () => UserStatus,
|
|
@@ -54693,6 +54695,7 @@ var APP_PREFIX = prefixed("app" /* APP */);
|
|
|
54693
54695
|
var APP_DEV = prefixed("app_dev" /* APP_DEV */);
|
|
54694
54696
|
var APP_DEV_PREFIX = APP_DEV;
|
|
54695
54697
|
var BUDIBASE_DATASOURCE_TYPE = "budibase";
|
|
54698
|
+
var SQLITE_DESIGN_DOC_ID = "_design/sqlite";
|
|
54696
54699
|
|
|
54697
54700
|
// ../shared-core/src/constants/api.ts
|
|
54698
54701
|
var Header = /* @__PURE__ */ ((Header2) => {
|
|
@@ -55419,6 +55422,7 @@ var getCouchInfo = (connection) => {
|
|
|
55419
55422
|
const authCookie = Buffer.from(`${username}:${password}`).toString("base64");
|
|
55420
55423
|
return {
|
|
55421
55424
|
url: urlInfo.url,
|
|
55425
|
+
sqlUrl: environment_default.COUCH_DB_SQL_URL,
|
|
55422
55426
|
auth: {
|
|
55423
55427
|
username,
|
|
55424
55428
|
password
|
|
@@ -55491,8 +55495,13 @@ async function directCouchUrlCall({
|
|
|
55491
55495
|
}
|
|
55492
55496
|
};
|
|
55493
55497
|
if (body2 && method !== "GET") {
|
|
55494
|
-
|
|
55495
|
-
|
|
55498
|
+
if (typeof body2 === "string") {
|
|
55499
|
+
params2.body = body2;
|
|
55500
|
+
params2.headers["Content-Type"] = "text/plain";
|
|
55501
|
+
} else {
|
|
55502
|
+
params2.body = JSON.stringify(body2);
|
|
55503
|
+
params2.headers["Content-Type"] = "application/json";
|
|
55504
|
+
}
|
|
55496
55505
|
}
|
|
55497
55506
|
return await (0, import_node_fetch.default)(checkSlashesInUrl(encodeURI(url)), params2);
|
|
55498
55507
|
}
|
|
@@ -55691,6 +55700,12 @@ var DDInstrumentedDatabase = class {
|
|
|
55691
55700
|
return this.db.getIndexes(...args);
|
|
55692
55701
|
});
|
|
55693
55702
|
}
|
|
55703
|
+
sql(sql) {
|
|
55704
|
+
return import_dd_trace.default.trace("db.sql", (span) => {
|
|
55705
|
+
span?.addTags({ db_name: this.name });
|
|
55706
|
+
return this.db.sql(sql);
|
|
55707
|
+
});
|
|
55708
|
+
}
|
|
55694
55709
|
};
|
|
55695
55710
|
|
|
55696
55711
|
// src/db/couch/DatabaseImpl.ts
|
|
@@ -55874,6 +55889,20 @@ var DatabaseImpl = class _DatabaseImpl {
|
|
|
55874
55889
|
return () => db.list(params2);
|
|
55875
55890
|
});
|
|
55876
55891
|
}
|
|
55892
|
+
async sql(sql) {
|
|
55893
|
+
const dbName = this.name;
|
|
55894
|
+
const url = `/${dbName}/${SQLITE_DESIGN_DOC_ID}`;
|
|
55895
|
+
const response = await directCouchUrlCall({
|
|
55896
|
+
url: `${this.couchInfo.sqlUrl}/${url}`,
|
|
55897
|
+
method: "POST",
|
|
55898
|
+
cookie: this.couchInfo.cookie,
|
|
55899
|
+
body: sql
|
|
55900
|
+
});
|
|
55901
|
+
if (response.status > 300) {
|
|
55902
|
+
throw new Error(await response.text());
|
|
55903
|
+
}
|
|
55904
|
+
return await response.json();
|
|
55905
|
+
}
|
|
55877
55906
|
async query(viewName, params2) {
|
|
55878
55907
|
return this.performCall((db) => {
|
|
55879
55908
|
const [database, view] = viewName.split("/");
|
|
@@ -56492,6 +56521,7 @@ __export(db_exports, {
|
|
|
56492
56521
|
QueryBuilder: () => QueryBuilder,
|
|
56493
56522
|
Replication: () => Replication_default,
|
|
56494
56523
|
SEPARATOR: () => SEPARATOR,
|
|
56524
|
+
SQLITE_DESIGN_DOC_ID: () => SQLITE_DESIGN_DOC_ID,
|
|
56495
56525
|
StaticDatabases: () => StaticDatabases,
|
|
56496
56526
|
UNICODE_MAX: () => UNICODE_MAX,
|
|
56497
56527
|
ViewName: () => ViewName,
|
|
@@ -57327,14 +57357,12 @@ var QueryBuilder = class _QueryBuilder {
|
|
|
57327
57357
|
return input.replace(/ /g, "_");
|
|
57328
57358
|
}
|
|
57329
57359
|
}
|
|
57330
|
-
|
|
57331
|
-
|
|
57332
|
-
|
|
57333
|
-
|
|
57334
|
-
|
|
57335
|
-
|
|
57336
|
-
*/
|
|
57337
|
-
preprocess(value, { escape, lowercase, wrap, type } = {}) {
|
|
57360
|
+
preprocess(value, {
|
|
57361
|
+
escape,
|
|
57362
|
+
lowercase,
|
|
57363
|
+
wrap,
|
|
57364
|
+
type
|
|
57365
|
+
} = {}) {
|
|
57338
57366
|
const hasVersion = !!this.#version;
|
|
57339
57367
|
const originalType = typeof value;
|
|
57340
57368
|
if (value && lowercase) {
|
|
@@ -57641,14 +57669,19 @@ async function runQuery(url, body2, cookie) {
|
|
|
57641
57669
|
async function recursiveSearch(dbName, index2, query, params2) {
|
|
57642
57670
|
const bookmark = params2.bookmark;
|
|
57643
57671
|
const rows = params2.rows || [];
|
|
57644
|
-
if (rows.length >= params2.limit) {
|
|
57672
|
+
if (params2.limit && rows.length >= params2.limit) {
|
|
57645
57673
|
return rows;
|
|
57646
57674
|
}
|
|
57647
57675
|
let pageSize = QueryBuilder.maxLimit;
|
|
57648
|
-
if (rows.length > params2.limit - QueryBuilder.maxLimit) {
|
|
57676
|
+
if (params2.limit && rows.length > params2.limit - QueryBuilder.maxLimit) {
|
|
57649
57677
|
pageSize = params2.limit - rows.length;
|
|
57650
57678
|
}
|
|
57651
|
-
const
|
|
57679
|
+
const queryBuilder = new QueryBuilder(dbName, index2, query);
|
|
57680
|
+
queryBuilder.setVersion(params2.version).setBookmark(bookmark).setLimit(pageSize).setSort(params2.sort).setSortOrder(params2.sortOrder).setSortType(params2.sortType);
|
|
57681
|
+
if (params2.tableId) {
|
|
57682
|
+
queryBuilder.setTable(params2.tableId);
|
|
57683
|
+
}
|
|
57684
|
+
const page = await queryBuilder.run();
|
|
57652
57685
|
if (!page.rows.length) {
|
|
57653
57686
|
return rows;
|
|
57654
57687
|
}
|
|
@@ -63618,7 +63651,8 @@ var UserDB = class _UserDB {
|
|
|
63618
63651
|
await user_exports.invalidateUser(userId);
|
|
63619
63652
|
await invalidateSessions(userId, { reason: "deletion" });
|
|
63620
63653
|
}
|
|
63621
|
-
static async createAdminUser(email, tenantId,
|
|
63654
|
+
static async createAdminUser(email, tenantId, opts) {
|
|
63655
|
+
const password = opts?.password;
|
|
63622
63656
|
const user = {
|
|
63623
63657
|
email,
|
|
63624
63658
|
password,
|
|
@@ -66091,6 +66125,7 @@ var init9 = (opts = {}) => {
|
|
|
66091
66125
|
NotFoundError,
|
|
66092
66126
|
RedisClient,
|
|
66093
66127
|
SEPARATOR,
|
|
66128
|
+
SQLITE_DESIGN_DOC_ID,
|
|
66094
66129
|
StaticDatabases,
|
|
66095
66130
|
UNICODE_MAX,
|
|
66096
66131
|
UsageLimitError,
|