@mondaydotcomorg/monday-authorization 3.5.2-feat-shaime-support-entity-attributes-4-ddec1d3 → 3.5.2-feat-shaime-support-entity-attributes-3-6202ab7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/dist/authorization-attributes-ms-service.d.ts +1 -17
  2. package/dist/authorization-attributes-ms-service.d.ts.map +1 -1
  3. package/dist/authorization-attributes-ms-service.js +47 -58
  4. package/dist/authorization-attributes-sns-service.d.ts +2 -23
  5. package/dist/authorization-attributes-sns-service.d.ts.map +1 -1
  6. package/dist/authorization-attributes-sns-service.js +11 -49
  7. package/dist/base-attribute-assignment.d.ts +6 -7
  8. package/dist/base-attribute-assignment.d.ts.map +1 -1
  9. package/dist/base-attribute-assignment.js +5 -7
  10. package/dist/entity-attribute-assignment.d.ts +4 -8
  11. package/dist/entity-attribute-assignment.d.ts.map +1 -1
  12. package/dist/entity-attribute-assignment.js +4 -3
  13. package/dist/errors/argument-error.d.ts.map +1 -1
  14. package/dist/errors/argument-error.js +0 -1
  15. package/dist/esm/authorization-attributes-ms-service.d.ts +1 -17
  16. package/dist/esm/authorization-attributes-ms-service.d.ts.map +1 -1
  17. package/dist/esm/authorization-attributes-ms-service.mjs +47 -58
  18. package/dist/esm/authorization-attributes-sns-service.d.ts +2 -23
  19. package/dist/esm/authorization-attributes-sns-service.d.ts.map +1 -1
  20. package/dist/esm/authorization-attributes-sns-service.mjs +11 -49
  21. package/dist/esm/base-attribute-assignment.d.ts +6 -7
  22. package/dist/esm/base-attribute-assignment.d.ts.map +1 -1
  23. package/dist/esm/base-attribute-assignment.mjs +5 -7
  24. package/dist/esm/entity-attribute-assignment.d.ts +4 -8
  25. package/dist/esm/entity-attribute-assignment.d.ts.map +1 -1
  26. package/dist/esm/entity-attribute-assignment.mjs +4 -3
  27. package/dist/esm/errors/argument-error.d.ts.map +1 -1
  28. package/dist/esm/errors/argument-error.mjs +0 -1
  29. package/dist/esm/resource-attribute-assignment.d.ts +3 -7
  30. package/dist/esm/resource-attribute-assignment.d.ts.map +1 -1
  31. package/dist/esm/resource-attribute-assignment.mjs +3 -2
  32. package/dist/esm/resource-attributes-constants.d.ts +9 -9
  33. package/dist/esm/resource-attributes-constants.d.ts.map +1 -1
  34. package/dist/esm/resource-attributes-constants.mjs +2 -2
  35. package/dist/esm/testKit/index.d.ts +4 -4
  36. package/dist/esm/testKit/index.d.ts.map +1 -1
  37. package/dist/esm/types/authorization-attributes-contracts.d.ts +1 -2
  38. package/dist/esm/types/authorization-attributes-contracts.d.ts.map +1 -1
  39. package/dist/esm/types/authorization-attributes-service.interface.d.ts +2 -16
  40. package/dist/esm/types/authorization-attributes-service.interface.d.ts.map +1 -1
  41. package/dist/esm/types/general.d.ts +1 -1
  42. package/dist/esm/types/general.d.ts.map +1 -1
  43. package/dist/esm/utils/assigment-schema.d.ts +23 -0
  44. package/dist/esm/utils/assigment-schema.d.ts.map +1 -0
  45. package/dist/esm/utils/assigment-schema.mjs +29 -0
  46. package/dist/esm/utils/resource-schema.d.ts +17 -0
  47. package/dist/esm/utils/resource-schema.d.ts.map +1 -0
  48. package/dist/esm/utils/resource-schema.mjs +16 -0
  49. package/dist/esm/utils/validation.d.ts +9 -28
  50. package/dist/esm/utils/validation.d.ts.map +1 -1
  51. package/dist/esm/utils/validation.mjs +39 -121
  52. package/dist/resource-attribute-assignment.d.ts +3 -7
  53. package/dist/resource-attribute-assignment.d.ts.map +1 -1
  54. package/dist/resource-attribute-assignment.js +3 -2
  55. package/dist/resource-attributes-constants.d.ts +9 -9
  56. package/dist/resource-attributes-constants.d.ts.map +1 -1
  57. package/dist/resource-attributes-constants.js +2 -2
  58. package/dist/testKit/index.d.ts +4 -4
  59. package/dist/testKit/index.d.ts.map +1 -1
  60. package/dist/types/authorization-attributes-contracts.d.ts +1 -2
  61. package/dist/types/authorization-attributes-contracts.d.ts.map +1 -1
  62. package/dist/types/authorization-attributes-service.interface.d.ts +2 -16
  63. package/dist/types/authorization-attributes-service.interface.d.ts.map +1 -1
  64. package/dist/types/general.d.ts +1 -1
  65. package/dist/types/general.d.ts.map +1 -1
  66. package/dist/utils/assigment-schema.d.ts +23 -0
  67. package/dist/utils/assigment-schema.d.ts.map +1 -0
  68. package/dist/utils/assigment-schema.js +36 -0
  69. package/dist/utils/resource-schema.d.ts +17 -0
  70. package/dist/utils/resource-schema.d.ts.map +1 -0
  71. package/dist/utils/resource-schema.js +22 -0
  72. package/dist/utils/validation.d.ts +9 -28
  73. package/dist/utils/validation.d.ts.map +1 -1
  74. package/dist/utils/validation.js +39 -121
  75. package/package.json +1 -1
  76. package/src/authorization-attributes-ms-service.ts +93 -117
  77. package/src/authorization-attributes-sns-service.ts +14 -69
  78. package/src/base-attribute-assignment.ts +10 -26
  79. package/src/entity-attribute-assignment.ts +9 -6
  80. package/src/errors/argument-error.ts +0 -1
  81. package/src/resource-attribute-assignment.ts +10 -12
  82. package/src/resource-attributes-constants.ts +2 -2
  83. package/src/testKit/index.ts +5 -5
  84. package/src/types/authorization-attributes-contracts.ts +1 -1
  85. package/src/types/authorization-attributes-service.interface.ts +2 -33
  86. package/src/types/general.ts +1 -1
  87. package/src/utils/assigment-schema.ts +29 -0
  88. package/src/utils/resource-schema.ts +21 -0
  89. package/src/utils/validation.ts +51 -140
@@ -0,0 +1,23 @@
1
+ export declare const entityAssignmentSchema: import("ajv").ValidateFunction<{
2
+ entityId: any;
3
+ entityType: any;
4
+ key: any;
5
+ } & {
6
+ entityId: any;
7
+ } & {
8
+ entityType: any;
9
+ } & {
10
+ key: any;
11
+ }>;
12
+ export declare const resourceAssignmentSchema: import("ajv").ValidateFunction<{
13
+ id: any;
14
+ type: any;
15
+ key: any;
16
+ } & {
17
+ id: any;
18
+ } & {
19
+ type: any;
20
+ } & {
21
+ key: any;
22
+ }>;
23
+ //# sourceMappingURL=assigment-schema.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,36 @@
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' },
19
+ },
20
+ required: ['entityId', 'entityType', 'key'],
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' },
30
+ },
31
+ required: ['id', 'type', 'key'],
32
+ additionalProperties: false,
33
+ });
34
+
35
+ exports.entityAssignmentSchema = entityAssignmentSchema;
36
+ exports.resourceAssignmentSchema = resourceAssignmentSchema;
@@ -0,0 +1,17 @@
1
+ export interface Resource {
2
+ id?: number;
3
+ type: string;
4
+ wrapperData?: object;
5
+ }
6
+ export declare const resourceSchema: import("ajv").ValidateFunction<{
7
+ id: any;
8
+ type: any;
9
+ wrapperData: any;
10
+ } & {
11
+ id: any;
12
+ } & {
13
+ type: any;
14
+ } & {
15
+ wrapperData: any;
16
+ }>;
17
+ //# sourceMappingURL=resource-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource-schema.d.ts","sourceRoot":"","sources":["../../src/utils/resource-schema.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,QAAQ;IACvB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,cAAc;;;;;;;;;;EASzB,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: 'string', minLength: 1 },
17
+ },
18
+ required: ['id', 'type', 'wrapperData'],
19
+ additionalProperties: false,
20
+ });
21
+
22
+ exports.resourceSchema = resourceSchema;
@@ -1,45 +1,26 @@
1
+ import { ResourceAttributeAssignment, EntityAttributeAssignment } from '../types/authorization-attributes-contracts';
1
2
  import { Resource } from '../types/general';
2
3
  /**
3
4
  * Utility class for common validation operations using AJV
4
5
  */
5
6
  export declare class ValidationUtils {
6
7
  private static ajv;
7
- /**
8
- * Validates that a value is an integer. Throws ArgumentError with a descriptive message on failure.
9
- */
8
+ private static integerValidator;
9
+ private static stringValidator;
10
+ private static stringArrayValidator;
10
11
  static validateInteger(value: number): void;
11
- /**
12
- * Validates that a value is a non-empty string. Throws ArgumentError on failure.
13
- */
14
12
  static validateString(value: string): void;
15
- /**
16
- * Validates that a value is an array of non-empty strings. Throws ArgumentError on failure.
17
- * Allows empty arrays - caller should handle early return.
18
- */
19
13
  static validateStringArray(value: string[]): void;
14
+ static validateResource(resource: Resource): void;
20
15
  /**
21
16
  * Validates an attribute assignment object using a single AJV schema.
22
17
  * Preserves legacy error messages for each field.
23
18
  */
24
- static validateAssignment<TType extends string>(data: {
25
- id: any;
26
- type: string;
27
- attributeKey: any;
28
- attributeValue: any;
29
- }, validTypes: readonly TType[], fieldNames: {
30
- id: string;
31
- type: string;
32
- }): {
33
- id: number;
34
- type: TType;
35
- attributeKey: string;
36
- attributeValue: string;
37
- };
19
+ static validateResourceAssignment(resource: ResourceAttributeAssignment): void;
20
+ static validateEntityAssignment(entity: EntityAttributeAssignment): void;
38
21
  /**
39
- * Validates a Resource-like object shape: { id: number; type: string }.
40
- * Throws ArgumentError with legacy-compatible messages.
22
+ * Formats AJV validation errors into a readable error message
41
23
  */
42
- static validateResource(resource: Resource): void;
43
- static validateArrayTypeOf<T>(attributesMessages: T[], messageClass: abstract new (...args: any[]) => T): void;
24
+ private static formatValidationErrors;
44
25
  }
45
26
  //# sourceMappingURL=validation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C;;GAEG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAC,GAAG,CAAgC;IAClD;;OAEG;IACH,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAS3C;;OAEG;IACH,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAa1C;;;OAGG;IACH,MAAM,CAAC,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI;IAkBjD;;;OAGG;IACH,MAAM,CAAC,kBAAkB,CAAC,KAAK,SAAS,MAAM,EAC5C,IAAI,EAAE;QAAE,EAAE,EAAE,GAAG,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,GAAG,CAAC;QAAC,cAAc,EAAE,GAAG,CAAA;KAAE,EACvE,UAAU,EAAE,SAAS,KAAK,EAAE,EAC5B,UAAU,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GACvC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,KAAK,CAAC;QAAC,YAAY,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,MAAM,CAAA;KAAE;IA0D5E;;;OAGG;IACH,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAqBjD,MAAM,CAAC,mBAAmB,CAAC,CAAC,EAAE,kBAAkB,EAAE,CAAC,EAAE,EAAE,YAAY,EAAE,QAAQ,MAAM,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,IAAI;CAoB/G"}
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,2BAA2B,EAAE,yBAAyB,EAAE,MAAM,6CAA6C,CAAC;AACrH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAI5C;;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,0BAA0B,CAAC,QAAQ,EAAE,2BAA2B,GAAG,IAAI;IAY9E,MAAM,CAAC,wBAAwB,CAAC,MAAM,EAAE,yBAAyB,GAAG,IAAI;IAUxE;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,sBAAsB;CAGtC"}
@@ -2,6 +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 utils_assigmentSchema = require('./assigment-schema.js');
6
+ const utils_resourceSchema = require('./resource-schema.js');
5
7
 
6
8
  const _interopDefault = e => e && e.__esModule ? e : { default: e };
7
9
 
@@ -12,146 +14,62 @@ const Ajv__default = /*#__PURE__*/_interopDefault(Ajv);
12
14
  */
13
15
  class ValidationUtils {
14
16
  static ajv = new Ajv__default.default({ allErrors: true });
15
- /**
16
- * Validates that a value is an integer. Throws ArgumentError with a descriptive message on failure.
17
- */
17
+ static integerValidator = this.ajv.compile({ type: 'number', multipleOf: 1 });
18
+ static stringValidator = this.ajv.compile({ type: 'string', minLength: 1 });
19
+ static stringArrayValidator = this.ajv.compile({
20
+ type: 'array',
21
+ items: { type: 'string' },
22
+ });
18
23
  static validateInteger(value) {
19
- const numberSchema = { type: 'number', multipleOf: 1 };
20
- const validate = ValidationUtils.ajv.compile(numberSchema);
21
- const isValid = validate(value);
22
- if (!isValid) {
23
- throw new errors_argumentError.ArgumentError(`Value must be an integer, got: ${value}`);
24
+ const valid = this.integerValidator(value);
25
+ if (!valid) {
26
+ throw new errors_argumentError.ArgumentError('Invalid integer');
24
27
  }
25
28
  }
26
- /**
27
- * Validates that a value is a non-empty string. Throws ArgumentError on failure.
28
- */
29
29
  static validateString(value) {
30
- const non_empty_string_schema = {
31
- type: 'string',
32
- minLength: 1,
33
- pattern: '\\S',
34
- };
35
- const validate = ValidationUtils.ajv.compile(non_empty_string_schema);
36
- const isValid = validate(value);
37
- if (!isValid) {
38
- throw new errors_argumentError.ArgumentError(`Value must be a non-empty string, got: ${value}`);
30
+ const valid = this.stringValidator(value);
31
+ if (!valid) {
32
+ throw new errors_argumentError.ArgumentError('Invalid string');
39
33
  }
40
34
  }
41
- /**
42
- * Validates that a value is an array of non-empty strings. Throws ArgumentError on failure.
43
- * Allows empty arrays - caller should handle early return.
44
- */
45
35
  static validateStringArray(value) {
46
- const string_array_schema = {
47
- type: 'array',
48
- items: {
49
- type: 'string',
50
- minLength: 1,
51
- pattern: '\\S',
52
- },
53
- };
54
- const validateStringArray = ValidationUtils.ajv.compile(string_array_schema);
55
- const isValid = validateStringArray(value);
36
+ const valid = this.stringArrayValidator(value);
37
+ if (!valid) {
38
+ throw new errors_argumentError.ArgumentError('Invalid string array');
39
+ }
40
+ }
41
+ static validateResource(resource) {
42
+ const isValid = utils_resourceSchema.resourceSchema(resource);
56
43
  if (!isValid) {
57
- throw new errors_argumentError.ArgumentError(`Value must be an array of non-empty strings, got: ${value}`);
44
+ const errorMessage = this.formatValidationErrors(utils_resourceSchema.resourceSchema.errors);
45
+ throw new errors_argumentError.ArgumentError(errorMessage ? `Invalid resource: ${errorMessage}` : 'Invalid resource');
58
46
  }
59
- // Allow empty arrays to pass validation - caller should handle early return
60
- // Non-empty arrays will be validated for string content above
61
47
  }
62
48
  /**
63
49
  * Validates an attribute assignment object using a single AJV schema.
64
50
  * Preserves legacy error messages for each field.
65
51
  */
66
- static validateAssignment(data, validTypes, fieldNames) {
67
- const schema = {
68
- type: 'object',
69
- properties: {
70
- id: { type: 'number', multipleOf: 1 },
71
- type: { type: 'string', enum: validTypes },
72
- attributeKey: { type: 'string', minLength: 1 },
73
- attributeValue: { type: 'string', minLength: 1 },
74
- },
75
- required: ['id', 'type', 'attributeKey', 'attributeValue'],
76
- additionalProperties: false,
77
- };
78
- const validate = this.ajv.compile(schema);
79
- const valid = validate(data);
52
+ static validateResourceAssignment(resource) {
53
+ const valid = utils_assigmentSchema.resourceAssignmentSchema(resource);
80
54
  if (!valid) {
81
- // Map to legacy error messages deterministically
82
- const { id, type, attributeKey, attributeValue } = data;
83
- // id must be integer
84
- const isInteger = typeof id === 'number' && Number.isFinite(id) && Math.floor(id) === id;
85
- if (!isInteger) {
86
- throw new errors_argumentError.ArgumentError(`${fieldNames.id} must be an integer, got: ${id}`);
87
- }
88
- // type must be within enum
89
- if (typeof type !== 'string' || !validTypes.includes(type)) {
90
- throw new errors_argumentError.ArgumentError(`${fieldNames.type} must be one of [${validTypes.join(', ')}], got: ${type}`);
91
- }
92
- // attributeKey
93
- if (typeof attributeKey !== 'string') {
94
- throw new errors_argumentError.ArgumentError(`attributeKey must be a string, got: ${typeof attributeKey}`);
95
- }
96
- if (!attributeKey) {
97
- throw new errors_argumentError.ArgumentError('attributeKey must be a non-empty string');
98
- }
99
- // attributeValue
100
- if (typeof attributeValue !== 'string') {
101
- throw new errors_argumentError.ArgumentError(`attributeValue must be a string, got: ${typeof attributeValue}`);
102
- }
103
- if (!attributeValue) {
104
- throw new errors_argumentError.ArgumentError('attributeValue must be a non-empty string');
105
- }
106
- // Fallback
107
- throw new errors_argumentError.ArgumentError('Invalid attribute assignment');
55
+ const errorMessage = this.formatValidationErrors(utils_assigmentSchema.resourceAssignmentSchema.errors);
56
+ throw new errors_argumentError.ArgumentError(errorMessage
57
+ ? `Invalid resource attribute assignment: ${errorMessage}`
58
+ : 'Invalid resource attribute assignment');
108
59
  }
109
- return {
110
- id: data.id,
111
- type: data.type,
112
- attributeKey: data.attributeKey,
113
- attributeValue: data.attributeValue,
114
- };
115
60
  }
116
- /**
117
- * Validates a Resource-like object shape: { id: number; type: string }.
118
- * Throws ArgumentError with legacy-compatible messages.
119
- */
120
- static validateResource(resource) {
121
- if (!resource || typeof resource !== 'object') {
122
- throw new errors_argumentError.ArgumentError('resource must be an object');
123
- }
124
- const schema = {
125
- type: 'object',
126
- properties: {
127
- id: { type: 'number', multipleOf: 1 },
128
- type: { type: 'string', minLength: 1 },
129
- wrapperData: { type: 'string' },
130
- },
131
- required: ['type', 'id'],
132
- additionalProperties: false,
133
- };
134
- const validate = this.ajv.compile(schema);
135
- const isValid = validate(resource);
136
- if (!isValid) {
137
- throw new errors_argumentError.ArgumentError('Invalid resource');
61
+ static validateEntityAssignment(entity) {
62
+ const valid = utils_assigmentSchema.entityAssignmentSchema(entity);
63
+ if (!valid) {
64
+ const errorMessage = this.formatValidationErrors(utils_assigmentSchema.entityAssignmentSchema.errors);
65
+ throw new errors_argumentError.ArgumentError(errorMessage ? `Invalid entity attribute assignment: ${errorMessage}` : 'Invalid entity attribute assignment');
138
66
  }
139
67
  }
140
- static validateArrayTypeOf(attributesMessages, messageClass) {
141
- const arraySchema = {
142
- type: 'array',
143
- };
144
- const validateArray = ValidationUtils.ajv.compile(arraySchema);
145
- const isArrayValid = validateArray(attributesMessages);
146
- if (!isArrayValid) {
147
- throw new errors_argumentError.ArgumentError(`attributesMessages must be an array`);
148
- }
149
- for (let i = 0; i < attributesMessages.length; i++) {
150
- const item = attributesMessages[i];
151
- if (!(item instanceof messageClass)) {
152
- throw new errors_argumentError.ArgumentError(`attributesMessages[${i}] must be an instance of ${messageClass.name}, got: ${item?.constructor?.name || typeof item}`);
153
- }
154
- }
68
+ /**
69
+ * Formats AJV validation errors into a readable error message
70
+ */
71
+ static formatValidationErrors(errors) {
72
+ return (errors || []).join();
155
73
  }
156
74
  }
157
75
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mondaydotcomorg/monday-authorization",
3
- "version": "3.5.2-feat-shaime-support-entity-attributes-4-ddec1d3",
3
+ "version": "3.5.2-feat-shaime-support-entity-attributes-3-6202ab7",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "license": "BSD-3-Clause",