Moving table, datasource and datasource plus document types into the backend core.

This commit is contained in:
mike12345567 2022-05-25 10:52:19 +01:00
parent 58cfc29dc5
commit 62bc2f2be3
3 changed files with 29 additions and 3 deletions

View File

@ -15,6 +15,10 @@ exports.DocumentTypes = {
ROLE: "role", ROLE: "role",
MIGRATIONS: "migrations", MIGRATIONS: "migrations",
DEV_INFO: "devinfo", DEV_INFO: "devinfo",
TABLE: "ta",
ROW: "ro",
DATASOURCE: "datasource",
DATASOURCE_PLUS: "datasource_plus",
} }
exports.StaticDatabases = { exports.StaticDatabases = {

View File

@ -79,6 +79,28 @@ function getDocParams(docType, docId = null, otherProps = {}) {
} }
exports.getDocParams = getDocParams exports.getDocParams = getDocParams
/**
* Check if a given ID is that of a table.
* @returns {boolean}
*/
exports.isTableId = id => {
// this includes datasource plus tables
return (
id &&
(id.startsWith(`${DocumentTypes.TABLE}${SEPARATOR}`) ||
id.startsWith(`${DocumentTypes.DATASOURCE_PLUS}${SEPARATOR}`))
)
}
/**
* Check if a given ID is that of a datasource or datasource plus.
* @returns {boolean}
*/
exports.isDatasourceId = id => {
// this covers both datasources and datasource plus
return id && id.startsWith(`${DocumentTypes.DATASOURCE}${SEPARATOR}`)
}
/** /**
* Generates a new workspace ID. * Generates a new workspace ID.
* @returns {string} The new workspace ID which the workspace doc can be stored under. * @returns {string} The new workspace ID which the workspace doc can be stored under.

View File

@ -27,7 +27,9 @@ const DocumentTypes = {
APP_DEV: CoreDocTypes.APP_DEV, APP_DEV: CoreDocTypes.APP_DEV,
APP_METADATA: CoreDocTypes.APP_METADATA, APP_METADATA: CoreDocTypes.APP_METADATA,
ROLE: CoreDocTypes.ROLE, ROLE: CoreDocTypes.ROLE,
TABLE: "ta", TABLE: CoreDocTypes.TABLE,
DATASOURCE: CoreDocTypes.DATASOURCE,
DATASOURCE_PLUS: CoreDocTypes.DATASOURCE_PLUS,
ROW: "ro", ROW: "ro",
USER: "us", USER: "us",
AUTOMATION: "au", AUTOMATION: "au",
@ -36,8 +38,6 @@ const DocumentTypes = {
INSTANCE: "inst", INSTANCE: "inst",
LAYOUT: "layout", LAYOUT: "layout",
SCREEN: "screen", SCREEN: "screen",
DATASOURCE: "datasource",
DATASOURCE_PLUS: "datasource_plus",
QUERY: "query", QUERY: "query",
DEPLOYMENTS: "deployments", DEPLOYMENTS: "deployments",
METADATA: "metadata", METADATA: "metadata",