@fiado/api-invoker 5.98.0 → 5.100.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.
@@ -1,4 +1,4 @@
1
- import { IHttpRequest } from "@fiado/http-client";
1
+ import type { IHttpRequest } from "@fiado/http-client";
2
2
  import { GroupAddDirectoryRequest, GroupResponse } from "@fiado/type-kit/bin/group/index.js";
3
3
  import { IGroupApi } from "./interfaces/IGroupApi.js";
4
4
  type FiadoApiResponse<T> = import("@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse.js").default<T>;
@@ -18,6 +18,14 @@ export declare class GroupApi implements IGroupApi {
18
18
  members(params: GroupAddDirectoryRequest): Promise<any>;
19
19
  findById(id: string): Promise<any>;
20
20
  findAllWithCounts(): Promise<any>;
21
+ getMembersByGroupIds(groupIds: string[], pageSize?: number, lastKey?: string): Promise<FiadoApiResponse<{
22
+ items: {
23
+ directoryId: string;
24
+ groupId: string;
25
+ status?: string;
26
+ }[];
27
+ lastEvaluatedKey?: string;
28
+ }>>;
21
29
  deleteByDirectoryId(directoryId: string): Promise<FiadoApiResponse<{
22
30
  deletedCount: number;
23
31
  }>>;
@@ -64,6 +64,18 @@ let GroupApi = class GroupApi {
64
64
  const url = `${this.baseUrl}groups/counts`;
65
65
  return await this.httpRequest.get(`${url}`);
66
66
  }
67
+ async getMembersByGroupIds(groupIds, pageSize = 200, lastKey) {
68
+ const queryParams = [];
69
+ // El destino lee groupIds como multiValueQueryStringParameters: se repite la
70
+ // clave, no se manda separada por comas.
71
+ groupIds.forEach((groupId) => queryParams.push(`groupIds=${encodeURIComponent(groupId)}`));
72
+ queryParams.push(`pageSize=${pageSize}`);
73
+ if (lastKey) {
74
+ queryParams.push(`lastKey=${encodeURIComponent(lastKey)}`);
75
+ }
76
+ const url = `${this.baseUrl}members?${queryParams.join('&')}`;
77
+ return await this.httpRequest.get(url);
78
+ }
67
79
  async deleteByDirectoryId(directoryId) {
68
80
  const url = `${this.baseUrl}private/directory/${directoryId}`;
69
81
  return await this.httpRequest.delete(url);
@@ -25,6 +25,23 @@ export interface IGroupApi {
25
25
  directory: string;
26
26
  groups: GroupResponse[];
27
27
  }[]>>;
28
+ /**
29
+ * Miembros de uno o varios grupos, paginado.
30
+ *
31
+ * `lastKey` es el cursor que devolvió la llamada anterior. Hay que encadenarlo hasta
32
+ * que venga vacío: DynamoDB corta cada página en 1 MB, así que un grupo grande NO
33
+ * entra en una sola respuesta.
34
+ *
35
+ * Consumido por `direct-deposit-export-business` para resolver a quién exportar.
36
+ */
37
+ getMembersByGroupIds(groupIds: string[], pageSize?: number, lastKey?: string): Promise<FiadoApiResponse<{
38
+ items: {
39
+ directoryId: string;
40
+ groupId: string;
41
+ status?: string;
42
+ }[];
43
+ lastEvaluatedKey?: string;
44
+ }>>;
28
45
  /**
29
46
  * Buscar grupo por id
30
47
  * @param categoryId ID del grupo.
@@ -1,6 +1,6 @@
1
1
  import type { IHttpRequest } from "@fiado/http-client";
2
2
  import { StandardResponse } from "@fiado/gateway-adapter";
3
- import { AmortizationScheduleResponse, ComputeAmortizationScheduleRequest, ConsumePromotionRequest, PromotedSkusResponse, ConsumePromotionResponse, CreditPlanLevelEnum, CreditPlanResponse, FinancierResponse, ReservePromotionBonusRequest, ReservePromotionBonusResponse, ResolveCustomerSegmentsRequest, ResolveCustomerSegmentsResponse, ScopeWidePromotionsResponse, SkuPromotionsResponse, SettlePromotionBonusRequest, PromotionBonusResponse, SimulateCreditPlanRequest, SimulationResultResponse } from "@fiado/type-kit/bin/loanOfferings/index.js";
3
+ import { AmortizationScheduleResponse, ComputeAmortizationScheduleRequest, ConsumePromotionRequest, PromotedSkusResponse, ConsumePromotionResponse, CreditPlanLevelEnum, CreditPlanResponse, FinancierResponse, ReservePromotionBonusRequest, ReservePromotionBonusResponse, ResolveCustomerSegmentsRequest, ResolveCustomerSegmentsResponse, ScopeWidePromotionsResponse, SegmentCatalogResponse, SegmentStatusEnum, SkuPromotionsResponse, SettlePromotionBonusRequest, PromotionBonusResponse, SimulateCreditPlanRequest, SimulationResultResponse } from "@fiado/type-kit/bin/loanOfferings/index.js";
4
4
  import { SegmentMembersResponse } from "./dtos/SegmentMembers.js";
5
5
  import { ILoanOfferingsBusinessApi } from "./interfaces/ILoanOfferingsBusinessApi.js";
6
6
  /**
@@ -32,4 +32,5 @@ export default class LoanOfferingsBusinessApi implements ILoanOfferingsBusinessA
32
32
  listSkuPromotions(storeId: string, tenantId: string, level?: CreditPlanLevelEnum, segmentId?: string): Promise<StandardResponse<SkuPromotionsResponse>>;
33
33
  listScopeWidePromotions(storeId: string, tenantId: string, level?: CreditPlanLevelEnum, segmentId?: string): Promise<StandardResponse<ScopeWidePromotionsResponse>>;
34
34
  getSegmentMembers(retailCustomerIds: string[], tenantId: string): Promise<StandardResponse<SegmentMembersResponse>>;
35
+ listSegments(tenantId: string, status?: SegmentStatusEnum): Promise<StandardResponse<SegmentCatalogResponse>>;
35
36
  }
@@ -98,6 +98,13 @@ let LoanOfferingsBusinessApi = class LoanOfferingsBusinessApi {
98
98
  const url = `${this.baseUrl}/private/segments/members?${params.toString()}`;
99
99
  return await this.httpRequest.get(url);
100
100
  }
101
+ async listSegments(tenantId, status) {
102
+ const params = new URLSearchParams({ tenantId });
103
+ if (status)
104
+ params.set("status", status);
105
+ const url = `${this.baseUrl}/private/segments?${params.toString()}`;
106
+ return await this.httpRequest.get(url);
107
+ }
101
108
  };
102
109
  LoanOfferingsBusinessApi = __decorate([
103
110
  injectable(),
@@ -1,6 +1,6 @@
1
1
  import { StandardResponse } from "@fiado/gateway-adapter";
2
2
  import { SegmentMembersResponse } from "../dtos/SegmentMembers.js";
3
- import { AmortizationScheduleResponse, ComputeAmortizationScheduleRequest, ConsumePromotionRequest, PromotedSkusResponse, ConsumePromotionResponse, CreditPlanLevelEnum, CreditPlanResponse, FinancierResponse, ReservePromotionBonusRequest, ReservePromotionBonusResponse, ResolveCustomerSegmentsRequest, ResolveCustomerSegmentsResponse, ScopeWidePromotionsResponse, SkuPromotionsResponse, SettlePromotionBonusRequest, PromotionBonusResponse, SimulateCreditPlanRequest, SimulationResultResponse } from "@fiado/type-kit/bin/loanOfferings/index.js";
3
+ import { AmortizationScheduleResponse, ComputeAmortizationScheduleRequest, ConsumePromotionRequest, PromotedSkusResponse, ConsumePromotionResponse, CreditPlanLevelEnum, CreditPlanResponse, FinancierResponse, ReservePromotionBonusRequest, ReservePromotionBonusResponse, ResolveCustomerSegmentsRequest, ResolveCustomerSegmentsResponse, ScopeWidePromotionsResponse, SegmentCatalogResponse, SegmentStatusEnum, SkuPromotionsResponse, SettlePromotionBonusRequest, PromotionBonusResponse, SimulateCreditPlanRequest, SimulationResultResponse } from "@fiado/type-kit/bin/loanOfferings/index.js";
4
4
  /**
5
5
  * Contrato del publisher HTTP del lambda `loan-offerings-business` (componente 07 SureKeep Fase 1)
6
6
  * para sus endpoints privados service-to-service (VPC-only): LECTURAS del catálogo SOFOM y
@@ -152,4 +152,9 @@ export interface ILoanOfferingsBusinessApi {
152
152
  * @throws `400 UNKNOWN_TENANT` si el `tenantId` viene ausente o desconocido.
153
153
  */
154
154
  getSegmentMembers(retailCustomerIds: string[], tenantId: string): Promise<StandardResponse<SegmentMembersResponse>>;
155
+ /**
156
+ * `GET /private/segments` — catálogo de segmentos del silo, sin miembros; el catch-all viaja con `isDefault: true`.
157
+ * Sin `status` devuelve todos los estados.
158
+ */
159
+ listSegments(tenantId: string, status?: SegmentStatusEnum): Promise<StandardResponse<SegmentCatalogResponse>>;
155
160
  }
@@ -27,6 +27,7 @@ export default class OnboardingBusinessApi implements IOnboardingBusinessApi {
27
27
  getBatchByIds(ids: string[]): Promise<any>;
28
28
  tagsSummary(): Promise<any>;
29
29
  tagsByDirectories(directoryIds: string[]): Promise<any>;
30
+ getUsersByTag(tag: string, pageSize?: number, index?: string): Promise<any>;
30
31
  assignTag(params: {
31
32
  directoryId: string;
32
33
  tag: string;
@@ -101,6 +101,14 @@ let OnboardingBusinessApi = class OnboardingBusinessApi {
101
101
  const url = `${this.baseUrl}private/tags/by-directories`;
102
102
  return await this.httpRequest.post(`${url}`, { directoryIds });
103
103
  }
104
+ async getUsersByTag(tag, pageSize = 200, index) {
105
+ const queryParams = [`pageSize=${pageSize}`];
106
+ if (index) {
107
+ queryParams.push(`index=${encodeURIComponent(index)}`);
108
+ }
109
+ const url = `${this.baseUrl}private/tags/${encodeURIComponent(tag)}/users?${queryParams.join('&')}`;
110
+ return await this.httpRequest.get(`${url}`);
111
+ }
104
112
  async assignTag(params) {
105
113
  const url = `${this.baseUrl}private/tags`;
106
114
  return await this.httpRequest.post(`${url}`, { directoryId: params.directoryId, tag: params.tag });
@@ -23,6 +23,16 @@ export interface IOnboardingBusinessApi {
23
23
  /** Dashboard Ops Segmentos — tags distintos + count c/u (TagsSummaryResponse en data). */
24
24
  tagsSummary(): Promise<any>;
25
25
  /** Dashboard Ops Segmentos — tags por usuario para un batch de directoryIds (TagsByDirectoriesResponse en data). */
26
+ /**
27
+ * Directorios que tienen un tag, paginado.
28
+ *
29
+ * `index` es el cursor que devolvió la llamada anterior. Hay que encadenarlo hasta
30
+ * que venga vacío: un tag con miles de usuarios NO entra en una sola respuesta.
31
+ *
32
+ * Es el inverso de `tagsByDirectories` (ese da los tags DE unos directorios; éste da
33
+ * los directorios CON un tag). Consumido por `direct-deposit-export-business`.
34
+ */
35
+ getUsersByTag(tag: string, pageSize?: number, index?: string): Promise<any>;
26
36
  tagsByDirectories(directoryIds: string[]): Promise<any>;
27
37
  /** Asigna un tag a un directoryId. Idempotente: si ya estaba responde 200 con alreadyAssigned true. */
28
38
  assignTag(params: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fiado/api-invoker",
3
- "version": "5.98.0",
3
+ "version": "5.100.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.478.0",
37
+ "@fiado/type-kit": "3.481.0",
38
38
  "dotenv": "^16.4.7"
39
39
  },
40
40
  "peerDependencies": {
@@ -1,5 +1,9 @@
1
1
  import { inject, injectable } from "inversify";
2
- import { IHttpRequest } from "@fiado/http-client";
2
+ // `import type`: IHttpRequest solo se usa como tipo. Importarlo como valor arrastra
3
+ // @fiado/http-client al runtime, y jest no lo transforma (no esta en
4
+ // transformIgnorePatterns) — el test revienta con "Cannot use import statement outside
5
+ // a module". Mismo patron que OnboardingBusinessApi.
6
+ import type { IHttpRequest } from "@fiado/http-client";
3
7
  import dotenv from 'dotenv';
4
8
  import { GroupAddDirectoryRequest, GroupResponse } from "@fiado/type-kit/bin/group/index.js";
5
9
  import { IGroupApi } from "./interfaces/IGroupApi.js";
@@ -73,6 +77,25 @@ export class GroupApi implements IGroupApi {
73
77
  return await this.httpRequest.get(`${url}`);
74
78
  }
75
79
 
80
+ async getMembersByGroupIds(groupIds: string[], pageSize = 200, lastKey?: string): Promise<FiadoApiResponse<{
81
+ items: { directoryId: string; groupId: string; status?: string }[];
82
+ lastEvaluatedKey?: string;
83
+ }>> {
84
+ const queryParams: string[] = [];
85
+
86
+ // El destino lee groupIds como multiValueQueryStringParameters: se repite la
87
+ // clave, no se manda separada por comas.
88
+ groupIds.forEach((groupId) => queryParams.push(`groupIds=${encodeURIComponent(groupId)}`));
89
+ queryParams.push(`pageSize=${pageSize}`);
90
+
91
+ if (lastKey) {
92
+ queryParams.push(`lastKey=${encodeURIComponent(lastKey)}`);
93
+ }
94
+
95
+ const url = `${this.baseUrl}members?${queryParams.join('&')}`;
96
+ return await this.httpRequest.get(url);
97
+ }
98
+
76
99
  async deleteByDirectoryId(directoryId: string): Promise<FiadoApiResponse<{ deletedCount: number }>> {
77
100
  const url = `${this.baseUrl}private/directory/${directoryId}`;
78
101
  return await this.httpRequest.delete<FiadoApiResponse<{ deletedCount: number }>>(url);
@@ -29,6 +29,20 @@ export interface IGroupApi {
29
29
  */
30
30
  getMembershipDirectoryUserList(directories:string[], pageSize:number,index?:string): Promise<FiadoApiResponse<{directory:string,groups:GroupResponse[]}[]>>;
31
31
 
32
+ /**
33
+ * Miembros de uno o varios grupos, paginado.
34
+ *
35
+ * `lastKey` es el cursor que devolvió la llamada anterior. Hay que encadenarlo hasta
36
+ * que venga vacío: DynamoDB corta cada página en 1 MB, así que un grupo grande NO
37
+ * entra en una sola respuesta.
38
+ *
39
+ * Consumido por `direct-deposit-export-business` para resolver a quién exportar.
40
+ */
41
+ getMembersByGroupIds(groupIds: string[], pageSize?: number, lastKey?: string): Promise<FiadoApiResponse<{
42
+ items: { directoryId: string; groupId: string; status?: string }[];
43
+ lastEvaluatedKey?: string;
44
+ }>>;
45
+
32
46
 
33
47
 
34
48
  /**
@@ -15,6 +15,8 @@ import {
15
15
  ResolveCustomerSegmentsRequest,
16
16
  ResolveCustomerSegmentsResponse,
17
17
  ScopeWidePromotionsResponse,
18
+ SegmentCatalogResponse,
19
+ SegmentStatusEnum,
18
20
  SkuPromotionsResponse,
19
21
  SettlePromotionBonusRequest,
20
22
  PromotionBonusResponse,
@@ -165,4 +167,14 @@ export default class LoanOfferingsBusinessApi implements ILoanOfferingsBusinessA
165
167
  const url = `${this.baseUrl}/private/segments/members?${params.toString()}`;
166
168
  return await this.httpRequest.get(url);
167
169
  }
170
+
171
+ async listSegments(
172
+ tenantId: string,
173
+ status?: SegmentStatusEnum,
174
+ ): Promise<StandardResponse<SegmentCatalogResponse>> {
175
+ const params = new URLSearchParams({ tenantId });
176
+ if (status) params.set("status", status);
177
+ const url = `${this.baseUrl}/private/segments?${params.toString()}`;
178
+ return await this.httpRequest.get(url);
179
+ }
168
180
  }
@@ -14,6 +14,8 @@ import {
14
14
  ResolveCustomerSegmentsRequest,
15
15
  ResolveCustomerSegmentsResponse,
16
16
  ScopeWidePromotionsResponse,
17
+ SegmentCatalogResponse,
18
+ SegmentStatusEnum,
17
19
  SkuPromotionsResponse,
18
20
  SettlePromotionBonusRequest,
19
21
  PromotionBonusResponse,
@@ -232,4 +234,13 @@ export interface ILoanOfferingsBusinessApi {
232
234
  retailCustomerIds: string[],
233
235
  tenantId: string,
234
236
  ): Promise<StandardResponse<SegmentMembersResponse>>;
237
+
238
+ /**
239
+ * `GET /private/segments` — catálogo de segmentos del silo, sin miembros; el catch-all viaja con `isDefault: true`.
240
+ * Sin `status` devuelve todos los estados.
241
+ */
242
+ listSegments(
243
+ tenantId: string,
244
+ status?: SegmentStatusEnum,
245
+ ): Promise<StandardResponse<SegmentCatalogResponse>>;
235
246
  }
@@ -101,6 +101,17 @@ export default class OnboardingBusinessApi implements IOnboardingBusinessApi {
101
101
  return await this.httpRequest.post(`${url}`, { directoryIds });
102
102
  }
103
103
 
104
+ async getUsersByTag(tag: string, pageSize = 200, index?: string): Promise<any> {
105
+ const queryParams = [`pageSize=${pageSize}`];
106
+
107
+ if (index) {
108
+ queryParams.push(`index=${encodeURIComponent(index)}`);
109
+ }
110
+
111
+ const url = `${this.baseUrl}private/tags/${encodeURIComponent(tag)}/users?${queryParams.join('&')}`;
112
+ return await this.httpRequest.get(`${url}`);
113
+ }
114
+
104
115
  async assignTag(params: { directoryId: string; tag: string }): Promise<any> {
105
116
  const url = `${this.baseUrl}private/tags`;
106
117
  return await this.httpRequest.post(`${url}`, { directoryId: params.directoryId, tag: params.tag });
@@ -11,6 +11,17 @@ export interface IOnboardingBusinessApi {
11
11
  /** Dashboard Ops Segmentos — tags distintos + count c/u (TagsSummaryResponse en data). */
12
12
  tagsSummary(): Promise<any>
13
13
  /** Dashboard Ops Segmentos — tags por usuario para un batch de directoryIds (TagsByDirectoriesResponse en data). */
14
+ /**
15
+ * Directorios que tienen un tag, paginado.
16
+ *
17
+ * `index` es el cursor que devolvió la llamada anterior. Hay que encadenarlo hasta
18
+ * que venga vacío: un tag con miles de usuarios NO entra en una sola respuesta.
19
+ *
20
+ * Es el inverso de `tagsByDirectories` (ese da los tags DE unos directorios; éste da
21
+ * los directorios CON un tag). Consumido por `direct-deposit-export-business`.
22
+ */
23
+ getUsersByTag(tag: string, pageSize?: number, index?: string): Promise<any>;
24
+
14
25
  tagsByDirectories(directoryIds: string[]): Promise<any>
15
26
  /** Asigna un tag a un directoryId. Idempotente: si ya estaba responde 200 con alreadyAssigned true. */
16
27
  assignTag(params: { directoryId: string; tag: string }): Promise<any>