@fiado/api-invoker 4.20.0 → 4.20.2
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/complaint/ComplaintApi.d.ts +11 -0
- package/bin/complaint/ComplaintApi.js +34 -0
- package/bin/complaint/index.d.ts +2 -0
- package/bin/complaint/index.js +2 -0
- package/bin/complaint/interfaces/IComplaintApi.d.ts +12 -0
- package/bin/complaint/interfaces/IComplaintApi.js +1 -0
- package/bin/container.config.js +2 -0
- package/bin/index.d.ts +1 -0
- package/bin/index.js +1 -0
- package/bin/milestone-business/api/MilestoneBusinessApi.d.ts +3 -2
- package/bin/milestone-business/api/MilestoneBusinessApi.js +16 -0
- package/bin/milestone-business/api/interfaces/IMilestoneBusinessApi.d.ts +8 -1
- package/bin/twilio-connector/api/TwilioConnectorApi.d.ts +11 -0
- package/bin/twilio-connector/api/TwilioConnectorApi.js +30 -0
- package/bin/twilio-connector/api/interfaces/ITwilioConnectorApi.d.ts +11 -0
- package/bin/twilio-connector/api/interfaces/ITwilioConnectorApi.js +1 -0
- package/bin/twilio-connector/index.d.ts +2 -0
- package/bin/twilio-connector/index.js +2 -0
- package/package.json +2 -2
- package/src/complaint/ComplaintApi.ts +27 -0
- package/src/complaint/index.ts +2 -0
- package/src/complaint/interfaces/IComplaintApi.ts +18 -0
- package/src/container.config.ts +2 -0
- package/src/index.ts +1 -0
- package/src/milestone-business/api/MilestoneBusinessApi.ts +25 -2
- package/src/milestone-business/api/interfaces/IMilestoneBusinessApi.ts +9 -1
- package/src/twilio-connector/api/TwilioConnectorApi.ts +18 -0
- package/src/twilio-connector/api/interfaces/ITwilioConnectorApi.ts +12 -0
- package/src/twilio-connector/index.ts +2 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IHttpRequest } from "@fiado/http-client";
|
|
2
|
+
import { ResponseOptions } from "@fiado/gateway-adapter";
|
|
3
|
+
import { CreateComplaintRequest, CreateComplaintResponse, ComplaintResponse } from "@fiado/type-kit/bin/complaint/index.js";
|
|
4
|
+
import { IComplaintApi } from "./interfaces/IComplaintApi.js";
|
|
5
|
+
export declare class ComplaintApi implements IComplaintApi {
|
|
6
|
+
private httpRequest;
|
|
7
|
+
private readonly baseUrl;
|
|
8
|
+
constructor(httpRequest: IHttpRequest);
|
|
9
|
+
createComplaint(request: CreateComplaintRequest): Promise<ResponseOptions<CreateComplaintResponse>>;
|
|
10
|
+
getComplaint(complaintId: string): Promise<ResponseOptions<ComplaintResponse>>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
let ComplaintApi = class ComplaintApi {
|
|
15
|
+
httpRequest;
|
|
16
|
+
baseUrl = process.env.COMPLAINT_MAILBOX_LAMBDA_URL || "";
|
|
17
|
+
constructor(httpRequest) {
|
|
18
|
+
this.httpRequest = httpRequest;
|
|
19
|
+
}
|
|
20
|
+
async createComplaint(request) {
|
|
21
|
+
const url = `${this.baseUrl}backoffice/create`;
|
|
22
|
+
return await this.httpRequest.post(url, request);
|
|
23
|
+
}
|
|
24
|
+
async getComplaint(complaintId) {
|
|
25
|
+
const url = `${this.baseUrl}complaints/${complaintId}`;
|
|
26
|
+
return await this.httpRequest.get(url);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
ComplaintApi = __decorate([
|
|
30
|
+
injectable(),
|
|
31
|
+
__param(0, inject("IHttpRequest")),
|
|
32
|
+
__metadata("design:paramtypes", [Object])
|
|
33
|
+
], ComplaintApi);
|
|
34
|
+
export { ComplaintApi };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ResponseOptions } from "@fiado/gateway-adapter";
|
|
2
|
+
import { CreateComplaintRequest, CreateComplaintResponse, ComplaintResponse } from "@fiado/type-kit/bin/complaint/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Cliente del buzón anónimo de denuncias (`complaint-mailbox-business`, BO-19).
|
|
5
|
+
* URL base en `COMPLAINT_MAILBOX_LAMBDA_URL` (API Gateway privado VPC-only).
|
|
6
|
+
*/
|
|
7
|
+
export interface IComplaintApi {
|
|
8
|
+
/** Crea una denuncia. `POST /backoffice/create` */
|
|
9
|
+
createComplaint(request: CreateComplaintRequest): Promise<ResponseOptions<CreateComplaintResponse>>;
|
|
10
|
+
/** Lee una denuncia (sin exponer la identidad del denunciante). `GET /complaints/{complaintId}` */
|
|
11
|
+
getComplaint(complaintId: string): Promise<ResponseOptions<ComplaintResponse>>;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/bin/container.config.js
CHANGED
|
@@ -41,6 +41,7 @@ import CnbvApi from "./cnbv-business/CnbvApi.js";
|
|
|
41
41
|
import TransactionApi from "./transaction/api/TransactionApi.js";
|
|
42
42
|
import { PomeloProcessorApi } from "./pomeloProcessor/index.js";
|
|
43
43
|
import { DisputesApi } from "./disputes/index.js";
|
|
44
|
+
import { ComplaintApi } from "./complaint/index.js";
|
|
44
45
|
import TransactionAlertApi from "./riskProfile/api/TransactionAlertApi.js";
|
|
45
46
|
import { DirectoriesApi } from "./directories/index.js";
|
|
46
47
|
import CognitoConnectorApi from "./cognitoConnector/CognitoConnectorApi.js";
|
|
@@ -152,6 +153,7 @@ export const apiInvokerBindings = new ContainerModule(({ bind }) => {
|
|
|
152
153
|
bind("ICnbvApi").to(CnbvApi);
|
|
153
154
|
bind("IPomeloProcessorApi").to(PomeloProcessorApi);
|
|
154
155
|
bind("IDisputesApi").to(DisputesApi);
|
|
156
|
+
bind("IComplaintApi").to(ComplaintApi);
|
|
155
157
|
bind("ITransactionAlertApi").to(TransactionAlertApi);
|
|
156
158
|
bind("IDirectoriesApi").to(DirectoriesApi);
|
|
157
159
|
bind("ICognitoConnectorApi").to(CognitoConnectorApi);
|
package/bin/index.d.ts
CHANGED
|
@@ -34,6 +34,7 @@ export * from "./fiadoMessages/index.js";
|
|
|
34
34
|
export * from "./cnbv-business/index.js";
|
|
35
35
|
export * from "./pomeloProcessor/index.js";
|
|
36
36
|
export * from "./disputes/index.js";
|
|
37
|
+
export * from "./complaint/index.js";
|
|
37
38
|
export * from "./directories/index.js";
|
|
38
39
|
export * from "./cognitoConnector/index.js";
|
|
39
40
|
export * from "./centralPayments/index.js";
|
package/bin/index.js
CHANGED
|
@@ -34,6 +34,7 @@ export * from "./fiadoMessages/index.js";
|
|
|
34
34
|
export * from "./cnbv-business/index.js";
|
|
35
35
|
export * from "./pomeloProcessor/index.js";
|
|
36
36
|
export * from "./disputes/index.js";
|
|
37
|
+
export * from "./complaint/index.js";
|
|
37
38
|
export * from "./directories/index.js";
|
|
38
39
|
export * from "./cognitoConnector/index.js";
|
|
39
40
|
export * from "./centralPayments/index.js";
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { IHttpRequest } from "@fiado/http-client";
|
|
2
|
-
import { MilestonesByEventKeyDateRangeParams } from "@fiado/type-kit/bin/milestone-business/index.js";
|
|
1
|
+
import type { IHttpRequest } from "@fiado/http-client";
|
|
2
|
+
import { Milestone, MilestonesByEventKeyDateRangeParams } from "@fiado/type-kit/bin/milestone-business/index.js";
|
|
3
3
|
import { IMilestoneBusinessApi } from "./interfaces/IMilestoneBusinessApi.js";
|
|
4
4
|
export default class MilestoneBusinessApi implements IMilestoneBusinessApi {
|
|
5
5
|
private httpRequest;
|
|
6
6
|
private readonly baseUrl;
|
|
7
7
|
constructor(httpRequest: IHttpRequest);
|
|
8
8
|
listByEventKeyAndDateRange(eventKey: string, params: MilestonesByEventKeyDateRangeParams): Promise<any>;
|
|
9
|
+
listByDirectoryIds(directoryIds: string[]): Promise<Record<string, Milestone[]>>;
|
|
9
10
|
}
|
|
@@ -11,6 +11,7 @@ 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
|
+
import { MILESTONES_BY_DIRECTORY_IDS_MAX_BATCH, } from "@fiado/type-kit/bin/milestone-business/index.js";
|
|
14
15
|
let MilestoneBusinessApi = class MilestoneBusinessApi {
|
|
15
16
|
httpRequest;
|
|
16
17
|
baseUrl = process.env.MILESTONE_BUSINESS_LAMBDA_URL || "";
|
|
@@ -31,6 +32,21 @@ let MilestoneBusinessApi = class MilestoneBusinessApi {
|
|
|
31
32
|
const url = `${this.baseUrl}private/milestones/by-event-key?${queryParams.toString()}`;
|
|
32
33
|
return await this.httpRequest.get(url);
|
|
33
34
|
}
|
|
35
|
+
async listByDirectoryIds(directoryIds) {
|
|
36
|
+
// Dedup preservando el orden de aparición.
|
|
37
|
+
const uniqueIds = Array.from(new Set(directoryIds));
|
|
38
|
+
if (uniqueIds.length === 0)
|
|
39
|
+
return {};
|
|
40
|
+
const url = `${this.baseUrl}private/milestones/by-directory-ids`;
|
|
41
|
+
const merged = {};
|
|
42
|
+
// Chunking en lotes de MILESTONES_BY_DIRECTORY_IDS_MAX_BATCH (cap del endpoint batch).
|
|
43
|
+
for (let i = 0; i < uniqueIds.length; i += MILESTONES_BY_DIRECTORY_IDS_MAX_BATCH) {
|
|
44
|
+
const batch = uniqueIds.slice(i, i + MILESTONES_BY_DIRECTORY_IDS_MAX_BATCH);
|
|
45
|
+
const partial = await this.httpRequest.post(url, { directoryIds: batch });
|
|
46
|
+
Object.assign(merged, partial);
|
|
47
|
+
}
|
|
48
|
+
return merged;
|
|
49
|
+
}
|
|
34
50
|
};
|
|
35
51
|
MilestoneBusinessApi = __decorate([
|
|
36
52
|
injectable(),
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
import { MilestonesByEventKeyDateRangeParams } from "@fiado/type-kit/bin/milestone-business/index.js";
|
|
1
|
+
import { Milestone, MilestonesByEventKeyDateRangeParams } from "@fiado/type-kit/bin/milestone-business/index.js";
|
|
2
2
|
export interface IMilestoneBusinessApi {
|
|
3
3
|
/**
|
|
4
4
|
* Lista milestones por eventKey filtrados por rango de eventDate.
|
|
5
5
|
* Usado por el flujo de cálculo de comisiones (eventKey=HomeAzul para USA, HomeRosa para MEX).
|
|
6
6
|
*/
|
|
7
7
|
listByEventKeyAndDateRange(eventKey: string, params: MilestonesByEventKeyDateRangeParams): Promise<any>;
|
|
8
|
+
/**
|
|
9
|
+
* Devuelve, por cada directoryId, el array COMPLETO de milestones (mapa
|
|
10
|
+
* directoryId -> Milestone[]). Hace POST a `private/milestones/by-directory-ids`.
|
|
11
|
+
* Parte la lista en lotes de 100 (cap del endpoint batch), deduplica los ids
|
|
12
|
+
* y mergea los mapas parciales. Una sola llamada por lote (evita N+1).
|
|
13
|
+
*/
|
|
14
|
+
listByDirectoryIds(directoryIds: string[]): Promise<Record<string, Milestone[]>>;
|
|
8
15
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IHttpRequest } from "@fiado/http-client";
|
|
2
|
+
import { ConnectorSendMessageRequest, ConnectorSendMessageResponse } from "@fiado/type-kit/bin/twilioConnector/index.js";
|
|
3
|
+
import { ITwilioConnectorApi } from "./interfaces/ITwilioConnectorApi.js";
|
|
4
|
+
type FiadoApiResponse<T> = import("@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse.js").default<T>;
|
|
5
|
+
export default class TwilioConnectorApi implements ITwilioConnectorApi {
|
|
6
|
+
private httpRequest;
|
|
7
|
+
private readonly baseUrl;
|
|
8
|
+
constructor(httpRequest: IHttpRequest);
|
|
9
|
+
send(request: ConnectorSendMessageRequest): Promise<FiadoApiResponse<ConnectorSendMessageResponse>>;
|
|
10
|
+
}
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
let TwilioConnectorApi = class TwilioConnectorApi {
|
|
15
|
+
httpRequest;
|
|
16
|
+
baseUrl = process.env.TWILIO_CONNECTOR_LAMBDA_URL || "";
|
|
17
|
+
constructor(httpRequest) {
|
|
18
|
+
this.httpRequest = httpRequest;
|
|
19
|
+
}
|
|
20
|
+
async send(request) {
|
|
21
|
+
const url = `${this.baseUrl}/messages/send`;
|
|
22
|
+
return await this.httpRequest.post(url, request, { operationName: "privateSendMessage" });
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
TwilioConnectorApi = __decorate([
|
|
26
|
+
injectable(),
|
|
27
|
+
__param(0, inject("IHttpRequest")),
|
|
28
|
+
__metadata("design:paramtypes", [Object])
|
|
29
|
+
], TwilioConnectorApi);
|
|
30
|
+
export default TwilioConnectorApi;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ConnectorSendMessageRequest, ConnectorSendMessageResponse } from "@fiado/type-kit/bin/twilioConnector/index.js";
|
|
2
|
+
type FiadoApiResponse<T> = import("@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse.js").default<T>;
|
|
3
|
+
export interface ITwilioConnectorApi {
|
|
4
|
+
/**
|
|
5
|
+
* Envia un mensaje ya resuelto al twilio-connector (POST /messages/send).
|
|
6
|
+
* messages-business resuelve plantilla, remitente y `secretRef` desde el
|
|
7
|
+
* `senderConfig` del `(tenant, channel)`; el connector solo transmite a Twilio.
|
|
8
|
+
*/
|
|
9
|
+
send(request: ConnectorSendMessageRequest): Promise<FiadoApiResponse<ConnectorSendMessageResponse>>;
|
|
10
|
+
}
|
|
11
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fiado/api-invoker",
|
|
3
|
-
"version": "4.20.
|
|
3
|
+
"version": "4.20.2",
|
|
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": "^2.0.2",
|
|
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.77.0",
|
|
38
38
|
"dotenv": "^16.4.7"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { inject, injectable } from "inversify";
|
|
2
|
+
import { IHttpRequest } from "@fiado/http-client";
|
|
3
|
+
import { ResponseOptions } from "@fiado/gateway-adapter";
|
|
4
|
+
import {
|
|
5
|
+
CreateComplaintRequest,
|
|
6
|
+
CreateComplaintResponse,
|
|
7
|
+
ComplaintResponse,
|
|
8
|
+
} from "@fiado/type-kit/bin/complaint/index.js";
|
|
9
|
+
import { IComplaintApi } from "./interfaces/IComplaintApi.js";
|
|
10
|
+
|
|
11
|
+
@injectable()
|
|
12
|
+
export class ComplaintApi implements IComplaintApi {
|
|
13
|
+
|
|
14
|
+
private readonly baseUrl = process.env.COMPLAINT_MAILBOX_LAMBDA_URL || "";
|
|
15
|
+
|
|
16
|
+
constructor(@inject("IHttpRequest") private httpRequest: IHttpRequest) { }
|
|
17
|
+
|
|
18
|
+
async createComplaint(request: CreateComplaintRequest): Promise<ResponseOptions<CreateComplaintResponse>> {
|
|
19
|
+
const url = `${this.baseUrl}backoffice/create`;
|
|
20
|
+
return await this.httpRequest.post(url, request);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async getComplaint(complaintId: string): Promise<ResponseOptions<ComplaintResponse>> {
|
|
24
|
+
const url = `${this.baseUrl}complaints/${complaintId}`;
|
|
25
|
+
return await this.httpRequest.get(url);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ResponseOptions } from "@fiado/gateway-adapter";
|
|
2
|
+
import {
|
|
3
|
+
CreateComplaintRequest,
|
|
4
|
+
CreateComplaintResponse,
|
|
5
|
+
ComplaintResponse,
|
|
6
|
+
} from "@fiado/type-kit/bin/complaint/index.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Cliente del buzón anónimo de denuncias (`complaint-mailbox-business`, BO-19).
|
|
10
|
+
* URL base en `COMPLAINT_MAILBOX_LAMBDA_URL` (API Gateway privado VPC-only).
|
|
11
|
+
*/
|
|
12
|
+
export interface IComplaintApi {
|
|
13
|
+
/** Crea una denuncia. `POST /backoffice/create` */
|
|
14
|
+
createComplaint(request: CreateComplaintRequest): Promise<ResponseOptions<CreateComplaintResponse>>;
|
|
15
|
+
|
|
16
|
+
/** Lee una denuncia (sin exponer la identidad del denunciante). `GET /complaints/{complaintId}` */
|
|
17
|
+
getComplaint(complaintId: string): Promise<ResponseOptions<ComplaintResponse>>;
|
|
18
|
+
}
|
package/src/container.config.ts
CHANGED
|
@@ -65,6 +65,7 @@ import { ICnbvApi } from "./cnbv-business/index.js";
|
|
|
65
65
|
import TransactionApi from "./transaction/api/TransactionApi.js";
|
|
66
66
|
import { IPomeloProcessorApi, PomeloProcessorApi } from "./pomeloProcessor/index.js";
|
|
67
67
|
import { DisputesApi, IDisputesApi } from "./disputes/index.js";
|
|
68
|
+
import { ComplaintApi, IComplaintApi } from "./complaint/index.js";
|
|
68
69
|
import TransactionAlertApi from "./riskProfile/api/TransactionAlertApi.js";
|
|
69
70
|
import { DirectoriesApi, IDirectoriesApi } from "./directories/index.js";
|
|
70
71
|
import { ICognitoConnectorApi, ICognitoV2Api } from "./cognitoConnector/index.js";
|
|
@@ -213,6 +214,7 @@ export const apiInvokerBindings = new ContainerModule(({ bind }) => {
|
|
|
213
214
|
bind<ICnbvApi>("ICnbvApi").to(CnbvApi);
|
|
214
215
|
bind<IPomeloProcessorApi>("IPomeloProcessorApi").to(PomeloProcessorApi);
|
|
215
216
|
bind<IDisputesApi>("IDisputesApi").to(DisputesApi);
|
|
217
|
+
bind<IComplaintApi>("IComplaintApi").to(ComplaintApi);
|
|
216
218
|
bind<ITransactionAlertApi>("ITransactionAlertApi").to(TransactionAlertApi);
|
|
217
219
|
bind<IDirectoriesApi>("IDirectoriesApi").to(DirectoriesApi);
|
|
218
220
|
bind<ICognitoConnectorApi>("ICognitoConnectorApi").to(CognitoConnectorApi);
|
package/src/index.ts
CHANGED
|
@@ -34,6 +34,7 @@ export * from "./fiadoMessages/index.js";
|
|
|
34
34
|
export * from "./cnbv-business/index.js";
|
|
35
35
|
export * from "./pomeloProcessor/index.js";
|
|
36
36
|
export * from "./disputes/index.js";
|
|
37
|
+
export * from "./complaint/index.js";
|
|
37
38
|
export * from "./directories/index.js";
|
|
38
39
|
export * from "./cognitoConnector/index.js";
|
|
39
40
|
export * from "./centralPayments/index.js";
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { inject, injectable } from "inversify";
|
|
2
|
-
import { IHttpRequest } from "@fiado/http-client";
|
|
3
|
-
import {
|
|
2
|
+
import type { IHttpRequest } from "@fiado/http-client";
|
|
3
|
+
import {
|
|
4
|
+
Milestone,
|
|
5
|
+
MilestonesByEventKeyDateRangeParams,
|
|
6
|
+
MilestonesByDirectoryIdsResponse,
|
|
7
|
+
MILESTONES_BY_DIRECTORY_IDS_MAX_BATCH,
|
|
8
|
+
} from "@fiado/type-kit/bin/milestone-business/index.js";
|
|
4
9
|
import { IMilestoneBusinessApi } from "./interfaces/IMilestoneBusinessApi.js";
|
|
5
10
|
|
|
6
11
|
@injectable()
|
|
@@ -23,4 +28,22 @@ export default class MilestoneBusinessApi implements IMilestoneBusinessApi {
|
|
|
23
28
|
const url = `${this.baseUrl}private/milestones/by-event-key?${queryParams.toString()}`;
|
|
24
29
|
return await this.httpRequest.get(url);
|
|
25
30
|
}
|
|
31
|
+
|
|
32
|
+
async listByDirectoryIds(directoryIds: string[]): Promise<Record<string, Milestone[]>> {
|
|
33
|
+
// Dedup preservando el orden de aparición.
|
|
34
|
+
const uniqueIds = Array.from(new Set(directoryIds));
|
|
35
|
+
if (uniqueIds.length === 0) return {};
|
|
36
|
+
|
|
37
|
+
const url = `${this.baseUrl}private/milestones/by-directory-ids`;
|
|
38
|
+
const merged: Record<string, Milestone[]> = {};
|
|
39
|
+
|
|
40
|
+
// Chunking en lotes de MILESTONES_BY_DIRECTORY_IDS_MAX_BATCH (cap del endpoint batch).
|
|
41
|
+
for (let i = 0; i < uniqueIds.length; i += MILESTONES_BY_DIRECTORY_IDS_MAX_BATCH) {
|
|
42
|
+
const batch = uniqueIds.slice(i, i + MILESTONES_BY_DIRECTORY_IDS_MAX_BATCH);
|
|
43
|
+
const partial = await this.httpRequest.post<MilestonesByDirectoryIdsResponse>(url, { directoryIds: batch });
|
|
44
|
+
Object.assign(merged, partial);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return merged;
|
|
48
|
+
}
|
|
26
49
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MilestonesByEventKeyDateRangeParams } from "@fiado/type-kit/bin/milestone-business/index.js";
|
|
1
|
+
import { Milestone, MilestonesByEventKeyDateRangeParams } from "@fiado/type-kit/bin/milestone-business/index.js";
|
|
2
2
|
|
|
3
3
|
export interface IMilestoneBusinessApi {
|
|
4
4
|
/**
|
|
@@ -6,4 +6,12 @@ export interface IMilestoneBusinessApi {
|
|
|
6
6
|
* Usado por el flujo de cálculo de comisiones (eventKey=HomeAzul para USA, HomeRosa para MEX).
|
|
7
7
|
*/
|
|
8
8
|
listByEventKeyAndDateRange(eventKey: string, params: MilestonesByEventKeyDateRangeParams): Promise<any>;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Devuelve, por cada directoryId, el array COMPLETO de milestones (mapa
|
|
12
|
+
* directoryId -> Milestone[]). Hace POST a `private/milestones/by-directory-ids`.
|
|
13
|
+
* Parte la lista en lotes de 100 (cap del endpoint batch), deduplica los ids
|
|
14
|
+
* y mergea los mapas parciales. Una sola llamada por lote (evita N+1).
|
|
15
|
+
*/
|
|
16
|
+
listByDirectoryIds(directoryIds: string[]): Promise<Record<string, Milestone[]>>;
|
|
9
17
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { inject, injectable } from "inversify";
|
|
2
|
+
import { IHttpRequest } from "@fiado/http-client";
|
|
3
|
+
import { ConnectorSendMessageRequest, ConnectorSendMessageResponse } from "@fiado/type-kit/bin/twilioConnector/index.js";
|
|
4
|
+
import { ITwilioConnectorApi } from "./interfaces/ITwilioConnectorApi.js";
|
|
5
|
+
|
|
6
|
+
type FiadoApiResponse<T> = import("@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse.js").default<T>;
|
|
7
|
+
|
|
8
|
+
@injectable()
|
|
9
|
+
export default class TwilioConnectorApi implements ITwilioConnectorApi {
|
|
10
|
+
private readonly baseUrl = process.env.TWILIO_CONNECTOR_LAMBDA_URL || "";
|
|
11
|
+
|
|
12
|
+
constructor(@inject("IHttpRequest") private httpRequest: IHttpRequest) {}
|
|
13
|
+
|
|
14
|
+
async send(request: ConnectorSendMessageRequest): Promise<FiadoApiResponse<ConnectorSendMessageResponse>> {
|
|
15
|
+
const url = `${this.baseUrl}/messages/send`;
|
|
16
|
+
return await this.httpRequest.post(url, request, { operationName: "privateSendMessage" });
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ConnectorSendMessageRequest, ConnectorSendMessageResponse } from "@fiado/type-kit/bin/twilioConnector/index.js";
|
|
2
|
+
|
|
3
|
+
type FiadoApiResponse<T> = import("@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse.js").default<T>;
|
|
4
|
+
|
|
5
|
+
export interface ITwilioConnectorApi {
|
|
6
|
+
/**
|
|
7
|
+
* Envia un mensaje ya resuelto al twilio-connector (POST /messages/send).
|
|
8
|
+
* messages-business resuelve plantilla, remitente y `secretRef` desde el
|
|
9
|
+
* `senderConfig` del `(tenant, channel)`; el connector solo transmite a Twilio.
|
|
10
|
+
*/
|
|
11
|
+
send(request: ConnectorSendMessageRequest): Promise<FiadoApiResponse<ConnectorSendMessageResponse>>;
|
|
12
|
+
}
|