cgs-compliance-sdk 2.0.3 → 2.0.5
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/client-BIRcQF2C.d.ts +619 -0
- package/dist/client-CPBy8d1H.d.mts +619 -0
- package/dist/compliance/index.d.mts +231 -0
- package/dist/compliance/index.d.ts +231 -0
- package/dist/compliance/index.js +17 -19
- package/dist/compliance/index.js.map +1 -1
- package/dist/compliance/index.mjs +17 -19
- package/dist/compliance/index.mjs.map +1 -1
- package/dist/geolocation/index.d.mts +122 -0
- package/dist/geolocation/index.d.ts +122 -0
- package/dist/geolocation/index.js +1 -0
- package/dist/geolocation/index.js.map +1 -1
- package/dist/geolocation/index.mjs +1 -0
- package/dist/geolocation/index.mjs.map +1 -1
- package/dist/index-BQPX1yNM.d.ts +524 -0
- package/dist/index-CzElZ3T6.d.mts +524 -0
- package/dist/index.d.mts +48 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.js +18 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -19
- package/dist/index.mjs.map +1 -1
- package/dist/risk-profile/index.d.mts +2 -0
- package/dist/risk-profile/index.d.ts +2 -0
- package/dist/risk-profile/index.js.map +1 -1
- package/dist/risk-profile/index.mjs.map +1 -1
- package/dist/types-mQdu71xf.d.mts +61 -0
- package/dist/types-mQdu71xf.d.ts +61 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/errors.ts","../../src/core/client.ts","../../src/risk-profile/client.ts"],"names":[],"mappings":";;;AAOO,IAAM,QAAA,GAAN,MAAM,SAAA,SAAiB,KAAA,CAAM;AAAA,EAClC,WAAA,CACE,OAAA,EACO,IAAA,EACA,UAAA,EACA,OAAA,EACP;AACA,IAAA,KAAA,CAAM,OAAO,CAAA;AAJN,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AACA,IAAA,IAAA,CAAA,UAAA,GAAA,UAAA;AACA,IAA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;AAAA,IACzC,SAAS,KAAA,EAAO;AAEd,MAAA,OAAO,MAAM,IAAA,CAAK,aAAA,CAAc,aAAa,CAAA;AAAA,IAC/C;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,iBAAiB,WAAA,EAAmD;AAGxE,IAAA,MAAM,WAA8B,EAAC;AAErC,IAAA,KAAA,MAAW,cAAc,WAAA,EAAa;AACpC,MAAA,IAAI;AACF,QAAA,MAAM,OAAA,GAAU,MAAM,IAAA,CAAK,UAAA,CAAW,UAAU,CAAA;AAChD,QAAA,QAAA,CAAS,KAAK,OAAO,CAAA;AAAA,MACvB,SAAS,KAAA,EAAO;AAEd,QAAA,IAAI,IAAA,CAAK,OAAO,KAAA,EAAO;AACrB,UAAA,OAAA,CAAQ,IAAA,CAAK,CAAA,2CAAA,EAA8C,UAAU,CAAA,CAAE,CAAA;AAAA,QACzE;AAAA,MACF;AAAA,IACF;AAEA,IAAA,OAAO,QAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaA,MAAM,oBAAA,GAAmD;AACvD,IAAA,OAAO,IAAA,CAAK,QAA2B,qBAAqB,CAAA;AAAA,EAC9D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,MAAM,wBACJ,MAAA,EAC4B;AAC5B,IAAA,OAAO,IAAA,CAAK,QAA2B,qBAAA,EAAuB;AAAA,MAC5D,MAAA,EAAQ,KAAA;AAAA,MACR,IAAA,EAAM,IAAA,CAAK,SAAA,CAAU,MAAM;AAAA,KAC5B,CAAA;AAAA,EACH;AACF","file":"index.js","sourcesContent":["/**\n * Error hierarchy for CGS SDK\n *\n * Provides structured error handling with specific error types\n * for different failure scenarios.\n */\n\nexport class CGSError extends Error {\n constructor(\n message: string,\n public code: string,\n public statusCode?: number,\n public details?: Record<string, unknown>\n ) {\n super(message);\n this.name = 'CGSError';\n Object.setPrototypeOf(this, CGSError.prototype);\n }\n}\n\nexport class NetworkError extends CGSError {\n constructor(message: string, public originalError?: unknown) {\n super(message, 'NETWORK_ERROR', undefined, { originalError });\n this.name = 'NetworkError';\n Object.setPrototypeOf(this, NetworkError.prototype);\n }\n}\n\nexport class ValidationError extends CGSError {\n constructor(message: string, fields?: string[]) {\n super(message, 'VALIDATION_ERROR', 400, { fields });\n this.name = 'ValidationError';\n Object.setPrototypeOf(this, ValidationError.prototype);\n }\n}\n\nexport class ServiceUnavailableError extends CGSError {\n constructor(service: string) {\n super(`${service} is unavailable`, 'SERVICE_UNAVAILABLE', 503, { service });\n this.name = 'ServiceUnavailableError';\n Object.setPrototypeOf(this, ServiceUnavailableError.prototype);\n }\n}\n\nexport class ComplianceBlockedError extends CGSError {\n constructor(reasons: string[]) {\n super('Access blocked due to compliance rules', 'COMPLIANCE_BLOCKED', 403, { reasons });\n this.name = 'ComplianceBlockedError';\n Object.setPrototypeOf(this, ComplianceBlockedError.prototype);\n }\n}\n\nexport class AuthenticationError extends CGSError {\n constructor(message: string = 'Authentication failed') {\n super(message, 'AUTHENTICATION_ERROR', 401);\n this.name = 'AuthenticationError';\n Object.setPrototypeOf(this, AuthenticationError.prototype);\n }\n}\n\nexport class RateLimitError extends CGSError {\n constructor(public retryAfter?: number) {\n super('Rate limit exceeded', 'RATE_LIMIT_EXCEEDED', 429, { retryAfter });\n this.name = 'RateLimitError';\n Object.setPrototypeOf(this, RateLimitError.prototype);\n }\n}\n\nexport class TimeoutError extends CGSError {\n constructor(public timeout: number) {\n super(`Request timeout after ${timeout}ms`, 'TIMEOUT', 408, { timeout });\n this.name = 'TimeoutError';\n Object.setPrototypeOf(this, TimeoutError.prototype);\n }\n}\n\nexport class ComplianceError extends CGSError {\n constructor(\n message: string,\n public originalError?: unknown,\n code: string = 'COMPLIANCE_ERROR'\n ) {\n super(message, code, undefined, { originalError });\n this.name = 'ComplianceError';\n Object.setPrototypeOf(this, ComplianceError.prototype);\n }\n}\n","/**\n * Base HTTP client for all CGS SDK clients\n *\n * Provides common functionality:\n * - Request/response handling\n * - Error handling\n * - Retry logic with exponential backoff\n * - Timeout management\n * - Debug logging\n */\n\nimport type { BaseClientConfig, RequiredBaseClientConfig } from './config';\nimport {\n CGSError,\n NetworkError,\n TimeoutError,\n AuthenticationError,\n RateLimitError,\n ServiceUnavailableError,\n} from './errors';\n\nexport abstract class BaseClient {\n protected config: RequiredBaseClientConfig;\n\n constructor(config: BaseClientConfig) {\n this.config = {\n baseURL: config.baseURL,\n tenantId: config.tenantId,\n apiKey: config.apiKey || '',\n headers: config.headers || {},\n timeout: config.timeout || 10000,\n retries: config.retries || 3,\n debug: config.debug || false,\n };\n }\n\n /**\n * Make an HTTP request with timeout and error handling\n */\n protected async request<T>(\n endpoint: string,\n options: RequestInit = {},\n serviceURL?: string\n ): Promise<T> {\n const url = `${serviceURL || this.config.baseURL}${endpoint}`;\n\n const headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n 'X-Tenant-ID': this.config.tenantId,\n ...this.config.headers,\n ...((options.headers as Record<string, string>) || {}),\n };\n\n if (this.config.apiKey) {\n headers['Authorization'] = `Bearer ${this.config.apiKey}`;\n }\n\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);\n\n try {\n if (this.config.debug) {\n console.log(`[CGS SDK] ${options.method || 'GET'} ${url}`, {\n headers,\n body: options.body,\n });\n }\n\n const response = await fetch(url, {\n ...options,\n headers,\n signal: controller.signal,\n });\n\n clearTimeout(timeoutId);\n\n const data = await response.json();\n\n if (!response.ok) {\n this.handleErrorResponse(response.status, data);\n }\n\n if (this.config.debug) {\n console.log(`[CGS SDK] Response:`, data);\n }\n\n return data as T;\n } catch (error) {\n clearTimeout(timeoutId);\n\n if (error instanceof Error) {\n if (error.name === 'AbortError') {\n throw new TimeoutError(this.config.timeout);\n }\n if (error instanceof CGSError) {\n throw error;\n }\n }\n\n throw new NetworkError('Network request failed', error);\n }\n }\n\n /**\n * Make an HTTP request with retry logic\n */\n protected async requestWithRetry<T>(\n endpoint: string,\n options: RequestInit = {},\n serviceURL?: string,\n retries: number = this.config.retries\n ): Promise<T> {\n let lastError: Error | undefined;\n\n for (let attempt = 0; attempt <= retries; attempt++) {\n try {\n return await this.request<T>(endpoint, options, serviceURL);\n } catch (error) {\n lastError = error instanceof Error ? error : new Error('Unknown error');\n\n // Don't retry on client errors (4xx) or authentication errors\n if (\n lastError instanceof CGSError &&\n lastError.statusCode &&\n lastError.statusCode >= 400 &&\n lastError.statusCode < 500\n ) {\n throw lastError;\n }\n\n // Don't retry on last attempt\n if (attempt === retries) {\n break;\n }\n\n // Exponential backoff with jitter\n const delay = Math.min(1000 * Math.pow(2, attempt) + Math.random() * 1000, 10000);\n await new Promise((resolve) => setTimeout(resolve, delay));\n\n if (this.config.debug) {\n console.log(`[CGS SDK] Retry attempt ${attempt + 1}/${retries} after ${delay.toFixed(0)}ms`);\n }\n }\n }\n\n throw new NetworkError(`Request failed after ${retries} retries`, lastError);\n }\n\n /**\n * Handle error responses from API\n */\n protected handleErrorResponse(status: number, data: any): never {\n const message = data.error || data.message || `HTTP ${status}`;\n\n switch (status) {\n case 400:\n throw new CGSError(message, 'BAD_REQUEST', 400, data);\n case 401:\n throw new AuthenticationError(message);\n case 403:\n throw new CGSError(message, 'FORBIDDEN', 403, data);\n case 404:\n throw new CGSError(message, 'NOT_FOUND', 404, data);\n case 429:\n const retryAfter = data.retry_after || data.retryAfter;\n throw new RateLimitError(retryAfter);\n case 500:\n case 502:\n case 503:\n case 504:\n throw new ServiceUnavailableError(message);\n default:\n throw new CGSError(message, 'UNKNOWN_ERROR', status, data);\n }\n }\n\n /**\n * Build query string from parameters\n */\n protected buildQueryString(params: Record<string, unknown>): string {\n const query = new URLSearchParams();\n\n Object.entries(params).forEach(([key, value]) => {\n if (value !== undefined && value !== null) {\n if (Array.isArray(value)) {\n value.forEach((item) => query.append(key, String(item)));\n } else {\n query.append(key, String(value));\n }\n }\n });\n\n const queryString = query.toString();\n return queryString ? `?${queryString}` : '';\n }\n\n /**\n * Update client configuration\n */\n updateConfig(config: Partial<BaseClientConfig>): void {\n this.config = {\n ...this.config,\n ...config,\n headers: {\n ...this.config.headers,\n ...(config.headers || {}),\n },\n };\n }\n\n /**\n * Get current configuration (readonly)\n */\n getConfig(): Readonly<BaseClientConfig> {\n return { ...this.config };\n }\n\n /**\n * Health check endpoint\n */\n async healthCheck(): Promise<{ status: string; timestamp: string }> {\n return this.request('/api/v1/health');\n }\n}\n","/**\n * RiskProfileClient - Customer Risk Profile Management\n *\n * Provides methods to create, retrieve, and manage customer risk profiles\n * in the CGS Compliance Platform.\n */\n\nimport { BaseClient } from '../core/client';\nimport type { BaseClientConfig } from '../core/config';\nimport type {\n CustomerProfile,\n CreateProfileRequest,\n UpdateProfileRequest,\n ProfileDetailsResponse,\n ProfileFilters,\n ProfileListResponse,\n RiskDashboardMetrics,\n RiskConfiguration,\n} from './types';\n\nexport class RiskProfileClient extends BaseClient {\n constructor(config: BaseClientConfig) {\n super(config);\n }\n\n // ============================================================================\n // Profile Management\n // ============================================================================\n\n /**\n * Create a new customer risk profile\n *\n * @param request - Profile creation data\n * @returns Created customer profile\n *\n * @example\n * ```typescript\n * const profile = await client.createProfile({\n * customer_id: 'CUST-12345',\n * entity_type: 'individual',\n * customer_status: 'active',\n * full_name: 'John Doe',\n * email_address: 'john@example.com',\n * date_of_birth: '1990-01-15',\n * country_of_residence: 'US'\n * });\n * ```\n */\n async createProfile(request: CreateProfileRequest): Promise<CustomerProfile> {\n return this.request<CustomerProfile>('/api/v1/profiles', {\n method: 'POST',\n body: JSON.stringify(request),\n });\n }\n\n /**\n * Get customer profile by customer ID\n *\n * Note: This searches for the profile using the customer_id field.\n * Returns the first matching profile for the tenant.\n *\n * @param customerId - Customer ID to search for\n * @returns Customer profile\n *\n * @example\n * ```typescript\n * const profile = await client.getProfile('CUST-12345');\n * console.log('Risk score:', profile.risk_score);\n * ```\n */\n async getProfile(customerId: string): Promise<CustomerProfile> {\n const response = await this.queryProfiles({\n search: customerId,\n page: 1,\n page_size: 1,\n });\n\n if (response.data.length === 0) {\n throw new Error(`Profile not found for customer ID: ${customerId}`);\n }\n\n return response.data[0];\n }\n\n /**\n * Get profile by UUID\n *\n * @param profileId - Profile UUID\n * @returns Customer profile\n */\n async getProfileById(profileId: string): Promise<CustomerProfile> {\n // Note: The dashboard endpoint provides detailed profile view\n const details = await this.getProfileDetails(profileId);\n return details.profile;\n }\n\n /**\n * Get detailed profile information including risk factors and history\n *\n * @param profileId - Profile UUID\n * @returns Detailed profile response with risk factors and history\n *\n * @example\n * ```typescript\n * const details = await client.getProfileDetails(profileId);\n * console.log('Risk factors:', details.risk_factors);\n * console.log('Risk history:', details.risk_history);\n * console.log('Alert counts:', {\n * watchlist: details.watchlist_alert_count,\n * fraud: details.fraud_alert_count,\n * geo: details.geolocation_alert_count\n * });\n * ```\n */\n async getProfileDetails(profileId: string): Promise<ProfileDetailsResponse> {\n return this.request<ProfileDetailsResponse>(\n `/api/v1/risk-dashboard/profiles/${profileId}`\n );\n }\n\n /**\n * Update customer profile\n *\n * @param profileId - Profile UUID\n * @param updates - Fields to update\n * @returns Updated customer profile\n *\n * @example\n * ```typescript\n * const updated = await client.updateProfile(profileId, {\n * location: 'New York, USA',\n * location_compliance: 'compliant',\n * last_recorded_activity: new Date().toISOString()\n * });\n * ```\n */\n async updateProfile(\n profileId: string,\n updates: UpdateProfileRequest\n ): Promise<CustomerProfile> {\n return this.request<CustomerProfile>(`/api/v1/profiles/${profileId}`, {\n method: 'PUT',\n body: JSON.stringify(updates),\n });\n }\n\n /**\n * Manually recalculate risk score for a profile\n *\n * Triggers immediate risk score recalculation based on current risk factors.\n *\n * @param profileId - Profile UUID\n * @param reason - Optional reason for recalculation\n *\n * @example\n * ```typescript\n * await client.recalculateRiskScore(profileId, 'Manual review completed');\n * ```\n */\n async recalculateRiskScore(profileId: string, reason?: string): Promise<void> {\n const body = reason ? JSON.stringify({ reason }) : undefined;\n await this.request(`/api/v1/profiles/recalculate/${profileId}`, {\n method: 'POST',\n body,\n });\n }\n\n // ============================================================================\n // Query & Search\n // ============================================================================\n\n /**\n * Query profiles with advanced filters\n *\n * @param filters - Filter criteria and pagination\n * @returns Paginated list of profiles\n *\n * @example\n * ```typescript\n * const results = await client.queryProfiles({\n * risk_category: ['high', 'critical'],\n * kyc_status: ['pending'],\n * is_pep: true,\n * page: 1,\n * page_size: 20,\n * sort_by: 'risk_score',\n * sort_order: 'desc'\n * });\n *\n * console.log(`Found ${results.total} high-risk profiles`);\n * results.data.forEach(profile => {\n * console.log(`${profile.full_name}: ${profile.risk_score}`);\n * });\n * ```\n */\n async queryProfiles(filters: ProfileFilters = {}): Promise<ProfileListResponse> {\n const queryString = this.buildQueryString(filters);\n return this.request<ProfileListResponse>(\n `/api/v1/risk-dashboard/profiles${queryString}`\n );\n }\n\n /**\n * Search profiles by text (searches name, email, customer_id, account_number)\n *\n * @param searchText - Text to search for\n * @param limit - Maximum results to return (default: 10)\n * @returns Array of matching profiles\n */\n async searchProfiles(searchText: string, limit: number = 10): Promise<CustomerProfile[]> {\n const response = await this.queryProfiles({\n search: searchText,\n page: 1,\n page_size: limit,\n });\n return response.data;\n }\n\n /**\n * Get all high-risk profiles (high + critical)\n *\n * @param limit - Maximum results to return (default: 50)\n * @returns Array of high-risk profiles\n */\n async getHighRiskProfiles(limit: number = 50): Promise<CustomerProfile[]> {\n const response = await this.queryProfiles({\n risk_category: ['high', 'critical'],\n page: 1,\n page_size: limit,\n sort_by: 'risk_score',\n sort_order: 'desc',\n });\n return response.data;\n }\n\n /**\n * Get profiles requiring PEP review\n *\n * @param limit - Maximum results to return (default: 50)\n * @returns Array of PEP profiles\n */\n async getPEPProfiles(limit: number = 50): Promise<CustomerProfile[]> {\n const response = await this.queryProfiles({\n is_pep: true,\n page: 1,\n page_size: limit,\n });\n return response.data;\n }\n\n /**\n * Get profiles with sanctions matches\n *\n * @param limit - Maximum results to return (default: 50)\n * @returns Array of sanctioned profiles\n */\n async getSanctionedProfiles(limit: number = 50): Promise<CustomerProfile[]> {\n const response = await this.queryProfiles({\n has_sanctions: true,\n page: 1,\n page_size: limit,\n });\n return response.data;\n }\n\n // ============================================================================\n // Dashboard & Metrics\n // ============================================================================\n\n /**\n * Get risk dashboard metrics and statistics\n *\n * @param startDate - Optional start date for metrics (ISO format)\n * @param endDate - Optional end date for metrics (ISO format)\n * @returns Dashboard metrics\n *\n * @example\n * ```typescript\n * const metrics = await client.getDashboardMetrics();\n * console.log('Total risky profiles:', metrics.total_risky_profiles);\n * console.log('Critical profiles:', metrics.total_critical_profiles);\n * console.log('Average risk score:', metrics.average_risk_score);\n *\n * metrics.risk_distribution.forEach(item => {\n * console.log(`${item.category}: ${item.count} (${item.percentage}%)`);\n * });\n * ```\n */\n async getDashboardMetrics(\n startDate?: string,\n endDate?: string\n ): Promise<RiskDashboardMetrics> {\n const params: Record<string, string> = {};\n if (startDate) params.start_date = startDate;\n if (endDate) params.end_date = endDate;\n\n const queryString = this.buildQueryString(params);\n return this.request<RiskDashboardMetrics>(\n `/api/v1/risk-dashboard/metrics${queryString}`\n );\n }\n\n // ============================================================================\n // Bulk Operations\n // ============================================================================\n\n /**\n * Get or create profile (idempotent operation)\n *\n * Attempts to get existing profile by customer_id, creates if not found.\n *\n * @param customerId - Customer ID\n * @param createRequest - Profile data to use if creating new profile\n * @returns Existing or newly created profile\n *\n * @example\n * ```typescript\n * const profile = await client.getOrCreateProfile('CUST-123', {\n * customer_id: 'CUST-123',\n * entity_type: 'individual',\n * full_name: 'John Doe',\n * email_address: 'john@example.com'\n * });\n * ```\n */\n async getOrCreateProfile(\n customerId: string,\n createRequest: CreateProfileRequest\n ): Promise<CustomerProfile> {\n try {\n return await this.getProfile(customerId);\n } catch (error) {\n // Profile doesn't exist, create it\n return await this.createProfile(createRequest);\n }\n }\n\n /**\n * Batch get profiles by customer IDs\n *\n * @param customerIds - Array of customer IDs\n * @returns Array of profiles (may be less than input if some not found)\n */\n async batchGetProfiles(customerIds: string[]): Promise<CustomerProfile[]> {\n // Note: Current API doesn't have batch endpoint, so we query with search\n // In production, this should use a dedicated batch endpoint\n const profiles: CustomerProfile[] = [];\n\n for (const customerId of customerIds) {\n try {\n const profile = await this.getProfile(customerId);\n profiles.push(profile);\n } catch (error) {\n // Profile not found, skip\n if (this.config.debug) {\n console.warn(`[RiskProfileClient] Profile not found for: ${customerId}`);\n }\n }\n }\n\n return profiles;\n }\n\n // ============================================================================\n // Configuration\n // ============================================================================\n\n /**\n * Get risk configuration for tenant\n *\n * Returns the risk scoring weights and thresholds configured for the tenant.\n *\n * @returns Risk configuration\n */\n async getRiskConfiguration(): Promise<RiskConfiguration> {\n return this.request<RiskConfiguration>('/api/v1/risk-config');\n }\n\n /**\n * Update risk configuration for tenant\n *\n * Updates risk scoring weights and/or thresholds.\n *\n * @param config - Configuration updates\n * @returns Updated risk configuration\n */\n async updateRiskConfiguration(\n config: Partial<RiskConfiguration>\n ): Promise<RiskConfiguration> {\n return this.request<RiskConfiguration>('/api/v1/risk-config', {\n method: 'PUT',\n body: JSON.stringify(config),\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/core/errors.ts","../../src/core/client.ts","../../src/risk-profile/client.ts"],"names":[],"mappings":";;;AAOO,IAAM,QAAA,GAAN,MAAM,SAAA,SAAiB,KAAA,CAAM;AAAA,EAClC,WAAA,CACE,OAAA,EACO,IAAA,EACA,UAAA,EACA,OAAA,EACP;AACA,IAAA,KAAA,CAAM,OAAO,CAAA;AAJN,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AACA,IAAA,IAAA,CAAA,UAAA,GAAA,UAAA;AACA,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAGP,IAAA,IAAA,CAAK,IAAA,GAAO,UAAA;AACZ,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,SAAA,CAAS,SAAS,CAAA;AAAA,EAChD;AACF,CAAA;AAEO,IAAM,YAAA,GAAN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;AAGxE,IAAA,MAAM,WAA8B,EAAC;AAErC,IAAA,KAAA,MAAW,cAAc,WAAA,EAAa;AACpC,MAAA,IAAI;AACF,QAAA,MAAM,OAAA,GAAU,MAAM,IAAA,CAAK,UAAA,CAAW,UAAU,CAAA;AAChD,QAAA,QAAA,CAAS,KAAK,OAAO,CAAA;AAAA,MACvB,SAAS,KAAA,EAAO;AAEd,QAAA,IAAI,IAAA,CAAK,OAAO,KAAA,EAAO;AACrB,UAAA,OAAA,CAAQ,IAAA,CAAK,CAAA,2CAAA,EAA8C,UAAU,CAAA,CAAE,CAAA;AAAA,QACzE;AAAA,MACF;AAAA,IACF;AAEA,IAAA,OAAO,QAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaA,MAAM,oBAAA,GAAmD;AACvD,IAAA,OAAO,IAAA,CAAK,QAA2B,qBAAqB,CAAA;AAAA,EAC9D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,MAAM,wBACJ,MAAA,EAC4B;AAC5B,IAAA,OAAO,IAAA,CAAK,QAA2B,qBAAA,EAAuB;AAAA,MAC5D,MAAA,EAAQ,KAAA;AAAA,MACR,IAAA,EAAM,IAAA,CAAK,SAAA,CAAU,MAAM;AAAA,KAC5B,CAAA;AAAA,EACH;AACF","file":"index.js","sourcesContent":["/**\n * Error hierarchy for CGS SDK\n *\n * Provides structured error handling with specific error types\n * for different failure scenarios.\n */\n\nexport class CGSError extends Error {\n constructor(\n message: string,\n public code: string,\n public statusCode?: number,\n public details?: Record<string, unknown>\n ) {\n super(message);\n this.name = 'CGSError';\n Object.setPrototypeOf(this, CGSError.prototype);\n }\n}\n\nexport class NetworkError extends CGSError {\n constructor(message: string, public originalError?: unknown) {\n super(message, 'NETWORK_ERROR', undefined, { originalError });\n this.name = 'NetworkError';\n Object.setPrototypeOf(this, NetworkError.prototype);\n }\n}\n\nexport class ValidationError extends CGSError {\n constructor(message: string, fields?: string[]) {\n super(message, 'VALIDATION_ERROR', 400, { fields });\n this.name = 'ValidationError';\n Object.setPrototypeOf(this, ValidationError.prototype);\n }\n}\n\nexport class ServiceUnavailableError extends CGSError {\n constructor(service: string) {\n super(`${service} is unavailable`, 'SERVICE_UNAVAILABLE', 503, { service });\n this.name = 'ServiceUnavailableError';\n Object.setPrototypeOf(this, ServiceUnavailableError.prototype);\n }\n}\n\nexport class ComplianceBlockedError extends CGSError {\n constructor(reasons: string[]) {\n super('Access blocked due to compliance rules', 'COMPLIANCE_BLOCKED', 403, { reasons });\n this.name = 'ComplianceBlockedError';\n Object.setPrototypeOf(this, ComplianceBlockedError.prototype);\n }\n}\n\nexport class AuthenticationError extends CGSError {\n constructor(message: string = 'Authentication failed') {\n super(message, 'AUTHENTICATION_ERROR', 401);\n this.name = 'AuthenticationError';\n Object.setPrototypeOf(this, AuthenticationError.prototype);\n }\n}\n\nexport class RateLimitError extends CGSError {\n constructor(public retryAfter?: number) {\n super('Rate limit exceeded', 'RATE_LIMIT_EXCEEDED', 429, { retryAfter });\n this.name = 'RateLimitError';\n Object.setPrototypeOf(this, RateLimitError.prototype);\n }\n}\n\nexport class TimeoutError extends CGSError {\n constructor(public timeout: number) {\n super(`Request timeout after ${timeout}ms`, 'TIMEOUT', 408, { timeout });\n this.name = 'TimeoutError';\n Object.setPrototypeOf(this, TimeoutError.prototype);\n }\n}\n\nexport class ComplianceError extends CGSError {\n constructor(\n message: string,\n public originalError?: unknown,\n code: string = 'COMPLIANCE_ERROR'\n ) {\n super(message, code, undefined, { originalError });\n this.name = 'ComplianceError';\n Object.setPrototypeOf(this, ComplianceError.prototype);\n }\n}\n","/**\n * Base HTTP client for all CGS SDK clients\n *\n * Provides common functionality:\n * - Request/response handling\n * - Error handling\n * - Retry logic with exponential backoff\n * - Timeout management\n * - Debug logging\n */\n\nimport type { BaseClientConfig, RequiredBaseClientConfig } from './config';\nimport {\n CGSError,\n NetworkError,\n TimeoutError,\n AuthenticationError,\n RateLimitError,\n ServiceUnavailableError,\n} from './errors';\n\nexport abstract class BaseClient {\n protected config: RequiredBaseClientConfig;\n\n constructor(config: BaseClientConfig) {\n this.config = {\n baseURL: config.baseURL,\n tenantId: config.tenantId,\n apiKey: config.apiKey || '',\n headers: config.headers || {},\n timeout: config.timeout || 10000,\n retries: config.retries || 3,\n debug: config.debug || false,\n };\n }\n\n /**\n * Make an HTTP request with timeout and error handling\n */\n protected async request<T>(\n endpoint: string,\n options: RequestInit = {},\n serviceURL?: string\n ): Promise<T> {\n const url = `${serviceURL || this.config.baseURL}${endpoint}`;\n\n const headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n 'X-Tenant-ID': this.config.tenantId,\n ...this.config.headers,\n ...((options.headers as Record<string, string>) || {}),\n };\n\n if (this.config.apiKey) {\n headers['Authorization'] = `Bearer ${this.config.apiKey}`;\n }\n\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);\n\n try {\n if (this.config.debug) {\n console.log(`[CGS SDK] ${options.method || 'GET'} ${url}`, {\n headers,\n body: options.body,\n });\n }\n\n const response = await fetch(url, {\n ...options,\n headers,\n signal: controller.signal,\n });\n\n clearTimeout(timeoutId);\n\n const data = await response.json();\n\n if (!response.ok) {\n this.handleErrorResponse(response.status, data);\n }\n\n if (this.config.debug) {\n console.log(`[CGS SDK] Response:`, data);\n }\n\n return data as T;\n } catch (error) {\n clearTimeout(timeoutId);\n\n if (error instanceof Error) {\n if (error.name === 'AbortError') {\n throw new TimeoutError(this.config.timeout);\n }\n if (error instanceof CGSError) {\n throw error;\n }\n }\n\n throw new NetworkError('Network request failed', error);\n }\n }\n\n /**\n * Make an HTTP request with retry logic\n */\n protected async requestWithRetry<T>(\n endpoint: string,\n options: RequestInit = {},\n serviceURL?: string,\n retries: number = this.config.retries\n ): Promise<T> {\n let lastError: Error | undefined;\n\n for (let attempt = 0; attempt <= retries; attempt++) {\n try {\n return await this.request<T>(endpoint, options, serviceURL);\n } catch (error) {\n lastError = error instanceof Error ? error : new Error('Unknown error');\n\n // Don't retry on client errors (4xx) or authentication errors\n if (\n lastError instanceof CGSError &&\n lastError.statusCode &&\n lastError.statusCode >= 400 &&\n lastError.statusCode < 500\n ) {\n throw lastError;\n }\n\n // Don't retry on last attempt\n if (attempt === retries) {\n break;\n }\n\n // Exponential backoff with jitter\n const delay = Math.min(1000 * Math.pow(2, attempt) + Math.random() * 1000, 10000);\n await new Promise((resolve) => setTimeout(resolve, delay));\n\n if (this.config.debug) {\n console.log(`[CGS SDK] Retry attempt ${attempt + 1}/${retries} after ${delay.toFixed(0)}ms`);\n }\n }\n }\n\n throw new NetworkError(`Request failed after ${retries} retries`, lastError);\n }\n\n /**\n * Handle error responses from API\n */\n protected handleErrorResponse(status: number, data: any): never {\n const message = data.error || data.message || `HTTP ${status}`;\n\n switch (status) {\n case 400:\n throw new CGSError(message, 'BAD_REQUEST', 400, data);\n case 401:\n throw new AuthenticationError(message);\n case 403:\n throw new CGSError(message, 'FORBIDDEN', 403, data);\n case 404:\n throw new CGSError(message, 'NOT_FOUND', 404, data);\n case 429:\n const retryAfter = data.retry_after || data.retryAfter;\n throw new RateLimitError(retryAfter);\n case 500:\n case 502:\n case 503:\n case 504:\n throw new ServiceUnavailableError(message);\n default:\n throw new CGSError(message, 'UNKNOWN_ERROR', status, data);\n }\n }\n\n /**\n * Build query string from parameters\n */\n protected buildQueryString(params: Record<string, unknown>): string {\n const query = new URLSearchParams();\n\n Object.entries(params).forEach(([key, value]) => {\n if (value !== undefined && value !== null) {\n if (Array.isArray(value)) {\n value.forEach((item) => query.append(key, String(item)));\n } else {\n query.append(key, String(value));\n }\n }\n });\n\n const queryString = query.toString();\n return queryString ? `?${queryString}` : '';\n }\n\n /**\n * Update client configuration\n */\n updateConfig(config: Partial<BaseClientConfig>): void {\n this.config = {\n ...this.config,\n ...config,\n headers: {\n ...this.config.headers,\n ...(config.headers || {}),\n },\n };\n }\n\n /**\n * Get current configuration (readonly)\n */\n getConfig(): Readonly<BaseClientConfig> {\n return { ...this.config };\n }\n\n /**\n * Health check endpoint\n */\n async healthCheck(): Promise<{ status: string; timestamp: string }> {\n return this.request('/api/v1/health');\n }\n}\n","/**\n * RiskProfileClient - Customer Risk Profile Management\n *\n * Provides methods to create, retrieve, and manage customer risk profiles\n * in the CGS Compliance Platform.\n */\n\nimport { BaseClient } from '../core/client';\nimport type { BaseClientConfig } from '../core/config';\nimport type {\n CustomerProfile,\n CreateProfileRequest,\n UpdateProfileRequest,\n ProfileDetailsResponse,\n ProfileFilters,\n ProfileListResponse,\n RiskDashboardMetrics,\n RiskConfiguration,\n} from './types';\n\nexport class RiskProfileClient extends BaseClient {\n constructor(config: BaseClientConfig) {\n super(config);\n }\n\n // ============================================================================\n // Profile Management\n // ============================================================================\n\n /**\n * Create a new customer risk profile\n *\n * @param request - Profile creation data\n * @returns Created customer profile\n *\n * @example\n * ```typescript\n * const profile = await client.createProfile({\n * customer_id: 'CUST-12345',\n * entity_type: 'individual',\n * customer_status: 'active',\n * full_name: 'John Doe',\n * email_address: 'john@example.com',\n * date_of_birth: '1990-01-15',\n * country_of_residence: 'US'\n * });\n * ```\n */\n async createProfile(request: CreateProfileRequest): Promise<CustomerProfile> {\n return this.request<CustomerProfile>('/api/v1/profiles', {\n method: 'POST',\n body: JSON.stringify(request),\n });\n }\n\n /**\n * Get customer profile by customer ID\n *\n * Note: This searches for the profile using the customer_id field.\n * Returns the first matching profile for the tenant.\n *\n * @param customerId - Customer ID to search for\n * @returns Customer profile\n *\n * @example\n * ```typescript\n * const profile = await client.getProfile('CUST-12345');\n * console.log('Risk score:', profile.risk_score);\n * ```\n */\n async getProfile(customerId: string): Promise<CustomerProfile> {\n const response = await this.queryProfiles({\n search: customerId,\n page: 1,\n page_size: 1,\n });\n\n if (response.data.length === 0) {\n throw new Error(`Profile not found for customer ID: ${customerId}`);\n }\n\n return response.data[0];\n }\n\n /**\n * Get profile by UUID\n *\n * @param profileId - Profile UUID\n * @returns Customer profile\n */\n async getProfileById(profileId: string): Promise<CustomerProfile> {\n // Note: The dashboard endpoint provides detailed profile view\n const details = await this.getProfileDetails(profileId);\n return details.profile;\n }\n\n /**\n * Get detailed profile information including risk factors and history\n *\n * @param profileId - Profile UUID\n * @returns Detailed profile response with risk factors and history\n *\n * @example\n * ```typescript\n * const details = await client.getProfileDetails(profileId);\n * console.log('Risk factors:', details.risk_factors);\n * console.log('Risk history:', details.risk_history);\n * console.log('Alert counts:', {\n * watchlist: details.watchlist_alert_count,\n * fraud: details.fraud_alert_count,\n * geo: details.geolocation_alert_count\n * });\n * ```\n */\n async getProfileDetails(profileId: string): Promise<ProfileDetailsResponse> {\n return this.request<ProfileDetailsResponse>(\n `/api/v1/risk-dashboard/profiles/${profileId}`\n );\n }\n\n /**\n * Update customer profile\n *\n * @param profileId - Profile UUID\n * @param updates - Fields to update\n * @returns Updated customer profile\n *\n * @example\n * ```typescript\n * const updated = await client.updateProfile(profileId, {\n * location: 'New York, USA',\n * location_compliance: 'compliant',\n * last_recorded_activity: new Date().toISOString()\n * });\n * ```\n */\n async updateProfile(\n profileId: string,\n updates: UpdateProfileRequest\n ): Promise<CustomerProfile> {\n return this.request<CustomerProfile>(`/api/v1/profiles/${profileId}`, {\n method: 'PUT',\n body: JSON.stringify(updates),\n });\n }\n\n /**\n * Manually recalculate risk score for a profile\n *\n * Triggers immediate risk score recalculation based on current risk factors.\n *\n * @param profileId - Profile UUID\n * @param reason - Optional reason for recalculation\n *\n * @example\n * ```typescript\n * await client.recalculateRiskScore(profileId, 'Manual review completed');\n * ```\n */\n async recalculateRiskScore(profileId: string, reason?: string): Promise<void> {\n const body = reason ? JSON.stringify({ reason }) : undefined;\n await this.request(`/api/v1/profiles/recalculate/${profileId}`, {\n method: 'POST',\n body,\n });\n }\n\n // ============================================================================\n // Query & Search\n // ============================================================================\n\n /**\n * Query profiles with advanced filters\n *\n * @param filters - Filter criteria and pagination\n * @returns Paginated list of profiles\n *\n * @example\n * ```typescript\n * const results = await client.queryProfiles({\n * risk_category: ['high', 'critical'],\n * kyc_status: ['pending'],\n * is_pep: true,\n * page: 1,\n * page_size: 20,\n * sort_by: 'risk_score',\n * sort_order: 'desc'\n * });\n *\n * console.log(`Found ${results.total} high-risk profiles`);\n * results.data.forEach(profile => {\n * console.log(`${profile.full_name}: ${profile.risk_score}`);\n * });\n * ```\n */\n async queryProfiles(filters: ProfileFilters = {}): Promise<ProfileListResponse> {\n const queryString = this.buildQueryString(filters as Record<string, unknown>);\n return this.request<ProfileListResponse>(\n `/api/v1/risk-dashboard/profiles${queryString}`\n );\n }\n\n /**\n * Search profiles by text (searches name, email, customer_id, account_number)\n *\n * @param searchText - Text to search for\n * @param limit - Maximum results to return (default: 10)\n * @returns Array of matching profiles\n */\n async searchProfiles(searchText: string, limit: number = 10): Promise<CustomerProfile[]> {\n const response = await this.queryProfiles({\n search: searchText,\n page: 1,\n page_size: limit,\n });\n return response.data;\n }\n\n /**\n * Get all high-risk profiles (high + critical)\n *\n * @param limit - Maximum results to return (default: 50)\n * @returns Array of high-risk profiles\n */\n async getHighRiskProfiles(limit: number = 50): Promise<CustomerProfile[]> {\n const response = await this.queryProfiles({\n risk_category: ['high', 'critical'],\n page: 1,\n page_size: limit,\n sort_by: 'risk_score',\n sort_order: 'desc',\n });\n return response.data;\n }\n\n /**\n * Get profiles requiring PEP review\n *\n * @param limit - Maximum results to return (default: 50)\n * @returns Array of PEP profiles\n */\n async getPEPProfiles(limit: number = 50): Promise<CustomerProfile[]> {\n const response = await this.queryProfiles({\n is_pep: true,\n page: 1,\n page_size: limit,\n });\n return response.data;\n }\n\n /**\n * Get profiles with sanctions matches\n *\n * @param limit - Maximum results to return (default: 50)\n * @returns Array of sanctioned profiles\n */\n async getSanctionedProfiles(limit: number = 50): Promise<CustomerProfile[]> {\n const response = await this.queryProfiles({\n has_sanctions: true,\n page: 1,\n page_size: limit,\n });\n return response.data;\n }\n\n // ============================================================================\n // Dashboard & Metrics\n // ============================================================================\n\n /**\n * Get risk dashboard metrics and statistics\n *\n * @param startDate - Optional start date for metrics (ISO format)\n * @param endDate - Optional end date for metrics (ISO format)\n * @returns Dashboard metrics\n *\n * @example\n * ```typescript\n * const metrics = await client.getDashboardMetrics();\n * console.log('Total risky profiles:', metrics.total_risky_profiles);\n * console.log('Critical profiles:', metrics.total_critical_profiles);\n * console.log('Average risk score:', metrics.average_risk_score);\n *\n * metrics.risk_distribution.forEach(item => {\n * console.log(`${item.category}: ${item.count} (${item.percentage}%)`);\n * });\n * ```\n */\n async getDashboardMetrics(\n startDate?: string,\n endDate?: string\n ): Promise<RiskDashboardMetrics> {\n const params: Record<string, string> = {};\n if (startDate) params.start_date = startDate;\n if (endDate) params.end_date = endDate;\n\n const queryString = this.buildQueryString(params);\n return this.request<RiskDashboardMetrics>(\n `/api/v1/risk-dashboard/metrics${queryString}`\n );\n }\n\n // ============================================================================\n // Bulk Operations\n // ============================================================================\n\n /**\n * Get or create profile (idempotent operation)\n *\n * Attempts to get existing profile by customer_id, creates if not found.\n *\n * @param customerId - Customer ID\n * @param createRequest - Profile data to use if creating new profile\n * @returns Existing or newly created profile\n *\n * @example\n * ```typescript\n * const profile = await client.getOrCreateProfile('CUST-123', {\n * customer_id: 'CUST-123',\n * entity_type: 'individual',\n * full_name: 'John Doe',\n * email_address: 'john@example.com'\n * });\n * ```\n */\n async getOrCreateProfile(\n customerId: string,\n createRequest: CreateProfileRequest\n ): Promise<CustomerProfile> {\n try {\n return await this.getProfile(customerId);\n } catch (error) {\n // Profile doesn't exist, create it\n return await this.createProfile(createRequest);\n }\n }\n\n /**\n * Batch get profiles by customer IDs\n *\n * @param customerIds - Array of customer IDs\n * @returns Array of profiles (may be less than input if some not found)\n */\n async batchGetProfiles(customerIds: string[]): Promise<CustomerProfile[]> {\n // Note: Current API doesn't have batch endpoint, so we query with search\n // In production, this should use a dedicated batch endpoint\n const profiles: CustomerProfile[] = [];\n\n for (const customerId of customerIds) {\n try {\n const profile = await this.getProfile(customerId);\n profiles.push(profile);\n } catch (error) {\n // Profile not found, skip\n if (this.config.debug) {\n console.warn(`[RiskProfileClient] Profile not found for: ${customerId}`);\n }\n }\n }\n\n return profiles;\n }\n\n // ============================================================================\n // Configuration\n // ============================================================================\n\n /**\n * Get risk configuration for tenant\n *\n * Returns the risk scoring weights and thresholds configured for the tenant.\n *\n * @returns Risk configuration\n */\n async getRiskConfiguration(): Promise<RiskConfiguration> {\n return this.request<RiskConfiguration>('/api/v1/risk-config');\n }\n\n /**\n * Update risk configuration for tenant\n *\n * Updates risk scoring weights and/or thresholds.\n *\n * @param config - Configuration updates\n * @returns Updated risk configuration\n */\n async updateRiskConfiguration(\n config: Partial<RiskConfiguration>\n ): Promise<RiskConfiguration> {\n return this.request<RiskConfiguration>('/api/v1/risk-config', {\n method: 'PUT',\n body: JSON.stringify(config),\n });\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/errors.ts","../../src/core/client.ts","../../src/risk-profile/client.ts"],"names":[],"mappings":";AAOO,IAAM,QAAA,GAAN,MAAM,SAAA,SAAiB,KAAA,CAAM;AAAA,EAClC,WAAA,CACE,OAAA,EACO,IAAA,EACA,UAAA,EACA,OAAA,EACP;AACA,IAAA,KAAA,CAAM,OAAO,CAAA;AAJN,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AACA,IAAA,IAAA,CAAA,UAAA,GAAA,UAAA;AACA,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAGP,IAAA,IAAA,CAAK,IAAA,GAAO,UAAA;AACZ,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,SAAA,CAAS,SAAS,CAAA;AAAA,EAChD;AACF,CAAA;AAEO,IAAM,YAAA,GAAN,MAAM,aAAA,SAAqB,QAAA,CAAS;AAAA,EACzC,WAAA,CAAY,SAAwB,aAAA,EAAyB;AAC3D,IAAA,KAAA,CAAM,OAAA,EAAS,eAAA,EAAiB,MAAA,EAAW,EAAE,eAAe,CAAA;A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AA;AAChD,QAAA,QAAA,CAAS,KAAK,OAAO,CAAA;AAAA,MACvB,SAAS,KAAA,EAAO;AAEd,QAAA,IAAI,IAAA,CAAK,OAAO,KAAA,EAAO;AACrB,UAAA,OAAA,CAAQ,IAAA,CAAK,CAAA,2CAAA,EAA8C,UAAU,CAAA,CAAE,CAAA;AAAA,QACzE;AAAA,MACF;AAAA,IACF;AAEA,IAAA,OAAO,QAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaA,MAAM,oBAAA,GAAmD;AACvD,IAAA,OAAO,IAAA,CAAK,QAA2B,qBAAqB,CAAA;AAAA,EAC9D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,MAAM,wBACJ,MAAA,EAC4B;AAC5B,IAAA,OAAO,IAAA,CAAK,QAA2B,qBAAA,EAAuB;AAAA,MAC5D,MAAA,EAAQ,KAAA;AAAA,MACR,IAAA,EAAM,IAAA,CAAK,SAAA,CAAU,MAAM;AAAA,KAC5B,CAAA;AAAA,EACH;AACF","file":"index.mjs","sourcesContent":["/**\n * Error hierarchy for CGS SDK\n *\n * Provides structured error handling with specific error types\n * for different failure scenarios.\n */\n\nexport class CGSError extends Error {\n constructor(\n message: string,\n public code: string,\n public statusCode?: number,\n public details?: Record<string, unknown>\n ) {\n super(message);\n this.name = 'CGSError';\n Object.setPrototypeOf(this, CGSError.prototype);\n }\n}\n\nexport class NetworkError extends CGSError {\n constructor(message: string, public originalError?: unknown) {\n super(message, 'NETWORK_ERROR', undefined, { originalError });\n this.name = 'NetworkError';\n Object.setPrototypeOf(this, NetworkError.prototype);\n }\n}\n\nexport class ValidationError extends CGSError {\n constructor(message: string, fields?: string[]) {\n super(message, 'VALIDATION_ERROR', 400, { fields });\n this.name = 'ValidationError';\n Object.setPrototypeOf(this, ValidationError.prototype);\n }\n}\n\nexport class ServiceUnavailableError extends CGSError {\n constructor(service: string) {\n super(`${service} is unavailable`, 'SERVICE_UNAVAILABLE', 503, { service });\n this.name = 'ServiceUnavailableError';\n Object.setPrototypeOf(this, ServiceUnavailableError.prototype);\n }\n}\n\nexport class ComplianceBlockedError extends CGSError {\n constructor(reasons: string[]) {\n super('Access blocked due to compliance rules', 'COMPLIANCE_BLOCKED', 403, { reasons });\n this.name = 'ComplianceBlockedError';\n Object.setPrototypeOf(this, ComplianceBlockedError.prototype);\n }\n}\n\nexport class AuthenticationError extends CGSError {\n constructor(message: string = 'Authentication failed') {\n super(message, 'AUTHENTICATION_ERROR', 401);\n this.name = 'AuthenticationError';\n Object.setPrototypeOf(this, AuthenticationError.prototype);\n }\n}\n\nexport class RateLimitError extends CGSError {\n constructor(public retryAfter?: number) {\n super('Rate limit exceeded', 'RATE_LIMIT_EXCEEDED', 429, { retryAfter });\n this.name = 'RateLimitError';\n Object.setPrototypeOf(this, RateLimitError.prototype);\n }\n}\n\nexport class TimeoutError extends CGSError {\n constructor(public timeout: number) {\n super(`Request timeout after ${timeout}ms`, 'TIMEOUT', 408, { timeout });\n this.name = 'TimeoutError';\n Object.setPrototypeOf(this, TimeoutError.prototype);\n }\n}\n\nexport class ComplianceError extends CGSError {\n constructor(\n message: string,\n public originalError?: unknown,\n code: string = 'COMPLIANCE_ERROR'\n ) {\n super(message, code, undefined, { originalError });\n this.name = 'ComplianceError';\n Object.setPrototypeOf(this, ComplianceError.prototype);\n }\n}\n","/**\n * Base HTTP client for all CGS SDK clients\n *\n * Provides common functionality:\n * - Request/response handling\n * - Error handling\n * - Retry logic with exponential backoff\n * - Timeout management\n * - Debug logging\n */\n\nimport type { BaseClientConfig, RequiredBaseClientConfig } from './config';\nimport {\n CGSError,\n NetworkError,\n TimeoutError,\n AuthenticationError,\n RateLimitError,\n ServiceUnavailableError,\n} from './errors';\n\nexport abstract class BaseClient {\n protected config: RequiredBaseClientConfig;\n\n constructor(config: BaseClientConfig) {\n this.config = {\n baseURL: config.baseURL,\n tenantId: config.tenantId,\n apiKey: config.apiKey || '',\n headers: config.headers || {},\n timeout: config.timeout || 10000,\n retries: config.retries || 3,\n debug: config.debug || false,\n };\n }\n\n /**\n * Make an HTTP request with timeout and error handling\n */\n protected async request<T>(\n endpoint: string,\n options: RequestInit = {},\n serviceURL?: string\n ): Promise<T> {\n const url = `${serviceURL || this.config.baseURL}${endpoint}`;\n\n const headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n 'X-Tenant-ID': this.config.tenantId,\n ...this.config.headers,\n ...((options.headers as Record<string, string>) || {}),\n };\n\n if (this.config.apiKey) {\n headers['Authorization'] = `Bearer ${this.config.apiKey}`;\n }\n\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);\n\n try {\n if (this.config.debug) {\n console.log(`[CGS SDK] ${options.method || 'GET'} ${url}`, {\n headers,\n body: options.body,\n });\n }\n\n const response = await fetch(url, {\n ...options,\n headers,\n signal: controller.signal,\n });\n\n clearTimeout(timeoutId);\n\n const data = await response.json();\n\n if (!response.ok) {\n this.handleErrorResponse(response.status, data);\n }\n\n if (this.config.debug) {\n console.log(`[CGS SDK] Response:`, data);\n }\n\n return data as T;\n } catch (error) {\n clearTimeout(timeoutId);\n\n if (error instanceof Error) {\n if (error.name === 'AbortError') {\n throw new TimeoutError(this.config.timeout);\n }\n if (error instanceof CGSError) {\n throw error;\n }\n }\n\n throw new NetworkError('Network request failed', error);\n }\n }\n\n /**\n * Make an HTTP request with retry logic\n */\n protected async requestWithRetry<T>(\n endpoint: string,\n options: RequestInit = {},\n serviceURL?: string,\n retries: number = this.config.retries\n ): Promise<T> {\n let lastError: Error | undefined;\n\n for (let attempt = 0; attempt <= retries; attempt++) {\n try {\n return await this.request<T>(endpoint, options, serviceURL);\n } catch (error) {\n lastError = error instanceof Error ? error : new Error('Unknown error');\n\n // Don't retry on client errors (4xx) or authentication errors\n if (\n lastError instanceof CGSError &&\n lastError.statusCode &&\n lastError.statusCode >= 400 &&\n lastError.statusCode < 500\n ) {\n throw lastError;\n }\n\n // Don't retry on last attempt\n if (attempt === retries) {\n break;\n }\n\n // Exponential backoff with jitter\n const delay = Math.min(1000 * Math.pow(2, attempt) + Math.random() * 1000, 10000);\n await new Promise((resolve) => setTimeout(resolve, delay));\n\n if (this.config.debug) {\n console.log(`[CGS SDK] Retry attempt ${attempt + 1}/${retries} after ${delay.toFixed(0)}ms`);\n }\n }\n }\n\n throw new NetworkError(`Request failed after ${retries} retries`, lastError);\n }\n\n /**\n * Handle error responses from API\n */\n protected handleErrorResponse(status: number, data: any): never {\n const message = data.error || data.message || `HTTP ${status}`;\n\n switch (status) {\n case 400:\n throw new CGSError(message, 'BAD_REQUEST', 400, data);\n case 401:\n throw new AuthenticationError(message);\n case 403:\n throw new CGSError(message, 'FORBIDDEN', 403, data);\n case 404:\n throw new CGSError(message, 'NOT_FOUND', 404, data);\n case 429:\n const retryAfter = data.retry_after || data.retryAfter;\n throw new RateLimitError(retryAfter);\n case 500:\n case 502:\n case 503:\n case 504:\n throw new ServiceUnavailableError(message);\n default:\n throw new CGSError(message, 'UNKNOWN_ERROR', status, data);\n }\n }\n\n /**\n * Build query string from parameters\n */\n protected buildQueryString(params: Record<string, unknown>): string {\n const query = new URLSearchParams();\n\n Object.entries(params).forEach(([key, value]) => {\n if (value !== undefined && value !== null) {\n if (Array.isArray(value)) {\n value.forEach((item) => query.append(key, String(item)));\n } else {\n query.append(key, String(value));\n }\n }\n });\n\n const queryString = query.toString();\n return queryString ? `?${queryString}` : '';\n }\n\n /**\n * Update client configuration\n */\n updateConfig(config: Partial<BaseClientConfig>): void {\n this.config = {\n ...this.config,\n ...config,\n headers: {\n ...this.config.headers,\n ...(config.headers || {}),\n },\n };\n }\n\n /**\n * Get current configuration (readonly)\n */\n getConfig(): Readonly<BaseClientConfig> {\n return { ...this.config };\n }\n\n /**\n * Health check endpoint\n */\n async healthCheck(): Promise<{ status: string; timestamp: string }> {\n return this.request('/api/v1/health');\n }\n}\n","/**\n * RiskProfileClient - Customer Risk Profile Management\n *\n * Provides methods to create, retrieve, and manage customer risk profiles\n * in the CGS Compliance Platform.\n */\n\nimport { BaseClient } from '../core/client';\nimport type { BaseClientConfig } from '../core/config';\nimport type {\n CustomerProfile,\n CreateProfileRequest,\n UpdateProfileRequest,\n ProfileDetailsResponse,\n ProfileFilters,\n ProfileListResponse,\n RiskDashboardMetrics,\n RiskConfiguration,\n} from './types';\n\nexport class RiskProfileClient extends BaseClient {\n constructor(config: BaseClientConfig) {\n super(config);\n }\n\n // ============================================================================\n // Profile Management\n // ============================================================================\n\n /**\n * Create a new customer risk profile\n *\n * @param request - Profile creation data\n * @returns Created customer profile\n *\n * @example\n * ```typescript\n * const profile = await client.createProfile({\n * customer_id: 'CUST-12345',\n * entity_type: 'individual',\n * customer_status: 'active',\n * full_name: 'John Doe',\n * email_address: 'john@example.com',\n * date_of_birth: '1990-01-15',\n * country_of_residence: 'US'\n * });\n * ```\n */\n async createProfile(request: CreateProfileRequest): Promise<CustomerProfile> {\n return this.request<CustomerProfile>('/api/v1/profiles', {\n method: 'POST',\n body: JSON.stringify(request),\n });\n }\n\n /**\n * Get customer profile by customer ID\n *\n * Note: This searches for the profile using the customer_id field.\n * Returns the first matching profile for the tenant.\n *\n * @param customerId - Customer ID to search for\n * @returns Customer profile\n *\n * @example\n * ```typescript\n * const profile = await client.getProfile('CUST-12345');\n * console.log('Risk score:', profile.risk_score);\n * ```\n */\n async getProfile(customerId: string): Promise<CustomerProfile> {\n const response = await this.queryProfiles({\n search: customerId,\n page: 1,\n page_size: 1,\n });\n\n if (response.data.length === 0) {\n throw new Error(`Profile not found for customer ID: ${customerId}`);\n }\n\n return response.data[0];\n }\n\n /**\n * Get profile by UUID\n *\n * @param profileId - Profile UUID\n * @returns Customer profile\n */\n async getProfileById(profileId: string): Promise<CustomerProfile> {\n // Note: The dashboard endpoint provides detailed profile view\n const details = await this.getProfileDetails(profileId);\n return details.profile;\n }\n\n /**\n * Get detailed profile information including risk factors and history\n *\n * @param profileId - Profile UUID\n * @returns Detailed profile response with risk factors and history\n *\n * @example\n * ```typescript\n * const details = await client.getProfileDetails(profileId);\n * console.log('Risk factors:', details.risk_factors);\n * console.log('Risk history:', details.risk_history);\n * console.log('Alert counts:', {\n * watchlist: details.watchlist_alert_count,\n * fraud: details.fraud_alert_count,\n * geo: details.geolocation_alert_count\n * });\n * ```\n */\n async getProfileDetails(profileId: string): Promise<ProfileDetailsResponse> {\n return this.request<ProfileDetailsResponse>(\n `/api/v1/risk-dashboard/profiles/${profileId}`\n );\n }\n\n /**\n * Update customer profile\n *\n * @param profileId - Profile UUID\n * @param updates - Fields to update\n * @returns Updated customer profile\n *\n * @example\n * ```typescript\n * const updated = await client.updateProfile(profileId, {\n * location: 'New York, USA',\n * location_compliance: 'compliant',\n * last_recorded_activity: new Date().toISOString()\n * });\n * ```\n */\n async updateProfile(\n profileId: string,\n updates: UpdateProfileRequest\n ): Promise<CustomerProfile> {\n return this.request<CustomerProfile>(`/api/v1/profiles/${profileId}`, {\n method: 'PUT',\n body: JSON.stringify(updates),\n });\n }\n\n /**\n * Manually recalculate risk score for a profile\n *\n * Triggers immediate risk score recalculation based on current risk factors.\n *\n * @param profileId - Profile UUID\n * @param reason - Optional reason for recalculation\n *\n * @example\n * ```typescript\n * await client.recalculateRiskScore(profileId, 'Manual review completed');\n * ```\n */\n async recalculateRiskScore(profileId: string, reason?: string): Promise<void> {\n const body = reason ? JSON.stringify({ reason }) : undefined;\n await this.request(`/api/v1/profiles/recalculate/${profileId}`, {\n method: 'POST',\n body,\n });\n }\n\n // ============================================================================\n // Query & Search\n // ============================================================================\n\n /**\n * Query profiles with advanced filters\n *\n * @param filters - Filter criteria and pagination\n * @returns Paginated list of profiles\n *\n * @example\n * ```typescript\n * const results = await client.queryProfiles({\n * risk_category: ['high', 'critical'],\n * kyc_status: ['pending'],\n * is_pep: true,\n * page: 1,\n * page_size: 20,\n * sort_by: 'risk_score',\n * sort_order: 'desc'\n * });\n *\n * console.log(`Found ${results.total} high-risk profiles`);\n * results.data.forEach(profile => {\n * console.log(`${profile.full_name}: ${profile.risk_score}`);\n * });\n * ```\n */\n async queryProfiles(filters: ProfileFilters = {}): Promise<ProfileListResponse> {\n const queryString = this.buildQueryString(filters);\n return this.request<ProfileListResponse>(\n `/api/v1/risk-dashboard/profiles${queryString}`\n );\n }\n\n /**\n * Search profiles by text (searches name, email, customer_id, account_number)\n *\n * @param searchText - Text to search for\n * @param limit - Maximum results to return (default: 10)\n * @returns Array of matching profiles\n */\n async searchProfiles(searchText: string, limit: number = 10): Promise<CustomerProfile[]> {\n const response = await this.queryProfiles({\n search: searchText,\n page: 1,\n page_size: limit,\n });\n return response.data;\n }\n\n /**\n * Get all high-risk profiles (high + critical)\n *\n * @param limit - Maximum results to return (default: 50)\n * @returns Array of high-risk profiles\n */\n async getHighRiskProfiles(limit: number = 50): Promise<CustomerProfile[]> {\n const response = await this.queryProfiles({\n risk_category: ['high', 'critical'],\n page: 1,\n page_size: limit,\n sort_by: 'risk_score',\n sort_order: 'desc',\n });\n return response.data;\n }\n\n /**\n * Get profiles requiring PEP review\n *\n * @param limit - Maximum results to return (default: 50)\n * @returns Array of PEP profiles\n */\n async getPEPProfiles(limit: number = 50): Promise<CustomerProfile[]> {\n const response = await this.queryProfiles({\n is_pep: true,\n page: 1,\n page_size: limit,\n });\n return response.data;\n }\n\n /**\n * Get profiles with sanctions matches\n *\n * @param limit - Maximum results to return (default: 50)\n * @returns Array of sanctioned profiles\n */\n async getSanctionedProfiles(limit: number = 50): Promise<CustomerProfile[]> {\n const response = await this.queryProfiles({\n has_sanctions: true,\n page: 1,\n page_size: limit,\n });\n return response.data;\n }\n\n // ============================================================================\n // Dashboard & Metrics\n // ============================================================================\n\n /**\n * Get risk dashboard metrics and statistics\n *\n * @param startDate - Optional start date for metrics (ISO format)\n * @param endDate - Optional end date for metrics (ISO format)\n * @returns Dashboard metrics\n *\n * @example\n * ```typescript\n * const metrics = await client.getDashboardMetrics();\n * console.log('Total risky profiles:', metrics.total_risky_profiles);\n * console.log('Critical profiles:', metrics.total_critical_profiles);\n * console.log('Average risk score:', metrics.average_risk_score);\n *\n * metrics.risk_distribution.forEach(item => {\n * console.log(`${item.category}: ${item.count} (${item.percentage}%)`);\n * });\n * ```\n */\n async getDashboardMetrics(\n startDate?: string,\n endDate?: string\n ): Promise<RiskDashboardMetrics> {\n const params: Record<string, string> = {};\n if (startDate) params.start_date = startDate;\n if (endDate) params.end_date = endDate;\n\n const queryString = this.buildQueryString(params);\n return this.request<RiskDashboardMetrics>(\n `/api/v1/risk-dashboard/metrics${queryString}`\n );\n }\n\n // ============================================================================\n // Bulk Operations\n // ============================================================================\n\n /**\n * Get or create profile (idempotent operation)\n *\n * Attempts to get existing profile by customer_id, creates if not found.\n *\n * @param customerId - Customer ID\n * @param createRequest - Profile data to use if creating new profile\n * @returns Existing or newly created profile\n *\n * @example\n * ```typescript\n * const profile = await client.getOrCreateProfile('CUST-123', {\n * customer_id: 'CUST-123',\n * entity_type: 'individual',\n * full_name: 'John Doe',\n * email_address: 'john@example.com'\n * });\n * ```\n */\n async getOrCreateProfile(\n customerId: string,\n createRequest: CreateProfileRequest\n ): Promise<CustomerProfile> {\n try {\n return await this.getProfile(customerId);\n } catch (error) {\n // Profile doesn't exist, create it\n return await this.createProfile(createRequest);\n }\n }\n\n /**\n * Batch get profiles by customer IDs\n *\n * @param customerIds - Array of customer IDs\n * @returns Array of profiles (may be less than input if some not found)\n */\n async batchGetProfiles(customerIds: string[]): Promise<CustomerProfile[]> {\n // Note: Current API doesn't have batch endpoint, so we query with search\n // In production, this should use a dedicated batch endpoint\n const profiles: CustomerProfile[] = [];\n\n for (const customerId of customerIds) {\n try {\n const profile = await this.getProfile(customerId);\n profiles.push(profile);\n } catch (error) {\n // Profile not found, skip\n if (this.config.debug) {\n console.warn(`[RiskProfileClient] Profile not found for: ${customerId}`);\n }\n }\n }\n\n return profiles;\n }\n\n // ============================================================================\n // Configuration\n // ============================================================================\n\n /**\n * Get risk configuration for tenant\n *\n * Returns the risk scoring weights and thresholds configured for the tenant.\n *\n * @returns Risk configuration\n */\n async getRiskConfiguration(): Promise<RiskConfiguration> {\n return this.request<RiskConfiguration>('/api/v1/risk-config');\n }\n\n /**\n * Update risk configuration for tenant\n *\n * Updates risk scoring weights and/or thresholds.\n *\n * @param config - Configuration updates\n * @returns Updated risk configuration\n */\n async updateRiskConfiguration(\n config: Partial<RiskConfiguration>\n ): Promise<RiskConfiguration> {\n return this.request<RiskConfiguration>('/api/v1/risk-config', {\n method: 'PUT',\n body: JSON.stringify(config),\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/core/errors.ts","../../src/core/client.ts","../../src/risk-profile/client.ts"],"names":[],"mappings":";AAOO,IAAM,QAAA,GAAN,MAAM,SAAA,SAAiB,KAAA,CAAM;AAAA,EAClC,WAAA,CACE,OAAA,EACO,IAAA,EACA,UAAA,EACA,OAAA,EACP;AACA,IAAA,KAAA,CAAM,OAAO,CAAA;AAJN,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AACA,IAAA,IAAA,CAAA,UAAA,GAAA,UAAA;AACA,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAGP,IAAA,IAAA,CAAK,IAAA,GAAO,UAAA;AACZ,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,SAAA,CAAS,SAAS,CAAA;AAAA,EAChD;AACF,CAAA;AAEO,IAAM,YAAA,GAAN,MAAM,aAAA,SAAqB,QAAA,CAAS;AAAA,EACzC,WAAA,CAAY,SAAwB,aAAA,EAAyB;AAC3D,IAAA,KAAA,CAAM,OAAA,EAAS,eAAA,EAAiB,MAAA,EAAW,EAAE,eAAe,CAAA;AAD1B,IAAA,IAAA,CAAA,aAAA,GAAA,aAAA;AAElC,IAAA,IAAA,CAAK,IAAA,GAAO,cAAA;AACZ,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,aAAA,CAAa,SAAS,CAAA;AAAA,EACpD;AACF,CAAA;AAUO,IAAM,u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AA,CAAE,CAAA;AAAA,QACzE;AAAA,MACF;AAAA,IACF;AAEA,IAAA,OAAO,QAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaA,MAAM,oBAAA,GAAmD;AACvD,IAAA,OAAO,IAAA,CAAK,QAA2B,qBAAqB,CAAA;AAAA,EAC9D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,MAAM,wBACJ,MAAA,EAC4B;AAC5B,IAAA,OAAO,IAAA,CAAK,QAA2B,qBAAA,EAAuB;AAAA,MAC5D,MAAA,EAAQ,KAAA;AAAA,MACR,IAAA,EAAM,IAAA,CAAK,SAAA,CAAU,MAAM;AAAA,KAC5B,CAAA;AAAA,EACH;AACF","file":"index.mjs","sourcesContent":["/**\n * Error hierarchy for CGS SDK\n *\n * Provides structured error handling with specific error types\n * for different failure scenarios.\n */\n\nexport class CGSError extends Error {\n constructor(\n message: string,\n public code: string,\n public statusCode?: number,\n public details?: Record<string, unknown>\n ) {\n super(message);\n this.name = 'CGSError';\n Object.setPrototypeOf(this, CGSError.prototype);\n }\n}\n\nexport class NetworkError extends CGSError {\n constructor(message: string, public originalError?: unknown) {\n super(message, 'NETWORK_ERROR', undefined, { originalError });\n this.name = 'NetworkError';\n Object.setPrototypeOf(this, NetworkError.prototype);\n }\n}\n\nexport class ValidationError extends CGSError {\n constructor(message: string, fields?: string[]) {\n super(message, 'VALIDATION_ERROR', 400, { fields });\n this.name = 'ValidationError';\n Object.setPrototypeOf(this, ValidationError.prototype);\n }\n}\n\nexport class ServiceUnavailableError extends CGSError {\n constructor(service: string) {\n super(`${service} is unavailable`, 'SERVICE_UNAVAILABLE', 503, { service });\n this.name = 'ServiceUnavailableError';\n Object.setPrototypeOf(this, ServiceUnavailableError.prototype);\n }\n}\n\nexport class ComplianceBlockedError extends CGSError {\n constructor(reasons: string[]) {\n super('Access blocked due to compliance rules', 'COMPLIANCE_BLOCKED', 403, { reasons });\n this.name = 'ComplianceBlockedError';\n Object.setPrototypeOf(this, ComplianceBlockedError.prototype);\n }\n}\n\nexport class AuthenticationError extends CGSError {\n constructor(message: string = 'Authentication failed') {\n super(message, 'AUTHENTICATION_ERROR', 401);\n this.name = 'AuthenticationError';\n Object.setPrototypeOf(this, AuthenticationError.prototype);\n }\n}\n\nexport class RateLimitError extends CGSError {\n constructor(public retryAfter?: number) {\n super('Rate limit exceeded', 'RATE_LIMIT_EXCEEDED', 429, { retryAfter });\n this.name = 'RateLimitError';\n Object.setPrototypeOf(this, RateLimitError.prototype);\n }\n}\n\nexport class TimeoutError extends CGSError {\n constructor(public timeout: number) {\n super(`Request timeout after ${timeout}ms`, 'TIMEOUT', 408, { timeout });\n this.name = 'TimeoutError';\n Object.setPrototypeOf(this, TimeoutError.prototype);\n }\n}\n\nexport class ComplianceError extends CGSError {\n constructor(\n message: string,\n public originalError?: unknown,\n code: string = 'COMPLIANCE_ERROR'\n ) {\n super(message, code, undefined, { originalError });\n this.name = 'ComplianceError';\n Object.setPrototypeOf(this, ComplianceError.prototype);\n }\n}\n","/**\n * Base HTTP client for all CGS SDK clients\n *\n * Provides common functionality:\n * - Request/response handling\n * - Error handling\n * - Retry logic with exponential backoff\n * - Timeout management\n * - Debug logging\n */\n\nimport type { BaseClientConfig, RequiredBaseClientConfig } from './config';\nimport {\n CGSError,\n NetworkError,\n TimeoutError,\n AuthenticationError,\n RateLimitError,\n ServiceUnavailableError,\n} from './errors';\n\nexport abstract class BaseClient {\n protected config: RequiredBaseClientConfig;\n\n constructor(config: BaseClientConfig) {\n this.config = {\n baseURL: config.baseURL,\n tenantId: config.tenantId,\n apiKey: config.apiKey || '',\n headers: config.headers || {},\n timeout: config.timeout || 10000,\n retries: config.retries || 3,\n debug: config.debug || false,\n };\n }\n\n /**\n * Make an HTTP request with timeout and error handling\n */\n protected async request<T>(\n endpoint: string,\n options: RequestInit = {},\n serviceURL?: string\n ): Promise<T> {\n const url = `${serviceURL || this.config.baseURL}${endpoint}`;\n\n const headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n 'X-Tenant-ID': this.config.tenantId,\n ...this.config.headers,\n ...((options.headers as Record<string, string>) || {}),\n };\n\n if (this.config.apiKey) {\n headers['Authorization'] = `Bearer ${this.config.apiKey}`;\n }\n\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);\n\n try {\n if (this.config.debug) {\n console.log(`[CGS SDK] ${options.method || 'GET'} ${url}`, {\n headers,\n body: options.body,\n });\n }\n\n const response = await fetch(url, {\n ...options,\n headers,\n signal: controller.signal,\n });\n\n clearTimeout(timeoutId);\n\n const data = await response.json();\n\n if (!response.ok) {\n this.handleErrorResponse(response.status, data);\n }\n\n if (this.config.debug) {\n console.log(`[CGS SDK] Response:`, data);\n }\n\n return data as T;\n } catch (error) {\n clearTimeout(timeoutId);\n\n if (error instanceof Error) {\n if (error.name === 'AbortError') {\n throw new TimeoutError(this.config.timeout);\n }\n if (error instanceof CGSError) {\n throw error;\n }\n }\n\n throw new NetworkError('Network request failed', error);\n }\n }\n\n /**\n * Make an HTTP request with retry logic\n */\n protected async requestWithRetry<T>(\n endpoint: string,\n options: RequestInit = {},\n serviceURL?: string,\n retries: number = this.config.retries\n ): Promise<T> {\n let lastError: Error | undefined;\n\n for (let attempt = 0; attempt <= retries; attempt++) {\n try {\n return await this.request<T>(endpoint, options, serviceURL);\n } catch (error) {\n lastError = error instanceof Error ? error : new Error('Unknown error');\n\n // Don't retry on client errors (4xx) or authentication errors\n if (\n lastError instanceof CGSError &&\n lastError.statusCode &&\n lastError.statusCode >= 400 &&\n lastError.statusCode < 500\n ) {\n throw lastError;\n }\n\n // Don't retry on last attempt\n if (attempt === retries) {\n break;\n }\n\n // Exponential backoff with jitter\n const delay = Math.min(1000 * Math.pow(2, attempt) + Math.random() * 1000, 10000);\n await new Promise((resolve) => setTimeout(resolve, delay));\n\n if (this.config.debug) {\n console.log(`[CGS SDK] Retry attempt ${attempt + 1}/${retries} after ${delay.toFixed(0)}ms`);\n }\n }\n }\n\n throw new NetworkError(`Request failed after ${retries} retries`, lastError);\n }\n\n /**\n * Handle error responses from API\n */\n protected handleErrorResponse(status: number, data: any): never {\n const message = data.error || data.message || `HTTP ${status}`;\n\n switch (status) {\n case 400:\n throw new CGSError(message, 'BAD_REQUEST', 400, data);\n case 401:\n throw new AuthenticationError(message);\n case 403:\n throw new CGSError(message, 'FORBIDDEN', 403, data);\n case 404:\n throw new CGSError(message, 'NOT_FOUND', 404, data);\n case 429:\n const retryAfter = data.retry_after || data.retryAfter;\n throw new RateLimitError(retryAfter);\n case 500:\n case 502:\n case 503:\n case 504:\n throw new ServiceUnavailableError(message);\n default:\n throw new CGSError(message, 'UNKNOWN_ERROR', status, data);\n }\n }\n\n /**\n * Build query string from parameters\n */\n protected buildQueryString(params: Record<string, unknown>): string {\n const query = new URLSearchParams();\n\n Object.entries(params).forEach(([key, value]) => {\n if (value !== undefined && value !== null) {\n if (Array.isArray(value)) {\n value.forEach((item) => query.append(key, String(item)));\n } else {\n query.append(key, String(value));\n }\n }\n });\n\n const queryString = query.toString();\n return queryString ? `?${queryString}` : '';\n }\n\n /**\n * Update client configuration\n */\n updateConfig(config: Partial<BaseClientConfig>): void {\n this.config = {\n ...this.config,\n ...config,\n headers: {\n ...this.config.headers,\n ...(config.headers || {}),\n },\n };\n }\n\n /**\n * Get current configuration (readonly)\n */\n getConfig(): Readonly<BaseClientConfig> {\n return { ...this.config };\n }\n\n /**\n * Health check endpoint\n */\n async healthCheck(): Promise<{ status: string; timestamp: string }> {\n return this.request('/api/v1/health');\n }\n}\n","/**\n * RiskProfileClient - Customer Risk Profile Management\n *\n * Provides methods to create, retrieve, and manage customer risk profiles\n * in the CGS Compliance Platform.\n */\n\nimport { BaseClient } from '../core/client';\nimport type { BaseClientConfig } from '../core/config';\nimport type {\n CustomerProfile,\n CreateProfileRequest,\n UpdateProfileRequest,\n ProfileDetailsResponse,\n ProfileFilters,\n ProfileListResponse,\n RiskDashboardMetrics,\n RiskConfiguration,\n} from './types';\n\nexport class RiskProfileClient extends BaseClient {\n constructor(config: BaseClientConfig) {\n super(config);\n }\n\n // ============================================================================\n // Profile Management\n // ============================================================================\n\n /**\n * Create a new customer risk profile\n *\n * @param request - Profile creation data\n * @returns Created customer profile\n *\n * @example\n * ```typescript\n * const profile = await client.createProfile({\n * customer_id: 'CUST-12345',\n * entity_type: 'individual',\n * customer_status: 'active',\n * full_name: 'John Doe',\n * email_address: 'john@example.com',\n * date_of_birth: '1990-01-15',\n * country_of_residence: 'US'\n * });\n * ```\n */\n async createProfile(request: CreateProfileRequest): Promise<CustomerProfile> {\n return this.request<CustomerProfile>('/api/v1/profiles', {\n method: 'POST',\n body: JSON.stringify(request),\n });\n }\n\n /**\n * Get customer profile by customer ID\n *\n * Note: This searches for the profile using the customer_id field.\n * Returns the first matching profile for the tenant.\n *\n * @param customerId - Customer ID to search for\n * @returns Customer profile\n *\n * @example\n * ```typescript\n * const profile = await client.getProfile('CUST-12345');\n * console.log('Risk score:', profile.risk_score);\n * ```\n */\n async getProfile(customerId: string): Promise<CustomerProfile> {\n const response = await this.queryProfiles({\n search: customerId,\n page: 1,\n page_size: 1,\n });\n\n if (response.data.length === 0) {\n throw new Error(`Profile not found for customer ID: ${customerId}`);\n }\n\n return response.data[0];\n }\n\n /**\n * Get profile by UUID\n *\n * @param profileId - Profile UUID\n * @returns Customer profile\n */\n async getProfileById(profileId: string): Promise<CustomerProfile> {\n // Note: The dashboard endpoint provides detailed profile view\n const details = await this.getProfileDetails(profileId);\n return details.profile;\n }\n\n /**\n * Get detailed profile information including risk factors and history\n *\n * @param profileId - Profile UUID\n * @returns Detailed profile response with risk factors and history\n *\n * @example\n * ```typescript\n * const details = await client.getProfileDetails(profileId);\n * console.log('Risk factors:', details.risk_factors);\n * console.log('Risk history:', details.risk_history);\n * console.log('Alert counts:', {\n * watchlist: details.watchlist_alert_count,\n * fraud: details.fraud_alert_count,\n * geo: details.geolocation_alert_count\n * });\n * ```\n */\n async getProfileDetails(profileId: string): Promise<ProfileDetailsResponse> {\n return this.request<ProfileDetailsResponse>(\n `/api/v1/risk-dashboard/profiles/${profileId}`\n );\n }\n\n /**\n * Update customer profile\n *\n * @param profileId - Profile UUID\n * @param updates - Fields to update\n * @returns Updated customer profile\n *\n * @example\n * ```typescript\n * const updated = await client.updateProfile(profileId, {\n * location: 'New York, USA',\n * location_compliance: 'compliant',\n * last_recorded_activity: new Date().toISOString()\n * });\n * ```\n */\n async updateProfile(\n profileId: string,\n updates: UpdateProfileRequest\n ): Promise<CustomerProfile> {\n return this.request<CustomerProfile>(`/api/v1/profiles/${profileId}`, {\n method: 'PUT',\n body: JSON.stringify(updates),\n });\n }\n\n /**\n * Manually recalculate risk score for a profile\n *\n * Triggers immediate risk score recalculation based on current risk factors.\n *\n * @param profileId - Profile UUID\n * @param reason - Optional reason for recalculation\n *\n * @example\n * ```typescript\n * await client.recalculateRiskScore(profileId, 'Manual review completed');\n * ```\n */\n async recalculateRiskScore(profileId: string, reason?: string): Promise<void> {\n const body = reason ? JSON.stringify({ reason }) : undefined;\n await this.request(`/api/v1/profiles/recalculate/${profileId}`, {\n method: 'POST',\n body,\n });\n }\n\n // ============================================================================\n // Query & Search\n // ============================================================================\n\n /**\n * Query profiles with advanced filters\n *\n * @param filters - Filter criteria and pagination\n * @returns Paginated list of profiles\n *\n * @example\n * ```typescript\n * const results = await client.queryProfiles({\n * risk_category: ['high', 'critical'],\n * kyc_status: ['pending'],\n * is_pep: true,\n * page: 1,\n * page_size: 20,\n * sort_by: 'risk_score',\n * sort_order: 'desc'\n * });\n *\n * console.log(`Found ${results.total} high-risk profiles`);\n * results.data.forEach(profile => {\n * console.log(`${profile.full_name}: ${profile.risk_score}`);\n * });\n * ```\n */\n async queryProfiles(filters: ProfileFilters = {}): Promise<ProfileListResponse> {\n const queryString = this.buildQueryString(filters as Record<string, unknown>);\n return this.request<ProfileListResponse>(\n `/api/v1/risk-dashboard/profiles${queryString}`\n );\n }\n\n /**\n * Search profiles by text (searches name, email, customer_id, account_number)\n *\n * @param searchText - Text to search for\n * @param limit - Maximum results to return (default: 10)\n * @returns Array of matching profiles\n */\n async searchProfiles(searchText: string, limit: number = 10): Promise<CustomerProfile[]> {\n const response = await this.queryProfiles({\n search: searchText,\n page: 1,\n page_size: limit,\n });\n return response.data;\n }\n\n /**\n * Get all high-risk profiles (high + critical)\n *\n * @param limit - Maximum results to return (default: 50)\n * @returns Array of high-risk profiles\n */\n async getHighRiskProfiles(limit: number = 50): Promise<CustomerProfile[]> {\n const response = await this.queryProfiles({\n risk_category: ['high', 'critical'],\n page: 1,\n page_size: limit,\n sort_by: 'risk_score',\n sort_order: 'desc',\n });\n return response.data;\n }\n\n /**\n * Get profiles requiring PEP review\n *\n * @param limit - Maximum results to return (default: 50)\n * @returns Array of PEP profiles\n */\n async getPEPProfiles(limit: number = 50): Promise<CustomerProfile[]> {\n const response = await this.queryProfiles({\n is_pep: true,\n page: 1,\n page_size: limit,\n });\n return response.data;\n }\n\n /**\n * Get profiles with sanctions matches\n *\n * @param limit - Maximum results to return (default: 50)\n * @returns Array of sanctioned profiles\n */\n async getSanctionedProfiles(limit: number = 50): Promise<CustomerProfile[]> {\n const response = await this.queryProfiles({\n has_sanctions: true,\n page: 1,\n page_size: limit,\n });\n return response.data;\n }\n\n // ============================================================================\n // Dashboard & Metrics\n // ============================================================================\n\n /**\n * Get risk dashboard metrics and statistics\n *\n * @param startDate - Optional start date for metrics (ISO format)\n * @param endDate - Optional end date for metrics (ISO format)\n * @returns Dashboard metrics\n *\n * @example\n * ```typescript\n * const metrics = await client.getDashboardMetrics();\n * console.log('Total risky profiles:', metrics.total_risky_profiles);\n * console.log('Critical profiles:', metrics.total_critical_profiles);\n * console.log('Average risk score:', metrics.average_risk_score);\n *\n * metrics.risk_distribution.forEach(item => {\n * console.log(`${item.category}: ${item.count} (${item.percentage}%)`);\n * });\n * ```\n */\n async getDashboardMetrics(\n startDate?: string,\n endDate?: string\n ): Promise<RiskDashboardMetrics> {\n const params: Record<string, string> = {};\n if (startDate) params.start_date = startDate;\n if (endDate) params.end_date = endDate;\n\n const queryString = this.buildQueryString(params);\n return this.request<RiskDashboardMetrics>(\n `/api/v1/risk-dashboard/metrics${queryString}`\n );\n }\n\n // ============================================================================\n // Bulk Operations\n // ============================================================================\n\n /**\n * Get or create profile (idempotent operation)\n *\n * Attempts to get existing profile by customer_id, creates if not found.\n *\n * @param customerId - Customer ID\n * @param createRequest - Profile data to use if creating new profile\n * @returns Existing or newly created profile\n *\n * @example\n * ```typescript\n * const profile = await client.getOrCreateProfile('CUST-123', {\n * customer_id: 'CUST-123',\n * entity_type: 'individual',\n * full_name: 'John Doe',\n * email_address: 'john@example.com'\n * });\n * ```\n */\n async getOrCreateProfile(\n customerId: string,\n createRequest: CreateProfileRequest\n ): Promise<CustomerProfile> {\n try {\n return await this.getProfile(customerId);\n } catch (error) {\n // Profile doesn't exist, create it\n return await this.createProfile(createRequest);\n }\n }\n\n /**\n * Batch get profiles by customer IDs\n *\n * @param customerIds - Array of customer IDs\n * @returns Array of profiles (may be less than input if some not found)\n */\n async batchGetProfiles(customerIds: string[]): Promise<CustomerProfile[]> {\n // Note: Current API doesn't have batch endpoint, so we query with search\n // In production, this should use a dedicated batch endpoint\n const profiles: CustomerProfile[] = [];\n\n for (const customerId of customerIds) {\n try {\n const profile = await this.getProfile(customerId);\n profiles.push(profile);\n } catch (error) {\n // Profile not found, skip\n if (this.config.debug) {\n console.warn(`[RiskProfileClient] Profile not found for: ${customerId}`);\n }\n }\n }\n\n return profiles;\n }\n\n // ============================================================================\n // Configuration\n // ============================================================================\n\n /**\n * Get risk configuration for tenant\n *\n * Returns the risk scoring weights and thresholds configured for the tenant.\n *\n * @returns Risk configuration\n */\n async getRiskConfiguration(): Promise<RiskConfiguration> {\n return this.request<RiskConfiguration>('/api/v1/risk-config');\n }\n\n /**\n * Update risk configuration for tenant\n *\n * Updates risk scoring weights and/or thresholds.\n *\n * @param config - Configuration updates\n * @returns Updated risk configuration\n */\n async updateRiskConfiguration(\n config: Partial<RiskConfiguration>\n ): Promise<RiskConfiguration> {\n return this.request<RiskConfiguration>('/api/v1/risk-config', {\n method: 'PUT',\n body: JSON.stringify(config),\n });\n }\n}\n"]}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types used across all CGS SDK modules
|
|
3
|
+
*/
|
|
4
|
+
interface APIResponse<T> {
|
|
5
|
+
data?: T;
|
|
6
|
+
error?: string;
|
|
7
|
+
message?: string;
|
|
8
|
+
}
|
|
9
|
+
interface PaginationParams {
|
|
10
|
+
page?: number;
|
|
11
|
+
page_size?: number;
|
|
12
|
+
}
|
|
13
|
+
interface PaginatedResponse<T> {
|
|
14
|
+
data: T[];
|
|
15
|
+
total: number;
|
|
16
|
+
page: number;
|
|
17
|
+
page_size: number;
|
|
18
|
+
total_pages: number;
|
|
19
|
+
}
|
|
20
|
+
interface SuccessResponse<T = unknown> {
|
|
21
|
+
success: true;
|
|
22
|
+
data: T;
|
|
23
|
+
message?: string;
|
|
24
|
+
}
|
|
25
|
+
interface ErrorResponse {
|
|
26
|
+
success: false;
|
|
27
|
+
error: string;
|
|
28
|
+
code?: string;
|
|
29
|
+
details?: Record<string, unknown>;
|
|
30
|
+
}
|
|
31
|
+
type Result<T> = SuccessResponse<T> | ErrorResponse;
|
|
32
|
+
/**
|
|
33
|
+
* Standard timestamp format: ISO 8601
|
|
34
|
+
*/
|
|
35
|
+
type Timestamp = string;
|
|
36
|
+
/**
|
|
37
|
+
* UUID format
|
|
38
|
+
*/
|
|
39
|
+
type UUID = string;
|
|
40
|
+
/**
|
|
41
|
+
* Risk levels used across the platform
|
|
42
|
+
*/
|
|
43
|
+
type RiskLevel = 'low' | 'medium' | 'high' | 'critical';
|
|
44
|
+
/**
|
|
45
|
+
* Customer status types
|
|
46
|
+
*/
|
|
47
|
+
type CustomerStatus = 'active' | 'dormant' | 'deactive' | 'suspended';
|
|
48
|
+
/**
|
|
49
|
+
* Entity types for customer profiles
|
|
50
|
+
*/
|
|
51
|
+
type EntityType = 'individual' | 'corporate' | 'joint_account' | 'minor_with_guardian';
|
|
52
|
+
/**
|
|
53
|
+
* Location compliance status
|
|
54
|
+
*/
|
|
55
|
+
type LocationCompliance = 'compliant' | 'non-compliant' | 'unknown';
|
|
56
|
+
/**
|
|
57
|
+
* Verification event types
|
|
58
|
+
*/
|
|
59
|
+
type VerificationEventType = 'registration' | 'login' | 'transaction' | 'withdrawal' | 'deposit' | 'api_access' | 'profile_update';
|
|
60
|
+
|
|
61
|
+
export type { APIResponse as A, CustomerStatus as C, ErrorResponse as E, LocationCompliance as L, PaginationParams as P, Result as R, SuccessResponse as S, Timestamp as T, UUID as U, VerificationEventType as V, PaginatedResponse as a, RiskLevel as b, EntityType as c };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types used across all CGS SDK modules
|
|
3
|
+
*/
|
|
4
|
+
interface APIResponse<T> {
|
|
5
|
+
data?: T;
|
|
6
|
+
error?: string;
|
|
7
|
+
message?: string;
|
|
8
|
+
}
|
|
9
|
+
interface PaginationParams {
|
|
10
|
+
page?: number;
|
|
11
|
+
page_size?: number;
|
|
12
|
+
}
|
|
13
|
+
interface PaginatedResponse<T> {
|
|
14
|
+
data: T[];
|
|
15
|
+
total: number;
|
|
16
|
+
page: number;
|
|
17
|
+
page_size: number;
|
|
18
|
+
total_pages: number;
|
|
19
|
+
}
|
|
20
|
+
interface SuccessResponse<T = unknown> {
|
|
21
|
+
success: true;
|
|
22
|
+
data: T;
|
|
23
|
+
message?: string;
|
|
24
|
+
}
|
|
25
|
+
interface ErrorResponse {
|
|
26
|
+
success: false;
|
|
27
|
+
error: string;
|
|
28
|
+
code?: string;
|
|
29
|
+
details?: Record<string, unknown>;
|
|
30
|
+
}
|
|
31
|
+
type Result<T> = SuccessResponse<T> | ErrorResponse;
|
|
32
|
+
/**
|
|
33
|
+
* Standard timestamp format: ISO 8601
|
|
34
|
+
*/
|
|
35
|
+
type Timestamp = string;
|
|
36
|
+
/**
|
|
37
|
+
* UUID format
|
|
38
|
+
*/
|
|
39
|
+
type UUID = string;
|
|
40
|
+
/**
|
|
41
|
+
* Risk levels used across the platform
|
|
42
|
+
*/
|
|
43
|
+
type RiskLevel = 'low' | 'medium' | 'high' | 'critical';
|
|
44
|
+
/**
|
|
45
|
+
* Customer status types
|
|
46
|
+
*/
|
|
47
|
+
type CustomerStatus = 'active' | 'dormant' | 'deactive' | 'suspended';
|
|
48
|
+
/**
|
|
49
|
+
* Entity types for customer profiles
|
|
50
|
+
*/
|
|
51
|
+
type EntityType = 'individual' | 'corporate' | 'joint_account' | 'minor_with_guardian';
|
|
52
|
+
/**
|
|
53
|
+
* Location compliance status
|
|
54
|
+
*/
|
|
55
|
+
type LocationCompliance = 'compliant' | 'non-compliant' | 'unknown';
|
|
56
|
+
/**
|
|
57
|
+
* Verification event types
|
|
58
|
+
*/
|
|
59
|
+
type VerificationEventType = 'registration' | 'login' | 'transaction' | 'withdrawal' | 'deposit' | 'api_access' | 'profile_update';
|
|
60
|
+
|
|
61
|
+
export type { APIResponse as A, CustomerStatus as C, ErrorResponse as E, LocationCompliance as L, PaginationParams as P, Result as R, SuccessResponse as S, Timestamp as T, UUID as U, VerificationEventType as V, PaginatedResponse as a, RiskLevel as b, EntityType as c };
|
package/package.json
CHANGED