@artstesh/postboy 2.1.9 → 3.0.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 +27 -68
- package/lib/i-postboy-depending.service.d.ts +3 -3
- package/lib/i-postboy-depending.service.js +2 -2
- package/lib/index.d.ts +9 -10
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +28 -29
- package/lib/index.js.map +1 -1
- package/lib/models/message-queue.model.d.ts +43 -43
- package/lib/models/message-queue.model.js +65 -65
- package/lib/models/message-queue.model.js.map +1 -1
- package/lib/models/postboy-callback.message.d.ts +26 -8
- package/lib/models/postboy-callback.message.d.ts.map +1 -1
- package/lib/models/postboy-callback.message.js +36 -18
- package/lib/models/postboy-callback.message.js.map +1 -1
- package/lib/models/postboy-execution.handler.d.ts +14 -14
- package/lib/models/postboy-execution.handler.js +16 -16
- package/lib/models/postboy-executor.d.ts +3 -3
- package/lib/models/postboy-executor.d.ts.map +1 -1
- package/lib/models/postboy-executor.js +7 -7
- package/lib/models/postboy-executor.js.map +1 -1
- package/lib/models/postboy-generic-message.d.ts +7 -7
- package/lib/models/postboy-generic-message.d.ts.map +1 -1
- package/lib/models/postboy-generic-message.js +16 -18
- package/lib/models/postboy-generic-message.js.map +1 -1
- package/lib/models/postboy-middleware.d.ts +5 -0
- package/lib/models/postboy-middleware.d.ts.map +1 -0
- package/lib/models/{postboy-bbb.js → postboy-middleware.js} +1 -1
- package/lib/models/postboy-middleware.js.map +1 -0
- package/lib/models/postboy-subscription.d.ts +6 -6
- package/lib/models/postboy-subscription.js +10 -10
- package/lib/models/postboy.message.d.ts +4 -0
- package/lib/models/postboy.message.d.ts.map +1 -0
- package/lib/models/postboy.message.js +10 -0
- package/lib/models/postboy.message.js.map +1 -0
- package/lib/models/queue.d.ts +11 -0
- package/lib/models/queue.d.ts.map +1 -0
- package/lib/models/queue.js +34 -0
- package/lib/models/queue.js.map +1 -0
- package/lib/postboy-abstract.registrator.d.ts +89 -113
- package/lib/postboy-abstract.registrator.d.ts.map +1 -1
- package/lib/postboy-abstract.registrator.js +108 -141
- package/lib/postboy-abstract.registrator.js.map +1 -1
- package/lib/postboy.service.d.ts +91 -105
- package/lib/postboy.service.d.ts.map +1 -1
- package/lib/postboy.service.js +140 -161
- package/lib/postboy.service.js.map +1 -1
- package/package.json +2 -4
- package/lib/locker.store.d.ts +0 -9
- package/lib/locker.store.d.ts.map +0 -1
- package/lib/locker.store.js +0 -27
- package/lib/locker.store.js.map +0 -1
- package/lib/mocks/message-history-item-mock.d.ts +0 -10
- package/lib/mocks/message-history-item-mock.d.ts.map +0 -1
- package/lib/mocks/message-history-item-mock.js +0 -26
- package/lib/mocks/message-history-item-mock.js.map +0 -1
- package/lib/mocks/message-history-mock.d.ts +0 -9
- package/lib/mocks/message-history-mock.d.ts.map +0 -1
- package/lib/mocks/message-history-mock.js +0 -24
- package/lib/mocks/message-history-mock.js.map +0 -1
- package/lib/mocks/postboy-service-mock.d.ts +0 -22
- package/lib/mocks/postboy-service-mock.d.ts.map +0 -1
- package/lib/mocks/postboy-service-mock.js +0 -51
- package/lib/mocks/postboy-service-mock.js.map +0 -1
- package/lib/models/dictionary.d.ts +0 -18
- package/lib/models/dictionary.d.ts.map +0 -1
- package/lib/models/dictionary.js +0 -59
- package/lib/models/dictionary.js.map +0 -1
- package/lib/models/id-generator.d.ts +0 -4
- package/lib/models/id-generator.d.ts.map +0 -1
- package/lib/models/id-generator.js +0 -14
- package/lib/models/id-generator.js.map +0 -1
- package/lib/models/postboy-bbb.d.ts +0 -4
- package/lib/models/postboy-bbb.d.ts.map +0 -1
- package/lib/models/postboy-bbb.js.map +0 -1
- package/lib/models/postboy.locker.d.ts +0 -6
- package/lib/models/postboy.locker.d.ts.map +0 -1
- package/lib/models/postboy.locker.js +0 -3
- package/lib/models/postboy.locker.js.map +0 -1
|
@@ -1,142 +1,109 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PostboyAbstractRegistrator = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const postboy_generic_message_1 = require("./models/postboy-generic-message");
|
|
6
|
-
class PostboyAbstractRegistrator {
|
|
7
|
-
constructor(postboy) {
|
|
8
|
-
this.postboy = postboy;
|
|
9
|
-
this.ids = [];
|
|
10
|
-
this.services = [];
|
|
11
|
-
/**
|
|
12
|
-
*
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
*
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
* @
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* @param {MessageType<T>} type The constructor of the message type to be recorded
|
|
32
|
-
* @param {
|
|
33
|
-
*
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
this.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
* @
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
* @
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
*
|
|
110
|
-
* @param {MessageType<T>} type - The constructor of the message type to record, which extends PostboyGenericMessage.
|
|
111
|
-
* @param {Subject<T>} sub - The Subject instance to associate with the message type.
|
|
112
|
-
* @param {(s: Subject<T>) => Observable<T>} pipe - A function that takes the subject as input and returns an Observable with transformations applied.
|
|
113
|
-
* @return {this} The current instance of the class for chaining.
|
|
114
|
-
*/
|
|
115
|
-
recordWithPipe(type, sub, pipe) {
|
|
116
|
-
this.ids.push((0, postboy_generic_message_1.checkId)(type));
|
|
117
|
-
this.postboy.recordWithPipe(type, sub, pipe);
|
|
118
|
-
return this;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Records an executor associated with a specific type and execution logic.
|
|
122
|
-
*
|
|
123
|
-
* @param type The class constructor of the executor type to be recorded, which extends PostboyExecutor.
|
|
124
|
-
* @param exec A callback function that executes the logic using an instance of the specified executor type.
|
|
125
|
-
* @return void
|
|
126
|
-
*/
|
|
127
|
-
recordExecutor(type, exec) {
|
|
128
|
-
this.postboy.recordExecutor(type, exec);
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Records a handler for a specific executor type.
|
|
132
|
-
*
|
|
133
|
-
* @param executor The constructor of the executor type, which extends `PostboyExecutor`.
|
|
134
|
-
* @param handler The execution handler associated with the given executor type.
|
|
135
|
-
* @return void
|
|
136
|
-
*/
|
|
137
|
-
recordHandler(executor, handler) {
|
|
138
|
-
this.postboy.recordHandler(executor, handler);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
exports.PostboyAbstractRegistrator = PostboyAbstractRegistrator;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PostboyAbstractRegistrator = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const postboy_generic_message_1 = require("./models/postboy-generic-message");
|
|
6
|
+
class PostboyAbstractRegistrator {
|
|
7
|
+
constructor(postboy) {
|
|
8
|
+
this.postboy = postboy;
|
|
9
|
+
this.ids = [];
|
|
10
|
+
this.services = [];
|
|
11
|
+
/**
|
|
12
|
+
* A utility function that facilitates the recording and replaying of messages
|
|
13
|
+
* using a ReplaySubject. This function is designed to handle messages of a
|
|
14
|
+
* specific type and allows specifying a buffer size to determine how many
|
|
15
|
+
* of the most recent messages should be replayed.
|
|
16
|
+
*
|
|
17
|
+
* @template T Extends the PostboyGenericMessage type, representing the type of message
|
|
18
|
+
* to be recorded and replayed.
|
|
19
|
+
* @param {MessageType<T>} type The constructor of the message type to be recorded and replayed.
|
|
20
|
+
* @param {number} [bufferSize=1] The number of recent messages to retain in the ReplaySubject's buffer.
|
|
21
|
+
* Defaults to 1 if not specified.
|
|
22
|
+
* @returns The result of invoking the `record` method with the given message type and configured ReplaySubject.
|
|
23
|
+
*/
|
|
24
|
+
this.recordReplay = (type, bufferSize = 1) => this.record(type, new rxjs_1.ReplaySubject(bufferSize));
|
|
25
|
+
/**
|
|
26
|
+
* Represents a method that records a specific behavior associated with a message type.
|
|
27
|
+
* It creates a `BehaviorSubject` initialized with the provided initial message
|
|
28
|
+
* and associates it with the given message type using the `record` method.
|
|
29
|
+
*
|
|
30
|
+
* @template T - A type parameter extending `PostboyGenericMessage` that defines the message structure.
|
|
31
|
+
* @param {MessageType<T>} type - The constructor function of the message type to be recorded.
|
|
32
|
+
* @param {T} initial - The initial value of the message that will be set in the `BehaviorSubject`.
|
|
33
|
+
* @returns {void} - This function does not return a value; instead, it modifies the internal state.
|
|
34
|
+
*/
|
|
35
|
+
this.recordBehavior = (type, initial) => this.record(type, new rxjs_1.BehaviorSubject(initial));
|
|
36
|
+
/**
|
|
37
|
+
* A function that creates and returns a new generic message recorder for a specific message type.
|
|
38
|
+
*
|
|
39
|
+
* @template T - A type parameter extending from `PostboyGenericMessage`.
|
|
40
|
+
* @param {MessageType<T>} type - The constructor for the message type being recorded.
|
|
41
|
+
* @returns {Subject<T>} A new instance of `Subject<T>` bound to the specified message type.
|
|
42
|
+
*/
|
|
43
|
+
this.recordSubject = (type) => this.record(type, new rxjs_1.Subject());
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Registers a list of services to be used by the application.
|
|
47
|
+
*
|
|
48
|
+
* @param {IPostboyDependingService[]} services - An array of services to register.
|
|
49
|
+
* @return {void} This method does not return a value.
|
|
50
|
+
*/
|
|
51
|
+
registerServices(services) {
|
|
52
|
+
this.services = services;
|
|
53
|
+
}
|
|
54
|
+
up() {
|
|
55
|
+
this._up();
|
|
56
|
+
this.services.forEach((s) => s.up());
|
|
57
|
+
}
|
|
58
|
+
down() {
|
|
59
|
+
this.services = [];
|
|
60
|
+
this.ids.forEach((id) => this.postboy.unregister(id));
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Records a type and its corresponding Subject<T> into the Postboy system and updates the internal identifiers.
|
|
64
|
+
*
|
|
65
|
+
* @param {MessageType<T>} type - A constructor for the generic message type T.
|
|
66
|
+
* @param {Subject<T>} sub - The subject associated with the generic message type.
|
|
67
|
+
* @return {this} Returns the current instance for method chaining.
|
|
68
|
+
*/
|
|
69
|
+
record(type, sub) {
|
|
70
|
+
this.ids.push((0, postboy_generic_message_1.checkId)(type));
|
|
71
|
+
this.postboy.record(type, sub);
|
|
72
|
+
return this;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Records a message type with a specific subject and applies a transformation pipe to the subject.
|
|
76
|
+
*
|
|
77
|
+
* @param {MessageType<T>} type - The constructor of the message type to record, which extends PostboyGenericMessage.
|
|
78
|
+
* @param {Subject<T>} sub - The Subject instance to associate with the message type.
|
|
79
|
+
* @param {(s: Subject<T>) => Observable<T>} pipe - A function that takes the subject as input and returns an Observable with transformations applied.
|
|
80
|
+
* @return {this} The current instance of the class for chaining.
|
|
81
|
+
*/
|
|
82
|
+
recordWithPipe(type, sub, pipe) {
|
|
83
|
+
this.ids.push((0, postboy_generic_message_1.checkId)(type));
|
|
84
|
+
this.postboy.recordWithPipe(type, sub, pipe);
|
|
85
|
+
return this;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Records an executor associated with a specific type and execution logic.
|
|
89
|
+
*
|
|
90
|
+
* @param type The class constructor of the executor type to be recorded, which extends PostboyExecutor.
|
|
91
|
+
* @param exec A callback function that executes the logic using an instance of the specified executor type.
|
|
92
|
+
* @return void
|
|
93
|
+
*/
|
|
94
|
+
recordExecutor(type, exec) {
|
|
95
|
+
this.postboy.recordExecutor(type, exec);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Records a handler for a specific executor type.
|
|
99
|
+
*
|
|
100
|
+
* @param executor The constructor of the executor type, which extends `PostboyExecutor`.
|
|
101
|
+
* @param handler The execution handler associated with the given executor type.
|
|
102
|
+
* @return void
|
|
103
|
+
*/
|
|
104
|
+
recordHandler(executor, handler) {
|
|
105
|
+
this.postboy.recordHandler(executor, handler);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
exports.PostboyAbstractRegistrator = PostboyAbstractRegistrator;
|
|
142
109
|
//# sourceMappingURL=postboy-abstract.registrator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postboy-abstract.registrator.js","sourceRoot":"","sources":["../src/postboy-abstract.registrator.ts"],"names":[],"mappings":";;;AACA,+BAA2E;AAG3E,8EAAkF;AAKlF,MAAsB,0BAA0B;IAI9C,YAAsB,OAAuB;QAAvB,YAAO,GAAP,OAAO,CAAgB;QAHrC,QAAG,GAAa,EAAE,CAAC;QACnB,aAAQ,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CAAC;IACxD,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAkC,IAAoB,EAAE,GAAe;QAClF,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAA,iCAAO,EAAC,IAAI,CAAC,CAAC,CAAC;QAC7B,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAC/B,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;OAOG;IACI,cAAc,CACnB,IAAoB,EACpB,GAAe,EACf,IAAsC;QAEtC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAA,iCAAO,EAAC,IAAI,CAAC,CAAC,CAAC;QAC7B,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;QAC7C,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;OAMG;IACI,cAAc,CAAkC,IAA+B,EAAE,IAAiB;QACvG,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;;OAMG;IACI,aAAa,CAClB,QAAmC,EACnC,OAAsC;QAEtC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAChD,CAAC;CAuCF;AAzHD,gEAyHC"}
|
package/lib/postboy.service.d.ts
CHANGED
|
@@ -1,106 +1,92 @@
|
|
|
1
|
-
import { Observable, Subject } from 'rxjs';
|
|
2
|
-
import { PostboyGenericMessage } from './models/postboy-generic-message';
|
|
3
|
-
import {
|
|
4
|
-
import { PostboyExecutor } from './models/postboy-executor';
|
|
5
|
-
import { PostboyCallbackMessage } from './models/postboy-callback.message';
|
|
6
|
-
import { MessageType } from './postboy-abstract.registrator';
|
|
7
|
-
import { PostboyExecutionHandler } from './models/postboy-execution.handler';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
*
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
* @
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
*
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
* @
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
*
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
*
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
*
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* @
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
*
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
*
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
*
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
* @param {PostboyExecutor<T>} executor The executor to be executed, which includes its identifier and logic.
|
|
93
|
-
* @return {T} The resulting output from the executed executor function.
|
|
94
|
-
* @throws {Error} If the specified executor is not registered.
|
|
95
|
-
*/
|
|
96
|
-
exec<T>(executor: PostboyExecutor<T>): T;
|
|
97
|
-
/**
|
|
98
|
-
* Manages the recording of an executor and its corresponding handler into internal storage.
|
|
99
|
-
*
|
|
100
|
-
* @param {new (...args: any[]) => E} executor - The constructor for a class extending PostboyExecutor, used to register the executor type.
|
|
101
|
-
* @param {PostboyExecutionHandler<R, E>} handler - The handler responsible for processing the specific executor.
|
|
102
|
-
* @return {void} No return value.
|
|
103
|
-
*/
|
|
104
|
-
recordHandler<E extends PostboyExecutor<R>, R>(executor: new (...args: any[]) => E, handler: PostboyExecutionHandler<R, E>): void;
|
|
105
|
-
}
|
|
1
|
+
import { Observable, Subject } from 'rxjs';
|
|
2
|
+
import { PostboyGenericMessage } from './models/postboy-generic-message';
|
|
3
|
+
import { PostboySubscription } from './models/postboy-subscription';
|
|
4
|
+
import { PostboyExecutor } from './models/postboy-executor';
|
|
5
|
+
import { PostboyCallbackMessage } from './models/postboy-callback.message';
|
|
6
|
+
import { MessageType } from './postboy-abstract.registrator';
|
|
7
|
+
import { PostboyExecutionHandler } from './models/postboy-execution.handler';
|
|
8
|
+
import { PostboyMiddleware } from "./models/postboy-middleware";
|
|
9
|
+
export declare class PostboyService {
|
|
10
|
+
protected locked: Set<string>;
|
|
11
|
+
protected applications: Map<string, PostboySubscription<any>>;
|
|
12
|
+
protected executors: Map<string, (e: PostboyExecutor<any>) => any>;
|
|
13
|
+
protected middlewares: PostboyMiddleware[];
|
|
14
|
+
lock<T extends PostboyGenericMessage>(type: MessageType<T>): void;
|
|
15
|
+
unlock<T extends PostboyGenericMessage>(type: MessageType<T>): void;
|
|
16
|
+
addMiddleware(middleware: PostboyMiddleware): void;
|
|
17
|
+
removeMiddleware(middleware: PostboyMiddleware): void;
|
|
18
|
+
unregister(id: string): void;
|
|
19
|
+
/**
|
|
20
|
+
* Fires a registered event and passes the message to its subscribers.
|
|
21
|
+
*
|
|
22
|
+
* @param {PostboyGenericMessage} message - The message object containing the event data.
|
|
23
|
+
* @return {void} This method does not return a value.
|
|
24
|
+
* @throws {Error} Throws an error if no registered event is found for the provided message ID.
|
|
25
|
+
*/
|
|
26
|
+
fire(message: PostboyGenericMessage): void;
|
|
27
|
+
/**
|
|
28
|
+
* Triggers a callback function associated with a given message.
|
|
29
|
+
*
|
|
30
|
+
* @param {PostboyCallbackMessage<T>} message - The message object used to trigger the callback.
|
|
31
|
+
* It contains details about the event and result subscription.
|
|
32
|
+
* @param {(e: T) => void} [action] - Optional callback function to execute when the result of the message is emitted.
|
|
33
|
+
* @return {void} This method does not return any value.
|
|
34
|
+
*/
|
|
35
|
+
fireCallback<T>(message: PostboyCallbackMessage<T>, action?: (e: T) => void): Observable<T>;
|
|
36
|
+
/**
|
|
37
|
+
* Executes the provided executor function and returns its result.
|
|
38
|
+
*
|
|
39
|
+
* @param {PostboyExecutor<T>} executor The executor to be executed, which includes its identifier and logic.
|
|
40
|
+
* @return {T} The resulting output from the executed executor function.
|
|
41
|
+
* @throws {Error} If the specified executor is not registered.
|
|
42
|
+
*/
|
|
43
|
+
exec<T>(executor: PostboyExecutor<T>): T;
|
|
44
|
+
/**
|
|
45
|
+
* Subscribes to a specific message type and returns an observable of that type.
|
|
46
|
+
*
|
|
47
|
+
* @param type The constructor function of the type that extends PostboyGenericMessage.
|
|
48
|
+
* @return An Observable of the specified generic message type.
|
|
49
|
+
*/
|
|
50
|
+
sub<T extends PostboyGenericMessage>(type: MessageType<T>): Observable<T>;
|
|
51
|
+
/**
|
|
52
|
+
* Registers a given message type and its associated subject subscription with the system.
|
|
53
|
+
*
|
|
54
|
+
* @param type The constructor function of the message type that extends the PostboyGenericMessage.
|
|
55
|
+
* @param sub The Subject instance for the provided message type, used for managing subscriptions.
|
|
56
|
+
* @return {void} No return value.
|
|
57
|
+
*/
|
|
58
|
+
record<T extends PostboyGenericMessage>(type: MessageType<T>, sub: Subject<T>): void;
|
|
59
|
+
/**
|
|
60
|
+
* Registers a generic message type with a Subject and a transformation pipe.
|
|
61
|
+
*
|
|
62
|
+
* @param {MessageType<T>} type - The constructor of the message type being registered.
|
|
63
|
+
* @param {Subject<T>} sub - The Subject instance used to handle incoming messages of the specified type.
|
|
64
|
+
* @param {(s: Subject<T>) => Observable<T>} pipe - A function that applies a transformation or processing logic to the Subject and returns an Observable.
|
|
65
|
+
* @return {void} No return value.
|
|
66
|
+
*/
|
|
67
|
+
recordWithPipe<T extends PostboyGenericMessage>(type: MessageType<T>, sub: Subject<T>, pipe: (s: Subject<T>) => Observable<T>): void;
|
|
68
|
+
/**
|
|
69
|
+
* Records an executor instance and its corresponding execution function.
|
|
70
|
+
*
|
|
71
|
+
* @param {new (...args: any[]) => E} type - The constructor type of the executor.
|
|
72
|
+
* @param {(e: E) => T} exec - The function to execute with the provided executor instance.
|
|
73
|
+
* @return {void} No return value.
|
|
74
|
+
*/
|
|
75
|
+
recordExecutor<E extends PostboyExecutor<T>, T>(type: (new (...args: any[]) => E), exec: (e: E) => T): void;
|
|
76
|
+
/**
|
|
77
|
+
* Manages the recording of an executor and its corresponding handler into internal storage.
|
|
78
|
+
*
|
|
79
|
+
* @param {new (...args: any[]) => E} executor - The constructor for a class extending PostboyExecutor, used to register the executor type.
|
|
80
|
+
* @param {PostboyExecutionHandler<R, E>} handler - The handler responsible for processing the specific executor.
|
|
81
|
+
* @return {void} No return value.
|
|
82
|
+
*/
|
|
83
|
+
recordHandler<E extends PostboyExecutor<R>, R>(executor: new (...args: any[]) => E, handler: PostboyExecutionHandler<R, E>): void;
|
|
84
|
+
/**
|
|
85
|
+
* Executes each middleware in the order they are registered, passing the provided message to each middleware's handle method.
|
|
86
|
+
*
|
|
87
|
+
* @param {PostboyGenericMessage} msg - The message object to be processed by the middlewares.
|
|
88
|
+
* @return {void} This method does not return a value.
|
|
89
|
+
*/
|
|
90
|
+
private executeMiddleware;
|
|
91
|
+
}
|
|
106
92
|
//# sourceMappingURL=postboy.service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postboy.service.d.ts","sourceRoot":"","sources":["../src/postboy.service.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"post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