@fiado/api-invoker 5.112.0 → 5.114.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.
Files changed (29) hide show
  1. package/bin/index.d.ts +1 -0
  2. package/bin/index.js +1 -0
  3. package/bin/loanCredit/api/LoanCreditBusinessApi.d.ts +2 -0
  4. package/bin/loanCredit/api/LoanCreditBusinessApi.js +4 -0
  5. package/bin/loanCredit/api/dtos/CreditSummariesBatch.d.ts +11 -0
  6. package/bin/loanCredit/api/dtos/CreditSummariesBatch.js +1 -0
  7. package/bin/loanCredit/api/interfaces/ILoanCreditBusinessApi.d.ts +7 -0
  8. package/bin/loanCredit/index.d.ts +1 -0
  9. package/bin/loanCredit/index.js +1 -0
  10. package/bin/retailCommission/RetailCommissionBusinessApi.d.ts +12 -0
  11. package/bin/retailCommission/RetailCommissionBusinessApi.js +35 -0
  12. package/bin/retailCommission/index.d.ts +2 -0
  13. package/bin/retailCommission/index.js +2 -0
  14. package/bin/retailCommission/interfaces/IRetailCommissionBusinessApi.d.ts +16 -0
  15. package/bin/retailCommission/interfaces/IRetailCommissionBusinessApi.js +1 -0
  16. package/bin/retailOrg/api/RetailOrgBusinessApi.d.ts +4 -2
  17. package/bin/retailOrg/api/RetailOrgBusinessApi.js +11 -1
  18. package/bin/retailOrg/api/interfaces/IRetailOrgBusinessApi.d.ts +11 -2
  19. package/package.json +2 -2
  20. package/src/index.ts +1 -0
  21. package/src/loanCredit/api/LoanCreditBusinessApi.ts +12 -0
  22. package/src/loanCredit/api/dtos/CreditSummariesBatch.ts +14 -0
  23. package/src/loanCredit/api/interfaces/ILoanCreditBusinessApi.ts +14 -0
  24. package/src/loanCredit/index.ts +1 -0
  25. package/src/retailCommission/RetailCommissionBusinessApi.ts +25 -0
  26. package/src/retailCommission/index.ts +2 -0
  27. package/src/retailCommission/interfaces/IRetailCommissionBusinessApi.ts +20 -0
  28. package/src/retailOrg/api/RetailOrgBusinessApi.ts +17 -0
  29. package/src/retailOrg/api/interfaces/IRetailOrgBusinessApi.ts +18 -0
package/bin/index.d.ts CHANGED
@@ -90,6 +90,7 @@ export * from "./retailCards/index.js";
90
90
  export * from "./retailNotifications/index.js";
91
91
  export * from "./retailWizard/index.js";
92
92
  export * from "./retailPromotions/index.js";
93
+ export * from "./retailCommission/index.js";
93
94
  export * from "./retailIntegration/index.js";
94
95
  export * from "./shortlink/index.js";
95
96
  export * from "./loanConfig/index.js";
package/bin/index.js CHANGED
@@ -90,6 +90,7 @@ export * from "./retailCards/index.js";
90
90
  export * from "./retailNotifications/index.js";
91
91
  export * from "./retailWizard/index.js";
92
92
  export * from "./retailPromotions/index.js";
93
+ export * from "./retailCommission/index.js";
93
94
  export * from "./retailIntegration/index.js";
94
95
  export * from "./shortlink/index.js";
95
96
  export * from "./loanConfig/index.js";
@@ -1,6 +1,7 @@
1
1
  import type { IHttpRequest } from "@fiado/http-client";
2
2
  import { StandardResponse } from "@fiado/gateway-adapter";
3
3
  import { ActivationCheckRequest, ActivationCheckResponse, CreditPaymentAppliedRequest, CreditPaymentAppliedResponse, CreditSettledRequest, CreditSettledResponse, LoanBorrowerResponse, ListMessagingCandidatesRequest, ListMessagingCandidatesResponse, LoanCreditResponse, OriginateLoanCreditRequest, OriginateLoanCreditResponse, QuoteLoanCreditRequest, QuoteLoanCreditResponse, SignLoanCreditRequest, SignLoanCreditResponse, UpsertLoanBorrowerRequest, LoanBorrowerCreditItem, LoanContractDownloadUrl, LoanContractResponse, LoanCreditDetail, LoanInstallmentResponse, LoanPaymentListResponse, CreateCustomerPaymentRequest, LoanCustomerPaymentOptions, LoanCustomerPaymentResult } from "@fiado/type-kit/bin/loanCredit/index.js";
4
+ import { CreditSummariesBatchRequest, CreditSummariesBatchResponse } from "./dtos/CreditSummariesBatch.js";
4
5
  import { LoanCreditAnalyticsBatchRequest, LoanCreditAnalyticsBatchResponse } from "./dtos/LoanCreditAnalyticsBatch.js";
5
6
  import { CustomerCreditHistoryResponse } from "./dtos/CustomerCreditHistory.js";
6
7
  import { CreditLifecycleFactRequest, CreditLifecycleFactResponse } from "./dtos/CreditLifecycleFact.js";
@@ -32,6 +33,7 @@ export default class LoanCreditBusinessApi implements ILoanCreditBusinessApi {
32
33
  getBorrowerByRetailCustomer(retailCustomerId: string, tenantId: string): Promise<StandardResponse<LoanBorrowerResponse>>;
33
34
  getCustomerCreditHistory(retailCustomerId: string, tenantId: string): Promise<StandardResponse<CustomerCreditHistoryResponse>>;
34
35
  batchGetCreditAnalytics(input: LoanCreditAnalyticsBatchRequest, tenantId: string): Promise<StandardResponse<LoanCreditAnalyticsBatchResponse>>;
36
+ batchGetCreditSummaries(input: CreditSummariesBatchRequest, tenantId: string): Promise<StandardResponse<CreditSummariesBatchResponse>>;
35
37
  upsertBorrower(input: UpsertLoanBorrowerRequest, tenantId: string): Promise<StandardResponse<LoanBorrowerResponse>>;
36
38
  notifyLifecycleFact(creditId: string, input: CreditLifecycleFactRequest, tenantId: string): Promise<StandardResponse<CreditLifecycleFactResponse>>;
37
39
  listMessagingCandidates(input: ListMessagingCandidatesRequest, tenantId: string): Promise<StandardResponse<ListMessagingCandidatesResponse>>;
@@ -74,6 +74,10 @@ let LoanCreditBusinessApi = class LoanCreditBusinessApi {
74
74
  const url = `${this.baseUrl}/private/credits/analytics?tenantId=${encodeURIComponent(tenantId)}`;
75
75
  return await this.httpRequest.post(url, input);
76
76
  }
77
+ async batchGetCreditSummaries(input, tenantId) {
78
+ const url = `${this.baseUrl}/private/borrowers/credit-summaries?tenantId=${encodeURIComponent(tenantId)}`;
79
+ return await this.httpRequest.post(url, input);
80
+ }
77
81
  async upsertBorrower(input, tenantId) {
78
82
  const url = `${this.baseUrl}/private/borrowers?tenantId=${encodeURIComponent(tenantId)}`;
79
83
  return await this.httpRequest.post(url, input);
@@ -0,0 +1,11 @@
1
+ import type { CreditCustomerListItem } from "@fiado/type-kit/bin/loanCredit/index.js";
2
+ /** Body de `POST /private/borrowers/credit-summaries`. Hasta 100 ids por request; el caller pagina. */
3
+ export interface CreditSummariesBatchRequest {
4
+ retailCustomerIds: string[];
5
+ }
6
+ /** Bloque de crédito de un cliente retail, el mismo que pinta la tabla Clientes del backoffice. */
7
+ export type CreditSummaryItem = Pick<CreditCustomerListItem, "retailCustomerId" | "credit">;
8
+ /** Response de `POST /private/borrowers/credit-summaries`: un ítem por id pedido, en el mismo orden. */
9
+ export interface CreditSummariesBatchResponse {
10
+ items: CreditSummaryItem[];
11
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,5 +1,6 @@
1
1
  import { StandardResponse } from "@fiado/gateway-adapter";
2
2
  import { ActivationCheckRequest, CreditPaymentAppliedRequest, CreditPaymentAppliedResponse, CreditSettledRequest, CreditSettledResponse, ActivationCheckResponse, LoanBorrowerResponse, ListMessagingCandidatesRequest, ListMessagingCandidatesResponse, LoanCreditResponse, OriginateLoanCreditRequest, OriginateLoanCreditResponse, QuoteLoanCreditRequest, QuoteLoanCreditResponse, SignLoanCreditRequest, SignLoanCreditResponse, UpsertLoanBorrowerRequest, LoanBorrowerCreditItem, LoanContractDownloadUrl, LoanContractResponse, LoanCreditDetail, LoanInstallmentResponse, LoanPaymentListResponse, CreateCustomerPaymentRequest, LoanCustomerPaymentOptions, LoanCustomerPaymentResult } from "@fiado/type-kit/bin/loanCredit/index.js";
3
+ import { CreditSummariesBatchRequest, CreditSummariesBatchResponse } from "../dtos/CreditSummariesBatch.js";
3
4
  import { LoanCreditAnalyticsBatchRequest, LoanCreditAnalyticsBatchResponse } from "../dtos/LoanCreditAnalyticsBatch.js";
4
5
  import { CustomerCreditHistoryResponse } from "../dtos/CustomerCreditHistory.js";
5
6
  import { CreditLifecycleFactRequest, CreditLifecycleFactResponse } from "../dtos/CreditLifecycleFact.js";
@@ -91,6 +92,12 @@ export interface ILoanCreditBusinessApi {
91
92
  * `400 VALIDATION_ERROR` si el lote pasa de 500 ids o trae uno que no es ULID.
92
93
  */
93
94
  batchGetCreditAnalytics(input: LoanCreditAnalyticsBatchRequest, tenantId: string): Promise<StandardResponse<LoanCreditAnalyticsBatchResponse>>;
95
+ /**
96
+ * Bloque de crédito (nivel SK, conteos, saldo, mora) de hasta 100 clientes retail en lote. Un ítem
97
+ * por id pedido, en el mismo orden; `credit.state` distingue «sin acreditado» de «no se pudo leer».
98
+ * `400 VALIDATION_ERROR` si el lote viene vacío, repite ids o pasa de 100.
99
+ */
100
+ batchGetCreditSummaries(input: CreditSummariesBatchRequest, tenantId: string): Promise<StandardResponse<CreditSummariesBatchResponse>>;
94
101
  /**
95
102
  * Upsert idempotente del acreditado por `retailCustomerId` (mismo contrato que el consumidor
96
103
  * del evento `CustomerKycVerifiedV1` — fallback operativo mientras la cola no exista).
@@ -1,5 +1,6 @@
1
1
  export * from "./api/dtos/CreditLifecycleFact.js";
2
2
  export * from "./api/dtos/CustomerCreditHistory.js";
3
+ export * from "./api/dtos/CreditSummariesBatch.js";
3
4
  export * from "./api/dtos/LoanCreditAnalyticsBatch.js";
4
5
  export * from "./api/interfaces/ILoanCreditBusinessApi.js";
5
6
  export { default as LoanCreditBusinessApi } from "./api/LoanCreditBusinessApi.js";
@@ -1,5 +1,6 @@
1
1
  export * from "./api/dtos/CreditLifecycleFact.js";
2
2
  export * from "./api/dtos/CustomerCreditHistory.js";
3
+ export * from "./api/dtos/CreditSummariesBatch.js";
3
4
  export * from "./api/dtos/LoanCreditAnalyticsBatch.js";
4
5
  export * from "./api/interfaces/ILoanCreditBusinessApi.js";
5
6
  export { default as LoanCreditBusinessApi } from "./api/LoanCreditBusinessApi.js";
@@ -0,0 +1,12 @@
1
+ import type { IHttpRequest } from "@fiado/http-client";
2
+ import type { StandardResponse } from "@fiado/gateway-adapter";
3
+ import type { PrivateLatestClosedPayoutResponse } from "@fiado/type-kit/bin/retailCommission/index.js";
4
+ import type { IRetailCommissionBusinessApi } from "./interfaces/IRetailCommissionBusinessApi.js";
5
+ /** Publisher HTTP de `retail-commission-business`. Contrato → `IRetailCommissionBusinessApi`. */
6
+ export declare class RetailCommissionBusinessApi implements IRetailCommissionBusinessApi {
7
+ private readonly httpRequest;
8
+ constructor(httpRequest: IHttpRequest);
9
+ /** La URL del SSM termina en `/v1/`; se quita la barra final para no duplicarla. */
10
+ private get baseUrl();
11
+ getLatestClosedPayout(retailerId: string, tenantId: string): Promise<StandardResponse<PrivateLatestClosedPayoutResponse>>;
12
+ }
@@ -0,0 +1,35 @@
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
+ /** Publisher HTTP de `retail-commission-business`. Contrato → `IRetailCommissionBusinessApi`. */
15
+ let RetailCommissionBusinessApi = class RetailCommissionBusinessApi {
16
+ httpRequest;
17
+ constructor(httpRequest) {
18
+ this.httpRequest = httpRequest;
19
+ }
20
+ /** La URL del SSM termina en `/v1/`; se quita la barra final para no duplicarla. */
21
+ get baseUrl() {
22
+ return (process.env.RETAIL_COMMISSION_BUSINESS_URL || "").replace(/\/+$/, "");
23
+ }
24
+ async getLatestClosedPayout(retailerId, tenantId) {
25
+ const path = `/private/retailers/${encodeURIComponent(retailerId)}/payouts/latest-closed`;
26
+ const query = new URLSearchParams({ tenantId });
27
+ return await this.httpRequest.get(`${this.baseUrl}${path}?${query.toString()}`);
28
+ }
29
+ };
30
+ RetailCommissionBusinessApi = __decorate([
31
+ injectable(),
32
+ __param(0, inject("IHttpRequest")),
33
+ __metadata("design:paramtypes", [Object])
34
+ ], RetailCommissionBusinessApi);
35
+ export { RetailCommissionBusinessApi };
@@ -0,0 +1,2 @@
1
+ export * from "./interfaces/IRetailCommissionBusinessApi.js";
2
+ export * from "./RetailCommissionBusinessApi.js";
@@ -0,0 +1,2 @@
1
+ export * from "./interfaces/IRetailCommissionBusinessApi.js";
2
+ export * from "./RetailCommissionBusinessApi.js";
@@ -0,0 +1,16 @@
1
+ import type { StandardResponse } from "@fiado/gateway-adapter";
2
+ import type { PrivateLatestClosedPayoutResponse } from "@fiado/type-kit/bin/retailCommission/index.js";
3
+ /**
4
+ * Publisher de los endpoints privados de `retail-commission-business` (motor de comisiones de
5
+ * VentasLuga). No confundir con `commission-business`, que es otro servicio.
6
+ *
7
+ * Env var requerida en el consumer: `RETAIL_COMMISSION_BUSINESS_URL: '{{resolve:ssm:retail-commission-business}}'`.
8
+ * `tenantId` es obligatorio: los privados no llevan token y el silo lo declara el caller.
9
+ */
10
+ export interface IRetailCommissionBusinessApi {
11
+ /**
12
+ * `GET /private/retailers/{retailerId}/payouts/latest-closed` — el último corte semanal CERRADO
13
+ * de la cadena, con lo que le pagó a cada vendedor. Sin corte cerrado reciente: `period: null`.
14
+ */
15
+ getLatestClosedPayout(retailerId: string, tenantId: string): Promise<StandardResponse<PrivateLatestClosedPayoutResponse>>;
16
+ }
@@ -1,6 +1,6 @@
1
1
  import type { IHttpRequest } from "@fiado/http-client";
2
2
  import { StandardResponse } from "@fiado/gateway-adapter";
3
- import { RetailerValidationDto, StoreValidationDto, RetailUserValidationDto, CollectorValidationDto, PrivateSellerListResponse, RetailUserStatusEnum } from "@fiado/type-kit/bin/retailOrg/index.js";
3
+ import { RetailerValidationDto, StoreValidationDto, RetailUserValidationDto, CollectorValidationDto, PrivateSellerListResponse, PrivateGoalListResponse, GoalTargetTypeEnum, RetailUserStatusEnum } from "@fiado/type-kit/bin/retailOrg/index.js";
4
4
  import type { ApplyRetailUserEventRequest, ApplyRetailUserEventResponse, ApplyStoreEventRequest, ApplyStoreEventResponse } from "@fiado/type-kit/bin/retailIntegration/index.js";
5
5
  import { IRetailOrgBusinessApi, RetailerRosterStatusFilter, StoreRosterStatusFilter } from "./interfaces/IRetailOrgBusinessApi.js";
6
6
  /**
@@ -49,7 +49,9 @@ export default class RetailOrgBusinessApi implements IRetailOrgBusinessApi {
49
49
  * ⚠️ Es el único método de este publisher con el `retailerId` en el QUERY y no anidado en el
50
50
  * path: el caller no está validando un recurso, está pidiendo una colección entera.
51
51
  */
52
- listSellers(retailerId: string, tenantId: string, callerService: string, status?: RetailUserStatusEnum): Promise<StandardResponse<PrivateSellerListResponse>>;
52
+ listSellers(retailerId: string, tenantId: string, callerService: string, status?: RetailUserStatusEnum, includePhone?: boolean): Promise<StandardResponse<PrivateSellerListResponse>>;
53
+ /** Metas del periodo de una cadena. Contrato → `IRetailOrgBusinessApi.listGoals`. */
54
+ listGoals(retailerId: string, tenantId: string, periodId: string, targetType?: GoalTargetTypeEnum): Promise<StandardResponse<PrivateGoalListResponse>>;
53
55
  privateApplyStoreEvent(request: ApplyStoreEventRequest): Promise<StandardResponse<ApplyStoreEventResponse>>;
54
56
  privateApplyRetailUserEvent(request: ApplyRetailUserEventRequest): Promise<StandardResponse<ApplyRetailUserEventResponse>>;
55
57
  private applyRetailEvent;
@@ -92,14 +92,24 @@ let RetailOrgBusinessApi = class RetailOrgBusinessApi {
92
92
  * ⚠️ Es el único método de este publisher con el `retailerId` en el QUERY y no anidado en el
93
93
  * path: el caller no está validando un recurso, está pidiendo una colección entera.
94
94
  */
95
- async listSellers(retailerId, tenantId, callerService, status) {
95
+ async listSellers(retailerId, tenantId, callerService, status, includePhone) {
96
96
  // `URLSearchParams` en vez de concatenar: `status` es opcional y armar el `&status=` a mano
97
97
  // deja un `&status=undefined` en cuanto alguien se distrae.
98
98
  const query = new URLSearchParams({ retailerId, tenantId, callerService });
99
99
  if (status)
100
100
  query.set("status", status);
101
+ if (includePhone)
102
+ query.set("includePhone", "true");
101
103
  return await this.httpRequest.get(`${this.baseUrl}/private/sellers?${query.toString()}`);
102
104
  }
105
+ /** Metas del periodo de una cadena. Contrato → `IRetailOrgBusinessApi.listGoals`. */
106
+ async listGoals(retailerId, tenantId, periodId, targetType) {
107
+ const query = new URLSearchParams({ tenantId, periodId });
108
+ if (targetType)
109
+ query.set("targetType", targetType);
110
+ const path = `/private/retailers/${encodeURIComponent(retailerId)}/goals`;
111
+ return await this.httpRequest.get(`${this.baseUrl}${path}?${query.toString()}`);
112
+ }
103
113
  async privateApplyStoreEvent(request) {
104
114
  return await this.applyRetailEvent("/private/integration/store-events", request);
105
115
  }
@@ -1,5 +1,5 @@
1
1
  import { StandardResponse } from "@fiado/gateway-adapter";
2
- import { RetailerValidationDto, StoreValidationDto, RetailUserValidationDto, CollectorValidationDto, PrivateSellerListResponse, RetailUserStatusEnum, RetailerStatusEnum, StoreStatusEnum } from "@fiado/type-kit/bin/retailOrg/index.js";
2
+ import { RetailerValidationDto, StoreValidationDto, RetailUserValidationDto, CollectorValidationDto, PrivateSellerListResponse, PrivateGoalListResponse, GoalTargetTypeEnum, RetailUserStatusEnum, RetailerStatusEnum, StoreStatusEnum } from "@fiado/type-kit/bin/retailOrg/index.js";
3
3
  import type { ApplyRetailUserEventRequest, ApplyRetailUserEventResponse, ApplyStoreEventRequest, ApplyStoreEventResponse } from "@fiado/type-kit/bin/retailIntegration/index.js";
4
4
  /**
5
5
  * Filtro de `listStoresByRetailer`. `"ALL"` no es un estado de tienda: es la ausencia de filtro, y
@@ -206,6 +206,8 @@ export interface IRetailOrgBusinessApi {
206
206
  * lo perdería en silencio sin dejar ninguna forma de pedir el padrón completo. Si el motor
207
207
  * quiere solo activos, que lo diga explícito.
208
208
  *
209
+ * `includePhone: true` agrega el teléfono de cada vendedor (PII, por eso es opt-in).
210
+ *
209
211
  * ── `callerService`: quién exportó la nómina ─────────────────────────────────────────────────
210
212
  * El endpoint es `Feature.ANONIMUS` (sin token de usuario), así que **no hay `actorId`** al que
211
213
  * atribuirle la lectura — y esto exporta la nómina completa de una cadena en una sola llamada.
@@ -218,7 +220,14 @@ export interface IRetailOrgBusinessApi {
218
220
  * cerraría el corte sin devengos sin que nadie se entere hasta el día de pago.
219
221
  * @throws `400 VALIDATION_ERROR` si `retailerId` no es un ULID · `400 UNKNOWN_TENANT` sin `tenantId`.
220
222
  */
221
- listSellers(retailerId: string, tenantId: string, callerService: string, status?: RetailUserStatusEnum): Promise<StandardResponse<PrivateSellerListResponse>>;
223
+ listSellers(retailerId: string, tenantId: string, callerService: string, status?: RetailUserStatusEnum, includePhone?: boolean): Promise<StandardResponse<PrivateSellerListResponse>>;
224
+ /**
225
+ * `GET /private/retailers/{retailerId}/goals` — las metas del periodo (`YYYY-MM`) de una cadena,
226
+ * con `monthCents`/`weekCents`/`dayCents` ya derivadas. Sin metas devuelve `goals: []`, no 404.
227
+ *
228
+ * @throws `400 VALIDATION_ERROR` con un periodo o tipo inválido · `400 UNKNOWN_TENANT` sin tenant.
229
+ */
230
+ listGoals(retailerId: string, tenantId: string, periodId: string, targetType?: GoalTargetTypeEnum): Promise<StandardResponse<PrivateGoalListResponse>>;
222
231
  /** `POST /private/integration/store-events?tenantId=` — aplica un evento de tienda del retailer. */
223
232
  privateApplyStoreEvent(request: ApplyStoreEventRequest): Promise<StandardResponse<ApplyStoreEventResponse>>;
224
233
  /** `POST /private/integration/retail-user-events?tenantId=` — aplica un evento de usuario del retailer. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fiado/api-invoker",
3
- "version": "5.112.0",
3
+ "version": "5.114.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.14.0",
35
35
  "@fiado/http-client": "^2.0.1",
36
36
  "@fiado/logger": "^1.1.3",
37
- "@fiado/type-kit": "^3.500.0",
37
+ "@fiado/type-kit": "^3.506.0",
38
38
  "dotenv": "^16.4.7"
39
39
  },
40
40
  "peerDependencies": {
package/src/index.ts CHANGED
@@ -90,6 +90,7 @@ export * from "./retailCards/index.js";
90
90
  export * from "./retailNotifications/index.js";
91
91
  export * from "./retailWizard/index.js";
92
92
  export * from "./retailPromotions/index.js";
93
+ export * from "./retailCommission/index.js";
93
94
  export * from "./retailIntegration/index.js";
94
95
  export * from "./shortlink/index.js";
95
96
  export * from "./loanConfig/index.js";
@@ -29,6 +29,10 @@ import {
29
29
  LoanCustomerPaymentOptions,
30
30
  LoanCustomerPaymentResult,
31
31
  } from "@fiado/type-kit/bin/loanCredit/index.js";
32
+ import {
33
+ CreditSummariesBatchRequest,
34
+ CreditSummariesBatchResponse,
35
+ } from "./dtos/CreditSummariesBatch.js";
32
36
  import {
33
37
  LoanCreditAnalyticsBatchRequest,
34
38
  LoanCreditAnalyticsBatchResponse,
@@ -152,6 +156,14 @@ export default class LoanCreditBusinessApi implements ILoanCreditBusinessApi {
152
156
  return await this.httpRequest.post(url, input);
153
157
  }
154
158
 
159
+ async batchGetCreditSummaries(
160
+ input: CreditSummariesBatchRequest,
161
+ tenantId: string,
162
+ ): Promise<StandardResponse<CreditSummariesBatchResponse>> {
163
+ const url = `${this.baseUrl}/private/borrowers/credit-summaries?tenantId=${encodeURIComponent(tenantId)}`;
164
+ return await this.httpRequest.post(url, input);
165
+ }
166
+
155
167
  async upsertBorrower(
156
168
  input: UpsertLoanBorrowerRequest,
157
169
  tenantId: string,
@@ -0,0 +1,14 @@
1
+ import type { CreditCustomerListItem } from "@fiado/type-kit/bin/loanCredit/index.js";
2
+
3
+ /** Body de `POST /private/borrowers/credit-summaries`. Hasta 100 ids por request; el caller pagina. */
4
+ export interface CreditSummariesBatchRequest {
5
+ retailCustomerIds: string[];
6
+ }
7
+
8
+ /** Bloque de crédito de un cliente retail, el mismo que pinta la tabla Clientes del backoffice. */
9
+ export type CreditSummaryItem = Pick<CreditCustomerListItem, "retailCustomerId" | "credit">;
10
+
11
+ /** Response de `POST /private/borrowers/credit-summaries`: un ítem por id pedido, en el mismo orden. */
12
+ export interface CreditSummariesBatchResponse {
13
+ items: CreditSummaryItem[];
14
+ }
@@ -27,6 +27,10 @@ import {
27
27
  LoanCustomerPaymentOptions,
28
28
  LoanCustomerPaymentResult,
29
29
  } from "@fiado/type-kit/bin/loanCredit/index.js";
30
+ import {
31
+ CreditSummariesBatchRequest,
32
+ CreditSummariesBatchResponse,
33
+ } from "../dtos/CreditSummariesBatch.js";
30
34
  import {
31
35
  LoanCreditAnalyticsBatchRequest,
32
36
  LoanCreditAnalyticsBatchResponse,
@@ -174,6 +178,16 @@ export interface ILoanCreditBusinessApi {
174
178
  tenantId: string,
175
179
  ): Promise<StandardResponse<LoanCreditAnalyticsBatchResponse>>;
176
180
 
181
+ /**
182
+ * Bloque de crédito (nivel SK, conteos, saldo, mora) de hasta 100 clientes retail en lote. Un ítem
183
+ * por id pedido, en el mismo orden; `credit.state` distingue «sin acreditado» de «no se pudo leer».
184
+ * `400 VALIDATION_ERROR` si el lote viene vacío, repite ids o pasa de 100.
185
+ */
186
+ batchGetCreditSummaries(
187
+ input: CreditSummariesBatchRequest,
188
+ tenantId: string,
189
+ ): Promise<StandardResponse<CreditSummariesBatchResponse>>;
190
+
177
191
  /**
178
192
  * Upsert idempotente del acreditado por `retailCustomerId` (mismo contrato que el consumidor
179
193
  * del evento `CustomerKycVerifiedV1` — fallback operativo mientras la cola no exista).
@@ -1,5 +1,6 @@
1
1
  export * from "./api/dtos/CreditLifecycleFact.js";
2
2
  export * from "./api/dtos/CustomerCreditHistory.js";
3
+ export * from "./api/dtos/CreditSummariesBatch.js";
3
4
  export * from "./api/dtos/LoanCreditAnalyticsBatch.js";
4
5
  export * from "./api/interfaces/ILoanCreditBusinessApi.js";
5
6
  export { default as LoanCreditBusinessApi } from "./api/LoanCreditBusinessApi.js";
@@ -0,0 +1,25 @@
1
+ import { inject, injectable } from "inversify";
2
+ import type { IHttpRequest } from "@fiado/http-client";
3
+ import type { StandardResponse } from "@fiado/gateway-adapter";
4
+ import type { PrivateLatestClosedPayoutResponse } from "@fiado/type-kit/bin/retailCommission/index.js";
5
+ import type { IRetailCommissionBusinessApi } from "./interfaces/IRetailCommissionBusinessApi.js";
6
+
7
+ /** Publisher HTTP de `retail-commission-business`. Contrato → `IRetailCommissionBusinessApi`. */
8
+ @injectable()
9
+ export class RetailCommissionBusinessApi implements IRetailCommissionBusinessApi {
10
+ constructor(@inject("IHttpRequest") private readonly httpRequest: IHttpRequest) {}
11
+
12
+ /** La URL del SSM termina en `/v1/`; se quita la barra final para no duplicarla. */
13
+ private get baseUrl(): string {
14
+ return (process.env.RETAIL_COMMISSION_BUSINESS_URL || "").replace(/\/+$/, "");
15
+ }
16
+
17
+ async getLatestClosedPayout(
18
+ retailerId: string,
19
+ tenantId: string,
20
+ ): Promise<StandardResponse<PrivateLatestClosedPayoutResponse>> {
21
+ const path = `/private/retailers/${encodeURIComponent(retailerId)}/payouts/latest-closed`;
22
+ const query = new URLSearchParams({ tenantId });
23
+ return await this.httpRequest.get(`${this.baseUrl}${path}?${query.toString()}`);
24
+ }
25
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./interfaces/IRetailCommissionBusinessApi.js";
2
+ export * from "./RetailCommissionBusinessApi.js";
@@ -0,0 +1,20 @@
1
+ import type { StandardResponse } from "@fiado/gateway-adapter";
2
+ import type { PrivateLatestClosedPayoutResponse } from "@fiado/type-kit/bin/retailCommission/index.js";
3
+
4
+ /**
5
+ * Publisher de los endpoints privados de `retail-commission-business` (motor de comisiones de
6
+ * VentasLuga). No confundir con `commission-business`, que es otro servicio.
7
+ *
8
+ * Env var requerida en el consumer: `RETAIL_COMMISSION_BUSINESS_URL: '{{resolve:ssm:retail-commission-business}}'`.
9
+ * `tenantId` es obligatorio: los privados no llevan token y el silo lo declara el caller.
10
+ */
11
+ export interface IRetailCommissionBusinessApi {
12
+ /**
13
+ * `GET /private/retailers/{retailerId}/payouts/latest-closed` — el último corte semanal CERRADO
14
+ * de la cadena, con lo que le pagó a cada vendedor. Sin corte cerrado reciente: `period: null`.
15
+ */
16
+ getLatestClosedPayout(
17
+ retailerId: string,
18
+ tenantId: string,
19
+ ): Promise<StandardResponse<PrivateLatestClosedPayoutResponse>>;
20
+ }
@@ -7,6 +7,8 @@ import {
7
7
  RetailUserValidationDto,
8
8
  CollectorValidationDto,
9
9
  PrivateSellerListResponse,
10
+ PrivateGoalListResponse,
11
+ GoalTargetTypeEnum,
10
12
  RetailUserStatusEnum,
11
13
  } from "@fiado/type-kit/bin/retailOrg/index.js";
12
14
  import type {
@@ -142,14 +144,29 @@ export default class RetailOrgBusinessApi implements IRetailOrgBusinessApi {
142
144
  tenantId: string,
143
145
  callerService: string,
144
146
  status?: RetailUserStatusEnum,
147
+ includePhone?: boolean,
145
148
  ): Promise<StandardResponse<PrivateSellerListResponse>> {
146
149
  // `URLSearchParams` en vez de concatenar: `status` es opcional y armar el `&status=` a mano
147
150
  // deja un `&status=undefined` en cuanto alguien se distrae.
148
151
  const query = new URLSearchParams({ retailerId, tenantId, callerService });
149
152
  if (status) query.set("status", status);
153
+ if (includePhone) query.set("includePhone", "true");
150
154
  return await this.httpRequest.get(`${this.baseUrl}/private/sellers?${query.toString()}`);
151
155
  }
152
156
 
157
+ /** Metas del periodo de una cadena. Contrato → `IRetailOrgBusinessApi.listGoals`. */
158
+ async listGoals(
159
+ retailerId: string,
160
+ tenantId: string,
161
+ periodId: string,
162
+ targetType?: GoalTargetTypeEnum,
163
+ ): Promise<StandardResponse<PrivateGoalListResponse>> {
164
+ const query = new URLSearchParams({ tenantId, periodId });
165
+ if (targetType) query.set("targetType", targetType);
166
+ const path = `/private/retailers/${encodeURIComponent(retailerId)}/goals`;
167
+ return await this.httpRequest.get(`${this.baseUrl}${path}?${query.toString()}`);
168
+ }
169
+
153
170
  async privateApplyStoreEvent(request: ApplyStoreEventRequest): Promise<StandardResponse<ApplyStoreEventResponse>> {
154
171
  return await this.applyRetailEvent("/private/integration/store-events", request);
155
172
  }
@@ -5,6 +5,8 @@ import {
5
5
  RetailUserValidationDto,
6
6
  CollectorValidationDto,
7
7
  PrivateSellerListResponse,
8
+ PrivateGoalListResponse,
9
+ GoalTargetTypeEnum,
8
10
  RetailUserStatusEnum,
9
11
  RetailerStatusEnum,
10
12
  StoreStatusEnum,
@@ -258,6 +260,8 @@ export interface IRetailOrgBusinessApi {
258
260
  * lo perdería en silencio sin dejar ninguna forma de pedir el padrón completo. Si el motor
259
261
  * quiere solo activos, que lo diga explícito.
260
262
  *
263
+ * `includePhone: true` agrega el teléfono de cada vendedor (PII, por eso es opt-in).
264
+ *
261
265
  * ── `callerService`: quién exportó la nómina ─────────────────────────────────────────────────
262
266
  * El endpoint es `Feature.ANONIMUS` (sin token de usuario), así que **no hay `actorId`** al que
263
267
  * atribuirle la lectura — y esto exporta la nómina completa de una cadena en una sola llamada.
@@ -275,8 +279,22 @@ export interface IRetailOrgBusinessApi {
275
279
  tenantId: string,
276
280
  callerService: string,
277
281
  status?: RetailUserStatusEnum,
282
+ includePhone?: boolean,
278
283
  ): Promise<StandardResponse<PrivateSellerListResponse>>;
279
284
 
285
+ /**
286
+ * `GET /private/retailers/{retailerId}/goals` — las metas del periodo (`YYYY-MM`) de una cadena,
287
+ * con `monthCents`/`weekCents`/`dayCents` ya derivadas. Sin metas devuelve `goals: []`, no 404.
288
+ *
289
+ * @throws `400 VALIDATION_ERROR` con un periodo o tipo inválido · `400 UNKNOWN_TENANT` sin tenant.
290
+ */
291
+ listGoals(
292
+ retailerId: string,
293
+ tenantId: string,
294
+ periodId: string,
295
+ targetType?: GoalTargetTypeEnum,
296
+ ): Promise<StandardResponse<PrivateGoalListResponse>>;
297
+
280
298
  /** `POST /private/integration/store-events?tenantId=` — aplica un evento de tienda del retailer. */
281
299
  privateApplyStoreEvent(request: ApplyStoreEventRequest): Promise<StandardResponse<ApplyStoreEventResponse>>;
282
300