@fiado/api-invoker 5.50.0 → 5.51.0

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,2 +1,3 @@
1
1
  export * from './api/CollectionEngineApi.js';
2
2
  export * from './api/interfaces/ICollectionEngineApi.js';
3
+ export * from './queue/index.js';
@@ -1,2 +1,3 @@
1
1
  export * from './api/CollectionEngineApi.js';
2
2
  export * from './api/interfaces/ICollectionEngineApi.js';
3
+ export * from './queue/index.js';
@@ -0,0 +1,6 @@
1
+ import { MoneyInEvent } from "@fiado/type-kit/bin/collection/index.js";
2
+ import { ICollectionMoneyInPublisher } from "./interfaces/ICollectionMoneyInPublisher.js";
3
+ export default class CollectionMoneyInPublisher implements ICollectionMoneyInPublisher {
4
+ private readonly QUEUE_URL;
5
+ publish(message: MoneyInEvent): Promise<void>;
6
+ }
@@ -0,0 +1,30 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ 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;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { injectable } from "inversify";
8
+ import { SendMessageCommand, SQSClient } from "@aws-sdk/client-sqs";
9
+ let CollectionMoneyInPublisher = class CollectionMoneyInPublisher {
10
+ QUEUE_URL = process.env.COLLECTION_MONEY_IN_QUEUE;
11
+ async publish(message) {
12
+ try {
13
+ const client = new SQSClient();
14
+ const sendMessageRequest = {
15
+ QueueUrl: this.QUEUE_URL,
16
+ MessageBody: JSON.stringify(message)
17
+ };
18
+ const command = new SendMessageCommand(sendMessageRequest);
19
+ await client.send(command);
20
+ }
21
+ catch (error) {
22
+ const errorMessage = error instanceof Error ? error.message : String(error);
23
+ throw new Error(`Error publishing message to CollectionMoneyInQueue: ${errorMessage}`);
24
+ }
25
+ }
26
+ };
27
+ CollectionMoneyInPublisher = __decorate([
28
+ injectable()
29
+ ], CollectionMoneyInPublisher);
30
+ export default CollectionMoneyInPublisher;
@@ -0,0 +1,2 @@
1
+ export * from "./interfaces/ICollectionMoneyInPublisher.js";
2
+ export { default as CollectionMoneyInPublisher } from "./CollectionMoneyInPublisher.js";
@@ -0,0 +1,2 @@
1
+ export * from "./interfaces/ICollectionMoneyInPublisher.js";
2
+ export { default as CollectionMoneyInPublisher } from "./CollectionMoneyInPublisher.js";
@@ -0,0 +1,11 @@
1
+ import { MoneyInEvent } from "@fiado/type-kit/bin/collection/index.js";
2
+ /**
3
+ * Avisa al motor de cobro de que a un titular le entró dinero, para que reintente en el acto los
4
+ * cobros que había dejado esperando fondos.
5
+ *
6
+ * Lo publica quien registra el ingreso. Es una notificación, no una orden de cobro: el motor decide
7
+ * si ese saldo alcanza para algo y a qué cargos aplicarlo.
8
+ */
9
+ export interface ICollectionMoneyInPublisher {
10
+ publish(message: MoneyInEvent): Promise<void>;
11
+ }
@@ -84,6 +84,7 @@ import { CreditPaymentApi } from "./credit-payment/index.js";
84
84
  import { DocumentGeneratorApi } from "./document-generator/index.js";
85
85
  import CreditIncomeDetectionPublisher from "./credit-engine/queue/CreditIncomeDetectionPublisher.js";
86
86
  import CreditScoringPublisher from "./credit-engine/queue/CreditScoringPublisher.js";
87
+ import CollectionMoneyInPublisher from "./collection-engine/queue/CollectionMoneyInPublisher.js";
87
88
  import CreditOfferGenerationPublisher from "./credit-engine/queue/CreditOfferGenerationPublisher.js";
88
89
  import CreditCollectionPublisher from "./credit-engine/queue/CreditCollectionPublisher.js";
89
90
  import CreditDelinquencyPublisher from "./credit-engine/queue/CreditDelinquencyPublisher.js";
@@ -222,6 +223,7 @@ export const apiInvokerBindings = new ContainerModule(({ bind }) => {
222
223
  // Credit module - SQS publishers
223
224
  bind("ICreditIncomeDetectionPublisher").to(CreditIncomeDetectionPublisher);
224
225
  bind("ICreditScoringPublisher").to(CreditScoringPublisher);
226
+ bind("ICollectionMoneyInPublisher").to(CollectionMoneyInPublisher);
225
227
  bind("ICreditOfferGenerationPublisher").to(CreditOfferGenerationPublisher);
226
228
  bind("ICreditCollectionPublisher").to(CreditCollectionPublisher);
227
229
  bind("ICreditDelinquencyPublisher").to(CreditDelinquencyPublisher);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fiado/api-invoker",
3
- "version": "5.50.0",
3
+ "version": "5.51.0",
4
4
  "description": "Sirve como un puente entre diferentes funciones lambda, facilitando la comunicación entre ellas a través de invocaciones http",
5
5
  "type": "module",
6
6
  "main": "bin/index.js",
@@ -34,7 +34,7 @@
34
34
  "@fiado/gateway-adapter": "^3.9.0",
35
35
  "@fiado/http-client": "^2.0.1",
36
36
  "@fiado/logger": "^1.1.3",
37
- "@fiado/type-kit": "^3.371.0",
37
+ "@fiado/type-kit": "^3.373.0",
38
38
  "dotenv": "^16.4.7"
39
39
  },
40
40
  "peerDependencies": {
@@ -1,2 +1,3 @@
1
1
  export * from './api/CollectionEngineApi.js';
2
2
  export * from './api/interfaces/ICollectionEngineApi.js';
3
+ export * from './queue/index.js';
@@ -0,0 +1,24 @@
1
+ import { injectable } from "inversify";
2
+ import { SendMessageCommand, SendMessageRequest, SQSClient } from "@aws-sdk/client-sqs";
3
+ import { MoneyInEvent } from "@fiado/type-kit/bin/collection/index.js";
4
+ import { ICollectionMoneyInPublisher } from "./interfaces/ICollectionMoneyInPublisher.js";
5
+
6
+ @injectable()
7
+ export default class CollectionMoneyInPublisher implements ICollectionMoneyInPublisher {
8
+ private readonly QUEUE_URL = process.env.COLLECTION_MONEY_IN_QUEUE;
9
+
10
+ async publish(message: MoneyInEvent): Promise<void> {
11
+ try {
12
+ const client: SQSClient = new SQSClient();
13
+ const sendMessageRequest: SendMessageRequest = {
14
+ QueueUrl: this.QUEUE_URL,
15
+ MessageBody: JSON.stringify(message)
16
+ };
17
+ const command: SendMessageCommand = new SendMessageCommand(sendMessageRequest);
18
+ await client.send(command);
19
+ } catch (error) {
20
+ const errorMessage = error instanceof Error ? error.message : String(error);
21
+ throw new Error(`Error publishing message to CollectionMoneyInQueue: ${errorMessage}`);
22
+ }
23
+ }
24
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./interfaces/ICollectionMoneyInPublisher.js";
2
+ export { default as CollectionMoneyInPublisher } from "./CollectionMoneyInPublisher.js";
@@ -0,0 +1,12 @@
1
+ import { MoneyInEvent } from "@fiado/type-kit/bin/collection/index.js";
2
+
3
+ /**
4
+ * Avisa al motor de cobro de que a un titular le entró dinero, para que reintente en el acto los
5
+ * cobros que había dejado esperando fondos.
6
+ *
7
+ * Lo publica quien registra el ingreso. Es una notificación, no una orden de cobro: el motor decide
8
+ * si ese saldo alcanza para algo y a qué cargos aplicarlo.
9
+ */
10
+ export interface ICollectionMoneyInPublisher {
11
+ publish(message: MoneyInEvent): Promise<void>;
12
+ }
@@ -136,6 +136,8 @@ import {
136
136
  } from "./credit-engine/index.js";
137
137
  import CreditIncomeDetectionPublisher from "./credit-engine/queue/CreditIncomeDetectionPublisher.js";
138
138
  import CreditScoringPublisher from "./credit-engine/queue/CreditScoringPublisher.js";
139
+ import { ICollectionMoneyInPublisher } from "./collection-engine/queue/interfaces/ICollectionMoneyInPublisher.js";
140
+ import CollectionMoneyInPublisher from "./collection-engine/queue/CollectionMoneyInPublisher.js";
139
141
  import CreditOfferGenerationPublisher from "./credit-engine/queue/CreditOfferGenerationPublisher.js";
140
142
  import CreditCollectionPublisher from "./credit-engine/queue/CreditCollectionPublisher.js";
141
143
  import CreditDelinquencyPublisher from "./credit-engine/queue/CreditDelinquencyPublisher.js";
@@ -295,6 +297,7 @@ export const apiInvokerBindings = new ContainerModule(({ bind }) => {
295
297
  // Credit module - SQS publishers
296
298
  bind<ICreditIncomeDetectionPublisher>("ICreditIncomeDetectionPublisher").to(CreditIncomeDetectionPublisher);
297
299
  bind<ICreditScoringPublisher>("ICreditScoringPublisher").to(CreditScoringPublisher);
300
+ bind<ICollectionMoneyInPublisher>("ICollectionMoneyInPublisher").to(CollectionMoneyInPublisher);
298
301
  bind<ICreditOfferGenerationPublisher>("ICreditOfferGenerationPublisher").to(CreditOfferGenerationPublisher);
299
302
  bind<ICreditCollectionPublisher>("ICreditCollectionPublisher").to(CreditCollectionPublisher);
300
303
  bind<ICreditDelinquencyPublisher>("ICreditDelinquencyPublisher").to(CreditDelinquencyPublisher);