@magek/common 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/concepts/register.d.ts +2 -2
- package/dist/concepts/register.js +2 -2
- package/dist/config.d.ts +4 -5
- package/dist/config.js +6 -6
- package/dist/envelope.d.ts +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/read-model-store-adapter.d.ts +1 -1
- package/dist/{provider.d.ts → runtime.d.ts} +14 -11
- package/package.json +3 -3
- /package/dist/{provider.js → runtime.js} +0 -0
|
@@ -49,7 +49,7 @@ export declare class Register {
|
|
|
49
49
|
*
|
|
50
50
|
* @param {UUID} requestID - The ID of the current request
|
|
51
51
|
* @param {Record<string, string>} responseHeaders - The response headers object. It can be changed by the user.
|
|
52
|
-
* @param {FlusherFunction} flusher - The
|
|
52
|
+
* @param {FlusherFunction} flusher - The runtime-dependent function used to flush the events to the event store.
|
|
53
53
|
* @param {UserEnvelope} [currentUser] - The current user envelope, if available
|
|
54
54
|
* @param {ContextEnvelope} [context] - The current context envelope, if available
|
|
55
55
|
*/
|
|
@@ -80,7 +80,7 @@ export declare class Register {
|
|
|
80
80
|
*/
|
|
81
81
|
events(...events: Array<EventInterface | NotificationInterface>): Register;
|
|
82
82
|
/**
|
|
83
|
-
* Flushes the accumulated events and commands to the event store using the
|
|
83
|
+
* Flushes the accumulated events and commands to the event store using the runtime-dependent flusher function.
|
|
84
84
|
* This method can be called from a command or event handler to force the persistion of the events
|
|
85
85
|
* to the event store. After the events have been flushed, the eventList is cleared, so the same
|
|
86
86
|
* register instance can be used to register more events.
|
|
@@ -28,7 +28,7 @@ class Register {
|
|
|
28
28
|
*
|
|
29
29
|
* @param {UUID} requestID - The ID of the current request
|
|
30
30
|
* @param {Record<string, string>} responseHeaders - The response headers object. It can be changed by the user.
|
|
31
|
-
* @param {FlusherFunction} flusher - The
|
|
31
|
+
* @param {FlusherFunction} flusher - The runtime-dependent function used to flush the events to the event store.
|
|
32
32
|
* @param {UserEnvelope} [currentUser] - The current user envelope, if available
|
|
33
33
|
* @param {ContextEnvelope} [context] - The current context envelope, if available
|
|
34
34
|
*/
|
|
@@ -69,7 +69,7 @@ class Register {
|
|
|
69
69
|
return this;
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
72
|
-
* Flushes the accumulated events and commands to the event store using the
|
|
72
|
+
* Flushes the accumulated events and commands to the event store using the runtime-dependent flusher function.
|
|
73
73
|
* This method can be called from a command or event handler to force the persistion of the events
|
|
74
74
|
* to the event store. After the events have been flushed, the eventList is cleared, so the same
|
|
75
75
|
* register instance can be used to register more events.
|
package/dist/config.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CommandMetadata, DataMigrationMetadata, EntityInterface, EntityMetadata, EventHandlerInterface, EventMetadata, EventStreamConfiguration, GlobalErrorHandlerMetadata, NotificationMetadata, ProjectionMetadata, QueryMetadata, ReadModelInterface, ReadModelMetadata, ReducerMetadata, RoleMetadata, ScheduledCommandMetadata, SchemaMigrationMetadata, TokenVerifier } from './concepts';
|
|
2
|
-
import {
|
|
2
|
+
import { Runtime } from './runtime';
|
|
3
3
|
import { EventStoreAdapter } from './event-store-adapter';
|
|
4
4
|
import { ReadModelStoreAdapter } from './read-model-store-adapter';
|
|
5
5
|
import { SessionStoreAdapter } from './session-store-adapter';
|
|
@@ -15,14 +15,13 @@ export declare class MagekConfig {
|
|
|
15
15
|
logLevel: Level;
|
|
16
16
|
logPrefix?: string;
|
|
17
17
|
logger?: Logger;
|
|
18
|
-
private
|
|
18
|
+
private _runtime?;
|
|
19
19
|
eventStoreAdapter?: EventStoreAdapter;
|
|
20
20
|
readModelStoreAdapter?: ReadModelStoreAdapter;
|
|
21
21
|
sessionStoreAdapter?: SessionStoreAdapter;
|
|
22
22
|
appName: string;
|
|
23
23
|
assets?: Array<string>;
|
|
24
24
|
defaultResponseHeaders: Record<string, string>;
|
|
25
|
-
injectable?: unknown;
|
|
26
25
|
readonly subscriptions: {
|
|
27
26
|
maxConnectionDurationInSeconds: number;
|
|
28
27
|
maxDurationInSeconds: number;
|
|
@@ -88,8 +87,8 @@ export declare class MagekConfig {
|
|
|
88
87
|
get thereAreRoles(): boolean;
|
|
89
88
|
currentVersionFor(className: string): number;
|
|
90
89
|
validate(): void;
|
|
91
|
-
get
|
|
92
|
-
set
|
|
90
|
+
get runtime(): Runtime;
|
|
91
|
+
set runtime(runtime: Runtime);
|
|
93
92
|
get userProjectRootPath(): string;
|
|
94
93
|
set userProjectRootPath(path: string);
|
|
95
94
|
get eventStore(): EventStoreAdapter;
|
package/dist/config.js
CHANGED
|
@@ -120,13 +120,13 @@ class MagekConfig {
|
|
|
120
120
|
validate() {
|
|
121
121
|
this.validateAllMigrations();
|
|
122
122
|
}
|
|
123
|
-
get
|
|
124
|
-
if (!this.
|
|
125
|
-
throw new Error('It is required to set a
|
|
126
|
-
return this.
|
|
123
|
+
get runtime() {
|
|
124
|
+
if (!this._runtime)
|
|
125
|
+
throw new Error('It is required to set a runtime implementation (graphQL, api, messaging, scheduled, sensor) in your configuration files');
|
|
126
|
+
return this._runtime;
|
|
127
127
|
}
|
|
128
|
-
set
|
|
129
|
-
this.
|
|
128
|
+
set runtime(runtime) {
|
|
129
|
+
this._runtime = runtime;
|
|
130
130
|
}
|
|
131
131
|
get userProjectRootPath() {
|
|
132
132
|
if (!this._userProjectRootPath)
|
package/dist/envelope.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { Class } from './typelevel';
|
|
|
5
5
|
/**
|
|
6
6
|
* An `Envelope` carries a command/event body together with the name
|
|
7
7
|
* of its class. This is important information for the `Distributor` to
|
|
8
|
-
* work. Each
|
|
8
|
+
* work. Each runtime has to implement their own `Envelope`.
|
|
9
9
|
*/
|
|
10
10
|
export interface Envelope {
|
|
11
11
|
currentUser?: UserEnvelope;
|
|
@@ -167,7 +167,7 @@ export interface ContextEnvelope {
|
|
|
167
167
|
headers: unknown;
|
|
168
168
|
body: unknown;
|
|
169
169
|
};
|
|
170
|
-
/**
|
|
170
|
+
/** Runtime-dependent raw request context object */
|
|
171
171
|
rawContext: unknown;
|
|
172
172
|
}
|
|
173
173
|
export type EventEnvelopeFromDatabase = EventEnvelope & {
|
package/dist/index.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export * from './instrumentation/trace-types';
|
|
|
22
22
|
export * from './sensor/health-indicator-configuration';
|
|
23
23
|
export * from './internal-info';
|
|
24
24
|
export * from './stream-types';
|
|
25
|
-
export * from './
|
|
25
|
+
export * from './runtime';
|
|
26
26
|
export * from './event-store-adapter';
|
|
27
27
|
export * from './read-model-store-adapter';
|
|
28
28
|
export * from './session-store-adapter';
|
package/dist/index.js
CHANGED
|
@@ -25,7 +25,7 @@ tslib_1.__exportStar(require("./instrumentation/trace-types"), exports);
|
|
|
25
25
|
tslib_1.__exportStar(require("./sensor/health-indicator-configuration"), exports);
|
|
26
26
|
tslib_1.__exportStar(require("./internal-info"), exports);
|
|
27
27
|
tslib_1.__exportStar(require("./stream-types"), exports);
|
|
28
|
-
tslib_1.__exportStar(require("./
|
|
28
|
+
tslib_1.__exportStar(require("./runtime"), exports);
|
|
29
29
|
tslib_1.__exportStar(require("./event-store-adapter"), exports);
|
|
30
30
|
tslib_1.__exportStar(require("./read-model-store-adapter"), exports);
|
|
31
31
|
tslib_1.__exportStar(require("./session-store-adapter"), exports);
|
|
@@ -25,7 +25,7 @@ export interface ReadModelStoreAdapter {
|
|
|
25
25
|
fetch<TReadModel extends ReadModelInterface>(config: MagekConfig, readModelName: string, readModelID: UUID, sequenceKey?: SequenceKey): Promise<ReadOnlyNonEmptyArray<TReadModel> | undefined>;
|
|
26
26
|
/**
|
|
27
27
|
* Searches for read models based on specific parameters
|
|
28
|
-
* This method signature matches the original
|
|
28
|
+
* This method signature matches the original runtime interface
|
|
29
29
|
*
|
|
30
30
|
* @param config - The Magek configuration object
|
|
31
31
|
* @param readModelName - The name of the read model type
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { MagekConfig } from './config';
|
|
2
2
|
import { GraphQLRequestEnvelope, GraphQLRequestEnvelopeError, HealthEnvelope, ScheduledCommandEnvelope } from './envelope';
|
|
3
|
-
export interface
|
|
4
|
-
graphQL:
|
|
5
|
-
api:
|
|
6
|
-
messaging:
|
|
7
|
-
scheduled:
|
|
8
|
-
sensor:
|
|
3
|
+
export interface Runtime {
|
|
4
|
+
graphQL: GraphQLRuntime;
|
|
5
|
+
api: APIRuntime;
|
|
6
|
+
messaging: MessagingRuntime;
|
|
7
|
+
scheduled: ScheduledRuntime;
|
|
8
|
+
sensor: SensorRuntime;
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Runtime messaging adapter for pushing data to client connections.
|
|
12
|
+
*/
|
|
13
|
+
export interface MessagingRuntime {
|
|
11
14
|
/**
|
|
12
15
|
* Sends a message to a specific connection.
|
|
13
16
|
*
|
|
@@ -18,7 +21,7 @@ export interface ProviderMessagingLibrary {
|
|
|
18
21
|
*/
|
|
19
22
|
sendMessage(config: MagekConfig, connectionID: string, data: unknown): Promise<void>;
|
|
20
23
|
}
|
|
21
|
-
export interface
|
|
24
|
+
export interface SensorRuntime {
|
|
22
25
|
databaseEventsHealthDetails(config: MagekConfig): Promise<unknown>;
|
|
23
26
|
databaseReadModelsHealthDetails(config: MagekConfig): Promise<unknown>;
|
|
24
27
|
isDatabaseEventUp(config: MagekConfig): Promise<boolean>;
|
|
@@ -28,7 +31,7 @@ export interface ProviderSensorLibrary {
|
|
|
28
31
|
graphQLFunctionUrl(config: MagekConfig): Promise<string>;
|
|
29
32
|
rawRequestToHealthEnvelope(rawRequest: unknown): HealthEnvelope;
|
|
30
33
|
}
|
|
31
|
-
export interface
|
|
34
|
+
export interface GraphQLRuntime {
|
|
32
35
|
/**
|
|
33
36
|
* Converts a raw GraphQL request to a `GraphQLRequestEnvelope` or a `GraphQLRequestEnvelopeError`.
|
|
34
37
|
*
|
|
@@ -46,7 +49,7 @@ export interface ProviderGraphQLLibrary {
|
|
|
46
49
|
*/
|
|
47
50
|
handleResult(result?: unknown, headers?: Record<string, string>): Promise<unknown>;
|
|
48
51
|
}
|
|
49
|
-
export interface
|
|
52
|
+
export interface APIRuntime {
|
|
50
53
|
/**
|
|
51
54
|
* Handles a successful API request by returning the response body.
|
|
52
55
|
*
|
|
@@ -71,7 +74,7 @@ export interface ProviderAPIHandling {
|
|
|
71
74
|
*/
|
|
72
75
|
healthRequestResult(body: unknown, isHealthy: boolean): Promise<unknown>;
|
|
73
76
|
}
|
|
74
|
-
export interface
|
|
77
|
+
export interface ScheduledRuntime {
|
|
75
78
|
/**
|
|
76
79
|
* Converts a raw message into a `ScheduledCommandEnvelope`.
|
|
77
80
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magek/common",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "Contains Magek common helpers used by the core and provider packages",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"framework-common-helpers"
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
"uuid": "^13.0.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@magek/eslint-config": "^0.0.
|
|
36
|
+
"@magek/eslint-config": "^0.0.3",
|
|
37
37
|
"@types/chai": "5.2.3",
|
|
38
38
|
"@types/chai-as-promised": "8.0.2",
|
|
39
39
|
"@types/mocha": "10.0.10",
|
|
40
|
-
"@types/node": "22.19.
|
|
40
|
+
"@types/node": "22.19.7",
|
|
41
41
|
"@types/sinon": "21.0.0",
|
|
42
42
|
"@types/sinon-chai": "4.0.0",
|
|
43
43
|
"@types/uuid": "11.0.0",
|
|
File without changes
|