import { ADUserAttributes, ADUser } from './types'; import { User } from '../..'; /** * Attribute transformation function type. */ export type AttributeTransformer = (value: TIn, source: ADUserAttributes) => TOut; /** * Attribute validation function type. */ export type AttributeValidator = (value: T, attributeName: string) => { valid: boolean; error?: string; }; /** * Single attribute mapping configuration. */ export interface AttributeMapping { /** Source attribute name in AD */ source: keyof ADUserAttributes | string; /** Target attribute name in application user */ target: string; /** Optional transformation function */ transform?: AttributeTransformer; /** Optional validation function */ validate?: AttributeValidator; /** Default value if source is undefined */ defaultValue?: TOut; /** Whether this attribute is required */ required?: boolean; /** Custom extraction function for complex mappings */ extract?: (source: ADUserAttributes) => TIn; } /** * Complete attribute mapping configuration. */ export interface AttributeMappingConfig { /** Individual attribute mappings */ mappings: AttributeMapping[]; /** Whether to include unmapped attributes in metadata */ includeUnmapped?: boolean; /** Prefix for unmapped attributes in metadata */ unmappedPrefix?: string; /** Custom extension attribute mappings */ extensionMappings?: Record; /** Attributes to explicitly exclude */ excludeAttributes?: string[]; } /** * Result of attribute mapping operation. */ export interface AttributeMappingResult { /** Mapped attributes */ attributes: Record; /** Validation errors encountered */ errors: Array<{ attribute: string; error: string; }>; /** Unmapped attributes (if includeUnmapped is true) */ unmapped?: Record; /** Whether mapping was successful (no required attribute errors) */ success: boolean; } /** * Default attribute mappings from AD to application User. */ export declare const DEFAULT_ATTRIBUTE_MAPPINGS: AttributeMapping[]; /** * Extended attribute mappings for additional user properties. */ export declare const EXTENDED_ATTRIBUTE_MAPPINGS: AttributeMapping[]; /** * Healthcare-specific attribute mappings for HIPAA compliance. */ export declare const HEALTHCARE_ATTRIBUTE_MAPPINGS: AttributeMapping[]; /** * AD Attribute Mapper for user property transformation. * * Maps AD user attributes to application user properties using * configurable mapping rules with support for transformation, * validation, and custom extraction logic. * * @example * ```typescript * const mapper = new ADAttributeMapper({ * mappings: DEFAULT_ATTRIBUTE_MAPPINGS, * includeUnmapped: true, * unmappedPrefix: 'ad_', * }); * * const result = mapper.mapAttributes(adUserAttributes); * if (result.success) { * console.log('Mapped attributes:', result.attributes); * } else { * console.error('Mapping errors:', result.errors); * } * ``` */ export declare class ADAttributeMapper { private readonly config; /** * Create a new attribute mapper. * * @param config - Attribute mapping configuration */ constructor(config?: Partial); /** * Map AD user attributes to application user properties. * * @param source - Source AD user attributes * @returns Mapping result with attributes and any errors */ mapAttributes(source: ADUserAttributes): AttributeMappingResult; /** * Map AD user to application User type. * * @param adUser - Source AD user * @returns Mapped application User */ mapToUser(adUser: ADUser): User; /** * Add a mapping at runtime. * * @param mapping - Mapping to add */ addMapping(mapping: AttributeMapping): void; /** * Remove a mapping by source attribute. * * @param source - Source attribute name to remove */ removeMapping(source: string): void; /** * Get the current configuration. */ getConfig(): AttributeMappingConfig; /** * Get a nested value from an object using dot notation. */ private getNestedValue; } /** * Pre-built attribute transformers for common use cases. */ export declare const attributeTransformers: { /** * Normalize email to lowercase. */ readonly normalizeEmail: (value: string | undefined) => string | undefined; /** * Format display name (proper case). */ readonly formatDisplayName: (value: string | undefined) => string | undefined; /** * Parse phone number to E.164 format. */ readonly normalizePhone: (value: string | undefined) => string | undefined; /** * Convert ISO date string to timestamp. */ readonly dateToTimestamp: (value: string | undefined) => number | undefined; /** * Parse boolean from string. */ readonly parseBoolean: (value: unknown) => boolean; /** * Parse array from comma-separated string. */ readonly parseArray: (value: string | string[] | undefined) => string[]; /** * Mask sensitive data (show last 4 characters). */ readonly maskSensitive: (value: string | undefined) => string | undefined; }; /** * Pre-built attribute validators for common use cases. */ export declare const attributeValidators: { /** * Validate email format. */ readonly email: (value: string | undefined, attr: string) => { valid: boolean; error?: string; }; /** * Validate UPN format. */ readonly upn: (value: string | undefined, attr: string) => { valid: boolean; error?: string; }; /** * Validate GUID format. */ readonly guid: (value: string | undefined, attr: string) => { valid: boolean; error?: string; }; /** * Validate string length. */ readonly maxLength: (max: number) => (value: string | undefined, attr: string) => { valid: boolean; error?: string; }; /** * Validate required field. */ readonly required: (value: unknown, attr: string) => { valid: boolean; error?: string; }; /** * Validate against regex pattern. */ readonly pattern: (regex: RegExp, message: string) => (value: string | undefined, attr: string) => { valid: boolean; error?: string; }; }; /** * Create an attribute mapper with default configuration. * * @param options - Configuration options * @returns Configured ADAttributeMapper */ export declare function createAttributeMapper(options?: { includeExtended?: boolean; includeHealthcare?: boolean; customMappings?: AttributeMapping[]; includeUnmapped?: boolean; extensionMappings?: Record; }): ADAttributeMapper; /** * Create a mapping for a custom extension attribute. * * @param extensionName - Name of the extension attribute * @param targetName - Target property name * @param options - Additional mapping options * @returns AttributeMapping for the extension */ export declare function createExtensionMapping(extensionName: string, targetName: string, options?: { transform?: AttributeTransformer; validate?: AttributeValidator; required?: boolean; defaultValue?: T; }): AttributeMapping;