@mondaydotcomorg/monday-authorization 3.5.0 → 3.5.1-feat-shaime-support-entity-attributes-in-authorization-sdk-d2be13e

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 (121) hide show
  1. package/dist/attributions-service.d.ts.map +1 -1
  2. package/dist/attributions-service.js +1 -0
  3. package/dist/authorization-attributes-ms-service.d.ts +67 -0
  4. package/dist/authorization-attributes-ms-service.d.ts.map +1 -0
  5. package/dist/authorization-attributes-ms-service.js +256 -0
  6. package/dist/authorization-attributes-sns-service.d.ts +85 -0
  7. package/dist/authorization-attributes-sns-service.d.ts.map +1 -0
  8. package/dist/authorization-attributes-sns-service.js +203 -0
  9. package/dist/base-attribute-assignment.d.ts +18 -0
  10. package/dist/base-attribute-assignment.d.ts.map +1 -0
  11. package/dist/base-attribute-assignment.js +43 -0
  12. package/dist/clients/graph-api.d.ts.map +1 -1
  13. package/dist/clients/graph-api.js +1 -0
  14. package/dist/constants/sns.d.ts +12 -2
  15. package/dist/constants/sns.d.ts.map +1 -1
  16. package/dist/constants/sns.js +22 -2
  17. package/dist/constants.d.ts +3 -0
  18. package/dist/constants.d.ts.map +1 -1
  19. package/dist/constants.js +4 -0
  20. package/dist/entity-attribute-assignment.d.ts +24 -0
  21. package/dist/entity-attribute-assignment.d.ts.map +1 -0
  22. package/dist/entity-attribute-assignment.js +36 -0
  23. package/dist/entity-attributes-constants.d.ts +7 -0
  24. package/dist/entity-attributes-constants.d.ts.map +1 -0
  25. package/dist/entity-attributes-constants.js +9 -0
  26. package/dist/errors/argument-error.d.ts +4 -0
  27. package/dist/errors/argument-error.d.ts.map +1 -0
  28. package/dist/errors/argument-error.js +11 -0
  29. package/dist/esm/attributions-service.d.ts.map +1 -1
  30. package/dist/esm/attributions-service.mjs +1 -0
  31. package/dist/esm/authorization-attributes-ms-service.d.ts +67 -0
  32. package/dist/esm/authorization-attributes-ms-service.d.ts.map +1 -0
  33. package/dist/esm/authorization-attributes-ms-service.mjs +254 -0
  34. package/dist/esm/authorization-attributes-sns-service.d.ts +85 -0
  35. package/dist/esm/authorization-attributes-sns-service.d.ts.map +1 -0
  36. package/dist/esm/authorization-attributes-sns-service.mjs +197 -0
  37. package/dist/esm/base-attribute-assignment.d.ts +18 -0
  38. package/dist/esm/base-attribute-assignment.d.ts.map +1 -0
  39. package/dist/esm/base-attribute-assignment.mjs +41 -0
  40. package/dist/esm/clients/graph-api.d.ts.map +1 -1
  41. package/dist/esm/clients/graph-api.mjs +2 -1
  42. package/dist/esm/constants/sns.d.ts +12 -2
  43. package/dist/esm/constants/sns.d.ts.map +1 -1
  44. package/dist/esm/constants/sns.mjs +17 -3
  45. package/dist/esm/constants.d.ts +3 -0
  46. package/dist/esm/constants.d.ts.map +1 -1
  47. package/dist/esm/constants.mjs +5 -1
  48. package/dist/esm/entity-attribute-assignment.d.ts +24 -0
  49. package/dist/esm/entity-attribute-assignment.d.ts.map +1 -0
  50. package/dist/esm/entity-attribute-assignment.mjs +34 -0
  51. package/dist/esm/entity-attributes-constants.d.ts +7 -0
  52. package/dist/esm/entity-attributes-constants.d.ts.map +1 -0
  53. package/dist/esm/entity-attributes-constants.mjs +7 -0
  54. package/dist/esm/errors/argument-error.d.ts +4 -0
  55. package/dist/esm/errors/argument-error.d.ts.map +1 -0
  56. package/dist/esm/errors/argument-error.mjs +9 -0
  57. package/dist/esm/index.d.ts +9 -1
  58. package/dist/esm/index.d.ts.map +1 -1
  59. package/dist/esm/index.mjs +7 -1
  60. package/dist/esm/resource-attribute-assignment.d.ts +24 -0
  61. package/dist/esm/resource-attribute-assignment.d.ts.map +1 -0
  62. package/dist/esm/resource-attribute-assignment.mjs +34 -0
  63. package/dist/esm/resource-attributes-constants.d.ts +25 -0
  64. package/dist/esm/resource-attributes-constants.d.ts.map +1 -0
  65. package/dist/esm/resource-attributes-constants.mjs +25 -0
  66. package/dist/esm/roles-service.d.ts +1 -1
  67. package/dist/esm/roles-service.mjs +1 -1
  68. package/dist/esm/types/authorization-attributes-contracts.d.ts +36 -4
  69. package/dist/esm/types/authorization-attributes-contracts.d.ts.map +1 -1
  70. package/dist/esm/types/authorization-attributes-contracts.mjs +6 -1
  71. package/dist/esm/utils/path-utils.d.ts +8 -0
  72. package/dist/esm/utils/path-utils.d.ts.map +1 -0
  73. package/dist/esm/utils/path-utils.mjs +15 -0
  74. package/dist/esm/utils/validation.d.ts +45 -0
  75. package/dist/esm/utils/validation.d.ts.map +1 -0
  76. package/dist/esm/utils/validation.mjs +75 -0
  77. package/dist/index.d.ts +9 -1
  78. package/dist/index.d.ts.map +1 -1
  79. package/dist/index.js +15 -2
  80. package/dist/resource-attribute-assignment.d.ts +24 -0
  81. package/dist/resource-attribute-assignment.d.ts.map +1 -0
  82. package/dist/resource-attribute-assignment.js +36 -0
  83. package/dist/resource-attributes-constants.d.ts +25 -0
  84. package/dist/resource-attributes-constants.d.ts.map +1 -0
  85. package/dist/resource-attributes-constants.js +28 -0
  86. package/dist/roles-service.d.ts +1 -1
  87. package/dist/roles-service.js +1 -1
  88. package/dist/types/authorization-attributes-contracts.d.ts +36 -4
  89. package/dist/types/authorization-attributes-contracts.d.ts.map +1 -1
  90. package/dist/types/authorization-attributes-contracts.js +5 -0
  91. package/dist/utils/path-utils.d.ts +8 -0
  92. package/dist/utils/path-utils.d.ts.map +1 -0
  93. package/dist/utils/path-utils.js +17 -0
  94. package/dist/utils/validation.d.ts +45 -0
  95. package/dist/utils/validation.d.ts.map +1 -0
  96. package/dist/utils/validation.js +77 -0
  97. package/package.json +1 -1
  98. package/src/attributions-service.ts +4 -0
  99. package/src/authorization-attributes-ms-service.ts +400 -0
  100. package/src/authorization-attributes-sns-service.ts +290 -0
  101. package/src/base-attribute-assignment.ts +55 -0
  102. package/src/clients/graph-api.ts +2 -1
  103. package/src/constants/sns.ts +19 -2
  104. package/src/constants.ts +4 -0
  105. package/src/entity-attribute-assignment.ts +35 -0
  106. package/src/entity-attributes-constants.ts +7 -0
  107. package/src/errors/argument-error.ts +7 -0
  108. package/src/index.ts +18 -1
  109. package/src/resource-attribute-assignment.ts +43 -0
  110. package/src/resource-attributes-constants.ts +26 -0
  111. package/src/roles-service.ts +1 -1
  112. package/src/types/authorization-attributes-contracts.ts +56 -3
  113. package/src/utils/path-utils.ts +13 -0
  114. package/src/utils/validation.ts +77 -0
  115. package/dist/authorization-attributes-service.d.ts +0 -54
  116. package/dist/authorization-attributes-service.d.ts.map +0 -1
  117. package/dist/authorization-attributes-service.js +0 -186
  118. package/dist/esm/authorization-attributes-service.d.ts +0 -54
  119. package/dist/esm/authorization-attributes-service.d.ts.map +0 -1
  120. package/dist/esm/authorization-attributes-service.mjs +0 -180
  121. package/src/authorization-attributes-service.ts +0 -234
@@ -0,0 +1,85 @@
1
+ import { ResourceAttributeAssignment, ResourceAttributesOperation, EntityAttributesOperation } from './types/authorization-attributes-contracts';
2
+ import { EntityAttributeAssignment } from './entity-attribute-assignment';
3
+ import { Resource } from './types/general';
4
+ export declare class AuthorizationAttributesSnsService {
5
+ private static LOG_TAG;
6
+ private resourceSnsArn;
7
+ private entitySnsArn;
8
+ /**
9
+ * Public constructor to create the AuthorizationAttributesSnsService instance.
10
+ */
11
+ constructor();
12
+ /**
13
+ * Async function to upsert resource attributes using SNS.
14
+ * Sends the updates request to SNS and returns before the change actually took place.
15
+ * @param accountId The account ID
16
+ * @param appName App name of the calling app
17
+ * @param callerActionIdentifier Action identifier
18
+ * @param resourceAttributeAssignments Array of resource attribute assignments to upsert
19
+ * @return Promise with array of sent operations
20
+ */
21
+ upsertResourceAttributesAsync(accountId: number, appName: string, callerActionIdentifier: string, resourceAttributeAssignments: ResourceAttributeAssignment[]): Promise<ResourceAttributesOperation[]>;
22
+ /**
23
+ * Async function to delete resource attributes using SNS.
24
+ * Sends the updates request to SNS and returns before the change actually took place.
25
+ * @param accountId The account ID
26
+ * @param appName App name of the calling app
27
+ * @param callerActionIdentifier Action identifier
28
+ * @param resource The resource (resourceType, resourceId)
29
+ * @param attributeKeys Array of attribute keys to delete
30
+ * @return Promise with array of sent operations
31
+ */
32
+ deleteResourceAttributesAsync(accountId: number, appName: string, callerActionIdentifier: string, resource: Resource, attributeKeys: string[]): Promise<ResourceAttributesOperation[]>;
33
+ /**
34
+ * Async function to upsert entity attributes using SNS.
35
+ * Sends the updates request to SNS and returns before the change actually took place.
36
+ * @param accountId The account ID
37
+ * @param appName App name of the calling app
38
+ * @param callerActionIdentifier Action identifier
39
+ * @param entityAttributeAssignments Array of entity attribute assignments to upsert
40
+ * @return Promise with array of sent operations
41
+ */
42
+ upsertEntityAttributesAsync(accountId: number, appName: string, callerActionIdentifier: string, entityAttributeAssignments: EntityAttributeAssignment[]): Promise<EntityAttributesOperation[]>;
43
+ /**
44
+ * Async function to delete entity attributes using SNS.
45
+ * Sends the updates request to SNS and returns before the change actually took place.
46
+ * @param accountId The account ID
47
+ * @param appName App name of the calling app
48
+ * @param callerActionIdentifier Action identifier
49
+ * @param entityType The entity type
50
+ * @param entityId The entity ID
51
+ * @param attributeKeys Array of attribute keys to delete
52
+ * @return Promise with array of sent operations
53
+ */
54
+ deleteEntityAttributesAsync(accountId: number, appName: string, callerActionIdentifier: string, entityType: string, entityId: number, attributeKeys: string[]): Promise<EntityAttributesOperation[]>;
55
+ /**
56
+ * Async function, this function only send the updates request to SNS and return before the change actually took place
57
+ * @param accountId
58
+ * @param appName - App name of the calling app
59
+ * @param callerActionIdentifier - action identifier
60
+ * @param resourceAttributeOperations - Array of operations to do on resource attributes.
61
+ * @return {Promise<ResourceAttributesOperation[]>} Array of sent operations
62
+ * */
63
+ updateResourceAttributesAsync(accountId: number, appName: string, callerActionIdentifier: string, resourceAttributeOperations: ResourceAttributesOperation[]): Promise<ResourceAttributesOperation[]>;
64
+ /**
65
+ * Async function, this function only send the updates request to SNS and return before the change actually took place
66
+ * @param accountId
67
+ * @param appName - App name of the calling app
68
+ * @param callerActionIdentifier - action identifier
69
+ * @param entityAttributeOperations - Array of operations to do on entity attributes.
70
+ * @return {Promise<EntityAttributesOperation[]>} Array of sent operations
71
+ * */
72
+ updateEntityAttributesAsync(accountId: number, appName: string, callerActionIdentifier: string, entityAttributeOperations: EntityAttributesOperation[]): Promise<EntityAttributesOperation[]>;
73
+ private sendSingleSnsMessage;
74
+ private static getSnsTopicArn;
75
+ /**
76
+ * Checks we can contact the required SNS topic that used to send attribute updates to Authorization MS.
77
+ * This function can be used as health check for services that updating resource attributes in async is crucial.
78
+ * Note this function only verify the POD can contact AWS SDK and the topic exists, but the user still might get
79
+ * errors when pushing for the SNS (e.g: in case the AWS role of the POD don't have permissions to push messages).
80
+ * However, this is the best we can do without actually push dummy messages to the SNS.
81
+ * @return {Promise<boolean>} - true if succeeded
82
+ */
83
+ asyncResourceAttributesHealthCheck(): Promise<boolean>;
84
+ }
85
+ //# 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,EACL,2BAA2B,EAC3B,2BAA2B,EAC3B,yBAAyB,EAG1B,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAe3C,qBAAa,iCAAiC;IAC5C,OAAO,CAAC,MAAM,CAAC,OAAO,CAA8B;IACpD,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,YAAY,CAAS;IAE7B;;OAEG;;IAMH;;;;;;;;OAQG;IACG,6BAA6B,CACjC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,sBAAsB,EAAE,MAAM,EAC9B,4BAA4B,EAAE,2BAA2B,EAAE,GAC1D,OAAO,CAAC,2BAA2B,EAAE,CAAC;IAQzC;;;;;;;;;OASG;IACG,6BAA6B,CACjC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,sBAAsB,EAAE,MAAM,EAC9B,QAAQ,EAAE,QAAQ,EAClB,aAAa,EAAE,MAAM,EAAE,GACtB,OAAO,CAAC,2BAA2B,EAAE,CAAC;IAUzC;;;;;;;;OAQG;IACG,2BAA2B,CAC/B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,sBAAsB,EAAE,MAAM,EAC9B,0BAA0B,EAAE,yBAAyB,EAAE,GACtD,OAAO,CAAC,yBAAyB,EAAE,CAAC;IAcvC;;;;;;;;;;OAUG;IACG,2BAA2B,CAC/B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,sBAAsB,EAAE,MAAM,EAC9B,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,EAAE,GACtB,OAAO,CAAC,yBAAyB,EAAE,CAAC;IAUvC;;;;;;;UAOM;IACA,6BAA6B,CACjC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,sBAAsB,EAAE,MAAM,EAC9B,2BAA2B,EAAE,2BAA2B,EAAE,GACzD,OAAO,CAAC,2BAA2B,EAAE,CAAC;IAoBzC;;;;;;;UAOM;IACA,2BAA2B,CAC/B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,sBAAsB,EAAE,MAAM,EAC9B,yBAAyB,EAAE,yBAAyB,EAAE,GACrD,OAAO,CAAC,yBAAyB,EAAE,CAAC;YAoBzB,oBAAoB;IA2BlC,OAAO,CAAC,MAAM,CAAC,cAAc;IA0B7B;;;;;;;OAOG;IACG,kCAAkC,IAAI,OAAO,CAAC,OAAO,CAAC;CAoB7D"}
@@ -0,0 +1,197 @@
1
+ import chunk from 'lodash/chunk.js';
2
+ import { sendToSns, getTopicAttributes } from '@mondaydotcomorg/monday-sns';
3
+ import { ResourceAttributeOperationEnum, EntityAttributeOperationEnum } from './types/authorization-attributes-contracts.mjs';
4
+ import { EntityAttributeAssignment } from './entity-attribute-assignment.mjs';
5
+ import { logger } from './authorization-internal-service.mjs';
6
+ import { SnsTopicType, ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE, RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND, ASYNC_ENTITY_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE, ENTITY_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND, RESOURCE_SNS_ARN_ENV_VAR_NAME, RESOURCE_SNS_DEV_TEST_NAME, ENTITY_SNS_ARN_ENV_VAR_NAME, ENTITY_SNS_DEV_TEST_NAME } from './constants/sns.mjs';
7
+
8
+ class AuthorizationAttributesSnsService {
9
+ static LOG_TAG = 'authorization_attributes';
10
+ resourceSnsArn;
11
+ entitySnsArn;
12
+ /**
13
+ * Public constructor to create the AuthorizationAttributesSnsService instance.
14
+ */
15
+ constructor() {
16
+ this.resourceSnsArn = AuthorizationAttributesSnsService.getSnsTopicArn(SnsTopicType.RESOURCE);
17
+ this.entitySnsArn = AuthorizationAttributesSnsService.getSnsTopicArn(SnsTopicType.ENTITY);
18
+ }
19
+ /**
20
+ * Async function to upsert resource attributes using SNS.
21
+ * Sends the updates request to SNS and returns before the change actually took place.
22
+ * @param accountId The account ID
23
+ * @param appName App name of the calling app
24
+ * @param callerActionIdentifier Action identifier
25
+ * @param resourceAttributeAssignments Array of resource attribute assignments to upsert
26
+ * @return Promise with array of sent operations
27
+ */
28
+ async upsertResourceAttributesAsync(accountId, appName, callerActionIdentifier, resourceAttributeAssignments) {
29
+ const operations = resourceAttributeAssignments.map(assignment => ({
30
+ ...assignment,
31
+ operationType: ResourceAttributeOperationEnum.UPSERT,
32
+ }));
33
+ return this.updateResourceAttributesAsync(accountId, appName, callerActionIdentifier, operations);
34
+ }
35
+ /**
36
+ * Async function to delete resource attributes using SNS.
37
+ * Sends the updates request to SNS and returns before the change actually took place.
38
+ * @param accountId The account ID
39
+ * @param appName App name of the calling app
40
+ * @param callerActionIdentifier Action identifier
41
+ * @param resource The resource (resourceType, resourceId)
42
+ * @param attributeKeys Array of attribute keys to delete
43
+ * @return Promise with array of sent operations
44
+ */
45
+ async deleteResourceAttributesAsync(accountId, appName, callerActionIdentifier, resource, attributeKeys) {
46
+ const operations = attributeKeys.map(key => ({
47
+ resourceType: resource.type,
48
+ resourceId: resource.id,
49
+ key,
50
+ operationType: ResourceAttributeOperationEnum.DELETE,
51
+ }));
52
+ return this.updateResourceAttributesAsync(accountId, appName, callerActionIdentifier, operations);
53
+ }
54
+ /**
55
+ * Async function to upsert entity attributes using SNS.
56
+ * Sends the updates request to SNS and returns before the change actually took place.
57
+ * @param accountId The account ID
58
+ * @param appName App name of the calling app
59
+ * @param callerActionIdentifier Action identifier
60
+ * @param entityAttributeAssignments Array of entity attribute assignments to upsert
61
+ * @return Promise with array of sent operations
62
+ */
63
+ async upsertEntityAttributesAsync(accountId, appName, callerActionIdentifier, entityAttributeAssignments) {
64
+ const operations = entityAttributeAssignments.map(assignment => {
65
+ const assignmentData = assignment instanceof EntityAttributeAssignment ? assignment.toH() : assignment;
66
+ return {
67
+ entityId: assignmentData.entityId,
68
+ entityType: assignmentData.entityType,
69
+ key: assignmentData.key,
70
+ value: assignmentData.value,
71
+ operationType: EntityAttributeOperationEnum.UPSERT,
72
+ };
73
+ });
74
+ return this.updateEntityAttributesAsync(accountId, appName, callerActionIdentifier, operations);
75
+ }
76
+ /**
77
+ * Async function to delete entity attributes using SNS.
78
+ * Sends the updates request to SNS and returns before the change actually took place.
79
+ * @param accountId The account ID
80
+ * @param appName App name of the calling app
81
+ * @param callerActionIdentifier Action identifier
82
+ * @param entityType The entity type
83
+ * @param entityId The entity ID
84
+ * @param attributeKeys Array of attribute keys to delete
85
+ * @return Promise with array of sent operations
86
+ */
87
+ async deleteEntityAttributesAsync(accountId, appName, callerActionIdentifier, entityType, entityId, attributeKeys) {
88
+ const operations = attributeKeys.map(key => ({
89
+ entityType: entityType,
90
+ entityId,
91
+ key,
92
+ operationType: EntityAttributeOperationEnum.DELETE,
93
+ }));
94
+ return this.updateEntityAttributesAsync(accountId, appName, callerActionIdentifier, operations);
95
+ }
96
+ /**
97
+ * Async function, this function only send the updates request to SNS and return before the change actually took place
98
+ * @param accountId
99
+ * @param appName - App name of the calling app
100
+ * @param callerActionIdentifier - action identifier
101
+ * @param resourceAttributeOperations - Array of operations to do on resource attributes.
102
+ * @return {Promise<ResourceAttributesOperation[]>} Array of sent operations
103
+ * */
104
+ async updateResourceAttributesAsync(accountId, appName, callerActionIdentifier, resourceAttributeOperations) {
105
+ const topicArn = this.resourceSnsArn;
106
+ const sendToSnsPromises = [];
107
+ const operationChucks = chunk(resourceAttributeOperations, ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE);
108
+ for (const operationsChunk of operationChucks) {
109
+ sendToSnsPromises.push(this.sendSingleSnsMessage(topicArn, accountId, appName, callerActionIdentifier, operationsChunk, RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND, 'Authorization resource attributes async update: failed to send operations to SNS'));
110
+ }
111
+ return (await Promise.all(sendToSnsPromises)).flat();
112
+ }
113
+ /**
114
+ * Async function, this function only send the updates request to SNS and return before the change actually took place
115
+ * @param accountId
116
+ * @param appName - App name of the calling app
117
+ * @param callerActionIdentifier - action identifier
118
+ * @param entityAttributeOperations - Array of operations to do on entity attributes.
119
+ * @return {Promise<EntityAttributesOperation[]>} Array of sent operations
120
+ * */
121
+ async updateEntityAttributesAsync(accountId, appName, callerActionIdentifier, entityAttributeOperations) {
122
+ const topicArn = this.entitySnsArn;
123
+ const sendToSnsPromises = [];
124
+ const operationChucks = chunk(entityAttributeOperations, ASYNC_ENTITY_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE);
125
+ for (const operationsChunk of operationChucks) {
126
+ sendToSnsPromises.push(this.sendSingleSnsMessage(topicArn, accountId, appName, callerActionIdentifier, operationsChunk, ENTITY_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND, 'Authorization entity attributes async update: failed to send operations to SNS'));
127
+ }
128
+ return (await Promise.all(sendToSnsPromises)).flat();
129
+ }
130
+ async sendSingleSnsMessage(topicArn, accountId, appName, callerActionIdentifier, operations, kind, errorLogMessage) {
131
+ const payload = {
132
+ kind,
133
+ payload: {
134
+ accountId: accountId,
135
+ callerAppName: appName,
136
+ callerActionIdentifier: callerActionIdentifier,
137
+ operations: operations,
138
+ },
139
+ };
140
+ try {
141
+ await sendToSns(payload, topicArn);
142
+ return operations;
143
+ }
144
+ catch (error) {
145
+ logger.error({ error, tag: AuthorizationAttributesSnsService.LOG_TAG }, errorLogMessage);
146
+ return [];
147
+ }
148
+ }
149
+ static getSnsTopicArn(type) {
150
+ let envVarName;
151
+ let devTestName;
152
+ switch (type) {
153
+ case SnsTopicType.ENTITY:
154
+ envVarName = ENTITY_SNS_ARN_ENV_VAR_NAME;
155
+ devTestName = ENTITY_SNS_DEV_TEST_NAME;
156
+ break;
157
+ default:
158
+ // Default to resource SNS constants
159
+ envVarName = RESOURCE_SNS_ARN_ENV_VAR_NAME;
160
+ devTestName = RESOURCE_SNS_DEV_TEST_NAME;
161
+ break;
162
+ }
163
+ const arnFromEnv = process.env[envVarName];
164
+ if (arnFromEnv) {
165
+ return arnFromEnv;
166
+ }
167
+ if (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') {
168
+ return devTestName;
169
+ }
170
+ throw new Error(`Unable to get ${type} sns topic arn from env variable`);
171
+ }
172
+ /**
173
+ * Checks we can contact the required SNS topic that used to send attribute updates to Authorization MS.
174
+ * This function can be used as health check for services that updating resource attributes in async is crucial.
175
+ * Note this function only verify the POD can contact AWS SDK and the topic exists, but the user still might get
176
+ * errors when pushing for the SNS (e.g: in case the AWS role of the POD don't have permissions to push messages).
177
+ * However, this is the best we can do without actually push dummy messages to the SNS.
178
+ * @return {Promise<boolean>} - true if succeeded
179
+ */
180
+ async asyncResourceAttributesHealthCheck() {
181
+ try {
182
+ const requestedTopicArn = this.resourceSnsArn;
183
+ const attributes = await getTopicAttributes(requestedTopicArn);
184
+ const isHealthy = !(!attributes || !('TopicArn' in attributes) || attributes.TopicArn !== requestedTopicArn);
185
+ if (!isHealthy) {
186
+ logger.error({ requestedTopicArn, snsReturnedAttributes: attributes, tag: AuthorizationAttributesSnsService.LOG_TAG }, 'authorization-attributes-service failed in health check');
187
+ }
188
+ return isHealthy;
189
+ }
190
+ catch (error) {
191
+ logger.error({ error, tag: AuthorizationAttributesSnsService.LOG_TAG }, 'authorization-attributes-service got error during health check');
192
+ return false;
193
+ }
194
+ }
195
+ }
196
+
197
+ export { AuthorizationAttributesSnsService };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Base class for attribute assignments (Resource or Entity)
3
+ * Provides common validation and functionality
4
+ */
5
+ export declare abstract class BaseAttributeAssignment<TId extends number, TType extends string> {
6
+ readonly id: TId;
7
+ readonly type: TType;
8
+ readonly attributeKey: string;
9
+ readonly attributeValue: string;
10
+ constructor(id: TId, type: string, attributeKey: string, attributeValue: string, validTypes: readonly string[], idFieldName: string, typeFieldName: string);
11
+ /**
12
+ * Compares two assignments for equality
13
+ * @param other Another assignment instance
14
+ * @returns true if all properties are equal
15
+ */
16
+ equals(other: BaseAttributeAssignment<TId, TType>): boolean;
17
+ }
18
+ //# sourceMappingURL=base-attribute-assignment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-attribute-assignment.d.ts","sourceRoot":"","sources":["../../src/base-attribute-assignment.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,8BAAsB,uBAAuB,CAAC,GAAG,SAAS,MAAM,EAAE,KAAK,SAAS,MAAM;IACpF,SAAgB,EAAE,EAAE,GAAG,CAAC;IACxB,SAAgB,IAAI,EAAE,KAAK,CAAC;IAC5B,SAAgB,YAAY,EAAE,MAAM,CAAC;IACrC,SAAgB,cAAc,EAAE,MAAM,CAAC;gBAGrC,EAAE,EAAE,GAAG,EACP,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,SAAS,MAAM,EAAE,EAC7B,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,MAAM;IAmBvB;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,uBAAuB,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,OAAO;CAW5D"}
@@ -0,0 +1,41 @@
1
+ import { ValidationUtils } from './utils/validation.mjs';
2
+
3
+ /**
4
+ * Base class for attribute assignments (Resource or Entity)
5
+ * Provides common validation and functionality
6
+ */
7
+ class BaseAttributeAssignment {
8
+ id;
9
+ type;
10
+ attributeKey;
11
+ attributeValue;
12
+ constructor(id, type, attributeKey, attributeValue, validTypes, idFieldName, typeFieldName) {
13
+ // Validate id
14
+ ValidationUtils.validateInteger(id, idFieldName);
15
+ // Validate type
16
+ this.type = ValidationUtils.validateEnum(type, validTypes, typeFieldName);
17
+ // Validate attributeKey
18
+ ValidationUtils.validateString(attributeKey, 'attributeKey');
19
+ // Validate attributeValue
20
+ ValidationUtils.validateString(attributeValue, 'attributeValue');
21
+ this.id = id;
22
+ this.attributeKey = attributeKey;
23
+ this.attributeValue = attributeValue;
24
+ }
25
+ /**
26
+ * Compares two assignments for equality
27
+ * @param other Another assignment instance
28
+ * @returns true if all properties are equal
29
+ */
30
+ equals(other) {
31
+ if (!(other instanceof this.constructor)) {
32
+ return false;
33
+ }
34
+ return (this.id === other.id &&
35
+ this.type === other.type &&
36
+ this.attributeKey === other.attributeKey &&
37
+ this.attributeValue === other.attributeValue);
38
+ }
39
+ }
40
+
41
+ export { BaseAttributeAssignment };
@@ -1 +1 @@
1
- {"version":3,"file":"graph-api.d.ts","sourceRoot":"","sources":["../../../src/clients/graph-api.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,YAAY,EACZ,0BAA0B,EAG3B,MAAM,mCAAmC,CAAC;AAG3C,OAAO,EAEL,sBAAsB,EAMvB,MAAM,0BAA0B,CAA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AAC,MAAM,CAAC,iBAAiB;CAWjC"}
@@ -4,7 +4,7 @@ import { PermitTechnicalReason } from '../types/scoped-actions-contracts.mjs';
4
4
  import { AuthorizationInternalService } from '../authorization-internal-service.mjs';
5
5
  import { getAttributionsFromApi } from '../attributions-service.mjs';
6
6
  import { scopeToResource } from '../utils/authorization.utils.mjs';
7
- import { GRAPH_APP_NAME } from '../constants.mjs';
7
+ import { GRAPH_APP_NAME, GraphApiProfile } from '../constants.mjs';
8
8
  import { handleApiError } from '../utils/api-error-handler.mjs';
9
9
 
10
10
  const CAN_ACTION_IN_SCOPE_GRAPH_PATH = '/permissions/is-allowed';
@@ -63,6 +63,7 @@ class GraphApi {
63
63
  url: {
64
64
  appName: GRAPH_APP_NAME,
65
65
  path: CAN_ACTION_IN_SCOPE_GRAPH_PATH,
66
+ profile: GraphApiProfile.PERMISSION,
66
67
  },
67
68
  method: 'POST',
68
69
  headers: {
@@ -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,6 +1,20 @@
1
- const SNS_ARN_ENV_VAR_NAME = 'SHARED_AUTHORIZATION_SNS_ENDPOINT_RESOURCE_ATTRIBUTES';
2
- const SNS_DEV_TEST_NAME = 'arn:aws:sns:us-east-1:000000000000:monday-authorization-resource-attributes-sns-local';
1
+ var SnsTopicType;
2
+ (function (SnsTopicType) {
3
+ SnsTopicType["RESOURCE"] = "resource";
4
+ SnsTopicType["ENTITY"] = "entity";
5
+ })(SnsTopicType || (SnsTopicType = {}));
6
+ // Resource SNS constants
7
+ const RESOURCE_SNS_ARN_ENV_VAR_NAME = 'SHARED_AUTHORIZATION_SNS_ENDPOINT_RESOURCE_ATTRIBUTES';
8
+ const RESOURCE_SNS_DEV_TEST_NAME = 'arn:aws:sns:us-east-1:000000000000:monday-authorization-resource-attributes-sns-local';
9
+ // Entity SNS constants
10
+ const ENTITY_SNS_ARN_ENV_VAR_NAME = 'SHARED_AUTHORIZATION_SNS_ENDPOINT_ENTITY_ATTRIBUTES';
11
+ const ENTITY_SNS_DEV_TEST_NAME = 'arn:aws:sns:us-east-1:000000000000:monday-authorization-entity-attributes-sns-local';
3
12
  const RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND = 'resourceAttributeModification';
13
+ const ENTITY_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND = 'entityAttributeModification';
4
14
  const ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE = 100;
15
+ const ASYNC_ENTITY_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE = 100;
16
+ // Legacy exports for backward compatibility
17
+ const SNS_ARN_ENV_VAR_NAME = RESOURCE_SNS_ARN_ENV_VAR_NAME;
18
+ const SNS_DEV_TEST_NAME = RESOURCE_SNS_DEV_TEST_NAME;
5
19
 
6
- export { ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE, RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND, SNS_ARN_ENV_VAR_NAME, SNS_DEV_TEST_NAME };
20
+ export { ASYNC_ENTITY_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE, ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE, ENTITY_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND, ENTITY_SNS_ARN_ENV_VAR_NAME, ENTITY_SNS_DEV_TEST_NAME, RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND, RESOURCE_SNS_ARN_ENV_VAR_NAME, RESOURCE_SNS_DEV_TEST_NAME, SNS_ARN_ENV_VAR_NAME, SNS_DEV_TEST_NAME, SnsTopicType };
@@ -2,6 +2,9 @@ import { RecursivePartial } from '@mondaydotcomorg/monday-fetch-api';
2
2
  import { FetcherConfig } from '@mondaydotcomorg/trident-backend-api';
3
3
  export declare const APP_NAME = "authorization";
4
4
  export declare const GRAPH_APP_NAME = "authorization-graph";
5
+ export declare enum GraphApiProfile {
6
+ PERMISSION = "authorization-graph-permission"
7
+ }
5
8
  export declare const ERROR_MESSAGES: {
6
9
  readonly HTTP_CLIENT_NOT_INITIALIZED: "MondayAuthorization: HTTP client is not initialized";
7
10
  readonly REQUEST_FAILED: (method: string, status: number, reason: string) => string;
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAErE,eAAO,MAAM,QAAQ,kBAAkB,CAAC;AACxC,eAAO,MAAM,cAAc,wBAAwB,CAAC;AAEpD,eAAO,MAAM,cAAc;;sCAEA,MAAM,UAAU,MAAM,UAAU,MAAM;CAEvD,CAAC;AAEX,eAAO,MAAM,qBAAqB,EAAE,gBAAgB,CAAC,aAAa,CAUjE,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAErE,eAAO,MAAM,QAAQ,kBAAkB,CAAC;AACxC,eAAO,MAAM,cAAc,wBAAwB,CAAC;AAEpD,oBAAY,eAAe;IACzB,UAAU,mCAAmC;CAC9C;AAED,eAAO,MAAM,cAAc;;sCAEA,MAAM,UAAU,MAAM,UAAU,MAAM;CAEvD,CAAC;AAEX,eAAO,MAAM,qBAAqB,EAAE,gBAAgB,CAAC,aAAa,CAUjE,CAAC"}
@@ -1,5 +1,9 @@
1
1
  const APP_NAME = 'authorization';
2
2
  const GRAPH_APP_NAME = 'authorization-graph';
3
+ var GraphApiProfile;
4
+ (function (GraphApiProfile) {
5
+ GraphApiProfile["PERMISSION"] = "authorization-graph-permission";
6
+ })(GraphApiProfile || (GraphApiProfile = {}));
3
7
  const ERROR_MESSAGES = {
4
8
  HTTP_CLIENT_NOT_INITIALIZED: 'MondayAuthorization: HTTP client is not initialized',
5
9
  REQUEST_FAILED: (method, status, reason) => `MondayAuthorization: [${method}] request failed with status ${status} with reason: ${reason}`,
@@ -16,4 +20,4 @@ const DEFAULT_FETCH_OPTIONS = {
16
20
  },
17
21
  };
18
22
 
19
- export { APP_NAME, DEFAULT_FETCH_OPTIONS, ERROR_MESSAGES, GRAPH_APP_NAME };
23
+ export { APP_NAME, DEFAULT_FETCH_OPTIONS, ERROR_MESSAGES, GRAPH_APP_NAME, GraphApiProfile };
@@ -0,0 +1,24 @@
1
+ import { EntityType } from './entity-attributes-constants';
2
+ import { BaseAttributeAssignment } from './base-attribute-assignment';
3
+ export declare class EntityAttributeAssignment extends BaseAttributeAssignment<number, EntityType> {
4
+ readonly entityId: number;
5
+ readonly entityType: EntityType;
6
+ constructor(entityId: number, entityType: string, attributeKey: string, attributeValue: string);
7
+ /**
8
+ * Converts the assignment to hash format with camelCase keys
9
+ * @returns Object with camelCase keys: { entityId, entityType, key, value }
10
+ */
11
+ toH(): {
12
+ entityId: number;
13
+ entityType: string;
14
+ key: string;
15
+ value: string;
16
+ };
17
+ /**
18
+ * Compares two assignments for equality
19
+ * @param other Another EntityAttributeAssignment instance
20
+ * @returns true if all properties are equal
21
+ */
22
+ equals(other: EntityAttributeAssignment): boolean;
23
+ }
24
+ //# sourceMappingURL=entity-attribute-assignment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity-attribute-assignment.d.ts","sourceRoot":"","sources":["../../src/entity-attribute-assignment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,UAAU,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAEtE,qBAAa,yBAA0B,SAAQ,uBAAuB,CAAC,MAAM,EAAE,UAAU,CAAC;IACxF,SAAgB,QAAQ,EAAE,MAAM,CAAC;IACjC,SAAgB,UAAU,EAAE,UAAU,CAAC;gBAE3B,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;IAM9F;;;OAGG;IACH,GAAG,IAAI;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE;IAS3E;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO;CAGlD"}
@@ -0,0 +1,34 @@
1
+ import { ENTITY_TYPES } from './entity-attributes-constants.mjs';
2
+ import { BaseAttributeAssignment } from './base-attribute-assignment.mjs';
3
+
4
+ class EntityAttributeAssignment extends BaseAttributeAssignment {
5
+ entityId;
6
+ entityType;
7
+ constructor(entityId, entityType, attributeKey, attributeValue) {
8
+ super(entityId, entityType, attributeKey, attributeValue, Object.values(ENTITY_TYPES), 'entityId', 'entityType');
9
+ this.entityId = entityId;
10
+ this.entityType = this.type;
11
+ }
12
+ /**
13
+ * Converts the assignment to hash format with camelCase keys
14
+ * @returns Object with camelCase keys: { entityId, entityType, key, value }
15
+ */
16
+ toH() {
17
+ return {
18
+ entityId: this.entityId,
19
+ entityType: this.entityType,
20
+ key: this.attributeKey,
21
+ value: this.attributeValue,
22
+ };
23
+ }
24
+ /**
25
+ * Compares two assignments for equality
26
+ * @param other Another EntityAttributeAssignment instance
27
+ * @returns true if all properties are equal
28
+ */
29
+ equals(other) {
30
+ return super.equals(other);
31
+ }
32
+ }
33
+
34
+ export { EntityAttributeAssignment };
@@ -0,0 +1,7 @@
1
+ export declare const ENTITY_TYPES: {
2
+ readonly USER: "user";
3
+ readonly TEAM: "team";
4
+ readonly ACCOUNT: "account";
5
+ };
6
+ export type EntityType = (typeof ENTITY_TYPES)[keyof typeof ENTITY_TYPES];
7
+ //# sourceMappingURL=entity-attributes-constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity-attributes-constants.d.ts","sourceRoot":"","sources":["../../src/entity-attributes-constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY;;;;CAIf,CAAC;AAEX,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ const ENTITY_TYPES = {
2
+ USER: 'user',
3
+ TEAM: 'team',
4
+ ACCOUNT: 'account',
5
+ };
6
+
7
+ export { ENTITY_TYPES };
@@ -0,0 +1,4 @@
1
+ export declare class ArgumentError extends Error {
2
+ constructor(message: string);
3
+ }
4
+ //# sourceMappingURL=argument-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"argument-error.d.ts","sourceRoot":"","sources":["../../../src/errors/argument-error.ts"],"names":[],"mappings":"AAAA,qBAAa,aAAc,SAAQ,KAAK;gBAC1B,OAAO,EAAE,MAAM;CAK5B"}
@@ -0,0 +1,9 @@
1
+ class ArgumentError extends Error {
2
+ constructor(message) {
3
+ super(message);
4
+ this.name = 'ArgumentError';
5
+ Object.setPrototypeOf(this, ArgumentError.prototype);
6
+ }
7
+ }
8
+
9
+ export { ArgumentError };
@@ -18,7 +18,15 @@ export interface InitOptions {
18
18
  export declare function init(options?: InitOptions): Promise<void>;
19
19
  export { authorizationCheckMiddleware, getAuthorizationMiddleware, skipAuthorizationMiddleware, } from './authorization-middleware';
20
20
  export { AuthorizationService, AuthorizeResponse } from './authorization-service';
21
- export { AuthorizationAttributesService } from './authorization-attributes-service';
21
+ export { AuthorizationAttributesSnsService } from './authorization-attributes-sns-service';
22
+ export { AuthorizationAttributesMsService } from './authorization-attributes-ms-service';
23
+ export { ResourceAttributeAssignment } from './resource-attribute-assignment';
24
+ export { RESOURCE_TYPES, RESOURCE_ATTRIBUTES_CONSTANTS } from './resource-attributes-constants';
25
+ export { EntityAttributeAssignment } from './entity-attribute-assignment';
26
+ export { ENTITY_TYPES } from './entity-attributes-constants';
27
+ export { ArgumentError } from './errors/argument-error';
28
+ export { ResourceAttributeResponse, EntityAttributeResponse, ResourceType, EntityAttributeKeyType, ResourceAttributeKeyType, CommonAttributeKey, ResourceAttributeKey, EntityAttributeKey, } from './types/authorization-attributes-contracts';
29
+ export type { EntityType } from './entity-attributes-constants';
22
30
  export { RolesService } from './roles-service';
23
31
  export { MembershipsService } from './memberships';
24
32
  export { AuthorizationObject, Resource, BaseRequest, ResourceGetter, ContextGetter } from './types/general';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAGnE,OAAO,EAAqB,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,UAAU,kBAAkB;IAC1B,MAAM,CAAC,EAAE,aAAa,CAAC;IAC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AY,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC5G,OAAO,EACL,WAAW,EACX,YAAY,EACZ,0BAA0B,EAC1B,kBAAkB,GACnB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAErH,OAAO,EAAE,OAAO,EAAE,CAAC"}
@@ -5,7 +5,13 @@ import { initializeMetrics } from './metrics-service.mjs';
5
5
  import * as testKit_index from './testKit/index.mjs';
6
6
  export { testKit_index as TestKit };
7
7
  export { authorizationCheckMiddleware, getAuthorizationMiddleware, skipAuthorizationMiddleware } from './authorization-middleware.mjs';
8
- export { AuthorizationAttributesService } from './authorization-attributes-service.mjs';
8
+ export { AuthorizationAttributesSnsService } from './authorization-attributes-sns-service.mjs';
9
+ export { AuthorizationAttributesMsService } from './authorization-attributes-ms-service.mjs';
10
+ export { ResourceAttributeAssignment } from './resource-attribute-assignment.mjs';
11
+ export { RESOURCE_ATTRIBUTES_CONSTANTS, RESOURCE_TYPES } from './resource-attributes-constants.mjs';
12
+ export { EntityAttributeAssignment } from './entity-attribute-assignment.mjs';
13
+ export { ENTITY_TYPES } from './entity-attributes-constants.mjs';
14
+ export { ArgumentError } from './errors/argument-error.mjs';
9
15
  export { RolesService } from './roles-service.mjs';
10
16
  export { MembershipsService } from './memberships.mjs';
11
17
  export { RoleType } from './types/roles.mjs';
@@ -0,0 +1,24 @@
1
+ import { ResourceType } from './resource-attributes-constants';
2
+ import { BaseAttributeAssignment } from './base-attribute-assignment';
3
+ export declare class ResourceAttributeAssignment extends BaseAttributeAssignment<number, ResourceType> {
4
+ readonly resourceId: number;
5
+ readonly resourceType: ResourceType;
6
+ constructor(resourceId: number, resourceType: string, attributeKey: string, attributeValue: string);
7
+ /**
8
+ * Converts the assignment to hash format with camelCase keys
9
+ * @returns Object with camelCase keys: { resourceId, resourceType, key, value }
10
+ */
11
+ toH(): {
12
+ resourceId: number;
13
+ resourceType: string;
14
+ key: string;
15
+ value: string;
16
+ };
17
+ /**
18
+ * Compares two assignments for equality
19
+ * @param other Another ResourceAttributeAssignment instance
20
+ * @returns true if all properties are equal
21
+ */
22
+ equals(other: ResourceAttributeAssignment): boolean;
23
+ }
24
+ //# sourceMappingURL=resource-attribute-assignment.d.ts.map