@fiado/api-invoker 3.0.35 → 3.0.38

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,10 @@
1
+ import { IHttpRequest } from "@fiado/http-client";
2
+ import { IAiEngineApi } from "./interfaces/IAiEngineApi";
3
+ import { AiAnalyzeResponse } from "@fiado/type-kit/bin/aiEngine";
4
+ import FiadoApiResponse from "@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse";
5
+ export declare class AiEngineApi implements IAiEngineApi {
6
+ private readonly httpRequest;
7
+ private readonly baseUrl;
8
+ constructor(httpRequest: IHttpRequest);
9
+ analyze(prompt: string, systemPrompt?: string, modelId?: string): Promise<FiadoApiResponse<AiAnalyzeResponse>>;
10
+ }
@@ -0,0 +1,46 @@
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.AiEngineApi = void 0;
19
+ const dotenv_1 = __importDefault(require("dotenv"));
20
+ const inversify_1 = require("inversify");
21
+ const logger_1 = require("@fiado/logger");
22
+ dotenv_1.default.config();
23
+ let AiEngineApi = class AiEngineApi {
24
+ constructor(httpRequest) {
25
+ this.httpRequest = httpRequest;
26
+ this.baseUrl = process.env.AI_ENGINE_LAMBDA_URL || "";
27
+ }
28
+ async analyze(prompt, systemPrompt, modelId) {
29
+ try {
30
+ const url = `${this.baseUrl}ai/analyze`;
31
+ const body = { prompt, systemPrompt, modelId };
32
+ logger_1.log.info(`Calling AI Engine at: ${url}`);
33
+ return await this.httpRequest.post(url, body, { 'operationName': 'aiAnalyze' });
34
+ }
35
+ catch (error) {
36
+ logger_1.log.error('Error calling AI Engine from api-invoker', error);
37
+ throw new Error('Error calling AI Engine from api-invoker');
38
+ }
39
+ }
40
+ };
41
+ exports.AiEngineApi = AiEngineApi;
42
+ exports.AiEngineApi = AiEngineApi = __decorate([
43
+ (0, inversify_1.injectable)(),
44
+ __param(0, (0, inversify_1.inject)("IHttpRequest")),
45
+ __metadata("design:paramtypes", [Object])
46
+ ], AiEngineApi);
@@ -0,0 +1,2 @@
1
+ export * from './interfaces/IAiEngineApi';
2
+ export * from './AiEngineApi';
@@ -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/IAiEngineApi"), exports);
18
+ __exportStar(require("./AiEngineApi"), exports);
@@ -0,0 +1,5 @@
1
+ import { AiAnalyzeResponse } from "@fiado/type-kit/bin/aiEngine";
2
+ import FiadoApiResponse from "@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse";
3
+ export interface IAiEngineApi {
4
+ analyze(prompt: string, systemPrompt?: string, modelId?: string): Promise<FiadoApiResponse<AiAnalyzeResponse>>;
5
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -93,6 +93,8 @@ const TeamsNotificationPublisher_1 = __importDefault(require("./teams-connector/
93
93
  // Legal document
94
94
  const legalDocument_1 = require("./legalDocument");
95
95
  const CountriesBusinessApi_1 = __importDefault(require("./countries-business/CountriesBusinessApi"));
96
+ // AI Engine connector
97
+ const ai_engine_connector_1 = require("./ai-engine-connector");
96
98
  exports.apiInvokerBindings = new inversify_1.ContainerModule((bind) => {
97
99
  // UTILS bindings
98
100
  bind("InvokerUtils").to(InvokerUtils_1.InvokerUtils);
@@ -188,4 +190,6 @@ exports.apiInvokerBindings = new inversify_1.ContainerModule((bind) => {
188
190
  bind("ILegalDocumentApi").to(legalDocument_1.LegalDocumentApi);
189
191
  // Countries business
190
192
  bind("ICountriesBusinessApi").to(CountriesBusinessApi_1.default);
193
+ // AI Engine connector
194
+ bind("IAiEngineApi").to(ai_engine_connector_1.AiEngineApi);
191
195
  });
@@ -4,7 +4,8 @@ export default class ContractBusinessApi implements IContractBusinessApi {
4
4
  private httpRequest;
5
5
  private readonly baseUrl;
6
6
  constructor(httpRequest: IHttpRequest);
7
- signDomiciliation(params: {
7
+ signDocument(params: {
8
+ documentType: string;
8
9
  directoryId: string;
9
10
  peopleId: string;
10
11
  folio: string;
@@ -18,8 +18,9 @@ let ContractBusinessApi = class ContractBusinessApi {
18
18
  this.httpRequest = httpRequest;
19
19
  this.baseUrl = process.env.CONTRACT_BUSINESS_LAMBDA_URL || "";
20
20
  }
21
- async signDomiciliation(params) {
22
- return await this.httpRequest.post(`${this.baseUrl}domiciliation/sign`, params);
21
+ async signDocument(params) {
22
+ const { documentType, ...body } = params;
23
+ return await this.httpRequest.post(`${this.baseUrl}/sign/${documentType}`, body);
23
24
  }
24
25
  };
25
26
  ContractBusinessApi = __decorate([
@@ -1,5 +1,6 @@
1
1
  export interface IContractBusinessApi {
2
- signDomiciliation(params: {
2
+ signDocument(params: {
3
+ documentType: string;
3
4
  directoryId: string;
4
5
  peopleId: string;
5
6
  folio: string;
package/bin/index.d.ts CHANGED
@@ -67,3 +67,4 @@ export * from "./commission-business";
67
67
  export * from "./platform-error-events";
68
68
  export * from "./teams-connector";
69
69
  export * from "./countries-business";
70
+ export * from "./ai-engine-connector";
package/bin/index.js CHANGED
@@ -83,3 +83,4 @@ __exportStar(require("./commission-business"), exports);
83
83
  __exportStar(require("./platform-error-events"), exports);
84
84
  __exportStar(require("./teams-connector"), exports);
85
85
  __exportStar(require("./countries-business"), exports);
86
+ __exportStar(require("./ai-engine-connector"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fiado/api-invoker",
3
- "version": "3.0.35",
3
+ "version": "3.0.38",
4
4
  "description": "Sirve como un puente entre diferentes funciones lambda, facilitando la comunicación entre ellas a través de invocaciones http",
5
5
  "main": "bin/index.js",
6
6
  "types": "bin/index.d.ts",
@@ -16,7 +16,7 @@
16
16
  "@fiado/gateway-adapter": "^1.1.50",
17
17
  "@fiado/http-client": "^1.0.7",
18
18
  "@fiado/logger": "^1.0.3",
19
- "@fiado/type-kit": "^3.1.4",
19
+ "@fiado/type-kit": "^3.1.8",
20
20
  "dotenv": "^16.4.7",
21
21
  "i": "^0.3.7",
22
22
  "inversify": "^6.2.2",
@@ -0,0 +1,28 @@
1
+ import dotenv from 'dotenv';
2
+ import { inject, injectable } from "inversify";
3
+ import { IHttpRequest } from "@fiado/http-client";
4
+ import { IAiEngineApi } from "./interfaces/IAiEngineApi";
5
+ import { AiAnalyzeRequest, AiAnalyzeResponse } from "@fiado/type-kit/bin/aiEngine";
6
+ import FiadoApiResponse from "@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse";
7
+ import { log } from "@fiado/logger";
8
+ dotenv.config();
9
+
10
+ @injectable()
11
+ export class AiEngineApi implements IAiEngineApi {
12
+
13
+ private readonly baseUrl = process.env.AI_ENGINE_LAMBDA_URL || "";
14
+
15
+ constructor(@inject("IHttpRequest") private readonly httpRequest: IHttpRequest) {}
16
+
17
+ public async analyze(prompt: string, systemPrompt?: string, modelId?: string): Promise<FiadoApiResponse<AiAnalyzeResponse>> {
18
+ try {
19
+ const url = `${this.baseUrl}ai/analyze`;
20
+ const body: AiAnalyzeRequest = { prompt, systemPrompt, modelId };
21
+ log.info(`Calling AI Engine at: ${url}`);
22
+ return await this.httpRequest.post(url, body, { 'operationName': 'aiAnalyze' });
23
+ } catch (error) {
24
+ log.error('Error calling AI Engine from api-invoker', error as Error);
25
+ throw new Error('Error calling AI Engine from api-invoker');
26
+ }
27
+ }
28
+ }
@@ -0,0 +1,2 @@
1
+ export * from './interfaces/IAiEngineApi';
2
+ export * from './AiEngineApi';
@@ -0,0 +1,6 @@
1
+ import { AiAnalyzeResponse } from "@fiado/type-kit/bin/aiEngine";
2
+ import FiadoApiResponse from "@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse";
3
+
4
+ export interface IAiEngineApi {
5
+ analyze(prompt: string, systemPrompt?: string, modelId?: string): Promise<FiadoApiResponse<AiAnalyzeResponse>>;
6
+ }
@@ -137,6 +137,8 @@ import { ILegalDocumentApi, LegalDocumentApi } from "./legalDocument";
137
137
  // Countries business
138
138
  import { ICountriesBusinessApi } from "./countries-business";
139
139
  import CountriesBusinessApi from "./countries-business/CountriesBusinessApi";
140
+ // AI Engine connector
141
+ import { IAiEngineApi, AiEngineApi } from "./ai-engine-connector";
140
142
 
141
143
  export const apiInvokerBindings = new ContainerModule((bind: interfaces.Bind) => {
142
144
  // UTILS bindings
@@ -240,4 +242,7 @@ export const apiInvokerBindings = new ContainerModule((bind: interfaces.Bind) =>
240
242
 
241
243
  // Countries business
242
244
  bind<ICountriesBusinessApi>("ICountriesBusinessApi").to(CountriesBusinessApi);
245
+
246
+ // AI Engine connector
247
+ bind<IAiEngineApi>("IAiEngineApi").to(AiEngineApi);
243
248
  });
@@ -10,12 +10,14 @@ export default class ContractBusinessApi implements IContractBusinessApi {
10
10
  constructor(@inject("IHttpRequest") private httpRequest: IHttpRequest) {
11
11
  }
12
12
 
13
- async signDomiciliation(params: {
13
+ async signDocument(params: {
14
+ documentType: string;
14
15
  directoryId: string;
15
16
  peopleId: string;
16
17
  folio: string;
17
18
  sessionId: string;
18
19
  }): Promise<any> {
19
- return await this.httpRequest.post(`${this.baseUrl}domiciliation/sign`, params);
20
+ const { documentType, ...body } = params;
21
+ return await this.httpRequest.post(`${this.baseUrl}/sign/${documentType}`, body);
20
22
  }
21
23
  }
@@ -1,5 +1,6 @@
1
1
  export interface IContractBusinessApi {
2
- signDomiciliation(params: {
2
+ signDocument(params: {
3
+ documentType: string;
3
4
  directoryId: string;
4
5
  peopleId: string;
5
6
  folio: string;
package/src/index.ts CHANGED
@@ -67,3 +67,4 @@ export * from "./commission-business";
67
67
  export * from "./platform-error-events";
68
68
  export * from "./teams-connector";
69
69
  export * from "./countries-business";
70
+ export * from "./ai-engine-connector";