@mondaydotcomorg/monday-authorization 3.7.0-feat-shaime-support-entity-attributes-4-49e1de0 → 3.7.1
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.
- package/README.md +7 -1
- package/dist/authorization-attributes-ms-service.d.ts +20 -40
- package/dist/authorization-attributes-ms-service.d.ts.map +1 -1
- package/dist/authorization-attributes-ms-service.js +48 -103
- package/dist/authorization-attributes-service.d.ts +12 -10
- package/dist/authorization-attributes-service.d.ts.map +1 -1
- package/dist/authorization-attributes-service.js +17 -15
- package/dist/authorization-attributes-sns-service.d.ts +37 -44
- package/dist/authorization-attributes-sns-service.d.ts.map +1 -1
- package/dist/authorization-attributes-sns-service.js +53 -90
- package/dist/authorization-service.d.ts +0 -1
- package/dist/authorization-service.d.ts.map +1 -1
- package/dist/authorization-service.js +2 -22
- package/dist/base-attribute-assignment.d.ts +6 -7
- package/dist/base-attribute-assignment.d.ts.map +1 -1
- package/dist/base-attribute-assignment.js +5 -7
- package/dist/base-authorization-attributes-service.d.ts +32 -0
- package/dist/base-authorization-attributes-service.d.ts.map +1 -0
- package/dist/base-authorization-attributes-service.js +63 -0
- package/dist/entity-attribute-assignment.d.ts +4 -8
- package/dist/entity-attribute-assignment.d.ts.map +1 -1
- package/dist/entity-attribute-assignment.js +3 -4
- package/dist/esm/authorization-attributes-ms-service.d.ts +20 -40
- package/dist/esm/authorization-attributes-ms-service.d.ts.map +1 -1
- package/dist/esm/authorization-attributes-ms-service.mjs +48 -103
- package/dist/esm/authorization-attributes-service.d.ts +12 -10
- package/dist/esm/authorization-attributes-service.d.ts.map +1 -1
- package/dist/esm/authorization-attributes-service.mjs +17 -15
- package/dist/esm/authorization-attributes-sns-service.d.ts +37 -44
- package/dist/esm/authorization-attributes-sns-service.d.ts.map +1 -1
- package/dist/esm/authorization-attributes-sns-service.mjs +53 -90
- package/dist/esm/authorization-service.d.ts +0 -1
- package/dist/esm/authorization-service.d.ts.map +1 -1
- package/dist/esm/authorization-service.mjs +3 -23
- package/dist/esm/base-attribute-assignment.d.ts +6 -7
- package/dist/esm/base-attribute-assignment.d.ts.map +1 -1
- package/dist/esm/base-attribute-assignment.mjs +5 -7
- package/dist/esm/base-authorization-attributes-service.d.ts +32 -0
- package/dist/esm/base-authorization-attributes-service.d.ts.map +1 -0
- package/dist/esm/base-authorization-attributes-service.mjs +61 -0
- package/dist/esm/entity-attribute-assignment.d.ts +4 -8
- package/dist/esm/entity-attribute-assignment.d.ts.map +1 -1
- package/dist/esm/entity-attribute-assignment.mjs +3 -4
- package/dist/esm/index.d.ts +6 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.mjs +6 -0
- package/dist/esm/resource-attribute-assignment.d.ts +3 -7
- package/dist/esm/resource-attribute-assignment.d.ts.map +1 -1
- package/dist/esm/resource-attribute-assignment.mjs +8 -2
- package/dist/esm/resource-attributes-constants.d.ts +12 -10
- package/dist/esm/resource-attributes-constants.d.ts.map +1 -1
- package/dist/esm/resource-attributes-constants.mjs +4 -2
- package/dist/esm/testKit/index.d.ts +4 -4
- package/dist/esm/testKit/index.d.ts.map +1 -1
- package/dist/esm/types/authorization-attributes-contracts.d.ts +7 -21
- package/dist/esm/types/authorization-attributes-contracts.d.ts.map +1 -1
- package/dist/esm/types/general.d.ts +4 -3
- package/dist/esm/types/general.d.ts.map +1 -1
- package/dist/esm/utils/assignment-schema.d.ts +51 -0
- package/dist/esm/utils/assignment-schema.d.ts.map +1 -0
- package/dist/esm/utils/assignment-schema.mjs +54 -0
- package/dist/esm/utils/resource-schema.d.ts +9 -0
- package/dist/esm/utils/resource-schema.d.ts.map +1 -0
- package/dist/esm/utils/resource-schema.mjs +16 -0
- package/dist/esm/utils/validation.d.ts +11 -28
- package/dist/esm/utils/validation.d.ts.map +1 -1
- package/dist/esm/utils/validation.mjs +61 -118
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -0
- package/dist/resource-attribute-assignment.d.ts +3 -7
- package/dist/resource-attribute-assignment.d.ts.map +1 -1
- package/dist/resource-attribute-assignment.js +8 -2
- package/dist/resource-attributes-constants.d.ts +12 -10
- package/dist/resource-attributes-constants.d.ts.map +1 -1
- package/dist/resource-attributes-constants.js +4 -2
- package/dist/testKit/index.d.ts +4 -4
- package/dist/testKit/index.d.ts.map +1 -1
- package/dist/types/authorization-attributes-contracts.d.ts +7 -21
- package/dist/types/authorization-attributes-contracts.d.ts.map +1 -1
- package/dist/types/general.d.ts +4 -3
- package/dist/types/general.d.ts.map +1 -1
- package/dist/utils/assignment-schema.d.ts +51 -0
- package/dist/utils/assignment-schema.d.ts.map +1 -0
- package/dist/utils/assignment-schema.js +63 -0
- package/dist/utils/resource-schema.d.ts +9 -0
- package/dist/utils/resource-schema.d.ts.map +1 -0
- package/dist/utils/resource-schema.js +22 -0
- package/dist/utils/validation.d.ts +11 -28
- package/dist/utils/validation.d.ts.map +1 -1
- package/dist/utils/validation.js +61 -118
- package/package.json +2 -3
- package/src/authorization-attributes-ms-service.ts +92 -154
- package/src/authorization-attributes-service.ts +18 -16
- package/src/authorization-attributes-sns-service.ts +132 -131
- package/src/authorization-service.ts +3 -28
- package/src/base-attribute-assignment.ts +10 -26
- package/src/base-authorization-attributes-service.ts +90 -0
- package/src/entity-attribute-assignment.ts +7 -6
- package/src/index.ts +17 -0
- package/src/resource-attribute-assignment.ts +13 -10
- package/src/resource-attributes-constants.ts +4 -2
- package/src/testKit/index.ts +5 -5
- package/src/types/authorization-attributes-contracts.ts +7 -27
- package/src/types/general.ts +4 -3
- package/src/utils/assignment-schema.ts +56 -0
- package/src/utils/resource-schema.ts +16 -0
- package/src/utils/validation.ts +90 -137
- package/dist/esm/types/authorization-attributes-service.interface.d.ts +0 -57
- package/dist/esm/types/authorization-attributes-service.interface.d.ts.map +0 -1
- package/dist/esm/types/authorization-attributes-service.interface.mjs +0 -1
- package/dist/types/authorization-attributes-service.interface.d.ts +0 -57
- package/dist/types/authorization-attributes-service.interface.d.ts.map +0 -1
- package/dist/types/authorization-attributes-service.interface.js +0 -1
- package/src/types/authorization-attributes-service.interface.ts +0 -101
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import chunk from 'lodash/chunk.js';
|
|
2
2
|
import { sendToSns, getTopicAttributes } from '@mondaydotcomorg/monday-sns';
|
|
3
|
-
import { AttributeOperation } from './types/authorization-attributes-contracts.mjs';
|
|
4
3
|
import { logger } from './authorization-internal-service.mjs';
|
|
5
4
|
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';
|
|
5
|
+
import { BaseAuthorizationAttributesService } from './base-authorization-attributes-service.mjs';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Service class for managing resource attributes asynchronously via SNS.
|
|
9
9
|
* Provides asynchronous operations to create/update and delete attributes on resources.
|
|
10
10
|
*/
|
|
11
|
-
class AuthorizationAttributesSnsService {
|
|
11
|
+
class AuthorizationAttributesSnsService extends BaseAuthorizationAttributesService {
|
|
12
12
|
static LOG_TAG = 'authorization_attributes';
|
|
13
13
|
resourceSnsArn;
|
|
14
14
|
entitySnsArn;
|
|
@@ -16,128 +16,91 @@ class AuthorizationAttributesSnsService {
|
|
|
16
16
|
* Public constructor to create the AuthorizationAttributesSnsService instance.
|
|
17
17
|
*/
|
|
18
18
|
constructor() {
|
|
19
|
+
super();
|
|
19
20
|
this.resourceSnsArn = AuthorizationAttributesSnsService.getSnsTopicArn(SnsTopicType.RESOURCE);
|
|
20
21
|
this.entitySnsArn = AuthorizationAttributesSnsService.getSnsTopicArn(SnsTopicType.ENTITY);
|
|
21
22
|
}
|
|
22
23
|
/**
|
|
23
|
-
* Async function to
|
|
24
|
-
* Sends the
|
|
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.
|
|
25
26
|
* @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
27
|
* @param resource The resource (resourceType, resourceId)
|
|
48
|
-
* @param
|
|
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
|
|
28
|
+
* @param attributeKey Attribute key to delete
|
|
67
29
|
* @param appName App name of the calling app
|
|
68
30
|
* @param callerActionIdentifier Action identifier
|
|
69
|
-
* @
|
|
70
|
-
* @return Promise with array of sent operations
|
|
31
|
+
* @return Promise with sent operation
|
|
71
32
|
*/
|
|
72
|
-
async
|
|
33
|
+
async deleteResourceAttributes(accountId, resource, attributeKey, appName, callerActionIdentifier) {
|
|
73
34
|
if (!appName || !callerActionIdentifier) {
|
|
74
35
|
throw new Error('appName and callerActionIdentifier are required for SNS service');
|
|
75
36
|
}
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
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);
|
|
37
|
+
const operation = await super.deleteResourceAttributes(accountId, resource, attributeKey);
|
|
38
|
+
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');
|
|
39
|
+
return result;
|
|
86
40
|
}
|
|
87
41
|
/**
|
|
88
|
-
* Async function to delete entity
|
|
89
|
-
* Sends the
|
|
42
|
+
* Async function to delete an entity attribute using SNS.
|
|
43
|
+
* Sends the delete request to SNS and returns before the change actually took place.
|
|
90
44
|
* @param accountId The account ID
|
|
91
|
-
* @param appName App name of the calling app
|
|
92
|
-
* @param callerActionIdentifier Action identifier
|
|
93
45
|
* @param entityType The entity type
|
|
94
46
|
* @param entityId The entity ID
|
|
95
|
-
* @param
|
|
96
|
-
* @
|
|
47
|
+
* @param attributeKey Attribute key to delete
|
|
48
|
+
* @param appName App name of the calling app
|
|
49
|
+
* @param callerActionIdentifier Action identifier
|
|
50
|
+
* @return Promise with sent operation
|
|
97
51
|
*/
|
|
98
|
-
async deleteEntityAttributes(accountId, entityType, entityId,
|
|
52
|
+
async deleteEntityAttributes(accountId, entityType, entityId, attributeKey, appName, callerActionIdentifier) {
|
|
99
53
|
if (!appName || !callerActionIdentifier) {
|
|
100
54
|
throw new Error('appName and callerActionIdentifier are required for SNS service');
|
|
101
55
|
}
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
key,
|
|
106
|
-
operationType: AttributeOperation.DELETE,
|
|
107
|
-
}));
|
|
108
|
-
return this.updateEntityAttributes(accountId, appName, callerActionIdentifier, operations);
|
|
56
|
+
const operation = await super.deleteEntityAttributes(accountId, entityType, entityId, attributeKey);
|
|
57
|
+
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');
|
|
58
|
+
return result;
|
|
109
59
|
}
|
|
110
60
|
/**
|
|
111
|
-
* Async function, this function only send the
|
|
61
|
+
* Async function, this function only send the update request to SNS and return before the change actually took place
|
|
112
62
|
* @param accountId
|
|
113
63
|
* @param appName - App name of the calling app
|
|
114
64
|
* @param callerActionIdentifier - action identifier
|
|
115
|
-
* @param
|
|
116
|
-
* @return {Promise<
|
|
65
|
+
* @param resourceAttributeOperation - Operation to do on resource attribute.
|
|
66
|
+
* @return {Promise<ResourceAttributeUpsertOperation>} Sent operation
|
|
117
67
|
* */
|
|
118
|
-
async updateResourceAttributes(accountId, appName, callerActionIdentifier,
|
|
119
|
-
|
|
120
|
-
const
|
|
121
|
-
|
|
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();
|
|
68
|
+
async updateResourceAttributes(accountId, appName, callerActionIdentifier, resourceAttributeOperation) {
|
|
69
|
+
await super.updateResourceAttributes(accountId, appName, callerActionIdentifier, resourceAttributeOperation);
|
|
70
|
+
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');
|
|
71
|
+
return result;
|
|
126
72
|
}
|
|
127
73
|
/**
|
|
128
|
-
* Async function, this function only send the
|
|
74
|
+
* Async function, this function only send the update request to SNS and return before the change actually took place
|
|
129
75
|
* @param accountId
|
|
130
76
|
* @param appName - App name of the calling app
|
|
131
77
|
* @param callerActionIdentifier - action identifier
|
|
132
|
-
* @param
|
|
133
|
-
* @return {Promise<
|
|
78
|
+
* @param entityAttributeOperation - Operation to do on entity attribute.
|
|
79
|
+
* @return {Promise<EntityAttributeUpsertOperation>} Sent operation
|
|
134
80
|
* */
|
|
135
|
-
async updateEntityAttributes(accountId, appName, callerActionIdentifier,
|
|
136
|
-
|
|
81
|
+
async updateEntityAttributes(accountId, appName, callerActionIdentifier, entityAttributeOperation) {
|
|
82
|
+
await super.updateEntityAttributes(accountId, appName, callerActionIdentifier, entityAttributeOperation);
|
|
83
|
+
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');
|
|
84
|
+
return result;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Base function to send attribute operations to SNS.
|
|
88
|
+
* Chunks operations and sends them in parallel.
|
|
89
|
+
* @param topicArn The SNS topic ARN to send messages to
|
|
90
|
+
* @param accountId The account ID
|
|
91
|
+
* @param appName App name of the calling app
|
|
92
|
+
* @param callerActionIdentifier Action identifier
|
|
93
|
+
* @param operations Array of operations to send
|
|
94
|
+
* @param chunkSize Maximum number of operations per message
|
|
95
|
+
* @param messageKind The kind of message being sent
|
|
96
|
+
* @param errorLogMessage Error message to log if sending fails
|
|
97
|
+
* @return Promise with array of sent operations
|
|
98
|
+
*/
|
|
99
|
+
async sendOperationsToSns(topicArn, accountId, appName, callerActionIdentifier, operations, chunkSize, messageKind, errorLogMessage) {
|
|
137
100
|
const sendToSnsPromises = [];
|
|
138
|
-
const
|
|
139
|
-
for (const operationsChunk of
|
|
140
|
-
sendToSnsPromises.push(this.sendSingleSnsMessage(topicArn, accountId, appName, callerActionIdentifier, operationsChunk,
|
|
101
|
+
const operationChunks = chunk(operations, chunkSize);
|
|
102
|
+
for (const operationsChunk of operationChunks) {
|
|
103
|
+
sendToSnsPromises.push(this.sendSingleSnsMessage(topicArn, accountId, appName, callerActionIdentifier, operationsChunk, messageKind, errorLogMessage));
|
|
141
104
|
}
|
|
142
105
|
return (await Promise.all(sendToSnsPromises)).flat();
|
|
143
106
|
}
|
|
@@ -33,7 +33,6 @@ export declare class AuthorizationService {
|
|
|
33
33
|
private static fetchIsUserGrantedWithFeature;
|
|
34
34
|
private static getCachedKeyName;
|
|
35
35
|
static canActionInScope(accountId: number, userId: number, action: string, scope: ScopeOptions): Promise<ScopedActionPermit>;
|
|
36
|
-
private static getProfile;
|
|
37
36
|
static canActionInScopeMultiple(accountId: number, userId: number, scopedActions: ScopedAction[]): Promise<ScopedActionResponseObject[]>;
|
|
38
37
|
private static isAuthorizedSingular;
|
|
39
38
|
private static isAuthorizedMultiple;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization-service.d.ts","sourceRoot":"","sources":["../../src/authorization-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAGnE,OAAO,EAAmB,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAG7F,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,0BAA0B,EAC1B,YAAY,EACb,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"authorization-service.d.ts","sourceRoot":"","sources":["../../src/authorization-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAGnE,OAAO,EAAmB,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAG7F,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,0BAA0B,EAC1B,YAAY,EACb,MAAM,kCAAkC,CAAC;AAY1C,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,OAAO,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,mBAAmB,CAAC,EAAE,mBAAmB,EAAE,CAAC;CAC7C;AAED,wBAAgB,sBAAsB,CAAC,wBAAwB,EAAE,k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AoB;CAmF1C;AAED,wBAAgB,cAAc,CAC5B,MAAM,KAAA,EACN,sCAAsC,GAAE,MAAiD,QAY1F;AAED,wBAAsB,eAAe,kBAMpC;AAED,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,mBAAmB,CAepG"}
|
|
@@ -5,16 +5,13 @@ import { getIgniteClient } from '@mondaydotcomorg/ignite-sdk';
|
|
|
5
5
|
import { sendAuthorizationCheckResponseTimeMetric } from './prometheus-service.mjs';
|
|
6
6
|
import { recordAuthorizationTiming } from './metrics-service.mjs';
|
|
7
7
|
import { AuthorizationInternalService, logger } from './authorization-internal-service.mjs';
|
|
8
|
-
import { getProfile,
|
|
8
|
+
import { getProfile, getAttributionsFromApi } from './attributions-service.mjs';
|
|
9
9
|
import { GraphApi } from './clients/graph-api.mjs';
|
|
10
10
|
import { PlatformApi } from './clients/platform-api.mjs';
|
|
11
11
|
import { scopeToResource } from './utils/authorization.utils.mjs';
|
|
12
12
|
|
|
13
13
|
const GRANTED_FEATURE_CACHE_EXPIRATION_SECONDS = 5 * 60;
|
|
14
14
|
const PLATFORM_AUTHORIZE_PATH = '/internal_ms/authorization/authorize';
|
|
15
|
-
const ALLOWED_SDK_PLATFORM_PROFILES_KEY = 'allowed-sdk-platform-profiles';
|
|
16
|
-
const IN_RELEASE_SDK_PLATFORM_PROFILES_KEY = 'in-release-sdk-platform-profile';
|
|
17
|
-
const PLATFORM_PROFILE_RELEASE_FF = 'sdk-platform-profiles';
|
|
18
15
|
const NAVIGATE_CAN_ACTION_IN_SCOPE_TO_GRAPH_FF = 'navigate-can-action-in-scope-to-graph';
|
|
19
16
|
function setRequestFetchOptions(customMondayFetchOptions) {
|
|
20
17
|
AuthorizationInternalService.setRequestFetchOptions(customMondayFetchOptions);
|
|
@@ -88,23 +85,6 @@ class AuthorizationService {
|
|
|
88
85
|
const scopedActionResponseObjects = await this.canActionInScopeMultiple(accountId, userId, scopedActions);
|
|
89
86
|
return scopedActionResponseObjects[0].permit;
|
|
90
87
|
}
|
|
91
|
-
static getProfile(accountId, userId) {
|
|
92
|
-
const appName = process.env.APP_NAME ?? 'INVALID_APP_NAME';
|
|
93
|
-
if (!this.igniteClient) {
|
|
94
|
-
logger.error({ tag: 'authorization-service' }, 'AuthorizationService: igniteClient is not set, failing request');
|
|
95
|
-
throw new Error('AuthorizationService: igniteClient is not set, failing request');
|
|
96
|
-
}
|
|
97
|
-
if (this.igniteClient.configuration.getObjectValue(ALLOWED_SDK_PLATFORM_PROFILES_KEY, []).includes(appName)) {
|
|
98
|
-
return getProfile();
|
|
99
|
-
}
|
|
100
|
-
if (this.igniteClient.configuration
|
|
101
|
-
.getObjectValue(IN_RELEASE_SDK_PLATFORM_PROFILES_KEY, [])
|
|
102
|
-
.includes(appName) &&
|
|
103
|
-
this.igniteClient.isReleased(PLATFORM_PROFILE_RELEASE_FF, { accountId, userId })) {
|
|
104
|
-
return getProfile();
|
|
105
|
-
}
|
|
106
|
-
return PlatformProfile.APP;
|
|
107
|
-
}
|
|
108
88
|
static async canActionInScopeMultiple(accountId, userId, scopedActions) {
|
|
109
89
|
if (scopedActions.length === 0) {
|
|
110
90
|
return [];
|
|
@@ -119,7 +99,7 @@ class AuthorizationService {
|
|
|
119
99
|
}
|
|
120
100
|
else {
|
|
121
101
|
apiType = 'platform';
|
|
122
|
-
const profile =
|
|
102
|
+
const profile = getProfile();
|
|
123
103
|
const internalAuthToken = AuthorizationInternalService.generateInternalAuthToken(accountId, userId);
|
|
124
104
|
scopedActionResponseObjects = await this.platformApi.checkPermissions(profile, internalAuthToken, userId, scopedActions);
|
|
125
105
|
}
|
|
@@ -140,7 +120,7 @@ class AuthorizationService {
|
|
|
140
120
|
return this.isAuthorizedMultiple(accountId, userId, authorizationObjects);
|
|
141
121
|
}
|
|
142
122
|
static async isAuthorizedMultiple(accountId, userId, authorizationRequestObjects) {
|
|
143
|
-
const profile =
|
|
123
|
+
const profile = getProfile();
|
|
144
124
|
const internalAuthToken = AuthorizationInternalService.generateInternalAuthToken(accountId, userId);
|
|
145
125
|
const startTime = performance.now();
|
|
146
126
|
const attributionHeaders = getAttributionsFromApi();
|
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
import { EntityAttributeAssignment, ResourceAttributeDelete } from './types/authorization-attributes-contracts';
|
|
2
1
|
/**
|
|
3
2
|
* Base class for attribute assignments (Resource or Entity)
|
|
4
3
|
* Provides common validation and functionality
|
|
5
4
|
*/
|
|
6
|
-
export declare abstract class BaseAttributeAssignment<
|
|
7
|
-
readonly id:
|
|
8
|
-
readonly type:
|
|
5
|
+
export declare abstract class BaseAttributeAssignment<T, R> {
|
|
6
|
+
readonly id: number;
|
|
7
|
+
readonly type: T;
|
|
9
8
|
readonly attributeKey: string;
|
|
10
9
|
readonly attributeValue: string;
|
|
11
|
-
constructor(id:
|
|
10
|
+
constructor(id: number, type: T, attributeKey: string, attributeValue: string);
|
|
12
11
|
/**
|
|
13
12
|
* Compares two assignments for equality
|
|
14
13
|
* @param other Another assignment instance
|
|
15
14
|
* @returns true if all properties are equal
|
|
16
15
|
*/
|
|
17
|
-
equals(other: BaseAttributeAssignment<
|
|
18
|
-
abstract toDataTransferObject():
|
|
16
|
+
equals(other: BaseAttributeAssignment<T, R>): boolean;
|
|
17
|
+
abstract toDataTransferObject(): R;
|
|
19
18
|
}
|
|
20
19
|
//# sourceMappingURL=base-attribute-assignment.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-attribute-assignment.d.ts","sourceRoot":"","sources":["../../src/base-attribute-assignment.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"base-attribute-assignment.d.ts","sourceRoot":"","sources":["../../src/base-attribute-assignment.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,8BAAsB,uBAAuB,CAAC,CAAC,EAAE,CAAC;IAChD,SAAgB,EAAE,EAAE,MAAM,CAAC;IAC3B,SAAgB,IAAI,EAAE,CAAC,CAAC;IACxB,SAAgB,YAAY,EAAE,MAAM,CAAC;IACrC,SAAgB,cAAc,EAAE,MAAM,CAAC;gBAE3B,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;IAO7E;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,uBAAuB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO;IAIrD,QAAQ,CAAC,oBAAoB,IAAI,CAAC;CACnC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ValidationUtils } from './utils/validation.mjs';
|
|
2
1
|
import isEqual from 'lodash/isEqual.js';
|
|
3
2
|
|
|
4
3
|
/**
|
|
@@ -10,12 +9,11 @@ class BaseAttributeAssignment {
|
|
|
10
9
|
type;
|
|
11
10
|
attributeKey;
|
|
12
11
|
attributeValue;
|
|
13
|
-
constructor(id, type, attributeKey, attributeValue
|
|
14
|
-
|
|
15
|
-
this.
|
|
16
|
-
this.
|
|
17
|
-
this.
|
|
18
|
-
this.attributeValue = validated.attributeValue;
|
|
12
|
+
constructor(id, type, attributeKey, attributeValue) {
|
|
13
|
+
this.id = id;
|
|
14
|
+
this.type = type;
|
|
15
|
+
this.attributeKey = attributeKey;
|
|
16
|
+
this.attributeValue = attributeValue;
|
|
19
17
|
}
|
|
20
18
|
/**
|
|
21
19
|
* Compares two assignments for equality
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { EntityType } from './entity-attributes-constants';
|
|
2
|
+
import { ResourceAttributeDeleteOperation, EntityAttributeDeleteOperation, ResourceAttributeUpsertOperation, EntityAttributeUpsertOperation } from './types/authorization-attributes-contracts';
|
|
3
|
+
import { Resource } from './types/general';
|
|
4
|
+
/**
|
|
5
|
+
* Abstract base class for authorization attributes operations.
|
|
6
|
+
* Both MS (HTTP) and SNS (async) services extend this class.
|
|
7
|
+
*/
|
|
8
|
+
export declare abstract class BaseAuthorizationAttributesService {
|
|
9
|
+
/**
|
|
10
|
+
* Deletes a resource attribute.
|
|
11
|
+
* Returns Promise<ResourceAttributeDeleteOperation>
|
|
12
|
+
*/
|
|
13
|
+
deleteResourceAttributes(accountId: number, resource: Resource, attributeKey: string, _appName?: string, _callerActionIdentifier?: string): Promise<ResourceAttributeDeleteOperation>;
|
|
14
|
+
/**
|
|
15
|
+
* Deletes an entity attribute.
|
|
16
|
+
* Returns Promise<EntityAttributeDeleteOperation>
|
|
17
|
+
*/
|
|
18
|
+
deleteEntityAttributes(accountId: number, entityType: EntityType, entityId: number, attributeKey: string): Promise<EntityAttributeDeleteOperation>;
|
|
19
|
+
/**
|
|
20
|
+
* Updates a resource attribute (single operation - upsert only).
|
|
21
|
+
* For MS service: performs upsert operation
|
|
22
|
+
* For SNS service: returns Promise<ResourceAttributeUpsertOperation>
|
|
23
|
+
*/
|
|
24
|
+
updateResourceAttributes(accountId: number, _appName: string, _callerActionIdentifier: string, resourceAttributeOperation: ResourceAttributeUpsertOperation): Promise<ResourceAttributeUpsertOperation>;
|
|
25
|
+
/**
|
|
26
|
+
* Updates an entity attribute (single operation - upsert only).
|
|
27
|
+
* For MS service: performs upsert operation
|
|
28
|
+
* For SNS service: returns Promise<EntityAttributeUpsertOperation>
|
|
29
|
+
*/
|
|
30
|
+
updateEntityAttributes(accountId: number, _appName: string, _callerActionIdentifier: string, entityAttributeOperation: EntityAttributeUpsertOperation): Promise<EntityAttributeUpsertOperation>;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=base-authorization-attributes-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-authorization-attributes-service.d.ts","sourceRoot":"","sources":["../../src/base-authorization-attributes-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EACL,gCAAgC,EAChC,8BAA8B,EAC9B,gCAAgC,EAChC,8BAA8B,EAE/B,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAG3C;;;GAGG;AACH,8BAAsB,kCAAkC;IACtD;;;OAGG;IACH,wBAAwB,CACtB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,MAAM,EACpB,QAAQ,CAAC,EAAE,MAAM,EACjB,uBAAuB,CAAC,EAAE,MAAM,GAC/B,OAAO,CAAC,gCAAgC,CAAC;IAY5C;;;OAGG;IACH,sBAAsB,CACpB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,8BAA8B,CAAC;IAY1C;;;;OAIG;IACH,wBAAwB,CACtB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,uBAAuB,EAAE,MAAM,EAC/B,0BAA0B,EAAE,gCAAgC,GAC3D,OAAO,CAAC,gCAAgC,CAAC;IAK5C;;;;OAIG;IACH,sBAAsB,CACpB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,uBAAuB,EAAE,MAAM,EAC/B,wBAAwB,EAAE,8BAA8B,GACvD,OAAO,CAAC,8BAA8B,CAAC;CAK3C"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { AttributeOperation } from './types/authorization-attributes-contracts.mjs';
|
|
2
|
+
import { ValidationUtils } from './utils/validation.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Abstract base class for authorization attributes operations.
|
|
6
|
+
* Both MS (HTTP) and SNS (async) services extend this class.
|
|
7
|
+
*/
|
|
8
|
+
class BaseAuthorizationAttributesService {
|
|
9
|
+
/**
|
|
10
|
+
* Deletes a resource attribute.
|
|
11
|
+
* Returns Promise<ResourceAttributeDeleteOperation>
|
|
12
|
+
*/
|
|
13
|
+
deleteResourceAttributes(accountId, resource, attributeKey, _appName, _callerActionIdentifier) {
|
|
14
|
+
const operation = {
|
|
15
|
+
resourceType: resource.type,
|
|
16
|
+
resourceId: resource.id,
|
|
17
|
+
key: attributeKey,
|
|
18
|
+
operationType: AttributeOperation.DELETE,
|
|
19
|
+
};
|
|
20
|
+
ValidationUtils.validateInteger(accountId);
|
|
21
|
+
ValidationUtils.validatDeleteResourceAssignment(operation);
|
|
22
|
+
return Promise.resolve(operation);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Deletes an entity attribute.
|
|
26
|
+
* Returns Promise<EntityAttributeDeleteOperation>
|
|
27
|
+
*/
|
|
28
|
+
deleteEntityAttributes(accountId, entityType, entityId, attributeKey) {
|
|
29
|
+
const operation = {
|
|
30
|
+
entityType: entityType,
|
|
31
|
+
entityId: entityId,
|
|
32
|
+
key: attributeKey,
|
|
33
|
+
operationType: AttributeOperation.DELETE,
|
|
34
|
+
};
|
|
35
|
+
ValidationUtils.validateInteger(accountId);
|
|
36
|
+
ValidationUtils.validatDeleteEntityAssignment(operation);
|
|
37
|
+
return Promise.resolve(operation);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Updates a resource attribute (single operation - upsert only).
|
|
41
|
+
* For MS service: performs upsert operation
|
|
42
|
+
* For SNS service: returns Promise<ResourceAttributeUpsertOperation>
|
|
43
|
+
*/
|
|
44
|
+
updateResourceAttributes(accountId, _appName, _callerActionIdentifier, resourceAttributeOperation) {
|
|
45
|
+
ValidationUtils.validateInteger(accountId);
|
|
46
|
+
ValidationUtils.validatUpsertResourceAssignment(resourceAttributeOperation);
|
|
47
|
+
return Promise.resolve(resourceAttributeOperation);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Updates an entity attribute (single operation - upsert only).
|
|
51
|
+
* For MS service: performs upsert operation
|
|
52
|
+
* For SNS service: returns Promise<EntityAttributeUpsertOperation>
|
|
53
|
+
*/
|
|
54
|
+
updateEntityAttributes(accountId, _appName, _callerActionIdentifier, entityAttributeOperation) {
|
|
55
|
+
ValidationUtils.validateInteger(accountId);
|
|
56
|
+
ValidationUtils.validatUpsertEntityAssignment(entityAttributeOperation);
|
|
57
|
+
return Promise.resolve(entityAttributeOperation);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export { BaseAuthorizationAttributesService };
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import { EntityType } from './entity-attributes-constants';
|
|
2
2
|
import { BaseAttributeAssignment } from './base-attribute-assignment';
|
|
3
|
-
|
|
3
|
+
import { EntityAttributeAssignment as EntityAttributeAssignmentContract } from './types/authorization-attributes-contracts';
|
|
4
|
+
export declare class EntityAttributeAssignment extends BaseAttributeAssignment<EntityType, EntityAttributeAssignmentContract> {
|
|
4
5
|
readonly entityId: number;
|
|
5
6
|
readonly entityType: EntityType;
|
|
6
|
-
constructor(entityId: number, entityType:
|
|
7
|
-
toDataTransferObject():
|
|
8
|
-
entityId: number;
|
|
9
|
-
entityType: EntityType;
|
|
10
|
-
key: string;
|
|
11
|
-
value: string;
|
|
12
|
-
};
|
|
7
|
+
constructor(entityId: number, entityType: EntityType, key: string, value: string);
|
|
8
|
+
toDataTransferObject(): EntityAttributeAssignmentContract;
|
|
13
9
|
/**
|
|
14
10
|
* Compares two assignments for equality
|
|
15
11
|
* @param other Another EntityAttributeAssignment instance
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-attribute-assignment.d.ts","sourceRoot":"","sources":["../../src/entity-attribute-assignment.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"entity-attribute-assignment.d.ts","sourceRoot":"","sources":["../../src/entity-attribute-assignment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,yBAAyB,IAAI,iCAAiC,EAAE,MAAM,4CAA4C,CAAC;AAE5H,qBAAa,yBAA0B,SAAQ,uBAAuB,CAAC,UAAU,EAAE,iCAAiC,CAAC;IACnH,SAAgB,QAAQ,EAAE,MAAM,CAAC;IACjC,SAAgB,UAAU,EAAE,UAAU,CAAC;gBAE3B,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAMhF,oBAAoB,IAAI,iCAAiC;IAQzD;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO;CAGlD"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { ENTITY_TYPES } from './entity-attributes-constants.mjs';
|
|
2
1
|
import { BaseAttributeAssignment } from './base-attribute-assignment.mjs';
|
|
3
2
|
|
|
4
3
|
class EntityAttributeAssignment extends BaseAttributeAssignment {
|
|
5
4
|
entityId;
|
|
6
5
|
entityType;
|
|
7
|
-
constructor(entityId, entityType,
|
|
8
|
-
super(entityId, entityType,
|
|
6
|
+
constructor(entityId, entityType, key, value) {
|
|
7
|
+
super(entityId, entityType, key, value);
|
|
9
8
|
this.entityId = entityId;
|
|
10
|
-
this.entityType =
|
|
9
|
+
this.entityType = entityType;
|
|
11
10
|
}
|
|
12
11
|
toDataTransferObject() {
|
|
13
12
|
return {
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -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 { BaseAuthorizationAttributesService as IAuthorizationAttributesService } from './base-authorization-attributes-service';
|
|
27
33
|
export { TestKit };
|
|
28
34
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -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,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,EAAE,MAAM,yCAAyC,CAAC;AAEhI,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -6,9 +6,15 @@ 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';
|
|
17
|
+
export { BaseAuthorizationAttributesService as IAuthorizationAttributesService } from './base-authorization-attributes-service.mjs';
|
|
12
18
|
|
|
13
19
|
async function init(options = {}) {
|
|
14
20
|
if (options.prometheus) {
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import { ResourceType } from './resource-attributes-constants';
|
|
2
2
|
import { BaseAttributeAssignment } from './base-attribute-assignment';
|
|
3
|
-
|
|
3
|
+
import { ResourceAttributeAssignment as ResourceAttributeAssignmentContract } from './types/authorization-attributes-contracts';
|
|
4
|
+
export declare class ResourceAttributeAssignment extends BaseAttributeAssignment<ResourceType, ResourceAttributeAssignmentContract> {
|
|
4
5
|
readonly resourceId: number;
|
|
5
6
|
readonly resourceType: ResourceType;
|
|
6
7
|
constructor(resourceId: number, resourceType: ResourceType, attributeKey: string, attributeValue: string);
|
|
7
|
-
toDataTransferObject():
|
|
8
|
-
resourceId: number;
|
|
9
|
-
resourceType: ResourceType;
|
|
10
|
-
key: string;
|
|
11
|
-
value: string;
|
|
12
|
-
};
|
|
8
|
+
toDataTransferObject(): ResourceAttributeAssignmentContract;
|
|
13
9
|
/**
|
|
14
10
|
* Compares two assignments for equality
|
|
15
11
|
* @param other Another ResourceAttributeAssignment instance
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-attribute-assignment.d.ts","sourceRoot":"","sources":["../../src/resource-attribute-assignment.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
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;IAYxG,oBAAoB,IAAI,mCAAmC;IAQ3D;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,2BAA2B,GAAG,OAAO;CAGpD"}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
import { RESOURCE_TYPES } from './resource-attributes-constants.mjs';
|
|
2
1
|
import { BaseAttributeAssignment } from './base-attribute-assignment.mjs';
|
|
2
|
+
import { ValidationUtils } from './utils/validation.mjs';
|
|
3
3
|
|
|
4
4
|
class ResourceAttributeAssignment extends BaseAttributeAssignment {
|
|
5
5
|
resourceId;
|
|
6
6
|
resourceType;
|
|
7
7
|
constructor(resourceId, resourceType, attributeKey, attributeValue) {
|
|
8
|
-
|
|
8
|
+
ValidationUtils.validatUpsertResourceAssignment({
|
|
9
|
+
resourceId,
|
|
10
|
+
resourceType,
|
|
11
|
+
key: attributeKey,
|
|
12
|
+
value: attributeValue,
|
|
13
|
+
});
|
|
14
|
+
super(resourceId, resourceType, attributeKey, attributeValue);
|
|
9
15
|
this.resourceId = resourceId;
|
|
10
16
|
this.resourceType = this.type;
|
|
11
17
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
export declare const RESOURCE_ATTRIBUTES_CONSTANTS: {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export declare const RESOURCE_ATTRIBUTES_CONSTANTS: Readonly<{
|
|
2
|
+
ACCOUNT_RESOURCE_ATTRIBUTES: {
|
|
3
|
+
ENABLE_MEMBERS_INVITE_FROM_NON_AUTH_DOMAIN: string;
|
|
4
4
|
};
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
WORKSPACE_RESOURCE_ATTRIBUTES: {
|
|
6
|
+
IS_DEFAULT_WORKSPACE: string;
|
|
7
7
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
BOARD_RESOURCE_ATTRIBUTES: {
|
|
9
|
+
IS_SYNCABLE_CHILD_ENTITY: string;
|
|
10
|
+
SYSTEM_ENTITY_TYPE: string;
|
|
11
11
|
};
|
|
12
|
-
}
|
|
12
|
+
}>;
|
|
13
13
|
export declare enum ResourceType {
|
|
14
14
|
Account = "account",
|
|
15
15
|
AccountProduct = "account_product",
|
|
@@ -19,7 +19,9 @@ 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",
|
|
24
|
+
POST = "post"
|
|
23
25
|
}
|
|
24
26
|
export declare const RESOURCE_TYPES: readonly ResourceType[];
|
|
25
27
|
//# 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;;;;;;;;;;;
|
|
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;IACnB,IAAI,SAAS;CACd;AAGD,eAAO,MAAM,cAAc,yBAA6C,CAAC"}
|