@mondaydotcomorg/monday-authorization 3.6.0-feat-shaime-support-entity-attributes-3-edf2a0b → 3.6.1
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/dist/authorization-attributes-ms-service.d.ts +2 -2
- package/dist/authorization-attributes-ms-service.d.ts.map +1 -1
- package/dist/authorization-attributes-ms-service.js +10 -28
- 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 +2 -2
- package/dist/authorization-attributes-sns-service.d.ts.map +1 -1
- package/dist/authorization-attributes-sns-service.js +7 -23
- 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/esm/authorization-attributes-ms-service.d.ts +2 -2
- package/dist/esm/authorization-attributes-ms-service.d.ts.map +1 -1
- package/dist/esm/authorization-attributes-ms-service.mjs +10 -28
- 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 +2 -2
- package/dist/esm/authorization-attributes-sns-service.d.ts.map +1 -1
- package/dist/esm/authorization-attributes-sns-service.mjs +7 -23
- 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/index.d.ts +1 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.mjs +1 -0
- package/dist/esm/resource-attribute-assignment.d.ts.map +1 -1
- package/dist/esm/resource-attribute-assignment.mjs +7 -0
- package/dist/esm/resource-attributes-constants.d.ts +2 -1
- package/dist/esm/resource-attributes-constants.d.ts.map +1 -1
- package/dist/esm/resource-attributes-constants.mjs +1 -0
- package/dist/esm/utils/validation.mjs +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/resource-attribute-assignment.d.ts.map +1 -1
- package/dist/resource-attribute-assignment.js +7 -0
- package/dist/resource-attributes-constants.d.ts +2 -1
- package/dist/resource-attributes-constants.d.ts.map +1 -1
- package/dist/resource-attributes-constants.js +1 -0
- package/dist/utils/validation.js +2 -2
- package/package.json +1 -1
- package/src/authorization-attributes-ms-service.ts +19 -31
- package/src/authorization-attributes-service.ts +18 -16
- package/src/authorization-attributes-sns-service.ts +15 -23
- package/src/base-authorization-attributes-service.ts +90 -0
- package/src/index.ts +1 -1
- package/src/resource-attribute-assignment.ts +7 -0
- package/src/resource-attributes-constants.ts +1 -0
- package/src/utils/validation.ts +2 -2
- package/dist/esm/types/authorization-attributes-service.interface.d.ts +0 -32
- 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 -32
- 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 -63
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { ResourceAttributeUpsertOperation, ResourceAttributeDeleteOperation, EntityAttributeUpsertOperation, EntityAttributeDeleteOperation } from './types/authorization-attributes-contracts';
|
|
2
2
|
import { EntityType } from './entity-attributes-constants';
|
|
3
|
-
import {
|
|
3
|
+
import { BaseAuthorizationAttributesService } from './base-authorization-attributes-service';
|
|
4
4
|
import { Resource } from './types/general';
|
|
5
5
|
/**
|
|
6
6
|
* Service class for managing resource attributes in the authorization microservice.
|
|
7
7
|
* Provides synchronous HTTP operations to create/update and delete attributes on resources.
|
|
8
8
|
*/
|
|
9
|
-
export declare class AuthorizationAttributesMsService
|
|
9
|
+
export declare class AuthorizationAttributesMsService extends BaseAuthorizationAttributesService {
|
|
10
10
|
private static LOG_TAG;
|
|
11
11
|
private static httpClient;
|
|
12
12
|
constructor();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization-attributes-ms-service.d.ts","sourceRoot":"","sources":["../src/authorization-attributes-ms-service.ts"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"authorization-attributes-ms-service.d.ts","sourceRoot":"","sources":["../src/authorization-attributes-ms-service.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,gCAAgC,EAChC,gCAAgC,EAChC,8BAA8B,EAC9B,8BAA8B,EAC/B,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAI3D,OAAO,EAAE,kCAAkC,EAAE,MAAM,yCAAyC,CAAC;AAC7F,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAY3C;;;GAGG;AACH,qBAAa,gCAAiC,SAAQ,kCAAkC;IACtF,OAAO,CAAC,MAAM,CAAC,OAAO,CAAiC;IACvD,OAAO,CAAC,MAAM,CAAC,UAAU,CAAqD;;IAY9E;;;;;;OAMG;IACG,wBAAwB,CAC5B,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,MAAM,EACpB,QAAQ,CAAC,EAAE,MAAM,EACjB,uBAAuB,CAAC,EAAE,MAAM,GAC/B,OAAO,CAAC,gCAAgC,CAAC;IAoB5C;;;;;;;OAOG;IACG,sBAAsB,CAC1B,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,QAAQ,CAAC,EAAE,MAAM,EACjB,uBAAuB,CAAC,EAAE,MAAM,GAC/B,OAAO,CAAC,8BAA8B,CAAC;IAqB1C;;;;;;;OAOG;IACG,wBAAwB,CAC5B,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,uBAAuB,EAAE,MAAM,EAC/B,0BAA0B,EAAE,gCAAgC,GAC3D,OAAO,CAAC,gCAAgC,CAAC;IAqB5C;;;;;;;OAOG;IACG,sBAAsB,CAC1B,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,uBAAuB,EAAE,MAAM,EAC/B,wBAAwB,EAAE,8BAA8B,GACvD,OAAO,CAAC,8BAA8B,CAAC;IAsB1C;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAQhC;;OAEG;mBACkB,oBAAoB;IA6DzC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,iBAAiB;IA+ChC;;OAEG;mBACkB,oBAAoB;CA4D1C"}
|
|
@@ -4,11 +4,10 @@ const tridentBackendApi = require('@mondaydotcomorg/trident-backend-api');
|
|
|
4
4
|
const mondayJwt = require('@mondaydotcomorg/monday-jwt');
|
|
5
5
|
const resourceAttributeAssignment = require('./resource-attribute-assignment.js');
|
|
6
6
|
const entityAttributeAssignment = require('./entity-attribute-assignment.js');
|
|
7
|
-
const types_authorizationAttributesContracts = require('./types/authorization-attributes-contracts.js');
|
|
8
7
|
const authorizationInternalService = require('./authorization-internal-service.js');
|
|
9
8
|
const attributionsService = require('./attributions-service.js');
|
|
10
9
|
const constants = require('./constants.js');
|
|
11
|
-
const
|
|
10
|
+
const baseAuthorizationAttributesService = require('./base-authorization-attributes-service.js');
|
|
12
11
|
|
|
13
12
|
const INTERNAL_APP_NAME = 'internal_ms';
|
|
14
13
|
const UPSERT_RESOURCE_ATTRIBUTES_PATH = '/attributes/{accountId}/resource';
|
|
@@ -19,10 +18,11 @@ const DELETE_ENTITY_ATTRIBUTES_PATH = '/attributes/{accountId}/entity/{entityTyp
|
|
|
19
18
|
* Service class for managing resource attributes in the authorization microservice.
|
|
20
19
|
* Provides synchronous HTTP operations to create/update and delete attributes on resources.
|
|
21
20
|
*/
|
|
22
|
-
class AuthorizationAttributesMsService {
|
|
21
|
+
class AuthorizationAttributesMsService extends baseAuthorizationAttributesService.BaseAuthorizationAttributesService {
|
|
23
22
|
static LOG_TAG = 'authorization_attributes_ms';
|
|
24
23
|
static httpClient = tridentBackendApi.Api.getPart('httpClient');
|
|
25
24
|
constructor() {
|
|
25
|
+
super();
|
|
26
26
|
if (!AuthorizationAttributesMsService.httpClient) {
|
|
27
27
|
AuthorizationAttributesMsService.httpClient = tridentBackendApi.Api.getPart('httpClient');
|
|
28
28
|
if (!AuthorizationAttributesMsService.httpClient) {
|
|
@@ -38,22 +38,12 @@ class AuthorizationAttributesMsService {
|
|
|
38
38
|
* @returns Promise<ResourceAttributeDeleteOperation>
|
|
39
39
|
*/
|
|
40
40
|
async deleteResourceAttributes(accountId, resource, attributeKey, _appName, _callerActionIdentifier) {
|
|
41
|
-
|
|
42
|
-
utils_validation.ValidationUtils.validatDeleteResourceAssignment({
|
|
43
|
-
resourceType: resource.type,
|
|
44
|
-
resourceId: resource.id,
|
|
45
|
-
key: attributeKey,
|
|
46
|
-
});
|
|
41
|
+
const operation = await super.deleteResourceAttributes(accountId, resource, attributeKey);
|
|
47
42
|
await AuthorizationAttributesMsService.executeDeleteRequest(accountId, DELETE_RESOURCE_ATTRIBUTES_PATH, {
|
|
48
43
|
resourceType: resource.type,
|
|
49
44
|
resourceId: resource.id,
|
|
50
45
|
}, [attributeKey], 'resource', 'deleteResourceAttributesSync');
|
|
51
|
-
return
|
|
52
|
-
resourceType: resource.type,
|
|
53
|
-
resourceId: resource.id,
|
|
54
|
-
key: attributeKey,
|
|
55
|
-
operationType: types_authorizationAttributesContracts.AttributeOperation.DELETE,
|
|
56
|
-
};
|
|
46
|
+
return operation;
|
|
57
47
|
}
|
|
58
48
|
/**
|
|
59
49
|
* Deletes a specific attribute from an entity synchronously.
|
|
@@ -64,17 +54,12 @@ class AuthorizationAttributesMsService {
|
|
|
64
54
|
* @returns Promise<EntityAttributeDeleteOperation>
|
|
65
55
|
*/
|
|
66
56
|
async deleteEntityAttributes(accountId, entityType, entityId, attributeKey, _appName, _callerActionIdentifier) {
|
|
67
|
-
|
|
57
|
+
const operation = await super.deleteEntityAttributes(accountId, entityType, entityId, attributeKey);
|
|
68
58
|
await AuthorizationAttributesMsService.executeDeleteRequest(accountId, DELETE_ENTITY_ATTRIBUTES_PATH, {
|
|
69
59
|
entityType,
|
|
70
60
|
entityId,
|
|
71
61
|
}, [attributeKey], 'entity', 'deleteEntityAttributesSync');
|
|
72
|
-
return
|
|
73
|
-
entityType,
|
|
74
|
-
entityId,
|
|
75
|
-
key: attributeKey,
|
|
76
|
-
operationType: types_authorizationAttributesContracts.AttributeOperation.DELETE,
|
|
77
|
-
};
|
|
62
|
+
return operation;
|
|
78
63
|
}
|
|
79
64
|
/**
|
|
80
65
|
* Updates a resource attribute (single operation - upsert only).
|
|
@@ -85,9 +70,9 @@ class AuthorizationAttributesMsService {
|
|
|
85
70
|
* @returns Promise<ResourceAttributeUpsertOperation> Processed operation
|
|
86
71
|
*/
|
|
87
72
|
async updateResourceAttributes(accountId, _appName, _callerActionIdentifier, resourceAttributeOperation) {
|
|
88
|
-
|
|
73
|
+
await super.updateResourceAttributes(accountId, _appName, _callerActionIdentifier, resourceAttributeOperation);
|
|
89
74
|
await AuthorizationAttributesMsService.executeUpsertRequest(accountId, [
|
|
90
|
-
new resourceAttributeAssignment.ResourceAttributeAssignment(resourceAttributeOperation.resourceId, resourceAttributeOperation.resourceType, resourceAttributeOperation.key, resourceAttributeOperation.value
|
|
75
|
+
new resourceAttributeAssignment.ResourceAttributeAssignment(resourceAttributeOperation.resourceId, resourceAttributeOperation.resourceType, resourceAttributeOperation.key, resourceAttributeOperation.value),
|
|
91
76
|
], UPSERT_RESOURCE_ATTRIBUTES_PATH, 'resourceAttributeAssignments', 'resource', 'updateResourceAttributesSync');
|
|
92
77
|
return resourceAttributeOperation;
|
|
93
78
|
}
|
|
@@ -101,7 +86,7 @@ class AuthorizationAttributesMsService {
|
|
|
101
86
|
*/
|
|
102
87
|
async updateEntityAttributes(accountId, _appName, _callerActionIdentifier, entityAttributeOperation) {
|
|
103
88
|
// Validate before processing
|
|
104
|
-
|
|
89
|
+
await super.updateEntityAttributes(accountId, _appName, _callerActionIdentifier, entityAttributeOperation);
|
|
105
90
|
await AuthorizationAttributesMsService.executeUpsertRequest(accountId, [
|
|
106
91
|
new entityAttributeAssignment.EntityAttributeAssignment(entityAttributeOperation.entityId, entityAttributeOperation.entityType, entityAttributeOperation.key, entityAttributeOperation.value),
|
|
107
92
|
], UPSERT_ENTITY_ATTRIBUTES_PATH, 'entityAttributeAssignments', 'entity', 'upsertEntityAttributesSync');
|
|
@@ -124,9 +109,6 @@ class AuthorizationAttributesMsService {
|
|
|
124
109
|
* Generic helper for executing delete requests
|
|
125
110
|
*/
|
|
126
111
|
static async executeDeleteRequest(accountId, pathTemplate, pathParams, keys, logPrefix, methodName) {
|
|
127
|
-
// Validate inputs
|
|
128
|
-
utils_validation.ValidationUtils.validateInteger(accountId);
|
|
129
|
-
utils_validation.ValidationUtils.validateStringArray(keys);
|
|
130
112
|
if (!keys.length) {
|
|
131
113
|
authorizationInternalService.logger.warn({ tag: this.LOG_TAG, accountId, ...pathParams }, `${methodName} called with empty keys array`);
|
|
132
114
|
return;
|
|
@@ -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"}
|
|
@@ -5,42 +5,44 @@ const authorizationAttributesSnsService = require('./authorization-attributes-sn
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Main service class for managing resource and entity attributes.
|
|
8
|
-
* Provides access to both direct
|
|
8
|
+
* Provides access to both HTTP (direct microservice) and SNS (async messaging) operations.
|
|
9
9
|
*
|
|
10
10
|
* @example
|
|
11
11
|
* const service = new AuthorizationAttributesService();
|
|
12
12
|
*
|
|
13
|
-
* // Use direct
|
|
14
|
-
* await service.
|
|
13
|
+
* // Use HTTP operations (direct calls to microservice)
|
|
14
|
+
* await service.http().updateResourceAttributes(accountId, appName, actionId, operation);
|
|
15
15
|
*
|
|
16
|
-
* // Use SNS operations
|
|
17
|
-
* await service.sns().
|
|
16
|
+
* // Use SNS operations (async messaging, then to microservice)
|
|
17
|
+
* await service.sns().updateResourceAttributes(accountId, appName, actionId, operation);
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
20
|
class AuthorizationAttributesService {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
httpService = null;
|
|
22
|
+
snsService = null;
|
|
23
23
|
/**
|
|
24
|
-
* Gets the
|
|
24
|
+
* Gets the HTTP service instance.
|
|
25
|
+
* Performs direct HTTP calls to the authorization microservice.
|
|
25
26
|
* Initializes the service on first access (lazy initialization).
|
|
26
27
|
* @returns IAuthorizationAttributesService instance
|
|
27
28
|
*/
|
|
28
|
-
|
|
29
|
-
if (this.
|
|
30
|
-
this.
|
|
29
|
+
http() {
|
|
30
|
+
if (this.httpService === null) {
|
|
31
|
+
this.httpService = new authorizationAttributesMsService.AuthorizationAttributesMsService();
|
|
31
32
|
}
|
|
32
|
-
return this.
|
|
33
|
+
return this.httpService;
|
|
33
34
|
}
|
|
34
35
|
/**
|
|
35
36
|
* Gets the SNS service instance.
|
|
37
|
+
* Sends operations via SNS messaging, which are then processed by the microservice asynchronously.
|
|
36
38
|
* Initializes the service on first access (lazy initialization).
|
|
37
39
|
* @returns IAuthorizationAttributesService instance
|
|
38
40
|
*/
|
|
39
41
|
sns() {
|
|
40
|
-
if (this.
|
|
41
|
-
this.
|
|
42
|
+
if (this.snsService === null) {
|
|
43
|
+
this.snsService = new authorizationAttributesSnsService.AuthorizationAttributesSnsService();
|
|
42
44
|
}
|
|
43
|
-
return this.
|
|
45
|
+
return this.snsService;
|
|
44
46
|
}
|
|
45
47
|
}
|
|
46
48
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { ResourceAttributeUpsertOperation, EntityAttributeUpsertOperation, EntityAttributeDeleteOperation, ResourceAttributeDeleteOperation } from './types/authorization-attributes-contracts';
|
|
2
2
|
import { Resource } from './types/general';
|
|
3
|
-
import {
|
|
3
|
+
import { BaseAuthorizationAttributesService } from './base-authorization-attributes-service';
|
|
4
4
|
import { EntityType } from './entity-attributes-constants';
|
|
5
5
|
/**
|
|
6
6
|
* Service class for managing resource attributes asynchronously via SNS.
|
|
7
7
|
* Provides asynchronous operations to create/update and delete attributes on resources.
|
|
8
8
|
*/
|
|
9
|
-
export declare class AuthorizationAttributesSnsService
|
|
9
|
+
export declare class AuthorizationAttributesSnsService extends BaseAuthorizationAttributesService {
|
|
10
10
|
private static LOG_TAG;
|
|
11
11
|
private resourceSnsArn;
|
|
12
12
|
private entitySnsArn;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization-attributes-sns-service.d.ts","sourceRoot":"","sources":["../src/authorization-attributes-sns-service.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
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"}
|
|
@@ -2,10 +2,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2
2
|
|
|
3
3
|
const chunk = require('lodash/chunk.js');
|
|
4
4
|
const mondaySns = require('@mondaydotcomorg/monday-sns');
|
|
5
|
-
const types_authorizationAttributesContracts = require('./types/authorization-attributes-contracts.js');
|
|
6
5
|
const authorizationInternalService = require('./authorization-internal-service.js');
|
|
7
6
|
const constants_sns = require('./constants/sns.js');
|
|
8
|
-
const
|
|
7
|
+
const baseAuthorizationAttributesService = require('./base-authorization-attributes-service.js');
|
|
9
8
|
|
|
10
9
|
const _interopDefault = e => e && e.__esModule ? e : { default: e };
|
|
11
10
|
|
|
@@ -15,7 +14,7 @@ const chunk__default = /*#__PURE__*/_interopDefault(chunk);
|
|
|
15
14
|
* Service class for managing resource attributes asynchronously via SNS.
|
|
16
15
|
* Provides asynchronous operations to create/update and delete attributes on resources.
|
|
17
16
|
*/
|
|
18
|
-
class AuthorizationAttributesSnsService {
|
|
17
|
+
class AuthorizationAttributesSnsService extends baseAuthorizationAttributesService.BaseAuthorizationAttributesService {
|
|
19
18
|
static LOG_TAG = 'authorization_attributes';
|
|
20
19
|
resourceSnsArn;
|
|
21
20
|
entitySnsArn;
|
|
@@ -23,6 +22,7 @@ class AuthorizationAttributesSnsService {
|
|
|
23
22
|
* Public constructor to create the AuthorizationAttributesSnsService instance.
|
|
24
23
|
*/
|
|
25
24
|
constructor() {
|
|
25
|
+
super();
|
|
26
26
|
this.resourceSnsArn = AuthorizationAttributesSnsService.getSnsTopicArn(constants_sns.SnsTopicType.RESOURCE);
|
|
27
27
|
this.entitySnsArn = AuthorizationAttributesSnsService.getSnsTopicArn(constants_sns.SnsTopicType.ENTITY);
|
|
28
28
|
}
|
|
@@ -40,17 +40,7 @@ class AuthorizationAttributesSnsService {
|
|
|
40
40
|
if (!appName || !callerActionIdentifier) {
|
|
41
41
|
throw new Error('appName and callerActionIdentifier are required for SNS service');
|
|
42
42
|
}
|
|
43
|
-
|
|
44
|
-
resourceType: resource.type,
|
|
45
|
-
resourceId: resource.id,
|
|
46
|
-
key: attributeKey,
|
|
47
|
-
});
|
|
48
|
-
const operation = {
|
|
49
|
-
resourceType: resource.type,
|
|
50
|
-
resourceId: resource.id,
|
|
51
|
-
key: attributeKey,
|
|
52
|
-
operationType: types_authorizationAttributesContracts.AttributeOperation.DELETE,
|
|
53
|
-
};
|
|
43
|
+
const operation = await super.deleteResourceAttributes(accountId, resource, attributeKey);
|
|
54
44
|
const [result] = await this.sendOperationsToSns(this.resourceSnsArn, accountId, appName, callerActionIdentifier, [operation], constants_sns.ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE, constants_sns.RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND, 'Authorization resource attributes async delete: failed to send operations to SNS');
|
|
55
45
|
return result;
|
|
56
46
|
}
|
|
@@ -69,13 +59,7 @@ class AuthorizationAttributesSnsService {
|
|
|
69
59
|
if (!appName || !callerActionIdentifier) {
|
|
70
60
|
throw new Error('appName and callerActionIdentifier are required for SNS service');
|
|
71
61
|
}
|
|
72
|
-
|
|
73
|
-
const operation = {
|
|
74
|
-
entityType: entityType,
|
|
75
|
-
entityId,
|
|
76
|
-
key: attributeKey,
|
|
77
|
-
operationType: types_authorizationAttributesContracts.AttributeOperation.DELETE,
|
|
78
|
-
};
|
|
62
|
+
const operation = await super.deleteEntityAttributes(accountId, entityType, entityId, attributeKey);
|
|
79
63
|
const [result] = await this.sendOperationsToSns(this.entitySnsArn, accountId, appName, callerActionIdentifier, [operation], constants_sns.ASYNC_ENTITY_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE, constants_sns.ENTITY_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND, 'Authorization entity attributes async delete: failed to send operations to SNS');
|
|
80
64
|
return result;
|
|
81
65
|
}
|
|
@@ -88,7 +72,7 @@ class AuthorizationAttributesSnsService {
|
|
|
88
72
|
* @return {Promise<ResourceAttributeUpsertOperation>} Sent operation
|
|
89
73
|
* */
|
|
90
74
|
async updateResourceAttributes(accountId, appName, callerActionIdentifier, resourceAttributeOperation) {
|
|
91
|
-
|
|
75
|
+
await super.updateResourceAttributes(accountId, appName, callerActionIdentifier, resourceAttributeOperation);
|
|
92
76
|
const [result] = await this.sendOperationsToSns(this.resourceSnsArn, accountId, appName, callerActionIdentifier, [resourceAttributeOperation], constants_sns.ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE, constants_sns.RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND, 'Authorization resource attributes async update: failed to send operations to SNS');
|
|
93
77
|
return result;
|
|
94
78
|
}
|
|
@@ -101,7 +85,7 @@ class AuthorizationAttributesSnsService {
|
|
|
101
85
|
* @return {Promise<EntityAttributeUpsertOperation>} Sent operation
|
|
102
86
|
* */
|
|
103
87
|
async updateEntityAttributes(accountId, appName, callerActionIdentifier, entityAttributeOperation) {
|
|
104
|
-
|
|
88
|
+
await super.updateEntityAttributes(accountId, appName, callerActionIdentifier, entityAttributeOperation);
|
|
105
89
|
const [result] = await this.sendOperationsToSns(this.entitySnsArn, accountId, appName, callerActionIdentifier, [entityAttributeOperation], constants_sns.ASYNC_ENTITY_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE, constants_sns.ENTITY_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND, 'Authorization entity attributes async update: failed to send operations to SNS');
|
|
106
90
|
return result;
|
|
107
91
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { EntityType } from './entity-attributes-constants';
|
|
2
|
+
import { ResourceAttributeDeleteOperation, EntityAttributeDeleteOperation, ResourceAttributeUpsertOperation, EntityAttributeUpsertOperation } from './types/authorization-attributes-contracts';
|
|
3
|
+
import { Resource } from './types/general';
|
|
4
|
+
/**
|
|
5
|
+
* Abstract base class for authorization attributes operations.
|
|
6
|
+
* Both MS (HTTP) and SNS (async) services extend this class.
|
|
7
|
+
*/
|
|
8
|
+
export declare abstract class BaseAuthorizationAttributesService {
|
|
9
|
+
/**
|
|
10
|
+
* Deletes a resource attribute.
|
|
11
|
+
* Returns Promise<ResourceAttributeDeleteOperation>
|
|
12
|
+
*/
|
|
13
|
+
deleteResourceAttributes(accountId: number, resource: Resource, attributeKey: string, _appName?: string, _callerActionIdentifier?: string): Promise<ResourceAttributeDeleteOperation>;
|
|
14
|
+
/**
|
|
15
|
+
* Deletes an entity attribute.
|
|
16
|
+
* Returns Promise<EntityAttributeDeleteOperation>
|
|
17
|
+
*/
|
|
18
|
+
deleteEntityAttributes(accountId: number, entityType: EntityType, entityId: number, attributeKey: string): Promise<EntityAttributeDeleteOperation>;
|
|
19
|
+
/**
|
|
20
|
+
* Updates a resource attribute (single operation - upsert only).
|
|
21
|
+
* For MS service: performs upsert operation
|
|
22
|
+
* For SNS service: returns Promise<ResourceAttributeUpsertOperation>
|
|
23
|
+
*/
|
|
24
|
+
updateResourceAttributes(accountId: number, _appName: string, _callerActionIdentifier: string, resourceAttributeOperation: ResourceAttributeUpsertOperation): Promise<ResourceAttributeUpsertOperation>;
|
|
25
|
+
/**
|
|
26
|
+
* Updates an entity attribute (single operation - upsert only).
|
|
27
|
+
* For MS service: performs upsert operation
|
|
28
|
+
* For SNS service: returns Promise<EntityAttributeUpsertOperation>
|
|
29
|
+
*/
|
|
30
|
+
updateEntityAttributes(accountId: number, _appName: string, _callerActionIdentifier: string, entityAttributeOperation: EntityAttributeUpsertOperation): Promise<EntityAttributeUpsertOperation>;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=base-authorization-attributes-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-authorization-attributes-service.d.ts","sourceRoot":"","sources":["../src/base-authorization-attributes-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EACL,gCAAgC,EAChC,8BAA8B,EAC9B,gCAAgC,EAChC,8BAA8B,EAE/B,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAG3C;;;GAGG;AACH,8BAAsB,kCAAkC;IACtD;;;OAGG;IACH,wBAAwB,CACtB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,MAAM,EACpB,QAAQ,CAAC,EAAE,MAAM,EACjB,uBAAuB,CAAC,EAAE,MAAM,GAC/B,OAAO,CAAC,gCAAgC,CAAC;IAY5C;;;OAGG;IACH,sBAAsB,CACpB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,8BAA8B,CAAC;IAY1C;;;;OAIG;IACH,wBAAwB,CACtB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,uBAAuB,EAAE,MAAM,EAC/B,0BAA0B,EAAE,gCAAgC,GAC3D,OAAO,CAAC,gCAAgC,CAAC;IAK5C;;;;OAIG;IACH,sBAAsB,CACpB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,uBAAuB,EAAE,MAAM,EAC/B,wBAAwB,EAAE,8BAA8B,GACvD,OAAO,CAAC,8BAA8B,CAAC;CAK3C"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
const types_authorizationAttributesContracts = require('./types/authorization-attributes-contracts.js');
|
|
4
|
+
const utils_validation = require('./utils/validation.js');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Abstract base class for authorization attributes operations.
|
|
8
|
+
* Both MS (HTTP) and SNS (async) services extend this class.
|
|
9
|
+
*/
|
|
10
|
+
class BaseAuthorizationAttributesService {
|
|
11
|
+
/**
|
|
12
|
+
* Deletes a resource attribute.
|
|
13
|
+
* Returns Promise<ResourceAttributeDeleteOperation>
|
|
14
|
+
*/
|
|
15
|
+
deleteResourceAttributes(accountId, resource, attributeKey, _appName, _callerActionIdentifier) {
|
|
16
|
+
const operation = {
|
|
17
|
+
resourceType: resource.type,
|
|
18
|
+
resourceId: resource.id,
|
|
19
|
+
key: attributeKey,
|
|
20
|
+
operationType: types_authorizationAttributesContracts.AttributeOperation.DELETE,
|
|
21
|
+
};
|
|
22
|
+
utils_validation.ValidationUtils.validateInteger(accountId);
|
|
23
|
+
utils_validation.ValidationUtils.validatDeleteResourceAssignment(operation);
|
|
24
|
+
return Promise.resolve(operation);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Deletes an entity attribute.
|
|
28
|
+
* Returns Promise<EntityAttributeDeleteOperation>
|
|
29
|
+
*/
|
|
30
|
+
deleteEntityAttributes(accountId, entityType, entityId, attributeKey) {
|
|
31
|
+
const operation = {
|
|
32
|
+
entityType: entityType,
|
|
33
|
+
entityId: entityId,
|
|
34
|
+
key: attributeKey,
|
|
35
|
+
operationType: types_authorizationAttributesContracts.AttributeOperation.DELETE,
|
|
36
|
+
};
|
|
37
|
+
utils_validation.ValidationUtils.validateInteger(accountId);
|
|
38
|
+
utils_validation.ValidationUtils.validatDeleteEntityAssignment(operation);
|
|
39
|
+
return Promise.resolve(operation);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Updates a resource attribute (single operation - upsert only).
|
|
43
|
+
* For MS service: performs upsert operation
|
|
44
|
+
* For SNS service: returns Promise<ResourceAttributeUpsertOperation>
|
|
45
|
+
*/
|
|
46
|
+
updateResourceAttributes(accountId, _appName, _callerActionIdentifier, resourceAttributeOperation) {
|
|
47
|
+
utils_validation.ValidationUtils.validateInteger(accountId);
|
|
48
|
+
utils_validation.ValidationUtils.validatUpsertResourceAssignment(resourceAttributeOperation);
|
|
49
|
+
return Promise.resolve(resourceAttributeOperation);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Updates an entity attribute (single operation - upsert only).
|
|
53
|
+
* For MS service: performs upsert operation
|
|
54
|
+
* For SNS service: returns Promise<EntityAttributeUpsertOperation>
|
|
55
|
+
*/
|
|
56
|
+
updateEntityAttributes(accountId, _appName, _callerActionIdentifier, entityAttributeOperation) {
|
|
57
|
+
utils_validation.ValidationUtils.validateInteger(accountId);
|
|
58
|
+
utils_validation.ValidationUtils.validatUpsertEntityAssignment(entityAttributeOperation);
|
|
59
|
+
return Promise.resolve(entityAttributeOperation);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
exports.BaseAuthorizationAttributesService = BaseAuthorizationAttributesService;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { ResourceAttributeUpsertOperation, ResourceAttributeDeleteOperation, EntityAttributeUpsertOperation, EntityAttributeDeleteOperation } from './types/authorization-attributes-contracts';
|
|
2
2
|
import { EntityType } from './entity-attributes-constants';
|
|
3
|
-
import {
|
|
3
|
+
import { BaseAuthorizationAttributesService } from './base-authorization-attributes-service';
|
|
4
4
|
import { Resource } from './types/general';
|
|
5
5
|
/**
|
|
6
6
|
* Service class for managing resource attributes in the authorization microservice.
|
|
7
7
|
* Provides synchronous HTTP operations to create/update and delete attributes on resources.
|
|
8
8
|
*/
|
|
9
|
-
export declare class AuthorizationAttributesMsService
|
|
9
|
+
export declare class AuthorizationAttributesMsService extends BaseAuthorizationAttributesService {
|
|
10
10
|
private static LOG_TAG;
|
|
11
11
|
private static httpClient;
|
|
12
12
|
constructor();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization-attributes-ms-service.d.ts","sourceRoot":"","sources":["../../src/authorization-attributes-ms-service.ts"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"authorization-attributes-ms-service.d.ts","sourceRoot":"","sources":["../../src/authorization-attributes-ms-service.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,gCAAgC,EAChC,gCAAgC,EAChC,8BAA8B,EAC9B,8BAA8B,EAC/B,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAI3D,OAAO,EAAE,kCAAkC,EAAE,MAAM,yCAAyC,CAAC;AAC7F,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAY3C;;;GAGG;AACH,qBAAa,gCAAiC,SAAQ,kCAAkC;IACtF,OAAO,CAAC,MAAM,CAAC,OAAO,CAAiC;IACvD,OAAO,CAAC,MAAM,CAAC,UAAU,CAAqD;;IAY9E;;;;;;OAMG;IACG,wBAAwB,CAC5B,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,MAAM,EACpB,QAAQ,CAAC,EAAE,MAAM,EACjB,uBAAuB,CAAC,EAAE,MAAM,GAC/B,OAAO,CAAC,gCAAgC,CAAC;IAoB5C;;;;;;;OAOG;IACG,sBAAsB,CAC1B,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,QAAQ,CAAC,EAAE,MAAM,EACjB,uBAAuB,CAAC,EAAE,MAAM,GAC/B,OAAO,CAAC,8BAA8B,CAAC;IAqB1C;;;;;;;OAOG;IACG,wBAAwB,CAC5B,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,uBAAuB,EAAE,MAAM,EAC/B,0BAA0B,EAAE,gCAAgC,GAC3D,OAAO,CAAC,gCAAgC,CAAC;IAqB5C;;;;;;;OAOG;IACG,sBAAsB,CAC1B,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,uBAAuB,EAAE,MAAM,EAC/B,wBAAwB,EAAE,8BAA8B,GACvD,OAAO,CAAC,8BAA8B,CAAC;IAsB1C;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAQhC;;OAEG;mBACkB,oBAAoB;IA6DzC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,iBAAiB;IA+ChC;;OAEG;mBACkB,oBAAoB;CA4D1C"}
|
|
@@ -2,11 +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
5
|
import { logger, AuthorizationInternalService } from './authorization-internal-service.mjs';
|
|
7
6
|
import { getAttributionsFromApi } from './attributions-service.mjs';
|
|
8
7
|
import { APP_NAME } from './constants.mjs';
|
|
9
|
-
import {
|
|
8
|
+
import { BaseAuthorizationAttributesService } from './base-authorization-attributes-service.mjs';
|
|
10
9
|
|
|
11
10
|
const INTERNAL_APP_NAME = 'internal_ms';
|
|
12
11
|
const UPSERT_RESOURCE_ATTRIBUTES_PATH = '/attributes/{accountId}/resource';
|
|
@@ -17,10 +16,11 @@ const DELETE_ENTITY_ATTRIBUTES_PATH = '/attributes/{accountId}/entity/{entityTyp
|
|
|
17
16
|
* Service class for managing resource attributes in the authorization microservice.
|
|
18
17
|
* Provides synchronous HTTP operations to create/update and delete attributes on resources.
|
|
19
18
|
*/
|
|
20
|
-
class AuthorizationAttributesMsService {
|
|
19
|
+
class AuthorizationAttributesMsService extends BaseAuthorizationAttributesService {
|
|
21
20
|
static LOG_TAG = 'authorization_attributes_ms';
|
|
22
21
|
static httpClient = Api.getPart('httpClient');
|
|
23
22
|
constructor() {
|
|
23
|
+
super();
|
|
24
24
|
if (!AuthorizationAttributesMsService.httpClient) {
|
|
25
25
|
AuthorizationAttributesMsService.httpClient = Api.getPart('httpClient');
|
|
26
26
|
if (!AuthorizationAttributesMsService.httpClient) {
|
|
@@ -36,22 +36,12 @@ class AuthorizationAttributesMsService {
|
|
|
36
36
|
* @returns Promise<ResourceAttributeDeleteOperation>
|
|
37
37
|
*/
|
|
38
38
|
async deleteResourceAttributes(accountId, resource, attributeKey, _appName, _callerActionIdentifier) {
|
|
39
|
-
|
|
40
|
-
ValidationUtils.validatDeleteResourceAssignment({
|
|
41
|
-
resourceType: resource.type,
|
|
42
|
-
resourceId: resource.id,
|
|
43
|
-
key: attributeKey,
|
|
44
|
-
});
|
|
39
|
+
const operation = await super.deleteResourceAttributes(accountId, resource, attributeKey);
|
|
45
40
|
await AuthorizationAttributesMsService.executeDeleteRequest(accountId, DELETE_RESOURCE_ATTRIBUTES_PATH, {
|
|
46
41
|
resourceType: resource.type,
|
|
47
42
|
resourceId: resource.id,
|
|
48
43
|
}, [attributeKey], 'resource', 'deleteResourceAttributesSync');
|
|
49
|
-
return
|
|
50
|
-
resourceType: resource.type,
|
|
51
|
-
resourceId: resource.id,
|
|
52
|
-
key: attributeKey,
|
|
53
|
-
operationType: AttributeOperation.DELETE,
|
|
54
|
-
};
|
|
44
|
+
return operation;
|
|
55
45
|
}
|
|
56
46
|
/**
|
|
57
47
|
* Deletes a specific attribute from an entity synchronously.
|
|
@@ -62,17 +52,12 @@ class AuthorizationAttributesMsService {
|
|
|
62
52
|
* @returns Promise<EntityAttributeDeleteOperation>
|
|
63
53
|
*/
|
|
64
54
|
async deleteEntityAttributes(accountId, entityType, entityId, attributeKey, _appName, _callerActionIdentifier) {
|
|
65
|
-
|
|
55
|
+
const operation = await super.deleteEntityAttributes(accountId, entityType, entityId, attributeKey);
|
|
66
56
|
await AuthorizationAttributesMsService.executeDeleteRequest(accountId, DELETE_ENTITY_ATTRIBUTES_PATH, {
|
|
67
57
|
entityType,
|
|
68
58
|
entityId,
|
|
69
59
|
}, [attributeKey], 'entity', 'deleteEntityAttributesSync');
|
|
70
|
-
return
|
|
71
|
-
entityType,
|
|
72
|
-
entityId,
|
|
73
|
-
key: attributeKey,
|
|
74
|
-
operationType: AttributeOperation.DELETE,
|
|
75
|
-
};
|
|
60
|
+
return operation;
|
|
76
61
|
}
|
|
77
62
|
/**
|
|
78
63
|
* Updates a resource attribute (single operation - upsert only).
|
|
@@ -83,9 +68,9 @@ class AuthorizationAttributesMsService {
|
|
|
83
68
|
* @returns Promise<ResourceAttributeUpsertOperation> Processed operation
|
|
84
69
|
*/
|
|
85
70
|
async updateResourceAttributes(accountId, _appName, _callerActionIdentifier, resourceAttributeOperation) {
|
|
86
|
-
|
|
71
|
+
await super.updateResourceAttributes(accountId, _appName, _callerActionIdentifier, resourceAttributeOperation);
|
|
87
72
|
await AuthorizationAttributesMsService.executeUpsertRequest(accountId, [
|
|
88
|
-
new ResourceAttributeAssignment(resourceAttributeOperation.resourceId, resourceAttributeOperation.resourceType, resourceAttributeOperation.key, resourceAttributeOperation.value
|
|
73
|
+
new ResourceAttributeAssignment(resourceAttributeOperation.resourceId, resourceAttributeOperation.resourceType, resourceAttributeOperation.key, resourceAttributeOperation.value),
|
|
89
74
|
], UPSERT_RESOURCE_ATTRIBUTES_PATH, 'resourceAttributeAssignments', 'resource', 'updateResourceAttributesSync');
|
|
90
75
|
return resourceAttributeOperation;
|
|
91
76
|
}
|
|
@@ -99,7 +84,7 @@ class AuthorizationAttributesMsService {
|
|
|
99
84
|
*/
|
|
100
85
|
async updateEntityAttributes(accountId, _appName, _callerActionIdentifier, entityAttributeOperation) {
|
|
101
86
|
// Validate before processing
|
|
102
|
-
|
|
87
|
+
await super.updateEntityAttributes(accountId, _appName, _callerActionIdentifier, entityAttributeOperation);
|
|
103
88
|
await AuthorizationAttributesMsService.executeUpsertRequest(accountId, [
|
|
104
89
|
new EntityAttributeAssignment(entityAttributeOperation.entityId, entityAttributeOperation.entityType, entityAttributeOperation.key, entityAttributeOperation.value),
|
|
105
90
|
], UPSERT_ENTITY_ATTRIBUTES_PATH, 'entityAttributeAssignments', 'entity', 'upsertEntityAttributesSync');
|
|
@@ -122,9 +107,6 @@ class AuthorizationAttributesMsService {
|
|
|
122
107
|
* Generic helper for executing delete requests
|
|
123
108
|
*/
|
|
124
109
|
static async executeDeleteRequest(accountId, pathTemplate, pathParams, keys, logPrefix, methodName) {
|
|
125
|
-
// Validate inputs
|
|
126
|
-
ValidationUtils.validateInteger(accountId);
|
|
127
|
-
ValidationUtils.validateStringArray(keys);
|
|
128
110
|
if (!keys.length) {
|
|
129
111
|
logger.warn({ tag: this.LOG_TAG, accountId, ...pathParams }, `${methodName} called with empty keys array`);
|
|
130
112
|
return;
|
|
@@ -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"}
|