@fiado/api-invoker 5.129.0 → 5.131.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.
@@ -12,7 +12,9 @@ export declare enum CreditLifecycleFactEnum {
12
12
  CREDIT_SETTLED = "CREDIT_SETTLED",
13
13
  DEVICE_UNLOCKED = "DEVICE_UNLOCKED",
14
14
  /** Bienvenida al cerrar la venta. Solo la pista de crédito: la de contado no tiene `creditId`. */
15
- APP_WELCOME = "APP_WELCOME"
15
+ APP_WELCOME = "APP_WELCOME",
16
+ /** La venta se canceló y su crédito quedó descartado. Solo tras un descarte exitoso. */
17
+ SALE_CANCELLED_CREDIT_DISCARDED = "SALE_CANCELLED_CREDIT_DISCARDED"
16
18
  }
17
19
  /** Body de `POST /private/credits/{creditId}/lifecycle-facts`. */
18
20
  export interface CreditLifecycleFactRequest {
@@ -14,4 +14,6 @@ export var CreditLifecycleFactEnum;
14
14
  CreditLifecycleFactEnum["DEVICE_UNLOCKED"] = "DEVICE_UNLOCKED";
15
15
  /** Bienvenida al cerrar la venta. Solo la pista de crédito: la de contado no tiene `creditId`. */
16
16
  CreditLifecycleFactEnum["APP_WELCOME"] = "APP_WELCOME";
17
+ /** La venta se canceló y su crédito quedó descartado. Solo tras un descarte exitoso. */
18
+ CreditLifecycleFactEnum["SALE_CANCELLED_CREDIT_DISCARDED"] = "SALE_CANCELLED_CREDIT_DISCARDED";
17
19
  })(CreditLifecycleFactEnum || (CreditLifecycleFactEnum = {}));
@@ -1,6 +1,6 @@
1
1
  import type { StandardResponse } from "@fiado/gateway-adapter";
2
2
  import type { IHttpRequest } from "@fiado/http-client";
3
- import type { EvaluateRulesRequest, EvaluateRulesResponse, GenerateRulesRequest, GenerateRulesResponse, RulesCatalogResponse, ValidateRulesRequest, ValidateRulesResponse } from "@fiado/type-kit/bin/rules/index.js";
3
+ import type { EvaluateRulesRequest, EvaluateRulesResponse, GenerateRulesRequest, GenerateRulesResponse, PopulationCompileRequest, PopulationCompileResponse, PopulationExecutionPageResponse, PopulationExecutionRequest, PopulationExecutionResponse, PopulationTestRequest, PopulationTestResponse, RulesCatalogResponse, SegmentSchemaResponse, SegmentTableSchemaResponse, ValidateRulesRequest, ValidateRulesResponse } from "@fiado/type-kit/bin/rules/index.js";
4
4
  import type { IRulesApi } from "./interfaces/IRulesApi.js";
5
5
  /**
6
6
  * Contrato y semántica completos → `IRulesApi` (`StandardResponse` → leer `result.data`).
@@ -14,4 +14,11 @@ export declare class RulesApi implements IRulesApi {
14
14
  validate(request: ValidateRulesRequest): Promise<StandardResponse<ValidateRulesResponse>>;
15
15
  generate(request: GenerateRulesRequest): Promise<StandardResponse<GenerateRulesResponse>>;
16
16
  evaluate(request: EvaluateRulesRequest): Promise<StandardResponse<EvaluateRulesResponse>>;
17
+ populationSchema(consumer?: string): Promise<StandardResponse<SegmentSchemaResponse>>;
18
+ populationTableSchema(table: string, consumer?: string): Promise<StandardResponse<SegmentTableSchemaResponse>>;
19
+ populationCompile(request: PopulationCompileRequest): Promise<StandardResponse<PopulationCompileResponse>>;
20
+ populationTestStart(request: PopulationTestRequest): Promise<StandardResponse<PopulationTestResponse>>;
21
+ populationTestGet(testId: string, consumer?: string): Promise<StandardResponse<PopulationTestResponse>>;
22
+ populationExecutionStart(request: PopulationExecutionRequest): Promise<StandardResponse<PopulationExecutionResponse>>;
23
+ populationExecutionPage(executionId: string, nextToken?: string, consumer?: string): Promise<StandardResponse<PopulationExecutionPageResponse>>;
17
24
  }
@@ -11,6 +11,13 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
11
11
  return function (target, key) { decorator(target, key, paramIndex); }
12
12
  };
13
13
  import { inject, injectable } from "inversify";
14
+ // P2: el gateway de rewards corta a 29 s; el central corta la prueba a 12 s. Solo dispara ante falla real.
15
+ const POPULATION_TEST_CLIENT_TIMEOUT_MS = 20000;
16
+ const consumerQuery = (consumer) => consumer === undefined ? "" : `consumer=${encodeURIComponent(consumer)}`;
17
+ const withQuery = (url, ...parts) => {
18
+ const query = parts.filter((part) => part !== "").join("&");
19
+ return query === "" ? url : `${url}?${query}`;
20
+ };
14
21
  /**
15
22
  * Contrato y semántica completos → `IRulesApi` (`StandardResponse` → leer `result.data`).
16
23
  * Env: `RULES_BUSINESS_LAMBDA_URL` (SSM `fiado-rulesbusiness-lambda`).
@@ -36,6 +43,32 @@ let RulesApi = class RulesApi {
36
43
  async evaluate(request) {
37
44
  return await this.httpRequest.post(`${this.baseUrl}/evaluate`, request);
38
45
  }
46
+ async populationSchema(consumer) {
47
+ const url = withQuery(`${this.baseUrl}/population/schema`, consumerQuery(consumer));
48
+ return await this.httpRequest.get(url);
49
+ }
50
+ async populationTableSchema(table, consumer) {
51
+ const url = withQuery(`${this.baseUrl}/population/schema/${encodeURIComponent(table)}`, consumerQuery(consumer));
52
+ return await this.httpRequest.get(url);
53
+ }
54
+ async populationCompile(request) {
55
+ return await this.httpRequest.post(`${this.baseUrl}/population/compile`, request);
56
+ }
57
+ async populationTestStart(request) {
58
+ return await this.httpRequest.post(`${this.baseUrl}/population/tests`, request, undefined, undefined, undefined, { timeout: POPULATION_TEST_CLIENT_TIMEOUT_MS });
59
+ }
60
+ async populationTestGet(testId, consumer) {
61
+ const url = withQuery(`${this.baseUrl}/population/tests/${encodeURIComponent(testId)}`, consumerQuery(consumer));
62
+ return await this.httpRequest.get(url);
63
+ }
64
+ async populationExecutionStart(request) {
65
+ return await this.httpRequest.post(`${this.baseUrl}/population/executions`, request);
66
+ }
67
+ async populationExecutionPage(executionId, nextToken, consumer) {
68
+ const tokenQuery = nextToken === undefined ? "" : `nextToken=${encodeURIComponent(nextToken)}`;
69
+ const url = withQuery(`${this.baseUrl}/population/executions/${encodeURIComponent(executionId)}`, tokenQuery, consumerQuery(consumer));
70
+ return await this.httpRequest.get(url);
71
+ }
39
72
  };
40
73
  RulesApi = __decorate([
41
74
  injectable(),
@@ -1,5 +1,5 @@
1
1
  import type { StandardResponse } from "@fiado/gateway-adapter";
2
- import type { EvaluateRulesRequest, EvaluateRulesResponse, GenerateRulesRequest, GenerateRulesResponse, RulesCatalogResponse, ValidateRulesRequest, ValidateRulesResponse } from "@fiado/type-kit/bin/rules/index.js";
2
+ import type { EvaluateRulesRequest, EvaluateRulesResponse, GenerateRulesRequest, GenerateRulesResponse, PopulationCompileRequest, PopulationCompileResponse, PopulationExecutionPageResponse, PopulationExecutionRequest, PopulationExecutionResponse, PopulationTestRequest, PopulationTestResponse, RulesCatalogResponse, SegmentSchemaResponse, SegmentTableSchemaResponse, ValidateRulesRequest, ValidateRulesResponse } from "@fiado/type-kit/bin/rules/index.js";
3
3
  /**
4
4
  * Cliente del lambda central `rules-business` (catálogo, validación, generación con IA y evaluación de reglas).
5
5
  *
@@ -15,4 +15,21 @@ export interface IRulesApi {
15
15
  generate(request: GenerateRulesRequest): Promise<StandardResponse<GenerateRulesResponse>>;
16
16
  /** POST /evaluate — evalúa reglas sobre hasta 100 sujetos por llamada (400 `TOO_MANY_SUBJECTS`). */
17
17
  evaluate(request: EvaluateRulesRequest): Promise<StandardResponse<EvaluateRulesResponse>>;
18
+ /** GET /population/schema — tablas del datalake disponibles para segmentar población. */
19
+ populationSchema(consumer?: string): Promise<StandardResponse<SegmentSchemaResponse>>;
20
+ /** GET /population/schema/{table} — columnas de una tabla del datalake. */
21
+ populationTableSchema(table: string, consumer?: string): Promise<StandardResponse<SegmentTableSchemaResponse>>;
22
+ /** POST /population/compile — compila una `definition` a SQL parametrizado (no ejecuta nada). */
23
+ populationCompile(request: PopulationCompileRequest): Promise<StandardResponse<PopulationCompileResponse>>;
24
+ /**
25
+ * POST /population/tests — prueba sin estado. El central corta a 12 s y responde RUNNING + `testId`;
26
+ * el cliente usa un timeout explícito de 20000 ms (solo dispara ante falla real → 503).
27
+ */
28
+ populationTestStart(request: PopulationTestRequest): Promise<StandardResponse<PopulationTestResponse>>;
29
+ /** GET /population/tests/{testId} — sondeo de una prueba iniciada. */
30
+ populationTestGet(testId: string, consumer?: string): Promise<StandardResponse<PopulationTestResponse>>;
31
+ /** POST /population/executions — inicia la ejecución de una población. */
32
+ populationExecutionStart(request: PopulationExecutionRequest): Promise<StandardResponse<PopulationExecutionResponse>>;
33
+ /** GET /population/executions/{id} — página (≤1000 ids) de una ejecución; `nextToken` para continuar. */
34
+ populationExecutionPage(executionId: string, nextToken?: string, consumer?: string): Promise<StandardResponse<PopulationExecutionPageResponse>>;
18
35
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fiado/api-invoker",
3
- "version": "5.129.0",
3
+ "version": "5.131.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.540.0",
37
+ "@fiado/type-kit": "^3.541.0",
38
38
  "dotenv": "^16.4.7"
39
39
  },
40
40
  "peerDependencies": {
@@ -13,6 +13,8 @@ export enum CreditLifecycleFactEnum {
13
13
  DEVICE_UNLOCKED = "DEVICE_UNLOCKED",
14
14
  /** Bienvenida al cerrar la venta. Solo la pista de crédito: la de contado no tiene `creditId`. */
15
15
  APP_WELCOME = "APP_WELCOME",
16
+ /** La venta se canceló y su crédito quedó descartado. Solo tras un descarte exitoso. */
17
+ SALE_CANCELLED_CREDIT_DISCARDED = "SALE_CANCELLED_CREDIT_DISCARDED",
16
18
  }
17
19
 
18
20
  /** Body de `POST /private/credits/{creditId}/lifecycle-facts`. */
@@ -6,12 +6,32 @@ import type {
6
6
  EvaluateRulesResponse,
7
7
  GenerateRulesRequest,
8
8
  GenerateRulesResponse,
9
+ PopulationCompileRequest,
10
+ PopulationCompileResponse,
11
+ PopulationExecutionPageResponse,
12
+ PopulationExecutionRequest,
13
+ PopulationExecutionResponse,
14
+ PopulationTestRequest,
15
+ PopulationTestResponse,
9
16
  RulesCatalogResponse,
17
+ SegmentSchemaResponse,
18
+ SegmentTableSchemaResponse,
10
19
  ValidateRulesRequest,
11
20
  ValidateRulesResponse,
12
21
  } from "@fiado/type-kit/bin/rules/index.js";
13
22
  import type { IRulesApi } from "./interfaces/IRulesApi.js";
14
23
 
24
+ // P2: el gateway de rewards corta a 29 s; el central corta la prueba a 12 s. Solo dispara ante falla real.
25
+ const POPULATION_TEST_CLIENT_TIMEOUT_MS = 20000;
26
+
27
+ const consumerQuery = (consumer?: string): string =>
28
+ consumer === undefined ? "" : `consumer=${encodeURIComponent(consumer)}`;
29
+
30
+ const withQuery = (url: string, ...parts: string[]): string => {
31
+ const query = parts.filter((part) => part !== "").join("&");
32
+ return query === "" ? url : `${url}?${query}`;
33
+ };
34
+
15
35
  /**
16
36
  * Contrato y semántica completos → `IRulesApi` (`StandardResponse` → leer `result.data`).
17
37
  * Env: `RULES_BUSINESS_LAMBDA_URL` (SSM `fiado-rulesbusiness-lambda`).
@@ -41,4 +61,44 @@ export class RulesApi implements IRulesApi {
41
61
  async evaluate(request: EvaluateRulesRequest): Promise<StandardResponse<EvaluateRulesResponse>> {
42
62
  return await this.httpRequest.post<StandardResponse<EvaluateRulesResponse>>(`${this.baseUrl}/evaluate`, request);
43
63
  }
64
+
65
+ async populationSchema(consumer?: string): Promise<StandardResponse<SegmentSchemaResponse>> {
66
+ const url = withQuery(`${this.baseUrl}/population/schema`, consumerQuery(consumer));
67
+ return await this.httpRequest.get<StandardResponse<SegmentSchemaResponse>>(url);
68
+ }
69
+
70
+ async populationTableSchema(table: string, consumer?: string): Promise<StandardResponse<SegmentTableSchemaResponse>> {
71
+ const url = withQuery(`${this.baseUrl}/population/schema/${encodeURIComponent(table)}`, consumerQuery(consumer));
72
+ return await this.httpRequest.get<StandardResponse<SegmentTableSchemaResponse>>(url);
73
+ }
74
+
75
+ async populationCompile(request: PopulationCompileRequest): Promise<StandardResponse<PopulationCompileResponse>> {
76
+ return await this.httpRequest.post<StandardResponse<PopulationCompileResponse>>(`${this.baseUrl}/population/compile`, request);
77
+ }
78
+
79
+ async populationTestStart(request: PopulationTestRequest): Promise<StandardResponse<PopulationTestResponse>> {
80
+ return await this.httpRequest.post<StandardResponse<PopulationTestResponse>>(
81
+ `${this.baseUrl}/population/tests`,
82
+ request,
83
+ undefined,
84
+ undefined,
85
+ undefined,
86
+ { timeout: POPULATION_TEST_CLIENT_TIMEOUT_MS },
87
+ );
88
+ }
89
+
90
+ async populationTestGet(testId: string, consumer?: string): Promise<StandardResponse<PopulationTestResponse>> {
91
+ const url = withQuery(`${this.baseUrl}/population/tests/${encodeURIComponent(testId)}`, consumerQuery(consumer));
92
+ return await this.httpRequest.get<StandardResponse<PopulationTestResponse>>(url);
93
+ }
94
+
95
+ async populationExecutionStart(request: PopulationExecutionRequest): Promise<StandardResponse<PopulationExecutionResponse>> {
96
+ return await this.httpRequest.post<StandardResponse<PopulationExecutionResponse>>(`${this.baseUrl}/population/executions`, request);
97
+ }
98
+
99
+ async populationExecutionPage(executionId: string, nextToken?: string, consumer?: string): Promise<StandardResponse<PopulationExecutionPageResponse>> {
100
+ const tokenQuery = nextToken === undefined ? "" : `nextToken=${encodeURIComponent(nextToken)}`;
101
+ const url = withQuery(`${this.baseUrl}/population/executions/${encodeURIComponent(executionId)}`, tokenQuery, consumerQuery(consumer));
102
+ return await this.httpRequest.get<StandardResponse<PopulationExecutionPageResponse>>(url);
103
+ }
44
104
  }
@@ -4,7 +4,16 @@ import type {
4
4
  EvaluateRulesResponse,
5
5
  GenerateRulesRequest,
6
6
  GenerateRulesResponse,
7
+ PopulationCompileRequest,
8
+ PopulationCompileResponse,
9
+ PopulationExecutionPageResponse,
10
+ PopulationExecutionRequest,
11
+ PopulationExecutionResponse,
12
+ PopulationTestRequest,
13
+ PopulationTestResponse,
7
14
  RulesCatalogResponse,
15
+ SegmentSchemaResponse,
16
+ SegmentTableSchemaResponse,
8
17
  ValidateRulesRequest,
9
18
  ValidateRulesResponse,
10
19
  } from "@fiado/type-kit/bin/rules/index.js";
@@ -27,4 +36,28 @@ export interface IRulesApi {
27
36
 
28
37
  /** POST /evaluate — evalúa reglas sobre hasta 100 sujetos por llamada (400 `TOO_MANY_SUBJECTS`). */
29
38
  evaluate(request: EvaluateRulesRequest): Promise<StandardResponse<EvaluateRulesResponse>>;
39
+
40
+ /** GET /population/schema — tablas del datalake disponibles para segmentar población. */
41
+ populationSchema(consumer?: string): Promise<StandardResponse<SegmentSchemaResponse>>;
42
+
43
+ /** GET /population/schema/{table} — columnas de una tabla del datalake. */
44
+ populationTableSchema(table: string, consumer?: string): Promise<StandardResponse<SegmentTableSchemaResponse>>;
45
+
46
+ /** POST /population/compile — compila una `definition` a SQL parametrizado (no ejecuta nada). */
47
+ populationCompile(request: PopulationCompileRequest): Promise<StandardResponse<PopulationCompileResponse>>;
48
+
49
+ /**
50
+ * POST /population/tests — prueba sin estado. El central corta a 12 s y responde RUNNING + `testId`;
51
+ * el cliente usa un timeout explícito de 20000 ms (solo dispara ante falla real → 503).
52
+ */
53
+ populationTestStart(request: PopulationTestRequest): Promise<StandardResponse<PopulationTestResponse>>;
54
+
55
+ /** GET /population/tests/{testId} — sondeo de una prueba iniciada. */
56
+ populationTestGet(testId: string, consumer?: string): Promise<StandardResponse<PopulationTestResponse>>;
57
+
58
+ /** POST /population/executions — inicia la ejecución de una población. */
59
+ populationExecutionStart(request: PopulationExecutionRequest): Promise<StandardResponse<PopulationExecutionResponse>>;
60
+
61
+ /** GET /population/executions/{id} — página (≤1000 ids) de una ejecución; `nextToken` para continuar. */
62
+ populationExecutionPage(executionId: string, nextToken?: string, consumer?: string): Promise<StandardResponse<PopulationExecutionPageResponse>>;
30
63
  }