@fiado/api-invoker 5.53.0 → 5.55.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.
@@ -9,7 +9,7 @@ export default class AccountPagoConfiadoApi implements IAccountPagoConfiadoApi {
9
9
  constructor(httpRequest: IHttpRequest);
10
10
  cancelAccount(directoryId: string, accountNumber?: string, documentNumber?: string): Promise<ApiGatewayResponse<void>>;
11
11
  createAccount(provider: Provider, data: AccountCreateRequest): Promise<ApiGatewayResponse<AccountCreateResponse>>;
12
- getAccountByDirectoryId(directoryId: string): Promise<ApiGatewayResponse<GetAccountResponse[]>>;
12
+ getAccountByDirectoryId(directoryId: string): Promise<ApiGatewayResponse<GetAccountResponse>>;
13
13
  updateAccountBalance(accountId: string, params: AccountUpdateBalanceRequest): Promise<ApiGatewayResponse<Boolean>>;
14
14
  collectDebit(accountId: string, request: CollectDebitRequest): Promise<ApiGatewayResponse<CollectDebitResponse>>;
15
15
  update(directoryId: string, data: AccountUpdateRequest): Promise<ApiGatewayResponse<void>>;
@@ -3,7 +3,15 @@ import { ApiGatewayResponse } from "@fiado/gateway-adapter";
3
3
  import { Provider } from "@fiado/type-kit/bin/provider/index.js";
4
4
  export interface IAccountPagoConfiadoApi {
5
5
  createAccount(provider: Provider, data: AccountCreateRequest): Promise<ApiGatewayResponse<AccountCreateResponse>>;
6
- getAccountByDirectoryId(directoryId: string, provider: string): Promise<ApiGatewayResponse<GetAccountResponse[]>>;
6
+ /**
7
+ * La cuenta del titular. Devuelve UN objeto, no una lista: el lambda responde
8
+ * `ApiResponse.success({ data: account })`.
9
+ *
10
+ * Estuvo declarado como lista y no correspondia con lo que llega. Nadie lo noto porque sus
11
+ * consumidores lo leen sin tipar, pero el primero que confio en la declaracion escribio
12
+ * `data[0]` y su cobro reportaba como inexistente una cuenta que si estaba y tenia saldo.
13
+ */
14
+ getAccountByDirectoryId(directoryId: string, provider: string): Promise<ApiGatewayResponse<GetAccountResponse>>;
7
15
  updateAccountBalance(accountId: string, params: AccountUpdateBalanceRequest): Promise<ApiGatewayResponse<Boolean>>;
8
16
  /**
9
17
  * Debita el saldo disponible de la cuenta para cobrar una deuda, en una sola operación que lleva
@@ -1,9 +1,9 @@
1
1
  import type { IHttpRequest } from "@fiado/http-client";
2
2
  import { StandardResponse } from "@fiado/gateway-adapter";
3
- import { ConsumePromotionRequest, PromotedSkusResponse, ConsumePromotionResponse, CreditPlanResponse, FinancierResponse, SimulateCreditPlanRequest, SimulationResultResponse } from "@fiado/type-kit/bin/loanOfferings/index.js";
3
+ import { ConsumePromotionRequest, PromotedSkusResponse, ConsumePromotionResponse, CreditPlanResponse, FinancierResponse, ResolveCustomerSegmentsRequest, ResolveCustomerSegmentsResponse, SimulateCreditPlanRequest, SimulationResultResponse } from "@fiado/type-kit/bin/loanOfferings/index.js";
4
4
  import { ILoanOfferingsBusinessApi } from "./interfaces/ILoanOfferingsBusinessApi.js";
5
5
  /**
6
- * Publisher HTTP del lambda `loan-offerings-business` (componente 07 SureKeep Fase 1) para sus 5
6
+ * Publisher HTTP del lambda `loan-offerings-business` (componente 07 SureKeep Fase 1) para sus
7
7
  * endpoints privados. Contrato y semántica completos →
8
8
  * `ILoanOfferingsBusinessApi` (tenantId obligatorio, `StandardResponse` → leer `result.data`).
9
9
  *
@@ -24,4 +24,5 @@ export default class LoanOfferingsBusinessApi implements ILoanOfferingsBusinessA
24
24
  simulate(planId: string, input: SimulateCreditPlanRequest, tenantId: string): Promise<StandardResponse<SimulationResultResponse>>;
25
25
  consumePromotion(promotionId: string, input: ConsumePromotionRequest, tenantId: string): Promise<StandardResponse<ConsumePromotionResponse>>;
26
26
  listPromotedSkus(storeId: string, tenantId: string): Promise<StandardResponse<PromotedSkusResponse>>;
27
+ resolveCustomerSegments(input: ResolveCustomerSegmentsRequest, tenantId: string): Promise<StandardResponse<ResolveCustomerSegmentsResponse>>;
27
28
  }
@@ -12,7 +12,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
12
  };
13
13
  import { inject, injectable } from "inversify";
14
14
  /**
15
- * Publisher HTTP del lambda `loan-offerings-business` (componente 07 SureKeep Fase 1) para sus 5
15
+ * Publisher HTTP del lambda `loan-offerings-business` (componente 07 SureKeep Fase 1) para sus
16
16
  * endpoints privados. Contrato y semántica completos →
17
17
  * `ILoanOfferingsBusinessApi` (tenantId obligatorio, `StandardResponse` → leer `result.data`).
18
18
  *
@@ -54,6 +54,10 @@ let LoanOfferingsBusinessApi = class LoanOfferingsBusinessApi {
54
54
  const url = `${this.baseUrl}/private/promotions/promoted-skus?storeId=${encodeURIComponent(storeId)}&tenantId=${encodeURIComponent(tenantId)}`;
55
55
  return await this.httpRequest.get(url);
56
56
  }
57
+ async resolveCustomerSegments(input, tenantId) {
58
+ const url = `${this.baseUrl}/private/segments/resolve?tenantId=${encodeURIComponent(tenantId)}`;
59
+ return await this.httpRequest.post(url, input);
60
+ }
57
61
  };
58
62
  LoanOfferingsBusinessApi = __decorate([
59
63
  injectable(),
@@ -1,8 +1,8 @@
1
1
  import { StandardResponse } from "@fiado/gateway-adapter";
2
- import { ConsumePromotionRequest, PromotedSkusResponse, ConsumePromotionResponse, CreditPlanResponse, FinancierResponse, SimulateCreditPlanRequest, SimulationResultResponse } from "@fiado/type-kit/bin/loanOfferings/index.js";
2
+ import { ConsumePromotionRequest, PromotedSkusResponse, ConsumePromotionResponse, CreditPlanResponse, FinancierResponse, ResolveCustomerSegmentsRequest, ResolveCustomerSegmentsResponse, SimulateCreditPlanRequest, SimulationResultResponse } from "@fiado/type-kit/bin/loanOfferings/index.js";
3
3
  /**
4
4
  * Contrato del publisher HTTP del lambda `loan-offerings-business` (componente 07 SureKeep Fase 1)
5
- * para sus 5 endpoints privados service-to-service (VPC-only): 4 de LECTURA del catálogo SOFOM y
5
+ * para sus endpoints privados service-to-service (VPC-only): LECTURAS del catálogo SOFOM y
6
6
  * 1 de ESCRITURA que registra el consumo de una promoción.
7
7
  *
8
8
  * loan-offerings es el catálogo comercial del SOFOM: planes de crédito + financieras + la relación
@@ -11,7 +11,7 @@ import { ConsumePromotionRequest, PromotedSkusResponse, ConsumePromotionResponse
11
11
  * - motor de crédito (F3) → leer un plan · simular la cuota (amortización + IVA + CAT)
12
12
  *
13
13
  * ─────────────────────────────────────────────────────────────────────────────
14
- * `tenantId` es OBLIGATORIO en los 4 métodos — no es un detalle de firma.
14
+ * `tenantId` es OBLIGATORIO en todos los métodos — no es un detalle de firma.
15
15
  * ─────────────────────────────────────────────────────────────────────────────
16
16
  * Los privados NO llevan token de usuario (`Feature.ANONIMUS`; la protección es la red VPC), así que
17
17
  * el lambda destino no tiene `AuthContext.issuer` y NO puede inferir el silo. El caller declara el
@@ -83,4 +83,23 @@ export interface ILoanOfferingsBusinessApi {
83
83
  * el catálogo entero). El caller no puede aflojar ese criterio.
84
84
  */
85
85
  listPromotedSkus(storeId: string, tenantId: string): Promise<StandardResponse<PromotedSkusResponse>>;
86
+ /**
87
+ * POST /private/segments/resolve — los segmentos a los que pertenece el cliente HOY, evaluados
88
+ * en línea contra los hechos que manda el caller. No hay segmento persistido en el cliente.
89
+ *
90
+ * Los hechos los junta quien ya tiene al cliente delante; este lambda no sale a buscarlos a
91
+ * otro silo. Un hecho AUSENTE hace que su filtro NO se cumpla: sin el dato no se puede afirmar
92
+ * que el cliente califica, y de las dos salidas la segura es dejarlo fuera.
93
+ *
94
+ * `segmentIds` puede venir VACÍO y eso no es un error: significa que el cliente está en
95
+ * Estándar, el catch-all, que nunca se devuelve aquí.
96
+ *
97
+ * El resultado alimenta `customerSegmentIds` de {@link simulate}: sin él, las políticas de
98
+ * tienda acotadas a un segmento no aplican, y las que tienen compuerta encendida rechazan la
99
+ * venta con `422 STORE_POLICY_SCOPE_UNKNOWN`.
100
+ *
101
+ * @throws si el body no trae `retailCustomerId` o un hecho tiene el tipo equivocado
102
+ * (`400`), o si falta el tenant (`400 UNKNOWN_TENANT`).
103
+ */
104
+ resolveCustomerSegments(input: ResolveCustomerSegmentsRequest, tenantId: string): Promise<StandardResponse<ResolveCustomerSegmentsResponse>>;
86
105
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fiado/api-invoker",
3
- "version": "5.53.0",
3
+ "version": "5.55.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.381.0",
37
+ "@fiado/type-kit": "^3.382.0",
38
38
  "dotenv": "^16.4.7"
39
39
  },
40
40
  "peerDependencies": {
@@ -21,7 +21,7 @@ export default class AccountPagoConfiadoApi implements IAccountPagoConfiadoApi {
21
21
  return await this.httpRequest.post(url, data);
22
22
  }
23
23
 
24
- async getAccountByDirectoryId(directoryId: string): Promise<ApiGatewayResponse<GetAccountResponse[]>> {
24
+ async getAccountByDirectoryId(directoryId: string): Promise<ApiGatewayResponse<GetAccountResponse>> {
25
25
  const url = `${this.baseUrl}users/${directoryId}`;
26
26
  return await this.httpRequest.get(url);
27
27
  }
@@ -6,7 +6,15 @@ import { Provider } from "@fiado/type-kit/bin/provider/index.js";
6
6
  export interface IAccountPagoConfiadoApi {
7
7
  createAccount(provider: Provider, data: AccountCreateRequest): Promise<ApiGatewayResponse<AccountCreateResponse>>;
8
8
 
9
- getAccountByDirectoryId(directoryId: string, provider: string): Promise<ApiGatewayResponse<GetAccountResponse[]>>;
9
+ /**
10
+ * La cuenta del titular. Devuelve UN objeto, no una lista: el lambda responde
11
+ * `ApiResponse.success({ data: account })`.
12
+ *
13
+ * Estuvo declarado como lista y no correspondia con lo que llega. Nadie lo noto porque sus
14
+ * consumidores lo leen sin tipar, pero el primero que confio en la declaracion escribio
15
+ * `data[0]` y su cobro reportaba como inexistente una cuenta que si estaba y tenia saldo.
16
+ */
17
+ getAccountByDirectoryId(directoryId: string, provider: string): Promise<ApiGatewayResponse<GetAccountResponse>>;
10
18
 
11
19
  updateAccountBalance(accountId: string, params: AccountUpdateBalanceRequest): Promise<ApiGatewayResponse<Boolean>>;
12
20
 
@@ -7,13 +7,15 @@ import {
7
7
  ConsumePromotionResponse,
8
8
  CreditPlanResponse,
9
9
  FinancierResponse,
10
+ ResolveCustomerSegmentsRequest,
11
+ ResolveCustomerSegmentsResponse,
10
12
  SimulateCreditPlanRequest,
11
13
  SimulationResultResponse,
12
14
  } from "@fiado/type-kit/bin/loanOfferings/index.js";
13
15
  import { ILoanOfferingsBusinessApi } from "./interfaces/ILoanOfferingsBusinessApi.js";
14
16
 
15
17
  /**
16
- * Publisher HTTP del lambda `loan-offerings-business` (componente 07 SureKeep Fase 1) para sus 5
18
+ * Publisher HTTP del lambda `loan-offerings-business` (componente 07 SureKeep Fase 1) para sus
17
19
  * endpoints privados. Contrato y semántica completos →
18
20
  * `ILoanOfferingsBusinessApi` (tenantId obligatorio, `StandardResponse` → leer `result.data`).
19
21
  *
@@ -79,4 +81,12 @@ export default class LoanOfferingsBusinessApi implements ILoanOfferingsBusinessA
79
81
  const url = `${this.baseUrl}/private/promotions/promoted-skus?storeId=${encodeURIComponent(storeId)}&tenantId=${encodeURIComponent(tenantId)}`;
80
82
  return await this.httpRequest.get(url);
81
83
  }
84
+
85
+ async resolveCustomerSegments(
86
+ input: ResolveCustomerSegmentsRequest,
87
+ tenantId: string,
88
+ ): Promise<StandardResponse<ResolveCustomerSegmentsResponse>> {
89
+ const url = `${this.baseUrl}/private/segments/resolve?tenantId=${encodeURIComponent(tenantId)}`;
90
+ return await this.httpRequest.post(url, input);
91
+ }
82
92
  }
@@ -5,13 +5,15 @@ import {
5
5
  ConsumePromotionResponse,
6
6
  CreditPlanResponse,
7
7
  FinancierResponse,
8
+ ResolveCustomerSegmentsRequest,
9
+ ResolveCustomerSegmentsResponse,
8
10
  SimulateCreditPlanRequest,
9
11
  SimulationResultResponse,
10
12
  } from "@fiado/type-kit/bin/loanOfferings/index.js";
11
13
 
12
14
  /**
13
15
  * Contrato del publisher HTTP del lambda `loan-offerings-business` (componente 07 SureKeep Fase 1)
14
- * para sus 5 endpoints privados service-to-service (VPC-only): 4 de LECTURA del catálogo SOFOM y
16
+ * para sus endpoints privados service-to-service (VPC-only): LECTURAS del catálogo SOFOM y
15
17
  * 1 de ESCRITURA que registra el consumo de una promoción.
16
18
  *
17
19
  * loan-offerings es el catálogo comercial del SOFOM: planes de crédito + financieras + la relación
@@ -20,7 +22,7 @@ import {
20
22
  * - motor de crédito (F3) → leer un plan · simular la cuota (amortización + IVA + CAT)
21
23
  *
22
24
  * ─────────────────────────────────────────────────────────────────────────────
23
- * `tenantId` es OBLIGATORIO en los 4 métodos — no es un detalle de firma.
25
+ * `tenantId` es OBLIGATORIO en todos los métodos — no es un detalle de firma.
24
26
  * ─────────────────────────────────────────────────────────────────────────────
25
27
  * Los privados NO llevan token de usuario (`Feature.ANONIMUS`; la protección es la red VPC), así que
26
28
  * el lambda destino no tiene `AuthContext.issuer` y NO puede inferir el silo. El caller declara el
@@ -116,4 +118,27 @@ export interface ILoanOfferingsBusinessApi {
116
118
  storeId: string,
117
119
  tenantId: string,
118
120
  ): Promise<StandardResponse<PromotedSkusResponse>>;
121
+
122
+ /**
123
+ * POST /private/segments/resolve — los segmentos a los que pertenece el cliente HOY, evaluados
124
+ * en línea contra los hechos que manda el caller. No hay segmento persistido en el cliente.
125
+ *
126
+ * Los hechos los junta quien ya tiene al cliente delante; este lambda no sale a buscarlos a
127
+ * otro silo. Un hecho AUSENTE hace que su filtro NO se cumpla: sin el dato no se puede afirmar
128
+ * que el cliente califica, y de las dos salidas la segura es dejarlo fuera.
129
+ *
130
+ * `segmentIds` puede venir VACÍO y eso no es un error: significa que el cliente está en
131
+ * Estándar, el catch-all, que nunca se devuelve aquí.
132
+ *
133
+ * El resultado alimenta `customerSegmentIds` de {@link simulate}: sin él, las políticas de
134
+ * tienda acotadas a un segmento no aplican, y las que tienen compuerta encendida rechazan la
135
+ * venta con `422 STORE_POLICY_SCOPE_UNKNOWN`.
136
+ *
137
+ * @throws si el body no trae `retailCustomerId` o un hecho tiene el tipo equivocado
138
+ * (`400`), o si falta el tenant (`400 UNKNOWN_TENANT`).
139
+ */
140
+ resolveCustomerSegments(
141
+ input: ResolveCustomerSegmentsRequest,
142
+ tenantId: string,
143
+ ): Promise<StandardResponse<ResolveCustomerSegmentsResponse>>;
119
144
  }