@chromahq/core 0.1.5 → 0.1.6
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/index.cjs.js +24 -2
- package/dist/index.es.js +24 -2
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1313,16 +1313,38 @@ class ApplicationBootstrap {
|
|
|
1313
1313
|
const constructorString = ServiceClass.toString();
|
|
1314
1314
|
const constructorMatch = constructorString.match(/constructor\s*\(([^)]*)\)/);
|
|
1315
1315
|
if (!constructorMatch) return [];
|
|
1316
|
-
const parameters = constructorMatch[1].split(",").map((param) => param.trim()
|
|
1316
|
+
const parameters = constructorMatch[1].split(",").map((param) => param.trim()).filter((param) => param.length > 0);
|
|
1317
1317
|
const dependencies = [];
|
|
1318
1318
|
for (const param of parameters) {
|
|
1319
|
+
const paramName = param.toLowerCase();
|
|
1320
|
+
if (paramName === "store" || paramName.startsWith("store")) {
|
|
1321
|
+
let storeInstance;
|
|
1322
|
+
if (paramName === "store" && container.isBound("CentralStore")) {
|
|
1323
|
+
storeInstance = container.get("CentralStore");
|
|
1324
|
+
} else {
|
|
1325
|
+
const storeKeyMatch = paramName.match(/^store(.+)$/);
|
|
1326
|
+
if (storeKeyMatch && storeKeyMatch[1]) {
|
|
1327
|
+
const storeName = storeKeyMatch[1].replace(/^([A-Z])/, (m) => m.toLowerCase());
|
|
1328
|
+
const diKey = `CentralStore:${storeName}`;
|
|
1329
|
+
if (container.isBound(diKey)) {
|
|
1330
|
+
storeInstance = container.get(diKey);
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
if (!storeInstance) {
|
|
1335
|
+
this.logger.warn(`\u26A0\uFE0F No store found for parameter "${param}" in ${ServiceClass.name}`);
|
|
1336
|
+
}
|
|
1337
|
+
dependencies.push(storeInstance);
|
|
1338
|
+
continue;
|
|
1339
|
+
}
|
|
1319
1340
|
const matchingService = Array.from(this.serviceRegistry.entries()).find(
|
|
1320
|
-
([name]) => name.toLowerCase() ===
|
|
1341
|
+
([name]) => name.toLowerCase() === paramName
|
|
1321
1342
|
);
|
|
1322
1343
|
if (matchingService) {
|
|
1323
1344
|
dependencies.push(matchingService[1]);
|
|
1324
1345
|
} else {
|
|
1325
1346
|
this.logger.warn(`\u26A0\uFE0F No service found for parameter "${param}" in ${ServiceClass.name}`);
|
|
1347
|
+
dependencies.push(void 0);
|
|
1326
1348
|
}
|
|
1327
1349
|
}
|
|
1328
1350
|
return dependencies;
|
package/dist/index.es.js
CHANGED
|
@@ -1311,16 +1311,38 @@ class ApplicationBootstrap {
|
|
|
1311
1311
|
const constructorString = ServiceClass.toString();
|
|
1312
1312
|
const constructorMatch = constructorString.match(/constructor\s*\(([^)]*)\)/);
|
|
1313
1313
|
if (!constructorMatch) return [];
|
|
1314
|
-
const parameters = constructorMatch[1].split(",").map((param) => param.trim()
|
|
1314
|
+
const parameters = constructorMatch[1].split(",").map((param) => param.trim()).filter((param) => param.length > 0);
|
|
1315
1315
|
const dependencies = [];
|
|
1316
1316
|
for (const param of parameters) {
|
|
1317
|
+
const paramName = param.toLowerCase();
|
|
1318
|
+
if (paramName === "store" || paramName.startsWith("store")) {
|
|
1319
|
+
let storeInstance;
|
|
1320
|
+
if (paramName === "store" && container.isBound("CentralStore")) {
|
|
1321
|
+
storeInstance = container.get("CentralStore");
|
|
1322
|
+
} else {
|
|
1323
|
+
const storeKeyMatch = paramName.match(/^store(.+)$/);
|
|
1324
|
+
if (storeKeyMatch && storeKeyMatch[1]) {
|
|
1325
|
+
const storeName = storeKeyMatch[1].replace(/^([A-Z])/, (m) => m.toLowerCase());
|
|
1326
|
+
const diKey = `CentralStore:${storeName}`;
|
|
1327
|
+
if (container.isBound(diKey)) {
|
|
1328
|
+
storeInstance = container.get(diKey);
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1332
|
+
if (!storeInstance) {
|
|
1333
|
+
this.logger.warn(`\u26A0\uFE0F No store found for parameter "${param}" in ${ServiceClass.name}`);
|
|
1334
|
+
}
|
|
1335
|
+
dependencies.push(storeInstance);
|
|
1336
|
+
continue;
|
|
1337
|
+
}
|
|
1317
1338
|
const matchingService = Array.from(this.serviceRegistry.entries()).find(
|
|
1318
|
-
([name]) => name.toLowerCase() ===
|
|
1339
|
+
([name]) => name.toLowerCase() === paramName
|
|
1319
1340
|
);
|
|
1320
1341
|
if (matchingService) {
|
|
1321
1342
|
dependencies.push(matchingService[1]);
|
|
1322
1343
|
} else {
|
|
1323
1344
|
this.logger.warn(`\u26A0\uFE0F No service found for parameter "${param}" in ${ServiceClass.name}`);
|
|
1345
|
+
dependencies.push(void 0);
|
|
1324
1346
|
}
|
|
1325
1347
|
}
|
|
1326
1348
|
return dependencies;
|