@mondaydotcomorg/monday-authorization 3.5.0-feat-use-profile-for-graph-can-action-in-scope-f1451ab → 3.5.0-feat-shaime-support-entity-attributes-in-authorization-sdk-397ce54
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 +37 -0
- package/dist/authorization-attributes-ms-service.d.ts.map +1 -0
- package/dist/authorization-attributes-ms-service.js +232 -0
- package/dist/authorization-attributes-service.d.ts +45 -1
- package/dist/authorization-attributes-service.d.ts.map +1 -1
- package/dist/authorization-attributes-service.js +262 -0
- package/dist/clients/graph-api.d.ts.map +1 -1
- package/dist/clients/graph-api.js +0 -1
- package/dist/constants.d.ts +0 -3
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +0 -4
- 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 +37 -0
- package/dist/esm/authorization-attributes-ms-service.d.ts.map +1 -0
- package/dist/esm/authorization-attributes-ms-service.mjs +230 -0
- package/dist/esm/authorization-attributes-service.d.ts +45 -1
- package/dist/esm/authorization-attributes-service.d.ts.map +1 -1
- package/dist/esm/authorization-attributes-service.mjs +263 -1
- package/dist/esm/clients/graph-api.d.ts.map +1 -1
- package/dist/esm/clients/graph-api.mjs +1 -2
- package/dist/esm/constants.d.ts +0 -3
- package/dist/esm/constants.d.ts.map +1 -1
- package/dist/esm/constants.mjs +1 -5
- 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 +5 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.mjs +4 -0
- package/dist/esm/resource-attribute-assignment.d.ts +25 -0
- package/dist/esm/resource-attribute-assignment.d.ts.map +1 -0
- package/dist/esm/resource-attribute-assignment.mjs +60 -0
- package/dist/esm/resource-attributes-constants.d.ts +25 -0
- package/dist/esm/resource-attributes-constants.d.ts.map +1 -0
- package/dist/esm/resource-attributes-constants.mjs +25 -0
- package/dist/esm/types/authorization-attributes-contracts.d.ts +19 -3
- package/dist/esm/types/authorization-attributes-contracts.d.ts.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -0
- package/dist/resource-attribute-assignment.d.ts +25 -0
- package/dist/resource-attribute-assignment.d.ts.map +1 -0
- package/dist/resource-attribute-assignment.js +62 -0
- package/dist/resource-attributes-constants.d.ts +25 -0
- package/dist/resource-attributes-constants.d.ts.map +1 -0
- package/dist/resource-attributes-constants.js +28 -0
- package/dist/types/authorization-attributes-contracts.d.ts +19 -3
- package/dist/types/authorization-attributes-contracts.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/authorization-attributes-ms-service.ts +327 -0
- package/src/authorization-attributes-service.ts +325 -0
- package/src/clients/graph-api.ts +1 -2
- package/src/constants.ts +0 -4
- package/src/errors/argument-error.ts +8 -0
- package/src/index.ts +16 -0
- package/src/resource-attribute-assignment.ts +70 -0
- package/src/resource-attributes-constants.ts +27 -0
- package/src/types/authorization-attributes-contracts.ts +49 -3
package/src/index.ts
CHANGED
|
@@ -58,6 +58,22 @@ export {
|
|
|
58
58
|
} from './authorization-middleware';
|
|
59
59
|
export { AuthorizationService, AuthorizeResponse } from './authorization-service';
|
|
60
60
|
export { AuthorizationAttributesService } from './authorization-attributes-service';
|
|
61
|
+
export { AuthorizationAttributesMsService } from './authorization-attributes-ms-service';
|
|
62
|
+
export { ResourceAttributeAssignment } from './resource-attribute-assignment';
|
|
63
|
+
export { RESOURCE_TYPES, RESOURCE_ATTRIBUTES_CONSTANTS } from './resource-attributes-constants';
|
|
64
|
+
export { ArgumentError } from './errors/argument-error';
|
|
65
|
+
export {
|
|
66
|
+
EntityAttributeAssignment,
|
|
67
|
+
ResourceAttributeResponse,
|
|
68
|
+
EntityAttributeResponse,
|
|
69
|
+
ResourceType,
|
|
70
|
+
EntityType,
|
|
71
|
+
ResourceAttributeKeyType,
|
|
72
|
+
EntityAttributeKeyType,
|
|
73
|
+
CommonAttributeKey,
|
|
74
|
+
ResourceAttributeKey,
|
|
75
|
+
EntityAttributeKey,
|
|
76
|
+
} from './types/authorization-attributes-contracts';
|
|
61
77
|
export { RolesService } from './roles-service';
|
|
62
78
|
export { MembershipsService } from './memberships';
|
|
63
79
|
export { AuthorizationObject, Resource, BaseRequest, ResourceGetter, ContextGetter } from './types/general';
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { RESOURCE_TYPES, ResourceType } from './resource-attributes-constants';
|
|
2
|
+
import { ArgumentError } from './errors/argument-error';
|
|
3
|
+
|
|
4
|
+
export class ResourceAttributeAssignment {
|
|
5
|
+
public readonly resourceId: number;
|
|
6
|
+
public readonly resourceType: ResourceType;
|
|
7
|
+
public readonly attributeKey: string;
|
|
8
|
+
public readonly attributeValue: string;
|
|
9
|
+
|
|
10
|
+
constructor(resourceId: number, resourceType: string, attributeKey: string, attributeValue: string) {
|
|
11
|
+
// Validate resourceId
|
|
12
|
+
if (!Number.isInteger(resourceId)) {
|
|
13
|
+
throw new ArgumentError(`resourceId must be an integer, got: ${resourceId}`);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Validate resourceType
|
|
17
|
+
const validResourceTypes = Object.values(RESOURCE_TYPES);
|
|
18
|
+
if (!validResourceTypes.includes(resourceType as ResourceType)) {
|
|
19
|
+
throw new ArgumentError(
|
|
20
|
+
`resourceType must be one of [${validResourceTypes.join(', ')}], got: ${resourceType}`
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Validate attributeKey
|
|
25
|
+
if (typeof attributeKey !== 'string') {
|
|
26
|
+
throw new ArgumentError(`attributeKey must be a string, got: ${typeof attributeKey}`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Validate attributeValue
|
|
30
|
+
if (typeof attributeValue !== 'string') {
|
|
31
|
+
throw new ArgumentError(`attributeValue must be a string, got: ${typeof attributeValue}`);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
this.resourceId = resourceId;
|
|
35
|
+
this.resourceType = resourceType as ResourceType;
|
|
36
|
+
this.attributeKey = attributeKey;
|
|
37
|
+
this.attributeValue = attributeValue;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Converts the assignment to hash format with camelCase keys
|
|
42
|
+
* @returns Object with camelCase keys: { resourceId, resourceType, key, value }
|
|
43
|
+
*/
|
|
44
|
+
toH(): { resourceId: number; resourceType: string; key: string; value: string } {
|
|
45
|
+
return {
|
|
46
|
+
resourceId: this.resourceId,
|
|
47
|
+
resourceType: this.resourceType,
|
|
48
|
+
key: this.attributeKey,
|
|
49
|
+
value: this.attributeValue,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Compares two assignments for equality
|
|
55
|
+
* @param other Another ResourceAttributeAssignment instance
|
|
56
|
+
* @returns true if all properties are equal
|
|
57
|
+
*/
|
|
58
|
+
equals(other: ResourceAttributeAssignment): boolean {
|
|
59
|
+
if (!(other instanceof ResourceAttributeAssignment)) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
return (
|
|
63
|
+
this.resourceId === other.resourceId &&
|
|
64
|
+
this.resourceType === other.resourceType &&
|
|
65
|
+
this.attributeKey === other.attributeKey &&
|
|
66
|
+
this.attributeValue === other.attributeValue
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export const RESOURCE_TYPES = {
|
|
2
|
+
ACCOUNT: 'account',
|
|
3
|
+
ACCOUNT_PRODUCT: 'account_product',
|
|
4
|
+
WORKSPACE: 'workspace',
|
|
5
|
+
BOARD: 'board',
|
|
6
|
+
ITEM: 'item',
|
|
7
|
+
TEAM: 'team',
|
|
8
|
+
OVERVIEW: 'overview',
|
|
9
|
+
DOCUMENT: 'document',
|
|
10
|
+
CRM: 'crm',
|
|
11
|
+
} as const;
|
|
12
|
+
|
|
13
|
+
export const RESOURCE_ATTRIBUTES_CONSTANTS = {
|
|
14
|
+
ACCOUNT_RESOURCE_ATTRIBUTES: {
|
|
15
|
+
ENABLE_MEMBERS_INVITE_FROM_NON_AUTH_DOMAIN: 'enable_members_invite_from_non_auth_domain',
|
|
16
|
+
},
|
|
17
|
+
WORKSPACE_RESOURCE_ATTRIBUTES: {
|
|
18
|
+
IS_DEFAULT_WORKSPACE: 'is_default_workspace',
|
|
19
|
+
},
|
|
20
|
+
BOARD_RESOURCE_ATTRIBUTES: {
|
|
21
|
+
IS_SYNCABLE_CHILD_ENTITY: 'is_syncable_child_entity',
|
|
22
|
+
SYSTEM_ENTITY_TYPE: 'system_entity_type',
|
|
23
|
+
},
|
|
24
|
+
} as const;
|
|
25
|
+
|
|
26
|
+
export type ResourceType = typeof RESOURCE_TYPES[keyof typeof RESOURCE_TYPES];
|
|
27
|
+
|
|
@@ -1,16 +1,62 @@
|
|
|
1
1
|
import { Resource } from './general';
|
|
2
2
|
|
|
3
|
+
// Resource Types - matching the API
|
|
4
|
+
export type ResourceType =
|
|
5
|
+
| 'account'
|
|
6
|
+
| 'account_product'
|
|
7
|
+
| 'workspace'
|
|
8
|
+
| 'board'
|
|
9
|
+
| 'item'
|
|
10
|
+
| 'team'
|
|
11
|
+
| 'overview'
|
|
12
|
+
| 'document'
|
|
13
|
+
| 'crm';
|
|
14
|
+
|
|
15
|
+
// Entity Types - matching the API
|
|
16
|
+
export type EntityType =
|
|
17
|
+
| 'user'
|
|
18
|
+
| 'team'
|
|
19
|
+
| 'account';
|
|
20
|
+
|
|
21
|
+
// Common attribute keys that can be used for both resources and entities
|
|
22
|
+
export type CommonAttributeKey = string;
|
|
23
|
+
|
|
24
|
+
// Resource-specific attribute keys
|
|
25
|
+
export type ResourceAttributeKey = string;
|
|
26
|
+
|
|
27
|
+
// Entity-specific attribute keys
|
|
28
|
+
export type EntityAttributeKey = string;
|
|
29
|
+
|
|
30
|
+
// Combined types for attribute keys
|
|
31
|
+
export type ResourceAttributeKeyType = CommonAttributeKey | ResourceAttributeKey;
|
|
32
|
+
export type EntityAttributeKeyType = CommonAttributeKey | EntityAttributeKey;
|
|
33
|
+
|
|
34
|
+
// Resource Attribute Assignment - matching API contract
|
|
3
35
|
export interface ResourceAttributeAssignment {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
key:
|
|
36
|
+
resourceId: number;
|
|
37
|
+
resourceType: ResourceType;
|
|
38
|
+
key: ResourceAttributeKeyType;
|
|
7
39
|
value: string;
|
|
8
40
|
}
|
|
9
41
|
|
|
42
|
+
// Entity Attribute Assignment - matching API contract
|
|
43
|
+
export interface EntityAttributeAssignment {
|
|
44
|
+
entityId: number;
|
|
45
|
+
entityType: EntityType;
|
|
46
|
+
key: EntityAttributeKeyType;
|
|
47
|
+
value: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Response types
|
|
10
51
|
export interface ResourceAttributeResponse {
|
|
11
52
|
attributes: ResourceAttributeAssignment[];
|
|
12
53
|
}
|
|
13
54
|
|
|
55
|
+
export interface EntityAttributeResponse {
|
|
56
|
+
attributes: EntityAttributeAssignment[];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Legacy types for backward compatibility
|
|
14
60
|
export interface ResourceAttributeDelete {
|
|
15
61
|
resourceType: Resource['type'];
|
|
16
62
|
resourceId: Resource['id'];
|