noormme 1.0.0 → 1.0.2
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/LICENSE +89 -21
- package/README.md +195 -578
- package/dist/cjs/cli/commands/analyze.js +4 -1
- package/dist/cjs/cli/commands/generate.js +48 -8
- package/dist/cjs/cli/commands/init.js +54 -14
- package/dist/cjs/cli/commands/inspect.js +10 -3
- package/dist/cjs/cli/commands/migrate.js +38 -2
- package/dist/cjs/cli/commands/optimize.js +4 -1
- package/dist/cjs/cli/commands/status.js +41 -5
- package/dist/cjs/cli/commands/watch.js +4 -1
- package/dist/cjs/cli/index.js +4 -1
- package/dist/cjs/dialect/database-introspector.js +16 -21
- package/dist/cjs/dialect/sqlite/sqlite-introspector.js +13 -24
- package/dist/cjs/dynamic/dynamic.d.ts +20 -0
- package/dist/cjs/dynamic/dynamic.js +25 -0
- package/dist/cjs/edge-runtime/edge-config.d.ts +125 -0
- package/dist/cjs/edge-runtime/edge-config.js +323 -0
- package/dist/cjs/errors/NoormError.d.ts +27 -4
- package/dist/cjs/errors/NoormError.js +142 -21
- package/dist/cjs/logging/logger.d.ts +7 -2
- package/dist/cjs/logging/logger.js +21 -7
- package/dist/cjs/noormme.d.ts +12 -8
- package/dist/cjs/noormme.js +133 -61
- package/dist/cjs/operation-node/column-node.js +4 -0
- package/dist/cjs/operation-node/identifier-node.js +4 -0
- package/dist/cjs/operation-node/table-node.js +7 -0
- package/dist/cjs/parser/reference-parser.js +5 -0
- package/dist/cjs/parser/table-parser.js +2 -0
- package/dist/cjs/performance/index.d.ts +44 -0
- package/dist/cjs/performance/index.js +64 -0
- package/dist/cjs/performance/query-optimizer.d.ts +134 -0
- package/dist/cjs/performance/query-optimizer.js +391 -0
- package/dist/cjs/performance/services/cache-service.d.ts +177 -0
- package/dist/cjs/performance/services/cache-service.js +415 -0
- package/dist/cjs/performance/services/connection-factory.d.ts +198 -0
- package/dist/cjs/performance/services/connection-factory.js +498 -0
- package/dist/cjs/performance/services/metrics-collector.d.ts +162 -0
- package/dist/cjs/performance/services/metrics-collector.js +406 -0
- package/dist/cjs/performance/utils/query-parser.d.ts +123 -0
- package/dist/cjs/performance/utils/query-parser.js +295 -0
- package/dist/cjs/raw-builder/sql.d.ts +73 -26
- package/dist/cjs/raw-builder/sql.js +9 -0
- package/dist/cjs/repository/repository-factory.d.ts +10 -42
- package/dist/cjs/repository/repository-factory.js +276 -394
- package/dist/cjs/schema/core/coordinators/schema-discovery.coordinator.js +6 -4
- package/dist/cjs/schema/core/factories/discovery-factory.js +5 -5
- package/dist/cjs/schema/core/utils/name-generator.js +34 -2
- package/dist/cjs/schema/core/utils/type-mapper.d.ts +19 -14
- package/dist/cjs/schema/core/utils/type-mapper.js +4 -7
- package/dist/cjs/schema/dialects/sqlite/discovery/sqlite-constraint-discovery.js +3 -2
- package/dist/cjs/schema/dialects/sqlite/sqlite-discovery.coordinator.d.ts +2 -0
- package/dist/cjs/schema/dialects/sqlite/sqlite-discovery.coordinator.js +19 -5
- package/dist/cjs/schema/test/dialect-capabilities.test.js +6 -0
- package/dist/cjs/schema/test/error-handling.test.js +52 -33
- package/dist/cjs/schema/test/integration.test.js +51 -5
- package/dist/cjs/schema/test/sqlite-discovery-coordinator.test.js +8 -4
- package/dist/cjs/sqlite-migration/index.js +35 -2
- package/dist/cjs/testing/test-utils.d.ts +5 -0
- package/dist/cjs/testing/test-utils.js +66 -6
- package/dist/cjs/types/index.d.ts +78 -13
- package/dist/cjs/types/index.js +23 -0
- package/dist/cjs/types/type-generator.d.ts +8 -0
- package/dist/cjs/types/type-generator.js +86 -17
- package/dist/cjs/util/safe-sql-helpers.d.ts +124 -0
- package/dist/cjs/util/safe-sql-helpers.js +221 -0
- package/dist/cjs/util/security-validator.d.ts +44 -0
- package/dist/cjs/util/security-validator.js +256 -0
- package/dist/cjs/util/security.d.ts +60 -0
- package/dist/cjs/util/security.js +137 -0
- package/dist/cjs/watch/schema-watcher.js +26 -7
- package/dist/esm/cli/commands/generate.js +10 -6
- package/dist/esm/cli/commands/init.js +15 -11
- package/dist/esm/cli/commands/inspect.js +6 -2
- package/dist/esm/cli/commands/status.js +3 -3
- package/dist/esm/dialect/database-introspector.js +16 -21
- package/dist/esm/dialect/sqlite/sqlite-introspector.js +13 -24
- package/dist/esm/dynamic/dynamic.d.ts +20 -0
- package/dist/esm/dynamic/dynamic.js +25 -0
- package/dist/esm/edge-runtime/edge-config.d.ts +125 -0
- package/dist/esm/edge-runtime/edge-config.js +281 -0
- package/dist/esm/errors/NoormError.d.ts +27 -4
- package/dist/esm/errors/NoormError.js +134 -18
- package/dist/esm/logging/logger.d.ts +7 -2
- package/dist/esm/logging/logger.js +21 -7
- package/dist/esm/noormme.d.ts +12 -8
- package/dist/esm/noormme.js +130 -61
- package/dist/esm/operation-node/column-node.js +4 -0
- package/dist/esm/operation-node/identifier-node.js +4 -0
- package/dist/esm/operation-node/table-node.js +7 -0
- package/dist/esm/parser/reference-parser.js +5 -0
- package/dist/esm/parser/table-parser.js +2 -0
- package/dist/esm/performance/index.d.ts +44 -0
- package/dist/esm/performance/index.js +48 -0
- package/dist/esm/performance/query-optimizer.d.ts +134 -0
- package/dist/esm/performance/query-optimizer.js +387 -0
- package/dist/esm/performance/services/cache-service.d.ts +177 -0
- package/dist/esm/performance/services/cache-service.js +410 -0
- package/dist/esm/performance/services/connection-factory.d.ts +198 -0
- package/dist/esm/performance/services/connection-factory.js +493 -0
- package/dist/esm/performance/services/metrics-collector.d.ts +162 -0
- package/dist/esm/performance/services/metrics-collector.js +402 -0
- package/dist/esm/performance/utils/query-parser.d.ts +123 -0
- package/dist/esm/performance/utils/query-parser.js +292 -0
- package/dist/esm/raw-builder/sql.d.ts +73 -26
- package/dist/esm/raw-builder/sql.js +9 -0
- package/dist/esm/repository/repository-factory.d.ts +10 -42
- package/dist/esm/repository/repository-factory.js +277 -395
- package/dist/esm/schema/core/coordinators/schema-discovery.coordinator.js +6 -4
- package/dist/esm/schema/core/factories/discovery-factory.js +5 -5
- package/dist/esm/schema/core/utils/name-generator.js +34 -2
- package/dist/esm/schema/core/utils/type-mapper.d.ts +19 -14
- package/dist/esm/schema/core/utils/type-mapper.js +4 -7
- package/dist/esm/schema/dialects/sqlite/discovery/sqlite-constraint-discovery.js +3 -2
- package/dist/esm/schema/dialects/sqlite/sqlite-discovery.coordinator.d.ts +2 -0
- package/dist/esm/schema/dialects/sqlite/sqlite-discovery.coordinator.js +19 -5
- package/dist/esm/schema/test/dialect-capabilities.test.js +6 -0
- package/dist/esm/schema/test/error-handling.test.js +52 -33
- package/dist/esm/schema/test/integration.test.js +18 -5
- package/dist/esm/schema/test/sqlite-discovery-coordinator.test.js +8 -4
- package/dist/esm/testing/test-utils.d.ts +5 -0
- package/dist/esm/testing/test-utils.js +66 -6
- package/dist/esm/types/index.d.ts +78 -13
- package/dist/esm/types/index.js +22 -1
- package/dist/esm/types/type-generator.d.ts +8 -0
- package/dist/esm/types/type-generator.js +86 -17
- package/dist/esm/util/safe-sql-helpers.d.ts +124 -0
- package/dist/esm/util/safe-sql-helpers.js +209 -0
- package/dist/esm/util/security-validator.d.ts +44 -0
- package/dist/esm/util/security-validator.js +246 -0
- package/dist/esm/util/security.d.ts +60 -0
- package/dist/esm/util/security.js +114 -0
- package/dist/esm/watch/schema-watcher.js +26 -7
- package/package.json +1 -1
- package/dist/cjs/performance/query-analyzer.d.ts +0 -89
- package/dist/cjs/performance/query-analyzer.js +0 -263
- package/dist/esm/performance/query-analyzer.d.ts +0 -89
- package/dist/esm/performance/query-analyzer.js +0 -260
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.TypeGenerationError = exports.MigrationError = exports.SchemaDiscoveryError = exports.QueryExecutionError = exports.RelationshipNotFoundError = exports.ValidationError = exports.DatabaseInitializationError = exports.ConnectionError = exports.ColumnNotFoundError = exports.TableNotFoundError = exports.NoormError = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Enhanced error class with context-aware information
|
|
6
6
|
*/
|
|
@@ -55,31 +55,105 @@ exports.NoormError = NoormError;
|
|
|
55
55
|
*/
|
|
56
56
|
class TableNotFoundError extends NoormError {
|
|
57
57
|
constructor(tableName, availableTables = []) {
|
|
58
|
-
|
|
58
|
+
const message = availableTables.length > 0
|
|
59
|
+
? `Table '${tableName}' not found. Available tables: ${availableTables.join(', ')}`
|
|
60
|
+
: `Table '${tableName}' not found. Check your table name or run schema discovery.`;
|
|
61
|
+
super(message, {
|
|
59
62
|
table: tableName,
|
|
60
|
-
operation: '
|
|
63
|
+
operation: 'table_lookup',
|
|
61
64
|
suggestion: availableTables.length > 0
|
|
62
65
|
? `Available tables: ${availableTables.join(', ')}`
|
|
63
|
-
: 'Check your
|
|
66
|
+
: 'Check your table name or run schema discovery',
|
|
64
67
|
availableOptions: availableTables
|
|
65
68
|
});
|
|
69
|
+
this.name = 'TableNotFoundError';
|
|
66
70
|
}
|
|
67
71
|
}
|
|
68
72
|
exports.TableNotFoundError = TableNotFoundError;
|
|
69
73
|
class ColumnNotFoundError extends NoormError {
|
|
70
74
|
constructor(columnName, tableName, availableColumns = []) {
|
|
71
|
-
|
|
72
|
-
|
|
75
|
+
// Find similar column names for better suggestions
|
|
76
|
+
const similarColumns = availableColumns.filter(col => col.toLowerCase().includes(columnName.toLowerCase()) ||
|
|
77
|
+
columnName.toLowerCase().includes(col.toLowerCase()) ||
|
|
78
|
+
ColumnNotFoundError.calculateSimilarity(col, columnName) > 0.6);
|
|
79
|
+
let suggestion = 'Check your column name or run schema discovery';
|
|
80
|
+
if (availableColumns.length > 0) {
|
|
81
|
+
suggestion = `Available columns: ${availableColumns.join(', ')}`;
|
|
82
|
+
if (similarColumns.length > 0) {
|
|
83
|
+
suggestion += `\n → Did you mean '${similarColumns[0]}'? (${Math.round(ColumnNotFoundError.calculateSimilarity(similarColumns[0], columnName) * 100)}% similarity)`;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
super(`Column '${columnName}' not found in table '${tableName}'`, {
|
|
73
87
|
table: tableName,
|
|
74
88
|
operation: 'column_lookup',
|
|
75
|
-
suggestion:
|
|
76
|
-
? `Did you mean '${similar[0]}'?`
|
|
77
|
-
: `Available columns: ${availableColumns.join(', ')}`,
|
|
89
|
+
suggestion: suggestion,
|
|
78
90
|
availableOptions: availableColumns
|
|
79
91
|
});
|
|
92
|
+
this.name = 'ColumnNotFoundError';
|
|
93
|
+
}
|
|
94
|
+
static calculateSimilarity(str1, str2) {
|
|
95
|
+
const longer = str1.length > str2.length ? str1 : str2;
|
|
96
|
+
const shorter = str1.length > str2.length ? str2 : str1;
|
|
97
|
+
if (longer.length === 0)
|
|
98
|
+
return 1.0;
|
|
99
|
+
const editDistance = ColumnNotFoundError.levenshteinDistance(longer, shorter);
|
|
100
|
+
return (longer.length - editDistance) / longer.length;
|
|
101
|
+
}
|
|
102
|
+
static levenshteinDistance(str1, str2) {
|
|
103
|
+
const matrix = [];
|
|
104
|
+
for (let i = 0; i <= str2.length; i++) {
|
|
105
|
+
matrix[i] = [i];
|
|
106
|
+
}
|
|
107
|
+
for (let j = 0; j <= str1.length; j++) {
|
|
108
|
+
matrix[0][j] = j;
|
|
109
|
+
}
|
|
110
|
+
for (let i = 1; i <= str2.length; i++) {
|
|
111
|
+
for (let j = 1; j <= str1.length; j++) {
|
|
112
|
+
if (str2.charAt(i - 1) === str1.charAt(j - 1)) {
|
|
113
|
+
matrix[i][j] = matrix[i - 1][j - 1];
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
matrix[i][j] = Math.min(matrix[i - 1][j - 1] + 1, matrix[i][j - 1] + 1, matrix[i - 1][j] + 1);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return matrix[str2.length][str1.length];
|
|
80
121
|
}
|
|
81
122
|
}
|
|
82
123
|
exports.ColumnNotFoundError = ColumnNotFoundError;
|
|
124
|
+
class ConnectionError extends NoormError {
|
|
125
|
+
constructor(message, originalError) {
|
|
126
|
+
super(message, {
|
|
127
|
+
operation: 'connection',
|
|
128
|
+
suggestion: 'Check your database connection settings and ensure the database server is running',
|
|
129
|
+
originalError
|
|
130
|
+
});
|
|
131
|
+
this.name = 'ConnectionError';
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
exports.ConnectionError = ConnectionError;
|
|
135
|
+
class DatabaseInitializationError extends NoormError {
|
|
136
|
+
constructor(originalError, databasePath) {
|
|
137
|
+
super(`Failed to initialize database at ${databasePath}: ${originalError.message}`, {
|
|
138
|
+
operation: 'initialization',
|
|
139
|
+
suggestion: 'Check database permissions, path validity, and connection settings',
|
|
140
|
+
originalError
|
|
141
|
+
});
|
|
142
|
+
this.name = 'DatabaseInitializationError';
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
exports.DatabaseInitializationError = DatabaseInitializationError;
|
|
146
|
+
class ValidationError extends NoormError {
|
|
147
|
+
constructor(message, validationIssues = []) {
|
|
148
|
+
super(message, {
|
|
149
|
+
operation: 'validation',
|
|
150
|
+
suggestion: 'Check your input data and ensure it matches the expected schema',
|
|
151
|
+
availableOptions: validationIssues
|
|
152
|
+
});
|
|
153
|
+
this.name = 'ValidationError';
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
exports.ValidationError = ValidationError;
|
|
83
157
|
class RelationshipNotFoundError extends NoormError {
|
|
84
158
|
constructor(relationshipName, tableName, availableRelationships = []) {
|
|
85
159
|
super(`Relationship '${relationshipName}' not found on table '${tableName}'`, {
|
|
@@ -90,29 +164,76 @@ class RelationshipNotFoundError extends NoormError {
|
|
|
90
164
|
: 'No relationships defined for this table',
|
|
91
165
|
availableOptions: availableRelationships
|
|
92
166
|
});
|
|
167
|
+
this.name = 'RelationshipNotFoundError';
|
|
93
168
|
}
|
|
94
169
|
}
|
|
95
170
|
exports.RelationshipNotFoundError = RelationshipNotFoundError;
|
|
96
|
-
class
|
|
97
|
-
constructor(
|
|
98
|
-
super(message
|
|
171
|
+
class QueryExecutionError extends NoormError {
|
|
172
|
+
constructor(query, originalError, context) {
|
|
173
|
+
super(`Query execution failed: ${originalError.message}`, {
|
|
174
|
+
operation: context?.operation || 'query_execution',
|
|
175
|
+
table: context?.table,
|
|
176
|
+
suggestion: QueryExecutionError.getQuerySuggestion(query, originalError),
|
|
177
|
+
originalError
|
|
178
|
+
});
|
|
179
|
+
this.name = 'QueryExecutionError';
|
|
180
|
+
}
|
|
181
|
+
static getQuerySuggestion(query, error) {
|
|
182
|
+
const errorMsg = error.message.toLowerCase();
|
|
183
|
+
if (errorMsg.includes('syntax error')) {
|
|
184
|
+
return 'Check your SQL syntax. Common issues: missing commas, unclosed quotes, or invalid keywords.';
|
|
185
|
+
}
|
|
186
|
+
if (errorMsg.includes('no such table')) {
|
|
187
|
+
return 'Table does not exist. Check table name or run schema discovery to see available tables.';
|
|
188
|
+
}
|
|
189
|
+
if (errorMsg.includes('no such column')) {
|
|
190
|
+
return 'Column does not exist. Check column name or run schema discovery to see available columns.';
|
|
191
|
+
}
|
|
192
|
+
if (errorMsg.includes('constraint failed')) {
|
|
193
|
+
return 'Data constraint violation. Check for required fields, unique constraints, or foreign key references.';
|
|
194
|
+
}
|
|
195
|
+
if (errorMsg.includes('database is locked')) {
|
|
196
|
+
return 'Database is locked. Enable WAL mode for better concurrency: optimization: { enableWALMode: true }';
|
|
197
|
+
}
|
|
198
|
+
return 'Review your query and check the original error message for specific details.';
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
exports.QueryExecutionError = QueryExecutionError;
|
|
202
|
+
class SchemaDiscoveryError extends NoormError {
|
|
203
|
+
constructor(tableName, originalError) {
|
|
204
|
+
super(`Failed to discover schema for table '${tableName}': ${originalError.message}`, {
|
|
99
205
|
table: tableName,
|
|
100
|
-
operation: '
|
|
101
|
-
suggestion:
|
|
206
|
+
operation: 'schema_discovery',
|
|
207
|
+
suggestion: 'Check table permissions, table name validity, or database connection',
|
|
208
|
+
originalError
|
|
102
209
|
});
|
|
210
|
+
this.name = 'SchemaDiscoveryError';
|
|
103
211
|
}
|
|
104
212
|
}
|
|
105
|
-
exports.
|
|
106
|
-
class
|
|
107
|
-
constructor(
|
|
108
|
-
super(`
|
|
109
|
-
operation: '
|
|
110
|
-
suggestion: 'Check
|
|
213
|
+
exports.SchemaDiscoveryError = SchemaDiscoveryError;
|
|
214
|
+
class MigrationError extends NoormError {
|
|
215
|
+
constructor(migrationName, originalError, context) {
|
|
216
|
+
super(`Migration '${migrationName}' failed${context?.step ? ` at step: ${context.step}` : ''}: ${originalError.message}`, {
|
|
217
|
+
operation: 'migration',
|
|
218
|
+
suggestion: 'Check migration SQL syntax, database permissions, or rollback the migration',
|
|
111
219
|
originalError
|
|
112
220
|
});
|
|
221
|
+
this.name = 'MigrationError';
|
|
113
222
|
}
|
|
114
223
|
}
|
|
115
|
-
exports.
|
|
224
|
+
exports.MigrationError = MigrationError;
|
|
225
|
+
class TypeGenerationError extends NoormError {
|
|
226
|
+
constructor(tableName, originalError) {
|
|
227
|
+
super(`Failed to generate types for table '${tableName}': ${originalError.message}`, {
|
|
228
|
+
table: tableName,
|
|
229
|
+
operation: 'type_generation',
|
|
230
|
+
suggestion: 'Check table schema, column types, or custom type mappings configuration',
|
|
231
|
+
originalError
|
|
232
|
+
});
|
|
233
|
+
this.name = 'TypeGenerationError';
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
exports.TypeGenerationError = TypeGenerationError;
|
|
116
237
|
/**
|
|
117
238
|
* Helper function to find similar column names using simple string similarity
|
|
118
239
|
*/
|
|
@@ -10,11 +10,16 @@ interface QueryLog {
|
|
|
10
10
|
* Logger for NOORMME
|
|
11
11
|
*/
|
|
12
12
|
export declare class Logger {
|
|
13
|
-
private config;
|
|
14
13
|
private queryLogs;
|
|
15
14
|
private queryCount;
|
|
16
15
|
private totalQueryTime;
|
|
17
|
-
|
|
16
|
+
private config;
|
|
17
|
+
private namespace?;
|
|
18
|
+
constructor(configOrNamespace?: LoggingConfig | string);
|
|
19
|
+
/**
|
|
20
|
+
* Format namespace prefix
|
|
21
|
+
*/
|
|
22
|
+
private getPrefix;
|
|
18
23
|
/**
|
|
19
24
|
* Log debug message
|
|
20
25
|
*/
|
|
@@ -5,19 +5,33 @@ exports.Logger = void 0;
|
|
|
5
5
|
* Logger for NOORMME
|
|
6
6
|
*/
|
|
7
7
|
class Logger {
|
|
8
|
-
config;
|
|
9
8
|
queryLogs = [];
|
|
10
9
|
queryCount = 0;
|
|
11
10
|
totalQueryTime = 0;
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
config;
|
|
12
|
+
namespace;
|
|
13
|
+
constructor(configOrNamespace) {
|
|
14
|
+
if (typeof configOrNamespace === 'string') {
|
|
15
|
+
this.namespace = configOrNamespace;
|
|
16
|
+
this.config = { enabled: true, level: 'info' };
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
this.config = configOrNamespace || {};
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Format namespace prefix
|
|
24
|
+
*/
|
|
25
|
+
getPrefix(level) {
|
|
26
|
+
const prefix = this.namespace ? `[${this.namespace}]` : '';
|
|
27
|
+
return `[NOORMME ${level.toUpperCase()}]${prefix}`;
|
|
14
28
|
}
|
|
15
29
|
/**
|
|
16
30
|
* Log debug message
|
|
17
31
|
*/
|
|
18
32
|
debug(message, ...args) {
|
|
19
33
|
if (this.shouldLog('debug')) {
|
|
20
|
-
console.debug(
|
|
34
|
+
console.debug(`${this.getPrefix('debug')} ${message}`, ...args);
|
|
21
35
|
}
|
|
22
36
|
}
|
|
23
37
|
/**
|
|
@@ -25,7 +39,7 @@ class Logger {
|
|
|
25
39
|
*/
|
|
26
40
|
info(message, ...args) {
|
|
27
41
|
if (this.shouldLog('info')) {
|
|
28
|
-
console.info(
|
|
42
|
+
console.info(`${this.getPrefix('info')} ${message}`, ...args);
|
|
29
43
|
}
|
|
30
44
|
}
|
|
31
45
|
/**
|
|
@@ -33,7 +47,7 @@ class Logger {
|
|
|
33
47
|
*/
|
|
34
48
|
warn(message, ...args) {
|
|
35
49
|
if (this.shouldLog('warn')) {
|
|
36
|
-
console.warn(
|
|
50
|
+
console.warn(`${this.getPrefix('warn')} ${message}`, ...args);
|
|
37
51
|
}
|
|
38
52
|
}
|
|
39
53
|
/**
|
|
@@ -41,7 +55,7 @@ class Logger {
|
|
|
41
55
|
*/
|
|
42
56
|
error(message, ...args) {
|
|
43
57
|
if (this.shouldLog('error')) {
|
|
44
|
-
console.error(
|
|
58
|
+
console.error(`${this.getPrefix('error')} ${message}`, ...args);
|
|
45
59
|
}
|
|
46
60
|
}
|
|
47
61
|
/**
|
package/dist/cjs/noormme.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { NOORMConfig, SchemaInfo, Repository } from './types/index.js';
|
|
1
|
+
import { Kysely } from './kysely.js';
|
|
2
|
+
import { NOORMConfig, SchemaInfo, Repository, SchemaChange } from './types/index.js';
|
|
3
3
|
import { WatchOptions } from './watch/schema-watcher.js';
|
|
4
|
-
import { QueryAnalyzerOptions } from './performance/query-analyzer.js';
|
|
5
4
|
/**
|
|
6
5
|
* NOORMME - No ORM, just magic!
|
|
7
6
|
* Zero-configuration pseudo-ORM that works with any existing database
|
|
@@ -17,12 +16,13 @@ export declare class NOORMME {
|
|
|
17
16
|
private cacheManager;
|
|
18
17
|
private logger;
|
|
19
18
|
private schemaWatcher;
|
|
20
|
-
private
|
|
19
|
+
private metricsCollector;
|
|
21
20
|
private sqliteAutoOptimizer;
|
|
22
21
|
private sqliteAutoIndexer;
|
|
23
22
|
private initialized;
|
|
24
23
|
private repositories;
|
|
25
24
|
private instanceId;
|
|
25
|
+
private schemaChangeCallbacks;
|
|
26
26
|
constructor(configOrConnectionString?: NOORMConfig | string);
|
|
27
27
|
/**
|
|
28
28
|
* Initialize NOORMME - discovers schema and generates types
|
|
@@ -81,7 +81,7 @@ export declare class NOORMME {
|
|
|
81
81
|
/**
|
|
82
82
|
* Start monitoring schema changes in development mode
|
|
83
83
|
*/
|
|
84
|
-
startSchemaWatching(options?: WatchOptions): void
|
|
84
|
+
startSchemaWatching(options?: WatchOptions): Promise<void>;
|
|
85
85
|
/**
|
|
86
86
|
* Stop monitoring schema changes
|
|
87
87
|
*/
|
|
@@ -89,7 +89,7 @@ export declare class NOORMME {
|
|
|
89
89
|
/**
|
|
90
90
|
* Register callback for schema changes
|
|
91
91
|
*/
|
|
92
|
-
onSchemaChange(callback: (changes:
|
|
92
|
+
onSchemaChange(callback: (changes: SchemaChange[]) => void): void;
|
|
93
93
|
/**
|
|
94
94
|
* Get performance metrics
|
|
95
95
|
*/
|
|
@@ -102,7 +102,7 @@ export declare class NOORMME {
|
|
|
102
102
|
/**
|
|
103
103
|
* Enable query performance monitoring
|
|
104
104
|
*/
|
|
105
|
-
enablePerformanceMonitoring(options?:
|
|
105
|
+
enablePerformanceMonitoring(options?: any): void;
|
|
106
106
|
/**
|
|
107
107
|
* Disable query performance monitoring
|
|
108
108
|
*/
|
|
@@ -111,6 +111,10 @@ export declare class NOORMME {
|
|
|
111
111
|
* Close database connections
|
|
112
112
|
*/
|
|
113
113
|
close(): Promise<void>;
|
|
114
|
+
/**
|
|
115
|
+
* Alias for close() - for backward compatibility
|
|
116
|
+
*/
|
|
117
|
+
destroy(): Promise<void>;
|
|
114
118
|
/**
|
|
115
119
|
* Get the underlying Kysely instance for custom queries
|
|
116
120
|
*/
|
|
@@ -122,7 +126,7 @@ export declare class NOORMME {
|
|
|
122
126
|
/**
|
|
123
127
|
* Execute raw SQL
|
|
124
128
|
*/
|
|
125
|
-
execute(
|
|
129
|
+
execute(sqlString: string, parameters?: unknown[]): Promise<unknown>;
|
|
126
130
|
private mergeConfig;
|
|
127
131
|
/**
|
|
128
132
|
* Parse connection string into NOORMConfig
|