Fixing issue #5778 - making sure to only remove the first app_ element of the app ID.

This commit is contained in:
mike12345567 2022-05-09 12:29:44 +01:00
parent f07e87e598
commit 7b461c03dd
7 changed files with 51 additions and 57 deletions

View File

@ -23,24 +23,24 @@ exports.isDevApp = app => {
} }
/** /**
* Convert a development app ID to a deployed app ID. * Generates a development app ID from a real app ID.
* @returns {string} the dev app ID which can be used for dev database.
*/ */
exports.getProdAppID = appId => { exports.getDevelopmentAppID = appId => {
// if dev, convert it // split to take off the app_ element, then join it together incase any other app_ exist
if (appId.startsWith(APP_DEV_PREFIX)) { const split = appId.split(APP_PREFIX)
const id = appId.split(APP_DEV_PREFIX)[1] split.shift()
return `${APP_PREFIX}${id}` const rest = split.join(APP_PREFIX)
} return `${APP_DEV_PREFIX}${rest}`
return appId
} }
/** /**
* Convert a deployed app ID to a development app ID. * Convert a development app ID to a deployed app ID.
*/ */
exports.getDevelopmentAppID = appId => { exports.getProdAppID = appId => {
if (!appId.startsWith(APP_DEV_PREFIX)) { // split to take off the app_dev element, then join it together incase any other app_ exist
const id = appId.split(APP_PREFIX)[1] const split = appId.split(APP_DEV_PREFIX)
return `${APP_DEV_PREFIX}${id}` split.shift()
} const rest = split.join(APP_DEV_PREFIX)
return appId return `${APP_PREFIX}${rest}`
} }

View File

@ -43,6 +43,18 @@ exports.isDevAppID = isDevAppID
exports.getDevelopmentAppID = getDevelopmentAppID exports.getDevelopmentAppID = getDevelopmentAppID
exports.getProdAppID = getProdAppID exports.getProdAppID = getProdAppID
/**
* Generates a new app ID.
* @returns {string} The new app ID which the app doc can be stored under.
*/
exports.generateAppID = (tenantId = null) => {
let id = APP_PREFIX
if (tenantId) {
id += `${tenantId}${SEPARATOR}`
}
return `${id}${newid()}`
}
/** /**
* If creating DB allDocs/query params with only a single top level ID this can be used, this * If creating DB allDocs/query params with only a single top level ID this can be used, this
* is usually the case as most of our docs are top level e.g. tables, automations, users and so on. * is usually the case as most of our docs are top level e.g. tables, automations, users and so on.

View File

@ -70,7 +70,7 @@
"@apidevtools/swagger-parser": "^10.0.3", "@apidevtools/swagger-parser": "^10.0.3",
"@budibase/backend-core": "^1.0.146", "@budibase/backend-core": "^1.0.146",
"@budibase/client": "^1.0.146", "@budibase/client": "^1.0.146",
"@budibase/pro": "1.0.146", "@budibase/pro": "^1.0.145",
"@budibase/string-templates": "^1.0.146", "@budibase/string-templates": "^1.0.146",
"@bull-board/api": "^3.7.0", "@bull-board/api": "^3.7.0",
"@bull-board/koa": "^3.7.0", "@bull-board/koa": "^3.7.0",

View File

@ -9,6 +9,8 @@ const {
StaticDatabases, StaticDatabases,
isDevAppID, isDevAppID,
isProdAppID, isProdAppID,
getDevelopmentAppID,
generateAppID,
} = require("@budibase/backend-core/db") } = require("@budibase/backend-core/db")
const UNICODE_MAX = "\ufff0" const UNICODE_MAX = "\ufff0"
@ -80,6 +82,8 @@ exports.UNICODE_MAX = UNICODE_MAX
exports.SearchIndexes = SearchIndexes exports.SearchIndexes = SearchIndexes
exports.AppStatus = AppStatus exports.AppStatus = AppStatus
exports.BudibaseInternalDB = BudibaseInternalDB exports.BudibaseInternalDB = BudibaseInternalDB
exports.generateAppID = generateAppID
exports.generateDevAppID = getDevelopmentAppID
exports.generateRoleID = generateRoleID exports.generateRoleID = generateRoleID
exports.getRoleParams = getRoleParams exports.getRoleParams = getRoleParams
@ -243,28 +247,6 @@ exports.getLinkParams = (otherProps = {}) => {
return getDocParams(DocumentTypes.LINK, null, otherProps) return getDocParams(DocumentTypes.LINK, null, otherProps)
} }
/**
* Generates a new app ID.
* @returns {string} The new app ID which the app doc can be stored under.
*/
exports.generateAppID = (tenantId = null) => {
let id = `${DocumentTypes.APP}${SEPARATOR}`
if (tenantId) {
id += `${tenantId}${SEPARATOR}`
}
return `${id}${newid()}`
}
/**
* Generates a development app ID from a real app ID.
* @returns {string} the dev app ID which can be used for dev database.
*/
exports.generateDevAppID = appId => {
const prefix = `${DocumentTypes.APP}${SEPARATOR}`
const rest = appId.split(prefix)[1]
return `${DocumentTypes.APP_DEV}${SEPARATOR}${rest}`
}
/** /**
* Generates a new layout ID. * Generates a new layout ID.
* @returns {string} The new layout ID which the layout doc can be stored under. * @returns {string} The new layout ID which the layout doc can be stored under.

View File

@ -1014,10 +1014,10 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
"@budibase/backend-core@1.0.142": "@budibase/backend-core@1.0.145":
version "1.0.142" version "1.0.145"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.142.tgz#cbfa426dbf064dff0ea5f9840baae595c0f5343c" resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.145.tgz#4b9deb9a7808f45e4239c4aae6193020533e2de9"
integrity sha512-gd52tOm4mytHa3OQQVcEiwnVCvq0pC0q3YN+5D1uoGt9WaAZoshB5AhXnUPZohvpo5j8isO07qXvF+5YffPVaw== integrity sha512-UCQI9aQHRNskMH9AWqjjUfyPHOoO8fCW1iPjhOaijiFQ/8nr8TbfshQ5NKFXSCBdCUWIpuGO9664IeoL8LzWDA==
dependencies: dependencies:
"@techpass/passport-openidconnect" "^0.3.0" "@techpass/passport-openidconnect" "^0.3.0"
aws-sdk "^2.901.0" aws-sdk "^2.901.0"
@ -1091,12 +1091,12 @@
svelte-flatpickr "^3.2.3" svelte-flatpickr "^3.2.3"
svelte-portal "^1.0.0" svelte-portal "^1.0.0"
"@budibase/pro@1.0.142": "@budibase/pro@^1.0.145":
version "1.0.142" version "1.0.145"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.142.tgz#17cd53d67ce80e0cce2179caee0c03e6a0d7084e" resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.145.tgz#447a26d21ca94a14bfaa9d9cef5b9a7b7a6e7c17"
integrity sha512-c1SaRoVik/AVn4zNNsDciFeIr+P3J6Sc8hsE5M3pb0Zj/NzSEHXTesxcBVLlD2PYlwnvWPSoMvdDJKrEFHvOYQ== integrity sha512-j5/EGNsMoxy6YxYr5/JLQ+hSehKQrSYrmSPBBzQjQnMMeFNMqHLNlYDsrayXxkEt0ix4WGJxFKTZUR6cLO3nYA==
dependencies: dependencies:
"@budibase/backend-core" "1.0.142" "@budibase/backend-core" "1.0.145"
node-fetch "^2.6.1" node-fetch "^2.6.1"
"@budibase/standard-components@^0.9.139": "@budibase/standard-components@^0.9.139":

View File

@ -32,7 +32,7 @@
"license": "GPL-3.0", "license": "GPL-3.0",
"dependencies": { "dependencies": {
"@budibase/backend-core": "^1.0.146", "@budibase/backend-core": "^1.0.146",
"@budibase/pro": "1.0.146", "@budibase/pro": "^1.0.145",
"@budibase/string-templates": "^1.0.146", "@budibase/string-templates": "^1.0.146",
"@koa/router": "^8.0.0", "@koa/router": "^8.0.0",
"@sentry/node": "6.17.7", "@sentry/node": "6.17.7",

View File

@ -293,10 +293,10 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
"@budibase/backend-core@1.0.142": "@budibase/backend-core@1.0.145":
version "1.0.142" version "1.0.145"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.142.tgz#cbfa426dbf064dff0ea5f9840baae595c0f5343c" resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.145.tgz#4b9deb9a7808f45e4239c4aae6193020533e2de9"
integrity sha512-gd52tOm4mytHa3OQQVcEiwnVCvq0pC0q3YN+5D1uoGt9WaAZoshB5AhXnUPZohvpo5j8isO07qXvF+5YffPVaw== integrity sha512-UCQI9aQHRNskMH9AWqjjUfyPHOoO8fCW1iPjhOaijiFQ/8nr8TbfshQ5NKFXSCBdCUWIpuGO9664IeoL8LzWDA==
dependencies: dependencies:
"@techpass/passport-openidconnect" "^0.3.0" "@techpass/passport-openidconnect" "^0.3.0"
aws-sdk "^2.901.0" aws-sdk "^2.901.0"
@ -321,12 +321,12 @@
uuid "^8.3.2" uuid "^8.3.2"
zlib "^1.0.5" zlib "^1.0.5"
"@budibase/pro@1.0.142": "@budibase/pro@^1.0.145":
version "1.0.142" version "1.0.145"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.142.tgz#17cd53d67ce80e0cce2179caee0c03e6a0d7084e" resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.145.tgz#447a26d21ca94a14bfaa9d9cef5b9a7b7a6e7c17"
integrity sha512-c1SaRoVik/AVn4zNNsDciFeIr+P3J6Sc8hsE5M3pb0Zj/NzSEHXTesxcBVLlD2PYlwnvWPSoMvdDJKrEFHvOYQ== integrity sha512-j5/EGNsMoxy6YxYr5/JLQ+hSehKQrSYrmSPBBzQjQnMMeFNMqHLNlYDsrayXxkEt0ix4WGJxFKTZUR6cLO3nYA==
dependencies: dependencies:
"@budibase/backend-core" "1.0.142" "@budibase/backend-core" "1.0.145"
node-fetch "^2.6.1" node-fetch "^2.6.1"
"@cspotcode/source-map-consumer@0.8.0": "@cspotcode/source-map-consumer@0.8.0":