@magek/server 0.0.5 → 0.0.7

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.js CHANGED
@@ -46,42 +46,37 @@ exports.ServerRuntime = {
46
46
  },
47
47
  sensor: {
48
48
  databaseEventsHealthDetails: (config) => {
49
- var _a;
50
49
  // Delegate to event store adapter health check if available
51
- if ((_a = config.eventStoreAdapter) === null || _a === void 0 ? void 0 : _a.healthCheck) {
50
+ if (config.eventStoreAdapter?.healthCheck) {
52
51
  return config.eventStoreAdapter.healthCheck.details(config);
53
52
  }
54
53
  throw new Error('No event store adapter configured for health checks');
55
54
  },
56
55
  databaseReadModelsHealthDetails: (config) => {
57
- var _a;
58
56
  // Delegate to read model store adapter health check if available
59
- if ((_a = config.readModelStoreAdapter) === null || _a === void 0 ? void 0 : _a.healthCheck) {
57
+ if (config.readModelStoreAdapter?.healthCheck) {
60
58
  return config.readModelStoreAdapter.healthCheck.details(config);
61
59
  }
62
60
  throw new Error('No read model store adapter configured for health checks');
63
61
  },
64
62
  isDatabaseEventUp: (config) => {
65
- var _a;
66
63
  // Delegate to event store adapter health check if available
67
- if ((_a = config.eventStoreAdapter) === null || _a === void 0 ? void 0 : _a.healthCheck) {
64
+ if (config.eventStoreAdapter?.healthCheck) {
68
65
  return config.eventStoreAdapter.healthCheck.isUp(config);
69
66
  }
70
67
  return Promise.resolve(false);
71
68
  },
72
69
  areDatabaseReadModelsUp: (config) => {
73
- var _a;
74
70
  // Delegate to read model store adapter health check if available
75
- if ((_a = config.readModelStoreAdapter) === null || _a === void 0 ? void 0 : _a.healthCheck) {
71
+ if (config.readModelStoreAdapter?.healthCheck) {
76
72
  return config.readModelStoreAdapter.healthCheck.isUp(config);
77
73
  }
78
74
  return Promise.resolve(false);
79
75
  },
80
76
  databaseUrls: (config) => {
81
- var _a, _b, _c, _d, _e, _f;
82
77
  // Get URLs from both event store and read model store adapters
83
- const eventUrls = (_c = (_b = (_a = config.eventStoreAdapter) === null || _a === void 0 ? void 0 : _a.healthCheck) === null || _b === void 0 ? void 0 : _b.urls(config)) !== null && _c !== void 0 ? _c : Promise.resolve([]);
84
- const readModelUrls = (_f = (_e = (_d = config.readModelStoreAdapter) === null || _d === void 0 ? void 0 : _d.healthCheck) === null || _e === void 0 ? void 0 : _e.urls(config)) !== null && _f !== void 0 ? _f : Promise.resolve([]);
78
+ const eventUrls = config.eventStoreAdapter?.healthCheck?.urls(config) ?? Promise.resolve([]);
79
+ const readModelUrls = config.readModelStoreAdapter?.healthCheck?.urls(config) ?? Promise.resolve([]);
85
80
  return Promise.all([eventUrls, readModelUrls]).then(([events, readModels]) => [
86
81
  ...events,
87
82
  ...readModels
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GraphQLController = void 0;
4
4
  const http_1 = require("../http");
5
5
  class GraphQLController {
6
+ graphQLService;
6
7
  constructor(graphQLService) {
7
8
  this.graphQLService = graphQLService;
8
9
  }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.HealthController = void 0;
4
4
  const http_1 = require("../http");
5
5
  class HealthController {
6
+ healthService;
6
7
  constructor(healthService) {
7
8
  this.healthService = healthService;
8
9
  }
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LocalTestHelper = void 0;
4
4
  const local_queries_1 = require("./local-queries");
5
5
  class LocalTestHelper {
6
+ outputs;
7
+ queries;
6
8
  constructor(outputs, queries) {
7
9
  this.outputs = outputs;
8
10
  this.queries = queries;
@@ -5,9 +5,7 @@ exports.WebSocketRegistry = void 0;
5
5
  * Registry to manage active WebSocket connections
6
6
  */
7
7
  class WebSocketRegistry {
8
- constructor() {
9
- this.connections = new Map();
10
- }
8
+ connections = new Map();
11
9
  /**
12
10
  * Add a connection to the registry
13
11
  */
@@ -13,16 +13,16 @@ function webSocketMessageToEnvelope(config, webSocketRequest, requestID) {
13
13
  logger.debug('Received WebSocket GraphQL request: ', webSocketRequest);
14
14
  let eventType = 'MESSAGE';
15
15
  const incomingMessage = webSocketRequest.incomingMessage;
16
- const headers = incomingMessage === null || incomingMessage === void 0 ? void 0 : incomingMessage.headers;
16
+ const headers = incomingMessage?.headers;
17
17
  const data = webSocketRequest.data;
18
18
  try {
19
19
  const connectionContext = webSocketRequest.connectionContext;
20
- eventType = connectionContext === null || connectionContext === void 0 ? void 0 : connectionContext.eventType;
20
+ eventType = connectionContext?.eventType;
21
21
  return {
22
22
  requestID,
23
23
  eventType,
24
- connectionID: connectionContext === null || connectionContext === void 0 ? void 0 : connectionContext.connectionId.toString(),
25
- token: Array.isArray(headers === null || headers === void 0 ? void 0 : headers.authorization) ? headers.authorization[0] : headers === null || headers === void 0 ? void 0 : headers.authorization,
24
+ connectionID: connectionContext?.connectionId.toString(),
25
+ token: Array.isArray(headers?.authorization) ? headers.authorization[0] : headers?.authorization,
26
26
  value: data,
27
27
  context: {
28
28
  request: {
@@ -60,7 +60,7 @@ function httpMessageToEnvelope(config, httpRequest, requestId) {
60
60
  connectionID: undefined,
61
61
  requestID: requestId,
62
62
  eventType: eventType,
63
- token: Array.isArray(headers === null || headers === void 0 ? void 0 : headers.authorization) ? headers.authorization[0] : headers === null || headers === void 0 ? void 0 : headers.authorization,
63
+ token: Array.isArray(headers?.authorization) ? headers.authorization[0] : headers?.authorization,
64
64
  value: data,
65
65
  context: {
66
66
  request: {
@@ -15,7 +15,7 @@ async function databaseUrl() {
15
15
  async function countAll(database) {
16
16
  await database.loadDatabaseAsync();
17
17
  const count = await database.countAsync({});
18
- return count !== null && count !== void 0 ? count : 0;
18
+ return count ?? 0;
19
19
  }
20
20
  async function graphqlFunctionUrl() {
21
21
  try {
@@ -65,6 +65,6 @@ function rawRequestToSensorHealth(rawRequest) {
65
65
  rawContext: rawRequest,
66
66
  },
67
67
  componentPath: componentPath,
68
- token: Array.isArray(headers === null || headers === void 0 ? void 0 : headers.authorization) ? headers.authorization[0] : headers === null || headers === void 0 ? void 0 : headers.authorization,
68
+ token: Array.isArray(headers?.authorization) ? headers.authorization[0] : headers?.authorization,
69
69
  };
70
70
  }
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GraphQLService = void 0;
4
4
  class GraphQLService {
5
+ userApp;
5
6
  constructor(userApp) {
6
7
  this.userApp = userApp;
7
8
  }
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.HealthService = void 0;
4
4
  class HealthService {
5
+ userApp;
5
6
  constructor(userApp) {
6
7
  this.userApp = userApp;
7
8
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magek/server",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "description": "Debug your Magek projects locally",
5
5
  "keywords": [
6
6
  "server"
@@ -26,12 +26,12 @@
26
26
  "node": ">=22.0.0 <23.0.0"
27
27
  },
28
28
  "dependencies": {
29
- "@magek/common": "^0.0.5",
29
+ "@magek/common": "^0.0.7",
30
30
  "@fastify/cors": "11.2.0",
31
31
  "@fastify/websocket": "11.2.0",
32
32
  "@seald-io/nedb": "4.1.2",
33
- "fastify": "5.7.1",
34
- "fastify-sse-v2": "4.2.1",
33
+ "fastify": "5.7.2",
34
+ "fastify-sse-v2": "4.2.2",
35
35
  "node-schedule": "2.1.1",
36
36
  "tslib": "2.8.1"
37
37
  },
@@ -39,7 +39,7 @@
39
39
  "url": "https://github.com/theam/magek/issues"
40
40
  },
41
41
  "devDependencies": {
42
- "@magek/eslint-config": "^0.0.5",
42
+ "@magek/eslint-config": "^0.0.7",
43
43
  "@types/chai": "5.2.3",
44
44
  "@types/chai-as-promised": "8.0.2",
45
45
  "@types/mocha": "10.0.10",