@fiado/api-invoker 5.42.0 → 5.43.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/index.d.ts +1 -0
- package/bin/index.js +1 -0
- package/bin/loanCredit/api/dtos/LoanCreditAnalyticsBatch.d.ts +16 -3
- package/bin/loanCredit/api/interfaces/ILoanCreditBusinessApi.d.ts +4 -2
- package/bin/retailWizard/api/RetailWizardBusinessApi.d.ts +23 -0
- package/bin/retailWizard/api/RetailWizardBusinessApi.js +45 -0
- package/bin/retailWizard/api/interfaces/IRetailWizardBusinessApi.d.ts +58 -0
- package/bin/retailWizard/api/interfaces/IRetailWizardBusinessApi.js +1 -0
- package/bin/retailWizard/index.d.ts +2 -0
- package/bin/retailWizard/index.js +2 -0
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/loanCredit/api/dtos/LoanCreditAnalyticsBatch.ts +16 -3
- package/src/loanCredit/api/interfaces/ILoanCreditBusinessApi.ts +4 -2
- package/src/retailWizard/api/RetailWizardBusinessApi.ts +35 -0
- package/src/retailWizard/api/interfaces/IRetailWizardBusinessApi.ts +62 -0
- package/src/retailWizard/index.ts +2 -0
package/bin/index.d.ts
CHANGED
|
@@ -86,6 +86,7 @@ export * from "./retailCustomer/index.js";
|
|
|
86
86
|
export * from "./retailCatalog/index.js";
|
|
87
87
|
export * from "./retailCards/index.js";
|
|
88
88
|
export * from "./retailNotifications/index.js";
|
|
89
|
+
export * from "./retailWizard/index.js";
|
|
89
90
|
export * from "./shortlink/index.js";
|
|
90
91
|
export * from "./loanConfig/index.js";
|
|
91
92
|
export * from "./loanOfferings/index.js";
|
package/bin/index.js
CHANGED
|
@@ -86,6 +86,7 @@ export * from "./retailCustomer/index.js";
|
|
|
86
86
|
export * from "./retailCatalog/index.js";
|
|
87
87
|
export * from "./retailCards/index.js";
|
|
88
88
|
export * from "./retailNotifications/index.js";
|
|
89
|
+
export * from "./retailWizard/index.js";
|
|
89
90
|
export * from "./shortlink/index.js";
|
|
90
91
|
export * from "./loanConfig/index.js";
|
|
91
92
|
export * from "./loanOfferings/index.js";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { LoanCreditStatusEnum } from "@fiado/type-kit/bin/loanCredit/index.js";
|
|
1
|
+
import { LoanCreditStatusEnum, LoanInstallmentStatusEnum } from "@fiado/type-kit/bin/loanCredit/index.js";
|
|
2
2
|
import { ClientLevelEnum } from "@fiado/type-kit/bin/loanScoring/index.js";
|
|
3
3
|
/** Body de `POST /private/credits/analytics`. Hasta 500 ids por request; el caller pagina. */
|
|
4
4
|
export interface LoanCreditAnalyticsBatchRequest {
|
|
5
5
|
creditIds: string[];
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
|
-
* Lo mínimo de un crédito para contar: eje de riesgo, plan, cifras del enganche, estado y
|
|
9
|
-
* CERO PII — ni acreditado, ni nombre, ni teléfono.
|
|
8
|
+
* Lo mínimo de un crédito para contar: eje de riesgo, plan, cifras del enganche, estado, fechas y
|
|
9
|
+
* el estado de su primera cuota. CERO PII — ni acreditado, ni nombre, ni teléfono.
|
|
10
10
|
*/
|
|
11
11
|
export interface LoanCreditAnalyticsItem {
|
|
12
12
|
creditId: string;
|
|
@@ -19,7 +19,15 @@ export interface LoanCreditAnalyticsItem {
|
|
|
19
19
|
equipmentPriceCents: number;
|
|
20
20
|
downPaymentCents: number;
|
|
21
21
|
status: LoanCreditStatusEnum;
|
|
22
|
+
/** Instante de activación; ausente mientras el crédito no se activó. */
|
|
23
|
+
activatedAt?: string;
|
|
22
24
|
createdAt: string;
|
|
25
|
+
/** Estado de la cuota 1; ausente si el crédito no tiene plan o la cuota no se pudo leer. */
|
|
26
|
+
firstInstallmentStatus?: LoanInstallmentStatusEnum;
|
|
27
|
+
/** Vencimiento de la cuota 1 (YYYY-MM-DD); ausente hasta que se activa el crédito. */
|
|
28
|
+
firstInstallmentDueDate?: string;
|
|
29
|
+
/** Instante en que se pagó la cuota 1; ausente mientras no se pagó. */
|
|
30
|
+
firstInstallmentPaidAt?: string;
|
|
23
31
|
}
|
|
24
32
|
/**
|
|
25
33
|
* Los ids que no existen simplemente no vuelven; los que DynamoDB no alcanzó a leer salen
|
|
@@ -28,4 +36,9 @@ export interface LoanCreditAnalyticsItem {
|
|
|
28
36
|
export interface LoanCreditAnalyticsBatchResponse {
|
|
29
37
|
items: LoanCreditAnalyticsItem[];
|
|
30
38
|
unresolvedCreditIds: string[];
|
|
39
|
+
/**
|
|
40
|
+
* Créditos cuya PRIMERA CUOTA no se pudo leer; sus ítems vuelven sin los campos
|
|
41
|
+
* `firstInstallment*`. Opcional: las versiones desplegadas antes de la cosecha no lo mandan.
|
|
42
|
+
*/
|
|
43
|
+
unresolvedFirstInstallmentCreditIds?: string[];
|
|
31
44
|
}
|
|
@@ -59,11 +59,13 @@ export interface ILoanCreditBusinessApi {
|
|
|
59
59
|
getBorrowerByRetailCustomer(retailCustomerId: string, tenantId: string): Promise<StandardResponse<LoanBorrowerResponse>>;
|
|
60
60
|
/**
|
|
61
61
|
* Lee créditos EN LOTE por su id y devuelve solo lo que se cuenta: el eje de riesgo congelado
|
|
62
|
-
* al originar, el plan, las cifras del enganche, el estado
|
|
62
|
+
* al originar, el plan, las cifras del enganche, el estado, las fechas de originación y
|
|
63
|
+
* activación, y el estado de su PRIMERA cuota (la cosecha de primera cuota). **Cero PII.**
|
|
63
64
|
*
|
|
64
65
|
* Se resuelve por BatchGetItem sobre la clave primaria, así que el orden de salida NO es el de
|
|
65
66
|
* entrada. Un id que no existe no vuelve; uno que DynamoDB no alcanzó a leer vuelve nombrado en
|
|
66
|
-
* `unresolvedCreditIds` — nunca se confunde «no pude leerlo» con «no existe».
|
|
67
|
+
* `unresolvedCreditIds` — nunca se confunde «no pude leerlo» con «no existe». El crédito cuya
|
|
68
|
+
* cuota 1 no se pudo leer sale en `unresolvedFirstInstallmentCreditIds`, sin campos de cuota.
|
|
67
69
|
* `400 VALIDATION_ERROR` si el lote pasa de 500 ids o trae uno que no es ULID.
|
|
68
70
|
*/
|
|
69
71
|
batchGetCreditAnalytics(input: LoanCreditAnalyticsBatchRequest, tenantId: string): Promise<StandardResponse<LoanCreditAnalyticsBatchResponse>>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { IHttpRequest } from "@fiado/http-client";
|
|
2
|
+
import { StandardResponse } from "@fiado/gateway-adapter";
|
|
3
|
+
import { WizardSessionLookupResponse } from "@fiado/type-kit/bin/retailWizard/index.js";
|
|
4
|
+
import { IRetailWizardBusinessApi } from "./interfaces/IRetailWizardBusinessApi.js";
|
|
5
|
+
/**
|
|
6
|
+
* Publisher HTTP del lambda `retail-wizard-business` (componente 05 SureKeep Fase 2) para sus
|
|
7
|
+
* endpoints privados. Contrato y semantica completos -> `IRetailWizardBusinessApi`.
|
|
8
|
+
*
|
|
9
|
+
* Env var requerida en el consumer: `RETAIL_WIZARD_BUSINESS_URL`.
|
|
10
|
+
* El template.yml del consumer la setea con:
|
|
11
|
+
*
|
|
12
|
+
* RETAIL_WIZARD_BUSINESS_URL: '{{resolve:ssm:retail-wizard-business}}'
|
|
13
|
+
*/
|
|
14
|
+
export default class RetailWizardBusinessApi implements IRetailWizardBusinessApi {
|
|
15
|
+
private httpRequest;
|
|
16
|
+
private readonly baseUrl;
|
|
17
|
+
constructor(httpRequest: IHttpRequest);
|
|
18
|
+
/**
|
|
19
|
+
* Traduce un lote de `wizardSessionId` a tienda / cliente / equipo. Contrato completo (los cuatro
|
|
20
|
+
* estados, el techo de 100 y lo que NO devuelve) -> `IRetailWizardBusinessApi`.
|
|
21
|
+
*/
|
|
22
|
+
getWizardSessionsByIds(wizardSessionIds: string[], tenantId: string): Promise<StandardResponse<WizardSessionLookupResponse>>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
import { inject, injectable } from "inversify";
|
|
14
|
+
/**
|
|
15
|
+
* Publisher HTTP del lambda `retail-wizard-business` (componente 05 SureKeep Fase 2) para sus
|
|
16
|
+
* endpoints privados. Contrato y semantica completos -> `IRetailWizardBusinessApi`.
|
|
17
|
+
*
|
|
18
|
+
* Env var requerida en el consumer: `RETAIL_WIZARD_BUSINESS_URL`.
|
|
19
|
+
* El template.yml del consumer la setea con:
|
|
20
|
+
*
|
|
21
|
+
* RETAIL_WIZARD_BUSINESS_URL: '{{resolve:ssm:retail-wizard-business}}'
|
|
22
|
+
*/
|
|
23
|
+
let RetailWizardBusinessApi = class RetailWizardBusinessApi {
|
|
24
|
+
httpRequest;
|
|
25
|
+
baseUrl = process.env.RETAIL_WIZARD_BUSINESS_URL || "";
|
|
26
|
+
constructor(httpRequest) {
|
|
27
|
+
this.httpRequest = httpRequest;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Traduce un lote de `wizardSessionId` a tienda / cliente / equipo. Contrato completo (los cuatro
|
|
31
|
+
* estados, el techo de 100 y lo que NO devuelve) -> `IRetailWizardBusinessApi`.
|
|
32
|
+
*/
|
|
33
|
+
async getWizardSessionsByIds(wizardSessionIds, tenantId) {
|
|
34
|
+
// `URLSearchParams` codifica la coma del separador; el lambda destino hace `split(',')`
|
|
35
|
+
// sobre el valor ya decodificado por API Gateway.
|
|
36
|
+
const query = new URLSearchParams({ ids: wizardSessionIds.join(","), tenantId });
|
|
37
|
+
return await this.httpRequest.get(`${this.baseUrl}/private/wizard-sessions/batch?${query.toString()}`);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
RetailWizardBusinessApi = __decorate([
|
|
41
|
+
injectable(),
|
|
42
|
+
__param(0, inject("IHttpRequest")),
|
|
43
|
+
__metadata("design:paramtypes", [Object])
|
|
44
|
+
], RetailWizardBusinessApi);
|
|
45
|
+
export default RetailWizardBusinessApi;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { StandardResponse } from "@fiado/gateway-adapter";
|
|
2
|
+
import { WizardSessionLookupResponse } from "@fiado/type-kit/bin/retailWizard/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Contrato del publisher HTTP del lambda `retail-wizard-business` (componente 05 SureKeep Fase 2)
|
|
5
|
+
* para sus endpoints privados (service-to-service, VPC-only).
|
|
6
|
+
*
|
|
7
|
+
* Consumidor previsto: `loan-credit-business`, que guarda `wizardSessionId` en cada credito y sin
|
|
8
|
+
* esto no puede traducirlo a la tienda, el cliente ni el equipo de la venta (columnas de Cartera).
|
|
9
|
+
*
|
|
10
|
+
* ─────────────────────────────────────────────────────────────────────────────
|
|
11
|
+
* `tenantId` es OBLIGATORIO — no es un detalle de firma.
|
|
12
|
+
* ─────────────────────────────────────────────────────────────────────────────
|
|
13
|
+
* Los privados NO llevan token de usuario (`Feature.ANONIMUS`; la proteccion es la red VPC), asi que
|
|
14
|
+
* el lambda destino no tiene `AuthContext.issuer` y NO puede inferir el silo. El caller declara el
|
|
15
|
+
* tenant explicito por query. Sin `tenantId` -> `400 UNKNOWN_TENANT` (fail-closed). Nunca hay
|
|
16
|
+
* default: caer a un tenant seria fail-OPEN y podria devolver datos de otra SOFOM.
|
|
17
|
+
*
|
|
18
|
+
* ⚠️ Patron de retorno: `StandardResponse<T>` — el consumer accede `result.data`, NO `result.body`.
|
|
19
|
+
* `@fiado/http-client` entrega el BODY PELADO; `.statusCode`/`.body` no existen en runtime.
|
|
20
|
+
*
|
|
21
|
+
* Env var requerida en el consumer: `RETAIL_WIZARD_BUSINESS_URL`.
|
|
22
|
+
* El template.yml del consumer la setea con:
|
|
23
|
+
*
|
|
24
|
+
* RETAIL_WIZARD_BUSINESS_URL: '{{resolve:ssm:retail-wizard-business}}'
|
|
25
|
+
*
|
|
26
|
+
* Convencion CLAUDE.md global: SSM key = nombre del lambda owner de la URL.
|
|
27
|
+
*/
|
|
28
|
+
export interface IRetailWizardBusinessApi {
|
|
29
|
+
/**
|
|
30
|
+
* `GET /private/wizard-sessions/batch?ids=` — traduce un lote de `wizardSessionId` a la tienda,
|
|
31
|
+
* el cliente y el equipo de cada venta.
|
|
32
|
+
*
|
|
33
|
+
* ── 🔴 Por que el lote va por SESION y no por venta ──────────────────────────────────────────
|
|
34
|
+
* `<T>RetailSale_GT` tiene 5 GSIs y ninguno por `creditId` ni por `wizardSessionId`: entrar por
|
|
35
|
+
* la venta exigiria un indice nuevo (CloudFormation). La sesion se lee por su `pk` directo.
|
|
36
|
+
*
|
|
37
|
+
* ── El contrato del lote (identico a `GET /borrowers/portfolio`, DEC-010) ────────────────────
|
|
38
|
+
* Devuelve UNA entrada por cada id pedido, en el MISMO orden — el caller nunca reconcilia. Los
|
|
39
|
+
* ids repetidos se consultan una sola vez pero salen repetidos en la respuesta. Techo de 100 ids
|
|
40
|
+
* por request. Un fallo parcial NO tumba el lote: esa entrada sale `UNAVAILABLE` y el resto
|
|
41
|
+
* responde.
|
|
42
|
+
*
|
|
43
|
+
* Cuatro estados por entrada (`WizardSessionLookupStatusEnum`): `OK` se leyo completo ·
|
|
44
|
+
* `NOT_FOUND` no existe (dato POSITIVO) · `UNAVAILABLE` no se pudo leer, reintenta ese id ·
|
|
45
|
+
* `INVALID_ID` no tiene forma de id, nunca reintentar.
|
|
46
|
+
*
|
|
47
|
+
* ── ⚠️ Lo que este endpoint NO devuelve ──────────────────────────────────────────────────────
|
|
48
|
+
* NO trae el NOMBRE del cliente, ni el de la tienda, ni el del vendedor: la sesion del wizard no
|
|
49
|
+
* los guarda (solo ids). El caller los resuelve con `retail-customer` y `retail-org`. Tampoco
|
|
50
|
+
* viaja el telefono, que es PII. La marca y el modelo del equipo SI vienen: la sesion los congela
|
|
51
|
+
* al reservar.
|
|
52
|
+
*
|
|
53
|
+
* @throws `400 WIZARD_SESSION_IDS_REQUIRED` si `ids` viene vacio o ausente ·
|
|
54
|
+
* `400 WIZARD_SESSION_BATCH_TOO_LARGE` si supera los 100 ids ·
|
|
55
|
+
* `400 UNKNOWN_TENANT` sin `tenantId`.
|
|
56
|
+
*/
|
|
57
|
+
getWizardSessionsByIds(wizardSessionIds: string[], tenantId: string): Promise<StandardResponse<WizardSessionLookupResponse>>;
|
|
58
|
+
}
|
|
@@ -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.43.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/index.ts
CHANGED
|
@@ -86,6 +86,7 @@ export * from "./retailCustomer/index.js";
|
|
|
86
86
|
export * from "./retailCatalog/index.js";
|
|
87
87
|
export * from "./retailCards/index.js";
|
|
88
88
|
export * from "./retailNotifications/index.js";
|
|
89
|
+
export * from "./retailWizard/index.js";
|
|
89
90
|
export * from "./shortlink/index.js";
|
|
90
91
|
export * from "./loanConfig/index.js";
|
|
91
92
|
export * from "./loanOfferings/index.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LoanCreditStatusEnum } from "@fiado/type-kit/bin/loanCredit/index.js";
|
|
1
|
+
import { LoanCreditStatusEnum, LoanInstallmentStatusEnum } from "@fiado/type-kit/bin/loanCredit/index.js";
|
|
2
2
|
import { ClientLevelEnum } from "@fiado/type-kit/bin/loanScoring/index.js";
|
|
3
3
|
|
|
4
4
|
/** Body de `POST /private/credits/analytics`. Hasta 500 ids por request; el caller pagina. */
|
|
@@ -7,8 +7,8 @@ export interface LoanCreditAnalyticsBatchRequest {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* Lo mínimo de un crédito para contar: eje de riesgo, plan, cifras del enganche, estado y
|
|
11
|
-
* CERO PII — ni acreditado, ni nombre, ni teléfono.
|
|
10
|
+
* Lo mínimo de un crédito para contar: eje de riesgo, plan, cifras del enganche, estado, fechas y
|
|
11
|
+
* el estado de su primera cuota. CERO PII — ni acreditado, ni nombre, ni teléfono.
|
|
12
12
|
*/
|
|
13
13
|
export interface LoanCreditAnalyticsItem {
|
|
14
14
|
creditId: string;
|
|
@@ -21,7 +21,15 @@ export interface LoanCreditAnalyticsItem {
|
|
|
21
21
|
equipmentPriceCents: number;
|
|
22
22
|
downPaymentCents: number;
|
|
23
23
|
status: LoanCreditStatusEnum;
|
|
24
|
+
/** Instante de activación; ausente mientras el crédito no se activó. */
|
|
25
|
+
activatedAt?: string;
|
|
24
26
|
createdAt: string;
|
|
27
|
+
/** Estado de la cuota 1; ausente si el crédito no tiene plan o la cuota no se pudo leer. */
|
|
28
|
+
firstInstallmentStatus?: LoanInstallmentStatusEnum;
|
|
29
|
+
/** Vencimiento de la cuota 1 (YYYY-MM-DD); ausente hasta que se activa el crédito. */
|
|
30
|
+
firstInstallmentDueDate?: string;
|
|
31
|
+
/** Instante en que se pagó la cuota 1; ausente mientras no se pagó. */
|
|
32
|
+
firstInstallmentPaidAt?: string;
|
|
25
33
|
}
|
|
26
34
|
|
|
27
35
|
/**
|
|
@@ -31,4 +39,9 @@ export interface LoanCreditAnalyticsItem {
|
|
|
31
39
|
export interface LoanCreditAnalyticsBatchResponse {
|
|
32
40
|
items: LoanCreditAnalyticsItem[];
|
|
33
41
|
unresolvedCreditIds: string[];
|
|
42
|
+
/**
|
|
43
|
+
* Créditos cuya PRIMERA CUOTA no se pudo leer; sus ítems vuelven sin los campos
|
|
44
|
+
* `firstInstallment*`. Opcional: las versiones desplegadas antes de la cosecha no lo mandan.
|
|
45
|
+
*/
|
|
46
|
+
unresolvedFirstInstallmentCreditIds?: string[];
|
|
34
47
|
}
|
|
@@ -106,11 +106,13 @@ export interface ILoanCreditBusinessApi {
|
|
|
106
106
|
|
|
107
107
|
/**
|
|
108
108
|
* Lee créditos EN LOTE por su id y devuelve solo lo que se cuenta: el eje de riesgo congelado
|
|
109
|
-
* al originar, el plan, las cifras del enganche, el estado
|
|
109
|
+
* al originar, el plan, las cifras del enganche, el estado, las fechas de originación y
|
|
110
|
+
* activación, y el estado de su PRIMERA cuota (la cosecha de primera cuota). **Cero PII.**
|
|
110
111
|
*
|
|
111
112
|
* Se resuelve por BatchGetItem sobre la clave primaria, así que el orden de salida NO es el de
|
|
112
113
|
* entrada. Un id que no existe no vuelve; uno que DynamoDB no alcanzó a leer vuelve nombrado en
|
|
113
|
-
* `unresolvedCreditIds` — nunca se confunde «no pude leerlo» con «no existe».
|
|
114
|
+
* `unresolvedCreditIds` — nunca se confunde «no pude leerlo» con «no existe». El crédito cuya
|
|
115
|
+
* cuota 1 no se pudo leer sale en `unresolvedFirstInstallmentCreditIds`, sin campos de cuota.
|
|
114
116
|
* `400 VALIDATION_ERROR` si el lote pasa de 500 ids o trae uno que no es ULID.
|
|
115
117
|
*/
|
|
116
118
|
batchGetCreditAnalytics(
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { inject, injectable } from "inversify";
|
|
2
|
+
import type { IHttpRequest } from "@fiado/http-client";
|
|
3
|
+
import { StandardResponse } from "@fiado/gateway-adapter";
|
|
4
|
+
import { WizardSessionLookupResponse } from "@fiado/type-kit/bin/retailWizard/index.js";
|
|
5
|
+
import { IRetailWizardBusinessApi } from "./interfaces/IRetailWizardBusinessApi.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Publisher HTTP del lambda `retail-wizard-business` (componente 05 SureKeep Fase 2) para sus
|
|
9
|
+
* endpoints privados. Contrato y semantica completos -> `IRetailWizardBusinessApi`.
|
|
10
|
+
*
|
|
11
|
+
* Env var requerida en el consumer: `RETAIL_WIZARD_BUSINESS_URL`.
|
|
12
|
+
* El template.yml del consumer la setea con:
|
|
13
|
+
*
|
|
14
|
+
* RETAIL_WIZARD_BUSINESS_URL: '{{resolve:ssm:retail-wizard-business}}'
|
|
15
|
+
*/
|
|
16
|
+
@injectable()
|
|
17
|
+
export default class RetailWizardBusinessApi implements IRetailWizardBusinessApi {
|
|
18
|
+
private readonly baseUrl = process.env.RETAIL_WIZARD_BUSINESS_URL || "";
|
|
19
|
+
|
|
20
|
+
constructor(@inject("IHttpRequest") private httpRequest: IHttpRequest) {}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Traduce un lote de `wizardSessionId` a tienda / cliente / equipo. Contrato completo (los cuatro
|
|
24
|
+
* estados, el techo de 100 y lo que NO devuelve) -> `IRetailWizardBusinessApi`.
|
|
25
|
+
*/
|
|
26
|
+
async getWizardSessionsByIds(
|
|
27
|
+
wizardSessionIds: string[],
|
|
28
|
+
tenantId: string,
|
|
29
|
+
): Promise<StandardResponse<WizardSessionLookupResponse>> {
|
|
30
|
+
// `URLSearchParams` codifica la coma del separador; el lambda destino hace `split(',')`
|
|
31
|
+
// sobre el valor ya decodificado por API Gateway.
|
|
32
|
+
const query = new URLSearchParams({ ids: wizardSessionIds.join(","), tenantId });
|
|
33
|
+
return await this.httpRequest.get(`${this.baseUrl}/private/wizard-sessions/batch?${query.toString()}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { StandardResponse } from "@fiado/gateway-adapter";
|
|
2
|
+
import { WizardSessionLookupResponse } from "@fiado/type-kit/bin/retailWizard/index.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Contrato del publisher HTTP del lambda `retail-wizard-business` (componente 05 SureKeep Fase 2)
|
|
6
|
+
* para sus endpoints privados (service-to-service, VPC-only).
|
|
7
|
+
*
|
|
8
|
+
* Consumidor previsto: `loan-credit-business`, que guarda `wizardSessionId` en cada credito y sin
|
|
9
|
+
* esto no puede traducirlo a la tienda, el cliente ni el equipo de la venta (columnas de Cartera).
|
|
10
|
+
*
|
|
11
|
+
* ─────────────────────────────────────────────────────────────────────────────
|
|
12
|
+
* `tenantId` es OBLIGATORIO — no es un detalle de firma.
|
|
13
|
+
* ─────────────────────────────────────────────────────────────────────────────
|
|
14
|
+
* Los privados NO llevan token de usuario (`Feature.ANONIMUS`; la proteccion es la red VPC), asi que
|
|
15
|
+
* el lambda destino no tiene `AuthContext.issuer` y NO puede inferir el silo. El caller declara el
|
|
16
|
+
* tenant explicito por query. Sin `tenantId` -> `400 UNKNOWN_TENANT` (fail-closed). Nunca hay
|
|
17
|
+
* default: caer a un tenant seria fail-OPEN y podria devolver datos de otra SOFOM.
|
|
18
|
+
*
|
|
19
|
+
* ⚠️ Patron de retorno: `StandardResponse<T>` — el consumer accede `result.data`, NO `result.body`.
|
|
20
|
+
* `@fiado/http-client` entrega el BODY PELADO; `.statusCode`/`.body` no existen en runtime.
|
|
21
|
+
*
|
|
22
|
+
* Env var requerida en el consumer: `RETAIL_WIZARD_BUSINESS_URL`.
|
|
23
|
+
* El template.yml del consumer la setea con:
|
|
24
|
+
*
|
|
25
|
+
* RETAIL_WIZARD_BUSINESS_URL: '{{resolve:ssm:retail-wizard-business}}'
|
|
26
|
+
*
|
|
27
|
+
* Convencion CLAUDE.md global: SSM key = nombre del lambda owner de la URL.
|
|
28
|
+
*/
|
|
29
|
+
export interface IRetailWizardBusinessApi {
|
|
30
|
+
/**
|
|
31
|
+
* `GET /private/wizard-sessions/batch?ids=` — traduce un lote de `wizardSessionId` a la tienda,
|
|
32
|
+
* el cliente y el equipo de cada venta.
|
|
33
|
+
*
|
|
34
|
+
* ── 🔴 Por que el lote va por SESION y no por venta ──────────────────────────────────────────
|
|
35
|
+
* `<T>RetailSale_GT` tiene 5 GSIs y ninguno por `creditId` ni por `wizardSessionId`: entrar por
|
|
36
|
+
* la venta exigiria un indice nuevo (CloudFormation). La sesion se lee por su `pk` directo.
|
|
37
|
+
*
|
|
38
|
+
* ── El contrato del lote (identico a `GET /borrowers/portfolio`, DEC-010) ────────────────────
|
|
39
|
+
* Devuelve UNA entrada por cada id pedido, en el MISMO orden — el caller nunca reconcilia. Los
|
|
40
|
+
* ids repetidos se consultan una sola vez pero salen repetidos en la respuesta. Techo de 100 ids
|
|
41
|
+
* por request. Un fallo parcial NO tumba el lote: esa entrada sale `UNAVAILABLE` y el resto
|
|
42
|
+
* responde.
|
|
43
|
+
*
|
|
44
|
+
* Cuatro estados por entrada (`WizardSessionLookupStatusEnum`): `OK` se leyo completo ·
|
|
45
|
+
* `NOT_FOUND` no existe (dato POSITIVO) · `UNAVAILABLE` no se pudo leer, reintenta ese id ·
|
|
46
|
+
* `INVALID_ID` no tiene forma de id, nunca reintentar.
|
|
47
|
+
*
|
|
48
|
+
* ── ⚠️ Lo que este endpoint NO devuelve ──────────────────────────────────────────────────────
|
|
49
|
+
* NO trae el NOMBRE del cliente, ni el de la tienda, ni el del vendedor: la sesion del wizard no
|
|
50
|
+
* los guarda (solo ids). El caller los resuelve con `retail-customer` y `retail-org`. Tampoco
|
|
51
|
+
* viaja el telefono, que es PII. La marca y el modelo del equipo SI vienen: la sesion los congela
|
|
52
|
+
* al reservar.
|
|
53
|
+
*
|
|
54
|
+
* @throws `400 WIZARD_SESSION_IDS_REQUIRED` si `ids` viene vacio o ausente ·
|
|
55
|
+
* `400 WIZARD_SESSION_BATCH_TOO_LARGE` si supera los 100 ids ·
|
|
56
|
+
* `400 UNKNOWN_TENANT` sin `tenantId`.
|
|
57
|
+
*/
|
|
58
|
+
getWizardSessionsByIds(
|
|
59
|
+
wizardSessionIds: string[],
|
|
60
|
+
tenantId: string,
|
|
61
|
+
): Promise<StandardResponse<WizardSessionLookupResponse>>;
|
|
62
|
+
}
|