@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,643 +0,0 @@
1
- /**
2
- * Mexico Reports Resource
3
- *
4
- * Extends ReportsResource with Mexico-specific behavior:
5
- * - Accepts flattened CreateMexReportInput (MX fields at root level)
6
- * - Filters list/iterate to Mexico reports only
7
- * - Returns MexReport models
8
- */
9
-
10
- import { z } from "zod";
11
- import type {
12
- CreateReportInput,
13
- UpdateReportInput,
14
- CreateReportItemInput,
15
- UpdateReportItemInput,
16
- CreateMexReportInput,
17
- UpdateMexReportInput,
18
- CreateMexReportItemInput,
19
- UpdateMexReportItemInput,
20
- ListOptions,
21
- PaginatedResponse,
22
- AtomicBatchResult,
23
- PartialBatchResult,
24
- MexSubmitReportInput,
25
- ValidationResult,
26
- GenerateResult,
27
- SubmissionResult,
28
- MexReportDefaultsInput,
29
- ReportDefaultsInput,
30
- } from "@artu-ai/shared";
31
- import {
32
- Jurisdiction,
33
- createMexReportInputSchema,
34
- updateMexReportInputSchema,
35
- createMexReportItemInputSchema,
36
- updateMexReportItemInputSchema,
37
- mexSubmitReportInputSchema,
38
- transformSort,
39
- mexReportFieldMapping,
40
- mexReportDefaultsInputSchema,
41
- } from "@artu-ai/shared";
42
- import type {
43
- ReportFilter,
44
- ReportSort,
45
- MexReportFilter,
46
- MexReportSort,
47
- } from "@artu-ai/shared";
48
- import {
49
- ReportsResource,
50
- type ReportItemFilter,
51
- type ReportItemSort,
52
- } from "../reports";
53
- import { type BatchOptions } from "../clients";
54
- import { MexReport, type ReportData, type ReportItemData } from "../../models";
55
- import { MexReportItem } from "../../models/mex";
56
-
57
- // ===========================
58
- // MexReportsResource
59
- // ===========================
60
-
61
- /**
62
- * Mexico-scoped reports resource.
63
- *
64
- * Provides the same operations as ReportsResource but with:
65
- * - Flattened input types (MX fields at root level)
66
- * - Automatic jurisdiction scoping
67
- * - MexReport model return type
68
- *
69
- * @example
70
- * ```typescript
71
- * const mexSdk = new ComplianceSDK({
72
- * apiKey,
73
- * environment: "test",
74
- * jurisdiction: Jurisdiction.Mexico,
75
- * });
76
- *
77
- * // Create with flattened input
78
- * const report = await mexSdk.reports.create({
79
- * actividadVulnerable: {
80
- * AVI: { mesReportado: "202401" },
81
- * },
82
- * });
83
- *
84
- * // List returns only Mexico reports
85
- * const { data } = await mexSdk.reports.list();
86
- * // data is MexReport[]
87
- * ```
88
- */
89
- export class MexReportsResource<
90
- TSort = MexReportSort,
91
- TDefaults = MexReportDefaultsInput,
92
- > extends ReportsResource<TSort, TDefaults> {
93
- // ─────────────────────────────────────────────────────────────────
94
- // Report CRUD (override with flattened input types)
95
- // ─────────────────────────────────────────────────────────────────
96
-
97
- /**
98
- * Creates a new Mexico report with flattened input.
99
- */
100
- async create(data: CreateMexReportInput): Promise<MexReport> {
101
- const validated = this.validate(createMexReportInputSchema, data);
102
- const nestedData = this.transformToNested(validated);
103
-
104
- const response = await this.execute(() =>
105
- this.trpc.reports.create.mutate(nestedData)
106
- );
107
-
108
- return this.instantiate(response);
109
- }
110
-
111
- /**
112
- * Retrieves a report by ID.
113
- */
114
- async retrieve(id: string): Promise<MexReport> {
115
- const response = await this.execute(() =>
116
- this.trpc.reports.retrieve.query({ id })
117
- );
118
- return this.instantiate(response);
119
- }
120
-
121
- async retrieveByMetadata(key: string, value: string): Promise<MexReport> {
122
- const response = await this.execute(() =>
123
- this.trpc.reports.retrieveByMetadata.query({ key, value })
124
- );
125
- return this.instantiate(response);
126
- }
127
-
128
- async retrieveByExternalId(externalId: string): Promise<MexReport> {
129
- const response = await this.execute(() =>
130
- this.trpc.reports.retrieveByExternalId.query({ externalId })
131
- );
132
- return this.instantiate(response);
133
- }
134
-
135
- /**
136
- * Updates a Mexico report with flattened input.
137
- */
138
- async update(id: string, data: UpdateMexReportInput): Promise<MexReport> {
139
- const validated = this.validate(updateMexReportInputSchema, data);
140
- const nestedData = this.transformUpdateToNested(validated);
141
-
142
- const response = await this.execute(() =>
143
- this.trpc.reports.update.mutate({ id, data: nestedData })
144
- );
145
- return this.instantiate(response);
146
- }
147
-
148
- // ─────────────────────────────────────────────────────────────────
149
- // List & Pagination (scoped to Mexico)
150
- // ─────────────────────────────────────────────────────────────────
151
-
152
- /**
153
- * Lists Mexico reports with optional filtering.
154
- *
155
- * Accepts flattened MX filter (future MX-specific report fields at root level).
156
- * Automatically filters to reports with Mexico jurisdiction data.
157
- */
158
- async list(
159
- options?: ListOptions<MexReportFilter, TSort>
160
- ): Promise<PaginatedResponse<MexReport>> {
161
- const scopedFilter = this.applyScopeToFilter(options?.filter);
162
- const scopedSort = this.applyScopeToSort(options?.sort);
163
-
164
- const response = await this.execute(() =>
165
- this.trpc.reports.list.query({
166
- ...options,
167
- filter: scopedFilter,
168
- sort: scopedSort,
169
- })
170
- );
171
-
172
- return {
173
- data: response.data.map((r) => this.instantiate(r)),
174
- pagination: response.pagination,
175
- };
176
- }
177
-
178
- /**
179
- * Iterates over Mexico reports.
180
- *
181
- * Accepts flattened MX filter (future MX-specific report fields at root level).
182
- * Automatically filters to reports with Mexico jurisdiction data.
183
- */
184
- iterate(
185
- filter?: MexReportFilter
186
- ): AsyncGenerator<MexReport, void, undefined> {
187
- const scopedFilter = this.applyScopeToFilter(filter);
188
- return this.createIterator<MexReport>({ filter: scopedFilter });
189
- }
190
-
191
- // ─────────────────────────────────────────────────────────────────
192
- // Batch Operations
193
- // ─────────────────────────────────────────────────────────────────
194
-
195
- async createMany(
196
- reports: CreateMexReportInput[],
197
- options?: { atomic?: true }
198
- ): Promise<AtomicBatchResult<MexReport>>;
199
- async createMany(
200
- reports: CreateMexReportInput[],
201
- options: { atomic: false }
202
- ): Promise<PartialBatchResult<MexReport>>;
203
- async createMany(
204
- reports: CreateMexReportInput[],
205
- options: BatchOptions = {}
206
- ): Promise<AtomicBatchResult<MexReport> | PartialBatchResult<MexReport>> {
207
- const atomic = options.atomic ?? true;
208
- const validated = this.validate(
209
- z.array(createMexReportInputSchema),
210
- reports
211
- );
212
- const nestedItems = validated.map((r) => this.transformToNested(r));
213
-
214
- const response = await this.execute(() =>
215
- this.trpc.reports.createMany.mutate({ items: nestedItems, atomic })
216
- );
217
-
218
- if (response.atomic) {
219
- return {
220
- atomic: true,
221
- data: response.data.map((r) => this.instantiate(r)),
222
- };
223
- } else {
224
- return {
225
- atomic: false,
226
- succeeded: response.succeeded.map((item) => ({
227
- index: item.index,
228
- data: this.instantiate(item.data),
229
- })),
230
- failed: response.failed,
231
- };
232
- }
233
- }
234
-
235
- async updateMany(
236
- updates: { id: string; data: UpdateMexReportInput }[],
237
- options?: { atomic?: true }
238
- ): Promise<AtomicBatchResult<MexReport>>;
239
- async updateMany(
240
- updates: { id: string; data: UpdateMexReportInput }[],
241
- options: { atomic: false }
242
- ): Promise<PartialBatchResult<MexReport>>;
243
- async updateMany(
244
- updates: { id: string; data: UpdateMexReportInput }[],
245
- options: BatchOptions = {}
246
- ): Promise<AtomicBatchResult<MexReport> | PartialBatchResult<MexReport>> {
247
- const atomic = options.atomic ?? true;
248
- const updateItemSchema = z.object({
249
- id: z.uuid(),
250
- data: updateMexReportInputSchema,
251
- });
252
-
253
- const validated = this.validate(z.array(updateItemSchema), updates);
254
- const nestedUpdates = validated.map((u) => ({
255
- id: u.id,
256
- data: this.transformUpdateToNested(u.data),
257
- }));
258
-
259
- const response = await this.execute(() =>
260
- this.trpc.reports.updateMany.mutate({ items: nestedUpdates, atomic })
261
- );
262
-
263
- if (response.atomic) {
264
- return {
265
- atomic: true,
266
- data: response.data.map((r) => this.instantiate(r)),
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
- // Report Items
282
- // ─────────────────────────────────────────────────────────────────
283
-
284
- /**
285
- * Adds an item to a report with flattened Mexico input.
286
- */
287
- async addItem(
288
- reportId: string,
289
- data: CreateMexReportItemInput
290
- ): Promise<MexReportItem> {
291
- const validated = this.validate(createMexReportItemInputSchema, data);
292
- const nestedData = this.transformItemToNested(validated);
293
-
294
- const response = await this.execute(() =>
295
- this.trpc.reports.addItem.mutate({ reportId, data: nestedData })
296
- );
297
-
298
- return this.instantiateItem(response);
299
- }
300
-
301
- /**
302
- * Gets a specific report item.
303
- */
304
- async getItem(reportId: string, itemId: string): Promise<MexReportItem> {
305
- const response = await this.execute(() =>
306
- this.trpc.reports.getItem.query({ reportId, itemId })
307
- );
308
- return this.instantiateItem(response);
309
- }
310
-
311
- /**
312
- * Updates a report item with flattened Mexico input.
313
- */
314
- async updateItem(
315
- reportId: string,
316
- itemId: string,
317
- data: UpdateMexReportItemInput
318
- ): Promise<MexReportItem> {
319
- const validated = this.validate(updateMexReportItemInputSchema, data);
320
- const nestedData = this.transformItemUpdateToNested(validated);
321
-
322
- const response = await this.execute(() =>
323
- this.trpc.reports.updateItem.mutate({
324
- reportId,
325
- itemId,
326
- data: nestedData,
327
- })
328
- );
329
- return this.instantiateItem(response);
330
- }
331
-
332
- /**
333
- * Lists items in a report with filtering, sorting, and pagination.
334
- */
335
- async listItems(
336
- reportId: string,
337
- options?: ListOptions<ReportItemFilter, ReportItemSort>
338
- ): Promise<PaginatedResponse<MexReportItem>> {
339
- const response = await this.execute(() =>
340
- this.trpc.reports.listItems.query({
341
- reportId,
342
- ...options,
343
- })
344
- );
345
-
346
- return {
347
- data: response.data.map((i) => this.instantiateItem(i)),
348
- pagination: response.pagination,
349
- };
350
- }
351
-
352
- /**
353
- * Adds multiple items to a report with flattened Mexico input.
354
- */
355
- async addItems(
356
- reportId: string,
357
- items: CreateMexReportItemInput[]
358
- ): Promise<{ added: number; items: MexReportItem[] }> {
359
- const validated = this.validate(
360
- z.array(createMexReportItemInputSchema),
361
- items
362
- );
363
- const nestedItems = validated.map((i) => this.transformItemToNested(i));
364
-
365
- const response = await this.execute(() =>
366
- this.trpc.reports.addItems.mutate({ reportId, items: nestedItems })
367
- );
368
-
369
- return {
370
- added: response.added,
371
- items: response.items.map((i) => this.instantiateItem(i)),
372
- };
373
- }
374
-
375
- // ─────────────────────────────────────────────────────────────────
376
- // Validation
377
- // ─────────────────────────────────────────────────────────────────
378
-
379
- /**
380
- * Validates a Mexico report.
381
- *
382
- * Uses Mexico-scoped validation input (jurisdiction is implicit).
383
- *
384
- * @param reportId - The report ID to validate
385
- * @param defaults - Mexico report defaults including activity-specific settings
386
- *
387
- * @example
388
- * ```typescript
389
- * const result = await mexSdk.reports.validateReport(report.id, {
390
- * actividadVulnerable: {
391
- * rfc: "ABC200101XXX",
392
- * AVI: {
393
- * platformDomain: "https://example.com",
394
- * alertType: "100",
395
- * },
396
- * },
397
- * });
398
- * ```
399
- */
400
- override async validateReport(
401
- reportId: string,
402
- defaults: TDefaults
403
- ): Promise<ValidationResult> {
404
- const validated = this.validate(
405
- mexReportDefaultsInputSchema,
406
- defaults as MexReportDefaultsInput
407
- );
408
- const nestedInput = this.transformValidateToNested(reportId, validated);
409
- return this.execute(() => this.trpc.reports.validate.mutate(nestedInput));
410
- }
411
-
412
- // ─────────────────────────────────────────────────────────────────
413
- // Generation
414
- // ─────────────────────────────────────────────────────────────────
415
-
416
- /**
417
- * Generates XML for a Mexico report.
418
- *
419
- * Uses the same input as validateReport since generation requires
420
- * the same transformation and defaults.
421
- *
422
- * @param reportId - The report ID to generate XML for
423
- * @param defaults - Mexico report defaults including activity-specific settings
424
- *
425
- * @example
426
- * ```typescript
427
- * const result = await mexSdk.reports.generateReport(report.id, {
428
- * actividadVulnerable: {
429
- * rfc: "ABC200101XXX",
430
- * AVI: {
431
- * platformDomain: "https://example.com",
432
- * alertType: "100",
433
- * },
434
- * },
435
- * });
436
- * console.log(result.xml);
437
- * ```
438
- */
439
- override async generateReport(
440
- reportId: string,
441
- defaults: TDefaults
442
- ): Promise<GenerateResult> {
443
- const validated = this.validate(
444
- mexReportDefaultsInputSchema,
445
- defaults as MexReportDefaultsInput
446
- );
447
- const nestedInput = this.transformValidateToNested(reportId, validated);
448
- return this.execute(() => this.trpc.reports.generate.mutate(nestedInput));
449
- }
450
-
451
- // ─────────────────────────────────────────────────────────────────
452
- // Submission
453
- // ─────────────────────────────────────────────────────────────────
454
-
455
- /**
456
- * Submits a validated Mexico report.
457
- *
458
- * The report must be in "valid" status. After submission, the report
459
- * is locked and cannot be edited (except rejected reports which can
460
- * be edited and resubmitted).
461
- *
462
- * @param reportId - The report ID
463
- * @param actividadVulnerable - The activity type (AVI, JYS, or TSC)
464
- * @param data - Optional submission data (acuseRecibo, notes)
465
- *
466
- * @example
467
- * ```typescript
468
- * const result = await mexSdk.reports.submitReport(
469
- * report.id,
470
- * "AVI",
471
- * { acuseRecibo: "SAT-12345", notes: "Submitted via portal" }
472
- * );
473
- * ```
474
- */
475
- async submit(input: MexSubmitReportInput): Promise<SubmissionResult> {
476
- const validated = this.validate(mexSubmitReportInputSchema, input);
477
-
478
- const jurisdictions = {
479
- MX: {
480
- actividadVulnerable: validated.actividadVulnerable,
481
- },
482
- };
483
-
484
- return this.execute(() =>
485
- this.trpc.reports.submit.mutate({
486
- reportId: validated.reportId,
487
- jurisdictions,
488
- })
489
- );
490
- }
491
-
492
- // ─────────────────────────────────────────────────────────────────
493
- // Protected Helpers
494
- // ─────────────────────────────────────────────────────────────────
495
-
496
- /**
497
- * Applies Mexico jurisdiction filter.
498
- *
499
- * Currently MexReportFilter has the same fields as the base filter,
500
- * but this method ensures the jurisdiction scope is applied.
501
- * Uses `availableJurisdictions` to find any report that includes Mexico.
502
- */
503
- protected applyScopeToFilter(filter?: MexReportFilter): ReportFilter {
504
- if (!filter) {
505
- return {
506
- availableJurisdictions: Jurisdiction.Mexico,
507
- };
508
- }
509
-
510
- // Currently no MX-specific report filter fields to nest
511
- // Just pass through and add jurisdiction scope
512
- return {
513
- ...filter,
514
- availableJurisdictions: Jurisdiction.Mexico,
515
- } as ReportFilter;
516
- }
517
-
518
- /**
519
- * Transforms a flattened MexReportSort to nested ReportSort format.
520
- *
521
- * Maps flattened field names to their full API paths.
522
- *
523
- * Note: Uses unknown parameter to allow derived classes to override with their own sort types.
524
- */
525
- protected applyScopeToSort(sort?: TSort): ReportSort | undefined {
526
- if (!sort || !Array.isArray(sort) || sort.length === 0) {
527
- return undefined;
528
- }
529
- return transformSort(sort as MexReportSort, mexReportFieldMapping);
530
- }
531
-
532
- /**
533
- * Transforms flattened MX input to nested API format.
534
- */
535
- protected transformToNested(data: CreateMexReportInput): CreateReportInput {
536
- const { actividadVulnerable, ...baseFields } = data;
537
-
538
- // Build MX jurisdiction data
539
- const mexData: Record<string, unknown> = {};
540
- if (actividadVulnerable !== undefined) {
541
- mexData.actividadVulnerable = actividadVulnerable;
542
- }
543
-
544
- return {
545
- ...baseFields,
546
- jurisdictions:
547
- Object.keys(mexData).length > 0
548
- ? {
549
- MX: mexData,
550
- }
551
- : undefined,
552
- } as CreateReportInput;
553
- }
554
-
555
- /**
556
- * Transforms flattened MX update input to nested API format.
557
- */
558
- protected transformUpdateToNested(
559
- data: UpdateMexReportInput
560
- ): UpdateReportInput {
561
- const { actividadVulnerable, ...baseFields } = data;
562
-
563
- if (actividadVulnerable === undefined) {
564
- return baseFields as UpdateReportInput;
565
- }
566
-
567
- return {
568
- ...baseFields,
569
- jurisdictions: {
570
- MX: { actividadVulnerable },
571
- },
572
- } as UpdateReportInput;
573
- }
574
-
575
- /**
576
- * Instantiates a MexReport model.
577
- */
578
- protected override instantiate(data: ReportData): MexReport {
579
- return new MexReport(data);
580
- }
581
-
582
- /**
583
- * Instantiates a MexReportItem model.
584
- */
585
- protected override instantiateItem(data: ReportItemData): MexReportItem {
586
- return new MexReportItem(data);
587
- }
588
-
589
- /**
590
- * Transforms flattened MX report item input to nested API format.
591
- */
592
- protected transformItemToNested(
593
- data: CreateMexReportItemInput
594
- ): CreateReportItemInput {
595
- const { actividadVulnerable, ...baseFields } = data;
596
-
597
- if (actividadVulnerable === undefined) {
598
- return baseFields as CreateReportItemInput;
599
- }
600
-
601
- return {
602
- ...baseFields,
603
- jurisdictions: {
604
- MX: { actividadVulnerable },
605
- },
606
- } as CreateReportItemInput;
607
- }
608
-
609
- /**
610
- * Transforms flattened MX report item update input to nested API format.
611
- */
612
- protected transformItemUpdateToNested(
613
- data: UpdateMexReportItemInput
614
- ): UpdateReportItemInput {
615
- const { actividadVulnerable, ...baseFields } = data;
616
-
617
- if (actividadVulnerable === undefined) {
618
- return baseFields as UpdateReportItemInput;
619
- }
620
-
621
- return {
622
- ...baseFields,
623
- jurisdictions: {
624
- MX: { actividadVulnerable },
625
- },
626
- } as UpdateReportItemInput;
627
- }
628
-
629
- /**
630
- * Transforms flattened MX validate/generate input to nested API format.
631
- */
632
- protected transformValidateToNested(
633
- reportId: string,
634
- defaults: MexReportDefaultsInput
635
- ): { reportId: string } & ReportDefaultsInput {
636
- return {
637
- reportId,
638
- jurisdictions: {
639
- MX: defaults,
640
- },
641
- };
642
- }
643
- }