@chromahq/core 0.1.8 → 0.1.10
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 +29 -26
- package/dist/index.es.js +29 -26
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -47,7 +47,6 @@ const DEFAULT_PORT_NAME = "chroma-bridge";
|
|
|
47
47
|
|
|
48
48
|
class DefaultErrorHandler {
|
|
49
49
|
handle(error, context) {
|
|
50
|
-
console.error("Error in bridge handler:", error);
|
|
51
50
|
return {
|
|
52
51
|
id: context.request.id,
|
|
53
52
|
error: error?.message ?? "UNKNOWN_ERROR",
|
|
@@ -1073,7 +1072,21 @@ function getNextCronDate(expr) {
|
|
|
1073
1072
|
}
|
|
1074
1073
|
}
|
|
1075
1074
|
|
|
1076
|
-
|
|
1075
|
+
function Injectable() {
|
|
1076
|
+
return function(constructor) {
|
|
1077
|
+
L$1()(constructor);
|
|
1078
|
+
};
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
1082
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
1083
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
1084
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1085
|
+
if (decorator = decorators[i])
|
|
1086
|
+
result = (decorator(result)) || result;
|
|
1087
|
+
return result;
|
|
1088
|
+
};
|
|
1089
|
+
let Scheduler = class {
|
|
1077
1090
|
constructor() {
|
|
1078
1091
|
this.registry = JobRegistry.instance;
|
|
1079
1092
|
this.alarm = new AlarmAdapter();
|
|
@@ -1126,7 +1139,9 @@ class Scheduler {
|
|
|
1126
1139
|
try {
|
|
1127
1140
|
this.registry.updateState(id, JobState.RUNNING);
|
|
1128
1141
|
console.log(`Executing job ${id}`);
|
|
1129
|
-
|
|
1142
|
+
const jobInstance = container.get(id);
|
|
1143
|
+
console.log(jobInstance);
|
|
1144
|
+
await jobInstance.handle.bind(jobInstance).call(jobInstance, context);
|
|
1130
1145
|
if (!context.isStopped() && !context.isPaused()) {
|
|
1131
1146
|
this.registry.updateState(id, JobState.COMPLETED);
|
|
1132
1147
|
const options = this.registry.meta(id);
|
|
@@ -1159,7 +1174,10 @@ class Scheduler {
|
|
|
1159
1174
|
const jobs = [];
|
|
1160
1175
|
return jobs;
|
|
1161
1176
|
}
|
|
1162
|
-
}
|
|
1177
|
+
};
|
|
1178
|
+
Scheduler = __decorateClass([
|
|
1179
|
+
Injectable()
|
|
1180
|
+
], Scheduler);
|
|
1163
1181
|
|
|
1164
1182
|
class ApplicationBootstrap {
|
|
1165
1183
|
constructor() {
|
|
@@ -1216,6 +1234,7 @@ class ApplicationBootstrap {
|
|
|
1216
1234
|
*/
|
|
1217
1235
|
async bootServices() {
|
|
1218
1236
|
this.logger.info("\u{1F680} Booting services...");
|
|
1237
|
+
console.log("services", this.serviceRegistry.entries());
|
|
1219
1238
|
for (const [serviceName, ServiceClass] of this.serviceRegistry.entries()) {
|
|
1220
1239
|
try {
|
|
1221
1240
|
const instance = container.get(ServiceClass);
|
|
@@ -1275,7 +1294,7 @@ class ApplicationBootstrap {
|
|
|
1275
1294
|
const diKey = `CentralStore:${store.name}`;
|
|
1276
1295
|
container.bind(diKey).toConstantValue(storeInstance);
|
|
1277
1296
|
if (isFirstStore) {
|
|
1278
|
-
container.bind("
|
|
1297
|
+
container.bind("appStore").toConstantValue(storeInstance);
|
|
1279
1298
|
isFirstStore = false;
|
|
1280
1299
|
}
|
|
1281
1300
|
this.registerMessageClass(classes.GetStoreStateMessage, `store:${store.name}:getState`);
|
|
@@ -1318,13 +1337,11 @@ class ApplicationBootstrap {
|
|
|
1318
1337
|
const paramName = param.toLowerCase();
|
|
1319
1338
|
if (paramName === "appstore") {
|
|
1320
1339
|
let storeInstance;
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
throw new Error(`No store found for parameter "${param}" in ${ServiceClass.name}`);
|
|
1325
|
-
}
|
|
1326
|
-
Reflect.defineMetadata("name", param, storeInstance);
|
|
1340
|
+
storeInstance = container.get("appStore");
|
|
1341
|
+
if (!storeInstance) {
|
|
1342
|
+
throw new Error(`No store found for parameter "${param}" in ${ServiceClass.name}`);
|
|
1327
1343
|
}
|
|
1344
|
+
dependencies.push("appStore");
|
|
1328
1345
|
continue;
|
|
1329
1346
|
}
|
|
1330
1347
|
const matchingService = Array.from(this.serviceRegistry.entries()).find(
|
|
@@ -1448,9 +1465,6 @@ class ApplicationBootstrap {
|
|
|
1448
1465
|
serviceMetadata.dependencies.forEach((dependency, index) => {
|
|
1449
1466
|
b(_$1(dependency), ServiceClass, index);
|
|
1450
1467
|
});
|
|
1451
|
-
if (container.isBound("CentralStore")) {
|
|
1452
|
-
b(_$1("CentralStore"), ServiceClass, serviceMetadata.dependencies.length);
|
|
1453
|
-
}
|
|
1454
1468
|
container.bind(ServiceClass).toSelf().inSingletonScope();
|
|
1455
1469
|
serviceMetadata.registered = true;
|
|
1456
1470
|
this.logger.success(`\u2705 Registered service: ${ServiceClass.name}`);
|
|
@@ -1512,9 +1526,6 @@ class ApplicationBootstrap {
|
|
|
1512
1526
|
dependencies.forEach((dependency, index) => {
|
|
1513
1527
|
b(_$1(dependency), MessageClass, index);
|
|
1514
1528
|
});
|
|
1515
|
-
if (container.isBound("CentralStore")) {
|
|
1516
|
-
b(_$1("CentralStore"), MessageClass, dependencies.length);
|
|
1517
|
-
}
|
|
1518
1529
|
const messageMetadata = Reflect.getMetadata("name", MessageClass);
|
|
1519
1530
|
const messageName = messageMetadata || MessageClass.name;
|
|
1520
1531
|
container.bind(messageName).to(MessageClass).inSingletonScope();
|
|
@@ -1575,13 +1586,11 @@ class ApplicationBootstrap {
|
|
|
1575
1586
|
dependencies.forEach((dependency, index) => {
|
|
1576
1587
|
b(_$1(dependency), JobClass, index);
|
|
1577
1588
|
});
|
|
1578
|
-
if (container.isBound("CentralStore")) {
|
|
1579
|
-
b(_$1("CentralStore"), JobClass, dependencies.length);
|
|
1580
|
-
}
|
|
1581
1589
|
const jobMetadata = Reflect.getMetadata("name", JobClass);
|
|
1582
1590
|
const jobName = jobMetadata || JobClass.name;
|
|
1583
1591
|
container.bind(JobClass).toSelf().inSingletonScope();
|
|
1584
1592
|
const id = `${jobName.toLowerCase()}:${JobClass.name.toLowerCase()} ${Math.random().toString(36).substring(2, 15)}`;
|
|
1593
|
+
container.bind(id).to(JobClass).inSingletonScope();
|
|
1585
1594
|
const options = Reflect.getMetadata("job:options", JobClass) || {};
|
|
1586
1595
|
const instance = container.get(JobClass);
|
|
1587
1596
|
JobRegistry.instance.register(id, instance, options);
|
|
@@ -1670,12 +1679,6 @@ function Message(name) {
|
|
|
1670
1679
|
};
|
|
1671
1680
|
}
|
|
1672
1681
|
|
|
1673
|
-
function Injectable() {
|
|
1674
|
-
return function(constructor) {
|
|
1675
|
-
L$1()(constructor);
|
|
1676
|
-
};
|
|
1677
|
-
}
|
|
1678
|
-
|
|
1679
1682
|
class Booteable {
|
|
1680
1683
|
/**
|
|
1681
1684
|
* Optional destroy method to be called when the service is being destroyed.
|
package/dist/index.es.js
CHANGED
|
@@ -45,7 +45,6 @@ const DEFAULT_PORT_NAME = "chroma-bridge";
|
|
|
45
45
|
|
|
46
46
|
class DefaultErrorHandler {
|
|
47
47
|
handle(error, context) {
|
|
48
|
-
console.error("Error in bridge handler:", error);
|
|
49
48
|
return {
|
|
50
49
|
id: context.request.id,
|
|
51
50
|
error: error?.message ?? "UNKNOWN_ERROR",
|
|
@@ -1071,7 +1070,21 @@ function getNextCronDate(expr) {
|
|
|
1071
1070
|
}
|
|
1072
1071
|
}
|
|
1073
1072
|
|
|
1074
|
-
|
|
1073
|
+
function Injectable() {
|
|
1074
|
+
return function(constructor) {
|
|
1075
|
+
L$1()(constructor);
|
|
1076
|
+
};
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
1080
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
1081
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
1082
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1083
|
+
if (decorator = decorators[i])
|
|
1084
|
+
result = (decorator(result)) || result;
|
|
1085
|
+
return result;
|
|
1086
|
+
};
|
|
1087
|
+
let Scheduler = class {
|
|
1075
1088
|
constructor() {
|
|
1076
1089
|
this.registry = JobRegistry.instance;
|
|
1077
1090
|
this.alarm = new AlarmAdapter();
|
|
@@ -1124,7 +1137,9 @@ class Scheduler {
|
|
|
1124
1137
|
try {
|
|
1125
1138
|
this.registry.updateState(id, JobState.RUNNING);
|
|
1126
1139
|
console.log(`Executing job ${id}`);
|
|
1127
|
-
|
|
1140
|
+
const jobInstance = container.get(id);
|
|
1141
|
+
console.log(jobInstance);
|
|
1142
|
+
await jobInstance.handle.bind(jobInstance).call(jobInstance, context);
|
|
1128
1143
|
if (!context.isStopped() && !context.isPaused()) {
|
|
1129
1144
|
this.registry.updateState(id, JobState.COMPLETED);
|
|
1130
1145
|
const options = this.registry.meta(id);
|
|
@@ -1157,7 +1172,10 @@ class Scheduler {
|
|
|
1157
1172
|
const jobs = [];
|
|
1158
1173
|
return jobs;
|
|
1159
1174
|
}
|
|
1160
|
-
}
|
|
1175
|
+
};
|
|
1176
|
+
Scheduler = __decorateClass([
|
|
1177
|
+
Injectable()
|
|
1178
|
+
], Scheduler);
|
|
1161
1179
|
|
|
1162
1180
|
class ApplicationBootstrap {
|
|
1163
1181
|
constructor() {
|
|
@@ -1214,6 +1232,7 @@ class ApplicationBootstrap {
|
|
|
1214
1232
|
*/
|
|
1215
1233
|
async bootServices() {
|
|
1216
1234
|
this.logger.info("\u{1F680} Booting services...");
|
|
1235
|
+
console.log("services", this.serviceRegistry.entries());
|
|
1217
1236
|
for (const [serviceName, ServiceClass] of this.serviceRegistry.entries()) {
|
|
1218
1237
|
try {
|
|
1219
1238
|
const instance = container.get(ServiceClass);
|
|
@@ -1273,7 +1292,7 @@ class ApplicationBootstrap {
|
|
|
1273
1292
|
const diKey = `CentralStore:${store.name}`;
|
|
1274
1293
|
container.bind(diKey).toConstantValue(storeInstance);
|
|
1275
1294
|
if (isFirstStore) {
|
|
1276
|
-
container.bind("
|
|
1295
|
+
container.bind("appStore").toConstantValue(storeInstance);
|
|
1277
1296
|
isFirstStore = false;
|
|
1278
1297
|
}
|
|
1279
1298
|
this.registerMessageClass(classes.GetStoreStateMessage, `store:${store.name}:getState`);
|
|
@@ -1316,13 +1335,11 @@ class ApplicationBootstrap {
|
|
|
1316
1335
|
const paramName = param.toLowerCase();
|
|
1317
1336
|
if (paramName === "appstore") {
|
|
1318
1337
|
let storeInstance;
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
throw new Error(`No store found for parameter "${param}" in ${ServiceClass.name}`);
|
|
1323
|
-
}
|
|
1324
|
-
Reflect.defineMetadata("name", param, storeInstance);
|
|
1338
|
+
storeInstance = container.get("appStore");
|
|
1339
|
+
if (!storeInstance) {
|
|
1340
|
+
throw new Error(`No store found for parameter "${param}" in ${ServiceClass.name}`);
|
|
1325
1341
|
}
|
|
1342
|
+
dependencies.push("appStore");
|
|
1326
1343
|
continue;
|
|
1327
1344
|
}
|
|
1328
1345
|
const matchingService = Array.from(this.serviceRegistry.entries()).find(
|
|
@@ -1446,9 +1463,6 @@ class ApplicationBootstrap {
|
|
|
1446
1463
|
serviceMetadata.dependencies.forEach((dependency, index) => {
|
|
1447
1464
|
b(_$1(dependency), ServiceClass, index);
|
|
1448
1465
|
});
|
|
1449
|
-
if (container.isBound("CentralStore")) {
|
|
1450
|
-
b(_$1("CentralStore"), ServiceClass, serviceMetadata.dependencies.length);
|
|
1451
|
-
}
|
|
1452
1466
|
container.bind(ServiceClass).toSelf().inSingletonScope();
|
|
1453
1467
|
serviceMetadata.registered = true;
|
|
1454
1468
|
this.logger.success(`\u2705 Registered service: ${ServiceClass.name}`);
|
|
@@ -1510,9 +1524,6 @@ class ApplicationBootstrap {
|
|
|
1510
1524
|
dependencies.forEach((dependency, index) => {
|
|
1511
1525
|
b(_$1(dependency), MessageClass, index);
|
|
1512
1526
|
});
|
|
1513
|
-
if (container.isBound("CentralStore")) {
|
|
1514
|
-
b(_$1("CentralStore"), MessageClass, dependencies.length);
|
|
1515
|
-
}
|
|
1516
1527
|
const messageMetadata = Reflect.getMetadata("name", MessageClass);
|
|
1517
1528
|
const messageName = messageMetadata || MessageClass.name;
|
|
1518
1529
|
container.bind(messageName).to(MessageClass).inSingletonScope();
|
|
@@ -1573,13 +1584,11 @@ class ApplicationBootstrap {
|
|
|
1573
1584
|
dependencies.forEach((dependency, index) => {
|
|
1574
1585
|
b(_$1(dependency), JobClass, index);
|
|
1575
1586
|
});
|
|
1576
|
-
if (container.isBound("CentralStore")) {
|
|
1577
|
-
b(_$1("CentralStore"), JobClass, dependencies.length);
|
|
1578
|
-
}
|
|
1579
1587
|
const jobMetadata = Reflect.getMetadata("name", JobClass);
|
|
1580
1588
|
const jobName = jobMetadata || JobClass.name;
|
|
1581
1589
|
container.bind(JobClass).toSelf().inSingletonScope();
|
|
1582
1590
|
const id = `${jobName.toLowerCase()}:${JobClass.name.toLowerCase()} ${Math.random().toString(36).substring(2, 15)}`;
|
|
1591
|
+
container.bind(id).to(JobClass).inSingletonScope();
|
|
1583
1592
|
const options = Reflect.getMetadata("job:options", JobClass) || {};
|
|
1584
1593
|
const instance = container.get(JobClass);
|
|
1585
1594
|
JobRegistry.instance.register(id, instance, options);
|
|
@@ -1668,12 +1677,6 @@ function Message(name) {
|
|
|
1668
1677
|
};
|
|
1669
1678
|
}
|
|
1670
1679
|
|
|
1671
|
-
function Injectable() {
|
|
1672
|
-
return function(constructor) {
|
|
1673
|
-
L$1()(constructor);
|
|
1674
|
-
};
|
|
1675
|
-
}
|
|
1676
|
-
|
|
1677
1680
|
class Booteable {
|
|
1678
1681
|
/**
|
|
1679
1682
|
* Optional destroy method to be called when the service is being destroyed.
|