refactor: move tunnel and respond into core

This commit is contained in:
admin committed 2026-06-16 19:44:07 +05:00
1 parent c1c0e3383b
commit dd99f4a47b
8 files changed
+9 -6

No files matched your search

+3
View File
@@ -1,2 +1,5 @@
export type { ConnectionSource, ResolvedConnection, SshConfig } from './config/baseSchema.js' export type { ConnectionSource, ResolvedConnection, SshConfig } from './config/baseSchema.js'
export { baseConnectionShape, sshConfigSchema } from './config/baseSchema.js' export { baseConnectionShape, sshConfigSchema } from './config/baseSchema.js'
export { errorMessage, fail, ok } from './mcp/respond.js'
export type { Tunnel } from './net/tunnel.js'
export { buildSshAuth, expandHome, openTunnel } from './net/tunnel.js'
File renamed without changes.
@@ -2,7 +2,7 @@ import { readFileSync } from 'node:fs'
import net from 'node:net' import net from 'node:net'
import { homedir } from 'node:os' import { homedir } from 'node:os'
import { Client, type ConnectConfig } from 'ssh2' import { Client, type ConnectConfig } from 'ssh2'
import type { SshConfig } from '../config/types.js' import type { SshConfig } from '../config/baseSchema.js'
export type Tunnel = { export type Tunnel = {
localHost: string localHost: string
@@ -72,7 +72,7 @@ vi.mock('ssh2', () => ({
} }
})) }))
import type { SshConfig } from '../../../src/config/types.js' import type { SshConfig } from '../../../src/config/baseSchema.js'
import { buildSshAuth, expandHome, openTunnel } from '../../../src/net/tunnel.js' import { buildSshAuth, expandHome, openTunnel } from '../../../src/net/tunnel.js'
const sshConfig = (extra: Partial<SshConfig> = {}): SshConfig => ({ const sshConfig = (extra: Partial<SshConfig> = {}): SshConfig => ({
+1 -1
View File
@@ -1,6 +1,6 @@
import { openTunnel, type Tunnel } from '@dbmole/core'
import type { Registry } from '../config/registry.js' import type { Registry } from '../config/registry.js'
import { type ConnectionConfig, type ConnectionSource, defaultPort } from '../config/types.js' import { type ConnectionConfig, type ConnectionSource, defaultPort } from '../config/types.js'
import { openTunnel, type Tunnel } from '../net/tunnel.js'
import type { Driver, DriverTarget } from './driver.js' import type { Driver, DriverTarget } from './driver.js'
import { createMysqlDriver } from './mysql.js' import { createMysqlDriver } from './mysql.js'
import { createPostgresDriver } from './postgres.js' import { createPostgresDriver } from './postgres.js'
+1 -1
View File
@@ -1,3 +1,4 @@
import { errorMessage, fail, ok } from '@dbmole/core'
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js' import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
import * as z from 'zod' import * as z from 'zod'
import type { Registry } from '../config/registry.js' import type { Registry } from '../config/registry.js'
@@ -10,7 +11,6 @@ import {
import { DriverDisposedError } from '../db/driver.js' import { DriverDisposedError } from '../db/driver.js'
import type { Manager } from '../db/manager.js' import type { Manager } from '../db/manager.js'
import { formatDbError } from '../format.js' import { formatDbError } from '../format.js'
import { errorMessage, fail, ok } from './respond.js'
const patchSchema = z const patchSchema = z
.object({ .object({
+1 -1
View File
@@ -1,8 +1,8 @@
import { errorMessage, fail, ok } from '@dbmole/core'
import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js' import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js'
import { DriverDisposedError } from '../db/driver.js' import { DriverDisposedError } from '../db/driver.js'
import type { ManagedConnection, Manager } from '../db/manager.js' import type { ManagedConnection, Manager } from '../db/manager.js'
import { formatDbError } from '../format.js' import { formatDbError } from '../format.js'
import { errorMessage, fail, ok } from './respond.js'
// One transparent retry when the driver was disposed under the caller (a // One transparent retry when the driver was disposed under the caller (a
// concurrent invalidate/rotation ended its pools). manager.get on the retry // concurrent invalidate/rotation ended its pools). manager.get on the retry
@@ -1,9 +1,9 @@
import type { Tunnel } from '@dbmole/core'
import { beforeEach, describe, expect, it, vi } from 'vitest' import { beforeEach, describe, expect, it, vi } from 'vitest'
import type { Registry } from '../../../src/config/registry.js' import type { Registry } from '../../../src/config/registry.js'
import type { ConnectionConfig, ResolvedConnection, SshConfig } from '../../../src/config/types.js' import type { ConnectionConfig, ResolvedConnection, SshConfig } from '../../../src/config/types.js'
import type { Driver, DriverTarget } from '../../../src/db/driver.js' import type { Driver, DriverTarget } from '../../../src/db/driver.js'
import { createManager } from '../../../src/db/manager.js' import { createManager } from '../../../src/db/manager.js'
import type { Tunnel } from '../../../src/net/tunnel.js'
const config = (extra: Partial<ConnectionConfig> = {}): ConnectionConfig => ({ const config = (extra: Partial<ConnectionConfig> = {}): ConnectionConfig => ({
name: 'c', name: 'c',