@mondaydotcomorg/monday-authorization 3.5.1 → 3.5.3-feat-shaime-support-entity-attributes-in-authorization-sdk-127d99a
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 +90 -0
- package/dist/authorization-attributes-ms-service.d.ts.map +1 -0
- package/dist/authorization-attributes-ms-service.js +351 -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 +90 -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/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 +90 -0
- package/dist/esm/authorization-attributes-ms-service.d.ts.map +1 -0
- package/dist/esm/authorization-attributes-ms-service.mjs +349 -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 +90 -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/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 +56 -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 +56 -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 +513 -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 +4 -4
- 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 -3
- 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 +101 -0
- package/src/types/general.ts +3 -2
- package/src/utils/validation.ts +114 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility class for common validation operations using Zod
|
|
3
|
+
*/
|
|
4
|
+
export declare class ValidationUtils {
|
|
5
|
+
/**
|
|
6
|
+
* Validates that a value is an integer
|
|
7
|
+
* @param value The value to validate
|
|
8
|
+
* @param fieldName The name of the field for error messages
|
|
9
|
+
* @throws ArgumentError if value is not an integer
|
|
10
|
+
*/
|
|
11
|
+
static validateInteger(value: any, fieldName: string): void;
|
|
12
|
+
/**
|
|
13
|
+
* Validates that a value is a non-empty string
|
|
14
|
+
* @param value The value to validate
|
|
15
|
+
* @param fieldName The name of the field for error messages
|
|
16
|
+
* @throws ArgumentError if value is not a string or is empty
|
|
17
|
+
*/
|
|
18
|
+
static validateString(value: any, fieldName: string): void;
|
|
19
|
+
/**
|
|
20
|
+
* Validates that a value is an array and optionally checks minimum length
|
|
21
|
+
* @param value The value to validate
|
|
22
|
+
* @param fieldName The name of the field for error messages
|
|
23
|
+
* @param minLength Minimum required length (default: 0)
|
|
24
|
+
* @returns The validated array
|
|
25
|
+
* @throws ArgumentError if value is not an array or doesn't meet minimum length
|
|
26
|
+
*/
|
|
27
|
+
static validateArray<T>(value: any, fieldName: string, minLength?: number): T[];
|
|
28
|
+
/**
|
|
29
|
+
* Validates that a value is one of the allowed enum values
|
|
30
|
+
* @param value The value to validate
|
|
31
|
+
* @param validValues Array of valid values
|
|
32
|
+
* @param fieldName The name of the field for error messages
|
|
33
|
+
* @returns The validated value as the enum type
|
|
34
|
+
* @throws ArgumentError if value is not in validValues
|
|
35
|
+
*/
|
|
36
|
+
static validateEnum<T extends string>(value: string, validValues: readonly T[], fieldName: string): T;
|
|
37
|
+
/**
|
|
38
|
+
* Validates that all items in an array are strings
|
|
39
|
+
* @param value Array to validate
|
|
40
|
+
* @param fieldName The name of the field for error messages
|
|
41
|
+
* @throws ArgumentError if any item is not a string
|
|
42
|
+
*/
|
|
43
|
+
static validateStringArray(value: any[], fieldName: string): void;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../src/utils/validation.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,qBAAa,eAAe;IAC1B;;;;;OAKG;IACH,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;IAY3D;;;;;OAKG;IACH,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;IAe1D;;;;;;;OAOG;IACH,MAAM,CAAC,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,SAAI,GAAG,CAAC,EAAE;IAe1E;;;;;;;OAOG;IACH,MAAM,CAAC,YAAY,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,CAAC;IAYrG;;;;;OAKG;IACH,MAAM,CAAC,mBAAmB,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;CAkBlE"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ArgumentError } from '../errors/argument-error.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Utility class for common validation operations using Zod
|
|
6
|
+
*/
|
|
7
|
+
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, fieldName) {
|
|
15
|
+
const schema = z.number().int();
|
|
16
|
+
try {
|
|
17
|
+
schema.parse(value);
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
if (error instanceof z.ZodError) {
|
|
21
|
+
throw new ArgumentError(`${fieldName} must be an integer, got: ${value}`);
|
|
22
|
+
}
|
|
23
|
+
throw error;
|
|
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, fieldName) {
|
|
33
|
+
const schema = z.string().min(1);
|
|
34
|
+
try {
|
|
35
|
+
schema.parse(value);
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
if (error instanceof z.ZodError) {
|
|
39
|
+
if (typeof value !== 'string') {
|
|
40
|
+
throw new ArgumentError(`${fieldName} must be a string, got: ${typeof value}`);
|
|
41
|
+
}
|
|
42
|
+
throw new ArgumentError(`${fieldName} must be a non-empty string`);
|
|
43
|
+
}
|
|
44
|
+
throw error;
|
|
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(value, fieldName, minLength = 0) {
|
|
56
|
+
const schema = z.array(z.any()).min(minLength);
|
|
57
|
+
try {
|
|
58
|
+
return schema.parse(value);
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
if (error instanceof z.ZodError) {
|
|
62
|
+
if (!Array.isArray(value)) {
|
|
63
|
+
throw new ArgumentError(`${fieldName} must be an array`);
|
|
64
|
+
}
|
|
65
|
+
throw new ArgumentError(`${fieldName} must have at least ${minLength} items`);
|
|
66
|
+
}
|
|
67
|
+
throw error;
|
|
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(value, validValues, fieldName) {
|
|
79
|
+
const schema = z.enum(validValues);
|
|
80
|
+
try {
|
|
81
|
+
return schema.parse(value);
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
if (error instanceof z.ZodError) {
|
|
85
|
+
throw new ArgumentError(`${fieldName} must be one of [${validValues.join(', ')}], got: ${value}`);
|
|
86
|
+
}
|
|
87
|
+
throw error;
|
|
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, fieldName) {
|
|
97
|
+
const schema = z.array(z.string());
|
|
98
|
+
try {
|
|
99
|
+
schema.parse(value);
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
if (error instanceof z.ZodError) {
|
|
103
|
+
const zodError = error;
|
|
104
|
+
const firstError = zodError.issues[0];
|
|
105
|
+
// Check if it's an array item validation error
|
|
106
|
+
if (firstError.path.length > 0 && typeof firstError.path[0] === 'number') {
|
|
107
|
+
const index = firstError.path[0];
|
|
108
|
+
throw new ArgumentError(`All ${fieldName} must be strings, but item at index ${index} is not`);
|
|
109
|
+
}
|
|
110
|
+
throw new ArgumentError(`${fieldName} must be an array`);
|
|
111
|
+
}
|
|
112
|
+
throw error;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export { ValidationUtils };
|
package/dist/index.d.ts
CHANGED
|
@@ -19,6 +19,15 @@ 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 { AuthorizationAttributesSnsService } from './authorization-attributes-sns-service';
|
|
23
|
+
export { AuthorizationAttributesMsService } from './authorization-attributes-ms-service';
|
|
24
|
+
export { IAuthorizationAttributesService } from './types/authorization-attributes-service.interface';
|
|
25
|
+
export { ResourceAttributeAssignment } from './resource-attribute-assignment';
|
|
26
|
+
export { RESOURCE_TYPES, RESOURCE_ATTRIBUTES_CONSTANTS } from './resource-attributes-constants';
|
|
27
|
+
export { EntityAttributeAssignment } from './entity-attribute-assignment';
|
|
28
|
+
export { ENTITY_TYPES } from './entity-attributes-constants';
|
|
29
|
+
export { ArgumentError } from './errors/argument-error';
|
|
30
|
+
export type { EntityType } from './entity-attributes-constants';
|
|
22
31
|
export { RolesService } from './roles-service';
|
|
23
32
|
export { MembershipsService } from './memberships';
|
|
24
33
|
export { AuthorizationObject, Resource, BaseRequest, ResourceGetter, ContextGetter } from './types/general';
|
package/dist/index.d.ts.map
CH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2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AAC9E,OAAO,EAAE,cAAc,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChG,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,YAAY,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,WAAW,EAAE,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,13 @@ 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 authorizationAttributesSnsService = require('./authorization-attributes-sns-service.js');
|
|
10
|
+
const authorizationAttributesMsService = require('./authorization-attributes-ms-service.js');
|
|
11
|
+
const resourceAttributeAssignment = require('./resource-attribute-assignment.js');
|
|
12
|
+
const resourceAttributesConstants = require('./resource-attributes-constants.js');
|
|
13
|
+
const entityAttributeAssignment = require('./entity-attribute-assignment.js');
|
|
14
|
+
const entityAttributesConstants = require('./entity-attributes-constants.js');
|
|
15
|
+
const errors_argumentError = require('./errors/argument-error.js');
|
|
9
16
|
const rolesService = require('./roles-service.js');
|
|
10
17
|
const memberships = require('./memberships.js');
|
|
11
18
|
const types_roles = require('./types/roles.js');
|
|
@@ -44,6 +51,14 @@ exports.authorizationCheckMiddleware = authorizationMiddleware.authorizationChec
|
|
|
44
51
|
exports.getAuthorizationMiddleware = authorizationMiddleware.getAuthorizationMiddleware;
|
|
45
52
|
exports.skipAuthorizationMiddleware = authorizationMiddleware.skipAuthorizationMiddleware;
|
|
46
53
|
exports.AuthorizationAttributesService = authorizationAttributesService.AuthorizationAttributesService;
|
|
54
|
+
exports.AuthorizationAttributesSnsService = authorizationAttributesSnsService.AuthorizationAttributesSnsService;
|
|
55
|
+
exports.AuthorizationAttributesMsService = authorizationAttributesMsService.AuthorizationAttributesMsService;
|
|
56
|
+
exports.ResourceAttributeAssignment = resourceAttributeAssignment.ResourceAttributeAssignment;
|
|
57
|
+
exports.RESOURCE_ATTRIBUTES_CONSTANTS = resourceAttributesConstants.RESOURCE_ATTRIBUTES_CONSTANTS;
|
|
58
|
+
exports.RESOURCE_TYPES = resourceAttributesConstants.RESOURCE_TYPES;
|
|
59
|
+
exports.EntityAttributeAssignment = entityAttributeAssignment.EntityAttributeAssignment;
|
|
60
|
+
exports.ENTITY_TYPES = entityAttributesConstants.ENTITY_TYPES;
|
|
61
|
+
exports.ArgumentError = errors_argumentError.ArgumentError;
|
|
47
62
|
exports.RolesService = rolesService.RolesService;
|
|
48
63
|
exports.MembershipsService = memberships.MembershipsService;
|
|
49
64
|
Object.defineProperty(exports, 'RoleType', {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Action } from './types/general';
|
|
2
1
|
export declare const METRICS: {
|
|
3
2
|
AUTHORIZATION_CHECK: string;
|
|
4
3
|
AUTHORIZATION_CHECKS_PER_REQUEST: string;
|
|
@@ -6,5 +5,5 @@ export declare const METRICS: {
|
|
|
6
5
|
};
|
|
7
6
|
export declare function setPrometheus(customPrometheus: any): void;
|
|
8
7
|
export declare function getMetricsManager(): any;
|
|
9
|
-
export declare function sendAuthorizationCheckResponseTimeMetric(resourceType: string, action:
|
|
8
|
+
export declare function sendAuthorizationCheckResponseTimeMetric(resourceType: string, action: string, isAuthorized: boolean, responseStatus: number, time: number): void;
|
|
10
9
|
//# sourceMappingURL=prometheus-service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prometheus-service.d.ts","sourceRoot":"","sources":["../src/prometheus-service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prometheus-service.d.ts","sourceRoot":"","sources":["../src/prometheus-service.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,OAAO;;;;CAInB,CAAC;AAQF,wBAAgB,aAAa,CAAC,gBAAgB,KAAA,QAa7C;AAED,wBAAgB,iBAAiB,QAEhC;AAED,wBAAgB,wCAAwC,CACtD,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,OAAO,EACrB,cAAc,EAAE,MAAM,EACtB,IAAI,EAAE,MAAM,QASb"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ResourceType } from './resource-attributes-constants';
|
|
2
|
+
import { BaseAttributeAssignment } from './base-attribute-assignment';
|
|
3
|
+
export declare class ResourceAttributeAssignment extends BaseAttributeAssignment<number, ResourceType> {
|
|
4
|
+
readonly resourceId: number;
|
|
5
|
+
readonly resourceType: ResourceType;
|
|
6
|
+
constructor(resourceId: number, resourceType: string, attributeKey: string, attributeValue: string);
|
|
7
|
+
/**
|
|
8
|
+
* Converts the assignment to a plain object with camelCase keys
|
|
9
|
+
* @returns Plain object with camelCase keys: { resourceId, resourceType, key, value }
|
|
10
|
+
*/
|
|
11
|
+
toPlainObject(): {
|
|
12
|
+
resourceId: number;
|
|
13
|
+
resourceType: string;
|
|
14
|
+
key: string;
|
|
15
|
+
value: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Compares two assignments for equality
|
|
19
|
+
* @param other Another ResourceAttributeAssignment instance
|
|
20
|
+
* @returns true if all properties are equal
|
|
21
|
+
*/
|
|
22
|
+
equals(other: ResourceAttributeAssignment): boolean;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=resource-attribute-assignment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-attribute-assignment.d.ts","sourceRoot":"","sources":["../src/resource-attribute-assignment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/E,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAEtE,qBAAa,2BAA4B,SAAQ,uBAAuB,CAAC,MAAM,EAAE,YAAY,CAAC;IAC5F,SAAgB,UAAU,EAAE,MAAM,CAAC;IACnC,SAAgB,YAAY,EAAE,YAAY,CAAC;gBAE/B,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;IAclG;;;OAGG;IACH,aAAa,IAAI;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE;IASzF;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,2BAA2B,GAAG,OAAO;CAGpD"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
const resourceAttributesConstants = require('./resource-attributes-constants.js');
|
|
4
|
+
const baseAttributeAssignment = require('./base-attribute-assignment.js');
|
|
5
|
+
|
|
6
|
+
class ResourceAttributeAssignment extends baseAttributeAssignment.BaseAttributeAssignment {
|
|
7
|
+
resourceId;
|
|
8
|
+
resourceType;
|
|
9
|
+
constructor(resourceId, resourceType, attributeKey, attributeValue) {
|
|
10
|
+
super(resourceId, resourceType, attributeKey, attributeValue, Object.values(resourceAttributesConstants.RESOURCE_TYPES), 'resourceId', 'resourceType');
|
|
11
|
+
this.resourceId = resourceId;
|
|
12
|
+
this.resourceType = this.type;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Converts the assignment to a plain object with camelCase keys
|
|
16
|
+
* @returns Plain object with camelCase keys: { resourceId, resourceType, key, value }
|
|
17
|
+
*/
|
|
18
|
+
toPlainObject() {
|
|
19
|
+
return {
|
|
20
|
+
resourceId: this.resourceId,
|
|
21
|
+
resourceType: this.resourceType,
|
|
22
|
+
key: this.attributeKey,
|
|
23
|
+
value: this.attributeValue,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Compares two assignments for equality
|
|
28
|
+
* @param other Another ResourceAttributeAssignment instance
|
|
29
|
+
* @returns true if all properties are equal
|
|
30
|
+
*/
|
|
31
|
+
equals(other) {
|
|
32
|
+
return super.equals(other);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
exports.ResourceAttributeAssignment = ResourceAttributeAssignment;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const RESOURCE_ATTRIBUTES_CONSTANTS: {
|
|
2
|
+
readonly ACCOUNT_RESOURCE_ATTRIBUTES: {
|
|
3
|
+
readonly ENABLE_MEMBERS_INVITE_FROM_NON_AUTH_DOMAIN: "enable_members_invite_from_non_auth_domain";
|
|
4
|
+
};
|
|
5
|
+
readonly WORKSPACE_RESOURCE_ATTRIBUTES: {
|
|
6
|
+
readonly IS_DEFAULT_WORKSPACE: "is_default_workspace";
|
|
7
|
+
};
|
|
8
|
+
readonly BOARD_RESOURCE_ATTRIBUTES: {
|
|
9
|
+
readonly IS_SYNCABLE_CHILD_ENTITY: "is_syncable_child_entity";
|
|
10
|
+
readonly SYSTEM_ENTITY_TYPE: "system_entity_type";
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export type ResourceType = 'account' | 'account_product' | 'workspace' | 'board' | 'item' | 'team' | 'overview' | 'document' | 'crm';
|
|
14
|
+
export declare const RESOURCE_TYPES: Record<string, ResourceType>;
|
|
15
|
+
//# sourceMappingURL=resource-attributes-constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-attributes-constants.d.ts","sourceRoot":"","sources":["../src/resource-attributes-constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,6BAA6B;;;;;;;;;;;CAWhC,CAAC;AAEX,MAAM,MAAM,YAAY,GACpB,SAAS,GACT,iBAAiB,GACjB,WAAW,GACX,OAAO,GACP,MAAM,GACN,MAAM,GACN,UAAU,GACV,UAAU,GACV,KAAK,CAAC;AAEV,eAAO,MAAM,cAAc,EAUtB,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
const RESOURCE_ATTRIBUTES_CONSTANTS = {
|
|
4
|
+
ACCOUNT_RESOURCE_ATTRIBUTES: {
|
|
5
|
+
ENABLE_MEMBERS_INVITE_FROM_NON_AUTH_DOMAIN: 'enable_members_invite_from_non_auth_domain',
|
|
6
|
+
},
|
|
7
|
+
WORKSPACE_RESOURCE_ATTRIBUTES: {
|
|
8
|
+
IS_DEFAULT_WORKSPACE: 'is_default_workspace',
|
|
9
|
+
},
|
|
10
|
+
BOARD_RESOURCE_ATTRIBUTES: {
|
|
11
|
+
IS_SYNCABLE_CHILD_ENTITY: 'is_syncable_child_entity',
|
|
12
|
+
SYSTEM_ENTITY_TYPE: 'system_entity_type',
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
const RESOURCE_TYPES = {
|
|
16
|
+
ACCOUNT: 'account',
|
|
17
|
+
ACCOUNT_PRODUCT: 'account_product',
|
|
18
|
+
WORKSPACE: 'workspace',
|
|
19
|
+
BOARD: 'board',
|
|
20
|
+
ITEM: 'item',
|
|
21
|
+
TEAM: 'team',
|
|
22
|
+
OVERVIEW: 'overview',
|
|
23
|
+
DOCUMENT: 'document',
|
|
24
|
+
CRM: 'crm',
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
exports.RESOURCE_ATTRIBUTES_CONSTANTS = RESOURCE_ATTRIBUTES_CONSTANTS;
|
|
28
|
+
exports.RESOURCE_TYPES = RESOURCE_TYPES;
|
package/dist/testKit/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseRequest, BaseResponse, ContextGetter, Resource, ResourceGetter } from '../types/general';
|
|
2
2
|
import type { NextFunction } from 'express';
|
|
3
3
|
export type TestPermittedAction = {
|
|
4
4
|
accountId: number;
|
|
5
5
|
userId: number;
|
|
6
6
|
resources: Resource[];
|
|
7
|
-
action:
|
|
7
|
+
action: string;
|
|
8
8
|
};
|
|
9
|
-
export declare const addTestPermittedAction: (accountId: number, userId: number, resources: Resource[], action:
|
|
9
|
+
export declare const addTestPermittedAction: (accountId: number, userId: number, resources: Resource[], action: string) => void;
|
|
10
10
|
export declare const clearTestPermittedActions: () => void;
|
|
11
|
-
export declare const getTestAuthorizationMiddleware: (action:
|
|
11
|
+
export declare const getTestAuthorizationMiddleware: (action: string, resourceGetter: ResourceGetter, contextGetter?: ContextGetter) => (request: BaseRequest, response: BaseResponse, next: NextFunction) => Promise<void>;
|
|
12
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testKit/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testKit/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGtG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,MAAM,MAAM,mBAAmB,GAAG;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAGF,eAAO,MAAM,sBAAsB,GAAI,WAAW,MAAM,EAAE,QAAQ,MAAM,EAAE,WAAW,QAAQ,EAAE,EAAE,QAAQ,MAAM,SAE9G,CAAC;AAEF,eAAO,MAAM,yBAAyB,YAErC,CAAC;AA4BF,eAAO,MAAM,8BAA8B,GACzC,QAAQ,MAAM,EACd,gBAAgB,cAAc,EAC9B,gBAAgB,aAAa,MAG3B,SAAS,WAAW,EACpB,UAAU,YAAY,EACtB,MAAM,YAAY,KACjB,OAAO,CAAC,IAAI,CAYhB,CAAC"}
|
|
@@ -1,28 +1,43 @@
|
|
|
1
1
|
import { Resource } from './general';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import type { EntityType } from '../entity-attributes-constants';
|
|
3
|
+
import type { ResourceType } from '../resource-attributes-constants';
|
|
4
|
+
export type { EntityType, ResourceType };
|
|
5
|
+
interface AttributeAssignment {
|
|
5
6
|
key: string;
|
|
6
7
|
value: string;
|
|
7
8
|
}
|
|
8
|
-
export interface
|
|
9
|
-
|
|
9
|
+
export interface ResourceAttributeAssignment extends AttributeAssignment {
|
|
10
|
+
resourceId: number;
|
|
11
|
+
resourceType: ResourceType;
|
|
12
|
+
}
|
|
13
|
+
export interface EntityAttributeAssignment extends AttributeAssignment {
|
|
14
|
+
entityId: number;
|
|
15
|
+
entityType: EntityType;
|
|
10
16
|
}
|
|
11
17
|
export interface ResourceAttributeDelete {
|
|
12
18
|
resourceType: Resource['type'];
|
|
13
19
|
resourceId: Resource['id'];
|
|
14
20
|
key: string;
|
|
15
21
|
}
|
|
16
|
-
export
|
|
22
|
+
export interface EntityAttributeDelete {
|
|
23
|
+
entityType: EntityType;
|
|
24
|
+
entityId: number;
|
|
25
|
+
key: string;
|
|
26
|
+
}
|
|
27
|
+
export declare enum AttributeOperation {
|
|
17
28
|
UPSERT = "upsert",
|
|
18
29
|
DELETE = "delete"
|
|
19
30
|
}
|
|
20
|
-
interface
|
|
21
|
-
|
|
31
|
+
export interface ResourceAttributeResponse {
|
|
32
|
+
attributes: ResourceAttributeAssignment[];
|
|
33
|
+
}
|
|
34
|
+
export interface EntityAttributeResponse {
|
|
35
|
+
attributes: EntityAttributeAssignment[];
|
|
36
|
+
}
|
|
37
|
+
export interface ResourceAttributeOperation extends ResourceAttributeAssignment {
|
|
38
|
+
operationType: AttributeOperation;
|
|
22
39
|
}
|
|
23
|
-
interface
|
|
24
|
-
operationType:
|
|
40
|
+
export interface EntityAttributeOperation extends EntityAttributeAssignment {
|
|
41
|
+
operationType: AttributeOperation;
|
|
25
42
|
}
|
|
26
|
-
export type ResourceAttributesOperation = UpsertResourceAttributeOperation | DeleteResourceAttributeOperation;
|
|
27
|
-
export {};
|
|
28
43
|
//# sourceMappingURL=authorization-attributes-contracts.d.ts.map
|
|
@@ -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;
|
|
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,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC;AAEzC,UAAU,mBAAmB;IAC3B,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;AAID,MAAM,WAAW,yBAA0B,SAAQ,mBAAmB;IACpE,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,UAAU,CAAC;CACxB;AAGD,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,0BAA2B,SAAQ,2BAA2B;IAC7E,aAAa,EAAE,kBAAkB,CAAC;CACnC;AAED,MAAM,WAAW,wBAAyB,SAAQ,yBAAyB;IACzE,aAAa,EAAE,kBAAkB,CAAC;CACnC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
|
|
3
|
-
exports.
|
|
4
|
-
(function (
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
})(exports.
|
|
3
|
+
exports.AttributeOperation = void 0;
|
|
4
|
+
(function (AttributeOperation) {
|
|
5
|
+
AttributeOperation["UPSERT"] = "upsert";
|
|
6
|
+
AttributeOperation["DELETE"] = "delete";
|
|
7
|
+
})(exports.AttributeOperation || (exports.AttributeOperation = {}));
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { ResourceAttributeAssignment as ResourceAttributeAssignmentContract, EntityAttributeAssignment as EntityAttributeAssignmentContract, EntityType, ResourceAttributeOperation, EntityAttributeOperation } from './authorization-attributes-contracts';
|
|
2
|
+
import { ResourceAttributeAssignment } from '../resource-attribute-assignment';
|
|
3
|
+
import { EntityAttributeAssignment } from '../entity-attribute-assignment';
|
|
4
|
+
import { Resource } from './general';
|
|
5
|
+
/**
|
|
6
|
+
* Resource type compatible with both MS and SNS services
|
|
7
|
+
*/
|
|
8
|
+
export interface CompatibleResource {
|
|
9
|
+
resourceType?: string;
|
|
10
|
+
resourceId?: number;
|
|
11
|
+
type?: string;
|
|
12
|
+
id?: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Interface for authorization attributes operations.
|
|
16
|
+
* Both MS (direct) and SNS (async) services implement this interface.
|
|
17
|
+
*/
|
|
18
|
+
export interface IAuthorizationAttributesService {
|
|
19
|
+
/**
|
|
20
|
+
* Upserts resource attributes.
|
|
21
|
+
* For MS service: returns Promise<void>
|
|
22
|
+
* For SNS service: requires appName and callerActionIdentifier, returns Promise<ResourceAttributesOperation[]>
|
|
23
|
+
*/
|
|
24
|
+
upsertResourceAttributes(accountId: number, resourceAttributeAssignments: ResourceAttributeAssignment[] | ResourceAttributeAssignmentContract[], appName?: string, callerActionIdentifier?: string): Promise<void | ResourceAttributeOperation[]>;
|
|
25
|
+
/**
|
|
26
|
+
* Deletes resource attributes.
|
|
27
|
+
* For MS service: returns Promise<void>
|
|
28
|
+
* For SNS service: requires appName and callerActionIdentifier, returns Promise<ResourceAttributesOperation[]>
|
|
29
|
+
*/
|
|
30
|
+
deleteResourceAttributes(accountId: number, resource: CompatibleResource | Resource, attributeKeys: string[], appName?: string, callerActionIdentifier?: string): Promise<void | ResourceAttributeOperation[]>;
|
|
31
|
+
/**
|
|
32
|
+
* Upserts entity attributes.
|
|
33
|
+
* For MS service: returns Promise<void>
|
|
34
|
+
* For SNS service: requires appName and callerActionIdentifier, returns Promise<EntityAttributesOperation[]>
|
|
35
|
+
*/
|
|
36
|
+
upsertEntityAttributes(accountId: number, entityAttributeAssignments: EntityAttributeAssignment[] | EntityAttributeAssignmentContract[], appName?: string, callerActionIdentifier?: string): Promise<void | EntityAttributeOperation[]>;
|
|
37
|
+
/**
|
|
38
|
+
* Deletes entity attributes.
|
|
39
|
+
* For MS service: returns Promise<void>
|
|
40
|
+
* For SNS service: requires appName and callerActionIdentifier, returns Promise<EntityAttributesOperation[]>
|
|
41
|
+
*/
|
|
42
|
+
deleteEntityAttributes(accountId: number, entityType: EntityType | string, entityId: number, attributeKeys: string[], appName?: string, callerActionIdentifier?: string): Promise<void | EntityAttributeOperation[]>;
|
|
43
|
+
/**
|
|
44
|
+
* Updates resource attributes (batch operations).
|
|
45
|
+
* For MS service: may throw error or delegate to upsert/delete
|
|
46
|
+
* For SNS service: returns Promise<ResourceAttributesOperation[]>
|
|
47
|
+
*/
|
|
48
|
+
updateResourceAttributes(accountId: number, appName: string, callerActionIdentifier: string, resourceAttributeOperations: ResourceAttributeOperation[]): Promise<ResourceAttributeOperation[]>;
|
|
49
|
+
/**
|
|
50
|
+
* Updates entity attributes (batch operations).
|
|
51
|
+
* For MS service: may throw error or delegate to upsert/delete
|
|
52
|
+
* For SNS service: returns Promise<EntityAttributesOperation[]>
|
|
53
|
+
*/
|
|
54
|
+
updateEntityAttributes(accountId: number, appName: string, callerActionIdentifier: string, entityAttributeOperations: EntityAttributeOperation[]): Promise<EntityAttributeOperation[]>;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=authorization-attributes-service.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorization-attributes-service.interface.d.ts","sourceRoot":"","sources":["../../src/types/authorization-attributes-service.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,IAAI,m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AAS,EAAE,MAAM,EACjB,UAAU,EAAE,UAAU,GAAG,MAAM,EAC/B,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,EAAE,EACvB,OAAO,CAAC,EAAE,MAAM,EAChB,sBAAsB,CAAC,EAAE,MAAM,GAC9B,OAAO,CAAC,IAAI,GAAG,wBAAwB,EAAE,CAAC,CAAC;IAE9C;;;;OAIG;IACH,wBAAwB,CACtB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,sBAAsB,EAAE,MAAM,EAC9B,2BAA2B,EAAE,0BAA0B,EAAE,GACxD,OAAO,CAAC,0BAA0B,EAAE,CAAC,CAAC;IAEzC;;;;OAIG;IACH,sBAAsB,CACpB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,sBAAsB,EAAE,MAAM,EAC9B,yBAAyB,EAAE,wBAAwB,EAAE,GACpD,OAAO,CAAC,wBAAwB,EAAE,CAAC,CAAC;CACxC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/dist/types/general.d.ts
CHANGED
|
@@ -4,7 +4,6 @@ export interface Resource {
|
|
|
4
4
|
type: string;
|
|
5
5
|
wrapperData?: object;
|
|
6
6
|
}
|
|
7
|
-
export type Action = string;
|
|
8
7
|
export interface Context {
|
|
9
8
|
accountId: number;
|
|
10
9
|
userId: number;
|
|
@@ -13,7 +12,7 @@ export interface AuthorizationObject {
|
|
|
13
12
|
resource_id?: Resource['id'];
|
|
14
13
|
resource_type: Resource['type'];
|
|
15
14
|
wrapper_data?: Resource['wrapperData'];
|
|
16
|
-
action:
|
|
15
|
+
action: string;
|
|
17
16
|
}
|
|
18
17
|
export interface AuthorizationParams {
|
|
19
18
|
authorizationObjects: AuthorizationObject[];
|
|
@@ -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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gB,CAAC,CAAC;AACtD,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,EAAE,WAAW,KAAK,QAAQ,EAAE,CAAC;AAClE,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,EAAE,WAAW,KAAK,OAAO,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility class for common validation operations using Zod
|
|
3
|
+
*/
|
|
4
|
+
export declare class ValidationUtils {
|
|
5
|
+
/**
|
|
6
|
+
* Validates that a value is an integer
|
|
7
|
+
* @param value The value to validate
|
|
8
|
+
* @param fieldName The name of the field for error messages
|
|
9
|
+
* @throws ArgumentError if value is not an integer
|
|
10
|
+
*/
|
|
11
|
+
static validateInteger(value: any, fieldName: string): void;
|
|
12
|
+
/**
|
|
13
|
+
* Validates that a value is a non-empty string
|
|
14
|
+
* @param value The value to validate
|
|
15
|
+
* @param fieldName The name of the field for error messages
|
|
16
|
+
* @throws ArgumentError if value is not a string or is empty
|
|
17
|
+
*/
|
|
18
|
+
static validateString(value: any, fieldName: string): void;
|
|
19
|
+
/**
|
|
20
|
+
* Validates that a value is an array and optionally checks minimum length
|
|
21
|
+
* @param value The value to validate
|
|
22
|
+
* @param fieldName The name of the field for error messages
|
|
23
|
+
* @param minLength Minimum required length (default: 0)
|
|
24
|
+
* @returns The validated array
|
|
25
|
+
* @throws ArgumentError if value is not an array or doesn't meet minimum length
|
|
26
|
+
*/
|
|
27
|
+
static validateArray<T>(value: any, fieldName: string, minLength?: number): T[];
|
|
28
|
+
/**
|
|
29
|
+
* Validates that a value is one of the allowed enum values
|
|
30
|
+
* @param value The value to validate
|
|
31
|
+
* @param validValues Array of valid values
|
|
32
|
+
* @param fieldName The name of the field for error messages
|
|
33
|
+
* @returns The validated value as the enum type
|
|
34
|
+
* @throws ArgumentError if value is not in validValues
|
|
35
|
+
*/
|
|
36
|
+
static validateEnum<T extends string>(value: string, validValues: readonly T[], fieldName: string): T;
|
|
37
|
+
/**
|
|
38
|
+
* Validates that all items in an array are strings
|
|
39
|
+
* @param value Array to validate
|
|
40
|
+
* @param fieldName The name of the field for error messages
|
|
41
|
+
* @throws ArgumentError if any item is not a string
|
|
42
|
+
*/
|
|
43
|
+
static validateStringArray(value: any[], fieldName: string): void;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,qBAAa,eAAe;IAC1B;;;;;OAKG;IACH,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;IAY3D;;;;;OAKG;IACH,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;IAe1D;;;;;;;OAOG;IACH,MAAM,CAAC,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,SAAI,GAAG,CAAC,EAAE;IAe1E;;;;;;;OAOG;IACH,MAAM,CAAC,YAAY,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,CAAC;IAYrG;;;;;OAKG;IACH,MAAM,CAAC,mBAAmB,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;CAkBlE"}
|