@fiado/api-invoker 1.0.17 → 1.0.19

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.
@@ -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,2 @@
1
+ export * from './interfaces/IAddressApi';
2
+ export * from './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
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -8,10 +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
+ const TernApi_1 = __importDefault(require("./tern/api/TernApi"));
12
12
  exports.apiInvokerBindings = new inversify_1.ContainerModule((bind) => {
13
13
  bind("IDirectoryApi").to(directory_1.DirectoryApi);
14
14
  bind("IIdentityApi").to(identity_1.IdentityApi);
15
+ bind("ITernApi").to(TernApi_1.default);
15
16
  bind("INotificationMessagesPublisher").to(NotificationMessagePublisher_1.default);
16
- bind("ISessionActivityPublisher").to(sessionActivity_1.SessionActivityPublisher);
17
17
  });
File without changes
File without changes
package/bin/index.d.ts CHANGED
@@ -2,4 +2,6 @@ export * from './directory';
2
2
  export * from './identity';
3
3
  export * from './notificationMessages';
4
4
  export * from './sessionActivity';
5
+ export * from './tern';
6
+ export * from './address';
5
7
  export * from "./container.config";
package/bin/index.js CHANGED
@@ -18,4 +18,6 @@ __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);
22
+ __exportStar(require("./address"), exports);
21
23
  __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,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export * from './api/TernApi';
2
+ export * from './api/interfaces/ITernApi';
@@ -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.17",
3
+ "version": "1.0.19",
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.39",
19
+ "@fiado/type-kit": "^1.0.61",
20
20
  "dotenv": "^16.4.5",
21
21
  "inversify": "^6.0.2",
22
22
  "reflect-metadata": "^0.2.1",
@@ -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,4 @@
1
+
2
+
3
+ export * from './interfaces/IAddressApi';
4
+ export * from './AddressApi';
@@ -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
+ }
@@ -1,13 +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/queue/interfaces/INotificationMessagesPublisher";
4
+ import {INotificationMessagesPublisher} from "./notificationMessages";
5
5
  import NotificationMessagePublisher from "./notificationMessages/queue/NotificationMessagePublisher";
6
- import { ISessionActivityPublisher, SessionActivityPublisher } from "./sessionActivity";
6
+ import {ITernApi} from "./tern";
7
+ import TernApi from "./tern/api/TernApi";
7
8
 
8
9
  export const apiInvokerBindings = new ContainerModule((bind: interfaces.Bind) => {
9
10
  bind<IDirectoryApi>("IDirectoryApi").to(DirectoryApi);
10
11
  bind<IIdentityApi>("IIdentityApi").to(IdentityApi);
12
+ bind<ITernApi>("ITernApi").to(TernApi);
11
13
  bind<INotificationMessagesPublisher>("INotificationMessagesPublisher").to(NotificationMessagePublisher);
12
- bind<ISessionActivityPublisher>("ISessionActivityPublisher").to(SessionActivityPublisher);
13
14
  });
File without changes
package/src/index.ts CHANGED
@@ -2,6 +2,8 @@ export * from './directory';
2
2
  export * from './identity';
3
3
  export * from './notificationMessages';
4
4
  export * from './sessionActivity';
5
+ export * from './tern';
6
+ export * from './address';
5
7
 
6
8
  export * from "./container.config";
7
9
 
@@ -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
+ }
@@ -0,0 +1,2 @@
1
+ export * from './api/TernApi';
2
+ export * from './api/interfaces/ITernApi';