@mondaydotcomorg/monday-authorization 3.6.0-feat-shaime-support-entity-attributes-3-31fcbe3 → 3.6.0-feat-shaime-support-entity-attributes-3-02be333
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/dist/authorization-attributes-ms-service.d.ts +2 -2
- package/dist/authorization-attributes-ms-service.d.ts.map +1 -1
- package/dist/authorization-attributes-ms-service.js +10 -38
- 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 +2 -2
- package/dist/authorization-attributes-sns-service.d.ts.map +1 -1
- package/dist/authorization-attributes-sns-service.js +7 -23
- 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/esm/authorization-attributes-ms-service.d.ts +2 -2
- package/dist/esm/authorization-attributes-ms-service.d.ts.map +1 -1
- package/dist/esm/authorization-attributes-ms-service.mjs +10 -38
- 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 +2 -2
- package/dist/esm/authorization-attributes-sns-service.d.ts.map +1 -1
- package/dist/esm/authorization-attributes-sns-service.mjs +7 -23
- 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/index.d.ts +1 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.mjs +1 -0
- package/dist/esm/resource-attribute-assignment.d.ts.map +1 -1
- package/dist/esm/resource-attribute-assignment.mjs +7 -0
- package/dist/esm/resource-attributes-constants.d.ts +2 -1
- package/dist/esm/resource-attributes-constants.d.ts.map +1 -1
- package/dist/esm/resource-attributes-constants.mjs +1 -0
- package/dist/esm/utils/assignment-schema.d.ts.map +1 -1
- package/dist/esm/utils/assignment-schema.mjs +5 -0
- package/dist/esm/utils/validation.mjs +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/resource-attribute-assignment.d.ts.map +1 -1
- package/dist/resource-attribute-assignment.js +7 -0
- package/dist/resource-attributes-constants.d.ts +2 -1
- package/dist/resource-attributes-constants.d.ts.map +1 -1
- package/dist/resource-attributes-constants.js +1 -0
- package/dist/utils/assignment-schema.d.ts.map +1 -1
- package/dist/utils/assignment-schema.js +5 -0
- package/dist/utils/validation.js +2 -2
- package/package.json +1 -1
- package/src/authorization-attributes-ms-service.ts +19 -41
- package/src/authorization-attributes-service.ts +18 -16
- package/src/authorization-attributes-sns-service.ts +15 -23
- package/src/base-authorization-attributes-service.ts +90 -0
- package/src/index.ts +1 -1
- package/src/resource-attribute-assignment.ts +7 -0
- package/src/resource-attributes-constants.ts +1 -0
- package/src/utils/assignment-schema.ts +5 -0
- package/src/utils/validation.ts +2 -2
- package/dist/esm/types/authorization-attributes-service.interface.d.ts +0 -32
- 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 -32
- 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 -63
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization-attributes-service.d.ts","sourceRoot":"","sources":["../../src/authorization-attributes-service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"authorization-attributes-service.d.ts","sourceRoot":"","sources":["../../src/authorization-attributes-service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kCAAkC,IAAI,+BAA+B,EAAE,MAAM,yCAAyC,CAAC;AAEhI;;;;;;;;;;;;;GAaG;AACH,qBAAa,8BAA8B;IACzC,OAAO,CAAC,WAAW,CAAiD;IACpE,OAAO,CAAC,UAAU,CAAkD;IAEpE;;;;;OAKG;IACH,IAAI,IAAI,+BAA+B;IAOvC;;;;;OAKG;IACH,GAAG,IAAI,+BAA+B;CAMvC"}
|
|
@@ -3,42 +3,44 @@ import { AuthorizationAttributesSnsService } from './authorization-attributes-sn
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Main service class for managing resource and entity attributes.
|
|
6
|
-
* Provides access to both direct
|
|
6
|
+
* Provides access to both HTTP (direct microservice) and SNS (async messaging) operations.
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
9
9
|
* const service = new AuthorizationAttributesService();
|
|
10
10
|
*
|
|
11
|
-
* // Use direct
|
|
12
|
-
* await service.
|
|
11
|
+
* // Use HTTP operations (direct calls to microservice)
|
|
12
|
+
* await service.http().updateResourceAttributes(accountId, appName, actionId, operation);
|
|
13
13
|
*
|
|
14
|
-
* // Use SNS operations
|
|
15
|
-
* await service.sns().
|
|
14
|
+
* // Use SNS operations (async messaging, then to microservice)
|
|
15
|
+
* await service.sns().updateResourceAttributes(accountId, appName, actionId, operation);
|
|
16
16
|
* ```
|
|
17
17
|
*/
|
|
18
18
|
class AuthorizationAttributesService {
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
httpService = null;
|
|
20
|
+
snsService = null;
|
|
21
21
|
/**
|
|
22
|
-
* Gets the
|
|
22
|
+
* Gets the HTTP service instance.
|
|
23
|
+
* Performs direct HTTP calls to the authorization microservice.
|
|
23
24
|
* Initializes the service on first access (lazy initialization).
|
|
24
25
|
* @returns IAuthorizationAttributesService instance
|
|
25
26
|
*/
|
|
26
|
-
|
|
27
|
-
if (this.
|
|
28
|
-
this.
|
|
27
|
+
http() {
|
|
28
|
+
if (this.httpService === null) {
|
|
29
|
+
this.httpService = new AuthorizationAttributesMsService();
|
|
29
30
|
}
|
|
30
|
-
return this.
|
|
31
|
+
return this.httpService;
|
|
31
32
|
}
|
|
32
33
|
/**
|
|
33
34
|
* Gets the SNS service instance.
|
|
35
|
+
* Sends operations via SNS messaging, which are then processed by the microservice asynchronously.
|
|
34
36
|
* Initializes the service on first access (lazy initialization).
|
|
35
37
|
* @returns IAuthorizationAttributesService instance
|
|
36
38
|
*/
|
|
37
39
|
sns() {
|
|
38
|
-
if (this.
|
|
39
|
-
this.
|
|
40
|
+
if (this.snsService === null) {
|
|
41
|
+
this.snsService = new AuthorizationAttributesSnsService();
|
|
40
42
|
}
|
|
41
|
-
return this.
|
|
43
|
+
return this.snsService;
|
|
42
44
|
}
|
|
43
45
|
}
|
|
44
46
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { ResourceAttributeUpsertOperation, EntityAttributeUpsertOperation, EntityAttributeDeleteOperation, ResourceAttributeDeleteOperation } from './types/authorization-attributes-contracts';
|
|
2
2
|
import { Resource } from './types/general';
|
|
3
|
-
import {
|
|
3
|
+
import { BaseAuthorizationAttributesService } from './base-authorization-attributes-service';
|
|
4
4
|
import { EntityType } from './entity-attributes-constants';
|
|
5
5
|
/**
|
|
6
6
|
* Service class for managing resource attributes asynchronously via SNS.
|
|
7
7
|
* Provides asynchronous operations to create/update and delete attributes on resources.
|
|
8
8
|
*/
|
|
9
|
-
export declare class AuthorizationAttributesSnsService
|
|
9
|
+
export declare class AuthorizationAttributesSnsService extends BaseAuthorizationAttributesService {
|
|
10
10
|
private static LOG_TAG;
|
|
11
11
|
private resourceSnsArn;
|
|
12
12
|
private entitySnsArn;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization-attributes-sns-service.d.ts","sourceRoot":"","sources":["../../src/authorization-attributes-sns-service.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"authorization-attributes-sns-service.d.ts","sourceRoot":"","sources":["../../src/authorization-attributes-sns-service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e1C;;;;;;;;;;;;OAYG;YACW,mBAAmB;YAkCnB,oBAAoB;IAiClC,OAAO,CAAC,MAAM,CAAC,cAAc;IA0B7B;;;;;;;OAOG;IACG,kCAAkC,IAAI,OAAO,CAAC,OAAO,CAAC;CAoB7D"}
|
|
@@ -1,15 +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';
|
|
6
|
-
import {
|
|
5
|
+
import { BaseAuthorizationAttributesService } from './base-authorization-attributes-service.mjs';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* Service class for managing resource attributes asynchronously via SNS.
|
|
10
9
|
* Provides asynchronous operations to create/update and delete attributes on resources.
|
|
11
10
|
*/
|
|
12
|
-
class AuthorizationAttributesSnsService {
|
|
11
|
+
class AuthorizationAttributesSnsService extends BaseAuthorizationAttributesService {
|
|
13
12
|
static LOG_TAG = 'authorization_attributes';
|
|
14
13
|
resourceSnsArn;
|
|
15
14
|
entitySnsArn;
|
|
@@ -17,6 +16,7 @@ class AuthorizationAttributesSnsService {
|
|
|
17
16
|
* Public constructor to create the AuthorizationAttributesSnsService instance.
|
|
18
17
|
*/
|
|
19
18
|
constructor() {
|
|
19
|
+
super();
|
|
20
20
|
this.resourceSnsArn = AuthorizationAttributesSnsService.getSnsTopicArn(SnsTopicType.RESOURCE);
|
|
21
21
|
this.entitySnsArn = AuthorizationAttributesSnsService.getSnsTopicArn(SnsTopicType.ENTITY);
|
|
22
22
|
}
|
|
@@ -34,17 +34,7 @@ class AuthorizationAttributesSnsService {
|
|
|
34
34
|
if (!appName || !callerActionIdentifier) {
|
|
35
35
|
throw new Error('appName and callerActionIdentifier are required for SNS service');
|
|
36
36
|
}
|
|
37
|
-
|
|
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
|
-
};
|
|
37
|
+
const operation = await super.deleteResourceAttributes(accountId, resource, attributeKey);
|
|
48
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');
|
|
49
39
|
return result;
|
|
50
40
|
}
|
|
@@ -63,13 +53,7 @@ class AuthorizationAttributesSnsService {
|
|
|
63
53
|
if (!appName || !callerActionIdentifier) {
|
|
64
54
|
throw new Error('appName and callerActionIdentifier are required for SNS service');
|
|
65
55
|
}
|
|
66
|
-
|
|
67
|
-
const operation = {
|
|
68
|
-
entityType: entityType,
|
|
69
|
-
entityId,
|
|
70
|
-
key: attributeKey,
|
|
71
|
-
operationType: AttributeOperation.DELETE,
|
|
72
|
-
};
|
|
56
|
+
const operation = await super.deleteEntityAttributes(accountId, entityType, entityId, attributeKey);
|
|
73
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');
|
|
74
58
|
return result;
|
|
75
59
|
}
|
|
@@ -82,7 +66,7 @@ class AuthorizationAttributesSnsService {
|
|
|
82
66
|
* @return {Promise<ResourceAttributeUpsertOperation>} Sent operation
|
|
83
67
|
* */
|
|
84
68
|
async updateResourceAttributes(accountId, appName, callerActionIdentifier, resourceAttributeOperation) {
|
|
85
|
-
|
|
69
|
+
await super.updateResourceAttributes(accountId, appName, callerActionIdentifier, resourceAttributeOperation);
|
|
86
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');
|
|
87
71
|
return result;
|
|
88
72
|
}
|
|
@@ -95,7 +79,7 @@ class AuthorizationAttributesSnsService {
|
|
|
95
79
|
* @return {Promise<EntityAttributeUpsertOperation>} Sent operation
|
|
96
80
|
* */
|
|
97
81
|
async updateEntityAttributes(accountId, appName, callerActionIdentifier, entityAttributeOperation) {
|
|
98
|
-
|
|
82
|
+
await super.updateEntityAttributes(accountId, appName, callerActionIdentifier, entityAttributeOperation);
|
|
99
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');
|
|
100
84
|
return result;
|
|
101
85
|
}
|
|
@@ -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 };
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -29,6 +29,6 @@ export { AuthorizationObject, Resource, BaseRequest, ResourceGetter, ContextGett
|
|
|
29
29
|
export { Translation, ScopedAction, ScopedActionResponseObject, ScopedActionPermit, } from './types/scoped-actions-contracts';
|
|
30
30
|
export { CustomRole, BasicRole, RoleType, RoleCreateRequest, RoleUpdateRequest, RolesResponse } from './types/roles';
|
|
31
31
|
export { AttributeAssignment, AttributeOperation, ResourceAttributeDeleteAssignment, ResourceAttributeUpsertOperation, ResourceAttributeDeleteOperation, EntityAttributeDeleteAssignment, EntityAttributeUpsertOperation, EntityAttributeDeleteOperation, ResourceAttributeAssignment as ResourceAttributeAssignmentContract, EntityAttributeAssignment as EntityAttributeAssignmentContract, } from './types/authorization-attributes-contracts';
|
|
32
|
-
export {
|
|
32
|
+
export { BaseAuthorizationAttributesService as IAuthorizationAttributesService } from './base-authorization-attributes-service';
|
|
33
33
|
export { TestKit };
|
|
34
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":"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AAiB,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,kCAAkC,IAAI,+BAA+B,EAAE,MAAM,yCAAyC,CAAC;AAEhI,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -14,6 +14,7 @@ export { RolesService } from './roles-service.mjs';
|
|
|
14
14
|
export { MembershipsService } from './memberships.mjs';
|
|
15
15
|
export { RoleType } from './types/roles.mjs';
|
|
16
16
|
export { AttributeOperation } from './types/authorization-attributes-contracts.mjs';
|
|
17
|
+
export { BaseAuthorizationAttributesService as IAuthorizationAttributesService } from './base-authorization-attributes-service.mjs';
|
|
17
18
|
|
|
18
19
|
async function init(options = {}) {
|
|
19
20
|
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;
|
|
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,9 +1,16 @@
|
|
|
1
1
|
import { BaseAttributeAssignment } from './base-attribute-assignment.mjs';
|
|
2
|
+
import { ValidationUtils } from './utils/validation.mjs';
|
|
2
3
|
|
|
3
4
|
class ResourceAttributeAssignment extends BaseAttributeAssignment {
|
|
4
5
|
resourceId;
|
|
5
6
|
resourceType;
|
|
6
7
|
constructor(resourceId, resourceType, attributeKey, attributeValue) {
|
|
8
|
+
ValidationUtils.validatUpsertResourceAssignment({
|
|
9
|
+
resourceId,
|
|
10
|
+
resourceType,
|
|
11
|
+
key: attributeKey,
|
|
12
|
+
value: attributeValue,
|
|
13
|
+
});
|
|
7
14
|
super(resourceId, resourceType, attributeKey, attributeValue);
|
|
8
15
|
this.resourceId = resourceId;
|
|
9
16
|
this.resourceType = this.type;
|
|
@@ -20,7 +20,8 @@ export declare enum ResourceType {
|
|
|
20
20
|
Overview = "overview",
|
|
21
21
|
Document = "document",
|
|
22
22
|
Crm = "crm",
|
|
23
|
-
Feature = "feature"
|
|
23
|
+
Feature = "feature",
|
|
24
|
+
POST = "post"
|
|
24
25
|
}
|
|
25
26
|
export declare const RESOURCE_TYPES: readonly ResourceType[];
|
|
26
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;;;;;;;;;;;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;
|
|
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"}
|
|
@@ -22,6 +22,7 @@ var ResourceType;
|
|
|
22
22
|
ResourceType["Document"] = "document";
|
|
23
23
|
ResourceType["Crm"] = "crm";
|
|
24
24
|
ResourceType["Feature"] = "feature";
|
|
25
|
+
ResourceType["POST"] = "post";
|
|
25
26
|
})(ResourceType || (ResourceType = {}));
|
|
26
27
|
// Define the array of strings and use 'as const' to make its contents literal types
|
|
27
28
|
const RESOURCE_TYPES = Object.freeze(Object.values(ResourceType));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assignment-schema.d.ts","sourceRoot":"","sources":["../../../src/utils/assignment-schema.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"assignment-schema.d.ts","sourceRoot":"","sources":["../../../src/utils/assignment-schema.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;EAWvC,CAAC;AAEH,eAAO,MAAM,4BAA4B;;;;;;;;;;EAUvC,CAAC;AAEH,eAAO,MAAM,8BAA8B;;;;;;;;;;EAUzC,CAAC;AAEH,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;EAWzC,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Ajv from 'ajv';
|
|
2
2
|
import { EntityType } from '../entity-attributes-constants.mjs';
|
|
3
3
|
import { ResourceType } from '../resource-attributes-constants.mjs';
|
|
4
|
+
import { AttributeOperation } from '../types/authorization-attributes-contracts.mjs';
|
|
4
5
|
|
|
5
6
|
const ajv = new Ajv({ allErrors: true });
|
|
6
7
|
const entityUpsertAssignmentSchema = ajv.compile({
|
|
@@ -10,6 +11,7 @@ const entityUpsertAssignmentSchema = ajv.compile({
|
|
|
10
11
|
entityType: { type: 'string', enum: Object.values(EntityType) },
|
|
11
12
|
key: { type: 'string', minLength: 1 },
|
|
12
13
|
value: { type: 'string', minLength: 1 },
|
|
14
|
+
operationType: { type: 'string', enum: Object.values(AttributeOperation) },
|
|
13
15
|
},
|
|
14
16
|
required: ['entityId', 'entityType', 'key', 'value'],
|
|
15
17
|
additionalProperties: false,
|
|
@@ -20,6 +22,7 @@ const entityDeleteAssignmentSchema = ajv.compile({
|
|
|
20
22
|
entityId: { type: 'number', multipleOf: 1 },
|
|
21
23
|
entityType: { type: 'string', enum: Object.values(EntityType) },
|
|
22
24
|
key: { type: 'string', minLength: 1 },
|
|
25
|
+
operationType: { type: 'string', enum: Object.values(AttributeOperation) },
|
|
23
26
|
},
|
|
24
27
|
required: ['entityId', 'entityType', 'key'],
|
|
25
28
|
additionalProperties: false,
|
|
@@ -30,6 +33,7 @@ const resourceDeleteAssignmentSchema = ajv.compile({
|
|
|
30
33
|
resourceId: { type: 'number', multipleOf: 1 },
|
|
31
34
|
resourceType: { type: 'string', enum: Object.values(ResourceType) },
|
|
32
35
|
key: { type: 'string', minLength: 1 },
|
|
36
|
+
operationType: { type: 'string', enum: Object.values(AttributeOperation) },
|
|
33
37
|
},
|
|
34
38
|
required: ['resourceId', 'resourceType', 'key'],
|
|
35
39
|
additionalProperties: false,
|
|
@@ -41,6 +45,7 @@ const resourceUpsertAssignmentSchema = ajv.compile({
|
|
|
41
45
|
resourceType: { type: 'string', enum: Object.values(ResourceType) },
|
|
42
46
|
key: { type: 'string', minLength: 1 },
|
|
43
47
|
value: { type: 'string', minLength: 1 },
|
|
48
|
+
operationType: { type: 'string', enum: Object.values(AttributeOperation) },
|
|
44
49
|
},
|
|
45
50
|
required: ['resourceId', 'resourceType', 'key', 'value'],
|
|
46
51
|
additionalProperties: false,
|
|
@@ -55,7 +55,7 @@ class ValidationUtils {
|
|
|
55
55
|
static validatDeleteResourceAssignment(resource) {
|
|
56
56
|
const valid = resourceDeleteAssignmentSchema(resource);
|
|
57
57
|
if (!valid) {
|
|
58
|
-
const errorMessage = this.formatValidationErrors(
|
|
58
|
+
const errorMessage = this.formatValidationErrors(resourceDeleteAssignmentSchema.errors);
|
|
59
59
|
throw new ArgumentError(errorMessage
|
|
60
60
|
? `Invalid resource attribute assignment: ${errorMessage}`
|
|
61
61
|
: 'Invalid resource attribute assignment');
|
|
@@ -79,7 +79,7 @@ class ValidationUtils {
|
|
|
79
79
|
* Formats AJV validation errors into a readable error message
|
|
80
80
|
*/
|
|
81
81
|
static formatValidationErrors(errors) {
|
|
82
|
-
if (!errors || errors.length
|
|
82
|
+
if (!errors || !errors.length) {
|
|
83
83
|
return '';
|
|
84
84
|
}
|
|
85
85
|
return errors
|
package/dist/index.d.ts
CHANGED
|
@@ -29,6 +29,6 @@ export { AuthorizationObject, Resource, BaseRequest, ResourceGetter, ContextGett
|
|
|
29
29
|
export { Translation, ScopedAction, ScopedActionResponseObject, ScopedActionPermit, } from './types/scoped-actions-contracts';
|
|
30
30
|
export { CustomRole, BasicRole, RoleType, RoleCreateRequest, RoleUpdateRequest, RolesResponse } from './types/roles';
|
|
31
31
|
export { AttributeAssignment, AttributeOperation, ResourceAttributeDeleteAssignment, ResourceAttributeUpsertOperation, ResourceAttributeDeleteOperation, EntityAttributeDeleteAssignment, EntityAttributeUpsertOperation, EntityAttributeDeleteOperation, ResourceAttributeAssignment as ResourceAttributeAssignmentContract, EntityAttributeAssignment as EntityAttributeAssignmentContract, } from './types/authorization-attributes-contracts';
|
|
32
|
-
export {
|
|
32
|
+
export { BaseAuthorizationAttributesService as IAuthorizationAttributesService } from './base-authorization-attributes-service';
|
|
33
33
|
export { TestKit };
|
|
34
34
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/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;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E,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,kCAAkC,IAAI,+BAA+B,EAAE,MAAM,yCAAyC,CAAC;AAEhI,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -14,6 +14,7 @@ const rolesService = require('./roles-service.js');
|
|
|
14
14
|
const memberships = require('./memberships.js');
|
|
15
15
|
const types_roles = require('./types/roles.js');
|
|
16
16
|
const types_authorizationAttributesContracts = require('./types/authorization-attributes-contracts.js');
|
|
17
|
+
const baseAuthorizationAttributesService = require('./base-authorization-attributes-service.js');
|
|
17
18
|
|
|
18
19
|
async function init(options = {}) {
|
|
19
20
|
if (options.prometheus) {
|
|
@@ -72,4 +73,5 @@ Object.defineProperty(exports, 'AttributeOperation', {
|
|
|
72
73
|
enumerable: true,
|
|
73
74
|
get: () => types_authorizationAttributesContracts.AttributeOperation
|
|
74
75
|
});
|
|
76
|
+
exports.IAuthorizationAttributesService = baseAuthorizationAttributesService.BaseAuthorizationAttributesService;
|
|
75
77
|
exports.init = init;
|
|
@@ -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;
|
|
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,18 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
|
|
3
3
|
const baseAttributeAssignment = require('./base-attribute-assignment.js');
|
|
4
|
+
const utils_validation = require('./utils/validation.js');
|
|
4
5
|
|
|
5
6
|
class ResourceAttributeAssignment extends baseAttributeAssignment.BaseAttributeAssignment {
|
|
6
7
|
resourceId;
|
|
7
8
|
resourceType;
|
|
8
9
|
constructor(resourceId, resourceType, attributeKey, attributeValue) {
|
|
10
|
+
utils_validation.ValidationUtils.validatUpsertResourceAssignment({
|
|
11
|
+
resourceId,
|
|
12
|
+
resourceType,
|
|
13
|
+
key: attributeKey,
|
|
14
|
+
value: attributeValue,
|
|
15
|
+
});
|
|
9
16
|
super(resourceId, resourceType, attributeKey, attributeValue);
|
|
10
17
|
this.resourceId = resourceId;
|
|
11
18
|
this.resourceType = this.type;
|
|
@@ -20,7 +20,8 @@ export declare enum ResourceType {
|
|
|
20
20
|
Overview = "overview",
|
|
21
21
|
Document = "document",
|
|
22
22
|
Crm = "crm",
|
|
23
|
-
Feature = "feature"
|
|
23
|
+
Feature = "feature",
|
|
24
|
+
POST = "post"
|
|
24
25
|
}
|
|
25
26
|
export declare const RESOURCE_TYPES: readonly ResourceType[];
|
|
26
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;;;;;;;;;;;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;
|
|
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"}
|
|
@@ -24,6 +24,7 @@ exports.ResourceType = void 0;
|
|
|
24
24
|
ResourceType["Document"] = "document";
|
|
25
25
|
ResourceType["Crm"] = "crm";
|
|
26
26
|
ResourceType["Feature"] = "feature";
|
|
27
|
+
ResourceType["POST"] = "post";
|
|
27
28
|
})(exports.ResourceType || (exports.ResourceType = {}));
|
|
28
29
|
// Define the array of strings and use 'as const' to make its contents literal types
|
|
29
30
|
const RESOURCE_TYPES = Object.freeze(Object.values(exports.ResourceType));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assignment-schema.d.ts","sourceRoot":"","sources":["../../src/utils/assignment-schema.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"assignment-schema.d.ts","sourceRoot":"","sources":["../../src/utils/assignment-schema.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;EAWvC,CAAC;AAEH,eAAO,MAAM,4BAA4B;;;;;;;;;;EAUvC,CAAC;AAEH,eAAO,MAAM,8BAA8B;;;;;;;;;;EAUzC,CAAC;AAEH,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;EAWzC,CAAC"}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
3
3
|
const Ajv = require('ajv');
|
|
4
4
|
const entityAttributesConstants = require('../entity-attributes-constants.js');
|
|
5
5
|
const resourceAttributesConstants = require('../resource-attributes-constants.js');
|
|
6
|
+
const types_authorizationAttributesContracts = require('../types/authorization-attributes-contracts.js');
|
|
6
7
|
|
|
7
8
|
const _interopDefault = e => e && e.__esModule ? e : { default: e };
|
|
8
9
|
|
|
@@ -16,6 +17,7 @@ const entityUpsertAssignmentSchema = ajv.compile({
|
|
|
16
17
|
entityType: { type: 'string', enum: Object.values(entityAttributesConstants.EntityType) },
|
|
17
18
|
key: { type: 'string', minLength: 1 },
|
|
18
19
|
value: { type: 'string', minLength: 1 },
|
|
20
|
+
operationType: { type: 'string', enum: Object.values(types_authorizationAttributesContracts.AttributeOperation) },
|
|
19
21
|
},
|
|
20
22
|
required: ['entityId', 'entityType', 'key', 'value'],
|
|
21
23
|
additionalProperties: false,
|
|
@@ -26,6 +28,7 @@ const entityDeleteAssignmentSchema = ajv.compile({
|
|
|
26
28
|
entityId: { type: 'number', multipleOf: 1 },
|
|
27
29
|
entityType: { type: 'string', enum: Object.values(entityAttributesConstants.EntityType) },
|
|
28
30
|
key: { type: 'string', minLength: 1 },
|
|
31
|
+
operationType: { type: 'string', enum: Object.values(types_authorizationAttributesContracts.AttributeOperation) },
|
|
29
32
|
},
|
|
30
33
|
required: ['entityId', 'entityType', 'key'],
|
|
31
34
|
additionalProperties: false,
|
|
@@ -36,6 +39,7 @@ const resourceDeleteAssignmentSchema = ajv.compile({
|
|
|
36
39
|
resourceId: { type: 'number', multipleOf: 1 },
|
|
37
40
|
resourceType: { type: 'string', enum: Object.values(resourceAttributesConstants.ResourceType) },
|
|
38
41
|
key: { type: 'string', minLength: 1 },
|
|
42
|
+
operationType: { type: 'string', enum: Object.values(types_authorizationAttributesContracts.AttributeOperation) },
|
|
39
43
|
},
|
|
40
44
|
required: ['resourceId', 'resourceType', 'key'],
|
|
41
45
|
additionalProperties: false,
|
|
@@ -47,6 +51,7 @@ const resourceUpsertAssignmentSchema = ajv.compile({
|
|
|
47
51
|
resourceType: { type: 'string', enum: Object.values(resourceAttributesConstants.ResourceType) },
|
|
48
52
|
key: { type: 'string', minLength: 1 },
|
|
49
53
|
value: { type: 'string', minLength: 1 },
|
|
54
|
+
operationType: { type: 'string', enum: Object.values(types_authorizationAttributesContracts.AttributeOperation) },
|
|
50
55
|
},
|
|
51
56
|
required: ['resourceId', 'resourceType', 'key', 'value'],
|
|
52
57
|
additionalProperties: false,
|
package/dist/utils/validation.js
CHANGED
|
@@ -61,7 +61,7 @@ class ValidationUtils {
|
|
|
61
61
|
static validatDeleteResourceAssignment(resource) {
|
|
62
62
|
const valid = utils_assignmentSchema.resourceDeleteAssignmentSchema(resource);
|
|
63
63
|
if (!valid) {
|
|
64
|
-
const errorMessage = this.formatValidationErrors(utils_assignmentSchema.
|
|
64
|
+
const errorMessage = this.formatValidationErrors(utils_assignmentSchema.resourceDeleteAssignmentSchema.errors);
|
|
65
65
|
throw new errors_argumentError.ArgumentError(errorMessage
|
|
66
66
|
? `Invalid resource attribute assignment: ${errorMessage}`
|
|
67
67
|
: 'Invalid resource attribute assignment');
|
|
@@ -85,7 +85,7 @@ class ValidationUtils {
|
|
|
85
85
|
* Formats AJV validation errors into a readable error message
|
|
86
86
|
*/
|
|
87
87
|
static formatValidationErrors(errors) {
|
|
88
|
-
if (!errors || errors.length
|
|
88
|
+
if (!errors || !errors.length) {
|
|
89
89
|
return '';
|
|
90
90
|
}
|
|
91
91
|
return errors
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mondaydotcomorg/monday-authorization",
|
|
3
|
-
"version": "3.6.0-feat-shaime-support-entity-attributes-3-
|
|
3
|
+
"version": "3.6.0-feat-shaime-support-entity-attributes-3-02be333",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"license": "BSD-3-Clause",
|