@mondaydotcomorg/monday-authorization 3.6.0-feat-shaime-support-entity-attributes-1-f58d933 → 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 -171
- 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 -167
- 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 -222
- 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
package/src/utils/validation.ts
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
|
-
import Ajv, { ValidateFunction } from 'ajv';
|
|
1
|
+
import Ajv, { ValidateFunction, ErrorObject } from 'ajv';
|
|
2
2
|
import { ArgumentError } from '../errors/argument-error';
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import {
|
|
4
|
+
ResourceAttributeAssignment,
|
|
5
|
+
EntityAttributeAssignment,
|
|
6
|
+
ResourceAttributeDeleteAssignment,
|
|
7
|
+
EntityAttributeDeleteAssignment,
|
|
8
|
+
} from '../types/authorization-attributes-contracts';
|
|
9
|
+
import { Resource } from '../types/general';
|
|
10
|
+
import {
|
|
11
|
+
entityUpsertAssignmentSchema,
|
|
12
|
+
resourceUpsertAssignmentSchema,
|
|
13
|
+
entityDeleteAssignmentSchema,
|
|
14
|
+
resourceDeleteAssignmentSchema,
|
|
15
|
+
} from './assignment-schema';
|
|
16
|
+
import { resourceSchema } from './resource-schema';
|
|
5
17
|
|
|
6
18
|
/**
|
|
7
19
|
* Utility class for common validation operations using AJV
|
|
@@ -37,27 +49,76 @@ export class ValidationUtils {
|
|
|
37
49
|
}
|
|
38
50
|
}
|
|
39
51
|
|
|
52
|
+
public static validateResource(resource: Resource) {
|
|
53
|
+
const isValid = resourceSchema(resource);
|
|
54
|
+
if (!isValid) {
|
|
55
|
+
const errorMessage = this.formatValidationErrors(resourceSchema.errors);
|
|
56
|
+
throw new ArgumentError(errorMessage ? `Invalid resource: ${errorMessage}` : 'Invalid resource');
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
40
60
|
/**
|
|
41
61
|
* Validates an attribute assignment object using a single AJV schema.
|
|
42
62
|
* Preserves legacy error messages for each field.
|
|
43
63
|
*/
|
|
44
|
-
static
|
|
45
|
-
const valid =
|
|
64
|
+
static validatUpsertResourceAssignment(resource: ResourceAttributeAssignment): void {
|
|
65
|
+
const valid = resourceUpsertAssignmentSchema(resource);
|
|
66
|
+
if (!valid) {
|
|
67
|
+
const errorMessage = this.formatValidationErrors(resourceUpsertAssignmentSchema.errors);
|
|
68
|
+
throw new ArgumentError(
|
|
69
|
+
errorMessage
|
|
70
|
+
? `Invalid resource attribute assignment: ${errorMessage}`
|
|
71
|
+
: 'Invalid resource attribute assignment'
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
static validatDeleteResourceAssignment(resource: ResourceAttributeDeleteAssignment): void {
|
|
77
|
+
const valid = resourceDeleteAssignmentSchema(resource);
|
|
78
|
+
if (!valid) {
|
|
79
|
+
const errorMessage = this.formatValidationErrors(resourceUpsertAssignmentSchema.errors);
|
|
80
|
+
throw new ArgumentError(
|
|
81
|
+
errorMessage
|
|
82
|
+
? `Invalid resource attribute assignment: ${errorMessage}`
|
|
83
|
+
: 'Invalid resource attribute assignment'
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
static validatUpsertEntityAssignment(entity: EntityAttributeAssignment): void {
|
|
89
|
+
const valid = entityUpsertAssignmentSchema(entity);
|
|
46
90
|
if (!valid) {
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
91
|
+
const errorMessage = this.formatValidationErrors(entityUpsertAssignmentSchema.errors);
|
|
92
|
+
throw new ArgumentError(
|
|
93
|
+
errorMessage ? `Invalid entity attribute assignment: ${errorMessage}` : 'Invalid entity attribute assignment'
|
|
94
|
+
);
|
|
51
95
|
}
|
|
52
96
|
}
|
|
53
97
|
|
|
54
|
-
static
|
|
55
|
-
const valid =
|
|
98
|
+
static validatDeleteEntityAssignment(entity: EntityAttributeDeleteAssignment): void {
|
|
99
|
+
const valid = entityDeleteAssignmentSchema(entity);
|
|
56
100
|
if (!valid) {
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
101
|
+
const errorMessage = this.formatValidationErrors(entityDeleteAssignmentSchema.errors);
|
|
102
|
+
throw new ArgumentError(
|
|
103
|
+
errorMessage ? `Invalid entity attribute assignment: ${errorMessage}` : 'Invalid entity attribute assignment'
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Formats AJV validation errors into a readable error message
|
|
109
|
+
*/
|
|
110
|
+
private static formatValidationErrors(errors: ErrorObject[] | null | undefined): string {
|
|
111
|
+
if (!errors || errors.length === 0) {
|
|
112
|
+
return '';
|
|
61
113
|
}
|
|
114
|
+
|
|
115
|
+
return errors
|
|
116
|
+
.map(err => {
|
|
117
|
+
const path =
|
|
118
|
+
err.instancePath || (err.params && 'missingProperty' in err.params ? `/${err.params.missingProperty}` : '');
|
|
119
|
+
const message = err.message || 'validation failed';
|
|
120
|
+
return path ? `${path}: ${message}` : message;
|
|
121
|
+
})
|
|
122
|
+
.join('; ');
|
|
62
123
|
}
|
|
63
124
|
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export declare const entityAssignmentSchema: import("ajv").ValidateFunction<{
|
|
2
|
-
entityId: any;
|
|
3
|
-
entityType: any;
|
|
4
|
-
attributeKey: any;
|
|
5
|
-
attributeValue: any;
|
|
6
|
-
} & {
|
|
7
|
-
entityId: any;
|
|
8
|
-
} & {
|
|
9
|
-
entityType: any;
|
|
10
|
-
} & {
|
|
11
|
-
attributeKey: any;
|
|
12
|
-
} & {
|
|
13
|
-
attributeValue: any;
|
|
14
|
-
}>;
|
|
15
|
-
export declare const resourceAssignmentSchema: import("ajv").ValidateFunction<{
|
|
16
|
-
id: any;
|
|
17
|
-
type: any;
|
|
18
|
-
attributeKey: any;
|
|
19
|
-
attributeValue: any;
|
|
20
|
-
} & {
|
|
21
|
-
id: any;
|
|
22
|
-
} & {
|
|
23
|
-
type: any;
|
|
24
|
-
} & {
|
|
25
|
-
attributeKey: any;
|
|
26
|
-
} & {
|
|
27
|
-
attributeValue: any;
|
|
28
|
-
}>;
|
|
29
|
-
//# sourceMappingURL=assigment-schema.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"assigment-schema.d.ts","sourceRoot":"","sources":["../../../src/utils/assigment-schema.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;EAUjC,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;EAUnC,CAAC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import Ajv from 'ajv';
|
|
2
|
-
import { EntityType } from '../entity-attributes-constants.mjs';
|
|
3
|
-
import { ResourceType } from '../resource-attributes-constants.mjs';
|
|
4
|
-
|
|
5
|
-
const ajv = new Ajv({ allErrors: true });
|
|
6
|
-
const entityAssignmentSchema = ajv.compile({
|
|
7
|
-
type: 'object',
|
|
8
|
-
properties: {
|
|
9
|
-
entityId: { type: 'number', multipleOf: 1 },
|
|
10
|
-
entityType: { type: 'string', enum: Object.values(EntityType) },
|
|
11
|
-
key: { type: 'string', minLength: 1 },
|
|
12
|
-
value: { type: 'string', minLength: 1 },
|
|
13
|
-
},
|
|
14
|
-
required: ['entityId', 'entityType', 'attributeKey', 'attributeValue'],
|
|
15
|
-
additionalProperties: false,
|
|
16
|
-
});
|
|
17
|
-
const resourceAssignmentSchema = ajv.compile({
|
|
18
|
-
type: 'object',
|
|
19
|
-
properties: {
|
|
20
|
-
id: { type: 'number', multipleOf: 1 },
|
|
21
|
-
type: { type: 'string', enum: Object.values(ResourceType) },
|
|
22
|
-
key: { type: 'string', minLength: 1 },
|
|
23
|
-
value: { type: 'string', minLength: 1 },
|
|
24
|
-
},
|
|
25
|
-
required: ['id', 'type', 'attributeKey', 'attributeValue'],
|
|
26
|
-
additionalProperties: false,
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
export { entityAssignmentSchema, resourceAssignmentSchema };
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export declare const entityAssignmentSchema: import("ajv").ValidateFunction<{
|
|
2
|
-
entityId: any;
|
|
3
|
-
entityType: any;
|
|
4
|
-
attributeKey: any;
|
|
5
|
-
attributeValue: any;
|
|
6
|
-
} & {
|
|
7
|
-
entityId: any;
|
|
8
|
-
} & {
|
|
9
|
-
entityType: any;
|
|
10
|
-
} & {
|
|
11
|
-
attributeKey: any;
|
|
12
|
-
} & {
|
|
13
|
-
attributeValue: any;
|
|
14
|
-
}>;
|
|
15
|
-
export declare const resourceAssignmentSchema: import("ajv").ValidateFunction<{
|
|
16
|
-
id: any;
|
|
17
|
-
type: any;
|
|
18
|
-
attributeKey: any;
|
|
19
|
-
attributeValue: any;
|
|
20
|
-
} & {
|
|
21
|
-
id: any;
|
|
22
|
-
} & {
|
|
23
|
-
type: any;
|
|
24
|
-
} & {
|
|
25
|
-
attributeKey: any;
|
|
26
|
-
} & {
|
|
27
|
-
attributeValue: any;
|
|
28
|
-
}>;
|
|
29
|
-
//# sourceMappingURL=assigment-schema.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"assigment-schema.d.ts","sourceRoot":"","sources":["../../src/utils/assigment-schema.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;EAUjC,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;EAUnC,CAAC"}
|
|
@@ -1,36 +0,0 @@
|
|
|
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 entityAssignmentSchema = 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', 'attributeKey', 'attributeValue'],
|
|
21
|
-
additionalProperties: false,
|
|
22
|
-
});
|
|
23
|
-
const resourceAssignmentSchema = ajv.compile({
|
|
24
|
-
type: 'object',
|
|
25
|
-
properties: {
|
|
26
|
-
id: { type: 'number', multipleOf: 1 },
|
|
27
|
-
type: { type: 'string', enum: Object.values(resourceAttributesConstants.ResourceType) },
|
|
28
|
-
key: { type: 'string', minLength: 1 },
|
|
29
|
-
value: { type: 'string', minLength: 1 },
|
|
30
|
-
},
|
|
31
|
-
required: ['id', 'type', 'attributeKey', 'attributeValue'],
|
|
32
|
-
additionalProperties: false,
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
exports.entityAssignmentSchema = entityAssignmentSchema;
|
|
36
|
-
exports.resourceAssignmentSchema = resourceAssignmentSchema;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import Ajv from 'ajv';
|
|
2
|
-
import { EntityType } from '../entity-attributes-constants';
|
|
3
|
-
import { ResourceType } from '../resource-attributes-constants';
|
|
4
|
-
|
|
5
|
-
const ajv = new Ajv({ allErrors: true });
|
|
6
|
-
|
|
7
|
-
export const entityAssignmentSchema = ajv.compile({
|
|
8
|
-
type: 'object',
|
|
9
|
-
properties: {
|
|
10
|
-
entityId: { type: 'number', multipleOf: 1 },
|
|
11
|
-
entityType: { type: 'string', enum: Object.values(EntityType) },
|
|
12
|
-
key: { type: 'string', minLength: 1 },
|
|
13
|
-
value: { type: 'string', minLength: 1 },
|
|
14
|
-
},
|
|
15
|
-
required: ['entityId', 'entityType', 'attributeKey', 'attributeValue'],
|
|
16
|
-
additionalProperties: false,
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
export const resourceAssignmentSchema = ajv.compile({
|
|
20
|
-
type: 'object',
|
|
21
|
-
properties: {
|
|
22
|
-
id: { type: 'number', multipleOf: 1 },
|
|
23
|
-
type: { type: 'string', enum: Object.values(ResourceType) },
|
|
24
|
-
key: { type: 'string', minLength: 1 },
|
|
25
|
-
value: { type: 'string', minLength: 1 },
|
|
26
|
-
},
|
|
27
|
-
required: ['id', 'type', 'attributeKey', 'attributeValue'],
|
|
28
|
-
additionalProperties: false,
|
|
29
|
-
});
|