@magek/core 0.0.1 → 0.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magek/core",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Library for your Magek apps",
5
5
  "author": "Boosterin Labs SLU",
6
6
  "homepage": "https://magek.ai",
@@ -23,7 +23,7 @@
23
23
  "node": ">=22.0.0 <23.0.0"
24
24
  },
25
25
  "dependencies": {
26
- "@magek/common": "^0.0.1",
26
+ "@magek/common": "^0.0.2",
27
27
  "fp-ts": "2.16.11",
28
28
  "graphql-scalars": "1.25.0",
29
29
  "inflected": "2.1.0",
@@ -36,7 +36,7 @@
36
36
  "fast-check": "4.5.3"
37
37
  },
38
38
  "devDependencies": {
39
- "@magek/eslint-config": "^0.0.1",
39
+ "@magek/eslint-config": "^0.0.2",
40
40
  "@types/chai": "5.2.3",
41
41
  "@types/chai-as-promised": "8.0.2",
42
42
  "@types/inflected": "2.1.3",
@@ -1,6 +0,0 @@
1
- import { MagekConfig } from '@magek/common';
2
- export declare class MagekRocketDispatcher {
3
- readonly config: MagekConfig;
4
- constructor(config: MagekConfig);
5
- dispatch(request: unknown): Promise<unknown>;
6
- }
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MagekRocketDispatcher = void 0;
4
- class MagekRocketDispatcher {
5
- constructor(config) {
6
- this.config = config;
7
- }
8
- dispatch(request) {
9
- const rawToEnvelopes = this.config.provider.rockets.rawToEnvelopes(this.config, request);
10
- const rocketId = rawToEnvelopes.rocketId;
11
- if (!rocketId) {
12
- throw new Error('Attempt to execute a rocket function but the ID is missing.');
13
- }
14
- const rocketFunction = this.config.getRegisteredRocketFunction(rocketId);
15
- if (!rocketFunction) {
16
- throw new Error(`Rocket function with ID "${rocketId}" not found. Did you forget registering the function with "config.registerRocketFunction()"?`);
17
- }
18
- return rocketFunction(this.config, request);
19
- }
20
- }
21
- exports.MagekRocketDispatcher = MagekRocketDispatcher;
@@ -1,5 +0,0 @@
1
- import { MagekConfig, HealthIndicatorMetadata, HealthIndicatorsResult } from '@magek/common';
2
- export declare class RocketsHealthIndicator {
3
- health(config: MagekConfig, healthIndicatorMetadata: HealthIndicatorMetadata): Promise<HealthIndicatorsResult>;
4
- private getOverAllHealthStatus;
5
- }
@@ -1,57 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RocketsHealthIndicator = void 0;
4
- const common_1 = require("@magek/common");
5
- class RocketsHealthIndicator {
6
- async health(config, healthIndicatorMetadata) {
7
- const results = await config.provider.sensor.areRocketFunctionsUp(config);
8
- if (Object.keys(results).length === 0) {
9
- return {
10
- name: 'Rockets',
11
- id: common_1.HEALTH_INDICATORS_IDS.ROCKETS,
12
- status: common_1.HealthStatus.UNKNOWN,
13
- details: {
14
- reason: 'No Rockets found',
15
- },
16
- };
17
- }
18
- // Check if we're looking for a specific rocket
19
- const componentPath = healthIndicatorMetadata.healthIndicatorConfiguration.id;
20
- const rocketName = componentPath.split('/')[1]; // rockets/<rocket-name>
21
- if (rocketName) {
22
- const rocketStatus = results[rocketName];
23
- if (rocketStatus === undefined) {
24
- throw new Error(`Rocket "${rocketName}" not found`);
25
- }
26
- return {
27
- name: rocketName,
28
- id: `${common_1.HEALTH_INDICATORS_IDS.ROCKETS}/${rocketName}`,
29
- status: rocketStatus ? common_1.HealthStatus.UP : common_1.HealthStatus.DOWN,
30
- };
31
- }
32
- // return all rockets status
33
- return {
34
- name: 'Rockets',
35
- id: common_1.HEALTH_INDICATORS_IDS.ROCKETS,
36
- status: this.getOverAllHealthStatus(results),
37
- components: Object.entries(results).map(([rocketName, status]) => {
38
- return {
39
- name: rocketName,
40
- id: `${common_1.HEALTH_INDICATORS_IDS.ROCKETS}/${rocketName}`,
41
- status: status ? common_1.HealthStatus.UP : common_1.HealthStatus.DOWN,
42
- };
43
- }),
44
- };
45
- }
46
- getOverAllHealthStatus(results) {
47
- const statusValues = Object.values(results);
48
- if (statusValues.every((status) => status)) {
49
- return common_1.HealthStatus.UP;
50
- }
51
- if (statusValues.every((status) => !status)) {
52
- return common_1.HealthStatus.DOWN;
53
- }
54
- return common_1.HealthStatus.PARTIALLY_UP;
55
- }
56
- }
57
- exports.RocketsHealthIndicator = RocketsHealthIndicator;