@fiado/api-invoker 1.3.81 → 1.3.83
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/cognitoConnector/interfaces/ICognitoConnectorApiV2.d.ts +46 -0
- package/bin/cognitoConnector/interfaces/ICognitoConnectorApiV2.js +2 -0
- package/bin/container.config.js +2 -0
- package/bin/directory/DirectoryApi.d.ts +1 -0
- package/bin/directory/DirectoryApi.js +23 -1
- package/bin/directorySetting/DirectorySettingApi.d.ts +31 -0
- package/bin/directorySetting/DirectorySettingApi.js +56 -0
- package/bin/directorySetting/index.d.ts +2 -0
- package/bin/directorySetting/index.js +18 -0
- package/bin/directorySetting/interfaces/IDirectorySettingApi.d.ts +42 -0
- package/bin/directorySetting/interfaces/IDirectorySettingApi.js +2 -0
- package/bin/estafeta/EstafetaApi.d.ts +0 -0
- package/bin/estafeta/EstafetaApi.js +0 -0
- 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/directory/DirectoryApi.ts +24 -3
- package/src/directorySetting/DirectorySettingApi.ts +42 -0
- package/src/directorySetting/index.ts +3 -0
- package/src/directorySetting/interfaces/IDirectorySettingApi.ts +56 -0
- package/src/index.ts +1 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ChangePasswordRequest, GetUserRequest, GetUserResponse, RefreshTokenRequest, RefreshTokenResponse, RespondToAuthChallengeRequest, SetPasswordRequest, SignInRequest, SignInResponse, SignUpConfirmRequest, SignUpRequest, SignUpResponse } from "@fiado/type-kit/bin/cognitoConnector";
|
|
2
|
+
export interface ICognitoApi {
|
|
3
|
+
/**
|
|
4
|
+
* Healthcheck for the cognito-connector
|
|
5
|
+
*/
|
|
6
|
+
healthcheck(): Promise<HealthcheckResponse>;
|
|
7
|
+
/**
|
|
8
|
+
* Create a new user in Cognito
|
|
9
|
+
*/
|
|
10
|
+
signUp(request: SignUpRequest): Promise<SignUpResponse>;
|
|
11
|
+
/**
|
|
12
|
+
* Confirm sign-up for a user in Cognito
|
|
13
|
+
*/
|
|
14
|
+
signUpConfirm(request: SignUpConfirmRequest): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Sign in a user
|
|
17
|
+
*/
|
|
18
|
+
signIn(request: SignInRequest): Promise<SignInResponse>;
|
|
19
|
+
/**
|
|
20
|
+
* Sign out a user
|
|
21
|
+
*/
|
|
22
|
+
signOut(): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Change a user's password
|
|
25
|
+
*/
|
|
26
|
+
changePassword(request: ChangePasswordRequest): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Retrieve user details
|
|
29
|
+
*/
|
|
30
|
+
getUser(request: GetUserRequest): Promise<GetUserResponse>;
|
|
31
|
+
/**
|
|
32
|
+
* Refresh a user's tokens
|
|
33
|
+
*/
|
|
34
|
+
refreshToken(request: RefreshTokenRequest): Promise<RefreshTokenResponse>;
|
|
35
|
+
/**
|
|
36
|
+
* Respond to an auth challenge
|
|
37
|
+
*/
|
|
38
|
+
respondToAuthChallenge(request: RespondToAuthChallengeRequest): Promise<any>;
|
|
39
|
+
/**
|
|
40
|
+
* Reset a user's password
|
|
41
|
+
*/
|
|
42
|
+
resetPassword(request: SetPasswordRequest): Promise<void>;
|
|
43
|
+
}
|
|
44
|
+
export interface HealthcheckResponse {
|
|
45
|
+
status: string;
|
|
46
|
+
}
|
package/bin/container.config.js
CHANGED
|
@@ -59,6 +59,7 @@ const document_image_processor_1 = require("./document-image-processor");
|
|
|
59
59
|
const order_collector_business_1 = require("./order-collector-business");
|
|
60
60
|
const EstafetaApi_1 = __importDefault(require("./estafeta/api/EstafetaApi"));
|
|
61
61
|
const appselectondata_1 = require("./appselectondata");
|
|
62
|
+
const directorySetting_1 = require("./directorySetting");
|
|
62
63
|
exports.apiInvokerBindings = new inversify_1.ContainerModule((bind) => {
|
|
63
64
|
// UTILS bindings
|
|
64
65
|
bind("InvokerUtils").to(InvokerUtils_1.InvokerUtils);
|
|
@@ -116,4 +117,5 @@ exports.apiInvokerBindings = new inversify_1.ContainerModule((bind) => {
|
|
|
116
117
|
bind("IOrderCollectorApi").to(order_collector_business_1.OrderCollectorApi);
|
|
117
118
|
bind("IEstafetaApi").to(EstafetaApi_1.default);
|
|
118
119
|
bind("IAppSelectionDataApi").to(appselectondata_1.AppSelectionDataApi);
|
|
120
|
+
bind("IDirectorySettingApi").to(directorySetting_1.DirectorySettingApi);
|
|
119
121
|
});
|
|
@@ -18,4 +18,5 @@ export declare class DirectoryApi implements IDirectoryApi {
|
|
|
18
18
|
updateUserProfile(directoryId: string, profile: Profile): Promise<void>;
|
|
19
19
|
updateStatus(directoryId: string, status: Status): Promise<void>;
|
|
20
20
|
getByPeopleId(peopleId: string): Promise<any>;
|
|
21
|
+
private normalizeE164Light;
|
|
21
22
|
}
|
|
@@ -67,8 +67,15 @@ let DirectoryApi = class DirectoryApi {
|
|
|
67
67
|
const operationName = "getByOwnerDirectoryId";
|
|
68
68
|
return await this.httpRequest.post(`${url}`, null, { 'operationName': operationName });
|
|
69
69
|
}
|
|
70
|
+
// public async getByPhoneNumber(phoneNumber: string): Promise<any> {
|
|
71
|
+
// const url = `${this.baseUrl}?phoneNumber=${phoneNumber}`;
|
|
72
|
+
// const operationName = "getUserInfoByParams";
|
|
73
|
+
// return await this.httpRequest.post(`${url}`, null, { 'operationName': operationName });
|
|
74
|
+
// }
|
|
70
75
|
async getByPhoneNumber(phoneNumber) {
|
|
71
|
-
|
|
76
|
+
// 🔒 Normaliza y codifica para preservar el '+'
|
|
77
|
+
const normalized = this.normalizeE164Light(phoneNumber);
|
|
78
|
+
const url = `${this.baseUrl}?phoneNumber=${encodeURIComponent(normalized)}`;
|
|
72
79
|
const operationName = "getUserInfoByParams";
|
|
73
80
|
return await this.httpRequest.post(`${url}`, null, { 'operationName': operationName });
|
|
74
81
|
}
|
|
@@ -114,6 +121,21 @@ let DirectoryApi = class DirectoryApi {
|
|
|
114
121
|
const operationName = "getUserInfoByParams";
|
|
115
122
|
return await this.httpRequest.post(`${url}`, null, { 'operationName': operationName });
|
|
116
123
|
}
|
|
124
|
+
// --- Helper ligero para E.164 limpia espacios y garantiza '+'
|
|
125
|
+
normalizeE164Light(input) {
|
|
126
|
+
if (!input)
|
|
127
|
+
return input;
|
|
128
|
+
const trimmed = String(input).trim().replace(/\s+/g, "");
|
|
129
|
+
// Si ya viene como +<dígitos>
|
|
130
|
+
if (/^\+\d{6,15}$/.test(trimmed))
|
|
131
|
+
return trimmed;
|
|
132
|
+
// Si viene como <dígitos> a secas, antepone '+'
|
|
133
|
+
if (/^\d{6,15}$/.test(trimmed))
|
|
134
|
+
return `+${trimmed}`;
|
|
135
|
+
// Si trae símbolos como '-', '(', ')', etc., filtra a dígitos y antepone '+'
|
|
136
|
+
const digits = trimmed.replace(/\D+/g, "");
|
|
137
|
+
return digits ? `+${digits}` : trimmed;
|
|
138
|
+
}
|
|
117
139
|
};
|
|
118
140
|
exports.DirectoryApi = DirectoryApi;
|
|
119
141
|
exports.DirectoryApi = DirectoryApi = __decorate([
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { IHttpRequest } from "@fiado/http-client";
|
|
2
|
+
import { IDirectorySettingApi } from "./interfaces/IDirectorySettingApi";
|
|
3
|
+
import FiadoApiResponse from '@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse';
|
|
4
|
+
import { DirectorySettingCreateRequest } from '@fiado/type-kit/bin/directorySetting';
|
|
5
|
+
export declare class DirectorySettingApi implements IDirectorySettingApi {
|
|
6
|
+
private httpRequest;
|
|
7
|
+
private readonly baseUrl;
|
|
8
|
+
constructor(httpRequest: IHttpRequest);
|
|
9
|
+
createBatchDirectorySetting(params: DirectorySettingCreateRequest): Promise<FiadoApiResponse<{
|
|
10
|
+
key: string;
|
|
11
|
+
value: string;
|
|
12
|
+
directoryId: string;
|
|
13
|
+
metadata?: any;
|
|
14
|
+
}[]>>;
|
|
15
|
+
getByIds(ids: string[]): Promise<FiadoApiResponse<{
|
|
16
|
+
key: string;
|
|
17
|
+
value: string;
|
|
18
|
+
directoryId: string;
|
|
19
|
+
metadata?: any;
|
|
20
|
+
}[]>>;
|
|
21
|
+
getDirectorySettingsByDirectoryId(params: {
|
|
22
|
+
pageSize?: number;
|
|
23
|
+
index?: string;
|
|
24
|
+
directoryId: string;
|
|
25
|
+
}): Promise<FiadoApiResponse<{
|
|
26
|
+
key: string;
|
|
27
|
+
value: string;
|
|
28
|
+
directoryId: string;
|
|
29
|
+
metadata?: any;
|
|
30
|
+
}>>;
|
|
31
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
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.DirectorySettingApi = void 0;
|
|
19
|
+
const dotenv_1 = __importDefault(require("dotenv"));
|
|
20
|
+
const inversify_1 = require("inversify");
|
|
21
|
+
dotenv_1.default.config();
|
|
22
|
+
let DirectorySettingApi = class DirectorySettingApi {
|
|
23
|
+
constructor(httpRequest) {
|
|
24
|
+
this.httpRequest = httpRequest;
|
|
25
|
+
this.baseUrl = process.env.DIRECTORY_SETTING_URL || "";
|
|
26
|
+
}
|
|
27
|
+
async createBatchDirectorySetting(params) {
|
|
28
|
+
const url = `${this.baseUrl}create/batch`;
|
|
29
|
+
return await this.httpRequest.post(url, document);
|
|
30
|
+
}
|
|
31
|
+
async getByIds(ids) {
|
|
32
|
+
if (ids.length === 0) {
|
|
33
|
+
throw new Error("At least one people ID is required.");
|
|
34
|
+
}
|
|
35
|
+
const url = `${this.baseUrl}get/ids?${ids.map(id => `id=${encodeURIComponent(id)}`).join('&')}`;
|
|
36
|
+
return await this.httpRequest.get(`${url}`);
|
|
37
|
+
}
|
|
38
|
+
async getDirectorySettingsByDirectoryId(params) {
|
|
39
|
+
const url = `${this.baseUrl}get/directory/${params.directoryId}`;
|
|
40
|
+
const queryParameters = [];
|
|
41
|
+
if (params.pageSize)
|
|
42
|
+
queryParameters.push(`pageSize=${params.pageSize}`);
|
|
43
|
+
if (params.index)
|
|
44
|
+
queryParameters.push(`index=${params.index}`);
|
|
45
|
+
if (queryParameters.length > 0) {
|
|
46
|
+
url.concat(`?${queryParameters.join('&')}`);
|
|
47
|
+
}
|
|
48
|
+
return await this.httpRequest.get(url);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
exports.DirectorySettingApi = DirectorySettingApi;
|
|
52
|
+
exports.DirectorySettingApi = DirectorySettingApi = __decorate([
|
|
53
|
+
(0, inversify_1.injectable)(),
|
|
54
|
+
__param(0, (0, inversify_1.inject)("IHttpRequest")),
|
|
55
|
+
__metadata("design:paramtypes", [Object])
|
|
56
|
+
], DirectorySettingApi);
|
|
@@ -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/IDirectorySettingApi"), exports);
|
|
18
|
+
__exportStar(require("./DirectorySettingApi"), exports);
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import FiadoApiResponse from "@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse";
|
|
2
|
+
import { DirectorySettingCreateRequest } from "@fiado/type-kit/bin/directorySetting/dtos/DirectorySettingCreateRequest";
|
|
3
|
+
/**
|
|
4
|
+
* Interfaz para el servicio Directory que permite operaciones sobre directorios.
|
|
5
|
+
*/
|
|
6
|
+
export interface IDirectorySettingApi {
|
|
7
|
+
/**
|
|
8
|
+
* Crea en batch settings de directorio.
|
|
9
|
+
* @param params Parámetros para crear el setting de directorio.
|
|
10
|
+
* @returns Una promesa que resuelve a la respuesta del API.
|
|
11
|
+
* @throws {Error} Lanza un error si los parámetros de entrada son inválidos.
|
|
12
|
+
*/
|
|
13
|
+
createBatchDirectorySetting(params: DirectorySettingCreateRequest): Promise<FiadoApiResponse<{
|
|
14
|
+
key: string;
|
|
15
|
+
value: string;
|
|
16
|
+
directoryId: string;
|
|
17
|
+
metadata?: any;
|
|
18
|
+
}[]>>;
|
|
19
|
+
/**
|
|
20
|
+
* Obtiene una lista de settings por sus IDs.
|
|
21
|
+
* @param ids Array de IDs de directorios (UUIDs) a buscar.
|
|
22
|
+
* @returns Una promesa que resuelve a un arreglo de objetos de directorio.
|
|
23
|
+
* Puede devolver un arreglo vacío si no se encuentran coincidencias.
|
|
24
|
+
* @throws {Error} Lanza un error si los parámetros de entrada son inválidos.
|
|
25
|
+
*/
|
|
26
|
+
getByIds(ids: string[]): Promise<FiadoApiResponse<{
|
|
27
|
+
key: string;
|
|
28
|
+
value: string;
|
|
29
|
+
directoryId: string;
|
|
30
|
+
metadata?: any;
|
|
31
|
+
}[]>>;
|
|
32
|
+
getDirectorySettingsByDirectoryId(params: {
|
|
33
|
+
pageSize?: number;
|
|
34
|
+
index?: string;
|
|
35
|
+
directoryId: string;
|
|
36
|
+
}): Promise<FiadoApiResponse<{
|
|
37
|
+
key: string;
|
|
38
|
+
value: string;
|
|
39
|
+
directoryId: string;
|
|
40
|
+
metadata?: any;
|
|
41
|
+
}>>;
|
|
42
|
+
}
|
|
File without changes
|
|
File without changes
|
package/bin/index.d.ts
CHANGED
package/bin/index.js
CHANGED
|
@@ -62,3 +62,4 @@ __exportStar(require("./document-image-processor"), exports);
|
|
|
62
62
|
__exportStar(require("./order-collector-business"), exports);
|
|
63
63
|
__exportStar(require("./estafeta"), exports);
|
|
64
64
|
__exportStar(require("./appselectondata"), exports);
|
|
65
|
+
__exportStar(require("./directorySetting"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fiado/api-invoker",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.83",
|
|
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.43",
|
|
17
17
|
"@fiado/http-client": "^1.0.7",
|
|
18
18
|
"@fiado/logger": "^1.0.3",
|
|
19
|
-
"@fiado/type-kit": "^2.0.
|
|
19
|
+
"@fiado/type-kit": "^2.0.50",
|
|
20
20
|
"dotenv": "^16.4.7",
|
|
21
21
|
"inversify": "^6.2.2",
|
|
22
22
|
"reflect-metadata": "^0.2.2"
|
package/src/container.config.ts
CHANGED
|
@@ -75,6 +75,7 @@ import { IOrderCollectorApi, OrderCollectorApi } from "./order-collector-busines
|
|
|
75
75
|
import { IEstafetaApi } from "./estafeta";
|
|
76
76
|
import EstafetaApi from "./estafeta/api/EstafetaApi";
|
|
77
77
|
import { AppSelectionDataApi, IAppSelectionDataApi } from "./appselectondata";
|
|
78
|
+
import { DirectorySettingApi, IDirectorySettingApi } from "./directorySetting";
|
|
78
79
|
|
|
79
80
|
export const apiInvokerBindings = new ContainerModule((bind: interfaces.Bind) => {
|
|
80
81
|
// UTILS bindings
|
|
@@ -134,4 +135,5 @@ export const apiInvokerBindings = new ContainerModule((bind: interfaces.Bind) =>
|
|
|
134
135
|
bind<IOrderCollectorApi>("IOrderCollectorApi").to(OrderCollectorApi);
|
|
135
136
|
bind<IEstafetaApi>("IEstafetaApi").to(EstafetaApi);
|
|
136
137
|
bind<IAppSelectionDataApi>("IAppSelectionDataApi").to(AppSelectionDataApi);
|
|
138
|
+
bind<IDirectorySettingApi>("IDirectorySettingApi").to(DirectorySettingApi);
|
|
137
139
|
});
|
|
@@ -79,11 +79,19 @@ export class DirectoryApi implements IDirectoryApi {
|
|
|
79
79
|
return await this.httpRequest.post(`${url}`, null, { 'operationName': operationName });
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
public async getByPhoneNumber(phoneNumber: string): Promise<any> {
|
|
82
|
+
// public async getByPhoneNumber(phoneNumber: string): Promise<any> {
|
|
83
83
|
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
// const url = `${this.baseUrl}?phoneNumber=${phoneNumber}`;
|
|
85
|
+
// const operationName = "getUserInfoByParams";
|
|
86
86
|
|
|
87
|
+
// return await this.httpRequest.post(`${url}`, null, { 'operationName': operationName });
|
|
88
|
+
// }
|
|
89
|
+
|
|
90
|
+
public async getByPhoneNumber(phoneNumber: string): Promise<any> {
|
|
91
|
+
// 🔒 Normaliza y codifica para preservar el '+'
|
|
92
|
+
const normalized = this.normalizeE164Light(phoneNumber);
|
|
93
|
+
const url = `${this.baseUrl}?phoneNumber=${encodeURIComponent(normalized)}`;
|
|
94
|
+
const operationName = "getUserInfoByParams";
|
|
87
95
|
return await this.httpRequest.post(`${url}`, null, { 'operationName': operationName });
|
|
88
96
|
}
|
|
89
97
|
|
|
@@ -147,4 +155,17 @@ export class DirectoryApi implements IDirectoryApi {
|
|
|
147
155
|
|
|
148
156
|
return await this.httpRequest.post(`${url}`, null, { 'operationName': operationName });
|
|
149
157
|
}
|
|
158
|
+
|
|
159
|
+
// --- Helper ligero para E.164 limpia espacios y garantiza '+'
|
|
160
|
+
private normalizeE164Light(input?: string): string {
|
|
161
|
+
if (!input) return input as any;
|
|
162
|
+
const trimmed = String(input).trim().replace(/\s+/g, "");
|
|
163
|
+
// Si ya viene como +<dígitos>
|
|
164
|
+
if (/^\+\d{6,15}$/.test(trimmed)) return trimmed;
|
|
165
|
+
// Si viene como <dígitos> a secas, antepone '+'
|
|
166
|
+
if (/^\d{6,15}$/.test(trimmed)) return `+${trimmed}`;
|
|
167
|
+
// Si trae símbolos como '-', '(', ')', etc., filtra a dígitos y antepone '+'
|
|
168
|
+
const digits = trimmed.replace(/\D+/g, "");
|
|
169
|
+
return digits ? `+${digits}` : trimmed;
|
|
170
|
+
}
|
|
150
171
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import dotenv from 'dotenv';
|
|
2
|
+
import { inject, injectable } from "inversify";
|
|
3
|
+
import { IHttpRequest } from "@fiado/http-client";
|
|
4
|
+
import { IDirectorySettingApi } from "./interfaces/IDirectorySettingApi";
|
|
5
|
+
import FiadoApiResponse from '@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse';
|
|
6
|
+
import { DirectorySettingCreateRequest } from '@fiado/type-kit/bin/directorySetting';
|
|
7
|
+
dotenv.config();
|
|
8
|
+
|
|
9
|
+
@injectable()
|
|
10
|
+
export class DirectorySettingApi implements IDirectorySettingApi {
|
|
11
|
+
|
|
12
|
+
private readonly baseUrl = process.env.DIRECTORY_SETTING_URL || "";
|
|
13
|
+
|
|
14
|
+
constructor(@inject("IHttpRequest") private httpRequest: IHttpRequest) {}
|
|
15
|
+
|
|
16
|
+
async createBatchDirectorySetting(params: DirectorySettingCreateRequest): Promise<FiadoApiResponse<{ key: string; value: string; directoryId: string; metadata?: any; }[]>> {
|
|
17
|
+
const url = `${this.baseUrl}create/batch`;
|
|
18
|
+
return await this.httpRequest.post(url, document);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async getByIds(ids: string[]): Promise<FiadoApiResponse<{ key: string; value: string; directoryId: string; metadata?: any; }[]>> {
|
|
22
|
+
|
|
23
|
+
if (ids.length === 0) {
|
|
24
|
+
throw new Error("At least one people ID is required.")
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const url = `${this.baseUrl}get/ids?${ids.map(id => `id=${encodeURIComponent(id)}`).join('&')}`;
|
|
28
|
+
return await this.httpRequest.get(`${url}`);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async getDirectorySettingsByDirectoryId(params: { pageSize?: number; index?: string; directoryId: string; }): Promise<FiadoApiResponse<{ key: string; value: string; directoryId: string; metadata?: any; }>> {
|
|
32
|
+
const url = `${this.baseUrl}get/directory/${params.directoryId}`;
|
|
33
|
+
const queryParameters = [];
|
|
34
|
+
if (params.pageSize) queryParameters.push(`pageSize=${params.pageSize}`);
|
|
35
|
+
if (params.index) queryParameters.push(`index=${params.index}`);
|
|
36
|
+
|
|
37
|
+
if (queryParameters.length > 0) {
|
|
38
|
+
url.concat(`?${queryParameters.join('&')}`);
|
|
39
|
+
}
|
|
40
|
+
return await this.httpRequest.get(url);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
|
|
2
|
+
import FiadoApiResponse from "@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse";
|
|
3
|
+
import { DirectorySettingCreateRequest } from "@fiado/type-kit/bin/directorySetting/dtos/DirectorySettingCreateRequest";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Interfaz para el servicio Directory que permite operaciones sobre directorios.
|
|
7
|
+
*/
|
|
8
|
+
export interface IDirectorySettingApi {
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Crea en batch settings de directorio.
|
|
13
|
+
* @param params Parámetros para crear el setting de directorio.
|
|
14
|
+
* @returns Una promesa que resuelve a la respuesta del API.
|
|
15
|
+
* @throws {Error} Lanza un error si los parámetros de entrada son inválidos.
|
|
16
|
+
*/
|
|
17
|
+
createBatchDirectorySetting(params: DirectorySettingCreateRequest): Promise<FiadoApiResponse<{
|
|
18
|
+
key: string;
|
|
19
|
+
value: string;
|
|
20
|
+
directoryId:string
|
|
21
|
+
metadata?: any;
|
|
22
|
+
}[]>>;
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Obtiene una lista de settings por sus IDs.
|
|
27
|
+
* @param ids Array de IDs de directorios (UUIDs) a buscar.
|
|
28
|
+
* @returns Una promesa que resuelve a un arreglo de objetos de directorio.
|
|
29
|
+
* Puede devolver un arreglo vacío si no se encuentran coincidencias.
|
|
30
|
+
* @throws {Error} Lanza un error si los parámetros de entrada son inválidos.
|
|
31
|
+
*/
|
|
32
|
+
getByIds(ids: string[]): Promise<FiadoApiResponse<{
|
|
33
|
+
key: string;
|
|
34
|
+
value: string;
|
|
35
|
+
directoryId:string
|
|
36
|
+
metadata?: any;
|
|
37
|
+
}[]>>;
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
getDirectorySettingsByDirectoryId(params:{
|
|
43
|
+
pageSize?: number;
|
|
44
|
+
index?: string;
|
|
45
|
+
directoryId: string;
|
|
46
|
+
}): Promise<FiadoApiResponse<
|
|
47
|
+
{
|
|
48
|
+
key: string;
|
|
49
|
+
value: string;
|
|
50
|
+
directoryId:string
|
|
51
|
+
metadata?: any;
|
|
52
|
+
}
|
|
53
|
+
>>;
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
}
|