Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: cleanup unused type and utils (#13130)
boojackc0a786c2e948
diff --git a/frontend/src/components/CreateDatabasePrepForm/CreateDatabasePrepForm.vue b/frontend/src/components/CreateDatabasePrepForm/CreateDatabasePrepForm.vueindex 9e36df5991..4cf7ba7718 100644--- a/frontend/src/components/CreateDatabasePrepForm/CreateDatabasePrepForm.vue+++ b/frontend/src/components/CreateDatabasePrepForm/CreateDatabasePrepForm.vue@@ -184,7 +184,6 @@ import {isValidProjectName,UNKNOWN_PROJECT_NAME,} from "@/types";-import { INTERNAL_RDS_INSTANCE_USER_LIST } from "@/types/InstanceUser";import { Engine } from "@/types/proto/v1/common";import type { InstanceRole } from "@/types/proto/v1/instance_role_service";import { Issue, Issue_Type } from "@/types/proto/v1/issue_service";@@ -196,6 +195,8 @@ import {} from "@/utils";import { FeatureModal } from "../FeatureGuard";+const INTERNAL_RDS_INSTANCE_USER_LIST = ["rds_ad", "rdsadmin", "rds_iam"];+interface LocalState {projectName?: string;environmentName?: string;diff --git a/frontend/src/components/CustomApproval/Settings/components/common/utils.ts b/frontend/src/components/CustomApproval/Settings/components/common/utils.tsindex 029baad33c..49bb6bba8e 100644--- a/frontend/src/components/CustomApproval/Settings/components/common/utils.ts+++ b/frontend/src/components/CustomApproval/Settings/components/common/utils.ts@@ -4,7 +4,6 @@ import { type Factor, SQLTypeList } from "@/plugins/cel";import { t, te } from "@/plugins/i18n";import { useEnvironmentV1Store, useProjectV1List } from "@/store";import {- engineName,PresetRiskLevelList,SupportedSourceList,DEFAULT_PROJECT_NAME,@@ -12,9 +11,10 @@ import {import type { Risk } from "@/types/proto/v1/risk_service";import { Risk_Source, risk_SourceToJSON } from "@/types/proto/v1/risk_service";import {+ engineNameV1,extractEnvironmentResourceName,extractProjectResourceName,- supportedEngineList,+ supportedEngineV1List,} from "@/utils";export const sourceText = (source: Risk_Source) => {@@ -122,7 +122,7 @@ const FactorList = {"affected_rows","table_rows","sql_type",- "table_name",+ "table_name")),};@@ -172,8 +172,8 @@ const getProjectIdOptions = () => {};const getDBEndingOptions = () => {- return supportedEngineList().map<SelectOption>((type) => ({- label: engineName(type),+ return supportedEngineV1List().map<SelectOption>((type) => ({+ label: engineNameV1(type),value: type,}));};diff --git a/frontend/src/components/DataSourceSelect.vue b/frontend/src/components/DataSourceSelect.vuedeleted file mode 100644index 9a283fd7a3..0000000000--- a/frontend/src/components/DataSourceSelect.vue+++ /dev/null@@ -1,74 +0,0 @@-<template>- <select- class="btn-select w-full disabled:cursor-not-allowed"- :disabled="disabled"- @change="- (e) => {- $emit(- 'select-data-source-id',- parseInt((e.target as HTMLOptionElement).value)- );- }- "- >- <option disabled :selected="undefined === state.selectedId">- <template v-if="!database">- {{ $t("data-source.select-database-first") }}- </template>- <template v-else> {{ $t("data-source.select-data-source") }} </template>- </option>- <template v-if="database">- <option- v-for="(dataSource, index) in database.dataSourceList"- :key="index"- :value="dataSource.id"- :selected="dataSource.id == state.selectedId"- >- <template v-if="dataSource.type == 'RO'">- {{ dataSource.name }} ({{ $t("common.readonly") }})- </template>- <template v-else>- {{ dataSource.name }}- </template>- </option>- </template>- </select>-</template>--<script lang="ts">-import type { PropType } from "vue";-import { defineComponent, reactive } from "vue";-import type { Database } from "../types";--interface LocalState {- selectedId?: number;-}--export default defineComponent({- name: "DataSourceSelect",- props: {- selectedId: {- type: Number,- default: undefined,- },- database: {- type: Object as PropType<Database>,- default: undefined,- },- disabled: {- default: false,- type: Boolean,- },- },- emits: ["select-data-source-id"],- setup(props) {- const state = reactive<LocalState>({- selectedId: props.selectedId,- });-- return {- state,- };- },-});-</script>diff --git a/frontend/src/components/Database/DatabaseOverviewPanel.vue b/frontend/src/components/Database/DatabaseOverviewPanel.vueindex 2272f92f36..8e6eed87cc 100644--- a/frontend/src/components/Database/DatabaseOverviewPanel.vue+++ b/frontend/src/components/Database/DatabaseOverviewPanel.vue@@ -79,7 +79,7 @@<div v-if="allowGetSchema" class="py-6"><div- v-if="hasSchemaProperty"+ v-if="hasSchemaPropertyV1"class="flex flex-row justify-start items-center mb-4"><span class="text-lg leading-6 font-medium text-main mr-2">Schema</span>@@ -207,17 +207,17 @@ import TableDataTable from "@/components/TableDataTable.vue";import TaskTable from "@/components/TaskTable.vue";import ViewDataTable from "@/components/ViewDataTable.vue";import { useDBSchemaV1Store } from "@/store";-import type { ComposedDatabase, DataSource } from "@/types";+import type { ComposedDatabase } from "@/types";import type { Anomaly } from "@/types/proto/v1/anomaly_service";import { Engine, State } from "@/types/proto/v1/common";import { DatabaseMetadataView } from "@/types/proto/v1/database_service";+import { hasSchemaProperty } from "@/utils";import { SearchBox } from "../v2";interface LocalState {selectedSchemaName: string;tableNameSearchKeyword: string;externalTableNameSearchKeyword: string;- editingDataSource?: DataSource;}const props = defineProps({@@ -257,16 +257,8 @@ const databaseEngine = computed(() => {return props.database.instanceResource.engine;});-const hasSchemaProperty = computed(() => {- return (- databaseEngine.value === Engine.POSTGRES ||- databaseEngine.value === Engine.SNOWFLAKE ||- databaseEngine.value === Engine.ORACLE ||- databaseEngine.value === Engine.DM ||- databaseEngine.value === Engine.MSSQL ||- databaseEngine.value === Engine.REDSHIFT ||- databaseEngine.value === Engine.RISINGWAVE- );+const hasSchemaPropertyV1 = computed(() => {+ return hasSchemaProperty(databaseEngine.value);});watch(@@ -326,7 +318,7 @@ const databaseSchemaMetadata = computed(() => {});const tableList = computed(() => {- if (hasSchemaProperty.value) {+ if (hasSchemaPropertyV1.value) {return (schemaList.value.find((schema) => schema.name === state.selectedSchemaName@@ -337,7 +329,7 @@ const tableList = computed(() => {});const viewList = computed(() => {- if (hasSchemaProperty.value) {+ if (hasSchemaPropertyV1.value) {return (schemaList.value.find((schema) => schema.name === state.selectedSchemaName@@ -359,7 +351,7 @@ const externalTableList = computed(() => {});const functionList = computed(() => {- if (hasSchemaProperty.value) {+ if (hasSchemaPropertyV1.value) {return (schemaList.value.find((schema) => schema.name === state.selectedSchemaName@@ -370,7 +362,7 @@ const functionList = computed(() => {});const streamList = computed(() => {- if (hasSchemaProperty.value) {+ if (hasSchemaPropertyV1.value) {return (schemaList.value.find((schema) => schema.name === state.selectedSchemaName@@ -384,7 +376,7 @@ const streamList = computed(() => {});const taskList = computed(() => {- if (hasSchemaProperty.value) {+ if (hasSchemaPropertyV1.value) {return (schemaList.value.find((schema) => schema.name === state.selectedSchemaNamediff --git a/frontend/src/components/DatabaseName.vue b/frontend/src/components/DatabaseName.vuedeleted file mode 100644index 123a4e95b8..0000000000--- a/frontend/src/components/DatabaseName.vue+++ /dev/null@@ -1,29 +0,0 @@-<template>- <component :is="tag">- <span v-if="prefix" class="ml-1 text-gray-400">{{ prefix }}</span>- {{ database.name }}- </component>-</template>--<script lang="ts" setup>-import { computed } from "vue";-import type { Database } from "@/types";--const props = withDefaults(- defineProps<{- database: Database;- tag?: string;- }>(),- {- tag: "span",- }-);--const prefix = computed(() => {- const { database } = props;- if (database.instance.engine === "REDIS") {- return `${database.instance.name}`;- }- return "";-});-</script>diff --git a/frontend/src/components/ExternalTableDetailDrawer.vue b/frontend/src/components/ExternalTableDetailDrawer.vueindex 7de6317bde..e2b23bcc51 100644--- a/frontend/src/components/ExternalTableDetailDrawer.vue+++ b/frontend/src/components/ExternalTableDetailDrawer.vue@@ -143,9 +143,12 @@ import {useDBSchemaV1Store,} from "@/store";import { DEFAULT_PROJECT_NAME, defaultProject } from "@/types";-import { Engine } from "@/types/proto/v1/common";import { TableMetadata } from "@/types/proto/v1/database_service";-import { hasProjectPermissionV2, isDatabaseV1Queryable } from "@/utils";+import {+ hasProjectPermissionV2,+ hasSchemaProperty,+ isDatabaseV1Queryable,+} from "@/utils";import ColumnDataTable from "./ColumnDataTable/index.vue";import { SQLEditorButtonV1 } from "./DatabaseDetail";@@ -210,14 +213,8 @@ const allowQuery = computed(() => {return isDatabaseV1Queryable(database.value, currentUserV1.value);});-const hasSchemaProperty = computed(- () =>- instanceEngine.value === Engine.POSTGRES ||- instanceEngine.value === Engine.RISINGWAVE-);-const getTableName = (tableName: string) => {- if (hasSchemaProperty.value) {+ if (hasSchemaProperty(instanceEngine.value)) {return `"${props.schemaName}"."${tableName}"`;}return tableName;diff --git a/frontend/src/components/FunctionDataTable.vue b/frontend/src/components/FunctionDataTable.vueindex cf63525797..9cbe948413 100644--- a/frontend/src/components/FunctionDataTable.vue+++ b/frontend/src/components/FunctionDataTable.vue@@ -16,8 +16,8 @@ import type { PropType } from "vue";import { computed } from "vue";import { useI18n } from "vue-i18n";import type { ComposedDatabase } from "@/types";-import { Engine } from "@/types/proto/v1/common";import type { FunctionMetadata } from "@/types/proto/v1/database_service";+import { hasSchemaProperty } from "@/utils";import EllipsisSQLView from "./EllipsisSQLView.vue";const props = defineProps({@@ -39,25 +39,12 @@ const { t } = useI18n();const engine = computed(() => props.database.instanceResource.engine);-const isPostgres = computed(() => engine.value === Engine.POSTGRES);--const hasSchemaProperty = computed(() => {- return (- isPostgres.value ||- engine.value === Engine.SNOWFLAKE ||- engine.value === Engine.ORACLE ||- engine.value === Engine.DM ||- engine.value === Engine.MSSQL ||- engine.value === Engine.RISINGWAVE- );-});-const columns = computed(() => {const columns: (DataTableColumn<FunctionMetadata> & { hide?: boolean })[] = [{key: "name",title: t("common.schema"),- hide: !hasSchemaProperty.value,+ hide: !hasSchemaProperty(engine.value),ellipsis: {tooltip: true,},diff --git a/frontend/src/components/InstanceEngineIcon.vue b/frontend/src/components/InstanceEngineIcon.vuedeleted file mode 100644index 14b4ca50ff..0000000000--- a/frontend/src/components/InstanceEngineIcon.vue+++ /dev/null@@ -1,27 +0,0 @@-<template>- <NTooltip :disabled="!instance.engineVersion">- <template #trigger>- <div class="relative w-4" v-bind="$attrs">- <EngineIcon :engine="engineFromJSON(instance.engine)" />- <div- v-if="showStatus"- class="bg-green-400 border-surface-high rounded-full absolute border-2"- style="bottom: -3px; height: 9px; right: -3px; width: 9px"- />- </div>- </template>- <span>{{ instance.engineVersion }}</span>- </NTooltip>-</template>--<script lang="ts" setup>-import { NTooltip } from "naive-ui";-import { engineFromJSON } from "@/types/proto/v1/common";-import type { Instance } from "../types";-import { EngineIcon } from "./Icon";--defineProps<{- instance: Instance;- showStatus?: boolean;-}>();-</script>diff --git a/frontend/src/components/InstanceUserTable.vue b/frontend/src/components/InstanceUserTable.vuedeleted file mode 100644index 74ed1c435a..0000000000--- a/frontend/src/components/InstanceUserTable.vue+++ /dev/null@@ -1,55 +0,0 @@-<template>- <BBTable- :column-list="columnList"- :data-source="instanceUserList"- :show-header="true"- :row-clickable="false"- :left-bordered="true"- :right-bordered="true"- >- <template #body="{ rowData: instanceUser }">- <BBTableCell :left-padding="4" class="w-4">- {{ instanceUser.name }}- </BBTableCell>- <BBTableCell class="whitespace-pre-wrap break-all">- {{ instanceUser.grant.replaceAll("\n", "\n\n") }}- </BBTableCell>- </template>- </BBTable>-</template>--<script lang="ts">-import type { PropType } from "vue";-import { computed } from "vue";-import { useI18n } from "vue-i18n";-import { BBTable, BBTableCell } from "@/bbkit";-import type { InstanceUser } from "../types/InstanceUser";--export default {- name: "InstanceUserTable",- components: {- BBTable,- BBTableCell,- },- props: {- instanceUserList: {- required: true,- type: Object as PropType<InstanceUser[]>,- },- },- setup() {- const { t } = useI18n();- const columnList = computed(() => [- {- title: t("common.user"),- },- {- title: t("instance.grants"),- },- ]);- return {- columnList,- };- },-};-</script>diff --git a/frontend/src/components/TableDataTable.vue b/frontend/src/components/TableDataTable.vueindex 9402cf4d46..e19891d33e 100644--- a/frontend/src/components/TableDataTable.vue+++ b/frontend/src/components/TableDataTable.vue@@ -36,7 +36,7 @@ import type { ComposedDatabase } from "@/types";import { Engine } from "@/types/proto/v1/common";import type { TableMetadata } from "@/types/proto/v1/database_service";import { DataClassificationSetting_DataClassificationConfig as DataClassificationConfig } from "@/types/proto/v1/setting_service";-import { bytesToString, isGhostTable } from "@/utils";+import { bytesToString, hasSchemaProperty, isGhostTable } from "@/utils";import TableDetailDrawer from "./TableDetailDrawer.vue";type LocalState = {@@ -100,16 +100,6 @@ const isPostgres = computed(() => engine.value === Engine.POSTGRES || engine.value === Engine.RISINGWAVE);-const hasSchemaProperty = computed(() => {- return (- isPostgres.value ||- engine.value === Engine.SNOWFLAKE ||- engine.value === Engine.ORACLE ||- engine.value === Engine.DM ||- engine.value === Engine.MSSQL- );-});-const hasClassificationProperty = computed(() => {return !!classificationConfig.value;});@@ -140,7 +130,7 @@ const columns = computed(() => {{key: "schema",title: t("common.schema"),- hide: !hasSchemaProperty.value,+ hide: !hasSchemaProperty(engine.value),ellipsis: {tooltip: true,},diff --git a/frontend/src/components/TableDetailDrawer.vue b/frontend/src/components/TableDetailDrawer.vueindex 7428eecab9..cc9ca36521 100644--- a/frontend/src/components/TableDetailDrawer.vue+++ b/frontend/src/components/TableDetailDrawer.vue@@ -259,6 +259,7 @@ import type { DataClassificationSetting_DataClassificationConfig } from "@/typesimport {bytesToString,hasProjectPermissionV2,+ hasSchemaProperty,isDatabaseV1Queryable,isGhostTable,} from "@/utils";@@ -339,12 +340,6 @@ const allowQuery = computed(() => {return isDatabaseV1Queryable(database.value, currentUserV1.value);});-const hasSchemaProperty = computed(- () =>- instanceEngine.value === Engine.POSTGRES ||- instanceEngine.value === Engine.RISINGWAVE-);-const hasPartitionTables = computed(() => {return (// Only show partition tables for PostgreSQL.@@ -375,7 +370,7 @@ const shouldShowColumnTable = computed(() => {});const getTableName = (tableName: string) => {- if (hasSchemaProperty.value) {+ if (hasSchemaProperty(instanceEngine.value)) {return `"${props.schemaName}"."${tableName}"`;}return tableName;diff --git a/frontend/src/components/TableSchemaViewer.vue b/frontend/src/components/TableSchemaViewer.vueindex 34cc6f60dd..f047c0ad4b 100644--- a/frontend/src/components/TableSchemaViewer.vue+++ b/frontend/src/components/TableSchemaViewer.vue@@ -47,13 +47,13 @@ import {useSettingV1Store,} from "@/store";import type { ComposedDatabase } from "@/types";-import { Engine } from "@/types/proto/v1/common";import {DatabaseMetadata,DatabaseMetadataView,SchemaMetadata,TableMetadata,} from "@/types/proto/v1/database_service";+import { hasSchemaProperty } from "@/utils";const props = defineProps<{database: ComposedDatabase;@@ -98,7 +98,7 @@ const tableMetadata = computed(() => {const resourceName = computed(() => {if (props.table) {- if (hasSchemaProperty.value) {+ if (hasSchemaProperty(engine.value)) {return `${props.schema}.${props.table}`;} else {return props.table;@@ -110,18 +110,6 @@ const resourceName = computed(() => {return props.database.name;});-const hasSchemaProperty = computed(() => {- return (- engine.value === Engine.POSTGRES ||- engine.value === Engine.SNOWFLAKE ||- engine.value === Engine.ORACLE ||- engine.value === Engine.DM ||- engine.value === Engine.MSSQL ||- engine.value === Engine.REDSHIFT ||- engine.value === Engine.RISINGWAVE- );-});-onMounted(async () => {await dbSchemaStore.getOrFetchDatabaseMetadata({database: props.database.name,diff --git a/frontend/src/components/ViewDataTable.vue b/frontend/src/components/ViewDataTable.vueindex 7b0f23fc77..ba20a80609 100644--- a/frontend/src/components/ViewDataTable.vue+++ b/frontend/src/components/ViewDataTable.vue@@ -16,8 +16,8 @@ import type { PropType } from "vue";import { computed } from "vue";import { useI18n } from "vue-i18n";import type { ComposedDatabase } from "@/types";-import { Engine } from "@/types/proto/v1/common";import type { ViewMetadata } from "@/types/proto/v1/database_service";+import { hasSchemaProperty } from "@/utils";import EllipsisSQLView from "./EllipsisSQLView.vue";const props = defineProps({@@ -39,14 +39,6 @@ const { t } = useI18n();const engine = computed(() => props.database.instanceResource.engine);-const hasSchemaProperty = computed(() => {- return (- engine.value === Engine.POSTGRES ||- engine.value === Engine.SNOWFLAKE ||- engine.value === Engine.RISINGWAVE- );-});-const columns = computed(() => {const columns: (DataTableColumn<ViewMetadata> & { hide?: boolean })[] = [{@@ -76,7 +68,7 @@ const columns = computed(() => {});const getViewName = (viewName: string) => {- if (hasSchemaProperty.value) {+ if (hasSchemaProperty(engine.value)) {return `"${props.schemaName}"."${viewName}"`;}return viewName;diff --git a/frontend/src/main.ts b/frontend/src/main.tsindex f5814c9a27..c49f22a6d8 100644--- a/frontend/src/main.ts+++ b/frontend/src/main.ts@@ -18,15 +18,12 @@ import { router } from "./router";import { AUTH_SIGNIN_MODULE } from "./router/auth";import { pinia, pushNotification, useAuthStore } from "./store";import {- environmentName,humanizeTs,humanizeDuration,humanizeDurationV1,humanizeDate,- instanceName,isDev,isRelease,- projectName,sizeToFit,urlfy,} from "./utils";@@ -136,9 +133,6 @@ app.config.globalProperties.isRelease = isRelease();app.config.globalProperties.sizeToFit = sizeToFit;app.config.globalProperties.urlfy = urlfy;app.config.globalProperties.isEmpty = isEmpty;-app.config.globalProperties.environmentName = environmentName;-app.config.globalProperties.projectName = projectName;-app.config.globalProperties.instanceName = instanceName;app// Need to use a directive on the element.diff --git a/frontend/src/shims-vue-globals.d.ts b/frontend/src/shims-vue-globals.d.tsindex a10a80efe9..e8dc77bb0e 100644--- a/frontend/src/shims-vue-globals.d.ts+++ b/frontend/src/shims-vue-globals.d.ts@@ -1,13 +1,10 @@import type dayjs from "dayjs";import type { isEmpty } from "lodash-es";import type {- environmentName,humanizeTs,humanizeDuration,humanizeDurationV1,humanizeDate,- instanceName,- projectName,sizeToFit,urlfy,} from "./utils";@@ -26,8 +23,5 @@ declare module "vue" {sizeToFit: typeof sizeToFit;urlfy: typeof urlfy;isEmpty: typeof isEmpty;- environmentName: typeof environmentName;- projectName: typeof projectName;- instanceName: typeof instanceName;}}diff --git a/frontend/src/store/modules/user.ts b/frontend/src/store/modules/user.tsindex 6712d7c5cf..ad59680088 100644--- a/frontend/src/store/modules/user.ts+++ b/frontend/src/store/modules/user.ts@@ -3,7 +3,6 @@ import { defineStore } from "pinia";import { computed, ref, watch } from "vue";import { authServiceClient } from "@/grpcweb";import {- type PrincipalType,PresetRoleType,PRESET_WORKSPACE_ROLES,ALL_USERS_USER_EMAIL,@@ -219,15 +218,3 @@ export const getUpdateMaskFromUsers = (}return updateMask;};--export const convertUserTypeToPrincipalType = (- userType: UserType-): PrincipalType => {- if (userType === UserType.SYSTEM_BOT) {- return "SYSTEM_BOT";- } else if (userType === UserType.SERVICE_ACCOUNT) {- return "SERVICE_ACCOUNT";- } else {- return "END_USER";- }-};diff --git a/frontend/src/store/modules/v1/common.ts b/frontend/src/store/modules/v1/common.tsindex 55131f224f..4e4b46374c 100644--- a/frontend/src/store/modules/v1/common.ts+++ b/frontend/src/store/modules/v1/common.ts@@ -1,4 +1,4 @@-import type { ResourceId, Project, SheetId } from "@/types";+import type { ResourceId } from "@/types";import { UNKNOWN_ID } from "@/types";export const userNamePrefix = "users/";@@ -132,22 +132,6 @@ export const getProjectNameAndDatabaseGroupName = (name: string): string[] => {return tokens;};-export const getProjectPathByLegacyProject = (project: Project): string => {- return `${projectNamePrefix}${project.resourceId}`;-};--export const getSheetPathByLegacyProject = (- project: Project,- sheetId: SheetId-): string => {- if (sheetId === UNKNOWN_ID) {- return "";- }- return `${getProjectPathByLegacyProject(- project- )}/${sheetNamePrefix}${sheetId}`;-};-export const getProjectPathFromRepoName = (repoName: string): string => {return repoName.split("/gitOpsInfo")[0];};diff --git a/frontend/src/store/modules/v1/vcs_provider.ts b/frontend/src/store/modules/v1/vcs_provider.tsindex 09c17301ef..0532837b06 100644--- a/frontend/src/store/modules/v1/vcs_provider.ts+++ b/frontend/src/store/modules/v1/vcs_provider.ts@@ -4,7 +4,6 @@ import { defineStore } from "pinia";import { computed } from "vue";import { vcsProviderServiceClient } from "@/grpcweb";import { useCache } from "@/store/cache";-import type { VCSId } from "@/types";import type { VCSProvider } from "@/types/proto/v1/vcs_provider_service";import { vcsProviderPrefix } from "./common";@@ -67,7 +66,7 @@ export const useVCSProviderStore = defineStore("vcs_provider", () => {return vcs;};- const getVCSById = (vcsId: VCSId) => {+ const getVCSById = (vcsId: string) => {return getVCSByName(`${vcsProviderPrefix}${vcsId}`);};diff --git a/frontend/src/types/InstanceUser.ts b/frontend/src/types/InstanceUser.tsdeleted file mode 100644index 68dc6985d1..0000000000--- a/frontend/src/types/InstanceUser.ts+++ /dev/null@@ -1,18 +0,0 @@-import type { InstanceId, InstanceUserId } from "./id";--export type InstanceUser = {- id: InstanceUserId;-- // Related fields- instanceId: InstanceId;-- // Domain specific fields- name: string;- grant: string;-};--export const INTERNAL_RDS_INSTANCE_USER_LIST = [- "rds_ad",- "rdsadmin",- "rds_iam",-];diff --git a/frontend/src/types/common.ts b/frontend/src/types/common.tsindex fc08434801..1d448ced58 100644--- a/frontend/src/types/common.ts+++ b/frontend/src/types/common.ts@@ -1,11 +1,5 @@-import { EMPTY_ID, UNKNOWN_ID } from "./const";-import type { DataSource } from "./dataSource";-import type { Database } from "./database";-import type { Environment } from "./environment";+import { UNKNOWN_ID } from "./const";import type { CommandId, CommandRegisterId } from "./id";-import type { Instance } from "./instance";-import type { Principal } from "./principal";-import type { Project, ProjectMember } from "./project";import type { SQLReviewPolicy } from "./sqlReview";// System bot id@@ -13,23 +7,9 @@ export const SYSTEM_BOT_ID = 1;// System bot emailexport const SYSTEM_BOT_EMAIL = "[email protected]";-// The project to hold those databases synced from the instance but haven't been assigned an application-// project yet. We can't use UNKNOWN_ID because of referential integrity.-export const DEFAULT_PROJECT_ID = 1;--export const ALL_DATABASE_NAME = "*";-// For text input, we do validation if there is no further keystroke after 1sexport const TEXT_VALIDATION_DELAY = 1000;-// Normally, we poll issue every 10s to fetch any update from the server side.-// If change occurs, then we will start the poll from 0.2s, 0.4s, 0.8s, 1.6s, 3.2s, 5s, 10s, 10s ... with jitter-// We do this because new update is more likely to happen after the initial change (e.g task gets new update after changing its status)-export const NORMAL_POLL_INTERVAL = 10000;-export const MINIMUM_POLL_INTERVAL = 200;-// Add jitter to avoid timer from different clients converging to the same polling frequency.-export const POLL_JITTER = 200;-// Link to inquire enterprise planexport const ENTERPRISE_INQUIRE_LINK ="https://www.bytebase.com/contact-us?source=console";@@ -51,130 +31,13 @@ export type Command = {run: () => void;};-export type ResourceType =- | "PRINCIPAL"- | "ENVIRONMENT"- | "PROJECT"- | "PROJECT_MEMBER"- | "INSTANCE"- | "DATABASE"- | "DATA_SOURCE"- | "POLICY"- | "ACTIVITY"- | "REPOSITORY"- | "ANOMALY"- | "DEPLOYMENT_CONFIG"- | "SHEET"- | "SQL_REVIEW"- | "AUDIT_LOG";+export type ResourceType = "SQL_REVIEW";interface ResourceMaker {- (type: "PRINCIPAL"): Principal;- (type: "ENVIRONMENT"): Environment;- (type: "PROJECT"): Project;- (type: "PROJECT_MEMBER"): ProjectMember;- (type: "INSTANCE"): Instance;- (type: "DATABASE"): Database;- (type: "DATA_SOURCE"): DataSource;(type: "SQL_REVIEW"): SQLReviewPolicy;}const makeUnknown = (type: ResourceType) => {- // Have to omit creator and updater to avoid recursion.- const UNKNOWN_PRINCIPAL: Principal = {- id: UNKNOWN_ID,- type: "END_USER",- name: "<<Unknown principal>>",- email: "",- role: "DEVELOPER",- } as Principal;-- const UNKNOWN_ENVIRONMENT: Environment = {- id: UNKNOWN_ID,- resourceId: "",- rowStatus: "NORMAL",- name: "<<Unknown environment>>",- order: 0,- tier: "UNPROTECTED",- };-- const UNKNOWN_PROJECT: Project = {- id: UNKNOWN_ID,- resourceId: "",- rowStatus: "NORMAL",- name: "<<Unknown project>>",- key: "UNK",- memberList: [],- workflowType: "UI",- };-- const UNKNOWN_PROJECT_MEMBER: ProjectMember = {- id: `projects/${UNKNOWN_ID}/roles/${UNKNOWN_ID}/principals/${UNKNOWN_ID}`,- project: UNKNOWN_PROJECT,- role: "DEVELOPER",- principal: UNKNOWN_PRINCIPAL,- };-- const UNKNOWN_INSTANCE: Instance = {- id: UNKNOWN_ID,- resourceId: "",- rowStatus: "NORMAL",- environment: UNKNOWN_ENVIRONMENT,- dataSourceList: [],- name: "<<Unknown instance>>",- engine: "MYSQL",- engineVersion: "",- externalLink: "",- srv: false,- authenticationDatabase: "",- };-- const UNKNOWN_DATABASE: Database = {- id: UNKNOWN_ID,- instanceId: UNKNOWN_ID,- instance: UNKNOWN_INSTANCE,- projectId: UNKNOWN_ID,- project: UNKNOWN_PROJECT,- labels: [],- dataSourceList: [],- name: "<<Unknown database>>",- characterSet: "",- collation: "",- syncStatus: "NOT_FOUND",- lastSuccessfulSyncTs: 0,- schemaVersion: "",- };-- const UNKNOWN_DATA_SOURCE: DataSource = {- id: UNKNOWN_ID,- instanceId: UNKNOWN_ID,- databaseId: UNKNOWN_ID,- name: "<<Unknown data source>>",- type: "RO",- username: "",- password: "",- sslCa: "",- sslCert: "",- sslKey: "",- host: "",- port: "",- database: "",- options: {- srv: false,- authenticationDatabase: "",- authenticationPrivateKey: "",- sid: "",- serviceName: "",- sshHost: "",- sshPort: "",- sshUser: "",- sshPassword: "",- sshPrivateKey: "",- },- // UI-only fields- updateSsl: false,- };-const UNKNOWN_SQL_REVIEW_POLICY: SQLReviewPolicy = {id: `${UNKNOWN_ID}`,enforce: false,@@ -184,139 +47,9 @@ const makeUnknown = (type: ResourceType) => {};switch (type) {- case "PRINCIPAL":- return UNKNOWN_PRINCIPAL;- case "ENVIRONMENT":- return UNKNOWN_ENVIRONMENT;- case "PROJECT":- return UNKNOWN_PROJECT;- case "PROJECT_MEMBER":- return UNKNOWN_PROJECT_MEMBER;- case "INSTANCE":- return UNKNOWN_INSTANCE;- case "DATABASE":- return UNKNOWN_DATABASE;- case "DATA_SOURCE":- return UNKNOWN_DATA_SOURCE;case "SQL_REVIEW":return UNKNOWN_SQL_REVIEW_POLICY;}};export const unknown = makeUnknown as ResourceMaker;--const makeEmpty = (type: ResourceType) => {- // Have to omit creator and updater to avoid recursion.- const EMPTY_PRINCIPAL: Principal = {- id: EMPTY_ID,- type: "END_USER",- name: "",- email: "",- role: "DEVELOPER",- } as Principal;-- const EMPTY_ENVIRONMENT: Environment = {- id: EMPTY_ID,- resourceId: "",- rowStatus: "NORMAL",- name: "",- order: 0,- tier: "UNPROTECTED",- };-- const EMPTY_PROJECT: Project = {- id: EMPTY_ID,- resourceId: "",- rowStatus: "NORMAL",- name: "",- key: "",- memberList: [],- workflowType: "UI",- };-- const EMPTY_PROJECT_MEMBER: ProjectMember = {- id: `projects/${EMPTY_ID}/roles/${EMPTY_ID}/principals/${EMPTY_ID}`,- project: EMPTY_PROJECT,- role: "DEVELOPER",- principal: EMPTY_PRINCIPAL,- };-- const EMPTY_INSTANCE: Instance = {- id: EMPTY_ID,- resourceId: "",- rowStatus: "NORMAL",- environment: EMPTY_ENVIRONMENT,- dataSourceList: [],- name: "",- engine: "MYSQL",- engineVersion: "",- externalLink: "",- srv: false,- authenticationDatabase: "",- };-- const EMPTY_DATABASE: Database = {- id: EMPTY_ID,- instanceId: UNKNOWN_ID,- instance: EMPTY_INSTANCE,- projectId: UNKNOWN_ID,- project: EMPTY_PROJECT,- dataSourceList: [],- labels: [],- name: "",- characterSet: "",- collation: "",- syncStatus: "NOT_FOUND",- lastSuccessfulSyncTs: 0,- schemaVersion: "",- };-- const EMPTY_DATA_SOURCE: DataSource = {- id: EMPTY_ID,- instanceId: UNKNOWN_ID,- databaseId: UNKNOWN_ID,- name: "",- type: "RO",- username: "",- password: "",- sslCa: "",- sslCert: "",- sslKey: "",- host: "",- port: "",- database: "",- options: {- srv: false,- authenticationDatabase: "",- authenticationPrivateKey: "",- sid: "",- serviceName: "",- sshHost: "",- sshPort: "",- sshUser: "",- sshPassword: "",- sshPrivateKey: "",- },- // UI-only fields- updateSsl: false,- };-- switch (type) {- case "PRINCIPAL":- return EMPTY_PRINCIPAL;- case "ENVIRONMENT":- return EMPTY_ENVIRONMENT;- case "PROJECT":- return EMPTY_PROJECT;- case "PROJECT_MEMBER":- return EMPTY_PROJECT_MEMBER;- case "INSTANCE":- return EMPTY_INSTANCE;- case "DATABASE":- return EMPTY_DATABASE;- case "DATA_SOURCE":- return EMPTY_DATA_SOURCE;- }-};--export const empty = makeEmpty as ResourceMaker;diff --git a/frontend/src/types/dataSource.ts b/frontend/src/types/dataSource.tsindex 2e6edcd90f..d0d6204ca8 100644--- a/frontend/src/types/dataSource.ts+++ b/frontend/src/types/dataSource.ts@@ -1,7 +1,3 @@-// For now the ADMIN requires the same database privilege as RW.-// The seperation is to make it explicit which one serves as the ADMIN data source,-import type { DatabaseId, DataSourceId, InstanceId } from "./id";-// which from the ops perspective, having different meaning from the normal RW data source.export type DataSourceType = "ADMIN" | "RW" | "RO";@@ -20,29 +16,3 @@ export interface DataSourceOptions {sshPrivateKey: string;authenticationPrivateKey: string;}--export type DataSource = {- id: DataSourceId;-- // Related fields- databaseId: DatabaseId;- instanceId: InstanceId;-- // Domain specific fields- name: string;- type: DataSourceType;- // In mysql, username can be empty which means anonymous user- username: string;- password?: string;- sslCa?: string;- sslCert?: string;- sslKey?: string;- host: string;- port: string;- database: string;-- options: DataSourceOptions;- // UI-only fields- updateSsl?: boolean;- updateSsh?: boolean;-};diff --git a/frontend/src/types/database.ts b/frontend/src/types/database.tsdeleted file mode 100644index 5d7b548829..0000000000--- a/frontend/src/types/database.ts+++ /dev/null@@ -1,31 +0,0 @@-// We periodically sync the underlying db schema and stores those info-// in the "database" object.-// Physically, a database belongs to an instance. Logically, it belongs to a project.-import type { DataSource } from "./dataSource";-import type { DatabaseId, InstanceId, ProjectId } from "./id";-import type { Instance } from "./instance";-import type { Project } from "./project";--// "OK" means we find the database with the same name.-// "NOT_FOUND" means no matching database name found, this usually means someone changes the underlying db name without Bytebase knowledge.-export type DatabaseSyncStatus = "OK" | "NOT_FOUND";-// Database-export type Database = {- id: DatabaseId;-- // Related fields- projectId: ProjectId;- project: Project;- instanceId: InstanceId;- instance: Instance;- dataSourceList: DataSource[];-- // Domain specific fields- syncStatus: DatabaseSyncStatus;- lastSuccessfulSyncTs: number;- name: string;- characterSet: string;- collation: string;- schemaVersion: string;- labels: { key: string; value: string }[];-};diff --git a/frontend/src/types/environment.ts b/frontend/src/types/environment.tsdeleted file mode 100644index 22d02c9110..0000000000--- a/frontend/src/types/environment.ts+++ /dev/null@@ -1,15 +0,0 @@-import type { RowStatus } from "./common";-import type { EnvironmentId } from "./id";--export type Environment = {- id: EnvironmentId;- resourceId: string;-- // Standard fields- rowStatus: RowStatus;-- // Domain specific fields- name: string;- order: number;- tier: "PROTECTED" | "UNPROTECTED";-};diff --git a/frontend/src/types/id.ts b/frontend/src/types/id.tsindex 0850b2433c..b469b9cb80 100644--- a/frontend/src/types/id.ts+++ b/frontend/src/types/id.ts@@ -4,29 +4,6 @@ export type ResourceId = string;// IdType includes auto incremental int in database and resource id.export type IdType = number | ResourceId;-export type ExecutionId = IdType;--export type PrincipalId = IdType;--export type ProjectId = IdType;--export type EnvironmentId = IdType;--export type InstanceId = IdType;--export type InstanceUserId = string;--export type DataSourceId = IdType;--export type DatabaseId = IdType;--export type VCSId = IdType;--export type RepositoryId = IdType;--export type MigrationHistoryId = string;-export type CommandId = string;-export type CommandRegisterId = string;-export type SheetId = IdType;+export type CommandRegisterId = string;diff --git a/frontend/src/types/index.ts b/frontend/src/types/index.tsindex 0a3873f94e..c60ebb1154 100644--- a/frontend/src/types/index.ts+++ b/frontend/src/types/index.ts@@ -4,22 +4,15 @@ export * from "./auditLog";export * from "./auth";export * from "./common";export * from "./const";-export * from "./database";export * from "./dataSource";-export * from "./environment";export * from "./error";export * from "./help";export * from "./id";-export * from "./instance";export * from "./issue";-export * from "./member";export * from "./notification";export * from "./oauth";export * from "./plan";-export * from "./principal";-export * from "./project";-export * from "./repository";-export * from "./sql";+export * from "./member";export * from "./sqlAdvice";export * from "./store";export * from "./vcs";@@ -28,7 +21,6 @@ export * from "./sheet";export * from "./sqlReview";export * from "./utils";export * from "./externalApproval";-export * from "./mfa";export * from "./risk";export * from "./workspaceApprovalSetting";export * from "./review";diff --git a/frontend/src/types/instance.ts b/frontend/src/types/instance.tsdeleted file mode 100644index fb230d8d17..0000000000--- a/frontend/src/types/instance.ts+++ /dev/null@@ -1,249 +0,0 @@-import type { DataSource } from ".";-import type { RowStatus } from "./common";-import type { Environment } from "./environment";-import type { InstanceId, MigrationHistoryId } from "./id";-import { Engine } from "./proto/v1/common";--export const EngineTypeList = [- "CLICKHOUSE",- "MYSQL",- "POSTGRES",- "SNOWFLAKE",- "TIDB",- "MONGODB",- "SPANNER",- "REDIS",- "ORACLE",- "MSSQL",- "REDSHIFT",- "MARIADB",- "OCEANBASE",- "DM",- "RISINGWAVE",- "BIGQUERY",- "DYNAMODB",- "DATABRICKS",-] as const;--export type EngineType = (typeof EngineTypeList)[number];--export function convertEngineType(type: EngineType): Engine {- switch (type) {- case "CLICKHOUSE":- return Engine.CLICKHOUSE;- case "MYSQL":- return Engine.MYSQL;- case "POSTGRES":- return Engine.POSTGRES;- case "SNOWFLAKE":- return Engine.SNOWFLAKE;- case "TIDB":- return Engine.TIDB;- case "MONGODB":- return Engine.MONGODB;- case "SPANNER":- return Engine.SPANNER;- case "REDIS":- return Engine.REDIS;- case "ORACLE":- return Engine.ORACLE;- case "MSSQL":- return Engine.MSSQL;- case "REDSHIFT":- return Engine.REDSHIFT;- case "MARIADB":- return Engine.MARIADB;- case "OCEANBASE":- return Engine.OCEANBASE;- case "DM":- return Engine.DM;- case "RISINGWAVE":- return Engine.RISINGWAVE;- case "BIGQUERY":- return Engine.BIGQUERY;- case "DYNAMODB":- return Engine.DYNAMODB;- case "DATABRICKS":- return Engine.DATABRICKS;- }- return Engine.ENGINE_UNSPECIFIED;-}--export function isPostgresFamily(type: Engine): boolean {- return (- type == Engine.POSTGRES ||- type == Engine.REDSHIFT ||- type == Engine.RISINGWAVE- );-}--export function defaultCharset(type: EngineType): string {- switch (type) {- case "CLICKHOUSE":- case "SNOWFLAKE":- return "";- case "MYSQL":- case "TIDB":- case "MARIADB":- case "OCEANBASE":- return "utf8mb4";- case "POSTGRES":- return "UTF8";- case "MONGODB":- return "";- case "SPANNER":- return "";- case "REDIS":- return "";- case "ORACLE":- return "UTF8";- case "DM":- return "UTF8";- case "MSSQL":- return "";- case "REDSHIFT":- return "UNICODE";- case "RISINGWAVE":- return "UTF8";- case "BIGQUERY":- return "";- case "DYNAMODB":- return "";- case "DATABRICKS":- return "";- }- return "";-}--export function engineName(type: EngineType): string {- switch (type) {- case "CLICKHOUSE":- return "ClickHouse";- case "MYSQL":- return "MySQL";- case "POSTGRES":- return "PostgreSQL";- case "SNOWFLAKE":- return "Snowflake";- case "TIDB":- return "TiDB";- case "MONGODB":- return "MongoDB";- case "SPANNER":- return "Spanner";- case "REDIS":- return "Redis";- case "ORACLE":- return "Oracle";- case "MSSQL":- return "MSSQL";- case "REDSHIFT":- return "Redshift";- case "MARIADB":- return "MariaDB";- case "OCEANBASE":- return "OceanBase";- case "DM":- return "DM";- case "RISINGWAVE":- return "RisingWave";- case "BIGQUERY":- return "BigQuery";- case "DYNAMODB":- return "DynamoDB";- case "DATABRICKS":- return "Databricks";- }- return "";-}--export function defaultCollation(type: EngineType): string {- switch (type) {- case "CLICKHOUSE":- case "SNOWFLAKE":- return "";- case "MYSQL":- case "TIDB":- case "MARIADB":- case "OCEANBASE":- return "utf8mb4_general_ci";- // For postgres, we don't explicitly specify a default since the default might be UNSET (denoted by "C").- // If that's the case, setting an explicit default such as "en_US.UTF-8" might fail if the instance doesn't- // install it.- case "POSTGRES":- case "RISINGWAVE":- return "";- case "MONGODB":- return "";- case "SPANNER":- return "";- case "REDIS":- return "";- case "ORACLE":- return "BINARY_CI";- case "MSSQL":- return "";- case "REDSHIFT":- return "";- case "DM":- return "BINARY_CI";- case "BIGQUERY":- return "";- case "DYNAMODB":- return "";- case "DATABRICKS":- return "";- }-}--export type Instance = {- id: InstanceId;- resourceId: string;- rowStatus: RowStatus;-- // Related fields- environment: Environment;- // An instance must have a admin data source, maybe a read-only data source.- dataSourceList: DataSource[];-- // Domain specific fields- name: string;- engine: EngineType;- engineVersion: string;- externalLink?: string;- srv: boolean;- authenticationDatabase: string;-};--export type MigrationSchemaStatus = "UNKNOWN" | "OK" | "NOT_EXIST";--export type InstanceMigration = {- status: MigrationSchemaStatus;- error: string;-};--export type MigrationSource = "UI" | "VCS" | "LIBRARY";--export type MigrationType = "BASELINE" | "MIGRATE" | "BRANCH" | "DATA";--export type MigrationStatus = "PENDING" | "DONE" | "FAILED";--export type MigrationHistory = {- id: MigrationHistoryId;- creator: string;- createdTs: number;- updater: string;- updatedTs: number;- releaseVersion: string;- database: string;- source: MigrationSource;- type: MigrationType;- status: MigrationStatus;- version: string;- description: string;- statement: string;- schema: string;- schemaPrev: string;- executionDurationNs: number;- issueId: number;-};diff --git a/frontend/src/types/member.ts b/frontend/src/types/member.tsindex 6d6e8ad66c..3f49f30c11 100644--- a/frontend/src/types/member.ts+++ b/frontend/src/types/member.ts@@ -1,7 +1,4 @@-export type MemberStatus = "INVITED" | "ACTIVE";--export type RoleType = "OWNER" | "DBA" | "DEVELOPER";-+// IAM related resource definition.export interface DatabaseResource {databaseName: string;schema?: string;diff --git a/frontend/src/types/mfa.ts b/frontend/src/types/mfa.tsdeleted file mode 100644index 892ab66e1e..0000000000--- a/frontend/src/types/mfa.ts+++ /dev/null@@ -1,3 +0,0 @@-// make linter happy-// remove this if we really have something to export-export {};diff --git a/frontend/src/types/onboardingGuide.ts b/frontend/src/types/onboardingGuide.tsdeleted file mode 100644index e69de29bb2..0000000000diff --git a/frontend/src/types/principal.ts b/frontend/src/types/principal.tsdeleted file mode 100644index 37619208df..0000000000--- a/frontend/src/types/principal.ts+++ /dev/null@@ -1,18 +0,0 @@-// This is a facet of the underlying identity entity.-// For now, there is only user type. In the future,-import type { PrincipalId } from "./id";-import type { RoleType } from "./member";--// we may support application/bot identity.-export type PrincipalType = "END_USER" | "SYSTEM_BOT" | "SERVICE_ACCOUNT";--export type Principal = {- id: PrincipalId;-- // Domain specific fields- type: PrincipalType;- name: string;- email: string;- role: RoleType;- serviceKey: string;-};diff --git a/frontend/src/types/project.ts b/frontend/src/types/project.tsdeleted file mode 100644index d6ebb24b38..0000000000--- a/frontend/src/types/project.ts+++ /dev/null@@ -1,43 +0,0 @@-import type {- VCSProvider,- VCSRepository,-} from "@/types/proto/v1/vcs_provider_service";-import type { RowStatus } from "./common";-import type { ProjectId } from "./id";-import type { Principal } from "./principal";-import type { RepositoryConfig } from "./repository";--export type ProjectWorkflowType = "UI" | "VCS";--// Project-export type Project = {- id: ProjectId;- resourceId: string;- rowStatus: RowStatus;-- // Domain specific fields- name: string;- key: string;- // Returns the member list directly because we need it quite frequently in order- // to do various access check.- memberList: ProjectMember[];- workflowType: ProjectWorkflowType;-};--// Project Member-export type ProjectMember = {- id: string; // projects/%s/roles/%s/principals/%d-- // Related fields- project: Project;-- // Domain specific fields- role: string;- principal: Principal;-};--export type ProjectRepositoryConfig = {- vcs: VCSProvider;- repositoryInfo: VCSRepository;- repositoryConfig: RepositoryConfig;-};diff --git a/frontend/src/types/repository.ts b/frontend/src/types/repository.tsdeleted file mode 100644index a8a797f986..0000000000--- a/frontend/src/types/repository.ts+++ /dev/null@@ -1,6 +0,0 @@-export type RepositoryConfig = {- baseDirectory: string;- branch: string;- resourceId: string;- databaseGroup: string;-};diff --git a/frontend/src/types/sql.ts b/frontend/src/types/sql.tsdeleted file mode 100644index 8d93b67094..0000000000--- a/frontend/src/types/sql.ts+++ /dev/null@@ -1,11 +0,0 @@-import type { InstanceId } from "./id";--export type QueryInfo = {- instanceId: InstanceId;- databaseName?: string;- dataSourceId?: string;- statement: string;- limit?: number;- // exportFomat includes QUERY, CSV, JSON.- exportFormat?: string;-};diff --git a/frontend/src/types/sqlEditor/editor.ts b/frontend/src/types/sqlEditor/editor.tsindex 51a2a11c1d..4d5bcc32d8 100644--- a/frontend/src/types/sqlEditor/editor.ts+++ b/frontend/src/types/sqlEditor/editor.ts@@ -1,5 +1,4 @@import type * as monaco from "monaco-editor";-import type { EngineType } from "@/types";import { Engine } from "../proto/v1/common";export type EditorModel = monaco.editor.ITextModel;@@ -28,17 +27,6 @@ export const EngineToSQLDialectMap = new Map<Engine, SQLDialect>([[Engine.OCEANBASE, "OCEANBASE"],]);-export const languageOfEngine = (engine?: EngineType | "unknown"): Language => {- if (engine === "MONGODB") {- return "javascript";- }- if (engine === "REDIS") {- return "redis";- }-- return "sql";-};-export const languageOfEngineV1 = (engine?: Engine): Language => {if (engine === Engine.MONGODB) {return "javascript";diff --git a/frontend/src/types/v1/instance.ts b/frontend/src/types/v1/instance.tsindex a2ac852701..d313e125a8 100644--- a/frontend/src/types/v1/instance.ts+++ b/frontend/src/types/v1/instance.ts@@ -160,3 +160,11 @@ export const defaultCollationOfEngineV1 = (engine: Engine): string => {}return "";};++export function isPostgresFamily(type: Engine): boolean {+ return (+ type == Engine.POSTGRES ||+ type == Engine.REDSHIFT ||+ type == Engine.RISINGWAVE+ );+}diff --git a/frontend/src/types/v1/project.ts b/frontend/src/types/v1/project.tsindex f31bc83559..64ad7695c7 100644--- a/frontend/src/types/v1/project.ts+++ b/frontend/src/types/v1/project.ts@@ -2,6 +2,7 @@ import { EMPTY_ID, UNKNOWN_ID } from "../const";import { State } from "../proto/v1/common";import { IamPolicy } from "../proto/v1/iam_policy";import { Project, Workflow } from "../proto/v1/project_service";+import type { VCSProvider, VCSRepository } from "../proto/v1/vcs_provider_service";export const DEFAULT_PROJECT_UID = 1;export const EMPTY_PROJECT_NAME = `projects/${EMPTY_ID}`;@@ -52,3 +53,16 @@ export const isValidProjectName = (name: string | undefined) => {name !== UNKNOWN_PROJECT_NAME);};++export type RepositoryConfig = {+ baseDirectory: string;+ branch: string;+ resourceId: string;+ databaseGroup: string;+};++export type ProjectRepositoryConfig = {+ vcs: VCSProvider;+ repositoryInfo: VCSRepository;+ repositoryConfig: RepositoryConfig;+};diff --git a/frontend/src/utils/common.ts b/frontend/src/utils/common.tsdeleted file mode 100644index 76f7efbdfe..0000000000--- a/frontend/src/utils/common.ts+++ /dev/null@@ -1,37 +0,0 @@-import { unknownUser, emptyUser, type ComposedUser } from "@/types";-import { Environment } from "@/types/proto/v1/environment_service";--export type ResourceType = "USER" | "ENVIRONMENT";--interface ResourceMaker {- (type: "USER"): ComposedUser;- (type: "ENVIRONMENT"): Environment;-}--const makeUnknown = (type: ResourceType) => {- const UNKNOWN_ENVIRONMENT: Environment = Environment.fromPartial({- title: "<<Unknown environment>>",- });-- switch (type) {- case "USER":- return unknownUser();- case "ENVIRONMENT":- return UNKNOWN_ENVIRONMENT;- }-};--export const unknown = makeUnknown as ResourceMaker;--const makeEmpty = (type: ResourceType) => {- const EMPTY_ENVIRONMENT: Environment = Environment.fromPartial({});-- switch (type) {- case "USER":- return emptyUser();- case "ENVIRONMENT":- return EMPTY_ENVIRONMENT;- }-};--export const empty = makeEmpty as ResourceMaker;diff --git a/frontend/src/utils/database.ts b/frontend/src/utils/database.tsdeleted file mode 100644index 9e23a560c3..0000000000--- a/frontend/src/utils/database.ts+++ /dev/null@@ -1,100 +0,0 @@-import { Engine } from "@/types/proto/v1/common";-import type { Database, Environment } from "../types";-import { semverCompare } from "./util";--// Sort the list to put prod items first.-export function sortDatabaseList(- list: Database[],- environmentList: Environment[]-): Database[] {- return list.sort((a: Database, b: Database) => {- let aEnvIndex = -1;- let bEnvIndex = -1;-- for (let i = 0; i < environmentList.length; i++) {- if (environmentList[i].id == a.instance.environment.id) {- aEnvIndex = i;- }- if (environmentList[i].id == b.instance.environment.id) {- bEnvIndex = i;- }-- if (aEnvIndex != -1 && bEnvIndex != -1) {- break;- }- }- return bEnvIndex - aEnvIndex;- });-}--const MIN_GHOST_SUPPORT_MYSQL_VERSION = "5.7.0";--export function allowGhostMigration(databaseList: Database[]): boolean {- return databaseList.every((db) => {- return (- db.instance.engine === "MYSQL" &&- semverCompare(db.instance.engineVersion, MIN_GHOST_SUPPORT_MYSQL_VERSION)- );- });-}--type DatabaseFilterFields = "name" | "project" | "instance" | "environment";-export function filterDatabaseByKeyword(- db: Database,- keyword: string,- columns: DatabaseFilterFields[] = ["name"]-): boolean {- keyword = keyword.trim().toLowerCase();- if (!keyword) {- // Skip the filter- return true;- }-- if (columns.includes("name") && db.name.toLowerCase().includes(keyword)) {- return true;- }-- if (- columns.includes("project") &&- db.project.name.toLowerCase().includes(keyword)- ) {- return true;- }-- if (- columns.includes("instance") &&- db.instance.name.toLowerCase().includes(keyword)- ) {- return true;- }-- if (- columns.includes("environment") &&- db.instance.environment.name.toLowerCase().includes(keyword)- ) {- return true;- }-- return false;-}--export function isArchivedDatabase(db: Database): boolean {- if (db.instance.rowStatus === "ARCHIVED") {- return true;- }- if (db.instance.environment.rowStatus === "ARCHIVED") {- return true;- }- return false;-}--export const hasSchemaProperty = (databaseEngine: Engine) => {- return (- databaseEngine === Engine.POSTGRES ||- databaseEngine === Engine.SNOWFLAKE ||- databaseEngine === Engine.ORACLE ||- databaseEngine === Engine.MSSQL ||- databaseEngine === Engine.REDSHIFT ||- databaseEngine === Engine.RISINGWAVE- );-};diff --git a/frontend/src/utils/environment.ts b/frontend/src/utils/environment.tsdeleted file mode 100644index 1768c62a07..0000000000--- a/frontend/src/utils/environment.ts+++ /dev/null@@ -1,9 +0,0 @@-import type { Environment } from "../types";--export function environmentName(environment: Environment) {- let name = environment.name;- if (environment.rowStatus == "ARCHIVED") {- name += " (Archived)";- }- return name;-}diff --git a/frontend/src/utils/id.ts b/frontend/src/utils/id.tsdeleted file mode 100644index 8f9eeb9b9e..0000000000--- a/frontend/src/utils/id.ts+++ /dev/null@@ -1,5 +0,0 @@-import type { ResourceId } from "@/types";--export const convertToResourceId = (raw: string): ResourceId => {- return raw.toLowerCase().replaceAll(" ", "-");-};diff --git a/frontend/src/utils/index.ts b/frontend/src/utils/index.tsindex 9a6cad218d..5701bcd262 100644--- a/frontend/src/utils/index.ts+++ b/frontend/src/utils/index.ts@@ -1,12 +1,8 @@export * from "./css";export * from "./clipboard";export * from "./collections";-export * from "./database";-export * from "./environment";-export * from "./instance";export * from "./issue";export * from "./link";-export * from "./project";export * from "./role";export * from "./slug";export * from "./table";@@ -22,7 +18,6 @@ export * from "./schemaEditor";export * from "./sso";export * from "./math";export * from "./idp";-export * from "./id";export * from "./workspaceApprovalSetting";export * from "./slowQuery";export * from "./resource-composer";diff --git a/frontend/src/utils/instance.ts b/frontend/src/utils/instance.tsdeleted file mode 100644index 4f217deee1..0000000000--- a/frontend/src/utils/instance.ts+++ /dev/null@@ -1,177 +0,0 @@-import { computed, unref } from "vue";-import type {- InstanceResource,- Instance as InstanceV1,-} from "@/types/proto/v1/instance_service";-import type {- EngineType,- Environment,- Instance,- Language,- MaybeRef,-} from "../types";-import { languageOfEngine, languageOfEngineV1 } from "../types";--export const supportedEngineList = () => {- const engines: EngineType[] = [- "MYSQL",- "POSTGRES",- "TIDB",- "SNOWFLAKE",- "CLICKHOUSE",- "MONGODB",- "REDIS",- "SPANNER",- "ORACLE",- "OCEANBASE",- "MARIADB",- "MSSQL",- "REDSHIFT",- "DM",- "RISINGWAVE",- ];- return engines;-};--export function instanceName(instance: Instance) {- let name = instance.name;- if (instance.rowStatus == "ARCHIVED") {- name += " (Archived)";- }- return name;-}--// Sort the list to put prod items first.-export function sortInstanceList(- list: Instance[],- environmentList: Environment[]-): Instance[] {- return list.sort((a: Instance, b: Instance) => {- let aEnvIndex = -1;- let bEnvIndex = -1;-- for (let i = 0; i < environmentList.length; i++) {- if (environmentList[i].id == a.environment.id) {- aEnvIndex = i;- }- if (environmentList[i].id == b.environment.id) {- bEnvIndex = i;- }-- if (aEnvIndex != -1 && bEnvIndex != -1) {- break;- }- }- return bEnvIndex - aEnvIndex;- });-}--export const useInstanceEditorLanguage = (- instance: MaybeRef<Instance | undefined>-) => {- return computed((): Language => {- return languageOfEngine(unref(instance)?.engine);- });-};--export const useInstanceV1EditorLanguage = (- instance: MaybeRef<InstanceV1 | InstanceResource | undefined>-) => {- return computed((): Language => {- return languageOfEngineV1(unref(instance)?.engine);- });-};--export const isValidSpannerHost = (host: string) => {- const RE =- /^projects\/(?<PROJECT_ID>(?:[a-z]|[-.:]|[0-9])+)\/instances\/(?<INSTANCE_ID>(?:[a-z]|[-]|[0-9])+)$/;- return RE.test(host);-};--export const instanceHasAlterSchema = (- instanceOrEngine: Instance | EngineType-): boolean => {- const engine = engineOfInstance(instanceOrEngine);- if (engine === "REDIS") return false;- return true;-};--export const instanceHasReadonlyMode = (- instanceOrEngine: Instance | EngineType-): boolean => {- const engine = engineOfInstance(instanceOrEngine);- if (engine === "MONGODB") return false;- if (engine === "REDIS") return false;- return true;-};--export const instanceHasCreateDatabase = (- instanceOrEngine: Instance | EngineType-): boolean => {- const engine = engineOfInstance(instanceOrEngine);- if (engine === "REDIS") return false;- if (engine === "ORACLE") return false;- if (engine === "DM") return false;- return true;-};--export const instanceHasStructuredQueryResult = (- instanceOrEngine: Instance | EngineType-): boolean => {- const engine = engineOfInstance(instanceOrEngine);- if (engine === "MONGODB") return false;- if (engine === "REDIS") return false;- return true;-};--export const instanceHasSSL = (- instanceOrEngine: Instance | EngineType-): boolean => {- const engine = engineOfInstance(instanceOrEngine);- return [- "CLICKHOUSE",- "MYSQL",- "TIDB",- "POSTGRES",- "REDIS",- "ORACLE",- "MARIADB",- "OCEANBASE",- "DM",- ].includes(engine);-};--export const instanceHasSSH = (- instanceOrEngine: Instance | EngineType-): boolean => {- const engine = engineOfInstance(instanceOrEngine);- return [- "MYSQL",- "TIDB",- "MARIADB",- "OCEANBASE",- "POSTGRES",- "REDIS",- ].includes(engine);-};--export const instanceHasCollationAndCharacterSet = (- instanceOrEngine: Instance | EngineType-) => {- const engine = engineOfInstance(instanceOrEngine);-- const excludedList: EngineType[] = [- "MONGODB",- "CLICKHOUSE",- "SNOWFLAKE",- "REDSHIFT",- ];- return !excludedList.includes(engine);-};--export const engineOfInstance = (instanceOrEngine: Instance | EngineType) => {- if (typeof instanceOrEngine === "string") {- return instanceOrEngine;- }- return instanceOrEngine.engine;-};diff --git a/frontend/src/utils/project.ts b/frontend/src/utils/project.tsdeleted file mode 100644index a2ae15e810..0000000000--- a/frontend/src/utils/project.ts+++ /dev/null@@ -1,13 +0,0 @@-import { DEFAULT_PROJECT_ID, type Project } from "../types";--export function projectName(project: Project) {- if (project.id === DEFAULT_PROJECT_ID) {- return "Unassigned";- }-- let name = project.name;- if (project.rowStatus == "ARCHIVED") {- name += " (Archived)";- }- return name;-}diff --git a/frontend/src/utils/slowQuery.ts b/frontend/src/utils/slowQuery.tsindex 5bbf2931d3..a532eb28f2 100644--- a/frontend/src/utils/slowQuery.ts+++ b/frontend/src/utils/slowQuery.ts@@ -1,4 +1,3 @@-import type { EngineType, Instance } from "@/types";import { Engine } from "@/types/proto/v1/common";import type {InstanceResource,@@ -6,22 +5,6 @@ import type {} from "@/types/proto/v1/instance_service";import { semverCompare } from "./util";-export const InstanceListSupportSlowQuery: [EngineType, string][] = [- ["MYSQL", "5.7"],- ["POSTGRES", "0"],-];--export const instanceSupportSlowQuery = (instance: Instance) => {- const { engine } = instance;- const item = InstanceListSupportSlowQuery.find((item) => item[0] === engine);- if (item) {- const [_, minVersion] = item;- if (minVersion === "0") return true;- return semverCompare(instance.engineVersion, minVersion, "gte");- }- return false;-};-export const InstanceV1ListSupportSlowQuery: [Engine, string][] = [[Engine.MYSQL, "5.7"],[Engine.POSTGRES, "0"],@@ -42,21 +25,6 @@ export const instanceV1SupportSlowQuery = (return false;};-export const slowQueryTypeOfInstance = (instance: Instance) => {- if (!instanceSupportSlowQuery(instance)) return undefined;- const { engine } = instance;- if (engine === "MYSQL") return "INSTANCE";- if (engine === "POSTGRES") return "DATABASE";- return undefined;-};--export const instanceHasSlowQueryDetail = (instance: Instance) => {- const { engine } = instance;- if (engine === "MYSQL") return true;-- return false;-};-export const instanceV1HasSlowQueryDetail = (instance: InstanceV1 | InstanceResource) => {diff --git a/frontend/src/utils/v1/instance.ts b/frontend/src/utils/v1/instance.tsindex b9208b59ac..66fd0b63e9 100644--- a/frontend/src/utils/v1/instance.ts+++ b/frontend/src/utils/v1/instance.ts@@ -1,8 +1,9 @@import { keyBy, orderBy } from "lodash-es";+import { computed, unref } from "vue";import { useI18n } from "vue-i18n";import { useEnvironmentV1Store, useSubscriptionV1Store } from "@/store";-import type { ComposedInstance } from "@/types";-import { isValidProjectName } from "@/types";+import type { ComposedInstance, MaybeRef } from "@/types";+import { isValidProjectName, languageOfEngineV1 } from "@/types";import { Engine, State } from "@/types/proto/v1/common";import type { Environment } from "@/types/proto/v1/environment_service";import type {@@ -112,20 +113,6 @@ export const supportedEngineV1List = () => {return engines;};-// export const useInstanceEditorLanguage = (-// instance: MaybeRef<Instance | undefined>-// ) => {-// return computed((): Language => {-// return languageOfEngine(unref(instance)?.engine);-// });-// };--// export const isValidSpannerHost = (host: string) => {-// const RE =-// /^projects\/(?<PROJECT_ID>(?:[a-z]|[-.:]|[0-9])+)\/instances\/(?<INSTANCE_ID>(?:[a-z]|[-]|[0-9])+)$/;-// return RE.test(host);-// };-export const instanceV1HasAlterSchema = (instanceOrEngine: Instance | InstanceResource | Engine): boolean => {@@ -313,3 +300,28 @@ export const engineNameV1 = (type: Engine): string => {}return "";};++export const hasSchemaProperty = (databaseEngine: Engine) => {+ return (+ databaseEngine === Engine.POSTGRES ||+ databaseEngine === Engine.SNOWFLAKE ||+ databaseEngine === Engine.ORACLE ||+ databaseEngine === Engine.MSSQL ||+ databaseEngine === Engine.REDSHIFT ||+ databaseEngine === Engine.RISINGWAVE+ );+};++export const useInstanceV1EditorLanguage = (+ instance: MaybeRef<Instance | InstanceResource | undefined>+) => {+ return computed(() => {+ return languageOfEngineV1(unref(instance)?.engine);+ });+};++export const isValidSpannerHost = (host: string) => {+ const RE =+ /^projects\/(?<PROJECT_ID>(?:[a-z]|[-.:]|[0-9])+)\/instances\/(?<INSTANCE_ID>(?:[a-z]|[-]|[0-9])+)$/;+ return RE.test(host);+};diff --git a/frontend/src/views/auth/Activate.vue b/frontend/src/views/auth/Activate.vuedeleted file mode 100644index 72e7e9ea2f..0000000000--- a/frontend/src/views/auth/Activate.vue+++ /dev/null@@ -1,119 +0,0 @@-<template>- <div class="mx-auto w-full max-w-sm">- <div>- <img- class="h-12 w-auto"- src="../../assets/logo-full.svg"- alt="Bytebase"- />- <h2 class="mt-6 text-3xl leading-9 font-extrabold text-main">- <i18n-t keypath="auth.activate.title" tag="p">- <template #type>- <span class="text-accent font-semibold">{{- state.role.charAt(0).toUpperCase() +- state.role.slice(1).toLowerCase()- }}</span>- </template>- </i18n-t>- </h2>- </div>-- <div class="mt-8">- <div class="mt-6">- <form class="space-y-6" @submit.prevent="tryActivate">- <div>- <label- for="email"- class="block text-sm font-medium leading-5 text-control"- >- {{ $t("common.email") }}- </label>- <div class="mt-2 text-base font-medium leading-5 text-accent">- {{ state.email }}- </div>- </div>- <div>- <label- for="password"- class="block text-sm font-medium leading-5 text-control"- >- {{ $t("common.password") }}- <span class="text-red-600">*</span>- </label>- <div class="mt-1 rounded-md shadow-sm">- <BBTextField- v-model:value="state.password"- type="password"- :input-props="{ id: 'password', autocomplete: 'on' }"- required- />- </div>- </div>-- <div>- <label- for="email"- class="block text-sm font-medium leading-5 text-control"- >- {{ $t("common.username") }}- </label>- <div class="mt-1 rounded-md shadow-sm">- <BBTextField- id="name"- v-model:value="state.name"- placeholder="Jim Gray"- />- </div>- </div>-- <div class="w-full">- <NButton attr-type="submit" type="primary" style="width: 100%">- {{ $t("common.activate") }}- </NButton>- </div>- </form>- </div>- </div>- </div>-</template>--<script lang="ts" setup>-import { NButton } from "naive-ui";-import { reactive } from "vue";-import { useRouter } from "vue-router";-import { BBTextField } from "@/bbkit";-import { useAuthStore } from "@/store";-import type { ActivateInfo, RoleType } from "../../types";--interface LocalState {- email: string;- password: string;- name: string;- role: RoleType;-}--const router = useRouter();-const token = router.currentRoute.value.query.token as string;--// TODO(tianzhou): Get info from activate token-const state = reactive<LocalState>({- email: "[email protected]",- password: "",- name: "Bob Invited",- role: "DEVELOPER",-});--const tryActivate = () => {- const activateInfo: ActivateInfo = {- email: state.email,- password: state.password,- name: state.name,- token: token,- };- useAuthStore()- .activate(activateInfo)- .then(() => {- router.push("/");- });-};-</script>diff --git a/frontend/src/views/sql-editor/AsidePanel/SchemaPane/HoverPanel/CodeViewer.vue b/frontend/src/views/sql-editor/AsidePanel/SchemaPane/HoverPanel/CodeViewer.vueindex f7ab29252c..3e6f709d7c 100644--- a/frontend/src/views/sql-editor/AsidePanel/SchemaPane/HoverPanel/CodeViewer.vue+++ b/frontend/src/views/sql-editor/AsidePanel/SchemaPane/HoverPanel/CodeViewer.vue@@ -28,11 +28,11 @@ import { MonacoEditor } from "@/components/MonacoEditor";import formatSQL from "@/components/MonacoEditor/sqlFormatter";import type { ComposedDatabase } from "@/types";import { dialectOfEngineV1 } from "@/types";-import { Engine } from "@/types/proto/v1/common";import type {DatabaseMetadata,SchemaMetadata,} from "@/types/proto/v1/database_service";+import { hasSchemaProperty } from "@/utils";const props = defineProps<{db: ComposedDatabase;@@ -47,13 +47,9 @@ const format = useLocalStorage<boolean>();const instanceEngine = computed(() => props.db.instanceResource.engine);-const hasSchemaProperty = computed(() => {- return [Engine.POSTGRES, Engine.RISINGWAVE].includes(instanceEngine.value);-});-const name = computed(() => {const { schema, name } = props;- if (hasSchemaProperty.value) {+ if (hasSchemaProperty(instanceEngine.value)) {return `${schema.name}.${name}`;}return name;diff --git a/frontend/src/views/sql-editor/AsidePanel/SchemaPane/HoverPanel/ExternalTableInfo.vue b/frontend/src/views/sql-editor/AsidePanel/SchemaPane/HoverPanel/ExternalTableInfo.vueindex 75e047dd62..7bd1e65413 100644--- a/frontend/src/views/sql-editor/AsidePanel/SchemaPane/HoverPanel/ExternalTableInfo.vue+++ b/frontend/src/views/sql-editor/AsidePanel/SchemaPane/HoverPanel/ExternalTableInfo.vue@@ -15,12 +15,12 @@<script setup lang="ts">import { computed } from "vue";import type { ComposedDatabase } from "@/types";-import { Engine } from "@/types/proto/v1/common";import type {DatabaseMetadata,SchemaMetadata,ExternalTableMetadata,} from "@/types/proto/v1/database_service";+import { hasSchemaProperty } from "@/utils";import InfoItem from "./InfoItem.vue";const props = defineProps<{@@ -32,13 +32,9 @@ const props = defineProps<{const instanceEngine = computed(() => props.db.instanceResource.engine);-const hasSchemaProperty = computed(() => {- return [Engine.POSTGRES, Engine.RISINGWAVE].includes(instanceEngine.value);-});-const name = computed(() => {const { schema, externalTable } = props;- if (hasSchemaProperty.value) {+ if (hasSchemaProperty(instanceEngine.value)) {return `${schema.name}.${externalTable.name}`;}return externalTable.name;diff --git a/frontend/src/views/sql-editor/AsidePanel/SchemaPane/HoverPanel/TableInfo.vue b/frontend/src/views/sql-editor/AsidePanel/SchemaPane/HoverPanel/TableInfo.vueindex fbe6d58f2f..e16f2037e4 100644--- a/frontend/src/views/sql-editor/AsidePanel/SchemaPane/HoverPanel/TableInfo.vue+++ b/frontend/src/views/sql-editor/AsidePanel/SchemaPane/HoverPanel/TableInfo.vue@@ -30,7 +30,7 @@ import type {SchemaMetadata,TableMetadata,} from "@/types/proto/v1/database_service";-import { bytesToString } from "@/utils";+import { bytesToString, hasSchemaProperty } from "@/utils";import InfoItem from "./InfoItem.vue";const props = defineProps<{@@ -42,13 +42,9 @@ const props = defineProps<{const instanceEngine = computed(() => props.db.instanceResource.engine);-const hasSchemaProperty = computed(() => {- return [Engine.POSTGRES, Engine.RISINGWAVE].includes(instanceEngine.value);-});-const name = computed(() => {const { schema, table } = props;- if (hasSchemaProperty.value) {+ if (hasSchemaProperty(instanceEngine.value)) {return `${schema.name}.${table.name}`;}return table.name;