chatbot-nc 2.1.44 → 2.1.45

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.
@@ -1,3 +1,4 @@
1
+ import { MessageAttributeValue } from "@aws-sdk/client-sqs";
1
2
  export declare const SQS: {
2
- publish: (topic: string, subject: string, message: string, messageAttributes?: Record<string, any>) => Promise<void>;
3
+ publish: (queue: string, message: string, delay?: number, messageAttributes?: Record<string, MessageAttributeValue>) => Promise<void>;
3
4
  };
@@ -5,14 +5,25 @@ const client_sqs_1 = require("@aws-sdk/client-sqs"); // ES Modules import
5
5
  const environment = (process.env.NODE_ENVIRONMENT || 'Test');
6
6
  const awsRegion = (process.env.AWS_DEFAULT_REGION || 'us-east-1');
7
7
  const client = new client_sqs_1.SQSClient({ region: awsRegion });
8
- const publish = async (topic, subject, message, messageAttributes) => {
8
+ const publish = async (queue, message, delay, messageAttributes) => {
9
9
  try {
10
- const topicName = `${environment}-${topic}`;
11
- // let auditLogger = new AuditLogger();
12
- // await auditLogger.audit(message, subject, messageAttributes);
10
+ let queueParam = {
11
+ QueueName: queue
12
+ };
13
+ var command = await new client_sqs_1.CreateQueueCommand(queueParam);
14
+ const parameter = await client.send(command);
15
+ const sqsParameters = {
16
+ QueueUrl: parameter.QueueUrl,
17
+ MessageBody: message,
18
+ DelaySeconds: delay !== null && delay !== void 0 ? delay : 0,
19
+ MessageAttributes: messageAttributes
20
+ };
21
+ console.info("Queue URL is " + parameter.QueueUrl);
22
+ let sendMessageCommand = new client_sqs_1.SendMessageCommand(sqsParameters);
23
+ const data = await client.send(sendMessageCommand);
13
24
  }
14
25
  catch (error) {
15
- console.error(`error occured while publishing event ${subject} to SNS `);
26
+ console.error(`error occured while senind sqs message to SNS `);
16
27
  console.error(error, error.stack);
17
28
  }
18
29
  };
@@ -1 +1 @@
1
- {"version":3,"file":"AWSSQS.js","sourceRoot":"","sources":["../../../../aws/services/AWSSQS.ts"],"names":[],"mappings":";;;AAAA,o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,UAAU,GAA4B;YACtC,SAAS,EAAE,KAAK;SACnB,CAAC;QACF,IAAI,OAAO,GAAG,MAAM,IAAI,+BAAkB,CAAC,UAAU,CAAC,CAAC;QACvD,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAE5C,MAAM,aAAa,GAA4B;YAC3C,QAAQ,EAAE,SAAS,CAAC,QAAQ;YAC5B,WAAW,EAAE,OAAO;YACpB,YAAY,EAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,CAAC;YACvB,iBAAiB,EAAE,iBAAiB;SACvC,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;QAEnD,IAAI,kBAAkB,GAAG,IAAI,+BAAkB,CAAC,aAAa,CAAC,CAAC;QAC/D,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;IAEvD,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QAClB,OAAO,CAAC,KAAK,CAAC,gDAAgD,CAAC,CAAA;QAC/D,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;AACL,CAAC,CAAA;AAIY,QAAA,GAAG,GAAG;IACf,OAAO;CACV,CAAA"}
@@ -1,3 +1,4 @@
1
+ import { MessageAttributeValue } from "@aws-sdk/client-sqs";
1
2
  export declare const SQS: {
2
- publish: (topic: string, subject: string, message: string, messageAttributes?: Record<string, any>) => Promise<void>;
3
+ publish: (queue: string, message: string, delay?: number, messageAttributes?: Record<string, MessageAttributeValue>) => Promise<void>;
3
4
  };
@@ -7,18 +7,29 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { SQSClient } from "@aws-sdk/client-sqs"; // ES Modules import
10
+ import { CreateQueueCommand, SendMessageCommand, SQSClient } from "@aws-sdk/client-sqs"; // ES Modules import
11
11
  const environment = (process.env.NODE_ENVIRONMENT || 'Test');
12
12
  const awsRegion = (process.env.AWS_DEFAULT_REGION || 'us-east-1');
13
13
  const client = new SQSClient({ region: awsRegion });
14
- const publish = (topic, subject, message, messageAttributes) => __awaiter(void 0, void 0, void 0, function* () {
14
+ const publish = (queue, message, delay, messageAttributes) => __awaiter(void 0, void 0, void 0, function* () {
15
15
  try {
16
- const topicName = `${environment}-${topic}`;
17
- // let auditLogger = new AuditLogger();
18
- // await auditLogger.audit(message, subject, messageAttributes);
16
+ let queueParam = {
17
+ QueueName: queue
18
+ };
19
+ var command = yield new CreateQueueCommand(queueParam);
20
+ const parameter = yield client.send(command);
21
+ const sqsParameters = {
22
+ QueueUrl: parameter.QueueUrl,
23
+ MessageBody: message,
24
+ DelaySeconds: delay !== null && delay !== void 0 ? delay : 0,
25
+ MessageAttributes: messageAttributes
26
+ };
27
+ console.info("Queue URL is " + parameter.QueueUrl);
28
+ let sendMessageCommand = new SendMessageCommand(sqsParameters);
29
+ const data = yield client.send(sendMessageCommand);
19
30
  }
20
31
  catch (error) {
21
- console.error(`error occured while publishing event ${subject} to SNS `);
32
+ console.error(`error occured while senind sqs message to SNS `);
22
33
  console.error(error, error.stack);
23
34
  }
24
35
  });
@@ -1 +1 @@
1
- {"version":3,"file":"AWSSQS.js","sourceRoot":"","sources":["../../../../aws/services/AWSSQS.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC,CAAC,oBAAoB;AAErE,MAAM,WAAW,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,MAAM,CAAC,CAAC;AAC7D,MAAM,SAAS,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,WAAW,CAAC,CAAC;AAElE,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE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;QAE5C,MAAM,aAAa,GAA4B;YAC3C,QAAQ,EAAE,SAAS,CAAC,QAAQ;YAC5B,WAAW,EAAE,OAAO;YACpB,YAAY,EAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,CAAC;YACvB,iBAAiB,EAAE,iBAAiB;SACvC,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;QAEnD,IAAI,kBAAkB,GAAG,IAAI,kBAAkB,CAAC,aAAa,CAAC,CAAC;QAC/D,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;IAEvD,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QAClB,OAAO,CAAC,KAAK,CAAC,gDAAgD,CAAC,CAAA;QAC/D,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;AACL,CAAC,CAAA,CAAA;AAID,MAAM,CAAC,MAAM,GAAG,GAAG;IACf,OAAO;CACV,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chatbot-nc",
3
- "version": "2.1.44",
3
+ "version": "2.1.45",
4
4
  "description": "",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",