@fiado/api-invoker 5.152.0 → 5.154.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.
- package/README.md +1 -0
- package/bin/container.config.js +5 -0
- package/bin/gsf-connector/index.d.ts +2 -0
- package/bin/gsf-connector/index.js +2 -0
- package/bin/gsf-connector/queue/GsfSyncPublisher.d.ts +6 -0
- package/bin/gsf-connector/queue/GsfSyncPublisher.js +36 -0
- package/bin/gsf-connector/queue/interfaces/IGsfSyncPublisher.d.ts +9 -0
- package/bin/gsf-connector/queue/interfaces/IGsfSyncPublisher.js +1 -0
- package/bin/index.d.ts +1 -0
- package/bin/index.js +1 -0
- package/bin/meeting-connector/api/interfaces/IMeetingConnectorApi.d.ts +3 -0
- package/package.json +2 -2
- package/src/container.config.ts +6 -0
- package/src/gsf-connector/index.ts +2 -0
- package/src/gsf-connector/queue/GsfSyncPublisher.ts +30 -0
- package/src/gsf-connector/queue/interfaces/IGsfSyncPublisher.ts +10 -0
- package/src/index.ts +1 -0
- package/src/meeting-connector/api/interfaces/IMeetingConnectorApi.ts +2 -1
package/README.md
CHANGED
|
@@ -266,6 +266,7 @@ Para comunicación asíncrona, la librería provee publishers que envían mensaj
|
|
|
266
266
|
| `ITransactionPublisher` | Eventos de transacción | `TRANSACTION_QUEUE` |
|
|
267
267
|
| `IActivityPublisher` | Eventos de actividad | `ACTIVITY_QUEUE` |
|
|
268
268
|
| `ITransactionAlarmPublisher` | Alarmas de transacción | `TRANSACTION_ALARM_QUEUE` |
|
|
269
|
+
| `IGsfSyncPublisher` | Alta del crédito y pagos hacia GSF (`GsfSyncQueue.fifo`) | `GSF_SYNC_QUEUE_URL` |
|
|
269
270
|
| `IPublisher` | Publisher genérico | Configurable |
|
|
270
271
|
|
|
271
272
|
### Ejemplo de Publisher
|
package/bin/container.config.js
CHANGED
|
@@ -153,6 +153,8 @@ import { RewardsEligibilityPublisher, RewardsEligibilityBusinessApi } from "./re
|
|
|
153
153
|
import { RulesApi } from "./rules-business/index.js";
|
|
154
154
|
import CollectionEngineApi from "./collection-engine/api/CollectionEngineApi.js";
|
|
155
155
|
import DomainCallbackApi from "./domain-callback/api/DomainCallbackApi.js";
|
|
156
|
+
// GSF connector — publisher de la cola FIFO de sincronización de créditos y pagos
|
|
157
|
+
import { GsfSyncPublisher } from "./gsf-connector/index.js";
|
|
156
158
|
export const apiInvokerBindings = new ContainerModule(({ bind }) => {
|
|
157
159
|
// UTILS bindings
|
|
158
160
|
bind("InvokerUtils").to(InvokerUtils);
|
|
@@ -329,4 +331,7 @@ export const apiInvokerBindings = new ContainerModule(({ bind }) => {
|
|
|
329
331
|
bind("ICollectionEngineApi").to(CollectionEngineApi);
|
|
330
332
|
// Domain callback — el motor notifica al dominio dueño del cargo (applyCollectionResult)
|
|
331
333
|
bind("IDomainCallbackApi").to(DomainCallbackApi);
|
|
334
|
+
// GSF connector — alta del crédito y pagos hacia GsfSyncQueue.fifo.
|
|
335
|
+
// El productor necesita GSF_SYNC_QUEUE_URL y sqs:SendMessage sobre la cola.
|
|
336
|
+
bind("IGsfSyncPublisher").to(GsfSyncPublisher);
|
|
332
337
|
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { GsfCreateCreditMessage, GsfPaymentMessage } from "@fiado/type-kit/bin/gsfConnector/index.js";
|
|
2
|
+
import { IGsfSyncPublisher } from "./interfaces/IGsfSyncPublisher.js";
|
|
3
|
+
export declare class GsfSyncPublisher implements IGsfSyncPublisher {
|
|
4
|
+
private readonly GSF_SYNC_QUEUE_URL;
|
|
5
|
+
publish(message: GsfCreateCreditMessage | GsfPaymentMessage): Promise<void>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
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 { SendMessageCommand, SQSClient } from "@aws-sdk/client-sqs";
|
|
8
|
+
import { injectable } from "inversify";
|
|
9
|
+
let GsfSyncPublisher = class GsfSyncPublisher {
|
|
10
|
+
GSF_SYNC_QUEUE_URL = process.env.GSF_SYNC_QUEUE_URL;
|
|
11
|
+
async publish(message) {
|
|
12
|
+
if (!this.GSF_SYNC_QUEUE_URL) {
|
|
13
|
+
throw new Error("Error publishing message to GsfSyncQueue.fifo: GSF_SYNC_QUEUE_URL no está configurada");
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
const client = new SQSClient();
|
|
17
|
+
// FIFO: un grupo por crédito para que los pagos lleguen después de su alta.
|
|
18
|
+
const sendMessageRequest = {
|
|
19
|
+
QueueUrl: this.GSF_SYNC_QUEUE_URL,
|
|
20
|
+
MessageBody: JSON.stringify(message),
|
|
21
|
+
MessageGroupId: message.externalCreditId,
|
|
22
|
+
MessageDeduplicationId: message.messageId,
|
|
23
|
+
};
|
|
24
|
+
await client.send(new SendMessageCommand(sendMessageRequest));
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
// El cuerpo lleva datos personales: el error solo nombra la cola y el motivo.
|
|
28
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
29
|
+
throw new Error(`Error publishing message to GsfSyncQueue.fifo: ${errorMessage}`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
GsfSyncPublisher = __decorate([
|
|
34
|
+
injectable()
|
|
35
|
+
], GsfSyncPublisher);
|
|
36
|
+
export { GsfSyncPublisher };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { GsfCreateCreditMessage, GsfPaymentMessage } from "@fiado/type-kit/bin/gsfConnector/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Publisher hacia `GsfSyncQueue.fifo`, que consume `gsf-connector`: alta del crédito y sus pagos.
|
|
4
|
+
* El productor necesita la env var `GSF_SYNC_QUEUE_URL` (export `GsfSyncQueueUrl`) y `sqs:SendMessage`
|
|
5
|
+
* sobre la cola (export `GsfSyncQueueArn`).
|
|
6
|
+
*/
|
|
7
|
+
export interface IGsfSyncPublisher {
|
|
8
|
+
publish(message: GsfCreateCreditMessage | GsfPaymentMessage): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/bin/index.d.ts
CHANGED
package/bin/index.js
CHANGED
|
@@ -16,11 +16,14 @@ export type MeetingConnectorCreateRequest = {
|
|
|
16
16
|
timezone: string;
|
|
17
17
|
registrationRequired: boolean;
|
|
18
18
|
phoneRequired: boolean;
|
|
19
|
+
/** Con `options` (los textos de las opciones) y `type` distinto de MULTIPLE, la pregunta es de elegir. */
|
|
19
20
|
registrationQuestions?: Array<{
|
|
20
21
|
ref: string;
|
|
21
22
|
text: string;
|
|
22
23
|
required?: boolean;
|
|
23
24
|
dataType?: string;
|
|
25
|
+
type?: string;
|
|
26
|
+
options?: string[];
|
|
24
27
|
}>;
|
|
25
28
|
polls?: Array<{
|
|
26
29
|
title: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fiado/api-invoker",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.154.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.14.0",
|
|
35
35
|
"@fiado/http-client": "^2.0.1",
|
|
36
36
|
"@fiado/logger": "^1.1.3",
|
|
37
|
-
"@fiado/type-kit": "^3.
|
|
37
|
+
"@fiado/type-kit": "^3.612.0",
|
|
38
38
|
"dotenv": "^16.4.7"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
package/src/container.config.ts
CHANGED
|
@@ -226,6 +226,8 @@ import CollectionEngineApi from "./collection-engine/api/CollectionEngineApi.js"
|
|
|
226
226
|
// consumidor el resultado de un cobro (applyCollectionResult); baseUrl viaja por llamada
|
|
227
227
|
import { IDomainCallbackApi } from "./domain-callback/index.js";
|
|
228
228
|
import DomainCallbackApi from "./domain-callback/api/DomainCallbackApi.js";
|
|
229
|
+
// GSF connector — publisher de la cola FIFO de sincronización de créditos y pagos
|
|
230
|
+
import { IGsfSyncPublisher, GsfSyncPublisher } from "./gsf-connector/index.js";
|
|
229
231
|
|
|
230
232
|
export const apiInvokerBindings = new ContainerModule(({ bind }) => {
|
|
231
233
|
// UTILS bindings
|
|
@@ -432,4 +434,8 @@ export const apiInvokerBindings = new ContainerModule(({ bind }) => {
|
|
|
432
434
|
|
|
433
435
|
// Domain callback — el motor notifica al dominio dueño del cargo (applyCollectionResult)
|
|
434
436
|
bind<IDomainCallbackApi>("IDomainCallbackApi").to(DomainCallbackApi);
|
|
437
|
+
|
|
438
|
+
// GSF connector — alta del crédito y pagos hacia GsfSyncQueue.fifo.
|
|
439
|
+
// El productor necesita GSF_SYNC_QUEUE_URL y sqs:SendMessage sobre la cola.
|
|
440
|
+
bind<IGsfSyncPublisher>("IGsfSyncPublisher").to(GsfSyncPublisher);
|
|
435
441
|
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { SendMessageCommand, SendMessageRequest, SQSClient } from "@aws-sdk/client-sqs";
|
|
2
|
+
import { injectable } from "inversify";
|
|
3
|
+
import type { GsfCreateCreditMessage, GsfPaymentMessage } from "@fiado/type-kit/bin/gsfConnector/index.js";
|
|
4
|
+
import { IGsfSyncPublisher } from "./interfaces/IGsfSyncPublisher.js";
|
|
5
|
+
|
|
6
|
+
@injectable()
|
|
7
|
+
export class GsfSyncPublisher implements IGsfSyncPublisher {
|
|
8
|
+
private readonly GSF_SYNC_QUEUE_URL = process.env.GSF_SYNC_QUEUE_URL;
|
|
9
|
+
|
|
10
|
+
async publish(message: GsfCreateCreditMessage | GsfPaymentMessage): Promise<void> {
|
|
11
|
+
if (!this.GSF_SYNC_QUEUE_URL) {
|
|
12
|
+
throw new Error("Error publishing message to GsfSyncQueue.fifo: GSF_SYNC_QUEUE_URL no está configurada");
|
|
13
|
+
}
|
|
14
|
+
try {
|
|
15
|
+
const client: SQSClient = new SQSClient();
|
|
16
|
+
// FIFO: un grupo por crédito para que los pagos lleguen después de su alta.
|
|
17
|
+
const sendMessageRequest: SendMessageRequest = {
|
|
18
|
+
QueueUrl: this.GSF_SYNC_QUEUE_URL,
|
|
19
|
+
MessageBody: JSON.stringify(message),
|
|
20
|
+
MessageGroupId: message.externalCreditId,
|
|
21
|
+
MessageDeduplicationId: message.messageId,
|
|
22
|
+
};
|
|
23
|
+
await client.send(new SendMessageCommand(sendMessageRequest));
|
|
24
|
+
} catch (error) {
|
|
25
|
+
// El cuerpo lleva datos personales: el error solo nombra la cola y el motivo.
|
|
26
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
27
|
+
throw new Error(`Error publishing message to GsfSyncQueue.fifo: ${errorMessage}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { GsfCreateCreditMessage, GsfPaymentMessage } from "@fiado/type-kit/bin/gsfConnector/index.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Publisher hacia `GsfSyncQueue.fifo`, que consume `gsf-connector`: alta del crédito y sus pagos.
|
|
5
|
+
* El productor necesita la env var `GSF_SYNC_QUEUE_URL` (export `GsfSyncQueueUrl`) y `sqs:SendMessage`
|
|
6
|
+
* sobre la cola (export `GsfSyncQueueArn`).
|
|
7
|
+
*/
|
|
8
|
+
export interface IGsfSyncPublisher {
|
|
9
|
+
publish(message: GsfCreateCreditMessage | GsfPaymentMessage): Promise<void>;
|
|
10
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -14,7 +14,8 @@ export type MeetingConnectorCreateRequest = {
|
|
|
14
14
|
timezone: string;
|
|
15
15
|
registrationRequired: boolean;
|
|
16
16
|
phoneRequired: boolean;
|
|
17
|
-
|
|
17
|
+
/** Con `options` (los textos de las opciones) y `type` distinto de MULTIPLE, la pregunta es de elegir. */
|
|
18
|
+
registrationQuestions?: Array<{ ref: string; text: string; required?: boolean; dataType?: string; type?: string; options?: string[] }>;
|
|
18
19
|
polls?: Array<{ title: string; questions: Array<{ ref: string; text: string; type: string; options?: string[] }> }>;
|
|
19
20
|
};
|
|
20
21
|
|