@artu-ai/compliance-sdk 0.2.0 → 0.3.0

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 (155) hide show
  1. package/dist/models/Client.d.ts.map +1 -1
  2. package/dist/models/Client.js +21 -3
  3. package/dist/models/ReportItem.d.ts +2 -2
  4. package/dist/models/ReportItem.d.ts.map +1 -1
  5. package/dist/models/ReportItem.js +4 -4
  6. package/dist/models/mex/MexReportItem.js +1 -1
  7. package/dist/models/mex/actividad-vulnerable/MexActividadVulnerableReportItem.js +1 -1
  8. package/dist/models/mex/actividad-vulnerable/avi/MexAVIReportItem.js +1 -1
  9. package/dist/models/mex/actividad-vulnerable/jys/MexJYSReportItem.js +1 -1
  10. package/dist/models/mex/actividad-vulnerable/tsc/MexTSCReportItem.js +1 -1
  11. package/dist/resources/addresses.d.ts +3 -3
  12. package/dist/resources/addresses.d.ts.map +1 -1
  13. package/dist/resources/bank-accounts.d.ts +3 -3
  14. package/dist/resources/bank-accounts.d.ts.map +1 -1
  15. package/dist/resources/base.d.ts +7 -6
  16. package/dist/resources/base.d.ts.map +1 -1
  17. package/dist/resources/base.js +3 -0
  18. package/dist/resources/clients.d.ts +3 -3
  19. package/dist/resources/clients.d.ts.map +1 -1
  20. package/dist/resources/contact-methods.d.ts +3 -3
  21. package/dist/resources/contact-methods.d.ts.map +1 -1
  22. package/dist/resources/documents.d.ts +94 -7
  23. package/dist/resources/documents.d.ts.map +1 -1
  24. package/dist/resources/documents.js +107 -0
  25. package/dist/resources/index.d.ts +1 -1
  26. package/dist/resources/index.d.ts.map +1 -1
  27. package/dist/resources/index.js +1 -1
  28. package/dist/resources/mex/actividad-vulnerable/avi/clients.d.ts +9 -3
  29. package/dist/resources/mex/actividad-vulnerable/avi/clients.d.ts.map +1 -1
  30. package/dist/resources/mex/actividad-vulnerable/avi/clients.js +14 -1
  31. package/dist/resources/mex/actividad-vulnerable/avi/reports.d.ts +39 -21
  32. package/dist/resources/mex/actividad-vulnerable/avi/reports.d.ts.map +1 -1
  33. package/dist/resources/mex/actividad-vulnerable/avi/reports.js +88 -20
  34. package/dist/resources/mex/actividad-vulnerable/avi/transactions.d.ts +9 -3
  35. package/dist/resources/mex/actividad-vulnerable/avi/transactions.d.ts.map +1 -1
  36. package/dist/resources/mex/actividad-vulnerable/avi/transactions.js +14 -1
  37. package/dist/resources/mex/actividad-vulnerable/jys/clients.d.ts +10 -3
  38. package/dist/resources/mex/actividad-vulnerable/jys/clients.d.ts.map +1 -1
  39. package/dist/resources/mex/actividad-vulnerable/jys/clients.js +14 -1
  40. package/dist/resources/mex/actividad-vulnerable/jys/reports.d.ts +33 -11
  41. package/dist/resources/mex/actividad-vulnerable/jys/reports.d.ts.map +1 -1
  42. package/dist/resources/mex/actividad-vulnerable/jys/reports.js +82 -10
  43. package/dist/resources/mex/actividad-vulnerable/jys/transactions.d.ts +10 -3
  44. package/dist/resources/mex/actividad-vulnerable/jys/transactions.d.ts.map +1 -1
  45. package/dist/resources/mex/actividad-vulnerable/jys/transactions.js +14 -1
  46. package/dist/resources/mex/actividad-vulnerable/tsc/clients.d.ts +10 -3
  47. package/dist/resources/mex/actividad-vulnerable/tsc/clients.d.ts.map +1 -1
  48. package/dist/resources/mex/actividad-vulnerable/tsc/clients.js +14 -1
  49. package/dist/resources/mex/actividad-vulnerable/tsc/reports.d.ts +33 -11
  50. package/dist/resources/mex/actividad-vulnerable/tsc/reports.d.ts.map +1 -1
  51. package/dist/resources/mex/actividad-vulnerable/tsc/reports.js +82 -10
  52. package/dist/resources/mex/actividad-vulnerable/tsc/transactions.d.ts +10 -3
  53. package/dist/resources/mex/actividad-vulnerable/tsc/transactions.d.ts.map +1 -1
  54. package/dist/resources/mex/actividad-vulnerable/tsc/transactions.js +14 -1
  55. package/dist/resources/mex/addresses.d.ts +11 -3
  56. package/dist/resources/mex/addresses.d.ts.map +1 -1
  57. package/dist/resources/mex/addresses.js +16 -1
  58. package/dist/resources/mex/bank-accounts.d.ts +11 -3
  59. package/dist/resources/mex/bank-accounts.d.ts.map +1 -1
  60. package/dist/resources/mex/bank-accounts.js +16 -0
  61. package/dist/resources/mex/clients.d.ts +12 -3
  62. package/dist/resources/mex/clients.d.ts.map +1 -1
  63. package/dist/resources/mex/clients.js +17 -1
  64. package/dist/resources/mex/reports.d.ts +41 -19
  65. package/dist/resources/mex/reports.d.ts.map +1 -1
  66. package/dist/resources/mex/reports.js +55 -19
  67. package/dist/resources/mex/transactions.d.ts +11 -3
  68. package/dist/resources/mex/transactions.d.ts.map +1 -1
  69. package/dist/resources/mex/transactions.js +16 -1
  70. package/dist/resources/reports.d.ts +33 -39
  71. package/dist/resources/reports.d.ts.map +1 -1
  72. package/dist/resources/reports.js +34 -36
  73. package/dist/resources/transactions.d.ts +3 -3
  74. package/dist/resources/transactions.d.ts.map +1 -1
  75. package/dist/sdk/ComplianceSDK.d.ts +2 -0
  76. package/dist/sdk/ComplianceSDK.d.ts.map +1 -1
  77. package/dist/sdk/ComplianceSDK.js +17 -9
  78. package/dist/sdk/mex/ComplianceSDK.d.ts.map +1 -1
  79. package/dist/sdk/mex/actividad-vulnerable/avi/ComplianceSDK.d.ts.map +1 -1
  80. package/dist/sdk/mex/actividad-vulnerable/avi/types.d.ts +2 -2
  81. package/dist/sdk/mex/actividad-vulnerable/avi/types.d.ts.map +1 -1
  82. package/dist/sdk/mex/actividad-vulnerable/avi/types.js +1 -0
  83. package/dist/sdk/mex/actividad-vulnerable/jys/ComplianceSDK.d.ts.map +1 -1
  84. package/dist/sdk/mex/actividad-vulnerable/jys/types.d.ts +2 -2
  85. package/dist/sdk/mex/actividad-vulnerable/jys/types.d.ts.map +1 -1
  86. package/dist/sdk/mex/actividad-vulnerable/jys/types.js +1 -0
  87. package/dist/sdk/mex/actividad-vulnerable/tsc/ComplianceSDK.d.ts.map +1 -1
  88. package/dist/sdk/mex/actividad-vulnerable/tsc/types.d.ts +2 -2
  89. package/dist/sdk/mex/actividad-vulnerable/tsc/types.d.ts.map +1 -1
  90. package/dist/sdk/mex/actividad-vulnerable/tsc/types.js +1 -0
  91. package/dist/sdk/mex/types.d.ts +2 -2
  92. package/dist/sdk/mex/types.d.ts.map +1 -1
  93. package/dist/sdk/types.d.ts +24 -1
  94. package/dist/sdk/types.d.ts.map +1 -1
  95. package/dist/utils/environment.d.ts +24 -0
  96. package/dist/utils/environment.d.ts.map +1 -1
  97. package/dist/utils/environment.js +38 -0
  98. package/dist/utils/index.d.ts +2 -0
  99. package/dist/utils/index.d.ts.map +1 -1
  100. package/dist/utils/index.js +4 -0
  101. package/dist/utils/session.d.ts +20 -2
  102. package/dist/utils/session.d.ts.map +1 -1
  103. package/dist/utils/session.js +9 -1
  104. package/dist/utils/trpc-client.d.ts +370 -200
  105. package/dist/utils/trpc-client.d.ts.map +1 -1
  106. package/dist/utils/trpc-client.js +2 -1
  107. package/dist/utils/upload.d.ts +81 -0
  108. package/dist/utils/upload.d.ts.map +1 -0
  109. package/dist/utils/upload.js +261 -0
  110. package/package.json +9 -8
  111. package/src/models/Client.ts +23 -3
  112. package/src/models/ReportItem.ts +4 -4
  113. package/src/models/mex/MexReportItem.ts +1 -1
  114. package/src/models/mex/actividad-vulnerable/MexActividadVulnerableReportItem.ts +1 -1
  115. package/src/models/mex/actividad-vulnerable/avi/MexAVIReportItem.ts +1 -1
  116. package/src/models/mex/actividad-vulnerable/jys/MexJYSReportItem.ts +1 -1
  117. package/src/models/mex/actividad-vulnerable/tsc/MexTSCReportItem.ts +1 -1
  118. package/src/resources/addresses.ts +8 -4
  119. package/src/resources/bank-accounts.ts +8 -4
  120. package/src/resources/base.ts +9 -4
  121. package/src/resources/clients.ts +10 -4
  122. package/src/resources/contact-methods.ts +4 -2
  123. package/src/resources/documents.ts +185 -5
  124. package/src/resources/index.ts +6 -1
  125. package/src/resources/mex/actividad-vulnerable/avi/clients.ts +30 -8
  126. package/src/resources/mex/actividad-vulnerable/avi/reports.ts +122 -26
  127. package/src/resources/mex/actividad-vulnerable/avi/transactions.ts +20 -2
  128. package/src/resources/mex/actividad-vulnerable/jys/clients.ts +20 -2
  129. package/src/resources/mex/actividad-vulnerable/jys/reports.ts +118 -16
  130. package/src/resources/mex/actividad-vulnerable/jys/transactions.ts +20 -2
  131. package/src/resources/mex/actividad-vulnerable/tsc/clients.ts +20 -2
  132. package/src/resources/mex/actividad-vulnerable/tsc/reports.ts +118 -16
  133. package/src/resources/mex/actividad-vulnerable/tsc/transactions.ts +20 -2
  134. package/src/resources/mex/addresses.ts +24 -2
  135. package/src/resources/mex/bank-accounts.ts +26 -2
  136. package/src/resources/mex/clients.ts +25 -2
  137. package/src/resources/mex/reports.ts +94 -26
  138. package/src/resources/mex/transactions.ts +24 -2
  139. package/src/resources/reports.ts +65 -43
  140. package/src/resources/transactions.ts +8 -4
  141. package/src/sdk/ComplianceSDK.ts +23 -8
  142. package/src/sdk/mex/ComplianceSDK.ts +7 -0
  143. package/src/sdk/mex/actividad-vulnerable/avi/ComplianceSDK.ts +4 -0
  144. package/src/sdk/mex/actividad-vulnerable/avi/types.ts +22 -8
  145. package/src/sdk/mex/actividad-vulnerable/jys/ComplianceSDK.ts +3 -0
  146. package/src/sdk/mex/actividad-vulnerable/jys/types.ts +22 -8
  147. package/src/sdk/mex/actividad-vulnerable/tsc/ComplianceSDK.ts +3 -0
  148. package/src/sdk/mex/actividad-vulnerable/tsc/types.ts +22 -8
  149. package/src/sdk/mex/types.ts +6 -2
  150. package/src/sdk/types.ts +31 -2
  151. package/src/utils/environment.ts +42 -0
  152. package/src/utils/index.ts +19 -0
  153. package/src/utils/session.ts +33 -3
  154. package/src/utils/trpc-client.ts +10 -1
  155. package/src/utils/upload.ts +388 -0
@@ -23,7 +23,7 @@ import type {
23
23
  ValidationResult,
24
24
  GenerateResult,
25
25
  SubmissionResult,
26
- MexAVIValidateInput,
26
+ AviReportDefaultsInput,
27
27
  SubmitAVIReportInput,
28
28
  } from "@artu-ai/shared";
29
29
  import {
@@ -32,12 +32,20 @@ import {
32
32
  updateAVIReportInputSchema,
33
33
  createAVIReportItemInputSchema,
34
34
  updateAVIReportItemInputSchema,
35
- mexAviValidateInputSchema,
35
+ aviDefaultsInputSchema,
36
36
  submitAVIReportInputSchema,
37
+ transformSort,
38
+ aviReportFieldMapping,
39
+ } from "@artu-ai/shared";
40
+ import type {
41
+ AVIReportFilter,
42
+ AVIReportSort,
43
+ AVIReportItemFilter,
44
+ ReportSort,
45
+ ReportItemFilter,
46
+ ReportItemSort,
37
47
  } from "@artu-ai/shared";
38
- import type { AVIReportFilter } from "@artu-ai/shared";
39
48
  import { MexReportsResource } from "../../reports";
40
- import { type ReportItemFilter } from "../../../reports";
41
49
  import { type BatchOptions } from "../../../clients";
42
50
  import {
43
51
  MexAVIReport,
@@ -70,7 +78,7 @@ import {
70
78
  * console.log(report.mesReportado);
71
79
  * ```
72
80
  */
73
- export class AVIReportsResource extends MexReportsResource {
81
+ export class AVIReportsResource extends MexReportsResource<AVIReportSort, AviReportDefaultsInput> {
74
82
  // ─────────────────────────────────────────────────────────────────
75
83
  // Report CRUD
76
84
  // ─────────────────────────────────────────────────────────────────
@@ -127,14 +135,16 @@ export class AVIReportsResource extends MexReportsResource {
127
135
  * Accepts flattened AVI filter (future AVI-specific report fields at root level).
128
136
  */
129
137
  async list(
130
- options?: ListOptions<AVIReportFilter>
138
+ options?: ListOptions<AVIReportFilter, AVIReportSort>
131
139
  ): Promise<PaginatedResponse<MexAVIReport>> {
132
140
  const scopedFilter = this.applyScopeToFilter(options?.filter);
141
+ const scopedSort = this.applyScopeToSort(options?.sort);
133
142
 
134
143
  const response = await this.execute(() =>
135
144
  this.trpc.reports.list.query({
136
145
  ...options,
137
146
  filter: scopedFilter,
147
+ sort: scopedSort,
138
148
  })
139
149
  );
140
150
 
@@ -294,12 +304,16 @@ export class AVIReportsResource extends MexReportsResource {
294
304
 
295
305
  async listItems(
296
306
  reportId: string,
297
- options?: ListOptions<ReportItemFilter>
307
+ options?: ListOptions<AVIReportItemFilter, ReportItemSort>
298
308
  ): Promise<PaginatedResponse<MexAVIReportItem>> {
309
+ // Transform flattened AVI filter to nested format
310
+ const scopedFilter = this.applyScopeToItemFilter(options?.filter);
311
+
299
312
  const response = await this.execute(() =>
300
313
  this.trpc.reports.listItems.query({
301
314
  reportId,
302
315
  ...options,
316
+ filter: scopedFilter,
303
317
  })
304
318
  );
305
319
 
@@ -309,6 +323,38 @@ export class AVIReportsResource extends MexReportsResource {
309
323
  };
310
324
  }
311
325
 
326
+ /**
327
+ * Transforms a flattened AVIReportItemFilter to nested ReportItemFilter format.
328
+ */
329
+ protected applyScopeToItemFilter(
330
+ filter?: AVIReportItemFilter
331
+ ): ReportItemFilter | undefined {
332
+ if (!filter) return undefined;
333
+
334
+ const { alertType, alertDescription, ...baseFields } = filter;
335
+
336
+ // If no AVI-specific fields, return base filter as-is
337
+ if (alertType === undefined && alertDescription === undefined) {
338
+ return baseFields as ReportItemFilter;
339
+ }
340
+
341
+ // Build nested filter structure
342
+ const aviFilter: Record<string, unknown> = {};
343
+ if (alertType !== undefined) aviFilter.alertType = alertType;
344
+ if (alertDescription !== undefined) aviFilter.alertDescription = alertDescription;
345
+
346
+ return {
347
+ ...baseFields,
348
+ jurisdictions: {
349
+ MX: {
350
+ actividadVulnerable: {
351
+ AVI: aviFilter,
352
+ },
353
+ },
354
+ },
355
+ } as ReportItemFilter;
356
+ }
357
+
312
358
  async addItems(
313
359
  reportId: string,
314
360
  items: CreateAVIReportItemInput[]
@@ -336,24 +382,29 @@ export class AVIReportsResource extends MexReportsResource {
336
382
  /**
337
383
  * Validates an AVI report.
338
384
  *
339
- * Uses AVI-scoped validation input (jurisdiction and activity default automatically).
385
+ * Uses AVI-scoped validation input (jurisdiction and activity are implicit).
386
+ *
387
+ * @param reportId - The report ID to validate
388
+ * @param defaults - AVI report defaults including rfc, platformDomain, alertType, etc.
340
389
  *
341
390
  * @example
342
391
  * ```typescript
343
- * const result = await aviSdk.reports.validateReport({
344
- * reportId: report.id,
345
- * defaults: {
346
- * rfc: "ABC200101XXX",
347
- * platformDomain: "https://example.com",
348
- * },
392
+ * const result = await aviSdk.reports.validateReport(report.id, {
393
+ * rfc: "ABC200101XXX",
394
+ * platformDomain: "https://example.com",
395
+ * alertType: "100",
349
396
  * });
350
397
  * ```
351
398
  */
352
399
  override async validateReport(
353
- input: MexAVIValidateInput
400
+ reportId: string,
401
+ defaults: AviReportDefaultsInput
354
402
  ): Promise<ValidationResult> {
355
- const validated = this.validate(mexAviValidateInputSchema, input);
356
- return this.execute(() => this.trpc.reports.validate.mutate(validated));
403
+ const validated = this.validate(aviDefaultsInputSchema, defaults);
404
+ const nestedInput = this.transformAviDefaultsToNested(reportId, validated);
405
+ return this.execute(() =>
406
+ this.trpc.reports.validate.mutate(nestedInput as Parameters<typeof this.trpc.reports.validate.mutate>[0])
407
+ );
357
408
  }
358
409
 
359
410
  // ─────────────────────────────────────────────────────────────────
@@ -365,23 +416,30 @@ export class AVIReportsResource extends MexReportsResource {
365
416
  *
366
417
  * Uses the same input as validateReport.
367
418
  *
419
+ * @param reportId - The report ID to generate XML for
420
+ * @param defaults - AVI report defaults including rfc, platformDomain, alertType, etc.
421
+ *
368
422
  * @example
369
423
  * ```typescript
370
- * const result = await aviSdk.reports.generateReport({
371
- * reportId: report.id,
372
- * defaults: {
373
- * rfc: "ABC200101XXX",
374
- * platformDomain: "https://example.com",
375
- * },
424
+ * const result = await aviSdk.reports.generateReport(report.id, {
425
+ * rfc: "ABC200101XXX",
426
+ * platformDomain: "https://example.com",
427
+ * alertType: "100",
376
428
  * });
377
429
  * console.log(result.xml);
378
430
  * ```
379
431
  */
380
432
  override async generateReport(
381
- input: MexAVIValidateInput
433
+ reportId: string,
434
+ defaults: AviReportDefaultsInput
382
435
  ): Promise<GenerateResult> {
383
- const validated = this.validate(mexAviValidateInputSchema, input);
384
- return this.execute(() => this.trpc.reports.generate.mutate(validated));
436
+ const validated = this.validate(aviDefaultsInputSchema, defaults);
437
+ const nestedInput = this.transformAviDefaultsToNested(reportId, validated);
438
+ return this.execute(() =>
439
+ this.trpc.reports.generate.mutate(
440
+ nestedInput as Parameters<typeof this.trpc.reports.generate.mutate>[0]
441
+ )
442
+ );
385
443
  }
386
444
 
387
445
  // ─────────────────────────────────────────────────────────────────
@@ -430,6 +488,18 @@ export class AVIReportsResource extends MexReportsResource {
430
488
  // Protected Helpers
431
489
  // ─────────────────────────────────────────────────────────────────
432
490
 
491
+ /**
492
+ * Transforms a flattened AVIReportSort to nested ReportSort format.
493
+ *
494
+ * Maps flattened field names to their full API paths.
495
+ */
496
+ protected override applyScopeToSort(sort?: AVIReportSort): ReportSort | undefined {
497
+ if (!sort || sort.length === 0) {
498
+ return undefined;
499
+ }
500
+ return transformSort(sort, aviReportFieldMapping);
501
+ }
502
+
433
503
  protected override transformToNested(
434
504
  data: CreateAVIReportInput
435
505
  ): CreateReportInput {
@@ -510,4 +580,30 @@ export class AVIReportsResource extends MexReportsResource {
510
580
  },
511
581
  } as UpdateReportItemInput;
512
582
  }
583
+
584
+ /**
585
+ * Transforms AVI defaults to nested API format for validate/generate.
586
+ */
587
+ protected transformAviDefaultsToNested(
588
+ reportId: string,
589
+ defaults: AviReportDefaultsInput
590
+ ): { reportId: string; jurisdictions: unknown } {
591
+ const { rfc, collegiateEntityCode, exempt, priority, ...aviFields } =
592
+ defaults;
593
+
594
+ return {
595
+ reportId,
596
+ jurisdictions: {
597
+ MX: {
598
+ actividadVulnerable: {
599
+ rfc,
600
+ collegiateEntityCode,
601
+ exempt,
602
+ priority,
603
+ [CodigoActividad.AVI]: aviFields,
604
+ },
605
+ },
606
+ },
607
+ };
608
+ }
513
609
  }
@@ -10,6 +10,7 @@ import { z } from "zod";
10
10
  import type {
11
11
  CreateTransactionInput,
12
12
  UpdateTransactionInput,
13
+ TransactionSort,
13
14
  ListOptions,
14
15
  PaginatedResponse,
15
16
  CreateAVITransactionInput,
@@ -18,6 +19,7 @@ import type {
18
19
  PartialBatchResult,
19
20
  RelatedClient,
20
21
  AVITransactionFilter,
22
+ AVITransactionSort,
21
23
  } from "@artu-ai/shared";
22
24
  import {
23
25
  Jurisdiction,
@@ -25,6 +27,8 @@ import {
25
27
  createAVITransactionInputSchema,
26
28
  updateAVITransactionInputSchema,
27
29
  ClientRole,
30
+ transformSort,
31
+ aviTransactionFieldMapping,
28
32
  } from "@artu-ai/shared";
29
33
  import { MexTransactionsResource } from "../../transactions";
30
34
  import { type BatchOptions } from "../../../clients";
@@ -59,7 +63,7 @@ import { MexAVITransaction, type TransactionData } from "../../../../models";
59
63
  * console.log(txn.operationType);
60
64
  * ```
61
65
  */
62
- export class AVITransactionsResource extends MexTransactionsResource {
66
+ export class AVITransactionsResource extends MexTransactionsResource<AVITransactionSort> {
63
67
  // ─────────────────────────────────────────────────────────────────
64
68
  // CRUD Operations
65
69
  // ─────────────────────────────────────────────────────────────────
@@ -115,14 +119,16 @@ export class AVITransactionsResource extends MexTransactionsResource {
115
119
  * Accepts flattened AVI filter (future AVI-specific transaction fields at root level).
116
120
  */
117
121
  async list(
118
- options?: ListOptions<AVITransactionFilter>
122
+ options?: ListOptions<AVITransactionFilter, AVITransactionSort>
119
123
  ): Promise<PaginatedResponse<MexAVITransaction>> {
120
124
  const scopedFilter = this.applyScopeToFilter(options?.filter);
125
+ const scopedSort = this.applyScopeToSort(options?.sort);
121
126
 
122
127
  const response = await this.execute(() =>
123
128
  this.trpc.transactions.list.query({
124
129
  ...options,
125
130
  filter: scopedFilter,
131
+ sort: scopedSort,
126
132
  })
127
133
  );
128
134
 
@@ -300,6 +306,18 @@ export class AVITransactionsResource extends MexTransactionsResource {
300
306
  // Protected Helpers
301
307
  // ─────────────────────────────────────────────────────────────────
302
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
+
303
321
  protected override transformToNested(
304
322
  data: CreateAVITransactionInput
305
323
  ): CreateTransactionInput {
@@ -29,13 +29,17 @@ import type {
29
29
  SyncItem,
30
30
  SyncResult,
31
31
  JYSClientFilter,
32
+ JYSClientSort,
32
33
  } from "@artu-ai/shared";
33
34
  import {
34
35
  CodigoActividad,
35
36
  createJYSClientInputSchema,
36
37
  updateJYSClientInputSchema,
37
38
  linkedClientSchema,
39
+ transformSort,
40
+ jysClientFieldMapping,
38
41
  } from "@artu-ai/shared";
42
+ import type { ClientSort } from "@artu-ai/shared";
39
43
  import { MexClientsResource } from "../../clients";
40
44
  import { type BatchOptions, type ClientIncludeMap } from "../../../clients";
41
45
  import {
@@ -72,7 +76,7 @@ import {
72
76
  * // Returns MexJYSClient
73
77
  * ```
74
78
  */
75
- export class JYSClientsResource extends MexClientsResource {
79
+ export class JYSClientsResource extends MexClientsResource<JYSClientSort> {
76
80
  // ─────────────────────────────────────────────────────────────────
77
81
  // CRUD Operations
78
82
  // ─────────────────────────────────────────────────────────────────
@@ -126,14 +130,16 @@ export class JYSClientsResource extends MexClientsResource {
126
130
  * transforms to nested format before calling the API.
127
131
  */
128
132
  async list(
129
- options?: ListOptions<JYSClientFilter> & { includePrimaryContacts?: boolean }
133
+ options?: ListOptions<JYSClientFilter, JYSClientSort> & { includePrimaryContacts?: boolean }
130
134
  ): Promise<PaginatedResponse<MexJYSClient>> {
131
135
  const scopedFilter = this.applyScopeToFilter(options?.filter);
136
+ const scopedSort = this.applyScopeToSort(options?.sort);
132
137
 
133
138
  const response = await this.execute(() =>
134
139
  this.trpc.clients.list.query({
135
140
  ...options,
136
141
  filter: scopedFilter,
142
+ sort: scopedSort,
137
143
  })
138
144
  );
139
145
 
@@ -385,6 +391,18 @@ export class JYSClientsResource extends MexClientsResource {
385
391
  // Protected Helpers
386
392
  // ─────────────────────────────────────────────────────────────────
387
393
 
394
+ /**
395
+ * Transforms a flattened JYSClientSort to nested ClientSort format.
396
+ *
397
+ * Maps flattened field names to their full API paths.
398
+ */
399
+ protected override applyScopeToSort(sort?: JYSClientSort): ClientSort | undefined {
400
+ if (!sort || sort.length === 0) {
401
+ return undefined;
402
+ }
403
+ return transformSort(sort, jysClientFieldMapping);
404
+ }
405
+
388
406
  /**
389
407
  * Transforms JYS input to nested API format.
390
408
  * JYS has no additional fields, but we add the JYS activity marker.
@@ -20,7 +20,7 @@ import type {
20
20
  PaginatedResponse,
21
21
  AtomicBatchResult,
22
22
  PartialBatchResult,
23
- MexJYSValidateInput,
23
+ JysReportDefaultsInput,
24
24
  ValidationResult,
25
25
  GenerateResult,
26
26
  SubmissionResult,
@@ -32,12 +32,20 @@ import {
32
32
  updateJYSReportInputSchema,
33
33
  createJYSReportItemInputSchema,
34
34
  updateJYSReportItemInputSchema,
35
- mexJysValidateInputSchema,
35
+ jysDefaultsInputSchema,
36
36
  submitJYSSubmissionInputSchema,
37
+ transformSort,
38
+ jysReportFieldMapping,
39
+ } from "@artu-ai/shared";
40
+ import type {
41
+ JYSReportFilter,
42
+ JYSReportSort,
43
+ JYSReportItemFilter,
44
+ ReportSort,
45
+ ReportItemFilter,
46
+ ReportItemSort,
37
47
  } from "@artu-ai/shared";
38
- import type { JYSReportFilter } from "@artu-ai/shared";
39
48
  import { MexReportsResource } from "../../reports";
40
- import { type ReportItemFilter } from "../../../reports";
41
49
  import { type BatchOptions } from "../../../clients";
42
50
  import {
43
51
  MexJYSReport,
@@ -70,7 +78,7 @@ import {
70
78
  * console.log(report.mesReportado);
71
79
  * ```
72
80
  */
73
- export class JYSReportsResource extends MexReportsResource {
81
+ export class JYSReportsResource extends MexReportsResource<JYSReportSort, JysReportDefaultsInput> {
74
82
  // ─────────────────────────────────────────────────────────────────
75
83
  // Report CRUD
76
84
  // ─────────────────────────────────────────────────────────────────
@@ -127,14 +135,16 @@ export class JYSReportsResource extends MexReportsResource {
127
135
  * Accepts flattened JYS filter (future JYS-specific report fields at root level).
128
136
  */
129
137
  async list(
130
- options?: ListOptions<JYSReportFilter>
138
+ options?: ListOptions<JYSReportFilter, JYSReportSort>
131
139
  ): Promise<PaginatedResponse<MexJYSReport>> {
132
140
  const scopedFilter = this.applyScopeToFilter(options?.filter);
141
+ const scopedSort = this.applyScopeToSort(options?.sort);
133
142
 
134
143
  const response = await this.execute(() =>
135
144
  this.trpc.reports.list.query({
136
145
  ...options,
137
146
  filter: scopedFilter,
147
+ sort: scopedSort,
138
148
  })
139
149
  );
140
150
 
@@ -294,12 +304,16 @@ export class JYSReportsResource extends MexReportsResource {
294
304
 
295
305
  async listItems(
296
306
  reportId: string,
297
- options?: ListOptions<ReportItemFilter>
307
+ options?: ListOptions<JYSReportItemFilter, ReportItemSort>
298
308
  ): Promise<PaginatedResponse<MexJYSReportItem>> {
309
+ // Transform flattened JYS filter to nested format
310
+ const scopedFilter = this.applyScopeToItemFilter(options?.filter);
311
+
299
312
  const response = await this.execute(() =>
300
313
  this.trpc.reports.listItems.query({
301
314
  reportId,
302
315
  ...options,
316
+ filter: scopedFilter,
303
317
  })
304
318
  );
305
319
 
@@ -309,6 +323,38 @@ export class JYSReportsResource extends MexReportsResource {
309
323
  };
310
324
  }
311
325
 
326
+ /**
327
+ * Transforms a flattened JYSReportItemFilter to nested ReportItemFilter format.
328
+ */
329
+ protected applyScopeToItemFilter(
330
+ filter?: JYSReportItemFilter
331
+ ): ReportItemFilter | undefined {
332
+ if (!filter) return undefined;
333
+
334
+ const { alertType, alertDescription, ...baseFields } = filter;
335
+
336
+ // If no JYS-specific fields, return base filter as-is
337
+ if (alertType === undefined && alertDescription === undefined) {
338
+ return baseFields as ReportItemFilter;
339
+ }
340
+
341
+ // Build nested filter structure
342
+ const jysFilter: Record<string, unknown> = {};
343
+ if (alertType !== undefined) jysFilter.alertType = alertType;
344
+ if (alertDescription !== undefined) jysFilter.alertDescription = alertDescription;
345
+
346
+ return {
347
+ ...baseFields,
348
+ jurisdictions: {
349
+ MX: {
350
+ actividadVulnerable: {
351
+ JYS: jysFilter,
352
+ },
353
+ },
354
+ },
355
+ } as ReportItemFilter;
356
+ }
357
+
312
358
  async addItems(
313
359
  reportId: string,
314
360
  items: CreateJYSReportItemInput[]
@@ -338,19 +384,28 @@ export class JYSReportsResource extends MexReportsResource {
338
384
  *
339
385
  * Uses JYS-scoped validation input (jurisdiction and activity are implicit).
340
386
  *
387
+ * @param reportId - The report ID to validate
388
+ * @param defaults - JYS report defaults including rfc, alertType, etc.
389
+ *
341
390
  * @example
342
391
  * ```typescript
343
- * const result = await jysSdk.reports.validateReport({
344
- * reportId: report.id,
345
- * defaults: { rfc: "ABC200101XXX" },
392
+ * const result = await jysSdk.reports.validateReport(report.id, {
393
+ * rfc: "ABC200101XXX",
394
+ * alertType: "100",
346
395
  * });
347
396
  * ```
348
397
  */
349
398
  override async validateReport(
350
- input: MexJYSValidateInput
399
+ reportId: string,
400
+ defaults: JysReportDefaultsInput
351
401
  ): Promise<ValidationResult> {
352
- const validated = this.validate(mexJysValidateInputSchema, input);
353
- return this.execute(() => this.trpc.reports.validate.mutate(validated));
402
+ const validated = this.validate(jysDefaultsInputSchema, defaults);
403
+ const nestedInput = this.transformJysDefaultsToNested(reportId, validated);
404
+ return this.execute(() =>
405
+ this.trpc.reports.validate.mutate(
406
+ nestedInput as Parameters<typeof this.trpc.reports.validate.mutate>[0]
407
+ )
408
+ );
354
409
  }
355
410
 
356
411
  // ─────────────────────────────────────────────────────────────────
@@ -361,12 +416,21 @@ export class JYSReportsResource extends MexReportsResource {
361
416
  * Generates XML for a JYS report.
362
417
  *
363
418
  * Uses the same input as validateReport.
419
+ *
420
+ * @param reportId - The report ID to generate XML for
421
+ * @param defaults - JYS report defaults including rfc, alertType, etc.
364
422
  */
365
423
  override async generateReport(
366
- input: MexJYSValidateInput
424
+ reportId: string,
425
+ defaults: JysReportDefaultsInput
367
426
  ): Promise<GenerateResult> {
368
- const validated = this.validate(mexJysValidateInputSchema, input);
369
- return this.execute(() => this.trpc.reports.generate.mutate(validated));
427
+ const validated = this.validate(jysDefaultsInputSchema, defaults);
428
+ const nestedInput = this.transformJysDefaultsToNested(reportId, validated);
429
+ return this.execute(() =>
430
+ this.trpc.reports.generate.mutate(
431
+ nestedInput as Parameters<typeof this.trpc.reports.generate.mutate>[0]
432
+ )
433
+ );
370
434
  }
371
435
 
372
436
  // ─────────────────────────────────────────────────────────────────
@@ -406,6 +470,18 @@ export class JYSReportsResource extends MexReportsResource {
406
470
  // Protected Helpers
407
471
  // ─────────────────────────────────────────────────────────────────
408
472
 
473
+ /**
474
+ * Transforms a flattened JYSReportSort to nested ReportSort format.
475
+ *
476
+ * Maps flattened field names to their full API paths.
477
+ */
478
+ protected override applyScopeToSort(sort?: JYSReportSort): ReportSort | undefined {
479
+ if (!sort || sort.length === 0) {
480
+ return undefined;
481
+ }
482
+ return transformSort(sort, jysReportFieldMapping);
483
+ }
484
+
409
485
  protected override transformToNested(
410
486
  data: CreateJYSReportInput
411
487
  ): CreateReportInput {
@@ -486,4 +562,30 @@ export class JYSReportsResource extends MexReportsResource {
486
562
  },
487
563
  } as UpdateReportItemInput;
488
564
  }
565
+
566
+ /**
567
+ * Transforms JYS defaults to nested API format for validate/generate.
568
+ */
569
+ protected transformJysDefaultsToNested(
570
+ reportId: string,
571
+ defaults: JysReportDefaultsInput
572
+ ): { reportId: string; jurisdictions: unknown } {
573
+ const { rfc, collegiateEntityCode, exempt, priority, ...jysFields } =
574
+ defaults;
575
+
576
+ return {
577
+ reportId,
578
+ jurisdictions: {
579
+ MX: {
580
+ actividadVulnerable: {
581
+ rfc,
582
+ collegiateEntityCode,
583
+ exempt,
584
+ priority,
585
+ [CodigoActividad.JYS]: jysFields,
586
+ },
587
+ },
588
+ },
589
+ };
590
+ }
489
591
  }
@@ -18,6 +18,7 @@ import type {
18
18
  PartialBatchResult,
19
19
  RelatedClient,
20
20
  JYSTransactionFilter,
21
+ JYSTransactionSort,
21
22
  } from "@artu-ai/shared";
22
23
  import {
23
24
  Jurisdiction,
@@ -25,7 +26,10 @@ import {
25
26
  createJYSTransactionInputSchema,
26
27
  updateJYSTransactionInputSchema,
27
28
  ClientRole,
29
+ transformSort,
30
+ jysTransactionFieldMapping,
28
31
  } from "@artu-ai/shared";
32
+ import type { TransactionSort } from "@artu-ai/shared";
29
33
  import { MexTransactionsResource } from "../../transactions";
30
34
  import { type BatchOptions } from "../../../clients";
31
35
  import { MexJYSTransaction, type TransactionData } from "../../../../models";
@@ -62,7 +66,7 @@ import { MexJYSTransaction, type TransactionData } from "../../../../models";
62
66
  * console.log(txn.settlementType);
63
67
  * ```
64
68
  */
65
- export class JYSTransactionsResource extends MexTransactionsResource {
69
+ export class JYSTransactionsResource extends MexTransactionsResource<JYSTransactionSort> {
66
70
  // ─────────────────────────────────────────────────────────────────
67
71
  // CRUD Operations
68
72
  // ─────────────────────────────────────────────────────────────────
@@ -118,14 +122,16 @@ export class JYSTransactionsResource extends MexTransactionsResource {
118
122
  * Accepts flattened JYS filter (future JYS-specific transaction fields at root level).
119
123
  */
120
124
  async list(
121
- options?: ListOptions<JYSTransactionFilter>
125
+ options?: ListOptions<JYSTransactionFilter, JYSTransactionSort>
122
126
  ): Promise<PaginatedResponse<MexJYSTransaction>> {
123
127
  const scopedFilter = this.applyScopeToFilter(options?.filter);
128
+ const scopedSort = this.applyScopeToSort(options?.sort);
124
129
 
125
130
  const response = await this.execute(() =>
126
131
  this.trpc.transactions.list.query({
127
132
  ...options,
128
133
  filter: scopedFilter,
134
+ sort: scopedSort,
129
135
  })
130
136
  );
131
137
 
@@ -303,6 +309,18 @@ export class JYSTransactionsResource extends MexTransactionsResource {
303
309
  // Protected Helpers
304
310
  // ─────────────────────────────────────────────────────────────────
305
311
 
312
+ /**
313
+ * Transforms a flattened JYSTransactionSort to nested TransactionSort format.
314
+ *
315
+ * Maps flattened field names to their full API paths.
316
+ */
317
+ protected override applyScopeToSort(sort?: JYSTransactionSort): TransactionSort | undefined {
318
+ if (!sort || sort.length === 0) {
319
+ return undefined;
320
+ }
321
+ return transformSort(sort, jysTransactionFieldMapping);
322
+ }
323
+
306
324
  protected override transformToNested(
307
325
  data: CreateJYSTransactionInput
308
326
  ): CreateTransactionInput {