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