@fiado/api-invoker 5.127.0 → 5.128.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/container.config.js +3 -0
- package/bin/index.d.ts +1 -0
- package/bin/index.js +1 -0
- package/bin/rules-business/api/RulesApi.d.ts +17 -0
- package/bin/rules-business/api/RulesApi.js +45 -0
- package/bin/rules-business/api/interfaces/IRulesApi.d.ts +18 -0
- package/bin/rules-business/api/interfaces/IRulesApi.js +1 -0
- package/bin/rules-business/index.d.ts +2 -0
- package/bin/rules-business/index.js +2 -0
- package/package.json +2 -2
- package/src/container.config.ts +3 -0
- package/src/index.ts +1 -0
- package/src/rules-business/api/RulesApi.ts +44 -0
- package/src/rules-business/api/interfaces/IRulesApi.ts +30 -0
- package/src/rules-business/index.ts +2 -0
package/bin/container.config.js
CHANGED
|
@@ -147,6 +147,8 @@ import { CentralPaymentsWebhookApi } from "./central-payments-webhook/index.js";
|
|
|
147
147
|
// publisher de GRANT_FAILED + cliente del validador (rewards-eligibility-business)
|
|
148
148
|
import { RewardsGrantPublisher, RewardsBusinessApi } from "./rewards-business/index.js";
|
|
149
149
|
import { RewardsEligibilityPublisher, RewardsEligibilityBusinessApi } from "./rewards-eligibility-business/index.js";
|
|
150
|
+
// Rules — cliente del lambda central de reglas (rules-business)
|
|
151
|
+
import { RulesApi } from "./rules-business/index.js";
|
|
150
152
|
import CollectionEngineApi from "./collection-engine/api/CollectionEngineApi.js";
|
|
151
153
|
import DomainCallbackApi from "./domain-callback/api/DomainCallbackApi.js";
|
|
152
154
|
export const apiInvokerBindings = new ContainerModule(({ bind }) => {
|
|
@@ -318,6 +320,7 @@ export const apiInvokerBindings = new ContainerModule(({ bind }) => {
|
|
|
318
320
|
// El productor necesita REWARDS_ELIGIBILITY_QUEUE_URL y sqs:SendMessage sobre la cola.
|
|
319
321
|
bind("IRewardsEligibilityPublisher").to(RewardsEligibilityPublisher);
|
|
320
322
|
bind("IRewardsEligibilityBusinessApi").to(RewardsEligibilityBusinessApi);
|
|
323
|
+
bind("IRulesApi").to(RulesApi);
|
|
321
324
|
// Collection engine — motor de cobro central multitenant (collect/deregister)
|
|
322
325
|
bind("ICollectionEngineApi").to(CollectionEngineApi);
|
|
323
326
|
// Domain callback — el motor notifica al dominio dueño del cargo (applyCollectionResult)
|
package/bin/index.d.ts
CHANGED
package/bin/index.js
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { StandardResponse } from "@fiado/gateway-adapter";
|
|
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";
|
|
4
|
+
import type { IRulesApi } from "./interfaces/IRulesApi.js";
|
|
5
|
+
/**
|
|
6
|
+
* Contrato y semántica completos → `IRulesApi` (`StandardResponse` → leer `result.data`).
|
|
7
|
+
* Env: `RULES_BUSINESS_LAMBDA_URL` (SSM `fiado-rulesbusiness-lambda`).
|
|
8
|
+
*/
|
|
9
|
+
export declare class RulesApi implements IRulesApi {
|
|
10
|
+
private httpRequest;
|
|
11
|
+
private readonly baseUrl;
|
|
12
|
+
constructor(httpRequest: IHttpRequest);
|
|
13
|
+
catalog(items: string[], consumer?: string): Promise<StandardResponse<RulesCatalogResponse>>;
|
|
14
|
+
validate(request: ValidateRulesRequest): Promise<StandardResponse<ValidateRulesResponse>>;
|
|
15
|
+
generate(request: GenerateRulesRequest): Promise<StandardResponse<GenerateRulesResponse>>;
|
|
16
|
+
evaluate(request: EvaluateRulesRequest): Promise<StandardResponse<EvaluateRulesResponse>>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
* Contrato y semántica completos → `IRulesApi` (`StandardResponse` → leer `result.data`).
|
|
16
|
+
* Env: `RULES_BUSINESS_LAMBDA_URL` (SSM `fiado-rulesbusiness-lambda`).
|
|
17
|
+
*/
|
|
18
|
+
let RulesApi = class RulesApi {
|
|
19
|
+
httpRequest;
|
|
20
|
+
// El buildspec publica la URL en SSM con "/" final (`.../v1/`): se normaliza para no armar "//catalog".
|
|
21
|
+
baseUrl = (process.env.RULES_BUSINESS_LAMBDA_URL || "").replace(/\/+$/, "");
|
|
22
|
+
constructor(httpRequest) {
|
|
23
|
+
this.httpRequest = httpRequest;
|
|
24
|
+
}
|
|
25
|
+
async catalog(items, consumer) {
|
|
26
|
+
const consumerQuery = consumer === undefined ? "" : `&consumer=${encodeURIComponent(consumer)}`;
|
|
27
|
+
const url = `${this.baseUrl}/catalog?items=${encodeURIComponent(items.join(","))}${consumerQuery}`;
|
|
28
|
+
return await this.httpRequest.get(url);
|
|
29
|
+
}
|
|
30
|
+
async validate(request) {
|
|
31
|
+
return await this.httpRequest.post(`${this.baseUrl}/validate`, request);
|
|
32
|
+
}
|
|
33
|
+
async generate(request) {
|
|
34
|
+
return await this.httpRequest.post(`${this.baseUrl}/generate`, request);
|
|
35
|
+
}
|
|
36
|
+
async evaluate(request) {
|
|
37
|
+
return await this.httpRequest.post(`${this.baseUrl}/evaluate`, request);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
RulesApi = __decorate([
|
|
41
|
+
injectable(),
|
|
42
|
+
__param(0, inject("IHttpRequest")),
|
|
43
|
+
__metadata("design:paramtypes", [Object])
|
|
44
|
+
], RulesApi);
|
|
45
|
+
export { RulesApi };
|
|
@@ -0,0 +1,18 @@
|
|
|
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";
|
|
3
|
+
/**
|
|
4
|
+
* Cliente del lambda central `rules-business` (catálogo, validación, generación con IA y evaluación de reglas).
|
|
5
|
+
*
|
|
6
|
+
* Configuración: env `RULES_BUSINESS_LAMBDA_URL` (SSM `fiado-rulesbusiness-lambda`, API PRIVADA, stage `v1`).
|
|
7
|
+
* Todas las respuestas son `StandardResponse` → leer `result.data`.
|
|
8
|
+
*/
|
|
9
|
+
export interface IRulesApi {
|
|
10
|
+
/** GET /catalog — ítems pedidos (`source:key`) en el orden canónico del registro, no en el orden pedido. */
|
|
11
|
+
catalog(items: string[], consumer?: string): Promise<StandardResponse<RulesCatalogResponse>>;
|
|
12
|
+
/** POST /validate — valida la forma de una regla contra los ítems indicados. */
|
|
13
|
+
validate(request: ValidateRulesRequest): Promise<StandardResponse<ValidateRulesResponse>>;
|
|
14
|
+
/** POST /generate — genera/ajusta una regla con IA a partir del chat. */
|
|
15
|
+
generate(request: GenerateRulesRequest): Promise<StandardResponse<GenerateRulesResponse>>;
|
|
16
|
+
/** POST /evaluate — evalúa reglas sobre hasta 100 sujetos por llamada (400 `TOO_MANY_SUBJECTS`). */
|
|
17
|
+
evaluate(request: EvaluateRulesRequest): Promise<StandardResponse<EvaluateRulesResponse>>;
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fiado/api-invoker",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.128.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.
|
|
37
|
+
"@fiado/type-kit": "^3.539.0",
|
|
38
38
|
"dotenv": "^16.4.7"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
package/src/container.config.ts
CHANGED
|
@@ -213,6 +213,8 @@ import { ICentralPaymentsWebhookApi, CentralPaymentsWebhookApi } from "./central
|
|
|
213
213
|
// publisher de GRANT_FAILED + cliente del validador (rewards-eligibility-business)
|
|
214
214
|
import { IRewardsGrantPublisher, IRewardsBusinessApi, RewardsGrantPublisher, RewardsBusinessApi } from "./rewards-business/index.js";
|
|
215
215
|
import { IRewardsEligibilityPublisher, IRewardsEligibilityBusinessApi, RewardsEligibilityPublisher, RewardsEligibilityBusinessApi } from "./rewards-eligibility-business/index.js";
|
|
216
|
+
// Rules — cliente del lambda central de reglas (rules-business)
|
|
217
|
+
import { IRulesApi, RulesApi } from "./rules-business/index.js";
|
|
216
218
|
// Collection engine — cliente del motor de cobro central (collect/deregister)
|
|
217
219
|
import { ICollectionEngineApi } from "./collection-engine/index.js";
|
|
218
220
|
import CollectionEngineApi from "./collection-engine/api/CollectionEngineApi.js";
|
|
@@ -417,6 +419,7 @@ export const apiInvokerBindings = new ContainerModule(({ bind }) => {
|
|
|
417
419
|
// El productor necesita REWARDS_ELIGIBILITY_QUEUE_URL y sqs:SendMessage sobre la cola.
|
|
418
420
|
bind<IRewardsEligibilityPublisher>("IRewardsEligibilityPublisher").to(RewardsEligibilityPublisher);
|
|
419
421
|
bind<IRewardsEligibilityBusinessApi>("IRewardsEligibilityBusinessApi").to(RewardsEligibilityBusinessApi);
|
|
422
|
+
bind<IRulesApi>("IRulesApi").to(RulesApi);
|
|
420
423
|
|
|
421
424
|
// Collection engine — motor de cobro central multitenant (collect/deregister)
|
|
422
425
|
bind<ICollectionEngineApi>("ICollectionEngineApi").to(CollectionEngineApi);
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { inject, injectable } from "inversify";
|
|
2
|
+
import type { StandardResponse } from "@fiado/gateway-adapter";
|
|
3
|
+
import type { IHttpRequest } from "@fiado/http-client";
|
|
4
|
+
import type {
|
|
5
|
+
EvaluateRulesRequest,
|
|
6
|
+
EvaluateRulesResponse,
|
|
7
|
+
GenerateRulesRequest,
|
|
8
|
+
GenerateRulesResponse,
|
|
9
|
+
RulesCatalogResponse,
|
|
10
|
+
ValidateRulesRequest,
|
|
11
|
+
ValidateRulesResponse,
|
|
12
|
+
} from "@fiado/type-kit/bin/rules/index.js";
|
|
13
|
+
import type { IRulesApi } from "./interfaces/IRulesApi.js";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Contrato y semántica completos → `IRulesApi` (`StandardResponse` → leer `result.data`).
|
|
17
|
+
* Env: `RULES_BUSINESS_LAMBDA_URL` (SSM `fiado-rulesbusiness-lambda`).
|
|
18
|
+
*/
|
|
19
|
+
@injectable()
|
|
20
|
+
export class RulesApi implements IRulesApi {
|
|
21
|
+
|
|
22
|
+
// El buildspec publica la URL en SSM con "/" final (`.../v1/`): se normaliza para no armar "//catalog".
|
|
23
|
+
private readonly baseUrl = (process.env.RULES_BUSINESS_LAMBDA_URL || "").replace(/\/+$/, "");
|
|
24
|
+
|
|
25
|
+
constructor(@inject("IHttpRequest") private httpRequest: IHttpRequest) { }
|
|
26
|
+
|
|
27
|
+
async catalog(items: string[], consumer?: string): Promise<StandardResponse<RulesCatalogResponse>> {
|
|
28
|
+
const consumerQuery = consumer === undefined ? "" : `&consumer=${encodeURIComponent(consumer)}`;
|
|
29
|
+
const url = `${this.baseUrl}/catalog?items=${encodeURIComponent(items.join(","))}${consumerQuery}`;
|
|
30
|
+
return await this.httpRequest.get<StandardResponse<RulesCatalogResponse>>(url);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async validate(request: ValidateRulesRequest): Promise<StandardResponse<ValidateRulesResponse>> {
|
|
34
|
+
return await this.httpRequest.post<StandardResponse<ValidateRulesResponse>>(`${this.baseUrl}/validate`, request);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async generate(request: GenerateRulesRequest): Promise<StandardResponse<GenerateRulesResponse>> {
|
|
38
|
+
return await this.httpRequest.post<StandardResponse<GenerateRulesResponse>>(`${this.baseUrl}/generate`, request);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async evaluate(request: EvaluateRulesRequest): Promise<StandardResponse<EvaluateRulesResponse>> {
|
|
42
|
+
return await this.httpRequest.post<StandardResponse<EvaluateRulesResponse>>(`${this.baseUrl}/evaluate`, request);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { StandardResponse } from "@fiado/gateway-adapter";
|
|
2
|
+
import type {
|
|
3
|
+
EvaluateRulesRequest,
|
|
4
|
+
EvaluateRulesResponse,
|
|
5
|
+
GenerateRulesRequest,
|
|
6
|
+
GenerateRulesResponse,
|
|
7
|
+
RulesCatalogResponse,
|
|
8
|
+
ValidateRulesRequest,
|
|
9
|
+
ValidateRulesResponse,
|
|
10
|
+
} from "@fiado/type-kit/bin/rules/index.js";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Cliente del lambda central `rules-business` (catálogo, validación, generación con IA y evaluación de reglas).
|
|
14
|
+
*
|
|
15
|
+
* Configuración: env `RULES_BUSINESS_LAMBDA_URL` (SSM `fiado-rulesbusiness-lambda`, API PRIVADA, stage `v1`).
|
|
16
|
+
* Todas las respuestas son `StandardResponse` → leer `result.data`.
|
|
17
|
+
*/
|
|
18
|
+
export interface IRulesApi {
|
|
19
|
+
/** GET /catalog — ítems pedidos (`source:key`) en el orden canónico del registro, no en el orden pedido. */
|
|
20
|
+
catalog(items: string[], consumer?: string): Promise<StandardResponse<RulesCatalogResponse>>;
|
|
21
|
+
|
|
22
|
+
/** POST /validate — valida la forma de una regla contra los ítems indicados. */
|
|
23
|
+
validate(request: ValidateRulesRequest): Promise<StandardResponse<ValidateRulesResponse>>;
|
|
24
|
+
|
|
25
|
+
/** POST /generate — genera/ajusta una regla con IA a partir del chat. */
|
|
26
|
+
generate(request: GenerateRulesRequest): Promise<StandardResponse<GenerateRulesResponse>>;
|
|
27
|
+
|
|
28
|
+
/** POST /evaluate — evalúa reglas sobre hasta 100 sujetos por llamada (400 `TOO_MANY_SUBJECTS`). */
|
|
29
|
+
evaluate(request: EvaluateRulesRequest): Promise<StandardResponse<EvaluateRulesResponse>>;
|
|
30
|
+
}
|