@fiado/api-invoker 5.102.0 → 5.104.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/container.config.js +2 -0
- package/bin/onboarding-business/index.d.ts +2 -0
- package/bin/onboarding-business/index.js +2 -0
- package/bin/onboarding-business/queue/ExpedienteUpdatedPublisher.d.ts +10 -0
- package/bin/onboarding-business/queue/ExpedienteUpdatedPublisher.js +43 -0
- package/bin/onboarding-business/queue/interfaces/IExpedienteUpdatedPublisher.d.ts +14 -0
- package/bin/onboarding-business/queue/interfaces/IExpedienteUpdatedPublisher.js +1 -0
- package/bin/retailCards/api/RetailCardsBusinessApi.d.ts +2 -1
- package/bin/retailCards/api/RetailCardsBusinessApi.js +4 -0
- package/bin/retailCards/api/interfaces/IRetailCardsBusinessApi.d.ts +3 -1
- package/package.json +2 -2
- package/src/container.config.ts +2 -1
- package/src/onboarding-business/index.ts +3 -1
- package/src/onboarding-business/queue/ExpedienteUpdatedPublisher.ts +38 -0
- package/src/onboarding-business/queue/interfaces/IExpedienteUpdatedPublisher.ts +15 -0
- package/src/retailCards/api/RetailCardsBusinessApi.ts +6 -0
- package/src/retailCards/api/interfaces/IRetailCardsBusinessApi.ts +4 -0
package/bin/container.config.js
CHANGED
|
@@ -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);
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IHttpRequest } from "@fiado/http-client";
|
|
2
2
|
import { StandardResponse } from "@fiado/gateway-adapter";
|
|
3
|
-
import { CardDeliveryResponse, RegisterCardDeliveryRequest, ReverseCardMovementRequest } from "@fiado/type-kit/bin/retailCards/index.js";
|
|
3
|
+
import { CardBalanceResponse, CardDeliveryResponse, RegisterCardDeliveryRequest, ReverseCardMovementRequest } from "@fiado/type-kit/bin/retailCards/index.js";
|
|
4
4
|
import { IRetailCardsBusinessApi } from "./interfaces/IRetailCardsBusinessApi.js";
|
|
5
5
|
/**
|
|
6
6
|
* Publisher HTTP del lambda `retail-cards-business` (SureKeep Fase 1, pista Retail) para sus endpoints
|
|
@@ -20,4 +20,5 @@ export default class RetailCardsBusinessApi implements IRetailCardsBusinessApi {
|
|
|
20
20
|
constructor(httpRequest: IHttpRequest);
|
|
21
21
|
registerDelivery(storeId: string, body: RegisterCardDeliveryRequest, tenantId: string): Promise<StandardResponse<CardDeliveryResponse>>;
|
|
22
22
|
reverseDelivery(storeId: string, body: ReverseCardMovementRequest, tenantId: string): Promise<StandardResponse<void>>;
|
|
23
|
+
getBalance(storeId: string, tenantId: string): Promise<StandardResponse<CardBalanceResponse>>;
|
|
23
24
|
}
|
|
@@ -38,6 +38,10 @@ let RetailCardsBusinessApi = class RetailCardsBusinessApi {
|
|
|
38
38
|
const url = `${this.baseUrl}/private/stores/${encodeURIComponent(storeId)}/card-movements/reverse?tenantId=${encodeURIComponent(tenantId)}`;
|
|
39
39
|
return await this.httpRequest.post(url, body);
|
|
40
40
|
}
|
|
41
|
+
async getBalance(storeId, tenantId) {
|
|
42
|
+
const url = `${this.baseUrl}/private/stores/${encodeURIComponent(storeId)}/card-balance?tenantId=${encodeURIComponent(tenantId)}`;
|
|
43
|
+
return await this.httpRequest.get(url);
|
|
44
|
+
}
|
|
41
45
|
};
|
|
42
46
|
RetailCardsBusinessApi = __decorate([
|
|
43
47
|
injectable(),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StandardResponse } from "@fiado/gateway-adapter";
|
|
2
|
-
import { CardDeliveryResponse, RegisterCardDeliveryRequest, ReverseCardMovementRequest } from "@fiado/type-kit/bin/retailCards/index.js";
|
|
2
|
+
import { CardBalanceResponse, CardDeliveryResponse, RegisterCardDeliveryRequest, ReverseCardMovementRequest } from "@fiado/type-kit/bin/retailCards/index.js";
|
|
3
3
|
/**
|
|
4
4
|
* Contrato del publisher HTTP del lambda `retail-cards-business` (SureKeep Fase 1, pista Retail) para
|
|
5
5
|
* sus endpoints privados del inventario de tarjetas físicas PCF, consumidos por el wizard F2 (paso 09).
|
|
@@ -34,4 +34,6 @@ export interface IRetailCardsBusinessApi {
|
|
|
34
34
|
* cancela (DEC-007 destino). Escribe un contraasiento, no borra el original.
|
|
35
35
|
*/
|
|
36
36
|
reverseDelivery(storeId: string, body: ReverseCardMovementRequest, tenantId: string): Promise<StandardResponse<void>>;
|
|
37
|
+
/** GET `/private/stores/{storeId}/card-balance` — tarjetas disponibles en la tienda; sin saldo, `available: 0`. */
|
|
38
|
+
getBalance(storeId: string, tenantId: string): Promise<StandardResponse<CardBalanceResponse>>;
|
|
37
39
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fiado/api-invoker",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.104.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.486.0",
|
|
38
38
|
"dotenv": "^16.4.7"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
package/src/container.config.ts
CHANGED
|
@@ -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
|
+
}
|
|
@@ -2,6 +2,7 @@ import { inject, injectable } from "inversify";
|
|
|
2
2
|
import type { IHttpRequest } from "@fiado/http-client";
|
|
3
3
|
import { StandardResponse } from "@fiado/gateway-adapter";
|
|
4
4
|
import {
|
|
5
|
+
CardBalanceResponse,
|
|
5
6
|
CardDeliveryResponse,
|
|
6
7
|
RegisterCardDeliveryRequest,
|
|
7
8
|
ReverseCardMovementRequest,
|
|
@@ -44,4 +45,9 @@ export default class RetailCardsBusinessApi implements IRetailCardsBusinessApi {
|
|
|
44
45
|
const url = `${this.baseUrl}/private/stores/${encodeURIComponent(storeId)}/card-movements/reverse?tenantId=${encodeURIComponent(tenantId)}`;
|
|
45
46
|
return await this.httpRequest.post(url, body);
|
|
46
47
|
}
|
|
48
|
+
|
|
49
|
+
async getBalance(storeId: string, tenantId: string): Promise<StandardResponse<CardBalanceResponse>> {
|
|
50
|
+
const url = `${this.baseUrl}/private/stores/${encodeURIComponent(storeId)}/card-balance?tenantId=${encodeURIComponent(tenantId)}`;
|
|
51
|
+
return await this.httpRequest.get(url);
|
|
52
|
+
}
|
|
47
53
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { StandardResponse } from "@fiado/gateway-adapter";
|
|
2
2
|
import {
|
|
3
|
+
CardBalanceResponse,
|
|
3
4
|
CardDeliveryResponse,
|
|
4
5
|
RegisterCardDeliveryRequest,
|
|
5
6
|
ReverseCardMovementRequest,
|
|
@@ -48,4 +49,7 @@ export interface IRetailCardsBusinessApi {
|
|
|
48
49
|
body: ReverseCardMovementRequest,
|
|
49
50
|
tenantId: string,
|
|
50
51
|
): Promise<StandardResponse<void>>;
|
|
52
|
+
|
|
53
|
+
/** GET `/private/stores/{storeId}/card-balance` — tarjetas disponibles en la tienda; sin saldo, `available: 0`. */
|
|
54
|
+
getBalance(storeId: string, tenantId: string): Promise<StandardResponse<CardBalanceResponse>>;
|
|
51
55
|
}
|