@mondaydotcomorg/monday-authorization 3.5.1-fix-authorize-profile-picker-7481de0 → 3.5.3-feat-shaime-support-entity-attributes-in-authorization-sdk-e355942
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 +95 -0
- package/dist/authorization-attributes-ms-service.d.ts.map +1 -0
- package/dist/authorization-attributes-ms-service.js +362 -0
- package/dist/authorization-attributes-service.d.ts +26 -47
- package/dist/authorization-attributes-service.d.ts.map +1 -1
- package/dist/authorization-attributes-service.js +33 -171
- package/dist/authorization-attributes-sns-service.d.ts +91 -0
- package/dist/authorization-attributes-sns-service.d.ts.map +1 -0
- package/dist/authorization-attributes-sns-service.js +217 -0
- package/dist/authorization-middleware.d.ts +2 -2
- package/dist/authorization-middleware.d.ts.map +1 -1
- package/dist/authorization-service.d.ts +3 -3
- package/dist/authorization-service.d.ts.map +1 -1
- package/dist/authorization-service.js +7 -34
- package/dist/base-attribute-assignment.d.ts +18 -0
- package/dist/base-attribute-assignment.d.ts.map +1 -0
- package/dist/base-attribute-assignment.js +43 -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 +14 -0
- package/dist/entity-attribute-assignment.d.ts.map +1 -0
- package/dist/entity-attribute-assignment.js +24 -0
- package/dist/entity-attributes-constants.d.ts +7 -0
- package/dist/entity-attributes-constants.d.ts.map +1 -0
- package/dist/entity-attributes-constants.js +9 -0
- package/dist/errors/argument-error.d.ts +4 -0
- package/dist/errors/argument-error.d.ts.map +1 -0
- package/dist/errors/argument-error.js +11 -0
- package/dist/esm/authorization-attributes-ms-service.d.ts +95 -0
- package/dist/esm/authorization-attributes-ms-service.d.ts.map +1 -0
- package/dist/esm/authorization-attributes-ms-service.mjs +360 -0
- package/dist/esm/authorization-attributes-service.d.ts +26 -47
- package/dist/esm/authorization-attributes-service.d.ts.map +1 -1
- package/dist/esm/authorization-attributes-service.mjs +33 -167
- package/dist/esm/authorization-attributes-sns-service.d.ts +91 -0
- package/dist/esm/authorization-attributes-sns-service.d.ts.map +1 -0
- package/dist/esm/authorization-attributes-sns-service.mjs +211 -0
- package/dist/esm/authorization-middleware.d.ts +2 -2
- package/dist/esm/authorization-middleware.d.ts.map +1 -1
- package/dist/esm/authorization-service.d.ts +3 -3
- package/dist/esm/authorization-service.d.ts.map +1 -1
- package/dist/esm/authorization-service.mjs +7 -34
- package/dist/esm/base-attribute-assignment.d.ts +18 -0
- package/dist/esm/base-attribute-assignment.d.ts.map +1 -0
- package/dist/esm/base-attribute-assignment.mjs +41 -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 +14 -0
- package/dist/esm/entity-attribute-assignment.d.ts.map +1 -0
- package/dist/esm/entity-attribute-assignment.mjs +22 -0
- package/dist/esm/entity-attributes-constants.d.ts +7 -0
- package/dist/esm/entity-attributes-constants.d.ts.map +1 -0
- package/dist/esm/entity-attributes-constants.mjs +7 -0
- package/dist/esm/errors/argument-error.d.ts +4 -0
- package/dist/esm/errors/argument-error.d.ts.map +1 -0
- package/dist/esm/errors/argument-error.mjs +9 -0
- package/dist/esm/index.d.ts +9 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.mjs +7 -0
- package/dist/esm/prometheus-service.d.ts +1 -2
- package/dist/esm/prometheus-service.d.ts.map +1 -1
- package/dist/esm/resource-attribute-assignment.d.ts +24 -0
- package/dist/esm/resource-attribute-assignment.d.ts.map +1 -0
- package/dist/esm/resource-attribute-assignment.mjs +34 -0
- package/dist/esm/resource-attributes-constants.d.ts +15 -0
- package/dist/esm/resource-attributes-constants.d.ts.map +1 -0
- package/dist/esm/resource-attributes-constants.mjs +25 -0
- package/dist/esm/testKit/index.d.ts +4 -4
- package/dist/esm/testKit/index.d.ts.map +1 -1
- package/dist/esm/types/authorization-attributes-contracts.d.ts +27 -12
- package/dist/esm/types/authorization-attributes-contracts.d.ts.map +1 -1
- package/dist/esm/types/authorization-attributes-contracts.mjs +6 -6
- package/dist/esm/types/authorization-attributes-service.interface.d.ts +57 -0
- package/dist/esm/types/authorization-attributes-service.interface.d.ts.map +1 -0
- package/dist/esm/types/authorization-attributes-service.interface.mjs +1 -0
- package/dist/esm/types/general.d.ts +1 -2
- package/dist/esm/types/general.d.ts.map +1 -1
- package/dist/esm/utils/validation.d.ts +45 -0
- package/dist/esm/utils/validation.d.ts.map +1 -0
- package/dist/esm/utils/validation.mjs +117 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -0
- package/dist/prometheus-service.d.ts +1 -2
- package/dist/prometheus-service.d.ts.map +1 -1
- package/dist/resource-attribute-assignment.d.ts +24 -0
- package/dist/resource-attribute-assignment.d.ts.map +1 -0
- package/dist/resource-attribute-assignment.js +36 -0
- package/dist/resource-attributes-constants.d.ts +15 -0
- package/dist/resource-attributes-constants.d.ts.map +1 -0
- package/dist/resource-attributes-constants.js +28 -0
- package/dist/testKit/index.d.ts +4 -4
- package/dist/testKit/index.d.ts.map +1 -1
- package/dist/types/authorization-attributes-contracts.d.ts +27 -12
- package/dist/types/authorization-attributes-contracts.d.ts.map +1 -1
- package/dist/types/authorization-attributes-contracts.js +5 -5
- package/dist/types/authorization-attributes-service.interface.d.ts +57 -0
- package/dist/types/authorization-attributes-service.interface.d.ts.map +1 -0
- package/dist/types/authorization-attributes-service.interface.js +1 -0
- package/dist/types/general.d.ts +1 -2
- package/dist/types/general.d.ts.map +1 -1
- package/dist/utils/validation.d.ts +45 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +119 -0
- package/package.json +3 -2
- package/src/authorization-attributes-ms-service.ts +528 -0
- package/src/authorization-attributes-service.ts +35 -222
- package/src/authorization-attributes-sns-service.ts +312 -0
- package/src/authorization-middleware.ts +2 -2
- package/src/authorization-service.ts +15 -75
- package/src/base-attribute-assignment.ts +55 -0
- package/src/constants/sns.ts +19 -2
- package/src/entity-attribute-assignment.ts +21 -0
- package/src/entity-attributes-constants.ts +7 -0
- package/src/errors/argument-error.ts +7 -0
- package/src/index.ts +9 -0
- package/src/prometheus-service.ts +1 -2
- package/src/resource-attribute-assignment.ts +43 -0
- package/src/resource-attributes-constants.ts +35 -0
- package/src/testKit/index.ts +5 -5
- package/src/types/authorization-attributes-contracts.ts +36 -11
- package/src/types/authorization-attributes-service.interface.ts +100 -0
- package/src/types/general.ts +3 -2
- package/src/utils/validation.ts +114 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ArgumentError } from '../errors/argument-error';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Utility class for common validation operations using Zod
|
|
6
|
+
*/
|
|
7
|
+
export class ValidationUtils {
|
|
8
|
+
/**
|
|
9
|
+
* Validates that a value is an integer
|
|
10
|
+
* @param value The value to validate
|
|
11
|
+
* @param fieldName The name of the field for error messages
|
|
12
|
+
* @throws ArgumentError if value is not an integer
|
|
13
|
+
*/
|
|
14
|
+
static validateInteger(value: any, fieldName: string): void {
|
|
15
|
+
const schema = z.number().int();
|
|
16
|
+
try {
|
|
17
|
+
schema.parse(value);
|
|
18
|
+
} catch (error) {
|
|
19
|
+
if (error instanceof z.ZodError) {
|
|
20
|
+
throw new ArgumentError(`${fieldName} must be an integer, got: ${value}`);
|
|
21
|
+
}
|
|
22
|
+
throw error;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Validates that a value is a non-empty string
|
|
28
|
+
* @param value The value to validate
|
|
29
|
+
* @param fieldName The name of the field for error messages
|
|
30
|
+
* @throws ArgumentError if value is not a string or is empty
|
|
31
|
+
*/
|
|
32
|
+
static validateString(value: any, fieldName: string): void {
|
|
33
|
+
const schema = z.string().min(1);
|
|
34
|
+
try {
|
|
35
|
+
schema.parse(value);
|
|
36
|
+
} catch (error) {
|
|
37
|
+
if (error instanceof z.ZodError) {
|
|
38
|
+
if (typeof value !== 'string') {
|
|
39
|
+
throw new ArgumentError(`${fieldName} must be a string, got: ${typeof value}`);
|
|
40
|
+
}
|
|
41
|
+
throw new ArgumentError(`${fieldName} must be a non-empty string`);
|
|
42
|
+
}
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Validates that a value is an array and optionally checks minimum length
|
|
49
|
+
* @param value The value to validate
|
|
50
|
+
* @param fieldName The name of the field for error messages
|
|
51
|
+
* @param minLength Minimum required length (default: 0)
|
|
52
|
+
* @returns The validated array
|
|
53
|
+
* @throws ArgumentError if value is not an array or doesn't meet minimum length
|
|
54
|
+
*/
|
|
55
|
+
static validateArray<T>(value: any, fieldName: string, minLength = 0): T[] {
|
|
56
|
+
const schema = z.array(z.any()).min(minLength);
|
|
57
|
+
try {
|
|
58
|
+
return schema.parse(value) as T[];
|
|
59
|
+
} catch (error) {
|
|
60
|
+
if (error instanceof z.ZodError) {
|
|
61
|
+
if (!Array.isArray(value)) {
|
|
62
|
+
throw new ArgumentError(`${fieldName} must be an array`);
|
|
63
|
+
}
|
|
64
|
+
throw new ArgumentError(`${fieldName} must have at least ${minLength} items`);
|
|
65
|
+
}
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Validates that a value is one of the allowed enum values
|
|
72
|
+
* @param value The value to validate
|
|
73
|
+
* @param validValues Array of valid values
|
|
74
|
+
* @param fieldName The name of the field for error messages
|
|
75
|
+
* @returns The validated value as the enum type
|
|
76
|
+
* @throws ArgumentError if value is not in validValues
|
|
77
|
+
*/
|
|
78
|
+
static validateEnum<T extends string>(value: string, validValues: readonly T[], fieldName: string): T {
|
|
79
|
+
const schema = z.enum(validValues as [T, ...T[]]);
|
|
80
|
+
try {
|
|
81
|
+
return schema.parse(value) as T;
|
|
82
|
+
} catch (error) {
|
|
83
|
+
if (error instanceof z.ZodError) {
|
|
84
|
+
throw new ArgumentError(`${fieldName} must be one of [${validValues.join(', ')}], got: ${value}`);
|
|
85
|
+
}
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Validates that all items in an array are strings
|
|
92
|
+
* @param value Array to validate
|
|
93
|
+
* @param fieldName The name of the field for error messages
|
|
94
|
+
* @throws ArgumentError if any item is not a string
|
|
95
|
+
*/
|
|
96
|
+
static validateStringArray(value: any[], fieldName: string): void {
|
|
97
|
+
const schema = z.array(z.string());
|
|
98
|
+
try {
|
|
99
|
+
schema.parse(value);
|
|
100
|
+
} catch (error) {
|
|
101
|
+
if (error instanceof z.ZodError) {
|
|
102
|
+
const zodError = error as z.ZodError;
|
|
103
|
+
const firstError = zodError.issues[0];
|
|
104
|
+
// Check if it's an array item validation error
|
|
105
|
+
if (firstError.path.length > 0 && typeof firstError.path[0] === 'number') {
|
|
106
|
+
const index = firstError.path[0];
|
|
107
|
+
throw new ArgumentError(`All ${fieldName} must be strings, but item at index ${index} is not`);
|
|
108
|
+
}
|
|
109
|
+
throw new ArgumentError(`${fieldName} must be an array`);
|
|
110
|
+
}
|
|
111
|
+
throw error;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|