@budibase/backend-core 2.32.6 → 2.32.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 +36 -24
- 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/configs/configs.d.ts +2 -1
- package/dist/src/configs/configs.js +7 -0
- package/dist/src/configs/configs.js.map +1 -1
- package/dist/src/sql/sql.js +29 -21
- package/dist/src/sql/sql.js.map +1 -1
- package/dist/src/sql/sqlTable.d.ts +3 -0
- package/dist/src/sql/sqlTable.js +9 -1
- package/dist/src/sql/sqlTable.js.map +1 -1
- package/dist/tests/core/utilities/mocks/licenses.d.ts +0 -1
- package/dist/tests/core/utilities/mocks/licenses.js +1 -5
- package/dist/tests/core/utilities/mocks/licenses.js.map +1 -1
- package/package.json +4 -4
- package/src/configs/configs.ts +7 -0
- package/src/sql/sql.ts +43 -31
- package/src/sql/sqlTable.ts +12 -1
- package/tests/core/utilities/mocks/licenses.ts +0 -4
package/dist/index.js
CHANGED
|
@@ -54228,6 +54228,7 @@ var configs_exports = {};
|
|
|
54228
54228
|
__export(configs_exports, {
|
|
54229
54229
|
analyticsEnabled: () => analyticsEnabled,
|
|
54230
54230
|
generateConfigID: () => generateConfigID,
|
|
54231
|
+
getAIConfig: () => getAIConfig,
|
|
54231
54232
|
getConfig: () => getConfig,
|
|
54232
54233
|
getDefaultGoogleConfig: () => getDefaultGoogleConfig,
|
|
54233
54234
|
getGoogleConfig: () => getGoogleConfig,
|
|
@@ -66198,6 +66199,9 @@ async function getSCIMConfig() {
|
|
|
66198
66199
|
const config = await getConfig("scim" /* SCIM */);
|
|
66199
66200
|
return config?.config;
|
|
66200
66201
|
}
|
|
66202
|
+
async function getAIConfig() {
|
|
66203
|
+
return getConfig("ai" /* AI */);
|
|
66204
|
+
}
|
|
66201
66205
|
|
|
66202
66206
|
// src/migrations/index.ts
|
|
66203
66207
|
var migrations_exports = {};
|
|
@@ -67984,9 +67988,17 @@ var SqlTableQueryBuilder = class {
|
|
|
67984
67988
|
constructor(client) {
|
|
67985
67989
|
this.sqlClient = client;
|
|
67986
67990
|
}
|
|
67987
|
-
|
|
67991
|
+
getBaseSqlClient() {
|
|
67988
67992
|
return this.sqlClient;
|
|
67989
67993
|
}
|
|
67994
|
+
getSqlClient() {
|
|
67995
|
+
return this.extendedSqlClient || this.sqlClient;
|
|
67996
|
+
}
|
|
67997
|
+
// if working in a database like MySQL with many variants (MariaDB)
|
|
67998
|
+
// we can set another client which overrides the base one
|
|
67999
|
+
setExtendedSqlClient(client) {
|
|
68000
|
+
this.extendedSqlClient = client;
|
|
68001
|
+
}
|
|
67990
68002
|
/**
|
|
67991
68003
|
* @param json the input JSON structure from which an SQL query will be built.
|
|
67992
68004
|
* @return the operation that was found in the JSON.
|
|
@@ -68138,6 +68150,7 @@ var InternalBuilder = class {
|
|
|
68138
68150
|
return `"${str}"`;
|
|
68139
68151
|
case "mssql" /* MS_SQL */:
|
|
68140
68152
|
return `[${str}]`;
|
|
68153
|
+
case "mariadb" /* MARIADB */:
|
|
68141
68154
|
case "mysql2" /* MY_SQL */:
|
|
68142
68155
|
return `\`${str}\``;
|
|
68143
68156
|
}
|
|
@@ -68445,7 +68458,7 @@ var InternalBuilder = class {
|
|
|
68445
68458
|
)}${wrap}, FALSE)`
|
|
68446
68459
|
);
|
|
68447
68460
|
});
|
|
68448
|
-
} else if (this.client === "mysql2" /* MY_SQL */) {
|
|
68461
|
+
} else if (this.client === "mysql2" /* MY_SQL */ || this.client === "mariadb" /* MARIADB */) {
|
|
68449
68462
|
const jsonFnc = any ? "JSON_OVERLAPS" : "JSON_CONTAINS";
|
|
68450
68463
|
iterate(mode, (q2, key, value) => {
|
|
68451
68464
|
return q2[rawFnc](
|
|
@@ -68748,7 +68761,7 @@ var InternalBuilder = class {
|
|
|
68748
68761
|
continue;
|
|
68749
68762
|
}
|
|
68750
68763
|
const relatedTable = meta.tables?.[toTable];
|
|
68751
|
-
const toAlias = aliases?.[toTable] || toTable, fromAlias = aliases?.[fromTable] || fromTable;
|
|
68764
|
+
const toAlias = aliases?.[toTable] || toTable, fromAlias = aliases?.[fromTable] || fromTable, throughAlias = throughTable && aliases?.[throughTable] || throughTable;
|
|
68752
68765
|
let toTableWithSchema = this.tableNameWithSchema(toTable, {
|
|
68753
68766
|
alias: toAlias,
|
|
68754
68767
|
schema: endpoint.schema
|
|
@@ -68767,29 +68780,25 @@ var InternalBuilder = class {
|
|
|
68767
68780
|
);
|
|
68768
68781
|
const fieldList = relationshipFields.map((field) => this.buildJsonField(field)).join(",");
|
|
68769
68782
|
const primaryKey = `${toAlias}.${toPrimary || toKey}`;
|
|
68770
|
-
let subQuery = knex3.from(toTableWithSchema).
|
|
68771
|
-
|
|
68772
|
-
|
|
68783
|
+
let subQuery = knex3.from(toTableWithSchema).orderBy(primaryKey);
|
|
68784
|
+
const isManyToMany = throughTable && toPrimary && fromPrimary;
|
|
68785
|
+
let correlatedTo = isManyToMany ? `${throughAlias}.${fromKey}` : `${toAlias}.${toKey}`, correlatedFrom = isManyToMany ? `${fromAlias}.${fromPrimary}` : `${fromAlias}.${fromKey}`;
|
|
68786
|
+
if (isManyToMany) {
|
|
68773
68787
|
let throughTableWithSchema = this.tableNameWithSchema(throughTable, {
|
|
68774
68788
|
alias: throughAlias,
|
|
68775
68789
|
schema: endpoint.schema
|
|
68776
68790
|
});
|
|
68777
68791
|
subQuery = subQuery.join(throughTableWithSchema, function() {
|
|
68778
68792
|
this.on(`${toAlias}.${toPrimary}`, "=", `${throughAlias}.${toKey}`);
|
|
68779
|
-
})
|
|
68780
|
-
`${throughAlias}.${fromKey}`,
|
|
68781
|
-
"=",
|
|
68782
|
-
knex3.raw(this.quotedIdentifier(`${fromAlias}.${fromPrimary}`))
|
|
68783
|
-
);
|
|
68784
|
-
} else {
|
|
68785
|
-
subQuery = subQuery.where(
|
|
68786
|
-
`${toAlias}.${toKey}`,
|
|
68787
|
-
"=",
|
|
68788
|
-
knex3.raw(this.quotedIdentifier(`${fromAlias}.${fromKey}`))
|
|
68789
|
-
);
|
|
68793
|
+
});
|
|
68790
68794
|
}
|
|
68795
|
+
subQuery = subQuery.where(
|
|
68796
|
+
correlatedTo,
|
|
68797
|
+
"=",
|
|
68798
|
+
knex3.raw(this.quotedIdentifier(correlatedFrom))
|
|
68799
|
+
);
|
|
68791
68800
|
const standardWrap = (select) => {
|
|
68792
|
-
subQuery = subQuery.select(`${toAlias}.*`);
|
|
68801
|
+
subQuery = subQuery.select(`${toAlias}.*`).limit(getRelationshipLimit());
|
|
68793
68802
|
return knex3.select(knex3.raw(select)).from({
|
|
68794
68803
|
[toAlias]: subQuery
|
|
68795
68804
|
});
|
|
@@ -68807,11 +68816,14 @@ var InternalBuilder = class {
|
|
|
68807
68816
|
`json_agg(json_build_object(${fieldList}))`
|
|
68808
68817
|
);
|
|
68809
68818
|
break;
|
|
68810
|
-
case "
|
|
68819
|
+
case "mariadb" /* MARIADB */:
|
|
68811
68820
|
wrapperQuery = subQuery.select(
|
|
68812
|
-
knex3.raw(
|
|
68821
|
+
knex3.raw(
|
|
68822
|
+
`json_arrayagg(json_object(${fieldList}) LIMIT ${getRelationshipLimit()})`
|
|
68823
|
+
)
|
|
68813
68824
|
);
|
|
68814
68825
|
break;
|
|
68826
|
+
case "mysql2" /* MY_SQL */:
|
|
68815
68827
|
case "oracledb" /* ORACLE */:
|
|
68816
68828
|
wrapperQuery = standardWrap(
|
|
68817
68829
|
`json_arrayagg(json_object(${fieldList}))`
|
|
@@ -68820,7 +68832,7 @@ var InternalBuilder = class {
|
|
|
68820
68832
|
case "mssql" /* MS_SQL */:
|
|
68821
68833
|
wrapperQuery = knex3.raw(
|
|
68822
68834
|
`(SELECT ${this.quote(toAlias)} = (${knex3.select(`${fromAlias}.*`).from({
|
|
68823
|
-
[fromAlias]: subQuery.select(`${toAlias}.*`)
|
|
68835
|
+
[fromAlias]: subQuery.select(`${toAlias}.*`).limit(getRelationshipLimit())
|
|
68824
68836
|
})} FOR JSON PATH))`
|
|
68825
68837
|
);
|
|
68826
68838
|
break;
|
|
@@ -68931,7 +68943,7 @@ var InternalBuilder = class {
|
|
|
68931
68943
|
return query;
|
|
68932
68944
|
}
|
|
68933
68945
|
const parsedBody = body2.map((row) => this.parseBody(row));
|
|
68934
|
-
if (this.client === "pg" /* POSTGRES */ || this.client === "sqlite3" /* SQL_LITE */ || this.client === "mysql2" /* MY_SQL */) {
|
|
68946
|
+
if (this.client === "pg" /* POSTGRES */ || this.client === "sqlite3" /* SQL_LITE */ || this.client === "mysql2" /* MY_SQL */ || this.client === "mariadb" /* MARIADB */) {
|
|
68935
68947
|
const primary = this.table.primary;
|
|
68936
68948
|
if (!primary) {
|
|
68937
68949
|
throw new Error("Primary key is required for upsert");
|
|
@@ -69035,7 +69047,7 @@ var SqlQueryBuilder = class extends sqlTable_default {
|
|
|
69035
69047
|
_query(json, opts = {}) {
|
|
69036
69048
|
const sqlClient = this.getSqlClient();
|
|
69037
69049
|
const config = {
|
|
69038
|
-
client:
|
|
69050
|
+
client: this.getBaseSqlClient()
|
|
69039
69051
|
};
|
|
69040
69052
|
if (sqlClient === "sqlite3" /* SQL_LITE */ || sqlClient === "oracledb" /* ORACLE */) {
|
|
69041
69053
|
config.useNullAsDefault = true;
|
|
@@ -69137,7 +69149,7 @@ var SqlQueryBuilder = class extends sqlTable_default {
|
|
|
69137
69149
|
let id;
|
|
69138
69150
|
if (sqlClient === "mssql" /* MS_SQL */) {
|
|
69139
69151
|
id = results?.[0].id;
|
|
69140
|
-
} else if (sqlClient === "mysql2" /* MY_SQL */) {
|
|
69152
|
+
} else if (sqlClient === "mysql2" /* MY_SQL */ || sqlClient === "mariadb" /* MARIADB */) {
|
|
69141
69153
|
id = results?.insertId;
|
|
69142
69154
|
}
|
|
69143
69155
|
row = processFn(
|