@fiado/api-invoker 5.77.0 → 5.79.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 +1 -0
- package/bin/index.js +1 -0
- package/bin/loanCredit/api/LoanCreditBusinessApi.d.ts +2 -0
- package/bin/loanCredit/api/LoanCreditBusinessApi.js +4 -0
- package/bin/loanCredit/api/dtos/CreditLifecycleFact.d.ts +31 -0
- package/bin/loanCredit/api/dtos/CreditLifecycleFact.js +17 -0
- package/bin/loanCredit/api/interfaces/ILoanCreditBusinessApi.d.ts +12 -0
- package/bin/loanCredit/index.d.ts +1 -0
- package/bin/loanCredit/index.js +1 -0
- package/bin/whatsapp-connector/api/WhatsappConnectorApi.d.ts +11 -0
- package/bin/whatsapp-connector/api/WhatsappConnectorApi.js +31 -0
- package/bin/whatsapp-connector/api/interfaces/IWhatsappConnectorApi.d.ts +10 -0
- package/bin/whatsapp-connector/api/interfaces/IWhatsappConnectorApi.js +1 -0
- package/bin/whatsapp-connector/index.d.ts +2 -0
- package/bin/whatsapp-connector/index.js +2 -0
- package/package.json +2 -2
- package/src/container.config.ts +6 -0
- package/src/index.ts +1 -0
- package/src/loanCredit/api/LoanCreditBusinessApi.ts +13 -0
- package/src/loanCredit/api/dtos/CreditLifecycleFact.ts +33 -0
- package/src/loanCredit/api/interfaces/ILoanCreditBusinessApi.ts +20 -0
- package/src/loanCredit/index.ts +1 -0
- package/src/whatsapp-connector/api/WhatsappConnectorApi.ts +19 -0
- package/src/whatsapp-connector/api/interfaces/IWhatsappConnectorApi.ts +11 -0
- package/src/whatsapp-connector/index.ts +2 -0
package/bin/container.config.js
CHANGED
|
@@ -124,6 +124,8 @@ import { WalletFundingRulesApi } from "./wallet-funding-rules/index.js";
|
|
|
124
124
|
import { SnsSesConnectorApi } from "./sns-ses-connector/index.js";
|
|
125
125
|
// Twilio connector — envío WhatsApp/SMS por Twilio (lee TWILIO_CONNECTOR_LAMBDA_URL)
|
|
126
126
|
import { TwilioConnectorApi } from "./twilio-connector/index.js";
|
|
127
|
+
// Whatsapp connector — envío WhatsApp por Meta (lee WHATSAPP_CONNECTOR_LAMBDA_URL)
|
|
128
|
+
import { WhatsappConnectorApi } from "./whatsapp-connector/index.js";
|
|
127
129
|
// Remittance business — pricingResolve (Dashboard Ops Fase B, puente de resolución de precio en send-time)
|
|
128
130
|
import { RemittanceBusinessApi } from "./remittance-business/index.js";
|
|
129
131
|
import { BeneficiaryApi } from "./beneficiary/index.js";
|
|
@@ -274,6 +276,9 @@ export const apiInvokerBindings = new ContainerModule(({ bind }) => {
|
|
|
274
276
|
// Twilio connector — envío WhatsApp/SMS por Twilio, elegido por el `provider` del senderConfig.
|
|
275
277
|
// El consumidor necesita TWILIO_CONNECTOR_LAMBDA_URL desde el SSM `fiado-twilio-connector`.
|
|
276
278
|
bind("ITwilioConnectorApi").to(TwilioConnectorApi);
|
|
279
|
+
// Whatsapp connector — envío WhatsApp por Meta, elegido por el `provider` del senderConfig.
|
|
280
|
+
// El consumidor necesita WHATSAPP_CONNECTOR_LAMBDA_URL desde el SSM `whatsapp-connector`.
|
|
281
|
+
bind("IWhatsappConnectorApi").to(WhatsappConnectorApi);
|
|
277
282
|
// Remittance business — pricingResolve (Dashboard Ops Fase B, puente de resolución de precio en send-time)
|
|
278
283
|
bind("IRemittanceBusinessApi").to(RemittanceBusinessApi);
|
|
279
284
|
// Borrado en cascada del directorio — deleteByDirectoryId por dominio
|
package/bin/index.d.ts
CHANGED
|
@@ -104,6 +104,7 @@ export * from "./walletFundingSettlement/index.js";
|
|
|
104
104
|
export * from "./wallet-funding-rules/index.js";
|
|
105
105
|
export * from "./sns-ses-connector/index.js";
|
|
106
106
|
export * from "./twilio-connector/index.js";
|
|
107
|
+
export * from "./whatsapp-connector/index.js";
|
|
107
108
|
export * from "./remittance-business/index.js";
|
|
108
109
|
export * from "./modelias-connector/index.js";
|
|
109
110
|
export * from "./beneficiary/index.js";
|
package/bin/index.js
CHANGED
|
@@ -104,6 +104,7 @@ export * from "./walletFundingSettlement/index.js";
|
|
|
104
104
|
export * from "./wallet-funding-rules/index.js";
|
|
105
105
|
export * from "./sns-ses-connector/index.js";
|
|
106
106
|
export * from "./twilio-connector/index.js";
|
|
107
|
+
export * from "./whatsapp-connector/index.js";
|
|
107
108
|
export * from "./remittance-business/index.js";
|
|
108
109
|
export * from "./modelias-connector/index.js";
|
|
109
110
|
export * from "./beneficiary/index.js";
|
|
@@ -3,6 +3,7 @@ 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 } from "@fiado/type-kit/bin/loanCredit/index.js";
|
|
4
4
|
import { LoanCreditAnalyticsBatchRequest, LoanCreditAnalyticsBatchResponse } from "./dtos/LoanCreditAnalyticsBatch.js";
|
|
5
5
|
import { CustomerCreditHistoryResponse } from "./dtos/CustomerCreditHistory.js";
|
|
6
|
+
import { CreditLifecycleFactRequest, CreditLifecycleFactResponse } from "./dtos/CreditLifecycleFact.js";
|
|
6
7
|
import { ILoanCreditBusinessApi } from "./interfaces/ILoanCreditBusinessApi.js";
|
|
7
8
|
/**
|
|
8
9
|
* Publisher HTTP del lambda `loan-credit-business` (componente 09 SureKeep F2 — motor de crédito).
|
|
@@ -32,5 +33,6 @@ export default class LoanCreditBusinessApi implements ILoanCreditBusinessApi {
|
|
|
32
33
|
getCustomerCreditHistory(retailCustomerId: string, tenantId: string): Promise<StandardResponse<CustomerCreditHistoryResponse>>;
|
|
33
34
|
batchGetCreditAnalytics(input: LoanCreditAnalyticsBatchRequest, tenantId: string): Promise<StandardResponse<LoanCreditAnalyticsBatchResponse>>;
|
|
34
35
|
upsertBorrower(input: UpsertLoanBorrowerRequest, tenantId: string): Promise<StandardResponse<LoanBorrowerResponse>>;
|
|
36
|
+
notifyLifecycleFact(creditId: string, input: CreditLifecycleFactRequest, tenantId: string): Promise<StandardResponse<CreditLifecycleFactResponse>>;
|
|
35
37
|
listMessagingCandidates(input: ListMessagingCandidatesRequest, tenantId: string): Promise<StandardResponse<ListMessagingCandidatesResponse>>;
|
|
36
38
|
}
|
|
@@ -78,6 +78,10 @@ let LoanCreditBusinessApi = class LoanCreditBusinessApi {
|
|
|
78
78
|
const url = `${this.baseUrl}/private/borrowers?tenantId=${encodeURIComponent(tenantId)}`;
|
|
79
79
|
return await this.httpRequest.post(url, input);
|
|
80
80
|
}
|
|
81
|
+
async notifyLifecycleFact(creditId, input, tenantId) {
|
|
82
|
+
const url = `${this.baseUrl}/private/credits/${encodeURIComponent(creditId)}/lifecycle-facts?tenantId=${encodeURIComponent(tenantId)}`;
|
|
83
|
+
return await this.httpRequest.post(url, input);
|
|
84
|
+
}
|
|
81
85
|
async listMessagingCandidates(input, tenantId) {
|
|
82
86
|
const url = `${this.baseUrl}/private/messaging/candidates?tenantId=${encodeURIComponent(tenantId)}`;
|
|
83
87
|
return await this.httpRequest.post(url, input);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Los HECHOS del ciclo del crédito que le avisan algo al cliente. El productor nombra el hecho y
|
|
3
|
+
* nada más — el momento, la plantilla, el canal y el texto los resuelve `loan-credit-business`.
|
|
4
|
+
*/
|
|
5
|
+
export declare enum CreditLifecycleFactEnum {
|
|
6
|
+
APPLICATION_APPROVED = "APPLICATION_APPROVED",
|
|
7
|
+
DOWN_PAYMENT_RECEIVED = "DOWN_PAYMENT_RECEIVED",
|
|
8
|
+
CONTRACT_SIGNED = "CONTRACT_SIGNED",
|
|
9
|
+
MDM_ACTIVATED = "MDM_ACTIVATED",
|
|
10
|
+
PAYMENT_APPLIED = "PAYMENT_APPLIED",
|
|
11
|
+
PAYMENT_REJECTED = "PAYMENT_REJECTED",
|
|
12
|
+
CREDIT_SETTLED = "CREDIT_SETTLED",
|
|
13
|
+
DEVICE_UNLOCKED = "DEVICE_UNLOCKED",
|
|
14
|
+
/** Bienvenida al cerrar la venta. Solo la pista de crédito: la de contado no tiene `creditId`. */
|
|
15
|
+
APP_WELCOME = "APP_WELCOME"
|
|
16
|
+
}
|
|
17
|
+
/** Body de `POST /private/credits/{creditId}/lifecycle-facts`. */
|
|
18
|
+
export interface CreditLifecycleFactRequest {
|
|
19
|
+
fact: CreditLifecycleFactEnum;
|
|
20
|
+
/**
|
|
21
|
+
* Rastro hasta el hecho de origen. Es SOLO trazabilidad: viaja a la referencia del aviso y NO
|
|
22
|
+
* deduplica. El motor acota su largo y su charset — ver `notifyLifecycleFact`.
|
|
23
|
+
*/
|
|
24
|
+
factReference?: string;
|
|
25
|
+
}
|
|
26
|
+
/** Acuse (202) del hecho recibido: repite lo que entró para que el caller lo correlacione. */
|
|
27
|
+
export interface CreditLifecycleFactResponse {
|
|
28
|
+
creditId: string;
|
|
29
|
+
fact: CreditLifecycleFactEnum;
|
|
30
|
+
factReference: string | null;
|
|
31
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Los HECHOS del ciclo del crédito que le avisan algo al cliente. El productor nombra el hecho y
|
|
3
|
+
* nada más — el momento, la plantilla, el canal y el texto los resuelve `loan-credit-business`.
|
|
4
|
+
*/
|
|
5
|
+
export var CreditLifecycleFactEnum;
|
|
6
|
+
(function (CreditLifecycleFactEnum) {
|
|
7
|
+
CreditLifecycleFactEnum["APPLICATION_APPROVED"] = "APPLICATION_APPROVED";
|
|
8
|
+
CreditLifecycleFactEnum["DOWN_PAYMENT_RECEIVED"] = "DOWN_PAYMENT_RECEIVED";
|
|
9
|
+
CreditLifecycleFactEnum["CONTRACT_SIGNED"] = "CONTRACT_SIGNED";
|
|
10
|
+
CreditLifecycleFactEnum["MDM_ACTIVATED"] = "MDM_ACTIVATED";
|
|
11
|
+
CreditLifecycleFactEnum["PAYMENT_APPLIED"] = "PAYMENT_APPLIED";
|
|
12
|
+
CreditLifecycleFactEnum["PAYMENT_REJECTED"] = "PAYMENT_REJECTED";
|
|
13
|
+
CreditLifecycleFactEnum["CREDIT_SETTLED"] = "CREDIT_SETTLED";
|
|
14
|
+
CreditLifecycleFactEnum["DEVICE_UNLOCKED"] = "DEVICE_UNLOCKED";
|
|
15
|
+
/** Bienvenida al cerrar la venta. Solo la pista de crédito: la de contado no tiene `creditId`. */
|
|
16
|
+
CreditLifecycleFactEnum["APP_WELCOME"] = "APP_WELCOME";
|
|
17
|
+
})(CreditLifecycleFactEnum || (CreditLifecycleFactEnum = {}));
|
|
@@ -2,6 +2,7 @@ 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 } from "@fiado/type-kit/bin/loanCredit/index.js";
|
|
3
3
|
import { LoanCreditAnalyticsBatchRequest, LoanCreditAnalyticsBatchResponse } from "../dtos/LoanCreditAnalyticsBatch.js";
|
|
4
4
|
import { CustomerCreditHistoryResponse } from "../dtos/CustomerCreditHistory.js";
|
|
5
|
+
import { CreditLifecycleFactRequest, CreditLifecycleFactResponse } from "../dtos/CreditLifecycleFact.js";
|
|
5
6
|
/**
|
|
6
7
|
* Contrato del publisher de `loan-credit-business` (componente 09 SureKeep F2 — motor de crédito
|
|
7
8
|
* SOFOM, pista Loan). Endpoints PRIVADOS (VPC) consumidos por `retail-wizard-business` (pasos
|
|
@@ -95,6 +96,17 @@ export interface ILoanCreditBusinessApi {
|
|
|
95
96
|
* del evento `CustomerKycVerifiedV1` — fallback operativo mientras la cola no exista).
|
|
96
97
|
*/
|
|
97
98
|
upsertBorrower(input: UpsertLoanBorrowerRequest, tenantId: string): Promise<StandardResponse<LoanBorrowerResponse>>;
|
|
99
|
+
/**
|
|
100
|
+
* Puerta de los hechos del ciclo: el caller nombra el HECHO que ya ocurrió en su propio lambda
|
|
101
|
+
* (originación, enganche, firma, MDM, bienvenida) y el motor resuelve el momento, la plantilla,
|
|
102
|
+
* el canal y el texto. Se llama DESPUÉS de que el hecho quedó asentado.
|
|
103
|
+
*
|
|
104
|
+
* Responde `202` — el aviso es best-effort y no se promete entregado. `factReference` es solo
|
|
105
|
+
* trazabilidad hasta el hecho de origen: NO deduplica.
|
|
106
|
+
* `400 VALIDATION_ERROR` si el hecho está fuera del catálogo del motor o el `factReference`
|
|
107
|
+
* pasa los 120 caracteres o trae `#` / `~` · `400 UNKNOWN_TENANT`.
|
|
108
|
+
*/
|
|
109
|
+
notifyLifecycleFact(creditId: string, input: CreditLifecycleFactRequest, tenantId: string): Promise<StandardResponse<CreditLifecycleFactResponse>>;
|
|
98
110
|
/**
|
|
99
111
|
* Devuelve UNA PÁGINA de candidatos a mensaje del `slot` y el día de tienda pedidos: la persona,
|
|
100
112
|
* el momento que le toca, el canal y las variables ya resueltas. El motor barre su cartera, aplica
|
package/bin/loanCredit/index.js
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IHttpRequest } from "@fiado/http-client";
|
|
2
|
+
import { ConnectorSendMessageRequest, ConnectorSendMessageResponse } from "@fiado/type-kit/bin/whatsappConnector/index.js";
|
|
3
|
+
import { IWhatsappConnectorApi } from "./interfaces/IWhatsappConnectorApi.js";
|
|
4
|
+
type FiadoApiResponse<T> = import("@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse.js").default<T>;
|
|
5
|
+
export default class WhatsappConnectorApi implements IWhatsappConnectorApi {
|
|
6
|
+
private httpRequest;
|
|
7
|
+
private readonly baseUrl;
|
|
8
|
+
constructor(httpRequest: IHttpRequest);
|
|
9
|
+
send(request: ConnectorSendMessageRequest): Promise<FiadoApiResponse<ConnectorSendMessageResponse>>;
|
|
10
|
+
}
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
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 { joinUrl } from "../../utils/joinUrl.js";
|
|
15
|
+
let WhatsappConnectorApi = class WhatsappConnectorApi {
|
|
16
|
+
httpRequest;
|
|
17
|
+
baseUrl = process.env.WHATSAPP_CONNECTOR_LAMBDA_URL || "";
|
|
18
|
+
constructor(httpRequest) {
|
|
19
|
+
this.httpRequest = httpRequest;
|
|
20
|
+
}
|
|
21
|
+
async send(request) {
|
|
22
|
+
const url = joinUrl(this.baseUrl, "messages/send");
|
|
23
|
+
return await this.httpRequest.post(url, request, { operationName: "privateSendMessage" });
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
WhatsappConnectorApi = __decorate([
|
|
27
|
+
injectable(),
|
|
28
|
+
__param(0, inject("IHttpRequest")),
|
|
29
|
+
__metadata("design:paramtypes", [Object])
|
|
30
|
+
], WhatsappConnectorApi);
|
|
31
|
+
export default WhatsappConnectorApi;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ConnectorSendMessageRequest, ConnectorSendMessageResponse } from "@fiado/type-kit/bin/whatsappConnector/index.js";
|
|
2
|
+
type FiadoApiResponse<T> = import("@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse.js").default<T>;
|
|
3
|
+
export interface IWhatsappConnectorApi {
|
|
4
|
+
/**
|
|
5
|
+
* Envía un mensaje ya resuelto al whatsapp-connector (POST /messages/send).
|
|
6
|
+
* messages-business resuelve plantilla y proveedor; el connector solo transmite a Meta.
|
|
7
|
+
*/
|
|
8
|
+
send(request: ConnectorSendMessageRequest): Promise<FiadoApiResponse<ConnectorSendMessageResponse>>;
|
|
9
|
+
}
|
|
10
|
+
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.79.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.
|
|
37
|
+
"@fiado/type-kit": "^3.422.0",
|
|
38
38
|
"dotenv": "^16.4.7"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
package/src/container.config.ts
CHANGED
|
@@ -189,6 +189,8 @@ import { IWalletFundingRulesApi, WalletFundingRulesApi } from "./wallet-funding-
|
|
|
189
189
|
import { ISnsSesConnectorApi, SnsSesConnectorApi } from "./sns-ses-connector/index.js";
|
|
190
190
|
// Twilio connector — envío WhatsApp/SMS por Twilio (lee TWILIO_CONNECTOR_LAMBDA_URL)
|
|
191
191
|
import { ITwilioConnectorApi, TwilioConnectorApi } from "./twilio-connector/index.js";
|
|
192
|
+
// Whatsapp connector — envío WhatsApp por Meta (lee WHATSAPP_CONNECTOR_LAMBDA_URL)
|
|
193
|
+
import { IWhatsappConnectorApi, WhatsappConnectorApi } from "./whatsapp-connector/index.js";
|
|
192
194
|
// Remittance business — pricingResolve (Dashboard Ops Fase B, puente de resolución de precio en send-time)
|
|
193
195
|
import { IRemittanceBusinessApi, RemittanceBusinessApi } from "./remittance-business/index.js";
|
|
194
196
|
import { IBeneficiaryApi, BeneficiaryApi } from "./beneficiary/index.js";
|
|
@@ -366,6 +368,10 @@ export const apiInvokerBindings = new ContainerModule(({ bind }) => {
|
|
|
366
368
|
// El consumidor necesita TWILIO_CONNECTOR_LAMBDA_URL desde el SSM `fiado-twilio-connector`.
|
|
367
369
|
bind<ITwilioConnectorApi>("ITwilioConnectorApi").to(TwilioConnectorApi);
|
|
368
370
|
|
|
371
|
+
// Whatsapp connector — envío WhatsApp por Meta, elegido por el `provider` del senderConfig.
|
|
372
|
+
// El consumidor necesita WHATSAPP_CONNECTOR_LAMBDA_URL desde el SSM `whatsapp-connector`.
|
|
373
|
+
bind<IWhatsappConnectorApi>("IWhatsappConnectorApi").to(WhatsappConnectorApi);
|
|
374
|
+
|
|
369
375
|
// Remittance business — pricingResolve (Dashboard Ops Fase B, puente de resolución de precio en send-time)
|
|
370
376
|
bind<IRemittanceBusinessApi>("IRemittanceBusinessApi").to(RemittanceBusinessApi);
|
|
371
377
|
|
package/src/index.ts
CHANGED
|
@@ -104,6 +104,7 @@ export * from "./walletFundingSettlement/index.js";
|
|
|
104
104
|
export * from "./wallet-funding-rules/index.js";
|
|
105
105
|
export * from "./sns-ses-connector/index.js";
|
|
106
106
|
export * from "./twilio-connector/index.js";
|
|
107
|
+
export * from "./whatsapp-connector/index.js";
|
|
107
108
|
export * from "./remittance-business/index.js";
|
|
108
109
|
export * from "./modelias-connector/index.js";
|
|
109
110
|
export * from "./beneficiary/index.js";
|
|
@@ -25,6 +25,10 @@ import {
|
|
|
25
25
|
LoanCreditAnalyticsBatchResponse,
|
|
26
26
|
} from "./dtos/LoanCreditAnalyticsBatch.js";
|
|
27
27
|
import { CustomerCreditHistoryResponse } from "./dtos/CustomerCreditHistory.js";
|
|
28
|
+
import {
|
|
29
|
+
CreditLifecycleFactRequest,
|
|
30
|
+
CreditLifecycleFactResponse,
|
|
31
|
+
} from "./dtos/CreditLifecycleFact.js";
|
|
28
32
|
import { ILoanCreditBusinessApi } from "./interfaces/ILoanCreditBusinessApi.js";
|
|
29
33
|
|
|
30
34
|
/**
|
|
@@ -147,6 +151,15 @@ export default class LoanCreditBusinessApi implements ILoanCreditBusinessApi {
|
|
|
147
151
|
return await this.httpRequest.post(url, input);
|
|
148
152
|
}
|
|
149
153
|
|
|
154
|
+
async notifyLifecycleFact(
|
|
155
|
+
creditId: string,
|
|
156
|
+
input: CreditLifecycleFactRequest,
|
|
157
|
+
tenantId: string,
|
|
158
|
+
): Promise<StandardResponse<CreditLifecycleFactResponse>> {
|
|
159
|
+
const url = `${this.baseUrl}/private/credits/${encodeURIComponent(creditId)}/lifecycle-facts?tenantId=${encodeURIComponent(tenantId)}`;
|
|
160
|
+
return await this.httpRequest.post(url, input);
|
|
161
|
+
}
|
|
162
|
+
|
|
150
163
|
async listMessagingCandidates(
|
|
151
164
|
input: ListMessagingCandidatesRequest,
|
|
152
165
|
tenantId: string,
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Los HECHOS del ciclo del crédito que le avisan algo al cliente. El productor nombra el hecho y
|
|
3
|
+
* nada más — el momento, la plantilla, el canal y el texto los resuelve `loan-credit-business`.
|
|
4
|
+
*/
|
|
5
|
+
export enum CreditLifecycleFactEnum {
|
|
6
|
+
APPLICATION_APPROVED = "APPLICATION_APPROVED",
|
|
7
|
+
DOWN_PAYMENT_RECEIVED = "DOWN_PAYMENT_RECEIVED",
|
|
8
|
+
CONTRACT_SIGNED = "CONTRACT_SIGNED",
|
|
9
|
+
MDM_ACTIVATED = "MDM_ACTIVATED",
|
|
10
|
+
PAYMENT_APPLIED = "PAYMENT_APPLIED",
|
|
11
|
+
PAYMENT_REJECTED = "PAYMENT_REJECTED",
|
|
12
|
+
CREDIT_SETTLED = "CREDIT_SETTLED",
|
|
13
|
+
DEVICE_UNLOCKED = "DEVICE_UNLOCKED",
|
|
14
|
+
/** Bienvenida al cerrar la venta. Solo la pista de crédito: la de contado no tiene `creditId`. */
|
|
15
|
+
APP_WELCOME = "APP_WELCOME",
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Body de `POST /private/credits/{creditId}/lifecycle-facts`. */
|
|
19
|
+
export interface CreditLifecycleFactRequest {
|
|
20
|
+
fact: CreditLifecycleFactEnum;
|
|
21
|
+
/**
|
|
22
|
+
* Rastro hasta el hecho de origen. Es SOLO trazabilidad: viaja a la referencia del aviso y NO
|
|
23
|
+
* deduplica. El motor acota su largo y su charset — ver `notifyLifecycleFact`.
|
|
24
|
+
*/
|
|
25
|
+
factReference?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Acuse (202) del hecho recibido: repite lo que entró para que el caller lo correlacione. */
|
|
29
|
+
export interface CreditLifecycleFactResponse {
|
|
30
|
+
creditId: string;
|
|
31
|
+
fact: CreditLifecycleFactEnum;
|
|
32
|
+
factReference: string | null;
|
|
33
|
+
}
|
|
@@ -23,6 +23,10 @@ import {
|
|
|
23
23
|
LoanCreditAnalyticsBatchResponse,
|
|
24
24
|
} from "../dtos/LoanCreditAnalyticsBatch.js";
|
|
25
25
|
import { CustomerCreditHistoryResponse } from "../dtos/CustomerCreditHistory.js";
|
|
26
|
+
import {
|
|
27
|
+
CreditLifecycleFactRequest,
|
|
28
|
+
CreditLifecycleFactResponse,
|
|
29
|
+
} from "../dtos/CreditLifecycleFact.js";
|
|
26
30
|
|
|
27
31
|
/**
|
|
28
32
|
* Contrato del publisher de `loan-credit-business` (componente 09 SureKeep F2 — motor de crédito
|
|
@@ -170,6 +174,22 @@ export interface ILoanCreditBusinessApi {
|
|
|
170
174
|
tenantId: string,
|
|
171
175
|
): Promise<StandardResponse<LoanBorrowerResponse>>;
|
|
172
176
|
|
|
177
|
+
/**
|
|
178
|
+
* Puerta de los hechos del ciclo: el caller nombra el HECHO que ya ocurrió en su propio lambda
|
|
179
|
+
* (originación, enganche, firma, MDM, bienvenida) y el motor resuelve el momento, la plantilla,
|
|
180
|
+
* el canal y el texto. Se llama DESPUÉS de que el hecho quedó asentado.
|
|
181
|
+
*
|
|
182
|
+
* Responde `202` — el aviso es best-effort y no se promete entregado. `factReference` es solo
|
|
183
|
+
* trazabilidad hasta el hecho de origen: NO deduplica.
|
|
184
|
+
* `400 VALIDATION_ERROR` si el hecho está fuera del catálogo del motor o el `factReference`
|
|
185
|
+
* pasa los 120 caracteres o trae `#` / `~` · `400 UNKNOWN_TENANT`.
|
|
186
|
+
*/
|
|
187
|
+
notifyLifecycleFact(
|
|
188
|
+
creditId: string,
|
|
189
|
+
input: CreditLifecycleFactRequest,
|
|
190
|
+
tenantId: string,
|
|
191
|
+
): Promise<StandardResponse<CreditLifecycleFactResponse>>;
|
|
192
|
+
|
|
173
193
|
/**
|
|
174
194
|
* Devuelve UNA PÁGINA de candidatos a mensaje del `slot` y el día de tienda pedidos: la persona,
|
|
175
195
|
* el momento que le toca, el canal y las variables ya resueltas. El motor barre su cartera, aplica
|
package/src/loanCredit/index.ts
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { inject, injectable } from "inversify";
|
|
2
|
+
import type { IHttpRequest } from "@fiado/http-client";
|
|
3
|
+
import { ConnectorSendMessageRequest, ConnectorSendMessageResponse } from "@fiado/type-kit/bin/whatsappConnector/index.js";
|
|
4
|
+
import { IWhatsappConnectorApi } from "./interfaces/IWhatsappConnectorApi.js";
|
|
5
|
+
import { joinUrl } from "../../utils/joinUrl.js";
|
|
6
|
+
|
|
7
|
+
type FiadoApiResponse<T> = import("@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse.js").default<T>;
|
|
8
|
+
|
|
9
|
+
@injectable()
|
|
10
|
+
export default class WhatsappConnectorApi implements IWhatsappConnectorApi {
|
|
11
|
+
private readonly baseUrl = process.env.WHATSAPP_CONNECTOR_LAMBDA_URL || "";
|
|
12
|
+
|
|
13
|
+
constructor(@inject("IHttpRequest") private httpRequest: IHttpRequest) {}
|
|
14
|
+
|
|
15
|
+
async send(request: ConnectorSendMessageRequest): Promise<FiadoApiResponse<ConnectorSendMessageResponse>> {
|
|
16
|
+
const url = joinUrl(this.baseUrl, "messages/send");
|
|
17
|
+
return await this.httpRequest.post(url, request, { operationName: "privateSendMessage" });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ConnectorSendMessageRequest, ConnectorSendMessageResponse } from "@fiado/type-kit/bin/whatsappConnector/index.js";
|
|
2
|
+
|
|
3
|
+
type FiadoApiResponse<T> = import("@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse.js").default<T>;
|
|
4
|
+
|
|
5
|
+
export interface IWhatsappConnectorApi {
|
|
6
|
+
/**
|
|
7
|
+
* Envía un mensaje ya resuelto al whatsapp-connector (POST /messages/send).
|
|
8
|
+
* messages-business resuelve plantilla y proveedor; el connector solo transmite a Meta.
|
|
9
|
+
*/
|
|
10
|
+
send(request: ConnectorSendMessageRequest): Promise<FiadoApiResponse<ConnectorSendMessageResponse>>;
|
|
11
|
+
}
|