@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.
Files changed (78) hide show
  1. package/README.md +27 -68
  2. package/lib/i-postboy-depending.service.d.ts +3 -3
  3. package/lib/i-postboy-depending.service.js +2 -2
  4. package/lib/index.d.ts +9 -10
  5. package/lib/index.d.ts.map +1 -1
  6. package/lib/index.js +28 -29
  7. package/lib/index.js.map +1 -1
  8. package/lib/models/message-queue.model.d.ts +43 -43
  9. package/lib/models/message-queue.model.js +65 -65
  10. package/lib/models/message-queue.model.js.map +1 -1
  11. package/lib/models/postboy-callback.message.d.ts +26 -8
  12. package/lib/models/postboy-callback.message.d.ts.map +1 -1
  13. package/lib/models/postboy-callback.message.js +36 -18
  14. package/lib/models/postboy-callback.message.js.map +1 -1
  15. package/lib/models/postboy-execution.handler.d.ts +14 -14
  16. package/lib/models/postboy-execution.handler.js +16 -16
  17. package/lib/models/postboy-executor.d.ts +3 -3
  18. package/lib/models/postboy-executor.d.ts.map +1 -1
  19. package/lib/models/postboy-executor.js +7 -7
  20. package/lib/models/postboy-executor.js.map +1 -1
  21. package/lib/models/postboy-generic-message.d.ts +7 -7
  22. package/lib/models/postboy-generic-message.d.ts.map +1 -1
  23. package/lib/models/postboy-generic-message.js +16 -18
  24. package/lib/models/postboy-generic-message.js.map +1 -1
  25. package/lib/models/postboy-middleware.d.ts +5 -0
  26. package/lib/models/postboy-middleware.d.ts.map +1 -0
  27. package/lib/models/{postboy-bbb.js → postboy-middleware.js} +1 -1
  28. package/lib/models/postboy-middleware.js.map +1 -0
  29. package/lib/models/postboy-subscription.d.ts +6 -6
  30. package/lib/models/postboy-subscription.js +10 -10
  31. package/lib/models/postboy.message.d.ts +4 -0
  32. package/lib/models/postboy.message.d.ts.map +1 -0
  33. package/lib/models/postboy.message.js +10 -0
  34. package/lib/models/postboy.message.js.map +1 -0
  35. package/lib/models/queue.d.ts +11 -0
  36. package/lib/models/queue.d.ts.map +1 -0
  37. package/lib/models/queue.js +34 -0
  38. package/lib/models/queue.js.map +1 -0
  39. package/lib/postboy-abstract.registrator.d.ts +89 -113
  40. package/lib/postboy-abstract.registrator.d.ts.map +1 -1
  41. package/lib/postboy-abstract.registrator.js +108 -141
  42. package/lib/postboy-abstract.registrator.js.map +1 -1
  43. package/lib/postboy.service.d.ts +91 -105
  44. package/lib/postboy.service.d.ts.map +1 -1
  45. package/lib/postboy.service.js +140 -161
  46. package/lib/postboy.service.js.map +1 -1
  47. package/package.json +2 -4
  48. package/lib/locker.store.d.ts +0 -9
  49. package/lib/locker.store.d.ts.map +0 -1
  50. package/lib/locker.store.js +0 -27
  51. package/lib/locker.store.js.map +0 -1
  52. package/lib/mocks/message-history-item-mock.d.ts +0 -10
  53. package/lib/mocks/message-history-item-mock.d.ts.map +0 -1
  54. package/lib/mocks/message-history-item-mock.js +0 -26
  55. package/lib/mocks/message-history-item-mock.js.map +0 -1
  56. package/lib/mocks/message-history-mock.d.ts +0 -9
  57. package/lib/mocks/message-history-mock.d.ts.map +0 -1
  58. package/lib/mocks/message-history-mock.js +0 -24
  59. package/lib/mocks/message-history-mock.js.map +0 -1
  60. package/lib/mocks/postboy-service-mock.d.ts +0 -22
  61. package/lib/mocks/postboy-service-mock.d.ts.map +0 -1
  62. package/lib/mocks/postboy-service-mock.js +0 -51
  63. package/lib/mocks/postboy-service-mock.js.map +0 -1
  64. package/lib/models/dictionary.d.ts +0 -18
  65. package/lib/models/dictionary.d.ts.map +0 -1
  66. package/lib/models/dictionary.js +0 -59
  67. package/lib/models/dictionary.js.map +0 -1
  68. package/lib/models/id-generator.d.ts +0 -4
  69. package/lib/models/id-generator.d.ts.map +0 -1
  70. package/lib/models/id-generator.js +0 -14
  71. package/lib/models/id-generator.js.map +0 -1
  72. package/lib/models/postboy-bbb.d.ts +0 -4
  73. package/lib/models/postboy-bbb.d.ts.map +0 -1
  74. package/lib/models/postboy-bbb.js.map +0 -1
  75. package/lib/models/postboy.locker.d.ts +0 -6
  76. package/lib/models/postboy.locker.d.ts.map +0 -1
  77. package/lib/models/postboy.locker.js +0 -3
  78. package/lib/models/postboy.locker.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { PostboyGenericMessage } from './postboy-generic-message';
2
- export declare abstract class PostboyExecutor<T> extends PostboyGenericMessage {
3
- }
1
+ import { PostboyMessage } from "./postboy.message";
2
+ export declare abstract class PostboyExecutor<T> extends PostboyMessage {
3
+ }
4
4
  //# sourceMappingURL=postboy-executor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"postboy-executor.d.ts","sourceRoot":"","sources":["../../src/models/postboy-executor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAElE,8BAAsB,eAAe,CAAC,CAAC,CAAE,SAAQ,qBAAqB;CAAG"}
1
+ {"version":3,"file":"postboy-executor.d.ts","sourceRoot":"","sources":["../../src/models/postboy-executor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAEjD,8BAAsB,eAAe,CAAC,CAAC,CAAG,SAAQ,cAAc;CAAE"}
@@ -1,8 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PostboyExecutor = void 0;
4
- const postboy_generic_message_1 = require("./postboy-generic-message");
5
- class PostboyExecutor extends postboy_generic_message_1.PostboyGenericMessage {
6
- }
7
- exports.PostboyExecutor = PostboyExecutor;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PostboyExecutor = void 0;
4
+ const postboy_message_1 = require("./postboy.message");
5
+ class PostboyExecutor extends postboy_message_1.PostboyMessage {
6
+ }
7
+ exports.PostboyExecutor = PostboyExecutor;
8
8
  //# sourceMappingURL=postboy-executor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"postboy-executor.js","sourceRoot":"","sources":["../../src/models/postboy-executor.ts"],"names":[],"mappings":";;;AAAA,uEAAkE;AAElE,MAAsB,eAAmB,SAAQ,+CAAqB;CAAG;AAAzE,0CAAyE"}
1
+ {"version":3,"file":"postboy-executor.js","sourceRoot":"","sources":["../../src/models/postboy-executor.ts"],"names":[],"mappings":";;;AAAA,uDAAiD;AAEjD,MAAsB,eAAoB,SAAQ,gCAAc;CAAE;AAAlE,0CAAkE"}
@@ -1,8 +1,8 @@
1
- /**
2
- * An inheritor should have a static ID field
3
- */
4
- export declare abstract class PostboyGenericMessage {
5
- get id(): string;
6
- }
7
- export declare function checkId(message: new (...args: any[]) => any): string;
1
+ import { PostboyMessage } from "./postboy.message";
2
+ /**
3
+ * An inheritor should have a static ID field
4
+ */
5
+ export declare abstract class PostboyGenericMessage extends PostboyMessage {
6
+ }
7
+ export declare function checkId(message: new (...args: any[]) => any): string;
8
8
  //# sourceMappingURL=postboy-generic-message.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"postboy-generic-message.d.ts","sourceRoot":"","sources":["../../src/models/postboy-generic-message.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,8BAAsB,qBAAqB;IACzC,IAAW,EAAE,IAAI,MAAM,CAEtB;CACF;AACD,wBAAgB,OAAO,CAAC,OAAO,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,GAAG,MAAM,CAGpE"}
1
+ {"version":3,"file":"postboy-generic-message.d.ts","sourceRoot":"","sources":["../../src/models/postboy-generic-message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAEjD;;GAEG;AACH,8BAAsB,qBAAsB,SAAQ,cAAc;CACjE;AACD,wBAAgB,OAAO,CAAC,OAAO,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,GAAG,MAAM,CAGpE"}
@@ -1,19 +1,17 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkId = exports.PostboyGenericMessage = void 0;
4
- /**
5
- * An inheritor should have a static ID field
6
- */
7
- class PostboyGenericMessage {
8
- get id() {
9
- return this.constructor.ID;
10
- }
11
- }
12
- exports.PostboyGenericMessage = PostboyGenericMessage;
13
- function checkId(message) {
14
- if (!message.ID)
15
- throw new Error(`${message.name} should have a static ID field`);
16
- return message.ID;
17
- }
18
- exports.checkId = checkId;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkId = exports.PostboyGenericMessage = void 0;
4
+ const postboy_message_1 = require("./postboy.message");
5
+ /**
6
+ * An inheritor should have a static ID field
7
+ */
8
+ class PostboyGenericMessage extends postboy_message_1.PostboyMessage {
9
+ }
10
+ exports.PostboyGenericMessage = PostboyGenericMessage;
11
+ function checkId(message) {
12
+ if (!message.ID)
13
+ throw new Error(`${message.name} should have a static ID field`);
14
+ return message.ID;
15
+ }
16
+ exports.checkId = checkId;
19
17
  //# sourceMappingURL=postboy-generic-message.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"postboy-generic-message.js","sourceRoot":"","sources":["../../src/models/postboy-generic-message.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,MAAsB,qBAAqB;IACzC,IAAW,EAAE;QACX,OAAQ,IAAI,CAAC,WAAmB,CAAC,EAAE,CAAC;IACtC,CAAC;CACF;AAJD,sDAIC;AACD,SAAgB,OAAO,CAAC,OAAoC;IAC1D,IAAI,CAAE,OAAe,CAAC,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,OAAO,CAAC,IAAI,gCAAgC,CAAC,CAAC;IAC3F,OAAQ,OAAe,CAAC,EAAE,CAAC;AAC7B,CAAC;AAHD,0BAGC"}
1
+ {"version":3,"file":"postboy-generic-message.js","sourceRoot":"","sources":["../../src/models/postboy-generic-message.ts"],"names":[],"mappings":";;;AAAA,uDAAiD;AAEjD;;GAEG;AACH,MAAsB,qBAAsB,SAAQ,gCAAc;CACjE;AADD,sDACC;AACD,SAAgB,OAAO,CAAC,OAAoC;IAC1D,IAAI,CAAE,OAAe,CAAC,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,OAAO,CAAC,IAAI,gCAAgC,CAAC,CAAC;IAC3F,OAAQ,OAAe,CAAC,EAAE,CAAC;AAC7B,CAAC;AAHD,0BAGC"}
@@ -0,0 +1,5 @@
1
+ import { PostboyMessage } from "./postboy.message";
2
+ export interface PostboyMiddleware {
3
+ handle(message: PostboyMessage): void;
4
+ }
5
+ //# sourceMappingURL=postboy-middleware.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postboy-middleware.d.ts","sourceRoot":"","sources":["../../src/models/postboy-middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAEjD,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,CAAC;CACvC"}
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=postboy-bbb.js.map
3
+ //# sourceMappingURL=postboy-middleware.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postboy-middleware.js","sourceRoot":"","sources":["../../src/models/postboy-middleware.ts"],"names":[],"mappings":""}
@@ -1,7 +1,7 @@
1
- import { Observable, Subject } from 'rxjs';
2
- export declare class PostboySubscription<T> {
3
- sub: Subject<T>;
4
- pipe: (s: Subject<T>) => Observable<T>;
5
- constructor(sub: Subject<T>, pipe: (s: Subject<T>) => Observable<T>);
6
- }
1
+ import { Observable, Subject } from 'rxjs';
2
+ export declare class PostboySubscription<T> {
3
+ sub: Subject<T>;
4
+ pipe: (s: Subject<T>) => Observable<T>;
5
+ constructor(sub: Subject<T>, pipe: (s: Subject<T>) => Observable<T>);
6
+ }
7
7
  //# sourceMappingURL=postboy-subscription.d.ts.map
@@ -1,11 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PostboySubscription = void 0;
4
- class PostboySubscription {
5
- constructor(sub, pipe) {
6
- this.sub = sub;
7
- this.pipe = pipe;
8
- }
9
- }
10
- exports.PostboySubscription = PostboySubscription;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PostboySubscription = void 0;
4
+ class PostboySubscription {
5
+ constructor(sub, pipe) {
6
+ this.sub = sub;
7
+ this.pipe = pipe;
8
+ }
9
+ }
10
+ exports.PostboySubscription = PostboySubscription;
11
11
  //# sourceMappingURL=postboy-subscription.js.map
@@ -0,0 +1,4 @@
1
+ export declare abstract class PostboyMessage {
2
+ get id(): string;
3
+ }
4
+ //# sourceMappingURL=postboy.message.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postboy.message.d.ts","sourceRoot":"","sources":["../../src/models/postboy.message.ts"],"names":[],"mappings":"AAAA,8BAAsB,cAAc;IAClC,IAAW,EAAE,IAAI,MAAM,CAEtB;CACF"}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PostboyMessage = void 0;
4
+ class PostboyMessage {
5
+ get id() {
6
+ return this.constructor.ID;
7
+ }
8
+ }
9
+ exports.PostboyMessage = PostboyMessage;
10
+ //# sourceMappingURL=postboy.message.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postboy.message.js","sourceRoot":"","sources":["../../src/models/postboy.message.ts"],"names":[],"mappings":";;;AAAA,MAAsB,cAAc;IAClC,IAAW,EAAE;QACX,OAAQ,IAAI,CAAC,WAAmB,CAAC,EAAE,CAAC;IACtC,CAAC;CACF;AAJD,wCAIC"}
@@ -0,0 +1,11 @@
1
+ export declare class Queue<T> {
2
+ private storage;
3
+ private head;
4
+ private tail;
5
+ put(item: T): this;
6
+ putMany(items: T[]): this;
7
+ take(): T | undefined;
8
+ get size(): number;
9
+ each(action: (e: T) => void): void;
10
+ }
11
+ //# sourceMappingURL=queue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../src/models/queue.ts"],"names":[],"mappings":"AAAA,qBAAa,KAAK,CAAC,CAAC;IAClB,OAAO,CAAC,OAAO,CAAyB;IACxC,OAAO,CAAC,IAAI,CAAa;IACzB,OAAO,CAAC,IAAI,CAAa;IAEzB,GAAG,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI;IAMlB,OAAO,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,IAAI;IAKzB,IAAI,IAAI,CAAC,GAAG,SAAS;IAMrB,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI;CAG5B"}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Queue = void 0;
4
+ class Queue {
5
+ constructor() {
6
+ this.storage = {};
7
+ this.head = 0;
8
+ this.tail = 0;
9
+ }
10
+ put(item) {
11
+ this.storage[this.tail] = item;
12
+ this.tail++;
13
+ return this;
14
+ }
15
+ putMany(items) {
16
+ items.forEach((i) => this.put(i));
17
+ return this;
18
+ }
19
+ take() {
20
+ const item = this.storage[this.head];
21
+ if (item)
22
+ delete this.storage[this.head++];
23
+ return item;
24
+ }
25
+ get size() {
26
+ return this.tail - this.head;
27
+ }
28
+ each(action) {
29
+ while (this.size)
30
+ action(this.take());
31
+ }
32
+ }
33
+ exports.Queue = Queue;
34
+ //# sourceMappingURL=queue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queue.js","sourceRoot":"","sources":["../../src/models/queue.ts"],"names":[],"mappings":";;;AAAA,MAAa,KAAK;IAAlB;QACU,YAAO,GAAsB,EAAE,CAAC;QAChC,SAAI,GAAW,CAAC,CAAC;QACjB,SAAI,GAAW,CAAC,CAAC;IA0B3B,CAAC;IAxBC,GAAG,CAAC,IAAO;QACT,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;QAC/B,IAAI,CAAC,IAAI,EAAE,CAAC;QACZ,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CAAC,KAAU;QAChB,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAClC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI;QACF,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,IAAI;YAAE,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QAC3C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;IAC/B,CAAC;IAED,IAAI,CAAC,MAAsB;QACzB,OAAO,IAAI,CAAC,IAAI;YAAE,MAAM,CAAC,IAAI,CAAC,IAAI,EAAG,CAAC,CAAC;IACzC,CAAC;CACF;AA7BD,sBA6BC"}
@@ -1,114 +1,90 @@
1
- import { PostboyService } from './postboy.service';
2
- import { Observable, Subject } from 'rxjs';
3
- import { IPostboyDependingService } from './i-postboy-depending.service';
4
- import { PostboyExecutor } from './models/postboy-executor';
5
- import { PostboyGenericMessage } from './models/postboy-generic-message';
6
- import { PostboyExecutionHandler } from './models/postboy-execution.handler';
7
- export type MessageType<T extends PostboyGenericMessage> = new (...args: any[]) => T;
8
- export declare abstract class PostboyAbstractRegistrator {
9
- protected postboy: PostboyService;
10
- private ids;
11
- private services;
12
- constructor(postboy: PostboyService);
13
- /**
14
- * Registers a list of services to be used by the application.
15
- *
16
- * @param {IPostboyDependingService[]} services - An array of services to register.
17
- * @return {void} This method does not return a value.
18
- */
19
- registerServices(services: IPostboyDependingService[]): void;
20
- up(): void;
21
- protected abstract _up(): void;
22
- /**
23
- * @deprecated The method should be replaced with recordExecutor<T>
24
- */
25
- registerExecutor<E extends PostboyExecutor<T>, T>(id: string, exec: (e: E) => T): void;
26
- /**
27
- * @deprecated The method should be replaced with record<T>
28
- */
29
- register<T>(id: string, sub: Subject<T>): void;
30
- /**
31
- * @deprecated The method should be replaced with recordWithPipe<T>
32
- */
33
- registerWithPipe<T>(id: string, sub: Subject<T>, pipe: (s: Subject<T>) => Observable<T>): void;
34
- /**
35
- * @deprecated The method should be replaced with recordReplay<T>
36
- */
37
- registerReplay: <T>(id: string, bufferSize?: number) => void;
38
- /**
39
- * @deprecated The method should be replaced with recordBehavior<T>
40
- */
41
- registerBehavior: <T>(id: string, initial: T) => void;
42
- /**
43
- * @deprecated The method should be replaced with recordSubject<T>
44
- */
45
- registerSubject: <T>(id: string) => void;
46
- down(): void;
47
- /**
48
- * Records a type and its corresponding Subject<T> into the Postboy system and updates the internal identifiers.
49
- *
50
- * @param {MessageType<T>} type - A constructor for the generic message type T.
51
- * @param {Subject<T>} sub - The subject associated with the generic message type.
52
- * @return {this} Returns the current instance for method chaining.
53
- */
54
- record<T extends PostboyGenericMessage>(type: MessageType<T>, sub: Subject<T>): this;
55
- /**
56
- * Records a message type with a specific subject and applies a transformation pipe to the subject.
57
- *
58
- * @param {MessageType<T>} type - The constructor of the message type to record, which extends PostboyGenericMessage.
59
- * @param {Subject<T>} sub - The Subject instance to associate with the message type.
60
- * @param {(s: Subject<T>) => Observable<T>} pipe - A function that takes the subject as input and returns an Observable with transformations applied.
61
- * @return {this} The current instance of the class for chaining.
62
- */
63
- recordWithPipe<T extends PostboyGenericMessage>(type: MessageType<T>, sub: Subject<T>, pipe: (s: Subject<T>) => Observable<T>): this;
64
- /**
65
- * Records an executor associated with a specific type and execution logic.
66
- *
67
- * @param type The class constructor of the executor type to be recorded, which extends PostboyExecutor.
68
- * @param exec A callback function that executes the logic using an instance of the specified executor type.
69
- * @return void
70
- */
71
- recordExecutor<E extends PostboyExecutor<T>, T>(type: new (...args: any[]) => E, exec: (e: E) => T): void;
72
- /**
73
- * Records a handler for a specific executor type.
74
- *
75
- * @param executor The constructor of the executor type, which extends `PostboyExecutor`.
76
- * @param handler The execution handler associated with the given executor type.
77
- * @return void
78
- */
79
- recordHandler<E extends PostboyExecutor<R>, R>(executor: new (...args: any[]) => E, handler: PostboyExecutionHandler<R, E>): void;
80
- /**
81
- * A utility function that facilitates the recording and replaying of messages
82
- * using a ReplaySubject. This function is designed to handle messages of a
83
- * specific type and allows specifying a buffer size to determine how many
84
- * of the most recent messages should be replayed.
85
- *
86
- * @template T Extends the PostboyGenericMessage type, representing the type of message
87
- * to be recorded and replayed.
88
- * @param {MessageType<T>} type The constructor of the message type to be recorded and replayed.
89
- * @param {number} [bufferSize=1] The number of recent messages to retain in the ReplaySubject's buffer.
90
- * Defaults to 1 if not specified.
91
- * @returns The result of invoking the `record` method with the given message type and configured ReplaySubject.
92
- */
93
- recordReplay: <T extends PostboyGenericMessage>(type: MessageType<T>, bufferSize?: number) => this;
94
- /**
95
- * Represents a method that records a specific behavior associated with a message type.
96
- * It creates a `BehaviorSubject` initialized with the provided initial message
97
- * and associates it with the given message type using the `record` method.
98
- *
99
- * @template T - A type parameter extending `PostboyGenericMessage` that defines the message structure.
100
- * @param {MessageType<T>} type - The constructor function of the message type to be recorded.
101
- * @param {T} initial - The initial value of the message that will be set in the `BehaviorSubject`.
102
- * @returns {void} - This function does not return a value; instead, it modifies the internal state.
103
- */
104
- recordBehavior: <T extends PostboyGenericMessage>(type: MessageType<T>, initial: T) => this;
105
- /**
106
- * A function that creates and returns a new generic message recorder for a specific message type.
107
- *
108
- * @template T - A type parameter extending from `PostboyGenericMessage`.
109
- * @param {MessageType<T>} type - The constructor for the message type being recorded.
110
- * @returns {Subject<T>} A new instance of `Subject<T>` bound to the specified message type.
111
- */
112
- recordSubject: <T extends PostboyGenericMessage>(type: MessageType<T>) => this;
113
- }
1
+ import { PostboyService } from './postboy.service';
2
+ import { Observable, Subject } from 'rxjs';
3
+ import { IPostboyDependingService } from './i-postboy-depending.service';
4
+ import { PostboyExecutor } from './models/postboy-executor';
5
+ import { PostboyGenericMessage } from './models/postboy-generic-message';
6
+ import { PostboyExecutionHandler } from './models/postboy-execution.handler';
7
+ export type MessageType<T extends PostboyGenericMessage> = new (...args: any[]) => T;
8
+ export declare abstract class PostboyAbstractRegistrator {
9
+ protected postboy: PostboyService;
10
+ private ids;
11
+ private services;
12
+ constructor(postboy: PostboyService);
13
+ /**
14
+ * Registers a list of services to be used by the application.
15
+ *
16
+ * @param {IPostboyDependingService[]} services - An array of services to register.
17
+ * @return {void} This method does not return a value.
18
+ */
19
+ registerServices(services: IPostboyDependingService[]): void;
20
+ up(): void;
21
+ protected abstract _up(): void;
22
+ down(): void;
23
+ /**
24
+ * Records a type and its corresponding Subject<T> into the Postboy system and updates the internal identifiers.
25
+ *
26
+ * @param {MessageType<T>} type - A constructor for the generic message type T.
27
+ * @param {Subject<T>} sub - The subject associated with the generic message type.
28
+ * @return {this} Returns the current instance for method chaining.
29
+ */
30
+ record<T extends PostboyGenericMessage>(type: MessageType<T>, sub: Subject<T>): this;
31
+ /**
32
+ * Records a message type with a specific subject and applies a transformation pipe to the subject.
33
+ *
34
+ * @param {MessageType<T>} type - The constructor of the message type to record, which extends PostboyGenericMessage.
35
+ * @param {Subject<T>} sub - The Subject instance to associate with the message type.
36
+ * @param {(s: Subject<T>) => Observable<T>} pipe - A function that takes the subject as input and returns an Observable with transformations applied.
37
+ * @return {this} The current instance of the class for chaining.
38
+ */
39
+ recordWithPipe<T extends PostboyGenericMessage>(type: MessageType<T>, sub: Subject<T>, pipe: (s: Subject<T>) => Observable<T>): this;
40
+ /**
41
+ * Records an executor associated with a specific type and execution logic.
42
+ *
43
+ * @param type The class constructor of the executor type to be recorded, which extends PostboyExecutor.
44
+ * @param exec A callback function that executes the logic using an instance of the specified executor type.
45
+ * @return void
46
+ */
47
+ recordExecutor<E extends PostboyExecutor<T>, T>(type: new (...args: any[]) => E, exec: (e: E) => T): void;
48
+ /**
49
+ * Records a handler for a specific executor type.
50
+ *
51
+ * @param executor The constructor of the executor type, which extends `PostboyExecutor`.
52
+ * @param handler The execution handler associated with the given executor type.
53
+ * @return void
54
+ */
55
+ recordHandler<E extends PostboyExecutor<R>, R>(executor: new (...args: any[]) => E, handler: PostboyExecutionHandler<R, E>): void;
56
+ /**
57
+ * A utility function that facilitates the recording and replaying of messages
58
+ * using a ReplaySubject. This function is designed to handle messages of a
59
+ * specific type and allows specifying a buffer size to determine how many
60
+ * of the most recent messages should be replayed.
61
+ *
62
+ * @template T Extends the PostboyGenericMessage type, representing the type of message
63
+ * to be recorded and replayed.
64
+ * @param {MessageType<T>} type The constructor of the message type to be recorded and replayed.
65
+ * @param {number} [bufferSize=1] The number of recent messages to retain in the ReplaySubject's buffer.
66
+ * Defaults to 1 if not specified.
67
+ * @returns The result of invoking the `record` method with the given message type and configured ReplaySubject.
68
+ */
69
+ recordReplay: <T extends PostboyGenericMessage>(type: MessageType<T>, bufferSize?: number) => this;
70
+ /**
71
+ * Represents a method that records a specific behavior associated with a message type.
72
+ * It creates a `BehaviorSubject` initialized with the provided initial message
73
+ * and associates it with the given message type using the `record` method.
74
+ *
75
+ * @template T - A type parameter extending `PostboyGenericMessage` that defines the message structure.
76
+ * @param {MessageType<T>} type - The constructor function of the message type to be recorded.
77
+ * @param {T} initial - The initial value of the message that will be set in the `BehaviorSubject`.
78
+ * @returns {void} - This function does not return a value; instead, it modifies the internal state.
79
+ */
80
+ recordBehavior: <T extends PostboyGenericMessage>(type: MessageType<T>, initial: T) => this;
81
+ /**
82
+ * A function that creates and returns a new generic message recorder for a specific message type.
83
+ *
84
+ * @template T - A type parameter extending from `PostboyGenericMessage`.
85
+ * @param {MessageType<T>} type - The constructor for the message type being recorded.
86
+ * @returns {Subject<T>} A new instance of `Subject<T>` bound to the specified message type.
87
+ */
88
+ recordSubject: <T extends PostboyGenericMessage>(type: MessageType<T>) => this;
89
+ }
114
90
  //# sourceMappingURL=postboy-abstract.registrator.d.ts.map
@@ -1 +1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