@artu-ai/compliance-sdk 0.4.1 → 0.4.3

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,54 +0,0 @@
1
- /**
2
- * TSC-scoped ComplianceSDK
3
- *
4
- * Pre-configured SDK for Mexico jurisdiction and Tarjetas de Servicio y Crédito (TSC) activity.
5
- * Extends MexicoComplianceSDKScoped to inherit Mexico-specific resources like EBR.
6
- */
7
-
8
- import { MexicoComplianceSDKScoped } from "../../ComplianceSDK";
9
- import type { TSCScopedSDKOptions } from "./types";
10
- import type { TSCClientsResource } from "../../../../resources/mex/actividad-vulnerable/tsc/clients";
11
- import type { TSCTransactionsResource } from "../../../../resources/mex/actividad-vulnerable/tsc/transactions";
12
- import type { TSCReportsResource } from "../../../../resources/mex/actividad-vulnerable/tsc/reports";
13
-
14
- /**
15
- * TSC-scoped ComplianceSDK.
16
- * Pre-configured for Mexico jurisdiction and Tarjetas de Servicio y Crédito (TSC) activity.
17
- *
18
- * Inherits Mexico-specific resources:
19
- * - `ebr` - EBR (Evaluación Basada en Riesgos) for AML/KYC risk evaluation
20
- *
21
- * @example
22
- * ```typescript
23
- * import { ComplianceSDK } from "@artu/compliance-sdk/mexico/actividad-vulnerable/tsc";
24
- *
25
- * const sdk = new ComplianceSDK({
26
- * apiKey: process.env.API_KEY!,
27
- * environment: "test",
28
- * });
29
- *
30
- * // Already scoped - no need to specify jurisdiction/activity
31
- * const client = await sdk.clients.create({
32
- * type: ClientType.Person,
33
- * name: "Juan García",
34
- * });
35
- *
36
- * // Access inherited EBR resource
37
- * const weights = sdk.ebr.presets.suggested();
38
- * ```
39
- */
40
- export class TSCComplianceSDKScoped extends MexicoComplianceSDKScoped {
41
- // Override resource types with TSC-specific types
42
- // The registry creates these at runtime, we just need correct types
43
- // Note: @ts-expect-error is needed for some overrides due to sort type parameter variance
44
- declare public readonly clients: TSCClientsResource;
45
- // @ts-expect-error - Runtime type is correct, variance issue with sort types
46
- declare public readonly transactions: TSCTransactionsResource;
47
- // @ts-expect-error - Runtime type is correct, variance issue with sort types
48
- declare public readonly reports: TSCReportsResource;
49
- // addresses and bankAccounts inherited from MexicoComplianceSDKImpl (MexAddressesResource, MexBankAccountsResource)
50
-
51
- constructor(options: TSCScopedSDKOptions) {
52
- super({ ...options, actividadVulnerable: "TSC" });
53
- }
54
- }
@@ -1,16 +0,0 @@
1
- /**
2
- * TSC SDK Module
3
- *
4
- * Exports types, registration, and scoped SDK for Tarjetas de Servicio y Crédito.
5
- */
6
-
7
- // Types and registration
8
- export {
9
- type TSCSDKOptions,
10
- type TSCScopedSDKOptions,
11
- type TSCComplianceSDK,
12
- registerTSCScope,
13
- } from "./types";
14
-
15
- // Scoped SDK class
16
- export { TSCComplianceSDKScoped } from "./ComplianceSDK";
@@ -1,86 +0,0 @@
1
- /**
2
- * TSC SDK Types & Registration
3
- *
4
- * Tarjetas de Servicios y Crédito (Service and Credit Cards) - prepaid cards, etc.
5
- */
6
-
7
- import { Jurisdiction, CodigoActividad } from "@artu-ai/shared";
8
- import type {
9
- ComplianceSDKOptionsBase,
10
- DistributiveOmit,
11
- } from "../../../types";
12
- import type { MexicoComplianceSDK } from "../../types";
13
- import {
14
- TSCClientsResource,
15
- TSCTransactionsResource,
16
- TSCReportsResource,
17
- MexBankAccountsResource,
18
- MexAddressesResource,
19
- } from "../../../../resources";
20
- import { registerScope } from "../../../resource-registry";
21
- import type { ClientsResource } from "../../../../resources/clients";
22
- import type { TransactionsResource } from "../../../../resources/transactions";
23
- import type { ReportsResource } from "../../../../resources/reports";
24
- import type { BankAccountsResource } from "../../../../resources/bank-accounts";
25
- import type { AddressesResource } from "../../../../resources/addresses";
26
- import type { EBRResource } from "../../../../resources/mex/ebr";
27
-
28
- // ===========================
29
- // SDK Options
30
- // ===========================
31
-
32
- /**
33
- * Options for creating a TSC-scoped SDK
34
- */
35
- export type TSCSDKOptions = ComplianceSDKOptionsBase & {
36
- jurisdiction: typeof Jurisdiction.Mexico | "MX";
37
- actividadVulnerable: typeof CodigoActividad.TSC | "TSC";
38
- };
39
-
40
- /**
41
- * Options for TSC-scoped SDK (without jurisdiction/activity - pre-configured)
42
- */
43
- export type TSCScopedSDKOptions = DistributiveOmit<
44
- ComplianceSDKOptionsBase,
45
- "jurisdiction" | "actividadVulnerable"
46
- >;
47
-
48
- // ===========================
49
- // Typed SDK Interface
50
- // ===========================
51
-
52
- /**
53
- * Mexico TSC-scoped SDK - uses TSC resource types
54
- * Extends MexicoComplianceSDK with TSC-specific overrides
55
- */
56
- export interface TSCComplianceSDK extends Omit<
57
- MexicoComplianceSDK,
58
- "clients" | "transactions" | "reports"
59
- > {
60
- readonly clients: TSCClientsResource;
61
- readonly transactions: TSCTransactionsResource;
62
- readonly reports: TSCReportsResource;
63
- readonly bankAccounts: MexBankAccountsResource;
64
- /** EBR resource for risk-based evaluation */
65
- readonly ebr: EBRResource;
66
- }
67
-
68
- // ===========================
69
- // Registration
70
- // ===========================
71
-
72
- export function registerTSCScope(): void {
73
- // Note: Casts needed due to sort type parameter variance between scoped and base resources
74
- registerScope("MX:TSC", {
75
- clients: (config) =>
76
- new TSCClientsResource(config) as unknown as ClientsResource,
77
- transactions: (config) =>
78
- new TSCTransactionsResource(config) as unknown as TransactionsResource,
79
- reports: (config) =>
80
- new TSCReportsResource(config) as unknown as ReportsResource,
81
- bankAccounts: (config) =>
82
- new MexBankAccountsResource(config) as unknown as BankAccountsResource,
83
- addresses: (config) =>
84
- new MexAddressesResource(config) as unknown as AddressesResource,
85
- });
86
- }
@@ -1,66 +0,0 @@
1
- /**
2
- * Mexico SDK Module
3
- *
4
- * Barrel export for Mexico SDK types and registrations.
5
- */
6
-
7
- // Base Mexico types
8
- export {
9
- type ComplianceSDKOptionsMexico,
10
- type MexicoSDKOptions,
11
- type MexicoScopedSDKOptions,
12
- type MexicoComplianceSDK,
13
- } from "./types";
14
-
15
- // Scoped SDK class
16
- export {
17
- MexicoComplianceSDKScoped,
18
- MexicoComplianceSDKImpl,
19
- } from "./ComplianceSDK";
20
-
21
- // Actividad Vulnerable types and registrations
22
- export {
23
- type AVISDKOptions,
24
- type AVIComplianceSDK,
25
- type JYSSDKOptions,
26
- type JYSComplianceSDK,
27
- type TSCSDKOptions,
28
- type TSCComplianceSDK,
29
- registerActividadVulnerableScopes,
30
- } from "./actividad-vulnerable";
31
-
32
- // ===========================
33
- // Registration
34
- // ===========================
35
-
36
- import { registerScope } from "../resource-registry";
37
- import { registerSDKClass } from "../sdk-registry";
38
- import { MexClientsResource } from "../../resources/mex/clients";
39
- import { MexTransactionsResource } from "../../resources/mex/transactions";
40
- import { MexReportsResource } from "../../resources/mex/reports";
41
- import { MexBankAccountsResource } from "../../resources/mex/bank-accounts";
42
- import { MexAddressesResource } from "../../resources/mex/addresses";
43
- import { registerActividadVulnerableScopes } from "./actividad-vulnerable";
44
- import { MexicoComplianceSDKImpl } from "./ComplianceSDK";
45
- import type { ReportsResource } from "../../resources/reports";
46
-
47
- /**
48
- * Registers all Mexico scopes (base + activities)
49
- */
50
- export function registerMexicoScopes(): void {
51
- // Register Mexico base scope resources
52
- registerScope("MX", {
53
- clients: (config) => new MexClientsResource(config),
54
- transactions: (config) => new MexTransactionsResource(config),
55
- reports: (config) =>
56
- new MexReportsResource(config) as unknown as ReportsResource,
57
- bankAccounts: (config) => new MexBankAccountsResource(config),
58
- addresses: (config) => new MexAddressesResource(config),
59
- });
60
-
61
- // Register Mexico SDK class (for SDK class dispatch)
62
- registerSDKClass("MX", MexicoComplianceSDKImpl);
63
-
64
- // Register all activity scopes
65
- registerActividadVulnerableScopes();
66
- }
@@ -1,88 +0,0 @@
1
- /**
2
- * Mexico SDK Types
3
- *
4
- * Typed SDK interfaces and options for Mexico jurisdiction (base level).
5
- * Activity-specific types are in actividad-vulnerable/ subfolder.
6
- */
7
-
8
- import { Jurisdiction, type CodigoActividad } from "@artu-ai/shared";
9
- import type {
10
- ComplianceSDKOptionsBase,
11
- BaseComplianceSDK,
12
- DistributiveOmit,
13
- } from "../types";
14
- import type {
15
- MexClientsResource,
16
- MexTransactionsResource,
17
- MexBankAccountsResource,
18
- MexReportsResource,
19
- MexAddressesResource,
20
- EBRResource,
21
- } from "../../resources";
22
- import type { ContactMethodsResource } from "../../resources/contact-methods";
23
- import type { DocumentsResource } from "../../resources/documents";
24
-
25
- // ===========================
26
- // SDK Options Types
27
- // ===========================
28
-
29
- /**
30
- * SDK options - Mexico jurisdiction (supports actividadVulnerable)
31
- */
32
- export type ComplianceSDKOptionsMexico = ComplianceSDKOptionsBase & {
33
- /**
34
- * Target jurisdiction - Mexico
35
- */
36
- jurisdiction: typeof Jurisdiction.Mexico | "MX";
37
-
38
- /**
39
- * Target Actividad Vulnerable activity code.
40
- * Only available when jurisdiction is Mexico.
41
- */
42
- actividadVulnerable?: CodigoActividad | "AVI" | "JYS" | "TSC";
43
- };
44
-
45
- /**
46
- * Options for creating a Mexico-scoped SDK (no specific activity)
47
- */
48
- export type MexicoSDKOptions = ComplianceSDKOptionsBase & {
49
- jurisdiction: typeof Jurisdiction.Mexico | "MX";
50
- actividadVulnerable?: undefined;
51
- };
52
-
53
- /**
54
- * Options for Mexico-scoped SDK (without jurisdiction - pre-configured)
55
- */
56
- export type MexicoScopedSDKOptions = DistributiveOmit<
57
- ComplianceSDKOptionsBase,
58
- "jurisdiction"
59
- > & {
60
- /** Activity code - used by activity-scoped subclasses */
61
- actividadVulnerable?: CodigoActividad | "AVI" | "JYS" | "TSC";
62
- };
63
-
64
- // ===========================
65
- // Typed SDK Interface
66
- // ===========================
67
-
68
- /**
69
- * Mexico-scoped SDK - uses Mexico resource types
70
- */
71
- export interface MexicoComplianceSDK extends BaseComplianceSDK {
72
- // Core resources (Mexico-scoped)
73
- readonly clients: MexClientsResource;
74
- readonly transactions: MexTransactionsResource;
75
- readonly reports: MexReportsResource;
76
- readonly bankAccounts: MexBankAccountsResource;
77
-
78
- // Supporting resources (Mexico-scoped)
79
- readonly addresses: MexAddressesResource;
80
- readonly contactMethods: ContactMethodsResource;
81
- readonly documents: DocumentsResource;
82
-
83
- /**
84
- * EBR (Evaluación Basada en Riesgos) resource.
85
- * Mexico-only resource for risk-based evaluation methodology.
86
- */
87
- readonly ebr: EBRResource;
88
- }
@@ -1,204 +0,0 @@
1
- /**
2
- * SDK Resource Registry
3
- *
4
- * Provides a registry pattern for jurisdiction/activity-specific resource factories.
5
- * Each jurisdiction module registers its own factories, eliminating switch statements
6
- * in the main SDK class.
7
- *
8
- * @example
9
- * ```typescript
10
- * // In resources/mex/registry.ts
11
- * import { registerScope } from '../../sdk/registry';
12
- * import { MexClientsResource } from './clients';
13
- *
14
- * registerScope('MX', {
15
- * clients: (config) => new MexClientsResource(config),
16
- * // ...
17
- * });
18
- *
19
- * // In ComplianceSDK.ts
20
- * const factories = getResourceFactories(scope);
21
- * this.clients = factories.clients(config);
22
- * ```
23
- */
24
-
25
- import type { SDKScope } from "./types";
26
- import type { ResourceConfig } from "../resources/base";
27
- import type { ClientsResource } from "../resources/clients";
28
- import type { TransactionsResource } from "../resources/transactions";
29
- import type { ReportsResource } from "../resources/reports";
30
- import type { BankAccountsResource } from "../resources/bank-accounts";
31
- import type { AddressesResource } from "../resources/addresses";
32
-
33
- // ===========================
34
- // Factory Types
35
- // ===========================
36
-
37
- /**
38
- * Factory function that creates a resource instance
39
- */
40
- export type ResourceFactory<T> = (config: ResourceConfig) => T;
41
-
42
- /**
43
- * Resource factories for a specific scope (jurisdiction/activity)
44
- *
45
- * Each jurisdiction/activity registers factories that create the appropriate
46
- * resource class instances.
47
- */
48
- export interface ScopeResourceFactories {
49
- /** Factory for creating clients resource */
50
- clients: ResourceFactory<ClientsResource>;
51
- /** Factory for creating transactions resource */
52
- transactions: ResourceFactory<TransactionsResource>;
53
- /** Factory for creating reports resource */
54
- reports: ResourceFactory<ReportsResource>;
55
- /** Factory for creating bank accounts resource (optional - falls back to base) */
56
- bankAccounts?: ResourceFactory<BankAccountsResource>;
57
- /** Factory for creating addresses resource (optional for backwards compat) */
58
- addresses?: ResourceFactory<AddressesResource>;
59
- }
60
-
61
- // ===========================
62
- // Registry
63
- // ===========================
64
-
65
- /**
66
- * Registry of scope-specific resource factories.
67
- * Keys are scope identifiers:
68
- * - "base" - unscoped/default
69
- * - "MX" - Mexico jurisdiction
70
- * - "MX:AVI" - Mexico AVI activity
71
- * - "MX:JYS" - Mexico JYS activity
72
- * - etc.
73
- */
74
- const scopeRegistry = new Map<string, ScopeResourceFactories>();
75
-
76
- /**
77
- * Generates a scope key from SDKScope
78
- *
79
- * @param scope - SDK scope configuration
80
- * @returns Scope key string (e.g., "base", "MX", "MX:AVI")
81
- */
82
- export function getScopeKey(scope: SDKScope): string {
83
- if (!scope.jurisdiction) {
84
- return "base";
85
- }
86
-
87
- // Check for Mexico with activity
88
- if (
89
- scope.jurisdiction === "MX" &&
90
- "actividadVulnerable" in scope &&
91
- scope.actividadVulnerable
92
- ) {
93
- return `MX:${scope.actividadVulnerable}`;
94
- }
95
-
96
- return scope.jurisdiction;
97
- }
98
-
99
- /**
100
- * Registers resource factories for a specific scope.
101
- *
102
- * Called by jurisdiction modules during initialization.
103
- * Each jurisdiction/activity registers its own factories.
104
- *
105
- * @param scopeKey - Scope identifier (e.g., "base", "MX", "MX:AVI")
106
- * @param factories - Resource factory functions
107
- *
108
- * @example
109
- * ```typescript
110
- * // Register Mexico AVI factories
111
- * registerScope('MX:AVI', {
112
- * clients: (config) => new AVIClientsResource(config),
113
- * transactions: (config) => new AVITransactionsResource(config),
114
- * reports: (config) => new AVIReportsResource(config) as unknown as ReportsResource,
115
- * bankAccounts: (config) => new MexBankAccountsResource(config),
116
- * });
117
- * ```
118
- */
119
- export function registerScope(
120
- scopeKey: string,
121
- factories: ScopeResourceFactories
122
- ): void {
123
- if (scopeRegistry.has(scopeKey)) {
124
- // eslint-disable-next-line no-console
125
- console.warn(
126
- `[SDK Registry] Overwriting existing factories for scope: ${scopeKey}`
127
- );
128
- }
129
- scopeRegistry.set(scopeKey, factories);
130
- }
131
-
132
- /**
133
- * Gets resource factories for a specific scope.
134
- *
135
- * Looks up factories with fallback:
136
- * 1. Exact scope match (e.g., "MX:AVI")
137
- * 2. Jurisdiction-only match (e.g., "MX")
138
- * 3. Base/default factories
139
- *
140
- * @param scope - SDK scope configuration
141
- * @returns Resource factories for the scope
142
- * @throws Error if no factories are registered (not even base)
143
- *
144
- * @example
145
- * ```typescript
146
- * const factories = getResourceFactories({ jurisdiction: "MX", actividadVulnerable: "AVI" });
147
- * const clientsResource = factories.clients(config);
148
- * ```
149
- */
150
- export function getResourceFactories(scope: SDKScope): ScopeResourceFactories {
151
- const scopeKey = getScopeKey(scope);
152
-
153
- // Try exact match first
154
- let factories = scopeRegistry.get(scopeKey);
155
- if (factories) {
156
- return factories;
157
- }
158
-
159
- // If scope has activity, try jurisdiction-only
160
- if (scope.jurisdiction && scopeKey.includes(":")) {
161
- factories = scopeRegistry.get(scope.jurisdiction);
162
- if (factories) {
163
- return factories;
164
- }
165
- }
166
-
167
- // Fall back to base
168
- factories = scopeRegistry.get("base");
169
- if (factories) {
170
- return factories;
171
- }
172
-
173
- throw new Error(
174
- `[SDK Registry] No factories registered for scope: ${scopeKey}. ` +
175
- `Ensure registry modules are imported before creating SDK instance.`
176
- );
177
- }
178
-
179
- /**
180
- * Checks if factories are registered for a scope
181
- *
182
- * @param scopeKey - Scope identifier to check
183
- * @returns true if factories are registered
184
- */
185
- export function hasScope(scopeKey: string): boolean {
186
- return scopeRegistry.has(scopeKey);
187
- }
188
-
189
- /**
190
- * Gets all registered scope keys (for debugging/testing)
191
- *
192
- * @returns Array of registered scope keys
193
- */
194
- export function getRegisteredScopes(): string[] {
195
- return Array.from(scopeRegistry.keys());
196
- }
197
-
198
- /**
199
- * Clears all registered scopes (for testing only)
200
- * @internal
201
- */
202
- export function clearRegistry(): void {
203
- scopeRegistry.clear();
204
- }
@@ -1,99 +0,0 @@
1
- /**
2
- * SDK Class Registry
3
- *
4
- * Provides a registry pattern for jurisdiction-specific SDK classes.
5
- * Each jurisdiction can register its own SDK class that extends ComplianceSDKImpl
6
- * and adds jurisdiction-specific resources.
7
- *
8
- * @example
9
- * ```typescript
10
- * // In sdk/mex/index.ts
11
- * import { registerSDKClass } from '../sdk-registry';
12
- * import { MexicoComplianceSDKImpl } from './ComplianceSDK';
13
- *
14
- * registerSDKClass('MX', MexicoComplianceSDKImpl);
15
- *
16
- * // Now `new ComplianceSDK({ jurisdiction: "MX" })` returns MexicoComplianceSDKImpl
17
- * ```
18
- */
19
-
20
- import type { SDKScope } from "./types";
21
- import { getScopeKey } from "./resource-registry";
22
-
23
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
24
- type SDKClassConstructor = new (options: any) => any;
25
-
26
- const sdkClassRegistry = new Map<string, SDKClassConstructor>();
27
-
28
- /**
29
- * Registers an SDK class for a specific scope.
30
- *
31
- * @param scopeKey - Scope identifier (e.g., "MX", "MX:AVI", "US")
32
- * @param SDKClass - SDK class constructor
33
- */
34
- export function registerSDKClass(
35
- scopeKey: string,
36
- SDKClass: SDKClassConstructor
37
- ): void {
38
- if (sdkClassRegistry.has(scopeKey)) {
39
- // eslint-disable-next-line no-console
40
- console.warn(
41
- `[SDK Registry] Overwriting existing SDK class for scope: ${scopeKey}`
42
- );
43
- }
44
- sdkClassRegistry.set(scopeKey, SDKClass);
45
- }
46
-
47
- /**
48
- * Gets the SDK class for a specific scope.
49
- *
50
- * Looks up with fallback:
51
- * 1. Exact scope match (e.g., "MX:AVI")
52
- * 2. Jurisdiction-only match (e.g., "MX")
53
- * 3. Returns undefined (use base ComplianceSDKImpl)
54
- *
55
- * @param scope - SDK scope configuration
56
- * @returns SDK class constructor or undefined if no specific class registered
57
- */
58
- export function getSDKClass(scope: SDKScope): SDKClassConstructor | undefined {
59
- const scopeKey = getScopeKey(scope);
60
-
61
- // Try exact match first (e.g., "MX:AVI")
62
- let cls = sdkClassRegistry.get(scopeKey);
63
- if (cls) return cls;
64
-
65
- // Try jurisdiction only (e.g., "MX") if scope has activity
66
- if (scope.jurisdiction && scopeKey.includes(":")) {
67
- cls = sdkClassRegistry.get(scope.jurisdiction);
68
- if (cls) return cls;
69
- }
70
-
71
- return undefined;
72
- }
73
-
74
- /**
75
- * Checks if an SDK class is registered for a scope
76
- *
77
- * @param scopeKey - Scope identifier to check
78
- * @returns true if an SDK class is registered
79
- */
80
- export function hasSDKClass(scopeKey: string): boolean {
81
- return sdkClassRegistry.has(scopeKey);
82
- }
83
-
84
- /**
85
- * Gets all registered SDK class scope keys (for debugging/testing)
86
- *
87
- * @returns Array of registered scope keys
88
- */
89
- export function getRegisteredSDKClasses(): string[] {
90
- return Array.from(sdkClassRegistry.keys());
91
- }
92
-
93
- /**
94
- * Clears all registered SDK classes (for testing only)
95
- * @internal
96
- */
97
- export function clearSDKRegistry(): void {
98
- sdkClassRegistry.clear();
99
- }