fdb2 1.0.13 → 1.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (313) hide show
  1. package/README.md +9 -2
  2. package/bin/docker/.env +4 -0
  3. package/package.json +26 -18
  4. package/public/favicon.ico +0 -0
  5. package/public/favicon.png +0 -0
  6. package/view/modules/header.tpl +1 -1
  7. package/.dockerignore +0 -21
  8. package/.editorconfig +0 -11
  9. package/.eslintrc.cjs +0 -14
  10. package/.eslintrc.json +0 -7
  11. package/.prettierrc.js +0 -3
  12. package/.tpl.env +0 -22
  13. package/.vscodeignore +0 -45
  14. package/dist/package.json +0 -115
  15. package/dist/pnpm-lock.yaml +0 -8135
  16. package/dist/public/.vite/manifest.json +0 -82
  17. package/dist/public/bootstrap-icons.woff +0 -0
  18. package/dist/public/bootstrap-icons.woff2 +0 -0
  19. package/dist/public/bootstrap.css +0 -14152
  20. package/dist/public/bootstrap.js +0 -5038
  21. package/dist/public/explorer.css +0 -2379
  22. package/dist/public/explorer.js +0 -50586
  23. package/dist/public/index.css +0 -1099
  24. package/dist/public/index.js +0 -12862
  25. package/dist/public/layout.css +0 -318
  26. package/dist/public/layout.js +0 -25
  27. package/dist/public/vue.css +0 -1
  28. package/dist/public/vue.js +0 -9110
  29. package/dist/scripts/preinstall.js +0 -112
  30. package/dist/server/index.d.ts +0 -2
  31. package/dist/server/index.d.ts.map +0 -1
  32. package/dist/server/index.js +0 -601
  33. package/dist/server/index.js.map +0 -1
  34. package/dist/server/index.ts +0 -681
  35. package/dist/server/model/connection.entity.d.ts +0 -55
  36. package/dist/server/model/connection.entity.d.ts.map +0 -1
  37. package/dist/server/model/connection.entity.js +0 -59
  38. package/dist/server/model/connection.entity.js.map +0 -1
  39. package/dist/server/model/connection.entity.ts +0 -66
  40. package/dist/server/model/database.entity.d.ts +0 -203
  41. package/dist/server/model/database.entity.d.ts.map +0 -1
  42. package/dist/server/model/database.entity.js +0 -211
  43. package/dist/server/model/database.entity.js.map +0 -1
  44. package/dist/server/model/database.entity.ts +0 -246
  45. package/dist/server/service/connection.service.d.ts +0 -84
  46. package/dist/server/service/connection.service.d.ts.map +0 -1
  47. package/dist/server/service/connection.service.js +0 -369
  48. package/dist/server/service/connection.service.js.map +0 -1
  49. package/dist/server/service/connection.service.ts +0 -359
  50. package/dist/server/service/database/base.service.d.ts +0 -183
  51. package/dist/server/service/database/base.service.d.ts.map +0 -1
  52. package/dist/server/service/database/base.service.js +0 -253
  53. package/dist/server/service/database/base.service.js.map +0 -1
  54. package/dist/server/service/database/base.service.ts +0 -407
  55. package/dist/server/service/database/cockroachdb.service.d.ts +0 -116
  56. package/dist/server/service/database/cockroachdb.service.d.ts.map +0 -1
  57. package/dist/server/service/database/cockroachdb.service.js +0 -812
  58. package/dist/server/service/database/cockroachdb.service.js.map +0 -1
  59. package/dist/server/service/database/cockroachdb.service.ts +0 -871
  60. package/dist/server/service/database/database.service.d.ts +0 -495
  61. package/dist/server/service/database/database.service.d.ts.map +0 -1
  62. package/dist/server/service/database/database.service.js +0 -711
  63. package/dist/server/service/database/database.service.js.map +0 -1
  64. package/dist/server/service/database/database.service.ts +0 -776
  65. package/dist/server/service/database/index.d.ts +0 -8
  66. package/dist/server/service/database/index.d.ts.map +0 -1
  67. package/dist/server/service/database/index.js +0 -18
  68. package/dist/server/service/database/index.js.map +0 -1
  69. package/dist/server/service/database/index.ts +0 -7
  70. package/dist/server/service/database/mongodb.service.d.ts +0 -121
  71. package/dist/server/service/database/mongodb.service.d.ts.map +0 -1
  72. package/dist/server/service/database/mongodb.service.js +0 -502
  73. package/dist/server/service/database/mongodb.service.js.map +0 -1
  74. package/dist/server/service/database/mongodb.service.ts +0 -501
  75. package/dist/server/service/database/mssql.service.d.ts +0 -118
  76. package/dist/server/service/database/mssql.service.d.ts.map +0 -1
  77. package/dist/server/service/database/mssql.service.js +0 -871
  78. package/dist/server/service/database/mssql.service.js.map +0 -1
  79. package/dist/server/service/database/mssql.service.ts +0 -932
  80. package/dist/server/service/database/mysql.service.d.ts +0 -114
  81. package/dist/server/service/database/mysql.service.d.ts.map +0 -1
  82. package/dist/server/service/database/mysql.service.js +0 -960
  83. package/dist/server/service/database/mysql.service.js.map +0 -1
  84. package/dist/server/service/database/mysql.service.ts +0 -1026
  85. package/dist/server/service/database/oracle.service.d.ts +0 -126
  86. package/dist/server/service/database/oracle.service.d.ts.map +0 -1
  87. package/dist/server/service/database/oracle.service.js +0 -963
  88. package/dist/server/service/database/oracle.service.js.map +0 -1
  89. package/dist/server/service/database/oracle.service.ts +0 -1036
  90. package/dist/server/service/database/postgres.service.d.ts +0 -122
  91. package/dist/server/service/database/postgres.service.d.ts.map +0 -1
  92. package/dist/server/service/database/postgres.service.js +0 -882
  93. package/dist/server/service/database/postgres.service.js.map +0 -1
  94. package/dist/server/service/database/postgres.service.ts +0 -961
  95. package/dist/server/service/database/sap.service.d.ts +0 -115
  96. package/dist/server/service/database/sap.service.d.ts.map +0 -1
  97. package/dist/server/service/database/sap.service.js +0 -868
  98. package/dist/server/service/database/sap.service.js.map +0 -1
  99. package/dist/server/service/database/sap.service.ts +0 -922
  100. package/dist/server/service/database/sqlite.service.d.ts +0 -112
  101. package/dist/server/service/database/sqlite.service.d.ts.map +0 -1
  102. package/dist/server/service/database/sqlite.service.js +0 -723
  103. package/dist/server/service/database/sqlite.service.js.map +0 -1
  104. package/dist/server/service/database/sqlite.service.ts +0 -787
  105. package/dist/server/service/session.service.ts +0 -158
  106. package/dist/view/index.html +0 -45
  107. package/env.d.ts +0 -1
  108. package/packages/vscode/.vscodeignore +0 -44
  109. package/packages/vscode/README.md +0 -62
  110. package/packages/vscode/out/database-services/base.service.js +0 -236
  111. package/packages/vscode/out/database-services/base.service.js.map +0 -1
  112. package/packages/vscode/out/database-services/cockroachdb.service.js +0 -634
  113. package/packages/vscode/out/database-services/cockroachdb.service.js.map +0 -1
  114. package/packages/vscode/out/database-services/connection.service.js +0 -346
  115. package/packages/vscode/out/database-services/connection.service.js.map +0 -1
  116. package/packages/vscode/out/database-services/database.service.js +0 -571
  117. package/packages/vscode/out/database-services/database.service.js.map +0 -1
  118. package/packages/vscode/out/database-services/index.js +0 -18
  119. package/packages/vscode/out/database-services/index.js.map +0 -1
  120. package/packages/vscode/out/database-services/model/connection.entity.js +0 -11
  121. package/packages/vscode/out/database-services/model/connection.entity.js.map +0 -1
  122. package/packages/vscode/out/database-services/model/database.entity.js +0 -35
  123. package/packages/vscode/out/database-services/model/database.entity.js.map +0 -1
  124. package/packages/vscode/out/database-services/mongodb.service.js +0 -458
  125. package/packages/vscode/out/database-services/mongodb.service.js.map +0 -1
  126. package/packages/vscode/out/database-services/mssql.service.js +0 -694
  127. package/packages/vscode/out/database-services/mssql.service.js.map +0 -1
  128. package/packages/vscode/out/database-services/mysql.service.js +0 -735
  129. package/packages/vscode/out/database-services/mysql.service.js.map +0 -1
  130. package/packages/vscode/out/database-services/oracle.service.js +0 -787
  131. package/packages/vscode/out/database-services/oracle.service.js.map +0 -1
  132. package/packages/vscode/out/database-services/postgres.service.js +0 -696
  133. package/packages/vscode/out/database-services/postgres.service.js.map +0 -1
  134. package/packages/vscode/out/database-services/sap.service.js +0 -695
  135. package/packages/vscode/out/database-services/sap.service.js.map +0 -1
  136. package/packages/vscode/out/database-services/sqlite.service.js +0 -532
  137. package/packages/vscode/out/database-services/sqlite.service.js.map +0 -1
  138. package/packages/vscode/out/extension.js +0 -93
  139. package/packages/vscode/out/extension.js.map +0 -1
  140. package/packages/vscode/out/provider/DatabaseTreeProvider.js +0 -159
  141. package/packages/vscode/out/provider/DatabaseTreeProvider.js.map +0 -1
  142. package/packages/vscode/out/provider/WebViewProvider.js +0 -259
  143. package/packages/vscode/out/provider/WebViewProvider.js.map +0 -1
  144. package/packages/vscode/out/service/ConnectionManager.js +0 -105
  145. package/packages/vscode/out/service/ConnectionManager.js.map +0 -1
  146. package/packages/vscode/out/service/DatabaseServiceBridge.js +0 -395
  147. package/packages/vscode/out/service/DatabaseServiceBridge.js.map +0 -1
  148. package/packages/vscode/out/typings/connection.js +0 -3
  149. package/packages/vscode/out/typings/connection.js.map +0 -1
  150. package/packages/vscode/package.json +0 -144
  151. package/packages/vscode/resources/icon.svg +0 -5
  152. package/packages/vscode/resources/webview/_plugin-vue_export-helper.js +0 -6529
  153. package/packages/vscode/resources/webview/_plugin-vue_export-helper.js.map +0 -1
  154. package/packages/vscode/resources/webview/connection.css +0 -69
  155. package/packages/vscode/resources/webview/connection.js +0 -228
  156. package/packages/vscode/resources/webview/connection.js.map +0 -1
  157. package/packages/vscode/resources/webview/database.css +0 -259
  158. package/packages/vscode/resources/webview/database.js +0 -275
  159. package/packages/vscode/resources/webview/database.js.map +0 -1
  160. package/packages/vscode/resources/webview/favicon.ico +0 -0
  161. package/packages/vscode/resources/webview/index.html +0 -9
  162. package/packages/vscode/resources/webview/modules/header.tpl +0 -14
  163. package/packages/vscode/resources/webview/modules/initial_state.tpl +0 -55
  164. package/packages/vscode/resources/webview/query.css +0 -162
  165. package/packages/vscode/resources/webview/query.js +0 -198
  166. package/packages/vscode/resources/webview/query.js.map +0 -1
  167. package/packages/vscode/src/database-services/base.service.js.map +0 -1
  168. package/packages/vscode/src/database-services/base.service.ts +0 -363
  169. package/packages/vscode/src/database-services/cockroachdb.service.js.map +0 -1
  170. package/packages/vscode/src/database-services/cockroachdb.service.ts +0 -659
  171. package/packages/vscode/src/database-services/connection.service.ts +0 -341
  172. package/packages/vscode/src/database-services/database.service.ts +0 -630
  173. package/packages/vscode/src/database-services/index.ts +0 -7
  174. package/packages/vscode/src/database-services/model/connection.entity.js +0 -11
  175. package/packages/vscode/src/database-services/model/connection.entity.js.map +0 -1
  176. package/packages/vscode/src/database-services/model/connection.entity.ts +0 -66
  177. package/packages/vscode/src/database-services/model/database.entity.js +0 -35
  178. package/packages/vscode/src/database-services/model/database.entity.js.map +0 -1
  179. package/packages/vscode/src/database-services/model/database.entity.ts +0 -246
  180. package/packages/vscode/src/database-services/mongodb.service.js.map +0 -1
  181. package/packages/vscode/src/database-services/mongodb.service.ts +0 -454
  182. package/packages/vscode/src/database-services/mssql.service.js.map +0 -1
  183. package/packages/vscode/src/database-services/mssql.service.ts +0 -723
  184. package/packages/vscode/src/database-services/mysql.service.js.map +0 -1
  185. package/packages/vscode/src/database-services/mysql.service.ts +0 -761
  186. package/packages/vscode/src/database-services/oracle.service.js.map +0 -1
  187. package/packages/vscode/src/database-services/oracle.service.ts +0 -832
  188. package/packages/vscode/src/database-services/postgres.service.js.map +0 -1
  189. package/packages/vscode/src/database-services/postgres.service.ts +0 -741
  190. package/packages/vscode/src/database-services/sap.service.js.map +0 -1
  191. package/packages/vscode/src/database-services/sap.service.ts +0 -713
  192. package/packages/vscode/src/database-services/sqlite.service.js.map +0 -1
  193. package/packages/vscode/src/database-services/sqlite.service.ts +0 -558
  194. package/packages/vscode/src/extension.ts +0 -76
  195. package/packages/vscode/src/provider/DatabaseTreeProvider.ts +0 -167
  196. package/packages/vscode/src/provider/WebViewProvider.ts +0 -277
  197. package/packages/vscode/src/service/DatabaseServiceBridge.ts +0 -414
  198. package/packages/vscode/src/typings/connection.ts +0 -90
  199. package/packages/vscode/tsconfig.json +0 -21
  200. package/scripts/preinstall.js +0 -112
  201. package/server/index.ts +0 -681
  202. package/server/model/connection.entity.js +0 -11
  203. package/server/model/connection.entity.js.map +0 -1
  204. package/server/model/connection.entity.ts +0 -66
  205. package/server/model/database.entity.js +0 -35
  206. package/server/model/database.entity.js.map +0 -1
  207. package/server/model/database.entity.ts +0 -246
  208. package/server/service/connection.service.ts +0 -359
  209. package/server/service/database/base.service.ts +0 -407
  210. package/server/service/database/cockroachdb.service.ts +0 -871
  211. package/server/service/database/database.service.ts +0 -776
  212. package/server/service/database/index.ts +0 -7
  213. package/server/service/database/mongodb.service.ts +0 -501
  214. package/server/service/database/mssql.service.ts +0 -932
  215. package/server/service/database/mysql.service.ts +0 -1026
  216. package/server/service/database/oracle.service.ts +0 -1036
  217. package/server/service/database/postgres.service.ts +0 -961
  218. package/server/service/database/sap.service.ts +0 -922
  219. package/server/service/database/sqlite.service.ts +0 -787
  220. package/server/service/session.service.ts +0 -158
  221. package/server/tsconfig.json +0 -20
  222. package/src/adapter/ajax.ts +0 -135
  223. package/src/assets/base.css +0 -1
  224. package/src/assets/database.css +0 -950
  225. package/src/assets/images/collapse.png +0 -0
  226. package/src/assets/images/no-login.png +0 -0
  227. package/src/assets/images/svg/illustrations/illustration-1.svg +0 -1
  228. package/src/assets/images/svg/illustrations/illustration-2.svg +0 -2
  229. package/src/assets/images/svg/illustrations/illustration-3.svg +0 -50
  230. package/src/assets/images/svg/illustrations/illustration-4.svg +0 -1
  231. package/src/assets/images/svg/illustrations/illustration-5.svg +0 -73
  232. package/src/assets/images/svg/illustrations/illustration-6.svg +0 -89
  233. package/src/assets/images/svg/illustrations/illustration-7.svg +0 -39
  234. package/src/assets/images/svg/illustrations/illustration-8.svg +0 -1
  235. package/src/assets/images/svg/separators/curve-2.svg +0 -3
  236. package/src/assets/images/svg/separators/curve.svg +0 -3
  237. package/src/assets/images/svg/separators/line.svg +0 -3
  238. package/src/assets/images/theme/light/screen-1-1000x800.jpg +0 -0
  239. package/src/assets/images/theme/light/screen-2-1000x800.jpg +0 -0
  240. package/src/assets/login/bg.jpg +0 -0
  241. package/src/assets/login/bg.png +0 -0
  242. package/src/assets/login/left.jpg +0 -0
  243. package/src/assets/logo.svg +0 -73
  244. package/src/assets/logo.webp +0 -0
  245. package/src/assets/main.css +0 -1
  246. package/src/base/config.ts +0 -20
  247. package/src/base/detect.ts +0 -134
  248. package/src/base/entity.ts +0 -92
  249. package/src/base/eventBus.ts +0 -37
  250. package/src/components/connection-editor/index.vue +0 -589
  251. package/src/components/dataGrid/index.vue +0 -163
  252. package/src/components/dataGrid/pagination.vue +0 -106
  253. package/src/components/loading/index.vue +0 -43
  254. package/src/components/modal/index.ts +0 -181
  255. package/src/components/modal/index.vue +0 -560
  256. package/src/components/toast/index.ts +0 -44
  257. package/src/components/toast/toast.vue +0 -58
  258. package/src/components/user/name.vue +0 -104
  259. package/src/components/user/selector.vue +0 -416
  260. package/src/domain/SysConfig.ts +0 -74
  261. package/src/platform/App.vue +0 -8
  262. package/src/platform/database/components/connection-detail.vue +0 -1153
  263. package/src/platform/database/components/data-editor.vue +0 -478
  264. package/src/platform/database/components/data-import-export.vue +0 -1602
  265. package/src/platform/database/components/database-detail.vue +0 -1199
  266. package/src/platform/database/components/database-monitor.vue +0 -1086
  267. package/src/platform/database/components/db-tools.vue +0 -1265
  268. package/src/platform/database/components/query-history.vue +0 -1349
  269. package/src/platform/database/components/sql-executor.vue +0 -738
  270. package/src/platform/database/components/sql-query-editor.vue +0 -1046
  271. package/src/platform/database/components/table-data-grid.vue +0 -273
  272. package/src/platform/database/components/table-detail.vue +0 -1173
  273. package/src/platform/database/components/table-editor.vue +0 -917
  274. package/src/platform/database/explorer.vue +0 -1840
  275. package/src/platform/database/index.vue +0 -1193
  276. package/src/platform/database/layout.vue +0 -367
  277. package/src/platform/database/router.ts +0 -37
  278. package/src/platform/database/styles/common.scss +0 -602
  279. package/src/platform/database/types/common.ts +0 -445
  280. package/src/platform/database/utils/export.ts +0 -232
  281. package/src/platform/database/utils/helpers.ts +0 -437
  282. package/src/platform/index.ts +0 -33
  283. package/src/platform/router.ts +0 -41
  284. package/src/platform/vscode/bridge.ts +0 -121
  285. package/src/platform/vscode/components/ConnectionPanel.vue +0 -272
  286. package/src/platform/vscode/components/DatabasePanel.vue +0 -532
  287. package/src/platform/vscode/components/QueryPanel.vue +0 -371
  288. package/src/platform/vscode/entry/connection.ts +0 -13
  289. package/src/platform/vscode/entry/database.ts +0 -13
  290. package/src/platform/vscode/entry/query.ts +0 -13
  291. package/src/platform/vscode/index.ts +0 -5
  292. package/src/service/base.ts +0 -134
  293. package/src/service/database.ts +0 -506
  294. package/src/service/login.ts +0 -121
  295. package/src/shims-vue.d.ts +0 -7
  296. package/src/stores/connection.ts +0 -266
  297. package/src/stores/session.ts +0 -87
  298. package/src/typings/database-types.ts +0 -413
  299. package/src/typings/database.ts +0 -364
  300. package/src/typings/global.d.ts +0 -58
  301. package/src/typings/pinia.d.ts +0 -8
  302. package/src/utils/clipboard.ts +0 -30
  303. package/src/utils/database-types.ts +0 -243
  304. package/src/utils/modal.ts +0 -124
  305. package/src/utils/request.ts +0 -55
  306. package/src/utils/sleep.ts +0 -4
  307. package/src/utils/toast.ts +0 -73
  308. package/src/utils/util.ts +0 -171
  309. package/src/utils/xlsx.ts +0 -228
  310. package/tsconfig.json +0 -33
  311. package/tsconfig.server.json +0 -19
  312. package/vite.config.ts +0 -424
  313. package/vite.config.vscode.ts +0 -47
@@ -1,414 +0,0 @@
1
- /**
2
- * 数据库服务桥接层
3
- * 用于 VSCode 扩展调用 server 目录下的现有数据库服务
4
- * 为了简化部署,这里直接实现必要的功能,复用 server 目录的逻辑
5
- */
6
-
7
- import * as fs from 'fs';
8
- import * as path from 'path';
9
- import * as os from 'os';
10
- import { DataSource, type DataSourceOptions } from 'typeorm';
11
-
12
- // 引入数据库服务接口(从本地复制的服务)
13
- import { MySQLService } from '../database-services/mysql.service';
14
- import { PostgreSQLService } from '../database-services/postgres.service';
15
- import { SQLiteService } from '../database-services/sqlite.service';
16
- import { OracleService } from '../database-services/oracle.service';
17
- import { SQLServerService } from '../database-services/mssql.service';
18
- import { CockroachDBService } from '../database-services/cockroachdb.service';
19
- import { MongoDBService } from '../database-services/mongodb.service';
20
- import { SAPHANADatabaseService } from '../database-services/sap.service';
21
- import { BaseDatabaseService } from '../database-services/base.service';
22
- import { ConnectionEntity } from '../database-services/model/connection.entity';
23
-
24
- /**
25
- * 数据库服务桥接类
26
- * 直接复用 server 目录下的服务
27
- */
28
- export class DatabaseServiceBridge {
29
- /**
30
- * 连接配置文件路径
31
- */
32
- private readonly configPath: string;
33
-
34
- /**
35
- * 活跃的数据库连接实例
36
- */
37
- private activeConnections: Map<string, DataSource> = new Map();
38
-
39
- /**
40
- * 数据库服务实例
41
- */
42
- private mysqlService: MySQLService;
43
- private postgreSQLService: PostgreSQLService;
44
- private sqliteService: SQLiteService;
45
- private oracleService: OracleService;
46
- private sqlServerService: SQLServerService;
47
- private cockroachDBService: CockroachDBService;
48
- private mongoDBService: MongoDBService;
49
- private sapHANADatabaseService: SAPHANADatabaseService;
50
-
51
- constructor() {
52
- const dataDir = process.env.DB_TOOL_DATA_DIR || path.join(os.homedir(), '.fdb2');
53
- this.configPath = path.join(dataDir, 'connections.json');
54
-
55
- this.mysqlService = new MySQLService();
56
- this.postgreSQLService = new PostgreSQLService();
57
- this.sqliteService = new SQLiteService();
58
- this.oracleService = new OracleService();
59
- this.sqlServerService = new SQLServerService();
60
- this.cockroachDBService = new CockroachDBService();
61
- this.mongoDBService = new MongoDBService();
62
- this.sapHANADatabaseService = new SAPHANADatabaseService();
63
- }
64
-
65
- /**
66
- * 初始化服务
67
- */
68
- async init() {
69
- const configDir = path.dirname(this.configPath);
70
- if (!fs.existsSync(configDir)) {
71
- fs.mkdirSync(configDir, { recursive: true });
72
- }
73
- }
74
-
75
- /**
76
- * 连接管理接口
77
- */
78
- get connection() {
79
- return {
80
- getAllConnections: this.getAllConnections.bind(this),
81
- getConnectionById: this.getConnectionById.bind(this),
82
- addConnection: this.addConnection.bind(this),
83
- updateConnection: this.updateConnection.bind(this),
84
- deleteConnection: this.deleteConnection.bind(this),
85
- testConnection: this.testConnection.bind(this)
86
- };
87
- }
88
-
89
- /**
90
- * 数据库管理接口
91
- */
92
- get database() {
93
- return {
94
- getDatabases: this.getDatabases.bind(this),
95
- getTables: this.getTables.bind(this),
96
- executeQuery: this.executeQuery.bind(this),
97
- getViews: this.getViews.bind(this),
98
- getProcedures: this.getProcedures.bind(this)
99
- };
100
- }
101
-
102
- /**
103
- * 连接管理实现
104
- */
105
- private async getAllConnections(): Promise<ConnectionEntity[]> {
106
- try {
107
- if (!fs.existsSync(this.configPath)) {
108
- return [];
109
- }
110
- const data = fs.readFileSync(this.configPath, 'utf8');
111
- return JSON.parse(data) as ConnectionEntity[];
112
- } catch (error) {
113
- console.error('读取连接配置失败:', error);
114
- return [];
115
- }
116
- }
117
-
118
- private async getConnectionById(id: string): Promise<ConnectionEntity | null> {
119
- const connections = await this.getAllConnections();
120
- return connections.find(conn => conn.id === id) || null;
121
- }
122
-
123
- private async addConnection(connection: ConnectionEntity): Promise<ConnectionEntity> {
124
- const connections = await this.getAllConnections();
125
-
126
- if (connections.find(conn => conn.name === connection.name)) {
127
- throw new Error('连接名称已存在');
128
- }
129
-
130
- connection.id = this.generateId();
131
- connection.createdAt = new Date();
132
- connection.updatedAt = new Date();
133
- connection.enabled = connection.enabled !== undefined ? connection.enabled : true;
134
-
135
- connections.push(connection);
136
- await this.saveConnections(connections);
137
-
138
- return connection;
139
- }
140
-
141
- private async updateConnection(id: string, updates: Partial<ConnectionEntity>): Promise<ConnectionEntity> {
142
- const connections = await this.getAllConnections();
143
- const index = connections.findIndex(conn => conn.id === id);
144
-
145
- if (index === -1) {
146
- throw new Error('连接配置不存在');
147
- }
148
-
149
- if (updates.name && connections.find((conn, idx) => conn.name === updates.name && idx !== index)) {
150
- throw new Error('连接名称已存在');
151
- }
152
-
153
- connections[index] = { ...connections[index], ...updates, updatedAt: new Date() } as ConnectionEntity;
154
- await this.saveConnections(connections);
155
-
156
- return connections[index];
157
- }
158
-
159
- private async deleteConnection(id: string): Promise<void> {
160
- const connections = await this.getAllConnections();
161
- const filteredConnections = connections.filter(conn => conn.id !== id);
162
-
163
- if (filteredConnections.length === connections.length) {
164
- throw new Error('连接配置不存在');
165
- }
166
-
167
- if (this.activeConnections.has(id)) {
168
- await this.activeConnections.get(id)?.destroy();
169
- this.activeConnections.delete(id);
170
- }
171
-
172
- await this.saveConnections(filteredConnections);
173
- }
174
-
175
- private async testConnection(connection: ConnectionEntity): Promise<boolean> {
176
- try {
177
- const tempDataSource = await this.createTypeORMDataSource(connection);
178
- await tempDataSource.query('SELECT 1');
179
- await tempDataSource.destroy();
180
- return true;
181
- } catch (error) {
182
- console.error(error);
183
- return false;
184
- }
185
- }
186
-
187
- /**
188
- * 数据库管理实现
189
- */
190
- private async getDatabases(connectionId: string): Promise<string[]> {
191
- const dataSource = await this.getActiveConnection(connectionId);
192
- const databaseService = this.getDatabaseService(dataSource.options.type as string);
193
- return databaseService.getDatabases(dataSource);
194
- }
195
-
196
- private async getTables(connectionId: string, databaseName: string): Promise<any[]> {
197
- const dataSource = await this.getActiveConnection(connectionId, databaseName);
198
- const databaseService = this.getDatabaseService(dataSource.options.type as string);
199
- return databaseService.getTables(dataSource, databaseName);
200
- }
201
-
202
- private async executeQuery(connectionId: string, sql: string, databaseName?: string): Promise<any> {
203
- const dataSource = await this.getActiveConnection(connectionId, databaseName);
204
- const databaseService = this.getDatabaseService(dataSource.options.type as string);
205
- return databaseService.executeQuery(dataSource, sql);
206
- }
207
-
208
- private async getViews(connectionId: string, databaseName: string): Promise<any[]> {
209
- const dataSource = await this.getActiveConnection(connectionId, databaseName);
210
- const databaseService = this.getDatabaseService(dataSource.options.type as string);
211
- return databaseService.getViews(dataSource, databaseName);
212
- }
213
-
214
- private async getProcedures(connectionId: string, databaseName: string): Promise<any[]> {
215
- const dataSource = await this.getActiveConnection(connectionId, databaseName);
216
- const databaseService = this.getDatabaseService(dataSource.options.type as string);
217
- return databaseService.getProcedures(dataSource, databaseName);
218
- }
219
-
220
- /**
221
- * 获取活跃的数据库连接
222
- */
223
- private async getActiveConnection(id: string, database?: string): Promise<DataSource> {
224
- const key = database ? `${id}_${database}` : id;
225
- if (this.activeConnections.has(key)) {
226
- const db = this.activeConnections.get(key);
227
- if (db?.isInitialized) {
228
- return db;
229
- } else {
230
- this.activeConnections.delete(key);
231
- }
232
- }
233
-
234
- if (this.activeConnections.size >= 10) {
235
- const oldestKey = this.activeConnections.keys().next().value || '';
236
- const oldestConnection = this.activeConnections.get(oldestKey);
237
- try {
238
- await oldestConnection?.destroy();
239
- } catch (error) {
240
- console.error(`关闭旧连接 ${oldestKey} 失败:`, error);
241
- }
242
- this.activeConnections.delete(oldestKey);
243
- }
244
-
245
- const connectionConfig = await this.getConnectionById(id);
246
- if (!connectionConfig) {
247
- throw new Error('连接配置不存在');
248
- }
249
-
250
- const updatedConnectionConfig: ConnectionEntity = {
251
- ...connectionConfig,
252
- database: database || connectionConfig.database
253
- };
254
-
255
- const dataSource = await this.createTypeORMDataSource(updatedConnectionConfig);
256
- this.activeConnections.set(key, dataSource);
257
-
258
- return dataSource;
259
- }
260
-
261
- /**
262
- * 创建TypeORM数据源
263
- */
264
- private async createTypeORMDataSource(connectionConfig: ConnectionEntity): Promise<DataSource> {
265
- const connectionOptions = this.getTypeORMOptions(connectionConfig);
266
- return new DataSource(connectionOptions).initialize();
267
- }
268
-
269
- /**
270
- * 获取TypeORM连接配置
271
- */
272
- private getTypeORMOptions(connectionConfig: ConnectionEntity): DataSourceOptions {
273
- const baseOptions: DataSourceOptions = {
274
- type: connectionConfig.type as any,
275
- host: connectionConfig.host,
276
- port: connectionConfig.port,
277
- username: connectionConfig.username,
278
- password: connectionConfig.password,
279
- database: connectionConfig.database,
280
- synchronize: false,
281
- logging: false,
282
- extra: {
283
- multipleStatements: true
284
- },
285
- ...connectionConfig.options
286
- };
287
-
288
- switch (connectionConfig.type.toLowerCase()) {
289
- case 'sqlite':
290
- return {
291
- ...baseOptions,
292
- type: 'sqlite' as any,
293
- database: connectionConfig.database,
294
- host: undefined,
295
- port: undefined,
296
- username: undefined,
297
- password: undefined
298
- };
299
- case 'postgres':
300
- case 'postgresql':
301
- return {
302
- ...baseOptions,
303
- type: 'postgres' as any,
304
- ssl: connectionConfig.options?.ssl || false
305
- };
306
- case 'oracle':
307
- return {
308
- ...baseOptions,
309
- type: 'oracle' as any,
310
- connectString: `${connectionConfig.host}:${connectionConfig.port}/${connectionConfig.database}`,
311
- host: undefined,
312
- port: undefined,
313
- database: undefined,
314
- extra: {
315
- connectionTimeout: 60000,
316
- poolMax: 10,
317
- poolMin: 1,
318
- poolIncrement: 1
319
- }
320
- };
321
- case 'mssql':
322
- case 'sqlserver':
323
- return {
324
- ...baseOptions,
325
- type: 'mssql' as any,
326
- options: {
327
- encrypt: connectionConfig.options?.encrypt || false,
328
- trustServerCertificate: true
329
- },
330
- extra: {
331
- connectionTimeout: 60000,
332
- requestTimeout: 15000
333
- }
334
- };
335
- default:
336
- return baseOptions;
337
- }
338
- }
339
-
340
- /**
341
- * 获取数据库服务实例
342
- */
343
- private getDatabaseService(type: string): BaseDatabaseService {
344
- switch (type.toLowerCase()) {
345
- case 'mysql':
346
- case 'aurora-mysql':
347
- case 'auroramysql':
348
- return this.mysqlService;
349
- case 'postgres':
350
- case 'postgresql':
351
- case 'aurora-postgres':
352
- case 'aurorapostgres':
353
- case 'aurora-postgresql':
354
- return this.postgreSQLService;
355
- case 'sqlite':
356
- case 'better-sqlite3':
357
- case 'bettersqlite3':
358
- return this.sqliteService;
359
- case 'oracle':
360
- return this.oracleService;
361
- case 'mssql':
362
- case 'sqlserver':
363
- return this.sqlServerService;
364
- case 'cockroachdb':
365
- case 'cockroach':
366
- return this.cockroachDBService;
367
- case 'mongodb':
368
- case 'mongo':
369
- return this.mongoDBService;
370
- case 'sap':
371
- case 'sap-hana':
372
- case 'saphana':
373
- return this.sapHANADatabaseService;
374
- default:
375
- throw new Error(`不支持的数据库类型: ${type}`);
376
- }
377
- }
378
-
379
- /**
380
- * 保存连接配置到文件
381
- */
382
- private async saveConnections(connections: ConnectionEntity[]): Promise<void> {
383
- try {
384
- const dir = path.dirname(this.configPath);
385
- if (!fs.existsSync(dir)) {
386
- fs.mkdirSync(dir, { recursive: true });
387
- }
388
- fs.writeFileSync(this.configPath, JSON.stringify(connections, null, 2), 'utf8');
389
- } catch (error) {
390
- console.error('保存连接配置失败:', error);
391
- throw error;
392
- }
393
- }
394
-
395
- /**
396
- * 生成唯一ID
397
- */
398
- private generateId(): string {
399
- return Date.now().toString(36) + Math.random().toString(36).substr(2);
400
- }
401
- }
402
-
403
- // 创建全局单例
404
- let bridgeInstance: DatabaseServiceBridge | null = null;
405
-
406
- /**
407
- * 获取数据库服务桥接实例
408
- */
409
- export function getDatabaseServiceBridge(): DatabaseServiceBridge {
410
- if (!bridgeInstance) {
411
- bridgeInstance = new DatabaseServiceBridge();
412
- }
413
- return bridgeInstance;
414
- }
@@ -1,90 +0,0 @@
1
- /**
2
- * 数据库连接配置
3
- */
4
- export interface DatabaseConnection {
5
- id: string;
6
- name: string;
7
- type: DatabaseType;
8
- host: string;
9
- port: number;
10
- database?: string;
11
- username?: string;
12
- password?: string;
13
- ssl?: boolean;
14
- charset?: string;
15
- timezone?: string;
16
- connectionTimeout?: number;
17
- createdAt?: number;
18
- updatedAt?: number;
19
- }
20
-
21
- /**
22
- * 支持的数据库类型
23
- */
24
- export type DatabaseType =
25
- | 'mysql'
26
- | 'postgresql'
27
- | 'sqlite'
28
- | 'sqlserver'
29
- | 'oracle'
30
- | 'cockroachdb'
31
- | 'mongodb'
32
- | 'sap_hana';
33
-
34
- /**
35
- * 数据库类型配置
36
- */
37
- export interface DatabaseTypeConfig {
38
- type: DatabaseType;
39
- name: string;
40
- defaultPort: number;
41
- icon: string;
42
- driver: string;
43
- supports: string[];
44
- }
45
-
46
- /**
47
- * 查询结果
48
- */
49
- export interface QueryResult {
50
- columns: string[];
51
- rows: any[];
52
- rowCount: number;
53
- executionTime: number;
54
- }
55
-
56
- /**
57
- * 表信息
58
- */
59
- export interface TableInfo {
60
- name: string;
61
- type: 'table' | 'view' | 'system';
62
- engine?: string;
63
- rows?: number;
64
- size?: string;
65
- comment?: string;
66
- }
67
-
68
- /**
69
- * 列信息
70
- */
71
- export interface ColumnInfo {
72
- name: string;
73
- type: string;
74
- nullable: boolean;
75
- key: string;
76
- default?: any;
77
- extra?: string;
78
- comment?: string;
79
- }
80
-
81
- /**
82
- * 数据库信息
83
- */
84
- export interface DatabaseInfo {
85
- name: string;
86
- size?: string;
87
- tables?: number;
88
- charset?: string;
89
- collation?: string;
90
- }
@@ -1,21 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "module": "commonjs",
4
- "target": "ES2020",
5
- "outDir": "out",
6
- "lib": ["ES2020"],
7
- "sourceMap": true,
8
- "rootDir": "src",
9
- "strict": false,
10
- "esModuleInterop": true,
11
- "skipLibCheck": true,
12
- "forceConsistentCasingInFileNames": true,
13
- "resolveJsonModule": true,
14
- "moduleResolution": "node",
15
- "types": ["node", "vscode"],
16
- "baseUrl": ".",
17
- "noErrorTruncation": true
18
- },
19
- "include": ["src/**/*"],
20
- "exclude": ["node_modules", ".vscode-test"]
21
- }
@@ -1,112 +0,0 @@
1
- const { execSync } = require('child_process');
2
- const path = require('path');
3
- const fs = require('fs');
4
- const os = require('os');
5
-
6
- console.log('Checking for running fdb2 instances...');
7
-
8
- try {
9
- let pid = null;
10
-
11
- // 检查当前目录的 PID 文件
12
- const currentDirPidPath = path.join(process.cwd(), 'fdb2.server.pid');
13
- if (fs.existsSync(currentDirPidPath)) {
14
- try {
15
- pid = parseInt(fs.readFileSync(currentDirPidPath, 'utf8'));
16
- process.kill(pid, 0);
17
- console.log('Found running fdb2 instance with PID:', pid);
18
- } catch (error) {
19
- if (error.code !== 'ESRCH') {
20
- throw error;
21
- }
22
- }
23
- }
24
-
25
- // 如果没有找到,尝试从全局安装目录查找
26
- if (!pid) {
27
- try {
28
- const globalPath = execSync('npm root -g', { encoding: 'utf8' }).trim();
29
- const globalPidPath = path.join(globalPath, 'fdb2', 'fdb2.server.pid');
30
-
31
- if (fs.existsSync(globalPidPath)) {
32
- try {
33
- pid = parseInt(fs.readFileSync(globalPidPath, 'utf8'));
34
- process.kill(pid, 0);
35
- console.log('Found running fdb2 instance with PID:', pid);
36
- } catch (error) {
37
- if (error.code !== 'ESRCH') {
38
- throw error;
39
- }
40
- }
41
- }
42
- } catch (error) {
43
- // 忽略全局路径查找失败
44
- }
45
- }
46
-
47
- // 如果找到了运行中的进程,尝试停止它
48
- if (pid) {
49
- console.log('Stopping fdb2...');
50
-
51
- try {
52
- if (os.platform() === 'win32') {
53
- // Windows: 使用 taskkill
54
- execSync(`taskkill /F /PID ${pid}`, { stdio: 'inherit' });
55
- } else {
56
- // Unix-like: 使用 kill
57
- process.kill(pid, 'SIGTERM');
58
-
59
- // 等待进程结束
60
- let attempts = 0;
61
- while (attempts < 10) {
62
- try {
63
- process.kill(pid, 0);
64
- attempts++;
65
- // 等待 100ms
66
- Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 100);
67
- } catch (error) {
68
- if (error.code === 'ESRCH') {
69
- // 进程已结束
70
- break;
71
- }
72
- }
73
- }
74
-
75
- // 如果进程还在运行,强制终止
76
- try {
77
- process.kill(pid, 0);
78
- process.kill(pid, 'SIGKILL');
79
- } catch (error) {
80
- if (error.code !== 'ESRCH') {
81
- throw error;
82
- }
83
- }
84
- }
85
-
86
- console.log('fdb2 stopped successfully');
87
- } catch (stopError) {
88
- console.warn('Failed to stop fdb2:', stopError.message);
89
- console.warn('Please manually stop the fdb2 process before installation');
90
- }
91
- } else {
92
- console.log('No running fdb2 instance found');
93
- }
94
-
95
- // 清理 PID 文件
96
- if (fs.existsSync(currentDirPidPath)) {
97
- fs.unlinkSync(currentDirPidPath);
98
- }
99
-
100
- try {
101
- const globalPath = execSync('npm root -g', { encoding: 'utf8' }).trim();
102
- const globalPidPath = path.join(globalPath, 'fdb2', 'fdb2.server.pid');
103
- if (fs.existsSync(globalPidPath)) {
104
- fs.unlinkSync(globalPidPath);
105
- }
106
- } catch (error) {
107
- // 忽略全局路径清理失败
108
- }
109
-
110
- } catch (error) {
111
- console.warn('Pre-install check failed:', error.message);
112
- }