@artu-ai/compliance-sdk 0.6.9 → 0.8.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 (89) hide show
  1. package/dist/exports/mexico/actividad-vulnerable/avi.d.ts +2 -1
  2. package/dist/exports/mexico/actividad-vulnerable/avi.d.ts.map +1 -1
  3. package/dist/exports/mexico/actividad-vulnerable/jys.d.ts +2 -1
  4. package/dist/exports/mexico/actividad-vulnerable/jys.d.ts.map +1 -1
  5. package/dist/exports/mexico/actividad-vulnerable/mjr.d.ts +677 -0
  6. package/dist/exports/mexico/actividad-vulnerable/mjr.d.ts.map +1 -0
  7. package/dist/exports/mexico/actividad-vulnerable/mjr.js +110 -0
  8. package/dist/exports/mexico/actividad-vulnerable/tsc.d.ts +2 -1
  9. package/dist/exports/mexico/actividad-vulnerable/tsc.d.ts.map +1 -1
  10. package/dist/models/Client.d.ts +7 -1
  11. package/dist/models/Client.d.ts.map +1 -1
  12. package/dist/models/Client.js +19 -1
  13. package/dist/models/Transaction.d.ts +6 -0
  14. package/dist/models/Transaction.d.ts.map +1 -1
  15. package/dist/models/Transaction.js +10 -0
  16. package/dist/models/index.d.ts +1 -1
  17. package/dist/models/index.d.ts.map +1 -1
  18. package/dist/models/index.js +3 -3
  19. package/dist/models/mex/MexClient.d.ts +1 -1
  20. package/dist/models/mex/MexClient.d.ts.map +1 -1
  21. package/dist/models/mex/MexClient.js +2 -9
  22. package/dist/models/mex/MexReport.d.ts.map +1 -1
  23. package/dist/models/mex/MexReport.js +2 -9
  24. package/dist/models/mex/MexTransaction.d.ts +1 -1
  25. package/dist/models/mex/MexTransaction.d.ts.map +1 -1
  26. package/dist/models/mex/MexTransaction.js +2 -9
  27. package/dist/models/mex/actividad-vulnerable/avi/MexAVITransaction.d.ts +11 -21
  28. package/dist/models/mex/actividad-vulnerable/avi/MexAVITransaction.d.ts.map +1 -1
  29. package/dist/models/mex/actividad-vulnerable/avi/MexAVITransaction.js +21 -54
  30. package/dist/models/mex/actividad-vulnerable/index.d.ts +4 -0
  31. package/dist/models/mex/actividad-vulnerable/index.d.ts.map +1 -1
  32. package/dist/models/mex/actividad-vulnerable/index.js +4 -0
  33. package/dist/models/mex/actividad-vulnerable/mjr/MexMJRClient.d.ts +40 -0
  34. package/dist/models/mex/actividad-vulnerable/mjr/MexMJRClient.d.ts.map +1 -0
  35. package/dist/models/mex/actividad-vulnerable/mjr/MexMJRClient.js +54 -0
  36. package/dist/models/mex/actividad-vulnerable/mjr/MexMJRReport.d.ts +53 -0
  37. package/dist/models/mex/actividad-vulnerable/mjr/MexMJRReport.d.ts.map +1 -0
  38. package/dist/models/mex/actividad-vulnerable/mjr/MexMJRReport.js +75 -0
  39. package/dist/models/mex/actividad-vulnerable/mjr/MexMJRReportItem.d.ts +56 -0
  40. package/dist/models/mex/actividad-vulnerable/mjr/MexMJRReportItem.d.ts.map +1 -0
  41. package/dist/models/mex/actividad-vulnerable/mjr/MexMJRReportItem.js +63 -0
  42. package/dist/models/mex/actividad-vulnerable/mjr/MexMJRTransaction.d.ts +79 -0
  43. package/dist/models/mex/actividad-vulnerable/mjr/MexMJRTransaction.d.ts.map +1 -0
  44. package/dist/models/mex/actividad-vulnerable/mjr/MexMJRTransaction.js +126 -0
  45. package/dist/namespaces/mexico/actividad-vulnerable/index.d.ts +4 -2
  46. package/dist/namespaces/mexico/actividad-vulnerable/index.d.ts.map +1 -1
  47. package/dist/namespaces/mexico/index.d.ts +2 -1
  48. package/dist/namespaces/mexico/index.d.ts.map +1 -1
  49. package/dist/resources/exchange-rates.d.ts +14 -0
  50. package/dist/resources/exchange-rates.d.ts.map +1 -0
  51. package/dist/resources/exchange-rates.js +30 -0
  52. package/dist/resources/index.d.ts +1 -0
  53. package/dist/resources/index.d.ts.map +1 -1
  54. package/dist/resources/index.js +2 -0
  55. package/dist/resources/mex/actividad-vulnerable/index.d.ts +1 -0
  56. package/dist/resources/mex/actividad-vulnerable/index.d.ts.map +1 -1
  57. package/dist/resources/mex/actividad-vulnerable/index.js +2 -0
  58. package/dist/resources/mex/actividad-vulnerable/mjr/clients.d.ts +177 -0
  59. package/dist/resources/mex/actividad-vulnerable/mjr/clients.d.ts.map +1 -0
  60. package/dist/resources/mex/actividad-vulnerable/mjr/clients.js +320 -0
  61. package/dist/resources/mex/actividad-vulnerable/mjr/index.d.ts +7 -0
  62. package/dist/resources/mex/actividad-vulnerable/mjr/index.d.ts.map +1 -0
  63. package/dist/resources/mex/actividad-vulnerable/mjr/index.js +6 -0
  64. package/dist/resources/mex/actividad-vulnerable/mjr/reports.d.ts +170 -0
  65. package/dist/resources/mex/actividad-vulnerable/mjr/reports.d.ts.map +1 -0
  66. package/dist/resources/mex/actividad-vulnerable/mjr/reports.js +463 -0
  67. package/dist/resources/mex/actividad-vulnerable/mjr/transactions.d.ts +128 -0
  68. package/dist/resources/mex/actividad-vulnerable/mjr/transactions.d.ts.map +1 -0
  69. package/dist/resources/mex/actividad-vulnerable/mjr/transactions.js +343 -0
  70. package/dist/sdk/ComplianceSDK.d.ts +17 -1
  71. package/dist/sdk/ComplianceSDK.d.ts.map +1 -1
  72. package/dist/sdk/ComplianceSDK.js +18 -1
  73. package/dist/sdk/mex/actividad-vulnerable/index.d.ts +1 -0
  74. package/dist/sdk/mex/actividad-vulnerable/index.d.ts.map +1 -1
  75. package/dist/sdk/mex/actividad-vulnerable/index.js +6 -0
  76. package/dist/sdk/mex/actividad-vulnerable/mjr/ComplianceSDK.d.ts +56 -0
  77. package/dist/sdk/mex/actividad-vulnerable/mjr/ComplianceSDK.d.ts.map +1 -0
  78. package/dist/sdk/mex/actividad-vulnerable/mjr/ComplianceSDK.js +51 -0
  79. package/dist/sdk/mex/actividad-vulnerable/mjr/index.d.ts +8 -0
  80. package/dist/sdk/mex/actividad-vulnerable/mjr/index.d.ts.map +1 -0
  81. package/dist/sdk/mex/actividad-vulnerable/mjr/index.js +9 -0
  82. package/dist/sdk/mex/actividad-vulnerable/mjr/types.d.ts +35 -0
  83. package/dist/sdk/mex/actividad-vulnerable/mjr/types.d.ts.map +1 -0
  84. package/dist/sdk/mex/actividad-vulnerable/mjr/types.js +20 -0
  85. package/dist/sdk/mex/types.d.ts +4 -2
  86. package/dist/sdk/mex/types.d.ts.map +1 -1
  87. package/dist/sdk/types.d.ts +1 -1
  88. package/dist/sdk/types.d.ts.map +1 -1
  89. package/package.json +6 -2
@@ -0,0 +1,170 @@
1
+ /**
2
+ * MJR (Metales y Joyas - Precious Metals and Jewelry) Reports Resource
3
+ *
4
+ * Extends MexReportsResource with MJR-specific behavior:
5
+ * - Accepts flattened CreateMJRReportInput (MJR fields at root level)
6
+ * - Returns MexMJRReport models
7
+ */
8
+ import type { CreateReportInput, UpdateReportInput, CreateReportItemInput, UpdateReportItemInput, CreateMJRReportInput, UpdateMJRReportInput, UpsertMJRReportInput, CreateMJRReportItemInput, UpdateMJRReportItemInput, ListOptions, PaginatedResponse, AtomicBatchResult, PartialBatchResult, MjrReportDefaultsInput, ValidationResult, GenerateResult, SubmissionResult, SubmitMJRSubmissionInput, UpsertResult } from "@artu-ai/shared";
9
+ import type { MJRReportFilter, MJRReportSort, MJRReportItemFilter, ReportSort, ReportItemFilter, ReportItemSort } from "@artu-ai/shared";
10
+ import { MexReportsResource } from "../../reports";
11
+ import { MexMJRReport, MexMJRReportItem, type ReportData, type ReportItemData } from "../../../../models";
12
+ /**
13
+ * MJR (Metales y Joyas) scoped reports resource.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const mjrSdk = new ComplianceSDK({
18
+ * apiKey,
19
+ * jurisdiction: Jurisdiction.Mexico,
20
+ * actividadVulnerable: CodigoActividad.MJR,
21
+ * });
22
+ *
23
+ * // Create with fully flattened input
24
+ * const report = await mjrSdk.reports.create({
25
+ * mesReportado: "202401",
26
+ * });
27
+ *
28
+ * // Returns MexMJRReport
29
+ * console.log(report.mesReportado);
30
+ * ```
31
+ */
32
+ export declare class MJRReportsResource extends MexReportsResource<MJRReportSort, MjrReportDefaultsInput> {
33
+ create(data: CreateMJRReportInput): Promise<MexMJRReport>;
34
+ retrieve(id: string): Promise<MexMJRReport>;
35
+ retrieveByMetadata(key: string, value: string): Promise<MexMJRReport>;
36
+ retrieveByExternalId(externalId: string): Promise<MexMJRReport>;
37
+ update(id: string, data: UpdateMJRReportInput): Promise<MexMJRReport>;
38
+ /**
39
+ * Lists MJR reports with optional filtering.
40
+ *
41
+ * Accepts flattened MJR filter (future MJR-specific report fields at root level).
42
+ */
43
+ list(options?: ListOptions<MJRReportFilter, MJRReportSort>): Promise<PaginatedResponse<MexMJRReport>>;
44
+ /**
45
+ * Iterates over MJR reports.
46
+ *
47
+ * Accepts flattened MJR filter (future MJR-specific report fields at root level).
48
+ */
49
+ iterate(options?: {
50
+ filter?: MJRReportFilter;
51
+ sort?: MJRReportSort;
52
+ pageSize?: number;
53
+ }): AsyncGenerator<MexMJRReport, void, undefined>;
54
+ /**
55
+ * Counts MJR reports matching the given filter.
56
+ *
57
+ * @param filter - Optional filter criteria (with MJR fields at root level)
58
+ * @returns The count of matching reports
59
+ */
60
+ count(filter?: MJRReportFilter): Promise<number>;
61
+ createMany(reports: CreateMJRReportInput[], options?: {
62
+ atomic?: true;
63
+ }): Promise<AtomicBatchResult<MexMJRReport>>;
64
+ createMany(reports: CreateMJRReportInput[], options: {
65
+ atomic: false;
66
+ }): Promise<PartialBatchResult<MexMJRReport>>;
67
+ updateMany(updates: {
68
+ id: string;
69
+ data: UpdateMJRReportInput;
70
+ }[], options?: {
71
+ atomic?: true;
72
+ }): Promise<AtomicBatchResult<MexMJRReport>>;
73
+ updateMany(updates: {
74
+ id: string;
75
+ data: UpdateMJRReportInput;
76
+ }[], options: {
77
+ atomic: false;
78
+ }): Promise<PartialBatchResult<MexMJRReport>>;
79
+ /**
80
+ * Creates or updates a MJR report by externalId.
81
+ *
82
+ * @param data - Report upsert data with MJR fields at root level (must include externalId)
83
+ * @returns The created or updated report with action indicator
84
+ */
85
+ upsertByExternalId(data: UpsertMJRReportInput): Promise<UpsertResult<MexMJRReport>>;
86
+ /**
87
+ * Creates or updates multiple MJR reports by externalId.
88
+ *
89
+ * @param reports - Array of report upsert data (each must include externalId)
90
+ * @param options - Batch options (atomic: true by default)
91
+ * @returns Atomic result with data array, or partial result with succeeded/failed
92
+ */
93
+ upsertManyByExternalId(reports: UpsertMJRReportInput[], options?: {
94
+ atomic?: true;
95
+ }): Promise<AtomicBatchResult<UpsertResult<MexMJRReport>>>;
96
+ upsertManyByExternalId(reports: UpsertMJRReportInput[], options: {
97
+ atomic: false;
98
+ }): Promise<PartialBatchResult<UpsertResult<MexMJRReport>>>;
99
+ addItem(reportId: string, data: CreateMJRReportItemInput): Promise<MexMJRReportItem>;
100
+ getItem(reportId: string, itemId: string): Promise<MexMJRReportItem>;
101
+ updateItem(reportId: string, itemId: string, data: UpdateMJRReportItemInput): Promise<MexMJRReportItem>;
102
+ listItems(reportId: string, options?: ListOptions<MJRReportItemFilter, ReportItemSort>): Promise<PaginatedResponse<MexMJRReportItem>>;
103
+ /**
104
+ * Transforms a flattened MJRReportItemFilter to nested ReportItemFilter format.
105
+ */
106
+ protected applyScopeToItemFilter(filter?: MJRReportItemFilter): ReportItemFilter | undefined;
107
+ addItems(reportId: string, items: CreateMJRReportItemInput[]): Promise<{
108
+ added: number;
109
+ items: MexMJRReportItem[];
110
+ }>;
111
+ /**
112
+ * Validates a MJR report.
113
+ *
114
+ * Uses MJR-scoped validation input (jurisdiction and activity are implicit).
115
+ *
116
+ * @param reportId - The report ID to validate
117
+ * @param defaults - MJR report defaults including rfc, alertType, etc.
118
+ *
119
+ * @example
120
+ * ```typescript
121
+ * const result = await mjrSdk.reports.validateReport(report.id, {
122
+ * rfc: "ABC200101XXX",
123
+ * alertType: "100",
124
+ * });
125
+ * ```
126
+ */
127
+ validateReport(reportId: string, defaults: MjrReportDefaultsInput): Promise<ValidationResult>;
128
+ /**
129
+ * Generates XML for a MJR report.
130
+ *
131
+ * Uses the same input as validateReport.
132
+ *
133
+ * @param reportId - The report ID to generate XML for
134
+ * @param defaults - MJR report defaults including rfc, alertType, etc.
135
+ */
136
+ generateReport(reportId: string, defaults: MjrReportDefaultsInput): Promise<GenerateResult>;
137
+ /**
138
+ * Submits a validated MJR report.
139
+ *
140
+ * Uses MJR-scoped submission input (activity is implicit).
141
+ */
142
+ submit(input: SubmitMJRSubmissionInput): Promise<SubmissionResult>;
143
+ protected transformToNested(data: CreateMJRReportInput): CreateReportInput;
144
+ /**
145
+ * Transforms flattened MJR report update to nested API format.
146
+ *
147
+ * NOTE: Always includes `actividadVulnerable: { MJR: {} }` even if no
148
+ * MJR-specific fields are provided. This ensures that records touched via
149
+ * the MJR SDK can be filtered by `activityCodes: { in: ["MJR"] }`.
150
+ */
151
+ protected transformUpdateToNested(data: UpdateMJRReportInput): UpdateReportInput;
152
+ protected instantiate(data: ReportData): MexMJRReport;
153
+ protected instantiateItem(data: ReportItemData): MexMJRReportItem;
154
+ protected transformItemToNested(data: CreateMJRReportItemInput): CreateReportItemInput;
155
+ protected transformItemUpdateToNested(data: UpdateMJRReportItemInput): UpdateReportItemInput;
156
+ /**
157
+ * Transforms a flattened MJRReportSort to nested ReportSort format.
158
+ *
159
+ * Maps flattened field names to their full API paths using MJR-specific field mapping.
160
+ */
161
+ protected applyScopeToSort(sort?: MJRReportSort): ReportSort | undefined;
162
+ /**
163
+ * Transforms MJR defaults to nested API format for validate/generate.
164
+ */
165
+ protected transformMjrDefaultsToNested(reportId: string, defaults: MjrReportDefaultsInput): {
166
+ reportId: string;
167
+ jurisdictions: unknown;
168
+ };
169
+ }
170
+ //# sourceMappingURL=reports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reports.d.ts","sourceRoot":"","sources":["../../../../../src/resources/mex/actividad-vulnerable/mjr/reports.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EAEjB,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,E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C9B,OAAO,CAAC,gBAAgB,CAAC;cA0BT,iBAAiB,CAClC,IAAI,EAAE,oBAAoB,GACzB,iBAAiB;IAepB;;;;;;OAMG;cACgB,uBAAuB,CACxC,IAAI,EAAE,oBAAoB,GACzB,iBAAiB;cAcD,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,YAAY;cAI3C,eAAe,CAAC,IAAI,EAAE,cAAc,GAAG,gBAAgB;IAI1E,SAAS,CAAC,qBAAqB,CAC7B,IAAI,EAAE,wBAAwB,GAC7B,qBAAqB;IAqBxB,SAAS,CAAC,2BAA2B,CACnC,IAAI,EAAE,wBAAwB,GAC7B,qBAAqB;IAyBxB;;;;OAIG;cACgB,gBAAgB,CACjC,IAAI,CAAC,EAAE,aAAa,GACnB,UAAU,GAAG,SAAS;IAOzB;;OAEG;IACH,SAAS,CAAC,4BAA4B,CACpC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,sBAAsB,GAC/B;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,OAAO,CAAA;KAAE;CAmBhD"}
@@ -0,0 +1,463 @@
1
+ /**
2
+ * MJR (Metales y Joyas - Precious Metals and Jewelry) Reports Resource
3
+ *
4
+ * Extends MexReportsResource with MJR-specific behavior:
5
+ * - Accepts flattened CreateMJRReportInput (MJR fields at root level)
6
+ * - Returns MexMJRReport models
7
+ */
8
+ import { z } from "zod";
9
+ import { CodigoActividad, createMJRReportInputSchema, updateMJRReportInputSchema, upsertMJRReportInputSchema, createMJRReportItemInputSchema, updateMJRReportItemInputSchema, mjrDefaultsInputSchema, submitMJRSubmissionInputSchema, transformSort, mjrReportFieldMapping, } from "@artu-ai/shared";
10
+ import { MexReportsResource } from "../../reports";
11
+ import { MexMJRReport, MexMJRReportItem, } from "../../../../models";
12
+ // ===========================
13
+ // MJRReportsResource
14
+ // ===========================
15
+ /**
16
+ * MJR (Metales y Joyas) scoped reports resource.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * const mjrSdk = new ComplianceSDK({
21
+ * apiKey,
22
+ * jurisdiction: Jurisdiction.Mexico,
23
+ * actividadVulnerable: CodigoActividad.MJR,
24
+ * });
25
+ *
26
+ * // Create with fully flattened input
27
+ * const report = await mjrSdk.reports.create({
28
+ * mesReportado: "202401",
29
+ * });
30
+ *
31
+ * // Returns MexMJRReport
32
+ * console.log(report.mesReportado);
33
+ * ```
34
+ */
35
+ export class MJRReportsResource extends MexReportsResource {
36
+ // ─────────────────────────────────────────────────────────────────
37
+ // Report CRUD
38
+ // ─────────────────────────────────────────────────────────────────
39
+ async create(data) {
40
+ const validated = this.validate(createMJRReportInputSchema, data);
41
+ const nestedData = this.transformToNested(validated);
42
+ const response = await this.execute(() => this.trpc.reports.create.mutate(nestedData));
43
+ return this.instantiate(response);
44
+ }
45
+ async retrieve(id) {
46
+ const response = await this.execute(() => this.trpc.reports.retrieve.query({ id }));
47
+ return this.instantiate(response);
48
+ }
49
+ async retrieveByMetadata(key, value) {
50
+ const response = await this.execute(() => this.trpc.reports.retrieveByMetadata.query({ key, value }));
51
+ return this.instantiate(response);
52
+ }
53
+ async retrieveByExternalId(externalId) {
54
+ const response = await this.execute(() => this.trpc.reports.retrieveByExternalId.query({ externalId }));
55
+ return this.instantiate(response);
56
+ }
57
+ async update(id, data) {
58
+ const validated = this.validate(updateMJRReportInputSchema, data);
59
+ const nestedData = this.transformUpdateToNested(validated);
60
+ const response = await this.execute(() => this.trpc.reports.update.mutate({ id, data: nestedData }));
61
+ return this.instantiate(response);
62
+ }
63
+ // ─────────────────────────────────────────────────────────────────
64
+ // List & Pagination
65
+ // ─────────────────────────────────────────────────────────────────
66
+ /**
67
+ * Lists MJR reports with optional filtering.
68
+ *
69
+ * Accepts flattened MJR filter (future MJR-specific report fields at root level).
70
+ */
71
+ async list(options) {
72
+ const scopedFilter = this.applyScopeToFilter(options?.filter);
73
+ const scopedSort = this.applyScopeToSort(options?.sort);
74
+ const response = await this.execute(() => this.trpc.reports.list.query({
75
+ ...options,
76
+ filter: scopedFilter,
77
+ sort: scopedSort,
78
+ }));
79
+ return {
80
+ data: response.data.map((r) => this.instantiate(r)),
81
+ pagination: response.pagination,
82
+ };
83
+ }
84
+ /**
85
+ * Iterates over MJR reports.
86
+ *
87
+ * Accepts flattened MJR filter (future MJR-specific report fields at root level).
88
+ */
89
+ iterate(options) {
90
+ const scopedFilter = this.applyScopeToFilter(options?.filter);
91
+ // Note: sort is passed through - createIterator calls list() which handles transformation
92
+ return this.createIterator({
93
+ filter: scopedFilter,
94
+ sort: options?.sort,
95
+ pageSize: options?.pageSize,
96
+ });
97
+ }
98
+ /**
99
+ * Counts MJR reports matching the given filter.
100
+ *
101
+ * @param filter - Optional filter criteria (with MJR fields at root level)
102
+ * @returns The count of matching reports
103
+ */
104
+ async count(filter) {
105
+ const scopedFilter = this.applyScopeToFilter(filter);
106
+ const response = await this.execute(() => this.trpc.reports.count.query({ filter: scopedFilter }));
107
+ return response.count;
108
+ }
109
+ async createMany(reports, options = {}) {
110
+ const atomic = options.atomic ?? true;
111
+ const validated = this.validate(z.array(createMJRReportInputSchema), reports);
112
+ const nestedItems = validated.map((r) => this.transformToNested(r));
113
+ const response = await this.execute(() => this.trpc.reports.createMany.mutate({ items: nestedItems, atomic }));
114
+ if (response.atomic) {
115
+ return {
116
+ atomic: true,
117
+ data: response.data.map((r) => this.instantiate(r)),
118
+ };
119
+ }
120
+ else {
121
+ return {
122
+ atomic: false,
123
+ succeeded: response.succeeded.map((item) => ({
124
+ index: item.index,
125
+ data: this.instantiate(item.data),
126
+ })),
127
+ failed: response.failed,
128
+ };
129
+ }
130
+ }
131
+ async updateMany(updates, options = {}) {
132
+ const atomic = options.atomic ?? true;
133
+ const updateItemSchema = z.object({
134
+ id: z.uuid(),
135
+ data: updateMJRReportInputSchema,
136
+ });
137
+ const validated = this.validate(z.array(updateItemSchema), updates);
138
+ const nestedUpdates = validated.map((u) => ({
139
+ id: u.id,
140
+ data: this.transformUpdateToNested(u.data),
141
+ }));
142
+ const response = await this.execute(() => this.trpc.reports.updateMany.mutate({ items: nestedUpdates, atomic }));
143
+ if (response.atomic) {
144
+ return {
145
+ atomic: true,
146
+ data: response.data.map((r) => this.instantiate(r)),
147
+ };
148
+ }
149
+ else {
150
+ return {
151
+ atomic: false,
152
+ succeeded: response.succeeded.map((item) => ({
153
+ index: item.index,
154
+ data: this.instantiate(item.data),
155
+ })),
156
+ failed: response.failed,
157
+ };
158
+ }
159
+ }
160
+ // ─────────────────────────────────────────────────────────────────
161
+ // Upsert Operations
162
+ // ─────────────────────────────────────────────────────────────────
163
+ /**
164
+ * Creates or updates a MJR report by externalId.
165
+ *
166
+ * @param data - Report upsert data with MJR fields at root level (must include externalId)
167
+ * @returns The created or updated report with action indicator
168
+ */
169
+ async upsertByExternalId(data) {
170
+ const validated = this.validate(upsertMJRReportInputSchema, data);
171
+ const nestedData = this.transformToNested(validated);
172
+ const response = await this.execute(() => this.trpc.reports.upsertByExternalId.mutate(nestedData));
173
+ return {
174
+ data: this.instantiate(response.data),
175
+ action: response.action,
176
+ };
177
+ }
178
+ async upsertManyByExternalId(reports, options = {}) {
179
+ const atomic = options.atomic ?? true;
180
+ const validated = this.validate(z.array(upsertMJRReportInputSchema), reports);
181
+ const nestedItems = validated.map((r) => this.transformToNested(r));
182
+ const response = await this.execute(() => this.trpc.reports.upsertManyByExternalId.mutate({
183
+ items: nestedItems,
184
+ atomic,
185
+ }));
186
+ if (response.atomic) {
187
+ return {
188
+ atomic: true,
189
+ data: response.data.map((item) => ({
190
+ data: this.instantiate(item.data),
191
+ action: item.action,
192
+ })),
193
+ };
194
+ }
195
+ else {
196
+ return {
197
+ atomic: false,
198
+ succeeded: response.succeeded.map((item) => ({
199
+ index: item.index,
200
+ data: {
201
+ data: this.instantiate(item.data.data),
202
+ action: item.data.action,
203
+ },
204
+ })),
205
+ failed: response.failed,
206
+ };
207
+ }
208
+ }
209
+ // ─────────────────────────────────────────────────────────────────
210
+ // Report Items
211
+ // ─────────────────────────────────────────────────────────────────
212
+ async addItem(reportId, data) {
213
+ const validated = this.validate(createMJRReportItemInputSchema, data);
214
+ const nestedData = this.transformItemToNested(validated);
215
+ const response = await this.execute(() => this.trpc.reports.addItem.mutate({ reportId, data: nestedData }));
216
+ return this.instantiateItem(response);
217
+ }
218
+ async getItem(reportId, itemId) {
219
+ const response = await this.execute(() => this.trpc.reports.getItem.query({ reportId, itemId }));
220
+ return this.instantiateItem(response);
221
+ }
222
+ async updateItem(reportId, itemId, data) {
223
+ const validated = this.validate(updateMJRReportItemInputSchema, data);
224
+ const nestedData = this.transformItemUpdateToNested(validated);
225
+ const response = await this.execute(() => this.trpc.reports.updateItem.mutate({
226
+ reportId,
227
+ itemId,
228
+ data: nestedData,
229
+ }));
230
+ return this.instantiateItem(response);
231
+ }
232
+ async listItems(reportId, options) {
233
+ // Transform flattened MJR filter to nested format
234
+ const scopedFilter = this.applyScopeToItemFilter(options?.filter);
235
+ const response = await this.execute(() => this.trpc.reports.listItems.query({
236
+ reportId,
237
+ ...options,
238
+ filter: scopedFilter,
239
+ }));
240
+ return {
241
+ data: response.data.map((i) => this.instantiateItem(i)),
242
+ pagination: response.pagination,
243
+ };
244
+ }
245
+ /**
246
+ * Transforms a flattened MJRReportItemFilter to nested ReportItemFilter format.
247
+ */
248
+ applyScopeToItemFilter(filter) {
249
+ if (!filter)
250
+ return undefined;
251
+ const { alertType, alertDescription, ...baseFields } = filter;
252
+ // If no MJR-specific fields, return base filter as-is
253
+ if (alertType === undefined && alertDescription === undefined) {
254
+ return baseFields;
255
+ }
256
+ // Build nested filter structure
257
+ const mjrFilter = {};
258
+ if (alertType !== undefined)
259
+ mjrFilter.alertType = alertType;
260
+ if (alertDescription !== undefined)
261
+ mjrFilter.alertDescription = alertDescription;
262
+ return {
263
+ ...baseFields,
264
+ jurisdictions: {
265
+ MX: {
266
+ actividadVulnerable: {
267
+ MJR: mjrFilter,
268
+ },
269
+ },
270
+ },
271
+ };
272
+ }
273
+ async addItems(reportId, items) {
274
+ const validated = this.validate(z.array(createMJRReportItemInputSchema), items);
275
+ const nestedItems = validated.map((i) => this.transformItemToNested(i));
276
+ const response = await this.execute(() => this.trpc.reports.addItems.mutate({ reportId, items: nestedItems }));
277
+ return {
278
+ added: response.added,
279
+ items: response.items.map((i) => this.instantiateItem(i)),
280
+ };
281
+ }
282
+ // ─────────────────────────────────────────────────────────────────
283
+ // Validation
284
+ // ─────────────────────────────────────────────────────────────────
285
+ /**
286
+ * Validates a MJR report.
287
+ *
288
+ * Uses MJR-scoped validation input (jurisdiction and activity are implicit).
289
+ *
290
+ * @param reportId - The report ID to validate
291
+ * @param defaults - MJR report defaults including rfc, alertType, etc.
292
+ *
293
+ * @example
294
+ * ```typescript
295
+ * const result = await mjrSdk.reports.validateReport(report.id, {
296
+ * rfc: "ABC200101XXX",
297
+ * alertType: "100",
298
+ * });
299
+ * ```
300
+ */
301
+ async validateReport(reportId, defaults) {
302
+ const validated = this.validate(mjrDefaultsInputSchema, defaults);
303
+ const nestedInput = this.transformMjrDefaultsToNested(reportId, validated);
304
+ return this.execute(() => this.trpc.reports.validate.mutate(nestedInput));
305
+ }
306
+ // ─────────────────────────────────────────────────────────────────
307
+ // Generation
308
+ // ─────────────────────────────────────────────────────────────────
309
+ /**
310
+ * Generates XML for a MJR report.
311
+ *
312
+ * Uses the same input as validateReport.
313
+ *
314
+ * @param reportId - The report ID to generate XML for
315
+ * @param defaults - MJR report defaults including rfc, alertType, etc.
316
+ */
317
+ async generateReport(reportId, defaults) {
318
+ const validated = this.validate(mjrDefaultsInputSchema, defaults);
319
+ const nestedInput = this.transformMjrDefaultsToNested(reportId, validated);
320
+ return this.execute(() => this.trpc.reports.generate.mutate(nestedInput));
321
+ }
322
+ // ─────────────────────────────────────────────────────────────────
323
+ // Submission
324
+ // ─────────────────────────────────────────────────────────────────
325
+ /**
326
+ * Submits a validated MJR report.
327
+ *
328
+ * Uses MJR-scoped submission input (activity is implicit).
329
+ */
330
+ async submit(input) {
331
+ const validated = this.validate(submitMJRSubmissionInputSchema, input);
332
+ const jurisdictions = {
333
+ MX: {
334
+ actividadVulnerable: {
335
+ [CodigoActividad.MJR]: {
336
+ acuseRecibo: validated.acuseRecibo,
337
+ notes: validated.notes,
338
+ },
339
+ },
340
+ },
341
+ };
342
+ return this.execute(() => this.trpc.reports.submit.mutate({
343
+ reportId: validated.reportId,
344
+ jurisdictions,
345
+ }));
346
+ }
347
+ // ─────────────────────────────────────────────────────────────────
348
+ // Protected Helpers
349
+ // ─────────────────────────────────────────────────────────────────
350
+ transformToNested(data) {
351
+ const { mesReportado, ...baseFields } = data;
352
+ return {
353
+ ...baseFields,
354
+ jurisdictions: {
355
+ MX: {
356
+ actividadVulnerable: {
357
+ [CodigoActividad.MJR]: { mesReportado },
358
+ },
359
+ },
360
+ },
361
+ };
362
+ }
363
+ /**
364
+ * Transforms flattened MJR report update to nested API format.
365
+ *
366
+ * NOTE: Always includes `actividadVulnerable: { MJR: {} }` even if no
367
+ * MJR-specific fields are provided. This ensures that records touched via
368
+ * the MJR SDK can be filtered by `activityCodes: { in: ["MJR"] }`.
369
+ */
370
+ transformUpdateToNested(data) {
371
+ // Always include MJR activity marker to ensure filterability
372
+ return {
373
+ ...data,
374
+ jurisdictions: {
375
+ MX: {
376
+ actividadVulnerable: {
377
+ [CodigoActividad.MJR]: {},
378
+ },
379
+ },
380
+ },
381
+ };
382
+ }
383
+ instantiate(data) {
384
+ return new MexMJRReport(data);
385
+ }
386
+ instantiateItem(data) {
387
+ return new MexMJRReportItem(data);
388
+ }
389
+ transformItemToNested(data) {
390
+ const { alertType, alertDescription, amendment, ...baseFields } = data;
391
+ const mjrData = {};
392
+ if (alertType !== undefined)
393
+ mjrData.alertType = alertType;
394
+ if (alertDescription !== undefined)
395
+ mjrData.alertDescription = alertDescription;
396
+ if (amendment !== undefined)
397
+ mjrData.amendment = amendment;
398
+ return {
399
+ ...baseFields,
400
+ jurisdictions: {
401
+ MX: {
402
+ actividadVulnerable: {
403
+ [CodigoActividad.MJR]: mjrData,
404
+ },
405
+ },
406
+ },
407
+ };
408
+ }
409
+ transformItemUpdateToNested(data) {
410
+ const { alertType, alertDescription, amendment, ...baseFields } = data;
411
+ const mjrData = {};
412
+ if (alertType !== undefined)
413
+ mjrData.alertType = alertType;
414
+ if (alertDescription !== undefined)
415
+ mjrData.alertDescription = alertDescription;
416
+ if (amendment !== undefined)
417
+ mjrData.amendment = amendment;
418
+ if (Object.keys(mjrData).length === 0) {
419
+ return baseFields;
420
+ }
421
+ return {
422
+ ...baseFields,
423
+ jurisdictions: {
424
+ MX: {
425
+ actividadVulnerable: {
426
+ [CodigoActividad.MJR]: mjrData,
427
+ },
428
+ },
429
+ },
430
+ };
431
+ }
432
+ /**
433
+ * Transforms a flattened MJRReportSort to nested ReportSort format.
434
+ *
435
+ * Maps flattened field names to their full API paths using MJR-specific field mapping.
436
+ */
437
+ applyScopeToSort(sort) {
438
+ if (!sort || sort.length === 0) {
439
+ return undefined;
440
+ }
441
+ return transformSort(sort, mjrReportFieldMapping);
442
+ }
443
+ /**
444
+ * Transforms MJR defaults to nested API format for validate/generate.
445
+ */
446
+ transformMjrDefaultsToNested(reportId, defaults) {
447
+ const { rfc, collegiateEntityCode, exempt, priority, ...mjrFields } = defaults;
448
+ return {
449
+ reportId,
450
+ jurisdictions: {
451
+ MX: {
452
+ actividadVulnerable: {
453
+ rfc,
454
+ collegiateEntityCode,
455
+ exempt,
456
+ priority,
457
+ [CodigoActividad.MJR]: mjrFields,
458
+ },
459
+ },
460
+ },
461
+ };
462
+ }
463
+ }