@budibase/backend-core 3.2.38 → 3.2.40
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 +70 -32
- package/dist/index.js.map +3 -3
- package/dist/index.js.meta.json +1 -1
- package/dist/package.json +2 -2
- package/dist/plugins.js.meta.json +1 -1
- package/dist/src/features/features.d.ts +2 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -11598,7 +11598,9 @@ var TenantResolutionStrategy = /* @__PURE__ */ ((TenantResolutionStrategy2) => {
|
|
|
11598
11598
|
|
|
11599
11599
|
// ../types/src/sdk/featureFlag.ts
|
|
11600
11600
|
var FeatureFlagDefaults = {
|
|
11601
|
-
["USE_ZOD_VALIDATOR" /* USE_ZOD_VALIDATOR */]: false
|
|
11601
|
+
["USE_ZOD_VALIDATOR" /* USE_ZOD_VALIDATOR */]: false,
|
|
11602
|
+
// Account-portal
|
|
11603
|
+
["DIRECT_LOGIN_TO_ACCOUNT_PORTAL" /* DIRECT_LOGIN_TO_ACCOUNT_PORTAL */]: false
|
|
11602
11604
|
};
|
|
11603
11605
|
|
|
11604
11606
|
// ../types/src/sdk/cli/constants.ts
|
|
@@ -16926,7 +16928,23 @@ function runQuery(docs, query) {
|
|
|
16926
16928
|
if (docValue && typeof docValue === "object" && typeof testValue === "string") {
|
|
16927
16929
|
return docValue._id === testValue;
|
|
16928
16930
|
}
|
|
16929
|
-
|
|
16931
|
+
if (docValue === testValue) {
|
|
16932
|
+
return true;
|
|
16933
|
+
}
|
|
16934
|
+
if (docValue == null && testValue != null) {
|
|
16935
|
+
return false;
|
|
16936
|
+
}
|
|
16937
|
+
if (docValue != null && testValue == null) {
|
|
16938
|
+
return false;
|
|
16939
|
+
}
|
|
16940
|
+
const leftDate = (0, import_dayjs.default)(docValue);
|
|
16941
|
+
if (leftDate.isValid()) {
|
|
16942
|
+
const rightDate = (0, import_dayjs.default)(testValue);
|
|
16943
|
+
if (rightDate.isValid()) {
|
|
16944
|
+
return leftDate.isSame(rightDate);
|
|
16945
|
+
}
|
|
16946
|
+
}
|
|
16947
|
+
return false;
|
|
16930
16948
|
};
|
|
16931
16949
|
const not = (f) => (...args) => !f(...args);
|
|
16932
16950
|
const equalMatch = match("equal" /* EQUAL */, _valueMatches);
|
|
@@ -21141,7 +21159,7 @@ function isDocumentConflictError(error) {
|
|
|
21141
21159
|
var DOUBLE_SEPARATOR = `${SEPARATOR}${SEPARATOR}`;
|
|
21142
21160
|
var ROW_ID_REGEX = /^\[.*]$/g;
|
|
21143
21161
|
var ENCODED_SPACE = encodeURIComponent(" ");
|
|
21144
|
-
var ISO_DATE_REGEX = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z
|
|
21162
|
+
var ISO_DATE_REGEX = /^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}:\d{2}.\d{3}Z)?$/;
|
|
21145
21163
|
var TIME_REGEX = /^(?:\d{2}:)?(?:\d{2}:)(?:\d{2})$/;
|
|
21146
21164
|
function isExternalTableID(tableId) {
|
|
21147
21165
|
return tableId.startsWith("datasource" /* DATASOURCE */ + SEPARATOR);
|
|
@@ -21243,15 +21261,7 @@ function isInvalidISODateString(str) {
|
|
|
21243
21261
|
return isNaN(d.getTime());
|
|
21244
21262
|
}
|
|
21245
21263
|
function isValidISODateString(str) {
|
|
21246
|
-
|
|
21247
|
-
if (!ISO_DATE_REGEX.test(trimmedValue)) {
|
|
21248
|
-
return false;
|
|
21249
|
-
}
|
|
21250
|
-
let d = new Date(trimmedValue);
|
|
21251
|
-
if (isNaN(d.getTime())) {
|
|
21252
|
-
return false;
|
|
21253
|
-
}
|
|
21254
|
-
return d.toISOString() === trimmedValue;
|
|
21264
|
+
return ISO_DATE_REGEX.test(str.trim());
|
|
21255
21265
|
}
|
|
21256
21266
|
function isValidFilter(value) {
|
|
21257
21267
|
return value != null && value !== "";
|
|
@@ -29043,7 +29053,11 @@ async function errorHandling(ctx, next) {
|
|
|
29043
29053
|
};
|
|
29044
29054
|
}
|
|
29045
29055
|
if (environment_default.isTest() && ctx.headers["x-budibase-include-stacktrace"]) {
|
|
29046
|
-
|
|
29056
|
+
let rootErr = err;
|
|
29057
|
+
while (rootErr.cause) {
|
|
29058
|
+
rootErr = rootErr.cause;
|
|
29059
|
+
}
|
|
29060
|
+
error.stack = rootErr.stack;
|
|
29047
29061
|
}
|
|
29048
29062
|
ctx.body = error;
|
|
29049
29063
|
}
|
|
@@ -30066,16 +30080,6 @@ var InternalBuilder = class {
|
|
|
30066
30080
|
}
|
|
30067
30081
|
return parts.join(".");
|
|
30068
30082
|
}
|
|
30069
|
-
isFullSelectStatementRequired() {
|
|
30070
|
-
for (let column of Object.values(this.table.schema)) {
|
|
30071
|
-
if (this.SPECIAL_SELECT_CASES.POSTGRES_MONEY(column)) {
|
|
30072
|
-
return true;
|
|
30073
|
-
} else if (this.SPECIAL_SELECT_CASES.MSSQL_DATES(column)) {
|
|
30074
|
-
return true;
|
|
30075
|
-
}
|
|
30076
|
-
}
|
|
30077
|
-
return false;
|
|
30078
|
-
}
|
|
30079
30083
|
generateSelectStatement() {
|
|
30080
30084
|
const { table, resource } = this.query;
|
|
30081
30085
|
if (!resource || !resource.fields || resource.fields.length === 0) {
|
|
@@ -30083,10 +30087,7 @@ var InternalBuilder = class {
|
|
|
30083
30087
|
}
|
|
30084
30088
|
const alias = this.getTableName(table);
|
|
30085
30089
|
const schema = this.table.schema;
|
|
30086
|
-
|
|
30087
|
-
return [this.knex.raw("??", [`${alias}.*`])];
|
|
30088
|
-
}
|
|
30089
|
-
return resource.fields.map((field) => {
|
|
30090
|
+
const tableFields = resource.fields.map((field) => {
|
|
30090
30091
|
const parts = field.split(/\./g);
|
|
30091
30092
|
let table2 = void 0;
|
|
30092
30093
|
let column = parts[0];
|
|
@@ -30095,7 +30096,8 @@ var InternalBuilder = class {
|
|
|
30095
30096
|
column = parts.slice(1).join(".");
|
|
30096
30097
|
}
|
|
30097
30098
|
return { table: table2, column, field };
|
|
30098
|
-
}).filter(({ table: table2 }) => !table2 || table2 === alias)
|
|
30099
|
+
}).filter(({ table: table2 }) => !table2 || table2 === alias);
|
|
30100
|
+
return tableFields.map(({ table: table2, column, field }) => {
|
|
30099
30101
|
const columnSchema = schema[column];
|
|
30100
30102
|
if (this.SPECIAL_SELECT_CASES.POSTGRES_MONEY(columnSchema)) {
|
|
30101
30103
|
return this.knex.raw(`??::money::numeric as ??`, [
|
|
@@ -30489,13 +30491,24 @@ var InternalBuilder = class {
|
|
|
30489
30491
|
filters.oneOf,
|
|
30490
30492
|
"oneOf" /* ONE_OF */,
|
|
30491
30493
|
(q, key, array) => {
|
|
30494
|
+
const schema = this.getFieldSchema(key);
|
|
30495
|
+
const values2 = Array.isArray(array) ? array : [array];
|
|
30492
30496
|
if (shouldOr) {
|
|
30493
30497
|
q = q.or;
|
|
30494
30498
|
}
|
|
30495
30499
|
if (this.client === "oracledb" /* ORACLE */) {
|
|
30496
30500
|
key = this.convertClobs(key);
|
|
30501
|
+
} else if (this.client === "sqlite3" /* SQL_LITE */ && schema?.type === "datetime" /* DATETIME */ && schema.dateOnly) {
|
|
30502
|
+
for (const value of values2) {
|
|
30503
|
+
if (value != null) {
|
|
30504
|
+
q = q.or.whereLike(key, `${value.toISOString().slice(0, 10)}%`);
|
|
30505
|
+
} else {
|
|
30506
|
+
q = q.or.whereNull(key);
|
|
30507
|
+
}
|
|
30508
|
+
}
|
|
30509
|
+
return q;
|
|
30497
30510
|
}
|
|
30498
|
-
return q.whereIn(key,
|
|
30511
|
+
return q.whereIn(key, values2);
|
|
30499
30512
|
},
|
|
30500
30513
|
(q, key, array) => {
|
|
30501
30514
|
if (shouldOr) {
|
|
@@ -30542,6 +30555,14 @@ var InternalBuilder = class {
|
|
|
30542
30555
|
let rawKey = key;
|
|
30543
30556
|
let high = value.high;
|
|
30544
30557
|
let low = value.low;
|
|
30558
|
+
if (this.client === "sqlite3" /* SQL_LITE */ && schema?.type === "datetime" /* DATETIME */ && schema.dateOnly) {
|
|
30559
|
+
if (high != null) {
|
|
30560
|
+
high = `${high.toISOString().slice(0, 10)}T23:59:59.999Z`;
|
|
30561
|
+
}
|
|
30562
|
+
if (low != null) {
|
|
30563
|
+
low = low.toISOString().slice(0, 10);
|
|
30564
|
+
}
|
|
30565
|
+
}
|
|
30545
30566
|
if (this.client === "oracledb" /* ORACLE */) {
|
|
30546
30567
|
rawKey = this.convertClobs(key);
|
|
30547
30568
|
} else if (this.client === "sqlite3" /* SQL_LITE */ && schema?.type === "bigint" /* BIGINT */) {
|
|
@@ -30566,6 +30587,7 @@ var InternalBuilder = class {
|
|
|
30566
30587
|
}
|
|
30567
30588
|
if (filters.equal) {
|
|
30568
30589
|
iterate(filters.equal, "equal" /* EQUAL */, (q, key, value) => {
|
|
30590
|
+
const schema = this.getFieldSchema(key);
|
|
30569
30591
|
if (shouldOr) {
|
|
30570
30592
|
q = q.or;
|
|
30571
30593
|
}
|
|
@@ -30582,6 +30604,12 @@ var InternalBuilder = class {
|
|
|
30582
30604
|
subq.whereNotNull(identifier).andWhere(identifier, value)
|
|
30583
30605
|
)
|
|
30584
30606
|
);
|
|
30607
|
+
} else if (this.client === "sqlite3" /* SQL_LITE */ && schema?.type === "datetime" /* DATETIME */ && schema.dateOnly) {
|
|
30608
|
+
if (value != null) {
|
|
30609
|
+
return q.whereLike(key, `${value.toISOString().slice(0, 10)}%`);
|
|
30610
|
+
} else {
|
|
30611
|
+
return q.whereNull(key);
|
|
30612
|
+
}
|
|
30585
30613
|
} else {
|
|
30586
30614
|
return q.whereRaw(`COALESCE(?? = ?, FALSE)`, [
|
|
30587
30615
|
this.rawQuotedIdentifier(key),
|
|
@@ -30592,6 +30620,7 @@ var InternalBuilder = class {
|
|
|
30592
30620
|
}
|
|
30593
30621
|
if (filters.notEqual) {
|
|
30594
30622
|
iterate(filters.notEqual, "notEqual" /* NOT_EQUAL */, (q, key, value) => {
|
|
30623
|
+
const schema = this.getFieldSchema(key);
|
|
30595
30624
|
if (shouldOr) {
|
|
30596
30625
|
q = q.or;
|
|
30597
30626
|
}
|
|
@@ -30605,6 +30634,12 @@ var InternalBuilder = class {
|
|
|
30605
30634
|
return q.where(
|
|
30606
30635
|
(subq) => subq.not.whereNull(identifier).and.where(identifier, "!=", value)
|
|
30607
30636
|
).or.whereNull(identifier);
|
|
30637
|
+
} else if (this.client === "sqlite3" /* SQL_LITE */ && schema?.type === "datetime" /* DATETIME */ && schema.dateOnly) {
|
|
30638
|
+
if (value != null) {
|
|
30639
|
+
return q.not.whereLike(key, `${value.toISOString().slice(0, 10)}%`).or.whereNull(key);
|
|
30640
|
+
} else {
|
|
30641
|
+
return q.not.whereNull(key);
|
|
30642
|
+
}
|
|
30608
30643
|
} else {
|
|
30609
30644
|
return q.whereRaw(`COALESCE(?? != ?, TRUE)`, [
|
|
30610
30645
|
this.rawQuotedIdentifier(key),
|
|
@@ -30857,6 +30892,9 @@ var InternalBuilder = class {
|
|
|
30857
30892
|
const fieldList = relationshipFields.map(
|
|
30858
30893
|
(field) => this.buildJsonField(relatedTable, field)
|
|
30859
30894
|
);
|
|
30895
|
+
if (!fieldList.length) {
|
|
30896
|
+
continue;
|
|
30897
|
+
}
|
|
30860
30898
|
const fieldListFormatted = fieldList.map((f) => {
|
|
30861
30899
|
const separator = this.client === "oracledb" /* ORACLE */ ? " VALUE " : ",";
|
|
30862
30900
|
return this.knex.raw(`?${separator}??`, [f[0], f[1]]).toString();
|
|
@@ -30880,7 +30918,7 @@ var InternalBuilder = class {
|
|
|
30880
30918
|
this.rawQuotedIdentifier(correlatedFrom)
|
|
30881
30919
|
);
|
|
30882
30920
|
const standardWrap = (select) => {
|
|
30883
|
-
subQuery = subQuery.select(
|
|
30921
|
+
subQuery = subQuery.select(relationshipFields).limit(getRelationshipLimit());
|
|
30884
30922
|
return knex3.select(select).from({
|
|
30885
30923
|
[toAlias]: subQuery
|
|
30886
30924
|
});
|
|
@@ -31046,7 +31084,7 @@ var InternalBuilder = class {
|
|
|
31046
31084
|
return query.upsert(parsedBody);
|
|
31047
31085
|
}
|
|
31048
31086
|
read(opts = {}) {
|
|
31049
|
-
|
|
31087
|
+
const { operation, filters, paginate, relationships, table } = this.query;
|
|
31050
31088
|
const { limits } = opts;
|
|
31051
31089
|
let query = this.qualifiedKnex();
|
|
31052
31090
|
let foundOffset = null;
|
|
@@ -31085,7 +31123,7 @@ var InternalBuilder = class {
|
|
|
31085
31123
|
if (relationships?.length && aggregations.length === 0) {
|
|
31086
31124
|
const mainTable = this.query.tableAliases?.[table.name] || table.name;
|
|
31087
31125
|
const cte = this.addSorting(
|
|
31088
|
-
this.knex.with("paginated", query).select(this.generateSelectStatement()).from({
|
|
31126
|
+
this.knex.with("paginated", query.clone().clearSelect().select("*")).select(this.generateSelectStatement()).from({
|
|
31089
31127
|
[mainTable]: "paginated"
|
|
31090
31128
|
})
|
|
31091
31129
|
);
|