Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: tweak legacy type definitions (#13180)

boojack750ff8d3f3cb
diff --git a/frontend/src/directives/data-source-type.ts b/frontend/src/directives/data-source-type.ts
deleted file mode 100644
index 705445966f..0000000000
--- a/frontend/src/directives/data-source-type.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import type { DataSourceType } from "../types";
-
-const directive = {
- beforeMount(el: HTMLElement) {
- const dataSourceType = el.innerText as DataSourceType;
- switch (dataSourceType) {
- case "ADMIN":
- el.innerText = "ADMIN";
- return;
- case "RW":
- el.innerText = "Read & Write";
- return;
- case "RO":
- el.innerText = "Read Only";
- return;
- }
- },
-};
-
-export default directive;
diff --git a/frontend/src/main.ts b/frontend/src/main.ts
index c49f22a6d8..2c97ac5e06 100644
--- a/frontend/src/main.ts
+++ b/frontend/src/main.ts
@@ -8,7 +8,6 @@ import "./assets/css/github-markdown-style.css";
import "./assets/css/inter.css";
import "./assets/css/tailwind.css";
import { overrideAppProfile } from "./customAppProfile";
-import dataSourceType from "./directives/data-source-type";
import dayjs from "./plugins/dayjs";
import highlight from "./plugins/highlight";
import i18n from "./plugins/i18n";
@@ -134,12 +133,7 @@ app.config.globalProperties.sizeToFit = sizeToFit;
app.config.globalProperties.urlfy = urlfy;
app.config.globalProperties.isEmpty = isEmpty;
-app
- // Need to use a directive on the element.
- // The normal hljs.initHighlightingOnLoad() won't work because router change would cause vue
- // to re-render the page and remove the event listener required for
- .directive("data-source-type", dataSourceType)
- .use(pinia);
+app.use(pinia);
const overrideLang = () => {
const query = new URLSearchParams(window.location.search);
diff --git a/frontend/src/store/modules/auth.ts b/frontend/src/store/modules/auth.ts
index d8095daf0e..de9a8b2a35 100644
--- a/frontend/src/store/modules/auth.ts
+++ b/frontend/src/store/modules/auth.ts
@@ -2,11 +2,11 @@ import axios from "axios";
import { defineStore } from "pinia";
import { computed, ref } from "vue";
import { authServiceClient } from "@/grpcweb";
-import type { SignupInfo, ActivateInfo } from "@/types";
import { unknownUser } from "@/types";
import type {
LoginRequest,
LoginResponse,
+ User,
} from "@/types/proto/v1/auth_service";
import { UserType } from "@/types/proto/v1/auth_service";
import { getIntCookie } from "@/utils";
@@ -42,18 +42,18 @@ export const useAuthStore = defineStore("auth_v1", () => {
}
};
- const signup = async (signupInfo: SignupInfo) => {
+ const signup = async (request: Partial<User>) => {
await authServiceClient.createUser({
user: {
- email: signupInfo.email,
- title: signupInfo.name,
- password: signupInfo.password,
+ email: request.email,
+ title: request.name,
+ password: request.password,
userType: UserType.USER,
},
});
await login({
- email: signupInfo.email,
- password: signupInfo.password,
+ email: request.email,
+ password: request.password,
web: true,
});
await useWorkspaceV1Store().fetchIamPolicy();
@@ -68,22 +68,6 @@ export const useAuthStore = defineStore("auth_v1", () => {
}
};
- const activate = async (activateInfo: ActivateInfo) => {
- const activatedUser = (
- await axios.post("/api/auth/activate", {
- data: { type: "activateInfo", attributes: activateInfo },
- })
- ).data.data;
-
- currentUserId.value = activatedUser.id;
-
- // Refresh the corresponding user.
- const user = await useUserStore().getOrFetchUserById(
- String(activatedUser.id)
- );
- return user;
- };
-
const restoreUser = async () => {
currentUserId.value = getIntCookie("user");
if (currentUserId.value) {
@@ -111,7 +95,6 @@ export const useAuthStore = defineStore("auth_v1", () => {
login,
signup,
logout,
- activate,
restoreUser,
refreshUserIfNeeded,
};
diff --git a/frontend/src/types/auth.ts b/frontend/src/types/auth.ts
deleted file mode 100644
index eaa9f00d6f..0000000000
--- a/frontend/src/types/auth.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-export type SignupInfo = {
- email: string;
- password: string;
- name: string;
-};
-
-export type ActivateInfo = {
- email: string;
- password: string;
- name: string;
- token: string;
-};
-
-export type BytebaseLoginInfo = {
- email: string;
- password: string;
-};
diff --git a/frontend/src/types/common.ts b/frontend/src/types/common.ts
index 1d448ced58..9ca89a6aef 100644
--- a/frontend/src/types/common.ts
+++ b/frontend/src/types/common.ts
@@ -14,9 +14,6 @@ export const TEXT_VALIDATION_DELAY = 1000;
export const ENTERPRISE_INQUIRE_LINK =
"https://www.bytebase.com/contact-us?source=console";
-// RowStatus
-export type RowStatus = "NORMAL" | "ARCHIVED";
-
// Router
export type RouterSlug = {
issueSlug?: string;
diff --git a/frontend/src/types/error.ts b/frontend/src/types/error.ts
index a33c87a867..45a357dfba 100644
--- a/frontend/src/types/error.ts
+++ b/frontend/src/types/error.ts
@@ -7,10 +7,3 @@ export enum SQLReviewPolicyErrorCode {
}
export type ErrorCode = GeneralErrorCode | SQLReviewPolicyErrorCode | number;
-
-export type ErrorTag = "General" | "Compatibility";
-
-export type ErrorMeta = {
- code: ErrorCode;
- hash: string;
-};
diff --git a/frontend/src/types/externalApproval.ts b/frontend/src/types/externalApproval.ts
deleted file mode 100644
index 89e49b5cc4..0000000000
--- a/frontend/src/types/externalApproval.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-export type ExternalApprovalType = "bb.plugin.app.feishu";
-
-export type ExternalApprovalEvent = {
- type: ExternalApprovalType;
- action: ExternalApprovalEventActionType;
- stageName: string;
-};
-
-export type ExternalApprovalEventActionType = "APPROVE" | "REJECT";
diff --git a/frontend/src/types/index.ts b/frontend/src/types/index.ts
index c60ebb1154..5c1aebbfcd 100644
--- a/frontend/src/types/index.ts
+++ b/frontend/src/types/index.ts
@@ -1,7 +1,6 @@
export * from "./actuator";
export * from "./anomaly";
export * from "./auditLog";
-export * from "./auth";
export * from "./common";
export * from "./const";
export * from "./dataSource";
@@ -20,7 +19,6 @@ export * from "./sqlEditor";
export * from "./sheet";
export * from "./sqlReview";
export * from "./utils";
-export * from "./externalApproval";
export * from "./risk";
export * from "./workspaceApprovalSetting";
export * from "./review";
diff --git a/frontend/src/types/oauth.ts b/frontend/src/types/oauth.ts
index 3f4085a49e..fc4eab0390 100644
--- a/frontend/src/types/oauth.ts
+++ b/frontend/src/types/oauth.ts
@@ -1,83 +1,10 @@
-import { stringify } from "qs";
-import { VCSType, vCSTypeToJSON } from "@/types/proto/v1/common";
-
-export const OAuthStateSessionKey = "oauth-state";
-
export type OAuthWindowEventPayload = {
error: string;
code: string;
};
-export function redirectUrl(): string {
- return `${window.location.origin}/oauth/callback`;
-}
-
-// signin: users try to login via oauth
-// register-vcs: users try to bind a vcs to her workspace
-// link-vcs-repository: users try to bind a vcs repo to her project
-export type OAuthType =
- | "bb.oauth.signin"
- | "bb.oauth.register-vcs"
- | "bb.oauth.link-vcs-repository"
- | "bb.oauth.unknown";
export type OAuthState = {
event: string;
popup?: boolean;
redirect?: string;
};
-
-export function openWindowForOAuth(
- endpoint: string,
- applicationId: string,
- type: OAuthType,
- vcsType: VCSType
-): Window | null {
- const state: OAuthState = {
- // we use type to determine oauth type when receiving the callback
- event: `${type}.${vCSTypeToJSON(vcsType)}-${applicationId}`,
- popup: true,
- };
-
- const endpointQueryParams: Record<string, string> = {
- client_id: applicationId,
- state: stringify(state),
- response_type: "code",
- redirect_uri: redirectUrl(),
- };
-
- // Set proper popup window size for different VCS types
- let windowOpenOptions = "";
-
- if (vcsType == VCSType.GITHUB) {
- // GitHub OAuth App scopes: https://docs.github.com/en/developers/apps/building-oauth-apps/scopes-for-oauth-apps
- // We need the workflow scope to update GitHub action files.
-
- endpointQueryParams["scope"] = "api,repo,workflow";
- windowOpenOptions =
- "location=yes,left=200,top=200,height=640,width=480,scrollbars=yes,status=yes";
- } else if (vcsType == VCSType.BITBUCKET) {
- // Bitbucket OAuth App scopes: https://developer.atlassian.com/cloud/bitbucket/rest/intro/#authentication
- // Do not call `encodeURIComponent` here, will be encoded later.
- endpointQueryParams["scope"] = "account repository:write webhook";
- windowOpenOptions =
- "location=yes,left=200,top=200,height=640,width=720,scrollbars=yes,status=yes";
- } else if (vcsType == VCSType.GITLAB) {
- // GITLAB
- // GitLab OAuth App scopes: https://docs.gitlab.com/ee/integration/oauth_provider.html#authorized-applications
- endpointQueryParams["scope"] = "api";
- windowOpenOptions =
- "location=yes,left=200,top=200,height=640,width=480,scrollbars=yes,status=yes";
- } else if (vcsType == VCSType.AZURE_DEVOPS) {
- // Scopes for Azure: https://learn.microsoft.com/zh-cn/azure/devops/integrate/get-started/authentication/oauth?view=azure-devops#scopes
- // We need full scopes in the application: https://stackoverflow.com/questions/56143321/azure-devops-oauth-enpoint-always-returns-error-invalidscope
- endpointQueryParams["scope"] =
- "vso.code_full vso.identity vso.project vso.build_execute";
- endpointQueryParams["response_type"] = "Assertion";
- windowOpenOptions =
- "location=yes,left=200,top=200,height=640,width=720,scrollbars=yes,status=yes";
- }
-
- const fullEndpointURL = `${endpoint}?${stringify(endpointQueryParams)}`;
-
- return window.open(fullEndpointURL, "oauth", windowOpenOptions);
-}
diff --git a/frontend/src/types/review.ts b/frontend/src/types/review.ts
index a85236510b..138f45a9a0 100644
--- a/frontend/src/types/review.ts
+++ b/frontend/src/types/review.ts
@@ -2,10 +2,6 @@ import type { ApprovalStep, Issue_Approver } from "./proto/v1/issue_service";
import { ApprovalTemplate } from "./proto/v1/issue_service";
import type { ComposedUser } from "./v1/user";
-export type ApprovalEvent = {
- status: "APPROVED" | "REJECTED" | "PENDING";
-};
-
export type ReviewFlow = {
template: ApprovalTemplate;
approvers: Issue_Approver[];
diff --git a/frontend/src/types/sheet.ts b/frontend/src/types/sheet.ts
index e7cd40f847..2c5e47d0f6 100644
--- a/frontend/src/types/sheet.ts
+++ b/frontend/src/types/sheet.ts
@@ -1,20 +1,6 @@
import type { VNode } from "vue";
import type { Worksheet_Visibility } from "@/types/proto/v1/worksheet_service";
-interface SheetVCSPayload {
- fileName: string;
- filePath: string;
- size: number;
- author: string;
- lastCommitId: string;
- lastSyncTs: number;
-}
-
-// eslint-disable-next-line @typescript-eslint/ban-types
-type SheetEmptyPayload = {};
-
-export type SheetPayload = SheetVCSPayload | SheetEmptyPayload;
-
export type AccessOption = {
label: string;
description: string;
diff --git a/frontend/src/types/sqlAdvice.ts b/frontend/src/types/sqlAdvice.ts
index d35a6c77f8..c82a2e516a 100644
--- a/frontend/src/types/sqlAdvice.ts
+++ b/frontend/src/types/sqlAdvice.ts
@@ -1,13 +1 @@
-import type { SQLAdviceCode } from "./sqlAdviceCode";
-
export * from "./sqlAdviceCode";
-
-export type AdviceStatus = "SUCCESS" | "WARN" | "ERROR";
-
-export type Advice = {
- status: AdviceStatus;
- code: SQLAdviceCode;
- title: string;
- content: string;
- line: number;
-};
diff --git a/frontend/src/types/utils.ts b/frontend/src/types/utils.ts
index 82c26bedbe..527e46a71a 100644
--- a/frontend/src/types/utils.ts
+++ b/frontend/src/types/utils.ts
@@ -1,11 +1,8 @@
import type { Ref } from "vue";
-export type SubsetOf<T, S extends T> = S;
export type MaybeRef<T> = Ref<T> | T;
export type ValidatedMessage = {
type: "warning" | "error";
message: string;
};
-
-export type ArgumentsType<T> = T extends (...args: infer U) => any ? U : never;
diff --git a/frontend/src/views/auth/Signup.vue b/frontend/src/views/auth/Signup.vue
index 3901ba0dae..414bf6ebe1 100644
--- a/frontend/src/views/auth/Signup.vue
+++ b/frontend/src/views/auth/Signup.vue
@@ -226,8 +226,8 @@ import {
useAuthStore,
useOnboardingStateStore,
} from "@/store";
-import type { SignupInfo } from "@/types";
import { TEXT_VALIDATION_DELAY } from "@/types";
+import type { User } from "@/types/proto/v1/auth_service";
import { isValidEmail } from "@/utils";
import AuthFooter from "./AuthFooter.vue";
@@ -346,7 +346,7 @@ const trySignup = async () => {
state.isLoading = true;
try {
- const signupInfo: SignupInfo = {
+ const signupInfo: Partial<User> = {
email: state.email,
password: state.password,
name: state.name,