mftsccs-node 0.0.77 → 0.0.79-dev
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/README.md +60 -50
- package/dist/bundle.js +1 -1
- package/dist/bundle.mjs +1 -1
- package/dist/types/Api/MakeTheTypeConceptApi.d.ts +1 -30
- package/dist/types/DataStructures/AccessControl/AccessControlModels.d.ts +176 -0
- package/dist/types/DataStructures/BaseUrl.d.ts +2 -0
- package/dist/types/DataStructures/CCSConfig.d.ts +15 -1
- package/dist/types/DataStructures/Transaction/Transaction.d.ts +1 -0
- package/dist/types/Services/AccessControl/APIClientService.d.ts +162 -0
- package/dist/types/Services/AccessControl/AccessControlCacheService.d.ts +76 -18
- package/dist/types/Services/AccessControl/AccessControlService.d.ts +223 -237
- package/dist/types/Services/AccessControl/PermissionSet.d.ts +18 -3
- package/dist/types/Services/AccessControl/index.d.ts +15 -0
- package/dist/types/Services/CreateTypeConcept.d.ts +2 -0
- package/dist/types/app.d.ts +8 -1
- package/package.json +8 -3
|
@@ -8,35 +8,6 @@
|
|
|
8
8
|
import { Concept } from "../DataStructures/Concept";
|
|
9
9
|
/**
|
|
10
10
|
* Retrieves or creates a type concept based on a string identifier.
|
|
11
|
-
* Type concepts
|
|
12
|
-
*
|
|
13
|
-
* This function first attempts to find an existing type concept locally, then queries the backend
|
|
14
|
-
* if not found. If the concept doesn't exist in the backend, it creates a new type concept.
|
|
15
|
-
* The function uses caching to prevent duplicate requests for the same type.
|
|
16
|
-
*
|
|
17
|
-
* @param type - The string identifier for the type concept (e.g., "the_person", "the_location")
|
|
18
|
-
* @param userId - The user ID associated with the request
|
|
19
|
-
* @returns A promise that resolves to the Concept object representing the type
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* ```typescript
|
|
23
|
-
* // Get or create a "person" type concept
|
|
24
|
-
* const personType = await MakeTheTypeConceptApi('the_person', 123);
|
|
25
|
-
* console.log('Person type ID:', personType.id);
|
|
26
|
-
*
|
|
27
|
-
* // Use the type concept when creating new concepts
|
|
28
|
-
* const newPerson = await CreateConcept('John Doe', personType.id);
|
|
29
|
-
* ```
|
|
30
|
-
*
|
|
31
|
-
* @remarks
|
|
32
|
-
* - Uses local caching to prevent duplicate simultaneous requests
|
|
33
|
-
* - First searches for existing concept via GetConceptByCharacterAndCategory
|
|
34
|
-
* - Creates new type concept in backend if not found or if typeId is 4 (unknown type)
|
|
35
|
-
* - Automatically adds the retrieved concept to ConceptsData for local access
|
|
36
|
-
* - Cache entries are cleaned up after the fetch completes
|
|
37
|
-
* - Returns a default concept with id=0 if errors occur
|
|
38
|
-
*
|
|
39
|
-
* @see GetConceptByCharacterAndCategory for local concept searching
|
|
40
|
-
* @see MakeTheNameInBackend for creating named concepts
|
|
11
|
+
* Type concepts define categories and classifications used in the Concept Connection System.
|
|
41
12
|
*/
|
|
42
13
|
export declare function MakeTheTypeConceptApi(type: string, userId: number): Promise<Concept>;
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Data models for V1 Access Control Service
|
|
3
|
+
* These models mirror the C# FreeSchema.Models.AccessControl types
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Permission set enum (bitwise flags)
|
|
7
|
+
* Mirrors C# PermissionSet enum
|
|
8
|
+
*/
|
|
9
|
+
export declare enum PermissionSet {
|
|
10
|
+
None = 0,
|
|
11
|
+
Read = 1,// 1
|
|
12
|
+
Write = 2,// 2
|
|
13
|
+
Execute = 4,// 4
|
|
14
|
+
Delete = 8
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Request model for single access operations (check, assign, revoke)
|
|
18
|
+
*/
|
|
19
|
+
export interface AccessRequest {
|
|
20
|
+
accessId?: number | null;
|
|
21
|
+
permission: string;
|
|
22
|
+
entityId?: number | null;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Result model for access operations
|
|
26
|
+
*/
|
|
27
|
+
export interface AccessResult {
|
|
28
|
+
accessId: number;
|
|
29
|
+
permission: string;
|
|
30
|
+
entityId?: number | null;
|
|
31
|
+
hasAccess: boolean;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Target for bulk access operations
|
|
35
|
+
*/
|
|
36
|
+
export interface BulkAccessTarget {
|
|
37
|
+
entityId?: number | null;
|
|
38
|
+
permissions: string[];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Request model for bulk access operations
|
|
42
|
+
*/
|
|
43
|
+
export interface BulkAccessRequest {
|
|
44
|
+
accessId?: number | null;
|
|
45
|
+
targets: BulkAccessTarget[];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Request model for bulk check access operations
|
|
49
|
+
* Mirrors C# BulkCheckAccessRequest
|
|
50
|
+
*/
|
|
51
|
+
export interface BulkCheckAccessRequest {
|
|
52
|
+
accessIds: number[];
|
|
53
|
+
permission: string;
|
|
54
|
+
entityId?: number | null;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Request model for access inheritance operations
|
|
58
|
+
*/
|
|
59
|
+
export interface AccessInheritanceRequest {
|
|
60
|
+
accessId?: number | null;
|
|
61
|
+
connectionTypeId?: number;
|
|
62
|
+
enable?: boolean;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Request model for super admin operations
|
|
66
|
+
*/
|
|
67
|
+
export interface SuperAdminRequest {
|
|
68
|
+
accessId?: number | null;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Request model for parent access inheritance operations
|
|
72
|
+
* Mirrors C# ParentAccessInheritanceRequest
|
|
73
|
+
*/
|
|
74
|
+
export interface ParentAccessInheritanceRequest {
|
|
75
|
+
parentAccessId: number;
|
|
76
|
+
childAccessId?: number | null;
|
|
77
|
+
}
|
|
78
|
+
export interface ParentAccessInheritanceWithConceptRequest {
|
|
79
|
+
parentConceptId: number;
|
|
80
|
+
childConceptId?: number | null;
|
|
81
|
+
}
|
|
82
|
+
export interface BulkParentAccessInheritanceWithConceptRequest {
|
|
83
|
+
parentConceptId: number;
|
|
84
|
+
childConceptIds: number[];
|
|
85
|
+
}
|
|
86
|
+
export interface BulkParentAccessInheritanceResult {
|
|
87
|
+
childConceptId: number;
|
|
88
|
+
accessId: number;
|
|
89
|
+
success: boolean;
|
|
90
|
+
message?: string;
|
|
91
|
+
}
|
|
92
|
+
export interface SuperAdminWithConceptRequest {
|
|
93
|
+
conceptId: number;
|
|
94
|
+
}
|
|
95
|
+
export interface AccessInheritanceWithConceptRequest {
|
|
96
|
+
conceptId: number;
|
|
97
|
+
connectionTypeId?: number;
|
|
98
|
+
enable?: boolean;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Standard API response wrapper for access control endpoints
|
|
102
|
+
*/
|
|
103
|
+
export interface AccessControlAPIResponse<T = unknown> {
|
|
104
|
+
status: boolean;
|
|
105
|
+
message?: string;
|
|
106
|
+
data?: T;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Valid permissions for validation
|
|
110
|
+
*/
|
|
111
|
+
export declare const VALID_PERMISSIONS: Set<string>;
|
|
112
|
+
/**
|
|
113
|
+
* Check if a permission string is valid
|
|
114
|
+
*/
|
|
115
|
+
export declare function isValidPermission(permission: string): boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Request model for adding access by entity
|
|
118
|
+
* Mirrors C# AddAccessByEntityRequest
|
|
119
|
+
*/
|
|
120
|
+
export interface AddAccessByEntityRequest {
|
|
121
|
+
conceptId: number;
|
|
122
|
+
access: string;
|
|
123
|
+
entityId: number;
|
|
124
|
+
makePublic: boolean;
|
|
125
|
+
nestedAccessLevel: number;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Request model for adding public access to concept
|
|
129
|
+
* Mirrors C# AddPublicAccessToConcept
|
|
130
|
+
*/
|
|
131
|
+
export interface AddPublicAccessToConcept {
|
|
132
|
+
conceptId: number;
|
|
133
|
+
conceptIdList: number[];
|
|
134
|
+
accessList: string[];
|
|
135
|
+
nestedAccessLevel: number;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Request model for bulk adding access by entity
|
|
139
|
+
* Mirrors C# AddAccessByEntityBulkRequest
|
|
140
|
+
*/
|
|
141
|
+
export interface AddAccessByEntityBulkRequest {
|
|
142
|
+
conceptId: number;
|
|
143
|
+
conceptIdList: number[];
|
|
144
|
+
entityIdList: number[];
|
|
145
|
+
accessList: string[];
|
|
146
|
+
nestedAccessLevel: number;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Request model for adding access by user
|
|
150
|
+
* Mirrors C# AddAccessByUserRequest
|
|
151
|
+
*/
|
|
152
|
+
export interface AddAccessByUserRequest {
|
|
153
|
+
conceptId: number;
|
|
154
|
+
access: string;
|
|
155
|
+
userId: number;
|
|
156
|
+
makePublic: boolean;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Request model for checking bulk access
|
|
160
|
+
* Mirrors C# CheckAccessBulk
|
|
161
|
+
*/
|
|
162
|
+
export interface CheckAccessBulk {
|
|
163
|
+
userId: number;
|
|
164
|
+
access: string;
|
|
165
|
+
conceptIdList: number[];
|
|
166
|
+
connectionIdList: number[];
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Alternative API response format
|
|
170
|
+
* Mirrors C# AccessControlApiResponse
|
|
171
|
+
*/
|
|
172
|
+
export interface AccessControlApiResponse {
|
|
173
|
+
success?: boolean | null;
|
|
174
|
+
data?: unknown;
|
|
175
|
+
message?: string | null;
|
|
176
|
+
}
|
|
@@ -43,6 +43,7 @@ export declare class BaseUrl {
|
|
|
43
43
|
static setNodeCacheUrl(cacheServerUrl?: string): void;
|
|
44
44
|
static setCacheServers(cacheServers?: string[]): void;
|
|
45
45
|
static GetReadBaseUrl(): string;
|
|
46
|
+
static GetNodeBaseUrl(): string;
|
|
46
47
|
static GetReadBaseUrlCandidates(): string[];
|
|
47
48
|
/**
|
|
48
49
|
* Returns the URL for retrieving a single concept by ID.
|
|
@@ -254,6 +255,7 @@ export declare class BaseUrl {
|
|
|
254
255
|
* @returns {string} The type concept creation API endpoint
|
|
255
256
|
*/
|
|
256
257
|
static MakeTheTypeConceptUrl(): string;
|
|
258
|
+
static CreateTypeConceptUrl(): string;
|
|
257
259
|
/**
|
|
258
260
|
* Returns the URL for deleting a single connection.
|
|
259
261
|
* @returns {string} The connection deletion API endpoint
|
|
@@ -40,6 +40,13 @@
|
|
|
40
40
|
* await init("https://api.example.com", "", "MyApp", config);
|
|
41
41
|
* ```
|
|
42
42
|
*/
|
|
43
|
+
type CCSConfigOptions = Partial<Omit<CCSConfig, "cacheServers">> & {
|
|
44
|
+
cacheServers?: string[] | string;
|
|
45
|
+
cacheServerUrl?: string;
|
|
46
|
+
cacheServer?: string;
|
|
47
|
+
cache_servers?: string[] | string;
|
|
48
|
+
};
|
|
49
|
+
export declare function normalizeCacheServers(cacheServers?: string[] | string): any[];
|
|
43
50
|
export declare class CCSConfig {
|
|
44
51
|
/** URL for the AI service. Defaults to "https://ai.freeschema.com" */
|
|
45
52
|
aiUrl: string;
|
|
@@ -51,6 +58,10 @@ export declare class CCSConfig {
|
|
|
51
58
|
accessToken: string;
|
|
52
59
|
/** Whether to enable AI features. Defaults to true */
|
|
53
60
|
enableAi: boolean;
|
|
61
|
+
/** Whether to enable access control checks. Defaults to false (allow all access). */
|
|
62
|
+
enableAccessControl: boolean;
|
|
63
|
+
/** Base URL for Access Control API. Falls back to env/default when not provided. */
|
|
64
|
+
accessControlBaseUrl?: string;
|
|
54
65
|
/**
|
|
55
66
|
* Dictionary of feature flags for controlling CCS behavior.
|
|
56
67
|
* Available flags:
|
|
@@ -90,6 +101,8 @@ export declare class CCSConfig {
|
|
|
90
101
|
* const config = new CCSConfig({
|
|
91
102
|
* aiUrl: "https://custom-ai.example.com",
|
|
92
103
|
* enableAi: false,
|
|
104
|
+
* enableAccessControl: true,
|
|
105
|
+
* accessControlBaseUrl: "https://access.example.com/api/access-control",
|
|
93
106
|
* clientId: "123456",
|
|
94
107
|
* clientSecret: "secret",
|
|
95
108
|
* flags: {
|
|
@@ -99,7 +112,7 @@ export declare class CCSConfig {
|
|
|
99
112
|
* });
|
|
100
113
|
* ```
|
|
101
114
|
*/
|
|
102
|
-
constructor(options?:
|
|
115
|
+
constructor(options?: CCSConfigOptions);
|
|
103
116
|
/**
|
|
104
117
|
* Returns true if OAuth credentials are configured.
|
|
105
118
|
* @returns {boolean} Whether both clientId and clientSecret are set
|
|
@@ -171,3 +184,4 @@ export declare class CCSConfig {
|
|
|
171
184
|
*/
|
|
172
185
|
setParameter(paramName: string, value: string): void;
|
|
173
186
|
}
|
|
187
|
+
export {};
|
|
@@ -214,6 +214,7 @@ export declare class Transaction {
|
|
|
214
214
|
* ```
|
|
215
215
|
*/
|
|
216
216
|
MakeTheInstanceConcept(type: string, referent: string, composition: boolean | undefined, userId: number, accessId: number, sessionInformationId?: number, referentId?: number): Promise<Concept>;
|
|
217
|
+
CreateTypeConcept(typeConcept: Concept | number, characterValue: string, userId?: number, accessId?: number, sessionInformationId?: number): Promise<Concept>;
|
|
217
218
|
/**
|
|
218
219
|
* Creates a connection between two concepts within the transaction.
|
|
219
220
|
* Establishes a typed relationship between source and target concepts.
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* APIClientService
|
|
3
|
+
*
|
|
4
|
+
* API client service for Access Control endpoints.
|
|
5
|
+
* Provides typed HTTP methods for all access control API operations.
|
|
6
|
+
*
|
|
7
|
+
* This is the TypeScript equivalent of the C# APIClientService class.
|
|
8
|
+
*/
|
|
9
|
+
import { AccessRequest, AccessResult, AccessControlAPIResponse, BulkAccessRequest, BulkCheckAccessRequest, AccessInheritanceRequest, SuperAdminRequest, ParentAccessInheritanceRequest, ParentAccessInheritanceWithConceptRequest, BulkParentAccessInheritanceWithConceptRequest, BulkParentAccessInheritanceResult, SuperAdminWithConceptRequest, AccessInheritanceWithConceptRequest } from '../../DataStructures/AccessControl/AccessControlModels';
|
|
10
|
+
export interface IAPIClientService {
|
|
11
|
+
assignAccessAsync(request: AccessRequest): Promise<AccessControlAPIResponse<AccessResult>>;
|
|
12
|
+
checkAccessAsync(request: AccessRequest): Promise<AccessControlAPIResponse<AccessResult>>;
|
|
13
|
+
revokeAccessAsync(request: AccessRequest): Promise<AccessControlAPIResponse<AccessResult>>;
|
|
14
|
+
assignAccessBulkAsync(request: BulkAccessRequest): Promise<AccessControlAPIResponse<AccessResult[]>>;
|
|
15
|
+
revokeAccessBulkAsync(request: BulkAccessRequest): Promise<AccessControlAPIResponse<AccessResult[]>>;
|
|
16
|
+
checkAccessBulkAsync(request: BulkCheckAccessRequest): Promise<AccessControlAPIResponse<AccessResult[]>>;
|
|
17
|
+
getAccessByIdAsync(accessId: number): Promise<AccessControlAPIResponse<AccessResult[]>>;
|
|
18
|
+
setAccessInheritanceAsync(request: AccessInheritanceRequest): Promise<AccessControlAPIResponse>;
|
|
19
|
+
getAccessInheritanceStatusAsync(accessId: number, connectionTypeId?: number): Promise<AccessControlAPIResponse>;
|
|
20
|
+
assignSuperAdminAccessAsync(request: SuperAdminRequest): Promise<AccessControlAPIResponse>;
|
|
21
|
+
revokeSuperAdminAccessAsync(request: SuperAdminRequest): Promise<AccessControlAPIResponse>;
|
|
22
|
+
checkSuperAdminStatusAsync(accessId: number): Promise<AccessControlAPIResponse>;
|
|
23
|
+
setParentAccessInheritanceAsync(request: ParentAccessInheritanceRequest): Promise<AccessControlAPIResponse>;
|
|
24
|
+
removeParentAccessInheritanceAsync(accessId: number, parentAccessId?: number): Promise<AccessControlAPIResponse>;
|
|
25
|
+
hasParentAccessInheritanceAsync(accessId: number, parentAccessId?: number): Promise<AccessControlAPIResponse>;
|
|
26
|
+
getParentAccessIdAsync(accessId: number): Promise<AccessControlAPIResponse>;
|
|
27
|
+
setParentAccessInheritanceByConceptAsync(request: ParentAccessInheritanceWithConceptRequest): Promise<AccessControlAPIResponse>;
|
|
28
|
+
setParentAccessInheritanceBulkByConceptAsync(request: BulkParentAccessInheritanceWithConceptRequest): Promise<AccessControlAPIResponse<BulkParentAccessInheritanceResult[]>>;
|
|
29
|
+
removeParentAccessInheritanceByConceptAsync(childConceptId: number, parentConceptId?: number): Promise<AccessControlAPIResponse>;
|
|
30
|
+
removeParentAccessInheritanceBulkByConceptAsync(request: BulkParentAccessInheritanceWithConceptRequest): Promise<AccessControlAPIResponse<BulkParentAccessInheritanceResult[]>>;
|
|
31
|
+
hasParentAccessInheritanceByConceptAsync(childConceptId: number, parentConceptId?: number): Promise<AccessControlAPIResponse>;
|
|
32
|
+
getParentAccessIdByConceptAsync(childConceptId: number): Promise<AccessControlAPIResponse>;
|
|
33
|
+
assignSuperAdminByConceptAsync(request: SuperAdminWithConceptRequest): Promise<AccessControlAPIResponse>;
|
|
34
|
+
revokeSuperAdminByConceptAsync(request: SuperAdminWithConceptRequest): Promise<AccessControlAPIResponse>;
|
|
35
|
+
checkSuperAdminByConceptAsync(conceptId: number): Promise<AccessControlAPIResponse>;
|
|
36
|
+
setAccessInheritanceByConceptAsync(request: AccessInheritanceWithConceptRequest): Promise<AccessControlAPIResponse>;
|
|
37
|
+
getAccessInheritanceStatusByConceptAsync(conceptId: number, connectionTypeId?: number): Promise<AccessControlAPIResponse>;
|
|
38
|
+
}
|
|
39
|
+
export declare class APIClientService implements IAPIClientService {
|
|
40
|
+
private readonly baseUrl;
|
|
41
|
+
constructor(baseUrl?: string);
|
|
42
|
+
/**
|
|
43
|
+
* Perform a GET request and return typed response
|
|
44
|
+
*/
|
|
45
|
+
private getAsync;
|
|
46
|
+
/**
|
|
47
|
+
* Perform a POST request with JSON body and return typed response
|
|
48
|
+
*/
|
|
49
|
+
private postAsync;
|
|
50
|
+
/**
|
|
51
|
+
* Perform a DELETE request with optional JSON body and return typed response
|
|
52
|
+
*/
|
|
53
|
+
private deleteAsync;
|
|
54
|
+
/**
|
|
55
|
+
* Assign access to an entity
|
|
56
|
+
*/
|
|
57
|
+
assignAccessAsync(request: AccessRequest): Promise<AccessControlAPIResponse<AccessResult>>;
|
|
58
|
+
/**
|
|
59
|
+
* Check if an entity has access
|
|
60
|
+
*/
|
|
61
|
+
checkAccessAsync(request: AccessRequest): Promise<AccessControlAPIResponse<AccessResult>>;
|
|
62
|
+
/**
|
|
63
|
+
* Revoke access from an entity
|
|
64
|
+
*/
|
|
65
|
+
revokeAccessAsync(request: AccessRequest): Promise<AccessControlAPIResponse<AccessResult>>;
|
|
66
|
+
/**
|
|
67
|
+
* Assign access to multiple targets in bulk
|
|
68
|
+
*/
|
|
69
|
+
assignAccessBulkAsync(request: BulkAccessRequest): Promise<AccessControlAPIResponse<AccessResult[]>>;
|
|
70
|
+
/**
|
|
71
|
+
* Revoke access from multiple targets in bulk
|
|
72
|
+
*/
|
|
73
|
+
revokeAccessBulkAsync(request: BulkAccessRequest): Promise<AccessControlAPIResponse<AccessResult[]>>;
|
|
74
|
+
/**
|
|
75
|
+
* Check access for multiple targets in bulk
|
|
76
|
+
*/
|
|
77
|
+
checkAccessBulkAsync(request: BulkCheckAccessRequest): Promise<AccessControlAPIResponse<AccessResult[]>>;
|
|
78
|
+
/**
|
|
79
|
+
* Get all access entries for a specific accessId
|
|
80
|
+
*/
|
|
81
|
+
getAccessByIdAsync(accessId: number): Promise<AccessControlAPIResponse<AccessResult[]>>;
|
|
82
|
+
/**
|
|
83
|
+
* Set access inheritance for an access ID
|
|
84
|
+
*/
|
|
85
|
+
setAccessInheritanceAsync(request: AccessInheritanceRequest): Promise<AccessControlAPIResponse>;
|
|
86
|
+
/**
|
|
87
|
+
* Get access inheritance status
|
|
88
|
+
*/
|
|
89
|
+
getAccessInheritanceStatusAsync(accessId: number, connectionTypeId?: number): Promise<AccessControlAPIResponse>;
|
|
90
|
+
/**
|
|
91
|
+
* Assign super admin access
|
|
92
|
+
*/
|
|
93
|
+
assignSuperAdminAccessAsync(request: SuperAdminRequest): Promise<AccessControlAPIResponse>;
|
|
94
|
+
/**
|
|
95
|
+
* Revoke super admin access
|
|
96
|
+
*/
|
|
97
|
+
revokeSuperAdminAccessAsync(request: SuperAdminRequest): Promise<AccessControlAPIResponse>;
|
|
98
|
+
/**
|
|
99
|
+
* Check super admin status
|
|
100
|
+
*/
|
|
101
|
+
checkSuperAdminStatusAsync(accessId: number): Promise<AccessControlAPIResponse>;
|
|
102
|
+
/**
|
|
103
|
+
* Set parent access inheritance link
|
|
104
|
+
*/
|
|
105
|
+
setParentAccessInheritanceAsync(request: ParentAccessInheritanceRequest): Promise<AccessControlAPIResponse>;
|
|
106
|
+
/**
|
|
107
|
+
* Remove parent access inheritance link
|
|
108
|
+
*/
|
|
109
|
+
removeParentAccessInheritanceAsync(accessId: number, parentAccessId?: number): Promise<AccessControlAPIResponse>;
|
|
110
|
+
/**
|
|
111
|
+
* Check if parent access inheritance link exists
|
|
112
|
+
*/
|
|
113
|
+
hasParentAccessInheritanceAsync(accessId: number, parentAccessId?: number): Promise<AccessControlAPIResponse>;
|
|
114
|
+
/**
|
|
115
|
+
* Get the parent access ID for a given access ID
|
|
116
|
+
*/
|
|
117
|
+
getParentAccessIdAsync(accessId: number): Promise<AccessControlAPIResponse>;
|
|
118
|
+
/**
|
|
119
|
+
* Set parent access inheritance by concept IDs (server resolves conceptId → accessId)
|
|
120
|
+
*/
|
|
121
|
+
setParentAccessInheritanceByConceptAsync(request: ParentAccessInheritanceWithConceptRequest): Promise<AccessControlAPIResponse>;
|
|
122
|
+
/**
|
|
123
|
+
* Set parent access inheritance for multiple children with one parent (concept-based)
|
|
124
|
+
*/
|
|
125
|
+
setParentAccessInheritanceBulkByConceptAsync(request: BulkParentAccessInheritanceWithConceptRequest): Promise<AccessControlAPIResponse<BulkParentAccessInheritanceResult[]>>;
|
|
126
|
+
/**
|
|
127
|
+
* Remove parent access inheritance by concept IDs
|
|
128
|
+
*/
|
|
129
|
+
removeParentAccessInheritanceByConceptAsync(childConceptId: number, parentConceptId?: number): Promise<AccessControlAPIResponse>;
|
|
130
|
+
/**
|
|
131
|
+
* Remove parent access inheritance for multiple children (concept-based)
|
|
132
|
+
*/
|
|
133
|
+
removeParentAccessInheritanceBulkByConceptAsync(request: BulkParentAccessInheritanceWithConceptRequest): Promise<AccessControlAPIResponse<BulkParentAccessInheritanceResult[]>>;
|
|
134
|
+
/**
|
|
135
|
+
* Check if parent access inheritance exists by concept IDs
|
|
136
|
+
*/
|
|
137
|
+
hasParentAccessInheritanceByConceptAsync(childConceptId: number, parentConceptId?: number): Promise<AccessControlAPIResponse>;
|
|
138
|
+
/**
|
|
139
|
+
* Get the parent access ID by child concept ID
|
|
140
|
+
*/
|
|
141
|
+
getParentAccessIdByConceptAsync(childConceptId: number): Promise<AccessControlAPIResponse>;
|
|
142
|
+
/**
|
|
143
|
+
* Assign super admin by concept ID
|
|
144
|
+
*/
|
|
145
|
+
assignSuperAdminByConceptAsync(request: SuperAdminWithConceptRequest): Promise<AccessControlAPIResponse>;
|
|
146
|
+
/**
|
|
147
|
+
* Revoke super admin by concept ID
|
|
148
|
+
*/
|
|
149
|
+
revokeSuperAdminByConceptAsync(request: SuperAdminWithConceptRequest): Promise<AccessControlAPIResponse>;
|
|
150
|
+
/**
|
|
151
|
+
* Check super admin status by concept ID
|
|
152
|
+
*/
|
|
153
|
+
checkSuperAdminByConceptAsync(conceptId: number): Promise<AccessControlAPIResponse>;
|
|
154
|
+
/**
|
|
155
|
+
* Set access inheritance by concept ID
|
|
156
|
+
*/
|
|
157
|
+
setAccessInheritanceByConceptAsync(request: AccessInheritanceWithConceptRequest): Promise<AccessControlAPIResponse>;
|
|
158
|
+
/**
|
|
159
|
+
* Get access inheritance status by concept ID
|
|
160
|
+
*/
|
|
161
|
+
getAccessInheritanceStatusByConceptAsync(conceptId: number, connectionTypeId?: number): Promise<AccessControlAPIResponse>;
|
|
162
|
+
}
|
|
@@ -1,19 +1,77 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
/**
|
|
2
|
+
* CacheService
|
|
3
|
+
*
|
|
4
|
+
* Thread-safe in-memory cache for access checks with TTL-based expiration.
|
|
5
|
+
* Supports single and bulk queries with secondary indexes.
|
|
6
|
+
* Key format: "{accessId}:{permission}:{entityId}"
|
|
7
|
+
* Value: CacheEntry { value: boolean, expiresAt: number }
|
|
8
|
+
*
|
|
9
|
+
* This is the TypeScript equivalent of the C# CacheService class.
|
|
10
|
+
*/
|
|
11
|
+
export interface ICacheService {
|
|
12
|
+
get(accessId: number, permission: string, entityId?: number | null): boolean | null;
|
|
13
|
+
set(accessId: number, permission: string, entityId: number | null | undefined, hasAccess: boolean): void;
|
|
14
|
+
remove(accessId: number, permission: string, entityId?: number | null): void;
|
|
15
|
+
clear(): void;
|
|
16
|
+
getPermissionsByAccessAndEntity(accessId: number, entityId?: number | null): Map<string, boolean>;
|
|
17
|
+
getPermissionsByAccess(accessId: number): Map<string, boolean>;
|
|
18
|
+
getPermissionsByEntity(entityId: number): Map<string, boolean>;
|
|
19
|
+
getSuperAdmin(entityId: number): boolean | null;
|
|
20
|
+
setSuperAdmin(entityId: number, isSuperAdmin: boolean): void;
|
|
21
|
+
clearSuperAdminCache(): void;
|
|
22
|
+
}
|
|
23
|
+
export declare class CacheService implements ICacheService {
|
|
24
|
+
private readonly accessCache;
|
|
25
|
+
private readonly accessIndex;
|
|
26
|
+
private readonly entityIndex;
|
|
27
|
+
private static readonly superAdminCache;
|
|
28
|
+
private setCounter;
|
|
29
|
+
/**
|
|
30
|
+
* Generate a cache key from accessId, permission, and entityId
|
|
31
|
+
*/
|
|
32
|
+
private generateKey;
|
|
33
|
+
/**
|
|
34
|
+
* Get cached access. Returns true/false if present and not expired, null if not cached or expired.
|
|
35
|
+
*/
|
|
36
|
+
get(accessId: number, permission: string, entityId?: number | null): boolean | null;
|
|
37
|
+
/**
|
|
38
|
+
* Set or update cached access with TTL
|
|
39
|
+
*/
|
|
40
|
+
set(accessId: number, permission: string, entityId: number | null | undefined, hasAccess: boolean): void;
|
|
41
|
+
/**
|
|
42
|
+
* Remove a cached entry (e.g., after revoke)
|
|
43
|
+
*/
|
|
44
|
+
remove(accessId: number, permission: string, entityId?: number | null): void;
|
|
45
|
+
/**
|
|
46
|
+
* Clear all cached access entries
|
|
47
|
+
*/
|
|
48
|
+
clear(): void;
|
|
49
|
+
/**
|
|
50
|
+
* Sweep all expired entries from access cache, indexes, and super admin cache
|
|
51
|
+
*/
|
|
52
|
+
private sweepExpired;
|
|
53
|
+
/**
|
|
54
|
+
* Get all permissions for a specific accessId + entityId (excludes expired entries)
|
|
55
|
+
*/
|
|
56
|
+
getPermissionsByAccessAndEntity(accessId: number, entityId?: number | null): Map<string, boolean>;
|
|
57
|
+
/**
|
|
58
|
+
* Get all permissions for a specific accessId across all entities (excludes expired entries)
|
|
59
|
+
*/
|
|
60
|
+
getPermissionsByAccess(accessId: number): Map<string, boolean>;
|
|
61
|
+
/**
|
|
62
|
+
* Get all permissions for a specific entity across all accessIds (excludes expired entries)
|
|
63
|
+
*/
|
|
64
|
+
getPermissionsByEntity(entityId: number): Map<string, boolean>;
|
|
65
|
+
/**
|
|
66
|
+
* Get cached super admin status for an entity (returns null if expired or not cached)
|
|
67
|
+
*/
|
|
68
|
+
getSuperAdmin(entityId: number): boolean | null;
|
|
69
|
+
/**
|
|
70
|
+
* Set super admin status for an entity with TTL
|
|
71
|
+
*/
|
|
72
|
+
setSuperAdmin(entityId: number, isSuperAdmin: boolean): void;
|
|
73
|
+
/**
|
|
74
|
+
* Clear the super admin cache
|
|
75
|
+
*/
|
|
76
|
+
clearSuperAdminCache(): void;
|
|
19
77
|
}
|