@artstesh/postboy 2.1.5 → 2.1.7

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 (34) hide show
  1. package/README.md +81 -27
  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 +10 -10
  5. package/lib/index.js +29 -29
  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.js +23 -23
  12. package/lib/mocks/postboy-service-mock.d.ts +21 -21
  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 +105 -105
  32. package/lib/postboy.service.js +160 -160
  33. package/lib/postboy.service.js.map +1 -1
  34. package/package.json +1 -1
@@ -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
@@ -1,66 +1,66 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MessageQueue = void 0;
4
- const collections_1 = require("@artstesh/collections");
5
- class MessageQueue {
6
- /**
7
- * Gets the current data stored in the instance.
8
- *
9
- * @return {D | null} The current data or null if no data is set.
10
- */
11
- get data() {
12
- return this._data;
13
- }
14
- constructor(cache = true) {
15
- this.cache = cache;
16
- this.queries = new collections_1.Queue();
17
- this._requestInProgress = true;
18
- this._data = null;
19
- }
20
- /**
21
- * Resets the state of the instance by clearing stored data.
22
- * This method sets the internal data to null, effectively resetting the object.
23
- *
24
- * @return {void} Does not return a value.
25
- */
26
- reset() {
27
- this._data = null;
28
- return this;
29
- }
30
- /**
31
- * Attempts to finalize the provided query. It either queues the query for later processing
32
- * if a request is in progress or data is missing, or completes the query immediately.
33
- *
34
- * @param {PostboyCallbackMessage<D>} query - The callback message to be finalized.
35
- * @return {boolean} - Returns true if the query was successfully finalized, otherwise false.
36
- */
37
- tryFinish(query) {
38
- if (this._requestInProgress || this._data === null)
39
- return this.queries.put(query) && false;
40
- query.finish(this._data);
41
- return true;
42
- }
43
- /**
44
- * Adds a new query to the query queue.
45
- *
46
- * @param {PostboyCallbackMessage<D>} query - The query to be added to the queue.
47
- * @return {MessageQueue<D>} The updated QueryQueue instance.
48
- */
49
- add(query) {
50
- return this.queries.put(query) && this;
51
- }
52
- /**
53
- * Marks the operation as finished by updating the internal state and handling each query.
54
- *
55
- * @param {D} data - The data to be set for the current operation.
56
- * @return {void} This method does not return a value.
57
- */
58
- finish(data) {
59
- if (this.cache)
60
- this._data = data;
61
- this._requestInProgress = false;
62
- this.queries.each((q) => q.finish(data));
63
- }
64
- }
65
- exports.MessageQueue = MessageQueue;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MessageQueue = void 0;
4
+ const collections_1 = require("@artstesh/collections");
5
+ class MessageQueue {
6
+ /**
7
+ * Gets the current data stored in the instance.
8
+ *
9
+ * @return {D | null} The current data or null if no data is set.
10
+ */
11
+ get data() {
12
+ return this._data;
13
+ }
14
+ constructor(cache = true) {
15
+ this.cache = cache;
16
+ this.queries = new collections_1.Queue();
17
+ this._requestInProgress = true;
18
+ this._data = null;
19
+ }
20
+ /**
21
+ * Resets the state of the instance by clearing stored data.
22
+ * This method sets the internal data to null, effectively resetting the object.
23
+ *
24
+ * @return {void} Does not return a value.
25
+ */
26
+ reset() {
27
+ this._data = null;
28
+ return this;
29
+ }
30
+ /**
31
+ * Attempts to finalize the provided query. It either queues the query for later processing
32
+ * if a request is in progress or data is missing, or completes the query immediately.
33
+ *
34
+ * @param {PostboyCallbackMessage<D>} query - The callback message to be finalized.
35
+ * @return {boolean} - Returns true if the query was successfully finalized, otherwise false.
36
+ */
37
+ tryFinish(query) {
38
+ if (this._requestInProgress || this._data === null)
39
+ return this.queries.put(query) && false;
40
+ query.finish(this._data);
41
+ return true;
42
+ }
43
+ /**
44
+ * Adds a new query to the query queue.
45
+ *
46
+ * @param {PostboyCallbackMessage<D>} query - The query to be added to the queue.
47
+ * @return {MessageQueue<D>} The updated QueryQueue instance.
48
+ */
49
+ add(query) {
50
+ return this.queries.put(query) && this;
51
+ }
52
+ /**
53
+ * Marks the operation as finished by updating the internal state and handling each query.
54
+ *
55
+ * @param {D} data - The data to be set for the current operation.
56
+ * @return {void} This method does not return a value.
57
+ */
58
+ finish(data) {
59
+ if (this.cache)
60
+ this._data = data;
61
+ this._requestInProgress = false;
62
+ this.queries.each((q) => q.finish(data));
63
+ }
64
+ }
65
+ exports.MessageQueue = MessageQueue;
66
66
  //# sourceMappingURL=message-queue.model.js.map
@@ -1,9 +1,9 @@
1
- import { Observable, Subject } from 'rxjs';
2
- import { PostboyGenericMessage } from './postboy-generic-message';
3
- export declare abstract class PostboyCallbackMessage<T> extends PostboyGenericMessage {
4
- protected result$: Subject<T>;
5
- result: Observable<T>;
6
- next: (value: T) => void;
7
- finish(value: T): void;
8
- }
1
+ import { Observable, Subject } from 'rxjs';
2
+ import { PostboyGenericMessage } from './postboy-generic-message';
3
+ export declare abstract class PostboyCallbackMessage<T> extends PostboyGenericMessage {
4
+ protected result$: Subject<T>;
5
+ result: Observable<T>;
6
+ next: (value: T) => void;
7
+ finish(value: T): void;
8
+ }
9
9
  //# sourceMappingURL=postboy-callback.message.d.ts.map
@@ -1,19 +1,19 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PostboyCallbackMessage = void 0;
4
- const rxjs_1 = require("rxjs");
5
- const postboy_generic_message_1 = require("./postboy-generic-message");
6
- class PostboyCallbackMessage extends postboy_generic_message_1.PostboyGenericMessage {
7
- constructor() {
8
- super(...arguments);
9
- this.result$ = new rxjs_1.Subject();
10
- this.result = this.result$.asObservable();
11
- this.next = (value) => this.result$.next(value);
12
- }
13
- finish(value) {
14
- this.result$.next(value);
15
- this.result$.complete();
16
- }
17
- }
18
- exports.PostboyCallbackMessage = PostboyCallbackMessage;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PostboyCallbackMessage = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const postboy_generic_message_1 = require("./postboy-generic-message");
6
+ class PostboyCallbackMessage extends postboy_generic_message_1.PostboyGenericMessage {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.result$ = new rxjs_1.Subject();
10
+ this.result = this.result$.asObservable();
11
+ this.next = (value) => this.result$.next(value);
12
+ }
13
+ finish(value) {
14
+ this.result$.next(value);
15
+ this.result$.complete();
16
+ }
17
+ }
18
+ exports.PostboyCallbackMessage = PostboyCallbackMessage;
19
19
  //# sourceMappingURL=postboy-callback.message.js.map
@@ -1,15 +1,15 @@
1
- import { PostboyExecutor } from './postboy-executor';
2
- /**
3
- * Abstract class representing a handler for executing a Postboy task.
4
- *
5
- * This class is intended to manage the execution flow of a PostboyExecutor instance.
6
- * Subclasses must implement the `handle` method, which executes a given PostboyExecutor
7
- * and returns a result of type R.
8
- *
9
- * @template R The type of the result returned by the `handle` method.
10
- * @template E The type of the executor extending the PostboyExecutor.
11
- */
12
- export declare abstract class PostboyExecutionHandler<R, E extends PostboyExecutor<R>> {
13
- abstract handle(executor: E): R;
14
- }
1
+ import { PostboyExecutor } from './postboy-executor';
2
+ /**
3
+ * Abstract class representing a handler for executing a Postboy task.
4
+ *
5
+ * This class is intended to manage the execution flow of a PostboyExecutor instance.
6
+ * Subclasses must implement the `handle` method, which executes a given PostboyExecutor
7
+ * and returns a result of type R.
8
+ *
9
+ * @template R The type of the result returned by the `handle` method.
10
+ * @template E The type of the executor extending the PostboyExecutor.
11
+ */
12
+ export declare abstract class PostboyExecutionHandler<R, E extends PostboyExecutor<R>> {
13
+ abstract handle(executor: E): R;
14
+ }
15
15
  //# sourceMappingURL=postboy-execution.handler.d.ts.map
@@ -1,17 +1,17 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PostboyExecutionHandler = void 0;
4
- /**
5
- * Abstract class representing a handler for executing a Postboy task.
6
- *
7
- * This class is intended to manage the execution flow of a PostboyExecutor instance.
8
- * Subclasses must implement the `handle` method, which executes a given PostboyExecutor
9
- * and returns a result of type R.
10
- *
11
- * @template R The type of the result returned by the `handle` method.
12
- * @template E The type of the executor extending the PostboyExecutor.
13
- */
14
- class PostboyExecutionHandler {
15
- }
16
- exports.PostboyExecutionHandler = PostboyExecutionHandler;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PostboyExecutionHandler = void 0;
4
+ /**
5
+ * Abstract class representing a handler for executing a Postboy task.
6
+ *
7
+ * This class is intended to manage the execution flow of a PostboyExecutor instance.
8
+ * Subclasses must implement the `handle` method, which executes a given PostboyExecutor
9
+ * and returns a result of type R.
10
+ *
11
+ * @template R The type of the result returned by the `handle` method.
12
+ * @template E The type of the executor extending the PostboyExecutor.
13
+ */
14
+ class PostboyExecutionHandler {
15
+ }
16
+ exports.PostboyExecutionHandler = PostboyExecutionHandler;
17
17
  //# sourceMappingURL=postboy-execution.handler.js.map
@@ -1,4 +1,4 @@
1
- import { PostboyGenericMessage } from './postboy-generic-message';
2
- export declare abstract class PostboyExecutor<T> extends PostboyGenericMessage {
3
- }
1
+ import { PostboyGenericMessage } from './postboy-generic-message';
2
+ export declare abstract class PostboyExecutor<T> extends PostboyGenericMessage {
3
+ }
4
4
  //# sourceMappingURL=postboy-executor.d.ts.map
@@ -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_generic_message_1 = require("./postboy-generic-message");
5
+ class PostboyExecutor extends postboy_generic_message_1.PostboyGenericMessage {
6
+ }
7
+ exports.PostboyExecutor = PostboyExecutor;
8
8
  //# sourceMappingURL=postboy-executor.js.map
@@ -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
+ /**
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;
8
8
  //# sourceMappingURL=postboy-generic-message.d.ts.map
@@ -1,19 +1,19 @@
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
+ /**
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;
19
19
  //# sourceMappingURL=postboy-generic-message.js.map
@@ -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
@@ -1,6 +1,6 @@
1
- export interface PostboyLocker {
2
- locker?: string;
3
- unlocker?: string;
4
- locking: string[];
5
- }
1
+ export interface PostboyLocker {
2
+ locker?: string;
3
+ unlocker?: string;
4
+ locking: string[];
5
+ }
6
6
  //# sourceMappingURL=postboy.locker.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=postboy.locker.js.map