@fiado/api-invoker 1.0.18 → 1.0.20
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/address/AddressApi.d.ts +13 -0
- package/bin/address/AddressApi.js +55 -0
- package/bin/address/index.d.ts +2 -0
- package/bin/address/index.js +18 -0
- package/bin/address/interfaces/IAddressApi.d.ts +26 -0
- package/bin/address/interfaces/IAddressApi.js +2 -0
- package/bin/estafeta/EstafetaApi.d.ts +0 -0
- package/bin/estafeta/EstafetaApi.js +0 -0
- package/bin/identity/IdentityApi.d.ts +3 -0
- package/bin/identity/IdentityApi.js +15 -0
- package/bin/identity/interfaces/IIdentityApi.d.ts +16 -0
- package/bin/index.d.ts +1 -0
- package/bin/index.js +1 -0
- package/package.json +28 -28
- package/src/address/AddressApi.ts +48 -0
- package/src/address/index.ts +4 -0
- package/src/address/interfaces/IAddressApi.ts +31 -0
- package/src/container.config.ts +14 -14
- package/src/directory/DirectoryApi.ts +25 -25
- package/src/directory/index.ts +3 -3
- package/src/directory/interfaces/IDirectoryApi.ts +14 -14
- package/src/estafeta/EstafetaApi.ts +0 -0
- package/src/identity/IdentityApi.ts +47 -24
- package/src/identity/index.ts +3 -3
- package/src/identity/interfaces/IIdentityApi.ts +33 -14
- package/src/index.ts +11 -10
- 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 -22
- package/src/sessionActivity/queue/interfaces/ISessionActivityPublisher.ts +4 -4
- package/src/tern/api/TernApi.ts +41 -41
- package/src/tern/api/interfaces/ITernApi.ts +15 -15
- package/src/tern/index.ts +1 -1
- 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
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IHttpRequest } from "@fiado/http-client";
|
|
2
|
+
import { AddressCreateRequest, AddressResponse, AddressShippingCardRequest, AddressShippingCardResponse } from "@fiado/type-kit/bin/address";
|
|
3
|
+
import { IAddressApi } from "./interfaces/IAddressApi";
|
|
4
|
+
export declare class AddressApi implements IAddressApi {
|
|
5
|
+
private httpRequest;
|
|
6
|
+
private readonly baseUrl;
|
|
7
|
+
constructor(httpRequest: IHttpRequest);
|
|
8
|
+
getByDirectoryId(directoryId: string): Promise<AddressResponse[]>;
|
|
9
|
+
create(directoryId: string, address: AddressCreateRequest): Promise<void>;
|
|
10
|
+
getAddressLocationShipping(input: AddressShippingCardRequest): Promise<AddressShippingCardResponse>;
|
|
11
|
+
private validateBaseUrl;
|
|
12
|
+
private validateDirectoryId;
|
|
13
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.AddressApi = void 0;
|
|
16
|
+
const inversify_1 = require("inversify");
|
|
17
|
+
let AddressApi = class AddressApi {
|
|
18
|
+
constructor(httpRequest) {
|
|
19
|
+
this.httpRequest = httpRequest;
|
|
20
|
+
this.baseUrl = process.env.ADDRESS_LAMBDA_URL || "";
|
|
21
|
+
}
|
|
22
|
+
async getByDirectoryId(directoryId) {
|
|
23
|
+
this.validateBaseUrl();
|
|
24
|
+
this.validateDirectoryId(directoryId);
|
|
25
|
+
const url = `${this.baseUrl}/users/${directoryId}`;
|
|
26
|
+
return await this.httpRequest.post(`${url}`, null);
|
|
27
|
+
}
|
|
28
|
+
async create(directoryId, address) {
|
|
29
|
+
this.validateBaseUrl();
|
|
30
|
+
this.validateDirectoryId(directoryId);
|
|
31
|
+
const url = `${this.baseUrl}/users/${directoryId}`;
|
|
32
|
+
await this.httpRequest.post(url, address);
|
|
33
|
+
}
|
|
34
|
+
async getAddressLocationShipping(input) {
|
|
35
|
+
this.validateBaseUrl();
|
|
36
|
+
const url = `${this.baseUrl}/shipping`;
|
|
37
|
+
return await this.httpRequest.post(url, input);
|
|
38
|
+
}
|
|
39
|
+
validateBaseUrl() {
|
|
40
|
+
if (!this.baseUrl) {
|
|
41
|
+
throw new Error("Environment variable ADDRESS_LAMBDA_URL value not found");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
validateDirectoryId(directoryId) {
|
|
45
|
+
if (!directoryId) {
|
|
46
|
+
throw new Error("Directory ID is required.");
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
exports.AddressApi = AddressApi;
|
|
51
|
+
exports.AddressApi = AddressApi = __decorate([
|
|
52
|
+
(0, inversify_1.injectable)(),
|
|
53
|
+
__param(0, (0, inversify_1.inject)("IHttpRequest")),
|
|
54
|
+
__metadata("design:paramtypes", [Object])
|
|
55
|
+
], AddressApi);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./interfaces/IAddressApi"), exports);
|
|
18
|
+
__exportStar(require("./AddressApi"), exports);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { AddressCreateRequest, AddressResponse, AddressShippingCardRequest, AddressShippingCardResponse } from "@fiado/type-kit/bin/address";
|
|
2
|
+
export interface IAddressApi {
|
|
3
|
+
/**
|
|
4
|
+
* Obtiene una lista de direcciones por su ID de directorio.
|
|
5
|
+
* @param directoryId ID de directorio (UUID) a buscar.
|
|
6
|
+
* @returns Una promesa que resuelve a un arreglo de objetos de dirección.
|
|
7
|
+
* Puede devolver un arreglo vacío si no se encuentran coincidencias.
|
|
8
|
+
* @throws {Error} Lanza un error si los parámetros de entrada son inválidos.
|
|
9
|
+
*/
|
|
10
|
+
getByDirectoryId(directoryId: string): Promise<AddressResponse[]>;
|
|
11
|
+
/**
|
|
12
|
+
* Crea una nueva dirección para un directorio.
|
|
13
|
+
* @param directoryId ID de directorio (UUID) a buscar.
|
|
14
|
+
* @param address Objeto de dirección a crear.
|
|
15
|
+
* @returns Una promesa que resuelve a void.
|
|
16
|
+
* @throws {Error} Lanza un error si los parámetros de entrada son inválidos.
|
|
17
|
+
*/
|
|
18
|
+
create(directoryId: string, address: AddressCreateRequest): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Obtiene la dirección de envío de una tarjeta.
|
|
21
|
+
* @param input Objeto de solicitud de dirección de envío.
|
|
22
|
+
* @returns Una promesa que resuelve a un objeto de respuesta de dirección de envío.
|
|
23
|
+
* @throws {Error} Lanza un error si los parámetros de entrada son inválidos.
|
|
24
|
+
*/
|
|
25
|
+
getAddressLocationShipping(input: AddressShippingCardRequest): Promise<AddressShippingCardResponse>;
|
|
26
|
+
}
|
|
File without changes
|
|
File without changes
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { IIdentityApi } from "./interfaces/IIdentityApi";
|
|
2
2
|
import { IHttpRequest } from "@fiado/http-client";
|
|
3
|
+
import { PeopleUpdateRequest } from "@fiado/type-kit/bin/identity";
|
|
3
4
|
export declare class IdentityApi implements IIdentityApi {
|
|
4
5
|
private httpRequest;
|
|
5
6
|
private readonly baseUrl;
|
|
6
7
|
constructor(httpRequest: IHttpRequest);
|
|
7
8
|
getPeopleByIds(ids: string[]): Promise<any>;
|
|
9
|
+
updatePeopleById(id: string, data: PeopleUpdateRequest): Promise<void>;
|
|
10
|
+
getProfilePicture(directoryId: string): Promise<any>;
|
|
8
11
|
}
|
|
@@ -31,6 +31,21 @@ let IdentityApi = class IdentityApi {
|
|
|
31
31
|
const url = `${this.baseUrl}identities/people?${ids.map(id => `id=${encodeURIComponent(id)}`).join('&')}`;
|
|
32
32
|
return await this.httpRequest.get(`${url}`);
|
|
33
33
|
}
|
|
34
|
+
async updatePeopleById(id, data) {
|
|
35
|
+
if (!id) {
|
|
36
|
+
throw new Error("People ID is required.");
|
|
37
|
+
}
|
|
38
|
+
const url = `${this.baseUrl}identities/people/${id}`;
|
|
39
|
+
await this.httpRequest.put(url, data);
|
|
40
|
+
}
|
|
41
|
+
async getProfilePicture(directoryId) {
|
|
42
|
+
if (!directoryId) {
|
|
43
|
+
throw new Error("Directory ID is required.");
|
|
44
|
+
}
|
|
45
|
+
const url = `${this.baseUrl}identities/profile?directoryId=${directoryId}&typeOfDirectoryId=USER`;
|
|
46
|
+
const operationName = "getUserInfoByIds";
|
|
47
|
+
return await this.httpRequest.get(url, { 'operationName': operationName });
|
|
48
|
+
}
|
|
34
49
|
};
|
|
35
50
|
exports.IdentityApi = IdentityApi;
|
|
36
51
|
exports.IdentityApi = IdentityApi = __decorate([
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PeopleUpdateRequest } from "@fiado/type-kit/bin/identity";
|
|
1
2
|
/**
|
|
2
3
|
* Interfaz para el servicio Directory que permite operaciones sobre directorios.
|
|
3
4
|
*/
|
|
@@ -10,4 +11,19 @@ export interface IIdentityApi {
|
|
|
10
11
|
* @throws {Error} Lanza un error si los parámetros de entrada son inválidos.
|
|
11
12
|
*/
|
|
12
13
|
getPeopleByIds(ids: string[]): Promise<any>;
|
|
14
|
+
/**
|
|
15
|
+
* Actualiza la información de un people.
|
|
16
|
+
* @param id ID de people a actualizar.
|
|
17
|
+
* @param data Datos de people a actualizar.
|
|
18
|
+
* @returns Una promesa que resuelve a void.
|
|
19
|
+
* @throws {Error} Lanza un error si los parámetros de entrada son inválidos.
|
|
20
|
+
*/
|
|
21
|
+
updatePeopleById(id: string, data: PeopleUpdateRequest): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Obtiene la URL de la imagen de perfil de un usuario.
|
|
24
|
+
* @param directoryId ID de directorio del usuario.
|
|
25
|
+
* @returns Una promesa que resuelve a un objeto con la URL de la imagen de perfil.
|
|
26
|
+
* @throws {Error} Lanza un error si los parámetros de entrada son inválidos.
|
|
27
|
+
*/
|
|
28
|
+
getProfilePicture(directoryId: string): Promise<any>;
|
|
13
29
|
}
|
package/bin/index.d.ts
CHANGED
package/bin/index.js
CHANGED
|
@@ -19,4 +19,5 @@ __exportStar(require("./identity"), exports);
|
|
|
19
19
|
__exportStar(require("./notificationMessages"), exports);
|
|
20
20
|
__exportStar(require("./sessionActivity"), exports);
|
|
21
21
|
__exportStar(require("./tern"), exports);
|
|
22
|
+
__exportStar(require("./address"), exports);
|
|
22
23
|
__exportStar(require("./container.config"), exports);
|
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.
|
|
17
|
-
"@fiado/gateway-adapter": "^1.0.30",
|
|
18
|
-
"@fiado/http-client": "^1.0.1",
|
|
19
|
-
"@fiado/type-kit": "^1.0.
|
|
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.20",
|
|
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.19",
|
|
17
|
+
"@fiado/gateway-adapter": "^1.0.30",
|
|
18
|
+
"@fiado/http-client": "^1.0.1",
|
|
19
|
+
"@fiado/type-kit": "^1.0.64",
|
|
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
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { IHttpRequest } from "@fiado/http-client";
|
|
2
|
+
import { AddressCreateRequest, AddressResponse, AddressShippingCardRequest, AddressShippingCardResponse } from "@fiado/type-kit/bin/address";
|
|
3
|
+
import { inject, injectable } from "inversify";
|
|
4
|
+
import { IAddressApi } from "./interfaces/IAddressApi";
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@injectable()
|
|
8
|
+
export class AddressApi implements IAddressApi {
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
private readonly baseUrl = process.env.ADDRESS_LAMBDA_URL || "";
|
|
12
|
+
constructor(@inject("IHttpRequest") private httpRequest: IHttpRequest) { }
|
|
13
|
+
|
|
14
|
+
async getByDirectoryId(directoryId: string): Promise<AddressResponse[]> {
|
|
15
|
+
|
|
16
|
+
this.validateBaseUrl();
|
|
17
|
+
this.validateDirectoryId(directoryId);
|
|
18
|
+
|
|
19
|
+
const url = `${this.baseUrl}/users/${directoryId}`;
|
|
20
|
+
|
|
21
|
+
return await this.httpRequest.post(`${url}`, null);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async create(directoryId: string, address: AddressCreateRequest): Promise<void> {
|
|
25
|
+
this.validateBaseUrl();
|
|
26
|
+
this.validateDirectoryId(directoryId);
|
|
27
|
+
const url = `${this.baseUrl}/users/${directoryId}`;
|
|
28
|
+
await this.httpRequest.post<void>(url, address);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async getAddressLocationShipping(input: AddressShippingCardRequest): Promise<AddressShippingCardResponse> {
|
|
32
|
+
this.validateBaseUrl();
|
|
33
|
+
const url = `${this.baseUrl}/shipping`;
|
|
34
|
+
return await this.httpRequest.post<AddressShippingCardResponse>(url, input);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
private validateBaseUrl() {
|
|
38
|
+
if (!this.baseUrl) {
|
|
39
|
+
throw new Error("Environment variable ADDRESS_LAMBDA_URL value not found");
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
private validateDirectoryId(directoryId: string) {
|
|
44
|
+
if (!directoryId) {
|
|
45
|
+
throw new Error("Directory ID is required.");
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { AddressCreateRequest, AddressResponse, AddressShippingCardRequest, AddressShippingCardResponse } from "@fiado/type-kit/bin/address";
|
|
2
|
+
|
|
3
|
+
export interface IAddressApi {
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Obtiene una lista de direcciones por su ID de directorio.
|
|
7
|
+
* @param directoryId ID de directorio (UUID) a buscar.
|
|
8
|
+
* @returns Una promesa que resuelve a un arreglo de objetos de dirección.
|
|
9
|
+
* Puede devolver un arreglo vacío si no se encuentran coincidencias.
|
|
10
|
+
* @throws {Error} Lanza un error si los parámetros de entrada son inválidos.
|
|
11
|
+
*/
|
|
12
|
+
getByDirectoryId(directoryId: string): Promise<AddressResponse[]>;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Crea una nueva dirección para un directorio.
|
|
16
|
+
* @param directoryId ID de directorio (UUID) a buscar.
|
|
17
|
+
* @param address Objeto de dirección a crear.
|
|
18
|
+
* @returns Una promesa que resuelve a void.
|
|
19
|
+
* @throws {Error} Lanza un error si los parámetros de entrada son inválidos.
|
|
20
|
+
*/
|
|
21
|
+
create(directoryId: string, address: AddressCreateRequest): Promise<void>;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Obtiene la dirección de envío de una tarjeta.
|
|
25
|
+
* @param input Objeto de solicitud de dirección de envío.
|
|
26
|
+
* @returns Una promesa que resuelve a un objeto de respuesta de dirección de envío.
|
|
27
|
+
* @throws {Error} Lanza un error si los parámetros de entrada son inválidos.
|
|
28
|
+
*/
|
|
29
|
+
getAddressLocationShipping(input: AddressShippingCardRequest): Promise<AddressShippingCardResponse>;
|
|
30
|
+
|
|
31
|
+
}
|
package/src/container.config.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {ContainerModule, interfaces} from "inversify";
|
|
2
|
-
import {DirectoryApi, IDirectoryApi} from "./directory";
|
|
3
|
-
import {IdentityApi, IIdentityApi} from "./identity";
|
|
4
|
-
import {INotificationMessagesPublisher} from "./notificationMessages";
|
|
5
|
-
import NotificationMessagePublisher from "./notificationMessages/queue/NotificationMessagePublisher";
|
|
6
|
-
import {ITernApi} from "./tern";
|
|
7
|
-
import TernApi from "./tern/api/TernApi";
|
|
8
|
-
|
|
9
|
-
export const apiInvokerBindings = new ContainerModule((bind: interfaces.Bind) => {
|
|
10
|
-
bind<IDirectoryApi>("IDirectoryApi").to(DirectoryApi);
|
|
11
|
-
bind<IIdentityApi>("IIdentityApi").to(IdentityApi);
|
|
12
|
-
bind<ITernApi>("ITernApi").to(TernApi);
|
|
13
|
-
bind<INotificationMessagesPublisher>("INotificationMessagesPublisher").to(NotificationMessagePublisher);
|
|
14
|
-
});
|
|
1
|
+
import {ContainerModule, interfaces} from "inversify";
|
|
2
|
+
import {DirectoryApi, IDirectoryApi} from "./directory";
|
|
3
|
+
import {IdentityApi, IIdentityApi} from "./identity";
|
|
4
|
+
import {INotificationMessagesPublisher} from "./notificationMessages";
|
|
5
|
+
import NotificationMessagePublisher from "./notificationMessages/queue/NotificationMessagePublisher";
|
|
6
|
+
import {ITernApi} from "./tern";
|
|
7
|
+
import TernApi from "./tern/api/TernApi";
|
|
8
|
+
|
|
9
|
+
export const apiInvokerBindings = new ContainerModule((bind: interfaces.Bind) => {
|
|
10
|
+
bind<IDirectoryApi>("IDirectoryApi").to(DirectoryApi);
|
|
11
|
+
bind<IIdentityApi>("IIdentityApi").to(IdentityApi);
|
|
12
|
+
bind<ITernApi>("ITernApi").to(TernApi);
|
|
13
|
+
bind<INotificationMessagesPublisher>("INotificationMessagesPublisher").to(NotificationMessagePublisher);
|
|
14
|
+
});
|
|
@@ -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
|
+
}
|
|
File without changes
|
|
@@ -1,25 +1,48 @@
|
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
+
import { PeopleUpdateRequest } from "@fiado/type-kit/bin/identity";
|
|
6
|
+
dotenv.config();
|
|
7
|
+
|
|
8
|
+
@injectable()
|
|
9
|
+
export class IdentityApi implements IIdentityApi {
|
|
10
|
+
|
|
11
|
+
private readonly baseUrl = process.env.IDENTITY_LAMBDA_URL || "";
|
|
12
|
+
|
|
13
|
+
constructor(@inject("IHttpRequest") private httpRequest: IHttpRequest) { }
|
|
14
|
+
|
|
15
|
+
async getPeopleByIds(ids: string[]): Promise<any> {
|
|
16
|
+
|
|
17
|
+
if (ids.length === 0) {
|
|
18
|
+
throw new Error("At least one people ID is required.")
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const url = `${this.baseUrl}identities/people?${ids.map(id => `id=${encodeURIComponent(id)}`).join('&')}`;
|
|
22
|
+
return await this.httpRequest.get(`${url}`);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async updatePeopleById(id: string, data: PeopleUpdateRequest): Promise<void> {
|
|
26
|
+
|
|
27
|
+
if (!id) {
|
|
28
|
+
throw new Error("People ID is required.")
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const url = `${this.baseUrl}identities/people/${id}`;
|
|
32
|
+
await this.httpRequest.put<void>(url, data);
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async getProfilePicture(directoryId: string): Promise<any> {
|
|
37
|
+
|
|
38
|
+
if (!directoryId) {
|
|
39
|
+
throw new Error("Directory ID is required.")
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const url = `${this.baseUrl}identities/profile?directoryId=${directoryId}&typeOfDirectoryId=USER`;
|
|
43
|
+
const operationName = "getUserInfoByIds";
|
|
44
|
+
|
|
45
|
+
return await this.httpRequest.get<any>(url, { 'operationName': operationName });
|
|
46
|
+
|
|
47
|
+
}
|
|
25
48
|
}
|
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,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*
|
|
9
|
-
* @
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { PeopleUpdateRequest } from "@fiado/type-kit/bin/identity";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Interfaz para el servicio Directory que permite operaciones sobre directorios.
|
|
5
|
+
*/
|
|
6
|
+
export interface IIdentityApi {
|
|
7
|
+
/**
|
|
8
|
+
* Obtiene una lista de people por sus IDs.
|
|
9
|
+
* @param ids Array de IDs de peopleId (UUIDs) a buscar.
|
|
10
|
+
* @returns Una promesa que resuelve a un arreglo de objetos de people.
|
|
11
|
+
* Puede devolver un arreglo vacío si no se encuentran coincidencias.
|
|
12
|
+
* @throws {Error} Lanza un error si los parámetros de entrada son inválidos.
|
|
13
|
+
*/
|
|
14
|
+
getPeopleByIds(ids: string[]): Promise<any>;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Actualiza la información de un people.
|
|
18
|
+
* @param id ID de people a actualizar.
|
|
19
|
+
* @param data Datos de people a actualizar.
|
|
20
|
+
* @returns Una promesa que resuelve a void.
|
|
21
|
+
* @throws {Error} Lanza un error si los parámetros de entrada son inválidos.
|
|
22
|
+
*/
|
|
23
|
+
updatePeopleById(id: string, data: PeopleUpdateRequest): Promise<void>;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Obtiene la URL de la imagen de perfil de un usuario.
|
|
27
|
+
* @param directoryId ID de directorio del usuario.
|
|
28
|
+
* @returns Una promesa que resuelve a un objeto con la URL de la imagen de perfil.
|
|
29
|
+
* @throws {Error} Lanza un error si los parámetros de entrada son inválidos.
|
|
30
|
+
*/
|
|
31
|
+
getProfilePicture(directoryId: string): Promise<any>;
|
|
32
|
+
|
|
33
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
export * from './directory';
|
|
2
|
-
export * from './identity';
|
|
3
|
-
export * from './notificationMessages';
|
|
4
|
-
export * from './sessionActivity';
|
|
5
|
-
export * from './tern';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
export * from './directory';
|
|
2
|
+
export * from './identity';
|
|
3
|
+
export * from './notificationMessages';
|
|
4
|
+
export * from './sessionActivity';
|
|
5
|
+
export * from './tern';
|
|
6
|
+
export * from './address';
|
|
7
|
+
|
|
8
|
+
export * from "./container.config";
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
@@ -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,23 +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
|
-
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
|
-
}
|
|
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
|
+
}
|
|
23
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/src/tern/api/TernApi.ts
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import {ITernApi} from "./interfaces/ITernApi";
|
|
2
|
-
import {inject, injectable} from "inversify";
|
|
3
|
-
import {IHttpRequest} from "@fiado/http-client";
|
|
4
|
-
import {
|
|
5
|
-
TernCreateAccountRequest,
|
|
6
|
-
TernCreateUserRequest,
|
|
7
|
-
TernGetAccountRequest,
|
|
8
|
-
TernGetUserRequest
|
|
9
|
-
} from "@fiado/type-kit/bin/tern";
|
|
10
|
-
|
|
11
|
-
@injectable()
|
|
12
|
-
export default class TernApi implements ITernApi {
|
|
13
|
-
private readonly baseUrl = process.env.TERN_LAMBDA_URL || "";
|
|
14
|
-
|
|
15
|
-
constructor(@inject("IHttpRequest") private httpRequest: IHttpRequest) {
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/// USERS
|
|
19
|
-
async getUser(request: TernGetUserRequest): Promise<any> {
|
|
20
|
-
const url: string = `${this.baseUrl}users/${request.externalUserId}`;
|
|
21
|
-
return await this.httpRequest.get(url);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
async createUser(request: TernCreateUserRequest): Promise<any> {
|
|
25
|
-
const url: string = `${this.baseUrl}users/create`;
|
|
26
|
-
return await this.httpRequest.post(url, request);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/// ACCOUNTS
|
|
30
|
-
async getAccount(request: TernGetAccountRequest): Promise<any> {
|
|
31
|
-
const url: string = `${this.baseUrl}accounts/${request.externalAccountId}`;
|
|
32
|
-
return await this.httpRequest.get(url);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
async createAccount(request: TernCreateAccountRequest): Promise<any> {
|
|
36
|
-
const url: string = `${this.baseUrl}accounts/create`;
|
|
37
|
-
return await this.httpRequest.post(url, request);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
1
|
+
import {ITernApi} from "./interfaces/ITernApi";
|
|
2
|
+
import {inject, injectable} from "inversify";
|
|
3
|
+
import {IHttpRequest} from "@fiado/http-client";
|
|
4
|
+
import {
|
|
5
|
+
TernCreateAccountRequest,
|
|
6
|
+
TernCreateUserRequest,
|
|
7
|
+
TernGetAccountRequest,
|
|
8
|
+
TernGetUserRequest
|
|
9
|
+
} from "@fiado/type-kit/bin/tern";
|
|
10
|
+
|
|
11
|
+
@injectable()
|
|
12
|
+
export default class TernApi implements ITernApi {
|
|
13
|
+
private readonly baseUrl = process.env.TERN_LAMBDA_URL || "";
|
|
14
|
+
|
|
15
|
+
constructor(@inject("IHttpRequest") private httpRequest: IHttpRequest) {
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/// USERS
|
|
19
|
+
async getUser(request: TernGetUserRequest): Promise<any> {
|
|
20
|
+
const url: string = `${this.baseUrl}users/${request.externalUserId}`;
|
|
21
|
+
return await this.httpRequest.get(url);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async createUser(request: TernCreateUserRequest): Promise<any> {
|
|
25
|
+
const url: string = `${this.baseUrl}users/create`;
|
|
26
|
+
return await this.httpRequest.post(url, request);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/// ACCOUNTS
|
|
30
|
+
async getAccount(request: TernGetAccountRequest): Promise<any> {
|
|
31
|
+
const url: string = `${this.baseUrl}accounts/${request.externalAccountId}`;
|
|
32
|
+
return await this.httpRequest.get(url);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async createAccount(request: TernCreateAccountRequest): Promise<any> {
|
|
36
|
+
const url: string = `${this.baseUrl}accounts/create`;
|
|
37
|
+
return await this.httpRequest.post(url, request);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
TernCreateAccountRequest,
|
|
3
|
-
TernCreateUserRequest,
|
|
4
|
-
TernGetAccountRequest,
|
|
5
|
-
TernGetUserRequest
|
|
6
|
-
} from "@fiado/type-kit/bin/tern";
|
|
7
|
-
|
|
8
|
-
export interface ITernApi {
|
|
9
|
-
getUser(request: TernGetUserRequest): Promise<any>;
|
|
10
|
-
|
|
11
|
-
createUser(request: TernCreateUserRequest): Promise<any>;
|
|
12
|
-
|
|
13
|
-
getAccount(request: TernGetAccountRequest): Promise<any>;
|
|
14
|
-
|
|
15
|
-
createAccount(request: TernCreateAccountRequest): Promise<any>;
|
|
1
|
+
import {
|
|
2
|
+
TernCreateAccountRequest,
|
|
3
|
+
TernCreateUserRequest,
|
|
4
|
+
TernGetAccountRequest,
|
|
5
|
+
TernGetUserRequest
|
|
6
|
+
} from "@fiado/type-kit/bin/tern";
|
|
7
|
+
|
|
8
|
+
export interface ITernApi {
|
|
9
|
+
getUser(request: TernGetUserRequest): Promise<any>;
|
|
10
|
+
|
|
11
|
+
createUser(request: TernCreateUserRequest): Promise<any>;
|
|
12
|
+
|
|
13
|
+
getAccount(request: TernGetAccountRequest): Promise<any>;
|
|
14
|
+
|
|
15
|
+
createAccount(request: TernCreateAccountRequest): Promise<any>;
|
|
16
16
|
}
|
package/src/tern/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './api/TernApi';
|
|
1
|
+
export * from './api/TernApi';
|
|
2
2
|
export * from './api/interfaces/ITernApi';
|
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
|
+
}
|