@aesop-fables/triginta 0.8.3 → 0.8.5

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.
@@ -0,0 +1,3 @@
1
+ export declare const TrigintaHeaders: {
2
+ LogLevel: string;
3
+ };
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TrigintaHeaders = void 0;
4
+ exports.TrigintaHeaders = {
5
+ LogLevel: 'X-Log-Level',
6
+ };
@@ -32,6 +32,8 @@ const containr_1 = require("@aesop-fables/containr");
32
32
  const core_1 = __importDefault(require("@middy/core"));
33
33
  const Decorators_1 = require("../Decorators");
34
34
  const HttpLambdaServices_1 = require("./HttpLambdaServices");
35
+ const LoggingRegistry_1 = require("../logging/LoggingRegistry");
36
+ const Levels_1 = require("../logging/Levels");
35
37
  let HttpResponseGenerator = class HttpResponseGenerator {
36
38
  constructor(configuredRoute) {
37
39
  this.configuredRoute = configuredRoute;
@@ -137,6 +139,7 @@ exports.HttpLambdaFactory = HttpLambdaFactory;
137
139
  exports.useTrigintaHttp = (0, containr_1.createServiceModule)('triginta/http', (services) => {
138
140
  services.autoResolve(HttpLambdaServices_1.HttpLambdaServices.HttpResponseGenerator, HttpResponseGenerator, containr_1.Scopes.Transient);
139
141
  services.autoResolve(HttpLambdaServices_1.HttpLambdaServices.HttpLambdaFactory, HttpLambdaFactory, containr_1.Scopes.Transient);
142
+ services.include(new LoggingRegistry_1.LoggingRegistry(Levels_1.CurrentRequestLoggingLevel));
140
143
  });
141
144
  function validateContainer(container) {
142
145
  if (typeof container === 'undefined') {
package/lib/index.d.ts CHANGED
@@ -17,11 +17,13 @@ export * from './sqs/SqsPublisher';
17
17
  export * from './http/IConfiguredRoute';
18
18
  export * from './TrigintaConfig';
19
19
  export * from './resolveEnvironmentSettings';
20
+ export * from './TrigintaHeaders';
20
21
  export * from './s3/IS3RecordHandler';
21
22
  export * from './s3/S3Lambda';
22
23
  export * from './s3/S3LambdaServices';
23
24
  export * as Localization from './localization';
24
25
  export * as Validation from './validation';
26
+ export * as Logging from './logging';
25
27
  import * as httpUtils from './http/invokeHttpHandler';
26
28
  import * as sqsUtils from './sqs/invokeSqsHandler';
27
29
  import * as s3Utils from './s3/invokeS3Handler';
package/lib/index.js CHANGED
@@ -29,7 +29,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
29
29
  return (mod && mod.__esModule) ? mod : { "default": mod };
30
30
  };
31
31
  Object.defineProperty(exports, "__esModule", { value: true });
32
- exports.TestUtils = exports.Validation = exports.Localization = exports.RouteRegistry = void 0;
32
+ exports.TestUtils = exports.Logging = exports.Validation = exports.Localization = exports.RouteRegistry = void 0;
33
33
  __exportStar(require("./Bootstrapping"), exports);
34
34
  __exportStar(require("./IHandler"), exports);
35
35
  __exportStar(require("./http/IHttpEndpoint"), exports);
@@ -50,11 +50,13 @@ __exportStar(require("./sqs/SqsPublisher"), exports);
50
50
  __exportStar(require("./http/IConfiguredRoute"), exports);
51
51
  __exportStar(require("./TrigintaConfig"), exports);
52
52
  __exportStar(require("./resolveEnvironmentSettings"), exports);
53
+ __exportStar(require("./TrigintaHeaders"), exports);
53
54
  __exportStar(require("./s3/IS3RecordHandler"), exports);
54
55
  __exportStar(require("./s3/S3Lambda"), exports);
55
56
  __exportStar(require("./s3/S3LambdaServices"), exports);
56
57
  exports.Localization = __importStar(require("./localization"));
57
58
  exports.Validation = __importStar(require("./validation"));
59
+ exports.Logging = __importStar(require("./logging"));
58
60
  const httpUtils = __importStar(require("./http/invokeHttpHandler"));
59
61
  const sqsUtils = __importStar(require("./sqs/invokeSqsHandler"));
60
62
  const s3Utils = __importStar(require("./s3/invokeS3Handler"));
@@ -0,0 +1,10 @@
1
+ import { ILogger } from './ILogger';
2
+ export declare class ConsoleLogger implements ILogger {
3
+ private readonly level;
4
+ constructor(level: string);
5
+ log(level: string, message: string): void;
6
+ debug(message: string): void;
7
+ info(message: string): void;
8
+ warn(message: string): void;
9
+ error(message: string): void;
10
+ }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConsoleLogger = void 0;
4
+ const levelMap = {
5
+ debug: 3,
6
+ error: 0,
7
+ info: 2,
8
+ warn: 1,
9
+ };
10
+ const shouldLog = (level, target) => {
11
+ var _a, _b;
12
+ const a = (_a = levelMap[level]) !== null && _a !== void 0 ? _a : 0;
13
+ const b = (_b = levelMap[target]) !== null && _b !== void 0 ? _b : 0;
14
+ return a >= b;
15
+ };
16
+ class ConsoleLogger {
17
+ constructor(level) {
18
+ this.level = level;
19
+ }
20
+ log(level, message) {
21
+ if (shouldLog(this.level, level)) {
22
+ console.log(`${level}: ${message}`);
23
+ }
24
+ }
25
+ debug(message) {
26
+ this.log('debug', message);
27
+ }
28
+ info(message) {
29
+ this.log('info', message);
30
+ }
31
+ warn(message) {
32
+ this.log('warn', message);
33
+ }
34
+ error(message) {
35
+ this.log('error', message);
36
+ }
37
+ }
38
+ exports.ConsoleLogger = ConsoleLogger;
@@ -0,0 +1,12 @@
1
+ export interface ILogger {
2
+ debug(message: string): void;
3
+ info(message: string): void;
4
+ warn(message: string): void;
5
+ error(message: string): void;
6
+ }
7
+ export declare class NulloLogger implements ILogger {
8
+ debug(): void;
9
+ info(): void;
10
+ warn(): void;
11
+ error(): void;
12
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NulloLogger = void 0;
4
+ class NulloLogger {
5
+ debug() {
6
+ // no-op
7
+ }
8
+ info() {
9
+ // no-op
10
+ }
11
+ warn() {
12
+ // no-op
13
+ }
14
+ error() {
15
+ // no-op
16
+ }
17
+ }
18
+ exports.NulloLogger = NulloLogger;
@@ -0,0 +1,7 @@
1
+ import { ILogger } from './ILogger';
2
+ /**
3
+ * Provides a mechanism for contextually building up a logger
4
+ */
5
+ export interface ILoggerFactory {
6
+ createLogger(): ILogger;
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,14 @@
1
+ import { APIGatewayProxyEventV2, SQSRecord } from 'aws-lambda';
2
+ export interface LoggingLevel {
3
+ resolveLevel(): string | undefined;
4
+ }
5
+ export declare class CurrentRequestLoggingLevel implements LoggingLevel {
6
+ private readonly event;
7
+ constructor(event: APIGatewayProxyEventV2);
8
+ resolveLevel(): string | undefined;
9
+ }
10
+ export declare class CurrentRecordLoggingLevel implements LoggingLevel {
11
+ private readonly record;
12
+ constructor(record: SQSRecord);
13
+ resolveLevel(): string | undefined;
14
+ }
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.CurrentRecordLoggingLevel = exports.CurrentRequestLoggingLevel = void 0;
16
+ const containr_1 = require("@aesop-fables/containr");
17
+ const HttpLambdaServices_1 = require("../http/HttpLambdaServices");
18
+ const SqsLambdaServices_1 = require("../sqs/SqsLambdaServices");
19
+ const TrigintaHeaders_1 = require("../TrigintaHeaders");
20
+ let CurrentRequestLoggingLevel = class CurrentRequestLoggingLevel {
21
+ constructor(event) {
22
+ this.event = event;
23
+ }
24
+ resolveLevel() {
25
+ return this.event.headers[TrigintaHeaders_1.TrigintaHeaders.LogLevel.toLowerCase()];
26
+ }
27
+ };
28
+ CurrentRequestLoggingLevel = __decorate([
29
+ __param(0, (0, containr_1.inject)(HttpLambdaServices_1.HttpLambdaServices.CurrentEvent)),
30
+ __metadata("design:paramtypes", [Object])
31
+ ], CurrentRequestLoggingLevel);
32
+ exports.CurrentRequestLoggingLevel = CurrentRequestLoggingLevel;
33
+ let CurrentRecordLoggingLevel = class CurrentRecordLoggingLevel {
34
+ constructor(record) {
35
+ this.record = record;
36
+ }
37
+ resolveLevel() {
38
+ var _a;
39
+ return (_a = this.record.messageAttributes[TrigintaHeaders_1.TrigintaHeaders.LogLevel]) === null || _a === void 0 ? void 0 : _a.stringValue;
40
+ }
41
+ };
42
+ CurrentRecordLoggingLevel = __decorate([
43
+ __param(0, (0, containr_1.inject)(SqsLambdaServices_1.SqsLambdaServices.CurrentRecord)),
44
+ __metadata("design:paramtypes", [Object])
45
+ ], CurrentRecordLoggingLevel);
46
+ exports.CurrentRecordLoggingLevel = CurrentRecordLoggingLevel;
@@ -0,0 +1,8 @@
1
+ import { ILogger } from './ILogger';
2
+ import { ILoggerFactory } from './ILoggerFactory';
3
+ import { LoggingLevel } from './Levels';
4
+ export declare class LoggerFactory implements ILoggerFactory {
5
+ private readonly levels;
6
+ constructor(levels: LoggingLevel);
7
+ createLogger(): ILogger;
8
+ }
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.LoggerFactory = void 0;
16
+ const containr_1 = require("@aesop-fables/containr");
17
+ const ILogger_1 = require("./ILogger");
18
+ const LoggingServices_1 = require("./LoggingServices");
19
+ const ConsoleLogger_1 = require("./ConsoleLogger");
20
+ let LoggerFactory = class LoggerFactory {
21
+ constructor(levels) {
22
+ this.levels = levels;
23
+ }
24
+ createLogger() {
25
+ const level = this.levels.resolveLevel();
26
+ if (!level) {
27
+ return new ILogger_1.NulloLogger();
28
+ }
29
+ return new ConsoleLogger_1.ConsoleLogger(level);
30
+ }
31
+ };
32
+ LoggerFactory = __decorate([
33
+ __param(0, (0, containr_1.inject)(LoggingServices_1.LoggingServices.Levels)),
34
+ __metadata("design:paramtypes", [Object])
35
+ ], LoggerFactory);
36
+ exports.LoggerFactory = LoggerFactory;
@@ -0,0 +1,7 @@
1
+ import { IServiceRegistry, Newable, ServiceCollection } from '@aesop-fables/containr';
2
+ import { LoggingLevel } from './Levels';
3
+ export declare class LoggingRegistry implements IServiceRegistry {
4
+ private readonly levels;
5
+ constructor(levels: Newable<LoggingLevel>);
6
+ configureServices(services: ServiceCollection): void;
7
+ }
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LoggingRegistry = void 0;
4
+ const containr_1 = require("@aesop-fables/containr");
5
+ const LoggingServices_1 = require("./LoggingServices");
6
+ const LoggerFactory_1 = require("./LoggerFactory");
7
+ class LoggingRegistry {
8
+ constructor(levels) {
9
+ this.levels = levels;
10
+ }
11
+ configureServices(services) {
12
+ services.factory(LoggingServices_1.LoggingServices.Levels, (container) => {
13
+ return container.resolve(this.levels);
14
+ }, containr_1.Scopes.Transient);
15
+ services.autoResolve(LoggingServices_1.LoggingServices.Factory, LoggerFactory_1.LoggerFactory, containr_1.Scopes.Transient);
16
+ services.factory(LoggingServices_1.LoggingServices.Logger, (container) => {
17
+ const factory = container.get(LoggingServices_1.LoggingServices.Factory);
18
+ return factory.createLogger();
19
+ }, containr_1.Scopes.Transient);
20
+ }
21
+ }
22
+ exports.LoggingRegistry = LoggingRegistry;
@@ -0,0 +1,5 @@
1
+ export declare const LoggingServices: {
2
+ Factory: string;
3
+ Levels: string;
4
+ Logger: string;
5
+ };
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LoggingServices = void 0;
4
+ const Utils_1 = require("../Utils");
5
+ const namedService = (0, Utils_1.createServiceNamespacer)('logging');
6
+ exports.LoggingServices = {
7
+ Factory: namedService('factory'),
8
+ Levels: namedService('levels'),
9
+ Logger: namedService('logger'),
10
+ };
@@ -0,0 +1,7 @@
1
+ export * from './ConsoleLogger';
2
+ export * from './ILogger';
3
+ export * from './ILoggerFactory';
4
+ export * from './Levels';
5
+ export * from './LoggerFactory';
6
+ export * from './LoggingServices';
7
+ export * from './LoggingRegistry';
@@ -0,0 +1,23 @@
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("./ConsoleLogger"), exports);
18
+ __exportStar(require("./ILogger"), exports);
19
+ __exportStar(require("./ILoggerFactory"), exports);
20
+ __exportStar(require("./Levels"), exports);
21
+ __exportStar(require("./LoggerFactory"), exports);
22
+ __exportStar(require("./LoggingServices"), exports);
23
+ __exportStar(require("./LoggingRegistry"), exports);
@@ -1,13 +1,17 @@
1
- import { MessageBodyAttributeMap, SendMessageResult } from 'aws-sdk/clients/sqs';
2
- import { SqsPublisher } from './SqsPublisher';
1
+ import { MessageBodyAttributeMap, SendMessageRequest, SendMessageResult } from 'aws-sdk/clients/sqs';
2
+ import { ISqsPublisher } from './SqsPublisher';
3
3
  import { SQSMessageAttributes } from 'aws-lambda';
4
4
  import { ISqsMessage } from './ISqsMessage';
5
+ import { LoggingLevel } from '../logging';
6
+ declare type ConfigureSqsDelegate = (params: SendMessageRequest) => Promise<void>;
5
7
  export interface IMessagePublisher {
6
- publish(event: ISqsMessage): Promise<SendMessageResult>;
8
+ publish(event: ISqsMessage, defaultAttributes?: SQSMessageAttributes, configure?: ConfigureSqsDelegate): Promise<SendMessageResult>;
7
9
  }
8
10
  export declare class MessagePublisher implements IMessagePublisher {
9
11
  private readonly sqsPublisher;
10
- constructor(sqsPublisher: SqsPublisher);
11
- publish(sqsMessage: ISqsMessage): Promise<SendMessageResult>;
12
+ private readonly levels;
13
+ constructor(sqsPublisher: ISqsPublisher, levels: LoggingLevel);
14
+ publish(sqsMessage: ISqsMessage, defaultAttributes?: SQSMessageAttributes, configure?: ConfigureSqsDelegate): Promise<SendMessageResult>;
12
15
  }
13
16
  export declare function messageTypeConverter(attributes: SQSMessageAttributes): MessageBodyAttributeMap;
17
+ export {};
@@ -23,27 +23,41 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
23
23
  Object.defineProperty(exports, "__esModule", { value: true });
24
24
  exports.messageTypeConverter = exports.MessagePublisher = void 0;
25
25
  const containr_1 = require("@aesop-fables/containr");
26
- const SqsPublisher_1 = require("./SqsPublisher");
27
26
  const SqsLambdaServices_1 = require("./SqsLambdaServices");
27
+ const logging_1 = require("../logging");
28
+ const TrigintaHeaders_1 = require("../TrigintaHeaders");
28
29
  let MessagePublisher = class MessagePublisher {
29
30
  // eslint-disable-next-line prettier/prettier
30
- constructor(sqsPublisher) {
31
+ constructor(sqsPublisher, levels) {
31
32
  this.sqsPublisher = sqsPublisher;
33
+ this.levels = levels;
32
34
  }
33
- publish(sqsMessage) {
35
+ publish(sqsMessage, defaultAttributes, configure) {
34
36
  return __awaiter(this, void 0, void 0, function* () {
35
- const message = {
36
- MessageAttributes: messageTypeConverter(sqsMessage.getAttributes()),
37
+ const attributes = Object.assign(Object.assign({}, messageTypeConverter(defaultAttributes !== null && defaultAttributes !== void 0 ? defaultAttributes : {})), messageTypeConverter(sqsMessage.getAttributes()));
38
+ const level = this.levels.resolveLevel();
39
+ if (level) {
40
+ attributes[TrigintaHeaders_1.TrigintaHeaders.LogLevel] = {
41
+ DataType: 'String',
42
+ StringValue: level,
43
+ };
44
+ }
45
+ const params = {
46
+ MessageAttributes: attributes,
37
47
  MessageBody: sqsMessage.getBody(),
38
48
  QueueUrl: sqsMessage.getQueueUrl(),
39
49
  };
40
- return this.sqsPublisher.sendMessage(message);
50
+ if (typeof configure === 'function') {
51
+ yield configure(params);
52
+ }
53
+ return this.sqsPublisher.sendMessage(params);
41
54
  });
42
55
  }
43
56
  };
44
57
  MessagePublisher = __decorate([
45
58
  __param(0, (0, containr_1.inject)(SqsLambdaServices_1.SqsLambdaServices.SqsPublisher)),
46
- __metadata("design:paramtypes", [SqsPublisher_1.SqsPublisher])
59
+ __param(1, (0, containr_1.inject)(logging_1.LoggingServices.Levels)),
60
+ __metadata("design:paramtypes", [Object, Object])
47
61
  ], MessagePublisher);
48
62
  exports.MessagePublisher = MessagePublisher;
49
63
  function messageTypeConverter(attributes) {
@@ -35,6 +35,7 @@ const SqsLambdaServices_1 = require("./SqsLambdaServices");
35
35
  const RecordMatchers_1 = require("./RecordMatchers");
36
36
  const SqsPublisher_1 = require("./SqsPublisher");
37
37
  const MessagePublisher_1 = require("./MessagePublisher");
38
+ const logging_1 = require("../logging");
38
39
  function embedSqsEvent(event) {
39
40
  return (0, containr_1.createServiceModule)('@aesop-fables/triginta/sqs/event', (services) => {
40
41
  services.singleton(SqsLambdaServices_1.SqsLambdaServices.CurrentEvent, event);
@@ -102,6 +103,7 @@ exports.useTrigintaSqs = (0, containr_1.createServiceModuleWithOptions)('trigint
102
103
  services.autoResolve(SqsLambdaServices_1.SqsLambdaServices.MessageDeserializer, RecordMatchers_1.SqsMessageDeserializer, containr_1.Scopes.Transient);
103
104
  services.autoResolve(SqsLambdaServices_1.SqsLambdaServices.SqsPublisher, SqsPublisher_1.SqsPublisher, containr_1.Scopes.Transient);
104
105
  services.autoResolve(SqsLambdaServices_1.SqsLambdaServices.MessagePublisher, MessagePublisher_1.MessagePublisher, containr_1.Scopes.Transient);
106
+ services.include(new logging_1.LoggingRegistry(logging_1.CurrentRecordLoggingLevel));
105
107
  });
106
108
  function createBootstrappedSqsLambdaContext(container) {
107
109
  return {
@@ -1,11 +1,13 @@
1
1
  import { SendMessageRequest, SendMessageResult } from 'aws-sdk/clients/sqs';
2
2
  import { SqsSettings } from './SqsSettings';
3
+ import { ILogger } from '../logging/ILogger';
3
4
  export interface ISqsPublisher {
4
5
  sendMessage(message: SendMessageRequest): Promise<SendMessageResult>;
5
6
  }
6
7
  export declare class SqsPublisher implements ISqsPublisher {
7
8
  private readonly settings;
9
+ private readonly logger;
8
10
  private readonly sqs;
9
- constructor(settings: SqsSettings);
11
+ constructor(settings: SqsSettings, logger: ILogger);
10
12
  sendMessage(message: SendMessageRequest): Promise<SendMessageResult>;
11
13
  }
@@ -28,13 +28,17 @@ exports.SqsPublisher = void 0;
28
28
  const containr_1 = require("@aesop-fables/containr");
29
29
  const aws_sdk_1 = __importDefault(require("aws-sdk"));
30
30
  const SqsLambdaServices_1 = require("./SqsLambdaServices");
31
+ const logging_1 = require("../logging");
31
32
  let SqsPublisher = class SqsPublisher {
32
- constructor(settings) {
33
+ constructor(settings, logger) {
33
34
  this.settings = settings;
35
+ this.logger = logger;
36
+ this.logger.debug(JSON.stringify(this.settings, null, 2));
34
37
  this.sqs = new aws_sdk_1.default.SQS(this.settings);
35
38
  }
36
39
  sendMessage(message) {
37
40
  return __awaiter(this, void 0, void 0, function* () {
41
+ this.logger.debug(JSON.stringify(message, null, 2));
38
42
  const response = this.sqs.sendMessage(message).promise();
39
43
  if (!response) {
40
44
  throw new Error(`${response}`);
@@ -45,6 +49,7 @@ let SqsPublisher = class SqsPublisher {
45
49
  };
46
50
  SqsPublisher = __decorate([
47
51
  __param(0, (0, containr_1.inject)(SqsLambdaServices_1.SqsLambdaServices.SqsSettings)),
48
- __metadata("design:paramtypes", [Object])
52
+ __param(1, (0, containr_1.inject)(logging_1.LoggingServices.Logger)),
53
+ __metadata("design:paramtypes", [Object, Object])
49
54
  ], SqsPublisher);
50
55
  exports.SqsPublisher = SqsPublisher;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aesop-fables/triginta",
3
- "version": "0.8.3",
3
+ "version": "0.8.5",
4
4
  "description": "A lightweight framework that wraps the basic infrastructure usages of AWS Lambda (SQS, Kinesis, etc.).",
5
5
  "type": "commonjs",
6
6
  "exports": {
@@ -39,7 +39,7 @@
39
39
  "esbuild": "^0.17.8",
40
40
  "eslint": "8.42.0",
41
41
  "eslint-config-prettier": "^8.5.0",
42
- "eslint-plugin-jest": "27.2.1",
42
+ "eslint-plugin-jest": "27.2.2",
43
43
  "eslint-plugin-prettier": "^4.2.1",
44
44
  "jest": "29.5.0",
45
45
  "jest-mock-extended": "^3.0.1",