@nsshunt/stsappframework 3.1.167 → 3.1.169

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 (31) hide show
  1. package/dist/testertesting/app.js +49 -0
  2. package/dist/testertesting/app.js.map +1 -1
  3. package/dist/testertesting/commonTypes.js +2 -2
  4. package/dist/testertesting/commonTypes.js.map +1 -1
  5. package/dist/testertesting/testCase01.js +2 -2
  6. package/dist/testertesting/testCase01.js.map +1 -1
  7. package/dist/testertesting/workerInstance.js +21 -27
  8. package/dist/testertesting/workerInstance.js.map +1 -1
  9. package/dist/testertesting/workerManager.js +77 -25
  10. package/dist/testertesting/workerManager.js.map +1 -1
  11. package/dist/testertesting/workerWorkerTestRunner01.js +9 -145
  12. package/dist/testertesting/workerWorkerTestRunner01.js.map +1 -1
  13. package/package.json +3 -1
  14. package/src/testertesting/app.ts +62 -5
  15. package/src/testertesting/commonTypes.ts +19 -7
  16. package/src/testertesting/testCase01.ts +2 -2
  17. package/src/testertesting/workerInstance.ts +22 -32
  18. package/src/testertesting/workerManager.ts +85 -27
  19. package/src/testertesting/workerWorkerTestRunner01.ts +7 -179
  20. package/types/testertesting/commonTypes.d.ts +19 -8
  21. package/types/testertesting/commonTypes.d.ts.map +1 -1
  22. package/types/testertesting/workerInstance.d.ts +0 -2
  23. package/types/testertesting/workerInstance.d.ts.map +1 -1
  24. package/types/testertesting/workerManager.d.ts.map +1 -1
  25. package/types/testertesting/workerWorkerTestRunner01.d.ts +1 -14
  26. package/types/testertesting/workerWorkerTestRunner01.d.ts.map +1 -1
  27. package/dist/testertesting/requestResponseHelper.js +0 -83
  28. package/dist/testertesting/requestResponseHelper.js.map +0 -1
  29. package/src/testertesting/requestResponseHelper.ts +0 -95
  30. package/types/testertesting/requestResponseHelper.d.ts +0 -8
  31. package/types/testertesting/requestResponseHelper.d.ts.map +0 -1
@@ -1,95 +0,0 @@
1
- /* eslint @typescript-eslint/no-explicit-any: 0, @typescript-eslint/no-unused-vars: 0 */ // --> OFF
2
- import { MessagePort } from 'worker_threads';
3
-
4
- import type { IIWMessagePayload } from './commonTypes'
5
-
6
- import { defaultLogger } from '@nsshunt/stsutils'
7
-
8
- declare interface RequestResponseMessage {
9
- publishMessagePayload: IIWMessagePayload
10
- publishMessagePayloadResponse?: IIWMessagePayload
11
- cb: () => void,
12
- timeout: NodeJS.Timeout
13
- }
14
-
15
- declare type RequestResponseMessages = Record<string, RequestResponseMessage>;
16
-
17
- //@@ this should become a low level stsutils type helper
18
- export class RequestResponseHelper
19
- {
20
- #requestResponseMessages: RequestResponseMessages = { }
21
- #requestResponseMessageTimeout = 10000; //@@ config
22
- #port: MessagePort
23
-
24
- constructor(port: MessagePort) {
25
- this.#port = port
26
- this.#SetupListener();
27
- }
28
-
29
-
30
- #debug = (message: any) => {
31
- defaultLogger.debug(message);
32
- }
33
-
34
- PostMessage = (message: IIWMessagePayload): Promise<IIWMessagePayload> => {
35
- return new Promise((resolve, reject) => {
36
- const { messageId } = message.payload;
37
- if (messageId) {
38
- if (this.#requestResponseMessages[messageId]) {
39
- reject(`RequestResponseHelper: Message with id: [${messageId}] already exists within the Request/Response record structure`);
40
- } else {
41
- this.#requestResponseMessages[messageId] = {
42
- publishMessagePayload: { ...message },
43
- cb: () => {
44
- const detail = this.#requestResponseMessages[messageId].publishMessagePayloadResponse;
45
- clearTimeout(this.#requestResponseMessages[messageId].timeout);
46
- setTimeout(() => {
47
- delete this.#requestResponseMessages[messageId];
48
- }, 0);
49
- if (detail) {
50
- this.#debug(`RequestResponseHelper: Resolving response message with id: [${messageId}] from target worker port. Details: [${JSON.stringify(detail)}]`);
51
- resolve(detail);
52
- } else {
53
- const msg = `Could not get detail from this.#requestResponseMessages[messageId].publishMessagePayloadResponse`;
54
- this.#debug(msg);
55
- reject(msg);
56
- }
57
- },
58
- timeout: setTimeout(() => {
59
- setTimeout(() => {
60
- delete this.#requestResponseMessages[messageId];
61
- }, 0);
62
- this.#debug(`RequestResponseHelper: Timeout has occurred after: [${this.#requestResponseMessageTimeout}]ms with message id: [${messageId}]. Details: [${JSON.stringify(this.#requestResponseMessages[messageId].publishMessagePayload)}]`);
63
- reject('RequestResponseHelper: Did not receive response form parent process.');
64
- }, this.#requestResponseMessageTimeout) // max message timeout allowed
65
- };
66
- //debug(`RequestResponseHelper: Sending message with id: [${messageId}] to target worker port. Details: [${JSON.stringify(this.#requestResponseMessages[messageId].publishMessagePayload)}]`);
67
- this.#port.postMessage(message);
68
- }
69
- } else {
70
- const msg = `RequestResponseHelper: Response did not include a message id`;
71
- this.#debug(msg);
72
- reject(msg);
73
- }
74
- });
75
- }
76
-
77
- #SetupListener = () => {
78
- //this.#port.onmessage = async (msg: MessageEvent) => {
79
- this.#port.on('message', (msg: any) => {
80
- const publishMessagePayload: IIWMessagePayload = msg.data as IIWMessagePayload;
81
- if (publishMessagePayload.payload.messageId) {
82
- const messageId = publishMessagePayload.payload.messageId;
83
- if (messageId && messageId !== '') {
84
- if (this.#requestResponseMessages[messageId]) {
85
- const requestResponseMessage: RequestResponseMessage = this.#requestResponseMessages[messageId];
86
- requestResponseMessage.publishMessagePayloadResponse = { ...publishMessagePayload };
87
- requestResponseMessage.cb();
88
- } else {
89
- throw new Error(`RequestResponseHelper: Could not find Request/Response message with id: [${messageId}]`);
90
- }
91
- }
92
- }
93
- });
94
- }
95
- }
@@ -1,8 +0,0 @@
1
- import { MessagePort } from 'worker_threads';
2
- import type { IIWMessagePayload } from './commonTypes';
3
- export declare class RequestResponseHelper {
4
- #private;
5
- constructor(port: MessagePort);
6
- PostMessage: (message: IIWMessagePayload) => Promise<IIWMessagePayload>;
7
- }
8
- //# sourceMappingURL=requestResponseHelper.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"requestResponseHelper.d.ts","sourceRoot":"","sources":["../../src/testertesting/requestResponseHelper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AActD,qBAAa,qBAAqB;;gBAMlB,IAAI,EAAE,WAAW;IAU7B,WAAW,YAAa,iBAAiB,KAAG,OAAO,CAAC,iBAAiB,CAAC,CAyCrE;CAoBJ"}