nanodb-orm 0.0.1
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 +21 -0
- package/README.md +288 -0
- package/dist/constants/index.d.ts +59 -0
- package/dist/constants/index.d.ts.map +1 -0
- package/dist/constants/index.js +67 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/core/config.d.ts +17 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +40 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/connection.d.ts +29 -0
- package/dist/core/connection.d.ts.map +1 -0
- package/dist/core/connection.js +77 -0
- package/dist/core/connection.js.map +1 -0
- package/dist/core/index.d.ts +7 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +26 -0
- package/dist/core/index.js.map +1 -0
- package/dist/example.d.ts +67 -0
- package/dist/example.d.ts.map +1 -0
- package/dist/example.js +86 -0
- package/dist/example.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +41 -0
- package/dist/index.js.map +1 -0
- package/dist/init.d.ts +28 -0
- package/dist/init.d.ts.map +1 -0
- package/dist/init.js +63 -0
- package/dist/init.js.map +1 -0
- package/dist/types/errors.d.ts +23 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/errors.js +46 -0
- package/dist/types/errors.js.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +23 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/types.d.ts +30 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/types.js +6 -0
- package/dist/types/types.js.map +1 -0
- package/dist/utils/index.d.ts +10 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +18 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger.d.ts +26 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +41 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/migrations.d.ts +94 -0
- package/dist/utils/migrations.d.ts.map +1 -0
- package/dist/utils/migrations.js +440 -0
- package/dist/utils/migrations.js.map +1 -0
- package/dist/utils/schema-introspection.d.ts +183 -0
- package/dist/utils/schema-introspection.d.ts.map +1 -0
- package/dist/utils/schema-introspection.js +501 -0
- package/dist/utils/schema-introspection.js.map +1 -0
- package/dist/utils/seeds.d.ts +51 -0
- package/dist/utils/seeds.d.ts.map +1 -0
- package/dist/utils/seeds.js +209 -0
- package/dist/utils/seeds.js.map +1 -0
- package/dist/utils/sync.d.ts +57 -0
- package/dist/utils/sync.d.ts.map +1 -0
- package/dist/utils/sync.js +221 -0
- package/dist/utils/sync.js.map +1 -0
- package/package.json +53 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example usage of nanodb-orm package
|
|
3
|
+
* This file demonstrates how to use the database package in your application
|
|
4
|
+
*/
|
|
5
|
+
declare const exampleTables: {
|
|
6
|
+
users: {
|
|
7
|
+
id: {
|
|
8
|
+
dataType: string;
|
|
9
|
+
primary: boolean;
|
|
10
|
+
autoIncrement: boolean;
|
|
11
|
+
notNull: boolean;
|
|
12
|
+
};
|
|
13
|
+
name: {
|
|
14
|
+
dataType: string;
|
|
15
|
+
notNull: boolean;
|
|
16
|
+
};
|
|
17
|
+
age: {
|
|
18
|
+
dataType: string;
|
|
19
|
+
notNull: boolean;
|
|
20
|
+
};
|
|
21
|
+
email: {
|
|
22
|
+
dataType: string;
|
|
23
|
+
notNull: boolean;
|
|
24
|
+
unique: boolean;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
posts: {
|
|
28
|
+
id: {
|
|
29
|
+
dataType: string;
|
|
30
|
+
primary: boolean;
|
|
31
|
+
autoIncrement: boolean;
|
|
32
|
+
notNull: boolean;
|
|
33
|
+
};
|
|
34
|
+
title: {
|
|
35
|
+
dataType: string;
|
|
36
|
+
notNull: boolean;
|
|
37
|
+
};
|
|
38
|
+
content: {
|
|
39
|
+
dataType: string;
|
|
40
|
+
notNull: boolean;
|
|
41
|
+
};
|
|
42
|
+
userId: {
|
|
43
|
+
dataType: string;
|
|
44
|
+
notNull: boolean;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
declare const exampleSeedData: {
|
|
49
|
+
users: {
|
|
50
|
+
name: string;
|
|
51
|
+
age: number;
|
|
52
|
+
email: string;
|
|
53
|
+
}[];
|
|
54
|
+
posts: {
|
|
55
|
+
title: string;
|
|
56
|
+
content: string;
|
|
57
|
+
userId: number;
|
|
58
|
+
}[];
|
|
59
|
+
};
|
|
60
|
+
declare const exampleMigrationConfig: {
|
|
61
|
+
preserveData: boolean;
|
|
62
|
+
autoMigrate: boolean;
|
|
63
|
+
dropTables: boolean;
|
|
64
|
+
};
|
|
65
|
+
declare function example(): Promise<void>;
|
|
66
|
+
export { example, exampleTables, exampleSeedData, exampleMigrationConfig };
|
|
67
|
+
//# sourceMappingURL=example.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"example.d.ts","sourceRoot":"","sources":["../example.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAalB,CAAC;AAGF,QAAA,MAAM,eAAe;;;;;;;;;;;CASpB,CAAC;AAGF,QAAA,MAAM,sBAAsB;;;;CAI3B,CAAC;AAEF,iBAAe,OAAO,kBA2CrB;AAOD,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,sBAAsB,EAAE,CAAC"}
|
package/dist/example.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Example usage of nanodb-orm package
|
|
4
|
+
* This file demonstrates how to use the database package in your application
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.exampleMigrationConfig = exports.exampleSeedData = exports.exampleTables = void 0;
|
|
8
|
+
exports.example = example;
|
|
9
|
+
const index_1 = require("./index");
|
|
10
|
+
// Example: Define your Drizzle tables
|
|
11
|
+
const exampleTables = {
|
|
12
|
+
users: {
|
|
13
|
+
id: { dataType: 'integer', primary: true, autoIncrement: true, notNull: true },
|
|
14
|
+
name: { dataType: 'text', notNull: true },
|
|
15
|
+
age: { dataType: 'integer', notNull: true },
|
|
16
|
+
email: { dataType: 'text', notNull: true, unique: true }
|
|
17
|
+
},
|
|
18
|
+
posts: {
|
|
19
|
+
id: { dataType: 'integer', primary: true, autoIncrement: true, notNull: true },
|
|
20
|
+
title: { dataType: 'text', notNull: true },
|
|
21
|
+
content: { dataType: 'text', notNull: true },
|
|
22
|
+
userId: { dataType: 'integer', notNull: true }
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
exports.exampleTables = exampleTables;
|
|
26
|
+
// Example: Define seed data
|
|
27
|
+
const exampleSeedData = {
|
|
28
|
+
users: [
|
|
29
|
+
{ name: 'Alice Johnson', age: 28, email: 'alice@example.com' },
|
|
30
|
+
{ name: 'Bob Smith', age: 32, email: 'bob@example.com' }
|
|
31
|
+
],
|
|
32
|
+
posts: [
|
|
33
|
+
{ title: 'Welcome to our blog', content: 'This is our first post!', userId: 1 },
|
|
34
|
+
{ title: 'Getting started', content: 'Here are some tips for beginners.', userId: 2 }
|
|
35
|
+
]
|
|
36
|
+
};
|
|
37
|
+
exports.exampleSeedData = exampleSeedData;
|
|
38
|
+
// Example: Migration configuration
|
|
39
|
+
const exampleMigrationConfig = {
|
|
40
|
+
preserveData: true, // Always try to preserve existing data
|
|
41
|
+
autoMigrate: true, // Enable automatic migrations
|
|
42
|
+
dropTables: false // Don't drop tables by default
|
|
43
|
+
};
|
|
44
|
+
exports.exampleMigrationConfig = exampleMigrationConfig;
|
|
45
|
+
async function example() {
|
|
46
|
+
try {
|
|
47
|
+
console.log('🚀 Initializing database package...');
|
|
48
|
+
// Initialize the database package
|
|
49
|
+
(0, index_1.initializeDatabase)({
|
|
50
|
+
tables: exampleTables,
|
|
51
|
+
seedData: exampleSeedData,
|
|
52
|
+
migrationConfig: exampleMigrationConfig
|
|
53
|
+
});
|
|
54
|
+
console.log('✅ Database package initialized successfully!');
|
|
55
|
+
// Setup the database (create tables, run migrations, seed data)
|
|
56
|
+
console.log('🔧 Setting up database...');
|
|
57
|
+
await index_1.DatabaseSync.setup();
|
|
58
|
+
console.log('✅ Database setup completed!');
|
|
59
|
+
// Example: Schema introspection
|
|
60
|
+
console.log('🔍 Analyzing schema...');
|
|
61
|
+
const tableNames = index_1.SchemaIntrospection.getAllTableNames();
|
|
62
|
+
console.log('📊 Tables found:', tableNames);
|
|
63
|
+
const schemaStats = index_1.SchemaIntrospection.getSchemaStats();
|
|
64
|
+
console.log('📈 Schema statistics:', {
|
|
65
|
+
totalTables: schemaStats.totalTables,
|
|
66
|
+
tableNames: schemaStats.tableNames
|
|
67
|
+
});
|
|
68
|
+
// Example: Check database health
|
|
69
|
+
const healthCheck = await index_1.DatabaseSync.healthCheck();
|
|
70
|
+
console.log('🎯 Database health:', healthCheck.healthy);
|
|
71
|
+
console.log('📊 Database info:', {
|
|
72
|
+
tables: healthCheck.tables,
|
|
73
|
+
totalRecords: healthCheck.totalRecords,
|
|
74
|
+
schemaValid: healthCheck.schemaValid
|
|
75
|
+
});
|
|
76
|
+
console.log('🎉 Example completed successfully!');
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
console.error('❌ Error in example:', error);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
// Run the example if this file is executed directly
|
|
83
|
+
if (require.main === module) {
|
|
84
|
+
example();
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=example.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"example.js","sourceRoot":"","sources":["../example.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAyF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AAO,CAAC,CAAC;QACxD,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE;YAC/B,MAAM,EAAE,WAAW,CAAC,MAAM;YAC1B,YAAY,EAAE,WAAW,CAAC,YAAY;YACtC,WAAW,EAAE,WAAW,CAAC,WAAW;SACrC,CAAC,CAAC;QAEH,OAAO,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;IAEpD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,qBAAqB,EAAE,KAAK,CAAC,CAAC;IAC9C,CAAC;AACH,CAAC;AAED,oDAAoD;AACpD,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;IAC5B,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Database module exports
|
|
3
|
+
* Main entry point for all database-related functionality
|
|
4
|
+
*
|
|
5
|
+
* @fileoverview Organized database module with proper separation of concerns
|
|
6
|
+
* @version 2.0.0
|
|
7
|
+
* @author Database Team
|
|
8
|
+
*/
|
|
9
|
+
export * from './core';
|
|
10
|
+
export * from './utils';
|
|
11
|
+
export * from './init';
|
|
12
|
+
export { DatabaseError, SchemaError, SyncError, ConnectionError, ValidationError } from './types/errors';
|
|
13
|
+
export * from './constants';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,cAAc,QAAQ,CAAC;AAGvB,cAAc,SAAS,CAAC;AAGxB,cAAc,QAAQ,CAAC;AAGvB,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,SAAS,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGzG,cAAc,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Database module exports
|
|
4
|
+
* Main entry point for all database-related functionality
|
|
5
|
+
*
|
|
6
|
+
* @fileoverview Organized database module with proper separation of concerns
|
|
7
|
+
* @version 2.0.0
|
|
8
|
+
* @author Database Team
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
22
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.ValidationError = exports.ConnectionError = exports.SyncError = exports.SchemaError = exports.DatabaseError = void 0;
|
|
26
|
+
// Core database functionality
|
|
27
|
+
__exportStar(require("./core"), exports);
|
|
28
|
+
// Database utilities and services
|
|
29
|
+
__exportStar(require("./utils"), exports);
|
|
30
|
+
// Database initialization for npm package usage
|
|
31
|
+
__exportStar(require("./init"), exports);
|
|
32
|
+
// Explicit error exports for better IDE support
|
|
33
|
+
var errors_1 = require("./types/errors");
|
|
34
|
+
Object.defineProperty(exports, "DatabaseError", { enumerable: true, get: function () { return errors_1.DatabaseError; } });
|
|
35
|
+
Object.defineProperty(exports, "SchemaError", { enumerable: true, get: function () { return errors_1.SchemaError; } });
|
|
36
|
+
Object.defineProperty(exports, "SyncError", { enumerable: true, get: function () { return errors_1.SyncError; } });
|
|
37
|
+
Object.defineProperty(exports, "ConnectionError", { enumerable: true, get: function () { return errors_1.ConnectionError; } });
|
|
38
|
+
Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return errors_1.ValidationError; } });
|
|
39
|
+
// Constants and configuration values
|
|
40
|
+
__exportStar(require("./constants"), exports);
|
|
41
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;;;;;;;;;;;;;;;AAEH,8BAA8B;AAC9B,yCAAuB;AAEvB,kCAAkC;AAClC,0CAAwB;AAExB,gDAAgD;AAChD,yCAAuB;AAEvB,gDAAgD;AAChD,yCAAyG;AAAhG,uGAAA,aAAa,OAAA;AAAE,qGAAA,WAAW,OAAA;AAAE,mGAAA,SAAS,OAAA;AAAE,yGAAA,eAAe,OAAA;AAAE,yGAAA,eAAe,OAAA;AAEhF,qCAAqC;AACrC,8CAA4B"}
|
package/dist/init.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Database initialization utility
|
|
3
|
+
* Initializes the db package with schema data to work as an npm package
|
|
4
|
+
*/
|
|
5
|
+
export interface MigrationConfig {
|
|
6
|
+
preserveData?: boolean;
|
|
7
|
+
autoMigrate?: boolean;
|
|
8
|
+
dropTables?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface SchemaData {
|
|
11
|
+
tables: Record<string, any>;
|
|
12
|
+
seedData?: Record<string, any[]>;
|
|
13
|
+
migrationConfig?: MigrationConfig;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Initialize the database package with schema data
|
|
17
|
+
* This allows the db package to work independently without direct imports
|
|
18
|
+
*/
|
|
19
|
+
export declare function initializeDatabase(schemaData: SchemaData): void;
|
|
20
|
+
/**
|
|
21
|
+
* Get initialized schema data (for verification)
|
|
22
|
+
*/
|
|
23
|
+
export declare function getSchemaInfo(): {
|
|
24
|
+
tableNames: string[];
|
|
25
|
+
tableCount: number;
|
|
26
|
+
seedDataTables: string[];
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=init.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../init.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,MAAM,WAAW,eAAe;IAC9B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;IACjC,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAwC/D;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI;IAC/B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B,CAMA"}
|
package/dist/init.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Database initialization utility
|
|
4
|
+
* Initializes the db package with schema data to work as an npm package
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.initializeDatabase = initializeDatabase;
|
|
8
|
+
exports.getSchemaInfo = getSchemaInfo;
|
|
9
|
+
const schema_introspection_1 = require("./utils/schema-introspection");
|
|
10
|
+
const seeds_1 = require("./utils/seeds");
|
|
11
|
+
const migrations_1 = require("./utils/migrations");
|
|
12
|
+
const logger_1 = require("./utils/logger");
|
|
13
|
+
/**
|
|
14
|
+
* Initialize the database package with schema data
|
|
15
|
+
* This allows the db package to work independently without direct imports
|
|
16
|
+
*/
|
|
17
|
+
function initializeDatabase(schemaData) {
|
|
18
|
+
try {
|
|
19
|
+
logger_1.logger.info('Initializing database package with schema data...');
|
|
20
|
+
// Derive table names from the tables object
|
|
21
|
+
const tableNames = Object.keys(schemaData.tables);
|
|
22
|
+
// Initialize schema introspection
|
|
23
|
+
schema_introspection_1.SchemaIntrospection.initialize({
|
|
24
|
+
tables: schemaData.tables,
|
|
25
|
+
tableNames: tableNames,
|
|
26
|
+
});
|
|
27
|
+
// Initialize database migrations
|
|
28
|
+
migrations_1.DatabaseMigrations.initialize({
|
|
29
|
+
tables: schemaData.tables,
|
|
30
|
+
tableNames: tableNames,
|
|
31
|
+
migrationConfig: {
|
|
32
|
+
preserveData: true, // Always preserve data by default
|
|
33
|
+
autoMigrate: true, // Default to auto-migration
|
|
34
|
+
dropTables: false, // Default to not dropping tables
|
|
35
|
+
...schemaData.migrationConfig, // Override with any provided config
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
// Initialize database seeds
|
|
39
|
+
seeds_1.DatabaseSeeds.initialize({
|
|
40
|
+
tables: schemaData.tables,
|
|
41
|
+
tableNames: tableNames,
|
|
42
|
+
seedData: schemaData.seedData || {},
|
|
43
|
+
});
|
|
44
|
+
logger_1.logger.info('Database package initialized successfully!');
|
|
45
|
+
logger_1.logger.info(`Loaded ${tableNames.length} tables: ${tableNames.join(', ')}`);
|
|
46
|
+
logger_1.logger.info(`Loaded seed data for ${Object.keys(schemaData.seedData || {}).length} tables`);
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
logger_1.logger.error('Failed to initialize database package:', error);
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Get initialized schema data (for verification)
|
|
55
|
+
*/
|
|
56
|
+
function getSchemaInfo() {
|
|
57
|
+
return {
|
|
58
|
+
tableNames: schema_introspection_1.SchemaIntrospection.getAllTableNames(),
|
|
59
|
+
tableCount: schema_introspection_1.SchemaIntrospection.getTableCount(),
|
|
60
|
+
seedDataTables: Object.keys(seeds_1.DatabaseSeeds['seedData'] || {}),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=init.js.map
|
package/dist/init.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../init.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAuBH,gDAwCC;AAKD,sCAUC;AA5ED,uEAAmE;AACnE,yCAA8C;AAC9C,mDAAwD;AACxD,2CAAwC;AAcxC;;;GAGG;AACH,SAAgB,kBAAkB,CAAC,UAAsB;IACvD,IAAI,CAAC;QACH,eAAM,CAAC,IAAI,CAAC,mDAAmD,CAAC,CAAC;QAEjE,4CAA4C;QAC5C,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAElD,kCAAkC;QAClC,0CAAmB,CAAC,UAAU,CAAC;YAC7B,MAAM,EAAE,UAAU,CAAC,MAAM;YACzB,UAAU,EAAE,UAAU;SACvB,CAAC,CAAC;QAEH,iCAAiC;QACjC,+BAAkB,CAAC,UAAU,CAAC;YAC5B,MAAM,EAAE,UAAU,CAAC,MAAM;YACzB,UAAU,EAAE,UAAU;YACtB,eAAe,EAAE;gBACf,YAAY,EAAE,IAAI,EAAE,kCAAkC;gBACtD,WAAW,EAAE,IAAI,EAAG,4BAA4B;gBAChD,UAAU,EAAE,KAAK,EAAG,iCAAiC;gBACrD,GAAG,UAAU,CAAC,eAAe,EAAE,oCAAoC;aACpE;SACF,CAAC,CAAC;QAEH,4BAA4B;QAC5B,qBAAa,CAAC,UAAU,CAAC;YACvB,MAAM,EAAE,UAAU,CAAC,MAAM;YACzB,UAAU,EAAE,UAAU;YACtB,QAAQ,EAAE,UAAU,CAAC,QAAQ,IAAI,EAAE;SACpC,CAAC,CAAC;QAEH,eAAM,CAAC,IAAI,CAAC,4CAA4C,CAAC,CAAC;QAC1D,eAAM,CAAC,IAAI,CAAC,UAAU,UAAU,CAAC,MAAM,YAAY,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC5E,eAAM,CAAC,IAAI,CAAC,wBAAwB,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,MAAM,SAAS,CAAC,CAAC;IAE9F,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,eAAM,CAAC,KAAK,CAAC,wCAAwC,EAAE,KAAK,CAAC,CAAC;QAC9D,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAgB,aAAa;IAK3B,OAAO;QACL,UAAU,EAAE,0CAAmB,CAAC,gBAAgB,EAAE;QAClD,UAAU,EAAE,0CAAmB,CAAC,aAAa,EAAE;QAC/C,cAAc,EAAE,MAAM,CAAC,IAAI,CAAC,qBAAa,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;KAC7D,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom database error types for better error handling
|
|
3
|
+
*/
|
|
4
|
+
export declare class DatabaseError extends Error {
|
|
5
|
+
readonly operation: string;
|
|
6
|
+
readonly originalError?: Error | undefined;
|
|
7
|
+
constructor(message: string, operation: string, originalError?: Error | undefined);
|
|
8
|
+
}
|
|
9
|
+
export declare class SchemaError extends DatabaseError {
|
|
10
|
+
readonly tableName?: string | undefined;
|
|
11
|
+
constructor(message: string, tableName?: string | undefined, originalError?: Error);
|
|
12
|
+
}
|
|
13
|
+
export declare class SyncError extends DatabaseError {
|
|
14
|
+
constructor(message: string, originalError?: Error);
|
|
15
|
+
}
|
|
16
|
+
export declare class ConnectionError extends DatabaseError {
|
|
17
|
+
constructor(message: string, originalError?: Error);
|
|
18
|
+
}
|
|
19
|
+
export declare class ValidationError extends DatabaseError {
|
|
20
|
+
readonly field?: string | undefined;
|
|
21
|
+
constructor(message: string, field?: string | undefined, originalError?: Error);
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../types/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,qBAAa,aAAc,SAAQ,KAAK;aACO,SAAS,EAAE,MAAM;aAAkB,aAAa,CAAC,EAAE,KAAK;gBAAzF,OAAO,EAAE,MAAM,EAAkB,SAAS,EAAE,MAAM,EAAkB,aAAa,CAAC,EAAE,KAAK,YAAA;CAItG;AAED,qBAAa,WAAY,SAAQ,aAAa;aACC,SAAS,CAAC,EAAE,MAAM;gBAAnD,OAAO,EAAE,MAAM,EAAkB,SAAS,CAAC,EAAE,MAAM,YAAA,EAAE,aAAa,CAAC,EAAE,KAAK;CAIvF;AAED,qBAAa,SAAU,SAAQ,aAAa;gBAC9B,OAAO,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,KAAK;CAInD;AAED,qBAAa,eAAgB,SAAQ,aAAa;gBACpC,OAAO,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,KAAK;CAInD;AAED,qBAAa,eAAgB,SAAQ,aAAa;aACH,KAAK,CAAC,EAAE,MAAM;gBAA/C,OAAO,EAAE,MAAM,EAAkB,KAAK,CAAC,EAAE,MAAM,YAAA,EAAE,aAAa,CAAC,EAAE,KAAK;CAInF"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Custom database error types for better error handling
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ValidationError = exports.ConnectionError = exports.SyncError = exports.SchemaError = exports.DatabaseError = void 0;
|
|
7
|
+
class DatabaseError extends Error {
|
|
8
|
+
constructor(message, operation, originalError) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.operation = operation;
|
|
11
|
+
this.originalError = originalError;
|
|
12
|
+
this.name = 'DatabaseError';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.DatabaseError = DatabaseError;
|
|
16
|
+
class SchemaError extends DatabaseError {
|
|
17
|
+
constructor(message, tableName, originalError) {
|
|
18
|
+
super(message, 'schema', originalError);
|
|
19
|
+
this.tableName = tableName;
|
|
20
|
+
this.name = 'SchemaError';
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.SchemaError = SchemaError;
|
|
24
|
+
class SyncError extends DatabaseError {
|
|
25
|
+
constructor(message, originalError) {
|
|
26
|
+
super(message, 'sync', originalError);
|
|
27
|
+
this.name = 'SyncError';
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.SyncError = SyncError;
|
|
31
|
+
class ConnectionError extends DatabaseError {
|
|
32
|
+
constructor(message, originalError) {
|
|
33
|
+
super(message, 'connection', originalError);
|
|
34
|
+
this.name = 'ConnectionError';
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.ConnectionError = ConnectionError;
|
|
38
|
+
class ValidationError extends DatabaseError {
|
|
39
|
+
constructor(message, field, originalError) {
|
|
40
|
+
super(message, 'validation', originalError);
|
|
41
|
+
this.field = field;
|
|
42
|
+
this.name = 'ValidationError';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.ValidationError = ValidationError;
|
|
46
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../types/errors.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,MAAa,aAAc,SAAQ,KAAK;IACtC,YAAY,OAAe,EAAkB,SAAiB,EAAkB,aAAqB;QACnG,KAAK,C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
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Database types and interfaces
|
|
4
|
+
* TypeScript definitions for database-related functionality
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
18
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
__exportStar(require("./types"), exports);
|
|
22
|
+
__exportStar(require("./errors"), exports);
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../types/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;AAEH,0CAAwB;AACxB,2CAAyB"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Database-related TypeScript interfaces and types
|
|
3
|
+
*/
|
|
4
|
+
export interface DatabaseInfo {
|
|
5
|
+
dbTables: string[];
|
|
6
|
+
schemaTables: string[];
|
|
7
|
+
tableCounts: Record<string, number>;
|
|
8
|
+
connectionUrl: string;
|
|
9
|
+
hasAuth: boolean;
|
|
10
|
+
isSchemaSynced: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface HealthCheckResult {
|
|
13
|
+
isHealthy: boolean;
|
|
14
|
+
missingTables: string[];
|
|
15
|
+
errors: string[];
|
|
16
|
+
}
|
|
17
|
+
export interface SeedData {
|
|
18
|
+
[tableName: string]: Array<Record<string, any>>;
|
|
19
|
+
}
|
|
20
|
+
export interface SyncResult {
|
|
21
|
+
success: boolean;
|
|
22
|
+
message: string;
|
|
23
|
+
timestamp: Date;
|
|
24
|
+
}
|
|
25
|
+
export interface TableInfo {
|
|
26
|
+
name: string;
|
|
27
|
+
exists: boolean;
|
|
28
|
+
rowCount: number;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../types/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,cAAc,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,OAAO,CAAC;IACnB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,MAAM,WAAW,QAAQ;IACvB,CAAC,SAAS,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;CACjD;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../types/types.ts"],"names":[],"mappings":";AAAA;;GAEG"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Database utilities
|
|
3
|
+
* Helper functions and services for database operations
|
|
4
|
+
*/
|
|
5
|
+
export { DatabaseSync } from './sync';
|
|
6
|
+
export { DatabaseMigrations } from './migrations';
|
|
7
|
+
export { DatabaseSeeds } from './seeds';
|
|
8
|
+
export { SchemaIntrospection } from './schema-introspection';
|
|
9
|
+
export { logger } from './logger';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../utils/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Database utilities
|
|
4
|
+
* Helper functions and services for database operations
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.logger = exports.SchemaIntrospection = exports.DatabaseSeeds = exports.DatabaseMigrations = exports.DatabaseSync = void 0;
|
|
8
|
+
var sync_1 = require("./sync");
|
|
9
|
+
Object.defineProperty(exports, "DatabaseSync", { enumerable: true, get: function () { return sync_1.DatabaseSync; } });
|
|
10
|
+
var migrations_1 = require("./migrations");
|
|
11
|
+
Object.defineProperty(exports, "DatabaseMigrations", { enumerable: true, get: function () { return migrations_1.DatabaseMigrations; } });
|
|
12
|
+
var seeds_1 = require("./seeds");
|
|
13
|
+
Object.defineProperty(exports, "DatabaseSeeds", { enumerable: true, get: function () { return seeds_1.DatabaseSeeds; } });
|
|
14
|
+
var schema_introspection_1 = require("./schema-introspection");
|
|
15
|
+
Object.defineProperty(exports, "SchemaIntrospection", { enumerable: true, get: function () { return schema_introspection_1.SchemaIntrospection; } });
|
|
16
|
+
var logger_1 = require("./logger");
|
|
17
|
+
Object.defineProperty(exports, "logger", { enumerable: true, get: function () { return logger_1.logger; } });
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../utils/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+BAAsC;AAA7B,oGAAA,YAAY,OAAA;AACrB,2CAAkD;AAAzC,gHAAA,kBAAkB,OAAA;AAC3B,iCAAwC;AAA/B,sGAAA,aAAa,OAAA;AACtB,+DAA6D;AAApD,2HAAA,mBAAmB,OAAA;AAC5B,mCAAkC;AAAzB,gGAAA,MAAM,OAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simple logging abstraction for database operations
|
|
3
|
+
*/
|
|
4
|
+
export declare enum LogLevel {
|
|
5
|
+
DEBUG = 0,
|
|
6
|
+
INFO = 1,
|
|
7
|
+
WARN = 2,
|
|
8
|
+
ERROR = 3
|
|
9
|
+
}
|
|
10
|
+
export interface Logger {
|
|
11
|
+
debug(message: string, ...args: any[]): void;
|
|
12
|
+
info(message: string, ...args: any[]): void;
|
|
13
|
+
warn(message: string, ...args: any[]): void;
|
|
14
|
+
error(message: string, ...args: any[]): void;
|
|
15
|
+
}
|
|
16
|
+
declare class DatabaseLogger implements Logger {
|
|
17
|
+
private level;
|
|
18
|
+
constructor(level?: LogLevel);
|
|
19
|
+
debug(message: string, ...args: any[]): void;
|
|
20
|
+
info(message: string, ...args: any[]): void;
|
|
21
|
+
warn(message: string, ...args: any[]): void;
|
|
22
|
+
error(message: string, ...args: any[]): void;
|
|
23
|
+
}
|
|
24
|
+
export declare const logger: DatabaseLogger;
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../utils/logger.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,oBAAY,QAAQ;IAClB,KAAK,IAAI;IACT,IAAI,IAAI;IACR,IAAI,IAAI;IACR,KAAK,IAAI;CACV;AAED,MAAM,WAAW,MAAM;IACrB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAC7C,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAC5C,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAC5C,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;CAC9C;AAED,cAAM,cAAe,YAAW,MAAM;IACpC,OAAO,CAAC,KAAK,CAAW;gBAEZ,KAAK,GAAE,QAAwB;IAI3C,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAM5C,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAM3C,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAM3C,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;CAK7C;AAGD,eAAO,MAAM,MAAM,gBAElB,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Simple logging abstraction for database operations
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.logger = exports.LogLevel = void 0;
|
|
7
|
+
var LogLevel;
|
|
8
|
+
(function (LogLevel) {
|
|
9
|
+
LogLevel[LogLevel["DEBUG"] = 0] = "DEBUG";
|
|
10
|
+
LogLevel[LogLevel["INFO"] = 1] = "INFO";
|
|
11
|
+
LogLevel[LogLevel["WARN"] = 2] = "WARN";
|
|
12
|
+
LogLevel[LogLevel["ERROR"] = 3] = "ERROR";
|
|
13
|
+
})(LogLevel || (exports.LogLevel = LogLevel = {}));
|
|
14
|
+
class DatabaseLogger {
|
|
15
|
+
constructor(level = LogLevel.INFO) {
|
|
16
|
+
this.level = level;
|
|
17
|
+
}
|
|
18
|
+
debug(message, ...args) {
|
|
19
|
+
if (this.level <= LogLevel.DEBUG) {
|
|
20
|
+
console.log(`🔍 [DEBUG] ${message}`, ...args);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
info(message, ...args) {
|
|
24
|
+
if (this.level <= LogLevel.INFO) {
|
|
25
|
+
console.log(`ℹ️ [INFO] ${message}`, ...args);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
warn(message, ...args) {
|
|
29
|
+
if (this.level <= LogLevel.WARN) {
|
|
30
|
+
console.warn(`⚠️ [WARN] ${message}`, ...args);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
error(message, ...args) {
|
|
34
|
+
if (this.level <= LogLevel.ERROR) {
|
|
35
|
+
console.error(`❌ [ERROR] ${message}`, ...args);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
// Export default logger instance
|
|
40
|
+
exports.logger = new DatabaseLogger(process.env.NODE_ENV === 'development' ? LogLev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