@artstesh/postboy 1.2.1 → 1.3.0
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/README.md +1 -1
- package/lib/index.d.ts +3 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -2
- package/lib/index.js.map +1 -1
- package/lib/messages/add-middleware.executor.d.ts +19 -0
- package/lib/messages/add-middleware.executor.d.ts.map +1 -0
- package/lib/messages/add-middleware.executor.js +24 -0
- package/lib/messages/add-middleware.executor.js.map +1 -0
- package/lib/messages/add-namespace.executor.d.ts +19 -0
- package/lib/messages/add-namespace.executor.d.ts.map +1 -0
- package/lib/messages/add-namespace.executor.js +24 -0
- package/lib/messages/add-namespace.executor.js.map +1 -0
- package/lib/messages/connect-executor.executor.d.ts +25 -0
- package/lib/messages/connect-executor.executor.d.ts.map +1 -0
- package/lib/messages/connect-executor.executor.js +30 -0
- package/lib/messages/connect-executor.executor.js.map +1 -0
- package/lib/messages/connect-handler.executor.d.ts +25 -0
- package/lib/messages/connect-handler.executor.d.ts.map +1 -0
- package/lib/messages/connect-handler.executor.js +30 -0
- package/lib/messages/connect-handler.executor.js.map +1 -0
- package/lib/messages/connect-message.executor.d.ts +28 -0
- package/lib/messages/connect-message.executor.d.ts.map +1 -0
- package/lib/messages/connect-message.executor.js +31 -0
- package/lib/messages/connect-message.executor.js.map +1 -0
- package/lib/messages/connect.message.executor.d.ts +28 -0
- package/lib/messages/connect.message.executor.d.ts.map +1 -0
- package/lib/messages/connect.message.executor.js +31 -0
- package/lib/messages/connect.message.executor.js.map +1 -0
- package/lib/messages/disconnect-message.executor.d.ts +19 -0
- package/lib/messages/disconnect-message.executor.d.ts.map +1 -0
- package/lib/messages/disconnect-message.executor.js +25 -0
- package/lib/messages/disconnect-message.executor.js.map +1 -0
- package/lib/messages/eliminate-namespace.executor.d.ts +16 -0
- package/lib/messages/eliminate-namespace.executor.d.ts.map +1 -0
- package/lib/messages/eliminate-namespace.executor.js +22 -0
- package/lib/messages/eliminate-namespace.executor.js.map +1 -0
- package/lib/messages/index.d.ts +11 -0
- package/lib/messages/index.d.ts.map +1 -0
- package/lib/messages/index.js +24 -0
- package/lib/messages/index.js.map +1 -0
- package/lib/messages/lock-message.executor.d.ts +22 -0
- package/lib/messages/lock-message.executor.d.ts.map +1 -0
- package/lib/messages/lock-message.executor.js +26 -0
- package/lib/messages/lock-message.executor.js.map +1 -0
- package/lib/messages/remove-middleware.executor.d.ts +17 -0
- package/lib/messages/remove-middleware.executor.d.ts.map +1 -0
- package/lib/messages/remove-middleware.executor.js +22 -0
- package/lib/messages/remove-middleware.executor.js.map +1 -0
- package/lib/messages/unlock-message.executor.d.ts +21 -0
- package/lib/messages/unlock-message.executor.d.ts.map +1 -0
- package/lib/messages/unlock-message.executor.js +25 -0
- package/lib/messages/unlock-message.executor.js.map +1 -0
- package/lib/models/cancel-details.d.ts +9 -0
- package/lib/models/cancel-details.d.ts.map +1 -0
- package/lib/models/cancel-details.js +3 -0
- package/lib/models/cancel-details.js.map +1 -0
- package/lib/models/cancel-error.d.ts +7 -0
- package/lib/models/cancel-error.d.ts.map +1 -0
- package/lib/models/cancel-error.js +18 -0
- package/lib/models/cancel-error.js.map +1 -0
- package/lib/models/middleware-decision.enum.d.ts +5 -0
- package/lib/models/middleware-decision.enum.d.ts.map +1 -0
- package/lib/models/middleware-decision.enum.js +9 -0
- package/lib/models/middleware-decision.enum.js.map +1 -0
- package/lib/models/middleware-stage.enum.d.ts +6 -0
- package/lib/models/middleware-stage.enum.d.ts.map +1 -0
- package/lib/models/middleware-stage.enum.js +10 -0
- package/lib/models/middleware-stage.enum.js.map +1 -0
- package/lib/models/pipeline-context.d.ts +7 -0
- package/lib/models/pipeline-context.d.ts.map +1 -0
- package/lib/models/pipeline-context.js +3 -0
- package/lib/models/pipeline-context.js.map +1 -0
- package/lib/models/pipeline-result.d.ts +6 -0
- package/lib/models/pipeline-result.d.ts.map +1 -0
- package/lib/models/pipeline-result.js +3 -0
- package/lib/models/pipeline-result.js.map +1 -0
- package/lib/models/postboy-callback.message.d.ts +21 -0
- package/lib/models/postboy-callback.message.d.ts.map +1 -1
- package/lib/models/postboy-callback.message.js +23 -0
- package/lib/models/postboy-callback.message.js.map +1 -1
- package/lib/models/postboy-execution.handler.d.ts +6 -0
- package/lib/models/postboy-execution.handler.d.ts.map +1 -1
- package/lib/models/postboy-execution.handler.js.map +1 -1
- package/lib/models/postboy-executor.d.ts +1 -0
- package/lib/models/postboy-executor.d.ts.map +1 -1
- package/lib/models/postboy-executor.js.map +1 -1
- package/lib/models/postboy-message-metadata.d.ts +26 -0
- package/lib/models/postboy-message-metadata.d.ts.map +1 -0
- package/lib/models/postboy-message-metadata.js +3 -0
- package/lib/models/postboy-message-metadata.js.map +1 -0
- package/lib/models/postboy-message.context.d.ts +9 -0
- package/lib/models/postboy-message.context.d.ts.map +1 -0
- package/lib/models/postboy-message.context.js +3 -0
- package/lib/models/postboy-message.context.js.map +1 -0
- package/lib/models/postboy-subscription.d.ts +31 -2
- package/lib/models/postboy-subscription.d.ts.map +1 -1
- package/lib/models/postboy-subscription.js +31 -2
- package/lib/models/postboy-subscription.js.map +1 -1
- package/lib/models/postboy.message.d.ts +3 -0
- package/lib/models/postboy.message.d.ts.map +1 -1
- package/lib/models/postboy.message.js +7 -0
- package/lib/models/postboy.message.js.map +1 -1
- package/lib/models/postboy.settings.d.ts +13 -0
- package/lib/models/postboy.settings.d.ts.map +1 -0
- package/lib/models/postboy.settings.js +20 -0
- package/lib/models/postboy.settings.js.map +1 -0
- package/lib/postboy-abstract.registrator.d.ts +15 -32
- package/lib/postboy-abstract.registrator.d.ts.map +1 -1
- package/lib/postboy-abstract.registrator.js +68 -73
- package/lib/postboy-abstract.registrator.js.map +1 -1
- package/lib/postboy.service.d.ts +73 -39
- package/lib/postboy.service.d.ts.map +1 -1
- package/lib/postboy.service.js +124 -60
- package/lib/postboy.service.js.map +1 -1
- package/lib/services/namespace-registrator.d.ts +14 -0
- package/lib/services/namespace-registrator.d.ts.map +1 -0
- package/lib/services/namespace-registrator.js +21 -0
- package/lib/services/namespace-registrator.js.map +1 -0
- package/lib/services/postboy-context.service.d.ts +13 -0
- package/lib/services/postboy-context.service.d.ts.map +1 -0
- package/lib/services/postboy-context.service.js +50 -0
- package/lib/services/postboy-context.service.js.map +1 -0
- package/lib/services/postboy-dependency.resolver.d.ts +25 -0
- package/lib/services/postboy-dependency.resolver.d.ts.map +1 -1
- package/lib/services/postboy-dependency.resolver.js +25 -0
- package/lib/services/postboy-dependency.resolver.js.map +1 -1
- package/lib/services/postboy-message.store.d.ts +5 -1
- package/lib/services/postboy-message.store.d.ts.map +1 -1
- package/lib/services/postboy-message.store.js +28 -6
- package/lib/services/postboy-message.store.js.map +1 -1
- package/lib/services/postboy-middleware.d.ts +35 -0
- package/lib/services/postboy-middleware.d.ts.map +1 -0
- package/lib/services/postboy-middleware.js +47 -0
- package/lib/services/postboy-middleware.js.map +1 -0
- package/lib/services/postboy-middleware.service.d.ts +28 -0
- package/lib/services/postboy-middleware.service.d.ts.map +1 -1
- package/lib/services/postboy-middleware.service.js +30 -0
- package/lib/services/postboy-middleware.service.js.map +1 -1
- package/lib/services/postboy-namespace.store.d.ts +34 -0
- package/lib/services/postboy-namespace.store.d.ts.map +1 -0
- package/lib/services/postboy-namespace.store.js +54 -0
- package/lib/services/postboy-namespace.store.js.map +1 -0
- package/lib/utils/id.generator.d.ts +5 -0
- package/lib/utils/id.generator.d.ts.map +1 -0
- package/lib/utils/id.generator.js +18 -0
- package/lib/utils/id.generator.js.map +1 -0
- package/package.json +5 -10
package/lib/postboy.service.js
CHANGED
|
@@ -2,26 +2,53 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PostboyService = void 0;
|
|
4
4
|
const postboy_generic_message_1 = require("./models/postboy-generic-message");
|
|
5
|
-
const locker_store_1 = require("./locker.store");
|
|
6
5
|
const postboy_subscription_1 = require("./models/postboy-subscription");
|
|
7
6
|
const postboy_dependency_resolver_1 = require("./services/postboy-dependency.resolver");
|
|
7
|
+
const add_namespace_executor_1 = require("./messages/add-namespace.executor");
|
|
8
|
+
const eliminate_namespace_executor_1 = require("./messages/eliminate-namespace.executor");
|
|
9
|
+
const add_middleware_executor_1 = require("./messages/add-middleware.executor");
|
|
10
|
+
const remove_middleware_executor_1 = require("./messages/remove-middleware.executor");
|
|
11
|
+
const lock_message_executor_1 = require("./messages/lock-message.executor");
|
|
12
|
+
const unlock_message_executor_1 = require("./messages/unlock-message.executor");
|
|
13
|
+
const disconnect_message_executor_1 = require("./messages/disconnect-message.executor");
|
|
14
|
+
const connect_message_executor_1 = require("./messages/connect-message.executor");
|
|
15
|
+
const connect_executor_executor_1 = require("./messages/connect-executor.executor");
|
|
16
|
+
const connect_handler_executor_1 = require("./messages/connect-handler.executor");
|
|
17
|
+
const operators_1 = require("rxjs/internal/operators");
|
|
8
18
|
class PostboyService {
|
|
9
19
|
constructor(resolver) {
|
|
10
|
-
this.locker = new locker_store_1.LockerStore();
|
|
11
20
|
this.locked = new Set();
|
|
12
|
-
|
|
13
|
-
this.middleware =
|
|
14
|
-
this.store =
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
this.
|
|
21
|
+
this.dependencyResolver = resolver || new postboy_dependency_resolver_1.PostboyDependencyResolver();
|
|
22
|
+
this.middleware = this.dependencyResolver.getMiddlewareService();
|
|
23
|
+
this.store = this.dependencyResolver.getMessageStore();
|
|
24
|
+
this.namespaceStore = this.dependencyResolver.getNamespaceStore();
|
|
25
|
+
this.registerInfrastructureMessages();
|
|
26
|
+
}
|
|
27
|
+
registerInfrastructureMessages() {
|
|
28
|
+
this.store.registerExecutor(disconnect_message_executor_1.DisconnectMessage.ID, (e) => this.store.unregister(e.messageId));
|
|
29
|
+
this.store.registerExecutor(unlock_message_executor_1.UnlockMessage.ID, (e) => this.locked.delete((0, postboy_generic_message_1.checkId)(e.type)));
|
|
30
|
+
this.store.registerExecutor(lock_message_executor_1.LockMessage.ID, (e) => this.locked.add((0, postboy_generic_message_1.checkId)(e.type)));
|
|
31
|
+
this.store.registerExecutor(add_middleware_executor_1.AddMiddleware.ID, (e) => this.middleware.addMiddleware(e.middleware));
|
|
32
|
+
this.store.registerExecutor(remove_middleware_executor_1.RemoveMiddleware.ID, (e) => this.middleware.removeMiddleware(e.middleware));
|
|
33
|
+
this.store.registerExecutor(add_namespace_executor_1.AddNamespace.ID, (e) => this.namespaceStore.addSpace(e.space, this));
|
|
34
|
+
this.store.registerExecutor(eliminate_namespace_executor_1.EliminateNamespace.ID, (e) => this.namespaceStore.eliminateSpace(e.space));
|
|
35
|
+
this.store.registerExecutor(connect_message_executor_1.ConnectMessage.ID, (e) => {
|
|
36
|
+
const { type, sub, pipe } = e;
|
|
37
|
+
this.store.registerMessage((0, postboy_generic_message_1.checkId)(type), new postboy_subscription_1.PostboySubscription(sub, pipe));
|
|
38
|
+
});
|
|
39
|
+
this.store.registerExecutor(connect_executor_executor_1.ConnectExecutor.ID, (e) => {
|
|
40
|
+
const { type, exec } = e;
|
|
41
|
+
this.store.registerExecutor((0, postboy_generic_message_1.checkId)(type), exec);
|
|
42
|
+
});
|
|
43
|
+
this.store.registerExecutor(connect_handler_executor_1.ConnectHandler.ID, (e) => {
|
|
44
|
+
const { executor, handler } = e;
|
|
45
|
+
this.store.registerExecutor((0, postboy_generic_message_1.checkId)(executor), (e) => handler.handle(e));
|
|
46
|
+
});
|
|
21
47
|
}
|
|
22
48
|
/**
|
|
23
49
|
* Locks a specific message type to prevent further modifications or actions.
|
|
24
50
|
*
|
|
51
|
+
* @deprecated The method should be replaced with firing {@link LockMessage} message.
|
|
25
52
|
* @param {MessageType<T>} type - The message type to be locked. It must extend from the `PostboyGenericMessage`.
|
|
26
53
|
* @return {void} This method does not return a value.
|
|
27
54
|
*/
|
|
@@ -31,52 +58,43 @@ class PostboyService {
|
|
|
31
58
|
/**
|
|
32
59
|
* Unlocks a previously locked message type by removing its ID from the locked set.
|
|
33
60
|
*
|
|
61
|
+
* @deprecated The method should be replaced with firing {@link UnlockMessage} message.
|
|
34
62
|
* @param {MessageType<T>} type - The message type to unlock, which is a generic type extending PostboyGenericMessage.
|
|
35
63
|
* @return {void} This method does not return any value.
|
|
36
64
|
*/
|
|
37
65
|
unlock(type) {
|
|
38
66
|
this.locked.delete((0, postboy_generic_message_1.checkId)(type));
|
|
39
67
|
}
|
|
40
|
-
addMiddleware(middleware) {
|
|
41
|
-
return this.middleware.addMiddleware(middleware);
|
|
42
|
-
}
|
|
43
|
-
removeMiddleware(middleware) {
|
|
44
|
-
return this.middleware.removeMiddleware(middleware);
|
|
45
|
-
}
|
|
46
68
|
/**
|
|
47
|
-
*
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* @deprecated The method should be replaced with exec<T>
|
|
69
|
+
* Adds a middleware to the middleware stack.
|
|
70
|
+
*
|
|
71
|
+
* @deprecated The method should be replaced with firing {@link AddMiddleware} message.
|
|
72
|
+
* @param {PostboyMiddleware} middleware - The middleware instance to be added.
|
|
73
|
+
* @return {void}
|
|
54
74
|
*/
|
|
55
|
-
|
|
56
|
-
this.middleware.
|
|
57
|
-
return this.store.getExecutor(executor.id)(executor);
|
|
75
|
+
addMiddleware(middleware) {
|
|
76
|
+
return this.middleware.addMiddleware(middleware);
|
|
58
77
|
}
|
|
59
78
|
/**
|
|
60
|
-
*
|
|
79
|
+
* Removes a middleware from the current middleware stack.
|
|
80
|
+
*
|
|
81
|
+
* @deprecated The method should be replaced with firing {@link RemoveMiddleware} message.
|
|
82
|
+
* @param {PostboyMiddleware} middleware - The middleware instance to be removed.
|
|
83
|
+
* @return {void} No return value.
|
|
61
84
|
*/
|
|
62
|
-
|
|
63
|
-
this.
|
|
85
|
+
removeMiddleware(middleware) {
|
|
86
|
+
return this.middleware.removeMiddleware(middleware);
|
|
64
87
|
}
|
|
65
88
|
/**
|
|
66
|
-
*
|
|
89
|
+
* Unregisters a message identified by the given ID from the store.
|
|
90
|
+
*
|
|
91
|
+
* @deprecated The method should be replaced with firing {@link DisconnectMessage} message.
|
|
92
|
+
* @param {string} id - The unique identifier of the item to unregister.
|
|
93
|
+
* @return {void} No value is returned.
|
|
67
94
|
*/
|
|
68
|
-
registerWithPipe(id, sub, pipe) {
|
|
69
|
-
this.store.registerMessage(id, new postboy_subscription_1.PostboySubscription(sub, pipe));
|
|
70
|
-
}
|
|
71
95
|
unregister(id) {
|
|
72
96
|
return this.store.unregister(id);
|
|
73
97
|
}
|
|
74
|
-
/**
|
|
75
|
-
* @deprecated The method should be replaced with sub<T>
|
|
76
|
-
*/
|
|
77
|
-
subscribe(id) {
|
|
78
|
-
return this.store.getMessage(id, id).sub();
|
|
79
|
-
}
|
|
80
98
|
/**
|
|
81
99
|
* Fires a registered event and passes the message to its subscribers.
|
|
82
100
|
*
|
|
@@ -86,7 +104,7 @@ class PostboyService {
|
|
|
86
104
|
*/
|
|
87
105
|
fire(message) {
|
|
88
106
|
this.middleware.manage(message);
|
|
89
|
-
if (this.
|
|
107
|
+
if (!this.locked.has(message.id))
|
|
90
108
|
this.store.getMessage(message.id, message.constructor.name).fire(message);
|
|
91
109
|
}
|
|
92
110
|
/**
|
|
@@ -99,12 +117,23 @@ class PostboyService {
|
|
|
99
117
|
*/
|
|
100
118
|
fireCallback(message, action) {
|
|
101
119
|
this.middleware.manage(message);
|
|
120
|
+
this.store.callbackFired(message);
|
|
102
121
|
message.result.subscribe(action);
|
|
103
|
-
if (this.
|
|
122
|
+
if (!this.locked.has(message.id))
|
|
104
123
|
setTimeout(() => this.store.getMessage(message.id, message.constructor.name).fire(message));
|
|
105
124
|
return message.result;
|
|
106
125
|
}
|
|
107
|
-
|
|
126
|
+
/**
|
|
127
|
+
* Executes the provided executor function and returns its result.
|
|
128
|
+
*
|
|
129
|
+
* @param {PostboyExecutor<T>} executor The executor to be executed, which includes its identifier and logic.
|
|
130
|
+
* @return {T} The resulting output from the executed executor function.
|
|
131
|
+
* @throws {Error} If the specified executor is not registered.
|
|
132
|
+
*/
|
|
133
|
+
exec(executor) {
|
|
134
|
+
this.middleware.manage(executor);
|
|
135
|
+
return this.store.getExecutor(executor.id)(executor);
|
|
136
|
+
}
|
|
108
137
|
/**
|
|
109
138
|
* Subscribes to a specific message type and returns an observable of that type.
|
|
110
139
|
*
|
|
@@ -114,9 +143,19 @@ class PostboyService {
|
|
|
114
143
|
sub(type) {
|
|
115
144
|
return this.store.getMessage((0, postboy_generic_message_1.checkId)(type), type.name).sub();
|
|
116
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* Subscribes to a specific message type and automatically unsubscribes after receiving the first message.
|
|
148
|
+
*
|
|
149
|
+
* @param type The type of message to subscribe to.
|
|
150
|
+
* @return An observable that emits the first message of the specified type and then completes.
|
|
151
|
+
*/
|
|
152
|
+
once(type) {
|
|
153
|
+
return this.sub(type).pipe((0, operators_1.first)());
|
|
154
|
+
}
|
|
117
155
|
/**
|
|
118
156
|
* Registers a given message type and its associated subject subscription with the system.
|
|
119
157
|
*
|
|
158
|
+
* @deprecated The method should be replaced with firing {@link ConnectMessage} message.
|
|
120
159
|
* @param type The constructor function of the message type that extends the PostboyGenericMessage.
|
|
121
160
|
* @param sub The Subject instance for the provided message type, used for managing subscriptions.
|
|
122
161
|
* @return {void} No return value.
|
|
@@ -127,6 +166,7 @@ class PostboyService {
|
|
|
127
166
|
/**
|
|
128
167
|
* Registers a generic message type with a Subject and a transformation pipe.
|
|
129
168
|
*
|
|
169
|
+
* @deprecated The method should be replaced with firing {@link ConnectMessage} message.
|
|
130
170
|
* @param {MessageType<T>} type - The constructor of the message type being registered.
|
|
131
171
|
* @param {Subject<T>} sub - The Subject instance used to handle incoming messages of the specified type.
|
|
132
172
|
* @param {(s: Subject<T>) => Observable<T>} pipe - A function that applies a transformation or processing logic to the Subject and returns an Observable.
|
|
@@ -136,35 +176,59 @@ class PostboyService {
|
|
|
136
176
|
this.store.registerMessage((0, postboy_generic_message_1.checkId)(type), new postboy_subscription_1.PostboySubscription(sub, pipe));
|
|
137
177
|
}
|
|
138
178
|
/**
|
|
139
|
-
*
|
|
179
|
+
* Registers an executor for a specified message type.
|
|
140
180
|
*
|
|
141
|
-
* @
|
|
142
|
-
* @param {
|
|
143
|
-
* @
|
|
181
|
+
* @deprecated The method should be replaced with firing {@link ConnectExecutor} message.
|
|
182
|
+
* @param {MessageType<E>} type - The message type for which the executor is being registered.
|
|
183
|
+
* @param {(e: E) => T} exec - The executor function that will handle messages of the specified type.
|
|
184
|
+
* @return {void} This method does not return any value.
|
|
144
185
|
*/
|
|
145
186
|
recordExecutor(type, exec) {
|
|
146
187
|
this.store.registerExecutor((0, postboy_generic_message_1.checkId)(type), exec);
|
|
147
188
|
}
|
|
148
189
|
/**
|
|
149
|
-
*
|
|
190
|
+
* Registers a handler for a specific executor type.
|
|
150
191
|
*
|
|
151
|
-
* @
|
|
152
|
-
* @
|
|
153
|
-
* @
|
|
192
|
+
* @deprecated The method should be replaced with firing {@link ConnectHandler} message.
|
|
193
|
+
* @param executor The constructor of the executor class that extends `PostboyExecutor<R>`.
|
|
194
|
+
* @param handler An instance of `PostboyExecutionHandler<R, E>` that defines the logic for handling the executor.
|
|
195
|
+
* @return void
|
|
154
196
|
*/
|
|
155
|
-
|
|
156
|
-
this.
|
|
157
|
-
return this.store.getExecutor(executor.id)(executor);
|
|
197
|
+
recordHandler(executor, handler) {
|
|
198
|
+
this.store.registerExecutor((0, postboy_generic_message_1.checkId)(executor), (e) => handler.handle(e));
|
|
158
199
|
}
|
|
159
200
|
/**
|
|
160
|
-
*
|
|
201
|
+
* Adds a namespace to the namespace store.
|
|
161
202
|
*
|
|
162
|
-
* @
|
|
163
|
-
* @param {
|
|
164
|
-
* @return {
|
|
203
|
+
* @deprecated The method should be replaced with firing {@link AddNamespace} message.
|
|
204
|
+
* @param {string} space - The name of the namespace to be added.
|
|
205
|
+
* @return {PostboyAbstractRegistrator} The instance of the namespace after adding the specified namespace.
|
|
165
206
|
*/
|
|
166
|
-
|
|
167
|
-
this.
|
|
207
|
+
addNamespace(space) {
|
|
208
|
+
return this.namespaceStore.addSpace(space, this);
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Removes the specified namespace from the namespace store.
|
|
212
|
+
*
|
|
213
|
+
* @deprecated The method should be replaced with firing {@link EliminateNamespace} message.
|
|
214
|
+
* @param {string} space - The name of the namespace to be removed.
|
|
215
|
+
* @return {void} This method does not return a value.
|
|
216
|
+
*/
|
|
217
|
+
eliminateNamespace(space) {
|
|
218
|
+
var _a;
|
|
219
|
+
return (_a = this.namespaceStore) === null || _a === void 0 ? void 0 : _a.eliminateSpace(space);
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Disposes of resources and cleans up any internal components or stores associated with the instance.
|
|
223
|
+
* This method ensures that all resources are properly released to avoid memory leaks.
|
|
224
|
+
*
|
|
225
|
+
* @return {void} This method does not return a value.
|
|
226
|
+
*/
|
|
227
|
+
dispose() {
|
|
228
|
+
var _a;
|
|
229
|
+
(_a = this.namespaceStore) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
230
|
+
this.store.dispose();
|
|
231
|
+
this.middleware.dispose();
|
|
168
232
|
}
|
|
169
233
|
}
|
|
170
234
|
exports.PostboyService = PostboyService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postboy.service.js","sourceRoot":"","sources":["../src/postboy.service.ts"],"names":[],"mappings":";;;AACA,8EAAkF;AAClF,
|
|
1
|
+
{"version":3,"file":"postboy.service.js","sourceRoot":"","sources":["../src/postboy.service.ts"],"names":[],"mappings":";;;AACA,8EAAkF;AAClF,wEAAoE;AAMpE,wFAAmF;AAInF,8EAAiE;AACjE,0FAA6E;AAC7E,gFAAmE;AACnE,sFAAyE;AACzE,4EAA+D;AAC/D,gFAAmE;AACnE,wFAA2E;AAC3E,kFAAqE;AACrE,oFAAuE;AACvE,kFAAqE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ostboyAbstractRegistrator } from '../postboy-abstract.registrator';
|
|
2
|
+
import { PostboyService } from '../postboy.service';
|
|
3
|
+
/**
|
|
4
|
+
* NamespaceRegistrator is a specialized class that extends PostboyAbstractRegistrator.
|
|
5
|
+
*
|
|
6
|
+
* @class NamespaceRegistrator
|
|
7
|
+
* @extends PostboyAbstractRegistrator
|
|
8
|
+
* @param {PostboyService} postboy - An instance of the PostboyService, used for managing registrations.
|
|
9
|
+
*/
|
|
10
|
+
export declare class NamespaceRegistrator extends PostboyAbstractRegistrator {
|
|
11
|
+
constructor(postboy: PostboyService);
|
|
12
|
+
protected _up(): void;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=namespace-registrator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"namespace-registrator.d.ts","sourceRoot":"","sources":["../../src/services/namespace-registrator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD;;;;;;GAMG;AACH,qBAAa,oBAAqB,SAAQ,0BAA0B;gBACtD,OAAO,EAAE,cAAc;IAInC,SAAS,CAAC,GAAG,IAAI,IAAI;CAGtB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NamespaceRegistrator = void 0;
|
|
4
|
+
const postboy_abstract_registrator_1 = require("../postboy-abstract.registrator");
|
|
5
|
+
/**
|
|
6
|
+
* NamespaceRegistrator is a specialized class that extends PostboyAbstractRegistrator.
|
|
7
|
+
*
|
|
8
|
+
* @class NamespaceRegistrator
|
|
9
|
+
* @extends PostboyAbstractRegistrator
|
|
10
|
+
* @param {PostboyService} postboy - An instance of the PostboyService, used for managing registrations.
|
|
11
|
+
*/
|
|
12
|
+
class NamespaceRegistrator extends postboy_abstract_registrator_1.PostboyAbstractRegistrator {
|
|
13
|
+
constructor(postboy) {
|
|
14
|
+
super(postboy);
|
|
15
|
+
}
|
|
16
|
+
_up() {
|
|
17
|
+
// ignore
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.NamespaceRegistrator = NamespaceRegistrator;
|
|
21
|
+
//# sourceMappingURL=namespace-registrator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"namespace-registrator.js","sourceRoot":"","sources":["../../src/services/namespace-registrator.ts"],"names":[],"mappings":";;;AAAA,kFAA6E;AAG7E;;;;;;GAMG;AACH,MAAa,oBAAqB,SAAQ,yDAA0B;IAClE,YAAY,OAAuB;QACjC,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;IAES,GAAG;QACX,SAAS;IACX,CAAC;CACF;AARD,oDAQC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PostboyMessageContext } from '../models/postboy-message.context';
|
|
2
|
+
import { PostboyMessage } from '../models/postboy.message';
|
|
3
|
+
export declare class PostboyContextService {
|
|
4
|
+
active: boolean;
|
|
5
|
+
private readonly storage;
|
|
6
|
+
constructor(active?: boolean);
|
|
7
|
+
private get current();
|
|
8
|
+
run<T>(context: PostboyMessageContext, action: () => T): T;
|
|
9
|
+
private createRoot;
|
|
10
|
+
createChild(message: PostboyMessage): PostboyMessageContext;
|
|
11
|
+
dispose(): void;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=postboy-context.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postboy-context.service.d.ts","sourceRoot":"","sources":["../../src/services/postboy-context.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,qBAAa,qBAAqB;IAGb,MAAM,EAAE,OAAO;IAFlC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAkD;gBAEvD,MAAM,GAAE,OAAc;IAEzC,OAAO,KAAK,OAAO,GAElB;IAEM,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,qBAAqB,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC;IAIjE,OAAO,CAAC,UAAU;IAUX,WAAW,CAAC,OAAO,EAAE,cAAc,GAAG,qBAAqB;IAmB3D,OAAO,IAAI,IAAI;CAGvB"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PostboyContextService = void 0;
|
|
4
|
+
const node_async_hooks_1 = require("node:async_hooks");
|
|
5
|
+
class PostboyContextService {
|
|
6
|
+
constructor(active = true) {
|
|
7
|
+
this.active = active;
|
|
8
|
+
this.storage = new node_async_hooks_1.AsyncLocalStorage();
|
|
9
|
+
}
|
|
10
|
+
get current() {
|
|
11
|
+
return this.storage.getStore();
|
|
12
|
+
}
|
|
13
|
+
run(context, action) {
|
|
14
|
+
return this.active ? this.storage.run(context, action) : action();
|
|
15
|
+
}
|
|
16
|
+
createRoot(message) {
|
|
17
|
+
return {
|
|
18
|
+
correlationId: message.id,
|
|
19
|
+
currentMessageId: message.id,
|
|
20
|
+
depth: 0,
|
|
21
|
+
startedAt: new Date(),
|
|
22
|
+
tags: new Set(),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
createChild(message) {
|
|
26
|
+
var _a, _b, _c, _d;
|
|
27
|
+
if (!this.active)
|
|
28
|
+
return this.createRoot(message);
|
|
29
|
+
const parent = this.current;
|
|
30
|
+
const tags = (_b = (_a = this.current) === null || _a === void 0 ? void 0 : _a.tags) !== null && _b !== void 0 ? _b : new Set();
|
|
31
|
+
(_d = (_c = message.metadata) === null || _c === void 0 ? void 0 : _c.tags) === null || _d === void 0 ? void 0 : _d.forEach((tag) => tags.add(tag));
|
|
32
|
+
const data = !parent
|
|
33
|
+
? this.createRoot(message)
|
|
34
|
+
: {
|
|
35
|
+
correlationId: parent.correlationId,
|
|
36
|
+
currentMessageId: message.id,
|
|
37
|
+
parentMessageId: parent.currentMessageId,
|
|
38
|
+
depth: parent.depth + 1,
|
|
39
|
+
startedAt: parent.startedAt,
|
|
40
|
+
tags,
|
|
41
|
+
};
|
|
42
|
+
message.setMetadata({ correlationId: data.correlationId, causationId: data.parentMessageId, tags: data.tags });
|
|
43
|
+
return data;
|
|
44
|
+
}
|
|
45
|
+
dispose() {
|
|
46
|
+
this.storage.disable();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.PostboyContextService = PostboyContextService;
|
|
50
|
+
//# sourceMappingURL=postboy-context.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postboy-context.service.js","sourceRoot":"","sources":["../../src/services/postboy-context.service.ts"],"names":[],"mappings":";;;AAAA,uDAAqD;AAIrD,MAAa,qBAAqB;IAGhC,YAAmB,SAAkB,IAAI;QAAtB,WAAM,GAAN,MAAM,CAAgB;QAFxB,YAAO,GAAG,IAAI,oCAAiB,EAAyB,CAAC;IAE9B,CAAC;IAE7C,IAAY,OAAO;QACjB,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;IACjC,CAAC;IAEM,GAAG,CAAI,OAA8B,EAAE,MAAe;QAC3D,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACpE,CAAC;IAEO,UAAU,CAAC,OAAuB;QACxC,OAAO;YACL,aAAa,EAAE,OAAO,CAAC,EAAE;YACzB,gBAAgB,EAAE,OAAO,CAAC,EAAE;YAC5B,KAAK,EAAE,CAAC;YACR,SAAS,EAAE,IAAI,IAAI,EAAE;YACrB,IAAI,EAAE,IAAI,GAAG,EAAE;SAChB,CAAC;IACJ,CAAC;IAEM,WAAW,CAAC,OAAuB;;QACxC,IAAI,CAAC,IAAI,CAAC,MAAM;YAAE,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAClD,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,MAAM,IAAI,GAAG,MAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,IAAI,mCAAI,IAAI,GAAG,EAAE,CAAC;QAC7C,MAAA,MAAA,OAAO,CAAC,QAAQ,0CAAE,IAAI,0CAAE,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QACxD,MAAM,IAAI,GAAG,CAAC,MAAM;YAClB,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;YAC1B,CAAC,CAAC;gBACE,aAAa,EAAE,MAAM,CAAC,aAAa;gBACnC,gBAAgB,EAAE,OAAO,CAAC,EAAE;gBAC5B,eAAe,EAAE,MAAM,CAAC,gBAAgB;gBACxC,KAAK,EAAE,MAAM,CAAC,KAAK,GAAG,CAAC;gBACvB,SAAS,EAAE,MAAM,CAAC,SAAS;gBAC3B,IAAI;aACL,CAAC;QACN,OAAO,CAAC,WAAW,CAAC,EAAE,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,WAAW,EAAE,IAAI,CAAC,eAAe,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QAC/G,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,OAAO;QACZ,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;IACzB,CAAC;CACF;AA7CD,sDA6CC"}
|
|
@@ -1,7 +1,32 @@
|
|
|
1
1
|
import { PostboyMiddlewareService } from './postboy-middleware.service';
|
|
2
2
|
import { PostboyMessageStore } from './postboy-message.store';
|
|
3
|
+
import { PostboyNamespaceStore } from './postboy-namespace.store';
|
|
3
4
|
export declare class PostboyDependencyResolver {
|
|
5
|
+
/**
|
|
6
|
+
* Retrieves an instance of the PostboyMiddlewareService.
|
|
7
|
+
*
|
|
8
|
+
* This function initializes and returns a new instance of the
|
|
9
|
+
* PostboyMiddlewareService, which can be used to configure and manage
|
|
10
|
+
* middleware for a specific module or application.
|
|
11
|
+
*
|
|
12
|
+
* @returns {PostboyMiddlewareService} A new instance of PostboyMiddlewareService.
|
|
13
|
+
*/
|
|
4
14
|
getMiddlewareService: () => PostboyMiddlewareService;
|
|
15
|
+
/**
|
|
16
|
+
* A function that instantiates and returns a new instance of PostboyMessageStore.
|
|
17
|
+
*
|
|
18
|
+
* This function serves as a factory method for creating instances
|
|
19
|
+
* of the PostboyMessageStore class.
|
|
20
|
+
*
|
|
21
|
+
* @returns {PostboyMessageStore} A new instance of the PostboyMessageStore class.
|
|
22
|
+
*/
|
|
5
23
|
getMessageStore: () => PostboyMessageStore;
|
|
24
|
+
/**
|
|
25
|
+
* Creates and initializes a new instance of PostboyNamespaceStore using the provided PostboyService instance.
|
|
26
|
+
*
|
|
27
|
+
* @function getNamespaceStore
|
|
28
|
+
* @returns {PostboyNamespaceStore} A new instance of PostboyNamespaceStore associated with the given PostboyService.
|
|
29
|
+
*/
|
|
30
|
+
getNamespaceStore: () => PostboyNamespaceStore;
|
|
6
31
|
}
|
|
7
32
|
//# sourceMappingURL=postboy-dependency.resolver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postboy-dependency.resolver.d.ts","sourceRoot":"","sources":["../../src/services/postboy-dependency.resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"postboy-dependency.resolver.d.ts","sourceRoot":"","sources":["../../src/services/postboy-dependency.resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAElE,qBAAa,yBAAyB;IACpC;;;;;;;;OAQG;IACH,oBAAoB,iCAAwC;IAC5D;;;;;;;OAOG;IACH,eAAe,4BAAmC;IAClD;;;;;OAKG;IACH,iBAAiB,8BAAqC;CACvD"}
|
|
@@ -3,10 +3,35 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.PostboyDependencyResolver = void 0;
|
|
4
4
|
const postboy_middleware_service_1 = require("./postboy-middleware.service");
|
|
5
5
|
const postboy_message_store_1 = require("./postboy-message.store");
|
|
6
|
+
const postboy_namespace_store_1 = require("./postboy-namespace.store");
|
|
6
7
|
class PostboyDependencyResolver {
|
|
7
8
|
constructor() {
|
|
9
|
+
/**
|
|
10
|
+
* Retrieves an instance of the PostboyMiddlewareService.
|
|
11
|
+
*
|
|
12
|
+
* This function initializes and returns a new instance of the
|
|
13
|
+
* PostboyMiddlewareService, which can be used to configure and manage
|
|
14
|
+
* middleware for a specific module or application.
|
|
15
|
+
*
|
|
16
|
+
* @returns {PostboyMiddlewareService} A new instance of PostboyMiddlewareService.
|
|
17
|
+
*/
|
|
8
18
|
this.getMiddlewareService = () => new postboy_middleware_service_1.PostboyMiddlewareService();
|
|
19
|
+
/**
|
|
20
|
+
* A function that instantiates and returns a new instance of PostboyMessageStore.
|
|
21
|
+
*
|
|
22
|
+
* This function serves as a factory method for creating instances
|
|
23
|
+
* of the PostboyMessageStore class.
|
|
24
|
+
*
|
|
25
|
+
* @returns {PostboyMessageStore} A new instance of the PostboyMessageStore class.
|
|
26
|
+
*/
|
|
9
27
|
this.getMessageStore = () => new postboy_message_store_1.PostboyMessageStore();
|
|
28
|
+
/**
|
|
29
|
+
* Creates and initializes a new instance of PostboyNamespaceStore using the provided PostboyService instance.
|
|
30
|
+
*
|
|
31
|
+
* @function getNamespaceStore
|
|
32
|
+
* @returns {PostboyNamespaceStore} A new instance of PostboyNamespaceStore associated with the given PostboyService.
|
|
33
|
+
*/
|
|
34
|
+
this.getNamespaceStore = () => new postboy_namespace_store_1.PostboyNamespaceStore();
|
|
10
35
|
}
|
|
11
36
|
}
|
|
12
37
|
exports.PostboyDependencyResolver = PostboyDependencyResolver;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postboy-dependency.resolver.js","sourceRoot":"","sources":["../../src/services/postboy-dependency.resolver.ts"],"names":[],"mappings":";;;AAAA,6EAAwE;AACxE,mEAA8D;
|
|
1
|
+
{"version":3,"file":"postboy-dependency.resolver.js","sourceRoot":"","sources":["../../src/services/postboy-dependency.resolver.ts"],"names":[],"mappings":";;;AAAA,6EAAwE;AACxE,mEAA8D;AAC9D,uEAAkE;AAElE,MAAa,yBAAyB;IAAtC;QACE;;;;;;;;WAQG;QACH,yBAAoB,GAAG,GAAG,EAAE,CAAC,IAAI,qDAAwB,EAAE,CAAC;QAC5D;;;;;;;WAOG;QACH,oBAAe,GAAG,GAAG,EAAE,CAAC,IAAI,2CAAmB,EAAE,CAAC;QAClD;;;;;WAKG;QACH,sBAAiB,GAAG,GAAG,EAAE,CAAC,IAAI,+CAAqB,EAAE,CAAC;IACxD,CAAC;CAAA;AA3BD,8DA2BC"}
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import { PostboySubscription } from '../models/postboy-subscription';
|
|
2
2
|
import { PostboyExecutor } from '../models/postboy-executor';
|
|
3
|
+
import { PostboyCallbackMessage } from '../models/postboy-callback.message';
|
|
3
4
|
/**
|
|
4
5
|
* The PostboyMessageStore is a utility class for managing message subscriptions and executors.
|
|
5
6
|
* It provides functionality to register, retrieve, and unregister subscription-based messages and executors.
|
|
6
7
|
*/
|
|
7
8
|
export declare class PostboyMessageStore {
|
|
8
|
-
protected
|
|
9
|
+
protected messages: Map<string, PostboySubscription<any>>;
|
|
9
10
|
protected executors: Map<string, (e: PostboyExecutor<any>) => any>;
|
|
11
|
+
protected callbacks: Map<string, (() => void)[]>;
|
|
10
12
|
registerMessage(id: string, sub: PostboySubscription<any>): void;
|
|
11
13
|
registerExecutor(id: string, executor: (e: PostboyExecutor<any>) => any): void;
|
|
14
|
+
callbackFired(message: PostboyCallbackMessage<any>): void;
|
|
12
15
|
getMessage(id: string, name: string): PostboySubscription<any>;
|
|
13
16
|
getExecutor<T>(id: string): (e: PostboyExecutor<T>) => T;
|
|
14
17
|
unregister(id: string): void;
|
|
18
|
+
dispose(): void;
|
|
15
19
|
}
|
|
16
20
|
//# sourceMappingURL=postboy-message.store.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postboy-message.store.d.ts","sourceRoot":"","sources":["../../src/services/postboy-message.store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"postboy-message.store.d.ts","sourceRoot":"","sources":["../../src/services/postboy-message.store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAE5E;;;GAGG;AACH,qBAAa,mBAAmB;IAC9B,SAAS,CAAC,QAAQ,wCAA+C;IACjE,SAAS,CAAC,SAAS,kBAAuB,gBAAgB,GAAG,CAAC,KAAK,GAAG,EAAI;IAC1E,SAAS,CAAC,SAAS,qBAA0B,IAAI,KAAO;IAEjD,eAAe,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,mBAAmB,CAAC,GAAG,CAAC,GAAG,IAAI;IAMhE,gBAAgB,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,eAAe,CAAC,GAAG,CAAC,KAAK,GAAG,GAAG,IAAI;IAMrF,aAAa,CAAC,OAAO,EAAE,sBAAsB,CAAC,GAAG,CAAC,GAAG,IAAI;IAOlD,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,mBAAmB,CAAC,GAAG,CAAC;IAM9D,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,GAAG,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,KAAK,CAAC;IAMxD,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAQ5B,OAAO,IAAI,IAAI;CAOvB"}
|
|
@@ -7,17 +7,30 @@ exports.PostboyMessageStore = void 0;
|
|
|
7
7
|
*/
|
|
8
8
|
class PostboyMessageStore {
|
|
9
9
|
constructor() {
|
|
10
|
-
this.
|
|
10
|
+
this.messages = new Map();
|
|
11
11
|
this.executors = new Map();
|
|
12
|
+
this.callbacks = new Map();
|
|
12
13
|
}
|
|
13
14
|
registerMessage(id, sub) {
|
|
14
|
-
|
|
15
|
+
// tslint:disable-next-line:no-console
|
|
16
|
+
if (this.messages.has(id))
|
|
17
|
+
console.warn(`Message with id ${id} already registered. Overriding...`);
|
|
18
|
+
this.messages.set(id, sub);
|
|
15
19
|
}
|
|
16
20
|
registerExecutor(id, executor) {
|
|
21
|
+
// tslint:disable-next-line:no-console
|
|
22
|
+
if (this.executors.has(id))
|
|
23
|
+
console.warn(`Executor with id ${id} already registered. Overriding...`);
|
|
17
24
|
this.executors.set(id, executor);
|
|
18
25
|
}
|
|
26
|
+
callbackFired(message) {
|
|
27
|
+
const existingCallbacks = this.callbacks.get(message.id);
|
|
28
|
+
existingCallbacks
|
|
29
|
+
? existingCallbacks.push(() => message.complete())
|
|
30
|
+
: this.callbacks.set(message.id, [() => message.complete()]);
|
|
31
|
+
}
|
|
19
32
|
getMessage(id, name) {
|
|
20
|
-
const msg = this.
|
|
33
|
+
const msg = this.messages.get(id);
|
|
21
34
|
if (!msg)
|
|
22
35
|
throw new Error(`There is no registered event ${name}`);
|
|
23
36
|
return msg;
|
|
@@ -29,11 +42,20 @@ class PostboyMessageStore {
|
|
|
29
42
|
return executorFunction;
|
|
30
43
|
}
|
|
31
44
|
unregister(id) {
|
|
32
|
-
var _a;
|
|
33
|
-
(_a = this.
|
|
34
|
-
this.
|
|
45
|
+
var _a, _b;
|
|
46
|
+
(_a = this.messages.get(id)) === null || _a === void 0 ? void 0 : _a.finish();
|
|
47
|
+
this.messages.delete(id);
|
|
48
|
+
(_b = this.callbacks.get(id)) === null || _b === void 0 ? void 0 : _b.forEach((c) => c());
|
|
49
|
+
this.callbacks.delete(id);
|
|
35
50
|
this.executors.delete(id);
|
|
36
51
|
}
|
|
52
|
+
dispose() {
|
|
53
|
+
this.messages.forEach((m, id) => this.unregister(id));
|
|
54
|
+
this.callbacks.forEach((fs) => fs.forEach((f) => f()));
|
|
55
|
+
this.messages.clear();
|
|
56
|
+
this.executors.clear();
|
|
57
|
+
this.callbacks.clear();
|
|
58
|
+
}
|
|
37
59
|
}
|
|
38
60
|
exports.PostboyMessageStore = PostboyMessageStore;
|
|
39
61
|
//# sourceMappingURL=postboy-message.store.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postboy-message.store.js","sourceRoot":"","sources":["../../src/services/postboy-message.store.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"postboy-message.store.js","sourceRoot":"","sources":["../../src/services/postboy-message.store.ts"],"names":[],"mappings":";;;AAIA;;;GAGG;AACH,MAAa,mBAAmB;IAAhC;QACY,aAAQ,GAAG,IAAI,GAAG,EAAoC,CAAC;QACvD,cAAS,GAAG,IAAI,GAAG,EAA4C,CAAC;QAChE,cAAS,GAAG,IAAI,GAAG,EAA0B,CAAC;IAgD1D,CAAC;IA9CQ,eAAe,CAAC,EAAU,EAAE,GAA6B;QAC9D,sCAAsC;QACtC,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YAAE,OAAO,CAAC,IAAI,CAAC,mBAAmB,EAAE,oCA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