feat(transwarp): add Inceptor data source with table operations

This commit is contained in:
Hand Sonic authored and GitHub committed 2026-09-29 02:05:07 +08:00
1 parent 597b134d21
commit 6fdc338348
101 files changed
+2300 -66

No files matched your search

@@ -2885,6 +2885,9 @@ function applyProfile(val: string, preserveConnectionFields = false) {
jdbcDriverPathsInput.value = "";
jdbcManualClasspathOpen.value = true;
}
if (profile.type === "transwarp") {
form.value.connection_string = undefined;
}
if (profile.type === "spanner") {
// Google Cloud endpoints carry no host; the local emulator is opted into
// by typing host `localhost` and port 9010 explicitly.
@@ -2940,7 +2943,7 @@ function applyProfile(val: string, preserveConnectionFields = false) {
if (profile.type === "salesforce") {
resetSalesforceOAuthFields(form.value.external_config, form.value.password);
}
resetHiveKerberosFields(profile.type === "hive" || profile.type === "argo" || profile.type === "kyuubi" || profile.type === "impala" ? form.value : undefined);
resetHiveKerberosFields(profile.type === "hive" || profile.type === "argo" || profile.type === "transwarp" || profile.type === "kyuubi" || profile.type === "impala" ? form.value : undefined);
}
if (profile.type === "meilisearch") {
syncMeilisearchHostInput(form.value);
@@ -3174,7 +3177,7 @@ watch(
resetSalesforceOAuthFields(undefined, undefined);
}
resetElasticsearchProxyFields(config.db_type === "elasticsearch" ? config.external_config : undefined);
resetHiveKerberosFields(config.db_type === "hive" || config.db_type === "argo" || config.db_type === "kyuubi" || config.db_type === "impala" ? config : undefined);
resetHiveKerberosFields(config.db_type === "hive" || config.db_type === "argo" || config.db_type === "transwarp" || config.db_type === "kyuubi" || config.db_type === "impala" ? config : undefined);
resetDamengJvmOptions(config.db_type === "dameng" ? config : undefined);
h2ConnectionMode.value = h2ConnectionModeForConfig(config);
customColorInput.value = config.color || "";
@@ -4696,7 +4699,7 @@ function connectionConfigForSubmit(id: string, generatedName = "", validatePlugi
config.ssl = !!config.ssl || damengSsl.enabled;
config.url_params = applyDamengSslUrlParams(config.url_params, config.ssl, damengSsl.sslFilesPath, damengSsl.sslKeystorePassword, damengSsl.sslProtocol);
}
if (config.db_type === "hive" || config.db_type === "argo" || config.db_type === "kyuubi" || config.db_type === "impala") {
if (config.db_type === "hive" || config.db_type === "argo" || config.db_type === "transwarp" || config.db_type === "kyuubi" || config.db_type === "impala") {
if (hiveAuthMode.value === "kerberos" && !hivePrincipal.value.trim()) {
throw new Error(t("connection.hiveKerberosPrincipalRequired"));
}
@@ -5093,6 +5096,10 @@ function connectionConfigForSubmit(id: string, generatedName = "", validatePlugi
config.jdbc_driver_class = undefined;
config.jdbc_driver_paths = [];
}
if (config.db_type === "transwarp") {
config.jdbc_driver_class = undefined;
config.jdbc_driver_paths = [];
}
if (config.db_type === "h2") {
if (config.driver_profile === "h2-custom") {
config.jdbc_driver_class = config.jdbc_driver_class?.trim() || "org.h2.Driver";
@@ -8880,7 +8887,7 @@ function openExternalUrl(url: string) {
<p class="col-span-3 text-xs text-muted-foreground">{{ t("connection.oracleTnsPathHint") }}</p>
</div>
<template v-if="form.db_type === 'hive' || form.db_type === 'kyuubi' || form.db_type === 'impala'">
<template v-if="form.db_type === 'hive' || form.db_type === 'transwarp' || form.db_type === 'kyuubi' || form.db_type === 'impala'">
<div class="grid grid-cols-4 items-center gap-4">
<Label :class="connectionLabelClass">{{ t("connection.hiveAuthMode") }}</Label>
<div class="col-span-3 grid h-8 grid-cols-2 overflow-hidden rounded-md border border-input bg-muted/30 p-0.5">
@@ -9023,7 +9030,9 @@ function openExternalUrl(url: string) {
? 'catalog=paimon_catalog'
: form.db_type === 'cassandra'
? 'localdatacenter=dc1'
: 'sslmode=prefer'
: form.db_type === 'transwarp'
? 'fetchSize=500;auth=noSasl'
: 'sslmode=prefer'
"
/>
<p v-if="showGenericUrlParamsHint" class="text-xs leading-5 text-muted-foreground">
@@ -3409,13 +3409,14 @@ const canDeleteExistingRows = computed(() => !!props.customSaveHandler || canDel
watch(
() => [props.databaseType, props.connectionId, props.database, props.tableMeta?.schema, props.tableMeta?.tableName],
async () => {
if (props.databaseType !== "hive" || !props.connectionId || !props.database || !props.tableMeta) {
if ((props.databaseType !== "hive" && props.databaseType !== "transwarp") || !props.connectionId || !props.database || !props.tableMeta) {
hiveTableTransactional.value = undefined;
return;
}
try {
const sql = await buildHiveTablePropertiesSql({
schema: props.tableMeta.schema,
databaseType: props.databaseType,
schema: props.tableMeta.schema || props.database,
tableName: props.tableMeta.tableName,
propertyName: "transactional",
});
@@ -66,6 +66,11 @@ describe("ConnectionIcon", () => {
expect(listPlugins).not.toHaveBeenCalled();
});
it("shows the Inceptor logo for a saved Transwarp connection", async () => {
const container = await mountIcon({ ...connection, db_type: "transwarp", driver_profile: "transwarp-inceptor" });
expect(container.querySelector("img")?.getAttribute("src")).toBe("/icons/database/transwarp-inceptor.png");
});
it("renders a safe fallback for missing connection metadata", async () => {
const container = await mountIcon();
expect(container.querySelector("img")?.getAttribute("src")).toBe("/icons/database/postgres.svg");
+11
View File
@@ -55,6 +55,17 @@ describe("DatabaseIcon", () => {
app.unmount();
});
it.each(["transwarp", "transwarp-inceptor"])("uses the Inceptor asset for %s", async (dbType) => {
const container = document.createElement("div");
document.body.appendChild(container);
const app = createApp(DatabaseIcon, { dbType });
app.mount(container);
await nextTick();
expect(container.querySelector("img")?.getAttribute("src")).toBe("/icons/database/transwarp-inceptor.png");
app.unmount();
});
it("uses the Meilisearch asset", async () => {
const container = document.createElement("div");
document.body.appendChild(container);
@@ -60,6 +60,8 @@ const assetIcons: Record<string, string> = {
prestosql: "presto",
hive: "hive",
argo: "hive",
transwarp: "transwarp-inceptor.png",
transwarp_inceptor: "transwarp-inceptor.png",
kyuubi: "kyuubi.png",
impala: "impala",
hbase: "hbase",
@@ -129,6 +131,7 @@ const assetIcons: Record<string, string> = {
const normalizedType = computed(() => (props.dbType || "").toLowerCase().replace(/[\s-]+/g, "_"));
const assetName = computed(() => assetIcons[normalizedType.value]);
const useLightIconInDarkMode = computed(() => normalizedType.value === "easysearch" && isDark.value);
const brightenInceptorInDarkMode = computed(() => isDark.value && (normalizedType.value === "transwarp" || normalizedType.value === "transwarp_inceptor"));
const assetSrc = computed(() => {
if (!assetName.value) return "";
if (normalizedType.value === "uxdb" && isDark.value) return webPath("/icons/database/uxdb-dark.svg");
@@ -137,7 +140,14 @@ const assetSrc = computed(() => {
</script>
<template>
<img v-if="assetName" :src="assetSrc" alt="" class="database-logo object-contain" :class="{ 'database-logo-light': useLightIconInDarkMode, 'database-logo-impala': normalizedType === 'impala', 'database-logo-solr': normalizedType === 'solr' }" aria-hidden="true" />
<img
v-if="assetName"
:src="assetSrc"
alt=""
class="database-logo object-contain"
:class="{ 'database-logo-light': useLightIconInDarkMode, 'database-logo-inceptor-dark': brightenInceptorInDarkMode, 'database-logo-impala': normalizedType === 'impala', 'database-logo-solr': normalizedType === 'solr' }"
aria-hidden="true"
/>
<Database v-else class="text-blue-400" />
</template>
@@ -151,6 +161,10 @@ const assetSrc = computed(() => {
filter: brightness(0) invert(82%);
}
.database-logo-inceptor-dark {
filter: brightness(1.6);
}
.database-logo-impala {
transform: scale(1.55);
}
@@ -0,0 +1,98 @@
<script setup lang="ts">
import { computed, ref } from "vue";
import { ChevronDown } from "@lucide/vue";
import { useI18n } from "vue-i18n";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuTrigger } from "@/components/ui/dropdown-menu";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
import type { TablePhysicalOptionsConfig, TablePhysicalOptionsDraft } from "@/lib/table/tablePhysicalOptions";
const props = defineProps<{
modelValue: TablePhysicalOptionsDraft;
config: TablePhysicalOptionsConfig;
columns: Array<{ id: string; name: string }>;
disabled?: boolean;
}>();
const emit = defineEmits<{ "update:modelValue": [value: TablePhysicalOptionsDraft] }>();
const { t } = useI18n();
const search = ref({ partition: "", distribution: "" });
type ColumnGroup = "partition" | "distribution";
const columnGroups = computed(() => [
{ key: "partition" as const, label: props.config.partitionColumnsLabel },
{ key: "distribution" as const, label: props.config.distributionColumnsLabel },
]);
function selectedIds(group: ColumnGroup): string[] {
return group === "partition" ? props.modelValue.partitionColumnIds : props.modelValue.distributionColumnIds;
}
function selectedNames(group: ColumnGroup): string {
const selected = new Set(selectedIds(group));
return props.columns
.filter((column) => selected.has(column.id))
.map((column) => column.name)
.join(", ");
}
function availableColumns(group: ColumnGroup) {
const filter = search.value[group].trim().toLowerCase();
return props.columns.filter((column) => !filter || column.name.toLowerCase().includes(filter));
}
function toggleColumn(group: ColumnGroup, id: string) {
const current = selectedIds(group);
const next = current.includes(id) ? current.filter((selected) => selected !== id) : [...current, id];
emit("update:modelValue", {
...props.modelValue,
[group === "partition" ? "partitionColumnIds" : "distributionColumnIds"]: next,
});
}
function updateValue<K extends keyof TablePhysicalOptionsDraft>(field: K, value: TablePhysicalOptionsDraft[K]) {
emit("update:modelValue", { ...props.modelValue, [field]: value });
}
</script>
<template>
<div class="flex shrink-0 flex-wrap items-end gap-3 border-b pb-2">
<label v-for="group in columnGroups" :key="group.key" class="flex min-w-0 max-w-full flex-col gap-1 text-muted-foreground">
<span>{{ t(group.label) }}</span>
<DropdownMenu>
<DropdownMenuTrigger as-child>
<Button variant="outline" size="sm" class="h-8 w-48 max-w-full justify-between gap-1 px-2 font-normal" :disabled="disabled" :aria-label="t(group.label)">
<span class="min-w-0 truncate font-mono">{{ selectedNames(group.key) || t("structureEditor.indexColumnsPlaceholder") }}</span>
<ChevronDown class="size-3.5 shrink-0" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent class="max-h-64 min-w-48 overflow-y-auto" side="bottom" :side-offset="2">
<div class="px-2 pb-1 pt-0.5">
<Input v-model="search[group.key]" class="h-7 text-xs" :placeholder="t('grid.search')" @click.stop />
</div>
<DropdownMenuCheckboxItem v-for="column in availableColumns(group.key)" :key="column.id" :checked="selectedIds(group.key).includes(column.id)" @select.prevent @click="toggleColumn(group.key, column.id)">
{{ column.name }}
</DropdownMenuCheckboxItem>
<div v-if="availableColumns(group.key).length === 0" class="px-2 py-1 text-xs text-muted-foreground">{{ t("structureEditor.indexColumnsPlaceholder") }}</div>
</DropdownMenuContent>
</DropdownMenu>
</label>
<label class="flex min-w-0 max-w-full flex-col gap-1 text-muted-foreground">
<span>{{ t(config.bucketCountLabel) }}</span>
<Input :model-value="modelValue.bucketCount" type="number" min="1" :max="config.maxBuckets" step="1" class="h-8 w-24 max-w-full" :disabled="disabled" @update:model-value="updateValue('bucketCount', String($event ?? ''))" />
</label>
<label v-if="config.storageFormats.length" class="flex min-w-0 max-w-full flex-col gap-1 text-muted-foreground">
<span>{{ t(config.storageFormatLabel) }}</span>
<Select :model-value="modelValue.storageFormat || '__default'" :disabled="disabled" @update:model-value="updateValue('storageFormat', $event === '__default' ? '' : String($event))">
<SelectTrigger class="w-32 max-w-full"><SelectValue :placeholder="t('structureEditor.defaultAction')" /></SelectTrigger>
<SelectContent>
<SelectItem value="__default">{{ t("structureEditor.defaultAction") }}</SelectItem>
<SelectItem v-for="format in config.storageFormats" :key="format" :value="format">{{ format }}</SelectItem>
</SelectContent>
</Select>
</label>
<label v-if="config.transactionalLabel" class="flex h-9 items-center gap-2 text-muted-foreground">
<input :checked="modelValue.transactional" type="checkbox" class="h-4 w-4 accent-primary" :disabled="disabled" @change="updateValue('transactional', ($event.target as HTMLInputElement).checked)" />
{{ t(config.transactionalLabel) }}
</label>
</div>
</template>
@@ -16,6 +16,7 @@ import { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMe
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
import { SearchableSelect } from "@/components/ui/searchable-select";
import TablePhysicalOptionsEditor from "@/components/structure/TablePhysicalOptionsEditor.vue";
import CustomContextMenu, { type ContextMenuItem } from "@/components/ui/CustomContextMenu.vue";
import EditorSearchPanel from "@/components/editor/EditorSearchPanel.vue";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
@@ -58,6 +59,7 @@ import {
import { buildMysqlAutoIncrementCounterStatement, canEditMysqlAutoIncrementCounter, refreshMysqlAutoIncrementCounterDraft } from "@/lib/table/mysqlAutoIncrementCounter";
import { mysqlTableCollationSql, parseMysqlTableCollation } from "@/lib/table/mysqlTableCollation";
import { MYSQL_STORAGE_ENGINES_SQL, mysqlTableEngineSql, mysqlTableEngineSqlOption, parseMysqlTableEngineMetadata, refreshMysqlTableEngineDraft, supportsMysqlTableEngine } from "@/lib/table/mysqlTableEngine";
import { INCEPTOR_PHYSICAL_OPTIONS, buildInceptorCreateOptions, emptyTablePhysicalOptions, hasTablePhysicalOptions, pruneTablePhysicalOptions, restoreTablePhysicalOptions } from "@/lib/table/tablePhysicalOptions";
import { PRESET_FIELDS_TEMPLATE_ID, createTableColumnTemplateDrafts } from "@/lib/table/tableColumnTemplates";
import { getMysqlDataTypeHelp } from "@/lib/table/mysqlDataTypeHelp";
import { getPostgresDataTypeHelp, gaussdbMTypeDisplayName } from "@/lib/table/postgresDataTypeHelp";
@@ -1581,6 +1583,14 @@ const mysqlAutoIncrementLoading = ref(false);
const mysqlAutoIncrementLoadError = ref("");
const mysqlTableEngine = ref("");
const originalMysqlTableEngine = ref("");
const physicalOptions = ref(emptyTablePhysicalOptions());
watch(
() => columns.value.filter((column) => !column.markedForDrop).map((column) => column.id),
(ids) => {
if (!isCreateMode.value) return;
physicalOptions.value = pruneTablePhysicalOptions(physicalOptions.value, new Set(ids));
},
);
const mysqlTableEngineOptions = ref<string[]>([]);
const mysqlTableEngineLoading = ref(false);
const mysqlTableEngineLoadError = ref("");
@@ -1900,6 +1910,7 @@ function createCurrentDraft(initialized = true): TableStructureEditorDraft {
originalMysqlAutoIncrementValue: originalMysqlAutoIncrementValue.value,
mysqlTableEngine: mysqlTableEngine.value,
originalMysqlTableEngine: originalMysqlTableEngine.value,
physicalOptions: cloneDraftValue(physicalOptions.value),
tableOwner: tableOwner.value,
originalTableOwner: originalTableOwner.value,
columns: cloneDraftValue(columns.value),
@@ -1977,6 +1988,7 @@ function restoreDraft(draft: TableStructureEditorDraft) {
tableOwner.value = draft.tableOwner || "";
originalTableOwner.value = draft.originalTableOwner || "";
columns.value = cloneDraftValue(draft.columns || []);
physicalOptions.value = restoreTablePhysicalOptions(draft);
// Existing-index edits never support Concurrent (the checkbox is disabled and
// the core builder rejects the request), so a stale `concurrently: true`
// saved in a restored draft must not be submitted or deadlock the save.
@@ -2066,6 +2078,7 @@ function hasPendingStructureChanges(): boolean {
!!newTableName.value.trim() ||
!!tableComment.value.trim() ||
mysqlTableEngine.value !== originalMysqlTableEngine.value ||
hasTablePhysicalOptions(physicalOptions.value) ||
columns.value.length > 0 ||
indexes.value.length > 0 ||
foreignKeys.value.length > 0 ||
@@ -2236,6 +2249,7 @@ function structureChangeOptions(): BuildTableStructureChangeSqlOptions {
tableComment: tableComment.value,
originalTableComment: isCreateMode.value ? undefined : originalTableComment.value,
mysqlEngine: mysqlTableEngineSqlOption({ value: mysqlTableEngine.value, originalValue: originalMysqlTableEngine.value }, isCreateMode.value, supportsMysqlEngine.value && !mysqlTableEngineLoading.value && !mysqlTableEngineLoadError.value),
transwarpCreate: isCreateMode.value && databaseType.value === "transwarp" ? buildInceptorCreateOptions(physicalOptions.value, columns.value) : undefined,
tableCollation: mysqlTableDefaultCollation.value || undefined,
partitioned: isPartitionedParent.value,
isGaussdbMMode: connection.value?.driver_profile?.toLowerCase() === "gaussdb-m",
@@ -2425,6 +2439,7 @@ function resetState() {
mysqlAutoIncrementLoadError.value = "";
mysqlTableEngine.value = "";
originalMysqlTableEngine.value = "";
physicalOptions.value = emptyTablePhysicalOptions();
mysqlTableEngineOptions.value = [];
mysqlTableEngineLoadRequestId += 1;
mysqlTableEngineLoading.value = false;
@@ -4786,6 +4801,7 @@ watch(
mysqlAutoIncrementLoadError,
mysqlTableEngine,
originalMysqlTableEngine,
physicalOptions,
mysqlTableEngineLoading,
mysqlTableEngineLoadError,
mysqlTableDefaultCollation,
@@ -4965,6 +4981,8 @@ watch(
</Tooltip>
</div>
<TablePhysicalOptionsEditor v-if="isCreateMode && databaseType === 'transwarp'" v-model="physicalOptions" :config="INCEPTOR_PHYSICAL_OPTIONS" :columns="columns.filter((column) => !column.markedForDrop && !!column.name.trim())" :disabled="saving" />
<div v-if="supportsTableOwner" class="flex shrink-0 items-center gap-2">
<label class="flex shrink-0 items-center gap-1 font-medium text-muted-foreground">
<UserRound :class="structureIconClass" />