@mondaydotcomorg/monday-authorization 3.5.1 → 3.5.3-feat-shaime-support-entity-attributes-in-authorization-sdk-127d99a

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 (124) hide show
  1. package/dist/authorization-attributes-ms-service.d.ts +90 -0
  2. package/dist/authorization-attributes-ms-service.d.ts.map +1 -0
  3. package/dist/authorization-attributes-ms-service.js +351 -0
  4. package/dist/authorization-attributes-service.d.ts +26 -47
  5. package/dist/authorization-attributes-service.d.ts.map +1 -1
  6. package/dist/authorization-attributes-service.js +33 -171
  7. package/dist/authorization-attributes-sns-service.d.ts +90 -0
  8. package/dist/authorization-attributes-sns-service.d.ts.map +1 -0
  9. package/dist/authorization-attributes-sns-service.js +217 -0
  10. package/dist/authorization-middleware.d.ts +2 -2
  11. package/dist/authorization-middleware.d.ts.map +1 -1
  12. package/dist/authorization-service.d.ts +3 -3
  13. package/dist/authorization-service.d.ts.map +1 -1
  14. package/dist/base-attribute-assignment.d.ts +18 -0
  15. package/dist/base-attribute-assignment.d.ts.map +1 -0
  16. package/dist/base-attribute-assignment.js +43 -0
  17. package/dist/constants/sns.d.ts +12 -2
  18. package/dist/constants/sns.d.ts.map +1 -1
  19. package/dist/constants/sns.js +22 -2
  20. package/dist/entity-attribute-assignment.d.ts +14 -0
  21. package/dist/entity-attribute-assignment.d.ts.map +1 -0
  22. package/dist/entity-attribute-assignment.js +24 -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/authorization-attributes-ms-service.d.ts +90 -0
  30. package/dist/esm/authorization-attributes-ms-service.d.ts.map +1 -0
  31. package/dist/esm/authorization-attributes-ms-service.mjs +349 -0
  32. package/dist/esm/authorization-attributes-service.d.ts +26 -47
  33. package/dist/esm/authorization-attributes-service.d.ts.map +1 -1
  34. package/dist/esm/authorization-attributes-service.mjs +33 -167
  35. package/dist/esm/authorization-attributes-sns-service.d.ts +90 -0
  36. package/dist/esm/authorization-attributes-sns-service.d.ts.map +1 -0
  37. package/dist/esm/authorization-attributes-sns-service.mjs +211 -0
  38. package/dist/esm/authorization-middleware.d.ts +2 -2
  39. package/dist/esm/authorization-middleware.d.ts.map +1 -1
  40. package/dist/esm/authorization-service.d.ts +3 -3
  41. package/dist/esm/authorization-service.d.ts.map +1 -1
  42. package/dist/esm/base-attribute-assignment.d.ts +18 -0
  43. package/dist/esm/base-attribute-assignment.d.ts.map +1 -0
  44. package/dist/esm/base-attribute-assignment.mjs +41 -0
  45. package/dist/esm/constants/sns.d.ts +12 -2
  46. package/dist/esm/constants/sns.d.ts.map +1 -1
  47. package/dist/esm/constants/sns.mjs +17 -3
  48. package/dist/esm/entity-attribute-assignment.d.ts +14 -0
  49. package/dist/esm/entity-attribute-assignment.d.ts.map +1 -0
  50. package/dist/esm/entity-attribute-assignment.mjs +22 -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 -0
  58. package/dist/esm/index.d.ts.map +1 -1
  59. package/dist/esm/index.mjs +7 -0
  60. package/dist/esm/prometheus-service.d.ts +1 -2
  61. package/dist/esm/prometheus-service.d.ts.map +1 -1
  62. package/dist/esm/resource-attribute-assignment.d.ts +24 -0
  63. package/dist/esm/resource-attribute-assignment.d.ts.map +1 -0
  64. package/dist/esm/resource-attribute-assignment.mjs +34 -0
  65. package/dist/esm/resource-attributes-constants.d.ts +15 -0
  66. package/dist/esm/resource-attributes-constants.d.ts.map +1 -0
  67. package/dist/esm/resource-attributes-constants.mjs +25 -0
  68. package/dist/esm/testKit/index.d.ts +4 -4
  69. package/dist/esm/testKit/index.d.ts.map +1 -1
  70. package/dist/esm/types/authorization-attributes-contracts.d.ts +27 -12
  71. package/dist/esm/types/authorization-attributes-contracts.d.ts.map +1 -1
  72. package/dist/esm/types/authorization-attributes-contracts.mjs +6 -6
  73. package/dist/esm/types/authorization-attributes-service.interface.d.ts +56 -0
  74. package/dist/esm/types/authorization-attributes-service.interface.d.ts.map +1 -0
  75. package/dist/esm/types/authorization-attributes-service.interface.mjs +1 -0
  76. package/dist/esm/types/general.d.ts +1 -2
  77. package/dist/esm/types/general.d.ts.map +1 -1
  78. package/dist/esm/utils/validation.d.ts +45 -0
  79. package/dist/esm/utils/validation.d.ts.map +1 -0
  80. package/dist/esm/utils/validation.mjs +117 -0
  81. package/dist/index.d.ts +9 -0
  82. package/dist/index.d.ts.map +1 -1
  83. package/dist/index.js +15 -0
  84. package/dist/prometheus-service.d.ts +1 -2
  85. package/dist/prometheus-service.d.ts.map +1 -1
  86. package/dist/resource-attribute-assignment.d.ts +24 -0
  87. package/dist/resource-attribute-assignment.d.ts.map +1 -0
  88. package/dist/resource-attribute-assignment.js +36 -0
  89. package/dist/resource-attributes-constants.d.ts +15 -0
  90. package/dist/resource-attributes-constants.d.ts.map +1 -0
  91. package/dist/resource-attributes-constants.js +28 -0
  92. package/dist/testKit/index.d.ts +4 -4
  93. package/dist/testKit/index.d.ts.map +1 -1
  94. package/dist/types/authorization-attributes-contracts.d.ts +27 -12
  95. package/dist/types/authorization-attributes-contracts.d.ts.map +1 -1
  96. package/dist/types/authorization-attributes-contracts.js +5 -5
  97. package/dist/types/authorization-attributes-service.interface.d.ts +56 -0
  98. package/dist/types/authorization-attributes-service.interface.d.ts.map +1 -0
  99. package/dist/types/authorization-attributes-service.interface.js +1 -0
  100. package/dist/types/general.d.ts +1 -2
  101. package/dist/types/general.d.ts.map +1 -1
  102. package/dist/utils/validation.d.ts +45 -0
  103. package/dist/utils/validation.d.ts.map +1 -0
  104. package/dist/utils/validation.js +119 -0
  105. package/package.json +3 -2
  106. package/src/authorization-attributes-ms-service.ts +513 -0
  107. package/src/authorization-attributes-service.ts +35 -222
  108. package/src/authorization-attributes-sns-service.ts +312 -0
  109. package/src/authorization-middleware.ts +2 -2
  110. package/src/authorization-service.ts +4 -4
  111. package/src/base-attribute-assignment.ts +55 -0
  112. package/src/constants/sns.ts +19 -2
  113. package/src/entity-attribute-assignment.ts +21 -0
  114. package/src/entity-attributes-constants.ts +7 -0
  115. package/src/errors/argument-error.ts +7 -0
  116. package/src/index.ts +9 -0
  117. package/src/prometheus-service.ts +1 -3
  118. package/src/resource-attribute-assignment.ts +43 -0
  119. package/src/resource-attributes-constants.ts +35 -0
  120. package/src/testKit/index.ts +5 -5
  121. package/src/types/authorization-attributes-contracts.ts +36 -11
  122. package/src/types/authorization-attributes-service.interface.ts +101 -0
  123. package/src/types/general.ts +3 -2
  124. package/src/utils/validation.ts +114 -0
@@ -1,54 +1,33 @@
1
- import { FetcherConfig, HttpClient } from '@mondaydotcomorg/trident-backend-api';
2
- import { RecursivePartial } from '@mondaydotcomorg/monday-fetch-api';
3
- import { ResourceAttributeAssignment, ResourceAttributeResponse, ResourceAttributesOperation } from './types/authorization-attributes-contracts';
4
- import { Resource } from './types/general';
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
+ */
5
17
  export declare class AuthorizationAttributesService {
6
- private static LOG_TAG;
7
- private static API_PATHS;
8
- private httpClient;
9
- private fetchOptions;
10
- private snsArn;
18
+ private _directService;
19
+ private _snsService;
11
20
  /**
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.
21
+ * Gets the direct (MS) service instance.
22
+ * Initializes the service on first access (lazy initialization).
23
+ * @returns IAuthorizationAttributesService instance
15
24
  */
16
- constructor(httpClient?: HttpClient, fetchOptions?: RecursivePartial<FetcherConfig>);
25
+ direct(): IAuthorizationAttributesService;
17
26
  /**
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.
27
+ * Gets the SNS service instance.
28
+ * Initializes the service on first access (lazy initialization).
29
+ * @returns IAuthorizationAttributesService instance
23
30
  */
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: ResourceAttributesOperation[]): Promise<ResourceAttributesOperation[]>;
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>;
31
+ sns(): IAuthorizationAttributesService;
53
32
  }
54
33
  //# 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":"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,2BAA2B,EAC5B,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;IAqBnF;;;;;;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,2BAA2B,EAAE,GACzD,OAAO,CAAC,2BAA2B,EAAE,CAAC;YAY3B,oBAAoB;IA4BlC,OAAO,CAAC,MAAM,CAAC,cAAc;IAW7B;;;;;;;OAOG;IACG,kCAAkC,IAAI,OAAO,CAAC,OAAO,CAAC;CAoB7D"}
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,179 +1,45 @@
1
- import chunk from 'lodash/chunk.js';
2
- import { Api } from '@mondaydotcomorg/trident-backend-api';
3
- import { sendToSns, getTopicAttributes } from '@mondaydotcomorg/monday-sns';
4
- import { HttpFetcherError } from '@mondaydotcomorg/monday-fetch-api';
5
- import { logger } from './authorization-internal-service.mjs';
6
- import { getAttributionsFromApi } from './attributions-service.mjs';
7
- import { ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE, SNS_ARN_ENV_VAR_NAME, SNS_DEV_TEST_NAME, RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND } from './constants/sns.mjs';
8
- import { ERROR_MESSAGES, DEFAULT_FETCH_OPTIONS, APP_NAME } from './constants.mjs';
1
+ import { AuthorizationAttributesMsService } from './authorization-attributes-ms-service.mjs';
2
+ import { AuthorizationAttributesSnsService } from './authorization-attributes-sns-service.mjs';
9
3
 
4
+ /**
5
+ * Main service class for managing resource and entity attributes.
6
+ * Provides access to both direct (MS) and SNS operations.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * const service = new AuthorizationAttributesService();
11
+ *
12
+ * // Use direct operations
13
+ * await service.direct().upsertResourceAttributes(accountId, assignments);
14
+ *
15
+ * // Use SNS operations
16
+ * await service.sns().upsertResourceAttributes(accountId, assignments, appName, actionId);
17
+ * ```
18
+ */
10
19
  class AuthorizationAttributesService {
11
- static LOG_TAG = 'authorization_attributes';
12
- static API_PATHS = {
13
- UPSERT_RESOURCE_ATTRIBUTES: '/attributes/{accountId}/resource',
14
- DELETE_RESOURCE_ATTRIBUTES: '/attributes/{accountId}/resource/{resourceType}/{resourceId}',
15
- };
16
- httpClient;
17
- fetchOptions;
18
- snsArn;
20
+ _directService = null;
21
+ _snsService = null;
19
22
  /**
20
- * Public constructor to create the AuthorizationAttributesService instance.
21
- * @param httpClient The HTTP client to use for API requests, if not provided, the default HTTP client from Api will be used.
22
- * @param fetchOptions The fetch options to use for API requests, if not provided, the default fetch options will be used.
23
+ * Gets the direct (MS) service instance.
24
+ * Initializes the service on first access (lazy initialization).
25
+ * @returns IAuthorizationAttributesService instance
23
26
  */
24
- constructor(httpClient, fetchOptions) {
25
- if (!httpClient) {
26
- httpClient = Api.getPart('httpClient');
27
- if (!httpClient) {
28
- throw new Error(ERROR_MESSAGES.HTTP_CLIENT_NOT_INITIALIZED);
29
- }
30
- }
31
- if (!fetchOptions) {
32
- fetchOptions = DEFAULT_FETCH_OPTIONS;
33
- }
34
- else {
35
- fetchOptions = {
36
- ...DEFAULT_FETCH_OPTIONS,
37
- ...fetchOptions,
38
- };
39
- }
40
- this.httpClient = httpClient;
41
- this.fetchOptions = fetchOptions;
42
- this.snsArn = AuthorizationAttributesService.getSnsTopicArn();
43
- }
44
- /**
45
- * Upsert resource attributes synchronously, performing http call to the authorization MS to assign the given attributes to the given resource.
46
- * @param accountId
47
- * @param resourceAttributeAssignments - Array of resource (resourceType, resourceId) and attribute (key, value) pairs to upsert in the authorization MS.
48
- * e.g. [{ resourceType: 'board', resourceId: 123, key: 'board_kind', value: 'private' }]
49
- * @returns ResourceAttributeResponse - The affected (created and updated_ resource attributes assignments in the `attributes` field.
50
- */
51
- async upsertResourceAttributes(accountId, resourceAttributeAssignments) {
52
- const attributionHeaders = getAttributionsFromApi();
53
- try {
54
- return await this.httpClient.fetch({
55
- url: {
56
- appName: APP_NAME,
57
- path: AuthorizationAttributesService.API_PATHS.UPSERT_RESOURCE_ATTRIBUTES.replace('{accountId}', accountId.toString()),
58
- },
59
- method: 'POST',
60
- headers: {
61
- 'Content-Type': 'application/json',
62
- ...attributionHeaders,
63
- },
64
- body: JSON.stringify({ resourceAttributeAssignments }),
65
- }, this.fetchOptions);
66
- }
67
- catch (err) {
68
- if (err instanceof HttpFetcherError) {
69
- throw new Error(ERROR_MESSAGES.REQUEST_FAILED('upsertResourceAttributes', err.status, err.message));
70
- }
71
- throw err;
27
+ direct() {
28
+ if (this._directService === null) {
29
+ this._directService = new AuthorizationAttributesMsService();
72
30
  }
31
+ return this._directService;
73
32
  }
74
33
  /**
75
- * Delete resource attributes assignments synchronously, performing http call to the authorization MS to delete the given attributes from the given singular resource.
76
- * @param accountId
77
- * @param resource - The resource (resourceType, resourceId) to delete the attributes for.
78
- * @param attributeKeys - Array of attribute keys to delete for the resource.
79
- * @returns ResourceAttributeResponse - The affected (deleted) resource attributes assignments in the `attributes` field.
34
+ * Gets the SNS service instance.
35
+ * Initializes the service on first access (lazy initialization).
36
+ * @returns IAuthorizationAttributesService instance
80
37
  */
81
- async deleteResourceAttributes(accountId, resource, attributeKeys) {
82
- const attributionHeaders = getAttributionsFromApi();
83
- if (!resource.id) {
84
- throw new Error('Resource ID is required');
85
- }
86
- try {
87
- return await this.httpClient.fetch({
88
- url: {
89
- appName: APP_NAME,
90
- path: AuthorizationAttributesService.API_PATHS.DELETE_RESOURCE_ATTRIBUTES.replace('{accountId}', accountId.toString())
91
- .replace('{resourceType}', resource.type)
92
- .replace('{resourceId}', resource.id.toString()),
93
- },
94
- method: 'DELETE',
95
- headers: {
96
- 'Content-Type': 'application/json',
97
- ...attributionHeaders,
98
- },
99
- body: JSON.stringify({ keys: attributeKeys }),
100
- }, this.fetchOptions);
101
- }
102
- catch (err) {
103
- if (err instanceof HttpFetcherError) {
104
- throw new Error(ERROR_MESSAGES.REQUEST_FAILED('deleteResourceAttributes', err.status, err.message));
105
- }
106
- throw err;
107
- }
108
- }
109
- /**
110
- * Async function, this function only send the updates request to SNS and return before the change actually took place
111
- * @param accountId
112
- * @param appName - App name of the calling app
113
- * @param callerActionIdentifier - action identifier
114
- * @param resourceAttributeOperations - Array of operations to do on resource attributes.
115
- * @return {Promise<ResourceAttributesOperation[]>} Array of sent operations
116
- * */
117
- async updateResourceAttributesAsync(accountId, appName, callerActionIdentifier, resourceAttributeOperations) {
118
- const topicArn = this.snsArn;
119
- const sendToSnsPromises = [];
120
- const operationChucks = chunk(resourceAttributeOperations, ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE);
121
- for (const operationsChunk of operationChucks) {
122
- sendToSnsPromises.push(this.sendSingleSnsMessage(topicArn, accountId, appName, callerActionIdentifier, operationsChunk));
123
- }
124
- return (await Promise.all(sendToSnsPromises)).flat();
125
- }
126
- async sendSingleSnsMessage(topicArn, accountId, appName, callerActionIdentifier, operations) {
127
- const payload = {
128
- kind: RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND,
129
- payload: {
130
- accountId: accountId,
131
- callerAppName: appName,
132
- callerActionIdentifier: callerActionIdentifier,
133
- operations: operations,
134
- },
135
- };
136
- try {
137
- await sendToSns(payload, topicArn);
138
- return operations;
139
- }
140
- catch (error) {
141
- logger.error({ error, tag: AuthorizationAttributesService.LOG_TAG }, 'Authorization resource attributes async update: failed to send operations to SNS');
142
- return [];
143
- }
144
- }
145
- static getSnsTopicArn() {
146
- const arnFromEnv = process.env[SNS_ARN_ENV_VAR_NAME];
147
- if (arnFromEnv) {
148
- return arnFromEnv;
149
- }
150
- if (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') {
151
- return SNS_DEV_TEST_NAME;
152
- }
153
- throw new Error('Unable to get sns topic arn from env variable');
154
- }
155
- /**
156
- * Checks we can contact the required SNS topic that used to send attribute updates to Authorization MS.
157
- * This function can be used as health check for services that updating resource attributes in async is crucial.
158
- * Note this function only verify the POD can contact AWS SDK and the topic exists, but the user still might get
159
- * errors when pushing for the SNS (e.g: in case the AWS role of the POD don't have permissions to push messages).
160
- * However, this is the best we can do without actually push dummy messages to the SNS.
161
- * @return {Promise<boolean>} - true if succeeded
162
- */
163
- async asyncResourceAttributesHealthCheck() {
164
- try {
165
- const requestedTopicArn = this.snsArn;
166
- const attributes = await getTopicAttributes(requestedTopicArn);
167
- const isHealthy = !(!attributes || !('TopicArn' in attributes) || attributes.TopicArn !== requestedTopicArn);
168
- if (!isHealthy) {
169
- logger.error({ requestedTopicArn, snsReturnedAttributes: attributes, tag: AuthorizationAttributesService.LOG_TAG }, 'authorization-attributes-service failed in health check');
170
- }
171
- return isHealthy;
172
- }
173
- catch (error) {
174
- logger.error({ error, tag: AuthorizationAttributesService.LOG_TAG }, 'authorization-attributes-service got error during health check');
175
- return false;
38
+ sns() {
39
+ if (this._snsService === null) {
40
+ this._snsService = new AuthorizationAttributesSnsService();
176
41
  }
42
+ return this._snsService;
177
43
  }
178
44
  }
179
45
 
@@ -0,0 +1,90 @@
1
+ import { ResourceAttributeAssignment, ResourceAttributeOperation, EntityAttributeOperation, EntityType } from './types/authorization-attributes-contracts';
2
+ import { EntityAttributeAssignment } from './entity-attribute-assignment';
3
+ import { Resource } from './types/general';
4
+ import { IAuthorizationAttributesService } from './types/authorization-attributes-service.interface';
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 IAuthorizationAttributesService {
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 upsert resource attributes using SNS.
19
+ * Sends the updates request to SNS and returns before the change actually took place.
20
+ * @param accountId The account ID
21
+ * @param appName App name of the calling app
22
+ * @param callerActionIdentifier Action identifier
23
+ * @param resourceAttributeAssignments Array of resource attribute assignments to upsert
24
+ * @return Promise with array of sent operations
25
+ */
26
+ upsertResourceAttributes(accountId: number, resourceAttributeAssignments: ResourceAttributeAssignment[], appName?: string, callerActionIdentifier?: string): Promise<ResourceAttributeOperation[]>;
27
+ /**
28
+ * Async function to delete resource attributes using SNS.
29
+ * Sends the updates request to SNS and returns before the change actually took place.
30
+ * @param accountId The account ID
31
+ * @param appName App name of the calling app
32
+ * @param callerActionIdentifier Action identifier
33
+ * @param resource The resource (resourceType, resourceId)
34
+ * @param attributeKeys Array of attribute keys to delete
35
+ * @return Promise with array of sent operations
36
+ */
37
+ deleteResourceAttributes(accountId: number, resource: Resource, attributeKeys: string[], appName?: string, callerActionIdentifier?: string): Promise<ResourceAttributeOperation[]>;
38
+ /**
39
+ * Async function to upsert entity attributes using SNS.
40
+ * Sends the updates request to SNS and returns before the change actually took place.
41
+ * @param accountId The account ID
42
+ * @param appName App name of the calling app
43
+ * @param callerActionIdentifier Action identifier
44
+ * @param entityAttributeAssignments Array of entity attribute assignments to upsert
45
+ * @return Promise with array of sent operations
46
+ */
47
+ upsertEntityAttributes(accountId: number, entityAttributeAssignments: EntityAttributeAssignment[], appName?: string, callerActionIdentifier?: string): Promise<EntityAttributeOperation[]>;
48
+ /**
49
+ * Async function to delete entity attributes using SNS.
50
+ * Sends the updates request to SNS and returns before the change actually took place.
51
+ * @param accountId The account ID
52
+ * @param appName App name of the calling app
53
+ * @param callerActionIdentifier Action identifier
54
+ * @param entityType The entity type
55
+ * @param entityId The entity ID
56
+ * @param attributeKeys Array of attribute keys to delete
57
+ * @return Promise with array of sent operations
58
+ */
59
+ deleteEntityAttributes(accountId: number, entityType: EntityType | string, entityId: number, attributeKeys: string[], appName?: string, callerActionIdentifier?: string): Promise<EntityAttributeOperation[]>;
60
+ /**
61
+ * Async function, this function only send the updates request to SNS and return before the change actually took place
62
+ * @param accountId
63
+ * @param appName - App name of the calling app
64
+ * @param callerActionIdentifier - action identifier
65
+ * @param resourceAttributeOperations - Array of operations to do on resource attributes.
66
+ * @return {Promise<ResourceAttributesOperation[]>} Array of sent operations
67
+ * */
68
+ updateResourceAttributes(accountId: number, appName: string, callerActionIdentifier: string, resourceAttributeOperations: ResourceAttributeOperation[]): Promise<ResourceAttributeOperation[]>;
69
+ /**
70
+ * Async function, this function only send the updates request to SNS and return before the change actually took place
71
+ * @param accountId
72
+ * @param appName - App name of the calling app
73
+ * @param callerActionIdentifier - action identifier
74
+ * @param entityAttributeOperations - Array of operations to do on entity attributes.
75
+ * @return {Promise<EntityAttributeOperation[]>} Array of sent operations
76
+ * */
77
+ updateEntityAttributes(accountId: number, appName: string, callerActionIdentifier: string, entityAttributeOperations: EntityAttributeOperation[]): Promise<EntityAttributeOperation[]>;
78
+ private sendSingleSnsMessage;
79
+ private static getSnsTopicArn;
80
+ /**
81
+ * Checks we can contact the required SNS topic that used to send attribute updates to Authorization MS.
82
+ * This function can be used as health check for services that updating resource attributes in async is crucial.
83
+ * Note this function only verify the POD can contact AWS SDK and the topic exists, but the user still might get
84
+ * errors when pushing for the SNS (e.g: in case the AWS role of the POD don't have permissions to push messages).
85
+ * However, this is the best we can do without actually push dummy messages to the SNS.
86
+ * @return {Promise<boolean>} - true if succeeded
87
+ */
88
+ asyncResourceAttributesHealthCheck(): Promise<boolean>;
89
+ }
90
+ //# 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,0BAA0B,EAC1B,wBAAwB,EAExB,UAAU,EACX,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAc3C,OAAO,EAAE,+BAA+B,EAAE,MAAM,oDAAoD,CAAC;AAErG;;;GAGG;AACH,qBAAa,iCAAkC,YAAW,+BAA+B;IACvF,OAAO,CAAC,MAAM,CAAC,OAAO,CAA8B;IACpD,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,YAAY,CAAS;IAE7B;;OAEG;;IAMH;;;;;;;;OAQG;IACG,wBAAwB,CAC5B,SAAS,EAAE,MAAM,EACjB,4BAA4B,EAAE,2BAA2B,EAAE,EAC3D,OAAO,CAAC,EAAE,MAAM,EAChB,sBAAsB,CAAC,EAAE,MAAM,GAC9B,OAAO,CAAC,0BAA0B,EAAE,CAAC;IAWxC;;;;;;;;;OASG;IACG,wBAAwB,CAC5B,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,QAAQ,EAClB,aAAa,EAAE,MAAM,EAAE,EACvB,OAAO,CAAC,EAAE,MAAM,EAChB,sBAAsB,CAAC,EAAE,MAAM,GAC9B,OAAO,CAAC,0BAA0B,EAAE,CAAC;IAgBxC;;;;;;;;OAQG;IACG,sBAAsB,CAC1B,SAAS,EAAE,MAAM,EACjB,0BAA0B,EAAE,yBAAyB,EAAE,EACvD,OAAO,CAAC,EAAE,MAAM,EAChB,sBAAsB,CAAC,EAAE,MAAM,GAC9B,OAAO,CAAC,wBAAwB,EAAE,CAAC;IAgBtC;;;;;;;;;;OAUG;IACG,sBAAsB,CAC1B,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,UAAU,GAAG,MAAM,EAC/B,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,EAAE,EACvB,OAAO,CAAC,EAAE,MAAM,EAChB,sBAAsB,CAAC,EAAE,MAAM,GAC9B,OAAO,CAAC,wBAAwB,EAAE,CAAC;IAgBtC;;;;;;;UAOM;IACA,wBAAwB,CAC5B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,sBAAsB,EAAE,MAAM,EAC9B,2BAA2B,EAAE,0BAA0B,EAAE,GACxD,OAAO,CAAC,0BAA0B,EAAE,CAAC;IAoBxC;;;;;;;UAOM;IACA,sBAAsB,CAC1B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,sBAAsB,EAAE,MAAM,EAC9B,yBAAyB,EAAE,wBAAwB,EAAE,GACpD,OAAO,CAAC,wBAAwB,EAAE,CAAC;YAoBxB,oBAAoB;IA2BlC,OAAO,CAAC,MAAM,CAAC,cAAc;IA0B7B;;;;;;;OAOG;IACG,kCAAkC,IAAI,OAAO,CAAC,OAAO,CAAC;CAoB7D"}
@@ -0,0 +1,211 @@
1
+ import chunk from 'lodash/chunk.js';
2
+ import { sendToSns, getTopicAttributes } from '@mondaydotcomorg/monday-sns';
3
+ import { AttributeOperation } from './types/authorization-attributes-contracts.mjs';
4
+ import { logger } from './authorization-internal-service.mjs';
5
+ 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';
6
+
7
+ /**
8
+ * Service class for managing resource attributes asynchronously via SNS.
9
+ * Provides asynchronous operations to create/update and delete attributes on resources.
10
+ */
11
+ class AuthorizationAttributesSnsService {
12
+ static LOG_TAG = 'authorization_attributes';
13
+ resourceSnsArn;
14
+ entitySnsArn;
15
+ /**
16
+ * Public constructor to create the AuthorizationAttributesSnsService instance.
17
+ */
18
+ constructor() {
19
+ this.resourceSnsArn = AuthorizationAttributesSnsService.getSnsTopicArn(SnsTopicType.RESOURCE);
20
+ this.entitySnsArn = AuthorizationAttributesSnsService.getSnsTopicArn(SnsTopicType.ENTITY);
21
+ }
22
+ /**
23
+ * Async function to upsert 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 resourceAttributeAssignments Array of resource attribute assignments to upsert
29
+ * @return Promise with array of sent operations
30
+ */
31
+ async upsertResourceAttributes(accountId, resourceAttributeAssignments, appName, callerActionIdentifier) {
32
+ if (!appName || !callerActionIdentifier) {
33
+ throw new Error('appName and callerActionIdentifier are required for SNS service');
34
+ }
35
+ const operations = resourceAttributeAssignments.map(assignment => ({
36
+ ...assignment,
37
+ operationType: AttributeOperation.UPSERT,
38
+ }));
39
+ return this.updateResourceAttributes(accountId, appName, callerActionIdentifier, operations);
40
+ }
41
+ /**
42
+ * Async function to delete resource attributes using SNS.
43
+ * Sends the updates request to SNS and returns before the change actually took place.
44
+ * @param accountId The account ID
45
+ * @param appName App name of the calling app
46
+ * @param callerActionIdentifier Action identifier
47
+ * @param resource The resource (resourceType, resourceId)
48
+ * @param attributeKeys Array of attribute keys to delete
49
+ * @return Promise with array of sent operations
50
+ */
51
+ async deleteResourceAttributes(accountId, resource, attributeKeys, appName, callerActionIdentifier) {
52
+ if (!appName || !callerActionIdentifier) {
53
+ throw new Error('appName and callerActionIdentifier are required for SNS service');
54
+ }
55
+ const operations = attributeKeys.map(key => ({
56
+ resourceType: resource.type,
57
+ resourceId: resource.id,
58
+ key,
59
+ operationType: AttributeOperation.DELETE,
60
+ }));
61
+ return this.updateResourceAttributes(accountId, appName, callerActionIdentifier, operations);
62
+ }
63
+ /**
64
+ * Async function to upsert entity attributes using SNS.
65
+ * Sends the updates request to SNS and returns before the change actually took place.
66
+ * @param accountId The account ID
67
+ * @param appName App name of the calling app
68
+ * @param callerActionIdentifier Action identifier
69
+ * @param entityAttributeAssignments Array of entity attribute assignments to upsert
70
+ * @return Promise with array of sent operations
71
+ */
72
+ async upsertEntityAttributes(accountId, entityAttributeAssignments, appName, callerActionIdentifier) {
73
+ if (!appName || !callerActionIdentifier) {
74
+ throw new Error('appName and callerActionIdentifier are required for SNS service');
75
+ }
76
+ const operations = entityAttributeAssignments.map(assignment => {
77
+ return {
78
+ entityId: assignment.entityId,
79
+ entityType: assignment.entityType,
80
+ key: assignment.attributeKey,
81
+ value: assignment.attributeValue,
82
+ operationType: AttributeOperation.UPSERT,
83
+ };
84
+ });
85
+ return this.updateEntityAttributes(accountId, appName, callerActionIdentifier, operations);
86
+ }
87
+ /**
88
+ * Async function to delete entity attributes using SNS.
89
+ * Sends the updates request to SNS and returns before the change actually took place.
90
+ * @param accountId The account ID
91
+ * @param appName App name of the calling app
92
+ * @param callerActionIdentifier Action identifier
93
+ * @param entityType The entity type
94
+ * @param entityId The entity ID
95
+ * @param attributeKeys Array of attribute keys to delete
96
+ * @return Promise with array of sent operations
97
+ */
98
+ async deleteEntityAttributes(accountId, entityType, entityId, attributeKeys, appName, callerActionIdentifier) {
99
+ if (!appName || !callerActionIdentifier) {
100
+ throw new Error('appName and callerActionIdentifier are required for SNS service');
101
+ }
102
+ const operations = attributeKeys.map(key => ({
103
+ entityType: entityType,
104
+ entityId,
105
+ key,
106
+ operationType: AttributeOperation.DELETE,
107
+ }));
108
+ return this.updateEntityAttributes(accountId, appName, callerActionIdentifier, operations);
109
+ }
110
+ /**
111
+ * Async function, this function only send the updates request to SNS and return before the change actually took place
112
+ * @param accountId
113
+ * @param appName - App name of the calling app
114
+ * @param callerActionIdentifier - action identifier
115
+ * @param resourceAttributeOperations - Array of operations to do on resource attributes.
116
+ * @return {Promise<ResourceAttributesOperation[]>} Array of sent operations
117
+ * */
118
+ async updateResourceAttributes(accountId, appName, callerActionIdentifier, resourceAttributeOperations) {
119
+ const topicArn = this.resourceSnsArn;
120
+ const sendToSnsPromises = [];
121
+ const operationChucks = chunk(resourceAttributeOperations, ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE);
122
+ for (const operationsChunk of operationChucks) {
123
+ 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'));
124
+ }
125
+ return (await Promise.all(sendToSnsPromises)).flat();
126
+ }
127
+ /**
128
+ * Async function, this function only send the updates request to SNS and return before the change actually took place
129
+ * @param accountId
130
+ * @param appName - App name of the calling app
131
+ * @param callerActionIdentifier - action identifier
132
+ * @param entityAttributeOperations - Array of operations to do on entity attributes.
133
+ * @return {Promise<EntityAttributeOperation[]>} Array of sent operations
134
+ * */
135
+ async updateEntityAttributes(accountId, appName, callerActionIdentifier, entityAttributeOperations) {
136
+ const topicArn = this.entitySnsArn;
137
+ const sendToSnsPromises = [];
138
+ const operationChucks = chunk(entityAttributeOperations, ASYNC_ENTITY_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE);
139
+ for (const operationsChunk of operationChucks) {
140
+ 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'));
141
+ }
142
+ return (await Promise.all(sendToSnsPromises)).flat();
143
+ }
144
+ async sendSingleSnsMessage(topicArn, accountId, appName, callerActionIdentifier, operations, kind, errorLogMessage) {
145
+ const payload = {
146
+ kind,
147
+ payload: {
148
+ accountId: accountId,
149
+ callerAppName: appName,
150
+ callerActionIdentifier: callerActionIdentifier,
151
+ operations: operations,
152
+ },
153
+ };
154
+ try {
155
+ await sendToSns(payload, topicArn);
156
+ return operations;
157
+ }
158
+ catch (error) {
159
+ logger.error({ error, tag: AuthorizationAttributesSnsService.LOG_TAG }, errorLogMessage);
160
+ return [];
161
+ }
162
+ }
163
+ static getSnsTopicArn(type) {
164
+ let envVarName;
165
+ let devTestName;
166
+ switch (type) {
167
+ case SnsTopicType.ENTITY:
168
+ envVarName = ENTITY_SNS_ARN_ENV_VAR_NAME;
169
+ devTestName = ENTITY_SNS_DEV_TEST_NAME;
170
+ break;
171
+ default:
172
+ // Default to resource SNS constants
173
+ envVarName = RESOURCE_SNS_ARN_ENV_VAR_NAME;
174
+ devTestName = RESOURCE_SNS_DEV_TEST_NAME;
175
+ break;
176
+ }
177
+ const arnFromEnv = process.env[envVarName];
178
+ if (arnFromEnv) {
179
+ return arnFromEnv;
180
+ }
181
+ if (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') {
182
+ return devTestName;
183
+ }
184
+ throw new Error(`Unable to get ${type} sns topic arn from env variable`);
185
+ }
186
+ /**
187
+ * Checks we can contact the required SNS topic that used to send attribute updates to Authorization MS.
188
+ * This function can be used as health check for services that updating resource attributes in async is crucial.
189
+ * Note this function only verify the POD can contact AWS SDK and the topic exists, but the user still might get
190
+ * errors when pushing for the SNS (e.g: in case the AWS role of the POD don't have permissions to push messages).
191
+ * However, this is the best we can do without actually push dummy messages to the SNS.
192
+ * @return {Promise<boolean>} - true if succeeded
193
+ */
194
+ async asyncResourceAttributesHealthCheck() {
195
+ try {
196
+ const requestedTopicArn = this.resourceSnsArn;
197
+ const attributes = await getTopicAttributes(requestedTopicArn);
198
+ const isHealthy = !(!attributes || !('TopicArn' in attributes) || attributes.TopicArn !== requestedTopicArn);
199
+ if (!isHealthy) {
200
+ logger.error({ requestedTopicArn, snsReturnedAttributes: attributes, tag: AuthorizationAttributesSnsService.LOG_TAG }, 'authorization-attributes-service failed in health check');
201
+ }
202
+ return isHealthy;
203
+ }
204
+ catch (error) {
205
+ logger.error({ error, tag: AuthorizationAttributesSnsService.LOG_TAG }, 'authorization-attributes-service got error during health check');
206
+ return false;
207
+ }
208
+ }
209
+ }
210
+
211
+ export { AuthorizationAttributesSnsService };
@@ -1,6 +1,6 @@
1
- import { Action, BaseRequest, BaseResponse, Context, ContextGetter, ResourceGetter } from './types/general';
1
+ import { BaseRequest, BaseResponse, Context, ContextGetter, ResourceGetter } from './types/general';
2
2
  import type { NextFunction } from 'express';
3
- export declare function getAuthorizationMiddleware(action: Action, resourceGetter: ResourceGetter, contextGetter?: ContextGetter): (request: BaseRequest, response: BaseResponse, next: NextFunction) => Promise<void>;
3
+ export declare function getAuthorizationMiddleware(action: string, 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,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
+ {"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,6 +1,6 @@
1
1
  import { MondayFetchOptions } from '@mondaydotcomorg/monday-fetch';
2
2
  import { IgniteClient } from '@mondaydotcomorg/ignite-sdk';
3
- import { Action, AuthorizationObject, AuthorizationParams, Resource } from './types/general';
3
+ import { 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: Action): Promise<AuthorizeResponse>;
24
+ static isAuthorized(accountId: number, userId: number, resources: Resource[], action: string): 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: Action): AuthorizationParams;
43
+ export declare function createAuthorizationParams(resources: Resource[], action: string): AuthorizationParams;
44
44
  //# sourceMappingURL=authorization-service.d.ts.map