@mondaydotcomorg/monday-authorization 3.6.0-feat-shaime-support-entity-attributes-1-4c8e283 → 3.6.0-feat-shaime-support-entity-attributes-3-78dca48
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 +68 -0
- package/dist/authorization-attributes-ms-service.d.ts.map +1 -0
- package/dist/authorization-attributes-ms-service.js +263 -0
- package/dist/authorization-attributes-service.d.ts +25 -47
- package/dist/authorization-attributes-service.d.ts.map +1 -1
- package/dist/authorization-attributes-service.js +32 -172
- package/dist/authorization-attributes-sns-service.d.ts +84 -0
- package/dist/authorization-attributes-sns-service.d.ts.map +1 -0
- package/dist/authorization-attributes-sns-service.js +196 -0
- package/dist/constants/sns.d.ts +12 -2
- package/dist/constants/sns.d.ts.map +1 -1
- package/dist/constants/sns.js +22 -2
- package/dist/entity-attribute-assignment.d.ts.map +1 -1
- package/dist/entity-attribute-assignment.js +0 -2
- package/dist/esm/authorization-attributes-ms-service.d.ts +68 -0
- package/dist/esm/authorization-attributes-ms-service.d.ts.map +1 -0
- package/dist/esm/authorization-attributes-ms-service.mjs +261 -0
- package/dist/esm/authorization-attributes-service.d.ts +25 -47
- package/dist/esm/authorization-attributes-service.d.ts.map +1 -1
- package/dist/esm/authorization-attributes-service.mjs +32 -168
- package/dist/esm/authorization-attributes-sns-service.d.ts +84 -0
- package/dist/esm/authorization-attributes-sns-service.d.ts.map +1 -0
- package/dist/esm/authorization-attributes-sns-service.mjs +190 -0
- package/dist/esm/constants/sns.d.ts +12 -2
- package/dist/esm/constants/sns.d.ts.map +1 -1
- package/dist/esm/constants/sns.mjs +17 -3
- package/dist/esm/entity-attribute-assignment.d.ts.map +1 -1
- package/dist/esm/entity-attribute-assignment.mjs +0 -2
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.mjs +2 -0
- package/dist/esm/resource-attribute-assignment.d.ts.map +1 -1
- package/dist/esm/resource-attribute-assignment.mjs +0 -2
- 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/types/authorization-attributes-contracts.d.ts +2 -0
- package/dist/esm/types/authorization-attributes-contracts.d.ts.map +1 -1
- package/dist/esm/types/authorization-attributes-service.interface.d.ts +14 -25
- package/dist/esm/types/authorization-attributes-service.interface.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 +49 -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 -3
- package/dist/esm/utils/validation.d.ts.map +1 -1
- package/dist/esm/utils/validation.mjs +50 -13
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -0
- package/dist/resource-attribute-assignment.d.ts.map +1 -1
- package/dist/resource-attribute-assignment.js +0 -2
- 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/types/authorization-attributes-contracts.d.ts +2 -0
- package/dist/types/authorization-attributes-contracts.d.ts.map +1 -1
- package/dist/types/authorization-attributes-service.interface.d.ts +14 -25
- package/dist/types/authorization-attributes-service.interface.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 +58 -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 -3
- package/dist/utils/validation.d.ts.map +1 -1
- package/dist/utils/validation.js +50 -13
- package/package.json +1 -1
- package/src/authorization-attributes-ms-service.ts +397 -0
- package/src/authorization-attributes-service.ts +34 -223
- package/src/authorization-attributes-sns-service.ts +321 -0
- package/src/constants/sns.ts +19 -2
- package/src/entity-attribute-assignment.ts +0 -2
- package/src/index.ts +2 -0
- package/src/resource-attribute-assignment.ts +0 -2
- package/src/resource-attributes-constants.ts +1 -0
- package/src/types/authorization-attributes-contracts.ts +2 -0
- package/src/types/authorization-attributes-service.interface.ts +19 -31
- package/src/types/general.ts +4 -3
- package/src/utils/assignment-schema.ts +51 -0
- package/src/utils/resource-schema.ts +16 -0
- package/src/utils/validation.ts +76 -15
- package/dist/esm/utils/assigment-schema.d.ts +0 -29
- package/dist/esm/utils/assigment-schema.d.ts.map +0 -1
- package/dist/esm/utils/assigment-schema.mjs +0 -29
- package/dist/utils/assigment-schema.d.ts +0 -29
- package/dist/utils/assigment-schema.d.ts.map +0 -1
- package/dist/utils/assigment-schema.js +0 -36
- package/src/utils/assigment-schema.ts +0 -29
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Ajv from 'ajv';
|
|
2
2
|
import { ArgumentError } from '../errors/argument-error.mjs';
|
|
3
|
-
import {
|
|
3
|
+
import { resourceUpsertAssignmentSchema, resourceDeleteAssignmentSchema, entityUpsertAssignmentSchema, entityDeleteAssignmentSchema } from './assignment-schema.mjs';
|
|
4
|
+
import { resourceSchema } from './resource-schema.mjs';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Utility class for common validation operations using AJV
|
|
@@ -31,27 +32,63 @@ class ValidationUtils {
|
|
|
31
32
|
throw new ArgumentError('Invalid string array');
|
|
32
33
|
}
|
|
33
34
|
}
|
|
35
|
+
static validateResource(resource) {
|
|
36
|
+
const isValid = resourceSchema(resource);
|
|
37
|
+
if (!isValid) {
|
|
38
|
+
const errorMessage = this.formatValidationErrors(resourceSchema.errors);
|
|
39
|
+
throw new ArgumentError(errorMessage ? `Invalid resource: ${errorMessage}` : 'Invalid resource');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
34
42
|
/**
|
|
35
43
|
* Validates an attribute assignment object using a single AJV schema.
|
|
36
44
|
* Preserves legacy error messages for each field.
|
|
37
45
|
*/
|
|
38
|
-
static
|
|
39
|
-
const valid =
|
|
46
|
+
static validatUpsertResourceAssignment(resource) {
|
|
47
|
+
const valid = resourceUpsertAssignmentSchema(resource);
|
|
48
|
+
if (!valid) {
|
|
49
|
+
const errorMessage = this.formatValidationErrors(resourceUpsertAssignmentSchema.errors);
|
|
50
|
+
throw new ArgumentError(errorMessage
|
|
51
|
+
? `Invalid resource attribute assignment: ${errorMessage}`
|
|
52
|
+
: 'Invalid resource attribute assignment');
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
static validatDeleteResourceAssignment(resource) {
|
|
56
|
+
const valid = resourceDeleteAssignmentSchema(resource);
|
|
57
|
+
if (!valid) {
|
|
58
|
+
const errorMessage = this.formatValidationErrors(resourceUpsertAssignmentSchema.errors);
|
|
59
|
+
throw new ArgumentError(errorMessage
|
|
60
|
+
? `Invalid resource attribute assignment: ${errorMessage}`
|
|
61
|
+
: 'Invalid resource attribute assignment');
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
static validatUpsertEntityAssignment(entity) {
|
|
65
|
+
const valid = entityUpsertAssignmentSchema(entity);
|
|
40
66
|
if (!valid) {
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
.join(', ');
|
|
44
|
-
throw new ArgumentError(`Invalid resource attribute assignment: ${errorMessages}`);
|
|
67
|
+
const errorMessage = this.formatValidationErrors(entityUpsertAssignmentSchema.errors);
|
|
68
|
+
throw new ArgumentError(errorMessage ? `Invalid entity attribute assignment: ${errorMessage}` : 'Invalid entity attribute assignment');
|
|
45
69
|
}
|
|
46
70
|
}
|
|
47
|
-
static
|
|
48
|
-
const valid =
|
|
71
|
+
static validatDeleteEntityAssignment(entity) {
|
|
72
|
+
const valid = entityDeleteAssignmentSchema(entity);
|
|
49
73
|
if (!valid) {
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
74
|
+
const errorMessage = this.formatValidationErrors(entityDeleteAssignmentSchema.errors);
|
|
75
|
+
throw new ArgumentError(errorMessage ? `Invalid entity attribute assignment: ${errorMessage}` : 'Invalid entity attribute assignment');
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Formats AJV validation errors into a readable error message
|
|
80
|
+
*/
|
|
81
|
+
static formatValidationErrors(errors) {
|
|
82
|
+
if (!errors || errors.length === 0) {
|
|
83
|
+
return '';
|
|
54
84
|
}
|
|
85
|
+
return errors
|
|
86
|
+
.map(err => {
|
|
87
|
+
const path = err.instancePath || (err.params && 'missingProperty' in err.params ? `/${err.params.missingProperty}` : '');
|
|
88
|
+
const message = err.message || 'validation failed';
|
|
89
|
+
return path ? `${path}: ${message}` : message;
|
|
90
|
+
})
|
|
91
|
+
.join('; ');
|
|
55
92
|
}
|
|
56
93
|
}
|
|
57
94
|
|
package/dist/index.d.ts
CHANGED
|
@@ -19,6 +19,8 @@ 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';
|
|
22
24
|
export { RolesService } from './roles-service';
|
|
23
25
|
export { MembershipsService } from './memberships';
|
|
24
26
|
export { AuthorizationObject, Resource, BaseRequest, ResourceGetter, ContextGetter } from './types/general';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
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,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"}
|
package/dist/index.js
CHANGED
|
@@ -6,6 +6,8 @@ const metricsService = require('./metrics-service.js');
|
|
|
6
6
|
const testKit_index = require('./testKit/index.js');
|
|
7
7
|
const authorizationMiddleware = require('./authorization-middleware.js');
|
|
8
8
|
const authorizationAttributesService = require('./authorization-attributes-service.js');
|
|
9
|
+
const resourceAttributesConstants = require('./resource-attributes-constants.js');
|
|
10
|
+
const entityAttributesConstants = require('./entity-attributes-constants.js');
|
|
9
11
|
const rolesService = require('./roles-service.js');
|
|
10
12
|
const memberships = require('./memberships.js');
|
|
11
13
|
const types_roles = require('./types/roles.js');
|
|
@@ -44,6 +46,17 @@ exports.authorizationCheckMiddleware = authorizationMiddleware.authorizationChec
|
|
|
44
46
|
exports.getAuthorizationMiddleware = authorizationMiddleware.getAuthorizationMiddleware;
|
|
45
47
|
exports.skipAuthorizationMiddleware = authorizationMiddleware.skipAuthorizationMiddleware;
|
|
46
48
|
exports.AuthorizationAttributesService = authorizationAttributesService.AuthorizationAttributesService;
|
|
49
|
+
exports.RESOURCE_ATTRIBUTES_CONSTANTS = resourceAttributesConstants.RESOURCE_ATTRIBUTES_CONSTANTS;
|
|
50
|
+
exports.RESOURCE_TYPES = resourceAttributesConstants.RESOURCE_TYPES;
|
|
51
|
+
Object.defineProperty(exports, 'ResourceType', {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
get: () => resourceAttributesConstants.ResourceType
|
|
54
|
+
});
|
|
55
|
+
exports.ENTITY_TYPES = entityAttributesConstants.ENTITY_TYPES;
|
|
56
|
+
Object.defineProperty(exports, 'EntityType', {
|
|
57
|
+
enumerable: true,
|
|
58
|
+
get: () => entityAttributesConstants.EntityType
|
|
59
|
+
});
|
|
47
60
|
exports.RolesService = rolesService.RolesService;
|
|
48
61
|
exports.MembershipsService = memberships.MembershipsService;
|
|
49
62
|
Object.defineProperty(exports, 'RoleType', {
|
|
@@ -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;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,13 +1,11 @@
|
|
|
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');
|
|
5
4
|
|
|
6
5
|
class ResourceAttributeAssignment extends baseAttributeAssignment.BaseAttributeAssignment {
|
|
7
6
|
resourceId;
|
|
8
7
|
resourceType;
|
|
9
8
|
constructor(resourceId, resourceType, attributeKey, attributeValue) {
|
|
10
|
-
utils_validation.ValidationUtils.validateResourceAssignment({ resourceId, resourceType, key: attributeKey, value: attributeValue });
|
|
11
9
|
super(resourceId, resourceType, attributeKey, attributeValue);
|
|
12
10
|
this.resourceId = resourceId;
|
|
13
11
|
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;
|
|
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"}
|
|
@@ -23,6 +23,7 @@ exports.ResourceType = void 0;
|
|
|
23
23
|
ResourceType["Overview"] = "overview";
|
|
24
24
|
ResourceType["Document"] = "document";
|
|
25
25
|
ResourceType["Crm"] = "crm";
|
|
26
|
+
ResourceType["Feature"] = "feature";
|
|
26
27
|
})(exports.ResourceType || (exports.ResourceType = {}));
|
|
27
28
|
// Define the array of strings and use 'as const' to make its contents literal types
|
|
28
29
|
const RESOURCE_TYPES = Object.freeze(Object.values(exports.ResourceType));
|
|
@@ -9,10 +9,12 @@ export interface ResourceAttributeAssignment extends AttributeAssignment {
|
|
|
9
9
|
resourceId: number;
|
|
10
10
|
resourceType: ResourceType;
|
|
11
11
|
}
|
|
12
|
+
export type ResourceAttributeDeleteAssignment = Omit<ResourceAttributeAssignment, 'value'>;
|
|
12
13
|
export interface EntityAttributeAssignment extends AttributeAssignment {
|
|
13
14
|
entityId: number;
|
|
14
15
|
entityType: EntityType;
|
|
15
16
|
}
|
|
17
|
+
export type EntityAttributeDeleteAssignment = Omit<EntityAttributeAssignment, 'value'>;
|
|
16
18
|
export interface ResourceAttributeDelete {
|
|
17
19
|
resourceType: Resource['type'];
|
|
18
20
|
resourceId: Resource['id'];
|
|
@@ -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;
|
|
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;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;AAGvF,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,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
|
|
20
|
-
*
|
|
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:
|
|
13
|
+
deleteResourceAttributes(accountId: number, resource: Resource, attributeKey: string, appName?: string, callerActionIdentifier?: string): Promise<ResourceAttributeDeleteOperation>;
|
|
24
14
|
/**
|
|
25
|
-
* Deletes entity
|
|
26
|
-
*
|
|
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,
|
|
18
|
+
deleteEntityAttributes(accountId: number, entityType: EntityType | string, entityId: number, attributeKey: string, appName?: string, callerActionIdentifier?: string): Promise<EntityAttributeDeleteOperation>;
|
|
30
19
|
/**
|
|
31
|
-
* Updates resource
|
|
32
|
-
* For MS service:
|
|
33
|
-
* For SNS service: returns Promise<
|
|
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,
|
|
24
|
+
updateResourceAttributes(accountId: number, appName: string, callerActionIdentifier: string, resourceAttributeOperation: ResourceAttributeUpsertOperation): Promise<ResourceAttributeUpsertOperation>;
|
|
36
25
|
/**
|
|
37
|
-
* Updates entity
|
|
38
|
-
* For MS service:
|
|
39
|
-
* For SNS service: returns Promise<
|
|
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,
|
|
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
|
|
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"}
|
package/dist/types/general.d.ts
CHANGED
|
@@ -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
|
|
4
|
-
type:
|
|
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:
|
|
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;
|
|
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,W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+
} & {
|
|
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,58 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
const Ajv = require('ajv');
|
|
4
|
+
const entityAttributesConstants = require('../entity-attributes-constants.js');
|
|
5
|
+
const resourceAttributesConstants = require('../resource-attributes-constants.js');
|
|
6
|
+
|
|
7
|
+
const _interopDefault = e => e && e.__esModule ? e : { default: e };
|
|
8
|
+
|
|
9
|
+
const Ajv__default = /*#__PURE__*/_interopDefault(Ajv);
|
|
10
|
+
|
|
11
|
+
const ajv = new Ajv__default.default({ allErrors: true });
|
|
12
|
+
const entityUpsertAssignmentSchema = ajv.compile({
|
|
13
|
+
type: 'object',
|
|
14
|
+
properties: {
|
|
15
|
+
entityId: { type: 'number', multipleOf: 1 },
|
|
16
|
+
entityType: { type: 'string', enum: Object.values(entityAttributesConstants.EntityType) },
|
|
17
|
+
key: { type: 'string', minLength: 1 },
|
|
18
|
+
value: { type: 'string', minLength: 1 },
|
|
19
|
+
},
|
|
20
|
+
required: ['entityId', 'entityType', 'key', 'value'],
|
|
21
|
+
additionalProperties: false,
|
|
22
|
+
});
|
|
23
|
+
const entityDeleteAssignmentSchema = ajv.compile({
|
|
24
|
+
type: 'object',
|
|
25
|
+
properties: {
|
|
26
|
+
entityId: { type: 'number', multipleOf: 1 },
|
|
27
|
+
entityType: { type: 'string', enum: Object.values(entityAttributesConstants.EntityType) },
|
|
28
|
+
key: { type: 'string', minLength: 1 },
|
|
29
|
+
},
|
|
30
|
+
required: ['entityId', 'entityType', 'key'],
|
|
31
|
+
additionalProperties: false,
|
|
32
|
+
});
|
|
33
|
+
const resourceDeleteAssignmentSchema = ajv.compile({
|
|
34
|
+
type: 'object',
|
|
35
|
+
properties: {
|
|
36
|
+
resourceId: { type: 'number', multipleOf: 1 },
|
|
37
|
+
resourceType: { type: 'string', enum: Object.values(resourceAttributesConstants.ResourceType) },
|
|
38
|
+
key: { type: 'string', minLength: 1 },
|
|
39
|
+
},
|
|
40
|
+
required: ['id', 'type', 'key'],
|
|
41
|
+
additionalProperties: false,
|
|
42
|
+
});
|
|
43
|
+
const resourceUpsertAssignmentSchema = ajv.compile({
|
|
44
|
+
type: 'object',
|
|
45
|
+
properties: {
|
|
46
|
+
resourceId: { type: 'number', multipleOf: 1 },
|
|
47
|
+
resourceType: { type: 'string', enum: Object.values(resourceAttributesConstants.ResourceType) },
|
|
48
|
+
key: { type: 'string', minLength: 1 },
|
|
49
|
+
value: { type: 'string', minLength: 1 },
|
|
50
|
+
},
|
|
51
|
+
required: ['resourceId', 'resourceType', 'key', 'value'],
|
|
52
|
+
additionalProperties: false,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
exports.entityDeleteAssignmentSchema = entityDeleteAssignmentSchema;
|
|
56
|
+
exports.entityUpsertAssignmentSchema = entityUpsertAssignmentSchema;
|
|
57
|
+
exports.resourceDeleteAssignmentSchema = resourceDeleteAssignmentSchema;
|
|
58
|
+
exports.resourceUpsertAssignmentSchema = resourceUpsertAssignmentSchema;
|
|
@@ -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,22 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
const Ajv = require('ajv');
|
|
4
|
+
const resourceAttributesConstants = require('../resource-attributes-constants.js');
|
|
5
|
+
|
|
6
|
+
const _interopDefault = e => e && e.__esModule ? e : { default: e };
|
|
7
|
+
|
|
8
|
+
const Ajv__default = /*#__PURE__*/_interopDefault(Ajv);
|
|
9
|
+
|
|
10
|
+
const ajv = new Ajv__default.default({ allErrors: true });
|
|
11
|
+
const resourceSchema = ajv.compile({
|
|
12
|
+
type: 'object',
|
|
13
|
+
properties: {
|
|
14
|
+
id: { type: 'number', multipleOf: 1 },
|
|
15
|
+
type: { type: 'string', enum: resourceAttributesConstants.RESOURCE_TYPES },
|
|
16
|
+
wrapperData: { type: 'object' },
|
|
17
|
+
},
|
|
18
|
+
required: ['id', 'type'],
|
|
19
|
+
additionalProperties: false,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
exports.resourceSchema = resourceSchema;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ResourceAttributeAssignment, EntityAttributeAssignment } from '../types/authorization-attributes-contracts';
|
|
1
|
+
import { ResourceAttributeAssignment, EntityAttributeAssignment, ResourceAttributeDeleteAssignment, EntityAttributeDeleteAssignment } from '../types/authorization-attributes-contracts';
|
|
2
|
+
import { Resource } from '../types/general';
|
|
2
3
|
/**
|
|
3
4
|
* Utility class for common validation operations using AJV
|
|
4
5
|
*/
|
|
@@ -10,11 +11,18 @@ export declare class ValidationUtils {
|
|
|
10
11
|
static validateInteger(value: number): void;
|
|
11
12
|
static validateString(value: string): void;
|
|
12
13
|
static validateStringArray(value: string[]): void;
|
|
14
|
+
static validateResource(resource: Resource): void;
|
|
13
15
|
/**
|
|
14
16
|
* Validates an attribute assignment object using a single AJV schema.
|
|
15
17
|
* Preserves legacy error messages for each field.
|
|
16
18
|
*/
|
|
17
|
-
static
|
|
18
|
-
static
|
|
19
|
+
static validatUpsertResourceAssignment(resource: ResourceAttributeAssignment): void;
|
|
20
|
+
static validatDeleteResourceAssignment(resource: ResourceAttributeDeleteAssignment): void;
|
|
21
|
+
static validatUpsertEntityAssignment(entity: EntityAttributeAssignment): void;
|
|
22
|
+
static validatDeleteEntityAssignment(entity: EntityAttributeDeleteAssignment): void;
|
|
23
|
+
/**
|
|
24
|
+
* Formats AJV validation errors into a readable error message
|
|
25
|
+
*/
|
|
26
|
+
private static formatValidationErrors;
|
|
19
27
|
}
|
|
20
28
|
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,2BAA2B,EAC3B,yBAAyB,EACzB,iCAAiC,EACjC,+BAA+B,EAChC,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAS5C;;GAEG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAC,GAAG,CAAgC;IAElD,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAyE;IACxG,OAAO,CAAC,MAAM,CAAC,eAAe,CAAwE;IACtG,OAAO,CAAC,MAAM,CAAC,oBAAoB,CAGhC;WAEW,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;WAOpC,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;WAOnC,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI;WAO1C,gBAAgB,CAAC,QAAQ,EAAE,QAAQ;IAQjD;;;OAGG;IACH,MAAM,CAAC,+BAA+B,CAAC,QAAQ,EAAE,2BAA2B,GAAG,IAAI;IAYnF,MAAM,CAAC,+BAA+B,CAAC,QAAQ,EAAE,iCAAiC,GAAG,IAAI;IAYzF,MAAM,CAAC,6BAA6B,CAAC,MAAM,EAAE,yBAAyB,GAAG,IAAI;IAU7E,MAAM,CAAC,6BAA6B,CAAC,MAAM,EAAE,+BAA+B,GAAG,IAAI;IASnF;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,sBAAsB;CActC"}
|
package/dist/utils/validation.js
CHANGED
|
@@ -2,7 +2,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2
2
|
|
|
3
3
|
const Ajv = require('ajv');
|
|
4
4
|
const errors_argumentError = require('../errors/argument-error.js');
|
|
5
|
-
const
|
|
5
|
+
const utils_assignmentSchema = require('./assignment-schema.js');
|
|
6
|
+
const utils_resourceSchema = require('./resource-schema.js');
|
|
6
7
|
|
|
7
8
|
const _interopDefault = e => e && e.__esModule ? e : { default: e };
|
|
8
9
|
|
|
@@ -37,27 +38,63 @@ class ValidationUtils {
|
|
|
37
38
|
throw new errors_argumentError.ArgumentError('Invalid string array');
|
|
38
39
|
}
|
|
39
40
|
}
|
|
41
|
+
static validateResource(resource) {
|
|
42
|
+
const isValid = utils_resourceSchema.resourceSchema(resource);
|
|
43
|
+
if (!isValid) {
|
|
44
|
+
const errorMessage = this.formatValidationErrors(utils_resourceSchema.resourceSchema.errors);
|
|
45
|
+
throw new errors_argumentError.ArgumentError(errorMessage ? `Invalid resource: ${errorMessage}` : 'Invalid resource');
|
|
46
|
+
}
|
|
47
|
+
}
|
|
40
48
|
/**
|
|
41
49
|
* Validates an attribute assignment object using a single AJV schema.
|
|
42
50
|
* Preserves legacy error messages for each field.
|
|
43
51
|
*/
|
|
44
|
-
static
|
|
45
|
-
const valid =
|
|
52
|
+
static validatUpsertResourceAssignment(resource) {
|
|
53
|
+
const valid = utils_assignmentSchema.resourceUpsertAssignmentSchema(resource);
|
|
54
|
+
if (!valid) {
|
|
55
|
+
const errorMessage = this.formatValidationErrors(utils_assignmentSchema.resourceUpsertAssignmentSchema.errors);
|
|
56
|
+
throw new errors_argumentError.ArgumentError(errorMessage
|
|
57
|
+
? `Invalid resource attribute assignment: ${errorMessage}`
|
|
58
|
+
: 'Invalid resource attribute assignment');
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
static validatDeleteResourceAssignment(resource) {
|
|
62
|
+
const valid = utils_assignmentSchema.resourceDeleteAssignmentSchema(resource);
|
|
63
|
+
if (!valid) {
|
|
64
|
+
const errorMessage = this.formatValidationErrors(utils_assignmentSchema.resourceUpsertAssignmentSchema.errors);
|
|
65
|
+
throw new errors_argumentError.ArgumentError(errorMessage
|
|
66
|
+
? `Invalid resource attribute assignment: ${errorMessage}`
|
|
67
|
+
: 'Invalid resource attribute assignment');
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
static validatUpsertEntityAssignment(entity) {
|
|
71
|
+
const valid = utils_assignmentSchema.entityUpsertAssignmentSchema(entity);
|
|
46
72
|
if (!valid) {
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
.join(', ');
|
|
50
|
-
throw new errors_argumentError.ArgumentError(`Invalid resource attribute assignment: ${errorMessages}`);
|
|
73
|
+
const errorMessage = this.formatValidationErrors(utils_assignmentSchema.entityUpsertAssignmentSchema.errors);
|
|
74
|
+
throw new errors_argumentError.ArgumentError(errorMessage ? `Invalid entity attribute assignment: ${errorMessage}` : 'Invalid entity attribute assignment');
|
|
51
75
|
}
|
|
52
76
|
}
|
|
53
|
-
static
|
|
54
|
-
const valid =
|
|
77
|
+
static validatDeleteEntityAssignment(entity) {
|
|
78
|
+
const valid = utils_assignmentSchema.entityDeleteAssignmentSchema(entity);
|
|
55
79
|
if (!valid) {
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
80
|
+
const errorMessage = this.formatValidationErrors(utils_assignmentSchema.entityDeleteAssignmentSchema.errors);
|
|
81
|
+
throw new errors_argumentError.ArgumentError(errorMessage ? `Invalid entity attribute assignment: ${errorMessage}` : 'Invalid entity attribute assignment');
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Formats AJV validation errors into a readable error message
|
|
86
|
+
*/
|
|
87
|
+
static formatValidationErrors(errors) {
|
|
88
|
+
if (!errors || errors.length === 0) {
|
|
89
|
+
return '';
|
|
60
90
|
}
|
|
91
|
+
return errors
|
|
92
|
+
.map(err => {
|
|
93
|
+
const path = err.instancePath || (err.params && 'missingProperty' in err.params ? `/${err.params.missingProperty}` : '');
|
|
94
|
+
const message = err.message || 'validation failed';
|
|
95
|
+
return path ? `${path}: ${message}` : message;
|
|
96
|
+
})
|
|
97
|
+
.join('; ');
|
|
61
98
|
}
|
|
62
99
|
}
|
|
63
100
|
|
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
|
+
"version": "3.6.0-feat-shaime-support-entity-attributes-3-78dca48",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"license": "BSD-3-Clause",
|