@fiado/api-invoker 1.0.6 → 1.0.8
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/directory/DirectoryApi.js +2 -2
- package/bin/identity/IdentityApi.d.ts +10 -0
- package/bin/identity/IdentityApi.js +40 -0
- package/bin/identity/index.d.ts +2 -0
- package/bin/identity/index.js +18 -0
- package/bin/identity/interfaces/IIdentityApi.d.ts +15 -0
- package/bin/identity/interfaces/IIdentityApi.js +2 -0
- package/bin/index.d.ts +1 -0
- package/bin/index.js +1 -0
- package/package.json +1 -1
- package/src/container.config.ts +4 -1
- package/src/directory/DirectoryApi.ts +2 -3
- package/src/identity/IdentityApi.ts +25 -0
- package/src/identity/index.ts +4 -0
- package/src/identity/interfaces/IIdentityApi.ts +14 -0
- package/src/index.ts +3 -0
package/bin/container.config.js
CHANGED
|
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.apiInvokerBindings = void 0;
|
|
4
4
|
const inversify_1 = require("inversify");
|
|
5
5
|
const directory_1 = require("./directory");
|
|
6
|
+
const IdentityApi_1 = require("./identity/IdentityApi");
|
|
6
7
|
exports.apiInvokerBindings = new inversify_1.ContainerModule((bind) => {
|
|
7
8
|
bind("IDirectoryApi").to(directory_1.DirectoryApi);
|
|
9
|
+
bind("IIdentityApi").to(IdentityApi_1.IdentityApi);
|
|
8
10
|
});
|
|
@@ -28,9 +28,9 @@ let DirectoryApi = class DirectoryApi {
|
|
|
28
28
|
if (ids.length === 0) {
|
|
29
29
|
throw new Error("At least one directory ID is required.");
|
|
30
30
|
}
|
|
31
|
-
const
|
|
31
|
+
const url = `${this.baseUrl}?${ids.map(id => `directoryId=${encodeURIComponent(id)}`).join('&')}`;
|
|
32
32
|
const operationName = "getUserInfoByIds";
|
|
33
|
-
return await this.httpRequest.post(`${
|
|
33
|
+
return await this.httpRequest.post(`${url}`, {}, { 'operationName': operationName });
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
36
|
exports.DirectoryApi = DirectoryApi;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IIdentityApi } from "./interfaces/IIdentityApi";
|
|
2
|
+
import { IHttpRequest } from "@fiado/http-client";
|
|
3
|
+
export declare class IdentityApi implements IIdentityApi {
|
|
4
|
+
private httpRequest;
|
|
5
|
+
private readonly baseUrl;
|
|
6
|
+
constructor(httpRequest: IHttpRequest);
|
|
7
|
+
getPeopleByIds(ids: string[]): Promise<{
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
}[]>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
15
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.IdentityApi = void 0;
|
|
19
|
+
const inversify_1 = require("inversify");
|
|
20
|
+
const dotenv_1 = __importDefault(require("dotenv"));
|
|
21
|
+
dotenv_1.default.config();
|
|
22
|
+
let IdentityApi = class IdentityApi {
|
|
23
|
+
constructor(httpRequest) {
|
|
24
|
+
this.httpRequest = httpRequest;
|
|
25
|
+
this.baseUrl = process.env.IDENTITY_LAMBDA_URL || "";
|
|
26
|
+
}
|
|
27
|
+
async getPeopleByIds(ids) {
|
|
28
|
+
if (ids.length === 0) {
|
|
29
|
+
throw new Error("At least one people ID is required.");
|
|
30
|
+
}
|
|
31
|
+
const url = `${this.baseUrl}identities/people?${ids.map(id => `peopleId=${encodeURIComponent(id)}`).join('&')}`;
|
|
32
|
+
return await this.httpRequest.post(`${url}`, {});
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
exports.IdentityApi = IdentityApi;
|
|
36
|
+
exports.IdentityApi = IdentityApi = __decorate([
|
|
37
|
+
(0, inversify_1.injectable)(),
|
|
38
|
+
__param(0, (0, inversify_1.inject)("IHttpRequest")),
|
|
39
|
+
__metadata("design:paramtypes", [Object])
|
|
40
|
+
], IdentityApi);
|
package/bin/identity/index.d.ts
CHANGED
package/bin/identity/index.js
CHANGED
|
@@ -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/IIdentityApi"), exports);
|
|
18
|
+
__exportStar(require("./IdentityApi"), exports);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interfaz para el servicio Directory que permite operaciones sobre directorios.
|
|
3
|
+
*/
|
|
4
|
+
export interface IIdentityApi {
|
|
5
|
+
/**
|
|
6
|
+
* Obtiene una lista de people por sus IDs.
|
|
7
|
+
* @param ids Array de IDs de peopleId (UUIDs) a buscar.
|
|
8
|
+
* @returns Una promesa que resuelve a un arreglo de objetos de people.
|
|
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
|
+
getPeopleByIds(ids: string[]): Promise<Array<{
|
|
13
|
+
[key: string]: any;
|
|
14
|
+
}>>;
|
|
15
|
+
}
|
package/bin/index.d.ts
CHANGED
package/bin/index.js
CHANGED
|
@@ -15,4 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./directory"), exports);
|
|
18
|
+
__exportStar(require("./identity"), exports);
|
|
18
19
|
__exportStar(require("./container.config"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fiado/api-invoker",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "Sirve como un puente entre diferentes funciones lambda, facilitando la comunicación entre ellas a traves de invocaciones http",
|
|
5
5
|
"main": "bin/index.js",
|
|
6
6
|
"types": "bin/index.d.ts",
|
package/src/container.config.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
|
|
2
2
|
import { ContainerModule, interfaces } from "inversify";
|
|
3
3
|
import { DirectoryApi, IDirectoryApi } from "./directory";
|
|
4
|
+
import { IIdentityApi } from "./identity/interfaces/IIdentityApi";
|
|
5
|
+
import { IdentityApi } from "./identity/IdentityApi";
|
|
4
6
|
|
|
5
7
|
export const apiInvokerBindings = new ContainerModule((bind: interfaces.Bind) => {
|
|
6
|
-
bind<IDirectoryApi>("IDirectoryApi").to(DirectoryApi)
|
|
8
|
+
bind<IDirectoryApi>("IDirectoryApi").to(DirectoryApi);
|
|
9
|
+
bind<IIdentityApi>("IIdentityApi").to(IdentityApi);
|
|
7
10
|
});
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
import { inject, injectable } from "inversify";
|
|
3
2
|
import { IDirectoryApi } from "./interfaces/IDirectoryApi";
|
|
4
3
|
import { IHttpRequest } from "@fiado/http-client";
|
|
@@ -18,9 +17,9 @@ export class DirectoryApi implements IDirectoryApi {
|
|
|
18
17
|
throw new Error("At least one directory ID is required.")
|
|
19
18
|
}
|
|
20
19
|
|
|
21
|
-
const
|
|
20
|
+
const url = `${this.baseUrl}?${ids.map(id => `directoryId=${encodeURIComponent(id)}`).join('&')}`;
|
|
22
21
|
const operationName = "getUserInfoByIds";
|
|
23
22
|
|
|
24
|
-
return await this.httpRequest.post(`${
|
|
23
|
+
return await this.httpRequest.post(`${url}`, {}, { 'operationName': operationName } );
|
|
25
24
|
}
|
|
26
25
|
}
|
|
@@ -0,0 +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<{ [key: string]: 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 => `peopleId=${encodeURIComponent(id)}`).join('&')}`;
|
|
21
|
+
|
|
22
|
+
return await this.httpRequest.post(`${url}`, {} );
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
}
|
package/src/identity/index.ts
CHANGED
|
@@ -0,0 +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<Array<{[key: string]: any}>>;
|
|
14
|
+
}
|