@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,445 +0,0 @@
1
- /**
2
- * TSC (Tarjetas de Servicio y Crédito) Clients Resource
3
- *
4
- * Extends MexClientsResource with TSC-specific behavior.
5
- * TSC clients have the same fields as Mexico clients (no additional activity fields).
6
- * Returns MexTSCClient models.
7
- */
8
-
9
- import { z } from "zod";
10
- import type {
11
- CreateClientInput,
12
- UpdateClientInput,
13
- ListOptions,
14
- PaginatedResponse,
15
- CreateTSCClientInput,
16
- UpdateTSCClientInput,
17
- CreateMexClientInput,
18
- UpdateMexClientInput,
19
- AtomicBatchResult,
20
- PartialBatchResult,
21
- ClientRelationshipType,
22
- LinkedClient as LinkedClientInput,
23
- CreateMexAddressInput,
24
- UpdateMexAddressInput,
25
- CreateContactMethodInput,
26
- UpdateContactMethodInput,
27
- CreateBankAccountInput,
28
- UpdateBankAccountInput,
29
- SyncItem,
30
- SyncResult,
31
- TSCClientFilter,
32
- TSCClientSort,
33
- } from "@artu-ai/shared";
34
- import {
35
- CodigoActividad,
36
- createTSCClientInputSchema,
37
- updateTSCClientInputSchema,
38
- linkedClientSchema,
39
- transformSort,
40
- tscClientFieldMapping,
41
- } from "@artu-ai/shared";
42
- import type { ClientSort } from "@artu-ai/shared";
43
- import { MexClientsResource } from "../../clients";
44
- import { type BatchOptions, type ClientIncludeMap } from "../../../clients";
45
- import {
46
- MexTSCClient,
47
- MexAddress,
48
- MexBankAccount,
49
- ContactMethod,
50
- LinkedClient,
51
- type ClientData,
52
- } from "../../../../models";
53
-
54
- // ===========================
55
- // TSCClientsResource
56
- // ===========================
57
-
58
- /**
59
- * TSC (Tarjetas de Servicio y Crédito) scoped clients resource.
60
- *
61
- * @example
62
- * ```typescript
63
- * const tscSdk = new ComplianceSDK({
64
- * apiKey,
65
- * environment: "test",
66
- * jurisdiction: Jurisdiction.Mexico,
67
- * actividadVulnerable: CodigoActividad.TSC,
68
- * });
69
- *
70
- * const client = await tscSdk.clients.create({
71
- * type: ClientType.Person,
72
- * name: "Juan García",
73
- * rfc: "GAJL850101ABC",
74
- * });
75
- *
76
- * // Returns MexTSCClient
77
- * ```
78
- */
79
- export class TSCClientsResource extends MexClientsResource<TSCClientSort> {
80
- // ─────────────────────────────────────────────────────────────────
81
- // CRUD Operations
82
- // ─────────────────────────────────────────────────────────────────
83
-
84
- async create(data: CreateTSCClientInput): Promise<MexTSCClient> {
85
- const validated = this.validate(createTSCClientInputSchema, data);
86
- const nestedData = this.transformToNested(validated);
87
-
88
- const response = await this.execute(() =>
89
- this.trpc.clients.create.mutate(nestedData)
90
- );
91
-
92
- return this.instantiate(response);
93
- }
94
-
95
- async retrieve(
96
- id: string,
97
- include?: ClientIncludeMap
98
- ): Promise<MexTSCClient> {
99
- const response = await this.execute(() =>
100
- this.trpc.clients.retrieve.query({ id, include })
101
- );
102
- return this.instantiate(response);
103
- }
104
-
105
- async retrieveByExternalId(externalId: string): Promise<MexTSCClient> {
106
- const response = await this.execute(() =>
107
- this.trpc.clients.retrieveByExternalId.query({ externalId })
108
- );
109
- return this.instantiate(response);
110
- }
111
-
112
- async update(id: string, data: UpdateTSCClientInput): Promise<MexTSCClient> {
113
- const validated = this.validate(updateTSCClientInputSchema, data);
114
- const nestedData = this.transformUpdateToNested(validated);
115
-
116
- const response = await this.execute(() =>
117
- this.trpc.clients.update.mutate({ id, data: nestedData })
118
- );
119
- return this.instantiate(response);
120
- }
121
-
122
- // ─────────────────────────────────────────────────────────────────
123
- // List & Pagination
124
- // ─────────────────────────────────────────────────────────────────
125
-
126
- /**
127
- * Lists TSC clients with optional filtering.
128
- *
129
- * Accepts flattened TSC filter (MX fields at root level) and automatically
130
- * transforms to nested format before calling the API.
131
- */
132
- async list(
133
- options?: ListOptions<TSCClientFilter, TSCClientSort> & { includePrimaryContacts?: boolean }
134
- ): Promise<PaginatedResponse<MexTSCClient>> {
135
- const scopedFilter = this.applyScopeToFilter(options?.filter);
136
- const scopedSort = this.applyScopeToSort(options?.sort);
137
-
138
- const response = await this.execute(() =>
139
- this.trpc.clients.list.query({
140
- ...options,
141
- filter: scopedFilter,
142
- sort: scopedSort,
143
- })
144
- );
145
-
146
- return {
147
- data: response.data.map((c) => this.instantiate(c)),
148
- pagination: response.pagination,
149
- };
150
- }
151
-
152
- /**
153
- * Iterates over TSC clients.
154
- *
155
- * Accepts flattened TSC filter (MX fields at root level) and automatically
156
- * transforms to nested format before calling the API.
157
- */
158
- iterate(
159
- filter?: TSCClientFilter
160
- ): AsyncGenerator<MexTSCClient, void, undefined> {
161
- const scopedFilter = this.applyScopeToFilter(filter);
162
- return this.createIterator<MexTSCClient>({ filter: scopedFilter });
163
- }
164
-
165
- // ─────────────────────────────────────────────────────────────────
166
- // Batch Operations
167
- // ─────────────────────────────────────────────────────────────────
168
-
169
- async createMany(
170
- clients: CreateTSCClientInput[],
171
- options?: { atomic?: true }
172
- ): Promise<AtomicBatchResult<MexTSCClient>>;
173
- async createMany(
174
- clients: CreateTSCClientInput[],
175
- options: { atomic: false }
176
- ): Promise<PartialBatchResult<MexTSCClient>>;
177
- async createMany(
178
- clients: CreateTSCClientInput[],
179
- options: BatchOptions = {}
180
- ): Promise<
181
- AtomicBatchResult<MexTSCClient> | PartialBatchResult<MexTSCClient>
182
- > {
183
- const atomic = options.atomic ?? true;
184
- const validated = this.validate(
185
- z.array(createTSCClientInputSchema),
186
- clients
187
- );
188
- const nestedClients = validated.map((c) => this.transformToNested(c));
189
-
190
- const response = await this.execute(() =>
191
- this.trpc.clients.createMany.mutate({ items: nestedClients, atomic })
192
- );
193
-
194
- if (response.atomic) {
195
- return {
196
- atomic: true,
197
- data: response.data.map((c) => this.instantiate(c)),
198
- };
199
- } else {
200
- return {
201
- atomic: false,
202
- succeeded: response.succeeded.map((item) => ({
203
- index: item.index,
204
- data: this.instantiate(item.data),
205
- })),
206
- failed: response.failed,
207
- };
208
- }
209
- }
210
-
211
- async updateMany(
212
- updates: { id: string; data: UpdateTSCClientInput }[],
213
- options?: { atomic?: true }
214
- ): Promise<AtomicBatchResult<MexTSCClient>>;
215
- async updateMany(
216
- updates: { id: string; data: UpdateTSCClientInput }[],
217
- options: { atomic: false }
218
- ): Promise<PartialBatchResult<MexTSCClient>>;
219
- async updateMany(
220
- updates: { id: string; data: UpdateTSCClientInput }[],
221
- options: BatchOptions = {}
222
- ): Promise<
223
- AtomicBatchResult<MexTSCClient> | PartialBatchResult<MexTSCClient>
224
- > {
225
- const atomic = options.atomic ?? true;
226
- const updateItemSchema = z.object({
227
- id: z.uuid(),
228
- data: updateTSCClientInputSchema,
229
- });
230
-
231
- const validated = this.validate(z.array(updateItemSchema), updates);
232
- const nestedUpdates = validated.map((u) => ({
233
- id: u.id,
234
- data: this.transformUpdateToNested(u.data),
235
- }));
236
-
237
- const response = await this.execute(() =>
238
- this.trpc.clients.updateMany.mutate({ items: nestedUpdates, atomic })
239
- );
240
-
241
- if (response.atomic) {
242
- return {
243
- atomic: true,
244
- data: response.data.map((c) => this.instantiate(c)),
245
- };
246
- } else {
247
- return {
248
- atomic: false,
249
- succeeded: response.succeeded.map((item) => ({
250
- index: item.index,
251
- data: this.instantiate(item.data),
252
- })),
253
- failed: response.failed,
254
- };
255
- }
256
- }
257
-
258
- // ─────────────────────────────────────────────────────────────────
259
- // Client-to-Client Relationship Management (scoped returns)
260
- // ─────────────────────────────────────────────────────────────────
261
-
262
- async linkClient(
263
- parentClientId: string,
264
- childClientId: string,
265
- relationshipType: ClientRelationshipType,
266
- metadata?: Record<string, unknown>
267
- ): Promise<MexTSCClient> {
268
- const response = await this.execute(() =>
269
- this.trpc.clients.linkClient.mutate({
270
- parentClientId,
271
- childClientId,
272
- relationshipType,
273
- metadata,
274
- })
275
- );
276
- return this.instantiate(response);
277
- }
278
-
279
- async unlinkClient(
280
- parentClientId: string,
281
- childClientId: string,
282
- relationshipType: ClientRelationshipType
283
- ): Promise<MexTSCClient> {
284
- const response = await this.execute(() =>
285
- this.trpc.clients.unlinkClient.mutate({
286
- parentClientId,
287
- childClientId,
288
- relationshipType,
289
- })
290
- );
291
- return this.instantiate(response);
292
- }
293
-
294
- async listLinkedClients(
295
- parentClientId: string,
296
- relationshipType?: ClientRelationshipType
297
- ): Promise<LinkedClient[]> {
298
- return super.listLinkedClients(parentClientId, relationshipType);
299
- }
300
-
301
- async setLinkedClients(
302
- parentClientId: string,
303
- linkedClients: LinkedClientInput[]
304
- ): Promise<MexTSCClient> {
305
- const validated = this.validate(z.array(linkedClientSchema), linkedClients);
306
-
307
- const response = await this.execute(() =>
308
- this.trpc.clients.setLinkedClients.mutate({
309
- parentClientId,
310
- linkedClients: validated,
311
- })
312
- );
313
- return this.instantiate(response);
314
- }
315
-
316
- // ─────────────────────────────────────────────────────────────────
317
- // Sync All (Atomic)
318
- // ─────────────────────────────────────────────────────────────────
319
-
320
- async syncAll(
321
- clientId: string,
322
- data: {
323
- client?: UpdateTSCClientInput;
324
- addresses?: SyncItem<CreateMexAddressInput>[];
325
- contactMethods?: SyncItem<CreateContactMethodInput>[];
326
- bankAccounts?: SyncItem<CreateBankAccountInput>[];
327
- linkedClients?: LinkedClientInput[];
328
- },
329
- options: { replaceMode: true }
330
- ): Promise<{
331
- client: MexTSCClient;
332
- addresses: SyncResult<MexAddress>;
333
- contactMethods: SyncResult<ContactMethod>;
334
- bankAccounts: SyncResult<MexBankAccount>;
335
- }>;
336
- async syncAll(
337
- clientId: string,
338
- data: {
339
- client?: UpdateTSCClientInput;
340
- addresses?: SyncItem<UpdateMexAddressInput>[];
341
- contactMethods?: SyncItem<UpdateContactMethodInput>[];
342
- bankAccounts?: SyncItem<UpdateBankAccountInput>[];
343
- linkedClients?: LinkedClientInput[];
344
- },
345
- options?: { replaceMode?: boolean }
346
- ): Promise<{
347
- client: MexTSCClient;
348
- addresses: SyncResult<MexAddress>;
349
- contactMethods: SyncResult<ContactMethod>;
350
- bankAccounts: SyncResult<MexBankAccount>;
351
- }>;
352
- async syncAll(
353
- clientId: string,
354
- data: {
355
- client?: UpdateTSCClientInput;
356
- addresses?: SyncItem<UpdateMexAddressInput | CreateMexAddressInput>[];
357
- contactMethods?: SyncItem<UpdateContactMethodInput | CreateContactMethodInput>[];
358
- bankAccounts?: SyncItem<UpdateBankAccountInput | CreateBankAccountInput>[];
359
- linkedClients?: LinkedClientInput[];
360
- },
361
- options?: { replaceMode?: boolean }
362
- ): Promise<{
363
- client: MexTSCClient;
364
- addresses: SyncResult<MexAddress>;
365
- contactMethods: SyncResult<ContactMethod>;
366
- bankAccounts: SyncResult<MexBankAccount>;
367
- }> {
368
- // Transform client input using TSC-specific transform
369
- const transformedClient = data.client
370
- ? this.transformUpdateToNested(data.client)
371
- : undefined;
372
-
373
- // Call parent syncAll with transformed client data
374
- const result = await super.syncAll(
375
- clientId,
376
- {
377
- ...data,
378
- client: transformedClient as UpdateMexClientInput,
379
- },
380
- options as { replaceMode?: boolean }
381
- );
382
-
383
- // Re-instantiate client with TSC-specific model
384
- return {
385
- ...result,
386
- client: this.instantiate(result.client as unknown as ClientData),
387
- };
388
- }
389
-
390
- // ─────────────────────────────────────────────────────────────────
391
- // Protected Helpers
392
- // ─────────────────────────────────────────────────────────────────
393
-
394
- /**
395
- * Transforms TSC input to nested API format.
396
- * TSC has no additional fields, but we add the TSC activity marker.
397
- */
398
- protected override transformToNested(
399
- data: CreateTSCClientInput
400
- ): CreateClientInput {
401
- // Use parent transform for base + MX fields (cast needed for discriminated union)
402
- const nested = super.transformToNested(
403
- data as unknown as CreateMexClientInput
404
- );
405
-
406
- // Add TSC activity marker
407
- const mexData = nested.jurisdictions?.MX;
408
-
409
- return {
410
- ...nested,
411
- jurisdictions: {
412
- MX: {
413
- ...mexData,
414
- actividadVulnerable: {
415
- [CodigoActividad.TSC]: {},
416
- },
417
- },
418
- },
419
- } as CreateClientInput;
420
- }
421
-
422
- protected override transformUpdateToNested(
423
- data: UpdateTSCClientInput
424
- ): UpdateClientInput {
425
- return super.transformUpdateToNested(
426
- data as unknown as UpdateMexClientInput
427
- );
428
- }
429
-
430
- protected override instantiate(data: ClientData): MexTSCClient {
431
- return new MexTSCClient(data);
432
- }
433
-
434
- /**
435
- * Transforms a flattened TSCClientSort to nested ClientSort format.
436
- *
437
- * Maps flattened field names to their full API paths using TSC-specific field mapping.
438
- */
439
- protected override applyScopeToSort(sort?: TSCClientSort): ClientSort | undefined {
440
- if (!sort || sort.length === 0) {
441
- return undefined;
442
- }
443
- return transformSort(sort, tscClientFieldMapping);
444
- }
445
- }
@@ -1,7 +0,0 @@
1
- /**
2
- * TSC (Tarjetas de Servicio y Crédito) Scoped Resources
3
- */
4
-
5
- export { TSCClientsResource } from "./clients";
6
- export { TSCTransactionsResource } from "./transactions";
7
- export { TSCReportsResource } from "./reports";