@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.
- package/package.json +4 -5
- package/src/errors/api.ts +0 -305
- package/src/errors/base.ts +0 -127
- package/src/errors/index.ts +0 -63
- package/src/errors/upload.ts +0 -204
- package/src/errors/validation.ts +0 -163
- package/src/exports/base.ts +0 -139
- package/src/exports/index.ts +0 -187
- package/src/exports/mexico/actividad-vulnerable/avi.ts +0 -207
- package/src/exports/mexico/actividad-vulnerable/jys.ts +0 -214
- package/src/exports/mexico/actividad-vulnerable/tsc.ts +0 -202
- package/src/exports/mexico/index.ts +0 -215
- package/src/models/Address.ts +0 -235
- package/src/models/BankAccount.ts +0 -235
- package/src/models/Client.ts +0 -363
- package/src/models/ContactMethod.ts +0 -197
- package/src/models/Document.ts +0 -355
- package/src/models/LinkedClient.ts +0 -84
- package/src/models/Report.ts +0 -193
- package/src/models/ReportItem.ts +0 -211
- package/src/models/Transaction.ts +0 -219
- package/src/models/base.ts +0 -56
- package/src/models/index.ts +0 -148
- package/src/models/mex/MexAddress.ts +0 -184
- package/src/models/mex/MexBankAccount.ts +0 -121
- package/src/models/mex/MexClient.ts +0 -177
- package/src/models/mex/MexDocument.ts +0 -890
- package/src/models/mex/MexReport.ts +0 -99
- package/src/models/mex/MexReportItem.ts +0 -79
- package/src/models/mex/MexTransaction.ts +0 -105
- package/src/models/mex/actividad-vulnerable/MexActividadVulnerableClient.ts +0 -66
- package/src/models/mex/actividad-vulnerable/MexActividadVulnerableReport.ts +0 -73
- package/src/models/mex/actividad-vulnerable/MexActividadVulnerableReportItem.ts +0 -74
- package/src/models/mex/actividad-vulnerable/MexActividadVulnerableTransaction.ts +0 -50
- package/src/models/mex/actividad-vulnerable/avi/MexAVIClient.ts +0 -80
- package/src/models/mex/actividad-vulnerable/avi/MexAVIReport.ts +0 -114
- package/src/models/mex/actividad-vulnerable/avi/MexAVIReportItem.ts +0 -105
- package/src/models/mex/actividad-vulnerable/avi/MexAVITransaction.ts +0 -157
- package/src/models/mex/actividad-vulnerable/index.ts +0 -78
- package/src/models/mex/actividad-vulnerable/jys/MexJYSClient.ts +0 -73
- package/src/models/mex/actividad-vulnerable/jys/MexJYSReport.ts +0 -114
- package/src/models/mex/actividad-vulnerable/jys/MexJYSReportItem.ts +0 -105
- package/src/models/mex/actividad-vulnerable/jys/MexJYSTransaction.ts +0 -178
- package/src/models/mex/actividad-vulnerable/tsc/MexTSCClient.ts +0 -73
- package/src/models/mex/actividad-vulnerable/tsc/MexTSCReport.ts +0 -114
- package/src/models/mex/actividad-vulnerable/tsc/MexTSCReportItem.ts +0 -105
- package/src/models/mex/actividad-vulnerable/tsc/MexTSCTransaction.ts +0 -104
- package/src/models/mex/index.ts +0 -57
- package/src/models/types.ts +0 -196
- package/src/namespaces/index.ts +0 -29
- package/src/namespaces/mexico/actividad-vulnerable/avi/index.ts +0 -62
- package/src/namespaces/mexico/actividad-vulnerable/index.ts +0 -79
- package/src/namespaces/mexico/actividad-vulnerable/jys/index.ts +0 -72
- package/src/namespaces/mexico/actividad-vulnerable/tsc/index.ts +0 -60
- package/src/namespaces/mexico/index.ts +0 -325
- package/src/resources/addresses.ts +0 -391
- package/src/resources/bank-accounts.ts +0 -417
- package/src/resources/base.ts +0 -327
- package/src/resources/clients.ts +0 -808
- package/src/resources/contact-methods.ts +0 -412
- package/src/resources/documents.ts +0 -688
- package/src/resources/index.ts +0 -40
- package/src/resources/mex/actividad-vulnerable/avi/clients.ts +0 -559
- package/src/resources/mex/actividad-vulnerable/avi/index.ts +0 -7
- package/src/resources/mex/actividad-vulnerable/avi/reports.ts +0 -609
- package/src/resources/mex/actividad-vulnerable/avi/transactions.ts +0 -404
- package/src/resources/mex/actividad-vulnerable/index.ts +0 -12
- package/src/resources/mex/actividad-vulnerable/jys/clients.ts +0 -445
- package/src/resources/mex/actividad-vulnerable/jys/index.ts +0 -7
- package/src/resources/mex/actividad-vulnerable/jys/reports.ts +0 -591
- package/src/resources/mex/actividad-vulnerable/jys/transactions.ts +0 -395
- package/src/resources/mex/actividad-vulnerable/tsc/clients.ts +0 -445
- package/src/resources/mex/actividad-vulnerable/tsc/index.ts +0 -7
- package/src/resources/mex/actividad-vulnerable/tsc/reports.ts +0 -591
- package/src/resources/mex/actividad-vulnerable/tsc/transactions.ts +0 -404
- package/src/resources/mex/addresses.ts +0 -493
- package/src/resources/mex/bank-accounts.ts +0 -283
- package/src/resources/mex/clients.ts +0 -758
- package/src/resources/mex/ebr.ts +0 -621
- package/src/resources/mex/index.ts +0 -23
- package/src/resources/mex/reports.ts +0 -643
- package/src/resources/mex/transactions.ts +0 -422
- package/src/resources/reports.ts +0 -515
- package/src/resources/transactions.ts +0 -358
- package/src/sdk/ComplianceSDK.ts +0 -812
- package/src/sdk/base.ts +0 -43
- package/src/sdk/index.ts +0 -98
- package/src/sdk/mex/ComplianceSDK.ts +0 -147
- package/src/sdk/mex/actividad-vulnerable/avi/ComplianceSDK.ts +0 -55
- package/src/sdk/mex/actividad-vulnerable/avi/index.ts +0 -16
- package/src/sdk/mex/actividad-vulnerable/avi/types.ts +0 -86
- package/src/sdk/mex/actividad-vulnerable/index.ts +0 -58
- package/src/sdk/mex/actividad-vulnerable/jys/ComplianceSDK.ts +0 -54
- package/src/sdk/mex/actividad-vulnerable/jys/index.ts +0 -16
- package/src/sdk/mex/actividad-vulnerable/jys/types.ts +0 -86
- package/src/sdk/mex/actividad-vulnerable/tsc/ComplianceSDK.ts +0 -54
- package/src/sdk/mex/actividad-vulnerable/tsc/index.ts +0 -16
- package/src/sdk/mex/actividad-vulnerable/tsc/types.ts +0 -86
- package/src/sdk/mex/index.ts +0 -66
- package/src/sdk/mex/types.ts +0 -88
- package/src/sdk/resource-registry.ts +0 -204
- package/src/sdk/sdk-registry.ts +0 -99
- package/src/sdk/types.ts +0 -304
- package/src/utils/environment.ts +0 -187
- package/src/utils/filters.ts +0 -412
- package/src/utils/index.ts +0 -134
- package/src/utils/pagination.ts +0 -143
- package/src/utils/session.ts +0 -303
- package/src/utils/trpc-client.ts +0 -242
- package/src/utils/upload.ts +0 -388
|
@@ -1,404 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AVI (Activos Virtuales) Transactions Resource
|
|
3
|
-
*
|
|
4
|
-
* Extends MexTransactionsResource with AVI-specific behavior:
|
|
5
|
-
* - Accepts flattened CreateAVITransactionInput (AVI fields at root level)
|
|
6
|
-
* - Returns MexAVITransaction models
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { z } from "zod";
|
|
10
|
-
import type {
|
|
11
|
-
CreateTransactionInput,
|
|
12
|
-
UpdateTransactionInput,
|
|
13
|
-
TransactionSort,
|
|
14
|
-
ListOptions,
|
|
15
|
-
PaginatedResponse,
|
|
16
|
-
CreateAVITransactionInput,
|
|
17
|
-
UpdateAVITransactionInput,
|
|
18
|
-
AtomicBatchResult,
|
|
19
|
-
PartialBatchResult,
|
|
20
|
-
RelatedClient,
|
|
21
|
-
AVITransactionFilter,
|
|
22
|
-
AVITransactionSort,
|
|
23
|
-
} from "@artu-ai/shared";
|
|
24
|
-
import {
|
|
25
|
-
Jurisdiction,
|
|
26
|
-
CodigoActividad,
|
|
27
|
-
createAVITransactionInputSchema,
|
|
28
|
-
updateAVITransactionInputSchema,
|
|
29
|
-
ClientRole,
|
|
30
|
-
transformSort,
|
|
31
|
-
aviTransactionFieldMapping,
|
|
32
|
-
} from "@artu-ai/shared";
|
|
33
|
-
import { MexTransactionsResource } from "../../transactions";
|
|
34
|
-
import { type BatchOptions } from "../../../clients";
|
|
35
|
-
import { MexAVITransaction, type TransactionData } from "../../../../models";
|
|
36
|
-
|
|
37
|
-
// ===========================
|
|
38
|
-
// AVITransactionsResource
|
|
39
|
-
// ===========================
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* AVI (Activos Virtuales) scoped transactions resource.
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* ```typescript
|
|
46
|
-
* const aviSdk = new ComplianceSDK({
|
|
47
|
-
* apiKey,
|
|
48
|
-
* jurisdiction: Jurisdiction.Mexico,
|
|
49
|
-
* actividadVulnerable: CodigoActividad.AVI,
|
|
50
|
-
* });
|
|
51
|
-
*
|
|
52
|
-
* // Create with fully flattened input
|
|
53
|
-
* const txn = await aviSdk.transactions.create({
|
|
54
|
-
* amount: 50000,
|
|
55
|
-
* currency: "MXN",
|
|
56
|
-
* timestamp: new Date(),
|
|
57
|
-
* operationType: "buy",
|
|
58
|
-
* crypto: "BTC",
|
|
59
|
-
* hash: "ABC123DEF456",
|
|
60
|
-
* });
|
|
61
|
-
*
|
|
62
|
-
* // Returns MexAVITransaction
|
|
63
|
-
* console.log(txn.operationType);
|
|
64
|
-
* ```
|
|
65
|
-
*/
|
|
66
|
-
export class AVITransactionsResource extends MexTransactionsResource<AVITransactionSort> {
|
|
67
|
-
// ─────────────────────────────────────────────────────────────────
|
|
68
|
-
// CRUD Operations
|
|
69
|
-
// ─────────────────────────────────────────────────────────────────
|
|
70
|
-
|
|
71
|
-
async create(data: CreateAVITransactionInput): Promise<MexAVITransaction> {
|
|
72
|
-
const validated = this.validate(createAVITransactionInputSchema, data);
|
|
73
|
-
const nestedData = this.transformToNested(validated);
|
|
74
|
-
|
|
75
|
-
const response = await this.execute(() =>
|
|
76
|
-
this.trpc.transactions.create.mutate(nestedData)
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
return this.instantiate(response);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
async retrieve(id: string): Promise<MexAVITransaction> {
|
|
83
|
-
const response = await this.execute(() =>
|
|
84
|
-
this.trpc.transactions.retrieve.query({ id })
|
|
85
|
-
);
|
|
86
|
-
return this.instantiate(response);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
async retrieveByMetadata(
|
|
90
|
-
key: string,
|
|
91
|
-
value: string
|
|
92
|
-
): Promise<MexAVITransaction> {
|
|
93
|
-
const response = await this.execute(() =>
|
|
94
|
-
this.trpc.transactions.retrieveByMetadata.query({ key, value })
|
|
95
|
-
);
|
|
96
|
-
return this.instantiate(response);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
async update(
|
|
100
|
-
id: string,
|
|
101
|
-
data: UpdateAVITransactionInput
|
|
102
|
-
): Promise<MexAVITransaction> {
|
|
103
|
-
const validated = this.validate(updateAVITransactionInputSchema, data);
|
|
104
|
-
const nestedData = this.transformUpdateToNested(validated);
|
|
105
|
-
|
|
106
|
-
const response = await this.execute(() =>
|
|
107
|
-
this.trpc.transactions.update.mutate({ id, data: nestedData })
|
|
108
|
-
);
|
|
109
|
-
return this.instantiate(response);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// ─────────────────────────────────────────────────────────────────
|
|
113
|
-
// List & Pagination
|
|
114
|
-
// ─────────────────────────────────────────────────────────────────
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Lists AVI transactions with optional filtering.
|
|
118
|
-
*
|
|
119
|
-
* Accepts flattened AVI filter (future AVI-specific transaction fields at root level).
|
|
120
|
-
*/
|
|
121
|
-
async list(
|
|
122
|
-
options?: ListOptions<AVITransactionFilter, AVITransactionSort>
|
|
123
|
-
): Promise<PaginatedResponse<MexAVITransaction>> {
|
|
124
|
-
const scopedFilter = this.applyScopeToFilter(options?.filter);
|
|
125
|
-
const scopedSort = this.applyScopeToSort(options?.sort);
|
|
126
|
-
|
|
127
|
-
const response = await this.execute(() =>
|
|
128
|
-
this.trpc.transactions.list.query({
|
|
129
|
-
...options,
|
|
130
|
-
filter: scopedFilter,
|
|
131
|
-
sort: scopedSort,
|
|
132
|
-
})
|
|
133
|
-
);
|
|
134
|
-
|
|
135
|
-
return {
|
|
136
|
-
data: response.data.map((t) => this.instantiate(t)),
|
|
137
|
-
pagination: response.pagination,
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Iterates over AVI transactions.
|
|
143
|
-
*
|
|
144
|
-
* Accepts flattened AVI filter (future AVI-specific transaction fields at root level).
|
|
145
|
-
*/
|
|
146
|
-
iterate(
|
|
147
|
-
filter?: AVITransactionFilter
|
|
148
|
-
): AsyncGenerator<MexAVITransaction, void, undefined> {
|
|
149
|
-
const scopedFilter = this.applyScopeToFilter(filter);
|
|
150
|
-
return this.createIterator<MexAVITransaction>({ filter: scopedFilter });
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// ─────────────────────────────────────────────────────────────────
|
|
154
|
-
// Client Relationship Management (scoped returns)
|
|
155
|
-
// ─────────────────────────────────────────────────────────────────
|
|
156
|
-
|
|
157
|
-
async listByClient(
|
|
158
|
-
clientId: string,
|
|
159
|
-
options?: { cursor?: string; limit?: number }
|
|
160
|
-
): Promise<PaginatedResponse<MexAVITransaction>> {
|
|
161
|
-
const response = await this.execute(() =>
|
|
162
|
-
this.trpc.transactions.listByClient.query({ clientId, ...options })
|
|
163
|
-
);
|
|
164
|
-
|
|
165
|
-
return {
|
|
166
|
-
data: response.data.map((t) => this.instantiate(t)),
|
|
167
|
-
pagination: response.pagination,
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
async linkClient(
|
|
172
|
-
transactionId: string,
|
|
173
|
-
clientId: string,
|
|
174
|
-
role?: ClientRole
|
|
175
|
-
): Promise<MexAVITransaction> {
|
|
176
|
-
const response = await this.execute(() =>
|
|
177
|
-
this.trpc.transactions.linkClient.mutate({
|
|
178
|
-
transactionId,
|
|
179
|
-
clientId,
|
|
180
|
-
role,
|
|
181
|
-
})
|
|
182
|
-
);
|
|
183
|
-
return this.instantiate(response);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
async unlinkClient(
|
|
187
|
-
transactionId: string,
|
|
188
|
-
clientId: string
|
|
189
|
-
): Promise<MexAVITransaction> {
|
|
190
|
-
const response = await this.execute(() =>
|
|
191
|
-
this.trpc.transactions.unlinkClient.mutate({
|
|
192
|
-
transactionId,
|
|
193
|
-
clientId,
|
|
194
|
-
})
|
|
195
|
-
);
|
|
196
|
-
return this.instantiate(response);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
async setClients(
|
|
200
|
-
transactionId: string,
|
|
201
|
-
clients: RelatedClient[]
|
|
202
|
-
): Promise<MexAVITransaction> {
|
|
203
|
-
const response = await this.execute(() =>
|
|
204
|
-
this.trpc.transactions.setClients.mutate({
|
|
205
|
-
transactionId,
|
|
206
|
-
clients,
|
|
207
|
-
})
|
|
208
|
-
);
|
|
209
|
-
return this.instantiate(response);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
// ─────────────────────────────────────────────────────────────────
|
|
213
|
-
// Batch Operations
|
|
214
|
-
// ─────────────────────────────────────────────────────────────────
|
|
215
|
-
|
|
216
|
-
async createMany(
|
|
217
|
-
transactions: CreateAVITransactionInput[],
|
|
218
|
-
options?: { atomic?: true }
|
|
219
|
-
): Promise<AtomicBatchResult<MexAVITransaction>>;
|
|
220
|
-
async createMany(
|
|
221
|
-
transactions: CreateAVITransactionInput[],
|
|
222
|
-
options: { atomic: false }
|
|
223
|
-
): Promise<PartialBatchResult<MexAVITransaction>>;
|
|
224
|
-
async createMany(
|
|
225
|
-
transactions: CreateAVITransactionInput[],
|
|
226
|
-
options: BatchOptions = {}
|
|
227
|
-
): Promise<
|
|
228
|
-
AtomicBatchResult<MexAVITransaction> | PartialBatchResult<MexAVITransaction>
|
|
229
|
-
> {
|
|
230
|
-
const atomic = options.atomic ?? true;
|
|
231
|
-
const validated = this.validate(
|
|
232
|
-
z.array(createAVITransactionInputSchema),
|
|
233
|
-
transactions
|
|
234
|
-
);
|
|
235
|
-
const nestedItems = validated.map((t) => this.transformToNested(t));
|
|
236
|
-
|
|
237
|
-
const response = await this.execute(() =>
|
|
238
|
-
this.trpc.transactions.createMany.mutate({ items: nestedItems, atomic })
|
|
239
|
-
);
|
|
240
|
-
|
|
241
|
-
if (response.atomic) {
|
|
242
|
-
return {
|
|
243
|
-
atomic: true,
|
|
244
|
-
data: response.data.map((t) => this.instantiate(t)),
|
|
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
|
-
async updateMany(
|
|
259
|
-
updates: { id: string; data: UpdateAVITransactionInput }[],
|
|
260
|
-
options?: { atomic?: true }
|
|
261
|
-
): Promise<AtomicBatchResult<MexAVITransaction>>;
|
|
262
|
-
async updateMany(
|
|
263
|
-
updates: { id: string; data: UpdateAVITransactionInput }[],
|
|
264
|
-
options: { atomic: false }
|
|
265
|
-
): Promise<PartialBatchResult<MexAVITransaction>>;
|
|
266
|
-
async updateMany(
|
|
267
|
-
updates: { id: string; data: UpdateAVITransactionInput }[],
|
|
268
|
-
options: BatchOptions = {}
|
|
269
|
-
): Promise<
|
|
270
|
-
AtomicBatchResult<MexAVITransaction> | PartialBatchResult<MexAVITransaction>
|
|
271
|
-
> {
|
|
272
|
-
const atomic = options.atomic ?? true;
|
|
273
|
-
const updateItemSchema = z.object({
|
|
274
|
-
id: z.uuid(),
|
|
275
|
-
data: updateAVITransactionInputSchema,
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
const validated = this.validate(z.array(updateItemSchema), updates);
|
|
279
|
-
const nestedUpdates = validated.map((u) => ({
|
|
280
|
-
id: u.id,
|
|
281
|
-
data: this.transformUpdateToNested(u.data),
|
|
282
|
-
}));
|
|
283
|
-
|
|
284
|
-
const response = await this.execute(() =>
|
|
285
|
-
this.trpc.transactions.updateMany.mutate({ items: nestedUpdates, atomic })
|
|
286
|
-
);
|
|
287
|
-
|
|
288
|
-
if (response.atomic) {
|
|
289
|
-
return {
|
|
290
|
-
atomic: true,
|
|
291
|
-
data: response.data.map((t) => this.instantiate(t)),
|
|
292
|
-
};
|
|
293
|
-
} else {
|
|
294
|
-
return {
|
|
295
|
-
atomic: false,
|
|
296
|
-
succeeded: response.succeeded.map((item) => ({
|
|
297
|
-
index: item.index,
|
|
298
|
-
data: this.instantiate(item.data),
|
|
299
|
-
})),
|
|
300
|
-
failed: response.failed,
|
|
301
|
-
};
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
// ─────────────────────────────────────────────────────────────────
|
|
306
|
-
// Protected Helpers
|
|
307
|
-
// ─────────────────────────────────────────────────────────────────
|
|
308
|
-
|
|
309
|
-
/**
|
|
310
|
-
* Transforms a flattened AVITransactionSort to nested TransactionSort format.
|
|
311
|
-
*
|
|
312
|
-
* Maps flattened field names to their full API paths.
|
|
313
|
-
*/
|
|
314
|
-
protected override applyScopeToSort(sort?: AVITransactionSort): TransactionSort | undefined {
|
|
315
|
-
if (!sort || sort.length === 0) {
|
|
316
|
-
return undefined;
|
|
317
|
-
}
|
|
318
|
-
return transformSort(sort, aviTransactionFieldMapping);
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
protected override transformToNested(
|
|
322
|
-
data: CreateAVITransactionInput
|
|
323
|
-
): CreateTransactionInput {
|
|
324
|
-
// Extract AVI-specific fields based on operation type
|
|
325
|
-
const {
|
|
326
|
-
amount,
|
|
327
|
-
currency,
|
|
328
|
-
timestamp,
|
|
329
|
-
relatedClientIds,
|
|
330
|
-
description,
|
|
331
|
-
externalId,
|
|
332
|
-
metadata,
|
|
333
|
-
...aviFields
|
|
334
|
-
} = data as Record<string, unknown>;
|
|
335
|
-
|
|
336
|
-
// Build base fields (relatedClientIds is required)
|
|
337
|
-
const baseFields: Record<string, unknown> = {
|
|
338
|
-
amount,
|
|
339
|
-
currency,
|
|
340
|
-
timestamp,
|
|
341
|
-
relatedClientIds,
|
|
342
|
-
};
|
|
343
|
-
if (description !== undefined) baseFields.description = description;
|
|
344
|
-
if (externalId !== undefined) baseFields.externalId = externalId;
|
|
345
|
-
if (metadata !== undefined) baseFields.metadata = metadata;
|
|
346
|
-
|
|
347
|
-
return {
|
|
348
|
-
...baseFields,
|
|
349
|
-
primaryJurisdiction: Jurisdiction.Mexico,
|
|
350
|
-
jurisdictions: {
|
|
351
|
-
MX: {
|
|
352
|
-
actividadVulnerable: {
|
|
353
|
-
[CodigoActividad.AVI]: aviFields,
|
|
354
|
-
},
|
|
355
|
-
},
|
|
356
|
-
},
|
|
357
|
-
} as CreateTransactionInput;
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
protected override transformUpdateToNested(
|
|
361
|
-
data: UpdateAVITransactionInput
|
|
362
|
-
): UpdateTransactionInput {
|
|
363
|
-
// Cast to access fields - Zod validation ensures correctness
|
|
364
|
-
const input = data as Record<string, unknown>;
|
|
365
|
-
const {
|
|
366
|
-
status,
|
|
367
|
-
description,
|
|
368
|
-
externalId,
|
|
369
|
-
metadata,
|
|
370
|
-
primaryJurisdiction,
|
|
371
|
-
...aviFields
|
|
372
|
-
} = input;
|
|
373
|
-
|
|
374
|
-
// Build base update fields
|
|
375
|
-
const result: UpdateTransactionInput = {};
|
|
376
|
-
if (status !== undefined)
|
|
377
|
-
result.status = status as UpdateTransactionInput["status"];
|
|
378
|
-
if (description !== undefined) result.description = description as string;
|
|
379
|
-
if (externalId !== undefined) result.externalId = externalId as string;
|
|
380
|
-
if (metadata !== undefined)
|
|
381
|
-
result.metadata = metadata as Record<string, unknown>;
|
|
382
|
-
if (primaryJurisdiction !== undefined)
|
|
383
|
-
result.primaryJurisdiction =
|
|
384
|
-
primaryJurisdiction as UpdateTransactionInput["primaryJurisdiction"];
|
|
385
|
-
|
|
386
|
-
// If AVI fields are present (all-or-nothing), nest them in jurisdictions
|
|
387
|
-
// Check for operationType as the indicator that AVI data is being updated
|
|
388
|
-
if (aviFields.operationType !== undefined) {
|
|
389
|
-
(result as Record<string, unknown>).jurisdictions = {
|
|
390
|
-
MX: {
|
|
391
|
-
actividadVulnerable: {
|
|
392
|
-
[CodigoActividad.AVI]: aviFields,
|
|
393
|
-
},
|
|
394
|
-
},
|
|
395
|
-
};
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
return result;
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
protected override instantiate(data: TransactionData): MexAVITransaction {
|
|
402
|
-
return new MexAVITransaction(data);
|
|
403
|
-
}
|
|
404
|
-
}
|