@fiado/api-invoker 5.103.0 → 5.105.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,5 +1,5 @@
1
1
  import type { IHttpRequest } from "@fiado/http-client";
2
- import { CollectRequest, CollectResponse, DeregisterChargeResponse, RegisterCollectibleRequest, RegisterCollectibleResponse } from "@fiado/type-kit/bin/collection/index.js";
2
+ import { CollectRequest, CollectResponse, DeregisterChargeResponse, DisburseRequest, DisburseResponse, RegisterCollectibleRequest, RegisterCollectibleResponse } from "@fiado/type-kit/bin/collection/index.js";
3
3
  import { ICollectionEngineApi } from "./interfaces/ICollectionEngineApi.js";
4
4
  type FiadoApiResponse<T> = import("@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse.js").default<T>;
5
5
  /**
@@ -13,5 +13,6 @@ export default class CollectionEngineApi implements ICollectionEngineApi {
13
13
  registerCollectible(request: RegisterCollectibleRequest): Promise<FiadoApiResponse<RegisterCollectibleResponse>>;
14
14
  collect(request: CollectRequest): Promise<FiadoApiResponse<CollectResponse>>;
15
15
  deregister(domain: string, chargeId: string): Promise<FiadoApiResponse<DeregisterChargeResponse>>;
16
+ disburse(request: DisburseRequest): Promise<FiadoApiResponse<DisburseResponse>>;
16
17
  }
17
18
  export {};
@@ -37,6 +37,11 @@ let CollectionEngineApi = class CollectionEngineApi {
37
37
  + `/charges/${encodeURIComponent(chargeId)}/deregister`;
38
38
  return await this.httpRequest.post(url, {});
39
39
  }
40
+ async disburse(request) {
41
+ const url = `${this.baseUrl}collection/disburse`;
42
+ // Firma de http-client: post(url, data, headers, basicAuth, enableTimeout).
43
+ return await this.httpRequest.post(url, request, {}, undefined, true);
44
+ }
40
45
  };
41
46
  CollectionEngineApi = __decorate([
42
47
  injectable(),
@@ -1,4 +1,4 @@
1
- import { CollectRequest, CollectResponse, DeregisterChargeResponse, RegisterCollectibleRequest, RegisterCollectibleResponse } from "@fiado/type-kit/bin/collection/index.js";
1
+ import { CollectRequest, CollectResponse, DeregisterChargeResponse, DisburseRequest, DisburseResponse, RegisterCollectibleRequest, RegisterCollectibleResponse } from "@fiado/type-kit/bin/collection/index.js";
2
2
  type FiadoApiResponse<T> = import("@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse.js").default<T>;
3
3
  /**
4
4
  * Cliente para invocar los endpoints privados del lambda `collection-engine-business`.
@@ -46,5 +46,10 @@ export interface ICollectionEngineApi {
46
46
  * Backend: POST /collection/domains/{domain}/charges/{chargeId}/deregister (privado VPC).
47
47
  */
48
48
  deregister(domain: string, chargeId: string): Promise<FiadoApiResponse<DeregisterChargeResponse>>;
49
+ /**
50
+ * Dispersión síncrona: el motor deposita al titular y contesta si el dinero se movió.
51
+ * Backend: POST /collection/disburse (privado VPC), con timeout de cliente.
52
+ */
53
+ disburse(request: DisburseRequest): Promise<FiadoApiResponse<DisburseResponse>>;
49
54
  }
50
55
  export {};
@@ -67,6 +67,7 @@ import { DirectorySettingApi } from "./directorySetting/index.js";
67
67
  import { FirebaseConnectorApi } from "./firebase-connector/index.js";
68
68
  import OnboardingApi from "./onboarding/api/OnboardingApi.js";
69
69
  import OnboardingBusinessApi from "./onboarding-business/api/OnboardingBusinessApi.js";
70
+ import { ExpedienteUpdatedPublisher } from "./onboarding-business/index.js";
70
71
  import { PayrollApi } from "./payroll-business/index.js";
71
72
  import { ReferralBusinessApi } from "./referral-business/index.js";
72
73
  import { EventHistoryApi } from "./event-history-business/index.js";
@@ -198,6 +199,7 @@ export const apiInvokerBindings = new ContainerModule(({ bind }) => {
198
199
  bind("ICognitoV2Api").to(CognitoApi);
199
200
  bind("IZendeskApi").to(ZendeskApi);
200
201
  bind("IZendeskAlertsPublisher").to(ZendeskAlertsPublisher);
202
+ bind("IExpedienteUpdatedPublisher").to(ExpedienteUpdatedPublisher);
201
203
  bind("IBlackListApi").to(BlackListApi);
202
204
  bind("IDeviceApi").to(DeviceApi);
203
205
  bind("IObservationsApi").to(ObservationsApi);
@@ -1,2 +1,4 @@
1
1
  export * from './api/OnboardingBusinessApi.js';
2
2
  export * from './api/interfaces/IOnboardingBusinessApi.js';
3
+ export * from './queue/interfaces/IExpedienteUpdatedPublisher.js';
4
+ export * from './queue/ExpedienteUpdatedPublisher.js';
@@ -1,2 +1,4 @@
1
1
  export * from './api/OnboardingBusinessApi.js';
2
2
  export * from './api/interfaces/IOnboardingBusinessApi.js';
3
+ export * from './queue/interfaces/IExpedienteUpdatedPublisher.js';
4
+ export * from './queue/ExpedienteUpdatedPublisher.js';
@@ -0,0 +1,10 @@
1
+ import type { ExpedienteUpdatedSourceEnum } from "@fiado/type-kit/bin/onboarding/index.js";
2
+ import type { IExpedienteUpdatedPublisher } from "./interfaces/IExpedienteUpdatedPublisher.js";
3
+ /**
4
+ * Marcador fijo del log de fallo: la alarma de CloudWatch del productor filtra por este texto
5
+ * (mismo marcador que usa fiado-identity-lambda, TD-025 de onboarding-business).
6
+ */
7
+ export declare const EXPEDIENTE_PUBLISH_FAILED = "EXPEDIENTE_UPDATED publish failed";
8
+ export declare class ExpedienteUpdatedPublisher implements IExpedienteUpdatedPublisher {
9
+ publish(directoryId: string, peopleId: string, source: ExpedienteUpdatedSourceEnum): Promise<void>;
10
+ }
@@ -0,0 +1,43 @@
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 { randomUUID } from "node:crypto";
8
+ import { SendMessageCommand, SQSClient } from "@aws-sdk/client-sqs";
9
+ import { injectable } from "inversify";
10
+ import { log } from "@fiado/logger";
11
+ /**
12
+ * Marcador fijo del log de fallo: la alarma de CloudWatch del productor filtra por este texto
13
+ * (mismo marcador que usa fiado-identity-lambda, TD-025 de onboarding-business).
14
+ */
15
+ export const EXPEDIENTE_PUBLISH_FAILED = "EXPEDIENTE_UPDATED publish failed";
16
+ let ExpedienteUpdatedPublisher = class ExpedienteUpdatedPublisher {
17
+ async publish(directoryId, peopleId, source) {
18
+ try {
19
+ // Mensaje anémico a propósito: el consumidor SIEMPRE lee el expediente fresco.
20
+ const message = {
21
+ eventType: "EXPEDIENTE_UPDATED",
22
+ eventId: randomUUID(),
23
+ directoryId,
24
+ peopleId,
25
+ source,
26
+ occurredAt: new Date().toISOString(),
27
+ };
28
+ // Cola estándar: sin MessageGroupId. El evaluador del consumidor es idempotente.
29
+ await new SQSClient().send(new SendMessageCommand({
30
+ QueueUrl: process.env.ONBOARDING_READINESS_QUEUE_URL,
31
+ MessageBody: JSON.stringify(message),
32
+ }));
33
+ }
34
+ catch (error) {
35
+ const errorMessage = error instanceof Error ? error.message : String(error);
36
+ log.error(`${EXPEDIENTE_PUBLISH_FAILED}: ${errorMessage}`, { directoryId, peopleId, source });
37
+ }
38
+ }
39
+ };
40
+ ExpedienteUpdatedPublisher = __decorate([
41
+ injectable()
42
+ ], ExpedienteUpdatedPublisher);
43
+ export { ExpedienteUpdatedPublisher };
@@ -0,0 +1,14 @@
1
+ import type { ExpedienteUpdatedSourceEnum } from "@fiado/type-kit/bin/onboarding/index.js";
2
+ /**
3
+ * Publisher de EXPEDIENTE_UPDATED hacia OnboardingReadinessQueue (DEC-025), que consume
4
+ * onboarding-business para re-evaluar si algún lado del expediente ya cumple sus requisitos y
5
+ * disparar la emisión reactiva. Lo produce quien escribe el expediente (People / ARC / documentos):
6
+ * fiado-identity-lambda y, desde la migración del backoffice, people-business.
7
+ *
8
+ * El productor necesita `ONBOARDING_READINESS_QUEUE_URL` (`!ImportValue SqsOnboardingReadinessQueueUrl`)
9
+ * y `sqs:SendMessage` sobre `SqsOnboardingReadinessQueueArn`.
10
+ */
11
+ export interface IExpedienteUpdatedPublisher {
12
+ /** Fire-and-forget: JAMÁS lanza. Una falla de SQS no debe tumbar la escritura del expediente. */
13
+ publish(directoryId: string, peopleId: string, source: ExpedienteUpdatedSourceEnum): Promise<void>;
14
+ }
@@ -75,7 +75,8 @@ let TransactionProcessorApi = class TransactionProcessorApi {
75
75
  }
76
76
  async authorizeWelcomeBonus(request) {
77
77
  const url = `${this.baseUrl}bonus/authorize`;
78
- return await this.httpRequest.post(url, request);
78
+ // Firma de http-client: post(url, data, headers, basicAuth, enableTimeout).
79
+ return await this.httpRequest.post(url, request, {}, undefined, true);
79
80
  }
80
81
  };
81
82
  TransactionProcessorApi = __decorate([
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fiado/api-invoker",
3
- "version": "5.103.0",
3
+ "version": "5.105.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.486.0",
37
+ "@fiado/type-kit": "^3.487.0",
38
38
  "dotenv": "^16.4.7"
39
39
  },
40
40
  "peerDependencies": {
@@ -4,6 +4,8 @@ import {
4
4
  CollectRequest,
5
5
  CollectResponse,
6
6
  DeregisterChargeResponse,
7
+ DisburseRequest,
8
+ DisburseResponse,
7
9
  RegisterCollectibleRequest,
8
10
  RegisterCollectibleResponse,
9
11
  } from "@fiado/type-kit/bin/collection/index.js";
@@ -41,4 +43,10 @@ export default class CollectionEngineApi implements ICollectionEngineApi {
41
43
  + `/charges/${encodeURIComponent(chargeId)}/deregister`;
42
44
  return await this.httpRequest.post(url, {});
43
45
  }
46
+
47
+ async disburse(request: DisburseRequest): Promise<FiadoApiResponse<DisburseResponse>> {
48
+ const url = `${this.baseUrl}collection/disburse`;
49
+ // Firma de http-client: post(url, data, headers, basicAuth, enableTimeout).
50
+ return await this.httpRequest.post(url, request, {}, undefined, true);
51
+ }
44
52
  }
@@ -2,6 +2,8 @@ import {
2
2
  CollectRequest,
3
3
  CollectResponse,
4
4
  DeregisterChargeResponse,
5
+ DisburseRequest,
6
+ DisburseResponse,
5
7
  RegisterCollectibleRequest,
6
8
  RegisterCollectibleResponse,
7
9
  } from "@fiado/type-kit/bin/collection/index.js";
@@ -57,4 +59,10 @@ export interface ICollectionEngineApi {
57
59
  * Backend: POST /collection/domains/{domain}/charges/{chargeId}/deregister (privado VPC).
58
60
  */
59
61
  deregister(domain: string, chargeId: string): Promise<FiadoApiResponse<DeregisterChargeResponse>>;
62
+
63
+ /**
64
+ * Dispersión síncrona: el motor deposita al titular y contesta si el dinero se movió.
65
+ * Backend: POST /collection/disburse (privado VPC), con timeout de cliente.
66
+ */
67
+ disburse(request: DisburseRequest): Promise<FiadoApiResponse<DisburseResponse>>;
60
68
  }
@@ -98,7 +98,7 @@ import { FirebaseConnectorApi, IFirebaseConnectorApi } from "./firebase-connecto
98
98
  import { IOnboardingApi } from "./onboarding/index.js";
99
99
  import OnboardingApi from "./onboarding/api/OnboardingApi.js";
100
100
  import OnboardingBusinessApi from "./onboarding-business/api/OnboardingBusinessApi.js";
101
- import { IOnboardingBusinessApi } from "./onboarding-business/index.js";
101
+ import { IOnboardingBusinessApi, IExpedienteUpdatedPublisher, ExpedienteUpdatedPublisher } from "./onboarding-business/index.js";
102
102
  import { IPayrollApi, PayrollApi } from "./payroll-business/index.js";
103
103
  import { IReferralBusinessApi, ReferralBusinessApi } from "./referral-business/index.js";
104
104
  import { EventHistoryApi, IEventHistoryApi } from "./event-history-business/index.js";
@@ -271,6 +271,7 @@ export const apiInvokerBindings = new ContainerModule(({ bind }) => {
271
271
  bind<ICognitoV2Api>("ICognitoV2Api").to(CognitoApi);
272
272
  bind<IZendeskApi>("IZendeskApi").to(ZendeskApi);
273
273
  bind<IZendeskAlertsPublisher>("IZendeskAlertsPublisher").to(ZendeskAlertsPublisher);
274
+ bind<IExpedienteUpdatedPublisher>("IExpedienteUpdatedPublisher").to(ExpedienteUpdatedPublisher);
274
275
  bind<IBlackListApi>("IBlackListApi").to(BlackListApi);
275
276
  bind<IDeviceApi>("IDeviceApi").to(DeviceApi);
276
277
  bind<IObservationsApi>("IObservationsApi").to(ObservationsApi);
@@ -1,2 +1,4 @@
1
1
  export * from './api/OnboardingBusinessApi.js';
2
- export * from './api/interfaces/IOnboardingBusinessApi.js';
2
+ export * from './api/interfaces/IOnboardingBusinessApi.js';
3
+ export * from './queue/interfaces/IExpedienteUpdatedPublisher.js';
4
+ export * from './queue/ExpedienteUpdatedPublisher.js';
@@ -0,0 +1,38 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { SendMessageCommand, SQSClient } from "@aws-sdk/client-sqs";
3
+ import { injectable } from "inversify";
4
+ import { log } from "@fiado/logger";
5
+ import type { ExpedienteUpdatedMessage, ExpedienteUpdatedSourceEnum } from "@fiado/type-kit/bin/onboarding/index.js";
6
+ import type { IExpedienteUpdatedPublisher } from "./interfaces/IExpedienteUpdatedPublisher.js";
7
+
8
+ /**
9
+ * Marcador fijo del log de fallo: la alarma de CloudWatch del productor filtra por este texto
10
+ * (mismo marcador que usa fiado-identity-lambda, TD-025 de onboarding-business).
11
+ */
12
+ export const EXPEDIENTE_PUBLISH_FAILED = "EXPEDIENTE_UPDATED publish failed";
13
+
14
+ @injectable()
15
+ export class ExpedienteUpdatedPublisher implements IExpedienteUpdatedPublisher {
16
+
17
+ async publish(directoryId: string, peopleId: string, source: ExpedienteUpdatedSourceEnum): Promise<void> {
18
+ try {
19
+ // Mensaje anémico a propósito: el consumidor SIEMPRE lee el expediente fresco.
20
+ const message: ExpedienteUpdatedMessage = {
21
+ eventType: "EXPEDIENTE_UPDATED",
22
+ eventId: randomUUID(),
23
+ directoryId,
24
+ peopleId,
25
+ source,
26
+ occurredAt: new Date().toISOString(),
27
+ } as ExpedienteUpdatedMessage;
28
+ // Cola estándar: sin MessageGroupId. El evaluador del consumidor es idempotente.
29
+ await new SQSClient().send(new SendMessageCommand({
30
+ QueueUrl: process.env.ONBOARDING_READINESS_QUEUE_URL,
31
+ MessageBody: JSON.stringify(message),
32
+ }));
33
+ } catch (error) {
34
+ const errorMessage = error instanceof Error ? error.message : String(error);
35
+ log.error(`${EXPEDIENTE_PUBLISH_FAILED}: ${errorMessage}`, { directoryId, peopleId, source });
36
+ }
37
+ }
38
+ }
@@ -0,0 +1,15 @@
1
+ import type { ExpedienteUpdatedSourceEnum } from "@fiado/type-kit/bin/onboarding/index.js";
2
+
3
+ /**
4
+ * Publisher de EXPEDIENTE_UPDATED hacia OnboardingReadinessQueue (DEC-025), que consume
5
+ * onboarding-business para re-evaluar si algún lado del expediente ya cumple sus requisitos y
6
+ * disparar la emisión reactiva. Lo produce quien escribe el expediente (People / ARC / documentos):
7
+ * fiado-identity-lambda y, desde la migración del backoffice, people-business.
8
+ *
9
+ * El productor necesita `ONBOARDING_READINESS_QUEUE_URL` (`!ImportValue SqsOnboardingReadinessQueueUrl`)
10
+ * y `sqs:SendMessage` sobre `SqsOnboardingReadinessQueueArn`.
11
+ */
12
+ export interface IExpedienteUpdatedPublisher {
13
+ /** Fire-and-forget: JAMÁS lanza. Una falla de SQS no debe tumbar la escritura del expediente. */
14
+ publish(directoryId: string, peopleId: string, source: ExpedienteUpdatedSourceEnum): Promise<void>;
15
+ }
@@ -129,6 +129,7 @@ export default class TransactionProcessorApi implements ITransactionProcessorApi
129
129
  request: AuthorizeBonusRequest,
130
130
  ): Promise<FiadoApiResponse<TransactionProcessorResponse>> {
131
131
  const url = `${this.baseUrl}bonus/authorize`;
132
- return await this.httpRequest.post(url, request);
132
+ // Firma de http-client: post(url, data, headers, basicAuth, enableTimeout).
133
+ return await this.httpRequest.post(url, request, {}, undefined, true);
133
134
  }
134
135
  }