mftsccs-node 0.2.14 → 0.2.16

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.
@@ -1,267 +1,139 @@
1
- import { PermissionSet } from "./PermissionSet";
1
+ /**
2
+ * AccessControlService
3
+ *
4
+ * This service provides access control functionality including:
5
+ * - Check access for concepts with complex permission logic
6
+ * - Assign and revoke access permissions
7
+ * - Bulk operations for access management
8
+ * - Super admin checks with caching
9
+ * - Access inheritance management
10
+ *
11
+ * This is the TypeScript equivalent of the C# AccessControlService class.
12
+ * All methods are static and can be called directly on the class.
13
+ */
14
+ import { AccessResult, BulkAccessRequest } from '../../DataStructures/AccessControl/AccessControlModels';
15
+ import { PermissionSet } from './PermissionSet';
2
16
  export declare class AccessControlService {
3
- private static accessCache;
4
- private static baseUrl;
17
+ private static cacheService;
18
+ private static apiClient;
5
19
  private static initialize;
6
20
  /**
7
- * Checks if a user or entity has the specified access for a single concept.
8
- * @param userId - The user's ID.
9
- * @param access - The required PermissionSet.
10
- * @param conceptId - The concept ID to check.
11
- * @param entityId - Optional entity ID (defaults to userId).
12
- * @returns Promise<boolean> - True if access is granted, false otherwise.
21
+ * Check whether a user/entity has the specified permission.
22
+ * Returns true if allowed, false otherwise.
23
+ *
24
+ * @param conceptId - The ID of the concept to check access for
25
+ * @param permission - The permission to check (PermissionSet flags)
26
+ * @param entityId - Optional entity ID to check access for
27
+ * @returns Promise<boolean> - True if access is granted, false otherwise
13
28
  */
14
- static checkAccessOfConcept(userId: number, access: PermissionSet, conceptId: number, entityId?: number): Promise<boolean>;
29
+ static checkAccess(conceptId: number, permission: PermissionSet, entityId?: number | null): Promise<boolean>;
15
30
  /**
16
- * Checks if a user or entity has the specified access for all concepts in a list.
17
- * @param userId - The user's ID.
18
- * @param access - The required PermissionSet.
19
- * @param conceptIdList - Array of concept IDs to check.
20
- * @param entityId - Optional entity ID (defaults to userId).
21
- * @returns Promise<boolean> - True if access is granted for all, false otherwise.
31
+ * Get all conceptIds which have a certain permission for an entity.
32
+ * Optional filter by a list of conceptIds.
33
+ *
34
+ * @param permission - The permission to check (PermissionSet flags)
35
+ * @param conceptIdsFilter - List of concept IDs to filter
36
+ * @param entityId - Optional entity ID
37
+ * @returns Promise<number[]> - Array of concept IDs that have the permission
22
38
  */
23
- static checkAccessOfConceptList(userId: number, access: PermissionSet, conceptIdList: number[], entityId?: number): Promise<boolean>;
39
+ static getConceptIdsWithPermission(permission: PermissionSet, conceptIdsFilter: number[], entityId?: number | null): Promise<number[]>;
24
40
  /**
25
- * Filters a list of concept IDs, returning only those for which the user or entity has the specified access.
26
- * @param userId - The user's ID.
27
- * @param access - The required PermissionSet.
28
- * @param conceptIdList - Array of concept IDs to filter.
29
- * @param entityId - Optional entity ID (defaults to userId).
30
- * @returns Promise<number[]> - Array of concept IDs with access.
41
+ * Assign access permission to an entity
42
+ *
43
+ * @param conceptId - The concept ID to assign access for
44
+ * @param permission - The permission to assign (PermissionSet flags)
45
+ * @param entityId - Optional entity ID
46
+ * @returns Promise<boolean> - True if successful, false otherwise
31
47
  */
32
- static filterConceptListByAccess(userId: number, access: PermissionSet, conceptIdList: number[], entityId?: number): Promise<number[]>;
48
+ static assignAccess(conceptId: number, permission: PermissionSet, entityId?: number | null): Promise<boolean>;
33
49
  /**
34
- * Gets the entity ID for a given user ID.
35
- * @param userId - The user's ID.
36
- * @returns number - The entity ID (default: userId).
50
+ * Assign access permissions to multiple targets in bulk
51
+ *
52
+ * @param request - Bulk access request containing targets
53
+ * @returns Promise<AccessResult[]> - Array of access results
37
54
  */
38
- private static getEntityIdConceptByUserId;
55
+ static assignAccessBulk(request: BulkAccessRequest): Promise<AccessResult[]>;
39
56
  /**
40
- * Assigns access to a specific entity for a concept.
41
- * @param request - Object containing conceptId, access, entityId, makePublic.
42
- * @returns Promise<any> - API response.
57
+ * Revoke access permission from an entity
58
+ *
59
+ * @param conceptId - The concept ID to revoke access for
60
+ * @param permission - The permission to revoke (PermissionSet flags)
61
+ * @param entityId - Optional entity ID
62
+ * @returns Promise<boolean> - True if successfully revoked, false otherwise
43
63
  */
44
- static assignAccessToEntity(request: {
45
- conceptId: number;
46
- access: string;
47
- entityId: number;
48
- makePublic: boolean;
49
- }): Promise<any>;
64
+ static revokeAccess(conceptId: number, permission: PermissionSet, entityId?: number | null): Promise<boolean>;
50
65
  /**
51
- * Assigns public access to a concept or list of concepts.
52
- * @param request - Object containing conceptId, accessList, connectionTypeList, nestedAccessLevel, conceptIdList.
53
- * @returns Promise<any> - API response.
66
+ * Revoke access permissions from multiple targets in bulk
67
+ *
68
+ * @param request - Bulk access request containing targets
69
+ * @returns Promise<AccessResult[]> - Array of access results
54
70
  */
55
- static assignPublicAccess(request: {
56
- conceptId: number;
57
- accessList: string[];
58
- connectionTypeList?: string[];
59
- nestedAccessLevel?: number;
60
- conceptIdList?: number[];
61
- }): Promise<any>;
71
+ static revokeAccessBulk(request: BulkAccessRequest): Promise<AccessResult[]>;
62
72
  /**
63
- * Assigns public access to multiple concepts in bulk.
64
- * @param request - Object containing conceptIdList, accessList, connectionTypeList, nestedAccessLevel, conceptId.
65
- * @returns Promise<any> - API response.
73
+ * Set access inheritance for a concept
74
+ *
75
+ * @param conceptId - The concept ID to set inheritance for
76
+ * @returns Promise<boolean> - True if successful, false otherwise
66
77
  */
67
- static assignPublicAccessBlukConcept(request: {
68
- conceptIdList: number[];
69
- accessList: string[];
70
- connectionTypeList?: string[];
71
- nestedAccessLevel?: number;
72
- conceptId?: number;
73
- }): Promise<any>;
78
+ static setAccessInheritance(conceptId: number): Promise<boolean>;
74
79
  /**
75
- * Assigns access to multiple entities and concepts in bulk.
76
- * @param request - Object containing conceptId, conceptIdList, entityIdList, accessList, connectionTypeList, nestedAccessLevel.
77
- * @returns Promise<any> - API response.
80
+ * Get access inheritance status for a concept
81
+ *
82
+ * @param conceptId - The concept ID to check
83
+ * @param connectionTypeId - The connection type ID (default: 999)
84
+ * @returns Promise<boolean> - True if inheritance is enabled, false otherwise
78
85
  */
79
- static assignAccessToEntityBulk(request: {
80
- conceptId: number;
81
- conceptIdList?: number[];
82
- entityIdList: number[];
83
- accessList: string[];
84
- connectionTypeList?: string[];
85
- nestedAccessLevel?: number;
86
- }): Promise<any>;
86
+ static getAccessInheritanceStatus(conceptId: number, connectionTypeId?: number): Promise<boolean>;
87
87
  /**
88
- * Assigns access to a user for a concept.
89
- * @param request - Object containing conceptId, access, userId, makePublic.
90
- * @returns Promise<any> - API response.
88
+ * Set access inheritance status for a concept
89
+ *
90
+ * @param conceptId - The concept ID to set inheritance status for
91
+ * @param isEnabled - Whether to enable or disable inheritance
92
+ * @param connectionTypeId - The connection type ID (default: 999)
93
+ * @returns Promise<boolean> - True if successful, false otherwise
91
94
  */
92
- static assignAccessByUser(request: {
93
- conceptId: number;
94
- access: string;
95
- userId: number;
96
- makePublic: boolean;
97
- }): Promise<any>;
95
+ static setAccessInheritanceStatus(conceptId: number, isEnabled: boolean, connectionTypeId?: number): Promise<boolean>;
98
96
  /**
99
- * Revokes access for an entity from a concept.
100
- * @param params - Object containing conceptId, access, entityId.
101
- * @returns Promise<any> - API response.
97
+ * Check if an entity is a super admin
98
+ * Uses caching for performance
99
+ *
100
+ * @param entityId - The entity ID to check
101
+ * @returns Promise<boolean> - True if super admin, false otherwise
102
102
  */
103
- static revokeAccess(params: {
104
- conceptId: number;
105
- access: string;
106
- entityId: number;
107
- }): Promise<any>;
103
+ static isSuperAdmin(entityId: number): Promise<boolean>;
108
104
  /**
109
- * Revokes access for multiple entities in bulk.
110
- * @param request - Object containing conceptId, entityIdList, accessList.
111
- * @returns Promise<any> - API response.
105
+ * Assign super admin access to an entity
106
+ *
107
+ * @param entityId - The entity ID to grant super admin access to
108
+ * @returns Promise<number> - The entity ID if successful, 0 otherwise
112
109
  */
113
- static revokeAccessBulk(request: {
114
- conceptId: number;
115
- entityIdList: number[];
116
- accessList: string[];
117
- }): Promise<any>;
110
+ static assignSuperAdmin(entityId: number): Promise<number>;
118
111
  /**
119
- * Gets the access list for a concept and user.
120
- * @param conceptId - The concept ID.
121
- * @param userId - The user ID.
122
- * @returns Promise<any> - API response.
112
+ * Revoke super admin access from an entity
113
+ *
114
+ * @param entityId - The entity ID to revoke super admin access from
115
+ * @returns Promise<string> - Success message or error message
123
116
  */
124
- static getAccessList(conceptId: number, userId: number): Promise<any>;
117
+ static revokeSuperAdmin(entityId: number): Promise<string>;
125
118
  /**
126
- * Gets the public access list for a list of concept IDs.
127
- * @param conceptIdList - Array of concept IDs.
128
- * @returns Promise<any> - API response.
119
+ * Convert PermissionSet to string for API calls
129
120
  */
130
- static getPublicAccessList(conceptIdList: number[]): Promise<any>;
121
+ private static permissionSetToString;
131
122
  /**
132
- * Revokes public access for a concept.
133
- * @param request - Object containing conceptId, accessList.
134
- * @returns Promise<any> - API response.
123
+ * Internal method to check access via cache or API
124
+ *
125
+ * @param accessId - The access ID to check
126
+ * @param permission - The permission to check (string)
127
+ * @param entityId - Optional entity ID
128
+ * @returns Promise<boolean> - True if access is granted, false otherwise
135
129
  */
136
- static revokePublicAccess(request: {
137
- conceptId: number;
138
- accessList: string[];
139
- }): Promise<any>;
130
+ private static checkAccessInternal;
140
131
  /**
141
- * Checks if an entity has a specific permission for a concept.
142
- * @param params - Object containing conceptId, permission, entityId.
143
- * @returns Promise<any> - API response.
132
+ * Clear all access cache entries
144
133
  */
145
- static checkAccess(params: {
146
- conceptId: number;
147
- permission: string;
148
- entityId: number;
149
- }): Promise<any>;
134
+ static clearCache(): void;
150
135
  /**
151
- * Checks if a user has a specific access for a concept.
152
- * @param request - Object containing conceptId, access, userId.
153
- * @returns Promise<any> - API response.
136
+ * Clear super admin cache
154
137
  */
155
- static checkAccessByUser(request: {
156
- conceptId: number;
157
- access: string;
158
- userId: number;
159
- }): Promise<any>;
160
- /**
161
- * Filters concepts by access for a user.
162
- * @param request - Object containing userId, access, conceptIdList, connectionIdList.
163
- * @returns Promise<any> - API response.
164
- */
165
- static filterConceptsByAccess(request: {
166
- userId: number;
167
- access: string;
168
- conceptIdList?: number[];
169
- connectionIdList?: number[];
170
- }): Promise<any>;
171
- /**
172
- * Checks access for a user on multiple concepts in bulk.
173
- * @param request - Object containing userId, access, conceptIdList.
174
- * @returns Promise<any> - API response.
175
- */
176
- static checkAccessOfConceptBulk(request: {
177
- userId: number;
178
- access: string;
179
- conceptIdList: number[];
180
- }): Promise<any>;
181
- /**
182
- * Gets entities with a specific access for a concept.
183
- * @param conceptId - The concept ID.
184
- * @param access - The access type.
185
- * @returns Promise<any> - API response.
186
- */
187
- static getEntitiesByAccess(conceptId: number, access: string): Promise<any>;
188
- /**
189
- * Gets all entities with any access for a concept.
190
- * @param conceptId - The concept ID.
191
- * @returns Promise<any> - API response.
192
- */
193
- static getEntitiesWithAccess(conceptId: number): Promise<any>;
194
- /**
195
- * Gets access groups by entity.
196
- * @param entityId - Optional entity ID.
197
- * @returns Promise<any> - API response.
198
- */
199
- static getAccessGroupByEntity(entityId?: number): Promise<any>;
200
- /**
201
- * Gets access groups by user.
202
- * @param userId - Optional user ID.
203
- * @returns Promise<any> - API response.
204
- */
205
- static getAccessGroupByUser(userId?: number): Promise<any>;
206
- /**
207
- * Gets public access by access IDs.
208
- * @param accessIdList - Array of access IDs.
209
- * @returns Promise<any> - API response.
210
- */
211
- static getPublicAccessByAccessIds(accessIdList: number[]): Promise<any>;
212
- /**
213
- * Gets the full access mapping for public users.
214
- * @returns Promise<any> - API response.
215
- */
216
- static getFullAccessMappingForPublic(): Promise<any>;
217
- /**
218
- * Assigns public access for all users.
219
- * @returns Promise<any> - API response.
220
- */
221
- static assignPublicAccessForAllUser(): Promise<any>;
222
- /**
223
- * Assigns access by connection type for users.
224
- * @returns Promise<any> - API response.
225
- */
226
- static assignAccessByConncetionTypeOfUser(): Promise<any>;
227
- /**
228
- * Sets access inheritance for a concept.
229
- * @param request - Object containing mainConceptId, enable, connectionTypeId.
230
- * @returns Promise<any> - API response.
231
- */
232
- static setAccessInheritance(request: {
233
- mainConceptId: number;
234
- enable: boolean;
235
- connectionTypeId?: number;
236
- }): Promise<any>;
237
- /**
238
- * Gets the status of access inheritance for a concept.
239
- * @param mainConceptId - The main concept ID.
240
- * @param connectionTypeId - The connection type ID (default: 999).
241
- * @returns Promise<any> - API response.
242
- */
243
- static getAccessInheritanceStatus(mainConceptId: number, connectionTypeId?: number): Promise<any>;
244
- /**
245
- * Performs a GET request to the backend API.
246
- * @param path - The API path.
247
- * @param errorMsg - Error message to throw if request fails.
248
- * @returns Promise<any> - API response.
249
- */
250
- private static _get;
251
- /**
252
- * Performs a POST request to the backend API.
253
- * @param path - The API path.
254
- * @param body - Request body.
255
- * @param errorMsg - Error message to throw if request fails.
256
- * @returns Promise<any> - API response.
257
- */
258
- private static _post;
259
- /**
260
- * Performs a DELETE request to the backend API.
261
- * @param path - The API path.
262
- * @param body - Optional request body.
263
- * @param errorMsg - Error message to throw if request fails.
264
- * @returns Promise<any> - API response.
265
- */
266
- private static _delete;
138
+ static clearSuperAdminCache(): void;
267
139
  }
@@ -1,8 +1,23 @@
1
+ /**
2
+ * Permission set enum (bitwise flags)
3
+ * Mirrors C# PermissionSet enum
4
+ */
1
5
  export declare enum PermissionSet {
2
6
  None = 0,
3
- Read = 1,
4
- Write = 2,
5
- Execute = 4,
7
+ Read = 1,// 1
8
+ Write = 2,// 2
9
+ Execute = 4,// 4
6
10
  Delete = 8
7
11
  }
12
+ /**
13
+ * Convert an array of permission strings to a PermissionSet bitfield
14
+ */
8
15
  export declare function getPermissionSetFromStrings(permissions: string[]): PermissionSet;
16
+ /**
17
+ * Convert a PermissionSet bitfield to an array of permission strings
18
+ */
19
+ export declare function getStringsFromPermissionSet(permissions: PermissionSet): string[];
20
+ /**
21
+ * Check if a permission string is valid
22
+ */
23
+ export declare function isValidPermission(permission: string): boolean;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Access Control Services
3
+ *
4
+ * This module exports all access control components:
5
+ * - AccessControlService: Main service for access control operations
6
+ * - CacheService: In-memory caching for access checks
7
+ * - APIClientService: HTTP client for access control API endpoints
8
+ * - PermissionSet: Permission flags and utilities
9
+ * - Models: Data types for access control operations
10
+ */
11
+ export { AccessControlService } from './AccessControlService';
12
+ export { CacheService, ICacheService } from './AccessControlCacheService';
13
+ export { APIClientService, IAPIClientService } from './APIClientService';
14
+ export { PermissionSet, getPermissionSetFromStrings, getStringsFromPermissionSet, isValidPermission } from './PermissionSet';
15
+ export { PermissionSet as PermissionSetEnum, AccessRequest, AccessResult, BulkAccessRequest, BulkAccessTarget, BulkCheckAccessRequest, AccessInheritanceRequest, SuperAdminRequest, AccessControlAPIResponse, AccessControlApiResponse, AddAccessByEntityRequest, AddPublicAccessToConcept, AddAccessByEntityBulkRequest, AddAccessByUserRequest, CheckAccessBulk, VALID_PERMISSIONS, isValidPermission as isValidPermissionFromModels } from '../../DataStructures/AccessControl/AccessControlModels';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mftsccs-node",
3
- "version": "0.2.14",
3
+ "version": "0.2.16",
4
4
  "environment": "production",
5
5
  "description": "Full Pack of concept and connection system",
6
6
  "main": "dist/bundle.js",
@@ -1 +0,0 @@
1
- /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */