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: update `storage.get` types (#14643)
boojack1be00099ac1e
diff --git a/frontend/src/components/AlterSchemaPrepForm/SchemaEditorModal.vue b/frontend/src/components/AlterSchemaPrepForm/SchemaEditorModal.vueindex 38b561e3b1..fe4e99cb68 100644--- a/frontend/src/components/AlterSchemaPrepForm/SchemaEditorModal.vue+++ b/frontend/src/components/AlterSchemaPrepForm/SchemaEditorModal.vue@@ -494,7 +494,7 @@ const handlePreviewIssue = async () => {sqlMap[db.name] = sql;});const sqlMapStorageKey = `bb.issues.sql-map.${uuidv4()}`;- useStorageStore().put(sqlMapStorageKey, JSON.stringify(sqlMap));+ useStorageStore().put(sqlMapStorageKey, sqlMap);query.sqlMapStorageKey = sqlMapStorageKey;const databaseNameList = databaseList.value.map((db) => db.databaseName);query.name = generateIssueTitle(diff --git a/frontend/src/components/IssueV1/components/Sidebar/GhostSection/common.ts b/frontend/src/components/IssueV1/components/Sidebar/GhostSection/common.tsindex 511d7bcab3..a92d0bdabb 100644--- a/frontend/src/components/IssueV1/components/Sidebar/GhostSection/common.ts+++ b/frontend/src/components/IssueV1/components/Sidebar/GhostSection/common.ts@@ -137,7 +137,7 @@ export const provideIssueGhostContext = () => {sqlMap[target] = getSheetStatement(sheet);});const sqlMapStorageKey = `bb.issues.sql-map.${uuidv4()}`;- useStorageStore().put(sqlMapStorageKey, JSON.stringify(sqlMap));+ useStorageStore().put(sqlMapStorageKey, sqlMap);overrides["sqlMapStorageKey"] = sqlMapStorageKey;await reInitialize(overrides);diff --git a/frontend/src/components/IssueV1/logic/initialize/create.ts b/frontend/src/components/IssueV1/logic/initialize/create.tsindex f084455b22..3f5f1fceb4 100644--- a/frontend/src/components/IssueV1/logic/initialize/create.ts+++ b/frontend/src/components/IssueV1/logic/initialize/create.ts@@ -491,18 +491,9 @@ const extractInitialSQLFromQuery = async (}const sqlMapStorageKey = query.sqlMapStorageKey;if (sqlMapStorageKey && typeof sqlMapStorageKey === "string") {- const sqlMapJSON = (await storageStore.get(sqlStorageKey)) || "{}";- try {- const sqlMap = JSON.parse(sqlMapJSON) as Record<string, string>;- const keys = Object.keys(sqlMap);- if (keys.every((key) => typeof sqlMap[key] === "string")) {- return {- sqlMap,- };- }- } catch {- // Nothing- }+ const sqlMap =+ (await storageStore.get<Record<string, string>>(sqlMapStorageKey)) || {};+ return { sqlMap };}return {};};diff --git a/frontend/src/components/Plan/logic/initialize/create.ts b/frontend/src/components/Plan/logic/initialize/create.tsindex fea0ea8284..cf4d9027cd 100644--- a/frontend/src/components/Plan/logic/initialize/create.ts+++ b/frontend/src/components/Plan/logic/initialize/create.ts@@ -389,18 +389,9 @@ const extractInitialSQLFromQuery = async (}const sqlMapStorageKey = query.sqlMapStorageKey;if (sqlMapStorageKey && typeof sqlMapStorageKey === "string") {- const sqlMapJSON = (await storageStore.get(sqlStorageKey)) || "{}";- try {- const sqlMap = JSON.parse(sqlMapJSON) as Record<string, string>;- const keys = Object.keys(sqlMap);- if (keys.every((key) => typeof sqlMap[key] === "string")) {- return {- sqlMap,- };- }- } catch {- // Nothing- }+ const sqlMap =+ (await storageStore.get<Record<string, string>>(sqlMapStorageKey)) || {};+ return { sqlMap };}return {};};diff --git a/frontend/src/components/SyncDatabaseSchema/index.vue b/frontend/src/components/SyncDatabaseSchema/index.vueindex 83cc4097b4..5ad9011142 100644--- a/frontend/src/components/SyncDatabaseSchema/index.vue+++ b/frontend/src/components/SyncDatabaseSchema/index.vue@@ -257,7 +257,7 @@ const tryFinishSetup = async () => {});query.databaseList = Object.keys(sqlMap).join(",");const sqlMapStorageKey = `bb.issues.sql-map.${uuidv4()}`;- useStorageStore().put(sqlMapStorageKey, JSON.stringify(sqlMap));+ useStorageStore().put(sqlMapStorageKey, sqlMap);query.sqlMapStorageKey = sqlMapStorageKey;query.name = generateIssueTitle("bb.issue.database.schema.update",diff --git a/frontend/src/store/modules/v1/storage.ts b/frontend/src/store/modules/v1/storage.tsindex 8df60ec1fa..aad7ddc47a 100644--- a/frontend/src/store/modules/v1/storage.ts+++ b/frontend/src/store/modules/v1/storage.ts@@ -16,7 +16,7 @@ export const useStorageStore = defineStore("storageStore", () => {revs_limit: 1,});- const put = async (key: string, value: any) => {+ const put = async <T = any>(key: string, value: T) => {await db.put({_id: key,@@ -25,11 +25,12 @@ export const useStorageStore = defineStore("storageStore", () => {{ force: true });};- const get = async (key: string) => {+ const get = async <T = any>(key: string) => {try {const doc = await db.get(key);- return doc.value;+ return doc.value as T;} catch {+ // Data not found or error occurred.return undefined;}};