@fiado/api-invoker 5.13.1 → 5.15.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 +2 -0
- package/bin/platformRbac/api/PlatformRbacBusinessApi.d.ts +2 -1
- package/bin/platformRbac/api/PlatformRbacBusinessApi.js +4 -0
- package/bin/platformRbac/api/interfaces/IPlatformRbacBusinessApi.d.ts +3 -1
- package/bin/zendesk/index.d.ts +2 -0
- package/bin/zendesk/index.js +2 -0
- package/bin/zendesk/queue/ZendeskAlertsPublisher.d.ts +9 -0
- package/bin/zendesk/queue/ZendeskAlertsPublisher.js +37 -0
- package/bin/zendesk/queue/interfaces/IZendeskAlertsPublisher.d.ts +15 -0
- package/bin/zendesk/queue/interfaces/IZendeskAlertsPublisher.js +1 -0
- package/package.json +2 -2
- package/src/container.config.ts +3 -0
- package/src/platformRbac/api/PlatformRbacBusinessApi.ts +9 -0
- package/src/platformRbac/api/interfaces/IPlatformRbacBusinessApi.ts +7 -0
- package/src/zendesk/index.ts +2 -0
- package/src/zendesk/queue/ZendeskAlertsPublisher.ts +38 -0
- package/src/zendesk/queue/interfaces/IZendeskAlertsPublisher.ts +17 -0
package/bin/container.config.js
CHANGED
|
@@ -48,6 +48,7 @@ import TransactionAlertApi from "./riskProfile/api/TransactionAlertApi.js";
|
|
|
48
48
|
import { DirectoriesApi } from "./directories/index.js";
|
|
49
49
|
import CognitoConnectorApi from "./cognitoConnector/CognitoConnectorApi.js";
|
|
50
50
|
import { ZendeskApi } from "./zendesk/index.js";
|
|
51
|
+
import ZendeskAlertsPublisher from "./zendesk/queue/ZendeskAlertsPublisher.js";
|
|
51
52
|
import { BlackListApi } from "./blacklist/index.js";
|
|
52
53
|
import { DeviceApi } from "./device/index.js";
|
|
53
54
|
import { ObservationsApi } from "./observations/index.js";
|
|
@@ -182,6 +183,7 @@ export const apiInvokerBindings = new ContainerModule(({ bind }) => {
|
|
|
182
183
|
bind("ICognitoConnectorApi").to(CognitoConnectorApi);
|
|
183
184
|
bind("ICognitoV2Api").to(CognitoApi);
|
|
184
185
|
bind("IZendeskApi").to(ZendeskApi);
|
|
186
|
+
bind("IZendeskAlertsPublisher").to(ZendeskAlertsPublisher);
|
|
185
187
|
bind("IBlackListApi").to(BlackListApi);
|
|
186
188
|
bind("IDeviceApi").to(DeviceApi);
|
|
187
189
|
bind("IObservationsApi").to(ObservationsApi);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IHttpRequest } from "@fiado/http-client";
|
|
2
2
|
import { ApiGatewayResponse, ResolvedPermissions, ResolveInput } from "@fiado/gateway-adapter";
|
|
3
|
-
import { DefineNextChallengeRequest, DefineNextChallengeResponse, PrepareChallengeRequest, PrepareChallengeResponse, VerifyChallengeRequest, VerifyChallengeResponse, AuthorizeRequest, AuthorizeResponse, EffectivePermissionsResponse, InjectableUserAttributesResponse, PermissionScope, CreateLevelEntityRequest, CreateLevelEntityResponse, CreateTenantUserRequest, CreateTenantUserResponse } from "@fiado/type-kit/bin/platformRbac/index.js";
|
|
3
|
+
import { DefineNextChallengeRequest, DefineNextChallengeResponse, PrepareChallengeRequest, PrepareChallengeResponse, VerifyChallengeRequest, VerifyChallengeResponse, AuthorizeRequest, AuthorizeResponse, EffectivePermissionsResponse, InjectableUserAttributesResponse, PermissionScope, CreateLevelEntityRequest, CreateLevelEntityResponse, CreateTenantUserRequest, CreateTenantUserResponse, UserProfileResponse } from "@fiado/type-kit/bin/platformRbac/index.js";
|
|
4
4
|
import { IPlatformRbacBusinessApi } from "./interfaces/IPlatformRbacBusinessApi.js";
|
|
5
5
|
/**
|
|
6
6
|
* Publisher HTTP del lambda `platform-rbac-business` (componente 06 SureKeep Fase 0)
|
|
@@ -28,4 +28,5 @@ export default class PlatformRbacBusinessApi implements IPlatformRbacBusinessApi
|
|
|
28
28
|
resolvePermissions(input: ResolveInput): Promise<ApiGatewayResponse<ResolvedPermissions>>;
|
|
29
29
|
createLevelEntity(tenantId: string, level: PermissionScope, input: CreateLevelEntityRequest): Promise<ApiGatewayResponse<CreateLevelEntityResponse>>;
|
|
30
30
|
createTenantUser(tenantId: string, input: CreateTenantUserRequest): Promise<ApiGatewayResponse<CreateTenantUserResponse>>;
|
|
31
|
+
getUserProfile(cognitoSub: string, tenantId: string): Promise<ApiGatewayResponse<UserProfileResponse>>;
|
|
31
32
|
}
|
|
@@ -76,6 +76,10 @@ let PlatformRbacBusinessApi = class PlatformRbacBusinessApi {
|
|
|
76
76
|
const url = `${this.baseUrl}/internal/tenants/${encodeURIComponent(tenantId)}/users`;
|
|
77
77
|
return await this.httpRequest.post(url, input);
|
|
78
78
|
}
|
|
79
|
+
async getUserProfile(cognitoSub, tenantId) {
|
|
80
|
+
const url = `${this.baseUrl}/internal/users/${encodeURIComponent(cognitoSub)}/profile?tenantId=${encodeURIComponent(tenantId)}`;
|
|
81
|
+
return await this.httpRequest.get(url);
|
|
82
|
+
}
|
|
79
83
|
};
|
|
80
84
|
PlatformRbacBusinessApi = __decorate([
|
|
81
85
|
injectable(),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ApiGatewayResponse, ResolvedPermissions, ResolveInput } from "@fiado/gateway-adapter";
|
|
2
|
-
import { DefineNextChallengeRequest, DefineNextChallengeResponse, PrepareChallengeRequest, PrepareChallengeResponse, VerifyChallengeRequest, VerifyChallengeResponse, AuthorizeRequest, AuthorizeResponse, EffectivePermissionsResponse, InjectableUserAttributesResponse, PermissionScope, CreateLevelEntityRequest, CreateLevelEntityResponse, CreateTenantUserRequest, CreateTenantUserResponse } from "@fiado/type-kit/bin/platformRbac/index.js";
|
|
2
|
+
import { DefineNextChallengeRequest, DefineNextChallengeResponse, PrepareChallengeRequest, PrepareChallengeResponse, VerifyChallengeRequest, VerifyChallengeResponse, AuthorizeRequest, AuthorizeResponse, EffectivePermissionsResponse, InjectableUserAttributesResponse, PermissionScope, CreateLevelEntityRequest, CreateLevelEntityResponse, CreateTenantUserRequest, CreateTenantUserResponse, UserProfileResponse } from "@fiado/type-kit/bin/platformRbac/index.js";
|
|
3
3
|
/**
|
|
4
4
|
* Contrato del publisher HTTP del lambda `platform-rbac-business` (componente 06 SureKeep Fase 0)
|
|
5
5
|
* para los 3 endpoints internos del Custom Auth Challenge flow (MFA).
|
|
@@ -75,4 +75,6 @@ export interface IPlatformRbacBusinessApi {
|
|
|
75
75
|
* queda INVITED (mitiga orphan) y retail-org guarda el `cognitoSub` retornado. Idempotente por identidad Cognito.
|
|
76
76
|
*/
|
|
77
77
|
createTenantUser(tenantId: string, input: CreateTenantUserRequest): Promise<ApiGatewayResponse<CreateTenantUserResponse>>;
|
|
78
|
+
/** GET /internal/users/{cognitoSub}/profile?tenantId= — perfil básico del SharedUser (displayName, email, phone, status). */
|
|
79
|
+
getUserProfile(cognitoSub: string, tenantId: string): Promise<ApiGatewayResponse<UserProfileResponse>>;
|
|
78
80
|
}
|
package/bin/zendesk/index.d.ts
CHANGED
package/bin/zendesk/index.js
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ZendeskInternalAlertRequest } from "@fiado/type-kit/bin/helpdesk/index.js";
|
|
2
|
+
import { SendProactiveMessageRequest } from "@fiado/type-kit/bin/zendeskMessaging/index.js";
|
|
3
|
+
import { IZendeskAlertsPublisher } from "./interfaces/IZendeskAlertsPublisher.js";
|
|
4
|
+
export default class ZendeskAlertsPublisher implements IZendeskAlertsPublisher {
|
|
5
|
+
private readonly ZENDESK_ALERTS_QUEUE;
|
|
6
|
+
createInternalNote(alert: ZendeskInternalAlertRequest): Promise<void>;
|
|
7
|
+
sendProactiveMessage(message: SendProactiveMessageRequest): Promise<void>;
|
|
8
|
+
private publish;
|
|
9
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
import { injectable } from "inversify";
|
|
8
|
+
import { SendMessageCommand, SQSClient } from "@aws-sdk/client-sqs";
|
|
9
|
+
import { ZendeskAlertKind } from "@fiado/type-kit/bin/helpdesk/index.js";
|
|
10
|
+
let ZendeskAlertsPublisher = class ZendeskAlertsPublisher {
|
|
11
|
+
ZENDESK_ALERTS_QUEUE = process.env.ZENDESK_ALERTS_QUEUE;
|
|
12
|
+
async createInternalNote(alert) {
|
|
13
|
+
await this.publish({ kind: ZendeskAlertKind.INTERNAL_NOTE, payload: alert });
|
|
14
|
+
}
|
|
15
|
+
async sendProactiveMessage(message) {
|
|
16
|
+
await this.publish({ kind: ZendeskAlertKind.PROACTIVE_MESSAGE, payload: message });
|
|
17
|
+
}
|
|
18
|
+
async publish(message) {
|
|
19
|
+
try {
|
|
20
|
+
const client = new SQSClient();
|
|
21
|
+
const sendMessageRequest = {
|
|
22
|
+
QueueUrl: this.ZENDESK_ALERTS_QUEUE,
|
|
23
|
+
MessageBody: JSON.stringify(message)
|
|
24
|
+
};
|
|
25
|
+
const command = new SendMessageCommand(sendMessageRequest);
|
|
26
|
+
await client.send(command);
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
30
|
+
throw new Error(`Error publishing message to queue ${': ' + errorMessage}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
ZendeskAlertsPublisher = __decorate([
|
|
35
|
+
injectable()
|
|
36
|
+
], ZendeskAlertsPublisher);
|
|
37
|
+
export default ZendeskAlertsPublisher;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ZendeskInternalAlertRequest } from "@fiado/type-kit/bin/helpdesk/index.js";
|
|
2
|
+
import { SendProactiveMessageRequest } from "@fiado/type-kit/bin/zendeskMessaging/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Publica alertas hacia Zendesk sin pagar su latencia: el caller encola y sigue.
|
|
5
|
+
* Consume zendesk-business.
|
|
6
|
+
*/
|
|
7
|
+
export interface IZendeskAlertsPublisher {
|
|
8
|
+
/** Nota interna sobre un usuario. Solo la ven los agentes. */
|
|
9
|
+
createInternalNote(alert: ZendeskInternalAlertRequest): Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* Mensaje al chat del usuario. Si el usuario está esperando la respuesta ahora, conviene
|
|
12
|
+
* el endpoint síncrono `IZendeskApi.sendProactiveMessage`: acá el fallo no es inmediato.
|
|
13
|
+
*/
|
|
14
|
+
sendProactiveMessage(message: SendProactiveMessageRequest): Promise<void>;
|
|
15
|
+
}
|
|
@@ -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.15.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.260.0",
|
|
38
38
|
"dotenv": "^16.4.7"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
package/src/container.config.ts
CHANGED
|
@@ -75,6 +75,8 @@ import { DirectoriesApi, IDirectoriesApi } from "./directories/index.js";
|
|
|
75
75
|
import { ICognitoConnectorApi, ICognitoV2Api } from "./cognitoConnector/index.js";
|
|
76
76
|
import CognitoConnectorApi from "./cognitoConnector/CognitoConnectorApi.js";
|
|
77
77
|
import { IZendeskApi, ZendeskApi } from "./zendesk/index.js";
|
|
78
|
+
import ZendeskAlertsPublisher from "./zendesk/queue/ZendeskAlertsPublisher.js";
|
|
79
|
+
import { IZendeskAlertsPublisher } from "./zendesk/queue/interfaces/IZendeskAlertsPublisher.js";
|
|
78
80
|
import { BlackListApi, IBlackListApi } from "./blacklist/index.js";
|
|
79
81
|
import { DeviceApi, IDeviceApi } from "./device/index.js";
|
|
80
82
|
import { IObservationsApi, ObservationsApi } from "./observations/index.js";
|
|
@@ -247,6 +249,7 @@ export const apiInvokerBindings = new ContainerModule(({ bind }) => {
|
|
|
247
249
|
bind<ICognitoConnectorApi>("ICognitoConnectorApi").to(CognitoConnectorApi);
|
|
248
250
|
bind<ICognitoV2Api>("ICognitoV2Api").to(CognitoApi);
|
|
249
251
|
bind<IZendeskApi>("IZendeskApi").to(ZendeskApi);
|
|
252
|
+
bind<IZendeskAlertsPublisher>("IZendeskAlertsPublisher").to(ZendeskAlertsPublisher);
|
|
250
253
|
bind<IBlackListApi>("IBlackListApi").to(BlackListApi);
|
|
251
254
|
bind<IDeviceApi>("IDeviceApi").to(DeviceApi);
|
|
252
255
|
bind<IObservationsApi>("IObservationsApi").to(ObservationsApi);
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
CreateLevelEntityResponse,
|
|
19
19
|
CreateTenantUserRequest,
|
|
20
20
|
CreateTenantUserResponse,
|
|
21
|
+
UserProfileResponse,
|
|
21
22
|
} from "@fiado/type-kit/bin/platformRbac/index.js";
|
|
22
23
|
import { IPlatformRbacBusinessApi } from "./interfaces/IPlatformRbacBusinessApi.js";
|
|
23
24
|
|
|
@@ -117,4 +118,12 @@ export default class PlatformRbacBusinessApi implements IPlatformRbacBusinessApi
|
|
|
117
118
|
const url = `${this.baseUrl}/internal/tenants/${encodeURIComponent(tenantId)}/users`;
|
|
118
119
|
return await this.httpRequest.post(url, input);
|
|
119
120
|
}
|
|
121
|
+
|
|
122
|
+
async getUserProfile(
|
|
123
|
+
cognitoSub: string,
|
|
124
|
+
tenantId: string,
|
|
125
|
+
): Promise<ApiGatewayResponse<UserProfileResponse>> {
|
|
126
|
+
const url = `${this.baseUrl}/internal/users/${encodeURIComponent(cognitoSub)}/profile?tenantId=${encodeURIComponent(tenantId)}`;
|
|
127
|
+
return await this.httpRequest.get(url);
|
|
128
|
+
}
|
|
120
129
|
}
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
CreateLevelEntityResponse,
|
|
16
16
|
CreateTenantUserRequest,
|
|
17
17
|
CreateTenantUserResponse,
|
|
18
|
+
UserProfileResponse,
|
|
18
19
|
} from "@fiado/type-kit/bin/platformRbac/index.js";
|
|
19
20
|
|
|
20
21
|
/**
|
|
@@ -121,4 +122,10 @@ export interface IPlatformRbacBusinessApi {
|
|
|
121
122
|
tenantId: string,
|
|
122
123
|
input: CreateTenantUserRequest,
|
|
123
124
|
): Promise<ApiGatewayResponse<CreateTenantUserResponse>>;
|
|
125
|
+
|
|
126
|
+
/** GET /internal/users/{cognitoSub}/profile?tenantId= — perfil básico del SharedUser (displayName, email, phone, status). */
|
|
127
|
+
getUserProfile(
|
|
128
|
+
cognitoSub: string,
|
|
129
|
+
tenantId: string,
|
|
130
|
+
): Promise<ApiGatewayResponse<UserProfileResponse>>;
|
|
124
131
|
}
|
package/src/zendesk/index.ts
CHANGED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { injectable } from "inversify";
|
|
2
|
+
import { SendMessageCommand, SendMessageRequest, SQSClient } from "@aws-sdk/client-sqs";
|
|
3
|
+
import {
|
|
4
|
+
IZendeskAlertMessage,
|
|
5
|
+
ZendeskAlertKind,
|
|
6
|
+
ZendeskInternalAlertRequest
|
|
7
|
+
} from "@fiado/type-kit/bin/helpdesk/index.js";
|
|
8
|
+
import { SendProactiveMessageRequest } from "@fiado/type-kit/bin/zendeskMessaging/index.js";
|
|
9
|
+
import { IZendeskAlertsPublisher } from "./interfaces/IZendeskAlertsPublisher.js";
|
|
10
|
+
|
|
11
|
+
@injectable()
|
|
12
|
+
export default class ZendeskAlertsPublisher implements IZendeskAlertsPublisher {
|
|
13
|
+
|
|
14
|
+
private readonly ZENDESK_ALERTS_QUEUE = process.env.ZENDESK_ALERTS_QUEUE;
|
|
15
|
+
|
|
16
|
+
async createInternalNote(alert: ZendeskInternalAlertRequest): Promise<void> {
|
|
17
|
+
await this.publish({ kind: ZendeskAlertKind.INTERNAL_NOTE, payload: alert });
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async sendProactiveMessage(message: SendProactiveMessageRequest): Promise<void> {
|
|
21
|
+
await this.publish({ kind: ZendeskAlertKind.PROACTIVE_MESSAGE, payload: message });
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
private async publish(message: IZendeskAlertMessage): Promise<void> {
|
|
25
|
+
try {
|
|
26
|
+
const client: SQSClient = new SQSClient();
|
|
27
|
+
const sendMessageRequest: SendMessageRequest = {
|
|
28
|
+
QueueUrl: this.ZENDESK_ALERTS_QUEUE,
|
|
29
|
+
MessageBody: JSON.stringify(message)
|
|
30
|
+
};
|
|
31
|
+
const command: SendMessageCommand = new SendMessageCommand(sendMessageRequest);
|
|
32
|
+
await client.send(command);
|
|
33
|
+
} catch (error) {
|
|
34
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
35
|
+
throw new Error(`Error publishing message to queue ${': ' + errorMessage}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ZendeskInternalAlertRequest } from "@fiado/type-kit/bin/helpdesk/index.js";
|
|
2
|
+
import { SendProactiveMessageRequest } from "@fiado/type-kit/bin/zendeskMessaging/index.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Publica alertas hacia Zendesk sin pagar su latencia: el caller encola y sigue.
|
|
6
|
+
* Consume zendesk-business.
|
|
7
|
+
*/
|
|
8
|
+
export interface IZendeskAlertsPublisher {
|
|
9
|
+
/** Nota interna sobre un usuario. Solo la ven los agentes. */
|
|
10
|
+
createInternalNote(alert: ZendeskInternalAlertRequest): Promise<void>;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Mensaje al chat del usuario. Si el usuario está esperando la respuesta ahora, conviene
|
|
14
|
+
* el endpoint síncrono `IZendeskApi.sendProactiveMessage`: acá el fallo no es inmediato.
|
|
15
|
+
*/
|
|
16
|
+
sendProactiveMessage(message: SendProactiveMessageRequest): Promise<void>;
|
|
17
|
+
}
|