@aesop-fables/triginta
Advanced tools
Comparing version 0.8.4 to 0.8.5
@@ -1,8 +0,9 @@ | ||
import { MessageBodyAttributeMap, SendMessageResult } from 'aws-sdk/clients/sqs'; | ||
import { SqsPublisher } from './SqsPublisher'; | ||
import { MessageBodyAttributeMap, SendMessageRequest, SendMessageResult } from 'aws-sdk/clients/sqs'; | ||
import { ISqsPublisher } from './SqsPublisher'; | ||
import { SQSMessageAttributes } from 'aws-lambda'; | ||
import { ISqsMessage } from './ISqsMessage'; | ||
import { LoggingLevel } from '../logging'; | ||
declare type ConfigureSqsDelegate = (params: SendMessageRequest) => Promise<void>; | ||
export interface IMessagePublisher { | ||
publish(event: ISqsMessage): Promise<SendMessageResult>; | ||
publish(event: ISqsMessage, defaultAttributes?: SQSMessageAttributes, configure?: ConfigureSqsDelegate): Promise<SendMessageResult>; | ||
} | ||
@@ -12,5 +13,6 @@ export declare class MessagePublisher implements IMessagePublisher { | ||
private readonly levels; | ||
constructor(sqsPublisher: SqsPublisher, levels: LoggingLevel); | ||
publish(sqsMessage: ISqsMessage): Promise<SendMessageResult>; | ||
constructor(sqsPublisher: ISqsPublisher, levels: LoggingLevel); | ||
publish(sqsMessage: ISqsMessage, defaultAttributes?: SQSMessageAttributes, configure?: ConfigureSqsDelegate): Promise<SendMessageResult>; | ||
} | ||
export declare function messageTypeConverter(attributes: SQSMessageAttributes): MessageBodyAttributeMap; | ||
export {}; |
@@ -26,3 +26,2 @@ "use strict"; | ||
const containr_1 = require("@aesop-fables/containr"); | ||
const SqsPublisher_1 = require("./SqsPublisher"); | ||
const SqsLambdaServices_1 = require("./SqsLambdaServices"); | ||
@@ -37,5 +36,5 @@ const logging_1 = require("../logging"); | ||
} | ||
publish(sqsMessage) { | ||
publish(sqsMessage, defaultAttributes, configure) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const attributes = Object.assign({}, messageTypeConverter(sqsMessage.getAttributes())); | ||
const attributes = Object.assign(Object.assign({}, messageTypeConverter(defaultAttributes !== null && defaultAttributes !== void 0 ? defaultAttributes : {})), messageTypeConverter(sqsMessage.getAttributes())); | ||
const level = this.levels.resolveLevel(); | ||
@@ -48,3 +47,3 @@ if (level) { | ||
} | ||
const message = { | ||
const params = { | ||
MessageAttributes: attributes, | ||
@@ -54,3 +53,6 @@ MessageBody: sqsMessage.getBody(), | ||
}; | ||
return this.sqsPublisher.sendMessage(message); | ||
if (typeof configure === 'function') { | ||
yield configure(params); | ||
} | ||
return this.sqsPublisher.sendMessage(params); | ||
}); | ||
@@ -62,3 +64,3 @@ } | ||
__param(1, (0, containr_1.inject)(logging_1.LoggingServices.Levels)), | ||
__metadata("design:paramtypes", [SqsPublisher_1.SqsPublisher, Object]) | ||
__metadata("design:paramtypes", [Object, Object]) | ||
], MessagePublisher); | ||
@@ -65,0 +67,0 @@ exports.MessagePublisher = MessagePublisher; |
{ | ||
"name": "@aesop-fables/triginta", | ||
"version": "0.8.4", | ||
"version": "0.8.5", | ||
"description": "A lightweight framework that wraps the basic infrastructure usages of AWS Lambda (SQS, Kinesis, etc.).", | ||
@@ -42,3 +42,3 @@ "type": "commonjs", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-plugin-jest": "27.2.1", | ||
"eslint-plugin-jest": "27.2.2", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
@@ -45,0 +45,0 @@ "jest": "29.5.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
116060
2517