@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.
Files changed (96) hide show
  1. package/dist/authorization-attributes-ms-service.d.ts +68 -0
  2. package/dist/authorization-attributes-ms-service.d.ts.map +1 -0
  3. package/dist/authorization-attributes-ms-service.js +263 -0
  4. package/dist/authorization-attributes-service.d.ts +25 -47
  5. package/dist/authorization-attributes-service.d.ts.map +1 -1
  6. package/dist/authorization-attributes-service.js +32 -171
  7. package/dist/authorization-attributes-sns-service.d.ts +84 -0
  8. package/dist/authorization-attributes-sns-service.d.ts.map +1 -0
  9. package/dist/authorization-attributes-sns-service.js +196 -0
  10. package/dist/constants/sns.d.ts +12 -2
  11. package/dist/constants/sns.d.ts.map +1 -1
  12. package/dist/constants/sns.js +22 -2
  13. package/dist/entity-attribute-assignment.d.ts.map +1 -1
  14. package/dist/entity-attribute-assignment.js +0 -2
  15. package/dist/esm/authorization-attributes-ms-service.d.ts +68 -0
  16. package/dist/esm/authorization-attributes-ms-service.d.ts.map +1 -0
  17. package/dist/esm/authorization-attributes-ms-service.mjs +261 -0
  18. package/dist/esm/authorization-attributes-service.d.ts +25 -47
  19. package/dist/esm/authorization-attributes-service.d.ts.map +1 -1
  20. package/dist/esm/authorization-attributes-service.mjs +32 -167
  21. package/dist/esm/authorization-attributes-sns-service.d.ts +84 -0
  22. package/dist/esm/authorization-attributes-sns-service.d.ts.map +1 -0
  23. package/dist/esm/authorization-attributes-sns-service.mjs +190 -0
  24. package/dist/esm/constants/sns.d.ts +12 -2
  25. package/dist/esm/constants/sns.d.ts.map +1 -1
  26. package/dist/esm/constants/sns.mjs +17 -3
  27. package/dist/esm/entity-attribute-assignment.d.ts.map +1 -1
  28. package/dist/esm/entity-attribute-assignment.mjs +0 -2
  29. package/dist/esm/index.d.ts +2 -0
  30. package/dist/esm/index.d.ts.map +1 -1
  31. package/dist/esm/index.mjs +2 -0
  32. package/dist/esm/resource-attribute-assignment.d.ts.map +1 -1
  33. package/dist/esm/resource-attribute-assignment.mjs +0 -2
  34. package/dist/esm/resource-attributes-constants.d.ts +2 -1
  35. package/dist/esm/resource-attributes-constants.d.ts.map +1 -1
  36. package/dist/esm/resource-attributes-constants.mjs +1 -0
  37. package/dist/esm/types/authorization-attributes-contracts.d.ts +2 -0
  38. package/dist/esm/types/authorization-attributes-contracts.d.ts.map +1 -1
  39. package/dist/esm/types/authorization-attributes-service.interface.d.ts +14 -25
  40. package/dist/esm/types/authorization-attributes-service.interface.d.ts.map +1 -1
  41. package/dist/esm/types/general.d.ts +4 -3
  42. package/dist/esm/types/general.d.ts.map +1 -1
  43. package/dist/esm/utils/assignment-schema.d.ts +51 -0
  44. package/dist/esm/utils/assignment-schema.d.ts.map +1 -0
  45. package/dist/esm/utils/assignment-schema.mjs +49 -0
  46. package/dist/esm/utils/resource-schema.d.ts +9 -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 +11 -3
  50. package/dist/esm/utils/validation.d.ts.map +1 -1
  51. package/dist/esm/utils/validation.mjs +50 -13
  52. package/dist/index.d.ts +2 -0
  53. package/dist/index.d.ts.map +1 -1
  54. package/dist/index.js +13 -0
  55. package/dist/resource-attribute-assignment.d.ts.map +1 -1
  56. package/dist/resource-attribute-assignment.js +0 -2
  57. package/dist/resource-attributes-constants.d.ts +2 -1
  58. package/dist/resource-attributes-constants.d.ts.map +1 -1
  59. package/dist/resource-attributes-constants.js +1 -0
  60. package/dist/types/authorization-attributes-contracts.d.ts +2 -0
  61. package/dist/types/authorization-attributes-contracts.d.ts.map +1 -1
  62. package/dist/types/authorization-attributes-service.interface.d.ts +14 -25
  63. package/dist/types/authorization-attributes-service.interface.d.ts.map +1 -1
  64. package/dist/types/general.d.ts +4 -3
  65. package/dist/types/general.d.ts.map +1 -1
  66. package/dist/utils/assignment-schema.d.ts +51 -0
  67. package/dist/utils/assignment-schema.d.ts.map +1 -0
  68. package/dist/utils/assignment-schema.js +58 -0
  69. package/dist/utils/resource-schema.d.ts +9 -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 +11 -3
  73. package/dist/utils/validation.d.ts.map +1 -1
  74. package/dist/utils/validation.js +50 -13
  75. package/package.json +1 -1
  76. package/src/authorization-attributes-ms-service.ts +397 -0
  77. package/src/authorization-attributes-service.ts +34 -222
  78. package/src/authorization-attributes-sns-service.ts +321 -0
  79. package/src/constants/sns.ts +19 -2
  80. package/src/entity-attribute-assignment.ts +0 -2
  81. package/src/index.ts +2 -0
  82. package/src/resource-attribute-assignment.ts +0 -2
  83. package/src/resource-attributes-constants.ts +1 -0
  84. package/src/types/authorization-attributes-contracts.ts +2 -0
  85. package/src/types/authorization-attributes-service.interface.ts +19 -31
  86. package/src/types/general.ts +4 -3
  87. package/src/utils/assignment-schema.ts +51 -0
  88. package/src/utils/resource-schema.ts +16 -0
  89. package/src/utils/validation.ts +76 -15
  90. package/dist/esm/utils/assigment-schema.d.ts +0 -29
  91. package/dist/esm/utils/assigment-schema.d.ts.map +0 -1
  92. package/dist/esm/utils/assigment-schema.mjs +0 -29
  93. package/dist/utils/assigment-schema.d.ts +0 -29
  94. package/dist/utils/assigment-schema.d.ts.map +0 -1
  95. package/dist/utils/assigment-schema.js +0 -36
  96. package/src/utils/assigment-schema.ts +0 -29
@@ -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 { ResourceAttributeAssignment, EntityAttributeAssignment } from '../types/authorization-attributes-contracts';
4
- import { entityAssignmentSchema, resourceAssignmentSchema } from './assigment-schema';
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 validateResourceAssignment(resource: ResourceAttributeAssignment): void {
45
- const valid = resourceAssignmentSchema(resource);
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 errorMessages = (resourceAssignmentSchema.errors || [])
48
- .map(err => err.message || 'validation failed')
49
- .join(', ');
50
- throw new ArgumentError(`Invalid resource attribute assignment: ${errorMessages}`);
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 validateEntityAssignment(entity: EntityAttributeAssignment): void {
55
- const valid = entityAssignmentSchema(entity);
98
+ static validatDeleteEntityAssignment(entity: EntityAttributeDeleteAssignment): void {
99
+ const valid = entityDeleteAssignmentSchema(entity);
56
100
  if (!valid) {
57
- const errorMessages = (entityAssignmentSchema.errors || [])
58
- .map(err => err.message || 'validation failed')
59
- .join(', ');
60
- throw new ArgumentError(`Invalid entity attribute assignment: ${errorMessages}`);
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
- });