noormme 1.1.0 → 1.2.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 +84 -65
- package/dist/cjs/agentic/ActionJournal.js +13 -9
- package/dist/cjs/agentic/CapabilityManager.js +35 -21
- package/dist/cjs/agentic/CognitiveRepository.js +19 -9
- package/dist/cjs/agentic/ContextBuffer.js +24 -12
- package/dist/cjs/agentic/Cortex.js +11 -4
- package/dist/cjs/agentic/EpisodicMemory.js +7 -5
- package/dist/cjs/agentic/PersonaManager.js +16 -8
- package/dist/cjs/agentic/PolicyEnforcer.js +31 -12
- package/dist/cjs/agentic/ResourceMonitor.js +4 -4
- package/dist/cjs/agentic/SessionCompressor.js +22 -14
- package/dist/cjs/agentic/SessionManager.js +36 -18
- package/dist/cjs/agentic/VectorIndexer.js +22 -18
- package/dist/cjs/agentic/improvement/AblationEngine.js +22 -15
- package/dist/cjs/agentic/improvement/ActionRefiner.js +12 -10
- package/dist/cjs/agentic/improvement/ConflictResolver.js +5 -5
- package/dist/cjs/agentic/improvement/CortexJanitor.js +30 -9
- package/dist/cjs/agentic/improvement/CuriosityEngine.js +27 -23
- package/dist/cjs/agentic/improvement/EvolutionRitual.js +4 -4
- package/dist/cjs/agentic/improvement/EvolutionaryPilot.js +16 -6
- package/dist/cjs/agentic/improvement/GoalArchitect.d.ts +2 -2
- package/dist/cjs/agentic/improvement/GoalArchitect.js +20 -18
- package/dist/cjs/agentic/improvement/GovernanceManager.js +19 -11
- package/dist/cjs/agentic/improvement/HiveLink.js +22 -15
- package/dist/cjs/agentic/improvement/KnowledgeDistiller.js +48 -32
- package/dist/cjs/agentic/improvement/RecursiveReasoner.js +40 -17
- package/dist/cjs/agentic/improvement/ReflectionEngine.js +10 -8
- package/dist/cjs/agentic/improvement/RitualOrchestrator.js +28 -22
- package/dist/cjs/agentic/improvement/RuleEngine.js +22 -17
- package/dist/cjs/agentic/improvement/SelfEvolution.js +24 -18
- package/dist/cjs/agentic/improvement/SelfTestRegistry.js +18 -15
- package/dist/cjs/agentic/improvement/SkillSynthesizer.js +42 -27
- package/dist/cjs/agentic/improvement/SovereignMetrics.js +19 -17
- package/dist/cjs/agentic/improvement/StrategicPlanner.js +120 -55
- package/dist/cjs/agentic/telemetry/CognitiveSynthesizer.js +26 -12
- package/dist/cjs/agentic/telemetry/EventHarvester.js +3 -2
- package/dist/cjs/agentic/telemetry/ResearchAlchemist.js +5 -2
- package/dist/cjs/cache/cache-manager.js +7 -4
- package/dist/cjs/cli/commands/analyze.js +5 -4
- package/dist/cjs/cli/commands/generate.js +81 -44
- package/dist/cjs/cli/commands/init.js +7 -3
- package/dist/cjs/cli/commands/inspect.js +139 -36
- package/dist/cjs/cli/commands/migrate.js +5 -4
- package/dist/cjs/cli/commands/optimize.js +4 -4
- package/dist/cjs/cli/commands/status.js +9 -7
- package/dist/cjs/cli/commands/watch.js +7 -6
- package/dist/cjs/cli/index.js +2 -2
- package/dist/cjs/cli/ui/spinner.d.ts +15 -0
- package/dist/cjs/cli/ui/spinner.js +76 -0
- package/dist/cjs/dialect/database-introspector.js +3 -1
- package/dist/cjs/dialect/postgresql/postgresql-driver.js +3 -1
- package/dist/cjs/dialect/postgresql/postgresql-features.js +18 -8
- package/dist/cjs/dialect/postgresql/postgresql-introspector.js +2 -2
- package/dist/cjs/dialect/sqlite/sqlite-auto-indexer.js +47 -33
- package/dist/cjs/dialect/sqlite/sqlite-auto-optimizer.js +8 -7
- package/dist/cjs/dialect/sqlite/sqlite-driver.js +2 -2
- package/dist/cjs/dialect/sqlite/sqlite-introspector.js +15 -12
- package/dist/cjs/edge-runtime/edge-config.js +21 -19
- package/dist/cjs/errors/NoormError.js +22 -20
- package/dist/cjs/helpers/agent-schema.js +2 -0
- package/dist/cjs/helpers/postgresql.js +7 -4
- package/dist/cjs/helpers/schema-evolution.js +31 -6
- package/dist/cjs/index.d.ts +3 -3
- package/dist/cjs/logging/logger.js +8 -4
- package/dist/cjs/migration/data_migrator.js +12 -11
- package/dist/cjs/migration/database_migration_manager.js +17 -13
- package/dist/cjs/migration/schema_differ.js +22 -14
- package/dist/cjs/migration/schema_introspector.js +8 -8
- package/dist/cjs/migration/type_mapper.js +68 -67
- package/dist/cjs/noormme.js +52 -37
- package/dist/cjs/performance/index.js +5 -5
- package/dist/cjs/performance/query-optimizer.js +26 -21
- package/dist/cjs/performance/services/cache-service.js +26 -16
- package/dist/cjs/performance/services/connection-factory.js +28 -23
- package/dist/cjs/performance/services/metrics-collector.js +41 -36
- package/dist/cjs/performance/utils/query-parser.js +15 -16
- package/dist/cjs/relationships/relationship-engine.js +10 -8
- package/dist/cjs/repository/repository-factory.js +97 -38
- package/dist/cjs/schema/core/coordinators/schema-discovery.coordinator.js +1 -3
- package/dist/cjs/schema/core/discovery/relationship-discovery.js +16 -16
- package/dist/cjs/schema/core/discovery/table-metadata-discovery.js +9 -9
- package/dist/cjs/schema/core/discovery/view-discovery.js +5 -4
- package/dist/cjs/schema/core/factories/discovery-factory.js +4 -4
- package/dist/cjs/schema/core/utils/name-generator.js +14 -5
- package/dist/cjs/schema/core/utils/type-mapper.js +24 -24
- package/dist/cjs/schema/dialects/postgresql/postgresql-discovery.coordinator.js +8 -7
- package/dist/cjs/schema/dialects/sqlite/discovery/sqlite-constraint-discovery.js +17 -15
- package/dist/cjs/schema/dialects/sqlite/discovery/sqlite-index-discovery.js +8 -8
- package/dist/cjs/schema/dialects/sqlite/introspection/sqlite-schema-introspector.js +6 -11
- package/dist/cjs/schema/dialects/sqlite/sqlite-discovery.coordinator.js +14 -13
- package/dist/cjs/schema/test/basic-schema-test.js +11 -9
- package/dist/cjs/schema/test/dialect-capabilities.test.js +6 -6
- package/dist/cjs/schema/test/discovery-factory.test.js +2 -2
- package/dist/cjs/schema/test/error-handling.test.js +8 -6
- package/dist/cjs/schema/test/integration.test.js +24 -18
- package/dist/cjs/schema/test/schema-discovery-coordinator.test.js +9 -9
- package/dist/cjs/schema/test/simple-schema-test.js +9 -9
- package/dist/cjs/schema/test/sqlite-discovery-coordinator.test.js +64 -48
- package/dist/cjs/schema/test/test-runner.js +3 -3
- package/dist/cjs/sqlite-migration/index.d.ts +2 -2
- package/dist/cjs/sqlite-migration/sqlite-migration-manager.js +21 -17
- package/dist/cjs/sqlite-migration/sqlite-migration-provider.js +38 -34
- package/dist/cjs/testing/test-utils.js +36 -34
- package/dist/cjs/types/index.d.ts +5 -2
- package/dist/cjs/types/index.js +6 -3
- package/dist/cjs/types/type-generator.js +46 -42
- package/dist/cjs/util/safe-sql-helpers.js +1 -1
- package/dist/cjs/util/security-validator.js +20 -9
- package/dist/cjs/utils/errorHelpers.js +20 -10
- package/dist/cjs/watch/schema-watcher.js +22 -23
- package/dist/esm/agentic/ActionJournal.js +13 -9
- package/dist/esm/agentic/CapabilityManager.js +35 -21
- package/dist/esm/agentic/CognitiveRepository.js +19 -9
- package/dist/esm/agentic/ContextBuffer.js +24 -12
- package/dist/esm/agentic/Cortex.js +11 -4
- package/dist/esm/agentic/EpisodicMemory.js +7 -5
- package/dist/esm/agentic/PersonaManager.js +16 -8
- package/dist/esm/agentic/PolicyEnforcer.js +31 -12
- package/dist/esm/agentic/ResourceMonitor.js +4 -4
- package/dist/esm/agentic/SessionCompressor.js +22 -14
- package/dist/esm/agentic/SessionManager.js +36 -18
- package/dist/esm/agentic/VectorIndexer.js +22 -18
- package/dist/esm/agentic/improvement/AblationEngine.js +22 -15
- package/dist/esm/agentic/improvement/ActionRefiner.js +12 -10
- package/dist/esm/agentic/improvement/ConflictResolver.js +5 -5
- package/dist/esm/agentic/improvement/CortexJanitor.js +30 -9
- package/dist/esm/agentic/improvement/CuriosityEngine.js +27 -23
- package/dist/esm/agentic/improvement/EvolutionRitual.js +4 -4
- package/dist/esm/agentic/improvement/EvolutionaryPilot.js +16 -6
- package/dist/esm/agentic/improvement/GoalArchitect.d.ts +2 -2
- package/dist/esm/agentic/improvement/GoalArchitect.js +20 -18
- package/dist/esm/agentic/improvement/GovernanceManager.js +19 -11
- package/dist/esm/agentic/improvement/HiveLink.js +22 -15
- package/dist/esm/agentic/improvement/KnowledgeDistiller.js +48 -32
- package/dist/esm/agentic/improvement/RecursiveReasoner.js +40 -17
- package/dist/esm/agentic/improvement/ReflectionEngine.js +10 -8
- package/dist/esm/agentic/improvement/RitualOrchestrator.js +28 -22
- package/dist/esm/agentic/improvement/RuleEngine.js +22 -17
- package/dist/esm/agentic/improvement/SelfEvolution.js +24 -18
- package/dist/esm/agentic/improvement/SelfTestRegistry.js +18 -15
- package/dist/esm/agentic/improvement/SkillSynthesizer.js +42 -27
- package/dist/esm/agentic/improvement/SovereignMetrics.js +19 -17
- package/dist/esm/agentic/improvement/StrategicPlanner.js +120 -55
- package/dist/esm/agentic/telemetry/CognitiveSynthesizer.js +26 -12
- package/dist/esm/agentic/telemetry/EventHarvester.js +3 -2
- package/dist/esm/agentic/telemetry/ResearchAlchemist.js +5 -2
- package/dist/esm/cache/cache-manager.js +7 -4
- package/dist/esm/cli/commands/analyze.js +5 -4
- package/dist/esm/cli/commands/generate.js +82 -45
- package/dist/esm/cli/commands/init.js +8 -4
- package/dist/esm/cli/commands/inspect.js +140 -37
- package/dist/esm/cli/commands/migrate.js +5 -4
- package/dist/esm/cli/commands/optimize.js +4 -4
- package/dist/esm/cli/commands/status.js +9 -7
- package/dist/esm/cli/commands/watch.js +7 -6
- package/dist/esm/cli/index.js +2 -2
- package/dist/esm/cli/ui/spinner.d.ts +15 -0
- package/dist/esm/cli/ui/spinner.js +70 -0
- package/dist/esm/dialect/database-introspector.js +3 -1
- package/dist/esm/dialect/postgresql/postgresql-driver.js +3 -1
- package/dist/esm/dialect/postgresql/postgresql-features.js +18 -8
- package/dist/esm/dialect/postgresql/postgresql-introspector.js +2 -2
- package/dist/esm/dialect/sqlite/sqlite-auto-indexer.js +47 -33
- package/dist/esm/dialect/sqlite/sqlite-auto-optimizer.js +8 -7
- package/dist/esm/dialect/sqlite/sqlite-driver.js +2 -2
- package/dist/esm/dialect/sqlite/sqlite-introspector.js +15 -12
- package/dist/esm/dynamic/dynamic.js +1 -1
- package/dist/esm/edge-runtime/edge-config.js +21 -19
- package/dist/esm/errors/NoormError.js +22 -20
- package/dist/esm/helpers/agent-schema.js +2 -0
- package/dist/esm/helpers/postgresql.js +7 -4
- package/dist/esm/helpers/schema-evolution.js +31 -6
- package/dist/esm/index.d.ts +3 -3
- package/dist/esm/index.js +2 -2
- package/dist/esm/logging/logger.js +8 -4
- package/dist/esm/migration/data_migrator.js +12 -11
- package/dist/esm/migration/database_migration_manager.js +18 -14
- package/dist/esm/migration/schema_differ.js +22 -14
- package/dist/esm/migration/schema_introspector.js +8 -8
- package/dist/esm/migration/type_mapper.js +68 -67
- package/dist/esm/noormme.js +52 -37
- package/dist/esm/performance/index.js +5 -5
- package/dist/esm/performance/query-optimizer.js +26 -21
- package/dist/esm/performance/services/cache-service.js +26 -16
- package/dist/esm/performance/services/connection-factory.js +28 -23
- package/dist/esm/performance/services/metrics-collector.js +41 -36
- package/dist/esm/performance/utils/query-parser.js +15 -16
- package/dist/esm/raw-builder/sql.js +1 -1
- package/dist/esm/relationships/relationship-engine.js +10 -8
- package/dist/esm/repository/repository-factory.js +98 -39
- package/dist/esm/schema/builders/alter-table-add-index-builder.js +1 -1
- package/dist/esm/schema/builders/create-index-builder.js +2 -2
- package/dist/esm/schema/core/coordinators/schema-discovery.coordinator.js +1 -3
- package/dist/esm/schema/core/discovery/relationship-discovery.js +16 -16
- package/dist/esm/schema/core/discovery/table-metadata-discovery.js +9 -9
- package/dist/esm/schema/core/discovery/view-discovery.js +5 -4
- package/dist/esm/schema/core/factories/discovery-factory.js +4 -4
- package/dist/esm/schema/core/utils/name-generator.js +14 -5
- package/dist/esm/schema/core/utils/type-mapper.js +24 -24
- package/dist/esm/schema/dialects/postgresql/postgresql-discovery.coordinator.js +8 -7
- package/dist/esm/schema/dialects/sqlite/discovery/sqlite-constraint-discovery.js +17 -15
- package/dist/esm/schema/dialects/sqlite/discovery/sqlite-index-discovery.js +8 -8
- package/dist/esm/schema/dialects/sqlite/introspection/sqlite-schema-introspector.js +6 -11
- package/dist/esm/schema/dialects/sqlite/sqlite-discovery.coordinator.js +14 -13
- package/dist/esm/schema/test/basic-schema-test.js +11 -9
- package/dist/esm/schema/test/dialect-capabilities.test.js +6 -6
- package/dist/esm/schema/test/discovery-factory.test.js +2 -2
- package/dist/esm/schema/test/error-handling.test.js +8 -6
- package/dist/esm/schema/test/integration.test.js +24 -18
- package/dist/esm/schema/test/schema-discovery-coordinator.test.js +9 -9
- package/dist/esm/schema/test/simple-schema-test.js +9 -9
- package/dist/esm/schema/test/sqlite-discovery-coordinator.test.js +64 -48
- package/dist/esm/schema/test/test-runner.js +3 -3
- package/dist/esm/sqlite-migration/index.d.ts +2 -2
- package/dist/esm/sqlite-migration/sqlite-migration-manager.js +21 -17
- package/dist/esm/sqlite-migration/sqlite-migration-provider.js +38 -34
- package/dist/esm/testing/test-utils.js +36 -34
- package/dist/esm/types/index.d.ts +5 -2
- package/dist/esm/types/index.js +6 -3
- package/dist/esm/types/type-generator.js +46 -42
- package/dist/esm/util/safe-sql-helpers.js +1 -1
- package/dist/esm/util/security-validator.js +20 -9
- package/dist/esm/utils/errorHelpers.js +21 -11
- package/dist/esm/watch/schema-watcher.js +22 -23
- package/package.json +40 -44
|
@@ -31,7 +31,7 @@ export class SQLiteAutoOptimizer {
|
|
|
31
31
|
journalMode: 'WAL',
|
|
32
32
|
synchronous: 'NORMAL',
|
|
33
33
|
cacheSize: -64000, // 64MB cache
|
|
34
|
-
tempStore: 'MEMORY'
|
|
34
|
+
tempStore: 'MEMORY',
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
@@ -39,7 +39,7 @@ export class SQLiteAutoOptimizer {
|
|
|
39
39
|
*/
|
|
40
40
|
async analyzeDatabase(db) {
|
|
41
41
|
try {
|
|
42
|
-
const [pageCount, pageSize, freelistCount, schemaVersion, userVersion, applicationId, cacheSize, synchronous, journalMode, autoVacuum, tempStore, foreignKeys] = await Promise.all([
|
|
42
|
+
const [pageCount, pageSize, freelistCount, schemaVersion, userVersion, applicationId, cacheSize, synchronous, journalMode, autoVacuum, tempStore, foreignKeys,] = await Promise.all([
|
|
43
43
|
this.getPragmaValue(db, 'page_count'),
|
|
44
44
|
this.getPragmaValue(db, 'page_size'),
|
|
45
45
|
this.getPragmaValue(db, 'freelist_count'),
|
|
@@ -51,7 +51,7 @@ export class SQLiteAutoOptimizer {
|
|
|
51
51
|
this.getPragmaValue(db, 'journal_mode'),
|
|
52
52
|
this.getPragmaValue(db, 'auto_vacuum'),
|
|
53
53
|
this.getPragmaValue(db, 'temp_store'),
|
|
54
|
-
this.getPragmaValue(db, 'foreign_keys')
|
|
54
|
+
this.getPragmaValue(db, 'foreign_keys'),
|
|
55
55
|
]);
|
|
56
56
|
// Run integrity check
|
|
57
57
|
const integrityResult = await sql `PRAGMA integrity_check`.execute(db);
|
|
@@ -70,7 +70,7 @@ export class SQLiteAutoOptimizer {
|
|
|
70
70
|
autoVacuum: Number(autoVacuum),
|
|
71
71
|
tempStore: Number(tempStore),
|
|
72
72
|
foreignKeys: Number(foreignKeys),
|
|
73
|
-
integrityCheck
|
|
73
|
+
integrityCheck,
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
76
|
catch (error) {
|
|
@@ -86,7 +86,7 @@ export class SQLiteAutoOptimizer {
|
|
|
86
86
|
appliedOptimizations: [],
|
|
87
87
|
recommendations: [],
|
|
88
88
|
performanceImpact: 'low',
|
|
89
|
-
warnings: []
|
|
89
|
+
warnings: [],
|
|
90
90
|
};
|
|
91
91
|
try {
|
|
92
92
|
// Analyze current state
|
|
@@ -286,7 +286,7 @@ export class SQLiteAutoOptimizer {
|
|
|
286
286
|
.where('type', '=', 'table')
|
|
287
287
|
.where('name', 'not like', 'sqlite_%')
|
|
288
288
|
.execute();
|
|
289
|
-
return result.map(row => row.name);
|
|
289
|
+
return result.map((row) => row.name);
|
|
290
290
|
}
|
|
291
291
|
catch (error) {
|
|
292
292
|
this.logger.debug('Failed to get table list:', error);
|
|
@@ -332,7 +332,8 @@ export class SQLiteAutoOptimizer {
|
|
|
332
332
|
}
|
|
333
333
|
// Check database size
|
|
334
334
|
const dbSize = metrics.pageCount * metrics.pageSize;
|
|
335
|
-
if (dbSize > 100 * 1024 * 1024) {
|
|
335
|
+
if (dbSize > 100 * 1024 * 1024) {
|
|
336
|
+
// 100MB
|
|
336
337
|
recommendations.push('For large databases, consider using SQLite backup API or .backup command for efficient backups.');
|
|
337
338
|
}
|
|
338
339
|
// Check for active transactions
|
|
@@ -66,7 +66,7 @@ class SqliteConnection {
|
|
|
66
66
|
executeQuery(compiledQuery) {
|
|
67
67
|
const { sql, parameters } = compiledQuery;
|
|
68
68
|
// Convert parameters to SQLite-compatible types
|
|
69
|
-
const sqliteParameters = parameters.map(param => {
|
|
69
|
+
const sqliteParameters = parameters.map((param) => {
|
|
70
70
|
if (param === undefined) {
|
|
71
71
|
return null;
|
|
72
72
|
}
|
|
@@ -99,7 +99,7 @@ class SqliteConnection {
|
|
|
99
99
|
async *streamQuery(compiledQuery, _chunkSize) {
|
|
100
100
|
const { sql, parameters, query } = compiledQuery;
|
|
101
101
|
// Convert parameters to SQLite-compatible types
|
|
102
|
-
const sqliteParameters = parameters.map(param => {
|
|
102
|
+
const sqliteParameters = parameters.map((param) => {
|
|
103
103
|
if (param === undefined) {
|
|
104
104
|
return null;
|
|
105
105
|
}
|
|
@@ -61,12 +61,13 @@ export class SqliteIntrospector extends DatabaseIntrospector {
|
|
|
61
61
|
name: col.name,
|
|
62
62
|
type: col.type,
|
|
63
63
|
nullable: !col.notnull,
|
|
64
|
-
isAutoIncrement: autoIncrementInfo.isAutoIncrement &&
|
|
64
|
+
isAutoIncrement: autoIncrementInfo.isAutoIncrement &&
|
|
65
|
+
col.name === autoIncrementInfo.columnName,
|
|
65
66
|
defaultValue: col.dflt_value,
|
|
66
|
-
isPrimaryKey: col.pk > 0
|
|
67
|
+
isPrimaryKey: col.pk > 0,
|
|
67
68
|
})),
|
|
68
69
|
indexes: [],
|
|
69
|
-
foreignKeys: []
|
|
70
|
+
foreignKeys: [],
|
|
70
71
|
};
|
|
71
72
|
});
|
|
72
73
|
}
|
|
@@ -83,7 +84,7 @@ export class SqliteIntrospector extends DatabaseIntrospector {
|
|
|
83
84
|
return {
|
|
84
85
|
isAutoIncrement: true,
|
|
85
86
|
columnName: autoIncrementMatch[1].replace(/["`]/g, ''),
|
|
86
|
-
type: 'autoincrement'
|
|
87
|
+
type: 'autoincrement',
|
|
87
88
|
};
|
|
88
89
|
}
|
|
89
90
|
// Method 2: Check for INTEGER PRIMARY KEY (implicit auto-increment)
|
|
@@ -92,7 +93,7 @@ export class SqliteIntrospector extends DatabaseIntrospector {
|
|
|
92
93
|
return {
|
|
93
94
|
isAutoIncrement: true,
|
|
94
95
|
columnName: integerPkMatch[1].replace(/["`]/g, ''),
|
|
95
|
-
type: 'rowid'
|
|
96
|
+
type: 'rowid',
|
|
96
97
|
};
|
|
97
98
|
}
|
|
98
99
|
// Method 3: Check columns for INTEGER PRIMARY KEY
|
|
@@ -103,7 +104,7 @@ export class SqliteIntrospector extends DatabaseIntrospector {
|
|
|
103
104
|
return {
|
|
104
105
|
isAutoIncrement: true,
|
|
105
106
|
columnName: pkCol.name,
|
|
106
|
-
type: 'rowid'
|
|
107
|
+
type: 'rowid',
|
|
107
108
|
};
|
|
108
109
|
}
|
|
109
110
|
}
|
|
@@ -113,7 +114,7 @@ export class SqliteIntrospector extends DatabaseIntrospector {
|
|
|
113
114
|
return {
|
|
114
115
|
isAutoIncrement: true,
|
|
115
116
|
columnName: 'rowid',
|
|
116
|
-
type: 'rowid'
|
|
117
|
+
type: 'rowid',
|
|
117
118
|
};
|
|
118
119
|
}
|
|
119
120
|
return { isAutoIncrement: false, columnName: null, type: 'none' };
|
|
@@ -132,7 +133,7 @@ export class SqliteIntrospector extends DatabaseIntrospector {
|
|
|
132
133
|
if (columnsMatch) {
|
|
133
134
|
const columns = columnsMatch[1]
|
|
134
135
|
.split(',')
|
|
135
|
-
.map(col => col.trim().replace(/["`]/g, ''));
|
|
136
|
+
.map((col) => col.trim().replace(/["`]/g, ''));
|
|
136
137
|
constraints.push(...columns);
|
|
137
138
|
}
|
|
138
139
|
}
|
|
@@ -168,7 +169,7 @@ export class SqliteIntrospector extends DatabaseIntrospector {
|
|
|
168
169
|
nullable: !col.notnull,
|
|
169
170
|
defaultValue: col.dflt_value,
|
|
170
171
|
isPrimaryKey: !!col.pk,
|
|
171
|
-
isAutoIncrement: col.type.toLowerCase().includes('integer') && col.pk
|
|
172
|
+
isAutoIncrement: col.type.toLowerCase().includes('integer') && col.pk,
|
|
172
173
|
}));
|
|
173
174
|
}
|
|
174
175
|
catch (error) {
|
|
@@ -189,7 +190,9 @@ export class SqliteIntrospector extends DatabaseIntrospector {
|
|
|
189
190
|
indexes.push({
|
|
190
191
|
name: idx.name,
|
|
191
192
|
unique: !!idx.unique,
|
|
192
|
-
columns: info
|
|
193
|
+
columns: info
|
|
194
|
+
.sort((a, b) => a.seqno - b.seqno)
|
|
195
|
+
.map((c) => c.name),
|
|
193
196
|
});
|
|
194
197
|
}
|
|
195
198
|
catch (e) {
|
|
@@ -197,7 +200,7 @@ export class SqliteIntrospector extends DatabaseIntrospector {
|
|
|
197
200
|
indexes.push({
|
|
198
201
|
name: idx.name,
|
|
199
202
|
unique: !!idx.unique,
|
|
200
|
-
columns: []
|
|
203
|
+
columns: [],
|
|
201
204
|
});
|
|
202
205
|
}
|
|
203
206
|
}
|
|
@@ -217,7 +220,7 @@ export class SqliteIntrospector extends DatabaseIntrospector {
|
|
|
217
220
|
name: `fk_${tableName}_${fk.from}`,
|
|
218
221
|
column: fk.from,
|
|
219
222
|
referencedTable: fk.table,
|
|
220
|
-
referencedColumn: fk.to
|
|
223
|
+
referencedColumn: fk.to,
|
|
221
224
|
}));
|
|
222
225
|
}
|
|
223
226
|
catch (error) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="./dynamic.d.ts" />
|
|
2
2
|
import { DynamicReferenceBuilder } from './dynamic-reference-builder.js';
|
|
3
3
|
import { DynamicTableBuilder } from './dynamic-table-builder.js';
|
|
4
|
-
import { validateColumnReference, validateTableReference } from '../util/security-validator.js';
|
|
4
|
+
import { validateColumnReference, validateTableReference, } from '../util/security-validator.js';
|
|
5
5
|
export class DynamicModule {
|
|
6
6
|
/**
|
|
7
7
|
* Creates a dynamic reference to a column that is not know at compile time.
|
|
@@ -13,19 +13,19 @@ export function getEdgeRuntimeConfig() {
|
|
|
13
13
|
return {
|
|
14
14
|
dialect: 'sqlite',
|
|
15
15
|
connection: {
|
|
16
|
-
database: ':memory:'
|
|
16
|
+
database: ':memory:',
|
|
17
17
|
},
|
|
18
18
|
optimization: {
|
|
19
19
|
enableWALMode: false, // WAL mode not supported in Edge Runtime
|
|
20
20
|
enableForeignKeys: true,
|
|
21
21
|
cacheSize: -2000, // 2MB cache (smaller for Edge Runtime)
|
|
22
22
|
synchronous: 'NORMAL',
|
|
23
|
-
tempStore: 'MEMORY' // Use memory for temporary storage
|
|
23
|
+
tempStore: 'MEMORY', // Use memory for temporary storage
|
|
24
24
|
},
|
|
25
25
|
logging: {
|
|
26
26
|
level: 'error', // Minimal logging for performance
|
|
27
|
-
enabled: false // Disable logging in Edge Runtime
|
|
28
|
-
}
|
|
27
|
+
enabled: false, // Disable logging in Edge Runtime
|
|
28
|
+
},
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
@@ -46,19 +46,19 @@ export function getRuntimeConfig() {
|
|
|
46
46
|
return {
|
|
47
47
|
dialect: 'sqlite',
|
|
48
48
|
connection: {
|
|
49
|
-
database: process.env.DATABASE_URL || './app.db'
|
|
49
|
+
database: process.env.DATABASE_URL || './app.db',
|
|
50
50
|
},
|
|
51
51
|
optimization: {
|
|
52
52
|
enableWALMode: true,
|
|
53
53
|
enableForeignKeys: true,
|
|
54
54
|
cacheSize: -64000, // 64MB cache
|
|
55
55
|
synchronous: 'NORMAL',
|
|
56
|
-
tempStore: 'DEFAULT'
|
|
56
|
+
tempStore: 'DEFAULT',
|
|
57
57
|
},
|
|
58
58
|
logging: {
|
|
59
59
|
level: process.env.NODE_ENV === 'development' ? 'info' : 'error',
|
|
60
|
-
enabled: true
|
|
61
|
-
}
|
|
60
|
+
enabled: true,
|
|
61
|
+
},
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
64
|
/**
|
|
@@ -151,15 +151,15 @@ export function createEdgeMiddleware() {
|
|
|
151
151
|
return new Response(JSON.stringify({
|
|
152
152
|
status: 'healthy',
|
|
153
153
|
runtime: 'edge',
|
|
154
|
-
timestamp: new Date().toISOString()
|
|
154
|
+
timestamp: new Date().toISOString(),
|
|
155
155
|
}), {
|
|
156
|
-
headers: { 'Content-Type': 'application/json' }
|
|
156
|
+
headers: { 'Content-Type': 'application/json' },
|
|
157
157
|
});
|
|
158
158
|
}
|
|
159
159
|
if (pathname === '/api/users' && method === 'GET') {
|
|
160
160
|
const users = await edgeDB.read('users');
|
|
161
161
|
return new Response(JSON.stringify(users), {
|
|
162
|
-
headers: { 'Content-Type': 'application/json' }
|
|
162
|
+
headers: { 'Content-Type': 'application/json' },
|
|
163
163
|
});
|
|
164
164
|
}
|
|
165
165
|
if (pathname === '/api/users' && method === 'POST') {
|
|
@@ -167,11 +167,11 @@ export function createEdgeMiddleware() {
|
|
|
167
167
|
const user = await edgeDB.write('users', data);
|
|
168
168
|
return new Response(JSON.stringify(user), {
|
|
169
169
|
status: 201,
|
|
170
|
-
headers: { 'Content-Type': 'application/json' }
|
|
170
|
+
headers: { 'Content-Type': 'application/json' },
|
|
171
171
|
});
|
|
172
172
|
}
|
|
173
173
|
return new Response('Not found', { status: 404 });
|
|
174
|
-
}
|
|
174
|
+
},
|
|
175
175
|
};
|
|
176
176
|
}
|
|
177
177
|
/**
|
|
@@ -188,13 +188,15 @@ export function createEdgeErrorHandler() {
|
|
|
188
188
|
// Return appropriate response
|
|
189
189
|
return new Response(JSON.stringify({
|
|
190
190
|
error: 'Internal Server Error',
|
|
191
|
-
message: process.env.NODE_ENV === 'development'
|
|
192
|
-
|
|
191
|
+
message: process.env.NODE_ENV === 'development'
|
|
192
|
+
? error.message
|
|
193
|
+
: 'Something went wrong',
|
|
194
|
+
timestamp: new Date().toISOString(),
|
|
193
195
|
}), {
|
|
194
196
|
status: 500,
|
|
195
|
-
headers: { 'Content-Type': 'application/json' }
|
|
197
|
+
headers: { 'Content-Type': 'application/json' },
|
|
196
198
|
});
|
|
197
|
-
}
|
|
199
|
+
},
|
|
198
200
|
};
|
|
199
201
|
}
|
|
200
202
|
/**
|
|
@@ -243,7 +245,7 @@ export class EdgeRuntimeMonitor {
|
|
|
243
245
|
totalOperations,
|
|
244
246
|
metrics,
|
|
245
247
|
timestamp: new Date().toISOString(),
|
|
246
|
-
runtime: 'edge'
|
|
248
|
+
runtime: 'edge',
|
|
247
249
|
};
|
|
248
250
|
}
|
|
249
251
|
}
|
|
@@ -274,5 +276,5 @@ export const EdgeRuntimeUtils = {
|
|
|
274
276
|
/**
|
|
275
277
|
* Create Edge Runtime monitor
|
|
276
278
|
*/
|
|
277
|
-
createMonitor: () => new EdgeRuntimeMonitor()
|
|
279
|
+
createMonitor: () => new EdgeRuntimeMonitor(),
|
|
278
280
|
};
|
|
@@ -27,7 +27,8 @@ export class NoormError extends Error {
|
|
|
27
27
|
if (this.context.suggestion) {
|
|
28
28
|
formatted += `\n Suggestion: ${this.context.suggestion}`;
|
|
29
29
|
}
|
|
30
|
-
if (this.context.availableOptions &&
|
|
30
|
+
if (this.context.availableOptions &&
|
|
31
|
+
this.context.availableOptions.length > 0) {
|
|
31
32
|
formatted += `\n Available options: ${this.context.availableOptions.join(', ')}`;
|
|
32
33
|
}
|
|
33
34
|
if (this.context.originalError) {
|
|
@@ -43,7 +44,7 @@ export class NoormError extends Error {
|
|
|
43
44
|
name: this.name,
|
|
44
45
|
message: this.message,
|
|
45
46
|
context: this.context,
|
|
46
|
-
stack: this.stack
|
|
47
|
+
stack: this.stack,
|
|
47
48
|
};
|
|
48
49
|
}
|
|
49
50
|
}
|
|
@@ -61,7 +62,7 @@ export class TableNotFoundError extends NoormError {
|
|
|
61
62
|
suggestion: availableTables.length > 0
|
|
62
63
|
? `Available tables: ${availableTables.join(', ')}`
|
|
63
64
|
: 'Check your table name or run schema discovery',
|
|
64
|
-
availableOptions: availableTables
|
|
65
|
+
availableOptions: availableTables,
|
|
65
66
|
});
|
|
66
67
|
this.name = 'TableNotFoundError';
|
|
67
68
|
}
|
|
@@ -69,7 +70,7 @@ export class TableNotFoundError extends NoormError {
|
|
|
69
70
|
export class ColumnNotFoundError extends NoormError {
|
|
70
71
|
constructor(columnName, tableName, availableColumns = []) {
|
|
71
72
|
// Find similar column names for better suggestions
|
|
72
|
-
const similarColumns = availableColumns.filter(col => col.toLowerCase().includes(columnName.toLowerCase()) ||
|
|
73
|
+
const similarColumns = availableColumns.filter((col) => col.toLowerCase().includes(columnName.toLowerCase()) ||
|
|
73
74
|
columnName.toLowerCase().includes(col.toLowerCase()) ||
|
|
74
75
|
ColumnNotFoundError.calculateSimilarity(col, columnName) > 0.6);
|
|
75
76
|
let suggestion = 'Check your column name or run schema discovery';
|
|
@@ -83,7 +84,7 @@ export class ColumnNotFoundError extends NoormError {
|
|
|
83
84
|
table: tableName,
|
|
84
85
|
operation: 'column_lookup',
|
|
85
86
|
suggestion: suggestion,
|
|
86
|
-
availableOptions: availableColumns
|
|
87
|
+
availableOptions: availableColumns,
|
|
87
88
|
});
|
|
88
89
|
this.name = 'ColumnNotFoundError';
|
|
89
90
|
}
|
|
@@ -121,7 +122,7 @@ export class ConnectionError extends NoormError {
|
|
|
121
122
|
super(message, {
|
|
122
123
|
operation: 'connection',
|
|
123
124
|
suggestion: 'Check your database connection settings and ensure the database server is running',
|
|
124
|
-
originalError
|
|
125
|
+
originalError,
|
|
125
126
|
});
|
|
126
127
|
this.name = 'ConnectionError';
|
|
127
128
|
}
|
|
@@ -131,7 +132,7 @@ export class DatabaseInitializationError extends NoormError {
|
|
|
131
132
|
super(`Failed to initialize database at ${databasePath}: ${originalError.message}`, {
|
|
132
133
|
operation: 'initialization',
|
|
133
134
|
suggestion: 'Check database permissions, path validity, and connection settings',
|
|
134
|
-
originalError
|
|
135
|
+
originalError,
|
|
135
136
|
});
|
|
136
137
|
this.name = 'DatabaseInitializationError';
|
|
137
138
|
}
|
|
@@ -141,7 +142,7 @@ export class ValidationError extends NoormError {
|
|
|
141
142
|
super(message, {
|
|
142
143
|
operation: 'validation',
|
|
143
144
|
suggestion: 'Check your input data and ensure it matches the expected schema',
|
|
144
|
-
availableOptions: validationIssues
|
|
145
|
+
availableOptions: validationIssues,
|
|
145
146
|
});
|
|
146
147
|
this.name = 'ValidationError';
|
|
147
148
|
}
|
|
@@ -154,7 +155,7 @@ export class RelationshipNotFoundError extends NoormError {
|
|
|
154
155
|
suggestion: availableRelationships.length > 0
|
|
155
156
|
? `Available relationships: ${availableRelationships.join(', ')}`
|
|
156
157
|
: 'No relationships defined for this table',
|
|
157
|
-
availableOptions: availableRelationships
|
|
158
|
+
availableOptions: availableRelationships,
|
|
158
159
|
});
|
|
159
160
|
this.name = 'RelationshipNotFoundError';
|
|
160
161
|
}
|
|
@@ -165,7 +166,7 @@ export class QueryExecutionError extends NoormError {
|
|
|
165
166
|
operation: context?.operation || 'query_execution',
|
|
166
167
|
table: context?.table,
|
|
167
168
|
suggestion: QueryExecutionError.getQuerySuggestion(query, originalError),
|
|
168
|
-
originalError
|
|
169
|
+
originalError,
|
|
169
170
|
});
|
|
170
171
|
this.name = 'QueryExecutionError';
|
|
171
172
|
}
|
|
@@ -195,7 +196,7 @@ export class SchemaDiscoveryError extends NoormError {
|
|
|
195
196
|
table: tableName,
|
|
196
197
|
operation: 'schema_discovery',
|
|
197
198
|
suggestion: 'Check table permissions, table name validity, or database connection',
|
|
198
|
-
originalError
|
|
199
|
+
originalError,
|
|
199
200
|
});
|
|
200
201
|
this.name = 'SchemaDiscoveryError';
|
|
201
202
|
}
|
|
@@ -205,7 +206,7 @@ export class MigrationError extends NoormError {
|
|
|
205
206
|
super(`Migration '${migrationName}' failed${context?.step ? ` at step: ${context.step}` : ''}: ${originalError.message}`, {
|
|
206
207
|
operation: 'migration',
|
|
207
208
|
suggestion: 'Check migration SQL syntax, database permissions, or rollback the migration',
|
|
208
|
-
originalError
|
|
209
|
+
originalError,
|
|
209
210
|
});
|
|
210
211
|
this.name = 'MigrationError';
|
|
211
212
|
}
|
|
@@ -216,7 +217,7 @@ export class TypeGenerationError extends NoormError {
|
|
|
216
217
|
table: tableName,
|
|
217
218
|
operation: 'type_generation',
|
|
218
219
|
suggestion: 'Check table schema, column types, or custom type mappings configuration',
|
|
219
|
-
originalError
|
|
220
|
+
originalError,
|
|
220
221
|
});
|
|
221
222
|
this.name = 'TypeGenerationError';
|
|
222
223
|
}
|
|
@@ -227,24 +228,25 @@ export class TypeGenerationError extends NoormError {
|
|
|
227
228
|
function findSimilarColumns(columns, target) {
|
|
228
229
|
const lowerTarget = target.toLowerCase();
|
|
229
230
|
// First, try exact case-insensitive match
|
|
230
|
-
const exactMatch = columns.find(col => col.toLowerCase() === lowerTarget);
|
|
231
|
+
const exactMatch = columns.find((col) => col.toLowerCase() === lowerTarget);
|
|
231
232
|
if (exactMatch)
|
|
232
233
|
return [exactMatch];
|
|
233
234
|
// Then try substring matches
|
|
234
|
-
const substringMatches = columns.filter(col => col.toLowerCase().includes(lowerTarget) ||
|
|
235
|
+
const substringMatches = columns.filter((col) => col.toLowerCase().includes(lowerTarget) ||
|
|
236
|
+
lowerTarget.includes(col.toLowerCase()));
|
|
235
237
|
if (substringMatches.length > 0) {
|
|
236
238
|
return substringMatches.slice(0, 3); // Return up to 3 matches
|
|
237
239
|
}
|
|
238
240
|
// Finally, try simple Levenshtein-like similarity
|
|
239
|
-
const similarities = columns.map(col => ({
|
|
241
|
+
const similarities = columns.map((col) => ({
|
|
240
242
|
name: col,
|
|
241
|
-
score: calculateSimilarity(lowerTarget, col.toLowerCase())
|
|
243
|
+
score: calculateSimilarity(lowerTarget, col.toLowerCase()),
|
|
242
244
|
}));
|
|
243
245
|
return similarities
|
|
244
|
-
.filter(s => s.score > 0.5) // Only return if similarity > 50%
|
|
246
|
+
.filter((s) => s.score > 0.5) // Only return if similarity > 50%
|
|
245
247
|
.sort((a, b) => b.score - a.score)
|
|
246
248
|
.slice(0, 3)
|
|
247
|
-
.map(s => s.name);
|
|
249
|
+
.map((s) => s.name);
|
|
248
250
|
}
|
|
249
251
|
/**
|
|
250
252
|
* Simple similarity calculation (Dice coefficient)
|
|
@@ -254,7 +256,7 @@ function calculateSimilarity(str1, str2) {
|
|
|
254
256
|
return 1;
|
|
255
257
|
const bigrams1 = getBigrams(str1);
|
|
256
258
|
const bigrams2 = getBigrams(str2);
|
|
257
|
-
const intersection = bigrams1.filter(bigram => bigrams2.includes(bigram));
|
|
259
|
+
const intersection = bigrams1.filter((bigram) => bigrams2.includes(bigram));
|
|
258
260
|
return (2 * intersection.length) / (bigrams1.length + bigrams2.length);
|
|
259
261
|
}
|
|
260
262
|
function getBigrams(str) {
|
|
@@ -101,6 +101,7 @@ export class AgentSchemaHelper {
|
|
|
101
101
|
.addColumn('fact', 'text', (col) => col.notNull())
|
|
102
102
|
.addColumn('confidence', 'real', (col) => col.notNull().defaultTo(1.0))
|
|
103
103
|
.addColumn('source_session_id', 'integer', (col) => col.references(`${sessionsTable}.id`).onDelete('set null'))
|
|
104
|
+
.addColumn('status', 'text', (col) => col.notNull().defaultTo('proposed'))
|
|
104
105
|
.addColumn('tags', 'text')
|
|
105
106
|
.addColumn('metadata', 'text')
|
|
106
107
|
.addColumn('created_at', 'timestamp', (col) => col.notNull())
|
|
@@ -225,6 +226,7 @@ export class AgentSchemaHelper {
|
|
|
225
226
|
.addColumn('last_run', 'timestamp')
|
|
226
227
|
.addColumn('next_run', 'timestamp')
|
|
227
228
|
.addColumn('status', 'text', (col) => col.notNull().defaultTo('pending'))
|
|
229
|
+
.addColumn('locked_until', 'timestamp')
|
|
228
230
|
.addColumn('metadata', 'text')
|
|
229
231
|
.execute();
|
|
230
232
|
// 16. Rules Table
|
|
@@ -51,7 +51,8 @@ export function createPostgresNoormme(poolConfig) {
|
|
|
51
51
|
const database = typeof poolConfig.database === 'string' ? poolConfig.database : '';
|
|
52
52
|
const user = typeof poolConfig.user === 'string' ? poolConfig.user : undefined;
|
|
53
53
|
const password = typeof poolConfig.password === 'string' ? poolConfig.password : undefined;
|
|
54
|
-
const ssl = typeof poolConfig.ssl === 'boolean' ||
|
|
54
|
+
const ssl = typeof poolConfig.ssl === 'boolean' ||
|
|
55
|
+
(poolConfig.ssl && typeof poolConfig.ssl === 'object')
|
|
55
56
|
? poolConfig.ssl
|
|
56
57
|
: undefined;
|
|
57
58
|
const config = {
|
|
@@ -66,9 +67,11 @@ export function createPostgresNoormme(poolConfig) {
|
|
|
66
67
|
pool: {
|
|
67
68
|
max: typeof poolConfig.max === 'number' ? poolConfig.max : undefined,
|
|
68
69
|
min: typeof poolConfig.min === 'number' ? poolConfig.min : undefined,
|
|
69
|
-
idleTimeoutMillis: typeof poolConfig.idleTimeoutMillis === 'number'
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
idleTimeoutMillis: typeof poolConfig.idleTimeoutMillis === 'number'
|
|
71
|
+
? poolConfig.idleTimeoutMillis
|
|
72
|
+
: undefined,
|
|
73
|
+
},
|
|
74
|
+
},
|
|
72
75
|
};
|
|
73
76
|
return new NOORMME(config);
|
|
74
77
|
}
|
|
@@ -16,7 +16,7 @@ export class SchemaEvolutionHelper {
|
|
|
16
16
|
async getStructuralOverview() {
|
|
17
17
|
const introspector = this.db.introspection;
|
|
18
18
|
const tables = await introspector.getTables();
|
|
19
|
-
let overview =
|
|
19
|
+
let overview = 'Current Database Schema Overview:\n\n';
|
|
20
20
|
for (const table of tables) {
|
|
21
21
|
overview += `Table: ${table.name}\n`;
|
|
22
22
|
if (table.columns) {
|
|
@@ -24,7 +24,7 @@ export class SchemaEvolutionHelper {
|
|
|
24
24
|
overview += ` - ${col.name} (${col.type}${col.nullable ? '?' : ''})\n`;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
overview +=
|
|
27
|
+
overview += '\n';
|
|
28
28
|
}
|
|
29
29
|
return overview;
|
|
30
30
|
}
|
|
@@ -61,9 +61,9 @@ export class SchemaEvolutionHelper {
|
|
|
61
61
|
/^CREATE TABLE/i,
|
|
62
62
|
/^CREATE (?:UNIQUE )?INDEX/i,
|
|
63
63
|
/^ALTER TABLE/i,
|
|
64
|
-
/^DROP INDEX/i
|
|
64
|
+
/^DROP INDEX/i,
|
|
65
65
|
];
|
|
66
|
-
const isAllowed = allowedPatterns.some(pattern => pattern.test(d));
|
|
66
|
+
const isAllowed = allowedPatterns.some((pattern) => pattern.test(d));
|
|
67
67
|
if (!isAllowed) {
|
|
68
68
|
throw new Error(`DDL operation not allowed autonomously: ${ddl}`);
|
|
69
69
|
}
|
|
@@ -73,7 +73,32 @@ export class SchemaEvolutionHelper {
|
|
|
73
73
|
for (const id of identifiers) {
|
|
74
74
|
const upId = id.toUpperCase();
|
|
75
75
|
// Skip keywords
|
|
76
|
-
if ([
|
|
76
|
+
if ([
|
|
77
|
+
'CREATE',
|
|
78
|
+
'TABLE',
|
|
79
|
+
'ALTER',
|
|
80
|
+
'ADD',
|
|
81
|
+
'COLUMN',
|
|
82
|
+
'INDEX',
|
|
83
|
+
'UNIQUE',
|
|
84
|
+
'ON',
|
|
85
|
+
'DROP',
|
|
86
|
+
'IF',
|
|
87
|
+
'EXISTS',
|
|
88
|
+
'NOT',
|
|
89
|
+
'NULL',
|
|
90
|
+
'PRIMARY',
|
|
91
|
+
'KEY',
|
|
92
|
+
'TIMESTAMP',
|
|
93
|
+
'TEXT',
|
|
94
|
+
'INTEGER',
|
|
95
|
+
'REAL',
|
|
96
|
+
'BOOLEAN',
|
|
97
|
+
'VARCHAR',
|
|
98
|
+
'REFERENCES',
|
|
99
|
+
'CASCADE',
|
|
100
|
+
'SET',
|
|
101
|
+
].includes(upId)) {
|
|
77
102
|
continue;
|
|
78
103
|
}
|
|
79
104
|
try {
|
|
@@ -81,7 +106,7 @@ export class SchemaEvolutionHelper {
|
|
|
81
106
|
}
|
|
82
107
|
catch (e) {
|
|
83
108
|
// Ignore small errors in validation if it's a known data type or complex expression
|
|
84
|
-
if (!['VARCHAR', 'TIMESTAMP', 'INT', 'TEXT'].some(t => upId.includes(t))) {
|
|
109
|
+
if (!['VARCHAR', 'TIMESTAMP', 'INT', 'TEXT'].some((t) => upId.includes(t))) {
|
|
85
110
|
console.warn(`[SchemaEvolution] Identifier validation warning for "${id}":`, e);
|
|
86
111
|
}
|
|
87
112
|
}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export * from './kysely.js';
|
|
2
2
|
export * from './query-creator.js';
|
|
3
3
|
export * from './expression/expression.js';
|
|
4
|
-
export { expressionBuilder
|
|
5
|
-
export type { ExpressionBuilder
|
|
4
|
+
export { expressionBuilder } from './expression/expression-builder.js';
|
|
5
|
+
export type { ExpressionBuilder } from './expression/expression-builder.js';
|
|
6
6
|
export * from './expression/expression-wrapper.js';
|
|
7
7
|
export * from './query-builder/where-interface.js';
|
|
8
8
|
export * from './query-builder/returning-interface.js';
|
|
@@ -245,7 +245,7 @@ export * from './agentic/improvement/GovernanceManager.js';
|
|
|
245
245
|
export * from './agentic/CognitiveRepository.js';
|
|
246
246
|
export * from './helpers/agent-schema.js';
|
|
247
247
|
export * from './helpers/schema-evolution.js';
|
|
248
|
-
export { NoormError, TableNotFoundError, ColumnNotFoundError, ConnectionError, DatabaseInitializationError, ValidationError, RelationshipNotFoundError, QueryExecutionError, SchemaDiscoveryError, MigrationError, TypeGenerationError } from './errors/NoormError.js';
|
|
248
|
+
export { NoormError, TableNotFoundError, ColumnNotFoundError, ConnectionError, DatabaseInitializationError, ValidationError, RelationshipNotFoundError, QueryExecutionError, SchemaDiscoveryError, MigrationError, TypeGenerationError, } from './errors/NoormError.js';
|
|
249
249
|
export * from './cli/commands/init.js';
|
|
250
250
|
export * from './cli/commands/inspect.js';
|
|
251
251
|
export * from './cli/commands/generate.js';
|
package/dist/esm/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export * from './kysely.js';
|
|
3
3
|
export * from './query-creator.js';
|
|
4
4
|
export * from './expression/expression.js';
|
|
5
|
-
export { expressionBuilder
|
|
5
|
+
export { expressionBuilder } from './expression/expression-builder.js';
|
|
6
6
|
export * from './expression/expression-wrapper.js';
|
|
7
7
|
export * from './query-builder/where-interface.js';
|
|
8
8
|
export * from './query-builder/returning-interface.js';
|
|
@@ -236,7 +236,7 @@ export * from './agentic/CognitiveRepository.js';
|
|
|
236
236
|
export * from './helpers/agent-schema.js';
|
|
237
237
|
export * from './helpers/schema-evolution.js';
|
|
238
238
|
// Error classes
|
|
239
|
-
export { NoormError, TableNotFoundError, ColumnNotFoundError, ConnectionError, DatabaseInitializationError, ValidationError, RelationshipNotFoundError, QueryExecutionError, SchemaDiscoveryError, MigrationError, TypeGenerationError } from './errors/NoormError.js';
|
|
239
|
+
export { NoormError, TableNotFoundError, ColumnNotFoundError, ConnectionError, DatabaseInitializationError, ValidationError, RelationshipNotFoundError, QueryExecutionError, SchemaDiscoveryError, MigrationError, TypeGenerationError, } from './errors/NoormError.js';
|
|
240
240
|
// CLI commands (for programmatic usage)
|
|
241
241
|
export * from './cli/commands/init.js';
|
|
242
242
|
export * from './cli/commands/inspect.js';
|
|
@@ -70,7 +70,7 @@ export class Logger {
|
|
|
70
70
|
sql,
|
|
71
71
|
parameters,
|
|
72
72
|
duration,
|
|
73
|
-
timestamp: Date.now()
|
|
73
|
+
timestamp: Date.now(),
|
|
74
74
|
};
|
|
75
75
|
this.queryLogs.push(queryLog);
|
|
76
76
|
this.queryCount++;
|
|
@@ -118,7 +118,7 @@ export class Logger {
|
|
|
118
118
|
* Get slow queries
|
|
119
119
|
*/
|
|
120
120
|
getSlowQueries(threshold = 1000) {
|
|
121
|
-
return this.queryLogs.filter(log => log.duration > threshold);
|
|
121
|
+
return this.queryLogs.filter((log) => log.duration > threshold);
|
|
122
122
|
}
|
|
123
123
|
/**
|
|
124
124
|
* Clear query logs
|
|
@@ -162,7 +162,11 @@ export class Logger {
|
|
|
162
162
|
const prefix = this.getPrefix(level);
|
|
163
163
|
let logMessage = `[${timestamp}] ${prefix} ${message}`;
|
|
164
164
|
if (args.length > 0) {
|
|
165
|
-
logMessage +=
|
|
165
|
+
logMessage +=
|
|
166
|
+
' ' +
|
|
167
|
+
args
|
|
168
|
+
.map((arg) => typeof arg === 'object' ? JSON.stringify(arg) : String(arg))
|
|
169
|
+
.join(' ');
|
|
166
170
|
}
|
|
167
171
|
logMessage += '\n';
|
|
168
172
|
fs.appendFileSync(this.config.file, logMessage);
|
|
@@ -187,7 +191,7 @@ export class Logger {
|
|
|
187
191
|
queryCount: this.queryCount,
|
|
188
192
|
averageQueryTime: this.getAverageQueryTime(),
|
|
189
193
|
totalQueryTime: this.totalQueryTime,
|
|
190
|
-
slowQueries: this.getSlowQueries().length
|
|
194
|
+
slowQueries: this.getSlowQueries().length,
|
|
191
195
|
};
|
|
192
196
|
}
|
|
193
197
|
/**
|