@fiado/api-invoker 4.63.0 → 4.65.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/loanConfig/api/LoanConfigBusinessApi.d.ts +27 -0
- package/bin/loanConfig/api/LoanConfigBusinessApi.js +52 -0
- package/bin/loanConfig/api/interfaces/ILoanConfigBusinessApi.d.ts +67 -0
- package/bin/loanConfig/api/interfaces/ILoanConfigBusinessApi.js +1 -0
- package/bin/loanConfig/index.d.ts +2 -0
- package/bin/loanConfig/index.js +2 -0
- package/bin/retailOrg/api/RetailOrgBusinessApi.d.ts +4 -3
- package/bin/retailOrg/api/RetailOrgBusinessApi.js +6 -2
- package/bin/retailOrg/api/interfaces/IRetailOrgBusinessApi.d.ts +20 -5
- package/package.json +2 -2
- package/src/index.ts +1 -0
- package/src/loanConfig/api/LoanConfigBusinessApi.ts +55 -0
- package/src/loanConfig/api/interfaces/ILoanConfigBusinessApi.ts +82 -0
- package/src/loanConfig/index.ts +2 -0
- package/src/retailOrg/api/RetailOrgBusinessApi.ts +11 -2
- package/src/retailOrg/api/interfaces/IRetailOrgBusinessApi.ts +24 -4
package/bin/index.d.ts
CHANGED
|
@@ -77,6 +77,7 @@ export * from "./milestone-business/index.js";
|
|
|
77
77
|
export * from "./cognitoBackofficeConnector/index.js";
|
|
78
78
|
export * from "./platformRbac/index.js";
|
|
79
79
|
export * from "./retailOrg/index.js";
|
|
80
|
+
export * from "./loanConfig/index.js";
|
|
80
81
|
export * from "./messages-business/index.js";
|
|
81
82
|
export * from "./totp-security/index.js";
|
|
82
83
|
export * from "./equality-connector/index.js";
|
package/bin/index.js
CHANGED
|
@@ -77,6 +77,7 @@ export * from "./milestone-business/index.js";
|
|
|
77
77
|
export * from "./cognitoBackofficeConnector/index.js";
|
|
78
78
|
export * from "./platformRbac/index.js";
|
|
79
79
|
export * from "./retailOrg/index.js";
|
|
80
|
+
export * from "./loanConfig/index.js";
|
|
80
81
|
export * from "./messages-business/index.js";
|
|
81
82
|
export * from "./totp-security/index.js";
|
|
82
83
|
export * from "./equality-connector/index.js";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { IHttpRequest } from "@fiado/http-client";
|
|
2
|
+
import { StandardResponse } from "@fiado/gateway-adapter";
|
|
3
|
+
import { BulkGetParametersResponse, ParameterKeyRef, ParameterResponse } from "@fiado/type-kit/bin/loanConfig/index.js";
|
|
4
|
+
import { ILoanConfigBusinessApi } from "./interfaces/ILoanConfigBusinessApi.js";
|
|
5
|
+
/**
|
|
6
|
+
* Publisher HTTP del lambda `loan-config-business` (componente 09 SureKeep Fase 1) para sus 3
|
|
7
|
+
* endpoints privados de lectura de parámetros. Contrato y semántica completos →
|
|
8
|
+
* `ILoanConfigBusinessApi` (tenantId obligatorio, cache 5 min del lado del consumer,
|
|
9
|
+
* `StandardResponse` → leer `result.data`).
|
|
10
|
+
*
|
|
11
|
+
* Env var requerida en el consumer: `LOAN_CONFIG_BUSINESS_URL`.
|
|
12
|
+
* El template.yml del consumer la setea con:
|
|
13
|
+
*
|
|
14
|
+
* LOAN_CONFIG_BUSINESS_URL: '{{resolve:ssm:loan-config-business}}'
|
|
15
|
+
*
|
|
16
|
+
* Convención CLAUDE.md global: SSM key = nombre del lambda owner de la URL.
|
|
17
|
+
*/
|
|
18
|
+
export default class LoanConfigBusinessApi implements ILoanConfigBusinessApi {
|
|
19
|
+
private httpRequest;
|
|
20
|
+
private readonly baseUrl;
|
|
21
|
+
constructor(httpRequest: IHttpRequest);
|
|
22
|
+
getParameter(paramType: string, key: string, tenantId: string): Promise<StandardResponse<ParameterResponse>>;
|
|
23
|
+
getParametersByType(paramType: string, tenantId: string): Promise<StandardResponse<{
|
|
24
|
+
parameters: ParameterResponse[];
|
|
25
|
+
}>>;
|
|
26
|
+
bulkGetParameters(items: ParameterKeyRef[], tenantId: string): Promise<StandardResponse<BulkGetParametersResponse>>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
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 `loan-config-business` (componente 09 SureKeep Fase 1) para sus 3
|
|
16
|
+
* endpoints privados de lectura de parámetros. Contrato y semántica completos →
|
|
17
|
+
* `ILoanConfigBusinessApi` (tenantId obligatorio, cache 5 min del lado del consumer,
|
|
18
|
+
* `StandardResponse` → leer `result.data`).
|
|
19
|
+
*
|
|
20
|
+
* Env var requerida en el consumer: `LOAN_CONFIG_BUSINESS_URL`.
|
|
21
|
+
* El template.yml del consumer la setea con:
|
|
22
|
+
*
|
|
23
|
+
* LOAN_CONFIG_BUSINESS_URL: '{{resolve:ssm:loan-config-business}}'
|
|
24
|
+
*
|
|
25
|
+
* Convención CLAUDE.md global: SSM key = nombre del lambda owner de la URL.
|
|
26
|
+
*/
|
|
27
|
+
let LoanConfigBusinessApi = class LoanConfigBusinessApi {
|
|
28
|
+
httpRequest;
|
|
29
|
+
// El buildspec publica la URL en SSM con "/" final — se normaliza para no armar "//private".
|
|
30
|
+
baseUrl = (process.env.LOAN_CONFIG_BUSINESS_URL || "").replace(/\/+$/, "");
|
|
31
|
+
constructor(httpRequest) {
|
|
32
|
+
this.httpRequest = httpRequest;
|
|
33
|
+
}
|
|
34
|
+
async getParameter(paramType, key, tenantId) {
|
|
35
|
+
const url = `${this.baseUrl}/private/parameters/${encodeURIComponent(paramType)}/${encodeURIComponent(key)}?tenantId=${encodeURIComponent(tenantId)}`;
|
|
36
|
+
return await this.httpRequest.get(url);
|
|
37
|
+
}
|
|
38
|
+
async getParametersByType(paramType, tenantId) {
|
|
39
|
+
const url = `${this.baseUrl}/private/parameters/by-type/${encodeURIComponent(paramType)}?tenantId=${encodeURIComponent(tenantId)}`;
|
|
40
|
+
return await this.httpRequest.get(url);
|
|
41
|
+
}
|
|
42
|
+
async bulkGetParameters(items, tenantId) {
|
|
43
|
+
const url = `${this.baseUrl}/private/parameters/bulk-get?tenantId=${encodeURIComponent(tenantId)}`;
|
|
44
|
+
return await this.httpRequest.post(url, { items });
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
LoanConfigBusinessApi = __decorate([
|
|
48
|
+
injectable(),
|
|
49
|
+
__param(0, inject("IHttpRequest")),
|
|
50
|
+
__metadata("design:paramtypes", [Object])
|
|
51
|
+
], LoanConfigBusinessApi);
|
|
52
|
+
export default LoanConfigBusinessApi;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { StandardResponse } from "@fiado/gateway-adapter";
|
|
2
|
+
import { BulkGetParametersResponse, ParameterKeyRef, ParameterResponse } from "@fiado/type-kit/bin/loanConfig/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Contrato del publisher HTTP del lambda `loan-config-business` (componente 09 SureKeep Fase 1)
|
|
5
|
+
* para sus 3 endpoints privados de LECTURA de parámetros operativos (service-to-service, VPC-only).
|
|
6
|
+
*
|
|
7
|
+
* loan-config es el "centro de configuración" del SOFOM: una tabla genérica de parámetros
|
|
8
|
+
* clave/valor discriminados por `paramType` (14 sub-tipos, M6_ADMIN §8). Consumidores previstos:
|
|
9
|
+
* - wizard de originación (F2) → WIZARD (OTP, KYC) · CREDIT (descarte, comisión)
|
|
10
|
+
* - motor de crédito (F3) → SCORING · CREDIT
|
|
11
|
+
* - cobranza / batch de mora → MORA_BLOCK · UNBLOCK · COLLECTIONS · NOTIFICATIONS
|
|
12
|
+
*
|
|
13
|
+
* ⏱️ El spec ordena cachear del lado del CONSUMER (~5 min en el warm container, configurable vía
|
|
14
|
+
* `CONFIG_CACHE_TTL_SECONDS`): los parámetros cambian poco y el hot path no debe pagar una llamada
|
|
15
|
+
* por lectura. `bulkGetParameters` es la forma eficiente de precargar el cache.
|
|
16
|
+
*
|
|
17
|
+
* ─────────────────────────────────────────────────────────────────────────────
|
|
18
|
+
* `tenantId` es OBLIGATORIO en los 3 métodos — no es un detalle de firma.
|
|
19
|
+
* ─────────────────────────────────────────────────────────────────────────────
|
|
20
|
+
* Los privados NO llevan token de usuario (`Feature.ANONIMUS`; la protección es la red VPC),
|
|
21
|
+
* así que el lambda destino no tiene `AuthContext.issuer` y NO puede inferir el silo. El caller
|
|
22
|
+
* declara el tenant explícito por query y `@fiado/tenant-context` asume el rol de ESE silo.
|
|
23
|
+
* Sin `tenantId` → `400 UNKNOWN_TENANT` (fail-closed). Nunca hay default: caer a un tenant por
|
|
24
|
+
* default sería fail-OPEN y podría devolver parámetros de otra SOFOM.
|
|
25
|
+
*
|
|
26
|
+
* ─────────────────────────────────────────────────────────────────────────────
|
|
27
|
+
* ⚠️ Patrón de retorno: `StandardResponse<T>` — el consumer accede `result.data`, NO `result.body`.
|
|
28
|
+
* ─────────────────────────────────────────────────────────────────────────────
|
|
29
|
+
* `@fiado/http-client` devuelve el body pelado (`response.data` de axios); los publishers viejos
|
|
30
|
+
* que tipan `{ statusCode, body }` son ficción del tipo (ver `IRetailOrgBusinessApi`, donde está
|
|
31
|
+
* documentado el 500 que costó descubrirlo). Los publishers nuevos dicen la verdad.
|
|
32
|
+
*
|
|
33
|
+
* Errores: el lambda destino lanza `DomainError` tipado → el publisher RECHAZA (no devuelve null).
|
|
34
|
+
* Cada consumer mapea a su propio error de dominio (ver `fiado-api-invoker § 6`):
|
|
35
|
+
* `404 PARAMETER_NOT_FOUND` (paramType+key inexistente)
|
|
36
|
+
* `400 UNKNOWN_TENANT` (tenantId ausente o desconocido)
|
|
37
|
+
*
|
|
38
|
+
* Env var requerida en el consumer: `LOAN_CONFIG_BUSINESS_URL`.
|
|
39
|
+
* El template.yml del consumer la setea con:
|
|
40
|
+
*
|
|
41
|
+
* LOAN_CONFIG_BUSINESS_URL: '{{resolve:ssm:loan-config-business}}'
|
|
42
|
+
*
|
|
43
|
+
* Convención CLAUDE.md global: SSM key = nombre del lambda owner de la URL.
|
|
44
|
+
*/
|
|
45
|
+
export interface ILoanConfigBusinessApi {
|
|
46
|
+
/**
|
|
47
|
+
* GET /private/parameters/{paramType}/{key} — un parámetro puntual. `data.effectiveValue` es el
|
|
48
|
+
* valor a usar (= `value`, o `defaultValue` cuando `value` es null/pendiente).
|
|
49
|
+
*
|
|
50
|
+
* @throws si el parámetro no existe (`404 PARAMETER_NOT_FOUND`).
|
|
51
|
+
*/
|
|
52
|
+
getParameter(paramType: string, key: string, tenantId: string): Promise<StandardResponse<ParameterResponse>>;
|
|
53
|
+
/**
|
|
54
|
+
* GET /private/parameters/by-type/{paramType} — todos los parámetros de una categoría (ej. toda
|
|
55
|
+
* la config de MORA_BLOCK de una vez). Devuelve `{ parameters: [] }` si la categoría está vacía
|
|
56
|
+
* (no 404): las 14 categorías del enum son válidas por definición.
|
|
57
|
+
*/
|
|
58
|
+
getParametersByType(paramType: string, tenantId: string): Promise<StandardResponse<{
|
|
59
|
+
parameters: ParameterResponse[];
|
|
60
|
+
}>>;
|
|
61
|
+
/**
|
|
62
|
+
* POST /private/parameters/bulk-get — el hot path: varios parámetros (de cualquier categoría) en
|
|
63
|
+
* UNA llamada. Los no existentes NO hacen fallar la llamada: vuelven en `data.notFound` y el
|
|
64
|
+
* consumer decide (típicamente: usar su default local o fallar tipado).
|
|
65
|
+
*/
|
|
66
|
+
bulkGetParameters(items: ParameterKeyRef[], tenantId: string): Promise<StandardResponse<BulkGetParametersResponse>>;
|
|
67
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { IHttpRequest } from "@fiado/http-client";
|
|
2
2
|
import { StandardResponse } from "@fiado/gateway-adapter";
|
|
3
|
-
import { RetailerValidationDto, StoreValidationDto, RetailUserValidationDto } from "@fiado/type-kit/bin/retailOrg/index.js";
|
|
3
|
+
import { RetailerValidationDto, StoreValidationDto, RetailUserValidationDto, CollectorValidationDto } from "@fiado/type-kit/bin/retailOrg/index.js";
|
|
4
4
|
import { IRetailOrgBusinessApi } from "./interfaces/IRetailOrgBusinessApi.js";
|
|
5
5
|
/**
|
|
6
|
-
* Publisher HTTP del lambda `retail-org-business` (componente 04 SureKeep Fase 1) para sus
|
|
6
|
+
* Publisher HTTP del lambda `retail-org-business` (componente 04 SureKeep Fase 1) para sus 6
|
|
7
7
|
* endpoints privados de validación. Contrato y semántica completos → `IRetailOrgBusinessApi`.
|
|
8
8
|
*
|
|
9
|
-
* Los
|
|
9
|
+
* Los paths y el `?tenantId=` fueron verificados contra dev (200 + negativos 400/404) el
|
|
10
10
|
* 2026-07-16 y matchean `openapi/private.yaml` del lambda destino.
|
|
11
11
|
*
|
|
12
12
|
* Env var requerida en el consumer: `RETAIL_ORG_BUSINESS_URL`.
|
|
@@ -25,4 +25,5 @@ export default class RetailOrgBusinessApi implements IRetailOrgBusinessApi {
|
|
|
25
25
|
getStore(retailerId: string, storeId: string, tenantId: string): Promise<StandardResponse<StoreValidationDto>>;
|
|
26
26
|
getStoreUsers(retailerId: string, storeId: string, tenantId: string): Promise<StandardResponse<RetailUserValidationDto[]>>;
|
|
27
27
|
getUserByCognitoSub(cognitoSub: string, tenantId: string): Promise<StandardResponse<RetailUserValidationDto>>;
|
|
28
|
+
listActiveCollectorsByRetailer(retailerId: string, tenantId: string): Promise<StandardResponse<CollectorValidationDto[]>>;
|
|
28
29
|
}
|
|
@@ -12,10 +12,10 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
12
12
|
};
|
|
13
13
|
import { inject, injectable } from "inversify";
|
|
14
14
|
/**
|
|
15
|
-
* Publisher HTTP del lambda `retail-org-business` (componente 04 SureKeep Fase 1) para sus
|
|
15
|
+
* Publisher HTTP del lambda `retail-org-business` (componente 04 SureKeep Fase 1) para sus 6
|
|
16
16
|
* endpoints privados de validación. Contrato y semántica completos → `IRetailOrgBusinessApi`.
|
|
17
17
|
*
|
|
18
|
-
* Los
|
|
18
|
+
* Los paths y el `?tenantId=` fueron verificados contra dev (200 + negativos 400/404) el
|
|
19
19
|
* 2026-07-16 y matchean `openapi/private.yaml` del lambda destino.
|
|
20
20
|
*
|
|
21
21
|
* Env var requerida en el consumer: `RETAIL_ORG_BUSINESS_URL`.
|
|
@@ -51,6 +51,10 @@ let RetailOrgBusinessApi = class RetailOrgBusinessApi {
|
|
|
51
51
|
const url = `${this.baseUrl}/private/users/by-cognito-sub/${encodeURIComponent(cognitoSub)}?tenantId=${encodeURIComponent(tenantId)}`;
|
|
52
52
|
return await this.httpRequest.get(url);
|
|
53
53
|
}
|
|
54
|
+
async listActiveCollectorsByRetailer(retailerId, tenantId) {
|
|
55
|
+
const url = `${this.baseUrl}/private/retailers/${encodeURIComponent(retailerId)}/collectors?tenantId=${encodeURIComponent(tenantId)}`;
|
|
56
|
+
return await this.httpRequest.get(url);
|
|
57
|
+
}
|
|
54
58
|
};
|
|
55
59
|
RetailOrgBusinessApi = __decorate([
|
|
56
60
|
injectable(),
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { StandardResponse } from "@fiado/gateway-adapter";
|
|
2
|
-
import { RetailerValidationDto, StoreValidationDto, RetailUserValidationDto } from "@fiado/type-kit/bin/retailOrg/index.js";
|
|
2
|
+
import { RetailerValidationDto, StoreValidationDto, RetailUserValidationDto, CollectorValidationDto } from "@fiado/type-kit/bin/retailOrg/index.js";
|
|
3
3
|
/**
|
|
4
4
|
* Contrato del publisher HTTP del lambda `retail-org-business` (componente 04 SureKeep Fase 1)
|
|
5
|
-
* para sus
|
|
5
|
+
* para sus 6 endpoints privados de VALIDACIÓN (service-to-service, VPC-only).
|
|
6
6
|
*
|
|
7
7
|
* Consumidores previstos (regla R5 — cruces entre lambdas son SOLO lecturas de validación;
|
|
8
8
|
* ningún lambda escribe en tabla ajena):
|
|
9
|
-
* - `retail-catalog-business`
|
|
10
|
-
* - `retail-cards-business`
|
|
11
|
-
* - `loan-*`
|
|
9
|
+
* - `retail-catalog-business` → valida `storeId` al registrar IMEIs
|
|
10
|
+
* - `retail-cards-business` → valida `storeId` de un lote de tarjetas PCF
|
|
11
|
+
* - `loan-*` → valida retailer / store / usuarios retail
|
|
12
|
+
* - `loan-collector-assignment-business` → lista cobradores ACTIVE del retailer para asignar cartera
|
|
12
13
|
*
|
|
13
14
|
* ─────────────────────────────────────────────────────────────────────────────
|
|
14
15
|
* `tenantId` es OBLIGATORIO en los 4 métodos — no es un detalle de firma.
|
|
@@ -87,4 +88,18 @@ export interface IRetailOrgBusinessApi {
|
|
|
87
88
|
* @throws si no hay usuario retail para ese sub (`404 RETAIL_USER_NOT_FOUND`).
|
|
88
89
|
*/
|
|
89
90
|
getUserByCognitoSub(cognitoSub: string, tenantId: string): Promise<StandardResponse<RetailUserValidationDto>>;
|
|
91
|
+
/**
|
|
92
|
+
* GET /private/retailers/{retailerId}/collectors — lista los COBRADORES del retailer que están
|
|
93
|
+
* `status=ACTIVE`. El criterio de "cobrador" lo aplica retail-org por `commissionTier === 'collector'`
|
|
94
|
+
* (el caller no lo declara). Lo consume `loan-collector-assignment-business` para alimentar su
|
|
95
|
+
* algoritmo de asignación de cartera.
|
|
96
|
+
*
|
|
97
|
+
* `tenantId` es OBLIGATORIO (igual que el resto de privados): sin él → `400 UNKNOWN_TENANT`
|
|
98
|
+
* (fail-closed). Nunca hay tenant por default — caer a uno sería fail-OPEN y podría filtrar
|
|
99
|
+
* cobradores de otra SOFOM.
|
|
100
|
+
*
|
|
101
|
+
* Devuelve el body PELADO en `StandardResponse<CollectorValidationDto[]>` (el consumer lee
|
|
102
|
+
* `result.data`, NO `result.body`). Retorna `[]` (no 404) si el retailer no tiene cobradores activos.
|
|
103
|
+
*/
|
|
104
|
+
listActiveCollectorsByRetailer(retailerId: string, tenantId: string): Promise<StandardResponse<CollectorValidationDto[]>>;
|
|
90
105
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fiado/api-invoker",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.65.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.191.0",
|
|
38
38
|
"dotenv": "^16.4.7"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
package/src/index.ts
CHANGED
|
@@ -77,6 +77,7 @@ export * from "./milestone-business/index.js";
|
|
|
77
77
|
export * from "./cognitoBackofficeConnector/index.js";
|
|
78
78
|
export * from "./platformRbac/index.js";
|
|
79
79
|
export * from "./retailOrg/index.js";
|
|
80
|
+
export * from "./loanConfig/index.js";
|
|
80
81
|
export * from "./messages-business/index.js";
|
|
81
82
|
export * from "./totp-security/index.js";
|
|
82
83
|
export * from "./equality-connector/index.js";
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { inject, injectable } from "inversify";
|
|
2
|
+
import type { IHttpRequest } from "@fiado/http-client";
|
|
3
|
+
import { StandardResponse } from "@fiado/gateway-adapter";
|
|
4
|
+
import {
|
|
5
|
+
BulkGetParametersResponse,
|
|
6
|
+
ParameterKeyRef,
|
|
7
|
+
ParameterResponse,
|
|
8
|
+
} from "@fiado/type-kit/bin/loanConfig/index.js";
|
|
9
|
+
import { ILoanConfigBusinessApi } from "./interfaces/ILoanConfigBusinessApi.js";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Publisher HTTP del lambda `loan-config-business` (componente 09 SureKeep Fase 1) para sus 3
|
|
13
|
+
* endpoints privados de lectura de parámetros. Contrato y semántica completos →
|
|
14
|
+
* `ILoanConfigBusinessApi` (tenantId obligatorio, cache 5 min del lado del consumer,
|
|
15
|
+
* `StandardResponse` → leer `result.data`).
|
|
16
|
+
*
|
|
17
|
+
* Env var requerida en el consumer: `LOAN_CONFIG_BUSINESS_URL`.
|
|
18
|
+
* El template.yml del consumer la setea con:
|
|
19
|
+
*
|
|
20
|
+
* LOAN_CONFIG_BUSINESS_URL: '{{resolve:ssm:loan-config-business}}'
|
|
21
|
+
*
|
|
22
|
+
* Convención CLAUDE.md global: SSM key = nombre del lambda owner de la URL.
|
|
23
|
+
*/
|
|
24
|
+
@injectable()
|
|
25
|
+
export default class LoanConfigBusinessApi implements ILoanConfigBusinessApi {
|
|
26
|
+
// El buildspec publica la URL en SSM con "/" final — se normaliza para no armar "//private".
|
|
27
|
+
private readonly baseUrl = (process.env.LOAN_CONFIG_BUSINESS_URL || "").replace(/\/+$/, "");
|
|
28
|
+
|
|
29
|
+
constructor(@inject("IHttpRequest") private httpRequest: IHttpRequest) {}
|
|
30
|
+
|
|
31
|
+
async getParameter(
|
|
32
|
+
paramType: string,
|
|
33
|
+
key: string,
|
|
34
|
+
tenantId: string,
|
|
35
|
+
): Promise<StandardResponse<ParameterResponse>> {
|
|
36
|
+
const url = `${this.baseUrl}/private/parameters/${encodeURIComponent(paramType)}/${encodeURIComponent(key)}?tenantId=${encodeURIComponent(tenantId)}`;
|
|
37
|
+
return await this.httpRequest.get(url);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async getParametersByType(
|
|
41
|
+
paramType: string,
|
|
42
|
+
tenantId: string,
|
|
43
|
+
): Promise<StandardResponse<{ parameters: ParameterResponse[] }>> {
|
|
44
|
+
const url = `${this.baseUrl}/private/parameters/by-type/${encodeURIComponent(paramType)}?tenantId=${encodeURIComponent(tenantId)}`;
|
|
45
|
+
return await this.httpRequest.get(url);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async bulkGetParameters(
|
|
49
|
+
items: ParameterKeyRef[],
|
|
50
|
+
tenantId: string,
|
|
51
|
+
): Promise<StandardResponse<BulkGetParametersResponse>> {
|
|
52
|
+
const url = `${this.baseUrl}/private/parameters/bulk-get?tenantId=${encodeURIComponent(tenantId)}`;
|
|
53
|
+
return await this.httpRequest.post(url, { items });
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { StandardResponse } from "@fiado/gateway-adapter";
|
|
2
|
+
import {
|
|
3
|
+
BulkGetParametersResponse,
|
|
4
|
+
ParameterKeyRef,
|
|
5
|
+
ParameterResponse,
|
|
6
|
+
} from "@fiado/type-kit/bin/loanConfig/index.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Contrato del publisher HTTP del lambda `loan-config-business` (componente 09 SureKeep Fase 1)
|
|
10
|
+
* para sus 3 endpoints privados de LECTURA de parámetros operativos (service-to-service, VPC-only).
|
|
11
|
+
*
|
|
12
|
+
* loan-config es el "centro de configuración" del SOFOM: una tabla genérica de parámetros
|
|
13
|
+
* clave/valor discriminados por `paramType` (14 sub-tipos, M6_ADMIN §8). Consumidores previstos:
|
|
14
|
+
* - wizard de originación (F2) → WIZARD (OTP, KYC) · CREDIT (descarte, comisión)
|
|
15
|
+
* - motor de crédito (F3) → SCORING · CREDIT
|
|
16
|
+
* - cobranza / batch de mora → MORA_BLOCK · UNBLOCK · COLLECTIONS · NOTIFICATIONS
|
|
17
|
+
*
|
|
18
|
+
* ⏱️ El spec ordena cachear del lado del CONSUMER (~5 min en el warm container, configurable vía
|
|
19
|
+
* `CONFIG_CACHE_TTL_SECONDS`): los parámetros cambian poco y el hot path no debe pagar una llamada
|
|
20
|
+
* por lectura. `bulkGetParameters` es la forma eficiente de precargar el cache.
|
|
21
|
+
*
|
|
22
|
+
* ─────────────────────────────────────────────────────────────────────────────
|
|
23
|
+
* `tenantId` es OBLIGATORIO en los 3 métodos — no es un detalle de firma.
|
|
24
|
+
* ─────────────────────────────────────────────────────────────────────────────
|
|
25
|
+
* Los privados NO llevan token de usuario (`Feature.ANONIMUS`; la protección es la red VPC),
|
|
26
|
+
* así que el lambda destino no tiene `AuthContext.issuer` y NO puede inferir el silo. El caller
|
|
27
|
+
* declara el tenant explícito por query y `@fiado/tenant-context` asume el rol de ESE silo.
|
|
28
|
+
* Sin `tenantId` → `400 UNKNOWN_TENANT` (fail-closed). Nunca hay default: caer a un tenant por
|
|
29
|
+
* default sería fail-OPEN y podría devolver parámetros de otra SOFOM.
|
|
30
|
+
*
|
|
31
|
+
* ─────────────────────────────────────────────────────────────────────────────
|
|
32
|
+
* ⚠️ Patrón de retorno: `StandardResponse<T>` — el consumer accede `result.data`, NO `result.body`.
|
|
33
|
+
* ─────────────────────────────────────────────────────────────────────────────
|
|
34
|
+
* `@fiado/http-client` devuelve el body pelado (`response.data` de axios); los publishers viejos
|
|
35
|
+
* que tipan `{ statusCode, body }` son ficción del tipo (ver `IRetailOrgBusinessApi`, donde está
|
|
36
|
+
* documentado el 500 que costó descubrirlo). Los publishers nuevos dicen la verdad.
|
|
37
|
+
*
|
|
38
|
+
* Errores: el lambda destino lanza `DomainError` tipado → el publisher RECHAZA (no devuelve null).
|
|
39
|
+
* Cada consumer mapea a su propio error de dominio (ver `fiado-api-invoker § 6`):
|
|
40
|
+
* `404 PARAMETER_NOT_FOUND` (paramType+key inexistente)
|
|
41
|
+
* `400 UNKNOWN_TENANT` (tenantId ausente o desconocido)
|
|
42
|
+
*
|
|
43
|
+
* Env var requerida en el consumer: `LOAN_CONFIG_BUSINESS_URL`.
|
|
44
|
+
* El template.yml del consumer la setea con:
|
|
45
|
+
*
|
|
46
|
+
* LOAN_CONFIG_BUSINESS_URL: '{{resolve:ssm:loan-config-business}}'
|
|
47
|
+
*
|
|
48
|
+
* Convención CLAUDE.md global: SSM key = nombre del lambda owner de la URL.
|
|
49
|
+
*/
|
|
50
|
+
export interface ILoanConfigBusinessApi {
|
|
51
|
+
/**
|
|
52
|
+
* GET /private/parameters/{paramType}/{key} — un parámetro puntual. `data.effectiveValue` es el
|
|
53
|
+
* valor a usar (= `value`, o `defaultValue` cuando `value` es null/pendiente).
|
|
54
|
+
*
|
|
55
|
+
* @throws si el parámetro no existe (`404 PARAMETER_NOT_FOUND`).
|
|
56
|
+
*/
|
|
57
|
+
getParameter(
|
|
58
|
+
paramType: string,
|
|
59
|
+
key: string,
|
|
60
|
+
tenantId: string,
|
|
61
|
+
): Promise<StandardResponse<ParameterResponse>>;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* GET /private/parameters/by-type/{paramType} — todos los parámetros de una categoría (ej. toda
|
|
65
|
+
* la config de MORA_BLOCK de una vez). Devuelve `{ parameters: [] }` si la categoría está vacía
|
|
66
|
+
* (no 404): las 14 categorías del enum son válidas por definición.
|
|
67
|
+
*/
|
|
68
|
+
getParametersByType(
|
|
69
|
+
paramType: string,
|
|
70
|
+
tenantId: string,
|
|
71
|
+
): Promise<StandardResponse<{ parameters: ParameterResponse[] }>>;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* POST /private/parameters/bulk-get — el hot path: varios parámetros (de cualquier categoría) en
|
|
75
|
+
* UNA llamada. Los no existentes NO hacen fallar la llamada: vuelven en `data.notFound` y el
|
|
76
|
+
* consumer decide (típicamente: usar su default local o fallar tipado).
|
|
77
|
+
*/
|
|
78
|
+
bulkGetParameters(
|
|
79
|
+
items: ParameterKeyRef[],
|
|
80
|
+
tenantId: string,
|
|
81
|
+
): Promise<StandardResponse<BulkGetParametersResponse>>;
|
|
82
|
+
}
|
|
@@ -5,14 +5,15 @@ import {
|
|
|
5
5
|
RetailerValidationDto,
|
|
6
6
|
StoreValidationDto,
|
|
7
7
|
RetailUserValidationDto,
|
|
8
|
+
CollectorValidationDto,
|
|
8
9
|
} from "@fiado/type-kit/bin/retailOrg/index.js";
|
|
9
10
|
import { IRetailOrgBusinessApi } from "./interfaces/IRetailOrgBusinessApi.js";
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
|
-
* Publisher HTTP del lambda `retail-org-business` (componente 04 SureKeep Fase 1) para sus
|
|
13
|
+
* Publisher HTTP del lambda `retail-org-business` (componente 04 SureKeep Fase 1) para sus 6
|
|
13
14
|
* endpoints privados de validación. Contrato y semántica completos → `IRetailOrgBusinessApi`.
|
|
14
15
|
*
|
|
15
|
-
* Los
|
|
16
|
+
* Los paths y el `?tenantId=` fueron verificados contra dev (200 + negativos 400/404) el
|
|
16
17
|
* 2026-07-16 y matchean `openapi/private.yaml` del lambda destino.
|
|
17
18
|
*
|
|
18
19
|
* Env var requerida en el consumer: `RETAIL_ORG_BUSINESS_URL`.
|
|
@@ -69,4 +70,12 @@ export default class RetailOrgBusinessApi implements IRetailOrgBusinessApi {
|
|
|
69
70
|
const url = `${this.baseUrl}/private/users/by-cognito-sub/${encodeURIComponent(cognitoSub)}?tenantId=${encodeURIComponent(tenantId)}`;
|
|
70
71
|
return await this.httpRequest.get(url);
|
|
71
72
|
}
|
|
73
|
+
|
|
74
|
+
async listActiveCollectorsByRetailer(
|
|
75
|
+
retailerId: string,
|
|
76
|
+
tenantId: string,
|
|
77
|
+
): Promise<StandardResponse<CollectorValidationDto[]>> {
|
|
78
|
+
const url = `${this.baseUrl}/private/retailers/${encodeURIComponent(retailerId)}/collectors?tenantId=${encodeURIComponent(tenantId)}`;
|
|
79
|
+
return await this.httpRequest.get(url);
|
|
80
|
+
}
|
|
72
81
|
}
|
|
@@ -3,17 +3,19 @@ import {
|
|
|
3
3
|
RetailerValidationDto,
|
|
4
4
|
StoreValidationDto,
|
|
5
5
|
RetailUserValidationDto,
|
|
6
|
+
CollectorValidationDto,
|
|
6
7
|
} from "@fiado/type-kit/bin/retailOrg/index.js";
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Contrato del publisher HTTP del lambda `retail-org-business` (componente 04 SureKeep Fase 1)
|
|
10
|
-
* para sus
|
|
11
|
+
* para sus 6 endpoints privados de VALIDACIÓN (service-to-service, VPC-only).
|
|
11
12
|
*
|
|
12
13
|
* Consumidores previstos (regla R5 — cruces entre lambdas son SOLO lecturas de validación;
|
|
13
14
|
* ningún lambda escribe en tabla ajena):
|
|
14
|
-
* - `retail-catalog-business`
|
|
15
|
-
* - `retail-cards-business`
|
|
16
|
-
* - `loan-*`
|
|
15
|
+
* - `retail-catalog-business` → valida `storeId` al registrar IMEIs
|
|
16
|
+
* - `retail-cards-business` → valida `storeId` de un lote de tarjetas PCF
|
|
17
|
+
* - `loan-*` → valida retailer / store / usuarios retail
|
|
18
|
+
* - `loan-collector-assignment-business` → lista cobradores ACTIVE del retailer para asignar cartera
|
|
17
19
|
*
|
|
18
20
|
* ─────────────────────────────────────────────────────────────────────────────
|
|
19
21
|
* `tenantId` es OBLIGATORIO en los 4 métodos — no es un detalle de firma.
|
|
@@ -113,4 +115,22 @@ export interface IRetailOrgBusinessApi {
|
|
|
113
115
|
cognitoSub: string,
|
|
114
116
|
tenantId: string,
|
|
115
117
|
): Promise<StandardResponse<RetailUserValidationDto>>;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* GET /private/retailers/{retailerId}/collectors — lista los COBRADORES del retailer que están
|
|
121
|
+
* `status=ACTIVE`. El criterio de "cobrador" lo aplica retail-org por `commissionTier === 'collector'`
|
|
122
|
+
* (el caller no lo declara). Lo consume `loan-collector-assignment-business` para alimentar su
|
|
123
|
+
* algoritmo de asignación de cartera.
|
|
124
|
+
*
|
|
125
|
+
* `tenantId` es OBLIGATORIO (igual que el resto de privados): sin él → `400 UNKNOWN_TENANT`
|
|
126
|
+
* (fail-closed). Nunca hay tenant por default — caer a uno sería fail-OPEN y podría filtrar
|
|
127
|
+
* cobradores de otra SOFOM.
|
|
128
|
+
*
|
|
129
|
+
* Devuelve el body PELADO en `StandardResponse<CollectorValidationDto[]>` (el consumer lee
|
|
130
|
+
* `result.data`, NO `result.body`). Retorna `[]` (no 404) si el retailer no tiene cobradores activos.
|
|
131
|
+
*/
|
|
132
|
+
listActiveCollectorsByRetailer(
|
|
133
|
+
retailerId: string,
|
|
134
|
+
tenantId: string,
|
|
135
|
+
): Promise<StandardResponse<CollectorValidationDto[]>>;
|
|
116
136
|
}
|