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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/dist/authorization-attributes-ms-service.d.ts +68 -0
  2. package/dist/authorization-attributes-ms-service.d.ts.map +1 -0
  3. package/dist/authorization-attributes-ms-service.js +263 -0
  4. package/dist/authorization-attributes-service.d.ts +25 -47
  5. package/dist/authorization-attributes-service.d.ts.map +1 -1
  6. package/dist/authorization-attributes-service.js +32 -171
  7. package/dist/authorization-attributes-sns-service.d.ts +84 -0
  8. package/dist/authorization-attributes-sns-service.d.ts.map +1 -0
  9. package/dist/authorization-attributes-sns-service.js +196 -0
  10. package/dist/constants/sns.d.ts +12 -2
  11. package/dist/constants/sns.d.ts.map +1 -1
  12. package/dist/constants/sns.js +22 -2
  13. package/dist/entity-attribute-assignment.d.ts.map +1 -1
  14. package/dist/entity-attribute-assignment.js +0 -2
  15. package/dist/esm/authorization-attributes-ms-service.d.ts +68 -0
  16. package/dist/esm/authorization-attributes-ms-service.d.ts.map +1 -0
  17. package/dist/esm/authorization-attributes-ms-service.mjs +261 -0
  18. package/dist/esm/authorization-attributes-service.d.ts +25 -47
  19. package/dist/esm/authorization-attributes-service.d.ts.map +1 -1
  20. package/dist/esm/authorization-attributes-service.mjs +32 -167
  21. package/dist/esm/authorization-attributes-sns-service.d.ts +84 -0
  22. package/dist/esm/authorization-attributes-sns-service.d.ts.map +1 -0
  23. package/dist/esm/authorization-attributes-sns-service.mjs +190 -0
  24. package/dist/esm/constants/sns.d.ts +12 -2
  25. package/dist/esm/constants/sns.d.ts.map +1 -1
  26. package/dist/esm/constants/sns.mjs +17 -3
  27. package/dist/esm/entity-attribute-assignment.d.ts.map +1 -1
  28. package/dist/esm/entity-attribute-assignment.mjs +0 -2
  29. package/dist/esm/index.d.ts +6 -0
  30. package/dist/esm/index.d.ts.map +1 -1
  31. package/dist/esm/index.mjs +5 -0
  32. package/dist/esm/resource-attribute-assignment.d.ts.map +1 -1
  33. package/dist/esm/resource-attribute-assignment.mjs +0 -2
  34. package/dist/esm/resource-attributes-constants.d.ts +2 -1
  35. package/dist/esm/resource-attributes-constants.d.ts.map +1 -1
  36. package/dist/esm/resource-attributes-constants.mjs +1 -0
  37. package/dist/esm/types/authorization-attributes-contracts.d.ts +2 -17
  38. package/dist/esm/types/authorization-attributes-contracts.d.ts.map +1 -1
  39. package/dist/esm/types/authorization-attributes-service.interface.d.ts +14 -25
  40. package/dist/esm/types/authorization-attributes-service.interface.d.ts.map +1 -1
  41. package/dist/esm/types/general.d.ts +4 -3
  42. package/dist/esm/types/general.d.ts.map +1 -1
  43. package/dist/esm/utils/assignment-schema.d.ts +51 -0
  44. package/dist/esm/utils/assignment-schema.d.ts.map +1 -0
  45. package/dist/esm/utils/assignment-schema.mjs +49 -0
  46. package/dist/esm/utils/resource-schema.d.ts +9 -0
  47. package/dist/esm/utils/resource-schema.d.ts.map +1 -0
  48. package/dist/esm/utils/resource-schema.mjs +16 -0
  49. package/dist/esm/utils/validation.d.ts +11 -3
  50. package/dist/esm/utils/validation.d.ts.map +1 -1
  51. package/dist/esm/utils/validation.mjs +50 -13
  52. package/dist/index.d.ts +6 -0
  53. package/dist/index.d.ts.map +1 -1
  54. package/dist/index.js +22 -0
  55. package/dist/resource-attribute-assignment.d.ts.map +1 -1
  56. package/dist/resource-attribute-assignment.js +0 -2
  57. package/dist/resource-attributes-constants.d.ts +2 -1
  58. package/dist/resource-attributes-constants.d.ts.map +1 -1
  59. package/dist/resource-attributes-constants.js +1 -0
  60. package/dist/types/authorization-attributes-contracts.d.ts +2 -17
  61. package/dist/types/authorization-attributes-contracts.d.ts.map +1 -1
  62. package/dist/types/authorization-attributes-service.interface.d.ts +14 -25
  63. package/dist/types/authorization-attributes-service.interface.d.ts.map +1 -1
  64. package/dist/types/general.d.ts +4 -3
  65. package/dist/types/general.d.ts.map +1 -1
  66. package/dist/utils/assignment-schema.d.ts +51 -0
  67. package/dist/utils/assignment-schema.d.ts.map +1 -0
  68. package/dist/utils/assignment-schema.js +58 -0
  69. package/dist/utils/resource-schema.d.ts +9 -0
  70. package/dist/utils/resource-schema.d.ts.map +1 -0
  71. package/dist/utils/resource-schema.js +22 -0
  72. package/dist/utils/validation.d.ts +11 -3
  73. package/dist/utils/validation.d.ts.map +1 -1
  74. package/dist/utils/validation.js +50 -13
  75. package/package.json +1 -1
  76. package/src/authorization-attributes-ms-service.ts +397 -0
  77. package/src/authorization-attributes-service.ts +34 -222
  78. package/src/authorization-attributes-sns-service.ts +321 -0
  79. package/src/constants/sns.ts +19 -2
  80. package/src/entity-attribute-assignment.ts +0 -2
  81. package/src/index.ts +17 -0
  82. package/src/resource-attribute-assignment.ts +0 -2
  83. package/src/resource-attributes-constants.ts +1 -0
  84. package/src/types/authorization-attributes-contracts.ts +2 -24
  85. package/src/types/authorization-attributes-service.interface.ts +19 -31
  86. package/src/types/general.ts +4 -3
  87. package/src/utils/assignment-schema.ts +51 -0
  88. package/src/utils/resource-schema.ts +16 -0
  89. package/src/utils/validation.ts +76 -15
  90. package/dist/esm/utils/assigment-schema.d.ts +0 -29
  91. package/dist/esm/utils/assigment-schema.d.ts.map +0 -1
  92. package/dist/esm/utils/assigment-schema.mjs +0 -29
  93. package/dist/utils/assigment-schema.d.ts +0 -29
  94. package/dist/utils/assigment-schema.d.ts.map +0 -1
  95. package/dist/utils/assigment-schema.js +0 -36
  96. package/src/utils/assigment-schema.ts +0 -29
@@ -0,0 +1,190 @@
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
+ import { ValidationUtils } from './utils/validation.mjs';
7
+
8
+ /**
9
+ * Service class for managing resource attributes asynchronously via SNS.
10
+ * Provides asynchronous operations to create/update and delete attributes on resources.
11
+ */
12
+ class AuthorizationAttributesSnsService {
13
+ static LOG_TAG = 'authorization_attributes';
14
+ resourceSnsArn;
15
+ entitySnsArn;
16
+ /**
17
+ * Public constructor to create the AuthorizationAttributesSnsService instance.
18
+ */
19
+ constructor() {
20
+ this.resourceSnsArn = AuthorizationAttributesSnsService.getSnsTopicArn(SnsTopicType.RESOURCE);
21
+ this.entitySnsArn = AuthorizationAttributesSnsService.getSnsTopicArn(SnsTopicType.ENTITY);
22
+ }
23
+ /**
24
+ * Async function to delete a resource attribute using SNS.
25
+ * Sends the delete request to SNS and returns before the change actually took place.
26
+ * @param accountId The account ID
27
+ * @param resource The resource (resourceType, resourceId)
28
+ * @param attributeKey Attribute key to delete
29
+ * @param appName App name of the calling app
30
+ * @param callerActionIdentifier Action identifier
31
+ * @return Promise with sent operation
32
+ */
33
+ async deleteResourceAttributes(accountId, resource, attributeKey, appName, callerActionIdentifier) {
34
+ if (!appName || !callerActionIdentifier) {
35
+ throw new Error('appName and callerActionIdentifier are required for SNS service');
36
+ }
37
+ ValidationUtils.validatDeleteResourceAssignment({
38
+ resourceType: resource.type,
39
+ resourceId: resource.id,
40
+ key: attributeKey,
41
+ });
42
+ const operation = {
43
+ resourceType: resource.type,
44
+ resourceId: resource.id,
45
+ key: attributeKey,
46
+ operationType: AttributeOperation.DELETE,
47
+ };
48
+ const [result] = await this.sendOperationsToSns(this.resourceSnsArn, accountId, appName, callerActionIdentifier, [operation], ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE, RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND, 'Authorization resource attributes async delete: failed to send operations to SNS');
49
+ return result;
50
+ }
51
+ /**
52
+ * Async function to delete an entity attribute using SNS.
53
+ * Sends the delete request to SNS and returns before the change actually took place.
54
+ * @param accountId The account ID
55
+ * @param entityType The entity type
56
+ * @param entityId The entity ID
57
+ * @param attributeKey Attribute key to delete
58
+ * @param appName App name of the calling app
59
+ * @param callerActionIdentifier Action identifier
60
+ * @return Promise with sent operation
61
+ */
62
+ async deleteEntityAttributes(accountId, entityType, entityId, attributeKey, appName, callerActionIdentifier) {
63
+ if (!appName || !callerActionIdentifier) {
64
+ throw new Error('appName and callerActionIdentifier are required for SNS service');
65
+ }
66
+ ValidationUtils.validatDeleteEntityAssignment({ entityId, entityType, key: attributeKey });
67
+ const operation = {
68
+ entityType: entityType,
69
+ entityId,
70
+ key: attributeKey,
71
+ operationType: AttributeOperation.DELETE,
72
+ };
73
+ const [result] = await this.sendOperationsToSns(this.entitySnsArn, accountId, appName, callerActionIdentifier, [operation], ASYNC_ENTITY_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE, ENTITY_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND, 'Authorization entity attributes async delete: failed to send operations to SNS');
74
+ return result;
75
+ }
76
+ /**
77
+ * Async function, this function only send the update request to SNS and return before the change actually took place
78
+ * @param accountId
79
+ * @param appName - App name of the calling app
80
+ * @param callerActionIdentifier - action identifier
81
+ * @param resourceAttributeOperation - Operation to do on resource attribute.
82
+ * @return {Promise<ResourceAttributeUpsertOperation>} Sent operation
83
+ * */
84
+ async updateResourceAttributes(accountId, appName, callerActionIdentifier, resourceAttributeOperation) {
85
+ ValidationUtils.validatUpsertResourceAssignment(resourceAttributeOperation);
86
+ const [result] = await this.sendOperationsToSns(this.resourceSnsArn, accountId, appName, callerActionIdentifier, [resourceAttributeOperation], ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE, RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND, 'Authorization resource attributes async update: failed to send operations to SNS');
87
+ return result;
88
+ }
89
+ /**
90
+ * Async function, this function only send the update request to SNS and return before the change actually took place
91
+ * @param accountId
92
+ * @param appName - App name of the calling app
93
+ * @param callerActionIdentifier - action identifier
94
+ * @param entityAttributeOperation - Operation to do on entity attribute.
95
+ * @return {Promise<EntityAttributeUpsertOperation>} Sent operation
96
+ * */
97
+ async updateEntityAttributes(accountId, appName, callerActionIdentifier, entityAttributeOperation) {
98
+ ValidationUtils.validatUpsertEntityAssignment(entityAttributeOperation);
99
+ const [result] = await this.sendOperationsToSns(this.entitySnsArn, accountId, appName, callerActionIdentifier, [entityAttributeOperation], ASYNC_ENTITY_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE, ENTITY_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND, 'Authorization entity attributes async update: failed to send operations to SNS');
100
+ return result;
101
+ }
102
+ /**
103
+ * Base function to send attribute operations to SNS.
104
+ * Chunks operations and sends them in parallel.
105
+ * @param topicArn The SNS topic ARN to send messages to
106
+ * @param accountId The account ID
107
+ * @param appName App name of the calling app
108
+ * @param callerActionIdentifier Action identifier
109
+ * @param operations Array of operations to send
110
+ * @param chunkSize Maximum number of operations per message
111
+ * @param messageKind The kind of message being sent
112
+ * @param errorLogMessage Error message to log if sending fails
113
+ * @return Promise with array of sent operations
114
+ */
115
+ async sendOperationsToSns(topicArn, accountId, appName, callerActionIdentifier, operations, chunkSize, messageKind, errorLogMessage) {
116
+ const sendToSnsPromises = [];
117
+ const operationChunks = chunk(operations, chunkSize);
118
+ for (const operationsChunk of operationChunks) {
119
+ sendToSnsPromises.push(this.sendSingleSnsMessage(topicArn, accountId, appName, callerActionIdentifier, operationsChunk, messageKind, errorLogMessage));
120
+ }
121
+ return (await Promise.all(sendToSnsPromises)).flat();
122
+ }
123
+ async sendSingleSnsMessage(topicArn, accountId, appName, callerActionIdentifier, operations, kind, errorLogMessage) {
124
+ const payload = {
125
+ kind,
126
+ payload: {
127
+ accountId: accountId,
128
+ callerAppName: appName,
129
+ callerActionIdentifier: callerActionIdentifier,
130
+ operations: operations,
131
+ },
132
+ };
133
+ try {
134
+ await sendToSns(payload, topicArn);
135
+ return operations;
136
+ }
137
+ catch (error) {
138
+ logger.error({ error, tag: AuthorizationAttributesSnsService.LOG_TAG }, errorLogMessage);
139
+ return [];
140
+ }
141
+ }
142
+ static getSnsTopicArn(type) {
143
+ let envVarName;
144
+ let devTestName;
145
+ switch (type) {
146
+ case SnsTopicType.ENTITY:
147
+ envVarName = ENTITY_SNS_ARN_ENV_VAR_NAME;
148
+ devTestName = ENTITY_SNS_DEV_TEST_NAME;
149
+ break;
150
+ default:
151
+ // Default to resource SNS constants
152
+ envVarName = RESOURCE_SNS_ARN_ENV_VAR_NAME;
153
+ devTestName = RESOURCE_SNS_DEV_TEST_NAME;
154
+ break;
155
+ }
156
+ const arnFromEnv = process.env[envVarName];
157
+ if (arnFromEnv) {
158
+ return arnFromEnv;
159
+ }
160
+ if (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') {
161
+ return devTestName;
162
+ }
163
+ throw new Error(`Unable to get ${type} sns topic arn from env variable`);
164
+ }
165
+ /**
166
+ * Checks we can contact the required SNS topic that used to send attribute updates to Authorization MS.
167
+ * This function can be used as health check for services that updating resource attributes in async is crucial.
168
+ * Note this function only verify the POD can contact AWS SDK and the topic exists, but the user still might get
169
+ * errors when pushing for the SNS (e.g: in case the AWS role of the POD don't have permissions to push messages).
170
+ * However, this is the best we can do without actually push dummy messages to the SNS.
171
+ * @return {Promise<boolean>} - true if succeeded
172
+ */
173
+ async asyncResourceAttributesHealthCheck() {
174
+ try {
175
+ const requestedTopicArn = this.resourceSnsArn;
176
+ const attributes = await getTopicAttributes(requestedTopicArn);
177
+ const isHealthy = !(!attributes || !('TopicArn' in attributes) || attributes.TopicArn !== requestedTopicArn);
178
+ if (!isHealthy) {
179
+ logger.error({ requestedTopicArn, snsReturnedAttributes: attributes, tag: AuthorizationAttributesSnsService.LOG_TAG }, 'authorization-attributes-service failed in health check');
180
+ }
181
+ return isHealthy;
182
+ }
183
+ catch (error) {
184
+ logger.error({ error, tag: AuthorizationAttributesSnsService.LOG_TAG }, 'authorization-attributes-service got error during health check');
185
+ return false;
186
+ }
187
+ }
188
+ }
189
+
190
+ export { AuthorizationAttributesSnsService };
@@ -1,5 +1,15 @@
1
- export declare const SNS_ARN_ENV_VAR_NAME = "SHARED_AUTHORIZATION_SNS_ENDPOINT_RESOURCE_ATTRIBUTES";
2
- export declare const SNS_DEV_TEST_NAME = "arn:aws:sns:us-east-1:000000000000:monday-authorization-resource-attributes-sns-local";
1
+ export declare enum SnsTopicType {
2
+ RESOURCE = "resource",
3
+ ENTITY = "entity"
4
+ }
5
+ export declare const RESOURCE_SNS_ARN_ENV_VAR_NAME = "SHARED_AUTHORIZATION_SNS_ENDPOINT_RESOURCE_ATTRIBUTES";
6
+ export declare const RESOURCE_SNS_DEV_TEST_NAME = "arn:aws:sns:us-east-1:000000000000:monday-authorization-resource-attributes-sns-local";
7
+ export declare const ENTITY_SNS_ARN_ENV_VAR_NAME = "SHARED_AUTHORIZATION_SNS_ENDPOINT_ENTITY_ATTRIBUTES";
8
+ export declare const ENTITY_SNS_DEV_TEST_NAME = "arn:aws:sns:us-east-1:000000000000:monday-authorization-entity-attributes-sns-local";
3
9
  export declare const RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND = "resourceAttributeModification";
10
+ export declare const ENTITY_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND = "entityAttributeModification";
4
11
  export declare const ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE = 100;
12
+ export declare const ASYNC_ENTITY_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE = 100;
13
+ export declare const SNS_ARN_ENV_VAR_NAME = "SHARED_AUTHORIZATION_SNS_ENDPOINT_RESOURCE_ATTRIBUTES";
14
+ export declare const SNS_DEV_TEST_NAME = "arn:aws:sns:us-east-1:000000000000:monday-authorization-resource-attributes-sns-local";
5
15
  //# sourceMappingURL=sns.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sns.d.ts","sourceRoot":"","sources":["../../../src/constants/sns.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,0DAA0D,CAAC;AAC5F,eAAO,MAAM,iBAAiB,0FAC2D,CAAC;AAC1F,eAAO,MAAM,qDAAqD,kCAAkC,CAAC;AACrG,eAAO,MAAM,oDAAoD,MAAM,CAAC"}
1
+ {"version":3,"file":"sns.d.ts","sourceRoot":"","sources":["../../../src/constants/sns.ts"],"names":[],"mappings":"AAAA,oBAAY,YAAY;IACtB,QAAQ,aAAa;IACrB,MAAM,WAAW;CAClB;AAGD,eAAO,MAAM,6BAA6B,0DAA0D,CAAC;AACrG,eAAO,MAAM,0BAA0B,0FACkD,CAAC;AAG1F,eAAO,MAAM,2BAA2B,wDAAwD,CAAC;AACjG,eAAO,MAAM,wBAAwB,wFACkD,CAAC;AACxF,eAAO,MAAM,qDAAqD,kCAAkC,CAAC;AACrG,eAAO,MAAM,mDAAmD,gCAAgC,CAAC;AACjG,eAAO,MAAM,oDAAoD,MAAM,CAAC;AACxE,eAAO,MAAM,kDAAkD,MAAM,CAAC;AAGtE,eAAO,MAAM,oBAAoB,0DAAgC,CAAC;AAClE,eAAO,MAAM,iBAAiB,0FAA6B,CAAC"}
@@ -1,6 +1,20 @@
1
- const SNS_ARN_ENV_VAR_NAME = 'SHARED_AUTHORIZATION_SNS_ENDPOINT_RESOURCE_ATTRIBUTES';
2
- const SNS_DEV_TEST_NAME = 'arn:aws:sns:us-east-1:000000000000:monday-authorization-resource-attributes-sns-local';
1
+ var SnsTopicType;
2
+ (function (SnsTopicType) {
3
+ SnsTopicType["RESOURCE"] = "resource";
4
+ SnsTopicType["ENTITY"] = "entity";
5
+ })(SnsTopicType || (SnsTopicType = {}));
6
+ // Resource SNS constants
7
+ const RESOURCE_SNS_ARN_ENV_VAR_NAME = 'SHARED_AUTHORIZATION_SNS_ENDPOINT_RESOURCE_ATTRIBUTES';
8
+ const RESOURCE_SNS_DEV_TEST_NAME = 'arn:aws:sns:us-east-1:000000000000:monday-authorization-resource-attributes-sns-local';
9
+ // Entity SNS constants
10
+ const ENTITY_SNS_ARN_ENV_VAR_NAME = 'SHARED_AUTHORIZATION_SNS_ENDPOINT_ENTITY_ATTRIBUTES';
11
+ const ENTITY_SNS_DEV_TEST_NAME = 'arn:aws:sns:us-east-1:000000000000:monday-authorization-entity-attributes-sns-local';
3
12
  const RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND = 'resourceAttributeModification';
13
+ const ENTITY_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND = 'entityAttributeModification';
4
14
  const ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE = 100;
15
+ const ASYNC_ENTITY_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE = 100;
16
+ // Legacy exports for backward compatibility
17
+ const SNS_ARN_ENV_VAR_NAME = RESOURCE_SNS_ARN_ENV_VAR_NAME;
18
+ const SNS_DEV_TEST_NAME = RESOURCE_SNS_DEV_TEST_NAME;
5
19
 
6
- export { ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE, RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND, SNS_ARN_ENV_VAR_NAME, SNS_DEV_TEST_NAME };
20
+ export { ASYNC_ENTITY_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE, ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE, ENTITY_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND, ENTITY_SNS_ARN_ENV_VAR_NAME, ENTITY_SNS_DEV_TEST_NAME, RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND, RESOURCE_SNS_ARN_ENV_VAR_NAME, RESOURCE_SNS_DEV_TEST_NAME, SNS_ARN_ENV_VAR_NAME, SNS_DEV_TEST_NAME, SnsTopicType };
@@ -1 +1 @@
1
- {"version":3,"file":"entity-attribute-assignment.d.ts","sourceRoot":"","sources":["../../src/entity-attribute-assignment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,yBAAyB,IAAI,iCAAiC,EAAE,MAAM,4CAA4C,CAAC;AAG5H,qBAAa,yBAA0B,SAAQ,uBAAuB,CAAC,UAAU,EAAE,iCAAiC,CAAC;IACnH,SAAgB,QAAQ,EAAE,MAAM,CAAC;IACjC,SAAgB,UAAU,EAAE,UAAU,CAAC;gBAE3B,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAOhF,oBAAoB,IAAI,iCAAiC;IAQzD;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO;CAGlD"}
1
+ {"version":3,"file":"entity-attribute-assignment.d.ts","sourceRoot":"","sources":["../../src/entity-attribute-assignment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,yBAAyB,IAAI,iCAAiC,EAAE,MAAM,4CAA4C,CAAC;AAE5H,qBAAa,yBAA0B,SAAQ,uBAAuB,CAAC,UAAU,EAAE,iCAAiC,CAAC;IACnH,SAAgB,QAAQ,EAAE,MAAM,CAAC;IACjC,SAAgB,UAAU,EAAE,UAAU,CAAC;gBAE3B,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAMhF,oBAAoB,IAAI,iCAAiC;IAQzD;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO;CAGlD"}
@@ -1,11 +1,9 @@
1
1
  import { BaseAttributeAssignment } from './base-attribute-assignment.mjs';
2
- import { ValidationUtils } from './utils/validation.mjs';
3
2
 
4
3
  class EntityAttributeAssignment extends BaseAttributeAssignment {
5
4
  entityId;
6
5
  entityType;
7
6
  constructor(entityId, entityType, key, value) {
8
- ValidationUtils.validateEntityAssignment({ entityId, entityType, key, value });
9
7
  super(entityId, entityType, key, value);
10
8
  this.entityId = entityId;
11
9
  this.entityType = entityType;
@@ -19,10 +19,16 @@ export declare function init(options?: InitOptions): Promise<void>;
19
19
  export { authorizationCheckMiddleware, getAuthorizationMiddleware, skipAuthorizationMiddleware, } from './authorization-middleware';
20
20
  export { AuthorizationService, AuthorizeResponse } from './authorization-service';
21
21
  export { AuthorizationAttributesService } from './authorization-attributes-service';
22
+ export * from './resource-attributes-constants';
23
+ export * from './entity-attributes-constants';
24
+ export { ResourceAttributeAssignment } from './resource-attribute-assignment';
25
+ export { EntityAttributeAssignment } from './entity-attribute-assignment';
22
26
  export { RolesService } from './roles-service';
23
27
  export { MembershipsService } from './memberships';
24
28
  export { AuthorizationObject, Resource, BaseRequest, ResourceGetter, ContextGetter } from './types/general';
25
29
  export { Translation, ScopedAction, ScopedActionResponseObject, ScopedActionPermit, } from './types/scoped-actions-contracts';
26
30
  export { CustomRole, BasicRole, RoleType, RoleCreateRequest, RoleUpdateRequest, RolesResponse } from './types/roles';
31
+ export { AttributeAssignment, AttributeOperation, ResourceAttributeDeleteAssignment, ResourceAttributeUpsertOperation, ResourceAttributeDeleteOperation, EntityAttributeDeleteAssignment, EntityAttributeUpsertOperation, EntityAttributeDeleteOperation, ResourceAttributeAssignment as ResourceAttributeAssignmentContract, EntityAttributeAssignment as EntityAttributeAssignmentContract, } from './types/authorization-attributes-contracts';
32
+ export { AuthorizationAttributesService as IAuthorizationAttributesService } from './types/authorization-attributes-service.interface';
27
33
  export { TestKit };
28
34
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAGnE,OAAO,EAAqB,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,UAAU,kBAAkB;IAC1B,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,WAAW,CAAC,EAAE,GAAG,CAAC;IAClB,sCAAsC,CAAC,EAAE,MAAM,CAAC;IAChD,OAAO,CAAC,EAAE,kBAAkB,CAAC;CAC9B;AAED,wBAAsB,IAAI,CAAC,OAAO,GAAE,WAAgB,iBA6BnD;AAED,OAAO,EACL,4BAA4B,EAC5B,0BAA0B,EAC1B,2BAA2B,GAC5B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAClF,OAAO,EAAE,8BAA8B,EAAE,MAAM,oCAAoC,CAAC;AACpF,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC5G,OAAO,EACL,WAAW,EACX,YAAY,EACZ,0BAA0B,EAC1B,kBAAkB,GACnB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAErH,OAAO,EAAE,OAAO,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAGnE,OAAO,EAAqB,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,UAAU,kBAAkB;IAC1B,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,WAAW,CAAC,EAAE,GAAG,CAAC;IAClB,sCAAsC,CAAC,EAAE,MAAM,CAAC;IAChD,OAAO,CAAC,EAAE,kBAAkB,CAAC;CAC9B;AAED,wBAAsB,IAAI,CAAC,OAAO,GAAE,WAAgB,iBA6BnD;AAED,OAAO,EACL,4BAA4B,EAC5B,0BAA0B,EAC1B,2BAA2B,GAC5B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAClF,OAAO,EAAE,8BAA8B,EAAE,MAAM,oCAAoC,CAAC;AACpF,cAAc,iCAAiC,CAAC;AAChD,cAAc,+BAA+B,CAAC;AAC9C,OAAO,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AAC9E,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC5G,OAAO,EACL,WAAW,EACX,YAAY,EACZ,0BAA0B,EAC1B,kBAAkB,GACnB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACrH,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,iCAAiC,EACjC,gCAAgC,EAChC,gCAAgC,EAChC,+BAA+B,EAC/B,8BAA8B,EAC9B,8BAA8B,EAC9B,2BAA2B,IAAI,mCAAmC,EAClE,yBAAyB,IAAI,iCAAiC,GAC/D,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,8BAA8B,IAAI,+BAA+B,EAAE,MAAM,oDAAoD,CAAC;AAEvI,OAAO,EAAE,OAAO,EAAE,CAAC"}
@@ -6,9 +6,14 @@ import * as testKit_index from './testKit/index.mjs';
6
6
  export { testKit_index as TestKit };
7
7
  export { authorizationCheckMiddleware, getAuthorizationMiddleware, skipAuthorizationMiddleware } from './authorization-middleware.mjs';
8
8
  export { AuthorizationAttributesService } from './authorization-attributes-service.mjs';
9
+ export { RESOURCE_ATTRIBUTES_CONSTANTS, RESOURCE_TYPES, ResourceType } from './resource-attributes-constants.mjs';
10
+ export { ENTITY_TYPES, EntityType } from './entity-attributes-constants.mjs';
11
+ export { ResourceAttributeAssignment } from './resource-attribute-assignment.mjs';
12
+ export { EntityAttributeAssignment } from './entity-attribute-assignment.mjs';
9
13
  export { RolesService } from './roles-service.mjs';
10
14
  export { MembershipsService } from './memberships.mjs';
11
15
  export { RoleType } from './types/roles.mjs';
16
+ export { AttributeOperation } from './types/authorization-attributes-contracts.mjs';
12
17
 
13
18
  async function init(options = {}) {
14
19
  if (options.prometheus) {
@@ -1 +1 @@
1
- {"version":3,"file":"resource-attribute-assignment.d.ts","sourceRoot":"","sources":["../../src/resource-attribute-assignment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,2BAA2B,IAAI,mCAAmC,EAAE,MAAM,4CAA4C,CAAC;AAGhI,qBAAa,2BAA4B,SAAQ,uBAAuB,CACtE,YAAY,EACZ,mCAAmC,CACpC;IACC,SAAgB,UAAU,EAAE,MAAM,CAAC;IACnC,SAAgB,YAAY,EAAE,YAAY,CAAC;gBAE/B,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;IAOxG,oBAAoB,IAAI,mCAAmC;IAQ3D;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,2BAA2B,GAAG,OAAO;CAGpD"}
1
+ {"version":3,"file":"resource-attribute-assignment.d.ts","sourceRoot":"","sources":["../../src/resource-attribute-assignment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,2BAA2B,IAAI,mCAAmC,EAAE,MAAM,4CAA4C,CAAC;AAEhI,qBAAa,2BAA4B,SAAQ,uBAAuB,CACtE,YAAY,EACZ,mCAAmC,CACpC;IACC,SAAgB,UAAU,EAAE,MAAM,CAAC;IACnC,SAAgB,YAAY,EAAE,YAAY,CAAC;gBAE/B,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;IAMxG,oBAAoB,IAAI,mCAAmC;IAQ3D;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,2BAA2B,GAAG,OAAO;CAGpD"}
@@ -1,11 +1,9 @@
1
1
  import { BaseAttributeAssignment } from './base-attribute-assignment.mjs';
2
- import { ValidationUtils } from './utils/validation.mjs';
3
2
 
4
3
  class ResourceAttributeAssignment extends BaseAttributeAssignment {
5
4
  resourceId;
6
5
  resourceType;
7
6
  constructor(resourceId, resourceType, attributeKey, attributeValue) {
8
- ValidationUtils.validateResourceAssignment({ resourceId, resourceType, key: attributeKey, value: attributeValue });
9
7
  super(resourceId, resourceType, attributeKey, attributeValue);
10
8
  this.resourceId = resourceId;
11
9
  this.resourceType = this.type;
@@ -19,7 +19,8 @@ export declare enum ResourceType {
19
19
  Team = "team",
20
20
  Overview = "overview",
21
21
  Document = "document",
22
- Crm = "crm"
22
+ Crm = "crm",
23
+ Feature = "feature"
23
24
  }
24
25
  export declare const RESOURCE_TYPES: readonly ResourceType[];
25
26
  //# sourceMappingURL=resource-attributes-constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resource-attributes-constants.d.ts","sourceRoot":"","sources":["../../src/resource-attributes-constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,6BAA6B;;;;;;;;;;;EAWxC,CAAC;AAEH,oBAAY,YAAY;IACtB,OAAO,YAAY;IACnB,cAAc,oBAAoB;IAClC,SAAS,cAAc;IACvB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,IAAI,SAAS;IACb,QAAQ,aAAa;IACrB,QAAQ,aAAa;IACrB,GAAG,QAAQ;CACZ;AAGD,eAAO,MAAM,cAAc,yBAA6C,CAAC"}
1
+ {"version":3,"file":"resource-attributes-constants.d.ts","sourceRoot":"","sources":["../../src/resource-attributes-constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,6BAA6B;;;;;;;;;;;EAWxC,CAAC;AAEH,oBAAY,YAAY;IACtB,OAAO,YAAY;IACnB,cAAc,oBAAoB;IAClC,SAAS,cAAc;IACvB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,IAAI,SAAS;IACb,QAAQ,aAAa;IACrB,QAAQ,aAAa;IACrB,GAAG,QAAQ;IACX,OAAO,YAAY;CACpB;AAGD,eAAO,MAAM,cAAc,yBAA6C,CAAC"}
@@ -21,6 +21,7 @@ var ResourceType;
21
21
  ResourceType["Overview"] = "overview";
22
22
  ResourceType["Document"] = "document";
23
23
  ResourceType["Crm"] = "crm";
24
+ ResourceType["Feature"] = "feature";
24
25
  })(ResourceType || (ResourceType = {}));
25
26
  // Define the array of strings and use 'as const' to make its contents literal types
26
27
  const RESOURCE_TYPES = Object.freeze(Object.values(ResourceType));
@@ -1,4 +1,3 @@
1
- import { Resource } from './general';
2
1
  import type { EntityType } from '../entity-attributes-constants';
3
2
  import type { ResourceType } from '../resource-attributes-constants';
4
3
  export interface AttributeAssignment {
@@ -9,30 +8,16 @@ export interface ResourceAttributeAssignment extends AttributeAssignment {
9
8
  resourceId: number;
10
9
  resourceType: ResourceType;
11
10
  }
11
+ export type ResourceAttributeDeleteAssignment = Omit<ResourceAttributeAssignment, 'value'>;
12
12
  export interface EntityAttributeAssignment extends AttributeAssignment {
13
13
  entityId: number;
14
14
  entityType: EntityType;
15
15
  }
16
- export interface ResourceAttributeDelete {
17
- resourceType: Resource['type'];
18
- resourceId: Resource['id'];
19
- key: string;
20
- }
21
- export interface EntityAttributeDelete {
22
- entityType: EntityType;
23
- entityId: number;
24
- key: string;
25
- }
16
+ export type EntityAttributeDeleteAssignment = Omit<EntityAttributeAssignment, 'value'>;
26
17
  export declare enum AttributeOperation {
27
18
  UPSERT = "upsert",
28
19
  DELETE = "delete"
29
20
  }
30
- export interface ResourceAttributeResponse {
31
- attributes: ResourceAttributeAssignment[];
32
- }
33
- export interface EntityAttributeResponse {
34
- attributes: EntityAttributeAssignment[];
35
- }
36
21
  export interface ResourceAttributeUpsertOperation extends ResourceAttributeAssignment {
37
22
  operationType: AttributeOperation;
38
23
  }
@@ -1 +1 @@
1
- {"version":3,"file":"authorization-attributes-contracts.d.ts","sourceRoot":"","sources":["../../../src/types/authorization-attributes-contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAErE,MAAM,WAAW,mBAAmB;IAClC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf;AAGD,MAAM,WAAW,2BAA4B,SAAQ,mBAAmB;IACtE,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,YAAY,CAAC;CAC5B;AAID,MAAM,WAAW,yBAA0B,SAAQ,mBAAmB;IACpE,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,UAAU,CAAC;CACxB;AAGD,MAAM,WAAW,uBAAuB;IACtC,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC/B,UAAU,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC3B,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,UAAU,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,oBAAY,kBAAkB;IAC5B,MAAM,WAAW;IACjB,MAAM,WAAW;CAClB;AAGD,MAAM,WAAW,yBAAyB;IACxC,UAAU,EAAE,2BAA2B,EAAE,CAAC;CAC3C;AAED,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,yBAAyB,EAAE,CAAC;CACzC;AAED,MAAM,WAAW,gCAAiC,SAAQ,2BAA2B;IACnF,aAAa,EAAE,kBAAkB,CAAC;CACnC;AACD,MAAM,MAAM,gCAAgC,GAAG,IAAI,CAAC,gCAAgC,EAAE,OAAO,CAAC,CAAC;AAE/F,MAAM,WAAW,8BAA+B,SAAQ,yBAAyB;IAC/E,aAAa,EAAE,kBAAkB,CAAC;CACnC;AACD,MAAM,MAAM,8BAA8B,GAAG,IAAI,CAAC,8BAA8B,EAAE,OAAO,CAAC,CAAC"}
1
+ {"version":3,"file":"authorization-attributes-contracts.d.ts","sourceRoot":"","sources":["../../../src/types/authorization-attributes-contracts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAErE,MAAM,WAAW,mBAAmB;IAClC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf;AAGD,MAAM,WAAW,2BAA4B,SAAQ,mBAAmB;IACtE,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,YAAY,CAAC;CAC5B;AACD,MAAM,MAAM,iCAAiC,GAAG,IAAI,CAAC,2BAA2B,EAAE,OAAO,CAAC,CAAC;AAI3F,MAAM,WAAW,yBAA0B,SAAQ,mBAAmB;IACpE,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,UAAU,CAAC;CACxB;AACD,MAAM,MAAM,+BAA+B,GAAG,IAAI,CAAC,yBAAyB,EAAE,OAAO,CAAC,CAAC;AAEvF,oBAAY,kBAAkB;IAC5B,MAAM,WAAW;IACjB,MAAM,WAAW;CAClB;AACD,MAAM,WAAW,gCAAiC,SAAQ,2BAA2B;IACnF,aAAa,EAAE,kBAAkB,CAAC;CACnC;AACD,MAAM,MAAM,gCAAgC,GAAG,IAAI,CAAC,gCAAgC,EAAE,OAAO,CAAC,CAAC;AAE/F,MAAM,WAAW,8BAA+B,SAAQ,yBAAyB;IAC/E,aAAa,EAAE,kBAAkB,CAAC;CACnC;AACD,MAAM,MAAM,8BAA8B,GAAG,IAAI,CAAC,8BAA8B,EAAE,OAAO,CAAC,CAAC"}
@@ -1,43 +1,32 @@
1
1
  import { EntityType } from '../entity-attributes-constants';
2
2
  import { ResourceAttributeDeleteOperation, EntityAttributeDeleteOperation, ResourceAttributeUpsertOperation, EntityAttributeUpsertOperation } from './authorization-attributes-contracts';
3
3
  import { Resource } from './general';
4
- /**
5
- * Resource type compatible with both MS and SNS services
6
- */
7
- export interface CompatibleResource {
8
- resourceType?: string;
9
- resourceId?: number;
10
- type?: string;
11
- id?: number;
12
- }
13
4
  /**
14
5
  * Interface for authorization attributes operations.
15
6
  * Both MS (direct) and SNS (async) services implement this interface.
16
7
  */
17
8
  export interface AuthorizationAttributesService {
18
9
  /**
19
- * Deletes resource attributes.
20
- * For MS service: returns Promise<void>
21
- * For SNS service: requires appName and callerActionIdentifier, returns Promise<ResourceAttributesOperation[]>
10
+ * Deletes a resource attribute.
11
+ * Returns Promise<ResourceAttributeDeleteOperation>
22
12
  */
23
- deleteResourceAttributes(accountId: number, resource: CompatibleResource | Resource, attributeKeys: string[], appName?: string, callerActionIdentifier?: string): Promise<void | ResourceAttributeDeleteOperation[]>;
13
+ deleteResourceAttributes(accountId: number, resource: Resource, attributeKey: string, appName?: string, callerActionIdentifier?: string): Promise<ResourceAttributeDeleteOperation>;
24
14
  /**
25
- * Deletes entity attributes.
26
- * For MS service: returns Promise<void>
27
- * For SNS service: requires appName and callerActionIdentifier, returns Promise<EntityAttributesOperation[]>
15
+ * Deletes an entity attribute.
16
+ * Returns Promise<EntityAttributeDeleteOperation>
28
17
  */
29
- deleteEntityAttributes(accountId: number, entityType: EntityType | string, entityId: number, attributeKeys: string[], appName?: string, callerActionIdentifier?: string): Promise<void | EntityAttributeDeleteOperation[]>;
18
+ deleteEntityAttributes(accountId: number, entityType: EntityType | string, entityId: number, attributeKey: string, appName?: string, callerActionIdentifier?: string): Promise<EntityAttributeDeleteOperation>;
30
19
  /**
31
- * Updates resource attributes (batch operations).
32
- * For MS service: may throw error or delegate to upsert/delete
33
- * For SNS service: returns Promise<ResourceAttributesOperation[]>
20
+ * Updates a resource attribute (single operation - upsert only).
21
+ * For MS service: performs upsert operation
22
+ * For SNS service: returns Promise<ResourceAttributeUpsertOperation>
34
23
  */
35
- updateResourceAttributes(accountId: number, appName: string, callerActionIdentifier: string, resourceAttributeOperations: ResourceAttributeUpsertOperation[]): Promise<ResourceAttributeUpsertOperation[]>;
24
+ updateResourceAttributes(accountId: number, appName: string, callerActionIdentifier: string, resourceAttributeOperation: ResourceAttributeUpsertOperation): Promise<ResourceAttributeUpsertOperation>;
36
25
  /**
37
- * Updates entity attributes (batch operations).
38
- * For MS service: may throw error or delegate to upsert/delete
39
- * For SNS service: returns Promise<EntityAttributesOperation[]>
26
+ * Updates an entity attribute (single operation - upsert only).
27
+ * For MS service: performs upsert operation
28
+ * For SNS service: returns Promise<EntityAttributeUpsertOperation>
40
29
  */
41
- updateEntityAttributes(accountId: number, appName: string, callerActionIdentifier: string, entityAttributeOperations: EntityAttributeUpsertOperation[]): Promise<EntityAttributeUpsertOperation[]>;
30
+ updateEntityAttributes(accountId: number, appName: string, callerActionIdentifier: string, entityAttributeOperation: EntityAttributeUpsertOperation): Promise<EntityAttributeUpsertOperation>;
42
31
  }
43
32
  //# sourceMappingURL=authorization-attributes-service.interface.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"authorization-attributes-service.interface.d.ts","sourceRoot":"","sources":["../../../src/types/authorization-attributes-service.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EACL,gCAAgC,EAChC,8BAA8B,EAC9B,gCAAgC,EAChC,8BAA8B,EAC/B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED;;;GAGG;AACH,MAAM,WAAW,8BAA8B;IAC7C;;;;OAIG;IACH,wBAAwB,CACtB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,kBAAkB,GAAG,QAAQ,EACvC,aAAa,EAAE,MAAM,EAAE,EACvB,OAAO,CAAC,EAAE,MAAM,EAChB,sBAAsB,CAAC,EAAE,MAAM,GAC9B,OAAO,CAAC,IAAI,GAAG,gCAAgC,EAAE,CAAC,CAAC;IAEtD;;;;OAIG;IACH,sBAAsB,CACpB,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,IAAI,GAAG,8BAA8B,EAAE,CAAC,CAAC;IAEpD;;;;OAIG;IACH,wBAAwB,CACtB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,sBAAsB,EAAE,MAAM,EAC9B,2BAA2B,EAAE,gCAAgC,EAAE,GAC9D,OAAO,CAAC,gCAAgC,EAAE,CAAC,CAAC;IAE/C;;;;OAIG;IACH,sBAAsB,CACpB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,sBAAsB,EAAE,MAAM,EAC9B,yBAAyB,EAAE,8BAA8B,EAAE,GAC1D,OAAO,CAAC,8BAA8B,EAAE,CAAC,CAAC;CAC9C"}
1
+ {"version":3,"file":"authorization-attributes-service.interface.d.ts","sourceRoot":"","sources":["../../../src/types/authorization-attributes-service.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EACL,gCAAgC,EAChC,8BAA8B,EAC9B,gCAAgC,EAChC,8BAA8B,EAC/B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC;;;GAGG;AACH,MAAM,WAAW,8BAA8B;IAC7C;;;OAGG;IACH,wBAAwB,CACtB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE,MAAM,EAChB,sBAAsB,CAAC,EAAE,MAAM,GAC9B,OAAO,CAAC,gCAAgC,CAAC,CAAC;IAE7C;;;OAGG;IACH,sBAAsB,CACpB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,UAAU,GAAG,MAAM,EAC/B,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE,MAAM,EAChB,sBAAsB,CAAC,EAAE,MAAM,GAC9B,OAAO,CAAC,8BAA8B,CAAC,CAAC;IAE3C;;;;OAIG;IACH,wBAAwB,CACtB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,sBAAsB,EAAE,MAAM,EAC9B,0BAA0B,EAAE,gCAAgC,GAC3D,OAAO,CAAC,gCAAgC,CAAC,CAAC;IAE7C;;;;OAIG;IACH,sBAAsB,CACpB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,sBAAsB,EAAE,MAAM,EAC9B,wBAAwB,EAAE,8BAA8B,GACvD,OAAO,CAAC,8BAA8B,CAAC,CAAC;CAC5C"}
@@ -1,7 +1,8 @@
1
1
  import type { Request, Response } from 'express';
2
+ import type { ResourceType } from '../resource-attributes-constants';
2
3
  export interface Resource {
3
- id?: number;
4
- type: string;
4
+ id: number;
5
+ type: ResourceType;
5
6
  wrapperData?: object;
6
7
  }
7
8
  export type Action = string;
@@ -11,7 +12,7 @@ export interface Context {
11
12
  }
12
13
  export interface AuthorizationObject {
13
14
  resource_id?: Resource['id'];
14
- resource_type: Resource['type'];
15
+ resource_type: string;
15
16
  wrapper_data?: Resource['wrapperData'];
16
17
  action: Action;
17
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"general.d.ts","sourceRoot":"","sources":["../../../src/types/general.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEjD,MAAM,WAAW,QAAQ;IACvB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AACD,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC;AAC5B,MAAM,WAAW,OAAO;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB;AACD,MAAM,WAAW,mBAAmB;IAClC,WAAW,CAAC,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC7B,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAChC,YAAY,CAAC,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC;IACvC,MAAM,EAAE,MAAM,CAAC;CAChB;AACD,MAAM,WAAW,mBAAmB;IAClC,oBAAoB,EAAE,mBAAmB,EAAE,CAAC;CAC7C;AAED,KAAK,WAAW,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC;AAE9C,MAAM,MAAM,cAAc,GAAG,WAAW,CAAC;AACzC,MAAM,MAAM,gBAAgB,GAAG,WAAW,CAAC;AAC3C,MAAM,MAAM,kBAAkB,GAAG,WAAW,CAAC;AAC7C,MAAM,MAAM,mBAAmB,GAAG,WAAW,CAAC;AAC9C,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC,cAAc,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,mBAAmB,CAAC,CAAC;AAC7G,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAC,gBAAgB,CAAC,CAAC;AACtD,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,EAAE,WAAW,KAAK,QAAQ,EAAE,CAAC;AAClE,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,EAAE,WAAW,KAAK,OAAO,CAAC"}
1
+ {"version":3,"file":"general.d.ts","sourceRoot":"","sources":["../../../src/types/general.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAErE,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,YAAY,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AACD,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC;AAC5B,MAAM,WAAW,OAAO;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB;AACD,MAAM,WAAW,mBAAmB;IAClC,WAAW,CAAC,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC;IACvC,MAAM,EAAE,MAAM,CAAC;CAChB;AACD,MAAM,WAAW,mBAAmB;IAClC,oBAAoB,EAAE,mBAAmB,EAAE,CAAC;CAC7C;AAED,KAAK,WAAW,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC;AAE9C,MAAM,MAAM,cAAc,GAAG,WAAW,CAAC;AACzC,MAAM,MAAM,gBAAgB,GAAG,WAAW,CAAC;AAC3C,MAAM,MAAM,kBAAkB,GAAG,WAAW,CAAC;AAC7C,MAAM,MAAM,mBAAmB,GAAG,WAAW,CAAC;AAC9C,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC,cAAc,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,mBAAmB,CAAC,CAAC;AAC7G,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAC,gBAAgB,CAAC,CAAC;AACtD,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,EAAE,WAAW,KAAK,QAAQ,EAAE,CAAC;AAClE,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,EAAE,WAAW,KAAK,OAAO,CAAC"}
@@ -0,0 +1,51 @@
1
+ export declare const entityUpsertAssignmentSchema: import("ajv").ValidateFunction<{
2
+ value: any;
3
+ key: any;
4
+ entityId: any;
5
+ entityType: any;
6
+ } & {
7
+ value: any;
8
+ } & {
9
+ key: any;
10
+ } & {
11
+ entityId: any;
12
+ } & {
13
+ entityType: any;
14
+ }>;
15
+ export declare const entityDeleteAssignmentSchema: import("ajv").ValidateFunction<{
16
+ key: any;
17
+ entityId: any;
18
+ entityType: any;
19
+ } & {
20
+ key: any;
21
+ } & {
22
+ entityId: any;
23
+ } & {
24
+ entityType: any;
25
+ }>;
26
+ export declare const resourceDeleteAssignmentSchema: import("ajv").ValidateFunction<{
27
+ id: any;
28
+ key: any;
29
+ type: any;
30
+ } & {
31
+ id: any;
32
+ } & {
33
+ key: any;
34
+ } & {
35
+ type: any;
36
+ }>;
37
+ export declare const resourceUpsertAssignmentSchema: import("ajv").ValidateFunction<{
38
+ value: any;
39
+ resourceId: any;
40
+ resourceType: any;
41
+ key: any;
42
+ } & {
43
+ value: any;
44
+ } & {
45
+ resourceId: any;
46
+ } & {
47
+ resourceType: any;
48
+ } & {
49
+ key: any;
50
+ }>;
51
+ //# sourceMappingURL=assignment-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assignment-schema.d.ts","sourceRoot":"","sources":["../../../src/utils/assignment-schema.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;EAUvC,CAAC;AAEH,eAAO,MAAM,4BAA4B;;;;;;;;;;EASvC,CAAC;AAEH,eAAO,MAAM,8BAA8B;;;;;;;;;;EASzC,CAAC;AAEH,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;EAUzC,CAAC"}
@@ -0,0 +1,49 @@
1
+ import Ajv from 'ajv';
2
+ import { EntityType } from '../entity-attributes-constants.mjs';
3
+ import { ResourceType } from '../resource-attributes-constants.mjs';
4
+
5
+ const ajv = new Ajv({ allErrors: true });
6
+ const entityUpsertAssignmentSchema = ajv.compile({
7
+ type: 'object',
8
+ properties: {
9
+ entityId: { type: 'number', multipleOf: 1 },
10
+ entityType: { type: 'string', enum: Object.values(EntityType) },
11
+ key: { type: 'string', minLength: 1 },
12
+ value: { type: 'string', minLength: 1 },
13
+ },
14
+ required: ['entityId', 'entityType', 'key', 'value'],
15
+ additionalProperties: false,
16
+ });
17
+ const entityDeleteAssignmentSchema = ajv.compile({
18
+ type: 'object',
19
+ properties: {
20
+ entityId: { type: 'number', multipleOf: 1 },
21
+ entityType: { type: 'string', enum: Object.values(EntityType) },
22
+ key: { type: 'string', minLength: 1 },
23
+ },
24
+ required: ['entityId', 'entityType', 'key'],
25
+ additionalProperties: false,
26
+ });
27
+ const resourceDeleteAssignmentSchema = ajv.compile({
28
+ type: 'object',
29
+ properties: {
30
+ resourceId: { type: 'number', multipleOf: 1 },
31
+ resourceType: { type: 'string', enum: Object.values(ResourceType) },
32
+ key: { type: 'string', minLength: 1 },
33
+ },
34
+ required: ['id', 'type', 'key'],
35
+ additionalProperties: false,
36
+ });
37
+ const resourceUpsertAssignmentSchema = ajv.compile({
38
+ type: 'object',
39
+ properties: {
40
+ resourceId: { type: 'number', multipleOf: 1 },
41
+ resourceType: { type: 'string', enum: Object.values(ResourceType) },
42
+ key: { type: 'string', minLength: 1 },
43
+ value: { type: 'string', minLength: 1 },
44
+ },
45
+ required: ['resourceId', 'resourceType', 'key', 'value'],
46
+ additionalProperties: false,
47
+ });
48
+
49
+ export { entityDeleteAssignmentSchema, entityUpsertAssignmentSchema, resourceDeleteAssignmentSchema, resourceUpsertAssignmentSchema };
@@ -0,0 +1,9 @@
1
+ export declare const resourceSchema: import("ajv").ValidateFunction<{
2
+ id: any;
3
+ type: any;
4
+ } & {
5
+ id: any;
6
+ } & {
7
+ type: any;
8
+ }>;
9
+ //# sourceMappingURL=resource-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource-schema.d.ts","sourceRoot":"","sources":["../../../src/utils/resource-schema.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,cAAc;;;;;;;EAUzB,CAAC"}
@@ -0,0 +1,16 @@
1
+ import Ajv from 'ajv';
2
+ import { RESOURCE_TYPES } from '../resource-attributes-constants.mjs';
3
+
4
+ const ajv = new Ajv({ allErrors: true });
5
+ const resourceSchema = ajv.compile({
6
+ type: 'object',
7
+ properties: {
8
+ id: { type: 'number', multipleOf: 1 },
9
+ type: { type: 'string', enum: RESOURCE_TYPES },
10
+ wrapperData: { type: 'object' },
11
+ },
12
+ required: ['id', 'type'],
13
+ additionalProperties: false,
14
+ });
15
+
16
+ export { resourceSchema };