@fiado/api-invoker 5.100.0 → 5.102.0
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/file-storage/FileStorageApi.d.ts +15 -0
- package/bin/file-storage/FileStorageApi.js +46 -0
- package/bin/file-storage/index.d.ts +2 -0
- package/bin/file-storage/index.js +2 -0
- package/bin/file-storage/interfaces/IFileStorageApi.d.ts +17 -0
- package/bin/file-storage/interfaces/IFileStorageApi.js +1 -0
- package/bin/group/GroupApi.d.ts +2 -2
- package/bin/group/interfaces/IGroupApi.d.ts +2 -2
- package/bin/index.d.ts +1 -0
- package/bin/index.js +1 -0
- package/package.json +2 -2
- package/src/container.config.ts +2 -0
- package/src/file-storage/FileStorageApi.ts +43 -0
- package/src/file-storage/index.ts +2 -0
- package/src/file-storage/interfaces/IFileStorageApi.ts +15 -0
- package/src/group/GroupApi.ts +2 -2
- package/src/group/interfaces/IGroupApi.ts +2 -2
- package/src/index.ts +1 -0
package/bin/container.config.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ContainerModule } from "inversify";
|
|
2
2
|
import { DirectoryApi } from "./directory/index.js";
|
|
3
3
|
import { IdentityApi } from "./identity/index.js";
|
|
4
|
+
import { FileStorageApi } from "./file-storage/index.js";
|
|
4
5
|
import NotificationMessagePublisher from "./notificationMessages/queue/NotificationMessagePublisher.js";
|
|
5
6
|
import TernApi from "./tern/api/TernApi.js";
|
|
6
7
|
import PomeloApi from "./pomelo/api/PomeloApi.js";
|
|
@@ -145,6 +146,7 @@ export const apiInvokerBindings = new ContainerModule(({ bind }) => {
|
|
|
145
146
|
// API invoker bindings
|
|
146
147
|
bind("IDirectoryApi").to(DirectoryApi);
|
|
147
148
|
bind("IIdentityApi").to(IdentityApi);
|
|
149
|
+
bind("IFileStorageApi").to(FileStorageApi);
|
|
148
150
|
bind("IAddressApi").to(AddressApi);
|
|
149
151
|
bind("IExchangeRatesApi").to(ExchangeRatesApi);
|
|
150
152
|
bind("ITernApi").to(TernApi);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { IHttpRequest } from "@fiado/http-client";
|
|
2
|
+
import type { UserDocumentItem } from "@fiado/type-kit/bin/fileStorage/index.js";
|
|
3
|
+
import type { IFileStorageApi } from "./interfaces/IFileStorageApi.js";
|
|
4
|
+
type FiadoApiResponse<T> = import("@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse.js").default<T>;
|
|
5
|
+
export declare class FileStorageApi implements IFileStorageApi {
|
|
6
|
+
private readonly httpRequest;
|
|
7
|
+
private readonly baseUrl;
|
|
8
|
+
constructor(httpRequest: IHttpRequest);
|
|
9
|
+
listDirectoryDocuments(directory: string): Promise<FiadoApiResponse<UserDocumentItem[]>>;
|
|
10
|
+
deleteUserDocument(fileName: string): Promise<FiadoApiResponse<void>>;
|
|
11
|
+
getUserDocumentSignUrl(key: string): Promise<FiadoApiResponse<{
|
|
12
|
+
url: string;
|
|
13
|
+
}>>;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
import { inject, injectable } from "inversify";
|
|
14
|
+
import dotenv from "dotenv";
|
|
15
|
+
dotenv.config();
|
|
16
|
+
let FileStorageApi = class FileStorageApi {
|
|
17
|
+
httpRequest;
|
|
18
|
+
baseUrl = process.env.FIADO_S3_LAMBDA_URL || "";
|
|
19
|
+
constructor(httpRequest) {
|
|
20
|
+
this.httpRequest = httpRequest;
|
|
21
|
+
}
|
|
22
|
+
async listDirectoryDocuments(directory) {
|
|
23
|
+
if (!directory) {
|
|
24
|
+
throw new Error("directory is required.");
|
|
25
|
+
}
|
|
26
|
+
return await this.httpRequest.post(this.baseUrl, { directory }, { operationName: "listDirectoryDocumentsV2" });
|
|
27
|
+
}
|
|
28
|
+
async deleteUserDocument(fileName) {
|
|
29
|
+
if (!fileName) {
|
|
30
|
+
throw new Error("fileName is required.");
|
|
31
|
+
}
|
|
32
|
+
return await this.httpRequest.post(this.baseUrl, { fileName }, { operationName: "deleteUserDocument" });
|
|
33
|
+
}
|
|
34
|
+
async getUserDocumentSignUrl(key) {
|
|
35
|
+
if (!key) {
|
|
36
|
+
throw new Error("key is required.");
|
|
37
|
+
}
|
|
38
|
+
return await this.httpRequest.post(this.baseUrl, { key }, { operationName: "getUserDocumentSignUrl" });
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
FileStorageApi = __decorate([
|
|
42
|
+
injectable(),
|
|
43
|
+
__param(0, inject("IHttpRequest")),
|
|
44
|
+
__metadata("design:paramtypes", [Object])
|
|
45
|
+
], FileStorageApi);
|
|
46
|
+
export { FileStorageApi };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { UserDocumentItem } from "@fiado/type-kit/bin/fileStorage/index.js";
|
|
2
|
+
type FiadoApiResponse<T> = import("@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse.js").default<T>;
|
|
3
|
+
/**
|
|
4
|
+
* Cliente de fiado-s3-lambda (documentos de usuario en S3). Una sola ruta POST; la operación viaja en el
|
|
5
|
+
* header `operationName`. Mismo contrato que consumía el S3Adapter de fiado-identity-lambda.
|
|
6
|
+
*/
|
|
7
|
+
export interface IFileStorageApi {
|
|
8
|
+
/** Lista los objetos bajo un prefijo, p. ej. `USER/{directoryId}`. Devuelve key completa, lastModified, sizeKb y url firmada. */
|
|
9
|
+
listDirectoryDocuments(directory: string): Promise<FiadoApiResponse<UserDocumentItem[]>>;
|
|
10
|
+
/** Borra un objeto por su key completa, p. ej. `USER/{directoryId}/{fileName}`. */
|
|
11
|
+
deleteUserDocument(fileName: string): Promise<FiadoApiResponse<void>>;
|
|
12
|
+
/** URL firmada de lectura para una key completa. */
|
|
13
|
+
getUserDocumentSignUrl(key: string): Promise<FiadoApiResponse<{
|
|
14
|
+
url: string;
|
|
15
|
+
}>>;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/bin/group/GroupApi.d.ts
CHANGED
|
@@ -19,12 +19,12 @@ export declare class GroupApi implements IGroupApi {
|
|
|
19
19
|
findById(id: string): Promise<any>;
|
|
20
20
|
findAllWithCounts(): Promise<any>;
|
|
21
21
|
getMembersByGroupIds(groupIds: string[], pageSize?: number, lastKey?: string): Promise<FiadoApiResponse<{
|
|
22
|
-
|
|
22
|
+
data: {
|
|
23
23
|
directoryId: string;
|
|
24
24
|
groupId: string;
|
|
25
25
|
status?: string;
|
|
26
26
|
}[];
|
|
27
|
-
lastEvaluatedKey
|
|
27
|
+
lastEvaluatedKey: string | null;
|
|
28
28
|
}>>;
|
|
29
29
|
deleteByDirectoryId(directoryId: string): Promise<FiadoApiResponse<{
|
|
30
30
|
deletedCount: number;
|
|
@@ -35,12 +35,12 @@ export interface IGroupApi {
|
|
|
35
35
|
* Consumido por `direct-deposit-export-business` para resolver a quién exportar.
|
|
36
36
|
*/
|
|
37
37
|
getMembersByGroupIds(groupIds: string[], pageSize?: number, lastKey?: string): Promise<FiadoApiResponse<{
|
|
38
|
-
|
|
38
|
+
data: {
|
|
39
39
|
directoryId: string;
|
|
40
40
|
groupId: string;
|
|
41
41
|
status?: string;
|
|
42
42
|
}[];
|
|
43
|
-
lastEvaluatedKey
|
|
43
|
+
lastEvaluatedKey: string | null;
|
|
44
44
|
}>>;
|
|
45
45
|
/**
|
|
46
46
|
* Buscar grupo por id
|
package/bin/index.d.ts
CHANGED
package/bin/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fiado/api-invoker",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.102.0",
|
|
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
|
"type": "module",
|
|
6
6
|
"main": "bin/index.js",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@fiado/gateway-adapter": "^3.9.0",
|
|
35
35
|
"@fiado/http-client": "^2.0.1",
|
|
36
36
|
"@fiado/logger": "^1.1.3",
|
|
37
|
-
"@fiado/type-kit": "3.
|
|
37
|
+
"@fiado/type-kit": "^3.485.0",
|
|
38
38
|
"dotenv": "^16.4.7"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
package/src/container.config.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ContainerModule } from "inversify";
|
|
2
2
|
import { DirectoryApi, IDirectoryApi } from "./directory/index.js";
|
|
3
3
|
import { IdentityApi, IIdentityApi } from "./identity/index.js";
|
|
4
|
+
import { FileStorageApi, IFileStorageApi } from "./file-storage/index.js";
|
|
4
5
|
import { INotificationMessagesPublisher } from "./notificationMessages/index.js";
|
|
5
6
|
import NotificationMessagePublisher from "./notificationMessages/queue/NotificationMessagePublisher.js";
|
|
6
7
|
import { ITernApi } from "./tern/index.js";
|
|
@@ -218,6 +219,7 @@ export const apiInvokerBindings = new ContainerModule(({ bind }) => {
|
|
|
218
219
|
// API invoker bindings
|
|
219
220
|
bind<IDirectoryApi>("IDirectoryApi").to(DirectoryApi);
|
|
220
221
|
bind<IIdentityApi>("IIdentityApi").to(IdentityApi);
|
|
222
|
+
bind<IFileStorageApi>("IFileStorageApi").to(FileStorageApi);
|
|
221
223
|
bind<IAddressApi>("IAddressApi").to(AddressApi);
|
|
222
224
|
bind<IExchangeRatesApi>("IExchangeRatesApi").to(ExchangeRatesApi);
|
|
223
225
|
bind<ITernApi>("ITernApi").to(TernApi);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { inject, injectable } from "inversify";
|
|
2
|
+
import type { IHttpRequest } from "@fiado/http-client";
|
|
3
|
+
import dotenv from "dotenv";
|
|
4
|
+
import type { UserDocumentItem } from "@fiado/type-kit/bin/fileStorage/index.js";
|
|
5
|
+
import type { IFileStorageApi } from "./interfaces/IFileStorageApi.js";
|
|
6
|
+
type FiadoApiResponse<T> = import("@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse.js").default<T>;
|
|
7
|
+
|
|
8
|
+
dotenv.config();
|
|
9
|
+
|
|
10
|
+
@injectable()
|
|
11
|
+
export class FileStorageApi implements IFileStorageApi {
|
|
12
|
+
|
|
13
|
+
private readonly baseUrl = process.env.FIADO_S3_LAMBDA_URL || "";
|
|
14
|
+
|
|
15
|
+
constructor(@inject("IHttpRequest") private readonly httpRequest: IHttpRequest) {}
|
|
16
|
+
|
|
17
|
+
async listDirectoryDocuments(directory: string): Promise<FiadoApiResponse<UserDocumentItem[]>> {
|
|
18
|
+
if (!directory) {
|
|
19
|
+
throw new Error("directory is required.");
|
|
20
|
+
}
|
|
21
|
+
return await this.httpRequest.post<FiadoApiResponse<UserDocumentItem[]>>(
|
|
22
|
+
this.baseUrl, { directory }, { operationName: "listDirectoryDocumentsV2" },
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async deleteUserDocument(fileName: string): Promise<FiadoApiResponse<void>> {
|
|
27
|
+
if (!fileName) {
|
|
28
|
+
throw new Error("fileName is required.");
|
|
29
|
+
}
|
|
30
|
+
return await this.httpRequest.post<FiadoApiResponse<void>>(
|
|
31
|
+
this.baseUrl, { fileName }, { operationName: "deleteUserDocument" },
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async getUserDocumentSignUrl(key: string): Promise<FiadoApiResponse<{ url: string }>> {
|
|
36
|
+
if (!key) {
|
|
37
|
+
throw new Error("key is required.");
|
|
38
|
+
}
|
|
39
|
+
return await this.httpRequest.post<FiadoApiResponse<{ url: string }>>(
|
|
40
|
+
this.baseUrl, { key }, { operationName: "getUserDocumentSignUrl" },
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { UserDocumentItem } from "@fiado/type-kit/bin/fileStorage/index.js";
|
|
2
|
+
type FiadoApiResponse<T> = import("@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse.js").default<T>;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Cliente de fiado-s3-lambda (documentos de usuario en S3). Una sola ruta POST; la operación viaja en el
|
|
6
|
+
* header `operationName`. Mismo contrato que consumía el S3Adapter de fiado-identity-lambda.
|
|
7
|
+
*/
|
|
8
|
+
export interface IFileStorageApi {
|
|
9
|
+
/** Lista los objetos bajo un prefijo, p. ej. `USER/{directoryId}`. Devuelve key completa, lastModified, sizeKb y url firmada. */
|
|
10
|
+
listDirectoryDocuments(directory: string): Promise<FiadoApiResponse<UserDocumentItem[]>>;
|
|
11
|
+
/** Borra un objeto por su key completa, p. ej. `USER/{directoryId}/{fileName}`. */
|
|
12
|
+
deleteUserDocument(fileName: string): Promise<FiadoApiResponse<void>>;
|
|
13
|
+
/** URL firmada de lectura para una key completa. */
|
|
14
|
+
getUserDocumentSignUrl(key: string): Promise<FiadoApiResponse<{ url: string }>>;
|
|
15
|
+
}
|
package/src/group/GroupApi.ts
CHANGED
|
@@ -78,8 +78,8 @@ export class GroupApi implements IGroupApi {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
async getMembersByGroupIds(groupIds: string[], pageSize = 200, lastKey?: string): Promise<FiadoApiResponse<{
|
|
81
|
-
|
|
82
|
-
lastEvaluatedKey
|
|
81
|
+
data: { directoryId: string; groupId: string; status?: string }[];
|
|
82
|
+
lastEvaluatedKey: string | null;
|
|
83
83
|
}>> {
|
|
84
84
|
const queryParams: string[] = [];
|
|
85
85
|
|
|
@@ -39,8 +39,8 @@ export interface IGroupApi {
|
|
|
39
39
|
* Consumido por `direct-deposit-export-business` para resolver a quién exportar.
|
|
40
40
|
*/
|
|
41
41
|
getMembersByGroupIds(groupIds: string[], pageSize?: number, lastKey?: string): Promise<FiadoApiResponse<{
|
|
42
|
-
|
|
43
|
-
lastEvaluatedKey
|
|
42
|
+
data: { directoryId: string; groupId: string; status?: string }[];
|
|
43
|
+
lastEvaluatedKey: string | null;
|
|
44
44
|
}>>;
|
|
45
45
|
|
|
46
46
|
|
package/src/index.ts
CHANGED