@freshguard/freshguard-core 0.13.2 → 0.14.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.
- package/README.md +4 -1
- package/dist/connectors/azure-sql.d.ts +33 -0
- package/dist/connectors/azure-sql.d.ts.map +1 -0
- package/dist/connectors/azure-sql.js +371 -0
- package/dist/connectors/azure-sql.js.map +1 -0
- package/dist/connectors/index.d.ts +3 -0
- package/dist/connectors/index.d.ts.map +1 -1
- package/dist/connectors/index.js +3 -0
- package/dist/connectors/index.js.map +1 -1
- package/dist/connectors/mssql.d.ts +33 -0
- package/dist/connectors/mssql.d.ts.map +1 -0
- package/dist/connectors/mssql.js +368 -0
- package/dist/connectors/mssql.js.map +1 -0
- package/dist/connectors/synapse.d.ts +33 -0
- package/dist/connectors/synapse.d.ts.map +1 -0
- package/dist/connectors/synapse.js +375 -0
- package/dist/connectors/synapse.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types/connector.d.ts +1 -1
- package/dist/types/connector.d.ts.map +1 -1
- package/dist/types/connector.js +3 -0
- package/dist/types/connector.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
[](https://www.npmjs.com/package/@freshguard/freshguard-core)
|
|
7
7
|
[](https://freshguard-dev.github.io/freshguard-core)
|
|
8
8
|
|
|
9
|
-
Monitor when your data pipelines go stale. Supports PostgreSQL, DuckDB, BigQuery, Snowflake, MySQL, and
|
|
9
|
+
Monitor when your data pipelines go stale. Supports PostgreSQL, DuckDB, BigQuery, Snowflake, MySQL, Redshift, SQL Server, Azure SQL, and Azure Synapse. Self-hosted. Free forever.
|
|
10
10
|
|
|
11
11
|
## Install
|
|
12
12
|
|
|
@@ -75,6 +75,9 @@ if (result.status === 'alert') {
|
|
|
75
75
|
| Snowflake | `SnowflakeConnector` | 0.2.0 |
|
|
76
76
|
| MySQL | `MySQLConnector` | 0.11.0 |
|
|
77
77
|
| Redshift | `RedshiftConnector` | 0.11.0 |
|
|
78
|
+
| SQL Server | `MSSQLConnector` | 0.14.0 |
|
|
79
|
+
| Azure SQL Database | `AzureSQLConnector` | 0.14.0 |
|
|
80
|
+
| Azure Synapse Analytics | `SynapseConnector` | 0.14.0 |
|
|
78
81
|
|
|
79
82
|
## CLI
|
|
80
83
|
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { BaseConnector } from './base-connector.js';
|
|
2
|
+
import type { ConnectorConfig, TableSchema, SecurityConfig } from '../types/connector.js';
|
|
3
|
+
import { type QueryResultRow } from '../types/driver-results.js';
|
|
4
|
+
import type { SourceCredentials } from '../types.js';
|
|
5
|
+
export declare class AzureSQLConnector extends BaseConnector {
|
|
6
|
+
private pool;
|
|
7
|
+
private connected;
|
|
8
|
+
constructor(config: ConnectorConfig, securityConfig?: Partial<SecurityConfig>);
|
|
9
|
+
private connect;
|
|
10
|
+
protected executeQuery(sql: string): Promise<QueryResultRow[]>;
|
|
11
|
+
protected executeParameterizedQuery(sql: string, parameters?: unknown[]): Promise<QueryResultRow[]>;
|
|
12
|
+
testConnection(debugConfig?: import('../types.js').DebugConfig): Promise<boolean>;
|
|
13
|
+
private mergeDebugConfig;
|
|
14
|
+
private generateConnectionSuggestion;
|
|
15
|
+
listTables(): Promise<string[]>;
|
|
16
|
+
getTableSchema(table: string): Promise<TableSchema>;
|
|
17
|
+
getLastModified(table: string): Promise<Date | null>;
|
|
18
|
+
close(): Promise<void>;
|
|
19
|
+
private mapMSSQLType;
|
|
20
|
+
protected escapeIdentifier(identifier: string): string;
|
|
21
|
+
connectLegacy(credentials: SourceCredentials): Promise<void>;
|
|
22
|
+
testConnectionLegacy(): Promise<{
|
|
23
|
+
success: boolean;
|
|
24
|
+
tableCount?: number;
|
|
25
|
+
error?: string;
|
|
26
|
+
}>;
|
|
27
|
+
getTableMetadata(tableName: string, timestampColumn?: string): Promise<{
|
|
28
|
+
rowCount: number;
|
|
29
|
+
lastUpdate?: Date;
|
|
30
|
+
}>;
|
|
31
|
+
query<T = unknown>(_sql: string): Promise<T[]>;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=azure-sql.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"azure-sql.d.ts","sourceRoot":"","sources":["../../src/connectors/azure-sql.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC1F,OAAO,EAAE,KAAK,cAAc,EAAa,MAAM,4BAA4B,CAAC;AAC5E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAoBrD,qBAAa,iBAAkB,SAAQ,aAAa;IAClD,OAAO,CAAC,IAAI,CAAqC;IACjD,OAAO,CAAC,SAAS,CAAS;gBAEd,MAAM,EAAE,eAAe,EAAE,cAAc,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC;YAS/D,OAAO;cA4CL,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;cAOpD,yBAAyB,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,GAAE,OAAO,EAAO,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAuDvG,cAAc,CAAC,WAAW,CAAC,EAAE,OAAO,aAAa,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC;IAmEvF,OAAO,CAAC,gBAAgB;IAYxB,OAAO,CAAC,4BAA4B;IAyC9B,UAAU,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IA8B/B,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAkDnD,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;IAyCpD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAiB5B,OAAO,CAAC,YAAY;IAsDpB,SAAS,CAAC,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;IAuBhD,aAAa,CAAC,WAAW,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAuB5D,oBAAoB,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IA+B1F,gBAAgB,CACpB,SAAS,EAAE,MAAM,EACjB,eAAe,SAAe,GAC7B,OAAO,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,IAAI,CAAA;KAAE,CAAC;IA0B7C,KAAK,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC;CAKrD"}
|
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
import * as mssql from 'mssql';
|
|
2
|
+
import { BaseConnector } from './base-connector.js';
|
|
3
|
+
import { rowString } from '../types/driver-results.js';
|
|
4
|
+
import { ConnectionError, TimeoutError, QueryError, ErrorHandler } from '../errors/index.js';
|
|
5
|
+
import { validateConnectorConfig } from '../validators/index.js';
|
|
6
|
+
export class AzureSQLConnector extends BaseConnector {
|
|
7
|
+
pool = null;
|
|
8
|
+
connected = false;
|
|
9
|
+
constructor(config, securityConfig) {
|
|
10
|
+
validateConnectorConfig(config);
|
|
11
|
+
super(config, securityConfig);
|
|
12
|
+
}
|
|
13
|
+
async connect() {
|
|
14
|
+
if (this.connected && this.pool) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
try {
|
|
18
|
+
const poolConfig = {
|
|
19
|
+
server: this.config.host,
|
|
20
|
+
port: this.config.port ?? 1433,
|
|
21
|
+
database: this.config.database,
|
|
22
|
+
user: this.config.username,
|
|
23
|
+
password: this.config.password,
|
|
24
|
+
options: {
|
|
25
|
+
encrypt: true,
|
|
26
|
+
trustServerCertificate: false,
|
|
27
|
+
connectTimeout: this.connectionTimeout,
|
|
28
|
+
requestTimeout: this.queryTimeout,
|
|
29
|
+
appName: this.config.applicationName ?? 'freshguard-core'
|
|
30
|
+
},
|
|
31
|
+
pool: {
|
|
32
|
+
max: 1,
|
|
33
|
+
min: 0,
|
|
34
|
+
idleTimeoutMillis: 30000
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
this.pool = new mssql.ConnectionPool(poolConfig);
|
|
38
|
+
await this.pool.connect();
|
|
39
|
+
this.connected = true;
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
throw new ConnectionError('Failed to connect to Azure SQL Database', this.config.host, this.config.port, error instanceof Error ? error : undefined);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
async executeQuery(sql) {
|
|
46
|
+
return this.executeParameterizedQuery(sql, []);
|
|
47
|
+
}
|
|
48
|
+
async executeParameterizedQuery(sql, parameters = []) {
|
|
49
|
+
await this.connect();
|
|
50
|
+
if (!this.pool) {
|
|
51
|
+
throw new ConnectionError('Database connection not available');
|
|
52
|
+
}
|
|
53
|
+
try {
|
|
54
|
+
const result = await this.executeWithTimeout(async () => {
|
|
55
|
+
if (!this.pool)
|
|
56
|
+
throw new ConnectionError('Database connection not available');
|
|
57
|
+
const request = this.pool.request();
|
|
58
|
+
for (let i = 0; i < parameters.length; i++) {
|
|
59
|
+
request.input(`p${i + 1}`, parameters[i]);
|
|
60
|
+
}
|
|
61
|
+
let mssqlSql = sql;
|
|
62
|
+
for (let i = parameters.length; i >= 1; i--) {
|
|
63
|
+
mssqlSql = mssqlSql.replace(new RegExp(`\\$${i}`, 'g'), `@p${i}`);
|
|
64
|
+
}
|
|
65
|
+
let paramIndex = 0;
|
|
66
|
+
mssqlSql = mssqlSql.replace(/\?/g, () => `@p${++paramIndex}`);
|
|
67
|
+
const res = await request.query(mssqlSql);
|
|
68
|
+
return (res.recordset ?? []);
|
|
69
|
+
}, this.queryTimeout);
|
|
70
|
+
this.validateResultSize(result);
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
if (error instanceof TimeoutError) {
|
|
75
|
+
throw error;
|
|
76
|
+
}
|
|
77
|
+
throw new QueryError(ErrorHandler.getUserMessage(error), 'query_execution', undefined, error instanceof Error ? error : undefined);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
async testConnection(debugConfig) {
|
|
81
|
+
const mergedDebugConfig = this.mergeDebugConfig(debugConfig);
|
|
82
|
+
const debugId = `azuresql-test-${Date.now().toString(36)}-${Math.random().toString(36).substr(2, 5)}`;
|
|
83
|
+
const startTime = performance.now();
|
|
84
|
+
try {
|
|
85
|
+
this.logDebugInfo(mergedDebugConfig, debugId, 'Starting connection test', {
|
|
86
|
+
host: this.config.host,
|
|
87
|
+
port: this.config.port,
|
|
88
|
+
database: this.config.database,
|
|
89
|
+
ssl: this.config.ssl
|
|
90
|
+
});
|
|
91
|
+
await this.connect();
|
|
92
|
+
if (!this.pool) {
|
|
93
|
+
this.logDebugError(mergedDebugConfig, debugId, 'Connection test', {
|
|
94
|
+
error: 'Connection not available after connect',
|
|
95
|
+
duration: performance.now() - startTime
|
|
96
|
+
});
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
const sql = 'SELECT 1 AS test';
|
|
100
|
+
await this.executeWithTimeout(async () => {
|
|
101
|
+
if (!this.pool)
|
|
102
|
+
throw new ConnectionError('Database connection not available');
|
|
103
|
+
const request = this.pool.request();
|
|
104
|
+
return request.query(sql);
|
|
105
|
+
}, this.connectionTimeout);
|
|
106
|
+
const duration = performance.now() - startTime;
|
|
107
|
+
if (mergedDebugConfig?.enabled) {
|
|
108
|
+
console.log(`[DEBUG-${debugId}] Connection test completed:`, {
|
|
109
|
+
success: true,
|
|
110
|
+
duration,
|
|
111
|
+
host: this.config.host,
|
|
112
|
+
database: this.config.database
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
const duration = performance.now() - startTime;
|
|
119
|
+
this.logDebugError(mergedDebugConfig, debugId, 'Connection test', {
|
|
120
|
+
host: this.config.host,
|
|
121
|
+
port: this.config.port,
|
|
122
|
+
database: this.config.database,
|
|
123
|
+
error: mergedDebugConfig?.exposeRawErrors && error instanceof Error ? error.message : 'Connection failed',
|
|
124
|
+
duration,
|
|
125
|
+
suggestion: this.generateConnectionSuggestion(error)
|
|
126
|
+
});
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
mergeDebugConfig(debugConfig) {
|
|
131
|
+
return {
|
|
132
|
+
enabled: debugConfig?.enabled ?? (process.env.NODE_ENV === 'development'),
|
|
133
|
+
exposeQueries: debugConfig?.exposeQueries ?? true,
|
|
134
|
+
exposeRawErrors: debugConfig?.exposeRawErrors ?? true,
|
|
135
|
+
logLevel: debugConfig?.logLevel ?? 'debug'
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
generateConnectionSuggestion(error) {
|
|
139
|
+
if (!(error instanceof Error)) {
|
|
140
|
+
return 'Check database connection configuration';
|
|
141
|
+
}
|
|
142
|
+
const message = error.message.toLowerCase();
|
|
143
|
+
if (message.includes('connect econnrefused') || message.includes('connection refused')) {
|
|
144
|
+
return `Azure SQL Database at ${this.config.host}:${this.config.port} is not accepting connections. Verify the server name and check Azure SQL firewall rules.`;
|
|
145
|
+
}
|
|
146
|
+
if (message.includes('timeout') || message.includes('connect timeout')) {
|
|
147
|
+
return `Connection timeout to ${this.config.host}:${this.config.port}. Check Azure SQL firewall rules, network connectivity, and ensure your IP is allowed.`;
|
|
148
|
+
}
|
|
149
|
+
if (message.includes('login failed') || message.includes('authentication failed')) {
|
|
150
|
+
return `Authentication failed for database '${this.config.database}'. Verify username, password, and Azure AD configuration if using AAD auth.`;
|
|
151
|
+
}
|
|
152
|
+
if (message.includes('cannot open database') || (message.includes('database') && message.includes('not exist'))) {
|
|
153
|
+
return `Database '${this.config.database}' not found. Check database name on your Azure SQL server.`;
|
|
154
|
+
}
|
|
155
|
+
if (message.includes('ssl') || message.includes('tls') || message.includes('encrypt')) {
|
|
156
|
+
return `SSL/TLS connection issue. Azure SQL requires encryption - check SSL certificate configuration.`;
|
|
157
|
+
}
|
|
158
|
+
if (message.includes('firewall')) {
|
|
159
|
+
return `Connection blocked by Azure SQL firewall. Add your client IP address to the server's firewall rules in the Azure portal.`;
|
|
160
|
+
}
|
|
161
|
+
if (message.includes('azure active directory') || message.includes('aad')) {
|
|
162
|
+
return `Azure AD authentication issue. Verify Azure AD admin is configured and the user has proper permissions.`;
|
|
163
|
+
}
|
|
164
|
+
return `Connection failed to ${this.config.host}:${this.config.port}. Check host, port, credentials, firewall rules, and network connectivity.`;
|
|
165
|
+
}
|
|
166
|
+
async listTables() {
|
|
167
|
+
const sql = `
|
|
168
|
+
SELECT TABLE_NAME as table_name
|
|
169
|
+
FROM INFORMATION_SCHEMA.TABLES
|
|
170
|
+
WHERE TABLE_TYPE = 'BASE TABLE'
|
|
171
|
+
AND TABLE_SCHEMA = 'dbo'
|
|
172
|
+
ORDER BY TABLE_NAME
|
|
173
|
+
`;
|
|
174
|
+
await this.validateQuery(sql);
|
|
175
|
+
try {
|
|
176
|
+
const result = await this.executeQuery(sql);
|
|
177
|
+
return result
|
|
178
|
+
.slice(0, this.maxRows)
|
|
179
|
+
.map((row) => rowString(row.table_name ?? row.TABLE_NAME ?? row.tablename))
|
|
180
|
+
.filter(Boolean);
|
|
181
|
+
}
|
|
182
|
+
catch (error) {
|
|
183
|
+
throw new QueryError('Failed to list tables', 'table_listing', undefined, error instanceof Error ? error : undefined);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
async getTableSchema(table) {
|
|
187
|
+
this.escapeIdentifier(table);
|
|
188
|
+
const sql = `
|
|
189
|
+
SELECT
|
|
190
|
+
COLUMN_NAME as column_name,
|
|
191
|
+
DATA_TYPE as data_type,
|
|
192
|
+
IS_NULLABLE as is_nullable
|
|
193
|
+
FROM INFORMATION_SCHEMA.COLUMNS
|
|
194
|
+
WHERE TABLE_SCHEMA = 'dbo'
|
|
195
|
+
AND TABLE_NAME = '${table}'
|
|
196
|
+
ORDER BY ORDINAL_POSITION
|
|
197
|
+
`;
|
|
198
|
+
await this.validateQuery(sql);
|
|
199
|
+
try {
|
|
200
|
+
const result = await this.executeQuery(sql);
|
|
201
|
+
const limited = result.slice(0, this.maxRows);
|
|
202
|
+
if (limited.length === 0) {
|
|
203
|
+
throw QueryError.tableNotFound(table);
|
|
204
|
+
}
|
|
205
|
+
return {
|
|
206
|
+
table,
|
|
207
|
+
columns: limited.map(row => ({
|
|
208
|
+
name: rowString(row.column_name ?? row.COLUMN_NAME),
|
|
209
|
+
type: this.mapMSSQLType(rowString(row.data_type ?? row.DATA_TYPE)),
|
|
210
|
+
nullable: (row.is_nullable ?? row.IS_NULLABLE) === 'YES'
|
|
211
|
+
}))
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
catch (error) {
|
|
215
|
+
if (error instanceof QueryError) {
|
|
216
|
+
throw error;
|
|
217
|
+
}
|
|
218
|
+
throw new QueryError('Failed to get table schema', 'schema_query', table, error instanceof Error ? error : undefined);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
async getLastModified(table) {
|
|
222
|
+
const timestampColumns = ['updated_at', 'modified_at', 'last_modified', 'timestamp'];
|
|
223
|
+
for (const column of timestampColumns) {
|
|
224
|
+
try {
|
|
225
|
+
const result = await this.getMaxTimestamp(table, column);
|
|
226
|
+
if (result) {
|
|
227
|
+
return result;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
catch {
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
try {
|
|
235
|
+
const sql = `
|
|
236
|
+
SELECT MAX(last_user_update) as last_modified
|
|
237
|
+
FROM sys.dm_db_index_usage_stats
|
|
238
|
+
WHERE database_id = DB_ID()
|
|
239
|
+
AND object_id = OBJECT_ID('dbo.${this.escapeIdentifier(table).replace(/\[|\]/g, '')}')
|
|
240
|
+
`;
|
|
241
|
+
await this.validateQuery(sql);
|
|
242
|
+
const result = await this.executeQuery(sql);
|
|
243
|
+
if (result.length > 0 && result[0]?.last_modified) {
|
|
244
|
+
return new Date(rowString(result[0].last_modified));
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
catch {
|
|
248
|
+
}
|
|
249
|
+
return null;
|
|
250
|
+
}
|
|
251
|
+
async close() {
|
|
252
|
+
if (this.pool) {
|
|
253
|
+
try {
|
|
254
|
+
await this.pool.close();
|
|
255
|
+
}
|
|
256
|
+
catch (error) {
|
|
257
|
+
console.warn('Warning: Error closing Azure SQL connection:', ErrorHandler.getUserMessage(error));
|
|
258
|
+
}
|
|
259
|
+
finally {
|
|
260
|
+
this.pool = null;
|
|
261
|
+
this.connected = false;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
mapMSSQLType(mssqlType) {
|
|
266
|
+
const typeMap = {
|
|
267
|
+
'tinyint': 'integer',
|
|
268
|
+
'smallint': 'integer',
|
|
269
|
+
'int': 'integer',
|
|
270
|
+
'integer': 'integer',
|
|
271
|
+
'bigint': 'bigint',
|
|
272
|
+
'decimal': 'decimal',
|
|
273
|
+
'numeric': 'decimal',
|
|
274
|
+
'money': 'decimal',
|
|
275
|
+
'smallmoney': 'decimal',
|
|
276
|
+
'float': 'float',
|
|
277
|
+
'real': 'float',
|
|
278
|
+
'bit': 'boolean',
|
|
279
|
+
'char': 'text',
|
|
280
|
+
'varchar': 'text',
|
|
281
|
+
'text': 'text',
|
|
282
|
+
'nchar': 'text',
|
|
283
|
+
'nvarchar': 'text',
|
|
284
|
+
'ntext': 'text',
|
|
285
|
+
'date': 'date',
|
|
286
|
+
'time': 'time',
|
|
287
|
+
'datetime': 'timestamp',
|
|
288
|
+
'datetime2': 'timestamp',
|
|
289
|
+
'smalldatetime': 'timestamp',
|
|
290
|
+
'datetimeoffset': 'timestamptz',
|
|
291
|
+
'binary': 'text',
|
|
292
|
+
'varbinary': 'text',
|
|
293
|
+
'image': 'text',
|
|
294
|
+
'uniqueidentifier': 'text',
|
|
295
|
+
'xml': 'text',
|
|
296
|
+
'sql_variant': 'text',
|
|
297
|
+
'hierarchyid': 'text',
|
|
298
|
+
'geometry': 'text',
|
|
299
|
+
'geography': 'text',
|
|
300
|
+
'timestamp': 'text',
|
|
301
|
+
'rowversion': 'text'
|
|
302
|
+
};
|
|
303
|
+
return typeMap[mssqlType.toLowerCase()] ?? 'unknown';
|
|
304
|
+
}
|
|
305
|
+
escapeIdentifier(identifier) {
|
|
306
|
+
if (!/^[a-zA-Z0-9_.]+$/.test(identifier)) {
|
|
307
|
+
throw new Error(`Invalid identifier: ${identifier}`);
|
|
308
|
+
}
|
|
309
|
+
if (identifier.length > 256) {
|
|
310
|
+
throw new Error('Identifier too long');
|
|
311
|
+
}
|
|
312
|
+
return `[${identifier}]`;
|
|
313
|
+
}
|
|
314
|
+
async connectLegacy(credentials) {
|
|
315
|
+
console.warn('Warning: connectLegacy is deprecated. Use constructor with ConnectorConfig instead.');
|
|
316
|
+
const config = {
|
|
317
|
+
host: credentials.host ?? '',
|
|
318
|
+
port: credentials.port ?? 1433,
|
|
319
|
+
database: credentials.database ?? '',
|
|
320
|
+
username: credentials.username ?? '',
|
|
321
|
+
password: credentials.password ?? '',
|
|
322
|
+
ssl: credentials.sslMode !== 'disable'
|
|
323
|
+
};
|
|
324
|
+
validateConnectorConfig(config);
|
|
325
|
+
this.config = { ...this.config, ...config };
|
|
326
|
+
await this.connect();
|
|
327
|
+
}
|
|
328
|
+
async testConnectionLegacy() {
|
|
329
|
+
console.warn('Warning: testConnectionLegacy is deprecated. Use testConnection() instead.');
|
|
330
|
+
try {
|
|
331
|
+
const success = await this.testConnection();
|
|
332
|
+
if (success) {
|
|
333
|
+
const tables = await this.listTables();
|
|
334
|
+
return {
|
|
335
|
+
success: true,
|
|
336
|
+
tableCount: tables.length
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
return {
|
|
341
|
+
success: false,
|
|
342
|
+
error: 'Connection test failed'
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
catch (error) {
|
|
347
|
+
return {
|
|
348
|
+
success: false,
|
|
349
|
+
error: ErrorHandler.getUserMessage(error)
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
async getTableMetadata(tableName, timestampColumn = 'updated_at') {
|
|
354
|
+
console.warn('Warning: getTableMetadata is deprecated. Use getRowCount() and getMaxTimestamp() instead.');
|
|
355
|
+
try {
|
|
356
|
+
const rowCount = await this.getRowCount(tableName);
|
|
357
|
+
const lastUpdate = await this.getMaxTimestamp(tableName, timestampColumn);
|
|
358
|
+
return {
|
|
359
|
+
rowCount,
|
|
360
|
+
lastUpdate: lastUpdate ?? undefined
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
catch (error) {
|
|
364
|
+
throw new QueryError('Failed to get table metadata', 'metadata_query', tableName, error instanceof Error ? error : undefined);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
async query(_sql) {
|
|
368
|
+
throw new Error('Direct SQL queries are not allowed for security reasons. Use specific methods like getRowCount(), getMaxTimestamp(), etc.');
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
//# sourceMappingURL=azure-sql.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"azure-sql.js","sourceRoot":"","sources":["../../src/connectors/azure-sql.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAA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AA2F,CAAC,CAAC;QAE1G,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;YACnD,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;YAE1E,OAAO;gBACL,QAAQ;gBACR,UAAU,EAAE,UAAU,IAAI,SAAS;aACpC,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,UAAU,CAClB,8BAA8B,EAC9B,gBAAgB,EAChB,SAAS,EACT,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAC3C,CAAC;QACJ,CAAC;IACH,CAAC;IAOD,KAAK,CAAC,KAAK,CAAc,IAAY;QACnC,MAAM,IAAI,KAAK,CACb,2HAA2H,CAC5H,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -4,4 +4,7 @@ export { BigQueryConnector } from './bigquery.js';
|
|
|
4
4
|
export { SnowflakeConnector } from './snowflake.js';
|
|
5
5
|
export { MySQLConnector } from './mysql.js';
|
|
6
6
|
export { RedshiftConnector } from './redshift.js';
|
|
7
|
+
export { MSSQLConnector } from './mssql.js';
|
|
8
|
+
export { AzureSQLConnector } from './azure-sql.js';
|
|
9
|
+
export { SynapseConnector } from './synapse.js';
|
|
7
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/connectors/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/connectors/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/connectors/index.js
CHANGED
|
@@ -4,4 +4,7 @@ export { BigQueryConnector } from './bigquery.js';
|
|
|
4
4
|
export { SnowflakeConnector } from './snowflake.js';
|
|
5
5
|
export { MySQLConnector } from './mysql.js';
|
|
6
6
|
export { RedshiftConnector } from './redshift.js';
|
|
7
|
+
export { MSSQLConnector } from './mssql.js';
|
|
8
|
+
export { AzureSQLConnector } from './azure-sql.js';
|
|
9
|
+
export { SynapseConnector } from './synapse.js';
|
|
7
10
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/connectors/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/connectors/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { BaseConnector } from './base-connector.js';
|
|
2
|
+
import type { ConnectorConfig, TableSchema, SecurityConfig } from '../types/connector.js';
|
|
3
|
+
import { type QueryResultRow } from '../types/driver-results.js';
|
|
4
|
+
import type { SourceCredentials } from '../types.js';
|
|
5
|
+
export declare class MSSQLConnector extends BaseConnector {
|
|
6
|
+
private pool;
|
|
7
|
+
private connected;
|
|
8
|
+
constructor(config: ConnectorConfig, securityConfig?: Partial<SecurityConfig>);
|
|
9
|
+
private connect;
|
|
10
|
+
protected executeQuery(sql: string): Promise<QueryResultRow[]>;
|
|
11
|
+
protected executeParameterizedQuery(sql: string, parameters?: unknown[]): Promise<QueryResultRow[]>;
|
|
12
|
+
testConnection(debugConfig?: import('../types.js').DebugConfig): Promise<boolean>;
|
|
13
|
+
private mergeDebugConfig;
|
|
14
|
+
private generateConnectionSuggestion;
|
|
15
|
+
listTables(): Promise<string[]>;
|
|
16
|
+
getTableSchema(table: string): Promise<TableSchema>;
|
|
17
|
+
getLastModified(table: string): Promise<Date | null>;
|
|
18
|
+
close(): Promise<void>;
|
|
19
|
+
private mapMSSQLType;
|
|
20
|
+
protected escapeIdentifier(identifier: string): string;
|
|
21
|
+
connectLegacy(credentials: SourceCredentials): Promise<void>;
|
|
22
|
+
testConnectionLegacy(): Promise<{
|
|
23
|
+
success: boolean;
|
|
24
|
+
tableCount?: number;
|
|
25
|
+
error?: string;
|
|
26
|
+
}>;
|
|
27
|
+
getTableMetadata(tableName: string, timestampColumn?: string): Promise<{
|
|
28
|
+
rowCount: number;
|
|
29
|
+
lastUpdate?: Date;
|
|
30
|
+
}>;
|
|
31
|
+
query<T = unknown>(_sql: string): Promise<T[]>;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=mssql.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mssql.d.ts","sourceRoot":"","sources":["../../src/connectors/mssql.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC1F,OAAO,EAAE,KAAK,cAAc,EAAa,MAAM,4BAA4B,CAAC;AAC5E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAoBrD,qBAAa,cAAe,SAAQ,aAAa;IAC/C,OAAO,CAAC,IAAI,CAAqC;IACjD,OAAO,CAAC,SAAS,CAAS;gBAEd,MAAM,EAAE,eAAe,EAAE,cAAc,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC;YAS/D,OAAO;cA2CL,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;cAOpD,yBAAyB,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,GAAE,OAAO,EAAO,GAAG,OAAO,CAAC,cAAc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