quidproquo-dev-server 0.0.239 → 0.0.241

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 (79) hide show
  1. package/lib/commonjs/actionProcessor/core/event/index.d.ts +1 -0
  2. package/lib/commonjs/actionProcessor/core/event/index.js +1 -0
  3. package/lib/commonjs/actionProcessor/core/event/queue/getEventMatchStoryActionProcessor.js +0 -1
  4. package/lib/commonjs/actionProcessor/core/event/ws/index.d.ts +1 -0
  5. package/lib/commonjs/actionProcessor/core/event/ws/index.js +17 -0
  6. package/lib/commonjs/actionProcessor/core/event/ws/websocket/getEventAutoRespondActionProcessor.d.ts +2 -0
  7. package/lib/commonjs/actionProcessor/core/event/ws/websocket/getEventAutoRespondActionProcessor.js +24 -0
  8. package/lib/commonjs/actionProcessor/core/event/ws/websocket/getEventGetRecordsActionProcessor.d.ts +2 -0
  9. package/lib/commonjs/actionProcessor/core/event/ws/websocket/getEventGetRecordsActionProcessor.js +53 -0
  10. package/lib/commonjs/actionProcessor/core/event/ws/websocket/getEventGetStorySessionActionProcessor.d.ts +2 -0
  11. package/lib/commonjs/actionProcessor/core/event/ws/websocket/getEventGetStorySessionActionProcessor.js +24 -0
  12. package/lib/commonjs/actionProcessor/core/event/ws/websocket/getEventMatchStoryActionProcessor.d.ts +2 -0
  13. package/lib/commonjs/actionProcessor/core/event/ws/websocket/getEventMatchStoryActionProcessor.js +41 -0
  14. package/lib/commonjs/actionProcessor/core/event/ws/websocket/getEventTransformResponseResultActionProcessor.d.ts +2 -0
  15. package/lib/commonjs/actionProcessor/core/event/ws/websocket/getEventTransformResponseResultActionProcessor.js +29 -0
  16. package/lib/commonjs/actionProcessor/core/event/ws/websocket/index.d.ts +2 -0
  17. package/lib/commonjs/actionProcessor/core/event/ws/websocket/index.js +21 -0
  18. package/lib/commonjs/actionProcessor/core/event/ws/websocket/types.d.ts +8 -0
  19. package/lib/commonjs/actionProcessor/core/event/ws/websocket/types.js +2 -0
  20. package/lib/commonjs/actionProcessor/webserver/index.js +2 -1
  21. package/lib/commonjs/actionProcessor/webserver/websocket/getWebsocketSendMessageActionProcessor.d.ts +2 -0
  22. package/lib/commonjs/actionProcessor/webserver/websocket/getWebsocketSendMessageActionProcessor.js +35 -0
  23. package/lib/commonjs/actionProcessor/webserver/websocket/index.d.ts +2 -0
  24. package/lib/commonjs/actionProcessor/webserver/websocket/index.js +17 -0
  25. package/lib/commonjs/implementations/eventBusImplementation.js +55 -37
  26. package/lib/commonjs/implementations/index.d.ts +1 -0
  27. package/lib/commonjs/implementations/index.js +1 -0
  28. package/lib/commonjs/implementations/queueImplementation.js +45 -3
  29. package/lib/commonjs/implementations/webSocket/index.d.ts +2 -0
  30. package/lib/commonjs/implementations/webSocket/index.js +18 -0
  31. package/lib/commonjs/implementations/webSocket/types/WsEvent.d.ts +13 -0
  32. package/lib/commonjs/implementations/webSocket/types/WsEvent.js +2 -0
  33. package/lib/commonjs/implementations/webSocket/types/index.d.ts +1 -0
  34. package/lib/commonjs/implementations/webSocket/types/index.js +17 -0
  35. package/lib/commonjs/implementations/webSocket/webSocketImplementation.d.ts +3 -0
  36. package/lib/commonjs/implementations/webSocket/webSocketImplementation.js +134 -0
  37. package/lib/commonjs/logic/eventBus.js +3 -0
  38. package/lib/commonjs/main.js +1 -0
  39. package/lib/commonjs/types/DevServerConfig.d.ts +2 -1
  40. package/lib/esm/actionProcessor/core/event/index.d.ts +1 -0
  41. package/lib/esm/actionProcessor/core/event/index.js +1 -0
  42. package/lib/esm/actionProcessor/core/event/queue/getEventMatchStoryActionProcessor.js +0 -1
  43. package/lib/esm/actionProcessor/core/event/ws/index.d.ts +1 -0
  44. package/lib/esm/actionProcessor/core/event/ws/index.js +1 -0
  45. package/lib/esm/actionProcessor/core/event/ws/websocket/getEventAutoRespondActionProcessor.d.ts +2 -0
  46. package/lib/esm/actionProcessor/core/event/ws/websocket/getEventAutoRespondActionProcessor.js +9 -0
  47. package/lib/esm/actionProcessor/core/event/ws/websocket/getEventGetRecordsActionProcessor.d.ts +2 -0
  48. package/lib/esm/actionProcessor/core/event/ws/websocket/getEventGetRecordsActionProcessor.js +38 -0
  49. package/lib/esm/actionProcessor/core/event/ws/websocket/getEventGetStorySessionActionProcessor.d.ts +2 -0
  50. package/lib/esm/actionProcessor/core/event/ws/websocket/getEventGetStorySessionActionProcessor.js +9 -0
  51. package/lib/esm/actionProcessor/core/event/ws/websocket/getEventMatchStoryActionProcessor.d.ts +2 -0
  52. package/lib/esm/actionProcessor/core/event/ws/websocket/getEventMatchStoryActionProcessor.js +26 -0
  53. package/lib/esm/actionProcessor/core/event/ws/websocket/getEventTransformResponseResultActionProcessor.d.ts +2 -0
  54. package/lib/esm/actionProcessor/core/event/ws/websocket/getEventTransformResponseResultActionProcessor.js +14 -0
  55. package/lib/esm/actionProcessor/core/event/ws/websocket/index.d.ts +2 -0
  56. package/lib/esm/actionProcessor/core/event/ws/websocket/index.js +12 -0
  57. package/lib/esm/actionProcessor/core/event/ws/websocket/types.d.ts +8 -0
  58. package/lib/esm/actionProcessor/core/event/ws/websocket/types.js +1 -0
  59. package/lib/esm/actionProcessor/webserver/index.js +2 -0
  60. package/lib/esm/actionProcessor/webserver/websocket/getWebsocketSendMessageActionProcessor.d.ts +2 -0
  61. package/lib/esm/actionProcessor/webserver/websocket/getWebsocketSendMessageActionProcessor.js +19 -0
  62. package/lib/esm/actionProcessor/webserver/websocket/index.d.ts +2 -0
  63. package/lib/esm/actionProcessor/webserver/websocket/index.js +4 -0
  64. package/lib/esm/implementations/eventBusImplementation.js +54 -34
  65. package/lib/esm/implementations/index.d.ts +1 -0
  66. package/lib/esm/implementations/index.js +1 -0
  67. package/lib/esm/implementations/queueImplementation.js +44 -4
  68. package/lib/esm/implementations/webSocket/index.d.ts +2 -0
  69. package/lib/esm/implementations/webSocket/index.js +2 -0
  70. package/lib/esm/implementations/webSocket/types/WsEvent.d.ts +13 -0
  71. package/lib/esm/implementations/webSocket/types/WsEvent.js +1 -0
  72. package/lib/esm/implementations/webSocket/types/index.d.ts +1 -0
  73. package/lib/esm/implementations/webSocket/types/index.js +1 -0
  74. package/lib/esm/implementations/webSocket/webSocketImplementation.d.ts +3 -0
  75. package/lib/esm/implementations/webSocket/webSocketImplementation.js +123 -0
  76. package/lib/esm/logic/eventBus.js +3 -0
  77. package/lib/esm/main.js +2 -1
  78. package/lib/esm/types/DevServerConfig.d.ts +2 -1
  79. package/package.json +7 -6
@@ -1,3 +1,4 @@
1
1
  export * from './express';
2
2
  export * from './node';
3
3
  export * from './queue';
4
+ export * from './ws';
@@ -17,3 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./express"), exports);
18
18
  __exportStar(require("./node"), exports);
19
19
  __exportStar(require("./queue"), exports);
20
+ __exportStar(require("./ws"), exports);
@@ -14,7 +14,6 @@ const quidproquo_actionprocessor_awslambda_1 = require("quidproquo-actionprocess
14
14
  const quidproquo_core_1 = require("quidproquo-core");
15
15
  const getProcessMatchStory = (qpqConfig) => {
16
16
  return ({ qpqEventRecord, eventParams: [event] }) => __awaiter(void 0, void 0, void 0, function* () {
17
- console.log('qpqEventRecord', JSON.stringify(qpqEventRecord, null, 2));
18
17
  const queueQueueProcessors = quidproquo_core_1.qpqCoreUtils.getQueueQueueProcessors(event.queueName, qpqConfig);
19
18
  const queueTypes = Object.keys(queueQueueProcessors).sort();
20
19
  // Find the most relevant match
@@ -0,0 +1 @@
1
+ export * from './websocket';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./websocket"), exports);
@@ -0,0 +1,2 @@
1
+ import { ActionProcessorListResolver } from 'quidproquo-core';
2
+ export declare const getEventAutoRespondActionProcessor: ActionProcessorListResolver;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.getEventAutoRespondActionProcessor = void 0;
13
+ const quidproquo_core_1 = require("quidproquo-core");
14
+ const getProcessAutoRespond = (qpqConfig) => {
15
+ return ({ qpqEventRecord, matchResult }) => __awaiter(void 0, void 0, void 0, function* () {
16
+ return (0, quidproquo_core_1.actionResult)(null);
17
+ });
18
+ };
19
+ const getEventAutoRespondActionProcessor = (qpqConfig) => __awaiter(void 0, void 0, void 0, function* () {
20
+ return ({
21
+ [quidproquo_core_1.EventActionType.AutoRespond]: getProcessAutoRespond(qpqConfig),
22
+ });
23
+ });
24
+ exports.getEventAutoRespondActionProcessor = getEventAutoRespondActionProcessor;
@@ -0,0 +1,2 @@
1
+ import { ActionProcessorListResolver } from 'quidproquo-core';
2
+ export declare const getEventGetRecordsActionProcessor: ActionProcessorListResolver;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.getEventGetRecordsActionProcessor = void 0;
13
+ const quidproquo_core_1 = require("quidproquo-core");
14
+ function processBody(body) {
15
+ if (!body) {
16
+ return undefined; // If the body is undefined, return undefined
17
+ }
18
+ // Convert the body to a string
19
+ if (Array.isArray(body)) {
20
+ // Merge Buffer[] into a single Buffer and convert to string
21
+ return Buffer.concat(body).toString();
22
+ }
23
+ else if (body instanceof ArrayBuffer) {
24
+ // Convert ArrayBuffer to string
25
+ return Buffer.from(body).toString();
26
+ }
27
+ else if (Buffer.isBuffer(body)) {
28
+ return body.toString(); // Convert Buffer to string
29
+ }
30
+ throw new Error('Unsupported body type');
31
+ }
32
+ const getProcessGetRecords = (qpqConfig) => {
33
+ return ({ eventParams: [wsEvent] }) => __awaiter(void 0, void 0, void 0, function* () {
34
+ const internalEventRecord = {
35
+ eventType: wsEvent.eventType,
36
+ messageId: wsEvent.messageId,
37
+ connectionId: wsEvent.connectionId,
38
+ requestTimeEpoch: wsEvent.requestTimeEpoch,
39
+ sourceIp: wsEvent.sourceIp,
40
+ userAgent: wsEvent.userAgent,
41
+ requestTime: new Date(wsEvent.requestTimeEpoch).toISOString(),
42
+ body: processBody(wsEvent.body),
43
+ apiName: wsEvent.apiName,
44
+ };
45
+ return (0, quidproquo_core_1.actionResult)([internalEventRecord]);
46
+ });
47
+ };
48
+ const getEventGetRecordsActionProcessor = (qpqConfig) => __awaiter(void 0, void 0, void 0, function* () {
49
+ return ({
50
+ [quidproquo_core_1.EventActionType.GetRecords]: getProcessGetRecords(qpqConfig),
51
+ });
52
+ });
53
+ exports.getEventGetRecordsActionProcessor = getEventGetRecordsActionProcessor;
@@ -0,0 +1,2 @@
1
+ import { ActionProcessorListResolver } from 'quidproquo-core';
2
+ export declare const getEventGetStorySessionActionProcessor: ActionProcessorListResolver;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.getEventGetStorySessionActionProcessor = void 0;
13
+ const quidproquo_core_1 = require("quidproquo-core");
14
+ const getProcessGetStorySession = (qpqConfig) => {
15
+ return ({ qpqEventRecord, eventParams }) => __awaiter(void 0, void 0, void 0, function* () {
16
+ return (0, quidproquo_core_1.actionResult)(void 0);
17
+ });
18
+ };
19
+ const getEventGetStorySessionActionProcessor = (qpqConfig) => __awaiter(void 0, void 0, void 0, function* () {
20
+ return ({
21
+ [quidproquo_core_1.EventActionType.GetStorySession]: getProcessGetStorySession(qpqConfig),
22
+ });
23
+ });
24
+ exports.getEventGetStorySessionActionProcessor = getEventGetStorySessionActionProcessor;
@@ -0,0 +1,2 @@
1
+ import { ActionProcessorListResolver } from 'quidproquo-core';
2
+ export declare const getEventMatchStoryActionProcessor: ActionProcessorListResolver;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.getEventMatchStoryActionProcessor = void 0;
13
+ const quidproquo_core_1 = require("quidproquo-core");
14
+ const quidproquo_webserver_1 = require("quidproquo-webserver");
15
+ const getProcessMatchStory = (qpqConfig) => {
16
+ return ({ qpqEventRecord, eventParams }) => __awaiter(void 0, void 0, void 0, function* () {
17
+ const webSocketConfig = quidproquo_webserver_1.qpqWebServerUtils.getWebsocketEntryByApiName(qpqEventRecord.apiName, qpqConfig);
18
+ switch (qpqEventRecord.eventType) {
19
+ case quidproquo_webserver_1.WebSocketEventType.Connect:
20
+ return (0, quidproquo_core_1.actionResult)({
21
+ runtime: webSocketConfig.eventProcessors.onConnect,
22
+ });
23
+ case quidproquo_webserver_1.WebSocketEventType.Disconnect:
24
+ return (0, quidproquo_core_1.actionResult)({
25
+ runtime: webSocketConfig.eventProcessors.onDisconnect,
26
+ });
27
+ case quidproquo_webserver_1.WebSocketEventType.Message:
28
+ return (0, quidproquo_core_1.actionResult)({
29
+ runtime: webSocketConfig.eventProcessors.onMessage,
30
+ });
31
+ default:
32
+ return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.NotFound, `Websocket lambda not implemented for ${qpqEventRecord.eventType}`);
33
+ }
34
+ });
35
+ };
36
+ const getEventMatchStoryActionProcessor = (qpqConfig) => __awaiter(void 0, void 0, void 0, function* () {
37
+ return ({
38
+ [quidproquo_core_1.EventActionType.MatchStory]: getProcessMatchStory(qpqConfig),
39
+ });
40
+ });
41
+ exports.getEventMatchStoryActionProcessor = getEventMatchStoryActionProcessor;
@@ -0,0 +1,2 @@
1
+ import { ActionProcessorListResolver } from 'quidproquo-core';
2
+ export declare const getEventTransformResponseResultActionProcessor: ActionProcessorListResolver;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.getEventTransformResponseResultActionProcessor = void 0;
13
+ const quidproquo_core_1 = require("quidproquo-core");
14
+ const getProcessTransformResponseResult = (qpqConfig) => {
15
+ return ({ eventParams, qpqEventRecordResponses }) => __awaiter(void 0, void 0, void 0, function* () {
16
+ const [record] = qpqEventRecordResponses;
17
+ if (!record.success) {
18
+ return (0, quidproquo_core_1.actionResultError)(record.error.errorType, record.error.errorText, record.error.errorStack);
19
+ }
20
+ // Transform back to api gateway
21
+ return (0, quidproquo_core_1.actionResult)(void 0);
22
+ });
23
+ };
24
+ const getEventTransformResponseResultActionProcessor = (qpqConfig) => __awaiter(void 0, void 0, void 0, function* () {
25
+ return ({
26
+ [quidproquo_core_1.EventActionType.TransformResponseResult]: getProcessTransformResponseResult(qpqConfig),
27
+ });
28
+ });
29
+ exports.getEventTransformResponseResultActionProcessor = getEventTransformResponseResultActionProcessor;
@@ -0,0 +1,2 @@
1
+ import { ActionProcessorListResolver } from 'quidproquo-core';
2
+ export declare const getWsWebsocketEventEventProcessor: ActionProcessorListResolver;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.getWsWebsocketEventEventProcessor = void 0;
13
+ const getEventAutoRespondActionProcessor_1 = require("./getEventAutoRespondActionProcessor");
14
+ const getEventGetRecordsActionProcessor_1 = require("./getEventGetRecordsActionProcessor");
15
+ const getEventGetStorySessionActionProcessor_1 = require("./getEventGetStorySessionActionProcessor");
16
+ const getEventMatchStoryActionProcessor_1 = require("./getEventMatchStoryActionProcessor");
17
+ const getEventTransformResponseResultActionProcessor_1 = require("./getEventTransformResponseResultActionProcessor");
18
+ const getWsWebsocketEventEventProcessor = (qpqConfig, dynamicModuleLoader) => __awaiter(void 0, void 0, void 0, function* () {
19
+ return (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (yield (0, getEventAutoRespondActionProcessor_1.getEventAutoRespondActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, getEventGetRecordsActionProcessor_1.getEventGetRecordsActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, getEventGetStorySessionActionProcessor_1.getEventGetStorySessionActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, getEventMatchStoryActionProcessor_1.getEventMatchStoryActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, getEventTransformResponseResultActionProcessor_1.getEventTransformResponseResultActionProcessor)(qpqConfig, dynamicModuleLoader))));
20
+ });
21
+ exports.getWsWebsocketEventEventProcessor = getWsWebsocketEventEventProcessor;
@@ -0,0 +1,8 @@
1
+ import { MatchStoryResult } from 'quidproquo-core';
2
+ import { WebsocketEvent, WebsocketEventResponse } from 'quidproquo-webserver';
3
+ import { WsEvent } from '../../../../../implementations/webSocket';
4
+ export type EventInput = [WsEvent];
5
+ export type EventOutput = void;
6
+ export type InternalEventRecord = WebsocketEvent<string | Blob | ArrayBuffer>;
7
+ export type InternalEventOutput = WebsocketEventResponse;
8
+ export type MatchResult = MatchStoryResult<any, any>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -11,7 +11,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.getWebserverActionProcessor = void 0;
13
13
  const serviceFunctionOverride_1 = require("./serviceFunctionOverride");
14
+ const websocket_1 = require("./websocket");
14
15
  const getWebserverActionProcessor = (qpqConfig, dynamicModuleLoader) => __awaiter(void 0, void 0, void 0, function* () {
15
- return (Object.assign({}, (yield (0, serviceFunctionOverride_1.getServiceFunctionActionProcessor)(qpqConfig, dynamicModuleLoader))));
16
+ return (Object.assign(Object.assign({}, (yield (0, serviceFunctionOverride_1.getServiceFunctionActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, websocket_1.getWebsocketActionProcessor)(qpqConfig, dynamicModuleLoader))));
16
17
  });
17
18
  exports.getWebserverActionProcessor = getWebserverActionProcessor;
@@ -0,0 +1,2 @@
1
+ import { ActionProcessorListResolver } from 'quidproquo-core';
2
+ export declare const getWebsocketSendMessageActionProcessor: ActionProcessorListResolver;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.getWebsocketSendMessageActionProcessor = void 0;
13
+ const quidproquo_core_1 = require("quidproquo-core");
14
+ const quidproquo_webserver_1 = require("quidproquo-webserver");
15
+ const webSocketImplementation_1 = require("../../../implementations/webSocket/webSocketImplementation");
16
+ const getProcessSendMessage = (qpqConfig) => {
17
+ return ({ connectionId, payload, websocketApiName }) => __awaiter(void 0, void 0, void 0, function* () {
18
+ var _a;
19
+ const websocketConfig = quidproquo_webserver_1.qpqWebServerUtils.getWebsocketEntryByApiName(websocketApiName, qpqConfig);
20
+ const service = ((_a = websocketConfig.owner) === null || _a === void 0 ? void 0 : _a.module) || quidproquo_core_1.qpqCoreUtils.getApplicationModuleName(qpqConfig);
21
+ try {
22
+ yield (0, webSocketImplementation_1.sendMessageToWebSocketConnection)(service, websocketApiName, connectionId, payload);
23
+ return (0, quidproquo_core_1.actionResult)(void 0);
24
+ }
25
+ catch (error) {
26
+ return (0, quidproquo_core_1.actionResultErrorFromCaughtError)(error, {});
27
+ }
28
+ });
29
+ };
30
+ const getWebsocketSendMessageActionProcessor = (qpqConfig) => __awaiter(void 0, void 0, void 0, function* () {
31
+ return ({
32
+ [quidproquo_webserver_1.WebsocketActionType.SendMessage]: getProcessSendMessage(qpqConfig),
33
+ });
34
+ });
35
+ exports.getWebsocketSendMessageActionProcessor = getWebsocketSendMessageActionProcessor;
@@ -0,0 +1,2 @@
1
+ import { ActionProcessorListResolver } from 'quidproquo-core';
2
+ export declare const getWebsocketActionProcessor: ActionProcessorListResolver;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.getWebsocketActionProcessor = void 0;
13
+ const getWebsocketSendMessageActionProcessor_1 = require("./getWebsocketSendMessageActionProcessor");
14
+ const getWebsocketActionProcessor = (qpqConfig, dynamicModuleLoader) => __awaiter(void 0, void 0, void 0, function* () {
15
+ return (Object.assign({}, (yield (0, getWebsocketSendMessageActionProcessor_1.getWebsocketSendMessageActionProcessor)(qpqConfig, dynamicModuleLoader))));
16
+ });
17
+ exports.getWebsocketActionProcessor = getWebsocketActionProcessor;
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ // import { EventBusActionType, QPQConfig, qpqCoreUtils, QpqFunctionRuntime, QueueActionType } from 'quidproquo-core';
2
3
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
4
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
5
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -10,45 +11,62 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
11
  };
11
12
  Object.defineProperty(exports, "__esModule", { value: true });
12
13
  exports.eventBusImplementation = void 0;
13
- const quidproquo_core_1 = require("quidproquo-core");
14
- const uuid_1 = require("uuid");
15
- const logic_1 = require("../logic");
16
- const processQueueEventBusSubscriptions = (qpqConfig, ebMessage) => __awaiter(void 0, void 0, void 0, function* () {
17
- var _a, _b, _c, _d;
18
- const allEventBuses = quidproquo_core_1.qpqCoreUtils.getAllEventBusConfigs(qpqConfig).filter((ebc) => {
19
- var _a, _b, _c, _d, _e, _f, _g, _h;
20
- return ((!((_a = ebc.owner) === null || _a === void 0 ? void 0 : _a.application) || ((_b = ebc.owner) === null || _b === void 0 ? void 0 : _b.application) === ebMessage.targetApplication) &&
21
- (!((_c = ebc.owner) === null || _c === void 0 ? void 0 : _c.environment) || ((_d = ebc.owner) === null || _d === void 0 ? void 0 : _d.environment) === ebMessage.targetEnvironment) &&
22
- (!((_e = ebc.owner) === null || _e === void 0 ? void 0 : _e.module) || ((_f = ebc.owner) === null || _f === void 0 ? void 0 : _f.module) === ebMessage.targetModule) &&
23
- ((!((_g = ebc.owner) === null || _g === void 0 ? void 0 : _g.feature) && !ebMessage.targetFeature) || ((_h = ebc.owner) === null || _h === void 0 ? void 0 : _h.feature) === ebMessage.targetFeature));
14
+ /*
15
+ const processQueueEventBusSubscriptions = async (qpqConfig: QPQConfig, ebMessage: AnyEventBusMessageWithSession) => {
16
+ const allEventBuses = qpqCoreUtils.getAllEventBusConfigs(qpqConfig).filter((ebc) => {
17
+ const thisService = qpqCoreUtils.getApplicationModuleName(qpqConfig);
18
+
19
+ const srcApplication = ebc.owner?.application || qpqCoreUtils.getApplicationName(qpqConfig);
20
+ const srcEnvironment = ebc.owner?.environment || qpqCoreUtils.getApplicationModuleEnvironment(qpqConfig);
21
+ const srcFeature = ebc.owner?.feature || qpqCoreUtils.getApplicationModuleFeature(qpqConfig);
22
+ const srcModule = ebc.owner?.module || qpqCoreUtils.getApplicationModuleName(qpqConfig);
23
+
24
+ return (
25
+ srcApplication === ebMessage.targetApplication &&
26
+ srcEnvironment === ebMessage.targetEnvironment &&
27
+ thisService == srcModule &&
28
+ srcModule === ebMessage.targetModule &&
29
+ ((!srcFeature && !ebMessage.targetFeature) || srcFeature === ebMessage.targetFeature)
30
+ );
31
+ });
32
+
33
+ // All the queues that we should publish to
34
+ const queues = qpqCoreUtils.getQueues(qpqConfig).filter((q) => {
35
+ return !!q.eventBusSubscriptions.find((ebsub) => {
36
+ return allEventBuses.some((eb) => ebsub === eb.owner?.resourceNameOverride || (!eb.owner?.resourceNameOverride && ebsub === eb.name));
24
37
  });
25
- // All the queues that we should publish to
26
- const queues = quidproquo_core_1.qpqCoreUtils.getQueues(qpqConfig).filter((q) => {
27
- return !!q.eventBusSubscriptions.find((ebsub) => {
28
- return allEventBuses.some((eb) => { var _a, _b; return ebsub === ((_a = eb.owner) === null || _a === void 0 ? void 0 : _a.resourceNameOverride) || (!((_b = eb.owner) === null || _b === void 0 ? void 0 : _b.resourceNameOverride) && ebsub === eb.name); });
29
- });
30
- });
31
- for (const queue of queues) {
32
- const queueMessage = {
33
- payload: ebMessage.payload,
34
- type: ebMessage.type,
35
- storySession: ebMessage.storySession,
36
- queueName: queue.name,
37
- targetApplication: ((_a = queue.owner) === null || _a === void 0 ? void 0 : _a.application) || quidproquo_core_1.qpqCoreUtils.getApplicationName(qpqConfig),
38
- targetEnvironment: ((_b = queue.owner) === null || _b === void 0 ? void 0 : _b.environment) || quidproquo_core_1.qpqCoreUtils.getApplicationModuleEnvironment(qpqConfig),
39
- targetFeature: ((_c = queue.owner) === null || _c === void 0 ? void 0 : _c.feature) || quidproquo_core_1.qpqCoreUtils.getApplicationModuleFeature(qpqConfig),
40
- targetModule: ((_d = queue.owner) === null || _d === void 0 ? void 0 : _d.module) || quidproquo_core_1.qpqCoreUtils.getApplicationModuleName(qpqConfig),
41
- messageId: (0, uuid_1.v4)(),
42
- };
43
- logic_1.eventBus.publish(quidproquo_core_1.QueueActionType.SendMessages, queueMessage);
44
- }
45
- });
38
+ });
39
+
40
+ console.log('allEventBuses: ', queues);
41
+
42
+ for (const queue of queues) {
43
+ const queueMessage: AnyQueueMessageWithSession = {
44
+ payload: ebMessage.payload,
45
+ type: ebMessage.type,
46
+
47
+ storySession: ebMessage.storySession,
48
+
49
+ queueName: queue.name,
50
+
51
+ targetApplication: queue.owner?.application || qpqCoreUtils.getApplicationName(qpqConfig),
52
+ targetEnvironment: queue.owner?.environment || qpqCoreUtils.getApplicationModuleEnvironment(qpqConfig),
53
+ targetFeature: queue.owner?.feature || qpqCoreUtils.getApplicationModuleFeature(qpqConfig),
54
+ targetModule: queue.owner?.module || qpqCoreUtils.getApplicationModuleName(qpqConfig),
55
+
56
+ messageId: uuidV4(),
57
+ };
58
+
59
+ eventBus.publish(QueueActionType.SendMessages, queueMessage);
60
+ }
61
+ };
62
+ */
46
63
  const eventBusImplementation = (devServerConfig) => __awaiter(void 0, void 0, void 0, function* () {
47
- logic_1.eventBus.on(quidproquo_core_1.EventBusActionType.SendMessages, (payload, correlation) => __awaiter(void 0, void 0, void 0, function* () {
48
- for (const qpqConfig of devServerConfig.qpqConfigs) {
49
- yield processQueueEventBusSubscriptions(qpqConfig, payload);
50
- }
51
- }));
64
+ // eventBus.on(EventBusActionType.SendMessages, async (payload: AnyEventBusMessageWithSession, correlation: string) => {
65
+ // console.log('Event Buss Ready to process!');
66
+ // for (const qpqConfig of devServerConfig.qpqConfigs) {
67
+ // await processQueueEventBusSubscriptions(qpqConfig, payload);
68
+ // }
69
+ // });
52
70
  // Never ends
53
71
  yield new Promise(() => { });
54
72
  });
@@ -2,3 +2,4 @@ export * from './apiImplementation';
2
2
  export * from './eventBusImplementation';
3
3
  export * from './queueImplementation';
4
4
  export * from './serviceFunctionImplementation';
5
+ export * from './webSocket';
@@ -18,3 +18,4 @@ __exportStar(require("./apiImplementation"), exports);
18
18
  __exportStar(require("./eventBusImplementation"), exports);
19
19
  __exportStar(require("./queueImplementation"), exports);
20
20
  __exportStar(require("./serviceFunctionImplementation"), exports);
21
+ __exportStar(require("./webSocket"), exports);
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.queueImplementation = void 0;
13
13
  const quidproquo_core_1 = require("quidproquo-core");
14
+ const uuid_1 = require("uuid");
14
15
  const queue_1 = require("../actionProcessor/core/event/queue");
15
16
  const logic_1 = require("../logic");
16
17
  const getDynamicModuleLoader = (qpqConfig, devServerConfig) => {
@@ -28,19 +29,60 @@ const processQueueMessages = (qpqConfig, payload, devServerConfig) => __awaiter(
28
29
  return;
29
30
  }
30
31
  const feature = quidproquo_core_1.qpqCoreUtils.getApplicationModuleFeature(qpqConfig);
31
- if ((!!payload.targetFeature || !!feature) && payload.targetFeature !== quidproquo_core_1.qpqCoreUtils.getApplicationModuleEnvironment(qpqConfig)) {
32
+ if ((!!payload.targetFeature || !!feature) && payload.targetFeature !== feature) {
32
33
  return;
33
34
  }
34
- console.log('Ready to process: ', JSON.stringify(payload, null, 2));
35
35
  yield (0, logic_1.processEvent)(payload, qpqConfig, getDynamicModuleLoader(qpqConfig, devServerConfig), queue_1.getQueueEventProcessor, quidproquo_core_1.QpqRuntimeType.QUEUE_EVENT);
36
36
  });
37
+ const processQueueEventBusSubscriptions = (qpqConfig, ebMessage) => __awaiter(void 0, void 0, void 0, function* () {
38
+ var _a, _b, _c, _d;
39
+ const thisServiceName = quidproquo_core_1.qpqCoreUtils.getApplicationModuleName(qpqConfig);
40
+ const allEventBuses = quidproquo_core_1.qpqCoreUtils.getAllEventBusConfigs(qpqConfig).filter((ebc) => {
41
+ var _a, _b, _c, _d;
42
+ const srcApplication = ((_a = ebc.owner) === null || _a === void 0 ? void 0 : _a.application) || quidproquo_core_1.qpqCoreUtils.getApplicationName(qpqConfig);
43
+ const srcEnvironment = ((_b = ebc.owner) === null || _b === void 0 ? void 0 : _b.environment) || quidproquo_core_1.qpqCoreUtils.getApplicationModuleEnvironment(qpqConfig);
44
+ const srcFeature = ((_c = ebc.owner) === null || _c === void 0 ? void 0 : _c.feature) || quidproquo_core_1.qpqCoreUtils.getApplicationModuleFeature(qpqConfig);
45
+ const srcModule = ((_d = ebc.owner) === null || _d === void 0 ? void 0 : _d.module) || quidproquo_core_1.qpqCoreUtils.getApplicationModuleName(qpqConfig);
46
+ return (srcApplication === ebMessage.targetApplication &&
47
+ srcEnvironment === ebMessage.targetEnvironment &&
48
+ srcModule === ebMessage.targetModule &&
49
+ ((!srcFeature && !ebMessage.targetFeature) || srcFeature === ebMessage.targetFeature));
50
+ });
51
+ // All the queues that we should publish to
52
+ const queues = quidproquo_core_1.qpqCoreUtils
53
+ .getQueues(qpqConfig)
54
+ .filter((q) => {
55
+ return !!q.eventBusSubscriptions.find((ebsub) => {
56
+ return allEventBuses.some((eb) => ebsub === eb.name);
57
+ });
58
+ })
59
+ .filter((q) => { var _a, _b; return !((_a = q.owner) === null || _a === void 0 ? void 0 : _a.module) || ((_b = q.owner) === null || _b === void 0 ? void 0 : _b.module) === thisServiceName; });
60
+ for (const queue of queues) {
61
+ const queueMessage = {
62
+ payload: ebMessage.payload,
63
+ type: ebMessage.type,
64
+ storySession: ebMessage.storySession,
65
+ queueName: queue.name,
66
+ targetApplication: ((_a = queue.owner) === null || _a === void 0 ? void 0 : _a.application) || quidproquo_core_1.qpqCoreUtils.getApplicationName(qpqConfig),
67
+ targetEnvironment: ((_b = queue.owner) === null || _b === void 0 ? void 0 : _b.environment) || quidproquo_core_1.qpqCoreUtils.getApplicationModuleEnvironment(qpqConfig),
68
+ targetFeature: ((_c = queue.owner) === null || _c === void 0 ? void 0 : _c.feature) || quidproquo_core_1.qpqCoreUtils.getApplicationModuleFeature(qpqConfig),
69
+ targetModule: ((_d = queue.owner) === null || _d === void 0 ? void 0 : _d.module) || quidproquo_core_1.qpqCoreUtils.getApplicationModuleName(qpqConfig),
70
+ messageId: (0, uuid_1.v4)(),
71
+ };
72
+ logic_1.eventBus.publish(quidproquo_core_1.QueueActionType.SendMessages, queueMessage);
73
+ }
74
+ });
37
75
  const queueImplementation = (devServerConfig) => __awaiter(void 0, void 0, void 0, function* () {
38
76
  logic_1.eventBus.on(quidproquo_core_1.QueueActionType.SendMessages, (payload, correlation) => __awaiter(void 0, void 0, void 0, function* () {
39
- console.log('Got QUEUE send message event');
40
77
  for (const qpqConfig of devServerConfig.qpqConfigs) {
41
78
  yield processQueueMessages(qpqConfig, payload, devServerConfig);
42
79
  }
43
80
  }));
81
+ logic_1.eventBus.on(quidproquo_core_1.EventBusActionType.SendMessages, (payload, correlation) => __awaiter(void 0, void 0, void 0, function* () {
82
+ for (const qpqConfig of devServerConfig.qpqConfigs) {
83
+ yield processQueueEventBusSubscriptions(qpqConfig, payload);
84
+ }
85
+ }));
44
86
  // Never ends
45
87
  yield new Promise(() => { });
46
88
  });
@@ -0,0 +1,2 @@
1
+ export * from './types';
2
+ export * from './webSocketImplementation';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./types"), exports);
18
+ __exportStar(require("./webSocketImplementation"), exports);
@@ -0,0 +1,13 @@
1
+ /// <reference types="node" />
2
+ import { WebSocketEventType } from 'quidproquo';
3
+ export type WsEvent = {
4
+ apiName: string;
5
+ service: string;
6
+ eventType: WebSocketEventType;
7
+ body?: ArrayBuffer | Buffer | Buffer[];
8
+ messageId: string;
9
+ connectionId: string;
10
+ requestTimeEpoch: number;
11
+ sourceIp: string;
12
+ userAgent: string;
13
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export * from './WsEvent';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./WsEvent"), exports);
@@ -0,0 +1,3 @@
1
+ import { DevServerConfig } from '../../types';
2
+ export declare const sendMessageToWebSocketConnection: (service: string, websocketApiName: string, connectionId: string, payload: any) => Promise<void>;
3
+ export declare const webSocketImplementation: (devServerConfig: DevServerConfig) => Promise<void>;