fdb2 1.0.0

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 (125) hide show
  1. package/.dockerignore +21 -0
  2. package/.editorconfig +11 -0
  3. package/.eslintrc.cjs +14 -0
  4. package/.eslintrc.json +7 -0
  5. package/.prettierrc.js +3 -0
  6. package/.tpl.env +22 -0
  7. package/README.md +260 -0
  8. package/bin/build.sh +28 -0
  9. package/bin/deploy.sh +8 -0
  10. package/bin/dev.sh +10 -0
  11. package/bin/docker/.env +4 -0
  12. package/bin/docker/dev-docker-compose.yml +43 -0
  13. package/bin/docker/dev.Dockerfile +24 -0
  14. package/bin/docker/prod-docker-compose.yml +17 -0
  15. package/bin/docker/prod.Dockerfile +29 -0
  16. package/bin/fdb2.js +142 -0
  17. package/data/connections.demo.json +32 -0
  18. package/env.d.ts +1 -0
  19. package/nw-build.js +120 -0
  20. package/nw-dev.js +65 -0
  21. package/package.json +114 -0
  22. package/public/favicon.ico +0 -0
  23. package/public/index.html +9 -0
  24. package/public/modules/header.tpl +14 -0
  25. package/public/modules/initial_state.tpl +55 -0
  26. package/server/index.ts +677 -0
  27. package/server/model/connection.entity.ts +66 -0
  28. package/server/model/database.entity.ts +246 -0
  29. package/server/service/connection.service.ts +334 -0
  30. package/server/service/database/base.service.ts +363 -0
  31. package/server/service/database/database.service.ts +510 -0
  32. package/server/service/database/index.ts +7 -0
  33. package/server/service/database/mssql.service.ts +723 -0
  34. package/server/service/database/mysql.service.ts +761 -0
  35. package/server/service/database/oracle.service.ts +839 -0
  36. package/server/service/database/postgres.service.ts +744 -0
  37. package/server/service/database/sqlite.service.ts +559 -0
  38. package/server/service/session.service.ts +158 -0
  39. package/server.js +128 -0
  40. package/src/adapter/ajax.ts +135 -0
  41. package/src/assets/base.css +1 -0
  42. package/src/assets/database.css +950 -0
  43. package/src/assets/images/collapse.png +0 -0
  44. package/src/assets/images/no-login.png +0 -0
  45. package/src/assets/images/svg/illustrations/illustration-1.svg +1 -0
  46. package/src/assets/images/svg/illustrations/illustration-2.svg +2 -0
  47. package/src/assets/images/svg/illustrations/illustration-3.svg +50 -0
  48. package/src/assets/images/svg/illustrations/illustration-4.svg +1 -0
  49. package/src/assets/images/svg/illustrations/illustration-5.svg +73 -0
  50. package/src/assets/images/svg/illustrations/illustration-6.svg +89 -0
  51. package/src/assets/images/svg/illustrations/illustration-7.svg +39 -0
  52. package/src/assets/images/svg/illustrations/illustration-8.svg +1 -0
  53. package/src/assets/images/svg/separators/curve-2.svg +3 -0
  54. package/src/assets/images/svg/separators/curve.svg +3 -0
  55. package/src/assets/images/svg/separators/line.svg +3 -0
  56. package/src/assets/images/theme/light/screen-1-1000x800.jpg +0 -0
  57. package/src/assets/images/theme/light/screen-2-1000x800.jpg +0 -0
  58. package/src/assets/login/bg.jpg +0 -0
  59. package/src/assets/login/bg.png +0 -0
  60. package/src/assets/login/left.jpg +0 -0
  61. package/src/assets/logo.svg +73 -0
  62. package/src/assets/logo.webp +0 -0
  63. package/src/assets/main.css +1 -0
  64. package/src/base/config.ts +20 -0
  65. package/src/base/detect.ts +134 -0
  66. package/src/base/entity.ts +92 -0
  67. package/src/base/eventBus.ts +37 -0
  68. package/src/base//345/237/272/347/241/200/345/261/202.md +7 -0
  69. package/src/components/connection-editor/index.vue +590 -0
  70. package/src/components/dataGrid/index.vue +105 -0
  71. package/src/components/dataGrid/pagination.vue +106 -0
  72. package/src/components/loading/index.vue +43 -0
  73. package/src/components/modal/index.ts +181 -0
  74. package/src/components/modal/index.vue +560 -0
  75. package/src/components/toast/index.ts +44 -0
  76. package/src/components/toast/toast.vue +58 -0
  77. package/src/components/user/name.vue +104 -0
  78. package/src/components/user/selector.vue +416 -0
  79. package/src/domain/SysConfig.ts +74 -0
  80. package/src/platform/App.vue +8 -0
  81. package/src/platform/database/components/connection-detail.vue +1154 -0
  82. package/src/platform/database/components/data-editor.vue +478 -0
  83. package/src/platform/database/components/data-import-export.vue +1602 -0
  84. package/src/platform/database/components/database-detail.vue +1173 -0
  85. package/src/platform/database/components/database-monitor.vue +1086 -0
  86. package/src/platform/database/components/db-tools.vue +577 -0
  87. package/src/platform/database/components/query-history.vue +1349 -0
  88. package/src/platform/database/components/sql-executor.vue +738 -0
  89. package/src/platform/database/components/sql-query-editor.vue +1046 -0
  90. package/src/platform/database/components/table-detail.vue +1376 -0
  91. package/src/platform/database/components/table-editor.vue +690 -0
  92. package/src/platform/database/explorer.vue +1840 -0
  93. package/src/platform/database/index.vue +1193 -0
  94. package/src/platform/database/layout.vue +367 -0
  95. package/src/platform/database/router.ts +37 -0
  96. package/src/platform/database/styles/common.scss +602 -0
  97. package/src/platform/database/types/common.ts +445 -0
  98. package/src/platform/database/utils/export.ts +232 -0
  99. package/src/platform/database/utils/helpers.ts +437 -0
  100. package/src/platform/index.ts +33 -0
  101. package/src/platform/router.ts +41 -0
  102. package/src/service/base.ts +128 -0
  103. package/src/service/database.ts +500 -0
  104. package/src/service/login.ts +121 -0
  105. package/src/shims-vue.d.ts +7 -0
  106. package/src/stores/connection.ts +266 -0
  107. package/src/stores/session.ts +87 -0
  108. package/src/typings/database-types.ts +413 -0
  109. package/src/typings/database.ts +364 -0
  110. package/src/typings/global.d.ts +58 -0
  111. package/src/typings/pinia.d.ts +8 -0
  112. package/src/utils/clipboard.ts +30 -0
  113. package/src/utils/database-types.ts +243 -0
  114. package/src/utils/modal.ts +124 -0
  115. package/src/utils/request.ts +55 -0
  116. package/src/utils/sleep.ts +4 -0
  117. package/src/utils/toast.ts +73 -0
  118. package/src/utils/util.ts +171 -0
  119. package/src/utils/xlsx.ts +228 -0
  120. package/tsconfig.json +33 -0
  121. package/tsconfig.server.json +19 -0
  122. package/view/index.html +9 -0
  123. package/view/modules/header.tpl +14 -0
  124. package/view/modules/initial_state.tpl +20 -0
  125. package/vite.config.ts +384 -0
@@ -0,0 +1,413 @@
1
+ /**
2
+ * 数据库类型定义
3
+ */
4
+
5
+ export enum DatabaseType {
6
+ MYSQL = 'mysql',
7
+ POSTGRESQL = 'postgres',
8
+ SQLITE = 'sqlite',
9
+ ORACLE = 'oracle',
10
+ SQLSERVER = 'mssql'
11
+ }
12
+
13
+ /**
14
+ * 数据库类型配置
15
+ */
16
+ export interface DatabaseTypeConfig {
17
+ /** 类型值 */
18
+ value: DatabaseType;
19
+ /** 显示名称 */
20
+ label: string;
21
+ /** 图标 */
22
+ icon: string;
23
+ /** 默认端口 */
24
+ defaultPort: number | null;
25
+ /** 描述 */
26
+ description: string;
27
+ /** 支持的列类型 */
28
+ supportedColumnTypes: ColumnType[];
29
+ }
30
+
31
+ /**
32
+ * 列类型定义
33
+ */
34
+ export interface ColumnType {
35
+ /** 类型名称 */
36
+ name: string;
37
+ /** 显示名称 */
38
+ label: string;
39
+ /** 类别 */
40
+ category: ColumnCategory;
41
+ /** 是否需要长度参数 */
42
+ requiresLength?: boolean;
43
+ /** 是否需要精度参数 */
44
+ requiresPrecision?: boolean;
45
+ /** 是否需要小数位数参数 */
46
+ requiresScale?: boolean;
47
+ /** 默认长度 */
48
+ defaultLength?: number;
49
+ /** 默认精度 */
50
+ defaultPrecision?: number;
51
+ /** 默认小数位数 */
52
+ defaultScale?: number;
53
+ /** 是否支持无符号 */
54
+ supportsUnsigned?: boolean;
55
+ /** 是否支持自增 */
56
+ supportsAutoIncrement?: boolean;
57
+ /** 描述 */
58
+ description?: string;
59
+ }
60
+
61
+ /**
62
+ * 列类型类别
63
+ */
64
+ export enum ColumnCategory {
65
+ NUMERIC = 'numeric',
66
+ STRING = 'string',
67
+ DATE_TIME = 'date_time',
68
+ BOOLEAN = 'boolean',
69
+ BINARY = 'binary',
70
+ TEXT = 'text',
71
+ SPATIAL = 'spatial',
72
+ JSON = 'json',
73
+ ARRAY = 'array',
74
+ OTHER = 'other'
75
+ }
76
+
77
+ /**
78
+ * MySQL 列类型定义
79
+ */
80
+ export const MYSQL_COLUMN_TYPES: ColumnType[] = [
81
+ // 数值类型
82
+ { name: 'TINYINT', label: 'TINYINT', category: ColumnCategory.NUMERIC, requiresLength: true, defaultLength: 4, supportsUnsigned: true, supportsAutoIncrement: true, description: '微整数,1字节' },
83
+ { name: 'SMALLINT', label: 'SMALLINT', category: ColumnCategory.NUMERIC, requiresLength: true, defaultLength: 6, supportsUnsigned: true, supportsAutoIncrement: true, description: '小整数,2字节' },
84
+ { name: 'MEDIUMINT', label: 'MEDIUMINT', category: ColumnCategory.NUMERIC, requiresLength: true, defaultLength: 9, supportsUnsigned: true, supportsAutoIncrement: true, description: '中等整数,3字节' },
85
+ { name: 'INT', label: 'INT', category: ColumnCategory.NUMERIC, requiresLength: true, defaultLength: 11, supportsUnsigned: true, supportsAutoIncrement: true, description: '标准整数,4字节' },
86
+ { name: 'BIGINT', label: 'BIGINT', category: ColumnCategory.NUMERIC, requiresLength: true, defaultLength: 20, supportsUnsigned: true, supportsAutoIncrement: true, description: '大整数,8字节' },
87
+ { name: 'DECIMAL', label: 'DECIMAL', category: ColumnCategory.NUMERIC, requiresPrecision: true, requiresScale: true, defaultPrecision: 10, defaultScale: 2, description: '定点小数' },
88
+ { name: 'FLOAT', label: 'FLOAT', category: ColumnCategory.NUMERIC, requiresPrecision: true, defaultPrecision: 10, requiresScale: true, defaultScale: 2, description: '单精度浮点数' },
89
+ { name: 'DOUBLE', label: 'DOUBLE', category: ColumnCategory.NUMERIC, requiresPrecision: true, defaultPrecision: 16, requiresScale: true, defaultScale: 4, description: '双精度浮点数' },
90
+ { name: 'BIT', label: 'BIT', category: ColumnCategory.NUMERIC, requiresLength: true, defaultLength: 1, description: '位类型' },
91
+ { name: 'SERIAL', label: 'SERIAL', category: ColumnCategory.NUMERIC, supportsAutoIncrement: true, description: '自增整数(别名)' },
92
+
93
+ // 字符串类型
94
+ { name: 'CHAR', label: 'CHAR', category: ColumnCategory.STRING, requiresLength: true, defaultLength: 1, description: '固定长度字符串' },
95
+ { name: 'VARCHAR', label: 'VARCHAR', category: ColumnCategory.STRING, requiresLength: true, defaultLength: 255, description: '可变长度字符串' },
96
+ { name: 'BINARY', label: 'BINARY', category: ColumnCategory.BINARY, requiresLength: true, defaultLength: 1, description: '固定长度二进制' },
97
+ { name: 'VARBINARY', label: 'VARBINARY', category: ColumnCategory.BINARY, requiresLength: true, defaultLength: 255, description: '可变长度二进制' },
98
+
99
+ // 文本类型
100
+ { name: 'TINYTEXT', label: 'TINYTEXT', category: ColumnCategory.TEXT, description: '微型文本,最大255字符' },
101
+ { name: 'TEXT', label: 'TEXT', category: ColumnCategory.TEXT, description: '文本,最大65535字符' },
102
+ { name: 'MEDIUMTEXT', label: 'MEDIUMTEXT', category: ColumnCategory.TEXT, description: '中等文本,最大16MB' },
103
+ { name: 'LONGTEXT', label: 'LONGTEXT', category: ColumnCategory.TEXT, description: '长文本,最大4GB' },
104
+
105
+ // 日期时间类型
106
+ { name: 'DATE', label: 'DATE', category: ColumnCategory.DATE_TIME, description: '日期' },
107
+ { name: 'TIME', label: 'TIME', category: ColumnCategory.DATE_TIME, description: '时间' },
108
+ { name: 'DATETIME', label: 'DATETIME', category: ColumnCategory.DATE_TIME, description: '日期时间' },
109
+ { name: 'TIMESTAMP', label: 'TIMESTAMP', category: ColumnCategory.DATE_TIME, description: '时间戳' },
110
+ { name: 'YEAR', label: 'YEAR', category: ColumnCategory.DATE_TIME, description: '年份' },
111
+
112
+ // JSON 类型
113
+ { name: 'JSON', label: 'JSON', category: ColumnCategory.JSON, description: 'JSON数据类型' },
114
+
115
+ // 枚举和集合类型
116
+ { name: 'ENUM', label: 'ENUM', category: ColumnCategory.OTHER, description: '枚举类型' },
117
+ { name: 'SET', label: 'SET', category: ColumnCategory.OTHER, description: '集合类型' },
118
+
119
+ // 空间类型
120
+ { name: 'GEOMETRY', label: 'GEOMETRY', category: ColumnCategory.SPATIAL, description: '几何类型' },
121
+ { name: 'POINT', label: 'POINT', category: ColumnCategory.SPATIAL, description: '点类型' },
122
+ { name: 'LINESTRING', label: 'LINESTRING', category: ColumnCategory.SPATIAL, description: '线类型' },
123
+ { name: 'POLYGON', label: 'POLYGON', category: ColumnCategory.SPATIAL, description: '多边形类型' }
124
+ ];
125
+
126
+ /**
127
+ * PostgreSQL 列类型定义
128
+ */
129
+ export const POSTGRESQL_COLUMN_TYPES: ColumnType[] = [
130
+ // 数值类型
131
+ { name: 'SMALLINT', label: 'SMALLINT', category: ColumnCategory.NUMERIC, description: '小整数,2字节' },
132
+ { name: 'INTEGER', label: 'INTEGER', category: ColumnCategory.NUMERIC, supportsAutoIncrement: true, description: '整数,4字节' },
133
+ { name: 'BIGINT', label: 'BIGINT', category: ColumnCategory.NUMERIC, supportsAutoIncrement: true, description: '大整数,8字节' },
134
+ { name: 'DECIMAL', label: 'DECIMAL', category: ColumnCategory.NUMERIC, requiresPrecision: true, requiresScale: true, defaultPrecision: 10, defaultScale: 2, description: '定点小数' },
135
+ { name: 'NUMERIC', label: 'NUMERIC', category: ColumnCategory.NUMERIC, requiresPrecision: true, requiresScale: true, defaultPrecision: 10, defaultScale: 2, description: '定点小数' },
136
+ { name: 'REAL', label: 'REAL', category: ColumnCategory.NUMERIC, description: '单精度浮点数,4字节' },
137
+ { name: 'DOUBLE PRECISION', label: 'DOUBLE PRECISION', category: ColumnCategory.NUMERIC, description: '双精度浮点数,8字节' },
138
+ { name: 'SMALLSERIAL', label: 'SMALLSERIAL', category: ColumnCategory.NUMERIC, supportsAutoIncrement: true, description: '自增小整数' },
139
+ { name: 'SERIAL', label: 'SERIAL', category: ColumnCategory.NUMERIC, supportsAutoIncrement: true, description: '自增整数' },
140
+ { name: 'BIGSERIAL', label: 'BIGSERIAL', category: ColumnCategory.NUMERIC, supportsAutoIncrement: true, description: '自增大整数' },
141
+ { name: 'MONEY', label: 'MONEY', category: ColumnCategory.NUMERIC, description: '货币类型' },
142
+
143
+ // 字符串类型
144
+ { name: 'CHARACTER VARYING', label: 'VARCHAR', category: ColumnCategory.STRING, requiresLength: true, defaultLength: 255, description: '可变长度字符串' },
145
+ { name: 'CHARACTER', label: 'CHAR', category: ColumnCategory.STRING, requiresLength: true, defaultLength: 1, description: '固定长度字符串' },
146
+ { name: 'TEXT', label: 'TEXT', category: ColumnCategory.TEXT, description: '文本' },
147
+
148
+ // 二进制类型
149
+ { name: 'BYTEA', label: 'BYTEA', category: ColumnCategory.BINARY, description: '二进制数据' },
150
+
151
+ // 日期时间类型
152
+ { name: 'DATE', label: 'DATE', category: ColumnCategory.DATE_TIME, description: '日期' },
153
+ { name: 'TIME', label: 'TIME', category: ColumnCategory.DATE_TIME, description: '时间' },
154
+ { name: 'TIME WITH TIME ZONE', label: 'TIME WITH TIME ZONE', category: ColumnCategory.DATE_TIME, description: '带时区时间' },
155
+ { name: 'TIMESTAMP', label: 'TIMESTAMP', category: ColumnCategory.DATE_TIME, description: '时间戳' },
156
+ { name: 'TIMESTAMP WITH TIME ZONE', label: 'TIMESTAMP WITH TIME ZONE', category: ColumnCategory.DATE_TIME, description: '带时区时间戳' },
157
+ { name: 'INTERVAL', label: 'INTERVAL', category: ColumnCategory.DATE_TIME, description: '时间间隔' },
158
+
159
+ // 布尔类型
160
+ { name: 'BOOLEAN', label: 'BOOLEAN', category: ColumnCategory.BOOLEAN, description: '布尔值' },
161
+
162
+ // JSON 类型
163
+ { name: 'JSON', label: 'JSON', category: ColumnCategory.JSON, description: 'JSON数据类型' },
164
+ { name: 'JSONB', label: 'JSONB', category: ColumnCategory.JSON, description: '二进制JSON数据类型' },
165
+
166
+ // 数组类型
167
+ { name: 'TEXT[]', label: 'TEXT[]', category: ColumnCategory.ARRAY, description: '文本数组' },
168
+ { name: 'INTEGER[]', label: 'INTEGER[]', category: ColumnCategory.ARRAY, description: '整数数组' },
169
+
170
+ // UUID 类型
171
+ { name: 'UUID', label: 'UUID', category: ColumnCategory.OTHER, description: 'UUID类型' },
172
+
173
+ // 网络地址类型
174
+ { name: 'INET', label: 'INET', category: ColumnCategory.OTHER, description: 'IP地址' },
175
+ { name: 'CIDR', label: 'CIDR', category: ColumnCategory.OTHER, description: 'CIDR地址' },
176
+
177
+ // 几何类型
178
+ { name: 'POINT', label: 'POINT', category: ColumnCategory.SPATIAL, description: '点类型' },
179
+ { name: 'LINE', label: 'LINE', category: ColumnCategory.SPATIAL, description: '线类型' },
180
+ { name: 'LSEG', label: 'LSEG', category: ColumnCategory.SPATIAL, description: '线段类型' },
181
+ { name: 'BOX', label: 'BOX', category: ColumnCategory.SPATIAL, description: '矩形类型' },
182
+ { name: 'PATH', label: 'PATH', category: ColumnCategory.SPATIAL, description: '路径类型' },
183
+ { name: 'POLYGON', label: 'POLYGON', category: ColumnCategory.SPATIAL, description: '多边形类型' },
184
+ { name: 'CIRCLE', label: 'CIRCLE', category: ColumnCategory.SPATIAL, description: '圆形类型' }
185
+ ];
186
+
187
+ /**
188
+ * SQLite 列类型定义
189
+ */
190
+ export const SQLITE_COLUMN_TYPES: ColumnType[] = [
191
+ // 数值类型
192
+ { name: 'INTEGER', label: 'INTEGER', category: ColumnCategory.NUMERIC, supportsAutoIncrement: true, description: '整数,支持自增' },
193
+ { name: 'INT', label: 'INT', category: ColumnCategory.NUMERIC, supportsAutoIncrement: true, description: '整数(INTEGER别名)' },
194
+ { name: 'BIGINT', label: 'BIGINT', category: ColumnCategory.NUMERIC, description: '大整数' },
195
+ { name: 'SMALLINT', label: 'SMALLINT', category: ColumnCategory.NUMERIC, description: '小整数' },
196
+ { name: 'TINYINT', label: 'TINYINT', category: ColumnCategory.NUMERIC, description: '微整数' },
197
+ { name: 'REAL', label: 'REAL', category: ColumnCategory.NUMERIC, description: '浮点数' },
198
+ { name: 'DOUBLE', label: 'DOUBLE', category: ColumnCategory.NUMERIC, description: '双精度浮点数' },
199
+ { name: 'FLOAT', label: 'FLOAT', category: ColumnCategory.NUMERIC, description: '浮点数' },
200
+
201
+ // 字符串类型
202
+ { name: 'TEXT', label: 'TEXT', category: ColumnCategory.TEXT, description: '文本' },
203
+ { name: 'CHARACTER', label: 'CHARACTER', category: ColumnCategory.STRING, requiresLength: true, defaultLength: 1, description: '字符' },
204
+ { name: 'VARCHAR', label: 'VARCHAR', category: ColumnCategory.STRING, requiresLength: true, defaultLength: 255, description: '可变长字符串' },
205
+ { name: 'NCHAR', label: 'NCHAR', category: ColumnCategory.STRING, requiresLength: true, defaultLength: 1, description: 'Unicode字符' },
206
+ { name: 'NVARCHAR', label: 'NVARCHAR', category: ColumnCategory.STRING, requiresLength: true, defaultLength: 255, description: 'Unicode可变长字符串' },
207
+ { name: 'CLOB', label: 'CLOB', category: ColumnCategory.TEXT, description: '字符大对象' },
208
+
209
+ // 二进制类型
210
+ { name: 'BLOB', label: 'BLOB', category: ColumnCategory.BINARY, description: '二进制大对象' },
211
+ { name: 'BINARY', label: 'BINARY', category: ColumnCategory.BINARY, requiresLength: true, defaultLength: 1, description: '二进制' },
212
+ { name: 'VARBINARY', label: 'VARBINARY', category: ColumnCategory.BINARY, requiresLength: true, defaultLength: 255, description: '可变长二进制' },
213
+
214
+ // 日期时间类型
215
+ { name: 'DATE', label: 'DATE', category: ColumnCategory.DATE_TIME, description: '日期' },
216
+ { name: 'DATETIME', label: 'DATETIME', category: ColumnCategory.DATE_TIME, description: '日期时间' },
217
+ { name: 'TIME', label: 'TIME', category: ColumnCategory.DATE_TIME, description: '时间' },
218
+ { name: 'TIMESTAMP', label: 'TIMESTAMP', category: ColumnCategory.DATE_TIME, description: '时间戳' },
219
+
220
+ // 数值(特殊)
221
+ { name: 'NUMERIC', label: 'NUMERIC', category: ColumnCategory.NUMERIC, requiresPrecision: true, requiresScale: true, defaultPrecision: 10, defaultScale: 2, description: '定点小数' },
222
+ { name: 'DECIMAL', label: 'DECIMAL', category: ColumnCategory.NUMERIC, requiresPrecision: true, requiresScale: true, defaultPrecision: 10, defaultScale: 2, description: '定点小数' },
223
+ { name: 'BOOLEAN', label: 'BOOLEAN', category: ColumnCategory.BOOLEAN, description: '布尔值' },
224
+
225
+ // 其他类型
226
+ { name: 'ANY', label: 'ANY', category: ColumnCategory.OTHER, description: '任意类型' }
227
+ ];
228
+
229
+ /**
230
+ * Oracle 列类型定义
231
+ */
232
+ export const ORACLE_COLUMN_TYPES: ColumnType[] = [
233
+ // 数值类型
234
+ { name: 'NUMBER', label: 'NUMBER', category: ColumnCategory.NUMERIC, requiresPrecision: true, requiresScale: true, defaultPrecision: 10, defaultScale: 2, description: '数值类型' },
235
+ { name: 'INTEGER', label: 'INTEGER', category: ColumnCategory.NUMERIC, description: '整数类型' },
236
+ { name: 'INT', label: 'INT', category: ColumnCategory.NUMERIC, description: '整数类型' },
237
+ { name: 'SMALLINT', label: 'SMALLINT', category: ColumnCategory.NUMERIC, description: '小整数类型' },
238
+ { name: 'REAL', label: 'REAL', category: ColumnCategory.NUMERIC, description: '浮点数类型' },
239
+ { name: 'DOUBLE PRECISION', label: 'DOUBLE PRECISION', category: ColumnCategory.NUMERIC, description: '双精度浮点数' },
240
+ { name: 'FLOAT', label: 'FLOAT', category: ColumnCategory.NUMERIC, requiresPrecision: true, defaultPrecision: 126, description: '浮点数' },
241
+ { name: 'BINARY_FLOAT', label: 'BINARY_FLOAT', category: ColumnCategory.NUMERIC, description: '二进制浮点数' },
242
+ { name: 'BINARY_DOUBLE', label: 'BINARY_DOUBLE', category: ColumnCategory.NUMERIC, description: '双精度二进制浮点数' },
243
+
244
+ // 字符串类型
245
+ { name: 'CHAR', label: 'CHAR', category: ColumnCategory.STRING, requiresLength: true, defaultLength: 1, description: '固定长度字符串' },
246
+ { name: 'VARCHAR2', label: 'VARCHAR2', category: ColumnCategory.STRING, requiresLength: true, defaultLength: 4000, description: '可变长度字符串' },
247
+ { name: 'NVARCHAR2', label: 'NVARCHAR2', category: ColumnCategory.STRING, requiresLength: true, defaultLength: 2000, description: 'Unicode可变长度字符串' },
248
+ { name: 'NCHAR', label: 'NCHAR', category: ColumnCategory.STRING, requiresLength: true, defaultLength: 1, description: 'Unicode固定长度字符串' },
249
+ { name: 'CLOB', label: 'CLOB', category: ColumnCategory.TEXT, description: '字符大对象' },
250
+ { name: 'NCLOB', label: 'NCLOB', category: ColumnCategory.TEXT, description: 'Unicode字符大对象' },
251
+ { name: 'LONG', label: 'LONG', category: ColumnCategory.TEXT, description: '长字符串类型' },
252
+
253
+ // 二进制类型
254
+ { name: 'RAW', label: 'RAW', category: ColumnCategory.BINARY, requiresLength: true, defaultLength: 2000, description: '二进制数据' },
255
+ { name: 'LONG RAW', label: 'LONG RAW', category: ColumnCategory.BINARY, description: '长二进制数据' },
256
+ { name: 'BLOB', label: 'BLOB', category: ColumnCategory.BINARY, description: '二进制大对象' },
257
+ { name: 'BFILE', label: 'BFILE', category: ColumnCategory.BINARY, description: '外部二进制文件' },
258
+
259
+ // 日期时间类型
260
+ { name: 'DATE', label: 'DATE', category: ColumnCategory.DATE_TIME, description: '日期时间' },
261
+ { name: 'TIMESTAMP', label: 'TIMESTAMP', category: ColumnCategory.DATE_TIME, description: '时间戳' },
262
+ { name: 'TIMESTAMP WITH TIME ZONE', label: 'TIMESTAMP WITH TIME ZONE', category: ColumnCategory.DATE_TIME, description: '带时区时间戳' },
263
+ { name: 'TIMESTAMP WITH LOCAL TIME ZONE', label: 'TIMESTAMP WITH LOCAL TIME ZONE', category: ColumnCategory.DATE_TIME, description: '带本地时区时间戳' },
264
+ { name: 'INTERVAL YEAR TO MONTH', label: 'INTERVAL YEAR TO MONTH', category: ColumnCategory.DATE_TIME, description: '年月间隔' },
265
+ { name: 'INTERVAL DAY TO SECOND', label: 'INTERVAL DAY TO SECOND', category: ColumnCategory.DATE_TIME, description: '日秒间隔' },
266
+
267
+ // 行标识符类型
268
+ { name: 'ROWID', label: 'ROWID', category: ColumnCategory.OTHER, description: '行标识符' },
269
+ { name: 'UROWID', label: 'UROWID', category: ColumnCategory.OTHER, description: '通用行标识符' },
270
+
271
+ // XML 类型
272
+ { name: 'XMLTYPE', label: 'XMLTYPE', category: ColumnCategory.OTHER, description: 'XML数据类型' },
273
+
274
+ // 空间类型
275
+ { name: 'SDO_GEOMETRY', label: 'SDO_GEOMETRY', category: ColumnCategory.SPATIAL, description: '空间几何类型' }
276
+ ];
277
+
278
+ /**
279
+ * SQL Server 列类型定义
280
+ */
281
+ export const SQLSERVER_COLUMN_TYPES: ColumnType[] = [
282
+ // 精确数值类型
283
+ { name: 'BIGINT', label: 'BIGINT', category: ColumnCategory.NUMERIC, supportsAutoIncrement: true, description: '大整数,8字节' },
284
+ { name: 'INT', label: 'INT', category: ColumnCategory.NUMERIC, supportsAutoIncrement: true, description: '整数,4字节' },
285
+ { name: 'SMALLINT', label: 'SMALLINT', category: ColumnCategory.NUMERIC, description: '小整数,2字节' },
286
+ { name: 'TINYINT', label: 'TINYINT', category: ColumnCategory.NUMERIC, description: '微整数,1字节' },
287
+ { name: 'BIT', label: 'BIT', category: ColumnCategory.BOOLEAN, description: '位类型,布尔值' },
288
+ { name: 'DECIMAL', label: 'DECIMAL', category: ColumnCategory.NUMERIC, requiresPrecision: true, requiresScale: true, defaultPrecision: 18, defaultScale: 0, description: '定点小数' },
289
+ { name: 'NUMERIC', label: 'NUMERIC', category: ColumnCategory.NUMERIC, requiresPrecision: true, requiresScale: true, defaultPrecision: 18, defaultScale: 0, description: '定点小数' },
290
+ { name: 'MONEY', label: 'MONEY', category: ColumnCategory.NUMERIC, description: '货币类型,8字节' },
291
+ { name: 'SMALLMONEY', label: 'SMALLMONEY', category: ColumnCategory.NUMERIC, description: '小货币类型,4字节' },
292
+
293
+ // 近似数值类型
294
+ { name: 'FLOAT', label: 'FLOAT', category: ColumnCategory.NUMERIC, requiresPrecision: true, defaultPrecision: 53, description: '浮点数' },
295
+ { name: 'REAL', label: 'REAL', category: ColumnCategory.NUMERIC, description: '浮点数,4字节' },
296
+
297
+ // 日期时间类型
298
+ { name: 'DATE', label: 'DATE', category: ColumnCategory.DATE_TIME, description: '日期' },
299
+ { name: 'TIME', label: 'TIME', category: ColumnCategory.DATE_TIME, description: '时间' },
300
+ { name: 'DATETIMEOFFSET', label: 'DATETIMEOFFSET', category: ColumnCategory.DATE_TIME, description: '带时区日期时间' },
301
+ { name: 'DATETIME2', label: 'DATETIME2', category: ColumnCategory.DATE_TIME, description: '扩展日期时间' },
302
+ { name: 'SMALLDATETIME', label: 'SMALLDATETIME', category: ColumnCategory.DATE_TIME, description: '小日期时间' },
303
+ { name: 'DATETIME', label: 'DATETIME', category: ColumnCategory.DATE_TIME, description: '日期时间' },
304
+
305
+ // 字符串类型
306
+ { name: 'CHAR', label: 'CHAR', category: ColumnCategory.STRING, requiresLength: true, defaultLength: 1, description: '固定长度字符串' },
307
+ { name: 'VARCHAR', label: 'VARCHAR', category: ColumnCategory.STRING, requiresLength: true, defaultLength: 1, description: '可变长度字符串' },
308
+ { name: 'TEXT', label: 'TEXT', category: ColumnCategory.TEXT, description: '文本' },
309
+ { name: 'NCHAR', label: 'NCHAR', category: ColumnCategory.STRING, requiresLength: true, defaultLength: 1, description: 'Unicode固定长度字符串' },
310
+ { name: 'NVARCHAR', label: 'NVARCHAR', category: ColumnCategory.STRING, requiresLength: true, defaultLength: 1, description: 'Unicode可变长度字符串' },
311
+ { name: 'NTEXT', label: 'NTEXT', category: ColumnCategory.TEXT, description: 'Unicode文本' },
312
+
313
+ // 二进制字符串类型
314
+ { name: 'BINARY', label: 'BINARY', category: ColumnCategory.BINARY, requiresLength: true, defaultLength: 1, description: '固定长度二进制' },
315
+ { name: 'VARBINARY', label: 'VARBINARY', category: ColumnCategory.BINARY, requiresLength: true, defaultLength: 1, description: '可变长度二进制' },
316
+ { name: 'IMAGE', label: 'IMAGE', category: ColumnCategory.BINARY, description: '二进制图像' },
317
+
318
+ // 其他类型
319
+ { name: 'CURSOR', label: 'CURSOR', category: ColumnCategory.OTHER, description: '游标类型' },
320
+ { name: 'TIMESTAMP', label: 'TIMESTAMP', category: ColumnCategory.OTHER, description: '时间戳类型' },
321
+ { name: 'UNIQUEIDENTIFIER', label: 'UNIQUEIDENTIFIER', category: ColumnCategory.OTHER, description: '唯一标识符' },
322
+ { name: 'SQL_VARIANT', label: 'SQL_VARIANT', category: ColumnCategory.OTHER, description: '变体类型' },
323
+ { name: 'TABLE', label: 'TABLE', category: ColumnCategory.OTHER, description: '表类型' },
324
+ { name: 'XML', label: 'XML', category: ColumnCategory.OTHER, description: 'XML数据类型' },
325
+
326
+ // 空间类型
327
+ { name: 'GEOGRAPHY', label: 'GEOGRAPHY', category: ColumnCategory.SPATIAL, description: '地理空间类型' },
328
+ { name: 'GEOMETRY', label: 'GEOMETRY', category: ColumnCategory.SPATIAL, description: '几何空间类型' }
329
+ ];
330
+
331
+ /**
332
+ * 数据库类型配置映射
333
+ */
334
+ export const DATABASE_TYPE_CONFIGS: Record<DatabaseType, DatabaseTypeConfig> = {
335
+ [DatabaseType.MYSQL]: {
336
+ value: DatabaseType.MYSQL,
337
+ label: 'MySQL',
338
+ icon: 'bi-database',
339
+ defaultPort: 3306,
340
+ description: 'MySQL数据库',
341
+ supportedColumnTypes: MYSQL_COLUMN_TYPES
342
+ },
343
+ [DatabaseType.POSTGRESQL]: {
344
+ value: DatabaseType.POSTGRESQL,
345
+ label: 'PostgreSQL',
346
+ icon: 'bi-database',
347
+ defaultPort: 5432,
348
+ description: 'PostgreSQL数据库',
349
+ supportedColumnTypes: POSTGRESQL_COLUMN_TYPES
350
+ },
351
+ [DatabaseType.SQLITE]: {
352
+ value: DatabaseType.SQLITE,
353
+ label: 'SQLite',
354
+ icon: 'bi-database',
355
+ defaultPort: null,
356
+ description: 'SQLite数据库',
357
+ supportedColumnTypes: SQLITE_COLUMN_TYPES
358
+ },
359
+ [DatabaseType.ORACLE]: {
360
+ value: DatabaseType.ORACLE,
361
+ label: 'Oracle',
362
+ icon: 'bi-database',
363
+ defaultPort: 1521,
364
+ description: 'Oracle数据库',
365
+ supportedColumnTypes: ORACLE_COLUMN_TYPES
366
+ },
367
+ [DatabaseType.SQLSERVER]: {
368
+ value: DatabaseType.SQLSERVER,
369
+ label: 'SQL Server',
370
+ icon: 'bi-database',
371
+ defaultPort: 1433,
372
+ description: 'Microsoft SQL Server',
373
+ supportedColumnTypes: SQLSERVER_COLUMN_TYPES
374
+ }
375
+ };
376
+
377
+ /**
378
+ * 根据数据库类型获取列类型
379
+ */
380
+ export function getColumnTypes(databaseType: DatabaseType): ColumnType[] {
381
+ const config = DATABASE_TYPE_CONFIGS[databaseType];
382
+ return config?.supportedColumnTypes || [];
383
+ }
384
+
385
+ /**
386
+ * 根据数据库名称获取列类型
387
+ */
388
+ export function getColumnTypesByName(databaseTypeName: string): ColumnType[] {
389
+ const type = Object.values(DatabaseType).find(t => t === databaseTypeName.toLowerCase());
390
+ return type ? getColumnTypes(type) : [];
391
+ }
392
+
393
+ /**
394
+ * 根据类别获取列类型
395
+ */
396
+ export function getColumnTypesByCategory(databaseType: DatabaseType, category: ColumnCategory): ColumnType[] {
397
+ const allTypes = getColumnTypes(databaseType);
398
+ return allTypes.filter(type => type.category === category);
399
+ }
400
+
401
+ /**
402
+ * 获取所有支持的数据库类型配置
403
+ */
404
+ export function getDatabaseTypeConfigs(): DatabaseTypeConfig[] {
405
+ return Object.values(DATABASE_TYPE_CONFIGS);
406
+ }
407
+
408
+ /**
409
+ * 获取所有支持的数据库类型
410
+ */
411
+ export function getSupportedDatabaseTypes(): DatabaseType[] {
412
+ return Object.values(DatabaseType);
413
+ }