@artstesh/postboy 2.1.10 → 3.0.1

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 (99) hide show
  1. package/README.md +27 -68
  2. package/lib/index.d.ts +2 -3
  3. package/lib/index.d.ts.map +1 -1
  4. package/lib/index.js +2 -3
  5. package/lib/index.js.map +1 -1
  6. package/lib/locker.store.d.ts +8 -8
  7. package/lib/locker.store.js +26 -26
  8. package/lib/mocks/message-history-item-mock.d.ts +9 -9
  9. package/lib/mocks/message-history-item-mock.js +25 -25
  10. package/lib/mocks/message-history-mock.d.ts +8 -8
  11. package/lib/mocks/message-history-mock.d.ts.map +1 -1
  12. package/lib/mocks/message-history-mock.js +22 -23
  13. package/lib/mocks/message-history-mock.js.map +1 -1
  14. package/lib/mocks/postboy-service-mock.d.ts +21 -21
  15. package/lib/mocks/postboy-service-mock.js +50 -50
  16. package/lib/models/message-queue.model.d.ts +43 -43
  17. package/lib/models/message-queue.model.js +65 -65
  18. package/lib/models/postboy-callback.message.d.ts +18 -0
  19. package/lib/models/postboy-callback.message.d.ts.map +1 -1
  20. package/lib/models/postboy-callback.message.js +18 -0
  21. package/lib/models/postboy-callback.message.js.map +1 -1
  22. package/lib/models/postboy-executor.d.ts +2 -2
  23. package/lib/models/postboy-executor.d.ts.map +1 -1
  24. package/lib/models/postboy-executor.js +2 -2
  25. package/lib/models/postboy-executor.js.map +1 -1
  26. package/lib/models/postboy-generic-message.d.ts +2 -2
  27. package/lib/models/postboy-generic-message.d.ts.map +1 -1
  28. package/lib/models/postboy-generic-message.js +4 -6
  29. package/lib/models/postboy-generic-message.js.map +1 -1
  30. package/lib/models/postboy-middleware.d.ts +5 -0
  31. package/lib/models/postboy-middleware.d.ts.map +1 -0
  32. package/lib/models/{postboy-bbb.js → postboy-middleware.js} +1 -1
  33. package/lib/models/postboy-middleware.js.map +1 -0
  34. package/lib/models/postboy-subscription.d.ts +6 -3
  35. package/lib/models/postboy-subscription.d.ts.map +1 -1
  36. package/lib/models/postboy-subscription.js +11 -2
  37. package/lib/models/postboy-subscription.js.map +1 -1
  38. package/lib/models/postboy.locker.d.ts +5 -5
  39. package/lib/models/postboy.locker.js +2 -2
  40. package/lib/models/postboy.message.d.ts +4 -0
  41. package/lib/models/postboy.message.d.ts.map +1 -0
  42. package/lib/models/postboy.message.js +10 -0
  43. package/lib/models/postboy.message.js.map +1 -0
  44. package/lib/postboy-abstract.registrator.d.ts +0 -24
  45. package/lib/postboy-abstract.registrator.d.ts.map +1 -1
  46. package/lib/postboy-abstract.registrator.js +0 -33
  47. package/lib/postboy-abstract.registrator.js.map +1 -1
  48. package/lib/postboy.service.d.ts +45 -39
  49. package/lib/postboy.service.d.ts.map +1 -1
  50. package/lib/postboy.service.js +63 -76
  51. package/lib/postboy.service.js.map +1 -1
  52. package/lib/services/postboy-dependency.resolver.d.ts +7 -0
  53. package/lib/services/postboy-dependency.resolver.d.ts.map +1 -0
  54. package/lib/services/postboy-dependency.resolver.js +13 -0
  55. package/lib/services/postboy-dependency.resolver.js.map +1 -0
  56. package/lib/services/postboy-message.store.d.ts +16 -0
  57. package/lib/services/postboy-message.store.d.ts.map +1 -0
  58. package/lib/services/postboy-message.store.js +39 -0
  59. package/lib/services/postboy-message.store.js.map +1 -0
  60. package/lib/services/postboy-middleware.service.d.ts +9 -0
  61. package/lib/services/postboy-middleware.service.d.ts.map +1 -0
  62. package/lib/services/postboy-middleware.service.js +20 -0
  63. package/lib/services/postboy-middleware.service.js.map +1 -0
  64. package/lib/tests/integration/models/test-callback-message.d.ts +6 -0
  65. package/lib/tests/integration/models/test-callback-message.d.ts.map +1 -0
  66. package/lib/tests/integration/models/test-callback-message.js +13 -0
  67. package/lib/tests/integration/models/test-callback-message.js.map +1 -0
  68. package/lib/tests/integration/models/test-executor.d.ts +7 -0
  69. package/lib/tests/integration/models/test-executor.d.ts.map +1 -0
  70. package/lib/tests/integration/models/test-executor.js +13 -0
  71. package/lib/tests/integration/models/test-executor.js.map +1 -0
  72. package/lib/tests/integration/models/test-handler.d.ts +8 -0
  73. package/lib/tests/integration/models/test-handler.d.ts.map +1 -0
  74. package/lib/tests/integration/models/test-handler.js +15 -0
  75. package/lib/tests/integration/models/test-handler.js.map +1 -0
  76. package/lib/tests/integration/models/test-message.d.ts +6 -0
  77. package/lib/tests/integration/models/test-message.d.ts.map +1 -0
  78. package/lib/tests/integration/models/test-message.js +13 -0
  79. package/lib/tests/integration/models/test-message.js.map +1 -0
  80. package/lib/tests/integration/models/test-postboy.d.ts +4 -0
  81. package/lib/tests/integration/models/test-postboy.d.ts.map +1 -0
  82. package/lib/tests/integration/models/test-postboy.js +8 -0
  83. package/lib/tests/integration/models/test-postboy.js.map +1 -0
  84. package/lib/tests/integration/models/test-registry.d.ts +8 -0
  85. package/lib/tests/integration/models/test-registry.d.ts.map +1 -0
  86. package/lib/tests/integration/models/test-registry.js +15 -0
  87. package/lib/tests/integration/models/test-registry.js.map +1 -0
  88. package/package.json +2 -4
  89. package/lib/models/dictionary.d.ts +0 -18
  90. package/lib/models/dictionary.d.ts.map +0 -1
  91. package/lib/models/dictionary.js +0 -59
  92. package/lib/models/dictionary.js.map +0 -1
  93. package/lib/models/id-generator.d.ts +0 -4
  94. package/lib/models/id-generator.d.ts.map +0 -1
  95. package/lib/models/id-generator.js +0 -14
  96. package/lib/models/id-generator.js.map +0 -1
  97. package/lib/models/postboy-bbb.d.ts +0 -4
  98. package/lib/models/postboy-bbb.d.ts.map +0 -1
  99. package/lib/models/postboy-bbb.js.map +0 -1
package/README.md CHANGED
@@ -1,81 +1,40 @@
1
- The `@artstesh/postboy` library is designed to simplify the development of TypeScript applications using an event-driven approach. It provides convenient tools for working with the `rxjs` library, managing events, and handling dependencies, allowing developers to focus on business logic rather than boilerplate.
1
+ # Introduction
2
2
 
3
- ## Purpose of the Library
3
+ ## 1.1 About the Library
4
+ Modern web development often feels like a survival race: components are scattered across dependency trees, services communicate through layers of abstraction, and events multiply like rabbits in the Australian outback. In this chaos, managing communication isn’t just a task—it’s an art of balancing flexibility and order.
4
5
 
5
- In complex applications a developer always faces with a huge amount of services, subscriptions and, as a result, with a long list of dependencies in components of the system. Some services have to combine their own logic with providing of subscriptions, other exist only to define a list of observations to link components of the system. It is getting harder to support so many dependencies, testing becomes a nightmare add... to say the truth, it looks bad) Plus, it is neccessary to close all the subs properly to avoid memory leaks...
6
+ **Postboy** was born from this chaos. It’s not just another RxJS-based Event Bus—it’s an attempt to bridge the gap between the power of reactive programming and everyday simplicity. Over years of working with Angular, I’ve watched standard event-handling approaches drown in boilerplate code, while complex state managers morphed into impenetrable "black boxes." Postboy is my answer to these challenges.
6
7
 
7
- `@artstesh/postboy` is a tool aimed at reducing this complexity by removing repetitive tasks from development. It focuses on minimizing boilerplate code and eliminating issues such as subscription leaks and improper dependency handling.
8
+ **Key Features:**
9
+ - Lightweight architecture with zero hidden dependencies.
10
+ - Flexible messaging system backed by TypeScript typing.
11
+ - Middleware for intercepting and transforming events (logging, validation, metrics).
12
+ - Async operations and callback management tools.
13
+ - Reactive patterns out of the box: ReplaySubject, BehaviorSubject, and more.
8
14
 
9
- ## Key Features
15
+ Postboy doesn’t aim to replace NgRx or Akita—it solves a narrower set of problems but does so with minimal entry barriers.
10
16
 
11
- 1. **Event-Driven Architecture**
12
- Enables creating event-based applications with minimal overhead and explicit subscription management. This is especially useful for large-scale applications where data delivery and reaction to events play a critical role.
17
+ ---
13
18
 
14
- 2. **Integration with `rxjs`**
15
- Reactive programming is supported out of the box. This enables easy use of `rxjs` to process events.
19
+ ## 1.2. Core Concepts
20
+ Imagine Postboy as your app’s postal service. Here’s how it works:
16
21
 
17
- 3. **Dependency Management**
18
- The library simplifies dependency handling by providing an efficient mechanism for managing them.
22
+ - **Messages (PostboyMessage)**
23
+ These are data envelopes. Every message has a unique `ID` and can carry anything: a simple notification, a complex DTO, or even a `UserLoggedInEvent` or `DataFetchRequest`.
19
24
 
20
- 4. **Seamless Integration**
21
- `@artstesh/postboy` can be easily integrated into existing TypeScript projects and helps structure applications into independent components with clear responsibilities for events and reactions.
25
+ - **Subscriptions**
26
+ Like subscribing to a magazine. Components register interest in specific message types and react when they "arrive in the mailbox."
22
27
 
23
- 5. **Modularity and Scalability**
24
- Thanks to its approach, the library is suitable for both small applications and large-scale projects with complex functionality.
28
+ - **Handlers (Executors)**
29
+ Special agents that execute synchronous tasks on demand. Need to fetch data from a store or validate permissions? An Executor handles it without event spaghetti.
25
30
 
26
- ## Usage Example
31
+ - **Middleware**
32
+ Customs officers inspecting every message at the border. Need to add auth headers or log errors? Middleware centralizes these tasks.
27
33
 
28
- Let’s take a look at a simple example to demonstrate how `@artstesh/postboy` can be used to handle events.
34
+ - **Registrators**
35
+ Archivists managing subscription lifecycles. They prevent memory leaks and keep your codebase tidy.
29
36
 
30
- ### The case
31
-
32
- Suppose we such a simple structure in an Angular application:
33
-
34
- <img src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI2MDAiIGhlaWdodD0iNDAwIiBzdHlsZT0iYmFja2dyb3VuZC1jb2xvcjogdHJhbnNwYXJlbnQ7IGZvbnQtZmFtaWx5OiBBcmlhbCwgc2Fucy1zZXJpZjsgZm9udC1zaXplOiAxNHB4OyI+DQogIDwhLS0gRmlyc3QgTGV2ZWwgQ29tcG9uZW50IC0tPg0KICA8cmVjdCB4PSIyMzAiIHk9IjIwIiB3aWR0aD0iMTQwIiBoZWlnaHQ9IjUwIiBmaWxsPSIjYzhlNmM5IiBzdHJva2U9IiMyZTdkMzIiIHN0cm9rZS13aWR0aD0iMiIgcng9IjYiPjwvcmVjdD4NCiAgPHRleHQgeD0iMzAwIiB5PSI1MCIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZmlsbD0iIzJlN2QzMiI+QXBwQ29tcG9uZW50PC90ZXh0Pg0KDQogIDwhLS0gU2Vjb25kIExldmVsIENvbXBvbmVudHMgLS0+DQogIDxyZWN0IHg9IjEz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WFkKSI+PC9saW5lPg0KDQogIDwhLS0gQXJyb3doZWFkIG1hcmtlciAtLT4NCiAgPGRlZnM+DQogICAgPG1hcmtlciBpZD0iYXJyb3doZWFkIiBtYXJrZXJXaWR0aD0iMTAiIG1hcmtlckhlaWdodD0iNyIgcmVmWD0iMTAiIHJlZlk9IjMuNSIgb3JpZW50PSJhdXRvIj4NCiAgICAgIDxwb2x5Z29uIHBvaW50cz0iMCAwLCAxMCAzLjUsIDAgNyIgZmlsbD0iIzYwNjA2MCI+PC9wb2x5Z29uPg0KICAgIDwvbWFya2VyPg0KICA8L2RlZnM+DQo8L3N2Zz4NCg==">
35
-
36
- **Child B** contains a text input and **Child A** have show the value of the input.
37
-
38
- In a common case, we would create a specific service with an observable; but it alse means that we have to get an instance of the service in **Child A** and **Child B** and the service itself looks pretty bad - it is just a wrapper over the observable.
39
-
40
- *I don't event want to describe the idea of sending information through the parents - it is much more painful and dirty.
41
-
42
- ### The postboy approach
43
-
44
- ```typescript
45
- import {PostboyService} from '@artstesh/postboy';
46
-
47
- public class ChildA {
48
- constructor(private postboy: PostboyService) {
49
- }
50
-
51
- public ngOnInit(){
52
- this.postboy.sub(UserInputEvent).subscribe(ev => {
53
- console.log(ev.text);
54
- })
55
- }
56
- }
57
-
58
- public class ChildB {
59
- constructor(private postboy: PostboyService) {
60
- }
61
-
62
- public onInput(){
63
- this.postboy.fire(new UserInputEvent(this.text));
64
- }
65
- }
66
- ```
67
-
68
- ### Key Benefits of This Approach
69
-
70
- - Clear separation of event generation and event handling.
71
- - TypeScript interfaces ensure strict typing for the data passed between different parts of the application.
72
- - The members of the system know nothing about each other
73
- - No need to create specific mediators
74
-
75
- ## Advantages of the Library
76
-
77
- - **Simplicity:** Clear structure for managing events and their processing.
78
- - **Safety:** TypeScript ensures type-safety, minimizing potential errors.
79
- - **Flexibility:** `rxjs` integration allows advanced event processing, such as filtering, pre-processing, and combining event streams.
80
- - **Scalability:** Code becomes clean and easy to extend without introducing unnecessary complexity.
37
+ ---
81
38
 
39
+ ### Why Does It Work?
40
+ Over the past five years, I’ve built dozens of enterprise apps. One recurring issue? Logic fragmentation. Components communicate via `@Output()` chains and services until a single button change breaks three screens. Postboy offers an alternative: a centralized yet unobtrusive event bus that doesn’t demand architectural overhauls.
package/lib/index.d.ts CHANGED
@@ -1,11 +1,10 @@
1
1
  export * from './postboy.service';
2
- export * from './mocks/postboy-service-mock';
3
2
  export * from './i-postboy-depending.service';
4
3
  export * from './postboy-abstract.registrator';
5
4
  export * from './models/postboy-generic-message';
6
5
  export * from './models/postboy-callback.message';
7
- export * from './models/postboy.locker';
8
6
  export * from './models/postboy-execution.handler';
9
7
  export * from './models/postboy-executor';
10
- export * from './models/message-queue.model';
8
+ export * from './models/postboy-middleware';
9
+ export * from './models/postboy.message';
11
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,mBAAmB,CAAC;AAClC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC;AACjD,cAAc,mCAAmC,CAAC;AAClD,cAAc,yBAAyB,CAAC;AACxC,cAAc,oCAAoC,CAAC;AACnD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,8BAA8B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,mBAAmB,CAAC;AAClC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC;AACjD,cAAc,mCAAmC,CAAC;AAClD,cAAc,oCAAoC,CAAC;AACnD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC"}
package/lib/index.js CHANGED
@@ -18,13 +18,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
20
  __exportStar(require("./postboy.service"), exports);
21
- __exportStar(require("./mocks/postboy-service-mock"), exports);
22
21
  __exportStar(require("./i-postboy-depending.service"), exports);
23
22
  __exportStar(require("./postboy-abstract.registrator"), exports);
24
23
  __exportStar(require("./models/postboy-generic-message"), exports);
25
24
  __exportStar(require("./models/postboy-callback.message"), exports);
26
- __exportStar(require("./models/postboy.locker"), exports);
27
25
  __exportStar(require("./models/postboy-execution.handler"), exports);
28
26
  __exportStar(require("./models/postboy-executor"), exports);
29
- __exportStar(require("./models/message-queue.model"), exports);
27
+ __exportStar(require("./models/postboy-middleware"), exports);
28
+ __exportStar(require("./models/postboy.message"), exports);
30
29
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;AAEH,oDAAkC;AAClC,+DAA6C;AAC7C,gEAA8C;AAC9C,iEAA+C;AAC/C,mEAAiD;AACjD,oEAAkD;AAClD,0DAAwC;AACxC,qEAAmD;AACnD,4DAA0C;AAC1C,+DAA6C"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;AAEH,oDAAkC;AAClC,gEAA8C;AAC9C,iEAA+C;AAC/C,mEAAiD;AACjD,oEAAkD;AAClD,qEAAmD;AACnD,4DAA0C;AAC1C,8DAA4C;AAC5C,2DAAyC"}
@@ -1,9 +1,9 @@
1
- import { PostboyLocker } from './models/postboy.locker';
2
- export declare class LockerStore {
3
- private lockers;
4
- private unlockers;
5
- private locked;
6
- addLocker(locker: PostboyLocker): void;
7
- check(eventId: string): boolean;
8
- }
1
+ import { PostboyLocker } from './models/postboy.locker';
2
+ export declare class LockerStore {
3
+ private lockers;
4
+ private unlockers;
5
+ private locked;
6
+ addLocker(locker: PostboyLocker): void;
7
+ check(eventId: string): boolean;
8
+ }
9
9
  //# sourceMappingURL=locker.store.d.ts.map
@@ -1,27 +1,27 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LockerStore = void 0;
4
- class LockerStore {
5
- constructor() {
6
- this.lockers = {};
7
- this.unlockers = {};
8
- this.locked = new Set();
9
- }
10
- addLocker(locker) {
11
- if (locker.locker)
12
- this.lockers[locker.locker] = locker.locking;
13
- if (locker.unlocker)
14
- this.unlockers[locker.unlocker] = locker.locking;
15
- }
16
- check(eventId) {
17
- if (this.locked.has(eventId))
18
- return false;
19
- if (this.unlockers[eventId])
20
- this.unlockers[eventId].forEach((id) => this.locked.delete(id));
21
- if (this.lockers[eventId])
22
- this.lockers[eventId].forEach((id) => this.locked.add(id));
23
- return true;
24
- }
25
- }
26
- exports.LockerStore = LockerStore;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LockerStore = void 0;
4
+ class LockerStore {
5
+ constructor() {
6
+ this.lockers = {};
7
+ this.unlockers = {};
8
+ this.locked = new Set();
9
+ }
10
+ addLocker(locker) {
11
+ if (locker.locker)
12
+ this.lockers[locker.locker] = locker.locking;
13
+ if (locker.unlocker)
14
+ this.unlockers[locker.unlocker] = locker.locking;
15
+ }
16
+ check(eventId) {
17
+ if (this.locked.has(eventId))
18
+ return false;
19
+ if (this.unlockers[eventId])
20
+ this.unlockers[eventId].forEach((id) => this.locked.delete(id));
21
+ if (this.lockers[eventId])
22
+ this.lockers[eventId].forEach((id) => this.locked.add(id));
23
+ return true;
24
+ }
25
+ }
26
+ exports.LockerStore = LockerStore;
27
27
  //# sourceMappingURL=locker.store.js.map
@@ -1,10 +1,10 @@
1
- import { PostboyGenericMessage } from '../models/postboy-generic-message';
2
- export declare class MessageHistoryItemMock<T extends PostboyGenericMessage> {
3
- private list;
4
- add(message: T): this;
5
- clear(): void;
6
- get length(): number;
7
- get last(): T;
8
- get all(): T[];
9
- }
1
+ import { PostboyGenericMessage } from '../models/postboy-generic-message';
2
+ export declare class MessageHistoryItemMock<T extends PostboyGenericMessage> {
3
+ private list;
4
+ add(message: T): this;
5
+ clear(): void;
6
+ get length(): number;
7
+ get last(): T;
8
+ get all(): T[];
9
+ }
10
10
  //# sourceMappingURL=message-history-item-mock.d.ts.map
@@ -1,26 +1,26 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MessageHistoryItemMock = void 0;
4
- class MessageHistoryItemMock {
5
- constructor() {
6
- this.list = [];
7
- }
8
- add(message) {
9
- this.list.push(message);
10
- return this;
11
- }
12
- clear() {
13
- this.list = [];
14
- }
15
- get length() {
16
- return this.list.length;
17
- }
18
- get last() {
19
- return this.list[this.list.length - 1];
20
- }
21
- get all() {
22
- return [...this.list];
23
- }
24
- }
25
- exports.MessageHistoryItemMock = MessageHistoryItemMock;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MessageHistoryItemMock = void 0;
4
+ class MessageHistoryItemMock {
5
+ constructor() {
6
+ this.list = [];
7
+ }
8
+ add(message) {
9
+ this.list.push(message);
10
+ return this;
11
+ }
12
+ clear() {
13
+ this.list = [];
14
+ }
15
+ get length() {
16
+ return this.list.length;
17
+ }
18
+ get last() {
19
+ return this.list[this.list.length - 1];
20
+ }
21
+ get all() {
22
+ return [...this.list];
23
+ }
24
+ }
25
+ exports.MessageHistoryItemMock = MessageHistoryItemMock;
26
26
  //# sourceMappingURL=message-history-item-mock.js.map
@@ -1,9 +1,9 @@
1
- import { PostboyGenericMessage } from '../models/postboy-generic-message';
2
- import { MessageHistoryItemMock } from './message-history-item-mock';
3
- export declare class MessageHistoryMock {
4
- private _items;
5
- get<T extends PostboyGenericMessage>(id: string): MessageHistoryItemMock<T>;
6
- add(message: PostboyGenericMessage): void;
7
- reset(): void;
8
- }
1
+ import { PostboyGenericMessage } from '../models/postboy-generic-message';
2
+ import { MessageHistoryItemMock } from './message-history-item-mock';
3
+ export declare class MessageHistoryMock {
4
+ private _items;
5
+ get<T extends PostboyGenericMessage>(id: string): MessageHistoryItemMock<T>;
6
+ add(message: PostboyGenericMessage): void;
7
+ reset(): void;
8
+ }
9
9
  //# sourceMappingURL=message-history-mock.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"message-history-mock.d.ts","sourceRoot":"","sources":["../../src/mocks/message-history-mock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAGrE,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAAiD;IAE/D,GAAG,CAAC,CAAC,SAAS,qBAAqB,EAAE,EAAE,EAAE,MAAM,GAAG,sBAAsB,CAAC,CAAC,CAAC;IAI3E,GAAG,CAAC,OAAO,EAAE,qBAAqB,GAAG,IAAI;IAKzC,KAAK,IAAI,IAAI;CAGd"}
1
+ {"version":3,"file":"message-history-mock.d.ts","sourceRoot":"","sources":["../../src/mocks/message-history-mock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,qBAAqB,EAAC,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAC,sBAAsB,EAAC,MAAM,6BAA6B,CAAC;AAEnE,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAAiD;IAE/D,GAAG,CAAC,CAAC,SAAS,qBAAqB,EAAE,EAAE,EAAE,MAAM,GAAG,sBAAsB,CAAC,CAAC,CAAC;IAI3E,GAAG,CAAC,OAAO,EAAE,qBAAqB,GAAG,IAAI;IAKzC,KAAK,IAAI,IAAI;CAGd"}
@@ -1,24 +1,23 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MessageHistoryMock = void 0;
4
- const message_history_item_mock_1 = require("./message-history-item-mock");
5
- const collections_1 = require("@artstesh/collections");
6
- class MessageHistoryMock {
7
- constructor() {
8
- this._items = new collections_1.Dictionary();
9
- }
10
- get(id) {
11
- var _a;
12
- return (_a = this._items.take(id)) !== null && _a !== void 0 ? _a : new message_history_item_mock_1.MessageHistoryItemMock();
13
- }
14
- add(message) {
15
- var _a;
16
- if (!((_a = this._items.take(message.id)) === null || _a === void 0 ? void 0 : _a.add(message)))
17
- this._items.put(message.id, new message_history_item_mock_1.MessageHistoryItemMock().add(message));
18
- }
19
- reset() {
20
- this._items.forEach((i) => i.clear());
21
- }
22
- }
23
- exports.MessageHistoryMock = MessageHistoryMock;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MessageHistoryMock = void 0;
4
+ const message_history_item_mock_1 = require("./message-history-item-mock");
5
+ class MessageHistoryMock {
6
+ constructor() {
7
+ this._items = new Map();
8
+ }
9
+ get(id) {
10
+ var _a;
11
+ return (_a = this._items.get(id)) !== null && _a !== void 0 ? _a : new message_history_item_mock_1.MessageHistoryItemMock();
12
+ }
13
+ add(message) {
14
+ var _a;
15
+ if (!((_a = this._items.get(message.id)) === null || _a === void 0 ? void 0 : _a.add(message)))
16
+ this._items.set(message.id, new message_history_item_mock_1.MessageHistoryItemMock().add(message));
17
+ }
18
+ reset() {
19
+ this._items.forEach((i) => i.clear());
20
+ }
21
+ }
22
+ exports.MessageHistoryMock = MessageHistoryMock;
24
23
  //# sourceMappingURL=message-history-mock.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"message-history-mock.js","sourceRoot":"","sources":["../../src/mocks/message-history-mock.ts"],"names":[],"mappings":";;;AACA,2EAAqE;AACrE,uDAAmD;AAEnD,MAAa,kBAAkB;IAA/B;QACU,WAAM,GAAG,IAAI,wBAAU,EAA+B,CAAC;IAcjE,CAAC;IAZC,GAAG,CAAkC,EAAU;;QAC7C,OAAO,MAAA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,mCAAI,IAAI,kDAAsB,EAAE,CAAC;IAC9D,CAAC;IAED,GAAG,CAAC,OAA8B;;QAChC,IAAI,CAAC,CAAA,MAAA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,0CAAE,GAAG,CAAC,OAAO,CAAC,CAAA;YAC7C,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,EAAE,IAAI,kDAAsB,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;IAC3E,CAAC;IAED,KAAK;QACH,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;IACxC,CAAC;CACF;AAfD,gDAeC"}
1
+ {"version":3,"file":"message-history-mock.js","sourceRoot":"","sources":["../../src/mocks/message-history-mock.ts"],"names":[],"mappings":";;;AACA,2EAAmE;AAEnE,MAAa,kBAAkB;IAA/B;QACU,WAAM,GAAG,IAAI,GAAG,EAAsC,CAAC;IAcjE,CAAC;IAZC,GAAG,CAAkC,EAAU;;QAC7C,OAAO,MAAA,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,mCAAI,IAAI,kDAAsB,EAAE,CAAC;IAC7D,CAAC;IAED,GAAG,CAAC,OAA8B;;QAChC,IAAI,CAAC,CAAA,MAAA,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,0CAAE,GAAG,CAAC,OAAO,CAAC,CAAA;YAC5C,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,EAAE,IAAI,kDAAsB,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;IAC3E,CAAC;IAED,KAAK;QACH,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;IACxC,CAAC;CACF;AAfD,gDAeC"}
@@ -1,22 +1,22 @@
1
- import { PostboyService } from '../postboy.service';
2
- import { Observable } from 'rxjs';
3
- import { PostboyExecutor } from '../models/postboy-executor';
4
- import { PostboyGenericMessage } from '../models/postboy-generic-message';
5
- import { PostboyCallbackMessage } from '../models/postboy-callback.message';
6
- import { MessageHistoryItemMock } from './message-history-item-mock';
7
- import { MessageType } from '../postboy-abstract.registrator';
8
- export declare class PostboyServiceMock extends PostboyService {
9
- private subscriptions;
10
- private _history;
11
- reset(): void;
12
- fired(id: string, times?: number): boolean;
13
- subscribed(id: string, times?: number): boolean;
14
- private count;
15
- exec<E extends PostboyExecutor<T>, T>(executor: E): T;
16
- subscribe<T>(id: string): Observable<T>;
17
- sub<T extends PostboyGenericMessage>(type: MessageType<T>): Observable<T>;
18
- fire<T extends PostboyGenericMessage>(message: T): void;
19
- fireCallback<T>(message: PostboyCallbackMessage<T>, action?: (e: T) => void): Observable<T>;
20
- history<T extends PostboyGenericMessage>(type: MessageType<T>): MessageHistoryItemMock<T>;
21
- }
1
+ import { PostboyService } from '../postboy.service';
2
+ import { Observable } from 'rxjs';
3
+ import { PostboyExecutor } from '../models/postboy-executor';
4
+ import { PostboyGenericMessage } from '../models/postboy-generic-message';
5
+ import { PostboyCallbackMessage } from '../models/postboy-callback.message';
6
+ import { MessageHistoryItemMock } from './message-history-item-mock';
7
+ import { MessageType } from '../postboy-abstract.registrator';
8
+ export declare class PostboyServiceMock extends PostboyService {
9
+ private subscriptions;
10
+ private _history;
11
+ reset(): void;
12
+ fired(id: string, times?: number): boolean;
13
+ subscribed(id: string, times?: number): boolean;
14
+ private count;
15
+ exec<E extends PostboyExecutor<T>, T>(executor: E): T;
16
+ subscribe<T>(id: string): Observable<T>;
17
+ sub<T extends PostboyGenericMessage>(type: MessageType<T>): Observable<T>;
18
+ fire<T extends PostboyGenericMessage>(message: T): void;
19
+ fireCallback<T>(message: PostboyCallbackMessage<T>, action?: (e: T) => void): Observable<T>;
20
+ history<T extends PostboyGenericMessage>(type: MessageType<T>): MessageHistoryItemMock<T>;
21
+ }
22
22
  //# sourceMappingURL=postboy-service-mock.d.ts.map
@@ -1,51 +1,51 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PostboyServiceMock = void 0;
4
- const postboy_service_1 = require("../postboy.service");
5
- const postboy_generic_message_1 = require("../models/postboy-generic-message");
6
- const message_history_mock_1 = require("./message-history-mock");
7
- class PostboyServiceMock extends postboy_service_1.PostboyService {
8
- constructor() {
9
- super(...arguments);
10
- this.subscriptions = [];
11
- this._history = new message_history_mock_1.MessageHistoryMock();
12
- this.count = (collection, el) => collection.filter((e) => e === el).length;
13
- }
14
- reset() {
15
- this.subscriptions = [];
16
- this._history.reset();
17
- }
18
- fired(id, times = 0) {
19
- var _a;
20
- return ((_a = this._history.get(id)) === null || _a === void 0 ? void 0 : _a.length) === times;
21
- }
22
- subscribed(id, times = 0) {
23
- const count = this.count(this.subscriptions, id);
24
- return !!count && (!times || count === times);
25
- }
26
- exec(executor) {
27
- this._history.add(executor);
28
- return super.exec(executor);
29
- }
30
- subscribe(id) {
31
- this.subscriptions.push(id);
32
- return super.subscribe(id);
33
- }
34
- sub(type) {
35
- this.subscriptions.push((0, postboy_generic_message_1.checkId)(type));
36
- return super.subscribe((0, postboy_generic_message_1.checkId)(type));
37
- }
38
- fire(message) {
39
- this._history.add(message);
40
- super.fire(message);
41
- }
42
- fireCallback(message, action) {
43
- this._history.add(message);
44
- return super.fireCallback(message, action);
45
- }
46
- history(type) {
47
- return this._history.get((0, postboy_generic_message_1.checkId)(type));
48
- }
49
- }
50
- exports.PostboyServiceMock = PostboyServiceMock;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PostboyServiceMock = void 0;
4
+ const postboy_service_1 = require("../postboy.service");
5
+ const postboy_generic_message_1 = require("../models/postboy-generic-message");
6
+ const message_history_mock_1 = require("./message-history-mock");
7
+ class PostboyServiceMock extends postboy_service_1.PostboyService {
8
+ constructor() {
9
+ super(...arguments);
10
+ this.subscriptions = [];
11
+ this._history = new message_history_mock_1.MessageHistoryMock();
12
+ this.count = (collection, el) => collection.filter((e) => e === el).length;
13
+ }
14
+ reset() {
15
+ this.subscriptions = [];
16
+ this._history.reset();
17
+ }
18
+ fired(id, times = 0) {
19
+ var _a;
20
+ return ((_a = this._history.get(id)) === null || _a === void 0 ? void 0 : _a.length) === times;
21
+ }
22
+ subscribed(id, times = 0) {
23
+ const count = this.count(this.subscriptions, id);
24
+ return !!count && (!times || count === times);
25
+ }
26
+ exec(executor) {
27
+ this._history.add(executor);
28
+ return super.exec(executor);
29
+ }
30
+ subscribe(id) {
31
+ this.subscriptions.push(id);
32
+ return super.subscribe(id);
33
+ }
34
+ sub(type) {
35
+ this.subscriptions.push((0, postboy_generic_message_1.checkId)(type));
36
+ return super.subscribe((0, postboy_generic_message_1.checkId)(type));
37
+ }
38
+ fire(message) {
39
+ this._history.add(message);
40
+ super.fire(message);
41
+ }
42
+ fireCallback(message, action) {
43
+ this._history.add(message);
44
+ return super.fireCallback(message, action);
45
+ }
46
+ history(type) {
47
+ return this._history.get((0, postboy_generic_message_1.checkId)(type));
48
+ }
49
+ }
50
+ exports.PostboyServiceMock = PostboyServiceMock;
51
51
  //# sourceMappingURL=postboy-service-mock.js.map
@@ -1,44 +1,44 @@
1
- import { PostboyCallbackMessage } from './postboy-callback.message';
2
- export declare class MessageQueue<D> {
3
- private cache;
4
- /**
5
- * Gets the current data stored in the instance.
6
- *
7
- * @return {D | null} The current data or null if no data is set.
8
- */
9
- get data(): D | null;
10
- private queries;
11
- private _requestInProgress;
12
- private _data;
13
- constructor(cache?: boolean);
14
- /**
15
- * Resets the state of the instance by clearing stored data.
16
- * This method sets the internal data to null, effectively resetting the object.
17
- *
18
- * @return {void} Does not return a value.
19
- */
20
- reset(): MessageQueue<D>;
21
- /**
22
- * Attempts to finalize the provided query. It either queues the query for later processing
23
- * if a request is in progress or data is missing, or completes the query immediately.
24
- *
25
- * @param {PostboyCallbackMessage<D>} query - The callback message to be finalized.
26
- * @return {boolean} - Returns true if the query was successfully finalized, otherwise false.
27
- */
28
- tryFinish(query: PostboyCallbackMessage<D>): boolean;
29
- /**
30
- * Adds a new query to the query queue.
31
- *
32
- * @param {PostboyCallbackMessage<D>} query - The query to be added to the queue.
33
- * @return {MessageQueue<D>} The updated QueryQueue instance.
34
- */
35
- add(query: PostboyCallbackMessage<D>): MessageQueue<D>;
36
- /**
37
- * Marks the operation as finished by updating the internal state and handling each query.
38
- *
39
- * @param {D} data - The data to be set for the current operation.
40
- * @return {void} This method does not return a value.
41
- */
42
- finish(data: D): void;
43
- }
1
+ import { PostboyCallbackMessage } from './postboy-callback.message';
2
+ export declare class MessageQueue<D> {
3
+ private cache;
4
+ /**
5
+ * Gets the current data stored in the instance.
6
+ *
7
+ * @return {D | null} The current data or null if no data is set.
8
+ */
9
+ get data(): D | null;
10
+ private queries;
11
+ private _requestInProgress;
12
+ private _data;
13
+ constructor(cache?: boolean);
14
+ /**
15
+ * Resets the state of the instance by clearing stored data.
16
+ * This method sets the internal data to null, effectively resetting the object.
17
+ *
18
+ * @return {void} Does not return a value.
19
+ */
20
+ reset(): MessageQueue<D>;
21
+ /**
22
+ * Attempts to finalize the provided query. It either queues the query for later processing
23
+ * if a request is in progress or data is missing, or completes the query immediately.
24
+ *
25
+ * @param {PostboyCallbackMessage<D>} query - The callback message to be finalized.
26
+ * @return {boolean} - Returns true if the query was successfully finalized, otherwise false.
27
+ */
28
+ tryFinish(query: PostboyCallbackMessage<D>): boolean;
29
+ /**
30
+ * Adds a new query to the query queue.
31
+ *
32
+ * @param {PostboyCallbackMessage<D>} query - The query to be added to the queue.
33
+ * @return {MessageQueue<D>} The updated QueryQueue instance.
34
+ */
35
+ add(query: PostboyCallbackMessage<D>): MessageQueue<D>;
36
+ /**
37
+ * Marks the operation as finished by updating the internal state and handling each query.
38
+ *
39
+ * @param {D} data - The data to be set for the current operation.
40
+ * @return {void} This method does not return a value.
41
+ */
42
+ finish(data: D): void;
43
+ }
44
44
  //# sourceMappingURL=message-queue.model.d.ts.map