@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,358 +0,0 @@
1
- /**
2
- * Transactions Resource
3
- *
4
- * CRUD operations, filtering, pagination, and client relationships.
5
- *
6
- * This is the base (unscoped) resource. For jurisdiction-scoped SDKs, use:
7
- * - MexTransactionsResource - Mexico-scoped with flattened MX fields
8
- * - AVITransactionsResource - Mexico AVI-scoped with flattened AVI fields
9
- * - JYSTransactionsResource - Mexico JYS-scoped with flattened JYS fields
10
- * - TSCTransactionsResource - Mexico TSC-scoped with flattened TSC fields
11
- */
12
-
13
- import { z } from "zod";
14
- import type {
15
- CreateTransactionInput,
16
- UpdateTransactionInput,
17
- TransactionFilter,
18
- TransactionSort,
19
- ListOptions,
20
- PaginatedResponse,
21
- AtomicBatchResult,
22
- PartialBatchResult,
23
- RelatedClient,
24
- } from "@artu-ai/shared";
25
- import {
26
- createTransactionInputSchema,
27
- updateTransactionInputSchema,
28
- ClientRole,
29
- } from "@artu-ai/shared";
30
- import type { BatchOptions } from "./clients";
31
- import { BaseResource } from "./base";
32
- import { Transaction, type TransactionData } from "../models";
33
-
34
- // ===========================
35
- // TransactionsResource
36
- // ===========================
37
-
38
- /**
39
- * Base resource manager for transaction operations.
40
- *
41
- * Provides:
42
- * - CRUD operations (create, retrieve, update, delete)
43
- * - Filtering and pagination
44
- * - Client relationship management (linkClient, unlinkClient)
45
- *
46
- * @example
47
- * ```typescript
48
- * // Create a transaction with full nested format
49
- * const txn = await sdk.transactions.create({
50
- * amount: 50000,
51
- * currency: "MXN",
52
- * primaryJurisdiction: "MX",
53
- * relatedClientIds: ["client_sender"],
54
- * timestamp: new Date(),
55
- * jurisdictions: {
56
- * MX: { actividadVulnerable: { AVI: { ... } } },
57
- * },
58
- * });
59
- *
60
- * // List with filtering
61
- * const { data, pagination } = await sdk.transactions.list({
62
- * filter: { status: "completed" },
63
- * limit: 20,
64
- * });
65
- * ```
66
- */
67
- export class TransactionsResource<
68
- TSort = TransactionSort,
69
- > extends BaseResource<
70
- Transaction,
71
- CreateTransactionInput,
72
- UpdateTransactionInput,
73
- TransactionFilter,
74
- TSort
75
- > {
76
- // ─────────────────────────────────────────────────────────────────
77
- // CRUD Operations
78
- // ─────────────────────────────────────────────────────────────────
79
-
80
- /**
81
- * Creates a new transaction.
82
- *
83
- * @param data - Transaction creation data in nested format
84
- * @returns The created transaction model
85
- */
86
- async create(data: CreateTransactionInput): Promise<Transaction> {
87
- const validated = this.validate(createTransactionInputSchema, data);
88
-
89
- const response = await this.execute(() =>
90
- this.trpc.transactions.create.mutate(validated)
91
- );
92
-
93
- return this.instantiate(response);
94
- }
95
-
96
- /**
97
- * Retrieves a transaction by ID.
98
- */
99
- async retrieve(id: string): Promise<Transaction> {
100
- const response = await this.execute(() =>
101
- this.trpc.transactions.retrieve.query({ id })
102
- );
103
- return this.instantiate(response);
104
- }
105
-
106
- /**
107
- * Retrieves a transaction by metadata key/value.
108
- */
109
- async retrieveByMetadata(key: string, value: string): Promise<Transaction> {
110
- const response = await this.execute(() =>
111
- this.trpc.transactions.retrieveByMetadata.query({ key, value })
112
- );
113
- return this.instantiate(response);
114
- }
115
-
116
- /**
117
- * Retrieves a transaction by externalId.
118
- */
119
- async retrieveByExternalId(externalId: string): Promise<Transaction> {
120
- const response = await this.execute(() =>
121
- this.trpc.transactions.retrieveByExternalId.query({ externalId })
122
- );
123
- return this.instantiate(response);
124
- }
125
-
126
- /**
127
- * Updates a transaction.
128
- */
129
- async update(id: string, data: UpdateTransactionInput): Promise<Transaction> {
130
- const validated = this.validate(updateTransactionInputSchema, data);
131
-
132
- const response = await this.execute(() =>
133
- this.trpc.transactions.update.mutate({ id, data: validated })
134
- );
135
- return this.instantiate(response);
136
- }
137
-
138
- /**
139
- * Deletes a transaction (soft delete).
140
- */
141
- async delete(id: string): Promise<void> {
142
- await this.execute(() => this.trpc.transactions.delete.mutate({ id }));
143
- }
144
-
145
- // ─────────────────────────────────────────────────────────────────
146
- // List & Pagination
147
- // ─────────────────────────────────────────────────────────────────
148
-
149
- /**
150
- * Lists transactions with optional filtering and pagination.
151
- */
152
- async list(
153
- options?: ListOptions<TransactionFilter, TSort>
154
- ): Promise<PaginatedResponse<Transaction>> {
155
- const response = await this.execute(() =>
156
- this.trpc.transactions.list.query(options as ListOptions<TransactionFilter, TransactionSort>)
157
- );
158
-
159
- return {
160
- data: response.data.map((t) => this.instantiate(t)),
161
- pagination: response.pagination,
162
- };
163
- }
164
-
165
- /**
166
- * Lists all transactions for a specific client.
167
- *
168
- * @param clientId - The client ID
169
- * @param options - Optional pagination options
170
- * @returns Paginated list of Transactions
171
- */
172
- async listByClient(
173
- clientId: string,
174
- options?: { cursor?: string; limit?: number }
175
- ): Promise<PaginatedResponse<Transaction>> {
176
- const response = await this.execute(() =>
177
- this.trpc.transactions.listByClient.query({ clientId, ...options })
178
- );
179
-
180
- return {
181
- data: response.data.map((t) => this.instantiate(t)),
182
- pagination: response.pagination,
183
- };
184
- }
185
-
186
- /**
187
- * Returns an async iterator over all transactions matching the filter.
188
- */
189
- iterate(
190
- filter?: TransactionFilter
191
- ): AsyncGenerator<Transaction, void, undefined> {
192
- return this.createIterator({ filter });
193
- }
194
-
195
- // ─────────────────────────────────────────────────────────────────
196
- // Client Relationship Management
197
- // ─────────────────────────────────────────────────────────────────
198
-
199
- /**
200
- * Links a client to a transaction with an optional role.
201
- */
202
- async linkClient(
203
- transactionId: string,
204
- clientId: string,
205
- role?: ClientRole
206
- ): Promise<Transaction> {
207
- const response = await this.execute(() =>
208
- this.trpc.transactions.linkClient.mutate({
209
- transactionId,
210
- clientId,
211
- role,
212
- })
213
- );
214
- return this.instantiate(response);
215
- }
216
-
217
- /**
218
- * Unlinks a client from a transaction.
219
- */
220
- async unlinkClient(
221
- transactionId: string,
222
- clientId: string
223
- ): Promise<Transaction> {
224
- const response = await this.execute(() =>
225
- this.trpc.transactions.unlinkClient.mutate({
226
- transactionId,
227
- clientId,
228
- })
229
- );
230
- return this.instantiate(response);
231
- }
232
-
233
- /**
234
- * Replaces all clients related to a transaction.
235
- */
236
- async setClients(
237
- transactionId: string,
238
- clients: RelatedClient[]
239
- ): Promise<Transaction> {
240
- const response = await this.execute(() =>
241
- this.trpc.transactions.setClients.mutate({
242
- transactionId,
243
- clients,
244
- })
245
- );
246
- return this.instantiate(response);
247
- }
248
-
249
- // ─────────────────────────────────────────────────────────────────
250
- // Batch Operations
251
- // ─────────────────────────────────────────────────────────────────
252
-
253
- /**
254
- * Creates multiple transactions in a single request.
255
- *
256
- * @param transactions - Array of transaction creation data
257
- * @param options - Batch options (atomic: true by default)
258
- * @returns Atomic result with data array, or partial result with succeeded/failed
259
- */
260
- async createMany(
261
- transactions: CreateTransactionInput[],
262
- options?: { atomic?: true }
263
- ): Promise<AtomicBatchResult<Transaction>>;
264
- async createMany(
265
- transactions: CreateTransactionInput[],
266
- options: { atomic: false }
267
- ): Promise<PartialBatchResult<Transaction>>;
268
- async createMany(
269
- transactions: CreateTransactionInput[],
270
- options: BatchOptions = {}
271
- ): Promise<AtomicBatchResult<Transaction> | PartialBatchResult<Transaction>> {
272
- const atomic = options.atomic ?? true;
273
- const validated = this.validate(
274
- z.array(createTransactionInputSchema),
275
- transactions
276
- );
277
-
278
- const response = await this.execute(() =>
279
- this.trpc.transactions.createMany.mutate({ items: validated, atomic })
280
- );
281
-
282
- if (response.atomic) {
283
- return {
284
- atomic: true,
285
- data: response.data.map((t) => this.instantiate(t)),
286
- };
287
- } else {
288
- return {
289
- atomic: false,
290
- succeeded: response.succeeded.map((item) => ({
291
- index: item.index,
292
- data: this.instantiate(item.data),
293
- })),
294
- failed: response.failed,
295
- };
296
- }
297
- }
298
-
299
- /**
300
- * Updates multiple transactions in a single request.
301
- *
302
- * @param updates - Array of { id, data } updates
303
- * @param options - Batch options (atomic: true by default)
304
- * @returns Atomic result with data array, or partial result with succeeded/failed
305
- */
306
- async updateMany(
307
- updates: { id: string; data: UpdateTransactionInput }[],
308
- options?: { atomic?: true }
309
- ): Promise<AtomicBatchResult<Transaction>>;
310
- async updateMany(
311
- updates: { id: string; data: UpdateTransactionInput }[],
312
- options: { atomic: false }
313
- ): Promise<PartialBatchResult<Transaction>>;
314
- async updateMany(
315
- updates: { id: string; data: UpdateTransactionInput }[],
316
- options: BatchOptions = {}
317
- ): Promise<AtomicBatchResult<Transaction> | PartialBatchResult<Transaction>> {
318
- const atomic = options.atomic ?? true;
319
- const updateItemSchema = z.object({
320
- id: z.uuid(),
321
- data: updateTransactionInputSchema,
322
- });
323
-
324
- const validated = this.validate(z.array(updateItemSchema), updates);
325
-
326
- const response = await this.execute(() =>
327
- this.trpc.transactions.updateMany.mutate({ items: validated, atomic })
328
- );
329
-
330
- if (response.atomic) {
331
- return {
332
- atomic: true,
333
- data: response.data.map((t) => this.instantiate(t)),
334
- };
335
- } else {
336
- return {
337
- atomic: false,
338
- succeeded: response.succeeded.map((item) => ({
339
- index: item.index,
340
- data: this.instantiate(item.data),
341
- })),
342
- failed: response.failed,
343
- };
344
- }
345
- }
346
-
347
- // ─────────────────────────────────────────────────────────────────
348
- // Instantiation (protected for subclasses to override)
349
- // ─────────────────────────────────────────────────────────────────
350
-
351
- /**
352
- * Instantiates a Transaction model from API response data.
353
- * Subclasses override this to return their specific model type.
354
- */
355
- protected instantiate(data: TransactionData): Transaction {
356
- return new Transaction(data);
357
- }
358
- }