@fiado/api-invoker 5.20.0 → 5.22.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,6 +1,6 @@
1
1
  import type { IBiometricsBusinessApi } from "./interfaces/IBiometricsBusinessApi.js";
2
2
  import type { BiometricVerificationChangedV1, BiometricVerificationResponse, CreateBiometricVerificationRequest } from "@fiado/type-kit/bin/biometrics/index.js";
3
- import type { ApiGatewayResponse } from "@fiado/gateway-adapter";
3
+ import type { StandardResponse } from "@fiado/gateway-adapter";
4
4
  import type { IHttpRequest } from "@fiado/http-client";
5
5
  /**
6
6
  * Implementación del cliente de `biometrics-business`. Ver `IBiometricsBusinessApi` para el
@@ -21,9 +21,9 @@ export declare class BiometricsBusinessApi implements IBiometricsBusinessApi {
21
21
  */
22
22
  private readonly baseUrl;
23
23
  constructor(httpRequest: IHttpRequest);
24
- createBiometricVerification(data: CreateBiometricVerificationRequest): Promise<ApiGatewayResponse<BiometricVerificationResponse>>;
25
- getBiometricVerification(biometricVerificationId: string): Promise<ApiGatewayResponse<BiometricVerificationResponse>>;
26
- applyBiometricEvent(biometricVerificationId: string, data: BiometricVerificationChangedV1): Promise<ApiGatewayResponse<void>>;
24
+ createBiometricVerification(data: CreateBiometricVerificationRequest): Promise<StandardResponse<BiometricVerificationResponse>>;
25
+ getBiometricVerification(biometricVerificationId: string): Promise<StandardResponse<BiometricVerificationResponse>>;
26
+ applyBiometricEvent(biometricVerificationId: string, data: BiometricVerificationChangedV1): Promise<StandardResponse<void>>;
27
27
  }
28
28
  /**
29
29
  * También como default, por simetría con el resto de los clients del paquete.
@@ -1,5 +1,5 @@
1
1
  import type { BiometricVerificationChangedV1, BiometricVerificationResponse, CreateBiometricVerificationRequest } from "@fiado/type-kit/bin/biometrics/index.js";
2
- import type { ApiGatewayResponse } from "@fiado/gateway-adapter";
2
+ import type { StandardResponse } from "@fiado/gateway-adapter";
3
3
  /**
4
4
  * Cliente de `biometrics-business`, el master de la lógica biométrica de Fiado.
5
5
  *
@@ -26,7 +26,7 @@ export interface IBiometricsBusinessApi {
26
26
  * soportada). **`biometrics-business` NO degrada**: no sabe qué debe pasar en tu flujo si falla.
27
27
  * Esa política es tuya — el wizard, por ejemplo, degrada a KYC completo.
28
28
  */
29
- createBiometricVerification(data: CreateBiometricVerificationRequest): Promise<ApiGatewayResponse<BiometricVerificationResponse>>;
29
+ createBiometricVerification(data: CreateBiometricVerificationRequest): Promise<StandardResponse<BiometricVerificationResponse>>;
30
30
  /**
31
31
  * El estado actual de una verificación. Es el endpoint de polling.
32
32
  *
@@ -36,7 +36,7 @@ export interface IBiometricsBusinessApi {
36
36
  *
37
37
  * La expiración no depende de que llegue ningún evento: este `GET` la calcula y la persiste.
38
38
  */
39
- getBiometricVerification(biometricVerificationId: string): Promise<ApiGatewayResponse<BiometricVerificationResponse>>;
39
+ getBiometricVerification(biometricVerificationId: string): Promise<StandardResponse<BiometricVerificationResponse>>;
40
40
  /**
41
41
  * Avisa que el proveedor reportó algo sobre una verificación. **Su único caller legítimo es
42
42
  * `kyc-metamap-webhook`** — un producto normal no llama acá.
@@ -51,5 +51,5 @@ export interface IBiometricsBusinessApi {
51
51
  * - `5xx` → devolver no-200 al proveedor **para que reintente**. Esto es seguro SOLO en la rama
52
52
  * biométrica, que corta antes de escribir nada y no tiene efectos que duplicar.
53
53
  */
54
- applyBiometricEvent(biometricVerificationId: string, data: BiometricVerificationChangedV1): Promise<ApiGatewayResponse<void>>;
54
+ applyBiometricEvent(biometricVerificationId: string, data: BiometricVerificationChangedV1): Promise<StandardResponse<void>>;
55
55
  }
@@ -18,9 +18,14 @@ let ZendeskAlertsPublisher = class ZendeskAlertsPublisher {
18
18
  async publish(message) {
19
19
  try {
20
20
  const client = new SQSClient();
21
+ const queueUrl = this.ZENDESK_ALERTS_QUEUE;
22
+ // Condicional a la URL: la FIFO exige MessageGroupId y la estándar lo rechaza.
23
+ // Serializa por usuario; sin MessageDeduplicationId (la cola dedup por contenido).
24
+ const directoryId = message.payload?.directoryId;
21
25
  const sendMessageRequest = {
22
- QueueUrl: this.ZENDESK_ALERTS_QUEUE,
23
- MessageBody: JSON.stringify(message)
26
+ QueueUrl: queueUrl,
27
+ MessageBody: JSON.stringify(message),
28
+ ...(queueUrl?.endsWith(".fifo") && directoryId ? { MessageGroupId: directoryId } : {})
24
29
  };
25
30
  const command = new SendMessageCommand(sendMessageRequest);
26
31
  await client.send(command);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fiado/api-invoker",
3
- "version": "5.20.0",
3
+ "version": "5.22.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.276.0",
37
+ "@fiado/type-kit": "^3.278.0",
38
38
  "dotenv": "^16.4.7"
39
39
  },
40
40
  "peerDependencies": {
@@ -5,7 +5,7 @@ import type {
5
5
  BiometricVerificationResponse,
6
6
  CreateBiometricVerificationRequest,
7
7
  } from "@fiado/type-kit/bin/biometrics/index.js";
8
- import type { ApiGatewayResponse } from "@fiado/gateway-adapter";
8
+ import type { StandardResponse } from "@fiado/gateway-adapter";
9
9
  // ⚠️ `import type` y NO un import de valor. `@fiado/http-client` se publica como CJS; importar
10
10
  // `IHttpRequest` como valor hace que jest falle al cargar el módulo bajo ESM
11
11
  // ("does not provide an export named 'IHttpRequest'"). Con `import type` se borra al compilar.
@@ -35,14 +35,14 @@ export class BiometricsBusinessApi implements IBiometricsBusinessApi {
35
35
 
36
36
  async createBiometricVerification(
37
37
  data: CreateBiometricVerificationRequest,
38
- ): Promise<ApiGatewayResponse<BiometricVerificationResponse>> {
38
+ ): Promise<StandardResponse<BiometricVerificationResponse>> {
39
39
  const url = `${this.baseUrl}/biometric-verifications`;
40
40
  return await this.httpRequest.post(url, data);
41
41
  }
42
42
 
43
43
  async getBiometricVerification(
44
44
  biometricVerificationId: string,
45
- ): Promise<ApiGatewayResponse<BiometricVerificationResponse>> {
45
+ ): Promise<StandardResponse<BiometricVerificationResponse>> {
46
46
  // encodeURIComponent y no interpolación pelada: el id va en el path, y aunque hoy lo genera
47
47
  // biometrics-business, el día que un caller pase basura preferimos un 404 a una URL rota.
48
48
  const url = `${this.baseUrl}/biometric-verifications/${encodeURIComponent(biometricVerificationId)}`;
@@ -52,7 +52,7 @@ export class BiometricsBusinessApi implements IBiometricsBusinessApi {
52
52
  async applyBiometricEvent(
53
53
  biometricVerificationId: string,
54
54
  data: BiometricVerificationChangedV1,
55
- ): Promise<ApiGatewayResponse<void>> {
55
+ ): Promise<StandardResponse<void>> {
56
56
  const url = `${this.baseUrl}/biometric-verifications/${encodeURIComponent(biometricVerificationId)}/events`;
57
57
  return await this.httpRequest.post(url, data);
58
58
  }
@@ -3,7 +3,7 @@ import type {
3
3
  BiometricVerificationResponse,
4
4
  CreateBiometricVerificationRequest,
5
5
  } from "@fiado/type-kit/bin/biometrics/index.js";
6
- import type { ApiGatewayResponse } from "@fiado/gateway-adapter";
6
+ import type { StandardResponse } from "@fiado/gateway-adapter";
7
7
 
8
8
  /**
9
9
  * Cliente de `biometrics-business`, el master de la lógica biométrica de Fiado.
@@ -33,7 +33,7 @@ export interface IBiometricsBusinessApi {
33
33
  */
34
34
  createBiometricVerification(
35
35
  data: CreateBiometricVerificationRequest,
36
- ): Promise<ApiGatewayResponse<BiometricVerificationResponse>>;
36
+ ): Promise<StandardResponse<BiometricVerificationResponse>>;
37
37
 
38
38
  /**
39
39
  * El estado actual de una verificación. Es el endpoint de polling.
@@ -46,7 +46,7 @@ export interface IBiometricsBusinessApi {
46
46
  */
47
47
  getBiometricVerification(
48
48
  biometricVerificationId: string,
49
- ): Promise<ApiGatewayResponse<BiometricVerificationResponse>>;
49
+ ): Promise<StandardResponse<BiometricVerificationResponse>>;
50
50
 
51
51
  /**
52
52
  * Avisa que el proveedor reportó algo sobre una verificación. **Su único caller legítimo es
@@ -65,5 +65,5 @@ export interface IBiometricsBusinessApi {
65
65
  applyBiometricEvent(
66
66
  biometricVerificationId: string,
67
67
  data: BiometricVerificationChangedV1,
68
- ): Promise<ApiGatewayResponse<void>>;
68
+ ): Promise<StandardResponse<void>>;
69
69
  }
@@ -24,9 +24,14 @@ export default class ZendeskAlertsPublisher implements IZendeskAlertsPublisher {
24
24
  private async publish(message: IZendeskAlertMessage): Promise<void> {
25
25
  try {
26
26
  const client: SQSClient = new SQSClient();
27
+ const queueUrl = this.ZENDESK_ALERTS_QUEUE;
28
+ // Condicional a la URL: la FIFO exige MessageGroupId y la estándar lo rechaza.
29
+ // Serializa por usuario; sin MessageDeduplicationId (la cola dedup por contenido).
30
+ const directoryId = (message.payload as { directoryId?: string })?.directoryId;
27
31
  const sendMessageRequest: SendMessageRequest = {
28
- QueueUrl: this.ZENDESK_ALERTS_QUEUE,
29
- MessageBody: JSON.stringify(message)
32
+ QueueUrl: queueUrl,
33
+ MessageBody: JSON.stringify(message),
34
+ ...(queueUrl?.endsWith(".fifo") && directoryId ? { MessageGroupId: directoryId } : {})
30
35
  };
31
36
  const command: SendMessageCommand = new SendMessageCommand(sendMessageRequest);
32
37
  await client.send(command);