kythia-core 0.9.4-beta.0 → 0.9.4-beta.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/changelog.md +14 -0
- package/package.json +1 -1
- package/src/Kythia.js +40 -8
- package/src/database/KythiaORM.js +10 -5
package/changelog.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [0.9.4-beta.2](https://github.com/kenndeclouv/kythia-core/compare/v0.9.4-beta.1...v0.9.4-beta.2) (2025-11-10)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### ✨ Added
|
|
9
|
+
|
|
10
|
+
* Enhance configuration validation in Kythia by adding checks for required bot and database settings, defaulting to SQLite if no driver is specified, and improving error logging for missing configurations. ([72148fa](https://github.com/kenndeclouv/kythia-core/commit/72148fa6b29a97da026746eb44fa4b8696744cb5))
|
|
11
|
+
|
|
12
|
+
### [0.9.4-beta.1](https://github.com/kenndeclouv/kythia-core/compare/v0.9.4-beta.0...v0.9.4-beta.1) (2025-11-09)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### ✨ Added
|
|
16
|
+
|
|
17
|
+
* Refactor KythiaORM to sync multiple models in a single operation, improving efficiency and logging. Updated version hashes in model_versions table after sync completion. ([1bc195d](https://github.com/kenndeclouv/kythia-core/commit/1bc195d17d67865d01cb6c0290a2715f876b2451))
|
|
18
|
+
|
|
5
19
|
### 0.9.4-beta.0 (2025-11-04)
|
|
6
20
|
|
|
7
21
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kythia-core",
|
|
3
|
-
"version": "0.9.4-beta.
|
|
3
|
+
"version": "0.9.4-beta.2",
|
|
4
4
|
"description": "Core library for the Kythia main Discord bot: extensible, modular, and scalable foundation for commands, components, and event management.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
package/src/Kythia.js
CHANGED
|
@@ -97,30 +97,62 @@ class Kythia {
|
|
|
97
97
|
* Throws an error if any required config is missing.
|
|
98
98
|
*/
|
|
99
99
|
_checkRequiredConfig() {
|
|
100
|
-
const
|
|
100
|
+
const requiredBotConfig = [
|
|
101
101
|
['bot', 'token'],
|
|
102
102
|
['bot', 'clientId'],
|
|
103
103
|
['bot', 'clientSecret'],
|
|
104
|
+
];
|
|
105
|
+
const missingBotConfigs = [];
|
|
106
|
+
for (const pathArr of requiredBotConfig) {
|
|
107
|
+
let value = this.kythiaConfig;
|
|
108
|
+
for (const key of pathArr) {
|
|
109
|
+
value = value?.[key];
|
|
110
|
+
}
|
|
111
|
+
if (value === undefined || value === null || value === '') {
|
|
112
|
+
missingBotConfigs.push(pathArr.join('.'));
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (!this.kythiaConfig.db) this.kythiaConfig.db = {};
|
|
117
|
+
|
|
118
|
+
let driver = this.kythiaConfig.db.driver;
|
|
119
|
+
if (!driver || driver === '') {
|
|
120
|
+
this.kythiaConfig.db.driver = 'sqlite';
|
|
121
|
+
driver = 'sqlite';
|
|
122
|
+
this.logger.info('💡 DB driver not specified. Defaulting to: sqlite');
|
|
123
|
+
} else {
|
|
124
|
+
driver = driver.toLowerCase();
|
|
125
|
+
this.kythiaConfig.db.driver = driver;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (driver === 'sqlite') {
|
|
129
|
+
if (!this.kythiaConfig.db.name || this.kythiaConfig.db.name === '') {
|
|
130
|
+
this.kythiaConfig.db.name = 'kythiadata.sqlite';
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const requiredDbConfig = [
|
|
104
135
|
['db', 'driver'],
|
|
105
|
-
['db', 'host'],
|
|
106
|
-
['db', 'port'],
|
|
107
136
|
['db', 'name'],
|
|
108
|
-
['db', 'user'],
|
|
109
137
|
];
|
|
110
138
|
|
|
111
|
-
|
|
139
|
+
if (driver !== 'sqlite') {
|
|
140
|
+
requiredDbConfig.push(['db', 'host'], ['db', 'port'], ['db', 'user'], ['db', 'pass']);
|
|
141
|
+
}
|
|
112
142
|
|
|
113
|
-
|
|
143
|
+
const missingDbConfigs = [];
|
|
144
|
+
for (const pathArr of requiredDbConfig) {
|
|
114
145
|
let value = this.kythiaConfig;
|
|
115
146
|
for (const key of pathArr) {
|
|
116
147
|
value = value?.[key];
|
|
117
148
|
}
|
|
118
|
-
|
|
119
149
|
if (value === undefined || value === null || value === '') {
|
|
120
|
-
|
|
150
|
+
missingDbConfigs.push(pathArr.join('.'));
|
|
121
151
|
}
|
|
122
152
|
}
|
|
123
153
|
|
|
154
|
+
const missingConfigs = missingBotConfigs.concat(missingDbConfigs);
|
|
155
|
+
|
|
124
156
|
if (missingConfigs.length > 0) {
|
|
125
157
|
this.logger.error('❌ Required configurations are not set:');
|
|
126
158
|
for (const missing of missingConfigs) {
|
|
@@ -448,10 +448,17 @@ async function KythiaORM({ kythiaInstance, sequelize, KythiaModel, logger, confi
|
|
|
448
448
|
}
|
|
449
449
|
}
|
|
450
450
|
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
451
|
+
const modelNamesToSync = modelsToSync.map(m => m.model.name);
|
|
452
|
+
|
|
453
|
+
logger.info(`🔄 Syncing models via sequelize.sync(): ${modelNamesToSync.join(', ')}...`);
|
|
454
|
+
await sequelize.sync({
|
|
455
|
+
models: modelNamesToSync,
|
|
456
|
+
alter: true,
|
|
457
|
+
});
|
|
458
|
+
logger.info('✅ Model sync complete.');
|
|
454
459
|
|
|
460
|
+
logger.info('💾 Updating version hashes in model_versions table...');
|
|
461
|
+
for (const { model, newHash } of modelsToSync) {
|
|
455
462
|
await sequelize.query(
|
|
456
463
|
`INSERT INTO ${versionTableName} (model_name, version_hash, updated_at)
|
|
457
464
|
VALUES (?, ?, CURRENT_TIMESTAMP)
|
|
@@ -462,8 +469,6 @@ async function KythiaORM({ kythiaInstance, sequelize, KythiaModel, logger, confi
|
|
|
462
469
|
type: sequelize.QueryTypes.INSERT,
|
|
463
470
|
}
|
|
464
471
|
);
|
|
465
|
-
|
|
466
|
-
logger.info(`✅ Synced model: ${model.name} (${newHash})`);
|
|
467
472
|
}
|
|
468
473
|
|
|
469
474
|
logger.info('✨ Database sync completed successfully!');
|