@fiado/api-invoker 5.114.0 → 5.115.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/platformRbac/api/PlatformRbacBusinessApi.d.ts +3 -1
- package/bin/platformRbac/api/PlatformRbacBusinessApi.js +16 -1
- package/bin/platformRbac/api/interfaces/IPlatformRbacBusinessApi.d.ts +6 -1
- package/package.json +2 -2
- package/src/platformRbac/api/PlatformRbacBusinessApi.ts +22 -1
- package/src/platformRbac/api/interfaces/IPlatformRbacBusinessApi.ts +7 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { IHttpRequest } from "@fiado/http-client";
|
|
2
2
|
import { APIGatewayProxyResultBody, ApiGatewayResponse, ResolvedPermissions, ResolveInput } from "@fiado/gateway-adapter";
|
|
3
3
|
import { DefineNextChallengeRequest, DefineNextChallengeResponse, PrepareChallengeRequest, PrepareChallengeResponse, VerifyChallengeRequest, VerifyChallengeResponse, AuthorizeRequest, AuthorizeResponse, EffectivePermissionsResponse, InjectableUserAttributesResponse, PermissionScope, CreateLevelEntityRequest, CreateLevelEntityResponse, CreateTenantUserRequest, CreateTenantUserResponse, UserProfileResponse, ListLevelEntitiesResponse, LevelEntityResponse, UpdateLevelEntityRequest, DeleteLevelEntityRequest, DeleteLevelEntityResponse, ListTenantUsersResponse, GetTenantUserResponse, TenantUserResponse, TenantUserAckResponse, UpdateTenantUserRequest, DeleteTenantUserRequest, DisableTenantUserRequest, EnableTenantUserRequest, ResetTenantUserPasswordRequest, ResetTenantUserPasswordResponse, ResetTenantUserMfaRequest, ListTenantRolesResponse, AssignTenantRoleRequest, AssignTenantRoleResponse, RevokeTenantRoleRequest, RevokeTenantRoleResponse } from "@fiado/type-kit/bin/platformRbac/index.js";
|
|
4
|
-
import type { TenantUsersBySubsResponse } from "@fiado/type-kit/bin/platformRbac/index.js";
|
|
4
|
+
import type { TenantUsersBySubsResponse, RoleAssignmentsByScopeRefsResponse } from "@fiado/type-kit/bin/platformRbac/index.js";
|
|
5
5
|
import { IPlatformRbacBusinessApi } from "./interfaces/IPlatformRbacBusinessApi.js";
|
|
6
6
|
/**
|
|
7
7
|
* Publisher HTTP del lambda `platform-rbac-business` (componente 06 SureKeep Fase 0)
|
|
@@ -79,4 +79,6 @@ export default class PlatformRbacBusinessApi implements IPlatformRbacBusinessApi
|
|
|
79
79
|
revokeTenantRole(tenantId: string, assignmentId: string, input: RevokeTenantRoleRequest): Promise<APIGatewayProxyResultBody<RevokeTenantRoleResponse>>;
|
|
80
80
|
/** POST /internal/tenants/{tenantId}/users/by-subs — usuarios del tenant por cognitoSub, en lotes de 100; devuelve el mapa de `.data`. */
|
|
81
81
|
getTenantUsersBySubs(tenantId: string, cognitoSubs: string[]): Promise<TenantUsersBySubsResponse>;
|
|
82
|
+
/** POST /internal/tenants/{tenantId}/role-assignments/by-scope-refs — asignaciones por destino, en lotes de 100. */
|
|
83
|
+
getRoleAssignmentsByScopeRefs(tenantId: string, scopeRefs: string[]): Promise<RoleAssignmentsByScopeRefsResponse>;
|
|
82
84
|
}
|
|
@@ -12,7 +12,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
12
12
|
};
|
|
13
13
|
import { inject, injectable } from "inversify";
|
|
14
14
|
// TD-AI-003: el tipo de retorno de los métodos viejos no refleja el runtime. Ver docs/TECH_DEBT.md.
|
|
15
|
-
import { TENANT_USERS_BY_SUBS_MAX_BATCH, } from "@fiado/type-kit/bin/platformRbac/index.js";
|
|
15
|
+
import { TENANT_USERS_BY_SUBS_MAX_BATCH, ROLE_ASSIGNMENTS_BY_SCOPE_REFS_MAX_BATCH, } from "@fiado/type-kit/bin/platformRbac/index.js";
|
|
16
16
|
import { joinUrl } from "../../utils/joinUrl.js";
|
|
17
17
|
import { postIdsInBatches } from "../../utils/postIdsInBatches.js";
|
|
18
18
|
/**
|
|
@@ -194,6 +194,21 @@ let PlatformRbacBusinessApi = class PlatformRbacBusinessApi {
|
|
|
194
194
|
const url = joinUrl(this.baseUrl, `internal/tenants/${encodeURIComponent(tenantId)}/users/by-subs`);
|
|
195
195
|
return await postIdsInBatches(this.httpRequest, url, "cognitoSubs", cognitoSubs, TENANT_USERS_BY_SUBS_MAX_BATCH);
|
|
196
196
|
}
|
|
197
|
+
/** POST /internal/tenants/{tenantId}/role-assignments/by-scope-refs — asignaciones por destino, en lotes de 100. */
|
|
198
|
+
async getRoleAssignmentsByScopeRefs(tenantId, scopeRefs) {
|
|
199
|
+
const url = joinUrl(this.baseUrl, `internal/tenants/${encodeURIComponent(tenantId)}/role-assignments/by-scope-refs`);
|
|
200
|
+
const unique = Array.from(new Set(scopeRefs.filter((ref) => typeof ref === "string" && ref.length > 0)));
|
|
201
|
+
const items = [];
|
|
202
|
+
for (let i = 0; i < unique.length; i += ROLE_ASSIGNMENTS_BY_SCOPE_REFS_MAX_BATCH) {
|
|
203
|
+
const batch = unique.slice(i, i + ROLE_ASSIGNMENTS_BY_SCOPE_REFS_MAX_BATCH);
|
|
204
|
+
const response = await this.httpRequest.post(url, { scopeRefs: batch });
|
|
205
|
+
const batchItems = response?.data?.items;
|
|
206
|
+
if (!Array.isArray(batchItems))
|
|
207
|
+
throw new Error(`Respuesta sin items de ${url}`);
|
|
208
|
+
items.push(...batchItems);
|
|
209
|
+
}
|
|
210
|
+
return { items };
|
|
211
|
+
}
|
|
197
212
|
};
|
|
198
213
|
PlatformRbacBusinessApi = __decorate([
|
|
199
214
|
injectable(),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { APIGatewayProxyResultBody, ApiGatewayResponse, ResolvedPermissions, ResolveInput } from "@fiado/gateway-adapter";
|
|
2
2
|
import { DefineNextChallengeRequest, DefineNextChallengeResponse, PrepareChallengeRequest, PrepareChallengeResponse, VerifyChallengeRequest, VerifyChallengeResponse, AuthorizeRequest, AuthorizeResponse, EffectivePermissionsResponse, InjectableUserAttributesResponse, PermissionScope, CreateLevelEntityRequest, CreateLevelEntityResponse, CreateTenantUserRequest, CreateTenantUserResponse, UserProfileResponse, ListLevelEntitiesResponse, LevelEntityResponse, UpdateLevelEntityRequest, DeleteLevelEntityRequest, DeleteLevelEntityResponse, ListTenantUsersResponse, GetTenantUserResponse, TenantUserResponse, TenantUserAckResponse, UpdateTenantUserRequest, DeleteTenantUserRequest, DisableTenantUserRequest, EnableTenantUserRequest, ResetTenantUserPasswordRequest, ResetTenantUserPasswordResponse, ResetTenantUserMfaRequest, ListTenantRolesResponse, AssignTenantRoleRequest, AssignTenantRoleResponse, RevokeTenantRoleRequest, RevokeTenantRoleResponse } from "@fiado/type-kit/bin/platformRbac/index.js";
|
|
3
|
-
import type { TenantUsersBySubsResponse } from "@fiado/type-kit/bin/platformRbac/index.js";
|
|
3
|
+
import type { TenantUsersBySubsResponse, RoleAssignmentsByScopeRefsResponse } from "@fiado/type-kit/bin/platformRbac/index.js";
|
|
4
4
|
/**
|
|
5
5
|
* Contrato del publisher HTTP del lambda `platform-rbac-business` (componente 06 SureKeep Fase 0)
|
|
6
6
|
* para los 3 endpoints internos del Custom Auth Challenge flow (MFA).
|
|
@@ -126,4 +126,9 @@ export interface IPlatformRbacBusinessApi {
|
|
|
126
126
|
* Devuelve el mapa ya desempaquetado de `.data`; lanza el error del http sin fallback.
|
|
127
127
|
*/
|
|
128
128
|
getTenantUsersBySubs(tenantId: string, cognitoSubs: string[]): Promise<TenantUsersBySubsResponse>;
|
|
129
|
+
/**
|
|
130
|
+
* POST /internal/tenants/{tenantId}/role-assignments/by-scope-refs — asignaciones vigentes por destino,
|
|
131
|
+
* en lotes de 100. Concatena los `items`; lanza el error del http sin fallback.
|
|
132
|
+
*/
|
|
133
|
+
getRoleAssignmentsByScopeRefs(tenantId: string, scopeRefs: string[]): Promise<RoleAssignmentsByScopeRefsResponse>;
|
|
129
134
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fiado/api-invoker",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.115.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.14.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.509.0",
|
|
38
38
|
"dotenv": "^16.4.7"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
@@ -46,8 +46,14 @@ import {
|
|
|
46
46
|
RevokeTenantRoleRequest,
|
|
47
47
|
RevokeTenantRoleResponse,
|
|
48
48
|
TENANT_USERS_BY_SUBS_MAX_BATCH,
|
|
49
|
+
ROLE_ASSIGNMENTS_BY_SCOPE_REFS_MAX_BATCH,
|
|
50
|
+
} from "@fiado/type-kit/bin/platformRbac/index.js";
|
|
51
|
+
import type {
|
|
52
|
+
TenantUserBySubItem,
|
|
53
|
+
TenantUsersBySubsResponse,
|
|
54
|
+
RoleAssignmentsByScopeRefsResponse,
|
|
55
|
+
ScopeRefRoleAssignments,
|
|
49
56
|
} from "@fiado/type-kit/bin/platformRbac/index.js";
|
|
50
|
-
import type { TenantUserBySubItem, TenantUsersBySubsResponse } from "@fiado/type-kit/bin/platformRbac/index.js";
|
|
51
57
|
import { IPlatformRbacBusinessApi } from "./interfaces/IPlatformRbacBusinessApi.js";
|
|
52
58
|
import { joinUrl } from "../../utils/joinUrl.js";
|
|
53
59
|
import { postIdsInBatches } from "../../utils/postIdsInBatches.js";
|
|
@@ -345,4 +351,19 @@ export default class PlatformRbacBusinessApi implements IPlatformRbacBusinessApi
|
|
|
345
351
|
this.httpRequest, url, "cognitoSubs", cognitoSubs, TENANT_USERS_BY_SUBS_MAX_BATCH,
|
|
346
352
|
);
|
|
347
353
|
}
|
|
354
|
+
|
|
355
|
+
/** POST /internal/tenants/{tenantId}/role-assignments/by-scope-refs — asignaciones por destino, en lotes de 100. */
|
|
356
|
+
async getRoleAssignmentsByScopeRefs(tenantId: string, scopeRefs: string[]): Promise<RoleAssignmentsByScopeRefsResponse> {
|
|
357
|
+
const url = joinUrl(this.baseUrl, `internal/tenants/${encodeURIComponent(tenantId)}/role-assignments/by-scope-refs`);
|
|
358
|
+
const unique = Array.from(new Set(scopeRefs.filter((ref) => typeof ref === "string" && ref.length > 0)));
|
|
359
|
+
const items: ScopeRefRoleAssignments[] = [];
|
|
360
|
+
for (let i = 0; i < unique.length; i += ROLE_ASSIGNMENTS_BY_SCOPE_REFS_MAX_BATCH) {
|
|
361
|
+
const batch = unique.slice(i, i + ROLE_ASSIGNMENTS_BY_SCOPE_REFS_MAX_BATCH);
|
|
362
|
+
const response = await this.httpRequest.post<{ data?: RoleAssignmentsByScopeRefsResponse }>(url, { scopeRefs: batch });
|
|
363
|
+
const batchItems = response?.data?.items;
|
|
364
|
+
if (!Array.isArray(batchItems)) throw new Error(`Respuesta sin items de ${url}`);
|
|
365
|
+
items.push(...batchItems);
|
|
366
|
+
}
|
|
367
|
+
return { items };
|
|
368
|
+
}
|
|
348
369
|
}
|
|
@@ -43,7 +43,7 @@ import {
|
|
|
43
43
|
RevokeTenantRoleRequest,
|
|
44
44
|
RevokeTenantRoleResponse,
|
|
45
45
|
} from "@fiado/type-kit/bin/platformRbac/index.js";
|
|
46
|
-
import type { TenantUsersBySubsResponse } from "@fiado/type-kit/bin/platformRbac/index.js";
|
|
46
|
+
import type { TenantUsersBySubsResponse, RoleAssignmentsByScopeRefsResponse } from "@fiado/type-kit/bin/platformRbac/index.js";
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
49
|
* Contrato del publisher HTTP del lambda `platform-rbac-business` (componente 06 SureKeep Fase 0)
|
|
@@ -280,4 +280,10 @@ export interface IPlatformRbacBusinessApi {
|
|
|
280
280
|
* Devuelve el mapa ya desempaquetado de `.data`; lanza el error del http sin fallback.
|
|
281
281
|
*/
|
|
282
282
|
getTenantUsersBySubs(tenantId: string, cognitoSubs: string[]): Promise<TenantUsersBySubsResponse>;
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* POST /internal/tenants/{tenantId}/role-assignments/by-scope-refs — asignaciones vigentes por destino,
|
|
286
|
+
* en lotes de 100. Concatena los `items`; lanza el error del http sin fallback.
|
|
287
|
+
*/
|
|
288
|
+
getRoleAssignmentsByScopeRefs(tenantId: string, scopeRefs: string[]): Promise<RoleAssignmentsByScopeRefsResponse>;
|
|
283
289
|
}
|