@mondaydotcomorg/monday-authorization 3.5.3-feat-shaime-support-entity-attributes-in-authorization-sdk-a77c130 → 3.6.0-feat-shaime-support-entity-attributes-1-4c8e283

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 (125) hide show
  1. package/dist/authorization-attributes-service.d.ts +47 -26
  2. package/dist/authorization-attributes-service.d.ts.map +1 -1
  3. package/dist/authorization-attributes-service.js +172 -33
  4. package/dist/authorization-middleware.d.ts +2 -2
  5. package/dist/authorization-middleware.d.ts.map +1 -1
  6. package/dist/authorization-service.d.ts +3 -3
  7. package/dist/authorization-service.d.ts.map +1 -1
  8. package/dist/base-attribute-assignment.d.ts +6 -5
  9. package/dist/base-attribute-assignment.d.ts.map +1 -1
  10. package/dist/base-attribute-assignment.js +8 -17
  11. package/dist/constants/sns.d.ts +2 -12
  12. package/dist/constants/sns.d.ts.map +1 -1
  13. package/dist/constants/sns.js +2 -22
  14. package/dist/entity-attribute-assignment.d.ts +4 -8
  15. package/dist/entity-attribute-assignment.d.ts.map +1 -1
  16. package/dist/entity-attribute-assignment.js +5 -4
  17. package/dist/entity-attributes-constants.d.ts +6 -6
  18. package/dist/entity-attributes-constants.d.ts.map +1 -1
  19. package/dist/entity-attributes-constants.js +7 -5
  20. package/dist/errors/argument-error.d.ts.map +1 -1
  21. package/dist/errors/argument-error.js +0 -1
  22. package/dist/esm/authorization-attributes-service.d.ts +47 -26
  23. package/dist/esm/authorization-attributes-service.d.ts.map +1 -1
  24. package/dist/esm/authorization-attributes-service.mjs +168 -33
  25. package/dist/esm/authorization-middleware.d.ts +2 -2
  26. package/dist/esm/authorization-middleware.d.ts.map +1 -1
  27. package/dist/esm/authorization-service.d.ts +3 -3
  28. package/dist/esm/authorization-service.d.ts.map +1 -1
  29. package/dist/esm/base-attribute-assignment.d.ts +6 -5
  30. package/dist/esm/base-attribute-assignment.d.ts.map +1 -1
  31. package/dist/esm/base-attribute-assignment.mjs +4 -17
  32. package/dist/esm/constants/sns.d.ts +2 -12
  33. package/dist/esm/constants/sns.d.ts.map +1 -1
  34. package/dist/esm/constants/sns.mjs +3 -17
  35. package/dist/esm/entity-attribute-assignment.d.ts +4 -8
  36. package/dist/esm/entity-attribute-assignment.d.ts.map +1 -1
  37. package/dist/esm/entity-attribute-assignment.mjs +5 -4
  38. package/dist/esm/entity-attributes-constants.d.ts +6 -6
  39. package/dist/esm/entity-attributes-constants.d.ts.map +1 -1
  40. package/dist/esm/entity-attributes-constants.mjs +8 -6
  41. package/dist/esm/errors/argument-error.d.ts.map +1 -1
  42. package/dist/esm/errors/argument-error.mjs +0 -1
  43. package/dist/esm/index.d.ts +0 -9
  44. package/dist/esm/index.d.ts.map +1 -1
  45. package/dist/esm/index.mjs +0 -7
  46. package/dist/esm/prometheus-service.d.ts +2 -1
  47. package/dist/esm/prometheus-service.d.ts.map +1 -1
  48. package/dist/esm/resource-attribute-assignment.d.ts +4 -8
  49. package/dist/esm/resource-attribute-assignment.d.ts.map +1 -1
  50. package/dist/esm/resource-attribute-assignment.mjs +3 -2
  51. package/dist/esm/resource-attributes-constants.d.ts +21 -11
  52. package/dist/esm/resource-attributes-constants.d.ts.map +1 -1
  53. package/dist/esm/resource-attributes-constants.mjs +17 -14
  54. package/dist/esm/testKit/index.d.ts +4 -4
  55. package/dist/esm/testKit/index.d.ts.map +1 -1
  56. package/dist/esm/types/authorization-attributes-contracts.d.ts +5 -4
  57. package/dist/esm/types/authorization-attributes-contracts.d.ts.map +1 -1
  58. package/dist/esm/types/authorization-attributes-service.interface.d.ts +7 -20
  59. package/dist/esm/types/authorization-attributes-service.interface.d.ts.map +1 -1
  60. package/dist/esm/types/general.d.ts +2 -1
  61. package/dist/esm/types/general.d.ts.map +1 -1
  62. package/dist/esm/utils/assigment-schema.d.ts +29 -0
  63. package/dist/esm/utils/assigment-schema.d.ts.map +1 -0
  64. package/dist/esm/utils/assigment-schema.mjs +29 -0
  65. package/dist/esm/utils/validation.d.ts +13 -38
  66. package/dist/esm/utils/validation.d.ts.map +1 -1
  67. package/dist/esm/utils/validation.mjs +38 -97
  68. package/dist/index.d.ts +0 -9
  69. package/dist/index.d.ts.map +1 -1
  70. package/dist/index.js +0 -15
  71. package/dist/prometheus-service.d.ts +2 -1
  72. package/dist/prometheus-service.d.ts.map +1 -1
  73. package/dist/resource-attribute-assignment.d.ts +4 -8
  74. package/dist/resource-attribute-assignment.d.ts.map +1 -1
  75. package/dist/resource-attribute-assignment.js +3 -2
  76. package/dist/resource-attributes-constants.d.ts +21 -11
  77. package/dist/resource-attributes-constants.d.ts.map +1 -1
  78. package/dist/resource-attributes-constants.js +16 -13
  79. package/dist/testKit/index.d.ts +4 -4
  80. package/dist/testKit/index.d.ts.map +1 -1
  81. package/dist/types/authorization-attributes-contracts.d.ts +5 -4
  82. package/dist/types/authorization-attributes-contracts.d.ts.map +1 -1
  83. package/dist/types/authorization-attributes-service.interface.d.ts +7 -20
  84. package/dist/types/authorization-attributes-service.interface.d.ts.map +1 -1
  85. package/dist/types/general.d.ts +2 -1
  86. package/dist/types/general.d.ts.map +1 -1
  87. package/dist/utils/assigment-schema.d.ts +29 -0
  88. package/dist/utils/assigment-schema.d.ts.map +1 -0
  89. package/dist/utils/assigment-schema.js +36 -0
  90. package/dist/utils/validation.d.ts +13 -38
  91. package/dist/utils/validation.d.ts.map +1 -1
  92. package/dist/utils/validation.js +42 -97
  93. package/package.json +3 -3
  94. package/src/authorization-attributes-service.ts +223 -35
  95. package/src/authorization-middleware.ts +2 -2
  96. package/src/authorization-service.ts +4 -4
  97. package/src/base-attribute-assignment.ts +10 -35
  98. package/src/constants/sns.ts +2 -19
  99. package/src/entity-attribute-assignment.ts +9 -6
  100. package/src/entity-attributes-constants.ts +6 -6
  101. package/src/errors/argument-error.ts +0 -1
  102. package/src/index.ts +0 -9
  103. package/src/prometheus-service.ts +3 -1
  104. package/src/resource-attribute-assignment.ts +11 -13
  105. package/src/resource-attributes-constants.ts +15 -23
  106. package/src/testKit/index.ts +5 -5
  107. package/src/types/authorization-attributes-contracts.ts +5 -5
  108. package/src/types/authorization-attributes-service.interface.ts +12 -38
  109. package/src/types/general.ts +2 -3
  110. package/src/utils/assigment-schema.ts +29 -0
  111. package/src/utils/validation.ts +41 -92
  112. package/dist/authorization-attributes-ms-service.d.ts +0 -90
  113. package/dist/authorization-attributes-ms-service.d.ts.map +0 -1
  114. package/dist/authorization-attributes-ms-service.js +0 -352
  115. package/dist/authorization-attributes-sns-service.d.ts +0 -90
  116. package/dist/authorization-attributes-sns-service.d.ts.map +0 -1
  117. package/dist/authorization-attributes-sns-service.js +0 -217
  118. package/dist/esm/authorization-attributes-ms-service.d.ts +0 -90
  119. package/dist/esm/authorization-attributes-ms-service.d.ts.map +0 -1
  120. package/dist/esm/authorization-attributes-ms-service.mjs +0 -350
  121. package/dist/esm/authorization-attributes-sns-service.d.ts +0 -90
  122. package/dist/esm/authorization-attributes-sns-service.d.ts.map +0 -1
  123. package/dist/esm/authorization-attributes-sns-service.mjs +0 -211
  124. package/src/authorization-attributes-ms-service.ts +0 -514
  125. package/src/authorization-attributes-sns-service.ts +0 -312
@@ -1,33 +1,54 @@
1
- import { IAuthorizationAttributesService } from './types/authorization-attributes-service.interface';
2
- /**
3
- * Main service class for managing resource and entity attributes.
4
- * Provides access to both direct (MS) and SNS operations.
5
- *
6
- * @example
7
- * ```typescript
8
- * const service = new AuthorizationAttributesService();
9
- *
10
- * // Use direct operations
11
- * await service.direct().upsertResourceAttributes(accountId, assignments);
12
- *
13
- * // Use SNS operations
14
- * await service.sns().upsertResourceAttributes(accountId, assignments, appName, actionId);
15
- * ```
16
- */
1
+ import { FetcherConfig, HttpClient } from '@mondaydotcomorg/trident-backend-api';
2
+ import { RecursivePartial } from '@mondaydotcomorg/monday-fetch-api';
3
+ import { ResourceAttributeAssignment, ResourceAttributeResponse, ResourceAttributeUpsertOperation } from './types/authorization-attributes-contracts';
4
+ import { Resource } from './types/general';
17
5
  export declare class AuthorizationAttributesService {
18
- private _directService;
19
- private _snsService;
6
+ private static LOG_TAG;
7
+ private static API_PATHS;
8
+ private httpClient;
9
+ private fetchOptions;
10
+ private snsArn;
20
11
  /**
21
- * Gets the direct (MS) service instance.
22
- * Initializes the service on first access (lazy initialization).
23
- * @returns IAuthorizationAttributesService instance
12
+ * Public constructor to create the AuthorizationAttributesService instance.
13
+ * @param httpClient The HTTP client to use for API requests, if not provided, the default HTTP client from Api will be used.
14
+ * @param fetchOptions The fetch options to use for API requests, if not provided, the default fetch options will be used.
24
15
  */
25
- direct(): IAuthorizationAttributesService;
16
+ constructor(httpClient?: HttpClient, fetchOptions?: RecursivePartial<FetcherConfig>);
26
17
  /**
27
- * Gets the SNS service instance.
28
- * Initializes the service on first access (lazy initialization).
29
- * @returns IAuthorizationAttributesService instance
18
+ * Upsert resource attributes synchronously, performing http call to the authorization MS to assign the given attributes to the given resource.
19
+ * @param accountId
20
+ * @param resourceAttributeAssignments - Array of resource (resourceType, resourceId) and attribute (key, value) pairs to upsert in the authorization MS.
21
+ * e.g. [{ resourceType: 'board', resourceId: 123, key: 'board_kind', value: 'private' }]
22
+ * @returns ResourceAttributeResponse - The affected (created and updated_ resource attributes assignments in the `attributes` field.
30
23
  */
31
- sns(): IAuthorizationAttributesService;
24
+ upsertResourceAttributes(accountId: number, resourceAttributeAssignments: ResourceAttributeAssignment[]): Promise<ResourceAttributeResponse>;
25
+ /**
26
+ * Delete resource attributes assignments synchronously, performing http call to the authorization MS to delete the given attributes from the given singular resource.
27
+ * @param accountId
28
+ * @param resource - The resource (resourceType, resourceId) to delete the attributes for.
29
+ * @param attributeKeys - Array of attribute keys to delete for the resource.
30
+ * @returns ResourceAttributeResponse - The affected (deleted) resource attributes assignments in the `attributes` field.
31
+ */
32
+ deleteResourceAttributes(accountId: number, resource: Resource, attributeKeys: string[]): Promise<ResourceAttributeResponse>;
33
+ /**
34
+ * Async function, this function only send the updates request to SNS and return before the change actually took place
35
+ * @param accountId
36
+ * @param appName - App name of the calling app
37
+ * @param callerActionIdentifier - action identifier
38
+ * @param resourceAttributeOperations - Array of operations to do on resource attributes.
39
+ * @return {Promise<ResourceAttributesOperation[]>} Array of sent operations
40
+ * */
41
+ updateResourceAttributesAsync(accountId: number, appName: string, callerActionIdentifier: string, resourceAttributeOperations: ResourceAttributeUpsertOperation[]): Promise<ResourceAttributeUpsertOperation[]>;
42
+ private sendSingleSnsMessage;
43
+ private static getSnsTopicArn;
44
+ /**
45
+ * Checks we can contact the required SNS topic that used to send attribute updates to Authorization MS.
46
+ * This function can be used as health check for services that updating resource attributes in async is crucial.
47
+ * Note this function only verify the POD can contact AWS SDK and the topic exists, but the user still might get
48
+ * errors when pushing for the SNS (e.g: in case the AWS role of the POD don't have permissions to push messages).
49
+ * However, this is the best we can do without actually push dummy messages to the SNS.
50
+ * @return {Promise<boolean>} - true if succeeded
51
+ */
52
+ asyncResourceAttributesHealthCheck(): Promise<boolean>;
32
53
  }
33
54
  //# sourceMappingURL=authorization-attributes-service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"authorization-attributes-service.d.ts","sourceRoot":"","sources":["../src/authorization-attributes-service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,+BAA+B,EAAE,MAAM,oDAAoD,CAAC;AAErG;;;;;;;;;;;;;;GAcG;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":"AACA,OAAO,EAAO,aAAa,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;AAEtF,OAAO,EAAoB,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACvF,OAAO,EACL,2BAA2B,EAC3B,yBAAyB,EACzB,gCAAgC,EACjC,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAY3C,qBAAa,8BAA8B;IACzC,OAAO,CAAC,MAAM,CAAC,OAAO,CAA8B;IACpD,OAAO,CAAC,MAAM,CAAC,SAAS,CAGb;IACX,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,YAAY,CAAkC;IACtD,OAAO,CAAC,MAAM,CAAS;IAEvB;;;;OAIG;gBACS,UAAU,CAAC,EAAE,UAAU,EAAE,YAAY,CAAC,EAAE,gBAAgB,CAAC,aAAa,CAAC;IAsBnF;;;;;;OAMG;IACG,wBAAwB,CAC5B,SAAS,EAAE,MAAM,EACjB,4BAA4B,EAAE,2BAA2B,EAAE,GAC1D,OAAO,CAAC,yBAAyB,CAAC;IA6BrC;;;;;;OAMG;IACG,wBAAwB,CAC5B,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,QAAQ,EAClB,aAAa,EAAE,MAAM,EAAE,GACtB,OAAO,CAAC,yBAAyB,CAAC;IAkCrC;;;;;;;UAOM;IACA,6BAA6B,CACjC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,sBAAsB,EAAE,MAAM,EAC9B,2BAA2B,EAAE,gCAAgC,EAAE,GAC9D,OAAO,CAAC,gCAAgC,EAAE,CAAC;YAYhC,oBAAoB;IA4BlC,OAAO,CAAC,MAAM,CAAC,cAAc;IAW7B;;;;;;;OAOG;IACG,kCAAkC,IAAI,OAAO,CAAC,OAAO,CAAC;CAoB7D"}
@@ -1,47 +1,186 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
- const authorizationAttributesMsService = require('./authorization-attributes-ms-service.js');
4
- const authorizationAttributesSnsService = require('./authorization-attributes-sns-service.js');
3
+ const chunk = require('lodash/chunk.js');
4
+ const tridentBackendApi = require('@mondaydotcomorg/trident-backend-api');
5
+ const mondaySns = require('@mondaydotcomorg/monday-sns');
6
+ const mondayFetchApi = require('@mondaydotcomorg/monday-fetch-api');
7
+ const authorizationInternalService = require('./authorization-internal-service.js');
8
+ const attributionsService = require('./attributions-service.js');
9
+ const constants_sns = require('./constants/sns.js');
10
+ const constants = require('./constants.js');
11
+
12
+ const _interopDefault = e => e && e.__esModule ? e : { default: e };
13
+
14
+ const chunk__default = /*#__PURE__*/_interopDefault(chunk);
5
15
 
6
- /**
7
- * Main service class for managing resource and entity attributes.
8
- * Provides access to both direct (MS) and SNS operations.
9
- *
10
- * @example
11
- * ```typescript
12
- * const service = new AuthorizationAttributesService();
13
- *
14
- * // Use direct operations
15
- * await service.direct().upsertResourceAttributes(accountId, assignments);
16
- *
17
- * // Use SNS operations
18
- * await service.sns().upsertResourceAttributes(accountId, assignments, appName, actionId);
19
- * ```
20
- */
21
16
  class AuthorizationAttributesService {
22
- _directService = null;
23
- _snsService = null;
17
+ static LOG_TAG = 'authorization_attributes';
18
+ static API_PATHS = {
19
+ UPSERT_RESOURCE_ATTRIBUTES: '/attributes/{accountId}/resource',
20
+ DELETE_RESOURCE_ATTRIBUTES: '/attributes/{accountId}/resource/{resourceType}/{resourceId}',
21
+ };
22
+ httpClient;
23
+ fetchOptions;
24
+ snsArn;
24
25
  /**
25
- * Gets the direct (MS) service instance.
26
- * Initializes the service on first access (lazy initialization).
27
- * @returns IAuthorizationAttributesService instance
26
+ * Public constructor to create the AuthorizationAttributesService instance.
27
+ * @param httpClient The HTTP client to use for API requests, if not provided, the default HTTP client from Api will be used.
28
+ * @param fetchOptions The fetch options to use for API requests, if not provided, the default fetch options will be used.
28
29
  */
29
- direct() {
30
- if (this._directService === null) {
31
- this._directService = new authorizationAttributesMsService.AuthorizationAttributesMsService();
30
+ constructor(httpClient, fetchOptions) {
31
+ console.log(1);
32
+ if (!httpClient) {
33
+ httpClient = tridentBackendApi.Api.getPart('httpClient');
34
+ if (!httpClient) {
35
+ throw new Error(constants.ERROR_MESSAGES.HTTP_CLIENT_NOT_INITIALIZED);
36
+ }
37
+ }
38
+ if (!fetchOptions) {
39
+ fetchOptions = constants.DEFAULT_FETCH_OPTIONS;
40
+ }
41
+ else {
42
+ fetchOptions = {
43
+ ...constants.DEFAULT_FETCH_OPTIONS,
44
+ ...fetchOptions,
45
+ };
32
46
  }
33
- return this._directService;
47
+ this.httpClient = httpClient;
48
+ this.fetchOptions = fetchOptions;
49
+ this.snsArn = AuthorizationAttributesService.getSnsTopicArn();
34
50
  }
35
51
  /**
36
- * Gets the SNS service instance.
37
- * Initializes the service on first access (lazy initialization).
38
- * @returns IAuthorizationAttributesService instance
52
+ * Upsert resource attributes synchronously, performing http call to the authorization MS to assign the given attributes to the given resource.
53
+ * @param accountId
54
+ * @param resourceAttributeAssignments - Array of resource (resourceType, resourceId) and attribute (key, value) pairs to upsert in the authorization MS.
55
+ * e.g. [{ resourceType: 'board', resourceId: 123, key: 'board_kind', value: 'private' }]
56
+ * @returns ResourceAttributeResponse - The affected (created and updated_ resource attributes assignments in the `attributes` field.
39
57
  */
40
- sns() {
41
- if (this._snsService === null) {
42
- this._snsService = new authorizationAttributesSnsService.AuthorizationAttributesSnsService();
58
+ async upsertResourceAttributes(accountId, resourceAttributeAssignments) {
59
+ const attributionHeaders = attributionsService.getAttributionsFromApi();
60
+ try {
61
+ return await this.httpClient.fetch({
62
+ url: {
63
+ appName: constants.APP_NAME,
64
+ path: AuthorizationAttributesService.API_PATHS.UPSERT_RESOURCE_ATTRIBUTES.replace('{accountId}', accountId.toString()),
65
+ },
66
+ method: 'POST',
67
+ headers: {
68
+ 'Content-Type': 'application/json',
69
+ ...attributionHeaders,
70
+ },
71
+ body: JSON.stringify({ resourceAttributeAssignments }),
72
+ }, this.fetchOptions);
73
+ }
74
+ catch (err) {
75
+ if (err instanceof mondayFetchApi.HttpFetcherError) {
76
+ throw new Error(constants.ERROR_MESSAGES.REQUEST_FAILED('upsertResourceAttributes', err.status, err.message));
77
+ }
78
+ throw err;
79
+ }
80
+ }
81
+ /**
82
+ * Delete resource attributes assignments synchronously, performing http call to the authorization MS to delete the given attributes from the given singular resource.
83
+ * @param accountId
84
+ * @param resource - The resource (resourceType, resourceId) to delete the attributes for.
85
+ * @param attributeKeys - Array of attribute keys to delete for the resource.
86
+ * @returns ResourceAttributeResponse - The affected (deleted) resource attributes assignments in the `attributes` field.
87
+ */
88
+ async deleteResourceAttributes(accountId, resource, attributeKeys) {
89
+ const attributionHeaders = attributionsService.getAttributionsFromApi();
90
+ if (!resource.id) {
91
+ throw new Error('Resource ID is required');
92
+ }
93
+ try {
94
+ return await this.httpClient.fetch({
95
+ url: {
96
+ appName: constants.APP_NAME,
97
+ path: AuthorizationAttributesService.API_PATHS.DELETE_RESOURCE_ATTRIBUTES.replace('{accountId}', accountId.toString())
98
+ .replace('{resourceType}', resource.type)
99
+ .replace('{resourceId}', resource.id.toString()),
100
+ },
101
+ method: 'DELETE',
102
+ headers: {
103
+ 'Content-Type': 'application/json',
104
+ ...attributionHeaders,
105
+ },
106
+ body: JSON.stringify({ keys: attributeKeys }),
107
+ }, this.fetchOptions);
108
+ }
109
+ catch (err) {
110
+ if (err instanceof mondayFetchApi.HttpFetcherError) {
111
+ throw new Error(constants.ERROR_MESSAGES.REQUEST_FAILED('deleteResourceAttributes', err.status, err.message));
112
+ }
113
+ throw err;
114
+ }
115
+ }
116
+ /**
117
+ * Async function, this function only send the updates request to SNS and return before the change actually took place
118
+ * @param accountId
119
+ * @param appName - App name of the calling app
120
+ * @param callerActionIdentifier - action identifier
121
+ * @param resourceAttributeOperations - Array of operations to do on resource attributes.
122
+ * @return {Promise<ResourceAttributesOperation[]>} Array of sent operations
123
+ * */
124
+ async updateResourceAttributesAsync(accountId, appName, callerActionIdentifier, resourceAttributeOperations) {
125
+ const topicArn = this.snsArn;
126
+ const sendToSnsPromises = [];
127
+ const operationChucks = chunk__default.default(resourceAttributeOperations, constants_sns.ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE);
128
+ for (const operationsChunk of operationChucks) {
129
+ sendToSnsPromises.push(this.sendSingleSnsMessage(topicArn, accountId, appName, callerActionIdentifier, operationsChunk));
130
+ }
131
+ return (await Promise.all(sendToSnsPromises)).flat();
132
+ }
133
+ async sendSingleSnsMessage(topicArn, accountId, appName, callerActionIdentifier, operations) {
134
+ const payload = {
135
+ kind: constants_sns.RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND,
136
+ payload: {
137
+ accountId: accountId,
138
+ callerAppName: appName,
139
+ callerActionIdentifier: callerActionIdentifier,
140
+ operations: operations,
141
+ },
142
+ };
143
+ try {
144
+ await mondaySns.sendToSns(payload, topicArn);
145
+ return operations;
146
+ }
147
+ catch (error) {
148
+ authorizationInternalService.logger.error({ error, tag: AuthorizationAttributesService.LOG_TAG }, 'Authorization resource attributes async update: failed to send operations to SNS');
149
+ return [];
150
+ }
151
+ }
152
+ static getSnsTopicArn() {
153
+ const arnFromEnv = process.env[constants_sns.SNS_ARN_ENV_VAR_NAME];
154
+ if (arnFromEnv) {
155
+ return arnFromEnv;
156
+ }
157
+ if (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') {
158
+ return constants_sns.SNS_DEV_TEST_NAME;
159
+ }
160
+ throw new Error('Unable to get sns topic arn from env variable');
161
+ }
162
+ /**
163
+ * Checks we can contact the required SNS topic that used to send attribute updates to Authorization MS.
164
+ * This function can be used as health check for services that updating resource attributes in async is crucial.
165
+ * Note this function only verify the POD can contact AWS SDK and the topic exists, but the user still might get
166
+ * errors when pushing for the SNS (e.g: in case the AWS role of the POD don't have permissions to push messages).
167
+ * However, this is the best we can do without actually push dummy messages to the SNS.
168
+ * @return {Promise<boolean>} - true if succeeded
169
+ */
170
+ async asyncResourceAttributesHealthCheck() {
171
+ try {
172
+ const requestedTopicArn = this.snsArn;
173
+ const attributes = await mondaySns.getTopicAttributes(requestedTopicArn);
174
+ const isHealthy = !(!attributes || !('TopicArn' in attributes) || attributes.TopicArn !== requestedTopicArn);
175
+ if (!isHealthy) {
176
+ authorizationInternalService.logger.error({ requestedTopicArn, snsReturnedAttributes: attributes, tag: AuthorizationAttributesService.LOG_TAG }, 'authorization-attributes-service failed in health check');
177
+ }
178
+ return isHealthy;
179
+ }
180
+ catch (error) {
181
+ authorizationInternalService.logger.error({ error, tag: AuthorizationAttributesService.LOG_TAG }, 'authorization-attributes-service got error during health check');
182
+ return false;
43
183
  }
44
- return this._snsService;
45
184
  }
46
185
  }
47
186
 
@@ -1,6 +1,6 @@
1
- import { BaseRequest, BaseResponse, Context, ContextGetter, ResourceGetter } from './types/general';
1
+ import { Action, BaseRequest, BaseResponse, Context, ContextGetter, ResourceGetter } from './types/general';
2
2
  import type { NextFunction } from 'express';
3
- export declare function getAuthorizationMiddleware(action: string, resourceGetter: ResourceGetter, contextGetter?: ContextGetter): (request: BaseRequest, response: BaseResponse, next: NextFunction) => Promise<void>;
3
+ export declare function getAuthorizationMiddleware(action: Action, resourceGetter: ResourceGetter, contextGetter?: ContextGetter): (request: BaseRequest, response: BaseResponse, next: NextFunction) => Promise<void>;
4
4
  export declare function skipAuthorizationMiddleware(request: BaseRequest, response: BaseResponse, next: NextFunction): void;
5
5
  export declare function authorizationCheckMiddleware(request: BaseRequest, response: BaseResponse, next: NextFunction): void;
6
6
  export declare function defaultContextGetter(request: BaseRequest): Context;
@@ -1 +1 @@
1
- {"version":3,"file":"authorization-middleware.d.ts","sourceRoot":"","sources":["../src/authorization-middleware.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACpG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAI5C,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,cAAc,EAC9B,aAAa,CAAC,EAAE,aAAa,IAG3B,SAAS,WAAW,EACpB,UAAU,YAAY,EACtB,MAAM,YAAY,KACjB,OAAO,CAAC,IAAI,CAAC,CAajB;AAED,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY,GAAG,IAAI,CAGlH;AAED,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY,GAAG,IAAI,CASnH;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAElE"}
1
+ {"version":3,"file":"authorization-middleware.d.ts","sourceRoot":"","sources":["../src/authorization-middleware.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC5G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAI5C,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,cAAc,EAC9B,aAAa,CAAC,EAAE,aAAa,IAG3B,SAAS,WAAW,EACpB,UAAU,YAAY,EACtB,MAAM,YAAY,KACjB,OAAO,CAAC,IAAI,CAAC,CAajB;AAED,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY,GAAG,IAAI,CAGlH;AAED,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY,GAAG,IAAI,CASnH;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAElE"}
@@ -1,6 +1,6 @@
1
1
  import { MondayFetchOptions } from '@mondaydotcomorg/monday-fetch';
2
2
  import { IgniteClient } from '@mondaydotcomorg/ignite-sdk';
3
- import { AuthorizationObject, AuthorizationParams, Resource } from './types/general';
3
+ import { Action, AuthorizationObject, AuthorizationParams, Resource } from './types/general';
4
4
  import { ScopedAction, ScopedActionPermit, ScopedActionResponseObject, ScopeOptions } from './types/scoped-actions-contracts';
5
5
  export interface AuthorizeResponse {
6
6
  isAuthorized: boolean;
@@ -21,7 +21,7 @@ export declare class AuthorizationService {
21
21
  * @deprecated use the second form with authorizationRequestObjects instead,
22
22
  * support of this function will be dropped gradually
23
23
  */
24
- static isAuthorized(accountId: number, userId: number, resources: Resource[], action: string): Promise<AuthorizeResponse>;
24
+ static isAuthorized(accountId: number, userId: number, resources: Resource[], action: Action): Promise<AuthorizeResponse>;
25
25
  static isAuthorized(accountId: number, userId: number, authorizationRequestObjects: AuthorizationObject[]): Promise<AuthorizeResponse>;
26
26
  /**
27
27
  * @deprecated - Please use Ignite instead: https://github.com/DaPulse/ignite-monorepo/blob/master/packages/ignite-sdk/README.md
@@ -40,5 +40,5 @@ export declare class AuthorizationService {
40
40
  }
41
41
  export declare function setRedisClient(client: any, grantedFeatureRedisExpirationInSeconds?: number): void;
42
42
  export declare function setIgniteClient(): Promise<void>;
43
- export declare function createAuthorizationParams(resources: Resource[], action: string): AuthorizationParams;
43
+ export declare function createAuthorizationParams(resources: Resource[], action: Action): AuthorizationParams;
44
44
  //# sourceMappingURL=authorization-service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"authorization-service.d.ts","sourceRoot":"","sources":["../src/authorization-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAGnE,OAAO,EAAmB,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAGrF,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,0BAA0B,EAC1B,YAAY,EACb,MAAM,kCAAkC,CAAC;AAe1C,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,OAAO,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,mBAAmB,CAAC,EAAE,mBAAmB,EAAE,CAAC;CAC7C;AAED,wBAAgB,sBAAsB,CAAC,wBAAwB,EAAE,kBAAkB,QAElF;AAMD,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,MAAM,KAAK,QAAQ,GAK1B;IACD,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAW;IAEpC,OAAO,CAAC,MAAM,KAAK,WAAW,GAK7B;IACD,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAc;IAE1C,MAAM,CAAC,eAAe,IAAI,IAAI;IAK9B,MAAM,CAAC,WAAW,CAAC,MAAC;IACpB,MAAM,CAAC,sCAAsC,CAAC,EAAE,MAAM,CAAC;IACvD,MAAM,CAAC,YAAY,CAAC,EAAE,YAAY,CAAC;IAEnC;;;OAGG;WACU,YAAY,CACvB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,QAAQ,EAAE,EACrB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,iBAAiB,CAAC;WAEhB,YAAY,CACvB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,2BAA2B,EAAE,mBAAmB,EAAE,GACjD,OAAO,CAAC,iBAAiB,CAAC;IAY7B;;;OAGG;WACU,wBAAwB,CACnC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE;QAAE,eAAe,CAAC,EAAE,OAAO,CAAA;KAAO,GAC1C,OAAO,CAAC,OAAO,CAAC;mBAkBE,6BAA6B;IAclD,OAAO,CAAC,MAAM,CAAC,gBAAgB;WAIlB,gBAAgB,CAC3B,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,YAAY,GAClB,OAAO,CAAC,kBAAkB,CAAC;IAM9B,OAAO,CAAC,MAAM,CAAC,UAAU;WAsBZ,wBAAwB,CACnC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,YAAY,EAAE,GAC5B,OAAO,CAAC,0BAA0B,EAAE,CAAC;mBA4CnB,oBAAoB;mBAUpB,oBAAoB;CAmF1C;AAED,wBAAgB,cAAc,CAC5B,MAAM,KAAA,EACN,sCAAsC,GAAE,MAAiD,QAY1F;AAED,wBAAsB,eAAe,kBAMpC;AAED,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,mBAAmB,CAepG"}
1
+ {"version":3,"file":"authorization-service.d.ts","sourceRoot":"","sources":["../src/authorization-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAGnE,OAAO,EAAmB,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAG7F,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,0BAA0B,EAC1B,YAAY,EACb,MAAM,kCAAkC,CAAC;AAe1C,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,OAAO,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,mBAAmB,CAAC,EAAE,mBAAmB,EAAE,CAAC;CAC7C;AAED,wBAAgB,sBAAsB,CAAC,wBAAwB,EAAE,kBAAkB,QAElF;AAMD,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,MAAM,KAAK,QAAQ,GAK1B;IACD,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAW;IAEpC,OAAO,CAAC,MAAM,KAAK,WAAW,GAK7B;IACD,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAc;IAE1C,MAAM,CAAC,eAAe,IAAI,IAAI;IAK9B,MAAM,CAAC,WAAW,CAAC,MAAC;IACpB,MAAM,CAAC,sCAAsC,CAAC,EAAE,MAAM,CAAC;IACvD,MAAM,CAAC,YAAY,CAAC,EAAE,YAAY,CAAC;IAEnC;;;OAGG;WACU,YAAY,CACvB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,QAAQ,EAAE,EACrB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,iBAAiB,CAAC;WAEhB,YAAY,CACvB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,2BAA2B,EAAE,mBAAmB,EAAE,GACjD,OAAO,CAAC,iBAAiB,CAAC;IAY7B;;;OAGG;WACU,wBAAwB,CACnC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE;QAAE,eAAe,CAAC,EAAE,OAAO,CAAA;KAAO,GAC1C,OAAO,CAAC,OAAO,CAAC;mBAkBE,6BAA6B;IAclD,OAAO,CAAC,MAAM,CAAC,gBAAgB;WAIlB,gBAAgB,CAC3B,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,YAAY,GAClB,OAAO,CAAC,kBAAkB,CAAC;IAM9B,OAAO,CAAC,MAAM,CAAC,UAAU;WAsBZ,wBAAwB,CACnC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,YAAY,EAAE,GAC5B,OAAO,CAAC,0BAA0B,EAAE,CAAC;mBA4CnB,oBAAoB;mBAUpB,oBAAoB;CAmF1C;AAED,wBAAgB,cAAc,CAC5B,MAAM,KAAA,EACN,sCAAsC,GAAE,MAAiD,QAY1F;AAED,wBAAsB,eAAe,kBAMpC;AAED,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,mBAAmB,CAepG"}
@@ -2,17 +2,18 @@
2
2
  * Base class for attribute assignments (Resource or Entity)
3
3
  * Provides common validation and functionality
4
4
  */
5
- export declare abstract class BaseAttributeAssignment<TId extends number, TType extends string> {
6
- readonly id: TId;
7
- readonly type: TType;
5
+ export declare abstract class BaseAttributeAssignment<T, R> {
6
+ readonly id: number;
7
+ readonly type: T;
8
8
  readonly attributeKey: string;
9
9
  readonly attributeValue: string;
10
- constructor(id: TId, type: string, attributeKey: string, attributeValue: string, validTypes: readonly string[], idFieldName: string, typeFieldName: string);
10
+ constructor(id: number, type: T, attributeKey: string, attributeValue: string);
11
11
  /**
12
12
  * Compares two assignments for equality
13
13
  * @param other Another assignment instance
14
14
  * @returns true if all properties are equal
15
15
  */
16
- equals(other: BaseAttributeAssignment<TId, TType>): boolean;
16
+ equals(other: BaseAttributeAssignment<T, R>): boolean;
17
+ abstract toDataTransferObject(): R;
17
18
  }
18
19
  //# sourceMappingURL=base-attribute-assignment.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"base-attribute-assignment.d.ts","sourceRoot":"","sources":["../src/base-attribute-assignment.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,8BAAsB,uBAAuB,CAAC,CAAC,EAAE,CAAC;IAChD,SAAgB,EAAE,EAAE,MAAM,CAAC;IAC3B,SAAgB,IAAI,EAAE,CAAC,CAAC;IACxB,SAAgB,YAAY,EAAE,MAAM,CAAC;IACrC,SAAgB,cAAc,EAAE,MAAM,CAAC;gBAE3B,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;IAO7E;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,uBAAuB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO;IAIrD,QAAQ,CAAC,oBAAoB,IAAI,CAAC;CACnC"}
@@ -1,6 +1,10 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
- const utils_validation = require('./utils/validation.js');
3
+ const isEqual = require('lodash/isEqual.js');
4
+
5
+ const _interopDefault = e => e && e.__esModule ? e : { default: e };
6
+
7
+ const isEqual__default = /*#__PURE__*/_interopDefault(isEqual);
4
8
 
5
9
  /**
6
10
  * Base class for attribute assignments (Resource or Entity)
@@ -11,16 +15,9 @@ class BaseAttributeAssignment {
11
15
  type;
12
16
  attributeKey;
13
17
  attributeValue;
14
- constructor(id, type, attributeKey, attributeValue, validTypes, idFieldName, typeFieldName) {
15
- // Validate id
16
- utils_validation.ValidationUtils.validateInteger(id, idFieldName);
17
- // Validate type
18
- this.type = utils_validation.ValidationUtils.validateEnum(type, validTypes, typeFieldName);
19
- // Validate attributeKey
20
- utils_validation.ValidationUtils.validateString(attributeKey, 'attributeKey');
21
- // Validate attributeValue
22
- utils_validation.ValidationUtils.validateString(attributeValue, 'attributeValue');
18
+ constructor(id, type, attributeKey, attributeValue) {
23
19
  this.id = id;
20
+ this.type = type;
24
21
  this.attributeKey = attributeKey;
25
22
  this.attributeValue = attributeValue;
26
23
  }
@@ -30,13 +27,7 @@ class BaseAttributeAssignment {
30
27
  * @returns true if all properties are equal
31
28
  */
32
29
  equals(other) {
33
- if (!(other instanceof this.constructor)) {
34
- return false;
35
- }
36
- return (this.id === other.id &&
37
- this.type === other.type &&
38
- this.attributeKey === other.attributeKey &&
39
- this.attributeValue === other.attributeValue);
30
+ return isEqual__default.default(this, other);
40
31
  }
41
32
  }
42
33
 
@@ -1,15 +1,5 @@
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";
9
- export declare const RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND = "resourceAttributeModification";
10
- export declare const ENTITY_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND = "entityAttributeModification";
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
1
  export declare const SNS_ARN_ENV_VAR_NAME = "SHARED_AUTHORIZATION_SNS_ENDPOINT_RESOURCE_ATTRIBUTES";
14
2
  export declare const SNS_DEV_TEST_NAME = "arn:aws:sns:us-east-1:000000000000:monday-authorization-resource-attributes-sns-local";
3
+ export declare const RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND = "resourceAttributeModification";
4
+ export declare const ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE = 100;
15
5
  //# sourceMappingURL=sns.d.ts.map
@@ -1 +1 @@
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
+ {"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,31 +1,11 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
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';
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';
14
5
  const RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND = 'resourceAttributeModification';
15
- const ENTITY_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND = 'entityAttributeModification';
16
6
  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;
21
7
 
22
- exports.ASYNC_ENTITY_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE = ASYNC_ENTITY_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE;
23
8
  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;
27
9
  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;
30
10
  exports.SNS_ARN_ENV_VAR_NAME = SNS_ARN_ENV_VAR_NAME;
31
11
  exports.SNS_DEV_TEST_NAME = SNS_DEV_TEST_NAME;
@@ -1,15 +1,11 @@
1
1
  import { EntityType } from './entity-attributes-constants';
2
2
  import { BaseAttributeAssignment } from './base-attribute-assignment';
3
- export declare class EntityAttributeAssignment extends BaseAttributeAssignment<number, EntityType> {
3
+ import { EntityAttributeAssignment as EntityAttributeAssignmentContract } from './types/authorization-attributes-contracts';
4
+ export declare class EntityAttributeAssignment extends BaseAttributeAssignment<EntityType, EntityAttributeAssignmentContract> {
4
5
  readonly entityId: number;
5
6
  readonly entityType: EntityType;
6
- constructor(entityId: number, entityType: string, attributeKey: string, attributeValue: string);
7
- toDataTransferObject(): {
8
- entityId: number;
9
- entityType: EntityType;
10
- key: string;
11
- value: string;
12
- };
7
+ constructor(entityId: number, entityType: EntityType, key: string, value: string);
8
+ toDataTransferObject(): EntityAttributeAssignmentContract;
13
9
  /**
14
10
  * Compares two assignments for equality
15
11
  * @param other Another EntityAttributeAssignment instance
@@ -1 +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,oBAAoB;;;;;;IAQpB;;;;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;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,15 +1,16 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
- const entityAttributesConstants = require('./entity-attributes-constants.js');
4
3
  const baseAttributeAssignment = require('./base-attribute-assignment.js');
4
+ const utils_validation = require('./utils/validation.js');
5
5
 
6
6
  class EntityAttributeAssignment extends baseAttributeAssignment.BaseAttributeAssignment {
7
7
  entityId;
8
8
  entityType;
9
- constructor(entityId, entityType, attributeKey, attributeValue) {
10
- super(entityId, entityType, attributeKey, attributeValue, Object.values(entityAttributesConstants.ENTITY_TYPES), 'entityId', 'entityType');
9
+ constructor(entityId, entityType, key, value) {
10
+ utils_validation.ValidationUtils.validateEntityAssignment({ entityId, entityType, key, value });
11
+ super(entityId, entityType, key, value);
11
12
  this.entityId = entityId;
12
- this.entityType = this.type;
13
+ this.entityType = entityType;
13
14
  }
14
15
  toDataTransferObject() {
15
16
  return {
@@ -1,7 +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];
1
+ export declare enum EntityType {
2
+ User = "user",
3
+ Team = "team",
4
+ Account = "account"
5
+ }
6
+ export declare const ENTITY_TYPES: readonly EntityType[];
7
7
  //# sourceMappingURL=entity-attributes-constants.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"entity-attributes-constants.d.ts","sourceRoot":"","sources":["../src/entity-attributes-constants.ts"],"names":[],"mappings":"AAAA,oBAAY,UAAU;IACpB,IAAI,SAAS;IACb,IAAI,SAAS;IACb,OAAO,YAAY;CACpB;AAED,eAAO,MAAM,YAAY,uBAA2C,CAAC"}
@@ -1,9 +1,11 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
- const ENTITY_TYPES = {
4
- USER: 'user',
5
- TEAM: 'team',
6
- ACCOUNT: 'account',
7
- };
3
+ exports.EntityType = void 0;
4
+ (function (EntityType) {
5
+ EntityType["User"] = "user";
6
+ EntityType["Team"] = "team";
7
+ EntityType["Account"] = "account";
8
+ })(exports.EntityType || (exports.EntityType = {}));
9
+ const ENTITY_TYPES = Object.freeze(Object.values(exports.EntityType));
8
10
 
9
11
  exports.ENTITY_TYPES = ENTITY_TYPES;
@@ -1 +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"}
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;CAI5B"}
@@ -4,7 +4,6 @@ class ArgumentError extends Error {
4
4
  constructor(message) {
5
5
  super(message);
6
6
  this.name = 'ArgumentError';
7
- Object.setPrototypeOf(this, ArgumentError.prototype);
8
7
  }
9
8
  }
10
9