@artu-ai/compliance-sdk 0.4.1 → 0.4.2

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.
Files changed (110) hide show
  1. package/package.json +3 -4
  2. package/src/errors/api.ts +0 -305
  3. package/src/errors/base.ts +0 -127
  4. package/src/errors/index.ts +0 -63
  5. package/src/errors/upload.ts +0 -204
  6. package/src/errors/validation.ts +0 -163
  7. package/src/exports/base.ts +0 -139
  8. package/src/exports/index.ts +0 -187
  9. package/src/exports/mexico/actividad-vulnerable/avi.ts +0 -207
  10. package/src/exports/mexico/actividad-vulnerable/jys.ts +0 -214
  11. package/src/exports/mexico/actividad-vulnerable/tsc.ts +0 -202
  12. package/src/exports/mexico/index.ts +0 -215
  13. package/src/models/Address.ts +0 -235
  14. package/src/models/BankAccount.ts +0 -235
  15. package/src/models/Client.ts +0 -363
  16. package/src/models/ContactMethod.ts +0 -197
  17. package/src/models/Document.ts +0 -355
  18. package/src/models/LinkedClient.ts +0 -84
  19. package/src/models/Report.ts +0 -193
  20. package/src/models/ReportItem.ts +0 -211
  21. package/src/models/Transaction.ts +0 -219
  22. package/src/models/base.ts +0 -56
  23. package/src/models/index.ts +0 -148
  24. package/src/models/mex/MexAddress.ts +0 -184
  25. package/src/models/mex/MexBankAccount.ts +0 -121
  26. package/src/models/mex/MexClient.ts +0 -177
  27. package/src/models/mex/MexDocument.ts +0 -890
  28. package/src/models/mex/MexReport.ts +0 -99
  29. package/src/models/mex/MexReportItem.ts +0 -79
  30. package/src/models/mex/MexTransaction.ts +0 -105
  31. package/src/models/mex/actividad-vulnerable/MexActividadVulnerableClient.ts +0 -66
  32. package/src/models/mex/actividad-vulnerable/MexActividadVulnerableReport.ts +0 -73
  33. package/src/models/mex/actividad-vulnerable/MexActividadVulnerableReportItem.ts +0 -74
  34. package/src/models/mex/actividad-vulnerable/MexActividadVulnerableTransaction.ts +0 -50
  35. package/src/models/mex/actividad-vulnerable/avi/MexAVIClient.ts +0 -80
  36. package/src/models/mex/actividad-vulnerable/avi/MexAVIReport.ts +0 -114
  37. package/src/models/mex/actividad-vulnerable/avi/MexAVIReportItem.ts +0 -105
  38. package/src/models/mex/actividad-vulnerable/avi/MexAVITransaction.ts +0 -157
  39. package/src/models/mex/actividad-vulnerable/index.ts +0 -78
  40. package/src/models/mex/actividad-vulnerable/jys/MexJYSClient.ts +0 -73
  41. package/src/models/mex/actividad-vulnerable/jys/MexJYSReport.ts +0 -114
  42. package/src/models/mex/actividad-vulnerable/jys/MexJYSReportItem.ts +0 -105
  43. package/src/models/mex/actividad-vulnerable/jys/MexJYSTransaction.ts +0 -178
  44. package/src/models/mex/actividad-vulnerable/tsc/MexTSCClient.ts +0 -73
  45. package/src/models/mex/actividad-vulnerable/tsc/MexTSCReport.ts +0 -114
  46. package/src/models/mex/actividad-vulnerable/tsc/MexTSCReportItem.ts +0 -105
  47. package/src/models/mex/actividad-vulnerable/tsc/MexTSCTransaction.ts +0 -104
  48. package/src/models/mex/index.ts +0 -57
  49. package/src/models/types.ts +0 -196
  50. package/src/namespaces/index.ts +0 -29
  51. package/src/namespaces/mexico/actividad-vulnerable/avi/index.ts +0 -62
  52. package/src/namespaces/mexico/actividad-vulnerable/index.ts +0 -79
  53. package/src/namespaces/mexico/actividad-vulnerable/jys/index.ts +0 -72
  54. package/src/namespaces/mexico/actividad-vulnerable/tsc/index.ts +0 -60
  55. package/src/namespaces/mexico/index.ts +0 -325
  56. package/src/resources/addresses.ts +0 -391
  57. package/src/resources/bank-accounts.ts +0 -417
  58. package/src/resources/base.ts +0 -327
  59. package/src/resources/clients.ts +0 -808
  60. package/src/resources/contact-methods.ts +0 -412
  61. package/src/resources/documents.ts +0 -688
  62. package/src/resources/index.ts +0 -40
  63. package/src/resources/mex/actividad-vulnerable/avi/clients.ts +0 -559
  64. package/src/resources/mex/actividad-vulnerable/avi/index.ts +0 -7
  65. package/src/resources/mex/actividad-vulnerable/avi/reports.ts +0 -609
  66. package/src/resources/mex/actividad-vulnerable/avi/transactions.ts +0 -404
  67. package/src/resources/mex/actividad-vulnerable/index.ts +0 -12
  68. package/src/resources/mex/actividad-vulnerable/jys/clients.ts +0 -445
  69. package/src/resources/mex/actividad-vulnerable/jys/index.ts +0 -7
  70. package/src/resources/mex/actividad-vulnerable/jys/reports.ts +0 -591
  71. package/src/resources/mex/actividad-vulnerable/jys/transactions.ts +0 -395
  72. package/src/resources/mex/actividad-vulnerable/tsc/clients.ts +0 -445
  73. package/src/resources/mex/actividad-vulnerable/tsc/index.ts +0 -7
  74. package/src/resources/mex/actividad-vulnerable/tsc/reports.ts +0 -591
  75. package/src/resources/mex/actividad-vulnerable/tsc/transactions.ts +0 -404
  76. package/src/resources/mex/addresses.ts +0 -493
  77. package/src/resources/mex/bank-accounts.ts +0 -283
  78. package/src/resources/mex/clients.ts +0 -758
  79. package/src/resources/mex/ebr.ts +0 -621
  80. package/src/resources/mex/index.ts +0 -23
  81. package/src/resources/mex/reports.ts +0 -643
  82. package/src/resources/mex/transactions.ts +0 -422
  83. package/src/resources/reports.ts +0 -515
  84. package/src/resources/transactions.ts +0 -358
  85. package/src/sdk/ComplianceSDK.ts +0 -812
  86. package/src/sdk/base.ts +0 -43
  87. package/src/sdk/index.ts +0 -98
  88. package/src/sdk/mex/ComplianceSDK.ts +0 -147
  89. package/src/sdk/mex/actividad-vulnerable/avi/ComplianceSDK.ts +0 -55
  90. package/src/sdk/mex/actividad-vulnerable/avi/index.ts +0 -16
  91. package/src/sdk/mex/actividad-vulnerable/avi/types.ts +0 -86
  92. package/src/sdk/mex/actividad-vulnerable/index.ts +0 -58
  93. package/src/sdk/mex/actividad-vulnerable/jys/ComplianceSDK.ts +0 -54
  94. package/src/sdk/mex/actividad-vulnerable/jys/index.ts +0 -16
  95. package/src/sdk/mex/actividad-vulnerable/jys/types.ts +0 -86
  96. package/src/sdk/mex/actividad-vulnerable/tsc/ComplianceSDK.ts +0 -54
  97. package/src/sdk/mex/actividad-vulnerable/tsc/index.ts +0 -16
  98. package/src/sdk/mex/actividad-vulnerable/tsc/types.ts +0 -86
  99. package/src/sdk/mex/index.ts +0 -66
  100. package/src/sdk/mex/types.ts +0 -88
  101. package/src/sdk/resource-registry.ts +0 -204
  102. package/src/sdk/sdk-registry.ts +0 -99
  103. package/src/sdk/types.ts +0 -304
  104. package/src/utils/environment.ts +0 -187
  105. package/src/utils/filters.ts +0 -412
  106. package/src/utils/index.ts +0 -134
  107. package/src/utils/pagination.ts +0 -143
  108. package/src/utils/session.ts +0 -303
  109. package/src/utils/trpc-client.ts +0 -242
  110. package/src/utils/upload.ts +0 -388
@@ -1,621 +0,0 @@
1
- /**
2
- * EBR Resource
3
- *
4
- * Provides the SDK interface for managing EBR (Evaluación Basada en Riesgos)
5
- * configurations. Supports both global EBR (no AV) and activity-specific EBR.
6
- *
7
- * @module resources/mex/ebr
8
- */
9
-
10
- import type { ZodError } from "zod";
11
- import { TRPCClientError } from "@trpc/client";
12
- import { ValidationError } from "../../errors/validation";
13
- import { mapTRPCError } from "../../errors";
14
- import type { SDKScope, Environment } from "../../sdk/types";
15
- import { isMexicoScope } from "../../sdk/types";
16
- import type { TRPCClient } from "../../utils/trpc-client";
17
-
18
- // Import from @artu-ai/shared
19
- import {
20
- // Constants
21
- WEIGHT_RANGE,
22
- DEFAULT_THRESHOLDS,
23
- // Schemas
24
- CreateEBRConfigInputSchema,
25
- type CreateEBRConfigInput,
26
- type EBRConfiguration,
27
- type EBRConfigListItem,
28
- type ScoreThresholds,
29
- // Enums
30
- RiskLevels,
31
- InternalRiskLevel,
32
- RegulatoryRiskLevel,
33
- } from "@artu-ai/shared";
34
-
35
- // ===========================
36
- // Weight Presets (SDK-only)
37
- // ===========================
38
-
39
- /**
40
- * Confidence level for weight presets.
41
- */
42
- export type PresetConfidence = "high" | "medium";
43
-
44
- /**
45
- * A weight preset for a specific Actividad Vulnerable.
46
- */
47
- export interface WeightPreset {
48
- client: number;
49
- geographic: number;
50
- product: number;
51
- transactional: number;
52
- confidence: PresetConfidence;
53
- }
54
-
55
- /**
56
- * Weight presets for all 15 Actividades Vulnerables.
57
- *
58
- * These presets are validated according to:
59
- * - ENR 2020/2023 (Evaluación Nacional de Riesgos)
60
- * - GAFI/FATF RBA Guidance
61
- * - LFPIORPI regulatory requirements
62
- */
63
- export const WEIGHT_PRESETS: Record<string, WeightPreset> = {
64
- // Inmobiliarias (Real Estate)
65
- INM: {
66
- client: 0.25,
67
- geographic: 0.35,
68
- product: 0.2,
69
- transactional: 0.2,
70
- confidence: "high",
71
- },
72
-
73
- // Metales Preciosos y Joyería (Precious Metals & Jewelry - DPMS)
74
- MPJ: {
75
- client: 0.25,
76
- geographic: 0.2,
77
- product: 0.2,
78
- transactional: 0.35,
79
- confidence: "high",
80
- },
81
-
82
- // Notarios y Corredores (Notaries & Brokers)
83
- NOT: {
84
- client: 0.4,
85
- geographic: 0.2,
86
- product: 0.25,
87
- transactional: 0.15,
88
- confidence: "high",
89
- },
90
-
91
- // Casas de Empeño (Pawn Shops)
92
- EMP: {
93
- client: 0.25,
94
- geographic: 0.2,
95
- product: 0.2,
96
- transactional: 0.35,
97
- confidence: "medium",
98
- },
99
-
100
- // Blindaje de Vehículos (Vehicle Armoring)
101
- BLI: {
102
- client: 0.35,
103
- geographic: 0.25,
104
- product: 0.3,
105
- transactional: 0.1,
106
- confidence: "medium",
107
- },
108
-
109
- // Venta de Vehículos (Vehicle Sales)
110
- VEH: {
111
- client: 0.25,
112
- geographic: 0.2,
113
- product: 0.25,
114
- transactional: 0.3,
115
- confidence: "high",
116
- },
117
-
118
- // Activos Virtuales (Virtual Assets - PSAV)
119
- AVI: {
120
- client: 0.35,
121
- geographic: 0.15,
122
- product: 0.3,
123
- transactional: 0.2,
124
- confidence: "high",
125
- },
126
-
127
- // Juegos y Sorteos (Gaming & Lotteries)
128
- JYS: {
129
- client: 0.25,
130
- geographic: 0.25,
131
- product: 0.2,
132
- transactional: 0.3,
133
- confidence: "high",
134
- },
135
-
136
- // Obras de Arte (Art Trade)
137
- ODA: {
138
- client: 0.3,
139
- geographic: 0.25,
140
- product: 0.3,
141
- transactional: 0.15,
142
- confidence: "high",
143
- },
144
-
145
- // Servicios Profesionales (Professional Services)
146
- SPR: {
147
- client: 0.4,
148
- geographic: 0.15,
149
- product: 0.3,
150
- transactional: 0.15,
151
- confidence: "high",
152
- },
153
-
154
- // Arrendamiento de Inmuebles (Real Estate Leasing)
155
- ARR: {
156
- client: 0.3,
157
- geographic: 0.25,
158
- product: 0.2,
159
- transactional: 0.25,
160
- confidence: "medium",
161
- },
162
-
163
- // Fideicomisos (Trusts)
164
- FID: {
165
- client: 0.4,
166
- geographic: 0.15,
167
- product: 0.3,
168
- transactional: 0.15,
169
- confidence: "high",
170
- },
171
-
172
- // Tarjetas de Servicios y Crédito (Prepaid Cards & Credit Services)
173
- TSC: {
174
- client: 0.25,
175
- geographic: 0.15,
176
- product: 0.3,
177
- transactional: 0.3,
178
- confidence: "medium",
179
- },
180
-
181
- // Donatarias / ONG (Charities & NGOs)
182
- DON: {
183
- client: 0.35,
184
- geographic: 0.25,
185
- product: 0.25,
186
- transactional: 0.15,
187
- confidence: "high",
188
- },
189
-
190
- // Comercio Exterior (Foreign Trade)
191
- CEX: {
192
- client: 0.25,
193
- geographic: 0.35,
194
- product: 0.25,
195
- transactional: 0.15,
196
- confidence: "medium",
197
- },
198
- } as const;
199
-
200
- /**
201
- * List of all Actividades Vulnerables with available presets.
202
- */
203
- const AVAILABLE_PRESET_ACTIVITIES = Object.keys(
204
- WEIGHT_PRESETS
205
- ) as readonly string[];
206
-
207
- /**
208
- * All 15 Actividades Vulnerables defined in LFPIORPI.
209
- */
210
- export const ACTIVIDADES_VULNERABLES = [
211
- "INM",
212
- "MPJ",
213
- "NOT",
214
- "EMP",
215
- "BLI",
216
- "VEH",
217
- "AVI",
218
- "JYS",
219
- "ODA",
220
- "SPR",
221
- "ARR",
222
- "FID",
223
- "TSC",
224
- "DON",
225
- "CEX",
226
- ] as const;
227
-
228
- export type ActividadVulnerable = (typeof ACTIVIDADES_VULNERABLES)[number];
229
-
230
- /** @deprecated Use WeightPreset instead */
231
- export type MERWeightPreset = WeightPreset;
232
-
233
- // ===========================
234
- // Types
235
- // ===========================
236
-
237
- /**
238
- * Context for EBR resource operations.
239
- * Passed from the main SDK.
240
- */
241
- export interface EBRResourceContext {
242
- /** tRPC client for API communication (optional for backward compatibility) */
243
- trpc?: TRPCClient;
244
- /** SDK scope (jurisdiction and optional actividadVulnerable) */
245
- scope: SDKScope;
246
- /** Environment (test or live) */
247
- environment: Environment;
248
- }
249
-
250
- /**
251
- * Weights sub-resource for accessing weight configuration.
252
- */
253
- export interface EBRWeightsResource {
254
- /** Valid weight range (min: 0.10, max: 0.70) */
255
- readonly range: typeof WEIGHT_RANGE;
256
- }
257
-
258
- /**
259
- * Thresholds sub-resource for accessing threshold configuration.
260
- */
261
- export interface EBRThresholdsResource {
262
- /** Default/suggested thresholds */
263
- readonly defaults: ScoreThresholds;
264
- }
265
-
266
- /**
267
- * Presets sub-resource for accessing weight presets.
268
- */
269
- export interface EBRPresetsResource {
270
- /**
271
- * Lists all available preset activity codes.
272
- * @returns Array of activity codes with presets
273
- */
274
- list(): readonly string[];
275
-
276
- /**
277
- * Gets the preset for a specific activity.
278
- * @param activity - Activity code (e.g., "AVI", "INM")
279
- * @returns The weight preset or null if not found
280
- */
281
- get(activity: string): WeightPreset | null;
282
-
283
- /**
284
- * Gets the suggested preset for the current SDK scope.
285
- * Returns null if SDK is not scoped to an activity or no preset exists.
286
- * @returns The suggested weight preset or null
287
- */
288
- suggested(): WeightPreset | null;
289
- }
290
-
291
- /**
292
- * Risk level sub-resource for risk level utilities.
293
- */
294
- export interface EBRRiskLevelResource {
295
- /**
296
- * Maps an internal risk level (5) to regulatory level (3).
297
- * @param internal - Internal risk level
298
- * @returns Regulatory risk level
299
- */
300
- mapToRegulatory(internal: InternalRiskLevel): RegulatoryRiskLevel;
301
-
302
- /**
303
- * Gets the recommended KYC update frequency for a risk level.
304
- * @param level - Internal risk level
305
- * @returns Update frequency in months
306
- */
307
- getUpdateFrequency(level: InternalRiskLevel): number;
308
- }
309
-
310
- // ===========================
311
- // EBR Resource Class
312
- // ===========================
313
-
314
- /**
315
- * EBR Resource
316
- *
317
- * Manages EBR (Evaluación Basada en Riesgos) configurations for Mexican
318
- * AML/KYC compliance under LFPIORPI.
319
- *
320
- * Key features:
321
- * - **Immutable configurations**: No updates - each change creates a new version
322
- * - **Scope-aware**: Works with global EBR or activity-specific EBR
323
- * - **Validation**: Full client-side validation before API calls
324
- * - **Audit trail**: All versions preserved with justifications
325
- *
326
- * @example
327
- * ```typescript
328
- * // Create EBR configuration
329
- * const config = await sdk.ebr.create({
330
- * weights: { client: 0.25, geographic: 0.35, product: 0.20, transactional: 0.20 },
331
- * thresholds: sdk.ebr.thresholds.defaults,
332
- * justification: "Initial configuration for Q4 2024",
333
- * });
334
- *
335
- * // Get suggested preset for current activity
336
- * const suggested = sdk.ebr.presets.suggested();
337
- *
338
- * // Map risk level for regulatory reporting
339
- * const regulatory = sdk.ebr.riskLevel.mapToRegulatory("muy_alto"); // "alto"
340
- * ```
341
- */
342
- export class EBRResource {
343
- protected readonly ctx: EBRResourceContext;
344
-
345
- constructor(context: EBRResourceContext) {
346
- this.ctx = context;
347
- }
348
-
349
- /**
350
- * Gets the tRPC client, throwing if not available.
351
- */
352
- private get trpc(): TRPCClient {
353
- if (!this.ctx.trpc) {
354
- throw new Error(
355
- "EBRResource requires tRPC client for API operations. " +
356
- "Make sure the SDK was initialized with API connection."
357
- );
358
- }
359
- return this.ctx.trpc;
360
- }
361
-
362
- // ===========================
363
- // Main Methods
364
- // ===========================
365
-
366
- /**
367
- * Creates a new EBR configuration.
368
- *
369
- * If a configuration already exists, the existing one is marked as "superseded"
370
- * and a new version is created. This maintains a complete audit trail.
371
- *
372
- * @param input - Configuration input (weights, thresholds, justification)
373
- * @returns The created EBR configuration
374
- * @throws {ValidationError} If input validation fails
375
- */
376
- async create(input: CreateEBRConfigInput): Promise<EBRConfiguration> {
377
- // 1. Validate input using Zod schema
378
- const parseResult = CreateEBRConfigInputSchema.safeParse(input);
379
-
380
- if (!parseResult.success) {
381
- throw ValidationError.fromZodError(parseResult.error as ZodError);
382
- }
383
-
384
- const validated = parseResult.data;
385
-
386
- // 2. Validate activity mismatch if explicitly provided
387
- if (validated.actividadVulnerable) {
388
- const scopeActivity = this.getCurrentActivity();
389
- if (scopeActivity && validated.actividadVulnerable !== scopeActivity) {
390
- throw new ValidationError([
391
- {
392
- path: ["actividadVulnerable"],
393
- message: `Activity mismatch - SDK scope is ${scopeActivity} but input specifies ${validated.actividadVulnerable}`,
394
- code: "ACTIVITY_MISMATCH",
395
- },
396
- ]);
397
- }
398
- }
399
-
400
- // 3. Determine the effective activity (from input or scope)
401
- const effectiveActivity =
402
- validated.actividadVulnerable ?? this.getCurrentActivity();
403
-
404
- // 4. Call the API
405
- const response = await this.execute(() =>
406
- this.trpc.ebr.create.mutate({
407
- ...validated,
408
- actividadVulnerable: effectiveActivity ?? undefined,
409
- })
410
- );
411
-
412
- return this.transformResponse(response);
413
- }
414
-
415
- /**
416
- * Gets the currently active EBR configuration.
417
- *
418
- * @returns The active configuration or null if none exists
419
- */
420
- async get(): Promise<EBRConfiguration | null> {
421
- const activity = this.getCurrentActivity();
422
-
423
- const response = await this.execute(() =>
424
- this.trpc.ebr.get.query({
425
- actividadVulnerable: activity ?? undefined,
426
- })
427
- );
428
-
429
- if (!response) {
430
- return null;
431
- }
432
-
433
- return this.transformResponse(response);
434
- }
435
-
436
- /**
437
- * Gets an EBR configuration by ID.
438
- *
439
- * @param id - Configuration ID
440
- * @returns The configuration or null if not found
441
- */
442
- async getById(id: string): Promise<EBRConfiguration | null> {
443
- const response = await this.execute(() =>
444
- this.trpc.ebr.getById.query({ id })
445
- );
446
-
447
- if (!response) {
448
- return null;
449
- }
450
-
451
- return this.transformResponse(response);
452
- }
453
-
454
- /**
455
- * Gets the complete history of EBR configurations.
456
- *
457
- * @param options - Optional options including limit
458
- * @returns Array of all EBR configuration versions, newest first
459
- */
460
- async getHistory(options?: { limit?: number }): Promise<EBRConfigListItem[]> {
461
- const activity = this.getCurrentActivity();
462
-
463
- const response = await this.execute(() =>
464
- this.trpc.ebr.getHistory.query({
465
- actividadVulnerable: activity ?? undefined,
466
- limit: options?.limit,
467
- })
468
- );
469
-
470
- return response;
471
- }
472
-
473
- /**
474
- * Promotes an EBR configuration from test to live environment.
475
- *
476
- * Must be called from the test environment.
477
- *
478
- * @returns The promoted configuration (now in live)
479
- */
480
- async promote(): Promise<EBRConfiguration> {
481
- const activity = this.getCurrentActivity();
482
-
483
- const response = await this.execute(() =>
484
- this.trpc.ebr.promote.mutate({
485
- actividadVulnerable: activity ?? undefined,
486
- })
487
- );
488
-
489
- return this.transformResponse(response);
490
- }
491
-
492
- // ===========================
493
- // Sub-Resources
494
- // ===========================
495
-
496
- /**
497
- * Weights configuration sub-resource.
498
- */
499
- get weights(): EBRWeightsResource {
500
- return {
501
- range: WEIGHT_RANGE,
502
- };
503
- }
504
-
505
- /**
506
- * Thresholds configuration sub-resource.
507
- */
508
- get thresholds(): EBRThresholdsResource {
509
- return {
510
- defaults: DEFAULT_THRESHOLDS as unknown as ScoreThresholds,
511
- };
512
- }
513
-
514
- /**
515
- * Presets sub-resource for weight presets.
516
- */
517
- get presets(): EBRPresetsResource {
518
- return {
519
- list: () => AVAILABLE_PRESET_ACTIVITIES,
520
-
521
- get: (activity: string): WeightPreset | null => {
522
- return WEIGHT_PRESETS[activity] ?? null;
523
- },
524
-
525
- suggested: (): WeightPreset | null => {
526
- const activity = this.getCurrentActivity();
527
- if (!activity) {
528
- return null;
529
- }
530
- return WEIGHT_PRESETS[activity] ?? null;
531
- },
532
- };
533
- }
534
-
535
- /**
536
- * Risk level utilities sub-resource.
537
- */
538
- get riskLevel(): EBRRiskLevelResource {
539
- return {
540
- mapToRegulatory: RiskLevels.mapToRegulatory,
541
- getUpdateFrequency: RiskLevels.getUpdateFrequency,
542
- };
543
- }
544
-
545
- // ===========================
546
- // Private Helpers
547
- // ===========================
548
-
549
- /**
550
- * Gets the current activity from the SDK scope.
551
- */
552
- private getCurrentActivity(): string | null {
553
- if (isMexicoScope(this.ctx.scope) && this.ctx.scope.actividadVulnerable) {
554
- return this.ctx.scope.actividadVulnerable;
555
- }
556
- return null;
557
- }
558
-
559
- /**
560
- * Wraps a tRPC operation with error mapping.
561
- */
562
- private async execute<T>(operation: () => Promise<T>): Promise<T> {
563
- try {
564
- return await operation();
565
- } catch (error) {
566
- if (error instanceof TRPCClientError) {
567
- throw mapTRPCError(error);
568
- }
569
- throw error;
570
- }
571
- }
572
-
573
- /**
574
- * Transforms API response to EBRConfiguration type.
575
- * Converts ISO date strings from API to Date objects.
576
- */
577
- private transformResponse(response: {
578
- id: string;
579
- organizationId: string;
580
- actividadVulnerable: string | null;
581
- environment: "test" | "live";
582
- version: number;
583
- weights: {
584
- client: number;
585
- geographic: number;
586
- product: number;
587
- transactional: number;
588
- };
589
- thresholds: ScoreThresholds;
590
- justification: string;
591
- reviewPeriodMonths: number;
592
- validUntil: string; // ISO string from API
593
- status: "active" | "superseded";
594
- createdAt: string; // ISO string from API
595
- createdBy: string;
596
- supersededAt?: string; // ISO string from API
597
- supersededBy?: string;
598
- promotedFromId?: string;
599
- }): EBRConfiguration {
600
- return {
601
- id: response.id,
602
- organizationId: response.organizationId,
603
- actividadVulnerable: response.actividadVulnerable,
604
- environment: response.environment,
605
- version: response.version,
606
- weights: response.weights,
607
- thresholds: response.thresholds,
608
- justification: response.justification,
609
- reviewPeriodMonths: response.reviewPeriodMonths,
610
- validUntil: new Date(response.validUntil),
611
- status: response.status,
612
- createdAt: new Date(response.createdAt),
613
- createdBy: response.createdBy,
614
- supersededAt: response.supersededAt
615
- ? new Date(response.supersededAt)
616
- : undefined,
617
- supersededBy: response.supersededBy,
618
- promotedFromId: response.promotedFromId,
619
- };
620
- }
621
- }
@@ -1,23 +0,0 @@
1
- /**
2
- * Mexico Scoped Resources
3
- */
4
-
5
- // Mexico-level resources
6
- export { MexClientsResource } from "./clients";
7
- export { MexTransactionsResource } from "./transactions";
8
- export { MexBankAccountsResource } from "./bank-accounts";
9
- export { MexAddressesResource } from "./addresses";
10
- export { MexReportsResource } from "./reports";
11
- export {
12
- EBRResource,
13
- type EBRResourceContext,
14
- type EBRPresetsResource,
15
- type EBRWeightsResource,
16
- type EBRThresholdsResource,
17
- type EBRRiskLevelResource,
18
- type WeightPreset,
19
- type PresetConfidence,
20
- } from "./ebr";
21
-
22
- // Activity-specific resources
23
- export * from "./actividad-vulnerable";