@artu-ai/compliance-sdk 0.2.0 → 0.4.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.
- package/dist/models/Client.d.ts.map +1 -1
- package/dist/models/Client.js +21 -3
- package/dist/models/ReportItem.d.ts +2 -2
- package/dist/models/ReportItem.d.ts.map +1 -1
- package/dist/models/ReportItem.js +4 -4
- package/dist/models/mex/MexReportItem.js +1 -1
- package/dist/models/mex/actividad-vulnerable/MexActividadVulnerableReportItem.js +1 -1
- package/dist/models/mex/actividad-vulnerable/avi/MexAVIReportItem.js +1 -1
- package/dist/models/mex/actividad-vulnerable/jys/MexJYSReportItem.js +1 -1
- package/dist/models/mex/actividad-vulnerable/tsc/MexTSCReportItem.js +1 -1
- package/dist/resources/addresses.d.ts +3 -3
- package/dist/resources/addresses.d.ts.map +1 -1
- package/dist/resources/bank-accounts.d.ts +3 -3
- package/dist/resources/bank-accounts.d.ts.map +1 -1
- package/dist/resources/base.d.ts +7 -6
- package/dist/resources/base.d.ts.map +1 -1
- package/dist/resources/base.js +3 -0
- package/dist/resources/clients.d.ts +3 -3
- package/dist/resources/clients.d.ts.map +1 -1
- package/dist/resources/contact-methods.d.ts +3 -3
- package/dist/resources/contact-methods.d.ts.map +1 -1
- package/dist/resources/documents.d.ts +94 -7
- package/dist/resources/documents.d.ts.map +1 -1
- package/dist/resources/documents.js +107 -0
- package/dist/resources/index.d.ts +1 -1
- package/dist/resources/index.d.ts.map +1 -1
- package/dist/resources/index.js +1 -1
- package/dist/resources/mex/actividad-vulnerable/avi/clients.d.ts +9 -3
- package/dist/resources/mex/actividad-vulnerable/avi/clients.d.ts.map +1 -1
- package/dist/resources/mex/actividad-vulnerable/avi/clients.js +14 -1
- package/dist/resources/mex/actividad-vulnerable/avi/reports.d.ts +39 -21
- package/dist/resources/mex/actividad-vulnerable/avi/reports.d.ts.map +1 -1
- package/dist/resources/mex/actividad-vulnerable/avi/reports.js +88 -20
- package/dist/resources/mex/actividad-vulnerable/avi/transactions.d.ts +9 -3
- package/dist/resources/mex/actividad-vulnerable/avi/transactions.d.ts.map +1 -1
- package/dist/resources/mex/actividad-vulnerable/avi/transactions.js +14 -1
- package/dist/resources/mex/actividad-vulnerable/jys/clients.d.ts +10 -3
- package/dist/resources/mex/actividad-vulnerable/jys/clients.d.ts.map +1 -1
- package/dist/resources/mex/actividad-vulnerable/jys/clients.js +14 -1
- package/dist/resources/mex/actividad-vulnerable/jys/reports.d.ts +33 -11
- package/dist/resources/mex/actividad-vulnerable/jys/reports.d.ts.map +1 -1
- package/dist/resources/mex/actividad-vulnerable/jys/reports.js +82 -10
- package/dist/resources/mex/actividad-vulnerable/jys/transactions.d.ts +10 -3
- package/dist/resources/mex/actividad-vulnerable/jys/transactions.d.ts.map +1 -1
- package/dist/resources/mex/actividad-vulnerable/jys/transactions.js +14 -1
- package/dist/resources/mex/actividad-vulnerable/tsc/clients.d.ts +10 -3
- package/dist/resources/mex/actividad-vulnerable/tsc/clients.d.ts.map +1 -1
- package/dist/resources/mex/actividad-vulnerable/tsc/clients.js +14 -1
- package/dist/resources/mex/actividad-vulnerable/tsc/reports.d.ts +33 -11
- package/dist/resources/mex/actividad-vulnerable/tsc/reports.d.ts.map +1 -1
- package/dist/resources/mex/actividad-vulnerable/tsc/reports.js +82 -10
- package/dist/resources/mex/actividad-vulnerable/tsc/transactions.d.ts +10 -3
- package/dist/resources/mex/actividad-vulnerable/tsc/transactions.d.ts.map +1 -1
- package/dist/resources/mex/actividad-vulnerable/tsc/transactions.js +14 -1
- package/dist/resources/mex/addresses.d.ts +11 -3
- package/dist/resources/mex/addresses.d.ts.map +1 -1
- package/dist/resources/mex/addresses.js +16 -1
- package/dist/resources/mex/bank-accounts.d.ts +11 -3
- package/dist/resources/mex/bank-accounts.d.ts.map +1 -1
- package/dist/resources/mex/bank-accounts.js +16 -0
- package/dist/resources/mex/clients.d.ts +12 -3
- package/dist/resources/mex/clients.d.ts.map +1 -1
- package/dist/resources/mex/clients.js +17 -1
- package/dist/resources/mex/reports.d.ts +41 -19
- package/dist/resources/mex/reports.d.ts.map +1 -1
- package/dist/resources/mex/reports.js +55 -19
- package/dist/resources/mex/transactions.d.ts +11 -3
- package/dist/resources/mex/transactions.d.ts.map +1 -1
- package/dist/resources/mex/transactions.js +16 -1
- package/dist/resources/reports.d.ts +33 -39
- package/dist/resources/reports.d.ts.map +1 -1
- package/dist/resources/reports.js +34 -36
- package/dist/resources/transactions.d.ts +3 -3
- package/dist/resources/transactions.d.ts.map +1 -1
- package/dist/sdk/ComplianceSDK.d.ts +2 -0
- package/dist/sdk/ComplianceSDK.d.ts.map +1 -1
- package/dist/sdk/ComplianceSDK.js +17 -9
- package/dist/sdk/mex/ComplianceSDK.d.ts.map +1 -1
- package/dist/sdk/mex/actividad-vulnerable/avi/ComplianceSDK.d.ts.map +1 -1
- package/dist/sdk/mex/actividad-vulnerable/avi/types.d.ts +2 -2
- package/dist/sdk/mex/actividad-vulnerable/avi/types.d.ts.map +1 -1
- package/dist/sdk/mex/actividad-vulnerable/avi/types.js +1 -0
- package/dist/sdk/mex/actividad-vulnerable/jys/ComplianceSDK.d.ts.map +1 -1
- package/dist/sdk/mex/actividad-vulnerable/jys/types.d.ts +2 -2
- package/dist/sdk/mex/actividad-vulnerable/jys/types.d.ts.map +1 -1
- package/dist/sdk/mex/actividad-vulnerable/jys/types.js +1 -0
- package/dist/sdk/mex/actividad-vulnerable/tsc/ComplianceSDK.d.ts.map +1 -1
- package/dist/sdk/mex/actividad-vulnerable/tsc/types.d.ts +2 -2
- package/dist/sdk/mex/actividad-vulnerable/tsc/types.d.ts.map +1 -1
- package/dist/sdk/mex/actividad-vulnerable/tsc/types.js +1 -0
- package/dist/sdk/mex/types.d.ts +2 -2
- package/dist/sdk/mex/types.d.ts.map +1 -1
- package/dist/sdk/types.d.ts +24 -1
- package/dist/sdk/types.d.ts.map +1 -1
- package/dist/utils/environment.d.ts +24 -0
- package/dist/utils/environment.d.ts.map +1 -1
- package/dist/utils/environment.js +38 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +4 -0
- package/dist/utils/session.d.ts +20 -2
- package/dist/utils/session.d.ts.map +1 -1
- package/dist/utils/session.js +9 -1
- package/dist/utils/trpc-client.d.ts +370 -200
- package/dist/utils/trpc-client.d.ts.map +1 -1
- package/dist/utils/trpc-client.js +2 -1
- package/dist/utils/upload.d.ts +81 -0
- package/dist/utils/upload.d.ts.map +1 -0
- package/dist/utils/upload.js +261 -0
- package/package.json +9 -8
- package/src/models/Client.ts +23 -3
- package/src/models/ReportItem.ts +4 -4
- package/src/models/mex/MexReportItem.ts +1 -1
- package/src/models/mex/actividad-vulnerable/MexActividadVulnerableReportItem.ts +1 -1
- package/src/models/mex/actividad-vulnerable/avi/MexAVIReportItem.ts +1 -1
- package/src/models/mex/actividad-vulnerable/jys/MexJYSReportItem.ts +1 -1
- package/src/models/mex/actividad-vulnerable/tsc/MexTSCReportItem.ts +1 -1
- package/src/resources/addresses.ts +8 -4
- package/src/resources/bank-accounts.ts +8 -4
- package/src/resources/base.ts +9 -4
- package/src/resources/clients.ts +10 -4
- package/src/resources/contact-methods.ts +4 -2
- package/src/resources/documents.ts +185 -5
- package/src/resources/index.ts +6 -1
- package/src/resources/mex/actividad-vulnerable/avi/clients.ts +30 -8
- package/src/resources/mex/actividad-vulnerable/avi/reports.ts +122 -26
- package/src/resources/mex/actividad-vulnerable/avi/transactions.ts +20 -2
- package/src/resources/mex/actividad-vulnerable/jys/clients.ts +20 -2
- package/src/resources/mex/actividad-vulnerable/jys/reports.ts +118 -16
- package/src/resources/mex/actividad-vulnerable/jys/transactions.ts +20 -2
- package/src/resources/mex/actividad-vulnerable/tsc/clients.ts +20 -2
- package/src/resources/mex/actividad-vulnerable/tsc/reports.ts +118 -16
- package/src/resources/mex/actividad-vulnerable/tsc/transactions.ts +20 -2
- package/src/resources/mex/addresses.ts +24 -2
- package/src/resources/mex/bank-accounts.ts +26 -2
- package/src/resources/mex/clients.ts +25 -2
- package/src/resources/mex/reports.ts +94 -26
- package/src/resources/mex/transactions.ts +24 -2
- package/src/resources/reports.ts +65 -43
- package/src/resources/transactions.ts +8 -4
- package/src/sdk/ComplianceSDK.ts +23 -8
- package/src/sdk/mex/ComplianceSDK.ts +7 -0
- package/src/sdk/mex/actividad-vulnerable/avi/ComplianceSDK.ts +4 -0
- package/src/sdk/mex/actividad-vulnerable/avi/types.ts +22 -8
- package/src/sdk/mex/actividad-vulnerable/jys/ComplianceSDK.ts +3 -0
- package/src/sdk/mex/actividad-vulnerable/jys/types.ts +22 -8
- package/src/sdk/mex/actividad-vulnerable/tsc/ComplianceSDK.ts +3 -0
- package/src/sdk/mex/actividad-vulnerable/tsc/types.ts +22 -8
- package/src/sdk/mex/types.ts +6 -2
- package/src/sdk/types.ts +31 -2
- package/src/utils/environment.ts +42 -0
- package/src/utils/index.ts +19 -0
- package/src/utils/session.ts +33 -3
- package/src/utils/trpc-client.ts +10 -1
- package/src/utils/upload.ts +388 -0
|
@@ -21,11 +21,12 @@ import type {
|
|
|
21
21
|
PaginatedResponse,
|
|
22
22
|
AtomicBatchResult,
|
|
23
23
|
PartialBatchResult,
|
|
24
|
-
MexValidateReportInput,
|
|
25
24
|
MexSubmitReportInput,
|
|
26
25
|
ValidationResult,
|
|
27
26
|
GenerateResult,
|
|
28
27
|
SubmissionResult,
|
|
28
|
+
MexReportDefaultsInput,
|
|
29
|
+
ReportDefaultsInput,
|
|
29
30
|
} from "@artu-ai/shared";
|
|
30
31
|
import {
|
|
31
32
|
Jurisdiction,
|
|
@@ -33,11 +34,22 @@ import {
|
|
|
33
34
|
updateMexReportInputSchema,
|
|
34
35
|
createMexReportItemInputSchema,
|
|
35
36
|
updateMexReportItemInputSchema,
|
|
36
|
-
mexValidateReportInputSchema,
|
|
37
37
|
mexSubmitReportInputSchema,
|
|
38
|
+
transformSort,
|
|
39
|
+
mexReportFieldMapping,
|
|
40
|
+
mexReportDefaultsInputSchema,
|
|
38
41
|
} from "@artu-ai/shared";
|
|
39
|
-
import type {
|
|
40
|
-
|
|
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";
|
|
41
53
|
import { type BatchOptions } from "../clients";
|
|
42
54
|
import { MexReport, type ReportData, type ReportItemData } from "../../models";
|
|
43
55
|
import { MexReportItem } from "../../models/mex";
|
|
@@ -74,7 +86,10 @@ import { MexReportItem } from "../../models/mex";
|
|
|
74
86
|
* // data is MexReport[]
|
|
75
87
|
* ```
|
|
76
88
|
*/
|
|
77
|
-
export class MexReportsResource
|
|
89
|
+
export class MexReportsResource<
|
|
90
|
+
TSort = MexReportSort,
|
|
91
|
+
TDefaults = MexReportDefaultsInput,
|
|
92
|
+
> extends ReportsResource<TSort, TDefaults> {
|
|
78
93
|
// ─────────────────────────────────────────────────────────────────
|
|
79
94
|
// Report CRUD (override with flattened input types)
|
|
80
95
|
// ─────────────────────────────────────────────────────────────────
|
|
@@ -141,14 +156,16 @@ export class MexReportsResource extends ReportsResource {
|
|
|
141
156
|
* Automatically filters to reports with Mexico jurisdiction data.
|
|
142
157
|
*/
|
|
143
158
|
async list(
|
|
144
|
-
options?: ListOptions<MexReportFilter>
|
|
159
|
+
options?: ListOptions<MexReportFilter, TSort>
|
|
145
160
|
): Promise<PaginatedResponse<MexReport>> {
|
|
146
161
|
const scopedFilter = this.applyScopeToFilter(options?.filter);
|
|
162
|
+
const scopedSort = this.applyScopeToSort(options?.sort);
|
|
147
163
|
|
|
148
164
|
const response = await this.execute(() =>
|
|
149
165
|
this.trpc.reports.list.query({
|
|
150
166
|
...options,
|
|
151
167
|
filter: scopedFilter,
|
|
168
|
+
sort: scopedSort,
|
|
152
169
|
})
|
|
153
170
|
);
|
|
154
171
|
|
|
@@ -164,7 +181,9 @@ export class MexReportsResource extends ReportsResource {
|
|
|
164
181
|
* Accepts flattened MX filter (future MX-specific report fields at root level).
|
|
165
182
|
* Automatically filters to reports with Mexico jurisdiction data.
|
|
166
183
|
*/
|
|
167
|
-
iterate(
|
|
184
|
+
iterate(
|
|
185
|
+
filter?: MexReportFilter
|
|
186
|
+
): AsyncGenerator<MexReport, void, undefined> {
|
|
168
187
|
const scopedFilter = this.applyScopeToFilter(filter);
|
|
169
188
|
return this.createIterator<MexReport>({ filter: scopedFilter });
|
|
170
189
|
}
|
|
@@ -311,11 +330,11 @@ export class MexReportsResource extends ReportsResource {
|
|
|
311
330
|
}
|
|
312
331
|
|
|
313
332
|
/**
|
|
314
|
-
* Lists items in a report.
|
|
333
|
+
* Lists items in a report with filtering, sorting, and pagination.
|
|
315
334
|
*/
|
|
316
335
|
async listItems(
|
|
317
336
|
reportId: string,
|
|
318
|
-
options?: ListOptions<ReportItemFilter>
|
|
337
|
+
options?: ListOptions<ReportItemFilter, ReportItemSort>
|
|
319
338
|
): Promise<PaginatedResponse<MexReportItem>> {
|
|
320
339
|
const response = await this.execute(() =>
|
|
321
340
|
this.trpc.reports.listItems.query({
|
|
@@ -362,23 +381,32 @@ export class MexReportsResource extends ReportsResource {
|
|
|
362
381
|
*
|
|
363
382
|
* Uses Mexico-scoped validation input (jurisdiction is implicit).
|
|
364
383
|
*
|
|
384
|
+
* @param reportId - The report ID to validate
|
|
385
|
+
* @param defaults - Mexico report defaults including activity-specific settings
|
|
386
|
+
*
|
|
365
387
|
* @example
|
|
366
388
|
* ```typescript
|
|
367
|
-
* const result = await mexSdk.reports.validateReport({
|
|
368
|
-
*
|
|
369
|
-
* actividadVulnerable: "AVI",
|
|
370
|
-
* defaults: {
|
|
389
|
+
* const result = await mexSdk.reports.validateReport(report.id, {
|
|
390
|
+
* actividadVulnerable: {
|
|
371
391
|
* rfc: "ABC200101XXX",
|
|
372
|
-
*
|
|
392
|
+
* AVI: {
|
|
393
|
+
* platformDomain: "https://example.com",
|
|
394
|
+
* alertType: "100",
|
|
395
|
+
* },
|
|
373
396
|
* },
|
|
374
397
|
* });
|
|
375
398
|
* ```
|
|
376
399
|
*/
|
|
377
|
-
async validateReport(
|
|
378
|
-
|
|
400
|
+
override async validateReport(
|
|
401
|
+
reportId: string,
|
|
402
|
+
defaults: TDefaults
|
|
379
403
|
): Promise<ValidationResult> {
|
|
380
|
-
const validated = this.validate(
|
|
381
|
-
|
|
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));
|
|
382
410
|
}
|
|
383
411
|
|
|
384
412
|
// ─────────────────────────────────────────────────────────────────
|
|
@@ -391,22 +419,33 @@ export class MexReportsResource extends ReportsResource {
|
|
|
391
419
|
* Uses the same input as validateReport since generation requires
|
|
392
420
|
* the same transformation and defaults.
|
|
393
421
|
*
|
|
422
|
+
* @param reportId - The report ID to generate XML for
|
|
423
|
+
* @param defaults - Mexico report defaults including activity-specific settings
|
|
424
|
+
*
|
|
394
425
|
* @example
|
|
395
426
|
* ```typescript
|
|
396
|
-
* const result = await mexSdk.reports.generateReport({
|
|
397
|
-
*
|
|
398
|
-
* actividadVulnerable: "AVI",
|
|
399
|
-
* defaults: {
|
|
427
|
+
* const result = await mexSdk.reports.generateReport(report.id, {
|
|
428
|
+
* actividadVulnerable: {
|
|
400
429
|
* rfc: "ABC200101XXX",
|
|
401
|
-
*
|
|
430
|
+
* AVI: {
|
|
431
|
+
* platformDomain: "https://example.com",
|
|
432
|
+
* alertType: "100",
|
|
433
|
+
* },
|
|
402
434
|
* },
|
|
403
435
|
* });
|
|
404
436
|
* console.log(result.xml);
|
|
405
437
|
* ```
|
|
406
438
|
*/
|
|
407
|
-
async generateReport(
|
|
408
|
-
|
|
409
|
-
|
|
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));
|
|
410
449
|
}
|
|
411
450
|
|
|
412
451
|
// ─────────────────────────────────────────────────────────────────
|
|
@@ -476,6 +515,20 @@ export class MexReportsResource extends ReportsResource {
|
|
|
476
515
|
} as ReportFilter;
|
|
477
516
|
}
|
|
478
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
|
+
|
|
479
532
|
/**
|
|
480
533
|
* Transforms flattened MX input to nested API format.
|
|
481
534
|
*/
|
|
@@ -572,4 +625,19 @@ export class MexReportsResource extends ReportsResource {
|
|
|
572
625
|
},
|
|
573
626
|
} as UpdateReportItemInput;
|
|
574
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
|
+
}
|
|
575
643
|
}
|
|
@@ -13,6 +13,7 @@ import type {
|
|
|
13
13
|
CreateTransactionInput,
|
|
14
14
|
UpdateTransactionInput,
|
|
15
15
|
TransactionFilter,
|
|
16
|
+
TransactionSort,
|
|
16
17
|
ListOptions,
|
|
17
18
|
PaginatedResponse,
|
|
18
19
|
CreateMexTransactionInput,
|
|
@@ -21,12 +22,15 @@ import type {
|
|
|
21
22
|
PartialBatchResult,
|
|
22
23
|
RelatedClient,
|
|
23
24
|
MexTransactionFilter,
|
|
25
|
+
MexTransactionSort,
|
|
24
26
|
} from "@artu-ai/shared";
|
|
25
27
|
import {
|
|
26
28
|
Jurisdiction,
|
|
27
29
|
createMexTransactionInputSchema,
|
|
28
30
|
updateMexTransactionInputSchema,
|
|
29
31
|
ClientRole,
|
|
32
|
+
transformSort,
|
|
33
|
+
mexTransactionFieldMapping,
|
|
30
34
|
} from "@artu-ai/shared";
|
|
31
35
|
import { TransactionsResource } from "../transactions";
|
|
32
36
|
import { type BatchOptions } from "../clients";
|
|
@@ -67,7 +71,9 @@ import { MexTransaction, type TransactionData } from "../../models";
|
|
|
67
71
|
* // data is MexTransaction[]
|
|
68
72
|
* ```
|
|
69
73
|
*/
|
|
70
|
-
export class MexTransactionsResource
|
|
74
|
+
export class MexTransactionsResource<
|
|
75
|
+
TSort = MexTransactionSort,
|
|
76
|
+
> extends TransactionsResource<TSort> {
|
|
71
77
|
// ─────────────────────────────────────────────────────────────────
|
|
72
78
|
// CRUD Operations (override with flattened input types)
|
|
73
79
|
// ─────────────────────────────────────────────────────────────────
|
|
@@ -139,14 +145,16 @@ export class MexTransactionsResource extends TransactionsResource {
|
|
|
139
145
|
* Accepts flattened MX filter (future MX-specific transaction fields at root level).
|
|
140
146
|
*/
|
|
141
147
|
async list(
|
|
142
|
-
options?: ListOptions<MexTransactionFilter>
|
|
148
|
+
options?: ListOptions<MexTransactionFilter, TSort>
|
|
143
149
|
): Promise<PaginatedResponse<MexTransaction>> {
|
|
144
150
|
const scopedFilter = this.applyScopeToFilter(options?.filter);
|
|
151
|
+
const scopedSort = this.applyScopeToSort(options?.sort);
|
|
145
152
|
|
|
146
153
|
const response = await this.execute(() =>
|
|
147
154
|
this.trpc.transactions.list.query({
|
|
148
155
|
...options,
|
|
149
156
|
filter: scopedFilter,
|
|
157
|
+
sort: scopedSort,
|
|
150
158
|
})
|
|
151
159
|
);
|
|
152
160
|
|
|
@@ -345,6 +353,20 @@ export class MexTransactionsResource extends TransactionsResource {
|
|
|
345
353
|
} as TransactionFilter;
|
|
346
354
|
}
|
|
347
355
|
|
|
356
|
+
/**
|
|
357
|
+
* Transforms a flattened MexTransactionSort to nested TransactionSort format.
|
|
358
|
+
*
|
|
359
|
+
* Maps flattened field names to their full API paths.
|
|
360
|
+
*
|
|
361
|
+
* Note: Uses unknown parameter to allow derived classes to override with their own sort types.
|
|
362
|
+
*/
|
|
363
|
+
protected applyScopeToSort(sort?: TSort): TransactionSort | undefined {
|
|
364
|
+
if (!sort || !Array.isArray(sort) || sort.length === 0) {
|
|
365
|
+
return undefined;
|
|
366
|
+
}
|
|
367
|
+
return transformSort(sort as MexTransactionSort, mexTransactionFieldMapping);
|
|
368
|
+
}
|
|
369
|
+
|
|
348
370
|
/**
|
|
349
371
|
* Transforms flattened MX input to nested API format.
|
|
350
372
|
*/
|
package/src/resources/reports.ts
CHANGED
|
@@ -14,10 +14,13 @@ import { z } from "zod";
|
|
|
14
14
|
import type {
|
|
15
15
|
CreateReportInput,
|
|
16
16
|
UpdateReportInput,
|
|
17
|
+
UpdateReportStatusInput,
|
|
17
18
|
CreateReportItemInput,
|
|
18
19
|
UpdateReportItemInput,
|
|
19
20
|
ReportFilter,
|
|
21
|
+
ReportSort,
|
|
20
22
|
ReportItemFilter,
|
|
23
|
+
ReportItemSort,
|
|
21
24
|
ValidationResult,
|
|
22
25
|
GenerateResult,
|
|
23
26
|
SubmitReportInput,
|
|
@@ -26,14 +29,15 @@ import type {
|
|
|
26
29
|
PaginatedResponse,
|
|
27
30
|
AtomicBatchResult,
|
|
28
31
|
PartialBatchResult,
|
|
29
|
-
|
|
32
|
+
ReportDefaultsInput,
|
|
30
33
|
} from "@artu-ai/shared";
|
|
31
34
|
import {
|
|
32
35
|
createReportInputSchema,
|
|
33
36
|
updateReportInputSchema,
|
|
37
|
+
updateReportStatusInputSchema,
|
|
34
38
|
createReportItemInputSchema,
|
|
35
39
|
updateReportItemInputSchema,
|
|
36
|
-
|
|
40
|
+
reportDefaultsInputSchema,
|
|
37
41
|
submitReportInputSchema,
|
|
38
42
|
} from "@artu-ai/shared";
|
|
39
43
|
import type { BatchOptions } from "./clients";
|
|
@@ -50,7 +54,7 @@ import {
|
|
|
50
54
|
// ===========================
|
|
51
55
|
|
|
52
56
|
// Re-export filter types for backwards compatibility
|
|
53
|
-
export type { ReportFilter, ReportItemFilter };
|
|
57
|
+
export type { ReportFilter, ReportItemFilter, ReportItemSort };
|
|
54
58
|
|
|
55
59
|
/**
|
|
56
60
|
* Add items result
|
|
@@ -98,11 +102,15 @@ export interface AddItemsResult {
|
|
|
98
102
|
* }
|
|
99
103
|
* ```
|
|
100
104
|
*/
|
|
101
|
-
export class ReportsResource
|
|
105
|
+
export class ReportsResource<
|
|
106
|
+
TSort = ReportSort,
|
|
107
|
+
TDefaults = ReportDefaultsInput,
|
|
108
|
+
> extends BaseResource<
|
|
102
109
|
Report,
|
|
103
110
|
CreateReportInput,
|
|
104
111
|
UpdateReportInput,
|
|
105
|
-
ReportFilter
|
|
112
|
+
ReportFilter,
|
|
113
|
+
TSort
|
|
106
114
|
> {
|
|
107
115
|
// ─────────────────────────────────────────────────────────────────
|
|
108
116
|
// Report CRUD
|
|
@@ -166,6 +174,24 @@ export class ReportsResource extends BaseResource<
|
|
|
166
174
|
return this.instantiate(response);
|
|
167
175
|
}
|
|
168
176
|
|
|
177
|
+
/**
|
|
178
|
+
* Updates a report's status.
|
|
179
|
+
*
|
|
180
|
+
* Restrictions:
|
|
181
|
+
* - Can only manually set to: Draft
|
|
182
|
+
* - Cannot change from: Accepted (terminal), Submitted (awaiting response)
|
|
183
|
+
*
|
|
184
|
+
* Use this to reset a report back to Draft status for re-editing.
|
|
185
|
+
*/
|
|
186
|
+
async updateStatus(id: string, data: UpdateReportStatusInput): Promise<Report> {
|
|
187
|
+
const validated = this.validate(updateReportStatusInputSchema, data);
|
|
188
|
+
|
|
189
|
+
const response = await this.execute(() =>
|
|
190
|
+
this.trpc.reports.updateStatus.mutate({ id, data: validated })
|
|
191
|
+
);
|
|
192
|
+
return this.instantiate(response);
|
|
193
|
+
}
|
|
194
|
+
|
|
169
195
|
/**
|
|
170
196
|
* Deletes a report.
|
|
171
197
|
*/
|
|
@@ -177,10 +203,12 @@ export class ReportsResource extends BaseResource<
|
|
|
177
203
|
* Lists reports with optional filtering and pagination.
|
|
178
204
|
*/
|
|
179
205
|
async list(
|
|
180
|
-
options?: ListOptions<ReportFilter>
|
|
206
|
+
options?: ListOptions<ReportFilter, TSort>
|
|
181
207
|
): Promise<PaginatedResponse<Report>> {
|
|
182
208
|
const response = await this.execute(() =>
|
|
183
|
-
this.trpc.reports.list.query(
|
|
209
|
+
this.trpc.reports.list.query(
|
|
210
|
+
options as ListOptions<ReportFilter, ReportSort>
|
|
211
|
+
)
|
|
184
212
|
);
|
|
185
213
|
|
|
186
214
|
return {
|
|
@@ -252,11 +280,11 @@ export class ReportsResource extends BaseResource<
|
|
|
252
280
|
}
|
|
253
281
|
|
|
254
282
|
/**
|
|
255
|
-
* Lists items in a report.
|
|
283
|
+
* Lists items in a report with filtering, sorting, and pagination.
|
|
256
284
|
*/
|
|
257
285
|
async listItems(
|
|
258
286
|
reportId: string,
|
|
259
|
-
options?: ListOptions<ReportItemFilter>
|
|
287
|
+
options?: ListOptions<ReportItemFilter, ReportItemSort>
|
|
260
288
|
): Promise<PaginatedResponse<ReportItem>> {
|
|
261
289
|
const response = await this.execute(() =>
|
|
262
290
|
this.trpc.reports.listItems.query({
|
|
@@ -313,49 +341,43 @@ export class ReportsResource extends BaseResource<
|
|
|
313
341
|
/**
|
|
314
342
|
* Validates a report and its items.
|
|
315
343
|
*
|
|
316
|
-
* Requires jurisdiction
|
|
344
|
+
* Requires jurisdiction-specific defaults.
|
|
317
345
|
* For scoped SDKs, use the scoped resource which provides a simpler API.
|
|
318
346
|
*
|
|
319
|
-
* @
|
|
320
|
-
*
|
|
321
|
-
* const result = await sdk.reports.validateReport({
|
|
322
|
-
* reportId: report.id,
|
|
323
|
-
* jurisdiction: "MX",
|
|
324
|
-
* actividadVulnerable: "AVI",
|
|
325
|
-
* defaults: {
|
|
326
|
-
* rfc: "ABC200101XXX",
|
|
327
|
-
* platformDomain: "https://example.com",
|
|
328
|
-
* },
|
|
329
|
-
* });
|
|
330
|
-
* ```
|
|
347
|
+
* @param reportId - The report ID to validate
|
|
348
|
+
* @param defaults - Jurisdiction-specific defaults for validation
|
|
331
349
|
*/
|
|
332
|
-
async validateReport(
|
|
333
|
-
|
|
334
|
-
|
|
350
|
+
async validateReport(
|
|
351
|
+
reportId: string,
|
|
352
|
+
defaults: TDefaults
|
|
353
|
+
): Promise<ValidationResult> {
|
|
354
|
+
const validated = this.validate(reportDefaultsInputSchema, defaults);
|
|
355
|
+
return this.execute(() =>
|
|
356
|
+
this.trpc.reports.validate.mutate({ reportId, ...validated })
|
|
357
|
+
);
|
|
335
358
|
}
|
|
336
359
|
|
|
337
360
|
/**
|
|
338
|
-
*
|
|
361
|
+
* Validates and generates the report output (e.g., XML for Mexico reports).
|
|
339
362
|
*
|
|
340
|
-
*
|
|
341
|
-
*
|
|
363
|
+
* Performs validation first:
|
|
364
|
+
* - If validation fails, returns `{ status: "validation_failed", validation: {...} }`
|
|
365
|
+
* - If validation passes, returns `{ status: "success", xml: "...", ... }`
|
|
342
366
|
*
|
|
343
|
-
*
|
|
344
|
-
*
|
|
345
|
-
*
|
|
346
|
-
*
|
|
347
|
-
*
|
|
348
|
-
* actividadVulnerable: "AVI",
|
|
349
|
-
* defaults: {
|
|
350
|
-
* rfc: "ABC200101XXX",
|
|
351
|
-
* platformDomain: "https://example.com",
|
|
352
|
-
* },
|
|
353
|
-
* });
|
|
354
|
-
* ```
|
|
367
|
+
* Use `validateReport` for dry-run/preview validation without generating XML.
|
|
368
|
+
*
|
|
369
|
+
* @param reportId - The report ID to generate
|
|
370
|
+
* @param defaults - Jurisdiction-specific defaults for generation
|
|
371
|
+
* @returns GenerateResult with status "success" or "validation_failed"
|
|
355
372
|
*/
|
|
356
|
-
async
|
|
357
|
-
|
|
358
|
-
|
|
373
|
+
async generateReport(
|
|
374
|
+
reportId: string,
|
|
375
|
+
defaults: TDefaults
|
|
376
|
+
): Promise<GenerateResult> {
|
|
377
|
+
const validated = this.validate(reportDefaultsInputSchema, defaults);
|
|
378
|
+
return this.execute(() =>
|
|
379
|
+
this.trpc.reports.generate.mutate({ reportId, ...validated })
|
|
380
|
+
);
|
|
359
381
|
}
|
|
360
382
|
|
|
361
383
|
// ─────────────────────────────────────────────────────────────────
|
|
@@ -15,6 +15,7 @@ import type {
|
|
|
15
15
|
CreateTransactionInput,
|
|
16
16
|
UpdateTransactionInput,
|
|
17
17
|
TransactionFilter,
|
|
18
|
+
TransactionSort,
|
|
18
19
|
ListOptions,
|
|
19
20
|
PaginatedResponse,
|
|
20
21
|
AtomicBatchResult,
|
|
@@ -63,11 +64,14 @@ import { Transaction, type TransactionData } from "../models";
|
|
|
63
64
|
* });
|
|
64
65
|
* ```
|
|
65
66
|
*/
|
|
66
|
-
export class TransactionsResource
|
|
67
|
+
export class TransactionsResource<
|
|
68
|
+
TSort = TransactionSort,
|
|
69
|
+
> extends BaseResource<
|
|
67
70
|
Transaction,
|
|
68
71
|
CreateTransactionInput,
|
|
69
72
|
UpdateTransactionInput,
|
|
70
|
-
TransactionFilter
|
|
73
|
+
TransactionFilter,
|
|
74
|
+
TSort
|
|
71
75
|
> {
|
|
72
76
|
// ─────────────────────────────────────────────────────────────────
|
|
73
77
|
// CRUD Operations
|
|
@@ -146,10 +150,10 @@ export class TransactionsResource extends BaseResource<
|
|
|
146
150
|
* Lists transactions with optional filtering and pagination.
|
|
147
151
|
*/
|
|
148
152
|
async list(
|
|
149
|
-
options?: ListOptions<TransactionFilter>
|
|
153
|
+
options?: ListOptions<TransactionFilter, TSort>
|
|
150
154
|
): Promise<PaginatedResponse<Transaction>> {
|
|
151
155
|
const response = await this.execute(() =>
|
|
152
|
-
this.trpc.transactions.list.query(options)
|
|
156
|
+
this.trpc.transactions.list.query(options as ListOptions<TransactionFilter, TransactionSort>)
|
|
153
157
|
);
|
|
154
158
|
|
|
155
159
|
return {
|
package/src/sdk/ComplianceSDK.ts
CHANGED
|
@@ -49,7 +49,11 @@ import {
|
|
|
49
49
|
LATEST_API_VERSION,
|
|
50
50
|
DEFAULT_TIMEOUT,
|
|
51
51
|
} from "../utils/trpc-client";
|
|
52
|
-
import {
|
|
52
|
+
import {
|
|
53
|
+
resolveEnvironment,
|
|
54
|
+
resolveBaseUrl,
|
|
55
|
+
resolveOrganizationId,
|
|
56
|
+
} from "../utils/environment";
|
|
53
57
|
import {
|
|
54
58
|
type SDKScope,
|
|
55
59
|
type Environment,
|
|
@@ -254,6 +258,9 @@ export class ComplianceSDKImpl {
|
|
|
254
258
|
/** Custom headers (cookie mode, for server-side cookie forwarding) */
|
|
255
259
|
protected readonly _headers?: Record<string, string>;
|
|
256
260
|
|
|
261
|
+
/** Organization ID for session login (cookie mode) */
|
|
262
|
+
protected readonly _organizationId?: string;
|
|
263
|
+
|
|
257
264
|
// ===========================
|
|
258
265
|
// Resource Managers
|
|
259
266
|
// ===========================
|
|
@@ -408,6 +415,7 @@ export class ComplianceSDKImpl {
|
|
|
408
415
|
const {
|
|
409
416
|
environment,
|
|
410
417
|
baseUrl,
|
|
418
|
+
organizationId,
|
|
411
419
|
apiVersion = LATEST_API_VERSION,
|
|
412
420
|
timeout = DEFAULT_TIMEOUT,
|
|
413
421
|
jurisdiction,
|
|
@@ -467,11 +475,14 @@ export class ComplianceSDKImpl {
|
|
|
467
475
|
}
|
|
468
476
|
}
|
|
469
477
|
|
|
470
|
-
//
|
|
471
|
-
const
|
|
472
|
-
this._environment =
|
|
478
|
+
// Resolve environment (from options or env var, defaults to "test")
|
|
479
|
+
const resolvedEnv = resolveEnvironment(environment);
|
|
480
|
+
this._environment = resolvedEnv;
|
|
473
481
|
this._apiVersion = apiVersion;
|
|
474
482
|
|
|
483
|
+
// Resolve organization ID (from options or env var)
|
|
484
|
+
this._organizationId = organizationId ?? resolveOrganizationId();
|
|
485
|
+
|
|
475
486
|
// Validate actividadVulnerable requires Mexico jurisdiction
|
|
476
487
|
if (actividadVulnerable && jurisdiction !== Jurisdiction.Mexico) {
|
|
477
488
|
throw new Error(
|
|
@@ -482,7 +493,7 @@ export class ComplianceSDKImpl {
|
|
|
482
493
|
|
|
483
494
|
// Resolve base URL
|
|
484
495
|
const resolvedBaseUrl = resolveBaseUrl({
|
|
485
|
-
environment:
|
|
496
|
+
environment: resolvedEnv,
|
|
486
497
|
baseUrl,
|
|
487
498
|
});
|
|
488
499
|
|
|
@@ -500,18 +511,20 @@ export class ComplianceSDKImpl {
|
|
|
500
511
|
mode: authMode,
|
|
501
512
|
apiKey: resolvedApiKey as string,
|
|
502
513
|
baseUrl: resolvedBaseUrl,
|
|
503
|
-
environment:
|
|
514
|
+
environment: resolvedEnv as SDKEnvironment,
|
|
504
515
|
apiVersion,
|
|
505
516
|
timeout,
|
|
517
|
+
organizationId: this._organizationId,
|
|
506
518
|
}
|
|
507
519
|
: {
|
|
508
520
|
mode: authMode,
|
|
509
521
|
credentials: resolvedCredentials,
|
|
510
522
|
headers: resolvedHeaders,
|
|
511
523
|
baseUrl: resolvedBaseUrl,
|
|
512
|
-
environment:
|
|
524
|
+
environment: resolvedEnv as SDKEnvironment,
|
|
513
525
|
apiVersion,
|
|
514
526
|
timeout,
|
|
527
|
+
organizationId: this._organizationId,
|
|
515
528
|
};
|
|
516
529
|
|
|
517
530
|
this.trpc = createAPIClient(trpcConfig);
|
|
@@ -520,7 +533,7 @@ export class ComplianceSDKImpl {
|
|
|
520
533
|
const resourceConfig = {
|
|
521
534
|
trpc: this.trpc,
|
|
522
535
|
scope: this._scope,
|
|
523
|
-
environment:
|
|
536
|
+
environment: resolvedEnv,
|
|
524
537
|
};
|
|
525
538
|
const factories = getResourceFactories(this._scope);
|
|
526
539
|
|
|
@@ -726,6 +739,8 @@ export class ComplianceSDKImpl {
|
|
|
726
739
|
environment: this._environment,
|
|
727
740
|
credentials: this._credentials ?? "include",
|
|
728
741
|
headers: this._headers,
|
|
742
|
+
// Use provided organizationId or fall back to SDK-level config
|
|
743
|
+
organizationId: options?.organizationId ?? this._organizationId,
|
|
729
744
|
};
|
|
730
745
|
|
|
731
746
|
if (options?.returnTo) {
|
|
@@ -40,12 +40,19 @@ export class MexicoComplianceSDKImpl extends ComplianceSDKImpl {
|
|
|
40
40
|
// ─────────────────────────────────────────────────────────────────
|
|
41
41
|
// Override resource types with Mexico-specific types
|
|
42
42
|
// The registry creates these at runtime, we just need correct types
|
|
43
|
+
// Note: @ts-expect-error is needed due to sort type parameter variance
|
|
44
|
+
// (MexClientSort vs ClientSort in list method parameters)
|
|
43
45
|
// ─────────────────────────────────────────────────────────────────
|
|
44
46
|
|
|
47
|
+
// @ts-expect-error - Runtime type is correct, variance issue with sort types
|
|
45
48
|
declare public readonly clients: MexClientsResource;
|
|
49
|
+
// @ts-expect-error - Runtime type is correct, variance issue with sort types
|
|
46
50
|
declare public readonly transactions: MexTransactionsResource;
|
|
51
|
+
// @ts-expect-error - Runtime type is correct, variance issue with sort types
|
|
47
52
|
declare public readonly reports: MexReportsResource;
|
|
53
|
+
// @ts-expect-error - Runtime type is correct, variance issue with sort types
|
|
48
54
|
declare public readonly bankAccounts: MexBankAccountsResource;
|
|
55
|
+
// @ts-expect-error - Runtime type is correct, variance issue with sort types
|
|
49
56
|
declare public readonly addresses: MexAddressesResource;
|
|
50
57
|
|
|
51
58
|
/**
|
|
@@ -40,8 +40,12 @@ import type { AVIReportsResource } from "../../../../resources/mex/actividad-vul
|
|
|
40
40
|
export class AVIComplianceSDKScoped extends MexicoComplianceSDKScoped {
|
|
41
41
|
// Override resource types with AVI-specific types
|
|
42
42
|
// The registry creates these at runtime, we just need correct types
|
|
43
|
+
// Note: @ts-expect-error is needed due to sort type parameter variance
|
|
44
|
+
// @ts-expect-error - Runtime type is correct, variance issue with sort types
|
|
43
45
|
declare public readonly clients: AVIClientsResource;
|
|
46
|
+
// @ts-expect-error - Runtime type is correct, variance issue with sort types
|
|
44
47
|
declare public readonly transactions: AVITransactionsResource;
|
|
48
|
+
// @ts-expect-error - Runtime type is correct, variance issue with sort types
|
|
45
49
|
declare public readonly reports: AVIReportsResource;
|
|
46
50
|
// addresses and bankAccounts inherited from MexicoComplianceSDKImpl (MexAddressesResource, MexBankAccountsResource)
|
|
47
51
|
|