@chromahq/core 0.1.12 → 0.1.14
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/dist/{IJob-aWBqI3FC.js → IJob-ByOJx8qA.js} +8 -2
- package/dist/IJob-ByOJx8qA.js.map +1 -0
- package/dist/{IJob-Bds0eWrM.js → IJob-CoWGJUZM.js} +8 -1
- package/dist/IJob-CoWGJUZM.js.map +1 -0
- package/dist/boot.cjs.js +47 -46
- package/dist/boot.cjs.js.map +1 -1
- package/dist/boot.d.ts +2 -1
- package/dist/boot.es.js +34 -33
- package/dist/boot.es.js.map +1 -1
- package/dist/index.cjs.js +4 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.es.js +4 -3
- package/dist/index.es.js.map +1 -1
- package/package.json +1 -1
- package/dist/IJob-Bds0eWrM.js.map +0 -1
- package/dist/IJob-aWBqI3FC.js.map +0 -1
package/dist/boot.d.ts
CHANGED
|
@@ -12,9 +12,10 @@ declare class BootstrapBuilder {
|
|
|
12
12
|
/**
|
|
13
13
|
* Create and start the application
|
|
14
14
|
*/
|
|
15
|
-
create({ keepPortAlive, portName, }?: {
|
|
15
|
+
create({ keepPortAlive, portName, enableLogs, }?: {
|
|
16
16
|
keepPortAlive?: boolean;
|
|
17
17
|
portName?: string;
|
|
18
|
+
enableLogs?: boolean;
|
|
18
19
|
}): Promise<void>;
|
|
19
20
|
}
|
|
20
21
|
|
package/dist/boot.es.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
const container = new Container({
|
|
5
|
-
defaultScope: "Singleton"
|
|
6
|
-
});
|
|
1
|
+
import { J as JobState, c as container, T as TOKENS } from './IJob-ByOJx8qA.js';
|
|
2
|
+
import '@inversifyjs/container';
|
|
7
3
|
|
|
8
4
|
class MiddlewareRegistryClass {
|
|
9
5
|
constructor() {
|
|
@@ -1144,9 +1140,9 @@ class ApplicationBootstrap {
|
|
|
1144
1140
|
* Add a store definition to be initialized
|
|
1145
1141
|
*/
|
|
1146
1142
|
withStore(storeDefinition) {
|
|
1147
|
-
if (storeDefinition && storeDefinition.
|
|
1143
|
+
if (storeDefinition && storeDefinition.def && storeDefinition.store) {
|
|
1148
1144
|
this.storeDefinitions.push(storeDefinition);
|
|
1149
|
-
this.logger.debug(`\u{1F4E6} Added store definition: ${storeDefinition.name}`);
|
|
1145
|
+
this.logger.debug(`\u{1F4E6} Added store definition: ${storeDefinition.def.name}`);
|
|
1150
1146
|
}
|
|
1151
1147
|
return this;
|
|
1152
1148
|
}
|
|
@@ -1154,9 +1150,7 @@ class ApplicationBootstrap {
|
|
|
1154
1150
|
* Add multiple store definitions to be initialized
|
|
1155
1151
|
*/
|
|
1156
1152
|
withStores(storeDefinitions) {
|
|
1157
|
-
|
|
1158
|
-
this.withStore(store);
|
|
1159
|
-
}
|
|
1153
|
+
storeDefinitions.forEach((store) => this.withStore(store));
|
|
1160
1154
|
return this;
|
|
1161
1155
|
}
|
|
1162
1156
|
/**
|
|
@@ -1164,9 +1158,11 @@ class ApplicationBootstrap {
|
|
|
1164
1158
|
*/
|
|
1165
1159
|
async create({
|
|
1166
1160
|
keepPortAlive = false,
|
|
1167
|
-
portName
|
|
1161
|
+
portName,
|
|
1162
|
+
enableLogs = true
|
|
1168
1163
|
}) {
|
|
1169
1164
|
try {
|
|
1165
|
+
this.logger = new BootstrapLogger(enableLogs);
|
|
1170
1166
|
this.logger.info("\u{1F680} Starting Chroma application bootstrap...");
|
|
1171
1167
|
await this.discoverAndInitializeStores();
|
|
1172
1168
|
await this.discoverServices();
|
|
@@ -1214,7 +1210,7 @@ class ApplicationBootstrap {
|
|
|
1214
1210
|
const ServiceClass = module?.default;
|
|
1215
1211
|
if (!ServiceClass || typeof ServiceClass !== "function") {
|
|
1216
1212
|
this.logger.warn(
|
|
1217
|
-
`\u26A0\uFE0F Skipping invalid service module - no default export or not a constructor`
|
|
1213
|
+
`\u26A0\uFE0F Skipping invalid service module - no default export or not a constructor` + module
|
|
1218
1214
|
);
|
|
1219
1215
|
continue;
|
|
1220
1216
|
}
|
|
@@ -1245,25 +1241,20 @@ class ApplicationBootstrap {
|
|
|
1245
1241
|
return;
|
|
1246
1242
|
}
|
|
1247
1243
|
this.logger.info(`Initializing ${this.storeDefinitions.length} store(s)...`);
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
isFirstStore = false;
|
|
1258
|
-
}
|
|
1259
|
-
this.registerMessageClass(classes.GetStoreStateMessage, `store:${store.name}:getState`);
|
|
1260
|
-
this.registerMessageClass(classes.SetStoreStateMessage, `store:${store.name}:setState`);
|
|
1261
|
-
this.registerMessageClass(
|
|
1262
|
-
classes.SubscribeToStoreMessage,
|
|
1263
|
-
`store:${store.name}:subscribe`
|
|
1264
|
-
);
|
|
1265
|
-
this.logger.debug(`\u2705 Initialized store: ${store.name}`);
|
|
1244
|
+
let isFirstStore = true;
|
|
1245
|
+
for (const store of this.storeDefinitions) {
|
|
1246
|
+
const diKey = `CentralStore:${store.name}`;
|
|
1247
|
+
const storeInstance = store.store;
|
|
1248
|
+
const classes = store.classes;
|
|
1249
|
+
container.bind(diKey).toConstantValue(storeInstance);
|
|
1250
|
+
if (isFirstStore) {
|
|
1251
|
+
container.bind(TOKENS.Store).toConstantValue(storeInstance);
|
|
1252
|
+
isFirstStore = false;
|
|
1266
1253
|
}
|
|
1254
|
+
this.registerMessageClass(classes.GetStoreStateMessage, `store:${store.name}:getState`);
|
|
1255
|
+
this.registerMessageClass(classes.SetStoreStateMessage, `store:${store.name}:setState`);
|
|
1256
|
+
this.registerMessageClass(classes.SubscribeToStoreMessage, `store:${store.name}:subscribe`);
|
|
1257
|
+
this.logger.debug(`\u2705 Initialized store: ${store.name}`);
|
|
1267
1258
|
}
|
|
1268
1259
|
this.logger.success(`\u2705 Initialized ${this.storeDefinitions.length} store(s)`);
|
|
1269
1260
|
} catch (error) {
|
|
@@ -1497,25 +1488,34 @@ class ApplicationBootstrap {
|
|
|
1497
1488
|
}
|
|
1498
1489
|
}
|
|
1499
1490
|
class BootstrapLogger {
|
|
1491
|
+
constructor(enableLogs = true) {
|
|
1492
|
+
this.enableLogs = enableLogs;
|
|
1493
|
+
}
|
|
1500
1494
|
info(message, context) {
|
|
1495
|
+
if (!this.enableLogs) return;
|
|
1501
1496
|
console.log(message);
|
|
1502
1497
|
if (context) console.log(" ", context);
|
|
1503
1498
|
}
|
|
1504
1499
|
success(message) {
|
|
1500
|
+
if (!this.enableLogs) return;
|
|
1505
1501
|
console.log(message);
|
|
1506
1502
|
}
|
|
1507
1503
|
warn(message) {
|
|
1504
|
+
if (!this.enableLogs) return;
|
|
1508
1505
|
console.warn(message);
|
|
1509
1506
|
}
|
|
1510
1507
|
error(message, error) {
|
|
1508
|
+
if (!this.enableLogs) return;
|
|
1511
1509
|
console.error(message);
|
|
1512
1510
|
if (error) console.error(" ", error);
|
|
1513
1511
|
}
|
|
1514
1512
|
debug(message, context) {
|
|
1513
|
+
if (!this.enableLogs) return;
|
|
1515
1514
|
console.debug(message);
|
|
1516
1515
|
if (context) console.debug(" ", context);
|
|
1517
1516
|
}
|
|
1518
1517
|
divider() {
|
|
1518
|
+
if (!this.enableLogs) return;
|
|
1519
1519
|
console.log("=".repeat(50));
|
|
1520
1520
|
}
|
|
1521
1521
|
}
|
|
@@ -1545,9 +1545,10 @@ class BootstrapBuilder {
|
|
|
1545
1545
|
*/
|
|
1546
1546
|
async create({
|
|
1547
1547
|
keepPortAlive = false,
|
|
1548
|
-
portName
|
|
1548
|
+
portName,
|
|
1549
|
+
enableLogs = true
|
|
1549
1550
|
} = {}) {
|
|
1550
|
-
await this.app.create({ keepPortAlive, portName });
|
|
1551
|
+
await this.app.create({ keepPortAlive, portName, enableLogs });
|
|
1551
1552
|
}
|
|
1552
1553
|
}
|
|
1553
1554
|
|