@artstesh/postboy 2.1.7 → 2.1.10

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 (35) hide show
  1. package/lib/i-postboy-depending.service.d.ts +3 -3
  2. package/lib/i-postboy-depending.service.js +2 -2
  3. package/lib/index.d.ts +10 -10
  4. package/lib/index.js +29 -29
  5. package/lib/locker.store.d.ts +8 -8
  6. package/lib/locker.store.js +26 -26
  7. package/lib/mocks/message-history-item-mock.d.ts +9 -9
  8. package/lib/mocks/message-history-item-mock.js +25 -25
  9. package/lib/mocks/message-history-mock.d.ts +8 -8
  10. package/lib/mocks/message-history-mock.js +23 -23
  11. package/lib/mocks/postboy-service-mock.d.ts +21 -21
  12. package/lib/mocks/postboy-service-mock.d.ts.map +1 -1
  13. package/lib/mocks/postboy-service-mock.js +50 -50
  14. package/lib/models/message-queue.model.d.ts +43 -43
  15. package/lib/models/message-queue.model.js +65 -65
  16. package/lib/models/postboy-callback.message.d.ts +8 -8
  17. package/lib/models/postboy-callback.message.js +18 -18
  18. package/lib/models/postboy-execution.handler.d.ts +14 -14
  19. package/lib/models/postboy-execution.handler.js +16 -16
  20. package/lib/models/postboy-executor.d.ts +3 -3
  21. package/lib/models/postboy-executor.js +7 -7
  22. package/lib/models/postboy-generic-message.d.ts +7 -7
  23. package/lib/models/postboy-generic-message.js +18 -18
  24. package/lib/models/postboy-subscription.d.ts +6 -6
  25. package/lib/models/postboy-subscription.js +10 -10
  26. package/lib/models/postboy.locker.d.ts +5 -5
  27. package/lib/models/postboy.locker.js +2 -2
  28. package/lib/postboy-abstract.registrator.d.ts +113 -113
  29. package/lib/postboy-abstract.registrator.d.ts.map +1 -1
  30. package/lib/postboy-abstract.registrator.js +141 -141
  31. package/lib/postboy.service.d.ts +108 -105
  32. package/lib/postboy.service.d.ts.map +1 -1
  33. package/lib/postboy.service.js +161 -160
  34. package/lib/postboy.service.js.map +1 -1
  35. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- export interface IPostboyDependingService {
2
- up(): void;
3
- }
1
+ export interface IPostboyDependingService {
2
+ up(): void;
3
+ }
4
4
  //# sourceMappingURL=i-postboy-depending.service.d.ts.map
@@ -1,3 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  //# sourceMappingURL=i-postboy-depending.service.js.map
package/lib/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- export * from './postboy.service';
2
- export * from './mocks/postboy-service-mock';
3
- export * from './i-postboy-depending.service';
4
- export * from './postboy-abstract.registrator';
5
- export * from './models/postboy-generic-message';
6
- export * from './models/postboy-callback.message';
7
- export * from './models/postboy.locker';
8
- export * from './models/postboy-execution.handler';
9
- export * from './models/postboy-executor';
10
- export * from './models/message-queue.model';
1
+ export * from './postboy.service';
2
+ export * from './mocks/postboy-service-mock';
3
+ export * from './i-postboy-depending.service';
4
+ export * from './postboy-abstract.registrator';
5
+ export * from './models/postboy-generic-message';
6
+ export * from './models/postboy-callback.message';
7
+ export * from './models/postboy.locker';
8
+ export * from './models/postboy-execution.handler';
9
+ export * from './models/postboy-executor';
10
+ export * from './models/message-queue.model';
11
11
  //# sourceMappingURL=index.d.ts.map
package/lib/index.js CHANGED
@@ -1,30 +1,30 @@
1
- "use strict";
2
- /*
3
- * Public API Surface of postboy
4
- */
5
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- var desc = Object.getOwnPropertyDescriptor(m, k);
8
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
- desc = { enumerable: true, get: function() { return m[k]; } };
10
- }
11
- Object.defineProperty(o, k2, desc);
12
- }) : (function(o, m, k, k2) {
13
- if (k2 === undefined) k2 = k;
14
- o[k2] = m[k];
15
- }));
16
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
17
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
18
- };
19
- Object.defineProperty(exports, "__esModule", { value: true });
20
- __exportStar(require("./postboy.service"), exports);
21
- __exportStar(require("./mocks/postboy-service-mock"), exports);
22
- __exportStar(require("./i-postboy-depending.service"), exports);
23
- __exportStar(require("./postboy-abstract.registrator"), exports);
24
- __exportStar(require("./models/postboy-generic-message"), exports);
25
- __exportStar(require("./models/postboy-callback.message"), exports);
26
- __exportStar(require("./models/postboy.locker"), exports);
27
- __exportStar(require("./models/postboy-execution.handler"), exports);
28
- __exportStar(require("./models/postboy-executor"), exports);
29
- __exportStar(require("./models/message-queue.model"), exports);
1
+ "use strict";
2
+ /*
3
+ * Public API Surface of postboy
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
17
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ __exportStar(require("./postboy.service"), exports);
21
+ __exportStar(require("./mocks/postboy-service-mock"), exports);
22
+ __exportStar(require("./i-postboy-depending.service"), exports);
23
+ __exportStar(require("./postboy-abstract.registrator"), exports);
24
+ __exportStar(require("./models/postboy-generic-message"), exports);
25
+ __exportStar(require("./models/postboy-callback.message"), exports);
26
+ __exportStar(require("./models/postboy.locker"), exports);
27
+ __exportStar(require("./models/postboy-execution.handler"), exports);
28
+ __exportStar(require("./models/postboy-executor"), exports);
29
+ __exportStar(require("./models/message-queue.model"), exports);
30
30
  //# sourceMappingURL=index.js.map
@@ -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,24 +1,24 @@
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
+ 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;
24
24
  //# sourceMappingURL=message-history-mock.js.map
@@ -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): void;
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 +1 @@
1
- {"version":3,"file":"postboy-service-mock.d.ts","sourceRoot":"","sources":["../../src/mocks/postboy-service-mock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAW,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AACnF,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAE5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,qBAAa,kBAAmB,SAAQ,cAAc;IACpD,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,QAAQ,CAA4B;IAE5C,KAAK,IAAI,IAAI;IAKb,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,GAAE,MAAU,GAAG,OAAO;IAI7C,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,GAAE,MAAU,GAAG,OAAO;IAKlD,OAAO,CAAC,KAAK,CAAmF;IAEhG,IAAI,CAAC,CAAC,SAAS,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC;IAKrD,SAAS,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC;IAKhC,GAAG,CAAC,CAAC,SAAS,qBAAqB,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;IAKhF,IAAI,CAAC,CAAC,SAAS,qBAAqB,EAAE,OAAO,EAAE,CAAC;IAKhD,YAAY,CAAC,CAAC,EAAE,OAAO,EAAE,sBAAsB,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,GAAG,IAAI;IAKlF,OAAO,CAAC,CAAC,SAAS,qBAAqB,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,sBAAsB,CAAC,CAAC,CAAC;CAG1F"}
1
+ {"version":3,"file":"postboy-service-mock.d.ts","sourceRoot":"","sources":["../../src/mocks/postboy-service-mock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAW,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AACnF,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAE5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,qBAAa,kBAAmB,SAAQ,cAAc;IACpD,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,QAAQ,CAA4B;IAE5C,KAAK,IAAI,IAAI;IAKb,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,GAAE,MAAU,GAAG,OAAO;IAI7C,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,GAAE,MAAU,GAAG,OAAO;IAKlD,OAAO,CAAC,KAAK,CAAmF;IAEhG,IAAI,CAAC,CAAC,SAAS,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC;IAKrD,SAAS,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC;IAKhC,GAAG,CAAC,CAAC,SAAS,qBAAqB,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;IAKhF,IAAI,CAAC,CAAC,SAAS,qBAAqB,EAAE,OAAO,EAAE,CAAC;IAKhD,YAAY,CAAC,CAAC,EAAE,OAAO,EAAE,sBAAsB,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,GAAG,UAAU,CAAC,CAAC,CAAC;IAK3F,OAAO,CAAC,CAAC,SAAS,qBAAqB,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,sBAAsB,CAAC,CAAC,CAAC;CAG1F"}
@@ -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