@magek/core 0.0.2 → 0.0.3
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/graphql-dispatcher.js +5 -5
- package/dist/index.d.ts +7 -8
- package/dist/index.js +8 -9
- package/dist/magek.d.ts +0 -1
- package/dist/magek.js +0 -32
- package/dist/scheduled-command-dispatcher.js +1 -1
- package/dist/sensor/health/health-indicators/database-events-health-indicator.js +2 -2
- package/dist/sensor/health/health-indicators/database-health-indicator.js +3 -3
- package/dist/sensor/health/health-indicators/database-read-models-health-indicator.js +2 -2
- package/dist/sensor/health/health-indicators/function-health-indicator.js +2 -2
- package/dist/sensor/health/health-indicators/health-indicator.js +3 -3
- package/dist/sensor/health/health-service.js +3 -3
- package/dist/services/graphql/websocket-protocol/graphql-websocket-protocol.js +6 -6
- package/dist/subscribers-notifier.js +1 -1
- package/package.json +4 -5
- package/dist/injectable/index.d.ts +0 -21
- package/dist/injectable/index.js +0 -2
|
@@ -25,19 +25,19 @@ class MagekGraphQLDispatcher {
|
|
|
25
25
|
}
|
|
26
26
|
async dispatch(request) {
|
|
27
27
|
const logger = (0, common_1.getLogger)(this.config, 'MagekGraphQLDispatcher#dispatch');
|
|
28
|
-
const envelopeOrError = await this.config.
|
|
28
|
+
const envelopeOrError = await this.config.runtime.graphQL.rawToEnvelope(this.config, request);
|
|
29
29
|
logger.debug('Received the following GraphQL envelope: ', envelopeOrError);
|
|
30
30
|
switch (envelopeOrError.eventType) {
|
|
31
31
|
case 'CONNECT':
|
|
32
|
-
return this.config.
|
|
32
|
+
return this.config.runtime.graphQL.handleResult(null, common_1.graphQLWebsocketSubprotocolHeaders);
|
|
33
33
|
case 'MESSAGE':
|
|
34
34
|
const responseHeaders = { ...this.config.defaultResponseHeaders };
|
|
35
35
|
const result = await this.handleMessage(envelopeOrError, responseHeaders);
|
|
36
|
-
return this.config.
|
|
36
|
+
return this.config.runtime.graphQL.handleResult(result, responseHeaders);
|
|
37
37
|
case 'DISCONNECT':
|
|
38
|
-
return this.config.
|
|
38
|
+
return this.config.runtime.graphQL.handleResult(await this.handleDisconnect(envelopeOrError.connectionID));
|
|
39
39
|
default:
|
|
40
|
-
return this.config.
|
|
40
|
+
return this.config.runtime.graphQL.handleResult({
|
|
41
41
|
errors: [new Error(`Unknown message type ${envelopeOrError.eventType}`)],
|
|
42
42
|
});
|
|
43
43
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -8,53 +8,52 @@ export { MagekTouchEntityHandler } from './touch-entity-handler';
|
|
|
8
8
|
export * from './services/token-verifiers';
|
|
9
9
|
export * from './instrumentation/index';
|
|
10
10
|
export * from './decorators/health-sensor';
|
|
11
|
-
export * as Injectable from './injectable';
|
|
12
11
|
/**
|
|
13
12
|
* Pushes a page of events to be processed by the event dispatcher.
|
|
14
13
|
*
|
|
15
|
-
* @param rawEvents A
|
|
14
|
+
* @param rawEvents A runtime-specific representation of the events to be processed
|
|
16
15
|
* @returns A promise that resolves when the events are processed
|
|
17
16
|
*/
|
|
18
17
|
export declare function eventDispatcher(rawEvents: unknown): Promise<void>;
|
|
19
18
|
/**
|
|
20
19
|
* Serves a GraphQL request. GraphQL resolvers can send response objects back to the client.
|
|
21
20
|
*
|
|
22
|
-
* @param rawRequest A
|
|
21
|
+
* @param rawRequest A runtime-specific representation of the GraphQL request.
|
|
23
22
|
* @returns A promise that resolves to the GraphQL response.
|
|
24
23
|
*/
|
|
25
24
|
export declare function graphQLDispatcher(rawRequest: unknown): Promise<unknown>;
|
|
26
25
|
/**
|
|
27
26
|
* Triggers pending scheduled commands. This function is meant to be called by a scheduler.
|
|
28
27
|
*
|
|
29
|
-
* @param rawRequest A
|
|
28
|
+
* @param rawRequest A runtime-specific representation of the request to trigger scheduled commands
|
|
30
29
|
* @returns A promise that resolves when the scheduled commands are triggered
|
|
31
30
|
*/
|
|
32
31
|
export declare function triggerScheduledCommands(rawRequest: unknown): Promise<void>;
|
|
33
32
|
/**
|
|
34
33
|
* Notifies subscribers of a new update on a read model
|
|
35
34
|
*
|
|
36
|
-
* @param rawRequest A
|
|
35
|
+
* @param rawRequest A runtime-specific representation of the request to notify subscribers.
|
|
37
36
|
* @returns A promise that resolves when the subscribers are notified
|
|
38
37
|
*/
|
|
39
38
|
export declare function notifySubscribers(rawRequest: unknown): Promise<void>;
|
|
40
39
|
/**
|
|
41
40
|
* Consumes events from the event stream and dispatches them to the event handlers
|
|
42
41
|
*
|
|
43
|
-
* @param rawEvent A
|
|
42
|
+
* @param rawEvent A runtime-specific representation of the event to be processed
|
|
44
43
|
* @returns A promise that resolves when the event is processed
|
|
45
44
|
*/
|
|
46
45
|
export declare function consumeEventStream(rawEvent: unknown): Promise<unknown>;
|
|
47
46
|
/**
|
|
48
47
|
* Produces events to the event stream
|
|
49
48
|
*
|
|
50
|
-
* @param rawEvent A
|
|
49
|
+
* @param rawEvent A runtime-specific representation of the event to be produced
|
|
51
50
|
* @returns A promise that resolves when the event is produced
|
|
52
51
|
*/
|
|
53
52
|
export declare function produceEventStream(rawEvent: unknown): Promise<unknown>;
|
|
54
53
|
/**
|
|
55
54
|
* Returns the health of the application
|
|
56
55
|
*
|
|
57
|
-
* @param request A
|
|
56
|
+
* @param request A runtime-specific representation of the request to check the health
|
|
58
57
|
* @returns A promise that resolves to the health of the application
|
|
59
58
|
*/
|
|
60
59
|
export declare function health(request: unknown): Promise<unknown>;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.MagekTouchEntityHandler = exports.MagekDataMigrationEntity = exports.MagekDataMigrationFinished = exports.MagekDataMigrations = exports.RegisterHandler = exports.Magek = void 0;
|
|
4
4
|
exports.eventDispatcher = eventDispatcher;
|
|
5
5
|
exports.graphQLDispatcher = graphQLDispatcher;
|
|
6
6
|
exports.triggerScheduledCommands = triggerScheduledCommands;
|
|
@@ -34,11 +34,10 @@ Object.defineProperty(exports, "MagekTouchEntityHandler", { enumerable: true, ge
|
|
|
34
34
|
tslib_1.__exportStar(require("./services/token-verifiers"), exports);
|
|
35
35
|
tslib_1.__exportStar(require("./instrumentation/index"), exports);
|
|
36
36
|
tslib_1.__exportStar(require("./decorators/health-sensor"), exports);
|
|
37
|
-
exports.Injectable = require("./injectable");
|
|
38
37
|
/**
|
|
39
38
|
* Pushes a page of events to be processed by the event dispatcher.
|
|
40
39
|
*
|
|
41
|
-
* @param rawEvents A
|
|
40
|
+
* @param rawEvents A runtime-specific representation of the events to be processed
|
|
42
41
|
* @returns A promise that resolves when the events are processed
|
|
43
42
|
*/
|
|
44
43
|
async function eventDispatcher(rawEvents) {
|
|
@@ -47,7 +46,7 @@ async function eventDispatcher(rawEvents) {
|
|
|
47
46
|
/**
|
|
48
47
|
* Serves a GraphQL request. GraphQL resolvers can send response objects back to the client.
|
|
49
48
|
*
|
|
50
|
-
* @param rawRequest A
|
|
49
|
+
* @param rawRequest A runtime-specific representation of the GraphQL request.
|
|
51
50
|
* @returns A promise that resolves to the GraphQL response.
|
|
52
51
|
*/
|
|
53
52
|
async function graphQLDispatcher(rawRequest) {
|
|
@@ -56,7 +55,7 @@ async function graphQLDispatcher(rawRequest) {
|
|
|
56
55
|
/**
|
|
57
56
|
* Triggers pending scheduled commands. This function is meant to be called by a scheduler.
|
|
58
57
|
*
|
|
59
|
-
* @param rawRequest A
|
|
58
|
+
* @param rawRequest A runtime-specific representation of the request to trigger scheduled commands
|
|
60
59
|
* @returns A promise that resolves when the scheduled commands are triggered
|
|
61
60
|
*/
|
|
62
61
|
async function triggerScheduledCommands(rawRequest) {
|
|
@@ -65,7 +64,7 @@ async function triggerScheduledCommands(rawRequest) {
|
|
|
65
64
|
/**
|
|
66
65
|
* Notifies subscribers of a new update on a read model
|
|
67
66
|
*
|
|
68
|
-
* @param rawRequest A
|
|
67
|
+
* @param rawRequest A runtime-specific representation of the request to notify subscribers.
|
|
69
68
|
* @returns A promise that resolves when the subscribers are notified
|
|
70
69
|
*/
|
|
71
70
|
async function notifySubscribers(rawRequest) {
|
|
@@ -74,7 +73,7 @@ async function notifySubscribers(rawRequest) {
|
|
|
74
73
|
/**
|
|
75
74
|
* Consumes events from the event stream and dispatches them to the event handlers
|
|
76
75
|
*
|
|
77
|
-
* @param rawEvent A
|
|
76
|
+
* @param rawEvent A runtime-specific representation of the event to be processed
|
|
78
77
|
* @returns A promise that resolves when the event is processed
|
|
79
78
|
*/
|
|
80
79
|
async function consumeEventStream(rawEvent) {
|
|
@@ -83,7 +82,7 @@ async function consumeEventStream(rawEvent) {
|
|
|
83
82
|
/**
|
|
84
83
|
* Produces events to the event stream
|
|
85
84
|
*
|
|
86
|
-
* @param rawEvent A
|
|
85
|
+
* @param rawEvent A runtime-specific representation of the event to be produced
|
|
87
86
|
* @returns A promise that resolves when the event is produced
|
|
88
87
|
*/
|
|
89
88
|
async function produceEventStream(rawEvent) {
|
|
@@ -92,7 +91,7 @@ async function produceEventStream(rawEvent) {
|
|
|
92
91
|
/**
|
|
93
92
|
* Returns the health of the application
|
|
94
93
|
*
|
|
95
|
-
* @param request A
|
|
94
|
+
* @param request A runtime-specific representation of the request to check the health
|
|
96
95
|
* @returns A promise that resolves to the health of the application
|
|
97
96
|
*/
|
|
98
97
|
async function health(request) {
|
package/dist/magek.d.ts
CHANGED
|
@@ -20,7 +20,6 @@ export declare class Magek {
|
|
|
20
20
|
* Initializes the Magek project
|
|
21
21
|
*/
|
|
22
22
|
static start(codeRootPath: string): void;
|
|
23
|
-
private static runInjectableCommands;
|
|
24
23
|
/**
|
|
25
24
|
* This function returns a "Searcher" configured to search instances of the read model class passed as param.
|
|
26
25
|
* For more information, check the Searcher class.
|
package/dist/magek.js
CHANGED
|
@@ -13,7 +13,6 @@ const entity_touched_1 = require("./core-concepts/touch-entity/events/entity-tou
|
|
|
13
13
|
const read_model_searcher_1 = require("./services/read-model-searcher");
|
|
14
14
|
const delete_event_dispatcher_1 = require("./delete-event-dispatcher");
|
|
15
15
|
const event_search_1 = require("./event-search");
|
|
16
|
-
const core_1 = require("@oclif/core");
|
|
17
16
|
/**
|
|
18
17
|
* Main class to interact with Magek and configure it.
|
|
19
18
|
* Sensible defaults are used whenever possible:
|
|
@@ -40,7 +39,6 @@ class Magek {
|
|
|
40
39
|
* Initializes the Magek project
|
|
41
40
|
*/
|
|
42
41
|
static start(codeRootPath) {
|
|
43
|
-
var _a;
|
|
44
42
|
if (!this.config.eventStoreAdapter) {
|
|
45
43
|
throw new Error('No eventStoreAdapter configured. Please add one in MagekConfig.');
|
|
46
44
|
}
|
|
@@ -55,36 +53,6 @@ class Magek {
|
|
|
55
53
|
importer_1.Importer.importUserProjectFiles(codeRootPath);
|
|
56
54
|
this.configureMagekConcepts();
|
|
57
55
|
this.config.validate();
|
|
58
|
-
const args = process.argv;
|
|
59
|
-
if (((_a = process.env['MAGEK_CLI_HOOK']) === null || _a === void 0 ? void 0 : _a.trim()) !== 'true') {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
const injectable = this.config.injectable;
|
|
63
|
-
if (injectable) {
|
|
64
|
-
const { commands } = injectable;
|
|
65
|
-
// Run the injectable CLI commands using oclif
|
|
66
|
-
this.runInjectableCommands(args, commands, projectRootPath).catch((error) => {
|
|
67
|
-
if (error instanceof core_1.Errors.ExitError) {
|
|
68
|
-
process.exit(error.oclif.exit);
|
|
69
|
-
}
|
|
70
|
-
console.error(error);
|
|
71
|
-
process.exit(1);
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
static async runInjectableCommands(args, commands, projectRootPath) {
|
|
76
|
-
// Get the subcommand from args (skip node and script path)
|
|
77
|
-
const subcommand = args[2];
|
|
78
|
-
if (!subcommand || !commands[subcommand]) {
|
|
79
|
-
console.log('Available commands:', Object.keys(commands).join(', '));
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
const CommandClass = commands[subcommand];
|
|
83
|
-
// Create a minimal oclif config
|
|
84
|
-
const config = await core_1.Config.load({ root: projectRootPath });
|
|
85
|
-
// Instantiate and run the command
|
|
86
|
-
const instance = new CommandClass(args.slice(3), config);
|
|
87
|
-
await instance.run();
|
|
88
56
|
}
|
|
89
57
|
/**
|
|
90
58
|
* This function returns a "Searcher" configured to search instances of the read model class passed as param.
|
|
@@ -40,7 +40,7 @@ class MagekScheduledCommandDispatcher {
|
|
|
40
40
|
*/
|
|
41
41
|
async dispatch(request) {
|
|
42
42
|
const logger = (0, common_1.getLogger)(this.config, 'MagekScheduledCommandDispatcher#dispatch');
|
|
43
|
-
const envelopeOrError = await this.config.
|
|
43
|
+
const envelopeOrError = await this.config.runtime.scheduled.rawToEnvelope(this.config, request);
|
|
44
44
|
logger.debug('Received ScheduledCommand envelope...', envelopeOrError);
|
|
45
45
|
await this.dispatchCommand(envelopeOrError);
|
|
46
46
|
}
|
|
@@ -9,7 +9,7 @@ class MagekDatabaseEventsHealthIndicator {
|
|
|
9
9
|
status: await this.isUp(config),
|
|
10
10
|
};
|
|
11
11
|
if (healthIndicatorMetadata.healthIndicatorConfiguration.details) {
|
|
12
|
-
const details = await config.
|
|
12
|
+
const details = await config.runtime.sensor.databaseEventsHealthDetails(config);
|
|
13
13
|
result.details = details;
|
|
14
14
|
}
|
|
15
15
|
return result;
|
|
@@ -19,7 +19,7 @@ class MagekDatabaseEventsHealthIndicator {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
async isUp(config) {
|
|
22
|
-
const databaseEvents = await config.
|
|
22
|
+
const databaseEvents = await config.runtime.sensor.isDatabaseEventUp(config);
|
|
23
23
|
return databaseEvents ? common_1.HealthStatus.UP : common_1.HealthStatus.DOWN;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -10,7 +10,7 @@ class MagekDatabaseHealthIndicator {
|
|
|
10
10
|
};
|
|
11
11
|
if (healthIndicatorMetadata.healthIndicatorConfiguration.details) {
|
|
12
12
|
const details = {
|
|
13
|
-
urls: await config.
|
|
13
|
+
urls: await config.runtime.sensor.databaseUrls(config),
|
|
14
14
|
};
|
|
15
15
|
result.details = details;
|
|
16
16
|
}
|
|
@@ -21,8 +21,8 @@ class MagekDatabaseHealthIndicator {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
async isUp(config) {
|
|
24
|
-
const databaseEvents = await config.
|
|
25
|
-
const databaseReadModels = await config.
|
|
24
|
+
const databaseEvents = await config.runtime.sensor.isDatabaseEventUp(config);
|
|
25
|
+
const databaseReadModels = await config.runtime.sensor.areDatabaseReadModelsUp(config);
|
|
26
26
|
return databaseEvents && databaseReadModels ? common_1.HealthStatus.UP : common_1.HealthStatus.DOWN;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -9,7 +9,7 @@ class MagekDatabaseReadModelsHealthIndicator {
|
|
|
9
9
|
status: await this.isUp(config),
|
|
10
10
|
};
|
|
11
11
|
if (healthIndicatorMetadata.healthIndicatorConfiguration.details) {
|
|
12
|
-
const details = await config.
|
|
12
|
+
const details = await config.runtime.sensor.databaseReadModelsHealthDetails(config);
|
|
13
13
|
result.details = details;
|
|
14
14
|
}
|
|
15
15
|
return result;
|
|
@@ -19,7 +19,7 @@ class MagekDatabaseReadModelsHealthIndicator {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
async isUp(config) {
|
|
22
|
-
const databaseReadModels = await config.
|
|
22
|
+
const databaseReadModels = await config.runtime.sensor.areDatabaseReadModelsUp(config);
|
|
23
23
|
return databaseReadModels ? common_1.HealthStatus.UP : common_1.HealthStatus.DOWN;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -10,7 +10,7 @@ class MagekFunctionHealthIndicator {
|
|
|
10
10
|
status: await this.isUp(config),
|
|
11
11
|
};
|
|
12
12
|
if (healthIndicatorMetadata.healthIndicatorConfiguration.details) {
|
|
13
|
-
const graphQLUrl = await config.
|
|
13
|
+
const graphQLUrl = await config.runtime.sensor.graphQLFunctionUrl(config);
|
|
14
14
|
const osInfoResult = await (0, os_info_1.osInfo)();
|
|
15
15
|
result.details = {
|
|
16
16
|
...osInfoResult,
|
|
@@ -24,7 +24,7 @@ class MagekFunctionHealthIndicator {
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
async isUp(config) {
|
|
27
|
-
return (await config.
|
|
27
|
+
return (await config.runtime.sensor.isGraphQLFunctionUp(config)) ? common_1.HealthStatus.UP : common_1.HealthStatus.DOWN;
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
exports.MagekFunctionHealthIndicator = MagekFunctionHealthIndicator;
|
|
@@ -21,9 +21,9 @@ class MagekHealthIndicator {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
async isUp(config) {
|
|
24
|
-
const graphqlUp = await config.
|
|
25
|
-
const databaseEvents = await config.
|
|
26
|
-
const databaseReadModels = await config.
|
|
24
|
+
const graphqlUp = await config.runtime.sensor.isGraphQLFunctionUp(config);
|
|
25
|
+
const databaseEvents = await config.runtime.sensor.isDatabaseEventUp(config);
|
|
26
|
+
const databaseReadModels = await config.runtime.sensor.areDatabaseReadModelsUp(config);
|
|
27
27
|
return graphqlUp && databaseEvents && databaseReadModels ? common_1.HealthStatus.UP : common_1.HealthStatus.DOWN;
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -16,7 +16,7 @@ class MagekHealthService {
|
|
|
16
16
|
}
|
|
17
17
|
async health(request) {
|
|
18
18
|
try {
|
|
19
|
-
const healthEnvelope = this.config.
|
|
19
|
+
const healthEnvelope = this.config.runtime.sensor.rawRequestToHealthEnvelope(request);
|
|
20
20
|
await this.validate(healthEnvelope);
|
|
21
21
|
const healthProviders = this.getHealthProviders();
|
|
22
22
|
const parents = this.parentsHealthProviders(healthEnvelope, healthProviders);
|
|
@@ -24,10 +24,10 @@ class MagekHealthService {
|
|
|
24
24
|
// Check if all components are healthy
|
|
25
25
|
const isHealthy = this.isOverallHealthy(healthIndicatorResults);
|
|
26
26
|
// Use the new health specific response handler
|
|
27
|
-
return await this.config.
|
|
27
|
+
return await this.config.runtime.api.healthRequestResult(healthIndicatorResults, isHealthy);
|
|
28
28
|
}
|
|
29
29
|
catch (e) {
|
|
30
|
-
return await this.config.
|
|
30
|
+
return await this.config.runtime.api.requestFailed(e);
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
async validate(healthEnvelope) {
|
|
@@ -43,7 +43,7 @@ class GraphQLWebsocketHandler {
|
|
|
43
43
|
catch (e) {
|
|
44
44
|
const error = e;
|
|
45
45
|
logger.error(e);
|
|
46
|
-
await this.config.
|
|
46
|
+
await this.config.runtime.messaging.sendMessage(this.config, envelope.connectionID, new common_1.GraphQLInitError(error.message));
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
async handleInit(connectionID, clientMessage) {
|
|
@@ -61,7 +61,7 @@ class GraphQLWebsocketHandler {
|
|
|
61
61
|
logger.debug('Storing connection data: ', connectionData);
|
|
62
62
|
await this.config.sessionStore.storeConnection(this.config, connectionID, connectionData);
|
|
63
63
|
logger.debug('Sending ACK');
|
|
64
|
-
await this.config.
|
|
64
|
+
await this.config.runtime.messaging.sendMessage(this.config, connectionID, new common_1.GraphQLInitAck());
|
|
65
65
|
}
|
|
66
66
|
async handleStart(connectionID, envelope, message) {
|
|
67
67
|
const logger = (0, common_1.getLogger)(this.config, 'GraphQLWebsocketHandler#handleStart');
|
|
@@ -69,7 +69,7 @@ class GraphQLWebsocketHandler {
|
|
|
69
69
|
throw new Error(`Missing "id" in ${message.type} message`);
|
|
70
70
|
}
|
|
71
71
|
if (!message.payload || !message.payload.query) {
|
|
72
|
-
await this.config.
|
|
72
|
+
await this.config.runtime.messaging.sendMessage(this.config, connectionID, new common_1.GraphQLError(message.id, {
|
|
73
73
|
errors: [new Error('Message payload is invalid it must contain at least the "query" property')],
|
|
74
74
|
}));
|
|
75
75
|
return;
|
|
@@ -83,8 +83,8 @@ class GraphQLWebsocketHandler {
|
|
|
83
83
|
}
|
|
84
84
|
logger.debug('Operation finished. Sending DATA:', result);
|
|
85
85
|
// It was a query or mutation. We send data and complete the operation
|
|
86
|
-
await this.config.
|
|
87
|
-
await this.config.
|
|
86
|
+
await this.config.runtime.messaging.sendMessage(this.config, connectionID, new common_1.GraphQLData(message.id, result));
|
|
87
|
+
await this.config.runtime.messaging.sendMessage(this.config, connectionID, new common_1.GraphQLComplete(message.id));
|
|
88
88
|
}
|
|
89
89
|
async augmentEnvelope(connectionID, envelope, message) {
|
|
90
90
|
const logger = (0, common_1.getLogger)(this.config, 'GraphQLWebsocketHandler#augmentEnvelope');
|
|
@@ -108,7 +108,7 @@ class GraphQLWebsocketHandler {
|
|
|
108
108
|
await this.callbacks.onStopOperation(connectionID, message.id);
|
|
109
109
|
logger.debug('Stop operation finished');
|
|
110
110
|
try {
|
|
111
|
-
await this.config.
|
|
111
|
+
await this.config.runtime.messaging.sendMessage(this.config, connectionID, new common_1.GraphQLComplete(message.id));
|
|
112
112
|
}
|
|
113
113
|
catch (e) {
|
|
114
114
|
// It could be the case that the client already closed the connection without waiting for stop operation to finish
|
|
@@ -96,7 +96,7 @@ class MagekSubscribersNotifier {
|
|
|
96
96
|
const readModel = result.data;
|
|
97
97
|
const message = new common_1.GraphQLData(subscription.operation.id, { data: readModel });
|
|
98
98
|
logger.debug(`Notifying connectionID '${subscription.connectionID}' with the following wrappeed read model: `, readModel);
|
|
99
|
-
await this.config.
|
|
99
|
+
await this.config.runtime.messaging.sendMessage(this.config, subscription.connectionID, message);
|
|
100
100
|
logger.debug('Notifications sent');
|
|
101
101
|
}
|
|
102
102
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magek/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
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.
|
|
26
|
+
"@magek/common": "^0.0.3",
|
|
27
27
|
"fp-ts": "2.16.11",
|
|
28
28
|
"graphql-scalars": "1.25.0",
|
|
29
29
|
"inflected": "2.1.0",
|
|
@@ -32,17 +32,16 @@
|
|
|
32
32
|
"jwks-rsa": "3.2.0",
|
|
33
33
|
"tslib": "2.8.1",
|
|
34
34
|
"validator": "13.15.26",
|
|
35
|
-
"@oclif/core": "4.8.0",
|
|
36
35
|
"fast-check": "4.5.3"
|
|
37
36
|
},
|
|
38
37
|
"devDependencies": {
|
|
39
|
-
"@magek/eslint-config": "^0.0.
|
|
38
|
+
"@magek/eslint-config": "^0.0.3",
|
|
40
39
|
"@types/chai": "5.2.3",
|
|
41
40
|
"@types/chai-as-promised": "8.0.2",
|
|
42
41
|
"@types/inflected": "2.1.3",
|
|
43
42
|
"@types/jsonwebtoken": "9.0.10",
|
|
44
43
|
"@types/mocha": "10.0.10",
|
|
45
|
-
"@types/node": "22.19.
|
|
44
|
+
"@types/node": "22.19.7",
|
|
46
45
|
"@types/sinon": "21.0.0",
|
|
47
46
|
"@types/sinon-chai": "4.0.0",
|
|
48
47
|
"chai": "6.2.2",
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { Command as OclifCommand, Config } from '@oclif/core';
|
|
2
|
-
/**
|
|
3
|
-
* Type for a concrete oclif Command class (non-abstract).
|
|
4
|
-
* This represents a class constructor that creates Command instances.
|
|
5
|
-
*/
|
|
6
|
-
export type ConcreteCommand = new (argv: string[], config: Config) => OclifCommand;
|
|
7
|
-
/**
|
|
8
|
-
* Injectable interface for registering custom CLI commands with Magek.
|
|
9
|
-
* Commands should be oclif Command classes (concrete implementations, not abstract).
|
|
10
|
-
*/
|
|
11
|
-
export interface Injectable {
|
|
12
|
-
/**
|
|
13
|
-
* Map of command names to oclif Command classes.
|
|
14
|
-
* The command name will be used as the subcommand name.
|
|
15
|
-
*/
|
|
16
|
-
commands: Record<string, ConcreteCommand>;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Type for an oclif Command class.
|
|
20
|
-
*/
|
|
21
|
-
export type Command = ConcreteCommand;
|
package/dist/injectable/index.js
DELETED