@mondaydotcomorg/monday-authorization 3.7.0-feat-shaime-support-entity-attributes-4-49e1de0 → 3.7.3
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 +7 -1
- package/dist/authorization-attributes-ms-service.d.ts +20 -40
- package/dist/authorization-attributes-ms-service.d.ts.map +1 -1
- package/dist/authorization-attributes-ms-service.js +48 -103
- package/dist/authorization-attributes-service.d.ts +12 -10
- package/dist/authorization-attributes-service.d.ts.map +1 -1
- package/dist/authorization-attributes-service.js +17 -15
- package/dist/authorization-attributes-sns-service.d.ts +37 -44
- package/dist/authorization-attributes-sns-service.d.ts.map +1 -1
- package/dist/authorization-attributes-sns-service.js +53 -90
- package/dist/authorization-service.d.ts +0 -1
- package/dist/authorization-service.d.ts.map +1 -1
- package/dist/authorization-service.js +2 -22
- package/dist/base-attribute-assignment.d.ts +6 -7
- package/dist/base-attribute-assignment.d.ts.map +1 -1
- package/dist/base-attribute-assignment.js +5 -7
- package/dist/base-authorization-attributes-service.d.ts +32 -0
- package/dist/base-authorization-attributes-service.d.ts.map +1 -0
- package/dist/base-authorization-attributes-service.js +63 -0
- package/dist/entity-attribute-assignment.d.ts +4 -8
- package/dist/entity-attribute-assignment.d.ts.map +1 -1
- package/dist/entity-attribute-assignment.js +3 -4
- package/dist/esm/authorization-attributes-ms-service.d.ts +20 -40
- package/dist/esm/authorization-attributes-ms-service.d.ts.map +1 -1
- package/dist/esm/authorization-attributes-ms-service.mjs +48 -103
- package/dist/esm/authorization-attributes-service.d.ts +12 -10
- package/dist/esm/authorization-attributes-service.d.ts.map +1 -1
- package/dist/esm/authorization-attributes-service.mjs +17 -15
- package/dist/esm/authorization-attributes-sns-service.d.ts +37 -44
- package/dist/esm/authorization-attributes-sns-service.d.ts.map +1 -1
- package/dist/esm/authorization-attributes-sns-service.mjs +53 -90
- package/dist/esm/authorization-service.d.ts +0 -1
- package/dist/esm/authorization-service.d.ts.map +1 -1
- package/dist/esm/authorization-service.mjs +3 -23
- package/dist/esm/base-attribute-assignment.d.ts +6 -7
- package/dist/esm/base-attribute-assignment.d.ts.map +1 -1
- package/dist/esm/base-attribute-assignment.mjs +5 -7
- package/dist/esm/base-authorization-attributes-service.d.ts +32 -0
- package/dist/esm/base-authorization-attributes-service.d.ts.map +1 -0
- package/dist/esm/base-authorization-attributes-service.mjs +61 -0
- package/dist/esm/entity-attribute-assignment.d.ts +4 -8
- package/dist/esm/entity-attribute-assignment.d.ts.map +1 -1
- package/dist/esm/entity-attribute-assignment.mjs +3 -4
- package/dist/esm/index.d.ts +6 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.mjs +6 -0
- package/dist/esm/resource-attribute-assignment.d.ts +3 -7
- package/dist/esm/resource-attribute-assignment.d.ts.map +1 -1
- package/dist/esm/resource-attribute-assignment.mjs +8 -2
- package/dist/esm/resource-attributes-constants.d.ts +13 -10
- package/dist/esm/resource-attributes-constants.d.ts.map +1 -1
- package/dist/esm/resource-attributes-constants.mjs +5 -2
- package/dist/esm/testKit/index.d.ts +4 -4
- package/dist/esm/testKit/index.d.ts.map +1 -1
- package/dist/esm/types/authorization-attributes-contracts.d.ts +7 -21
- package/dist/esm/types/authorization-attributes-contracts.d.ts.map +1 -1
- package/dist/esm/types/general.d.ts +4 -3
- package/dist/esm/types/general.d.ts.map +1 -1
- package/dist/esm/utils/assignment-schema.d.ts +51 -0
- package/dist/esm/utils/assignment-schema.d.ts.map +1 -0
- package/dist/esm/utils/assignment-schema.mjs +54 -0
- package/dist/esm/utils/resource-schema.d.ts +9 -0
- package/dist/esm/utils/resource-schema.d.ts.map +1 -0
- package/dist/esm/utils/resource-schema.mjs +16 -0
- package/dist/esm/utils/validation.d.ts +11 -28
- package/dist/esm/utils/validation.d.ts.map +1 -1
- package/dist/esm/utils/validation.mjs +61 -118
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -0
- package/dist/resource-attribute-assignment.d.ts +3 -7
- package/dist/resource-attribute-assignment.d.ts.map +1 -1
- package/dist/resource-attribute-assignment.js +8 -2
- package/dist/resource-attributes-constants.d.ts +13 -10
- package/dist/resource-attributes-constants.d.ts.map +1 -1
- package/dist/resource-attributes-constants.js +5 -2
- package/dist/testKit/index.d.ts +4 -4
- package/dist/testKit/index.d.ts.map +1 -1
- package/dist/types/authorization-attributes-contracts.d.ts +7 -21
- package/dist/types/authorization-attributes-contracts.d.ts.map +1 -1
- package/dist/types/general.d.ts +4 -3
- package/dist/types/general.d.ts.map +1 -1
- package/dist/utils/assignment-schema.d.ts +51 -0
- package/dist/utils/assignment-schema.d.ts.map +1 -0
- package/dist/utils/assignment-schema.js +63 -0
- package/dist/utils/resource-schema.d.ts +9 -0
- package/dist/utils/resource-schema.d.ts.map +1 -0
- package/dist/utils/resource-schema.js +22 -0
- package/dist/utils/validation.d.ts +11 -28
- package/dist/utils/validation.d.ts.map +1 -1
- package/dist/utils/validation.js +61 -118
- package/package.json +2 -3
- package/src/authorization-attributes-ms-service.ts +92 -154
- package/src/authorization-attributes-service.ts +18 -16
- package/src/authorization-attributes-sns-service.ts +132 -131
- package/src/authorization-service.ts +3 -28
- package/src/base-attribute-assignment.ts +10 -26
- package/src/base-authorization-attributes-service.ts +90 -0
- package/src/entity-attribute-assignment.ts +7 -6
- package/src/index.ts +17 -0
- package/src/resource-attribute-assignment.ts +13 -10
- package/src/resource-attributes-constants.ts +5 -2
- package/src/testKit/index.ts +5 -5
- package/src/types/authorization-attributes-contracts.ts +7 -27
- package/src/types/general.ts +4 -3
- package/src/utils/assignment-schema.ts +56 -0
- package/src/utils/resource-schema.ts +16 -0
- package/src/utils/validation.ts +90 -137
- package/dist/esm/types/authorization-attributes-service.interface.d.ts +0 -57
- package/dist/esm/types/authorization-attributes-service.interface.d.ts.map +0 -1
- package/dist/esm/types/authorization-attributes-service.interface.mjs +0 -1
- package/dist/types/authorization-attributes-service.interface.d.ts +0 -57
- package/dist/types/authorization-attributes-service.interface.d.ts.map +0 -1
- package/dist/types/authorization-attributes-service.interface.js +0 -1
- package/src/types/authorization-attributes-service.interface.ts +0 -101
|
@@ -2,12 +2,10 @@ import { Api } from '@mondaydotcomorg/trident-backend-api';
|
|
|
2
2
|
import { signAuthorizationHeader } from '@mondaydotcomorg/monday-jwt';
|
|
3
3
|
import { ResourceAttributeAssignment } from './resource-attribute-assignment.mjs';
|
|
4
4
|
import { EntityAttributeAssignment } from './entity-attribute-assignment.mjs';
|
|
5
|
-
import { AttributeOperation } from './types/authorization-attributes-contracts.mjs';
|
|
6
|
-
import { ArgumentError } from './errors/argument-error.mjs';
|
|
7
5
|
import { logger, AuthorizationInternalService } from './authorization-internal-service.mjs';
|
|
8
6
|
import { getAttributionsFromApi } from './attributions-service.mjs';
|
|
9
7
|
import { APP_NAME } from './constants.mjs';
|
|
10
|
-
import {
|
|
8
|
+
import { BaseAuthorizationAttributesService } from './base-authorization-attributes-service.mjs';
|
|
11
9
|
|
|
12
10
|
const INTERNAL_APP_NAME = 'internal_ms';
|
|
13
11
|
const UPSERT_RESOURCE_ATTRIBUTES_PATH = '/attributes/{accountId}/resource';
|
|
@@ -18,123 +16,79 @@ const DELETE_ENTITY_ATTRIBUTES_PATH = '/attributes/{accountId}/entity/{entityTyp
|
|
|
18
16
|
* Service class for managing resource attributes in the authorization microservice.
|
|
19
17
|
* Provides synchronous HTTP operations to create/update and delete attributes on resources.
|
|
20
18
|
*/
|
|
21
|
-
class AuthorizationAttributesMsService {
|
|
19
|
+
class AuthorizationAttributesMsService extends BaseAuthorizationAttributesService {
|
|
22
20
|
static LOG_TAG = 'authorization_attributes_ms';
|
|
23
|
-
static httpClient = Api.getPart('httpClient')
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
*/
|
|
33
|
-
async upsertResourceAttributes(accountId, resourceAttributeAssignments, _appName, _callerActionIdentifier) {
|
|
34
|
-
return AuthorizationAttributesMsService.executeUpsertRequest(accountId, resourceAttributeAssignments, UPSERT_RESOURCE_ATTRIBUTES_PATH, 'resourceAttributeAssignments', ResourceAttributeAssignment, 'resource', 'upsertResourceAttributes');
|
|
21
|
+
static httpClient = Api.getPart('httpClient');
|
|
22
|
+
constructor() {
|
|
23
|
+
super();
|
|
24
|
+
if (!AuthorizationAttributesMsService.httpClient) {
|
|
25
|
+
AuthorizationAttributesMsService.httpClient = Api.getPart('httpClient');
|
|
26
|
+
if (!AuthorizationAttributesMsService.httpClient) {
|
|
27
|
+
throw new Error('HTTP client is not initialized');
|
|
28
|
+
}
|
|
29
|
+
}
|
|
35
30
|
}
|
|
36
31
|
/**
|
|
37
|
-
* Deletes specific
|
|
32
|
+
* Deletes a specific attribute from a resource synchronously.
|
|
38
33
|
* @param accountId The account ID
|
|
39
34
|
* @param resource Object with resourceType (string) and resourceId (number)
|
|
40
|
-
* @param
|
|
41
|
-
* @returns Promise<
|
|
35
|
+
* @param attributeKey Attribute key string to delete
|
|
36
|
+
* @returns Promise<ResourceAttributeDeleteOperation>
|
|
42
37
|
*/
|
|
43
|
-
async deleteResourceAttributes(accountId, resource,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return AuthorizationAttributesMsService.executeDeleteRequest(accountId, DELETE_RESOURCE_ATTRIBUTES_PATH, {
|
|
38
|
+
async deleteResourceAttributes(accountId, resource, attributeKey, _appName, _callerActionIdentifier) {
|
|
39
|
+
const operation = await super.deleteResourceAttributes(accountId, resource, attributeKey);
|
|
40
|
+
await AuthorizationAttributesMsService.executeDeleteRequest(accountId, DELETE_RESOURCE_ATTRIBUTES_PATH, {
|
|
47
41
|
resourceType: resource.type,
|
|
48
42
|
resourceId: resource.id,
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Creates or updates entity attributes synchronously.
|
|
53
|
-
* @param accountId The account ID
|
|
54
|
-
* @param entityAttributeAssignments Array of EntityAttributeAssignment objects
|
|
55
|
-
* @returns Promise<void>
|
|
56
|
-
*/
|
|
57
|
-
async upsertEntityAttributes(accountId, entityAttributeAssignments, _appName, _callerActionIdentifier) {
|
|
58
|
-
return AuthorizationAttributesMsService.executeUpsertRequest(accountId, entityAttributeAssignments, UPSERT_ENTITY_ATTRIBUTES_PATH, 'entityAttributeAssignments', EntityAttributeAssignment, 'entity', 'upsertEntityAttributesSync');
|
|
43
|
+
}, [attributeKey], 'resource', 'deleteResourceAttributesSync');
|
|
44
|
+
return operation;
|
|
59
45
|
}
|
|
60
46
|
/**
|
|
61
|
-
* Deletes specific
|
|
47
|
+
* Deletes a specific attribute from an entity synchronously.
|
|
62
48
|
* @param accountId The account ID
|
|
63
49
|
* @param entityType The entity type
|
|
64
50
|
* @param entityId The entity ID
|
|
65
|
-
* @param
|
|
66
|
-
* @returns Promise<
|
|
51
|
+
* @param attributeKey Attribute key string to delete
|
|
52
|
+
* @returns Promise<EntityAttributeDeleteOperation>
|
|
67
53
|
*/
|
|
68
|
-
async deleteEntityAttributes(accountId, entityType, entityId,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
ValidationUtils.validateInteger(entityId);
|
|
73
|
-
return AuthorizationAttributesMsService.executeDeleteRequest(accountId, DELETE_ENTITY_ATTRIBUTES_PATH, {
|
|
54
|
+
async deleteEntityAttributes(accountId, entityType, entityId, attributeKey, _appName, _callerActionIdentifier) {
|
|
55
|
+
const operation = await super.deleteEntityAttributes(accountId, entityType, entityId, attributeKey);
|
|
56
|
+
await AuthorizationAttributesMsService.executeDeleteRequest(accountId, DELETE_ENTITY_ATTRIBUTES_PATH, {
|
|
74
57
|
entityType,
|
|
75
58
|
entityId,
|
|
76
|
-
},
|
|
59
|
+
}, [attributeKey], 'entity', 'deleteEntityAttributesSync');
|
|
60
|
+
return operation;
|
|
77
61
|
}
|
|
78
62
|
/**
|
|
79
|
-
* Updates resource
|
|
80
|
-
* Note: MS service does not support batch operations directly.
|
|
81
|
-
* This method processes operations sequentially using upsert/delete methods.
|
|
63
|
+
* Updates a resource attribute (single operation - upsert only).
|
|
82
64
|
* @param accountId The account ID
|
|
83
65
|
* @param appName App name (required for interface compatibility, but not used in MS service)
|
|
84
66
|
* @param callerActionIdentifier Action identifier (required for interface compatibility, but not used in MS service)
|
|
85
|
-
* @param
|
|
86
|
-
* @returns Promise<
|
|
67
|
+
* @param resourceAttributeOperation Operation to perform (must be UPSERT)
|
|
68
|
+
* @returns Promise<ResourceAttributeUpsertOperation> Processed operation
|
|
87
69
|
*/
|
|
88
|
-
async updateResourceAttributes(accountId, _appName, _callerActionIdentifier,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
await this.upsertResourceAttributes(accountId, [
|
|
96
|
-
new ResourceAttributeAssignment(operation.resourceId, operation.resourceType, operation.key, operation.value || ''),
|
|
97
|
-
]);
|
|
98
|
-
processedOperations.push(operation);
|
|
99
|
-
}
|
|
100
|
-
else if (operation.operationType === AttributeOperation.DELETE) {
|
|
101
|
-
if (!operation.resourceId) {
|
|
102
|
-
throw new ArgumentError('resourceId is required for delete operation');
|
|
103
|
-
}
|
|
104
|
-
await this.deleteResourceAttributes(accountId, {
|
|
105
|
-
type: operation.resourceType,
|
|
106
|
-
id: operation.resourceId,
|
|
107
|
-
}, [operation.key]);
|
|
108
|
-
processedOperations.push(operation);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
return processedOperations;
|
|
70
|
+
async updateResourceAttributes(accountId, _appName, _callerActionIdentifier, resourceAttributeOperation) {
|
|
71
|
+
await super.updateResourceAttributes(accountId, _appName, _callerActionIdentifier, resourceAttributeOperation);
|
|
72
|
+
await AuthorizationAttributesMsService.executeUpsertRequest(accountId, [
|
|
73
|
+
new ResourceAttributeAssignment(resourceAttributeOperation.resourceId, resourceAttributeOperation.resourceType, resourceAttributeOperation.key, resourceAttributeOperation.value),
|
|
74
|
+
], UPSERT_RESOURCE_ATTRIBUTES_PATH, 'resourceAttributeAssignments', 'resource', 'updateResourceAttributesSync');
|
|
75
|
+
return resourceAttributeOperation;
|
|
112
76
|
}
|
|
113
77
|
/**
|
|
114
|
-
* Updates entity
|
|
115
|
-
* Note: MS service does not support batch operations directly.
|
|
116
|
-
* This method processes operations sequentially using upsert/delete methods.
|
|
78
|
+
* Updates an entity attribute (single operation - upsert only).
|
|
117
79
|
* @param accountId The account ID
|
|
118
80
|
* @param appName App name (required for interface compatibility, but not used in MS service)
|
|
119
81
|
* @param callerActionIdentifier Action identifier (required for interface compatibility, but not used in MS service)
|
|
120
|
-
* @param
|
|
121
|
-
* @returns Promise<
|
|
82
|
+
* @param entityAttributeOperation Operation to perform (must be UPSERT)
|
|
83
|
+
* @returns Promise<EntityAttributeUpsertOperation> Processed operation
|
|
122
84
|
*/
|
|
123
|
-
async updateEntityAttributes(accountId, _appName, _callerActionIdentifier,
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
processedOperations.push(operation);
|
|
131
|
-
}
|
|
132
|
-
else if (operation.operationType === 'delete') {
|
|
133
|
-
await this.deleteEntityAttributes(accountId, operation.entityType, operation.entityId, [operation.key]);
|
|
134
|
-
processedOperations.push(operation);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
return processedOperations;
|
|
85
|
+
async updateEntityAttributes(accountId, _appName, _callerActionIdentifier, entityAttributeOperation) {
|
|
86
|
+
// Validate before processing
|
|
87
|
+
await super.updateEntityAttributes(accountId, _appName, _callerActionIdentifier, entityAttributeOperation);
|
|
88
|
+
await AuthorizationAttributesMsService.executeUpsertRequest(accountId, [
|
|
89
|
+
new EntityAttributeAssignment(entityAttributeOperation.entityId, entityAttributeOperation.entityType, entityAttributeOperation.key, entityAttributeOperation.value),
|
|
90
|
+
], UPSERT_ENTITY_ATTRIBUTES_PATH, 'entityAttributeAssignments', 'entity', 'upsertEntityAttributesSync');
|
|
91
|
+
return entityAttributeOperation;
|
|
138
92
|
}
|
|
139
93
|
/**
|
|
140
94
|
* Replaces path template parameters with actual values
|
|
@@ -152,10 +106,7 @@ class AuthorizationAttributesMsService {
|
|
|
152
106
|
/**
|
|
153
107
|
* Generic helper for executing delete requests
|
|
154
108
|
*/
|
|
155
|
-
static async executeDeleteRequest(accountId, pathTemplate, pathParams, keys, logPrefix, methodName
|
|
156
|
-
// Validate inputs
|
|
157
|
-
ValidationUtils.validateInteger(accountId);
|
|
158
|
-
ValidationUtils.validateStringArray(keys);
|
|
109
|
+
static async executeDeleteRequest(accountId, pathTemplate, pathParams, keys, logPrefix, methodName) {
|
|
159
110
|
if (!keys.length) {
|
|
160
111
|
logger.warn({ tag: this.LOG_TAG, accountId, ...pathParams }, `${methodName} called with empty keys array`);
|
|
161
112
|
return;
|
|
@@ -188,7 +139,6 @@ class AuthorizationAttributesMsService {
|
|
|
188
139
|
method: methodName,
|
|
189
140
|
accountId,
|
|
190
141
|
...pathParams,
|
|
191
|
-
...context,
|
|
192
142
|
error: err instanceof Error ? err.message : String(err),
|
|
193
143
|
}, `Failed in ${methodName}`);
|
|
194
144
|
throw err;
|
|
@@ -242,12 +192,7 @@ class AuthorizationAttributesMsService {
|
|
|
242
192
|
/**
|
|
243
193
|
* Generic helper for executing upsert requests
|
|
244
194
|
*/
|
|
245
|
-
static async executeUpsertRequest(accountId, assignments, pathTemplate, requestBodyKey,
|
|
246
|
-
ValidationUtils.validateInteger(accountId);
|
|
247
|
-
ValidationUtils.validateArrayTypeOf(assignments, assignmentClass);
|
|
248
|
-
if (!assignments.length) {
|
|
249
|
-
return;
|
|
250
|
-
}
|
|
195
|
+
static async executeUpsertRequest(accountId, assignments, pathTemplate, requestBodyKey, logPrefix, methodName) {
|
|
251
196
|
const assignmentDto = assignments.map(assignment => assignment.toDataTransferObject());
|
|
252
197
|
const requestBody = requestBodyKey === 'resourceAttributeAssignments'
|
|
253
198
|
? { resourceAttributeAssignments: assignmentDto }
|
|
@@ -1,29 +1,31 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseAuthorizationAttributesService as IAuthorizationAttributesService } from './base-authorization-attributes-service';
|
|
2
2
|
/**
|
|
3
3
|
* Main service class for managing resource and entity attributes.
|
|
4
|
-
* Provides access to both direct
|
|
4
|
+
* Provides access to both HTTP (direct microservice) and SNS (async messaging) operations.
|
|
5
5
|
*
|
|
6
6
|
* @example
|
|
7
7
|
* const service = new AuthorizationAttributesService();
|
|
8
8
|
*
|
|
9
|
-
* // Use direct
|
|
10
|
-
* await service.
|
|
9
|
+
* // Use HTTP operations (direct calls to microservice)
|
|
10
|
+
* await service.http().updateResourceAttributes(accountId, appName, actionId, operation);
|
|
11
11
|
*
|
|
12
|
-
* // Use SNS operations
|
|
13
|
-
* await service.sns().
|
|
12
|
+
* // Use SNS operations (async messaging, then to microservice)
|
|
13
|
+
* await service.sns().updateResourceAttributes(accountId, appName, actionId, operation);
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
16
|
export declare class AuthorizationAttributesService {
|
|
17
|
-
private
|
|
18
|
-
private
|
|
17
|
+
private httpService;
|
|
18
|
+
private snsService;
|
|
19
19
|
/**
|
|
20
|
-
* Gets the
|
|
20
|
+
* Gets the HTTP service instance.
|
|
21
|
+
* Performs direct HTTP calls to the authorization microservice.
|
|
21
22
|
* Initializes the service on first access (lazy initialization).
|
|
22
23
|
* @returns IAuthorizationAttributesService instance
|
|
23
24
|
*/
|
|
24
|
-
|
|
25
|
+
http(): IAuthorizationAttributesService;
|
|
25
26
|
/**
|
|
26
27
|
* Gets the SNS service instance.
|
|
28
|
+
* Sends operations via SNS messaging, which are then processed by the microservice asynchronously.
|
|
27
29
|
* Initializes the service on first access (lazy initialization).
|
|
28
30
|
* @returns IAuthorizationAttributesService instance
|
|
29
31
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization-attributes-service.d.ts","sourceRoot":"","sources":["../../src/authorization-attributes-service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"authorization-attributes-service.d.ts","sourceRoot":"","sources":["../../src/authorization-attributes-service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kCAAkC,IAAI,+BAA+B,EAAE,MAAM,yCAAyC,CAAC;AAEhI;;;;;;;;;;;;;GAaG;AACH,qBAAa,8BAA8B;IACzC,OAAO,CAAC,WAAW,CAAiD;IACpE,OAAO,CAAC,UAAU,CAAkD;IAEpE;;;;;OAKG;IACH,IAAI,IAAI,+BAA+B;IAOvC;;;;;OAKG;IACH,GAAG,IAAI,+BAA+B;CAMvC"}
|
|
@@ -3,42 +3,44 @@ import { AuthorizationAttributesSnsService } from './authorization-attributes-sn
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Main service class for managing resource and entity attributes.
|
|
6
|
-
* Provides access to both direct
|
|
6
|
+
* Provides access to both HTTP (direct microservice) and SNS (async messaging) operations.
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
9
9
|
* const service = new AuthorizationAttributesService();
|
|
10
10
|
*
|
|
11
|
-
* // Use direct
|
|
12
|
-
* await service.
|
|
11
|
+
* // Use HTTP operations (direct calls to microservice)
|
|
12
|
+
* await service.http().updateResourceAttributes(accountId, appName, actionId, operation);
|
|
13
13
|
*
|
|
14
|
-
* // Use SNS operations
|
|
15
|
-
* await service.sns().
|
|
14
|
+
* // Use SNS operations (async messaging, then to microservice)
|
|
15
|
+
* await service.sns().updateResourceAttributes(accountId, appName, actionId, operation);
|
|
16
16
|
* ```
|
|
17
17
|
*/
|
|
18
18
|
class AuthorizationAttributesService {
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
httpService = null;
|
|
20
|
+
snsService = null;
|
|
21
21
|
/**
|
|
22
|
-
* Gets the
|
|
22
|
+
* Gets the HTTP service instance.
|
|
23
|
+
* Performs direct HTTP calls to the authorization microservice.
|
|
23
24
|
* Initializes the service on first access (lazy initialization).
|
|
24
25
|
* @returns IAuthorizationAttributesService instance
|
|
25
26
|
*/
|
|
26
|
-
|
|
27
|
-
if (this.
|
|
28
|
-
this.
|
|
27
|
+
http() {
|
|
28
|
+
if (this.httpService === null) {
|
|
29
|
+
this.httpService = new AuthorizationAttributesMsService();
|
|
29
30
|
}
|
|
30
|
-
return this.
|
|
31
|
+
return this.httpService;
|
|
31
32
|
}
|
|
32
33
|
/**
|
|
33
34
|
* Gets the SNS service instance.
|
|
35
|
+
* Sends operations via SNS messaging, which are then processed by the microservice asynchronously.
|
|
34
36
|
* Initializes the service on first access (lazy initialization).
|
|
35
37
|
* @returns IAuthorizationAttributesService instance
|
|
36
38
|
*/
|
|
37
39
|
sns() {
|
|
38
|
-
if (this.
|
|
39
|
-
this.
|
|
40
|
+
if (this.snsService === null) {
|
|
41
|
+
this.snsService = new AuthorizationAttributesSnsService();
|
|
40
42
|
}
|
|
41
|
-
return this.
|
|
43
|
+
return this.snsService;
|
|
42
44
|
}
|
|
43
45
|
}
|
|
44
46
|
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { EntityAttributeAssignment } from './entity-attribute-assignment';
|
|
1
|
+
import { ResourceAttributeUpsertOperation, EntityAttributeUpsertOperation, EntityAttributeDeleteOperation, ResourceAttributeDeleteOperation } from './types/authorization-attributes-contracts';
|
|
3
2
|
import { Resource } from './types/general';
|
|
4
|
-
import {
|
|
3
|
+
import { BaseAuthorizationAttributesService } from './base-authorization-attributes-service';
|
|
5
4
|
import { EntityType } from './entity-attributes-constants';
|
|
6
5
|
/**
|
|
7
6
|
* Service class for managing resource attributes asynchronously via SNS.
|
|
8
7
|
* Provides asynchronous operations to create/update and delete attributes on resources.
|
|
9
8
|
*/
|
|
10
|
-
export declare class AuthorizationAttributesSnsService
|
|
9
|
+
export declare class AuthorizationAttributesSnsService extends BaseAuthorizationAttributesService {
|
|
11
10
|
private static LOG_TAG;
|
|
12
11
|
private resourceSnsArn;
|
|
13
12
|
private entitySnsArn;
|
|
@@ -16,66 +15,60 @@ export declare class AuthorizationAttributesSnsService implements AuthorizationA
|
|
|
16
15
|
*/
|
|
17
16
|
constructor();
|
|
18
17
|
/**
|
|
19
|
-
* Async function to
|
|
20
|
-
* Sends the
|
|
18
|
+
* Async function to delete a resource attribute using SNS.
|
|
19
|
+
* Sends the delete request to SNS and returns before the change actually took place.
|
|
21
20
|
* @param accountId The account ID
|
|
22
|
-
* @param appName App name of the calling app
|
|
23
|
-
* @param callerActionIdentifier Action identifier
|
|
24
|
-
* @param resourceAttributeAssignments Array of resource attribute assignments to upsert
|
|
25
|
-
* @return Promise with array of sent operations
|
|
26
|
-
*/
|
|
27
|
-
upsertResourceAttributes(accountId: number, resourceAttributeAssignments: ResourceAttributeAssignment[], appName?: string, callerActionIdentifier?: string): Promise<ResourceAttributeOperation[]>;
|
|
28
|
-
/**
|
|
29
|
-
* Async function to delete resource attributes using SNS.
|
|
30
|
-
* Sends the updates request to SNS and returns before the change actually took place.
|
|
31
|
-
* @param accountId The account ID
|
|
32
|
-
* @param appName App name of the calling app
|
|
33
|
-
* @param callerActionIdentifier Action identifier
|
|
34
21
|
* @param resource The resource (resourceType, resourceId)
|
|
35
|
-
* @param
|
|
36
|
-
* @return Promise with array of sent operations
|
|
37
|
-
*/
|
|
38
|
-
deleteResourceAttributes(accountId: number, resource: Resource, attributeKeys: string[], appName?: string, callerActionIdentifier?: string): Promise<ResourceAttributeOperation[]>;
|
|
39
|
-
/**
|
|
40
|
-
* Async function to upsert entity attributes using SNS.
|
|
41
|
-
* Sends the updates request to SNS and returns before the change actually took place.
|
|
42
|
-
* @param accountId The account ID
|
|
22
|
+
* @param attributeKey Attribute key to delete
|
|
43
23
|
* @param appName App name of the calling app
|
|
44
24
|
* @param callerActionIdentifier Action identifier
|
|
45
|
-
* @
|
|
46
|
-
* @return Promise with array of sent operations
|
|
25
|
+
* @return Promise with sent operation
|
|
47
26
|
*/
|
|
48
|
-
|
|
27
|
+
deleteResourceAttributes(accountId: number, resource: Resource, attributeKey: string, appName?: string, callerActionIdentifier?: string): Promise<ResourceAttributeDeleteOperation>;
|
|
49
28
|
/**
|
|
50
|
-
* Async function to delete entity
|
|
51
|
-
* Sends the
|
|
29
|
+
* Async function to delete an entity attribute using SNS.
|
|
30
|
+
* Sends the delete request to SNS and returns before the change actually took place.
|
|
52
31
|
* @param accountId The account ID
|
|
53
|
-
* @param appName App name of the calling app
|
|
54
|
-
* @param callerActionIdentifier Action identifier
|
|
55
32
|
* @param entityType The entity type
|
|
56
33
|
* @param entityId The entity ID
|
|
57
|
-
* @param
|
|
58
|
-
* @
|
|
34
|
+
* @param attributeKey Attribute key to delete
|
|
35
|
+
* @param appName App name of the calling app
|
|
36
|
+
* @param callerActionIdentifier Action identifier
|
|
37
|
+
* @return Promise with sent operation
|
|
59
38
|
*/
|
|
60
|
-
deleteEntityAttributes(accountId: number, entityType: EntityType
|
|
39
|
+
deleteEntityAttributes(accountId: number, entityType: EntityType, entityId: number, attributeKey: string, appName?: string, callerActionIdentifier?: string): Promise<EntityAttributeDeleteOperation>;
|
|
61
40
|
/**
|
|
62
|
-
* Async function, this function only send the
|
|
41
|
+
* Async function, this function only send the update request to SNS and return before the change actually took place
|
|
63
42
|
* @param accountId
|
|
64
43
|
* @param appName - App name of the calling app
|
|
65
44
|
* @param callerActionIdentifier - action identifier
|
|
66
|
-
* @param
|
|
67
|
-
* @return {Promise<
|
|
45
|
+
* @param resourceAttributeOperation - Operation to do on resource attribute.
|
|
46
|
+
* @return {Promise<ResourceAttributeUpsertOperation>} Sent operation
|
|
68
47
|
* */
|
|
69
|
-
updateResourceAttributes(accountId: number, appName: string, callerActionIdentifier: string,
|
|
48
|
+
updateResourceAttributes(accountId: number, appName: string, callerActionIdentifier: string, resourceAttributeOperation: ResourceAttributeUpsertOperation): Promise<ResourceAttributeUpsertOperation>;
|
|
70
49
|
/**
|
|
71
|
-
* Async function, this function only send the
|
|
50
|
+
* Async function, this function only send the update request to SNS and return before the change actually took place
|
|
72
51
|
* @param accountId
|
|
73
52
|
* @param appName - App name of the calling app
|
|
74
53
|
* @param callerActionIdentifier - action identifier
|
|
75
|
-
* @param
|
|
76
|
-
* @return {Promise<
|
|
54
|
+
* @param entityAttributeOperation - Operation to do on entity attribute.
|
|
55
|
+
* @return {Promise<EntityAttributeUpsertOperation>} Sent operation
|
|
77
56
|
* */
|
|
78
|
-
updateEntityAttributes(accountId: number, appName: string, callerActionIdentifier: string,
|
|
57
|
+
updateEntityAttributes(accountId: number, appName: string, callerActionIdentifier: string, entityAttributeOperation: EntityAttributeUpsertOperation): Promise<EntityAttributeUpsertOperation>;
|
|
58
|
+
/**
|
|
59
|
+
* Base function to send attribute operations to SNS.
|
|
60
|
+
* Chunks operations and sends them in parallel.
|
|
61
|
+
* @param topicArn The SNS topic ARN to send messages to
|
|
62
|
+
* @param accountId The account ID
|
|
63
|
+
* @param appName App name of the calling app
|
|
64
|
+
* @param callerActionIdentifier Action identifier
|
|
65
|
+
* @param operations Array of operations to send
|
|
66
|
+
* @param chunkSize Maximum number of operations per message
|
|
67
|
+
* @param messageKind The kind of message being sent
|
|
68
|
+
* @param errorLogMessage Error message to log if sending fails
|
|
69
|
+
* @return Promise with array of sent operations
|
|
70
|
+
*/
|
|
71
|
+
private sendOperationsToSns;
|
|
79
72
|
private sendSingleSnsMessage;
|
|
80
73
|
private static getSnsTopicArn;
|
|
81
74
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization-attributes-sns-service.d.ts","sourceRoot":"","sources":["../../src/authorization-attributes-sns-service.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"authorization-attributes-sns-service.d.ts","sourceRoot":"","sources":["../../src/authorization-attributes-sns-service.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,gCAAgC,EAChC,8BAA8B,EAC9B,8BAA8B,EAC9B,gCAAgC,EACjC,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAa3C,OAAO,EAAE,kCAAkC,EAAE,MAAM,yCAAyC,CAAC;AAC7F,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAG3D;;;GAGG;AACH,qBAAa,iCAAkC,SAAQ,kCAAkC;IACvF,OAAO,CAAC,MAAM,CAAC,OAAO,CAA8B;IACpD,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,YAAY,CAAS;IAE7B;;OAEG;;IAOH;;;;;;;;;OASG;IACG,wBAAwB,CAC5B,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE,MAAM,EAChB,sBAAsB,CAAC,EAAE,MAAM,GAC9B,OAAO,CAAC,gCAAgC,CAAC;IAsB5C;;;;;;;;;;OAUG;IACG,sBAAsB,CAC1B,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE,MAAM,EAChB,sBAAsB,CAAC,EAAE,MAAM,GAC9B,OAAO,CAAC,8BAA8B,CAAC;IAuB1C;;;;;;;UAOM;IACA,wBAAwB,CAC5B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,sBAAsB,EAAE,MAAM,EAC9B,0BAA0B,EAAE,gCAAgC,GAC3D,OAAO,CAAC,gCAAgC,CAAC;IAe5C;;;;;;;UAOM;IACA,sBAAsB,CAC1B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,sBAAsB,EAAE,MAAM,EAC9B,wBAAwB,EAAE,8BAA8B,GACvD,OAAO,CAAC,8BAA8B,CAAC;IAe1C;;;;;;;;;;;;OAYG;YACW,mBAAmB;YAkCnB,oBAAoB;IAiClC,OAAO,CAAC,MAAM,CAAC,cAAc;IA0B7B;;;;;;;OAOG;IACG,kCAAkC,IAAI,OAAO,CAAC,OAAO,CAAC;CAoB7D"}
|