@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,417 +0,0 @@
1
- /**
2
- * Bank Accounts Resource
3
- *
4
- * Manages bank account information for clients.
5
- *
6
- * This is the base (unscoped) resource. For jurisdiction-scoped SDKs, use:
7
- * - MexBankAccountsResource - Mexico-scoped with flattened CLABE fields
8
- */
9
-
10
- import { z } from "zod";
11
- import type {
12
- CreateBankAccountInput,
13
- UpdateBankAccountInput,
14
- BankAccountFilter,
15
- BankAccountSort,
16
- PaginatedResponse,
17
- ListOptions,
18
- AtomicBatchResult,
19
- PartialBatchResult,
20
- SyncItem,
21
- SyncResult,
22
- } from "@artu-ai/shared";
23
- import {
24
- createBankAccountInputSchema,
25
- updateBankAccountInputSchema,
26
- replaceSyncItemSchema,
27
- } from "@artu-ai/shared";
28
- import type { BatchOptions } from "./clients";
29
- import { BaseResource } from "./base";
30
- import { BankAccount, type BankAccountData } from "../models/BankAccount";
31
-
32
- // ===========================
33
- // BankAccountsResource
34
- // ===========================
35
-
36
- /**
37
- * Base resource for managing client bank accounts.
38
- *
39
- * @example
40
- * ```typescript
41
- * // Create a bank account with full nested format
42
- * const account = await sdk.bankAccounts.create("client_123", {
43
- * accountNumber: "1234567890",
44
- * bankName: "BBVA México",
45
- * type: BankAccountType.Checking,
46
- * currency: Currency.MXN,
47
- * jurisdictions: {
48
- * MX: {
49
- * clabe: "012345678901234567",
50
- * },
51
- * },
52
- * });
53
- *
54
- * // List accounts for a client
55
- * const accounts = await sdk.bankAccounts.list("client_123");
56
- * ```
57
- */
58
- export class BankAccountsResource<
59
- TSort = BankAccountSort,
60
- > extends BaseResource<
61
- BankAccount,
62
- CreateBankAccountInput,
63
- UpdateBankAccountInput,
64
- BankAccountFilter,
65
- TSort
66
- > {
67
- // ─────────────────────────────────────────────────────────────────
68
- // CRUD Operations
69
- // ─────────────────────────────────────────────────────────────────
70
-
71
- /**
72
- * Creates a new bank account for a client.
73
- *
74
- * @param data - Bank account creation data (includes clientId)
75
- * @returns The created bank account model
76
- */
77
- async create(data: CreateBankAccountInput): Promise<BankAccount> {
78
- const validated = this.validate(createBankAccountInputSchema, data);
79
-
80
- const response = await this.execute(() =>
81
- this.trpc.bankAccounts.create.mutate(validated)
82
- );
83
-
84
- return this.instantiate(response);
85
- }
86
-
87
- /**
88
- * Retrieves a bank account by ID.
89
- */
90
- async retrieve(id: string): Promise<BankAccount> {
91
- const response = await this.execute(() =>
92
- this.trpc.bankAccounts.retrieve.query({ id })
93
- );
94
- return this.instantiate(response);
95
- }
96
-
97
- /**
98
- * Retrieves a bank account by metadata key/value.
99
- */
100
- async retrieveByMetadata(key: string, value: string): Promise<BankAccount> {
101
- const response = await this.execute(() =>
102
- this.trpc.bankAccounts.retrieveByMetadata.query({ key, value })
103
- );
104
- return this.instantiate(response);
105
- }
106
-
107
- /**
108
- * Retrieves a bank account by externalId.
109
- */
110
- async retrieveByExternalId(externalId: string): Promise<BankAccount> {
111
- const response = await this.execute(() =>
112
- this.trpc.bankAccounts.retrieveByExternalId.query({ externalId })
113
- );
114
- return this.instantiate(response);
115
- }
116
-
117
- /**
118
- * Updates a bank account.
119
- */
120
- async update(id: string, data: UpdateBankAccountInput): Promise<BankAccount> {
121
- const validated = this.validate(updateBankAccountInputSchema, data);
122
-
123
- const response = await this.execute(() =>
124
- this.trpc.bankAccounts.update.mutate({ id, data: validated })
125
- );
126
- return this.instantiate(response);
127
- }
128
-
129
- /**
130
- * Deletes a bank account.
131
- */
132
- async delete(id: string): Promise<void> {
133
- await this.execute(() => this.trpc.bankAccounts.delete.mutate({ id }));
134
- }
135
-
136
- // ─────────────────────────────────────────────────────────────────
137
- // List & Pagination
138
- // ─────────────────────────────────────────────────────────────────
139
-
140
- /**
141
- * Lists bank accounts with optional filtering.
142
- */
143
- async list(
144
- options?: ListOptions<BankAccountFilter, TSort>
145
- ): Promise<PaginatedResponse<BankAccount>> {
146
- const response = await this.execute(() =>
147
- this.trpc.bankAccounts.list.query(options as ListOptions<BankAccountFilter, BankAccountSort>)
148
- );
149
-
150
- return {
151
- data: response.data.map((a) => this.instantiate(a)),
152
- pagination: response.pagination,
153
- };
154
- }
155
-
156
- /**
157
- * Lists all bank accounts for a specific client.
158
- */
159
- async listByClient(
160
- clientId: string,
161
- options?: { cursor?: string; limit?: number }
162
- ): Promise<PaginatedResponse<BankAccount>> {
163
- const response = await this.execute(() =>
164
- this.trpc.bankAccounts.listByClient.query({ clientId, ...options })
165
- );
166
-
167
- return {
168
- data: response.data.map((a) => this.instantiate(a)),
169
- pagination: response.pagination,
170
- };
171
- }
172
-
173
- /**
174
- * Returns an async iterator over all bank accounts matching the filter.
175
- */
176
- iterate(
177
- filter?: BankAccountFilter
178
- ): AsyncGenerator<BankAccount, void, undefined> {
179
- return this.createIterator({ filter });
180
- }
181
-
182
- // ─────────────────────────────────────────────────────────────────
183
- // Convenience Methods
184
- // ─────────────────────────────────────────────────────────────────
185
-
186
- /**
187
- * Gets the primary bank account for a client.
188
- *
189
- * @param clientId - The client ID
190
- * @returns The primary bank account, or null if none is marked as primary
191
- */
192
- async getPrimary(clientId: string): Promise<BankAccount | null> {
193
- const response = await this.execute(() =>
194
- this.trpc.bankAccounts.getPrimary.query({ clientId })
195
- );
196
-
197
- return response ? this.instantiate(response) : null;
198
- }
199
-
200
- /**
201
- * Sets a bank account as the primary account for a client.
202
- */
203
- async setPrimary(id: string): Promise<BankAccount> {
204
- const response = await this.execute(() =>
205
- this.trpc.bankAccounts.update.mutate({ id, data: { isPrimary: true } })
206
- );
207
- return this.instantiate(response);
208
- }
209
-
210
- /**
211
- * Activates a bank account.
212
- */
213
- async activate(id: string): Promise<BankAccount> {
214
- const response = await this.execute(() =>
215
- this.trpc.bankAccounts.update.mutate({ id, data: { isActive: true } })
216
- );
217
- return this.instantiate(response);
218
- }
219
-
220
- /**
221
- * Deactivates a bank account.
222
- */
223
- async deactivate(id: string): Promise<BankAccount> {
224
- const response = await this.execute(() =>
225
- this.trpc.bankAccounts.update.mutate({ id, data: { isActive: false } })
226
- );
227
- return this.instantiate(response);
228
- }
229
-
230
- // ─────────────────────────────────────────────────────────────────
231
- // Batch Operations
232
- // ─────────────────────────────────────────────────────────────────
233
-
234
- /**
235
- * Creates multiple bank accounts in a single request.
236
- *
237
- * @param accounts - Array of bank account creation data (each includes clientId)
238
- * @param options - Batch options (atomic: true by default)
239
- * @returns Atomic result with data array, or partial result with succeeded/failed
240
- */
241
- async createMany(
242
- accounts: CreateBankAccountInput[],
243
- options?: { atomic?: true }
244
- ): Promise<AtomicBatchResult<BankAccount>>;
245
- async createMany(
246
- accounts: CreateBankAccountInput[],
247
- options: { atomic: false }
248
- ): Promise<PartialBatchResult<BankAccount>>;
249
- async createMany(
250
- accounts: CreateBankAccountInput[],
251
- options: BatchOptions = {}
252
- ): Promise<AtomicBatchResult<BankAccount> | PartialBatchResult<BankAccount>> {
253
- const atomic = options.atomic ?? true;
254
- const validated = this.validate(
255
- z.array(createBankAccountInputSchema),
256
- accounts
257
- );
258
-
259
- const response = await this.execute(() =>
260
- this.trpc.bankAccounts.createMany.mutate({ items: validated, atomic })
261
- );
262
-
263
- if (response.atomic) {
264
- return {
265
- atomic: true,
266
- data: response.data.map((a) => this.instantiate(a)),
267
- };
268
- } else {
269
- return {
270
- atomic: false,
271
- succeeded: response.succeeded.map((item) => ({
272
- index: item.index,
273
- data: this.instantiate(item.data),
274
- })),
275
- failed: response.failed,
276
- };
277
- }
278
- }
279
-
280
- /**
281
- * Updates multiple bank accounts in a single request.
282
- *
283
- * @param updates - Array of { id, data } updates
284
- * @param options - Batch options (atomic: true by default)
285
- * @returns Atomic result with data array, or partial result with succeeded/failed
286
- */
287
- async updateMany(
288
- updates: { id: string; data: UpdateBankAccountInput }[],
289
- options?: { atomic?: true }
290
- ): Promise<AtomicBatchResult<BankAccount>>;
291
- async updateMany(
292
- updates: { id: string; data: UpdateBankAccountInput }[],
293
- options: { atomic: false }
294
- ): Promise<PartialBatchResult<BankAccount>>;
295
- async updateMany(
296
- updates: { id: string; data: UpdateBankAccountInput }[],
297
- options: BatchOptions = {}
298
- ): Promise<AtomicBatchResult<BankAccount> | PartialBatchResult<BankAccount>> {
299
- const atomic = options.atomic ?? true;
300
- const updateItemSchema = z.object({
301
- id: z.uuid(),
302
- data: updateBankAccountInputSchema,
303
- });
304
-
305
- const validated = this.validate(z.array(updateItemSchema), updates);
306
-
307
- const response = await this.execute(() =>
308
- this.trpc.bankAccounts.updateMany.mutate({ items: validated, atomic })
309
- );
310
-
311
- if (response.atomic) {
312
- return {
313
- atomic: true,
314
- data: response.data.map((a) => this.instantiate(a)),
315
- };
316
- } else {
317
- return {
318
- atomic: false,
319
- succeeded: response.succeeded.map((item) => ({
320
- index: item.index,
321
- data: this.instantiate(item.data),
322
- })),
323
- failed: response.failed,
324
- };
325
- }
326
- }
327
-
328
- // ─────────────────────────────────────────────────────────────────
329
- // Sync Operations
330
- // ─────────────────────────────────────────────────────────────────
331
-
332
- /**
333
- * Syncs bank accounts for a client - handles create, update, and delete in bulk.
334
- *
335
- * This is the most efficient way to reconcile a set of bank accounts for a client.
336
- *
337
- * @param clientId - The client ID
338
- * @param items - Array of sync items:
339
- * - Without `id`: create new bank account
340
- * - With `id` and `_delete: true`: delete existing bank account
341
- * - With `id` (no `_delete`): update existing bank account
342
- * @param options - Sync options
343
- * @param options.replaceMode - When true, items not in the array are deleted (default: false)
344
- * @returns Sync result with created, updated, and deleted arrays
345
- *
346
- * @example
347
- * ```typescript
348
- * // Patch mode (default) - only mentioned items are affected
349
- * const result = await sdk.bankAccounts.sync("client_123", [
350
- * // Create new account (no id)
351
- * { accountNumber: "1234567890", bankName: "BBVA", country: "MX" },
352
- * // Update existing account (has id)
353
- * { id: "ba_456", bankName: "BBVA México" },
354
- * // Delete account (has id and _delete: true)
355
- * { id: "ba_789", _delete: true },
356
- * ]);
357
- *
358
- * // Replace mode - provided array becomes the complete set (requires full create input for new items)
359
- * const result = await sdk.bankAccounts.sync("client_123", accounts, { replaceMode: true });
360
- *
361
- * console.log(result.created); // newly created accounts
362
- * console.log(result.updated); // updated accounts
363
- * console.log(result.deleted); // array of deleted IDs
364
- * ```
365
- */
366
- async sync(
367
- clientId: string,
368
- items: SyncItem<CreateBankAccountInput>[],
369
- options: { replaceMode: true }
370
- ): Promise<SyncResult<BankAccount>>;
371
- async sync(
372
- clientId: string,
373
- items: SyncItem<UpdateBankAccountInput>[],
374
- options?: { replaceMode?: boolean }
375
- ): Promise<SyncResult<BankAccount>>;
376
- async sync(
377
- clientId: string,
378
- items: SyncItem<UpdateBankAccountInput | CreateBankAccountInput>[],
379
- options?: { replaceMode?: boolean }
380
- ): Promise<SyncResult<BankAccount>> {
381
- const validated = this.validate(
382
- z.array(
383
- replaceSyncItemSchema(
384
- createBankAccountInputSchema,
385
- updateBankAccountInputSchema
386
- )
387
- ),
388
- items
389
- );
390
-
391
- const response = await this.execute(() =>
392
- this.trpc.bankAccounts.sync.mutate({
393
- clientId,
394
- items: validated,
395
- replaceMode: options?.replaceMode,
396
- })
397
- );
398
-
399
- return {
400
- created: response.created.map((a) => this.instantiate(a)),
401
- updated: response.updated.map((a) => this.instantiate(a)),
402
- deleted: response.deleted,
403
- };
404
- }
405
-
406
- // ─────────────────────────────────────────────────────────────────
407
- // Instantiation (protected for subclasses to override)
408
- // ─────────────────────────────────────────────────────────────────
409
-
410
- /**
411
- * Instantiates a BankAccount model from API response data.
412
- * Subclasses override this to return their specific model type.
413
- */
414
- protected instantiate(data: BankAccountData): BankAccount {
415
- return new BankAccount(data);
416
- }
417
- }