@plyaz/types 1.27.8 → 1.27.9

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.
@@ -344,6 +344,7 @@ export interface Permission {
344
344
  metadata?: Record<string, unknown>;
345
345
  createdAt: Date;
346
346
  updatedAt: Date;
347
+ conditions?: Record<string, unknown>;
347
348
  }
348
349
  /**
349
350
  * Role-Permission mapping (backoffice only).
@@ -899,3 +900,143 @@ export interface OAuthProviderConfig {
899
900
  /** Provider icon name (for UI) */
900
901
  iconName: string;
901
902
  }
903
+ /**
904
+ * Role assignment data
905
+ */
906
+ export interface RoleAssignmentData {
907
+ /** User ID */
908
+ userId: string;
909
+ /** Role ID */
910
+ roleId: string;
911
+ /** Role name/code */
912
+ role: string;
913
+ /** Is primary role */
914
+ isPrimary?: boolean;
915
+ /** Assignment status */
916
+ status?: 'ACTIVE' | 'INACTIVE' | 'SUSPENDED';
917
+ /** Assigned by user ID */
918
+ assignedBy?: string;
919
+ /** Assignment reason */
920
+ assignedReason?: string;
921
+ /** Assignment expiration */
922
+ expiresAt?: Date;
923
+ }
924
+ /**
925
+ * Role repository interface
926
+ */
927
+ export interface RoleRepositoryInterface {
928
+ findByScope(scope: 'B2C' | 'B2B'): Promise<Role[]>;
929
+ findUserRoles(userId: string): Promise<Role[]>;
930
+ assignRole(userId: string, roleId: string, assignedBy?: string, reason?: string): Promise<void>;
931
+ revokeRole(userId: string, roleId: string, revokedBy?: string, reason?: string): Promise<void>;
932
+ getRolePermissions(roleId: string): Promise<Permission[]>;
933
+ }
934
+ /**
935
+ * Dynamic role assignment
936
+ */
937
+ export interface DynamicRoleAssignment {
938
+ /** Assignment ID */
939
+ id: string;
940
+ /** User ID */
941
+ userId: string;
942
+ /** Role ID or name */
943
+ roleId: string;
944
+ /** Assignment conditions */
945
+ conditions?: Record<string, unknown>;
946
+ /** Assignment expiration */
947
+ expiresAt?: Date;
948
+ /** Assignment reason */
949
+ reason?: string;
950
+ /** Assigned by user ID */
951
+ assignedBy?: string;
952
+ /** Assignment metadata */
953
+ metadata?: Record<string, unknown>;
954
+ /** Created at */
955
+ createdAt: Date;
956
+ /** Is active */
957
+ isActive: boolean;
958
+ }
959
+ /**
960
+ * Role condition evaluator function
961
+ */
962
+ export type RoleConditionEvaluator = (userId: string, conditions: Record<string, unknown>, context?: Record<string, unknown>) => Promise<boolean>;
963
+ /**
964
+ * Dynamic roles configuration
965
+ */
966
+ export interface DynamicRolesConfig {
967
+ /** Enable role expiration */
968
+ enableExpiration: boolean;
969
+ /** Default role TTL in seconds */
970
+ defaultTTL: number;
971
+ /** Enable condition evaluation */
972
+ enableConditions: boolean;
973
+ /** Maximum assignments per user */
974
+ maxAssignmentsPerUser: number;
975
+ /** Enable audit logging */
976
+ enableAuditLog: boolean;
977
+ }
978
+ /**
979
+ * Role hierarchy node
980
+ */
981
+ export interface RoleNode {
982
+ /** Role information */
983
+ role: Role;
984
+ /** Parent roles (higher hierarchy) */
985
+ parents: Set<string>;
986
+ /** Child roles (lower hierarchy) */
987
+ children: Set<string>;
988
+ /** Direct permissions */
989
+ permissions: Set<string>;
990
+ /** Inherited permissions (computed) */
991
+ inheritedPermissions?: Set<string>;
992
+ }
993
+ /**
994
+ * Role hierarchy configuration
995
+ */
996
+ export interface RoleHierarchyConfig {
997
+ /** Enable permission inheritance */
998
+ enableInheritance: boolean;
999
+ /** Maximum hierarchy depth */
1000
+ maxDepth: number;
1001
+ /** Enable circular dependency detection */
1002
+ detectCircular: boolean;
1003
+ /** Cache inherited permissions */
1004
+ cacheInheritance: boolean;
1005
+ }
1006
+ export interface RoleConfig {
1007
+ hierarchyEnabled: boolean;
1008
+ cacheEnabled: boolean;
1009
+ cacheTTL: number;
1010
+ }
1011
+ export interface PermissionContext {
1012
+ /** Resource owner ID */
1013
+ ownerId?: string;
1014
+ /** Organization ID */
1015
+ organizationId?: string;
1016
+ /** Additional context data */
1017
+ [key: string]: unknown;
1018
+ }
1019
+ /**
1020
+ * Permission check result
1021
+ */
1022
+ export interface PermissionCheckResult {
1023
+ /** Permission granted */
1024
+ granted: boolean;
1025
+ /** Reason for decision */
1026
+ reason: string;
1027
+ /** Matched permission (if any) */
1028
+ matchedPermission?: Permission;
1029
+ /** Applied conditions */
1030
+ conditions?: Record<string, unknown>;
1031
+ }
1032
+ /**
1033
+ * Permission checker configuration
1034
+ */
1035
+ export interface PermissionCheckerConfig {
1036
+ /** Enable permission caching */
1037
+ enableCaching: boolean;
1038
+ /** Cache TTL in seconds */
1039
+ cacheTTL: number;
1040
+ /** Enable audit logging */
1041
+ enableAuditLog: boolean;
1042
+ }