@fiado/api-invoker 1.0.15 → 1.0.17
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/README.md +64 -64
- package/bin/container.config.js +2 -0
- package/bin/sessionActivity/queue/SessionActivityPublisher.js +12 -2
- package/package.json +28 -28
- package/src/container.config.ts +13 -11
- package/src/directory/DirectoryApi.ts +25 -25
- package/src/directory/index.ts +3 -3
- package/src/directory/interfaces/IDirectoryApi.ts +14 -14
- package/src/identity/IdentityApi.ts +24 -24
- package/src/identity/index.ts +3 -3
- package/src/identity/interfaces/IIdentityApi.ts +14 -14
- package/src/index.ts +9 -9
- package/src/notificationMessages/index.ts +1 -1
- package/src/notificationMessages/queue/NotificationMessagePublisher.ts +22 -22
- package/src/notificationMessages/queue/interfaces/INotificationMessagesPublisher.ts +4 -4
- package/src/sessionActivity/index.ts +2 -2
- package/src/sessionActivity/queue/SessionActivityPublisher.ts +22 -20
- package/src/sessionActivity/queue/interfaces/ISessionActivityPublisher.ts +4 -4
- package/tsconfig.json +21 -21
package/README.md
CHANGED
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
# fiado-api-invoker
|
|
2
|
-
|
|
3
|
-
`fiado-api-invoker` es una librería diseñada para facilitar la invocación de APIs privadas de AWS Lambda a través de API Gateway dentro de la misma VPC. Esta librería simplifica el proceso de configuración y llamada a servicios, permitiendo a los desarrolladores centrarse en la lógica de negocio.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
## Configuración
|
|
7
|
-
|
|
8
|
-
Antes de usar la librería, asegúrate de configurar la URL base del API Gateway privado que corresponda por ejemplo si vas a usar los servicios del Lambda `Directory` se puede hacer estableciendo la variable de entorno `DIRECTORY_LAMBDA_URL`.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
## Instalación
|
|
12
|
-
```bash
|
|
13
|
-
`npm install fiado-api-invoker @fiado/http-client`
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
## Configuración del Contenedor de InversifyJS
|
|
17
|
-
|
|
18
|
-
```typescript
|
|
19
|
-
import { Container } from "inversify";
|
|
20
|
-
import { IHttpRequest, AxiosHttpRequest } from "@fiado/http-client";
|
|
21
|
-
import { apiInvokerContainer } from '@fiado/api-invoker';
|
|
22
|
-
|
|
23
|
-
// Crea el contenedor principal de tu aplicación
|
|
24
|
-
const container = new Container();
|
|
25
|
-
|
|
26
|
-
// Aplica las configuraciones de vinculación de fiado-gateway-adapter al contenedor
|
|
27
|
-
container.load(gatewayAdapterBindings);
|
|
28
|
-
|
|
29
|
-
// Registro del cliente HTTP
|
|
30
|
-
container.bind<IHttpRequest>("IHttpRequest").to(AxiosHttpRequest);
|
|
31
|
-
|
|
32
|
-
// Exporta el contenedor para su uso en toda tu aplicación
|
|
33
|
-
export { container };
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
## Uso de IDirectoryApi en Servicios del Proyecto
|
|
40
|
-
|
|
41
|
-
Para utilizar `fiado-api-invoker`, necesitas configurar el contenedor de InversifyJS en tu aplicación. Aquí te mostramos cómo registrar las dependencias necesarias:
|
|
42
|
-
|
|
43
|
-
```typescript
|
|
44
|
-
import { inject, injectable } from "inversify";
|
|
45
|
-
import { IDirectoryApi } from "fiado-api-invoker";
|
|
46
|
-
import { log } from "@fiado/logger";
|
|
47
|
-
|
|
48
|
-
@injectable()
|
|
49
|
-
export class SomeService {
|
|
50
|
-
constructor(@inject("IDirectoryApi") private directoryApi: IDirectoryApi) {}
|
|
51
|
-
|
|
52
|
-
public async fetchDirectoryDetails(directoryIds: string[]): Promise<void> {
|
|
53
|
-
try {
|
|
54
|
-
const details = await this.directoryApi.getByIds(directoryIds);
|
|
55
|
-
log.info(details);
|
|
56
|
-
|
|
57
|
-
} catch (error) {
|
|
58
|
-
log.error("Error fetching directory details:", error);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
|
|
1
|
+
# fiado-api-invoker
|
|
2
|
+
|
|
3
|
+
`fiado-api-invoker` es una librería diseñada para facilitar la invocación de APIs privadas de AWS Lambda a través de API Gateway dentro de la misma VPC. Esta librería simplifica el proceso de configuración y llamada a servicios, permitiendo a los desarrolladores centrarse en la lógica de negocio.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Configuración
|
|
7
|
+
|
|
8
|
+
Antes de usar la librería, asegúrate de configurar la URL base del API Gateway privado que corresponda por ejemplo si vas a usar los servicios del Lambda `Directory` se puede hacer estableciendo la variable de entorno `DIRECTORY_LAMBDA_URL`.
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
## Instalación
|
|
12
|
+
```bash
|
|
13
|
+
`npm install fiado-api-invoker @fiado/http-client`
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Configuración del Contenedor de InversifyJS
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
import { Container } from "inversify";
|
|
20
|
+
import { IHttpRequest, AxiosHttpRequest } from "@fiado/http-client";
|
|
21
|
+
import { apiInvokerContainer } from '@fiado/api-invoker';
|
|
22
|
+
|
|
23
|
+
// Crea el contenedor principal de tu aplicación
|
|
24
|
+
const container = new Container();
|
|
25
|
+
|
|
26
|
+
// Aplica las configuraciones de vinculación de fiado-gateway-adapter al contenedor
|
|
27
|
+
container.load(gatewayAdapterBindings);
|
|
28
|
+
|
|
29
|
+
// Registro del cliente HTTP
|
|
30
|
+
container.bind<IHttpRequest>("IHttpRequest").to(AxiosHttpRequest);
|
|
31
|
+
|
|
32
|
+
// Exporta el contenedor para su uso en toda tu aplicación
|
|
33
|
+
export { container };
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
## Uso de IDirectoryApi en Servicios del Proyecto
|
|
40
|
+
|
|
41
|
+
Para utilizar `fiado-api-invoker`, necesitas configurar el contenedor de InversifyJS en tu aplicación. Aquí te mostramos cómo registrar las dependencias necesarias:
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
import { inject, injectable } from "inversify";
|
|
45
|
+
import { IDirectoryApi } from "fiado-api-invoker";
|
|
46
|
+
import { log } from "@fiado/logger";
|
|
47
|
+
|
|
48
|
+
@injectable()
|
|
49
|
+
export class SomeService {
|
|
50
|
+
constructor(@inject("IDirectoryApi") private directoryApi: IDirectoryApi) {}
|
|
51
|
+
|
|
52
|
+
public async fetchDirectoryDetails(directoryIds: string[]): Promise<void> {
|
|
53
|
+
try {
|
|
54
|
+
const details = await this.directoryApi.getByIds(directoryIds);
|
|
55
|
+
log.info(details);
|
|
56
|
+
|
|
57
|
+
} catch (error) {
|
|
58
|
+
log.error("Error fetching directory details:", error);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
|
package/bin/container.config.js
CHANGED
|
@@ -8,8 +8,10 @@ const inversify_1 = require("inversify");
|
|
|
8
8
|
const directory_1 = require("./directory");
|
|
9
9
|
const identity_1 = require("./identity");
|
|
10
10
|
const NotificationMessagePublisher_1 = __importDefault(require("./notificationMessages/queue/NotificationMessagePublisher"));
|
|
11
|
+
const sessionActivity_1 = require("./sessionActivity");
|
|
11
12
|
exports.apiInvokerBindings = new inversify_1.ContainerModule((bind) => {
|
|
12
13
|
bind("IDirectoryApi").to(directory_1.DirectoryApi);
|
|
13
14
|
bind("IIdentityApi").to(identity_1.IdentityApi);
|
|
14
15
|
bind("INotificationMessagesPublisher").to(NotificationMessagePublisher_1.default);
|
|
16
|
+
bind("ISessionActivityPublisher").to(sessionActivity_1.SessionActivityPublisher);
|
|
15
17
|
});
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
2
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
9
|
exports.SessionActivityPublisher = void 0;
|
|
4
10
|
const client_sqs_1 = require("@aws-sdk/client-sqs");
|
|
5
|
-
|
|
11
|
+
const inversify_1 = require("inversify");
|
|
12
|
+
let SessionActivityPublisher = class SessionActivityPublisher {
|
|
6
13
|
constructor() {
|
|
7
14
|
this.SESSION_ACTIVITY_QUEUE = process.env.SESSION_ACTIVITY_QUEUE;
|
|
8
15
|
}
|
|
@@ -20,5 +27,8 @@ class SessionActivityPublisher {
|
|
|
20
27
|
throw new Error(`Error publishing message to queue ${': ' + error.message ?? ''}`);
|
|
21
28
|
}
|
|
22
29
|
}
|
|
23
|
-
}
|
|
30
|
+
};
|
|
24
31
|
exports.SessionActivityPublisher = SessionActivityPublisher;
|
|
32
|
+
exports.SessionActivityPublisher = SessionActivityPublisher = __decorate([
|
|
33
|
+
(0, inversify_1.injectable)()
|
|
34
|
+
], SessionActivityPublisher);
|
package/package.json
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@fiado/api-invoker",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Sirve como un puente entre diferentes funciones lambda, facilitando la comunicación entre ellas a traves de invocaciones http",
|
|
5
|
-
"main": "bin/index.js",
|
|
6
|
-
"types": "bin/index.d.ts",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"test": "test",
|
|
9
|
-
"build": "tsc"
|
|
10
|
-
},
|
|
11
|
-
"keywords": [],
|
|
12
|
-
"author": "Fiado Inc",
|
|
13
|
-
"license": "ISC",
|
|
14
|
-
"dependencies": {
|
|
15
|
-
"@aws-sdk/client-sqs": "^3.572.0",
|
|
16
|
-
"@fiado/api-invoker": "^1.0.5",
|
|
17
|
-
"@fiado/gateway-adapter": "^1.0.30",
|
|
18
|
-
"@fiado/http-client": "^1.0.1",
|
|
19
|
-
"@fiado/type-kit": "^1.0.39",
|
|
20
|
-
"dotenv": "^16.4.5",
|
|
21
|
-
"inversify": "^6.0.2",
|
|
22
|
-
"reflect-metadata": "^0.2.1",
|
|
23
|
-
"typescript": "^5.4.3"
|
|
24
|
-
},
|
|
25
|
-
"devDependencies": {
|
|
26
|
-
"@types/node": "^20.12.7"
|
|
27
|
-
}
|
|
28
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@fiado/api-invoker",
|
|
3
|
+
"version": "1.0.17",
|
|
4
|
+
"description": "Sirve como un puente entre diferentes funciones lambda, facilitando la comunicación entre ellas a traves de invocaciones http",
|
|
5
|
+
"main": "bin/index.js",
|
|
6
|
+
"types": "bin/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "test",
|
|
9
|
+
"build": "tsc"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [],
|
|
12
|
+
"author": "Fiado Inc",
|
|
13
|
+
"license": "ISC",
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@aws-sdk/client-sqs": "^3.572.0",
|
|
16
|
+
"@fiado/api-invoker": "^1.0.5",
|
|
17
|
+
"@fiado/gateway-adapter": "^1.0.30",
|
|
18
|
+
"@fiado/http-client": "^1.0.1",
|
|
19
|
+
"@fiado/type-kit": "^1.0.39",
|
|
20
|
+
"dotenv": "^16.4.5",
|
|
21
|
+
"inversify": "^6.0.2",
|
|
22
|
+
"reflect-metadata": "^0.2.1",
|
|
23
|
+
"typescript": "^5.4.3"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/node": "^20.12.7"
|
|
27
|
+
}
|
|
28
|
+
}
|
package/src/container.config.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import {ContainerModule, interfaces} from "inversify";
|
|
2
|
-
import {DirectoryApi, IDirectoryApi} from "./directory";
|
|
3
|
-
import {IdentityApi, IIdentityApi} from "./identity";
|
|
4
|
-
import {INotificationMessagesPublisher} from "./notificationMessages/queue/interfaces/INotificationMessagesPublisher";
|
|
5
|
-
import NotificationMessagePublisher from "./notificationMessages/queue/NotificationMessagePublisher";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
bind<
|
|
10
|
-
bind<
|
|
11
|
-
|
|
1
|
+
import {ContainerModule, interfaces} from "inversify";
|
|
2
|
+
import {DirectoryApi, IDirectoryApi} from "./directory";
|
|
3
|
+
import {IdentityApi, IIdentityApi} from "./identity";
|
|
4
|
+
import {INotificationMessagesPublisher} from "./notificationMessages/queue/interfaces/INotificationMessagesPublisher";
|
|
5
|
+
import NotificationMessagePublisher from "./notificationMessages/queue/NotificationMessagePublisher";
|
|
6
|
+
import { ISessionActivityPublisher, SessionActivityPublisher } from "./sessionActivity";
|
|
7
|
+
|
|
8
|
+
export const apiInvokerBindings = new ContainerModule((bind: interfaces.Bind) => {
|
|
9
|
+
bind<IDirectoryApi>("IDirectoryApi").to(DirectoryApi);
|
|
10
|
+
bind<IIdentityApi>("IIdentityApi").to(IdentityApi);
|
|
11
|
+
bind<INotificationMessagesPublisher>("INotificationMessagesPublisher").to(NotificationMessagePublisher);
|
|
12
|
+
bind<ISessionActivityPublisher>("ISessionActivityPublisher").to(SessionActivityPublisher);
|
|
13
|
+
});
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { inject, injectable } from "inversify";
|
|
2
|
-
import { IDirectoryApi } from "./interfaces/IDirectoryApi";
|
|
3
|
-
import { IHttpRequest } from "@fiado/http-client";
|
|
4
|
-
import dotenv from 'dotenv';
|
|
5
|
-
dotenv.config();
|
|
6
|
-
|
|
7
|
-
@injectable()
|
|
8
|
-
export class DirectoryApi implements IDirectoryApi {
|
|
9
|
-
|
|
10
|
-
private readonly baseUrl = process.env.DIRECTORY_LAMBDA_URL || "";
|
|
11
|
-
|
|
12
|
-
constructor(@inject("IHttpRequest") private httpRequest: IHttpRequest) { }
|
|
13
|
-
|
|
14
|
-
public async getByIds(ids: string[]): Promise<any> {
|
|
15
|
-
|
|
16
|
-
if (ids.length === 0) {
|
|
17
|
-
throw new Error("At least one directory ID is required.")
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const url = `${this.baseUrl}?${ids.map(id => `directoryId=${encodeURIComponent(id)}`).join('&')}`;
|
|
21
|
-
const operationName = "getUserInfoByIds";
|
|
22
|
-
|
|
23
|
-
return await this.httpRequest.post(`${url}`, null, { 'operationName': operationName });
|
|
24
|
-
}
|
|
25
|
-
}
|
|
1
|
+
import { inject, injectable } from "inversify";
|
|
2
|
+
import { IDirectoryApi } from "./interfaces/IDirectoryApi";
|
|
3
|
+
import { IHttpRequest } from "@fiado/http-client";
|
|
4
|
+
import dotenv from 'dotenv';
|
|
5
|
+
dotenv.config();
|
|
6
|
+
|
|
7
|
+
@injectable()
|
|
8
|
+
export class DirectoryApi implements IDirectoryApi {
|
|
9
|
+
|
|
10
|
+
private readonly baseUrl = process.env.DIRECTORY_LAMBDA_URL || "";
|
|
11
|
+
|
|
12
|
+
constructor(@inject("IHttpRequest") private httpRequest: IHttpRequest) { }
|
|
13
|
+
|
|
14
|
+
public async getByIds(ids: string[]): Promise<any> {
|
|
15
|
+
|
|
16
|
+
if (ids.length === 0) {
|
|
17
|
+
throw new Error("At least one directory ID is required.")
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const url = `${this.baseUrl}?${ids.map(id => `directoryId=${encodeURIComponent(id)}`).join('&')}`;
|
|
21
|
+
const operationName = "getUserInfoByIds";
|
|
22
|
+
|
|
23
|
+
return await this.httpRequest.post(`${url}`, null, { 'operationName': operationName });
|
|
24
|
+
}
|
|
25
|
+
}
|
package/src/directory/index.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export * from './interfaces/IDirectoryApi';
|
|
3
|
-
export * from './DirectoryApi';
|
|
1
|
+
|
|
2
|
+
export * from './interfaces/IDirectoryApi';
|
|
3
|
+
export * from './DirectoryApi';
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Interfaz para el servicio Directory que permite operaciones sobre directorios.
|
|
4
|
-
*/
|
|
5
|
-
export interface IDirectoryApi {
|
|
6
|
-
/**
|
|
7
|
-
* Obtiene una lista de directorios por sus IDs.
|
|
8
|
-
* @param ids Array de IDs de directorios (UUIDs) a buscar.
|
|
9
|
-
* @returns Una promesa que resuelve a un arreglo de objetos de directorio.
|
|
10
|
-
* Puede devolver un arreglo vacío si no se encuentran coincidencias.
|
|
11
|
-
* @throws {Error} Lanza un error si los parámetros de entrada son inválidos.
|
|
12
|
-
*/
|
|
13
|
-
getByIds(ids: string[]): Promise<any>;
|
|
14
|
-
}
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* Interfaz para el servicio Directory que permite operaciones sobre directorios.
|
|
4
|
+
*/
|
|
5
|
+
export interface IDirectoryApi {
|
|
6
|
+
/**
|
|
7
|
+
* Obtiene una lista de directorios por sus IDs.
|
|
8
|
+
* @param ids Array de IDs de directorios (UUIDs) a buscar.
|
|
9
|
+
* @returns Una promesa que resuelve a un arreglo de objetos de directorio.
|
|
10
|
+
* Puede devolver un arreglo vacío si no se encuentran coincidencias.
|
|
11
|
+
* @throws {Error} Lanza un error si los parámetros de entrada son inválidos.
|
|
12
|
+
*/
|
|
13
|
+
getByIds(ids: string[]): Promise<any>;
|
|
14
|
+
}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { inject, injectable } from "inversify";
|
|
2
|
-
import { IIdentityApi } from "./interfaces/IIdentityApi";
|
|
3
|
-
import { IHttpRequest } from "@fiado/http-client";
|
|
4
|
-
import dotenv from 'dotenv';
|
|
5
|
-
dotenv.config();
|
|
6
|
-
|
|
7
|
-
@injectable()
|
|
8
|
-
export class IdentityApi implements IIdentityApi {
|
|
9
|
-
|
|
10
|
-
private readonly baseUrl = process.env.IDENTITY_LAMBDA_URL || "";
|
|
11
|
-
|
|
12
|
-
constructor(@inject("IHttpRequest") private httpRequest: IHttpRequest) { }
|
|
13
|
-
|
|
14
|
-
async getPeopleByIds(ids: string[]): Promise<any> {
|
|
15
|
-
|
|
16
|
-
if (ids.length === 0) {
|
|
17
|
-
throw new Error("At least one people ID is required.")
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const url = `${this.baseUrl}identities/people?${ids.map(id => `id=${encodeURIComponent(id)}`).join('&')}`;
|
|
21
|
-
|
|
22
|
-
return await this.httpRequest.get(`${url}`);
|
|
23
|
-
|
|
24
|
-
}
|
|
1
|
+
import { inject, injectable } from "inversify";
|
|
2
|
+
import { IIdentityApi } from "./interfaces/IIdentityApi";
|
|
3
|
+
import { IHttpRequest } from "@fiado/http-client";
|
|
4
|
+
import dotenv from 'dotenv';
|
|
5
|
+
dotenv.config();
|
|
6
|
+
|
|
7
|
+
@injectable()
|
|
8
|
+
export class IdentityApi implements IIdentityApi {
|
|
9
|
+
|
|
10
|
+
private readonly baseUrl = process.env.IDENTITY_LAMBDA_URL || "";
|
|
11
|
+
|
|
12
|
+
constructor(@inject("IHttpRequest") private httpRequest: IHttpRequest) { }
|
|
13
|
+
|
|
14
|
+
async getPeopleByIds(ids: string[]): Promise<any> {
|
|
15
|
+
|
|
16
|
+
if (ids.length === 0) {
|
|
17
|
+
throw new Error("At least one people ID is required.")
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const url = `${this.baseUrl}identities/people?${ids.map(id => `id=${encodeURIComponent(id)}`).join('&')}`;
|
|
21
|
+
|
|
22
|
+
return await this.httpRequest.get(`${url}`);
|
|
23
|
+
|
|
24
|
+
}
|
|
25
25
|
}
|
package/src/identity/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export * from './interfaces/IIdentityApi';
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
export * from './interfaces/IIdentityApi';
|
|
4
4
|
export * from './IdentityApi';
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Interfaz para el servicio Directory que permite operaciones sobre directorios.
|
|
4
|
-
*/
|
|
5
|
-
export interface IIdentityApi {
|
|
6
|
-
/**
|
|
7
|
-
* Obtiene una lista de people por sus IDs.
|
|
8
|
-
* @param ids Array de IDs de peopleId (UUIDs) a buscar.
|
|
9
|
-
* @returns Una promesa que resuelve a un arreglo de objetos de people.
|
|
10
|
-
* Puede devolver un arreglo vacío si no se encuentran coincidencias.
|
|
11
|
-
* @throws {Error} Lanza un error si los parámetros de entrada son inválidos.
|
|
12
|
-
*/
|
|
13
|
-
getPeopleByIds(ids: string[]): Promise<any>;
|
|
14
|
-
}
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* Interfaz para el servicio Directory que permite operaciones sobre directorios.
|
|
4
|
+
*/
|
|
5
|
+
export interface IIdentityApi {
|
|
6
|
+
/**
|
|
7
|
+
* Obtiene una lista de people por sus IDs.
|
|
8
|
+
* @param ids Array de IDs de peopleId (UUIDs) a buscar.
|
|
9
|
+
* @returns Una promesa que resuelve a un arreglo de objetos de people.
|
|
10
|
+
* Puede devolver un arreglo vacío si no se encuentran coincidencias.
|
|
11
|
+
* @throws {Error} Lanza un error si los parámetros de entrada son inválidos.
|
|
12
|
+
*/
|
|
13
|
+
getPeopleByIds(ids: string[]): Promise<any>;
|
|
14
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export * from './directory';
|
|
2
|
-
export * from './identity';
|
|
3
|
-
export * from './notificationMessages';
|
|
4
|
-
export * from './sessionActivity';
|
|
5
|
-
|
|
6
|
-
export * from "./container.config";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
export * from './directory';
|
|
2
|
+
export * from './identity';
|
|
3
|
+
export * from './notificationMessages';
|
|
4
|
+
export * from './sessionActivity';
|
|
5
|
+
|
|
6
|
+
export * from "./container.config";
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './queue/NotificationMessagePublisher';
|
|
1
|
+
export * from './queue/NotificationMessagePublisher';
|
|
2
2
|
export * from './queue/interfaces/INotificationMessagesPublisher';
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import {INotificationMessagesPublisher} from "./interfaces/INotificationMessagesPublisher";
|
|
2
|
-
import {NotificationQueueMessageRequest} from "@fiado/type-kit/bin/notificationMessages";
|
|
3
|
-
import {SendMessageCommand, SendMessageRequest, SQSClient} from "@aws-sdk/client-sqs";
|
|
4
|
-
import {injectable} from "inversify";
|
|
5
|
-
|
|
6
|
-
@injectable()
|
|
7
|
-
export default class NotificationMessagePublisher implements INotificationMessagesPublisher {
|
|
8
|
-
private readonly NOTIFICATION_MESSAGES_QUEUE = process.env.NOTIFICATION_MESSAGES_QUEUE
|
|
9
|
-
|
|
10
|
-
async publish(message: NotificationQueueMessageRequest): Promise<void> {
|
|
11
|
-
try {
|
|
12
|
-
const client: SQSClient = new SQSClient();
|
|
13
|
-
const sendMessageRequest: SendMessageRequest = {
|
|
14
|
-
QueueUrl: this.NOTIFICATION_MESSAGES_QUEUE,
|
|
15
|
-
MessageBody: JSON.stringify(message)
|
|
16
|
-
};
|
|
17
|
-
const command: SendMessageCommand = new SendMessageCommand(sendMessageRequest);
|
|
18
|
-
await client.send(command);
|
|
19
|
-
} catch (error) {
|
|
20
|
-
throw new Error(`Error publishing message to queue ${': ' + error.message ?? ''}`);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
1
|
+
import {INotificationMessagesPublisher} from "./interfaces/INotificationMessagesPublisher";
|
|
2
|
+
import {NotificationQueueMessageRequest} from "@fiado/type-kit/bin/notificationMessages";
|
|
3
|
+
import {SendMessageCommand, SendMessageRequest, SQSClient} from "@aws-sdk/client-sqs";
|
|
4
|
+
import {injectable} from "inversify";
|
|
5
|
+
|
|
6
|
+
@injectable()
|
|
7
|
+
export default class NotificationMessagePublisher implements INotificationMessagesPublisher {
|
|
8
|
+
private readonly NOTIFICATION_MESSAGES_QUEUE = process.env.NOTIFICATION_MESSAGES_QUEUE
|
|
9
|
+
|
|
10
|
+
async publish(message: NotificationQueueMessageRequest): Promise<void> {
|
|
11
|
+
try {
|
|
12
|
+
const client: SQSClient = new SQSClient();
|
|
13
|
+
const sendMessageRequest: SendMessageRequest = {
|
|
14
|
+
QueueUrl: this.NOTIFICATION_MESSAGES_QUEUE,
|
|
15
|
+
MessageBody: JSON.stringify(message)
|
|
16
|
+
};
|
|
17
|
+
const command: SendMessageCommand = new SendMessageCommand(sendMessageRequest);
|
|
18
|
+
await client.send(command);
|
|
19
|
+
} catch (error) {
|
|
20
|
+
throw new Error(`Error publishing message to queue ${': ' + error.message ?? ''}`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
23
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {NotificationQueueMessageRequest} from "@fiado/type-kit/bin/notificationMessages";
|
|
2
|
-
|
|
3
|
-
export interface INotificationMessagesPublisher {
|
|
4
|
-
publish(message: NotificationQueueMessageRequest): Promise<void>;
|
|
1
|
+
import {NotificationQueueMessageRequest} from "@fiado/type-kit/bin/notificationMessages";
|
|
2
|
+
|
|
3
|
+
export interface INotificationMessagesPublisher {
|
|
4
|
+
publish(message: NotificationQueueMessageRequest): Promise<void>;
|
|
5
5
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './queue/SessionActivityPublisher';
|
|
2
|
-
export * from './queue/interfaces/ISessionActivityPublisher';
|
|
1
|
+
export * from './queue/SessionActivityPublisher';
|
|
2
|
+
export * from './queue/interfaces/ISessionActivityPublisher';
|
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
import {SendMessageCommand, SendMessageRequest, SQSClient} from "@aws-sdk/client-sqs";
|
|
2
|
-
import {ISessionActivityPublisher} from "./interfaces/ISessionActivityPublisher";
|
|
3
|
-
import {SessionActivityQueueMessageRequest} from "@fiado/type-kit/bin/sessionActivity";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
1
|
+
import {SendMessageCommand, SendMessageRequest, SQSClient} from "@aws-sdk/client-sqs";
|
|
2
|
+
import {ISessionActivityPublisher} from "./interfaces/ISessionActivityPublisher";
|
|
3
|
+
import {SessionActivityQueueMessageRequest} from "@fiado/type-kit/bin/sessionActivity";
|
|
4
|
+
import {injectable} from "inversify";
|
|
5
|
+
|
|
6
|
+
@injectable()
|
|
7
|
+
export class SessionActivityPublisher implements ISessionActivityPublisher {
|
|
8
|
+
private readonly SESSION_ACTIVITY_QUEUE = process.env.SESSION_ACTIVITY_QUEUE
|
|
9
|
+
|
|
10
|
+
async publish(message: SessionActivityQueueMessageRequest): Promise<void> {
|
|
11
|
+
try {
|
|
12
|
+
const client: SQSClient = new SQSClient();
|
|
13
|
+
const sendMessageRequest: SendMessageRequest = {
|
|
14
|
+
QueueUrl: this.SESSION_ACTIVITY_QUEUE,
|
|
15
|
+
MessageBody: JSON.stringify(message)
|
|
16
|
+
};
|
|
17
|
+
const command: SendMessageCommand = new SendMessageCommand(sendMessageRequest);
|
|
18
|
+
await client.send(command);
|
|
19
|
+
} catch (error) {
|
|
20
|
+
throw new Error(`Error publishing message to queue ${': ' + error.message ?? ''}`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
21
23
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {SessionActivityQueueMessageRequest} from "@fiado/type-kit/bin/sessionActivity";
|
|
2
|
-
|
|
3
|
-
export interface ISessionActivityPublisher {
|
|
4
|
-
publish(message: SessionActivityQueueMessageRequest): Promise<void>;
|
|
1
|
+
import {SessionActivityQueueMessageRequest} from "@fiado/type-kit/bin/sessionActivity";
|
|
2
|
+
|
|
3
|
+
export interface ISessionActivityPublisher {
|
|
4
|
+
publish(message: SessionActivityQueueMessageRequest): Promise<void>;
|
|
5
5
|
}
|
package/tsconfig.json
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2020",
|
|
4
|
-
"module": "commonjs",
|
|
5
|
-
"esModuleInterop": true,
|
|
6
|
-
"skipLibCheck": true,
|
|
7
|
-
"forceConsistentCasingInFileNames": true,
|
|
8
|
-
"experimentalDecorators": true,
|
|
9
|
-
"emitDecoratorMetadata": true,
|
|
10
|
-
"outDir": "./bin",
|
|
11
|
-
"rootDir": "./src",
|
|
12
|
-
"moduleResolution": "node",
|
|
13
|
-
"declaration": true,
|
|
14
|
-
},
|
|
15
|
-
"include": [
|
|
16
|
-
"./src/**/*"
|
|
17
|
-
],
|
|
18
|
-
"exclude": [
|
|
19
|
-
"node_modules"
|
|
20
|
-
]
|
|
21
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"esModuleInterop": true,
|
|
6
|
+
"skipLibCheck": true,
|
|
7
|
+
"forceConsistentCasingInFileNames": true,
|
|
8
|
+
"experimentalDecorators": true,
|
|
9
|
+
"emitDecoratorMetadata": true,
|
|
10
|
+
"outDir": "./bin",
|
|
11
|
+
"rootDir": "./src",
|
|
12
|
+
"moduleResolution": "node",
|
|
13
|
+
"declaration": true,
|
|
14
|
+
},
|
|
15
|
+
"include": [
|
|
16
|
+
"./src/**/*"
|
|
17
|
+
],
|
|
18
|
+
"exclude": [
|
|
19
|
+
"node_modules"
|
|
20
|
+
]
|
|
21
|
+
}
|