@mondaydotcomorg/monday-authorization 3.7.0-feat-shaime-support-entity-attributes-4-49e1de0 → 3.7.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.
Files changed (115) hide show
  1. package/README.md +7 -1
  2. package/dist/authorization-attributes-ms-service.d.ts +20 -40
  3. package/dist/authorization-attributes-ms-service.d.ts.map +1 -1
  4. package/dist/authorization-attributes-ms-service.js +48 -103
  5. package/dist/authorization-attributes-service.d.ts +12 -10
  6. package/dist/authorization-attributes-service.d.ts.map +1 -1
  7. package/dist/authorization-attributes-service.js +17 -15
  8. package/dist/authorization-attributes-sns-service.d.ts +37 -44
  9. package/dist/authorization-attributes-sns-service.d.ts.map +1 -1
  10. package/dist/authorization-attributes-sns-service.js +53 -90
  11. package/dist/authorization-service.d.ts +0 -1
  12. package/dist/authorization-service.d.ts.map +1 -1
  13. package/dist/authorization-service.js +2 -22
  14. package/dist/base-attribute-assignment.d.ts +6 -7
  15. package/dist/base-attribute-assignment.d.ts.map +1 -1
  16. package/dist/base-attribute-assignment.js +5 -7
  17. package/dist/base-authorization-attributes-service.d.ts +32 -0
  18. package/dist/base-authorization-attributes-service.d.ts.map +1 -0
  19. package/dist/base-authorization-attributes-service.js +63 -0
  20. package/dist/entity-attribute-assignment.d.ts +4 -8
  21. package/dist/entity-attribute-assignment.d.ts.map +1 -1
  22. package/dist/entity-attribute-assignment.js +3 -4
  23. package/dist/esm/authorization-attributes-ms-service.d.ts +20 -40
  24. package/dist/esm/authorization-attributes-ms-service.d.ts.map +1 -1
  25. package/dist/esm/authorization-attributes-ms-service.mjs +48 -103
  26. package/dist/esm/authorization-attributes-service.d.ts +12 -10
  27. package/dist/esm/authorization-attributes-service.d.ts.map +1 -1
  28. package/dist/esm/authorization-attributes-service.mjs +17 -15
  29. package/dist/esm/authorization-attributes-sns-service.d.ts +37 -44
  30. package/dist/esm/authorization-attributes-sns-service.d.ts.map +1 -1
  31. package/dist/esm/authorization-attributes-sns-service.mjs +53 -90
  32. package/dist/esm/authorization-service.d.ts +0 -1
  33. package/dist/esm/authorization-service.d.ts.map +1 -1
  34. package/dist/esm/authorization-service.mjs +3 -23
  35. package/dist/esm/base-attribute-assignment.d.ts +6 -7
  36. package/dist/esm/base-attribute-assignment.d.ts.map +1 -1
  37. package/dist/esm/base-attribute-assignment.mjs +5 -7
  38. package/dist/esm/base-authorization-attributes-service.d.ts +32 -0
  39. package/dist/esm/base-authorization-attributes-service.d.ts.map +1 -0
  40. package/dist/esm/base-authorization-attributes-service.mjs +61 -0
  41. package/dist/esm/entity-attribute-assignment.d.ts +4 -8
  42. package/dist/esm/entity-attribute-assignment.d.ts.map +1 -1
  43. package/dist/esm/entity-attribute-assignment.mjs +3 -4
  44. package/dist/esm/index.d.ts +6 -0
  45. package/dist/esm/index.d.ts.map +1 -1
  46. package/dist/esm/index.mjs +6 -0
  47. package/dist/esm/resource-attribute-assignment.d.ts +3 -7
  48. package/dist/esm/resource-attribute-assignment.d.ts.map +1 -1
  49. package/dist/esm/resource-attribute-assignment.mjs +8 -2
  50. package/dist/esm/resource-attributes-constants.d.ts +12 -10
  51. package/dist/esm/resource-attributes-constants.d.ts.map +1 -1
  52. package/dist/esm/resource-attributes-constants.mjs +4 -2
  53. package/dist/esm/testKit/index.d.ts +4 -4
  54. package/dist/esm/testKit/index.d.ts.map +1 -1
  55. package/dist/esm/types/authorization-attributes-contracts.d.ts +7 -21
  56. package/dist/esm/types/authorization-attributes-contracts.d.ts.map +1 -1
  57. package/dist/esm/types/general.d.ts +4 -3
  58. package/dist/esm/types/general.d.ts.map +1 -1
  59. package/dist/esm/utils/assignment-schema.d.ts +51 -0
  60. package/dist/esm/utils/assignment-schema.d.ts.map +1 -0
  61. package/dist/esm/utils/assignment-schema.mjs +54 -0
  62. package/dist/esm/utils/resource-schema.d.ts +9 -0
  63. package/dist/esm/utils/resource-schema.d.ts.map +1 -0
  64. package/dist/esm/utils/resource-schema.mjs +16 -0
  65. package/dist/esm/utils/validation.d.ts +11 -28
  66. package/dist/esm/utils/validation.d.ts.map +1 -1
  67. package/dist/esm/utils/validation.mjs +61 -118
  68. package/dist/index.d.ts +6 -0
  69. package/dist/index.d.ts.map +1 -1
  70. package/dist/index.js +24 -0
  71. package/dist/resource-attribute-assignment.d.ts +3 -7
  72. package/dist/resource-attribute-assignment.d.ts.map +1 -1
  73. package/dist/resource-attribute-assignment.js +8 -2
  74. package/dist/resource-attributes-constants.d.ts +12 -10
  75. package/dist/resource-attributes-constants.d.ts.map +1 -1
  76. package/dist/resource-attributes-constants.js +4 -2
  77. package/dist/testKit/index.d.ts +4 -4
  78. package/dist/testKit/index.d.ts.map +1 -1
  79. package/dist/types/authorization-attributes-contracts.d.ts +7 -21
  80. package/dist/types/authorization-attributes-contracts.d.ts.map +1 -1
  81. package/dist/types/general.d.ts +4 -3
  82. package/dist/types/general.d.ts.map +1 -1
  83. package/dist/utils/assignment-schema.d.ts +51 -0
  84. package/dist/utils/assignment-schema.d.ts.map +1 -0
  85. package/dist/utils/assignment-schema.js +63 -0
  86. package/dist/utils/resource-schema.d.ts +9 -0
  87. package/dist/utils/resource-schema.d.ts.map +1 -0
  88. package/dist/utils/resource-schema.js +22 -0
  89. package/dist/utils/validation.d.ts +11 -28
  90. package/dist/utils/validation.d.ts.map +1 -1
  91. package/dist/utils/validation.js +61 -118
  92. package/package.json +2 -3
  93. package/src/authorization-attributes-ms-service.ts +92 -154
  94. package/src/authorization-attributes-service.ts +18 -16
  95. package/src/authorization-attributes-sns-service.ts +132 -131
  96. package/src/authorization-service.ts +3 -28
  97. package/src/base-attribute-assignment.ts +10 -26
  98. package/src/base-authorization-attributes-service.ts +90 -0
  99. package/src/entity-attribute-assignment.ts +7 -6
  100. package/src/index.ts +17 -0
  101. package/src/resource-attribute-assignment.ts +13 -10
  102. package/src/resource-attributes-constants.ts +4 -2
  103. package/src/testKit/index.ts +5 -5
  104. package/src/types/authorization-attributes-contracts.ts +7 -27
  105. package/src/types/general.ts +4 -3
  106. package/src/utils/assignment-schema.ts +56 -0
  107. package/src/utils/resource-schema.ts +16 -0
  108. package/src/utils/validation.ts +90 -137
  109. package/dist/esm/types/authorization-attributes-service.interface.d.ts +0 -57
  110. package/dist/esm/types/authorization-attributes-service.interface.d.ts.map +0 -1
  111. package/dist/esm/types/authorization-attributes-service.interface.mjs +0 -1
  112. package/dist/types/authorization-attributes-service.interface.d.ts +0 -57
  113. package/dist/types/authorization-attributes-service.interface.d.ts.map +0 -1
  114. package/dist/types/authorization-attributes-service.interface.js +0 -1
  115. 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 { ValidationUtils } from './utils/validation.mjs';
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') ?? null;
24
- static destroyHttpClient() {
25
- AuthorizationAttributesMsService.httpClient = null;
26
- }
27
- /**
28
- * Creates or updates resource attributes synchronously.
29
- * @param accountId The account ID
30
- * @param resourceAttributeAssignments Array of ResourceAttributeAssignment objects
31
- * @returns Promise<void>
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 attributes from a resource synchronously.
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 attributeKeys Array of attribute key strings to delete
41
- * @returns Promise<void>
35
+ * @param attributeKey Attribute key string to delete
36
+ * @returns Promise<ResourceAttributeDeleteOperation>
42
37
  */
43
- async deleteResourceAttributes(accountId, resource, attributeKeys, _appName, _callerActionIdentifier) {
44
- ValidationUtils.validateResource(resource);
45
- ValidationUtils.validateStringArray(attributeKeys);
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
- }, attributeKeys, 'resource', 'deleteResourceAttributesSync', { resource });
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 attributes from an entity synchronously.
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 attributeKeys Array of attribute key strings to delete
66
- * @returns Promise<void>
51
+ * @param attributeKey Attribute key string to delete
52
+ * @returns Promise<EntityAttributeDeleteOperation>
67
53
  */
68
- async deleteEntityAttributes(accountId, entityType, entityId, attributeKeys, _appName, _callerActionIdentifier) {
69
- if (!entityType || typeof entityType !== 'string' || entityType.trim() === '') {
70
- throw new ArgumentError(`entityType must be a non-empty string, got: ${entityType}`);
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
- }, attributeKeys, 'entity', 'deleteEntityAttributesSync', { entityType, entityId });
59
+ }, [attributeKey], 'entity', 'deleteEntityAttributesSync');
60
+ return operation;
77
61
  }
78
62
  /**
79
- * Updates resource attributes (batch operations).
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 resourceAttributeOperations Array of operations to perform
86
- * @returns Promise<ResourceAttributesOperation[]> Array of processed operations
67
+ * @param resourceAttributeOperation Operation to perform (must be UPSERT)
68
+ * @returns Promise<ResourceAttributeUpsertOperation> Processed operation
87
69
  */
88
- async updateResourceAttributes(accountId, _appName, _callerActionIdentifier, resourceAttributeOperations) {
89
- const processedOperations = [];
90
- for (const operation of resourceAttributeOperations) {
91
- if (operation.operationType === AttributeOperation.UPSERT) {
92
- if (!operation.resourceId) {
93
- throw new ArgumentError('resourceId is required for upsert operation');
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 attributes (batch operations).
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 entityAttributeOperations Array of operations to perform
121
- * @returns Promise<EntityAttributesOperation[]> Array of processed operations
82
+ * @param entityAttributeOperation Operation to perform (must be UPSERT)
83
+ * @returns Promise<EntityAttributeUpsertOperation> Processed operation
122
84
  */
123
- async updateEntityAttributes(accountId, _appName, _callerActionIdentifier, entityAttributeOperations) {
124
- const processedOperations = [];
125
- for (const operation of entityAttributeOperations) {
126
- if (operation.operationType === 'upsert') {
127
- await this.upsertEntityAttributes(accountId, [
128
- new EntityAttributeAssignment(operation.entityId, operation.entityType, operation.key, operation.value || ''),
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, context = {}) {
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, assignmentClass, logPrefix, methodName) {
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 { AuthorizationAttributesService as IAuthorizationAttributesService } from './types/authorization-attributes-service.interface';
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 (MS) and SNS operations.
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 operations
10
- * await service.direct().upsertResourceAttributes(accountId, assignments);
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().upsertResourceAttributes(accountId, assignments, appName, actionId);
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 _directService;
18
- private _snsService;
17
+ private httpService;
18
+ private snsService;
19
19
  /**
20
- * Gets the direct (MS) service instance.
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
- direct(): IAuthorizationAttributesService;
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,8BAA8B,IAAI,+BAA+B,EAAE,MAAM,oDAAoD,CAAC;AAEvI;;;;;;;;;;;;;GAaG;AACH,qBAAa,8BAA8B;IACzC,OAAO,CAAC,cAAc,CAAiD;IACvE,OAAO,CAAC,WAAW,CAAkD;IAErE;;;;OAIG;IACH,MAAM,IAAI,+BAA+B;IAOzC;;;;OAIG;IACH,GAAG,IAAI,+BAA+B;CAMvC"}
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 (MS) and SNS operations.
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 operations
12
- * await service.direct().upsertResourceAttributes(accountId, assignments);
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().upsertResourceAttributes(accountId, assignments, appName, actionId);
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
- _directService = null;
20
- _snsService = null;
19
+ httpService = null;
20
+ snsService = null;
21
21
  /**
22
- * Gets the direct (MS) service instance.
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
- direct() {
27
- if (this._directService === null) {
28
- this._directService = new AuthorizationAttributesMsService();
27
+ http() {
28
+ if (this.httpService === null) {
29
+ this.httpService = new AuthorizationAttributesMsService();
29
30
  }
30
- return this._directService;
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._snsService === null) {
39
- this._snsService = new AuthorizationAttributesSnsService();
40
+ if (this.snsService === null) {
41
+ this.snsService = new AuthorizationAttributesSnsService();
40
42
  }
41
- return this._snsService;
43
+ return this.snsService;
42
44
  }
43
45
  }
44
46
 
@@ -1,13 +1,12 @@
1
- import { ResourceAttributeAssignment, ResourceAttributeOperation, EntityAttributeOperation } from './types/authorization-attributes-contracts';
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 { AuthorizationAttributesService } from './types/authorization-attributes-service.interface';
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 implements AuthorizationAttributesService {
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 upsert resource attributes using SNS.
20
- * Sends the updates request to SNS and returns before the change actually took place.
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 attributeKeys Array of attribute keys to delete
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
- * @param entityAttributeAssignments Array of entity attribute assignments to upsert
46
- * @return Promise with array of sent operations
25
+ * @return Promise with sent operation
47
26
  */
48
- upsertEntityAttributes(accountId: number, entityAttributeAssignments: EntityAttributeAssignment[], appName?: string, callerActionIdentifier?: string): Promise<EntityAttributeOperation[]>;
27
+ deleteResourceAttributes(accountId: number, resource: Resource, attributeKey: string, appName?: string, callerActionIdentifier?: string): Promise<ResourceAttributeDeleteOperation>;
49
28
  /**
50
- * Async function to delete entity attributes using SNS.
51
- * Sends the updates request to SNS and returns before the change actually took place.
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 attributeKeys Array of attribute keys to delete
58
- * @return Promise with array of sent operations
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 | string, entityId: number, attributeKeys: string[], appName?: string, callerActionIdentifier?: string): Promise<EntityAttributeOperation[]>;
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 updates request to SNS and return before the change actually took place
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 resourceAttributeOperations - Array of operations to do on resource attributes.
67
- * @return {Promise<ResourceAttributesOperation[]>} Array of sent operations
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, resourceAttributeOperations: ResourceAttributeOperation[]): Promise<ResourceAttributeOperation[]>;
48
+ updateResourceAttributes(accountId: number, appName: string, callerActionIdentifier: string, resourceAttributeOperation: ResourceAttributeUpsertOperation): Promise<ResourceAttributeUpsertOperation>;
70
49
  /**
71
- * Async function, this function only send the updates request to SNS and return before the change actually took place
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 entityAttributeOperations - Array of operations to do on entity attributes.
76
- * @return {Promise<EntityAttributeOperation[]>} Array of sent operations
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, entityAttributeOperations: EntityAttributeOperation[]): Promise<EntityAttributeOperation[]>;
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,2BAA2B,EAC3B,0BAA0B,EAC1B,wBAAwB,EAEzB,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAc3C,OAAO,EAAE,8BAA8B,EAAE,MAAM,oDAAoD,CAAC;AACpG,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D;;;GAGG;AACH,qBAAa,iCAAkC,YAAW,8BAA8B;IACtF,OAAO,CAAC,MAAM,CAAC,OAAO,CAA8B;IACpD,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,YAAY,CAAS;IAE7B;;OAEG;;IAMH;;;;;;;;OAQG;IACG,wBAAwB,CAC5B,SAAS,EAAE,MAAM,EACjB,4BAA4B,EAAE,2BAA2B,EAAE,EAC3D,OAAO,CAAC,EAAE,MAAM,EAChB,sBAAsB,CAAC,EAAE,MAAM,GAC9B,OAAO,CAAC,0BAA0B,EAAE,CAAC;IAWxC;;;;;;;;;OASG;IACG,wBAAwB,CAC5B,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,QAAQ,EAClB,aAAa,EAAE,MAAM,EAAE,EACvB,OAAO,CAAC,EAAE,MAAM,EAChB,sBAAsB,CAAC,EAAE,MAAM,GAC9B,OAAO,CAAC,0BAA0B,EAAE,CAAC;IAgBxC;;;;;;;;OAQG;IACG,sBAAsB,CAC1B,SAAS,EAAE,MAAM,EACjB,0BAA0B,EAAE,yBAAyB,EAAE,EACvD,OAAO,CAAC,EAAE,MAAM,EAChB,sBAAsB,CAAC,EAAE,MAAM,GAC9B,OAAO,CAAC,wBAAwB,EAAE,CAAC;IAgBtC;;;;;;;;;;OAUG;IACG,sBAAsB,CAC1B,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,UAAU,GAAG,MAAM,EAC/B,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,EAAE,EACvB,OAAO,CAAC,EAAE,MAAM,EAChB,sBAAsB,CAAC,EAAE,MAAM,GAC9B,OAAO,CAAC,wBAAwB,EAAE,CAAC;IAgBtC;;;;;;;UAOM;IACA,wBAAwB,CAC5B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,sBAAsB,EAAE,MAAM,EAC9B,2BAA2B,EAAE,0BAA0B,EAAE,GACxD,OAAO,CAAC,0BAA0B,EAAE,CAAC;IAoBxC;;;;;;;UAOM;IACA,sBAAsB,CAC1B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,sBAAsB,EAAE,MAAM,EAC9B,yBAAyB,EAAE,wBAAwB,EAAE,GACpD,OAAO,CAAC,wBAAwB,EAAE,CAAC;YAoBxB,oBAAoB;IA2BlC,OAAO,CAAC,MAAM,CAAC,cAAc;IA0B7B;;;;;;;OAOG;IACG,kCAAkC,IAAI,OAAO,CAAC,OAAO,CAAC;CAoB7D"}
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"}