@fiado/api-invoker 4.79.0 → 5.1.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/bin/credit-engine/CreditEngineApi.js +9 -2
- package/bin/credit-engine/interfaces/ICreditEngineApi.d.ts +9 -0
- package/bin/kyc/index.d.ts +2 -0
- package/bin/kyc/index.js +2 -0
- package/bin/kyc/queue/RetailKycInboundPublisher.d.ts +6 -0
- package/bin/kyc/queue/RetailKycInboundPublisher.js +32 -0
- package/bin/kyc/queue/interfaces/IRetailKycInboundPublisher.d.ts +12 -0
- package/bin/kyc/queue/interfaces/IRetailKycInboundPublisher.js +1 -0
- package/package.json +2 -2
- package/src/credit-engine/CreditEngineApi.ts +10 -2
- package/src/credit-engine/interfaces/ICreditEngineApi.ts +9 -0
- package/src/kyc/index.ts +2 -0
- package/src/kyc/queue/RetailKycInboundPublisher.ts +26 -0
- package/src/kyc/queue/interfaces/IRetailKycInboundPublisher.ts +13 -0
|
@@ -29,11 +29,18 @@ let CreditEngineApi = class CreditEngineApi {
|
|
|
29
29
|
}
|
|
30
30
|
async getCreditProfile(directoryId, partnerId) {
|
|
31
31
|
const url = `${this.baseUrl}credit/profile/${directoryId}`;
|
|
32
|
-
|
|
32
|
+
// El endpoint devuelve el envelope de `ApiResponse.createResponse`
|
|
33
|
+
// (`@fiado/gateway-adapter`): { code, date, data, description, msg }.
|
|
34
|
+
// Desenvolvemos acá para que el consumer reciba el objeto de dominio
|
|
35
|
+
// directo — ver docs/TECH_DEBT.md TD-002 en benefits-marketplace-business.
|
|
36
|
+
const envelope = await this.httpRequest.get(url, { partnerId }, { operationName: "getCreditProfile" });
|
|
37
|
+
return envelope.data;
|
|
33
38
|
}
|
|
34
39
|
async getActiveCredit(directoryId) {
|
|
35
40
|
const url = `${this.baseUrl}credit/active/${directoryId}`;
|
|
36
|
-
|
|
41
|
+
// Mismo envelope que getCreditProfile — desenvolvemos `.data` acá.
|
|
42
|
+
const envelope = await this.httpRequest.get(url, undefined, { operationName: "getActiveCredit" });
|
|
43
|
+
return envelope.data;
|
|
37
44
|
}
|
|
38
45
|
async enrichDirectories(directoryIds) {
|
|
39
46
|
const url = `${this.baseUrl}credit/private/enrich-directories`;
|
|
@@ -18,6 +18,12 @@ export interface ICreditEngineApi {
|
|
|
18
18
|
* Obtiene el perfil financiero del directorio para un partner específico.
|
|
19
19
|
* Endpoint: `GET /credit/profile/{directoryId}?partnerId={partnerId}`
|
|
20
20
|
*
|
|
21
|
+
* El envelope HTTP (`{code, date, data, description, msg}` de
|
|
22
|
+
* `ApiResponse.createResponse`) se desenvuelve internamente — este método
|
|
23
|
+
* devuelve el objeto de dominio directo, el consumer NUNCA debe leer
|
|
24
|
+
* `.data` manualmente (ver docs/TECH_DEBT.md TD-002 en
|
|
25
|
+
* benefits-marketplace-business, resuelto en la raíz por este cambio).
|
|
26
|
+
*
|
|
21
27
|
* @param directoryId ID del directorio del usuario.
|
|
22
28
|
* @param partnerId ID del partner (tenant) del perfil a consultar.
|
|
23
29
|
*/
|
|
@@ -26,6 +32,9 @@ export interface ICreditEngineApi {
|
|
|
26
32
|
* Obtiene el crédito activo del cliente, si existe.
|
|
27
33
|
* Endpoint: `GET /credit/active/{directoryId}`
|
|
28
34
|
*
|
|
35
|
+
* El envelope HTTP se desenvuelve internamente (mismo criterio que
|
|
36
|
+
* `getCreditProfile`) — el consumer recibe el objeto de dominio directo.
|
|
37
|
+
*
|
|
29
38
|
* @param directoryId ID del directorio del usuario.
|
|
30
39
|
* @returns Detalle del crédito activo, o `null` si no hay crédito activo.
|
|
31
40
|
*/
|
package/bin/kyc/index.d.ts
CHANGED
package/bin/kyc/index.js
CHANGED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { KycVerificationChangedV1 } from "@fiado/type-kit/bin/kyc/index.js";
|
|
2
|
+
import { IRetailKycInboundPublisher } from "./interfaces/IRetailKycInboundPublisher.js";
|
|
3
|
+
export declare class RetailKycInboundPublisher implements IRetailKycInboundPublisher {
|
|
4
|
+
private readonly RETAIL_KYC_INBOUND_QUEUE_URL;
|
|
5
|
+
publish(message: KycVerificationChangedV1): Promise<void>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
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 RetailKycInboundPublisher = class RetailKycInboundPublisher {
|
|
10
|
+
RETAIL_KYC_INBOUND_QUEUE_URL = process.env.RETAIL_KYC_INBOUND_QUEUE_URL;
|
|
11
|
+
async publish(message) {
|
|
12
|
+
try {
|
|
13
|
+
const client = new SQSClient();
|
|
14
|
+
// Cola ESTÁNDAR (no FIFO): sin MessageGroupId/MessageDeduplicationId. La deduplicación
|
|
15
|
+
// la hace el consumidor con la llave de negocio (directoryId + verificationId + status + result).
|
|
16
|
+
const sendMessageRequest = {
|
|
17
|
+
QueueUrl: this.RETAIL_KYC_INBOUND_QUEUE_URL,
|
|
18
|
+
MessageBody: JSON.stringify(message),
|
|
19
|
+
};
|
|
20
|
+
const command = new SendMessageCommand(sendMessageRequest);
|
|
21
|
+
await client.send(command);
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
25
|
+
throw new Error(`Error publishing message to RetailKycInboundQueue: ${errorMessage}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
RetailKycInboundPublisher = __decorate([
|
|
30
|
+
injectable()
|
|
31
|
+
], RetailKycInboundPublisher);
|
|
32
|
+
export { RetailKycInboundPublisher };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { KycVerificationChangedV1 } from "@fiado/type-kit/bin/kyc/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Publisher del resultado del KYC hacia `RetailKycInboundQueue`, que consume
|
|
4
|
+
* `retail-wizard-business` (SureKeep F2).
|
|
5
|
+
*
|
|
6
|
+
* Lo produce `kyc-metamap-webhook` cuando una verificación pasa a COMPLETED. Vive acá —y no como
|
|
7
|
+
* SDK crudo en el webhook— porque la cola es COMPARTIDA cross-lambda: el estándar Fiado publica a una
|
|
8
|
+
* cola compartida vía Publisher de `@fiado/api-invoker` (mismo patrón que `ITransactionPublisher`).
|
|
9
|
+
*/
|
|
10
|
+
export interface IRetailKycInboundPublisher {
|
|
11
|
+
publish(message: KycVerificationChangedV1): Promise<void>;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fiado/api-invoker",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.1.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.
|
|
37
|
+
"@fiado/type-kit": "^3.210.0",
|
|
38
38
|
"dotenv": "^16.4.7"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
@@ -4,6 +4,7 @@ import { IHttpRequest } from "@fiado/http-client";
|
|
|
4
4
|
import { ICreditEngineApi } from "./interfaces/ICreditEngineApi.js";
|
|
5
5
|
import { CreditProfileResponse } from "@fiado/type-kit/bin/credit/dtos/internal/CreditProfileResponse.js";
|
|
6
6
|
import { CreditDetailResponse } from "@fiado/type-kit/bin/creditEngine/index.js";
|
|
7
|
+
type FiadoApiResponse<T> = import("@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse.js").default<T>;
|
|
7
8
|
dotenv.config();
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -24,20 +25,27 @@ export class CreditEngineApi implements ICreditEngineApi {
|
|
|
24
25
|
|
|
25
26
|
public async getCreditProfile(directoryId: string, partnerId: string): Promise<CreditProfileResponse> {
|
|
26
27
|
const url = `${this.baseUrl}credit/profile/${directoryId}`;
|
|
27
|
-
|
|
28
|
+
// El endpoint devuelve el envelope de `ApiResponse.createResponse`
|
|
29
|
+
// (`@fiado/gateway-adapter`): { code, date, data, description, msg }.
|
|
30
|
+
// Desenvolvemos acá para que el consumer reciba el objeto de dominio
|
|
31
|
+
// directo — ver docs/TECH_DEBT.md TD-002 en benefits-marketplace-business.
|
|
32
|
+
const envelope = await this.httpRequest.get<FiadoApiResponse<CreditProfileResponse>>(
|
|
28
33
|
url,
|
|
29
34
|
{ partnerId },
|
|
30
35
|
{ operationName: "getCreditProfile" },
|
|
31
36
|
);
|
|
37
|
+
return envelope.data;
|
|
32
38
|
}
|
|
33
39
|
|
|
34
40
|
public async getActiveCredit(directoryId: string): Promise<CreditDetailResponse | null> {
|
|
35
41
|
const url = `${this.baseUrl}credit/active/${directoryId}`;
|
|
36
|
-
|
|
42
|
+
// Mismo envelope que getCreditProfile — desenvolvemos `.data` acá.
|
|
43
|
+
const envelope = await this.httpRequest.get<FiadoApiResponse<CreditDetailResponse | null>>(
|
|
37
44
|
url,
|
|
38
45
|
undefined,
|
|
39
46
|
{ operationName: "getActiveCredit" },
|
|
40
47
|
);
|
|
48
|
+
return envelope.data;
|
|
41
49
|
}
|
|
42
50
|
|
|
43
51
|
public async enrichDirectories(directoryIds: string[]): Promise<any> {
|
|
@@ -18,6 +18,12 @@ export interface ICreditEngineApi {
|
|
|
18
18
|
* Obtiene el perfil financiero del directorio para un partner específico.
|
|
19
19
|
* Endpoint: `GET /credit/profile/{directoryId}?partnerId={partnerId}`
|
|
20
20
|
*
|
|
21
|
+
* El envelope HTTP (`{code, date, data, description, msg}` de
|
|
22
|
+
* `ApiResponse.createResponse`) se desenvuelve internamente — este método
|
|
23
|
+
* devuelve el objeto de dominio directo, el consumer NUNCA debe leer
|
|
24
|
+
* `.data` manualmente (ver docs/TECH_DEBT.md TD-002 en
|
|
25
|
+
* benefits-marketplace-business, resuelto en la raíz por este cambio).
|
|
26
|
+
*
|
|
21
27
|
* @param directoryId ID del directorio del usuario.
|
|
22
28
|
* @param partnerId ID del partner (tenant) del perfil a consultar.
|
|
23
29
|
*/
|
|
@@ -27,6 +33,9 @@ export interface ICreditEngineApi {
|
|
|
27
33
|
* Obtiene el crédito activo del cliente, si existe.
|
|
28
34
|
* Endpoint: `GET /credit/active/{directoryId}`
|
|
29
35
|
*
|
|
36
|
+
* El envelope HTTP se desenvuelve internamente (mismo criterio que
|
|
37
|
+
* `getCreditProfile`) — el consumer recibe el objeto de dominio directo.
|
|
38
|
+
*
|
|
30
39
|
* @param directoryId ID del directorio del usuario.
|
|
31
40
|
* @returns Detalle del crédito activo, o `null` si no hay crédito activo.
|
|
32
41
|
*/
|
package/src/kyc/index.ts
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { SendMessageCommand, SendMessageRequest, SQSClient } from "@aws-sdk/client-sqs";
|
|
2
|
+
import { injectable } from "inversify";
|
|
3
|
+
import { KycVerificationChangedV1 } from "@fiado/type-kit/bin/kyc/index.js";
|
|
4
|
+
import { IRetailKycInboundPublisher } from "./interfaces/IRetailKycInboundPublisher.js";
|
|
5
|
+
|
|
6
|
+
@injectable()
|
|
7
|
+
export class RetailKycInboundPublisher implements IRetailKycInboundPublisher {
|
|
8
|
+
private readonly RETAIL_KYC_INBOUND_QUEUE_URL = process.env.RETAIL_KYC_INBOUND_QUEUE_URL;
|
|
9
|
+
|
|
10
|
+
async publish(message: KycVerificationChangedV1): Promise<void> {
|
|
11
|
+
try {
|
|
12
|
+
const client: SQSClient = new SQSClient();
|
|
13
|
+
// Cola ESTÁNDAR (no FIFO): sin MessageGroupId/MessageDeduplicationId. La deduplicación
|
|
14
|
+
// la hace el consumidor con la llave de negocio (directoryId + verificationId + status + result).
|
|
15
|
+
const sendMessageRequest: SendMessageRequest = {
|
|
16
|
+
QueueUrl: this.RETAIL_KYC_INBOUND_QUEUE_URL,
|
|
17
|
+
MessageBody: JSON.stringify(message),
|
|
18
|
+
};
|
|
19
|
+
const command: SendMessageCommand = new SendMessageCommand(sendMessageRequest);
|
|
20
|
+
await client.send(command);
|
|
21
|
+
} catch (error) {
|
|
22
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
23
|
+
throw new Error(`Error publishing message to RetailKycInboundQueue: ${errorMessage}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { KycVerificationChangedV1 } from "@fiado/type-kit/bin/kyc/index.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Publisher del resultado del KYC hacia `RetailKycInboundQueue`, que consume
|
|
5
|
+
* `retail-wizard-business` (SureKeep F2).
|
|
6
|
+
*
|
|
7
|
+
* Lo produce `kyc-metamap-webhook` cuando una verificación pasa a COMPLETED. Vive acá —y no como
|
|
8
|
+
* SDK crudo en el webhook— porque la cola es COMPARTIDA cross-lambda: el estándar Fiado publica a una
|
|
9
|
+
* cola compartida vía Publisher de `@fiado/api-invoker` (mismo patrón que `ITransactionPublisher`).
|
|
10
|
+
*/
|
|
11
|
+
export interface IRetailKycInboundPublisher {
|
|
12
|
+
publish(message: KycVerificationChangedV1): Promise<void>;
|
|
13
|
+
}
|