@budibase/backend-core 2.29.1 → 2.29.2
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 +103 -98
- 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/constants/db.d.ts +1 -1
- package/dist/src/constants/db.js +2 -1
- package/dist/src/constants/db.js.map +1 -1
- package/dist/src/sql/sql.js +7 -3
- package/dist/src/sql/sql.js.map +1 -1
- package/dist/src/sql/sqlTable.js +2 -2
- package/dist/src/sql/sqlTable.js.map +1 -1
- package/dist/src/sql/utils.d.ts +2 -5
- package/dist/src/sql/utils.js +3 -3
- package/dist/src/sql/utils.js.map +1 -1
- package/dist/tests/core/utilities/structures/accounts.js +1 -1
- package/dist/tests/core/utilities/structures/accounts.js.map +1 -1
- package/package.json +4 -4
- package/src/constants/db.ts +1 -1
- package/src/sql/sql.ts +8 -3
- package/src/sql/sqlTable.ts +4 -2
- package/src/sql/utils.ts +4 -4
- package/tests/core/utilities/structures/accounts.ts +0 -1
package/dist/index.js
CHANGED
|
@@ -54131,8 +54131,8 @@ var require_lib9 = __commonJS({
|
|
|
54131
54131
|
var src_exports = {};
|
|
54132
54132
|
__export(src_exports, {
|
|
54133
54133
|
APP_DEV: () => APP_DEV,
|
|
54134
|
-
APP_DEV_PREFIX: () =>
|
|
54135
|
-
APP_PREFIX: () =>
|
|
54134
|
+
APP_DEV_PREFIX: () => APP_DEV_PREFIX2,
|
|
54135
|
+
APP_PREFIX: () => APP_PREFIX2,
|
|
54136
54136
|
AutomationViewMode: () => AutomationViewMode,
|
|
54137
54137
|
BUDIBASE_DATASOURCE_TYPE: () => BUDIBASE_DATASOURCE_TYPE,
|
|
54138
54138
|
BadRequestError: () => BadRequestError,
|
|
@@ -54659,8 +54659,8 @@ var BREAKDOWN_QUOTA_NAMES = [
|
|
|
54659
54659
|
var constants_exports2 = {};
|
|
54660
54660
|
__export(constants_exports2, {
|
|
54661
54661
|
APP_DEV: () => APP_DEV,
|
|
54662
|
-
APP_DEV_PREFIX: () =>
|
|
54663
|
-
APP_PREFIX: () =>
|
|
54662
|
+
APP_DEV_PREFIX: () => APP_DEV_PREFIX2,
|
|
54663
|
+
APP_PREFIX: () => APP_PREFIX2,
|
|
54664
54664
|
AutomationViewMode: () => AutomationViewMode,
|
|
54665
54665
|
BUDIBASE_DATASOURCE_TYPE: () => BUDIBASE_DATASOURCE_TYPE,
|
|
54666
54666
|
Config: () => Config,
|
|
@@ -54687,69 +54687,6 @@ __export(constants_exports2, {
|
|
|
54687
54687
|
ViewName: () => ViewName
|
|
54688
54688
|
});
|
|
54689
54689
|
|
|
54690
|
-
// src/constants/db.ts
|
|
54691
|
-
var AutomationViewMode = /* @__PURE__ */ ((AutomationViewMode2) => {
|
|
54692
|
-
AutomationViewMode2["ALL"] = "all";
|
|
54693
|
-
AutomationViewMode2["AUTOMATION"] = "automation";
|
|
54694
|
-
AutomationViewMode2["STATUS"] = "status";
|
|
54695
|
-
return AutomationViewMode2;
|
|
54696
|
-
})(AutomationViewMode || {});
|
|
54697
|
-
var ViewName = /* @__PURE__ */ ((ViewName3) => {
|
|
54698
|
-
ViewName3["USER_BY_APP"] = "by_app";
|
|
54699
|
-
ViewName3["USER_BY_EMAIL"] = "by_email2";
|
|
54700
|
-
ViewName3["BY_API_KEY"] = "by_api_key";
|
|
54701
|
-
ViewName3["LINK"] = "by_link";
|
|
54702
|
-
ViewName3["ROUTING"] = "screen_routes";
|
|
54703
|
-
ViewName3["AUTOMATION_LOGS"] = "automation_logs";
|
|
54704
|
-
ViewName3["ACCOUNT_BY_EMAIL"] = "account_by_email";
|
|
54705
|
-
ViewName3["PLATFORM_USERS_LOWERCASE"] = "platform_users_lowercase_2";
|
|
54706
|
-
ViewName3["USER_BY_GROUP"] = "user_by_group";
|
|
54707
|
-
ViewName3["APP_BACKUP_BY_TRIGGER"] = "by_trigger";
|
|
54708
|
-
return ViewName3;
|
|
54709
|
-
})(ViewName || {});
|
|
54710
|
-
var DeprecatedViews = {
|
|
54711
|
-
["by_email2" /* USER_BY_EMAIL */]: [
|
|
54712
|
-
// removed due to inaccuracy in view doc filter logic
|
|
54713
|
-
"by_email"
|
|
54714
|
-
]
|
|
54715
|
-
};
|
|
54716
|
-
var StaticDatabases = {
|
|
54717
|
-
GLOBAL: {
|
|
54718
|
-
name: "global-db",
|
|
54719
|
-
docs: {
|
|
54720
|
-
apiKeys: "apikeys",
|
|
54721
|
-
usageQuota: "usage_quota",
|
|
54722
|
-
licenseInfo: "license_info",
|
|
54723
|
-
environmentVariables: "environmentvariables"
|
|
54724
|
-
}
|
|
54725
|
-
},
|
|
54726
|
-
// contains information about tenancy and so on
|
|
54727
|
-
PLATFORM_INFO: {
|
|
54728
|
-
name: "global-info",
|
|
54729
|
-
docs: {
|
|
54730
|
-
tenants: "tenants",
|
|
54731
|
-
install: "install"
|
|
54732
|
-
}
|
|
54733
|
-
},
|
|
54734
|
-
AUDIT_LOGS: {
|
|
54735
|
-
name: "audit-logs"
|
|
54736
|
-
},
|
|
54737
|
-
SCIM_LOGS: {
|
|
54738
|
-
name: "scim-logs"
|
|
54739
|
-
}
|
|
54740
|
-
};
|
|
54741
|
-
var APP_PREFIX = prefixed("app" /* APP */);
|
|
54742
|
-
var APP_DEV = prefixed("app_dev" /* APP_DEV */);
|
|
54743
|
-
var APP_DEV_PREFIX = APP_DEV;
|
|
54744
|
-
var SQS_DATASOURCE_INTERNAL = "internal";
|
|
54745
|
-
var BUDIBASE_DATASOURCE_TYPE = "budibase";
|
|
54746
|
-
var SQLITE_DESIGN_DOC_ID = "_design/sqlite";
|
|
54747
|
-
var DEFAULT_JOBS_TABLE_ID = "ta_bb_jobs";
|
|
54748
|
-
var DEFAULT_INVENTORY_TABLE_ID = "ta_bb_inventory";
|
|
54749
|
-
var DEFAULT_EXPENSES_TABLE_ID = "ta_bb_expenses";
|
|
54750
|
-
var DEFAULT_EMPLOYEE_TABLE_ID = "ta_bb_employee";
|
|
54751
|
-
var DEFAULT_BB_DATASOURCE_ID = "datasource_internal_bb_default";
|
|
54752
|
-
|
|
54753
54690
|
// ../shared-core/src/constants/api.ts
|
|
54754
54691
|
var Header = /* @__PURE__ */ ((Header2) => {
|
|
54755
54692
|
Header2["API_KEY"] = "x-budibase-api-key";
|
|
@@ -54885,6 +54822,7 @@ var SqlNumberTypeRangeMap = {
|
|
|
54885
54822
|
min: -8388608
|
|
54886
54823
|
}
|
|
54887
54824
|
};
|
|
54825
|
+
var DEFAULT_BB_DATASOURCE_ID = "datasource_internal_bb_default";
|
|
54888
54826
|
|
|
54889
54827
|
// ../shared-core/src/filters.ts
|
|
54890
54828
|
var filters_exports = {};
|
|
@@ -55564,31 +55502,31 @@ __export(applications_exports, {
|
|
|
55564
55502
|
getDevAppID: () => getDevAppID,
|
|
55565
55503
|
getProdAppID: () => getProdAppID
|
|
55566
55504
|
});
|
|
55567
|
-
var
|
|
55568
|
-
var
|
|
55505
|
+
var APP_PREFIX = prefixed("app" /* APP */);
|
|
55506
|
+
var APP_DEV_PREFIX = prefixed("app_dev" /* APP_DEV */);
|
|
55569
55507
|
function getDevAppID(appId) {
|
|
55570
55508
|
if (!appId) {
|
|
55571
55509
|
throw new Error("No app ID provided");
|
|
55572
55510
|
}
|
|
55573
|
-
if (appId.startsWith(
|
|
55511
|
+
if (appId.startsWith(APP_DEV_PREFIX)) {
|
|
55574
55512
|
return appId;
|
|
55575
55513
|
}
|
|
55576
|
-
const split = appId.split(
|
|
55514
|
+
const split = appId.split(APP_PREFIX);
|
|
55577
55515
|
split.shift();
|
|
55578
|
-
const rest = split.join(
|
|
55579
|
-
return `${
|
|
55516
|
+
const rest = split.join(APP_PREFIX);
|
|
55517
|
+
return `${APP_DEV_PREFIX}${rest}`;
|
|
55580
55518
|
}
|
|
55581
55519
|
function getProdAppID(appId) {
|
|
55582
55520
|
if (!appId) {
|
|
55583
55521
|
throw new Error("No app ID provided");
|
|
55584
55522
|
}
|
|
55585
|
-
if (!appId.startsWith(
|
|
55523
|
+
if (!appId.startsWith(APP_DEV_PREFIX)) {
|
|
55586
55524
|
return appId;
|
|
55587
55525
|
}
|
|
55588
|
-
const split = appId.split(
|
|
55526
|
+
const split = appId.split(APP_DEV_PREFIX);
|
|
55589
55527
|
split.shift();
|
|
55590
|
-
const rest = split.join(
|
|
55591
|
-
return `${
|
|
55528
|
+
const rest = split.join(APP_DEV_PREFIX);
|
|
55529
|
+
return `${APP_PREFIX}${rest}`;
|
|
55592
55530
|
}
|
|
55593
55531
|
|
|
55594
55532
|
// ../shared-core/src/sdk/documents/users.ts
|
|
@@ -55743,6 +55681,68 @@ var allowSortColumnByType = {
|
|
|
55743
55681
|
["bb_reference_single" /* BB_REFERENCE_SINGLE */]: false
|
|
55744
55682
|
};
|
|
55745
55683
|
|
|
55684
|
+
// src/constants/db.ts
|
|
55685
|
+
var AutomationViewMode = /* @__PURE__ */ ((AutomationViewMode2) => {
|
|
55686
|
+
AutomationViewMode2["ALL"] = "all";
|
|
55687
|
+
AutomationViewMode2["AUTOMATION"] = "automation";
|
|
55688
|
+
AutomationViewMode2["STATUS"] = "status";
|
|
55689
|
+
return AutomationViewMode2;
|
|
55690
|
+
})(AutomationViewMode || {});
|
|
55691
|
+
var ViewName = /* @__PURE__ */ ((ViewName3) => {
|
|
55692
|
+
ViewName3["USER_BY_APP"] = "by_app";
|
|
55693
|
+
ViewName3["USER_BY_EMAIL"] = "by_email2";
|
|
55694
|
+
ViewName3["BY_API_KEY"] = "by_api_key";
|
|
55695
|
+
ViewName3["LINK"] = "by_link";
|
|
55696
|
+
ViewName3["ROUTING"] = "screen_routes";
|
|
55697
|
+
ViewName3["AUTOMATION_LOGS"] = "automation_logs";
|
|
55698
|
+
ViewName3["ACCOUNT_BY_EMAIL"] = "account_by_email";
|
|
55699
|
+
ViewName3["PLATFORM_USERS_LOWERCASE"] = "platform_users_lowercase_2";
|
|
55700
|
+
ViewName3["USER_BY_GROUP"] = "user_by_group";
|
|
55701
|
+
ViewName3["APP_BACKUP_BY_TRIGGER"] = "by_trigger";
|
|
55702
|
+
return ViewName3;
|
|
55703
|
+
})(ViewName || {});
|
|
55704
|
+
var DeprecatedViews = {
|
|
55705
|
+
["by_email2" /* USER_BY_EMAIL */]: [
|
|
55706
|
+
// removed due to inaccuracy in view doc filter logic
|
|
55707
|
+
"by_email"
|
|
55708
|
+
]
|
|
55709
|
+
};
|
|
55710
|
+
var StaticDatabases = {
|
|
55711
|
+
GLOBAL: {
|
|
55712
|
+
name: "global-db",
|
|
55713
|
+
docs: {
|
|
55714
|
+
apiKeys: "apikeys",
|
|
55715
|
+
usageQuota: "usage_quota",
|
|
55716
|
+
licenseInfo: "license_info",
|
|
55717
|
+
environmentVariables: "environmentvariables"
|
|
55718
|
+
}
|
|
55719
|
+
},
|
|
55720
|
+
// contains information about tenancy and so on
|
|
55721
|
+
PLATFORM_INFO: {
|
|
55722
|
+
name: "global-info",
|
|
55723
|
+
docs: {
|
|
55724
|
+
tenants: "tenants",
|
|
55725
|
+
install: "install"
|
|
55726
|
+
}
|
|
55727
|
+
},
|
|
55728
|
+
AUDIT_LOGS: {
|
|
55729
|
+
name: "audit-logs"
|
|
55730
|
+
},
|
|
55731
|
+
SCIM_LOGS: {
|
|
55732
|
+
name: "scim-logs"
|
|
55733
|
+
}
|
|
55734
|
+
};
|
|
55735
|
+
var APP_PREFIX2 = prefixed("app" /* APP */);
|
|
55736
|
+
var APP_DEV = prefixed("app_dev" /* APP_DEV */);
|
|
55737
|
+
var APP_DEV_PREFIX2 = APP_DEV;
|
|
55738
|
+
var SQS_DATASOURCE_INTERNAL = "internal";
|
|
55739
|
+
var BUDIBASE_DATASOURCE_TYPE = "budibase";
|
|
55740
|
+
var SQLITE_DESIGN_DOC_ID = "_design/sqlite";
|
|
55741
|
+
var DEFAULT_JOBS_TABLE_ID = "ta_bb_jobs";
|
|
55742
|
+
var DEFAULT_INVENTORY_TABLE_ID = "ta_bb_inventory";
|
|
55743
|
+
var DEFAULT_EXPENSES_TABLE_ID = "ta_bb_expenses";
|
|
55744
|
+
var DEFAULT_EMPLOYEE_TABLE_ID = "ta_bb_employee";
|
|
55745
|
+
|
|
55746
55746
|
// src/constants/misc.ts
|
|
55747
55747
|
var UserStatus = /* @__PURE__ */ ((UserStatus3) => {
|
|
55748
55748
|
UserStatus3["ACTIVE"] = "active";
|
|
@@ -56090,13 +56090,13 @@ function isDevAppID(appId) {
|
|
|
56090
56090
|
if (!appId) {
|
|
56091
56091
|
throw NO_APP_ERROR;
|
|
56092
56092
|
}
|
|
56093
|
-
return appId.startsWith(
|
|
56093
|
+
return appId.startsWith(APP_DEV_PREFIX2);
|
|
56094
56094
|
}
|
|
56095
56095
|
function isProdAppID(appId) {
|
|
56096
56096
|
if (!appId) {
|
|
56097
56097
|
throw NO_APP_ERROR;
|
|
56098
56098
|
}
|
|
56099
|
-
return appId.startsWith(
|
|
56099
|
+
return appId.startsWith(APP_PREFIX2) && !isDevAppID(appId);
|
|
56100
56100
|
}
|
|
56101
56101
|
function isDevApp(app) {
|
|
56102
56102
|
if (!app) {
|
|
@@ -56105,23 +56105,23 @@ function isDevApp(app) {
|
|
|
56105
56105
|
return isDevAppID(app.appId);
|
|
56106
56106
|
}
|
|
56107
56107
|
function getDevelopmentAppID(appId) {
|
|
56108
|
-
if (!appId || appId.startsWith(
|
|
56108
|
+
if (!appId || appId.startsWith(APP_DEV_PREFIX2)) {
|
|
56109
56109
|
return appId;
|
|
56110
56110
|
}
|
|
56111
|
-
const split = appId.split(
|
|
56111
|
+
const split = appId.split(APP_PREFIX2);
|
|
56112
56112
|
split.shift();
|
|
56113
|
-
const rest = split.join(
|
|
56114
|
-
return `${
|
|
56113
|
+
const rest = split.join(APP_PREFIX2);
|
|
56114
|
+
return `${APP_DEV_PREFIX2}${rest}`;
|
|
56115
56115
|
}
|
|
56116
56116
|
var getDevAppID2 = getDevelopmentAppID;
|
|
56117
56117
|
function getProdAppID2(appId) {
|
|
56118
|
-
if (!appId || !appId.startsWith(
|
|
56118
|
+
if (!appId || !appId.startsWith(APP_DEV_PREFIX2)) {
|
|
56119
56119
|
return appId;
|
|
56120
56120
|
}
|
|
56121
|
-
const split = appId.split(
|
|
56121
|
+
const split = appId.split(APP_DEV_PREFIX2);
|
|
56122
56122
|
split.shift();
|
|
56123
|
-
const rest = split.join(
|
|
56124
|
-
return `${
|
|
56123
|
+
const rest = split.join(APP_DEV_PREFIX2);
|
|
56124
|
+
return `${APP_PREFIX2}${rest}`;
|
|
56125
56125
|
}
|
|
56126
56126
|
function extractAppUUID(id) {
|
|
56127
56127
|
const split = id?.split("_") || [];
|
|
@@ -57353,8 +57353,8 @@ var import_uuid2 = require("uuid");
|
|
|
57353
57353
|
var db_exports = {};
|
|
57354
57354
|
__export(db_exports, {
|
|
57355
57355
|
APP_DEV: () => APP_DEV,
|
|
57356
|
-
APP_DEV_PREFIX: () =>
|
|
57357
|
-
APP_PREFIX: () =>
|
|
57356
|
+
APP_DEV_PREFIX: () => APP_DEV_PREFIX2,
|
|
57357
|
+
APP_PREFIX: () => APP_PREFIX2,
|
|
57358
57358
|
AutomationViewMode: () => AutomationViewMode,
|
|
57359
57359
|
BUDIBASE_DATASOURCE_TYPE: () => BUDIBASE_DATASOURCE_TYPE,
|
|
57360
57360
|
CONSTANT_EXTERNAL_ROW_COLS: () => CONSTANT_EXTERNAL_ROW_COLS,
|
|
@@ -57548,7 +57548,7 @@ __export(docIds_exports, {
|
|
|
57548
57548
|
|
|
57549
57549
|
// src/docIds/ids.ts
|
|
57550
57550
|
var generateAppID = (tenantId) => {
|
|
57551
|
-
let id =
|
|
57551
|
+
let id = APP_PREFIX2;
|
|
57552
57552
|
if (tenantId) {
|
|
57553
57553
|
id += `${tenantId}${SEPARATOR}`;
|
|
57554
57554
|
}
|
|
@@ -58708,7 +58708,7 @@ function sanitizeKey(input) {
|
|
|
58708
58708
|
return sanitize(sanitizeBucket(input)).replace(/\\/g, "/");
|
|
58709
58709
|
}
|
|
58710
58710
|
function sanitizeBucket(input) {
|
|
58711
|
-
return input.replace(new RegExp(
|
|
58711
|
+
return input.replace(new RegExp(APP_DEV_PREFIX2, "g"), APP_PREFIX2);
|
|
58712
58712
|
}
|
|
58713
58713
|
function ObjectStore(bucket, opts = { presigning: false }) {
|
|
58714
58714
|
const config = {
|
|
@@ -67112,15 +67112,15 @@ function buildExternalTableId(datasourceId, tableName) {
|
|
|
67112
67112
|
return `${datasourceId}${DOUBLE_SEPARATOR}${tableName}`;
|
|
67113
67113
|
}
|
|
67114
67114
|
function breakExternalTableId(tableId) {
|
|
67115
|
-
if (!tableId) {
|
|
67116
|
-
return {};
|
|
67117
|
-
}
|
|
67118
67115
|
const parts = tableId.split(DOUBLE_SEPARATOR);
|
|
67119
67116
|
let datasourceId = parts.shift();
|
|
67120
67117
|
let tableName = parts.join(DOUBLE_SEPARATOR);
|
|
67121
67118
|
if (tableName.includes(ENCODED_SPACE)) {
|
|
67122
67119
|
tableName = decodeURIComponent(tableName);
|
|
67123
67120
|
}
|
|
67121
|
+
if (!datasourceId || !tableName) {
|
|
67122
|
+
throw new Error("Unable to get datasource/table name from table ID");
|
|
67123
|
+
}
|
|
67124
67124
|
return { datasourceId, tableName };
|
|
67125
67125
|
}
|
|
67126
67126
|
function generateRowIdField(keyProps = []) {
|
|
@@ -67296,8 +67296,10 @@ function generateSchema(schema, table, tables, oldTable = null, renamed) {
|
|
|
67296
67296
|
}
|
|
67297
67297
|
const { tableName } = breakExternalTableId(column.tableId);
|
|
67298
67298
|
const relatedTable = tables[tableName];
|
|
67299
|
-
if (!relatedTable) {
|
|
67300
|
-
throw new Error(
|
|
67299
|
+
if (!relatedTable || !relatedTable.primary) {
|
|
67300
|
+
throw new Error(
|
|
67301
|
+
"Referenced table doesn't exist or has no primary keys"
|
|
67302
|
+
);
|
|
67301
67303
|
}
|
|
67302
67304
|
const relatedPrimary = relatedTable.primary[0];
|
|
67303
67305
|
const externalType = relatedTable.schema[relatedPrimary].externalType;
|
|
@@ -67778,7 +67780,9 @@ var InternalBuilder = class {
|
|
|
67778
67780
|
query = query.orderBy(`${aliased}.${key}`, direction, nulls);
|
|
67779
67781
|
}
|
|
67780
67782
|
}
|
|
67781
|
-
|
|
67783
|
+
if (!sort2 || sort2[primaryKey[0]] === void 0) {
|
|
67784
|
+
query = query.orderBy(`${aliased}.${primaryKey[0]}`);
|
|
67785
|
+
}
|
|
67782
67786
|
return query;
|
|
67783
67787
|
}
|
|
67784
67788
|
tableNameWithSchema(tableName, opts) {
|
|
@@ -67894,7 +67898,8 @@ var InternalBuilder = class {
|
|
|
67894
67898
|
if (!primary) {
|
|
67895
67899
|
throw new Error("Primary key is required for upsert");
|
|
67896
67900
|
}
|
|
67897
|
-
|
|
67901
|
+
const ret = query.insert(parsedBody).onConflict(primary).merge();
|
|
67902
|
+
return ret;
|
|
67898
67903
|
} else if (this.client === "mssql" /* MS_SQL */) {
|
|
67899
67904
|
return query.insert(parsedBody);
|
|
67900
67905
|
}
|