@memberjunction/sqlserver-dataprovider 2.50.0 → 2.52.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 +223 -19
- package/dist/SQLServerDataProvider.d.ts +93 -114
- package/dist/SQLServerDataProvider.d.ts.map +1 -1
- package/dist/SQLServerDataProvider.js +413 -444
- package/dist/SQLServerDataProvider.js.map +1 -1
- package/dist/SqlLogger.d.ts +61 -0
- package/dist/SqlLogger.d.ts.map +1 -0
- package/dist/SqlLogger.js +282 -0
- package/dist/SqlLogger.js.map +1 -0
- package/dist/config.d.ts +2 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +119 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +37 -0
- package/dist/types.js.map +1 -0
- package/package.json +10 -9
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview SQL Logging Implementation for SQL Server Data Provider
|
|
4
|
+
*
|
|
5
|
+
* This module provides SQL statement logging functionality with file I/O,
|
|
6
|
+
* filtering, formatting, and session management capabilities.
|
|
7
|
+
*
|
|
8
|
+
* @module @memberjunction/sqlserver-dataprovider/SqlLogger
|
|
9
|
+
*/
|
|
10
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
13
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
14
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
15
|
+
}
|
|
16
|
+
Object.defineProperty(o, k2, desc);
|
|
17
|
+
}) : (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
o[k2] = m[k];
|
|
20
|
+
}));
|
|
21
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
22
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
23
|
+
}) : function(o, v) {
|
|
24
|
+
o["default"] = v;
|
|
25
|
+
});
|
|
26
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
27
|
+
if (mod && mod.__esModule) return mod;
|
|
28
|
+
var result = {};
|
|
29
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
30
|
+
__setModuleDefault(result, mod);
|
|
31
|
+
return result;
|
|
32
|
+
};
|
|
33
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
+
exports.SqlLoggingSessionImpl = void 0;
|
|
35
|
+
const fs = __importStar(require("fs"));
|
|
36
|
+
const path = __importStar(require("path"));
|
|
37
|
+
const sql_formatter_1 = require("sql-formatter");
|
|
38
|
+
/**
|
|
39
|
+
* Internal implementation of SqlLoggingSession that handles SQL statement logging to files.
|
|
40
|
+
* This class manages file I/O, SQL formatting, and filtering based on session options.
|
|
41
|
+
*
|
|
42
|
+
* @internal
|
|
43
|
+
*/
|
|
44
|
+
class SqlLoggingSessionImpl {
|
|
45
|
+
constructor(id, filePath, options = {}) {
|
|
46
|
+
this._statementCount = 0;
|
|
47
|
+
this._emittedStatementCount = 0; // Track actually emitted statements
|
|
48
|
+
this._fileHandle = null;
|
|
49
|
+
this._disposed = false;
|
|
50
|
+
this.id = id;
|
|
51
|
+
this.filePath = filePath;
|
|
52
|
+
this.startTime = new Date();
|
|
53
|
+
this.options = options;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Gets the count of SQL statements actually written to the log file
|
|
57
|
+
* @returns The number of emitted statements (after filtering)
|
|
58
|
+
*/
|
|
59
|
+
get statementCount() {
|
|
60
|
+
return this._emittedStatementCount; // Return actually emitted statements
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Initializes the logging session by creating the log file and writing the header
|
|
64
|
+
* @throws Error if file creation fails
|
|
65
|
+
*/
|
|
66
|
+
async initialize() {
|
|
67
|
+
// Ensure directory exists
|
|
68
|
+
const dir = path.dirname(this.filePath);
|
|
69
|
+
await fs.promises.mkdir(dir, { recursive: true });
|
|
70
|
+
// Open file for writing
|
|
71
|
+
this._fileHandle = await fs.promises.open(this.filePath, 'w');
|
|
72
|
+
// Write header comment
|
|
73
|
+
const header = this._generateHeader();
|
|
74
|
+
await this._fileHandle.writeFile(header);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Logs a SQL statement to the file, applying filtering and formatting based on session options
|
|
78
|
+
*
|
|
79
|
+
* @param query - The SQL query to log
|
|
80
|
+
* @param parameters - Optional parameters for the query
|
|
81
|
+
* @param description - Optional description for this operation
|
|
82
|
+
* @param isMutation - Whether this is a data mutation operation
|
|
83
|
+
* @param simpleSQLFallback - Optional simple SQL to use if logRecordChangeMetadata=false
|
|
84
|
+
*/
|
|
85
|
+
async logSqlStatement(query, parameters, description, isMutation = false, simpleSQLFallback) {
|
|
86
|
+
const verbose = this.options.verboseOutput === true;
|
|
87
|
+
if (verbose) {
|
|
88
|
+
console.log(`=== SESSION ${this.id} LOG ATTEMPT ===`);
|
|
89
|
+
console.log(`Session disposed: ${this._disposed}, File handle exists: ${!!this._fileHandle}`);
|
|
90
|
+
console.log(`Query (first 100 chars): ${query.substring(0, 100)}...`);
|
|
91
|
+
console.log(`isMutation: ${isMutation}, description: ${description || 'none'}`);
|
|
92
|
+
console.log(`Options:`, this.options);
|
|
93
|
+
}
|
|
94
|
+
if (this._disposed || !this._fileHandle) {
|
|
95
|
+
if (verbose) {
|
|
96
|
+
console.log(`Session ${this.id}: Skipping - disposed or no file handle`);
|
|
97
|
+
}
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
// Filter statements based on statementTypes option
|
|
101
|
+
const statementTypes = this.options.statementTypes || 'both';
|
|
102
|
+
if (verbose) {
|
|
103
|
+
console.log(`Session ${this.id}: Statement filter check - statementTypes: ${statementTypes}, isMutation: ${isMutation}`);
|
|
104
|
+
}
|
|
105
|
+
if (statementTypes === 'mutations' && !isMutation) {
|
|
106
|
+
if (verbose) {
|
|
107
|
+
console.log(`Session ${this.id}: Skipping - mutations only but this is not a mutation`);
|
|
108
|
+
}
|
|
109
|
+
return; // Skip logging non-mutation statements
|
|
110
|
+
}
|
|
111
|
+
if (statementTypes === 'queries' && isMutation) {
|
|
112
|
+
if (verbose) {
|
|
113
|
+
console.log(`Session ${this.id}: Skipping - queries only but this is a mutation`);
|
|
114
|
+
}
|
|
115
|
+
return; // Skip logging mutation statements
|
|
116
|
+
}
|
|
117
|
+
if (verbose) {
|
|
118
|
+
console.log(`Session ${this.id}: Statement passed filters, proceeding to log`);
|
|
119
|
+
}
|
|
120
|
+
let logEntry = '';
|
|
121
|
+
// Add description comment if provided
|
|
122
|
+
if (description) {
|
|
123
|
+
logEntry += `-- ${description}\n`;
|
|
124
|
+
}
|
|
125
|
+
// Process the SQL statement
|
|
126
|
+
let processedQuery = query;
|
|
127
|
+
// Use simple SQL fallback if this session has logRecordChangeMetadata=false (default) and fallback is provided
|
|
128
|
+
if (this.options.logRecordChangeMetadata !== true && simpleSQLFallback) {
|
|
129
|
+
processedQuery = simpleSQLFallback;
|
|
130
|
+
// Update description to indicate we're using the simplified version
|
|
131
|
+
if (description && !description.includes('(core SP call only)')) {
|
|
132
|
+
logEntry = logEntry.replace(`-- ${description}\n`, `-- ${description} (core SP call only)\n`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
// Replace schema names with Flyway placeholders if migration format
|
|
136
|
+
if (this.options.formatAsMigration) {
|
|
137
|
+
processedQuery = processedQuery.replace(/\[(\w+)\]\./g, '[${flyway:defaultSchema}].');
|
|
138
|
+
}
|
|
139
|
+
// Apply pretty printing if enabled
|
|
140
|
+
if (this.options.prettyPrint) {
|
|
141
|
+
processedQuery = this._prettyPrintSql(processedQuery);
|
|
142
|
+
}
|
|
143
|
+
// Add the SQL statement
|
|
144
|
+
logEntry += `${processedQuery};\n`;
|
|
145
|
+
// Add parameter comment if parameters exist
|
|
146
|
+
if (parameters) {
|
|
147
|
+
if (Array.isArray(parameters)) {
|
|
148
|
+
if (parameters.length > 0) {
|
|
149
|
+
logEntry += `-- Parameters: ${parameters.map((p, i) => `@p${i}='${p}'`).join(', ')}\n`;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
else if (typeof parameters === 'object') {
|
|
153
|
+
const paramStr = Object.entries(parameters)
|
|
154
|
+
.map(([key, value]) => `@${key}='${value}'`)
|
|
155
|
+
.join(', ');
|
|
156
|
+
if (paramStr) {
|
|
157
|
+
logEntry += `-- Parameters: ${paramStr}\n`;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
// Add batch separator if specified
|
|
162
|
+
if (this.options.batchSeparator) {
|
|
163
|
+
logEntry += `\n${this.options.batchSeparator}\n`;
|
|
164
|
+
}
|
|
165
|
+
logEntry += '\n'; // Add blank line between statements
|
|
166
|
+
if (verbose) {
|
|
167
|
+
console.log(`Session ${this.id}: About to write log entry (${logEntry.length} chars)`);
|
|
168
|
+
console.log(`Session ${this.id}: Log entry preview: ${logEntry.substring(0, 200)}...`);
|
|
169
|
+
}
|
|
170
|
+
try {
|
|
171
|
+
await this._fileHandle.writeFile(logEntry);
|
|
172
|
+
this._statementCount++;
|
|
173
|
+
this._emittedStatementCount++; // Track actually emitted statements
|
|
174
|
+
if (verbose) {
|
|
175
|
+
console.log(`Session ${this.id}: Successfully wrote to file. New counts - total: ${this._statementCount}, emitted: ${this._emittedStatementCount}`);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
catch (error) {
|
|
179
|
+
console.error(`Session ${this.id}: Error writing to file:`, error);
|
|
180
|
+
throw error;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Disposes of the logging session, writes the footer, closes the file, and optionally deletes empty files
|
|
185
|
+
*/
|
|
186
|
+
async dispose() {
|
|
187
|
+
if (this._disposed) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
this._disposed = true;
|
|
191
|
+
if (this._fileHandle) {
|
|
192
|
+
// Write footer comment
|
|
193
|
+
const footer = this._generateFooter();
|
|
194
|
+
await this._fileHandle.writeFile(footer);
|
|
195
|
+
await this._fileHandle.close();
|
|
196
|
+
this._fileHandle = null;
|
|
197
|
+
// Check if we should delete empty log files
|
|
198
|
+
if (this._emittedStatementCount === 0 && !this.options.retainEmptyLogFiles) {
|
|
199
|
+
try {
|
|
200
|
+
await fs.promises.unlink(this.filePath);
|
|
201
|
+
// Log that we deleted the empty file (optional)
|
|
202
|
+
console.log(`Deleted empty SQL log file: ${this.filePath}`);
|
|
203
|
+
}
|
|
204
|
+
catch (error) {
|
|
205
|
+
// Ignore errors during deletion (file might already be deleted, etc.)
|
|
206
|
+
console.error(`Failed to delete empty SQL log file: ${this.filePath}`, error);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
_generateHeader() {
|
|
212
|
+
let header = `-- SQL Logging Session\n`;
|
|
213
|
+
header += `-- Session ID: ${this.id}\n`;
|
|
214
|
+
header += `-- Started: ${this.startTime.toISOString()}\n`;
|
|
215
|
+
if (this.options.description) {
|
|
216
|
+
header += `-- Description: ${this.options.description}\n`;
|
|
217
|
+
}
|
|
218
|
+
if (this.options.formatAsMigration) {
|
|
219
|
+
header += `-- Format: Migration-ready with Flyway schema placeholders\n`;
|
|
220
|
+
}
|
|
221
|
+
header += `-- Generated by MemberJunction SQLServerDataProvider\n`;
|
|
222
|
+
header += `\n`;
|
|
223
|
+
return header;
|
|
224
|
+
}
|
|
225
|
+
_generateFooter() {
|
|
226
|
+
const endTime = new Date();
|
|
227
|
+
const duration = endTime.getTime() - this.startTime.getTime();
|
|
228
|
+
let footer = `\n-- End of SQL Logging Session\n`;
|
|
229
|
+
footer += `-- Session ID: ${this.id}\n`;
|
|
230
|
+
footer += `-- Completed: ${endTime.toISOString()}\n`;
|
|
231
|
+
footer += `-- Duration: ${duration}ms\n`;
|
|
232
|
+
footer += `-- Total Statements: ${this._emittedStatementCount}\n`;
|
|
233
|
+
return footer;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Format SQL using sql-formatter library with SQL Server dialect
|
|
237
|
+
*/
|
|
238
|
+
_prettyPrintSql(sql) {
|
|
239
|
+
if (!sql)
|
|
240
|
+
return sql;
|
|
241
|
+
try {
|
|
242
|
+
let formatted = (0, sql_formatter_1.format)(sql, {
|
|
243
|
+
language: 'tsql', // SQL Server Transact-SQL dialect
|
|
244
|
+
tabWidth: 2,
|
|
245
|
+
keywordCase: 'upper',
|
|
246
|
+
functionCase: 'upper',
|
|
247
|
+
dataTypeCase: 'upper',
|
|
248
|
+
linesBetweenQueries: 1,
|
|
249
|
+
});
|
|
250
|
+
// Post-process to fix BEGIN/END formatting
|
|
251
|
+
formatted = this._postProcessBeginEnd(formatted);
|
|
252
|
+
return formatted;
|
|
253
|
+
}
|
|
254
|
+
catch (error) {
|
|
255
|
+
// If formatting fails, return original SQL
|
|
256
|
+
console.warn('SQL formatting failed, returning original:', error);
|
|
257
|
+
return sql;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Post-process SQL to ensure BEGIN, END, and EXEC keywords are on their own lines
|
|
262
|
+
*/
|
|
263
|
+
_postProcessBeginEnd(sql) {
|
|
264
|
+
if (!sql)
|
|
265
|
+
return sql;
|
|
266
|
+
// Fix BEGIN keyword - ensure it's on its own line
|
|
267
|
+
// Match: any non-whitespace followed by space(s) followed by BEGIN (word boundary)
|
|
268
|
+
sql = sql.replace(/(\S)\s+(BEGIN\b)/g, '$1\n$2');
|
|
269
|
+
// Fix BEGIN followed by other keywords - ensure what follows BEGIN is on a new line
|
|
270
|
+
// Match: BEGIN followed by space(s) followed by non-whitespace
|
|
271
|
+
sql = sql.replace(/(BEGIN\b)\s+(\S)/g, '$1\n$2');
|
|
272
|
+
// Fix END keyword - ensure it's on its own line
|
|
273
|
+
// Match: any non-whitespace followed by space(s) followed by END (word boundary)
|
|
274
|
+
sql = sql.replace(/(\S)\s+(END\b)/g, '$1\n$2');
|
|
275
|
+
// Fix EXEC keyword - ensure it's on its own line
|
|
276
|
+
// Match: any non-whitespace followed by space(s) followed by EXEC (word boundary)
|
|
277
|
+
sql = sql.replace(/(\S)\s+(EXEC\b)/g, '$1\n$2');
|
|
278
|
+
return sql;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
exports.SqlLoggingSessionImpl = SqlLoggingSessionImpl;
|
|
282
|
+
//# sourceMappingURL=SqlLogger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SqlLogger.js","sourceRoot":"","sources":["../src/SqlLogger.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AACzB,2CAA6B;AAC7B,iDAAoD;AAGpD;;;;;GAKG;AACH,MAAa,qBAAqB;IAUhC,YAAY,EAAU,EAAE,QAAgB,EAAE,UAA6B,EAAE;QALjE,oBAAe,GAAW,CAAC,CAAC;QAC5B,2BAAsB,GAAW,CAAC,CAAC,CAAC,oCAAoC;QACxE,gBAAW,GAAkC,IAAI,CAAC;QAClD,cAAS,GAAY,KAAK,CAAC;QAGjC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED;;;OAGG;IACH,IAAW,cAAc;QACvB,OAAO,IAAI,CAAC,sBAAsB,CAAC,CAAC,qCAAqC;IAC3E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C;QAErB,kDAAkD;QAClD,mFAAmF;QACnF,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,mBAAmB,EAAE,QAAQ,CAAC,CAAC;QAEjD,oFAAoF;QACpF,+DAA+D;QAC/D,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,mBAAmB,EAAE,QAAQ,CAAC,CAAC;QAEjD,gDAAgD;QAChD,iFAAiF;QACjF,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC;QAE/C,iDAAiD;QACjD,kFAAkF;QAClF,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,kBAAkB,EAAE,QAAQ,CAAC,CAAC;QAEhD,OAAO,GAAG,CAAC;IACb,CAAC;CACF;AAxRD,sDAwRC"}
|
package/dist/config.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { SQLServerDataProvider
|
|
1
|
+
import { SQLServerDataProvider } from "./SQLServerDataProvider";
|
|
2
|
+
import { SQLServerProviderConfigData } from "./types";
|
|
2
3
|
export declare function setupSQLServerClient(config: SQLServerProviderConfigData): Promise<SQLServerDataProvider>;
|
|
3
4
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;AAMtD,wBAAsB,oBAAoB,CAAC,MAAM,EAAE,2BAA2B,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAyC9G"}
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;AAAA,+CAA4H;AAC5H,
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;AAAA,+CAA4H;AAC5H,mEAAgE;AAGhE,2CAAwC;AAIjC,KAAK,UAAU,oBAAoB,CAAC,MAAmC;IAC1E,IAAI,CAAC;QACD,2HAA2H;QAC3H,MAAM,IAAI,GAA2C,MAAM,CAAC,UAAU,CAAC,CAAC,+BAA+B;QACvG,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACjB,MAAM,QAAQ,GAAG,IAAI,6CAAqB,EAAE,CAAA;YAC5C,MAAM,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAE9B,oEAAoE;YACpE,IAAA,kBAAW,EAAC,QAAQ,CAAC,CAAC;YAEtB,2BAA2B;YAC3B,MAAM,qBAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,2BAA2B,CAAC,CAAC;YAE3E,IAAI,MAAM,CAAC,2BAA2B,IAAI,MAAM,CAAC,2BAA2B,GAAG,CAAC,EAAE,CAAC;gBAC/E,uCAAuC;gBACvC,WAAW,CAAC,KAAK,IAAI,EAAE;oBACnB,IAAI,CAAC;wBACD,MAAM,QAAQ,CAAC,eAAe,EAAE,CAAC;oBACrC,CAAC;oBACD,OAAO,CAAC,EAAE,CAAC;wBACP,IAAA,eAAQ,EAAC,4BAA4B,EAAE,CAAC,CAAC,CAAA;oBAC7C,CAAC;gBACL,CAAC,EAAE,MAAM,CAAC,2BAA2B,GAAG,IAAI,CAAC,CAAA;YACjD,CAAC;YAED,OAAO,QAAQ,CAAA;QACnB,CAAC;aACI,CAAC;YACF,uCAAuC;YACvC,IAAA,gBAAS,EAAC,iEAAiE,CAAC,CAAA;YAC5E,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;YACrB,IAAI,IAAI,CAAC,SAAS;gBACd,OAAO,oBAAoB,CAAC,MAAM,CAAC,CAAA,CAAC,oDAAoD;;gBAExF,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC,CAAC,yDAAyD;QACnH,CAAC;IACL,CAAC;IACD,OAAO,CAAC,EAAE,CAAC;QACP,IAAA,eAAQ,EAAC,+BAA+B,EAAE,CAAC,CAAC,CAAA;IAChD,CAAC;AACL,CAAC;AAzCD,oDAyCC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { setupSQLServerClient } from "./config";
|
|
2
|
-
export { SQLServerDataProvider
|
|
2
|
+
export { SQLServerDataProvider } from "./SQLServerDataProvider";
|
|
3
|
+
export { ExecuteSQLOptions, ExecuteSQLBatchOptions, SQLServerProviderConfigData, SqlLoggingOptions, SqlLoggingSession } from "./types";
|
|
4
|
+
export { SqlLoggingSessionImpl } from "./SqlLogger";
|
|
3
5
|
export { UserCache } from "./UserCache";
|
|
4
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,2BAA2B,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,2BAA2B,EAC3B,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UserCache = exports.SQLServerProviderConfigData = exports.SQLServerDataProvider = exports.setupSQLServerClient = void 0;
|
|
3
|
+
exports.UserCache = exports.SqlLoggingSessionImpl = exports.SQLServerProviderConfigData = exports.SQLServerDataProvider = exports.setupSQLServerClient = void 0;
|
|
4
4
|
var config_1 = require("./config");
|
|
5
5
|
Object.defineProperty(exports, "setupSQLServerClient", { enumerable: true, get: function () { return config_1.setupSQLServerClient; } });
|
|
6
6
|
var SQLServerDataProvider_1 = require("./SQLServerDataProvider");
|
|
7
7
|
Object.defineProperty(exports, "SQLServerDataProvider", { enumerable: true, get: function () { return SQLServerDataProvider_1.SQLServerDataProvider; } });
|
|
8
|
-
|
|
8
|
+
var types_1 = require("./types");
|
|
9
|
+
Object.defineProperty(exports, "SQLServerProviderConfigData", { enumerable: true, get: function () { return types_1.SQLServerProviderConfigData; } });
|
|
10
|
+
var SqlLogger_1 = require("./SqlLogger");
|
|
11
|
+
Object.defineProperty(exports, "SqlLoggingSessionImpl", { enumerable: true, get: function () { return SqlLogger_1.SqlLoggingSessionImpl; } });
|
|
9
12
|
var UserCache_1 = require("./UserCache");
|
|
10
13
|
Object.defineProperty(exports, "UserCache", { enumerable: true, get: function () { return UserCache_1.UserCache; } });
|
|
11
14
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAAgD;AAAvC,8GAAA,oBAAoB,OAAA;AAC7B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAAgD;AAAvC,8GAAA,oBAAoB,OAAA;AAC7B,iEAAgE;AAAvD,8HAAA,qBAAqB,OAAA;AAC9B,iCAMiB;AAHf,oHAAA,2BAA2B,OAAA;AAI7B,yCAAoD;AAA3C,kHAAA,qBAAqB,OAAA;AAC9B,yCAAwC;AAA/B,sGAAA,SAAS,OAAA"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Type definitions for SQL Server Data Provider
|
|
3
|
+
*
|
|
4
|
+
* This module contains all the types, interfaces, and configuration classes
|
|
5
|
+
* used by the SQL Server Data Provider.
|
|
6
|
+
*
|
|
7
|
+
* @module @memberjunction/sqlserver-dataprovider/types
|
|
8
|
+
*/
|
|
9
|
+
import { ProviderConfigDataBase, UserInfo } from '@memberjunction/core';
|
|
10
|
+
import * as sql from 'mssql';
|
|
11
|
+
/**
|
|
12
|
+
* Configuration options for SQL execution with logging support
|
|
13
|
+
*/
|
|
14
|
+
export interface ExecuteSQLOptions {
|
|
15
|
+
/** Optional description for this SQL operation */
|
|
16
|
+
description?: string;
|
|
17
|
+
/** If true, this statement will not be logged to any logging session */
|
|
18
|
+
ignoreLogging?: boolean;
|
|
19
|
+
/** Whether this is a data mutation operation (INSERT/UPDATE/DELETE) */
|
|
20
|
+
isMutation?: boolean;
|
|
21
|
+
/** Simple SQL fallback for loggers with logRecordChangeMetadata=false (only for Save/Delete operations) */
|
|
22
|
+
simpleSQLFallback?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Context for SQL execution containing all necessary resources
|
|
26
|
+
*/
|
|
27
|
+
export interface SQLExecutionContext {
|
|
28
|
+
/** The connection pool to use for queries */
|
|
29
|
+
pool: sql.ConnectionPool;
|
|
30
|
+
/** Optional transaction if one is active */
|
|
31
|
+
transaction?: sql.Transaction | null;
|
|
32
|
+
/** Function to log SQL statements */
|
|
33
|
+
logSqlStatement?: (query: string, parameters?: any, description?: string, ignoreLogging?: boolean, isMutation?: boolean, simpleSQLFallback?: string, contextUser?: UserInfo) => Promise<void>;
|
|
34
|
+
/** Function to clear transaction reference on EREQINPROG */
|
|
35
|
+
clearTransaction?: () => void;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Options for internal SQL execution
|
|
39
|
+
*/
|
|
40
|
+
export interface InternalSQLOptions {
|
|
41
|
+
/** Optional description for this SQL operation */
|
|
42
|
+
description?: string;
|
|
43
|
+
/** If true, this statement will not be logged */
|
|
44
|
+
ignoreLogging?: boolean;
|
|
45
|
+
/** Whether this is a data mutation operation */
|
|
46
|
+
isMutation?: boolean;
|
|
47
|
+
/** Simple SQL fallback for loggers */
|
|
48
|
+
simpleSQLFallback?: string;
|
|
49
|
+
/** User context for logging */
|
|
50
|
+
contextUser?: UserInfo;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Configuration options for batch SQL execution
|
|
54
|
+
*/
|
|
55
|
+
export interface ExecuteSQLBatchOptions {
|
|
56
|
+
/** Optional description for this batch operation */
|
|
57
|
+
description?: string;
|
|
58
|
+
/** If true, this batch will not be logged to any logging session */
|
|
59
|
+
ignoreLogging?: boolean;
|
|
60
|
+
/** Whether this batch contains data mutation operations */
|
|
61
|
+
isMutation?: boolean;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Configuration data specific to SQL Server provider
|
|
65
|
+
*/
|
|
66
|
+
export declare class SQLServerProviderConfigData extends ProviderConfigDataBase {
|
|
67
|
+
/**
|
|
68
|
+
* Gets the SQL Server data source configuration
|
|
69
|
+
*/
|
|
70
|
+
get DataSource(): any;
|
|
71
|
+
/**
|
|
72
|
+
* Gets the interval in seconds for checking metadata refresh
|
|
73
|
+
*/
|
|
74
|
+
get CheckRefreshIntervalSeconds(): number;
|
|
75
|
+
constructor(dataSource: any, MJCoreSchemaName?: string, checkRefreshIntervalSeconds?: number, includeSchemas?: string[], excludeSchemas?: string[]);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Configuration options for SQL logging sessions
|
|
79
|
+
*/
|
|
80
|
+
export interface SqlLoggingOptions {
|
|
81
|
+
/** Whether to format output as a migration file with schema placeholders */
|
|
82
|
+
formatAsMigration?: boolean;
|
|
83
|
+
/** Optional description to include as a comment at the start of the log */
|
|
84
|
+
description?: string;
|
|
85
|
+
/** Which types of statements to log: 'queries' (all), 'mutations' (only data changes), 'both' (default) */
|
|
86
|
+
statementTypes?: 'queries' | 'mutations' | 'both';
|
|
87
|
+
/** Optional batch separator to emit after each statement (e.g., "GO" for SQL Server) */
|
|
88
|
+
batchSeparator?: string;
|
|
89
|
+
/** Whether to pretty print SQL statements with proper formatting */
|
|
90
|
+
prettyPrint?: boolean;
|
|
91
|
+
/** Whether to log record change metadata wrapper SQL (default: false). When false, only core spCreate/spUpdate/spDelete calls are logged */
|
|
92
|
+
logRecordChangeMetadata?: boolean;
|
|
93
|
+
/** Whether to retain log files that contain no SQL statements (default: false). When false, empty log files are automatically deleted on dispose */
|
|
94
|
+
retainEmptyLogFiles?: boolean;
|
|
95
|
+
/** Optional user ID to filter SQL logging - only log SQL executed by this user */
|
|
96
|
+
filterByUserId?: string;
|
|
97
|
+
/** Optional friendly name for this logging session (for UI display) */
|
|
98
|
+
sessionName?: string;
|
|
99
|
+
/** Whether to output verbose debug information to console (default: false) */
|
|
100
|
+
verboseOutput?: boolean;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Interface for SQL logging session with disposable pattern
|
|
104
|
+
*/
|
|
105
|
+
export interface SqlLoggingSession {
|
|
106
|
+
/** Unique session ID */
|
|
107
|
+
readonly id: string;
|
|
108
|
+
/** File path where SQL is being logged */
|
|
109
|
+
readonly filePath: string;
|
|
110
|
+
/** Session start time */
|
|
111
|
+
readonly startTime: Date;
|
|
112
|
+
/** Number of statements logged so far */
|
|
113
|
+
readonly statementCount: number;
|
|
114
|
+
/** Configuration options for this session */
|
|
115
|
+
readonly options: SqlLoggingOptions;
|
|
116
|
+
/** Dispose method to stop logging and clean up resources */
|
|
117
|
+
dispose(): Promise<void>;
|
|
118
|
+
}
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AiB;IAChC,wBAAwB;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,0CAA0C;IAC1C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,yBAAyB;IACzB,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC;IACzB,yCAAyC;IACzC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,6CAA6C;IAC7C,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAC;IACpC,4DAA4D;IAC5D,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Type definitions for SQL Server Data Provider
|
|
4
|
+
*
|
|
5
|
+
* This module contains all the types, interfaces, and configuration classes
|
|
6
|
+
* used by the SQL Server Data Provider.
|
|
7
|
+
*
|
|
8
|
+
* @module @memberjunction/sqlserver-dataprovider/types
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.SQLServerProviderConfigData = void 0;
|
|
12
|
+
const core_1 = require("@memberjunction/core");
|
|
13
|
+
/**
|
|
14
|
+
* Configuration data specific to SQL Server provider
|
|
15
|
+
*/
|
|
16
|
+
class SQLServerProviderConfigData extends core_1.ProviderConfigDataBase {
|
|
17
|
+
/**
|
|
18
|
+
* Gets the SQL Server data source configuration
|
|
19
|
+
*/
|
|
20
|
+
get DataSource() {
|
|
21
|
+
return this.Data.DataSource;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Gets the interval in seconds for checking metadata refresh
|
|
25
|
+
*/
|
|
26
|
+
get CheckRefreshIntervalSeconds() {
|
|
27
|
+
return this.Data.CheckRefreshIntervalSeconds;
|
|
28
|
+
}
|
|
29
|
+
constructor(dataSource, MJCoreSchemaName, checkRefreshIntervalSeconds = 0 /*default to disabling auto refresh */, includeSchemas, excludeSchemas) {
|
|
30
|
+
super({
|
|
31
|
+
DataSource: dataSource,
|
|
32
|
+
CheckRefreshIntervalSeconds: checkRefreshIntervalSeconds,
|
|
33
|
+
}, MJCoreSchemaName, includeSchemas, excludeSchemas);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.SQLServerProviderConfigData = SQLServerProviderConfigData;
|
|
37
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAEH,+CAAwE;AAmExE;;GAEG;AACH,MAAa,2BAA4B,SAAQ,6BAAsB;IACrE;;OAEG;IACH,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,IAAI,2BAA2B;QAC7B,OAAO,IAAI,CAAC,IAAI,CAAC,2BAA2B,CAAC;IAC/C,CAAC;IAED,YACE,UAAe,EACf,gBAAyB,EACzB,8BAAsC,CAAC,CAAC,sCAAsC,EAC9E,cAAyB,EACzB,cAAyB;QAEzB,KAAK,CACH;YACE,UAAU,EAAE,UAAU;YACtB,2BAA2B,EAAE,2BAA2B;SACzD,EACD,gBAAgB,EAChB,cAAc,EACd,cAAc,CACf,CAAC;IACJ,CAAC;CACF;AAhCD,kEAgCC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/sqlserver-dataprovider",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.52.0",
|
|
4
4
|
"description": "MemberJunction: SQL Server Client Data Provider",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -20,15 +20,16 @@
|
|
|
20
20
|
"typescript": "^5.4.5"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@memberjunction/actions": "2.
|
|
24
|
-
"@memberjunction/ai": "2.
|
|
25
|
-
"@memberjunction/ai-vector-dupe": "2.
|
|
26
|
-
"@memberjunction/aiengine": "2.
|
|
27
|
-
"@memberjunction/core": "2.
|
|
28
|
-
"@memberjunction/core-entities": "2.
|
|
29
|
-
"@memberjunction/global": "2.
|
|
30
|
-
"@memberjunction/queue": "2.
|
|
23
|
+
"@memberjunction/actions": "2.52.0",
|
|
24
|
+
"@memberjunction/ai": "2.52.0",
|
|
25
|
+
"@memberjunction/ai-vector-dupe": "2.52.0",
|
|
26
|
+
"@memberjunction/aiengine": "2.52.0",
|
|
27
|
+
"@memberjunction/core": "2.52.0",
|
|
28
|
+
"@memberjunction/core-entities": "2.52.0",
|
|
29
|
+
"@memberjunction/global": "2.52.0",
|
|
30
|
+
"@memberjunction/queue": "2.52.0",
|
|
31
31
|
"mssql": "^11.0.1",
|
|
32
|
+
"rxjs": "^7.8.1",
|
|
32
33
|
"sql-formatter": "^15.3.2",
|
|
33
34
|
"uuid": "^10.0.0"
|
|
34
35
|
}
|