Skip to content

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

chore: display targets in review center (#16319)

boojack28b8a5b62a76
diff --git a/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vue b/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vue
index 390bc3eab9..4f4025e361 100644
--- a/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vue
+++ b/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vue
@@ -16,16 +16,20 @@ import {
planCheckRunListForSpec,
planSpecHasPlanChecks,
usePlanContext,
- databaseForSpec,
} from "@/components/Plan/logic";
import PlanCheckRunBar from "@/components/PlanCheckRun/PlanCheckRunBar.vue";
-import { useCurrentUserV1, extractUserId, useCurrentProjectV1 } from "@/store";
+import {
+ useCurrentUserV1,
+ extractUserId,
+ useCurrentProjectV1,
+ useDatabaseV1Store,
+} from "@/store";
import { EMPTY_ID } from "@/types";
import { hasProjectPermissionV2 } from "@/utils";
const currentUser = useCurrentUserV1();
const { project } = useCurrentProjectV1();
-const { plan, selectedSpec } = usePlanContext();
+const { plan, selectedSpec, selectedTarget } = usePlanContext();
const show = computed(() => {
if (selectedSpec.value.id === String(EMPTY_ID)) {
@@ -35,7 +39,7 @@ const show = computed(() => {
});
const database = computed(() =>
- databaseForSpec(project.value, selectedSpec.value)
+ useDatabaseV1Store().getDatabaseByName(selectedTarget.value)
);
const allowRunChecks = computed(() => {
diff --git a/frontend/src/components/Plan/components/SpecListSection/CurrentSpecSection.vue b/frontend/src/components/Plan/components/SpecListSection/CurrentSpecSection.vue
index b61243abfa..65ba90f36d 100644
--- a/frontend/src/components/Plan/components/SpecListSection/CurrentSpecSection.vue
+++ b/frontend/src/components/Plan/components/SpecListSection/CurrentSpecSection.vue
@@ -27,7 +27,11 @@
</InstanceV1Name>
<span v-else>
<!-- For creating database issues, we will only show the resource id of target instance. -->
- {{ extractInstanceResourceName(targetOfSpec(selectedSpec) || "") }}
+ {{
+ extractInstanceResourceName(
+ selectedSpec.createDatabaseConfig?.target || ""
+ )
+ }}
</span>
<ChevronRightIcon class="text-control-light" :size="16" />
@@ -67,18 +71,14 @@ import {
EnvironmentV1Name,
InstanceV1Name,
} from "@/components/v2";
-import {
- useCurrentProjectV1,
- useDatabaseV1Store,
- useEnvironmentV1Store,
-} from "@/store";
+import { useDatabaseV1Store, useEnvironmentV1Store } from "@/store";
import {
formatEnvironmentName,
isValidDatabaseName,
unknownEnvironment,
} from "@/types";
import { extractInstanceResourceName, isNullOrUndefined } from "@/utils";
-import { databaseForSpec, targetOfSpec, usePlanContext } from "../../logic";
+import { usePlanContext } from "../../logic";
withDefaults(
defineProps<{
@@ -89,11 +89,10 @@ withDefaults(
}
);
-const { project } = useCurrentProjectV1();
-const { selectedSpec } = usePlanContext();
+const { selectedSpec, selectedTarget } = usePlanContext();
const coreDatabaseInfo = computed(() => {
- return databaseForSpec(project.value, selectedSpec.value);
+ return useDatabaseV1Store().getDatabaseByName(selectedTarget.value);
});
const isCreatingDatabaseSpec = computed(
diff --git a/frontend/src/components/Plan/components/SpecListSection/SpecCard.vue b/frontend/src/components/Plan/components/SpecListSection/SpecCard.vue
index 2ce85194f7..3551df96a0 100644
--- a/frontend/src/components/Plan/components/SpecListSection/SpecCard.vue
+++ b/frontend/src/components/Plan/components/SpecListSection/SpecCard.vue
@@ -1,15 +1,17 @@
<template>
<div
+ v-for="target in targetsForSpec(spec)"
+ :key="`${spec.id}-${target}`"
class="px-3 py-2 w-full cursor-pointer border rounded lg:flex-1 flex justify-start items-center overflow-hidden gap-x-1"
- :class="specClass"
- @click="onClickSpec(spec)"
+ :class="[getTargetClass(target)]"
+ @click="onClickSpec(spec, target)"
>
<NTooltip
v-if="
[
PlanCheckRun_Result_Status.WARNING,
PlanCheckRun_Result_Status.ERROR,
- ].includes(planCheckStatus)
+ ].includes(planCheckStatusForTarget(target))
"
trigger="hover"
placement="top"
@@ -18,7 +20,8 @@
<AlertCircleIcon
class="w-4 h-4 shrink-0"
:class="[
- planCheckStatus === PlanCheckRun_Result_Status.ERROR
+ planCheckStatusForTarget(target) ===
+ PlanCheckRun_Result_Status.ERROR
? 'text-error hover:text-error-hover'
: 'text-warning hover:text-warning-hover',
]"
@@ -35,16 +38,16 @@
class="flex items-center gap-1 truncate"
>
<InstanceV1Name
- :instance="databaseForSpec(project, spec).instanceResource"
+ :instance="getDatabaseForTarget(target).instanceResource"
:link="false"
class="text-gray-500 text-sm"
/>
<span class="truncate text-sm">{{
- databaseForSpec(project, spec).databaseName
+ getDatabaseForTarget(target).databaseName
}}</span>
</div>
<div
- v-else-if="isGroupingChangeSpec(spec) && relatedDatabaseGroup"
+ v-else-if="isGroupingChangeSpec(spec) && getRelatedDatabaseGroup(target)"
class="flex items-center gap-2 truncate"
>
<NTooltip>
@@ -53,7 +56,9 @@
</template>
{{ $t("dynamic.resource.database-group") }}
</NTooltip>
- <span class="truncate text-sm">{{ relatedDatabaseGroup.title }}</span>
+ <span class="truncate text-sm">{{
+ getRelatedDatabaseGroup(target)?.title
+ }}</span>
</div>
<!-- Fallback -->
<div v-else class="flex items-center gap-2 text-sm">Unknown target</div>
@@ -61,24 +66,28 @@
</template>
<script setup lang="ts">
-import { head, isEqual } from "lodash-es";
+import { isEqual } from "lodash-es";
import { AlertCircleIcon } from "lucide-vue-next";
import { NTooltip } from "naive-ui";
-import { computed } from "vue";
import DatabaseGroupIcon from "@/components/DatabaseGroupIcon.vue";
+import { mockDatabase } from "@/components/IssueV1/logic/utils";
import { planCheckRunSummaryForCheckRunList } from "@/components/PlanCheckRun/common";
import { InstanceV1Name } from "@/components/v2";
-import { useCurrentProjectV1, useDBGroupStore } from "@/store";
+import {
+ useCurrentProjectV1,
+ useDBGroupStore,
+ useDatabaseV1Store,
+} from "@/store";
+import { isValidDatabaseName } from "@/types";
import {
PlanCheckRun_Result_Status,
type Plan_Spec,
} from "@/types/proto/v1/plan_service";
+import { sheetNameOfSpec } from "@/utils";
import {
- databaseForSpec,
isDatabaseChangeSpec,
usePlanContext,
isGroupingChangeSpec,
- planCheckRunListForSpec,
targetsForSpec,
} from "../../logic";
@@ -87,46 +96,58 @@ const props = defineProps<{
}>();
const { project } = useCurrentProjectV1();
-const { isCreating, plan, selectedSpec, events } = usePlanContext();
+const { isCreating, plan, selectedSpec, selectedTarget, events } =
+ usePlanContext();
const dbGroupStore = useDBGroupStore();
-const specClass = computed(() => {
+const getTargetClass = (target: string) => {
const classes: string[] = [];
- const isSelected = isEqual(props.spec, selectedSpec.value);
- if (isSelected) {
+ const isSpecSelected = isEqual(props.spec, selectedSpec.value);
+ const isTargetSelected = isSpecSelected && selectedTarget.value === target;
+
+ if (isTargetSelected) {
classes.push("border-accent bg-accent bg-opacity-5 shadow");
}
- if (planCheckStatus.value === PlanCheckRun_Result_Status.WARNING) {
+
+ const checkStatus = planCheckStatusForTarget(target);
+ if (checkStatus === PlanCheckRun_Result_Status.WARNING) {
classes.push("bg-warning bg-opacity-5");
- if (isSelected) {
+ if (isTargetSelected) {
classes.push("border-warning");
}
- } else if (planCheckStatus.value === PlanCheckRun_Result_Status.ERROR) {
+ } else if (checkStatus === PlanCheckRun_Result_Status.ERROR) {
classes.push("bg-error bg-opacity-5");
- if (isSelected) {
+ if (isTargetSelected) {
classes.push("border-error");
}
}
+
return classes;
-});
+};
-const relatedDatabaseGroup = computed(() => {
- if (!isGroupingChangeSpec(props.spec)) {
- return undefined;
+const getDatabaseForTarget = (target: string) => {
+ const db = useDatabaseV1Store().getDatabaseByName(target);
+ if (!isValidDatabaseName(db.name)) {
+ return mockDatabase(project.value, target);
}
- const targets = targetsForSpec(props.spec);
- const maybeDBGroupName = head(targets);
- if (!maybeDBGroupName) {
+ return db;
+};
+
+const getRelatedDatabaseGroup = (target: string) => {
+ if (!isGroupingChangeSpec(props.spec)) {
return undefined;
}
- return dbGroupStore.getDBGroupByName(maybeDBGroupName);
-});
+ return dbGroupStore.getDBGroupByName(target);
+};
-const planCheckStatus = computed((): PlanCheckRun_Result_Status => {
+const planCheckStatusForTarget = (
+ target: string
+): PlanCheckRun_Result_Status => {
if (isCreating.value) return PlanCheckRun_Result_Status.STATUS_UNSPECIFIED;
- const summary = planCheckRunSummaryForCheckRunList(
- planCheckRunListForSpec(plan.value, props.spec)
+ const planCheckRuns = plan.value.planCheckRunList.filter(
+ (run) => run.sheet === sheetNameOfSpec(props.spec) && run.target === target
);
+ const summary = planCheckRunSummaryForCheckRunList(planCheckRuns);
if (summary.errorCount > 0) {
return PlanCheckRun_Result_Status.ERROR;
}
@@ -134,9 +155,10 @@ const planCheckStatus = computed((): PlanCheckRun_Result_Status => {
return PlanCheckRun_Result_Status.WARNING;
}
return PlanCheckRun_Result_Status.SUCCESS;
-});
+};
-const onClickSpec = (spec: Plan_Spec) => {
+const onClickSpec = (spec: Plan_Spec, target: string) => {
events.emit("select-spec", { spec });
+ events.emit("select-target", { target });
};
</script>
diff --git a/frontend/src/components/Plan/components/SpecListSection/SpecListSection.vue b/frontend/src/components/Plan/components/SpecListSection/SpecListSection.vue
index 4990bcf455..e93c43d87b 100644
--- a/frontend/src/components/Plan/components/SpecListSection/SpecListSection.vue
+++ b/frontend/src/components/Plan/components/SpecListSection/SpecListSection.vue
@@ -54,24 +54,21 @@
<script lang="ts" setup>
import { useDebounceFn } from "@vueuse/core";
-import { head } from "lodash-es";
import { NButton } from "naive-ui";
import { computed, reactive, ref, watch } from "vue";
import { BBSpin } from "@/bbkit";
import { useVerticalScrollState } from "@/composables/useScrollState";
import {
batchGetOrFetchDatabases,
- useCurrentProjectV1,
useDBGroupStore,
} from "@/store";
-import { DEBOUNCE_SEARCH_DELAY } from "@/types";
+import { DEBOUNCE_SEARCH_DELAY, isValidDatabaseName } from "@/types";
import type { Advice_Status } from "@/types/proto/v1/sql_service";
import { isDev } from "@/utils";
import {
- databaseForSpec,
isDatabaseChangeSpec,
isGroupingChangeSpec,
- targetOfSpec,
+ targetsForSpec,
usePlanContext,
} from "../../logic";
import { usePlanSQLCheckContext } from "../SQLCheckSection/context";
@@ -93,7 +90,6 @@ const MAX_LIST_HEIGHT = 256;
// This is set to 4 in development mode for easier testing.
const SPEC_PER_PAGE = isDev() ? 4 : 20;
-const { project } = useCurrentProjectV1();
const planContext = usePlanContext();
const { resultMap } = usePlanSQLCheckContext();
const { plan, selectedSpec } = planContext;
@@ -136,9 +132,8 @@ const shouldShowSpecFilter = computed(() => {
const shouldShowCurrentSpecView = computed(() => {
// Only show the current spec view when the selected spec is not in the filtered list.
- return !filteredSpecList.value
- .slice(0, state.index)
- .some((spec) => spec.id === selectedSpec.value.id);
+ const visibleSpecs = filteredSpecList.value.slice(0, state.index);
+ return !visibleSpecs.some((spec) => spec.id === selectedSpec.value.id);
});
const loadMore = useDebounceFn(async () => {
@@ -148,26 +143,38 @@ const loadMore = useDebounceFn(async () => {
isGroupingChangeSpec(spec)
);
if (isGroupChangingPlan) {
- // Should be only one database group in the plan.
- const spec = head(specList.value);
- if (!spec) {
- throw new Error("No spec found in the plan");
+ // Fetch all database groups referenced in specs
+ const dbGroupNames = new Set<string>();
+ for (const spec of specList.value) {
+ const targets = targetsForSpec(spec);
+ targets.forEach((target) => dbGroupNames.add(target));
}
- const databaseGroupName = targetOfSpec(spec);
- if (!databaseGroupName) {
- throw new Error("No database group name found in the spec");
- }
- await dbGroupStore.getOrFetchDBGroupByName(databaseGroupName);
+
+ await Promise.all(
+ Array.from(dbGroupNames).map((name) =>
+ dbGroupStore.getOrFetchDBGroupByName(name)
+ )
+ );
} else {
const fromIndex = state.index;
const toIndex = fromIndex + SPEC_PER_PAGE;
- const databaseNames = filteredSpecList.value
+
+ // Collect all database names from all targets in the visible specs
+ const databaseNames = new Set<string>();
+ filteredSpecList.value
.slice(fromIndex, toIndex)
- .map((spec) => databaseForSpec(project.value, spec).name);
+ .forEach((spec) => {
+ const targets = targetsForSpec(spec);
+ targets.forEach((target) => {
+ if (isValidDatabaseName(target)) {
+ databaseNames.add(target);
+ }
+ });
+ });
state.isRequesting = true;
try {
- await batchGetOrFetchDatabases(databaseNames);
+ await batchGetOrFetchDatabases(Array.from(databaseNames));
} finally {
state.index = toIndex;
state.isRequesting = false;
diff --git a/frontend/src/components/Plan/components/SpecListSection/filter.ts b/frontend/src/components/Plan/components/SpecListSection/filter.ts
index f8cee5c5a1..ece3b1f84c 100644
--- a/frontend/src/components/Plan/components/SpecListSection/filter.ts
+++ b/frontend/src/components/Plan/components/SpecListSection/filter.ts
@@ -3,7 +3,7 @@ import type { Plan_Spec } from "@/types/proto/v1/plan_service";
import type { CheckReleaseResponse_CheckResult } from "@/types/proto/v1/release_service";
import { Advice_Status } from "@/types/proto/v1/sql_service";
import { sheetNameOfSpec } from "@/utils";
-import { targetOfSpec, type PlanContext } from "../../logic";
+import { type PlanContext, targetsForSpec } from "../../logic";
export const filterSpec = (
planContext: PlanContext,
@@ -16,33 +16,39 @@ export const filterSpec = (
}
): boolean => {
const { isCreating } = planContext;
+ const targets = targetsForSpec(spec);
+
if (adviceStatus) {
if (isCreating.value) {
- const result = sqlCheckResultMap[targetOfSpec(spec) || ""];
- if (adviceStatus === Advice_Status.UNRECOGNIZED) {
- return !Boolean(result);
- }
- if (adviceStatus === Advice_Status.SUCCESS) {
- return result && result.advices.length === 0;
- }
- return (
- result &&
- result.advices.some((advice) => advice.status === adviceStatus)
- );
+ // Check if any target matches the filter criteria.
+ return targets.some((target) => {
+ const result = sqlCheckResultMap[target];
+ if (adviceStatus === Advice_Status.UNRECOGNIZED) {
+ return !Boolean(result);
+ }
+ if (adviceStatus === Advice_Status.SUCCESS) {
+ return result && result.advices.length === 0;
+ }
+ return (
+ result &&
+ result.advices.some((advice) => advice.status === adviceStatus)
+ );
+ });
} else {
- const planCheckRuns = planContext.plan.value.planCheckRunList.filter(
- (run) =>
- run.sheet === sheetNameOfSpec(spec) &&
- run.target === targetOfSpec(spec)
- );
- const summary = planCheckRunSummaryForCheckRunList(planCheckRuns);
- if (summary.errorCount > 0) {
- return adviceStatus === Advice_Status.ERROR;
- } else if (summary.warnCount > 0) {
- return adviceStatus === Advice_Status.WARNING;
- } else {
- return adviceStatus === Advice_Status.SUCCESS;
- }
+ // Check if any target has the specified advice status.
+ return targets.some((target) => {
+ const planCheckRuns = planContext.plan.value.planCheckRunList.filter(
+ (run) => run.sheet === sheetNameOfSpec(spec) && run.target === target
+ );
+ const summary = planCheckRunSummaryForCheckRunList(planCheckRuns);
+ if (summary.errorCount > 0) {
+ return adviceStatus === Advice_Status.ERROR;
+ } else if (summary.warnCount > 0) {
+ return adviceStatus === Advice_Status.WARNING;
+ } else {
+ return adviceStatus === Advice_Status.SUCCESS;
+ }
+ });
}
}
diff --git a/frontend/src/components/Plan/logic/base.ts b/frontend/src/components/Plan/logic/base.ts
index 11022e83d3..b619cbaac2 100644
--- a/frontend/src/components/Plan/logic/base.ts
+++ b/frontend/src/components/Plan/logic/base.ts
@@ -8,6 +8,7 @@ import { useUIStateStore } from "@/store";
import type { Plan_Spec } from "@/types/proto/v1/plan_service";
import { emptyPlanSpec } from "@/types/v1/issue/plan";
import type { PlanContext, PlanEvents } from "./context";
+import { targetsForSpec } from "./plan";
export const useBasePlanContext = (
context: Pick<PlanContext, "isCreating" | "ready" | "plan">
@@ -36,6 +37,18 @@ export const useBasePlanContext = (
return first(specs.value) || emptyPlanSpec();
});
+ const selectedTarget = computed((): string => {
+ const specTargets = targetsForSpec(selectedSpec.value);
+ const target = route.query.target as string;
+ if (target) {
+ if (specTargets.includes(target)) {
+ return target;
+ }
+ }
+ // Fallback to first target.
+ return first(specTargets) || "";
+ });
+
const formatOnSave = computed({
get: () => uiStateStore.editorFormatStatementOnSave,
set: (value: boolean) => uiStateStore.setEditorFormatStatementOnSave(value),
@@ -52,9 +65,21 @@ export const useBasePlanContext = (
});
});
+ events.on("select-target", ({ target }) => {
+ router.replace({
+ name: PROJECT_V1_ROUTE_REVIEW_CENTER_DETAIL,
+ query: {
+ ...route.query,
+ target: target,
+ },
+ hash: route.hash,
+ });
+ });
+
return {
events,
selectedSpec,
+ selectedTarget,
formatOnSave,
dialog,
};
diff --git a/frontend/src/components/Plan/logic/context.ts b/frontend/src/components/Plan/logic/context.ts
index 71c9831610..140eacc9cb 100644
--- a/frontend/src/components/Plan/logic/context.ts
+++ b/frontend/src/components/Plan/logic/context.ts
@@ -9,6 +9,7 @@ import type { ComposedPlan } from "@/types/v1/issue/plan";
export type PlanEvents = Emittery<{
"status-changed": { eager: boolean };
"select-spec": { spec: Plan_Spec };
+ "select-target": { target: string };
}>;
export type PlanContext = {
@@ -19,6 +20,7 @@ export type PlanContext = {
// TODO(steven): save related issue/rollout for checking if the plan is changable.
selectedSpec: Ref<Plan_Spec>;
+ selectedTarget: Ref<string>;
formatOnSave: Ref<boolean>;
// UI events
diff --git a/frontend/src/components/Plan/logic/plan-check.ts b/frontend/src/components/Plan/logic/plan-check.ts
index aad7c2d0ab..4fe475c28f 100644
--- a/frontend/src/components/Plan/logic/plan-check.ts
+++ b/frontend/src/components/Plan/logic/plan-check.ts
@@ -1,7 +1,6 @@
import type { Plan_Spec } from "@/types/proto/v1/plan_service";
import type { ComposedPlan } from "@/types/v1/issue/plan";
-import { sheetNameForSpec } from "./plan";
-import { databaseOfSpec, projectOfPlan } from "./utils";
+import { sheetNameForSpec, targetsForSpec } from "./plan";
export const planSpecHasPlanChecks = (spec: Plan_Spec) => {
if (spec.changeDatabaseConfig !== undefined) {
@@ -14,13 +13,14 @@ export const planCheckRunListForSpec = (
plan: ComposedPlan,
spec: Plan_Spec
) => {
- const target = databaseOfSpec(projectOfPlan(plan), spec).name;
+ const targets = targetsForSpec(spec);
const sheet = spec ? sheetNameForSpec(spec) : "";
return plan.planCheckRunList.filter((check) => {
+ if (!targets.includes(check.target)) {
+ return false;
+ }
if (sheet && check.sheet) {
- return check.sheet === sheet && check.target === target;
+ return check.sheet === sheet;
}
- // Otherwise filter by target only
- return check.target === target;
});
};
diff --git a/frontend/src/components/Plan/logic/plan.ts b/frontend/src/components/Plan/logic/plan.ts
index 8060e288b6..e0e6087e0f 100644
--- a/frontend/src/components/Plan/logic/plan.ts
+++ b/frontend/src/components/Plan/logic/plan.ts
@@ -11,20 +11,15 @@ import { Engine } from "@/types/proto/v1/common";
import type { Plan_Spec } from "@/types/proto/v1/plan_service";
export const databaseForSpec = (project: ComposedProject, spec: Plan_Spec) => {
- // Now we only handle changeDatabaseConfig specs.
- const { changeDatabaseConfig } = spec;
- if (changeDatabaseConfig !== undefined) {
- const targets = targetsForSpec(spec);
- if (targets.length === 0) {
- return unknownDatabase();
- }
- const db = useDatabaseV1Store().getDatabaseByName(targets[0]);
- if (!isValidDatabaseName(db.name)) {
- return mockDatabase(project, targets[0]);
- }
- return db;
+ const targets = targetsForSpec(spec);
+ if (targets.length === 0) {
+ return unknownDatabase();
+ }
+ const db = useDatabaseV1Store().getDatabaseByName(targets[0]);
+ if (!isValidDatabaseName(db.name)) {
+ return mockDatabase(project, targets[0]);
}
- return unknownDatabase();
+ return db;
};
/**
diff --git a/frontend/src/components/Plan/logic/utils.ts b/frontend/src/components/Plan/logic/utils.ts
index f604b35b00..4e2df0bf8c 100644
--- a/frontend/src/components/Plan/logic/utils.ts
+++ b/frontend/src/components/Plan/logic/utils.ts
@@ -1,34 +1,6 @@
-import { head } from "lodash-es";
-import { mockDatabase } from "@/components/IssueV1";
-import { useDatabaseV1Store, useProjectV1Store } from "@/store";
-import { isValidDatabaseName, unknownDatabase } from "@/types";
+import { useProjectV1Store } from "@/store";
import type { ComposedProject } from "@/types";
-import type { Plan_Spec } from "@/types/proto/v1/plan_service";
import type { ComposedPlan } from "@/types/v1/issue/plan";
-import { targetsForSpec } from "./plan";
export const projectOfPlan = (plan: ComposedPlan): ComposedProject =>
useProjectV1Store().getProjectByName(plan.project);
-
-export const targetOfSpec = (spec: Plan_Spec) => {
- const targets = targetsForSpec(spec);
- return head(targets);
-};
-
-export const databaseOfSpec = (project: ComposedProject, spec: Plan_Spec) => {
- if (spec.createDatabaseConfig) {
- return mockDatabase(
- project,
- `${spec.createDatabaseConfig.target}/databases/${spec.createDatabaseConfig.database}`
- );
- }
- const target = targetOfSpec(spec);
- if (!target) {
- return unknownDatabase();
- }
- const db = useDatabaseV1Store().getDatabaseByName(target);
- if (!isValidDatabaseName(db.name)) {
- return mockDatabase(project, target);
- }
- return db;
-};