@mondaydotcomorg/monday-authorization 3.6.0-feat-shaime-support-entity-attributes-1-f58d933 → 3.6.0-feat-shaime-support-entity-attributes-3-0d092e0

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 (96) hide show
  1. package/dist/authorization-attributes-ms-service.d.ts +68 -0
  2. package/dist/authorization-attributes-ms-service.d.ts.map +1 -0
  3. package/dist/authorization-attributes-ms-service.js +263 -0
  4. package/dist/authorization-attributes-service.d.ts +25 -47
  5. package/dist/authorization-attributes-service.d.ts.map +1 -1
  6. package/dist/authorization-attributes-service.js +32 -171
  7. package/dist/authorization-attributes-sns-service.d.ts +84 -0
  8. package/dist/authorization-attributes-sns-service.d.ts.map +1 -0
  9. package/dist/authorization-attributes-sns-service.js +196 -0
  10. package/dist/constants/sns.d.ts +12 -2
  11. package/dist/constants/sns.d.ts.map +1 -1
  12. package/dist/constants/sns.js +22 -2
  13. package/dist/entity-attribute-assignment.d.ts.map +1 -1
  14. package/dist/entity-attribute-assignment.js +0 -2
  15. package/dist/esm/authorization-attributes-ms-service.d.ts +68 -0
  16. package/dist/esm/authorization-attributes-ms-service.d.ts.map +1 -0
  17. package/dist/esm/authorization-attributes-ms-service.mjs +261 -0
  18. package/dist/esm/authorization-attributes-service.d.ts +25 -47
  19. package/dist/esm/authorization-attributes-service.d.ts.map +1 -1
  20. package/dist/esm/authorization-attributes-service.mjs +32 -167
  21. package/dist/esm/authorization-attributes-sns-service.d.ts +84 -0
  22. package/dist/esm/authorization-attributes-sns-service.d.ts.map +1 -0
  23. package/dist/esm/authorization-attributes-sns-service.mjs +190 -0
  24. package/dist/esm/constants/sns.d.ts +12 -2
  25. package/dist/esm/constants/sns.d.ts.map +1 -1
  26. package/dist/esm/constants/sns.mjs +17 -3
  27. package/dist/esm/entity-attribute-assignment.d.ts.map +1 -1
  28. package/dist/esm/entity-attribute-assignment.mjs +0 -2
  29. package/dist/esm/index.d.ts +6 -0
  30. package/dist/esm/index.d.ts.map +1 -1
  31. package/dist/esm/index.mjs +5 -0
  32. package/dist/esm/resource-attribute-assignment.d.ts.map +1 -1
  33. package/dist/esm/resource-attribute-assignment.mjs +0 -2
  34. package/dist/esm/resource-attributes-constants.d.ts +2 -1
  35. package/dist/esm/resource-attributes-constants.d.ts.map +1 -1
  36. package/dist/esm/resource-attributes-constants.mjs +1 -0
  37. package/dist/esm/types/authorization-attributes-contracts.d.ts +2 -17
  38. package/dist/esm/types/authorization-attributes-contracts.d.ts.map +1 -1
  39. package/dist/esm/types/authorization-attributes-service.interface.d.ts +14 -25
  40. package/dist/esm/types/authorization-attributes-service.interface.d.ts.map +1 -1
  41. package/dist/esm/types/general.d.ts +4 -3
  42. package/dist/esm/types/general.d.ts.map +1 -1
  43. package/dist/esm/utils/assignment-schema.d.ts +51 -0
  44. package/dist/esm/utils/assignment-schema.d.ts.map +1 -0
  45. package/dist/esm/utils/assignment-schema.mjs +49 -0
  46. package/dist/esm/utils/resource-schema.d.ts +9 -0
  47. package/dist/esm/utils/resource-schema.d.ts.map +1 -0
  48. package/dist/esm/utils/resource-schema.mjs +16 -0
  49. package/dist/esm/utils/validation.d.ts +11 -3
  50. package/dist/esm/utils/validation.d.ts.map +1 -1
  51. package/dist/esm/utils/validation.mjs +50 -13
  52. package/dist/index.d.ts +6 -0
  53. package/dist/index.d.ts.map +1 -1
  54. package/dist/index.js +22 -0
  55. package/dist/resource-attribute-assignment.d.ts.map +1 -1
  56. package/dist/resource-attribute-assignment.js +0 -2
  57. package/dist/resource-attributes-constants.d.ts +2 -1
  58. package/dist/resource-attributes-constants.d.ts.map +1 -1
  59. package/dist/resource-attributes-constants.js +1 -0
  60. package/dist/types/authorization-attributes-contracts.d.ts +2 -17
  61. package/dist/types/authorization-attributes-contracts.d.ts.map +1 -1
  62. package/dist/types/authorization-attributes-service.interface.d.ts +14 -25
  63. package/dist/types/authorization-attributes-service.interface.d.ts.map +1 -1
  64. package/dist/types/general.d.ts +4 -3
  65. package/dist/types/general.d.ts.map +1 -1
  66. package/dist/utils/assignment-schema.d.ts +51 -0
  67. package/dist/utils/assignment-schema.d.ts.map +1 -0
  68. package/dist/utils/assignment-schema.js +58 -0
  69. package/dist/utils/resource-schema.d.ts +9 -0
  70. package/dist/utils/resource-schema.d.ts.map +1 -0
  71. package/dist/utils/resource-schema.js +22 -0
  72. package/dist/utils/validation.d.ts +11 -3
  73. package/dist/utils/validation.d.ts.map +1 -1
  74. package/dist/utils/validation.js +50 -13
  75. package/package.json +1 -1
  76. package/src/authorization-attributes-ms-service.ts +397 -0
  77. package/src/authorization-attributes-service.ts +34 -222
  78. package/src/authorization-attributes-sns-service.ts +321 -0
  79. package/src/constants/sns.ts +19 -2
  80. package/src/entity-attribute-assignment.ts +0 -2
  81. package/src/index.ts +17 -0
  82. package/src/resource-attribute-assignment.ts +0 -2
  83. package/src/resource-attributes-constants.ts +1 -0
  84. package/src/types/authorization-attributes-contracts.ts +2 -24
  85. package/src/types/authorization-attributes-service.interface.ts +19 -31
  86. package/src/types/general.ts +4 -3
  87. package/src/utils/assignment-schema.ts +51 -0
  88. package/src/utils/resource-schema.ts +16 -0
  89. package/src/utils/validation.ts +76 -15
  90. package/dist/esm/utils/assigment-schema.d.ts +0 -29
  91. package/dist/esm/utils/assigment-schema.d.ts.map +0 -1
  92. package/dist/esm/utils/assigment-schema.mjs +0 -29
  93. package/dist/utils/assigment-schema.d.ts +0 -29
  94. package/dist/utils/assigment-schema.d.ts.map +0 -1
  95. package/dist/utils/assigment-schema.js +0 -36
  96. package/src/utils/assigment-schema.ts +0 -29
@@ -0,0 +1,84 @@
1
+ import { ResourceAttributeUpsertOperation, EntityAttributeUpsertOperation, EntityAttributeDeleteOperation, ResourceAttributeDeleteOperation } from './types/authorization-attributes-contracts';
2
+ import { Resource } from './types/general';
3
+ import { AuthorizationAttributesService } from './types/authorization-attributes-service.interface';
4
+ import { EntityType } from './entity-attributes-constants';
5
+ /**
6
+ * Service class for managing resource attributes asynchronously via SNS.
7
+ * Provides asynchronous operations to create/update and delete attributes on resources.
8
+ */
9
+ export declare class AuthorizationAttributesSnsService implements AuthorizationAttributesService {
10
+ private static LOG_TAG;
11
+ private resourceSnsArn;
12
+ private entitySnsArn;
13
+ /**
14
+ * Public constructor to create the AuthorizationAttributesSnsService instance.
15
+ */
16
+ constructor();
17
+ /**
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.
20
+ * @param accountId The account ID
21
+ * @param resource The resource (resourceType, resourceId)
22
+ * @param attributeKey Attribute key to delete
23
+ * @param appName App name of the calling app
24
+ * @param callerActionIdentifier Action identifier
25
+ * @return Promise with sent operation
26
+ */
27
+ deleteResourceAttributes(accountId: number, resource: Resource, attributeKey: string, appName?: string, callerActionIdentifier?: string): Promise<ResourceAttributeDeleteOperation>;
28
+ /**
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.
31
+ * @param accountId The account ID
32
+ * @param entityType The entity type
33
+ * @param entityId The entity ID
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
38
+ */
39
+ deleteEntityAttributes(accountId: number, entityType: EntityType, entityId: number, attributeKey: string, appName?: string, callerActionIdentifier?: string): Promise<EntityAttributeDeleteOperation>;
40
+ /**
41
+ * Async function, this function only send the update request to SNS and return before the change actually took place
42
+ * @param accountId
43
+ * @param appName - App name of the calling app
44
+ * @param callerActionIdentifier - action identifier
45
+ * @param resourceAttributeOperation - Operation to do on resource attribute.
46
+ * @return {Promise<ResourceAttributeUpsertOperation>} Sent operation
47
+ * */
48
+ updateResourceAttributes(accountId: number, appName: string, callerActionIdentifier: string, resourceAttributeOperation: ResourceAttributeUpsertOperation): Promise<ResourceAttributeUpsertOperation>;
49
+ /**
50
+ * Async function, this function only send the update request to SNS and return before the change actually took place
51
+ * @param accountId
52
+ * @param appName - App name of the calling app
53
+ * @param callerActionIdentifier - action identifier
54
+ * @param entityAttributeOperation - Operation to do on entity attribute.
55
+ * @return {Promise<EntityAttributeUpsertOperation>} Sent operation
56
+ * */
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;
72
+ private sendSingleSnsMessage;
73
+ private static getSnsTopicArn;
74
+ /**
75
+ * Checks we can contact the required SNS topic that used to send attribute updates to Authorization MS.
76
+ * This function can be used as health check for services that updating resource attributes in async is crucial.
77
+ * Note this function only verify the POD can contact AWS SDK and the topic exists, but the user still might get
78
+ * errors when pushing for the SNS (e.g: in case the AWS role of the POD don't have permissions to push messages).
79
+ * However, this is the best we can do without actually push dummy messages to the SNS.
80
+ * @return {Promise<boolean>} - true if succeeded
81
+ */
82
+ asyncResourceAttributesHealthCheck(): Promise<boolean>;
83
+ }
84
+ //# sourceMappingURL=authorization-attributes-sns-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorization-attributes-sns-service.d.ts","sourceRoot":"","sources":["../src/authorization-attributes-sns-service.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,gCAAgC,EAChC,8BAA8B,EAC9B,8BAA8B,EAC9B,gCAAgC,EACjC,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAa3C,OAAO,EAAE,8BAA8B,EAAE,MAAM,oDAAoD,CAAC;AACpG,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAI3D;;;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;;;;;;;;;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;IA4B5C;;;;;;;;;;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;IAwB1C;;;;;;;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"}
@@ -0,0 +1,196 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const chunk = require('lodash/chunk.js');
4
+ const mondaySns = require('@mondaydotcomorg/monday-sns');
5
+ const types_authorizationAttributesContracts = require('./types/authorization-attributes-contracts.js');
6
+ const authorizationInternalService = require('./authorization-internal-service.js');
7
+ const constants_sns = require('./constants/sns.js');
8
+ const utils_validation = require('./utils/validation.js');
9
+
10
+ const _interopDefault = e => e && e.__esModule ? e : { default: e };
11
+
12
+ const chunk__default = /*#__PURE__*/_interopDefault(chunk);
13
+
14
+ /**
15
+ * Service class for managing resource attributes asynchronously via SNS.
16
+ * Provides asynchronous operations to create/update and delete attributes on resources.
17
+ */
18
+ class AuthorizationAttributesSnsService {
19
+ static LOG_TAG = 'authorization_attributes';
20
+ resourceSnsArn;
21
+ entitySnsArn;
22
+ /**
23
+ * Public constructor to create the AuthorizationAttributesSnsService instance.
24
+ */
25
+ constructor() {
26
+ this.resourceSnsArn = AuthorizationAttributesSnsService.getSnsTopicArn(constants_sns.SnsTopicType.RESOURCE);
27
+ this.entitySnsArn = AuthorizationAttributesSnsService.getSnsTopicArn(constants_sns.SnsTopicType.ENTITY);
28
+ }
29
+ /**
30
+ * Async function to delete a resource attribute using SNS.
31
+ * Sends the delete request to SNS and returns before the change actually took place.
32
+ * @param accountId The account ID
33
+ * @param resource The resource (resourceType, resourceId)
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
38
+ */
39
+ async deleteResourceAttributes(accountId, resource, attributeKey, appName, callerActionIdentifier) {
40
+ if (!appName || !callerActionIdentifier) {
41
+ throw new Error('appName and callerActionIdentifier are required for SNS service');
42
+ }
43
+ utils_validation.ValidationUtils.validatDeleteResourceAssignment({
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
+ };
54
+ 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
+ return result;
56
+ }
57
+ /**
58
+ * Async function to delete an entity attribute using SNS.
59
+ * Sends the delete request to SNS and returns before the change actually took place.
60
+ * @param accountId The account ID
61
+ * @param entityType The entity type
62
+ * @param entityId The entity ID
63
+ * @param attributeKey Attribute key to delete
64
+ * @param appName App name of the calling app
65
+ * @param callerActionIdentifier Action identifier
66
+ * @return Promise with sent operation
67
+ */
68
+ async deleteEntityAttributes(accountId, entityType, entityId, attributeKey, appName, callerActionIdentifier) {
69
+ if (!appName || !callerActionIdentifier) {
70
+ throw new Error('appName and callerActionIdentifier are required for SNS service');
71
+ }
72
+ utils_validation.ValidationUtils.validatDeleteEntityAssignment({ entityId, entityType, key: attributeKey });
73
+ const operation = {
74
+ entityType: entityType,
75
+ entityId,
76
+ key: attributeKey,
77
+ operationType: types_authorizationAttributesContracts.AttributeOperation.DELETE,
78
+ };
79
+ 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
+ return result;
81
+ }
82
+ /**
83
+ * Async function, this function only send the update request to SNS and return before the change actually took place
84
+ * @param accountId
85
+ * @param appName - App name of the calling app
86
+ * @param callerActionIdentifier - action identifier
87
+ * @param resourceAttributeOperation - Operation to do on resource attribute.
88
+ * @return {Promise<ResourceAttributeUpsertOperation>} Sent operation
89
+ * */
90
+ async updateResourceAttributes(accountId, appName, callerActionIdentifier, resourceAttributeOperation) {
91
+ utils_validation.ValidationUtils.validatUpsertResourceAssignment(resourceAttributeOperation);
92
+ 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
+ return result;
94
+ }
95
+ /**
96
+ * Async function, this function only send the update request to SNS and return before the change actually took place
97
+ * @param accountId
98
+ * @param appName - App name of the calling app
99
+ * @param callerActionIdentifier - action identifier
100
+ * @param entityAttributeOperation - Operation to do on entity attribute.
101
+ * @return {Promise<EntityAttributeUpsertOperation>} Sent operation
102
+ * */
103
+ async updateEntityAttributes(accountId, appName, callerActionIdentifier, entityAttributeOperation) {
104
+ utils_validation.ValidationUtils.validatUpsertEntityAssignment(entityAttributeOperation);
105
+ 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
+ return result;
107
+ }
108
+ /**
109
+ * Base function to send attribute operations to SNS.
110
+ * Chunks operations and sends them in parallel.
111
+ * @param topicArn The SNS topic ARN to send messages to
112
+ * @param accountId The account ID
113
+ * @param appName App name of the calling app
114
+ * @param callerActionIdentifier Action identifier
115
+ * @param operations Array of operations to send
116
+ * @param chunkSize Maximum number of operations per message
117
+ * @param messageKind The kind of message being sent
118
+ * @param errorLogMessage Error message to log if sending fails
119
+ * @return Promise with array of sent operations
120
+ */
121
+ async sendOperationsToSns(topicArn, accountId, appName, callerActionIdentifier, operations, chunkSize, messageKind, errorLogMessage) {
122
+ const sendToSnsPromises = [];
123
+ const operationChunks = chunk__default.default(operations, chunkSize);
124
+ for (const operationsChunk of operationChunks) {
125
+ sendToSnsPromises.push(this.sendSingleSnsMessage(topicArn, accountId, appName, callerActionIdentifier, operationsChunk, messageKind, errorLogMessage));
126
+ }
127
+ return (await Promise.all(sendToSnsPromises)).flat();
128
+ }
129
+ async sendSingleSnsMessage(topicArn, accountId, appName, callerActionIdentifier, operations, kind, errorLogMessage) {
130
+ const payload = {
131
+ kind,
132
+ payload: {
133
+ accountId: accountId,
134
+ callerAppName: appName,
135
+ callerActionIdentifier: callerActionIdentifier,
136
+ operations: operations,
137
+ },
138
+ };
139
+ try {
140
+ await mondaySns.sendToSns(payload, topicArn);
141
+ return operations;
142
+ }
143
+ catch (error) {
144
+ authorizationInternalService.logger.error({ error, tag: AuthorizationAttributesSnsService.LOG_TAG }, errorLogMessage);
145
+ return [];
146
+ }
147
+ }
148
+ static getSnsTopicArn(type) {
149
+ let envVarName;
150
+ let devTestName;
151
+ switch (type) {
152
+ case constants_sns.SnsTopicType.ENTITY:
153
+ envVarName = constants_sns.ENTITY_SNS_ARN_ENV_VAR_NAME;
154
+ devTestName = constants_sns.ENTITY_SNS_DEV_TEST_NAME;
155
+ break;
156
+ default:
157
+ // Default to resource SNS constants
158
+ envVarName = constants_sns.RESOURCE_SNS_ARN_ENV_VAR_NAME;
159
+ devTestName = constants_sns.RESOURCE_SNS_DEV_TEST_NAME;
160
+ break;
161
+ }
162
+ const arnFromEnv = process.env[envVarName];
163
+ if (arnFromEnv) {
164
+ return arnFromEnv;
165
+ }
166
+ if (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') {
167
+ return devTestName;
168
+ }
169
+ throw new Error(`Unable to get ${type} sns topic arn from env variable`);
170
+ }
171
+ /**
172
+ * Checks we can contact the required SNS topic that used to send attribute updates to Authorization MS.
173
+ * This function can be used as health check for services that updating resource attributes in async is crucial.
174
+ * Note this function only verify the POD can contact AWS SDK and the topic exists, but the user still might get
175
+ * errors when pushing for the SNS (e.g: in case the AWS role of the POD don't have permissions to push messages).
176
+ * However, this is the best we can do without actually push dummy messages to the SNS.
177
+ * @return {Promise<boolean>} - true if succeeded
178
+ */
179
+ async asyncResourceAttributesHealthCheck() {
180
+ try {
181
+ const requestedTopicArn = this.resourceSnsArn;
182
+ const attributes = await mondaySns.getTopicAttributes(requestedTopicArn);
183
+ const isHealthy = !(!attributes || !('TopicArn' in attributes) || attributes.TopicArn !== requestedTopicArn);
184
+ if (!isHealthy) {
185
+ authorizationInternalService.logger.error({ requestedTopicArn, snsReturnedAttributes: attributes, tag: AuthorizationAttributesSnsService.LOG_TAG }, 'authorization-attributes-service failed in health check');
186
+ }
187
+ return isHealthy;
188
+ }
189
+ catch (error) {
190
+ authorizationInternalService.logger.error({ error, tag: AuthorizationAttributesSnsService.LOG_TAG }, 'authorization-attributes-service got error during health check');
191
+ return false;
192
+ }
193
+ }
194
+ }
195
+
196
+ exports.AuthorizationAttributesSnsService = AuthorizationAttributesSnsService;
@@ -1,5 +1,15 @@
1
- export declare const SNS_ARN_ENV_VAR_NAME = "SHARED_AUTHORIZATION_SNS_ENDPOINT_RESOURCE_ATTRIBUTES";
2
- export declare const SNS_DEV_TEST_NAME = "arn:aws:sns:us-east-1:000000000000:monday-authorization-resource-attributes-sns-local";
1
+ export declare enum SnsTopicType {
2
+ RESOURCE = "resource",
3
+ ENTITY = "entity"
4
+ }
5
+ export declare const RESOURCE_SNS_ARN_ENV_VAR_NAME = "SHARED_AUTHORIZATION_SNS_ENDPOINT_RESOURCE_ATTRIBUTES";
6
+ export declare const RESOURCE_SNS_DEV_TEST_NAME = "arn:aws:sns:us-east-1:000000000000:monday-authorization-resource-attributes-sns-local";
7
+ export declare const ENTITY_SNS_ARN_ENV_VAR_NAME = "SHARED_AUTHORIZATION_SNS_ENDPOINT_ENTITY_ATTRIBUTES";
8
+ export declare const ENTITY_SNS_DEV_TEST_NAME = "arn:aws:sns:us-east-1:000000000000:monday-authorization-entity-attributes-sns-local";
3
9
  export declare const RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND = "resourceAttributeModification";
10
+ export declare const ENTITY_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND = "entityAttributeModification";
4
11
  export declare const ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE = 100;
12
+ export declare const ASYNC_ENTITY_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE = 100;
13
+ export declare const SNS_ARN_ENV_VAR_NAME = "SHARED_AUTHORIZATION_SNS_ENDPOINT_RESOURCE_ATTRIBUTES";
14
+ export declare const SNS_DEV_TEST_NAME = "arn:aws:sns:us-east-1:000000000000:monday-authorization-resource-attributes-sns-local";
5
15
  //# sourceMappingURL=sns.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sns.d.ts","sourceRoot":"","sources":["../../src/constants/sns.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,0DAA0D,CAAC;AAC5F,eAAO,MAAM,iBAAiB,0FAC2D,CAAC;AAC1F,eAAO,MAAM,qDAAqD,kCAAkC,CAAC;AACrG,eAAO,MAAM,oDAAoD,MAAM,CAAC"}
1
+ {"version":3,"file":"sns.d.ts","sourceRoot":"","sources":["../../src/constants/sns.ts"],"names":[],"mappings":"AAAA,oBAAY,YAAY;IACtB,QAAQ,aAAa;IACrB,MAAM,WAAW;CAClB;AAGD,eAAO,MAAM,6BAA6B,0DAA0D,CAAC;AACrG,eAAO,MAAM,0BAA0B,0FACkD,CAAC;AAG1F,eAAO,MAAM,2BAA2B,wDAAwD,CAAC;AACjG,eAAO,MAAM,wBAAwB,wFACkD,CAAC;AACxF,eAAO,MAAM,qDAAqD,kCAAkC,CAAC;AACrG,eAAO,MAAM,mDAAmD,gCAAgC,CAAC;AACjG,eAAO,MAAM,oDAAoD,MAAM,CAAC;AACxE,eAAO,MAAM,kDAAkD,MAAM,CAAC;AAGtE,eAAO,MAAM,oBAAoB,0DAAgC,CAAC;AAClE,eAAO,MAAM,iBAAiB,0FAA6B,CAAC"}
@@ -1,11 +1,31 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
- const SNS_ARN_ENV_VAR_NAME = 'SHARED_AUTHORIZATION_SNS_ENDPOINT_RESOURCE_ATTRIBUTES';
4
- const SNS_DEV_TEST_NAME = 'arn:aws:sns:us-east-1:000000000000:monday-authorization-resource-attributes-sns-local';
3
+ exports.SnsTopicType = void 0;
4
+ (function (SnsTopicType) {
5
+ SnsTopicType["RESOURCE"] = "resource";
6
+ SnsTopicType["ENTITY"] = "entity";
7
+ })(exports.SnsTopicType || (exports.SnsTopicType = {}));
8
+ // Resource SNS constants
9
+ const RESOURCE_SNS_ARN_ENV_VAR_NAME = 'SHARED_AUTHORIZATION_SNS_ENDPOINT_RESOURCE_ATTRIBUTES';
10
+ const RESOURCE_SNS_DEV_TEST_NAME = 'arn:aws:sns:us-east-1:000000000000:monday-authorization-resource-attributes-sns-local';
11
+ // Entity SNS constants
12
+ const ENTITY_SNS_ARN_ENV_VAR_NAME = 'SHARED_AUTHORIZATION_SNS_ENDPOINT_ENTITY_ATTRIBUTES';
13
+ const ENTITY_SNS_DEV_TEST_NAME = 'arn:aws:sns:us-east-1:000000000000:monday-authorization-entity-attributes-sns-local';
5
14
  const RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND = 'resourceAttributeModification';
15
+ const ENTITY_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND = 'entityAttributeModification';
6
16
  const ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE = 100;
17
+ const ASYNC_ENTITY_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE = 100;
18
+ // Legacy exports for backward compatibility
19
+ const SNS_ARN_ENV_VAR_NAME = RESOURCE_SNS_ARN_ENV_VAR_NAME;
20
+ const SNS_DEV_TEST_NAME = RESOURCE_SNS_DEV_TEST_NAME;
7
21
 
22
+ exports.ASYNC_ENTITY_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE = ASYNC_ENTITY_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE;
8
23
  exports.ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE = ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE;
24
+ exports.ENTITY_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND = ENTITY_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND;
25
+ exports.ENTITY_SNS_ARN_ENV_VAR_NAME = ENTITY_SNS_ARN_ENV_VAR_NAME;
26
+ exports.ENTITY_SNS_DEV_TEST_NAME = ENTITY_SNS_DEV_TEST_NAME;
9
27
  exports.RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND = RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND;
28
+ exports.RESOURCE_SNS_ARN_ENV_VAR_NAME = RESOURCE_SNS_ARN_ENV_VAR_NAME;
29
+ exports.RESOURCE_SNS_DEV_TEST_NAME = RESOURCE_SNS_DEV_TEST_NAME;
10
30
  exports.SNS_ARN_ENV_VAR_NAME = SNS_ARN_ENV_VAR_NAME;
11
31
  exports.SNS_DEV_TEST_NAME = SNS_DEV_TEST_NAME;
@@ -1 +1 @@
1
- {"version":3,"file":"entity-attribute-assignment.d.ts","sourceRoot":"","sources":["../src/entity-attribute-assignment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,yBAAyB,IAAI,iCAAiC,EAAE,MAAM,4CAA4C,CAAC;AAG5H,qBAAa,yBAA0B,SAAQ,uBAAuB,CAAC,UAAU,EAAE,iCAAiC,CAAC;IACnH,SAAgB,QAAQ,EAAE,MAAM,CAAC;IACjC,SAAgB,UAAU,EAAE,UAAU,CAAC;gBAE3B,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAOhF,oBAAoB,IAAI,iCAAiC;IAQzD;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO;CAGlD"}
1
+ {"version":3,"file":"entity-attribute-assignment.d.ts","sourceRoot":"","sources":["../src/entity-attribute-assignment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,yBAAyB,IAAI,iCAAiC,EAAE,MAAM,4CAA4C,CAAC;AAE5H,qBAAa,yBAA0B,SAAQ,uBAAuB,CAAC,UAAU,EAAE,iCAAiC,CAAC;IACnH,SAAgB,QAAQ,EAAE,MAAM,CAAC;IACjC,SAAgB,UAAU,EAAE,UAAU,CAAC;gBAE3B,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAMhF,oBAAoB,IAAI,iCAAiC;IAQzD;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO;CAGlD"}
@@ -1,13 +1,11 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
3
  const baseAttributeAssignment = require('./base-attribute-assignment.js');
4
- const utils_validation = require('./utils/validation.js');
5
4
 
6
5
  class EntityAttributeAssignment extends baseAttributeAssignment.BaseAttributeAssignment {
7
6
  entityId;
8
7
  entityType;
9
8
  constructor(entityId, entityType, key, value) {
10
- utils_validation.ValidationUtils.validateEntityAssignment({ entityId, entityType, key, value });
11
9
  super(entityId, entityType, key, value);
12
10
  this.entityId = entityId;
13
11
  this.entityType = entityType;
@@ -0,0 +1,68 @@
1
+ import { ResourceAttributeUpsertOperation, ResourceAttributeDeleteOperation, EntityAttributeUpsertOperation, EntityAttributeDeleteOperation } from './types/authorization-attributes-contracts';
2
+ import { EntityType } from './entity-attributes-constants';
3
+ import { AuthorizationAttributesService } from './types/authorization-attributes-service.interface';
4
+ import { Resource } from './types/general';
5
+ /**
6
+ * Service class for managing resource attributes in the authorization microservice.
7
+ * Provides synchronous HTTP operations to create/update and delete attributes on resources.
8
+ */
9
+ export declare class AuthorizationAttributesMsService implements AuthorizationAttributesService {
10
+ private static LOG_TAG;
11
+ private static httpClient;
12
+ constructor();
13
+ /**
14
+ * Deletes a specific attribute from a resource synchronously.
15
+ * @param accountId The account ID
16
+ * @param resource Object with resourceType (string) and resourceId (number)
17
+ * @param attributeKey Attribute key string to delete
18
+ * @returns Promise<ResourceAttributeDeleteOperation>
19
+ */
20
+ deleteResourceAttributes(accountId: number, resource: Resource, attributeKey: string, _appName?: string, _callerActionIdentifier?: string): Promise<ResourceAttributeDeleteOperation>;
21
+ /**
22
+ * Deletes a specific attribute from an entity synchronously.
23
+ * @param accountId The account ID
24
+ * @param entityType The entity type
25
+ * @param entityId The entity ID
26
+ * @param attributeKey Attribute key string to delete
27
+ * @returns Promise<EntityAttributeDeleteOperation>
28
+ */
29
+ deleteEntityAttributes(accountId: number, entityType: EntityType, entityId: number, attributeKey: string, _appName?: string, _callerActionIdentifier?: string): Promise<EntityAttributeDeleteOperation>;
30
+ /**
31
+ * Updates a resource attribute (single operation - upsert only).
32
+ * @param accountId The account ID
33
+ * @param appName App name (required for interface compatibility, but not used in MS service)
34
+ * @param callerActionIdentifier Action identifier (required for interface compatibility, but not used in MS service)
35
+ * @param resourceAttributeOperation Operation to perform (must be UPSERT)
36
+ * @returns Promise<ResourceAttributeUpsertOperation> Processed operation
37
+ */
38
+ updateResourceAttributes(accountId: number, _appName: string, _callerActionIdentifier: string, resourceAttributeOperation: ResourceAttributeUpsertOperation): Promise<ResourceAttributeUpsertOperation>;
39
+ /**
40
+ * Updates an entity attribute (single operation - upsert only).
41
+ * @param accountId The account ID
42
+ * @param appName App name (required for interface compatibility, but not used in MS service)
43
+ * @param callerActionIdentifier Action identifier (required for interface compatibility, but not used in MS service)
44
+ * @param entityAttributeOperation Operation to perform (must be UPSERT)
45
+ * @returns Promise<EntityAttributeUpsertOperation> Processed operation
46
+ */
47
+ updateEntityAttributes(accountId: number, _appName: string, _callerActionIdentifier: string, entityAttributeOperation: EntityAttributeUpsertOperation): Promise<EntityAttributeUpsertOperation>;
48
+ /**
49
+ * Replaces path template parameters with actual values
50
+ * @param template Path template with placeholders like {accountId}
51
+ * @param params Object with parameter names and values
52
+ * @returns Path with all placeholders replaced
53
+ */
54
+ private static replacePathParams;
55
+ /**
56
+ * Generic helper for executing delete requests
57
+ */
58
+ private static executeDeleteRequest;
59
+ /**
60
+ * Gets request headers including Authorization, Content-Type, and optional attribution headers
61
+ */
62
+ private static getRequestHeaders;
63
+ /**
64
+ * Generic helper for executing upsert requests
65
+ */
66
+ private static executeUpsertRequest;
67
+ }
68
+ //# sourceMappingURL=authorization-attributes-ms-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorization-attributes-ms-service.d.ts","sourceRoot":"","sources":["../../src/authorization-attributes-ms-service.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,gCAAgC,EAChC,gCAAgC,EAChC,8BAA8B,EAC9B,8BAA8B,EAC/B,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAK3D,OAAO,EAAE,8BAA8B,EAAE,MAAM,oDAAoD,CAAC;AACpG,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAY3C;;;GAGG;AACH,qBAAa,gCAAiC,YAAW,8BAA8B;IACrF,OAAO,CAAC,MAAM,CAAC,OAAO,CAAiC;IACvD,OAAO,CAAC,MAAM,CAAC,UAAU,CAAqD;;IAW9E;;;;;;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;IA0B5C;;;;;;;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;IA0B5C;;;;;;;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;IA4B1C;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAQhC;;OAEG;mBACkB,oBAAoB;IAiEzC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,iBAAiB;IA+ChC;;OAEG;mBACkB,oBAAoB;CA4D1C"}