@fiado/api-invoker 1.0.16 → 1.0.18
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/index.d.ts +1 -0
- package/bin/index.js +1 -0
- package/bin/tern/api/TernApi.d.ts +12 -0
- package/bin/tern/api/TernApi.js +45 -0
- package/bin/tern/api/interfaces/ITernApi.d.ts +7 -0
- package/bin/tern/api/interfaces/ITernApi.js +2 -0
- package/bin/tern/index.d.ts +2 -0
- package/bin/tern/index.js +18 -0
- package/package.json +2 -2
- package/src/container.config.ts +4 -1
- package/src/index.ts +1 -0
- package/src/tern/api/TernApi.ts +41 -0
- package/src/tern/api/interfaces/ITernApi.ts +16 -0
- package/src/tern/index.ts +2 -0
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 TernApi_1 = __importDefault(require("./tern/api/TernApi"));
|
|
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);
|
|
15
|
+
bind("ITernApi").to(TernApi_1.default);
|
|
14
16
|
bind("INotificationMessagesPublisher").to(NotificationMessagePublisher_1.default);
|
|
15
17
|
});
|
package/bin/index.d.ts
CHANGED
package/bin/index.js
CHANGED
|
@@ -18,4 +18,5 @@ __exportStar(require("./directory"), exports);
|
|
|
18
18
|
__exportStar(require("./identity"), exports);
|
|
19
19
|
__exportStar(require("./notificationMessages"), exports);
|
|
20
20
|
__exportStar(require("./sessionActivity"), exports);
|
|
21
|
+
__exportStar(require("./tern"), exports);
|
|
21
22
|
__exportStar(require("./container.config"), exports);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ITernApi } from "./interfaces/ITernApi";
|
|
2
|
+
import { IHttpRequest } from "@fiado/http-client";
|
|
3
|
+
import { TernCreateAccountRequest, TernCreateUserRequest, TernGetAccountRequest, TernGetUserRequest } from "@fiado/type-kit/bin/tern";
|
|
4
|
+
export default class TernApi implements ITernApi {
|
|
5
|
+
private httpRequest;
|
|
6
|
+
private readonly baseUrl;
|
|
7
|
+
constructor(httpRequest: IHttpRequest);
|
|
8
|
+
getUser(request: TernGetUserRequest): Promise<any>;
|
|
9
|
+
createUser(request: TernCreateUserRequest): Promise<any>;
|
|
10
|
+
getAccount(request: TernGetAccountRequest): Promise<any>;
|
|
11
|
+
createAccount(request: TernCreateAccountRequest): Promise<any>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
const inversify_1 = require("inversify");
|
|
16
|
+
let TernApi = class TernApi {
|
|
17
|
+
constructor(httpRequest) {
|
|
18
|
+
this.httpRequest = httpRequest;
|
|
19
|
+
this.baseUrl = process.env.TERN_LAMBDA_URL || "";
|
|
20
|
+
}
|
|
21
|
+
/// USERS
|
|
22
|
+
async getUser(request) {
|
|
23
|
+
const url = `${this.baseUrl}users/${request.externalUserId}`;
|
|
24
|
+
return await this.httpRequest.get(url);
|
|
25
|
+
}
|
|
26
|
+
async createUser(request) {
|
|
27
|
+
const url = `${this.baseUrl}users/create`;
|
|
28
|
+
return await this.httpRequest.post(url, request);
|
|
29
|
+
}
|
|
30
|
+
/// ACCOUNTS
|
|
31
|
+
async getAccount(request) {
|
|
32
|
+
const url = `${this.baseUrl}accounts/${request.externalAccountId}`;
|
|
33
|
+
return await this.httpRequest.get(url);
|
|
34
|
+
}
|
|
35
|
+
async createAccount(request) {
|
|
36
|
+
const url = `${this.baseUrl}accounts/create`;
|
|
37
|
+
return await this.httpRequest.post(url, request);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
TernApi = __decorate([
|
|
41
|
+
(0, inversify_1.injectable)(),
|
|
42
|
+
__param(0, (0, inversify_1.inject)("IHttpRequest")),
|
|
43
|
+
__metadata("design:paramtypes", [Object])
|
|
44
|
+
], TernApi);
|
|
45
|
+
exports.default = TernApi;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TernCreateAccountRequest, TernCreateUserRequest, TernGetAccountRequest, TernGetUserRequest } from "@fiado/type-kit/bin/tern";
|
|
2
|
+
export interface ITernApi {
|
|
3
|
+
getUser(request: TernGetUserRequest): Promise<any>;
|
|
4
|
+
createUser(request: TernCreateUserRequest): Promise<any>;
|
|
5
|
+
getAccount(request: TernGetAccountRequest): Promise<any>;
|
|
6
|
+
createAccount(request: TernCreateAccountRequest): Promise<any>;
|
|
7
|
+
}
|
|
@@ -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("./api/TernApi"), exports);
|
|
18
|
+
__exportStar(require("./api/interfaces/ITernApi"), 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.18",
|
|
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",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"@fiado/api-invoker": "^1.0.5",
|
|
17
17
|
"@fiado/gateway-adapter": "^1.0.30",
|
|
18
18
|
"@fiado/http-client": "^1.0.1",
|
|
19
|
-
"@fiado/type-kit": "^1.0.
|
|
19
|
+
"@fiado/type-kit": "^1.0.59",
|
|
20
20
|
"dotenv": "^16.4.5",
|
|
21
21
|
"inversify": "^6.0.2",
|
|
22
22
|
"reflect-metadata": "^0.2.1",
|
package/src/container.config.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import {ContainerModule, interfaces} from "inversify";
|
|
2
2
|
import {DirectoryApi, IDirectoryApi} from "./directory";
|
|
3
3
|
import {IdentityApi, IIdentityApi} from "./identity";
|
|
4
|
-
import {INotificationMessagesPublisher} from "./notificationMessages
|
|
4
|
+
import {INotificationMessagesPublisher} from "./notificationMessages";
|
|
5
5
|
import NotificationMessagePublisher from "./notificationMessages/queue/NotificationMessagePublisher";
|
|
6
|
+
import {ITernApi} from "./tern";
|
|
7
|
+
import TernApi from "./tern/api/TernApi";
|
|
6
8
|
|
|
7
9
|
export const apiInvokerBindings = new ContainerModule((bind: interfaces.Bind) => {
|
|
8
10
|
bind<IDirectoryApi>("IDirectoryApi").to(DirectoryApi);
|
|
9
11
|
bind<IIdentityApi>("IIdentityApi").to(IdentityApi);
|
|
12
|
+
bind<ITernApi>("ITernApi").to(TernApi);
|
|
10
13
|
bind<INotificationMessagesPublisher>("INotificationMessagesPublisher").to(NotificationMessagePublisher);
|
|
11
14
|
});
|
package/src/index.ts
CHANGED
|
@@ -0,0 +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
|
+
}
|
|
@@ -0,0 +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>;
|
|
16
|
+
}
|