@fiado/api-invoker 5.126.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 +5 -0
- package/bin/index.d.ts +2 -0
- package/bin/index.js +2 -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/bin/usmarketgrowth-business/UsMarketGrowthBusinessApi.d.ts +11 -0
- package/bin/usmarketgrowth-business/UsMarketGrowthBusinessApi.js +33 -0
- package/bin/usmarketgrowth-business/index.d.ts +2 -0
- package/bin/usmarketgrowth-business/index.js +2 -0
- package/bin/usmarketgrowth-business/interfaces/IUsMarketGrowthBusinessApi.d.ts +17 -0
- package/bin/usmarketgrowth-business/interfaces/IUsMarketGrowthBusinessApi.js +1 -0
- package/package.json +2 -2
- package/src/container.config.ts +5 -0
- package/src/index.ts +2 -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/src/usmarketgrowth-business/UsMarketGrowthBusinessApi.ts +22 -0
- package/src/usmarketgrowth-business/index.ts +2 -0
- package/src/usmarketgrowth-business/interfaces/IUsMarketGrowthBusinessApi.ts +17 -0
package/bin/container.config.js
CHANGED
|
@@ -72,6 +72,7 @@ import OnboardingBusinessApi from "./onboarding-business/api/OnboardingBusinessA
|
|
|
72
72
|
import { ExpedienteUpdatedPublisher } from "./onboarding-business/index.js";
|
|
73
73
|
import { PayrollApi } from "./payroll-business/index.js";
|
|
74
74
|
import { ReferralBusinessApi } from "./referral-business/index.js";
|
|
75
|
+
import { UsMarketGrowthBusinessApi } from "./usmarketgrowth-business/index.js";
|
|
75
76
|
import { EventHistoryApi } from "./event-history-business/index.js";
|
|
76
77
|
import ReportProcessorBusinessApi from "./report-processor-business/api/ReportProcessorBusinessApi.js";
|
|
77
78
|
import NotificationWSMessagePublisher from "./notificationWebsockets/queue/NotificationWSMessagePublisher.js";
|
|
@@ -146,6 +147,8 @@ import { CentralPaymentsWebhookApi } from "./central-payments-webhook/index.js";
|
|
|
146
147
|
// publisher de GRANT_FAILED + cliente del validador (rewards-eligibility-business)
|
|
147
148
|
import { RewardsGrantPublisher, RewardsBusinessApi } from "./rewards-business/index.js";
|
|
148
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";
|
|
149
152
|
import CollectionEngineApi from "./collection-engine/api/CollectionEngineApi.js";
|
|
150
153
|
import DomainCallbackApi from "./domain-callback/api/DomainCallbackApi.js";
|
|
151
154
|
export const apiInvokerBindings = new ContainerModule(({ bind }) => {
|
|
@@ -227,6 +230,7 @@ export const apiInvokerBindings = new ContainerModule(({ bind }) => {
|
|
|
227
230
|
bind("IOnboardingBusinessApi").to(OnboardingBusinessApi);
|
|
228
231
|
bind("IPayrollApi").to(PayrollApi);
|
|
229
232
|
bind("IReferralBusinessApi").to(ReferralBusinessApi);
|
|
233
|
+
bind("IUsMarketGrowthBusinessApi").to(UsMarketGrowthBusinessApi);
|
|
230
234
|
bind("IEventHistoryApi").to(EventHistoryApi);
|
|
231
235
|
bind("IReportProcessorBusinessApi").to(ReportProcessorBusinessApi);
|
|
232
236
|
bind("IPeopleBusinessApi").to(PeopleBusinessApi);
|
|
@@ -316,6 +320,7 @@ export const apiInvokerBindings = new ContainerModule(({ bind }) => {
|
|
|
316
320
|
// El productor necesita REWARDS_ELIGIBILITY_QUEUE_URL y sqs:SendMessage sobre la cola.
|
|
317
321
|
bind("IRewardsEligibilityPublisher").to(RewardsEligibilityPublisher);
|
|
318
322
|
bind("IRewardsEligibilityBusinessApi").to(RewardsEligibilityBusinessApi);
|
|
323
|
+
bind("IRulesApi").to(RulesApi);
|
|
319
324
|
// Collection engine — motor de cobro central multitenant (collect/deregister)
|
|
320
325
|
bind("ICollectionEngineApi").to(CollectionEngineApi);
|
|
321
326
|
// Domain callback — el motor notifica al dominio dueño del cargo (applyCollectionResult)
|
package/bin/index.d.ts
CHANGED
|
@@ -62,6 +62,7 @@ export * from "./onboarding/index.js";
|
|
|
62
62
|
export * from "./onboarding-business/index.js";
|
|
63
63
|
export * from "./payroll-business/index.js";
|
|
64
64
|
export * from "./referral-business/index.js";
|
|
65
|
+
export * from "./usmarketgrowth-business/index.js";
|
|
65
66
|
export * from "./event-history-business/index.js";
|
|
66
67
|
export * from "./report-processor-business/index.js";
|
|
67
68
|
export * from "./notificationWebsockets/index.js";
|
|
@@ -126,3 +127,4 @@ export * from "./webhook-business/index.js";
|
|
|
126
127
|
export * from "./trustonicConnector/index.js";
|
|
127
128
|
export * from "./rewards-business/index.js";
|
|
128
129
|
export * from "./rewards-eligibility-business/index.js";
|
|
130
|
+
export * from "./rules-business/index.js";
|
package/bin/index.js
CHANGED
|
@@ -62,6 +62,7 @@ export * from "./onboarding/index.js";
|
|
|
62
62
|
export * from "./onboarding-business/index.js";
|
|
63
63
|
export * from "./payroll-business/index.js";
|
|
64
64
|
export * from "./referral-business/index.js";
|
|
65
|
+
export * from "./usmarketgrowth-business/index.js";
|
|
65
66
|
export * from "./event-history-business/index.js";
|
|
66
67
|
export * from "./report-processor-business/index.js";
|
|
67
68
|
export * from "./notificationWebsockets/index.js";
|
|
@@ -126,3 +127,4 @@ export * from "./webhook-business/index.js";
|
|
|
126
127
|
export * from "./trustonicConnector/index.js";
|
|
127
128
|
export * from "./rewards-business/index.js";
|
|
128
129
|
export * from "./rewards-eligibility-business/index.js";
|
|
130
|
+
export * from "./rules-business/index.js";
|
|
@@ -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 {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IHttpRequest } from "@fiado/http-client";
|
|
2
|
+
import type { PromoterByDirectoryIdResponse } from "@fiado/type-kit/bin/usmarketgrowth-business/index.js";
|
|
3
|
+
import { IUsMarketGrowthBusinessApi } from "./interfaces/IUsMarketGrowthBusinessApi.js";
|
|
4
|
+
type FiadoApiResponse<T> = import("@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse.js").default<T>;
|
|
5
|
+
export declare class UsMarketGrowthBusinessApi implements IUsMarketGrowthBusinessApi {
|
|
6
|
+
private httpRequest;
|
|
7
|
+
private readonly baseUrl;
|
|
8
|
+
constructor(httpRequest: IHttpRequest);
|
|
9
|
+
getPromoterByDirectoryId(directoryId: string): Promise<FiadoApiResponse<PromoterByDirectoryIdResponse>>;
|
|
10
|
+
}
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
import dotenv from 'dotenv';
|
|
15
|
+
import { joinUrl } from "../utils/joinUrl.js";
|
|
16
|
+
dotenv.config();
|
|
17
|
+
let UsMarketGrowthBusinessApi = class UsMarketGrowthBusinessApi {
|
|
18
|
+
httpRequest;
|
|
19
|
+
baseUrl = process.env.USMARKETGROWTH_BUSINESS_LAMBDA_URL || "";
|
|
20
|
+
constructor(httpRequest) {
|
|
21
|
+
this.httpRequest = httpRequest;
|
|
22
|
+
}
|
|
23
|
+
async getPromoterByDirectoryId(directoryId) {
|
|
24
|
+
const url = joinUrl(this.baseUrl, `private/promoters/directoryId/${encodeURIComponent(directoryId)}`);
|
|
25
|
+
return await this.httpRequest.get(url);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
UsMarketGrowthBusinessApi = __decorate([
|
|
29
|
+
injectable(),
|
|
30
|
+
__param(0, inject("IHttpRequest")),
|
|
31
|
+
__metadata("design:paramtypes", [Object])
|
|
32
|
+
], UsMarketGrowthBusinessApi);
|
|
33
|
+
export { UsMarketGrowthBusinessApi };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
type FiadoApiResponse<T> = import("@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse.js").default<T>;
|
|
2
|
+
import type { PromoterByDirectoryIdResponse } from "@fiado/type-kit/bin/usmarketgrowth-business/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Cliente de `usmarketgrowth-business` (promotores de US Market Growth).
|
|
5
|
+
*
|
|
6
|
+
* Env var requerida en el consumer: `USMARKETGROWTH_BUSINESS_LAMBDA_URL`, resuelta con
|
|
7
|
+
* `{{resolve:ssm:usmarketgrowth-business}}`.
|
|
8
|
+
*/
|
|
9
|
+
export interface IUsMarketGrowthBusinessApi {
|
|
10
|
+
/**
|
|
11
|
+
* Promotor ligado a un directorio (un directorio por llamada).
|
|
12
|
+
* Si el directorio no es de un promotor, el lambda responde 404 `PROMOTER_NOT_FOUND`.
|
|
13
|
+
* @param directoryId ID del directorio.
|
|
14
|
+
*/
|
|
15
|
+
getPromoterByDirectoryId(directoryId: string): Promise<FiadoApiResponse<PromoterByDirectoryIdResponse>>;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -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
|
@@ -103,6 +103,7 @@ import OnboardingBusinessApi from "./onboarding-business/api/OnboardingBusinessA
|
|
|
103
103
|
import { IOnboardingBusinessApi, IExpedienteUpdatedPublisher, ExpedienteUpdatedPublisher } from "./onboarding-business/index.js";
|
|
104
104
|
import { IPayrollApi, PayrollApi } from "./payroll-business/index.js";
|
|
105
105
|
import { IReferralBusinessApi, ReferralBusinessApi } from "./referral-business/index.js";
|
|
106
|
+
import { IUsMarketGrowthBusinessApi, UsMarketGrowthBusinessApi } from "./usmarketgrowth-business/index.js";
|
|
106
107
|
import { EventHistoryApi, IEventHistoryApi } from "./event-history-business/index.js";
|
|
107
108
|
import ReportProcessorBusinessApi from "./report-processor-business/api/ReportProcessorBusinessApi.js";
|
|
108
109
|
import { IReportProcessorBusinessApi } from "./report-processor-business/index.js";
|
|
@@ -212,6 +213,8 @@ import { ICentralPaymentsWebhookApi, CentralPaymentsWebhookApi } from "./central
|
|
|
212
213
|
// publisher de GRANT_FAILED + cliente del validador (rewards-eligibility-business)
|
|
213
214
|
import { IRewardsGrantPublisher, IRewardsBusinessApi, RewardsGrantPublisher, RewardsBusinessApi } from "./rewards-business/index.js";
|
|
214
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";
|
|
215
218
|
// Collection engine — cliente del motor de cobro central (collect/deregister)
|
|
216
219
|
import { ICollectionEngineApi } from "./collection-engine/index.js";
|
|
217
220
|
import CollectionEngineApi from "./collection-engine/api/CollectionEngineApi.js";
|
|
@@ -300,6 +303,7 @@ export const apiInvokerBindings = new ContainerModule(({ bind }) => {
|
|
|
300
303
|
bind<IOnboardingBusinessApi>("IOnboardingBusinessApi").to(OnboardingBusinessApi);
|
|
301
304
|
bind<IPayrollApi>("IPayrollApi").to(PayrollApi);
|
|
302
305
|
bind<IReferralBusinessApi>("IReferralBusinessApi").to(ReferralBusinessApi);
|
|
306
|
+
bind<IUsMarketGrowthBusinessApi>("IUsMarketGrowthBusinessApi").to(UsMarketGrowthBusinessApi);
|
|
303
307
|
bind<IEventHistoryApi>("IEventHistoryApi").to(EventHistoryApi);
|
|
304
308
|
bind<IReportProcessorBusinessApi>("IReportProcessorBusinessApi").to(ReportProcessorBusinessApi);
|
|
305
309
|
bind<IPeopleBusinessApi>("IPeopleBusinessApi").to(PeopleBusinessApi);
|
|
@@ -415,6 +419,7 @@ export const apiInvokerBindings = new ContainerModule(({ bind }) => {
|
|
|
415
419
|
// El productor necesita REWARDS_ELIGIBILITY_QUEUE_URL y sqs:SendMessage sobre la cola.
|
|
416
420
|
bind<IRewardsEligibilityPublisher>("IRewardsEligibilityPublisher").to(RewardsEligibilityPublisher);
|
|
417
421
|
bind<IRewardsEligibilityBusinessApi>("IRewardsEligibilityBusinessApi").to(RewardsEligibilityBusinessApi);
|
|
422
|
+
bind<IRulesApi>("IRulesApi").to(RulesApi);
|
|
418
423
|
|
|
419
424
|
// Collection engine — motor de cobro central multitenant (collect/deregister)
|
|
420
425
|
bind<ICollectionEngineApi>("ICollectionEngineApi").to(CollectionEngineApi);
|
package/src/index.ts
CHANGED
|
@@ -62,6 +62,7 @@ export * from "./onboarding/index.js";
|
|
|
62
62
|
export * from "./onboarding-business/index.js";
|
|
63
63
|
export * from "./payroll-business/index.js";
|
|
64
64
|
export * from "./referral-business/index.js";
|
|
65
|
+
export * from "./usmarketgrowth-business/index.js";
|
|
65
66
|
export * from "./event-history-business/index.js";
|
|
66
67
|
export * from "./report-processor-business/index.js";
|
|
67
68
|
export * from "./notificationWebsockets/index.js";
|
|
@@ -126,3 +127,4 @@ export * from "./webhook-business/index.js";
|
|
|
126
127
|
export * from "./trustonicConnector/index.js";
|
|
127
128
|
export * from "./rewards-business/index.js";
|
|
128
129
|
export * from "./rewards-eligibility-business/index.js";
|
|
130
|
+
export * from "./rules-business/index.js";
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { inject, injectable } from "inversify";
|
|
2
|
+
import type { IHttpRequest } from "@fiado/http-client";
|
|
3
|
+
import dotenv from 'dotenv';
|
|
4
|
+
import type { PromoterByDirectoryIdResponse } from "@fiado/type-kit/bin/usmarketgrowth-business/index.js";
|
|
5
|
+
import { IUsMarketGrowthBusinessApi } from "./interfaces/IUsMarketGrowthBusinessApi.js";
|
|
6
|
+
import { joinUrl } from "../utils/joinUrl.js";
|
|
7
|
+
type FiadoApiResponse<T> = import("@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse.js").default<T>;
|
|
8
|
+
|
|
9
|
+
dotenv.config();
|
|
10
|
+
|
|
11
|
+
@injectable()
|
|
12
|
+
export class UsMarketGrowthBusinessApi implements IUsMarketGrowthBusinessApi {
|
|
13
|
+
|
|
14
|
+
private readonly baseUrl = process.env.USMARKETGROWTH_BUSINESS_LAMBDA_URL || "";
|
|
15
|
+
|
|
16
|
+
constructor(@inject("IHttpRequest") private httpRequest: IHttpRequest) { }
|
|
17
|
+
|
|
18
|
+
async getPromoterByDirectoryId(directoryId: string): Promise<FiadoApiResponse<PromoterByDirectoryIdResponse>> {
|
|
19
|
+
const url = joinUrl(this.baseUrl, `private/promoters/directoryId/${encodeURIComponent(directoryId)}`);
|
|
20
|
+
return await this.httpRequest.get(url);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
type FiadoApiResponse<T> = import("@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse.js").default<T>;
|
|
2
|
+
import type { PromoterByDirectoryIdResponse } from "@fiado/type-kit/bin/usmarketgrowth-business/index.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Cliente de `usmarketgrowth-business` (promotores de US Market Growth).
|
|
6
|
+
*
|
|
7
|
+
* Env var requerida en el consumer: `USMARKETGROWTH_BUSINESS_LAMBDA_URL`, resuelta con
|
|
8
|
+
* `{{resolve:ssm:usmarketgrowth-business}}`.
|
|
9
|
+
*/
|
|
10
|
+
export interface IUsMarketGrowthBusinessApi {
|
|
11
|
+
/**
|
|
12
|
+
* Promotor ligado a un directorio (un directorio por llamada).
|
|
13
|
+
* Si el directorio no es de un promotor, el lambda responde 404 `PROMOTER_NOT_FOUND`.
|
|
14
|
+
* @param directoryId ID del directorio.
|
|
15
|
+
*/
|
|
16
|
+
getPromoterByDirectoryId(directoryId: string): Promise<FiadoApiResponse<PromoterByDirectoryIdResponse>>;
|
|
17
|
+
}
|