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: deprecate jsonapi part 3 (#9394)
Danny Xua6d904fe54ad
diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.tsindex 3767e95000..f2655e6161 100644--- a/frontend/src/router/index.ts+++ b/frontend/src/router/index.ts@@ -19,7 +19,6 @@ import { t } from "@/plugins/i18n";import {hasFeature,useVCSV1Store,- useDataSourceStore,useSQLReviewStore,useSheetV1Store,useAuthStore,@@ -1185,7 +1184,6 @@ router.beforeEach((to, from, next) => {const issueSlug = routerSlug.issueSlug;const instanceSlug = routerSlug.instanceSlug;const databaseSlug = routerSlug.databaseSlug;- const dataSourceSlug = routerSlug.dataSourceSlug;const vcsSlug = routerSlug.vcsSlug;const connectionSlug = routerSlug.connectionSlug;const sheetSlug = routerSlug.sheetSlug;@@ -1339,25 +1337,7 @@ router.beforeEach((to, from, next) => {view: DatabaseMetadataView.DATABASE_METADATA_VIEW_BASIC,}).then(() => {- if (!dataSourceSlug) {- next();- } else if (dataSourceSlug) {- useDataSourceStore()- .fetchDataSourceById({- dataSourceId: idFromSlug(dataSourceSlug),- databaseId: Number(database.uid),- })- .then(() => {- next();- })- .catch((error) => {- next({- name: "error.404",- replace: false,- });- throw error;- });- }+ next();});}).catch((error) => {diff --git a/frontend/src/store/modules/dataSource.ts b/frontend/src/store/modules/dataSource.tsdeleted file mode 100644index 7a635f91ac..0000000000--- a/frontend/src/store/modules/dataSource.ts+++ /dev/null@@ -1,156 +0,0 @@-import axios from "axios";-import { defineStore } from "pinia";-import {- DataSourceId,- DataSource,- DataSourceCreate,- DataSourceState,- ResourceObject,- DatabaseId,- unknown,- DataSourcePatch,- EMPTY_ID,- empty,-} from "@/types";--function convert(- dataSource: ResourceObject,- includedList: ResourceObject[]-): DataSource {- const databaseId = dataSource.attributes!.databaseId as string;- const instanceId = dataSource.attributes!.instanceId as string;-- return {- ...(dataSource.attributes as Omit<- DataSource,- "id" | "instanceId" | "databaseId"- >),- id: parseInt(dataSource.id),- databaseId: parseInt(databaseId),- instanceId: parseInt(instanceId),- };-}--export const useDataSourceStore = defineStore("dataSource", {- state: (): DataSourceState => ({- dataSourceById: new Map(),- }),-- actions: {- convert(dataSource: ResourceObject): DataSource {- // Pass includedList with [] here, otherwise, it may cause cyclic dependency- // e.g. Database calls this to convert its dataSourceList, while data source here- // also tries to convert its database.- return convert(dataSource, []);- },-- getDataSourceById(dataSourceId: DataSourceId): DataSource {- if (dataSourceId == EMPTY_ID) {- return empty("DATA_SOURCE") as DataSource;- }-- return (- this.dataSourceById.get(dataSourceId) ||- (unknown("DATA_SOURCE") as DataSource)- );- },-- setDataSourceById({- dataSourceId,- dataSource,- }: {- dataSourceId: DataSourceId;- dataSource: DataSource;- }) {- this.dataSourceById.set(dataSourceId, dataSource);- },-- async fetchDataSourceById({- dataSourceId,- databaseId,- }: {- dataSourceId: DataSourceId;- databaseId: DatabaseId;- }) {- const data = (- await axios.get(- `/api/database/${databaseId}/data-source/${dataSourceId}`- )- ).data;- const dataSource = convert(data.data, data.included);-- this.setDataSourceById({- dataSourceId,- dataSource,- });-- return dataSource;- },-- async createDataSource(dataSourceCreate: DataSourceCreate) {- const data = (- await axios.post(- `/api/database/${dataSourceCreate.databaseId}/data-source`,- {- data: {- type: "DataSourceCreate",- attributes: dataSourceCreate,- },- }- )- ).data;- const createdDataSource = convert(data.data, data.included);-- this.setDataSourceById({- dataSourceId: createdDataSource.id,- dataSource: createdDataSource,- });-- return createdDataSource;- },-- async patchDataSource({- databaseId,- dataSourceId,- dataSourcePatch,- }: {- databaseId: DatabaseId;- dataSourceId: DataSourceId;- dataSourcePatch: DataSourcePatch;- }) {- const data = (- await axios.patch(- `/api/database/${databaseId}/data-source/${dataSourceId}`,- {- data: {- type: "dataSourcePatch",- attributes: dataSourcePatch,- },- }- )- ).data;- const updatedDataSource = convert(data.data, data.included);-- this.setDataSourceById({- dataSourceId: updatedDataSource.id,- dataSource: updatedDataSource,- });-- return updatedDataSource;- },-- async deleteDataSourceById({- databaseId,- dataSourceId,- }: {- databaseId: DatabaseId;- dataSourceId: DataSourceId;- }) {- await axios.delete(- `/api/database/${databaseId}/data-source/${dataSourceId}`- );-- this.dataSourceById.delete(dataSourceId);- },- },-});diff --git a/frontend/src/store/modules/index.ts b/frontend/src/store/modules/index.tsindex 23e27414a5..6a0208ca34 100644--- a/frontend/src/store/modules/index.ts+++ b/frontend/src/store/modules/index.ts@@ -1,11 +1,9 @@export * from "./auth";export * from "./command";-export * from "./dataSource";export * from "./help";export * from "./issue";export * from "./notification";export * from "./slowQueryPolicy";-export * from "./principal";export * from "./router";export * from "./sqlEditor";export * from "./sqlEditorTree";diff --git a/frontend/src/store/modules/principal.ts b/frontend/src/store/modules/principal.tsdeleted file mode 100644index dd63a3106d..0000000000--- a/frontend/src/store/modules/principal.ts+++ /dev/null@@ -1,40 +0,0 @@-import {- Principal,- ResourceObject,- empty,- PrincipalType,- ResourceIdentifier,- RoleType,-} from "@/types";--function convert(principal: ResourceObject): Principal {- return {- id: parseInt(principal.id),- type: principal.attributes.type as PrincipalType,- name: principal.attributes.name as string,- email: principal.attributes.email as string,- role: principal.attributes.role as RoleType,- serviceKey: principal.attributes.serviceKey as string,- };-}--export function getPrincipalFromIncludedList(- data:- | ResourceIdentifier<ResourceObject>- | ResourceIdentifier<ResourceObject>[]- | undefined,- includedList: ResourceObject[]-): Principal {- if (data == null) {- return empty("PRINCIPAL") as Principal;- }- for (const item of includedList || []) {- if (item.type != "principal") {- continue;- }- if (item.id == (data as ResourceIdentifier).id) {- return convert(item);- }- }- return empty("PRINCIPAL") as Principal;-}diff --git a/frontend/src/types/index.ts b/frontend/src/types/index.tsindex ae844cc285..84be64e337 100644--- a/frontend/src/types/index.ts+++ b/frontend/src/types/index.ts@@ -15,7 +15,6 @@ export * from "./help";export * from "./id";export * from "./instance";export * from "./issue";-export * from "./jsonapi";export * from "./member";export * from "./notification";export * from "./oauth";diff --git a/frontend/src/types/jsonapi/index.ts b/frontend/src/types/jsonapi/index.tsdeleted file mode 100644index 3f98332ede..0000000000--- a/frontend/src/types/jsonapi/index.ts+++ /dev/null@@ -1,2 +0,0 @@-// Based on https://github.com/rmarganti/json-api-export * from "./resourceObject";diff --git a/frontend/src/types/jsonapi/resourceObject.ts b/frontend/src/types/jsonapi/resourceObject.tsdeleted file mode 100644index ba908656c1..0000000000--- a/frontend/src/types/jsonapi/resourceObject.ts+++ /dev/null@@ -1,32 +0,0 @@-/**- * A representation of a single resource.- */-export interface ResourceObject {- type: string;- id: string;- // [NOTE] This diverges from the spec a bit to make attributes required to avoid "possibly undefined ts warning"- attributes: Attributes;-}--/**- * An array of Resource Objects.- */-export type ResourceObjects = ResourceObject[];--/**- * Either or a single Resource Object or an array of Resource Objects.- */-export type ResourceObjectOrObjects = ResourceObject | ResourceObjects;--/**- * A ResourceIdentifier identifies and individual resource.- */-export type ResourceIdentifier<T extends ResourceObject = ResourceObject> =- Pick<T, "type" | "id">;--/**- * Attributes describing a Resource Object- */-export interface Attributes {- [index: string]: string | number | boolean | object | undefined;-}