@mondaydotcomorg/monday-authorization 3.5.3-feat-shaime-support-entity-attributes-in-authorization-sdk-ade64f6 → 3.7.0-feat-shaime-support-entity-attributes-4-49e1de0
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 +6 -8
- package/dist/authorization-attributes-ms-service.d.ts.map +1 -1
- package/dist/authorization-attributes-ms-service.js +16 -95
- package/dist/authorization-attributes-service.d.ts +1 -2
- package/dist/authorization-attributes-service.d.ts.map +1 -1
- package/dist/authorization-attributes-service.js +0 -1
- package/dist/authorization-attributes-sns-service.d.ts +4 -3
- package/dist/authorization-attributes-sns-service.d.ts.map +1 -1
- 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 +2 -0
- package/dist/base-attribute-assignment.d.ts.map +1 -1
- package/dist/base-attribute-assignment.js +11 -18
- package/dist/entity-attribute-assignment.d.ts +6 -0
- package/dist/entity-attribute-assignment.d.ts.map +1 -1
- package/dist/entity-attribute-assignment.js +9 -1
- package/dist/entity-attributes-constants.d.ts +6 -6
- package/dist/entity-attributes-constants.d.ts.map +1 -1
- package/dist/entity-attributes-constants.js +7 -5
- package/dist/errors/argument-error.d.ts.map +1 -1
- package/dist/errors/argument-error.js +0 -1
- package/dist/esm/authorization-attributes-ms-service.d.ts +6 -8
- package/dist/esm/authorization-attributes-ms-service.d.ts.map +1 -1
- package/dist/esm/authorization-attributes-ms-service.mjs +16 -95
- package/dist/esm/authorization-attributes-service.d.ts +1 -2
- package/dist/esm/authorization-attributes-service.d.ts.map +1 -1
- package/dist/esm/authorization-attributes-service.mjs +0 -1
- package/dist/esm/authorization-attributes-sns-service.d.ts +4 -3
- package/dist/esm/authorization-attributes-sns-service.d.ts.map +1 -1
- 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 +2 -0
- package/dist/esm/base-attribute-assignment.d.ts.map +1 -1
- package/dist/esm/base-attribute-assignment.mjs +7 -18
- package/dist/esm/entity-attribute-assignment.d.ts +6 -0
- package/dist/esm/entity-attribute-assignment.d.ts.map +1 -1
- package/dist/esm/entity-attribute-assignment.mjs +9 -1
- package/dist/esm/entity-attributes-constants.d.ts +6 -6
- package/dist/esm/entity-attributes-constants.d.ts.map +1 -1
- package/dist/esm/entity-attributes-constants.mjs +8 -6
- package/dist/esm/errors/argument-error.d.ts.map +1 -1
- package/dist/esm/errors/argument-error.mjs +0 -1
- package/dist/esm/index.d.ts +0 -9
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.mjs +0 -7
- package/dist/esm/prometheus-service.d.ts +2 -1
- package/dist/esm/prometheus-service.d.ts.map +1 -1
- package/dist/esm/resource-attribute-assignment.d.ts +7 -1
- package/dist/esm/resource-attribute-assignment.d.ts.map +1 -1
- package/dist/esm/resource-attribute-assignment.mjs +8 -0
- package/dist/esm/resource-attributes-constants.d.ts +12 -2
- package/dist/esm/resource-attributes-constants.d.ts.map +1 -1
- package/dist/esm/resource-attributes-constants.mjs +15 -12
- package/dist/esm/types/authorization-attributes-contracts.d.ts +1 -1
- package/dist/esm/types/authorization-attributes-contracts.d.ts.map +1 -1
- package/dist/esm/types/authorization-attributes-service.interface.d.ts +4 -3
- package/dist/esm/types/authorization-attributes-service.interface.d.ts.map +1 -1
- package/dist/esm/types/general.d.ts +2 -1
- package/dist/esm/types/general.d.ts.map +1 -1
- package/dist/esm/utils/validation.d.ts +30 -30
- package/dist/esm/utils/validation.d.ts.map +1 -1
- package/dist/esm/utils/validation.mjs +121 -86
- package/dist/index.d.ts +0 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -15
- package/dist/prometheus-service.d.ts +2 -1
- package/dist/prometheus-service.d.ts.map +1 -1
- package/dist/resource-attribute-assignment.d.ts +7 -1
- package/dist/resource-attribute-assignment.d.ts.map +1 -1
- package/dist/resource-attribute-assignment.js +8 -0
- package/dist/resource-attributes-constants.d.ts +12 -2
- package/dist/resource-attributes-constants.d.ts.map +1 -1
- package/dist/resource-attributes-constants.js +14 -11
- package/dist/types/authorization-attributes-contracts.d.ts +1 -1
- package/dist/types/authorization-attributes-contracts.d.ts.map +1 -1
- package/dist/types/authorization-attributes-service.interface.d.ts +4 -3
- package/dist/types/authorization-attributes-service.interface.d.ts.map +1 -1
- package/dist/types/general.d.ts +2 -1
- package/dist/types/general.d.ts.map +1 -1
- package/dist/utils/validation.d.ts +30 -30
- package/dist/utils/validation.d.ts.map +1 -1
- package/dist/utils/validation.js +125 -86
- package/package.json +4 -3
- package/src/authorization-attributes-ms-service.ts +23 -117
- package/src/authorization-attributes-service.ts +1 -2
- package/src/authorization-attributes-sns-service.ts +3 -3
- package/src/authorization-middleware.ts +2 -2
- package/src/authorization-service.ts +4 -4
- package/src/base-attribute-assignment.ts +14 -23
- package/src/entity-attribute-assignment.ts +10 -1
- package/src/entity-attributes-constants.ts +6 -6
- package/src/errors/argument-error.ts +0 -1
- package/src/index.ts +0 -9
- package/src/prometheus-service.ts +3 -1
- package/src/resource-attribute-assignment.ts +10 -1
- package/src/resource-attributes-constants.ts +13 -21
- package/src/types/authorization-attributes-contracts.ts +0 -2
- package/src/types/authorization-attributes-service.interface.ts +3 -3
- package/src/types/general.ts +2 -3
- package/src/utils/validation.ts +139 -82
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { ResourceAttributeAssignment as ResourceAttributeAssignmentContract, EntityAttributeAssignment as EntityAttributeAssignmentContract,
|
|
1
|
+
import { ResourceAttributeAssignment as ResourceAttributeAssignmentContract, EntityAttributeAssignment as EntityAttributeAssignmentContract, ResourceAttributeOperation, EntityAttributeOperation } from './authorization-attributes-contracts';
|
|
2
2
|
import { ResourceAttributeAssignment } from '../resource-attribute-assignment';
|
|
3
3
|
import { EntityAttributeAssignment } from '../entity-attribute-assignment';
|
|
4
4
|
import { Resource } from './general';
|
|
5
|
+
import { EntityType } from '../entity-attributes-constants';
|
|
5
6
|
/**
|
|
6
7
|
* Resource type compatible with both MS and SNS services
|
|
7
8
|
*/
|
|
@@ -15,8 +16,8 @@ export interface CompatibleResource {
|
|
|
15
16
|
* Interface for authorization attributes operations.
|
|
16
17
|
* Both MS (direct) and SNS (async) services implement this interface.
|
|
17
18
|
*/
|
|
18
|
-
export interface
|
|
19
|
-
/**
|
|
19
|
+
export interface AuthorizationAttributesService {
|
|
20
|
+
/**authorization-attributes-service.ts
|
|
20
21
|
* Upserts resource attributes.
|
|
21
22
|
* For MS service: returns Promise<void>
|
|
22
23
|
* For SNS service: requires appName and callerActionIdentifier, returns Promise<ResourceAttributesOperation[]>
|
|
@@ -1 +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,mCAAmC,EAClE,yBAAyB,IAAI,iCAAiC,EAC9D,
|
|
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,mCAAmC,EAClE,yBAAyB,IAAI,iCAAiC,EAC9D,0BAA0B,EAC1B,wBAAwB,EACzB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAE5D;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED;;;GAGG;AACH,MAAM,WAAW,8BAA8B;IAC7C;;;;OAIG;IACH,wBAAwB,CACtB,SAAS,EAAE,MAAM,EACjB,4BAA4B,EAAE,2BAA2B,EAAE,GAAG,mCAAmC,EAAE,EACnG,OAAO,CAAC,EAAE,MAAM,EAChB,sBAAsB,CAAC,EAAE,MAAM,GAC9B,OAAO,CAAC,IAAI,GAAG,0BAA0B,EAAE,CAAC,CAAC;IAEhD;;;;OAIG;IACH,wBAAwB,CACtB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,kBAAkB,GAAG,QAAQ,EACvC,aAAa,EAAE,MAAM,EAAE,EACvB,OAAO,CAAC,EAAE,MAAM,EAChB,sBAAsB,CAAC,EAAE,MAAM,GAC9B,OAAO,CAAC,IAAI,GAAG,0BAA0B,EAAE,CAAC,CAAC;IAEhD;;;;OAIG;IACH,sBAAsB,CACpB,SAAS,EAAE,MAAM,EACjB,0BAA0B,EAAE,yBAAyB,EAAE,GAAG,iCAAiC,EAAE,EAC7F,OAAO,CAAC,EAAE,MAAM,EAChB,sBAAsB,CAAC,EAAE,MAAM,GAC9B,OAAO,CAAC,IAAI,GAAG,wBAAwB,EAAE,CAAC,CAAC;IAE9C;;;;OAIG;IACH,sBAAsB,CACpB,SAAS,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"}
|
|
@@ -4,6 +4,7 @@ export interface Resource {
|
|
|
4
4
|
type: string;
|
|
5
5
|
wrapperData?: object;
|
|
6
6
|
}
|
|
7
|
+
export type Action = string;
|
|
7
8
|
export interface Context {
|
|
8
9
|
accountId: number;
|
|
9
10
|
userId: number;
|
|
@@ -12,7 +13,7 @@ export interface AuthorizationObject {
|
|
|
12
13
|
resource_id?: Resource['id'];
|
|
13
14
|
resource_type: Resource['type'];
|
|
14
15
|
wrapper_data?: Resource['wrapperData'];
|
|
15
|
-
action:
|
|
16
|
+
action: Action;
|
|
16
17
|
}
|
|
17
18
|
export interface AuthorizationParams {
|
|
18
19
|
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,MAAM,SAAS,CAAC;AAEjD,MAAM,WAAW,QAAQ;IACvB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;
|
|
1
|
+
{"version":3,"file":"general.d.ts","sourceRoot":"","sources":["../../../src/types/general.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEjD,MAAM,WAAW,QAAQ;IACvB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AACD,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC;AAC5B,MAAM,WAAW,OAAO;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB;AACD,MAAM,WAAW,mBAAmB;IAClC,WAAW,CAAC,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC7B,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAChC,YAAY,CAAC,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC;IACvC,MAAM,EAAE,MAAM,CAAC;CAChB;AACD,MAAM,WAAW,mBAAmB;IAClC,oBAAoB,EAAE,mBAAmB,EAAE,CAAC;CAC7C;AAED,KAAK,WAAW,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC;AAE9C,MAAM,MAAM,cAAc,GAAG,WAAW,CAAC;AACzC,MAAM,MAAM,gBAAgB,GAAG,WAAW,CAAC;AAC3C,MAAM,MAAM,kBAAkB,GAAG,WAAW,CAAC;AAC7C,MAAM,MAAM,mBAAmB,GAAG,WAAW,CAAC;AAC9C,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC,cAAc,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,mBAAmB,CAAC,CAAC;AAC7G,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAC,gBAAgB,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"}
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
+
import { Resource } from '../types/general';
|
|
1
2
|
/**
|
|
2
|
-
* Utility class for common validation operations using
|
|
3
|
+
* Utility class for common validation operations using AJV
|
|
3
4
|
*/
|
|
4
5
|
export declare class ValidationUtils {
|
|
6
|
+
private static ajv;
|
|
5
7
|
/**
|
|
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
|
|
8
|
+
* Validates that a value is an integer. Throws ArgumentError with a descriptive message on failure.
|
|
10
9
|
*/
|
|
11
|
-
static validateInteger(value:
|
|
10
|
+
static validateInteger(value: number): void;
|
|
12
11
|
/**
|
|
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
|
|
12
|
+
* Validates that a value is a non-empty string. Throws ArgumentError on failure.
|
|
17
13
|
*/
|
|
18
|
-
static validateString(value:
|
|
14
|
+
static validateString(value: string): void;
|
|
19
15
|
/**
|
|
20
|
-
* Validates that a value is an array
|
|
21
|
-
*
|
|
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
|
|
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.
|
|
26
18
|
*/
|
|
27
|
-
static
|
|
19
|
+
static validateStringArray(value: string[]): void;
|
|
28
20
|
/**
|
|
29
|
-
* Validates
|
|
30
|
-
*
|
|
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
|
|
21
|
+
* Validates an attribute assignment object using a single AJV schema.
|
|
22
|
+
* Preserves legacy error messages for each field.
|
|
35
23
|
*/
|
|
36
|
-
static
|
|
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
|
+
};
|
|
37
38
|
/**
|
|
38
|
-
* Validates
|
|
39
|
-
*
|
|
40
|
-
* @param fieldName The name of the field for error messages
|
|
41
|
-
* @throws ArgumentError if any item is not a string
|
|
39
|
+
* Validates a Resource-like object shape: { id: number; type: string }.
|
|
40
|
+
* Throws ArgumentError with legacy-compatible messages.
|
|
42
41
|
*/
|
|
43
|
-
static
|
|
42
|
+
static validateResource(resource: Resource): void;
|
|
43
|
+
static validateArrayTypeOf<T>(attributesMessages: T[], messageClass: abstract new (...args: any[]) => T): void;
|
|
44
44
|
}
|
|
45
45
|
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../src/utils/validation.ts"],"names":[],"mappings":"
|
|
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,115 +1,150 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Ajv from 'ajv';
|
|
2
2
|
import { ArgumentError } from '../errors/argument-error.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Utility class for common validation operations using
|
|
5
|
+
* Utility class for common validation operations using AJV
|
|
6
6
|
*/
|
|
7
7
|
class ValidationUtils {
|
|
8
|
+
static ajv = new Ajv({ allErrors: true });
|
|
8
9
|
/**
|
|
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
|
|
10
|
+
* Validates that a value is an integer. Throws ArgumentError with a descriptive message on failure.
|
|
13
11
|
*/
|
|
14
|
-
static validateInteger(value
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (error instanceof z.ZodError) {
|
|
21
|
-
throw new ArgumentError(`${fieldName} must be an integer, got: ${value}`);
|
|
22
|
-
}
|
|
23
|
-
throw error;
|
|
12
|
+
static validateInteger(value) {
|
|
13
|
+
const numberSchema = { type: 'number', multipleOf: 1 };
|
|
14
|
+
const validate = ValidationUtils.ajv.compile(numberSchema);
|
|
15
|
+
const isValid = validate(value);
|
|
16
|
+
if (!isValid) {
|
|
17
|
+
throw new ArgumentError(`Value must be an integer, got: ${value}`);
|
|
24
18
|
}
|
|
25
19
|
}
|
|
26
20
|
/**
|
|
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
|
|
21
|
+
* Validates that a value is a non-empty string. Throws ArgumentError on failure.
|
|
31
22
|
*/
|
|
32
|
-
static validateString(value
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
throw new ArgumentError(`${fieldName} must be a non-empty string`);
|
|
43
|
-
}
|
|
44
|
-
throw error;
|
|
23
|
+
static validateString(value) {
|
|
24
|
+
const non_empty_string_schema = {
|
|
25
|
+
type: 'string',
|
|
26
|
+
minLength: 1,
|
|
27
|
+
pattern: '\\S',
|
|
28
|
+
};
|
|
29
|
+
const validate = ValidationUtils.ajv.compile(non_empty_string_schema);
|
|
30
|
+
const isValid = validate(value);
|
|
31
|
+
if (!isValid) {
|
|
32
|
+
throw new ArgumentError(`Value must be a non-empty string, got: ${value}`);
|
|
45
33
|
}
|
|
46
34
|
}
|
|
47
35
|
/**
|
|
48
|
-
* Validates that a value is an array
|
|
49
|
-
*
|
|
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
|
|
36
|
+
* Validates that a value is an array of non-empty strings. Throws ArgumentError on failure.
|
|
37
|
+
* Allows empty arrays - caller should handle early return.
|
|
54
38
|
*/
|
|
55
|
-
static
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
throw
|
|
39
|
+
static validateStringArray(value) {
|
|
40
|
+
const string_array_schema = {
|
|
41
|
+
type: 'array',
|
|
42
|
+
items: {
|
|
43
|
+
type: 'string',
|
|
44
|
+
minLength: 1,
|
|
45
|
+
pattern: '\\S',
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
const validateStringArray = ValidationUtils.ajv.compile(string_array_schema);
|
|
49
|
+
const isValid = validateStringArray(value);
|
|
50
|
+
if (!isValid) {
|
|
51
|
+
throw new ArgumentError(`Value must be an array of non-empty strings, got: ${value}`);
|
|
68
52
|
}
|
|
53
|
+
// Allow empty arrays to pass validation - caller should handle early return
|
|
54
|
+
// Non-empty arrays will be validated for string content above
|
|
69
55
|
}
|
|
70
56
|
/**
|
|
71
|
-
* Validates
|
|
72
|
-
*
|
|
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
|
|
57
|
+
* Validates an attribute assignment object using a single AJV schema.
|
|
58
|
+
* Preserves legacy error messages for each field.
|
|
77
59
|
*/
|
|
78
|
-
static
|
|
79
|
-
const schema =
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
60
|
+
static validateAssignment(data, validTypes, fieldNames) {
|
|
61
|
+
const schema = {
|
|
62
|
+
type: 'object',
|
|
63
|
+
properties: {
|
|
64
|
+
id: { type: 'number', multipleOf: 1 },
|
|
65
|
+
type: { type: 'string', enum: validTypes },
|
|
66
|
+
attributeKey: { type: 'string', minLength: 1 },
|
|
67
|
+
attributeValue: { type: 'string', minLength: 1 },
|
|
68
|
+
},
|
|
69
|
+
required: ['id', 'type', 'attributeKey', 'attributeValue'],
|
|
70
|
+
additionalProperties: false,
|
|
71
|
+
};
|
|
72
|
+
const validate = this.ajv.compile(schema);
|
|
73
|
+
const valid = validate(data);
|
|
74
|
+
if (!valid) {
|
|
75
|
+
// Map to legacy error messages deterministically
|
|
76
|
+
const { id, type, attributeKey, attributeValue } = data;
|
|
77
|
+
// id must be integer
|
|
78
|
+
const isInteger = typeof id === 'number' && Number.isFinite(id) && Math.floor(id) === id;
|
|
79
|
+
if (!isInteger) {
|
|
80
|
+
throw new ArgumentError(`${fieldNames.id} must be an integer, got: ${id}`);
|
|
81
|
+
}
|
|
82
|
+
// type must be within enum
|
|
83
|
+
if (typeof type !== 'string' || !validTypes.includes(type)) {
|
|
84
|
+
throw new ArgumentError(`${fieldNames.type} must be one of [${validTypes.join(', ')}], got: ${type}`);
|
|
86
85
|
}
|
|
87
|
-
|
|
86
|
+
// attributeKey
|
|
87
|
+
if (typeof attributeKey !== 'string') {
|
|
88
|
+
throw new ArgumentError(`attributeKey must be a string, got: ${typeof attributeKey}`);
|
|
89
|
+
}
|
|
90
|
+
if (!attributeKey) {
|
|
91
|
+
throw new ArgumentError('attributeKey must be a non-empty string');
|
|
92
|
+
}
|
|
93
|
+
// attributeValue
|
|
94
|
+
if (typeof attributeValue !== 'string') {
|
|
95
|
+
throw new ArgumentError(`attributeValue must be a string, got: ${typeof attributeValue}`);
|
|
96
|
+
}
|
|
97
|
+
if (!attributeValue) {
|
|
98
|
+
throw new ArgumentError('attributeValue must be a non-empty string');
|
|
99
|
+
}
|
|
100
|
+
// Fallback
|
|
101
|
+
throw new ArgumentError('Invalid attribute assignment');
|
|
88
102
|
}
|
|
103
|
+
return {
|
|
104
|
+
id: data.id,
|
|
105
|
+
type: data.type,
|
|
106
|
+
attributeKey: data.attributeKey,
|
|
107
|
+
attributeValue: data.attributeValue,
|
|
108
|
+
};
|
|
89
109
|
}
|
|
90
110
|
/**
|
|
91
|
-
* Validates
|
|
92
|
-
*
|
|
93
|
-
* @param fieldName The name of the field for error messages
|
|
94
|
-
* @throws ArgumentError if any item is not a string
|
|
111
|
+
* Validates a Resource-like object shape: { id: number; type: string }.
|
|
112
|
+
* Throws ArgumentError with legacy-compatible messages.
|
|
95
113
|
*/
|
|
96
|
-
static
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
114
|
+
static validateResource(resource) {
|
|
115
|
+
if (!resource || typeof resource !== 'object') {
|
|
116
|
+
throw new ArgumentError('resource must be an object');
|
|
117
|
+
}
|
|
118
|
+
const schema = {
|
|
119
|
+
type: 'object',
|
|
120
|
+
properties: {
|
|
121
|
+
id: { type: 'number', multipleOf: 1 },
|
|
122
|
+
type: { type: 'string', minLength: 1 },
|
|
123
|
+
wrapperData: { type: 'string' },
|
|
124
|
+
},
|
|
125
|
+
required: ['type', 'id'],
|
|
126
|
+
additionalProperties: false,
|
|
127
|
+
};
|
|
128
|
+
const validate = this.ajv.compile(schema);
|
|
129
|
+
const isValid = validate(resource);
|
|
130
|
+
if (!isValid) {
|
|
131
|
+
throw new ArgumentError('Invalid resource');
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
static validateArrayTypeOf(attributesMessages, messageClass) {
|
|
135
|
+
const arraySchema = {
|
|
136
|
+
type: 'array',
|
|
137
|
+
};
|
|
138
|
+
const validateArray = ValidationUtils.ajv.compile(arraySchema);
|
|
139
|
+
const isArrayValid = validateArray(attributesMessages);
|
|
140
|
+
if (!isArrayValid) {
|
|
141
|
+
throw new ArgumentError(`attributesMessages must be an array`);
|
|
100
142
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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`);
|
|
143
|
+
for (let i = 0; i < attributesMessages.length; i++) {
|
|
144
|
+
const item = attributesMessages[i];
|
|
145
|
+
if (!(item instanceof messageClass)) {
|
|
146
|
+
throw new ArgumentError(`attributesMessages[${i}] must be an instance of ${messageClass.name}, got: ${item?.constructor?.name || typeof item}`);
|
|
111
147
|
}
|
|
112
|
-
throw error;
|
|
113
148
|
}
|
|
114
149
|
}
|
|
115
150
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -19,15 +19,6 @@ 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';
|
|
31
22
|
export { RolesService } from './roles-service';
|
|
32
23
|
export { MembershipsService } from './memberships';
|
|
33
24
|
export { AuthorizationObject, Resource, BaseRequest, ResourceGetter, ContextGetter } from './types/general';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAGnE,OAAO,EAAqB,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,UAAU,kBAAkB;IAC1B,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,WAAW,CAAC,EAAE,GAAG,CAAC;IAClB,sCAAsC,CAAC,EAAE,MAAM,CAAC;IAChD,OAAO,CAAC,EAAE,kBAAkB,CAAC;CAC9B;AAED,wBAAsB,IAAI,CAAC,OAAO,GAAE,WAAgB,iBA6BnD;AAED,OAAO,EACL,4BAA4B,EAC5B,0BAA0B,EAC1B,2BAA2B,GAC5B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAClF,OAAO,EAAE,8BAA8B,EAAE,MAAM,oCAAoC,CAAC;AACpF,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAGnE,OAAO,EAAqB,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,UAAU,kBAAkB;IAC1B,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,WAAW,CAAC,EAAE,GAAG,CAAC;IAClB,sCAAsC,CAAC,EAAE,MAAM,CAAC;IAChD,OAAO,CAAC,EAAE,kBAAkB,CAAC;CAC9B;AAED,wBAAsB,IAAI,CAAC,OAAO,GAAE,WAAgB,iBA6BnD;AAED,OAAO,EACL,4BAA4B,EAC5B,0BAA0B,EAC1B,2BAA2B,GAC5B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAClF,OAAO,EAAE,8BAA8B,EAAE,MAAM,oCAAoC,CAAC;AACpF,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,13 +6,6 @@ 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');
|
|
16
9
|
const rolesService = require('./roles-service.js');
|
|
17
10
|
const memberships = require('./memberships.js');
|
|
18
11
|
const types_roles = require('./types/roles.js');
|
|
@@ -51,14 +44,6 @@ exports.authorizationCheckMiddleware = authorizationMiddleware.authorizationChec
|
|
|
51
44
|
exports.getAuthorizationMiddleware = authorizationMiddleware.getAuthorizationMiddleware;
|
|
52
45
|
exports.skipAuthorizationMiddleware = authorizationMiddleware.skipAuthorizationMiddleware;
|
|
53
46
|
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;
|
|
62
47
|
exports.RolesService = rolesService.RolesService;
|
|
63
48
|
exports.MembershipsService = memberships.MembershipsService;
|
|
64
49
|
Object.defineProperty(exports, 'RoleType', {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Action } from './types/general';
|
|
1
2
|
export declare const METRICS: {
|
|
2
3
|
AUTHORIZATION_CHECK: string;
|
|
3
4
|
AUTHORIZATION_CHECKS_PER_REQUEST: string;
|
|
@@ -5,5 +6,5 @@ export declare const METRICS: {
|
|
|
5
6
|
};
|
|
6
7
|
export declare function setPrometheus(customPrometheus: any): void;
|
|
7
8
|
export declare function getMetricsManager(): any;
|
|
8
|
-
export declare function sendAuthorizationCheckResponseTimeMetric(resourceType: string, action:
|
|
9
|
+
export declare function sendAuthorizationCheckResponseTimeMetric(resourceType: string, action: Action, isAuthorized: boolean, responseStatus: number, time: number): void;
|
|
9
10
|
//# 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":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAKzC,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"}
|
|
@@ -3,7 +3,13 @@ import { BaseAttributeAssignment } from './base-attribute-assignment';
|
|
|
3
3
|
export declare class ResourceAttributeAssignment extends BaseAttributeAssignment<number, ResourceType> {
|
|
4
4
|
readonly resourceId: number;
|
|
5
5
|
readonly resourceType: ResourceType;
|
|
6
|
-
constructor(resourceId: number, resourceType:
|
|
6
|
+
constructor(resourceId: number, resourceType: ResourceType, attributeKey: string, attributeValue: string);
|
|
7
|
+
toDataTransferObject(): {
|
|
8
|
+
resourceId: number;
|
|
9
|
+
resourceType: ResourceType;
|
|
10
|
+
key: string;
|
|
11
|
+
value: string;
|
|
12
|
+
};
|
|
7
13
|
/**
|
|
8
14
|
* Compares two assignments for equality
|
|
9
15
|
* @param other Another ResourceAttributeAssignment instance
|
|
@@ -1 +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,
|
|
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,YAAY,EAAE,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;IAcxG,oBAAoB;;;;;;IAQpB;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,2BAA2B,GAAG,OAAO;CAGpD"}
|
|
@@ -11,6 +11,14 @@ class ResourceAttributeAssignment extends baseAttributeAssignment.BaseAttributeA
|
|
|
11
11
|
this.resourceId = resourceId;
|
|
12
12
|
this.resourceType = this.type;
|
|
13
13
|
}
|
|
14
|
+
toDataTransferObject() {
|
|
15
|
+
return {
|
|
16
|
+
resourceId: this.resourceId,
|
|
17
|
+
resourceType: this.resourceType,
|
|
18
|
+
key: this.attributeKey,
|
|
19
|
+
value: this.attributeValue,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
14
22
|
/**
|
|
15
23
|
* Compares two assignments for equality
|
|
16
24
|
* @param other Another ResourceAttributeAssignment instance
|
|
@@ -10,6 +10,16 @@ export declare const RESOURCE_ATTRIBUTES_CONSTANTS: {
|
|
|
10
10
|
readonly SYSTEM_ENTITY_TYPE: "system_entity_type";
|
|
11
11
|
};
|
|
12
12
|
};
|
|
13
|
-
export
|
|
14
|
-
|
|
13
|
+
export declare enum ResourceType {
|
|
14
|
+
Account = "account",
|
|
15
|
+
AccountProduct = "account_product",
|
|
16
|
+
Workspace = "workspace",
|
|
17
|
+
Board = "board",
|
|
18
|
+
Item = "item",
|
|
19
|
+
Team = "team",
|
|
20
|
+
Overview = "overview",
|
|
21
|
+
Document = "document",
|
|
22
|
+
Crm = "crm"
|
|
23
|
+
}
|
|
24
|
+
export declare const RESOURCE_TYPES: readonly ResourceType[];
|
|
15
25
|
//# sourceMappingURL=resource-attributes-constants.d.ts.map
|
|
@@ -1 +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,
|
|
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,oBAAY,YAAY;IACtB,OAAO,YAAY;IACnB,cAAc,oBAAoB;IAClC,SAAS,cAAc;IACvB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,IAAI,SAAS;IACb,QAAQ,aAAa;IACrB,QAAQ,aAAa;IACrB,GAAG,QAAQ;CACZ;AAGD,eAAO,MAAM,cAAc,yBAA6C,CAAC"}
|
|
@@ -12,17 +12,20 @@ const RESOURCE_ATTRIBUTES_CONSTANTS = {
|
|
|
12
12
|
SYSTEM_ENTITY_TYPE: 'system_entity_type',
|
|
13
13
|
},
|
|
14
14
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
15
|
+
exports.ResourceType = void 0;
|
|
16
|
+
(function (ResourceType) {
|
|
17
|
+
ResourceType["Account"] = "account";
|
|
18
|
+
ResourceType["AccountProduct"] = "account_product";
|
|
19
|
+
ResourceType["Workspace"] = "workspace";
|
|
20
|
+
ResourceType["Board"] = "board";
|
|
21
|
+
ResourceType["Item"] = "item";
|
|
22
|
+
ResourceType["Team"] = "team";
|
|
23
|
+
ResourceType["Overview"] = "overview";
|
|
24
|
+
ResourceType["Document"] = "document";
|
|
25
|
+
ResourceType["Crm"] = "crm";
|
|
26
|
+
})(exports.ResourceType || (exports.ResourceType = {}));
|
|
27
|
+
// Define the array of strings and use 'as const' to make its contents literal types
|
|
28
|
+
const RESOURCE_TYPES = Object.freeze(Object.values(exports.ResourceType));
|
|
26
29
|
|
|
27
30
|
exports.RESOURCE_ATTRIBUTES_CONSTANTS = RESOURCE_ATTRIBUTES_CONSTANTS;
|
|
28
31
|
exports.RESOURCE_TYPES = RESOURCE_TYPES;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Resource } from './general';
|
|
2
2
|
import type { EntityType } from '../entity-attributes-constants';
|
|
3
3
|
import type { ResourceType } from '../resource-attributes-constants';
|
|
4
|
-
export type { EntityType, ResourceType };
|
|
5
4
|
interface AttributeAssignment {
|
|
6
5
|
key: string;
|
|
7
6
|
value: string;
|
|
@@ -40,4 +39,5 @@ export interface ResourceAttributeOperation extends ResourceAttributeAssignment
|
|
|
40
39
|
export interface EntityAttributeOperation extends EntityAttributeAssignment {
|
|
41
40
|
operationType: AttributeOperation;
|
|
42
41
|
}
|
|
42
|
+
export {};
|
|
43
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;AACrC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAErE,
|
|
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,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,8 @@
|
|
|
1
|
-
import { ResourceAttributeAssignment as ResourceAttributeAssignmentContract, EntityAttributeAssignment as EntityAttributeAssignmentContract,
|
|
1
|
+
import { ResourceAttributeAssignment as ResourceAttributeAssignmentContract, EntityAttributeAssignment as EntityAttributeAssignmentContract, ResourceAttributeOperation, EntityAttributeOperation } from './authorization-attributes-contracts';
|
|
2
2
|
import { ResourceAttributeAssignment } from '../resource-attribute-assignment';
|
|
3
3
|
import { EntityAttributeAssignment } from '../entity-attribute-assignment';
|
|
4
4
|
import { Resource } from './general';
|
|
5
|
+
import { EntityType } from '../entity-attributes-constants';
|
|
5
6
|
/**
|
|
6
7
|
* Resource type compatible with both MS and SNS services
|
|
7
8
|
*/
|
|
@@ -15,8 +16,8 @@ export interface CompatibleResource {
|
|
|
15
16
|
* Interface for authorization attributes operations.
|
|
16
17
|
* Both MS (direct) and SNS (async) services implement this interface.
|
|
17
18
|
*/
|
|
18
|
-
export interface
|
|
19
|
-
/**
|
|
19
|
+
export interface AuthorizationAttributesService {
|
|
20
|
+
/**authorization-attributes-service.ts
|
|
20
21
|
* Upserts resource attributes.
|
|
21
22
|
* For MS service: returns Promise<void>
|
|
22
23
|
* For SNS service: requires appName and callerActionIdentifier, returns Promise<ResourceAttributesOperation[]>
|
|
@@ -1 +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,mCAAmC,EAClE,yBAAyB,IAAI,iCAAiC,EAC9D,
|
|
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,mCAAmC,EAClE,yBAAyB,IAAI,iCAAiC,EAC9D,0BAA0B,EAC1B,wBAAwB,EACzB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAE5D;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED;;;GAGG;AACH,MAAM,WAAW,8BAA8B;IAC7C;;;;OAIG;IACH,wBAAwB,CACtB,SAAS,EAAE,MAAM,EACjB,4BAA4B,EAAE,2BAA2B,EAAE,GAAG,mCAAmC,EAAE,EACnG,OAAO,CAAC,EAAE,MAAM,EAChB,sBAAsB,CAAC,EAAE,MAAM,GAC9B,OAAO,CAAC,IAAI,GAAG,0BAA0B,EAAE,CAAC,CAAC;IAEhD;;;;OAIG;IACH,wBAAwB,CACtB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,kBAAkB,GAAG,QAAQ,EACvC,aAAa,EAAE,MAAM,EAAE,EACvB,OAAO,CAAC,EAAE,MAAM,EAChB,sBAAsB,CAAC,EAAE,MAAM,GAC9B,OAAO,CAAC,IAAI,GAAG,0BAA0B,EAAE,CAAC,CAAC;IAEhD;;;;OAIG;IACH,sBAAsB,CACpB,SAAS,EAAE,MAAM,EACjB,0BAA0B,EAAE,yBAAyB,EAAE,GAAG,iCAAiC,EAAE,EAC7F,OAAO,CAAC,EAAE,MAAM,EAChB,sBAAsB,CAAC,EAAE,MAAM,GAC9B,OAAO,CAAC,IAAI,GAAG,wBAAwB,EAAE,CAAC,CAAC;IAE9C;;;;OAIG;IACH,sBAAsB,CACpB,SAAS,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"}
|