@fiado/api-invoker 5.103.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/package.json +1 -1
- 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/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 {};
|
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",
|
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
|
+
}
|