@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.
- 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
|
@@ -29,13 +29,17 @@ import type {
|
|
|
29
29
|
SyncItem,
|
|
30
30
|
SyncResult,
|
|
31
31
|
TSCClientFilter,
|
|
32
|
+
TSCClientSort,
|
|
32
33
|
} from "@artu-ai/shared";
|
|
33
34
|
import {
|
|
34
35
|
CodigoActividad,
|
|
35
36
|
createTSCClientInputSchema,
|
|
36
37
|
updateTSCClientInputSchema,
|
|
37
38
|
linkedClientSchema,
|
|
39
|
+
transformSort,
|
|
40
|
+
tscClientFieldMapping,
|
|
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 MexTSCClient
|
|
73
77
|
* ```
|
|
74
78
|
*/
|
|
75
|
-
export class TSCClientsResource extends MexClientsResource {
|
|
79
|
+
export class TSCClientsResource extends MexClientsResource<TSCClientSort> {
|
|
76
80
|
// ─────────────────────────────────────────────────────────────────
|
|
77
81
|
// CRUD Operations
|
|
78
82
|
// ─────────────────────────────────────────────────────────────────
|
|
@@ -126,14 +130,16 @@ export class TSCClientsResource extends MexClientsResource {
|
|
|
126
130
|
* transforms to nested format before calling the API.
|
|
127
131
|
*/
|
|
128
132
|
async list(
|
|
129
|
-
options?: ListOptions<TSCClientFilter> & { includePrimaryContacts?: boolean }
|
|
133
|
+
options?: ListOptions<TSCClientFilter, TSCClientSort> & { includePrimaryContacts?: boolean }
|
|
130
134
|
): Promise<PaginatedResponse<MexTSCClient>> {
|
|
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
|
|
|
@@ -424,4 +430,16 @@ export class TSCClientsResource extends MexClientsResource {
|
|
|
424
430
|
protected override instantiate(data: ClientData): MexTSCClient {
|
|
425
431
|
return new MexTSCClient(data);
|
|
426
432
|
}
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* Transforms a flattened TSCClientSort to nested ClientSort format.
|
|
436
|
+
*
|
|
437
|
+
* Maps flattened field names to their full API paths using TSC-specific field mapping.
|
|
438
|
+
*/
|
|
439
|
+
protected override applyScopeToSort(sort?: TSCClientSort): ClientSort | undefined {
|
|
440
|
+
if (!sort || sort.length === 0) {
|
|
441
|
+
return undefined;
|
|
442
|
+
}
|
|
443
|
+
return transformSort(sort, tscClientFieldMapping);
|
|
444
|
+
}
|
|
427
445
|
}
|
|
@@ -20,7 +20,7 @@ import type {
|
|
|
20
20
|
PaginatedResponse,
|
|
21
21
|
AtomicBatchResult,
|
|
22
22
|
PartialBatchResult,
|
|
23
|
-
|
|
23
|
+
TscReportDefaultsInput,
|
|
24
24
|
ValidationResult,
|
|
25
25
|
GenerateResult,
|
|
26
26
|
SubmissionResult,
|
|
@@ -32,12 +32,20 @@ import {
|
|
|
32
32
|
updateTSCReportInputSchema,
|
|
33
33
|
createTSCReportItemInputSchema,
|
|
34
34
|
updateTSCReportItemInputSchema,
|
|
35
|
-
|
|
35
|
+
tscDefaultsInputSchema,
|
|
36
36
|
submitTSCSubmissionInputSchema,
|
|
37
|
+
transformSort,
|
|
38
|
+
tscReportFieldMapping,
|
|
39
|
+
} from "@artu-ai/shared";
|
|
40
|
+
import type {
|
|
41
|
+
TSCReportFilter,
|
|
42
|
+
TSCReportSort,
|
|
43
|
+
TSCReportItemFilter,
|
|
44
|
+
ReportSort,
|
|
45
|
+
ReportItemFilter,
|
|
46
|
+
ReportItemSort,
|
|
37
47
|
} from "@artu-ai/shared";
|
|
38
|
-
import type { TSCReportFilter } 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
|
MexTSCReport,
|
|
@@ -70,7 +78,7 @@ import {
|
|
|
70
78
|
* console.log(report.mesReportado);
|
|
71
79
|
* ```
|
|
72
80
|
*/
|
|
73
|
-
export class TSCReportsResource extends MexReportsResource {
|
|
81
|
+
export class TSCReportsResource extends MexReportsResource<TSCReportSort, TscReportDefaultsInput> {
|
|
74
82
|
// ─────────────────────────────────────────────────────────────────
|
|
75
83
|
// Report CRUD
|
|
76
84
|
// ─────────────────────────────────────────────────────────────────
|
|
@@ -127,14 +135,16 @@ export class TSCReportsResource extends MexReportsResource {
|
|
|
127
135
|
* Accepts flattened TSC filter (future TSC-specific report fields at root level).
|
|
128
136
|
*/
|
|
129
137
|
async list(
|
|
130
|
-
options?: ListOptions<TSCReportFilter>
|
|
138
|
+
options?: ListOptions<TSCReportFilter, TSCReportSort>
|
|
131
139
|
): Promise<PaginatedResponse<MexTSCReport>> {
|
|
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 TSCReportsResource extends MexReportsResource {
|
|
|
294
304
|
|
|
295
305
|
async listItems(
|
|
296
306
|
reportId: string,
|
|
297
|
-
options?: ListOptions<
|
|
307
|
+
options?: ListOptions<TSCReportItemFilter, ReportItemSort>
|
|
298
308
|
): Promise<PaginatedResponse<MexTSCReportItem>> {
|
|
309
|
+
// Transform flattened TSC 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 TSCReportsResource extends MexReportsResource {
|
|
|
309
323
|
};
|
|
310
324
|
}
|
|
311
325
|
|
|
326
|
+
/**
|
|
327
|
+
* Transforms a flattened TSCReportItemFilter to nested ReportItemFilter format.
|
|
328
|
+
*/
|
|
329
|
+
protected applyScopeToItemFilter(
|
|
330
|
+
filter?: TSCReportItemFilter
|
|
331
|
+
): ReportItemFilter | undefined {
|
|
332
|
+
if (!filter) return undefined;
|
|
333
|
+
|
|
334
|
+
const { alertType, alertDescription, ...baseFields } = filter;
|
|
335
|
+
|
|
336
|
+
// If no TSC-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 tscFilter: Record<string, unknown> = {};
|
|
343
|
+
if (alertType !== undefined) tscFilter.alertType = alertType;
|
|
344
|
+
if (alertDescription !== undefined) tscFilter.alertDescription = alertDescription;
|
|
345
|
+
|
|
346
|
+
return {
|
|
347
|
+
...baseFields,
|
|
348
|
+
jurisdictions: {
|
|
349
|
+
MX: {
|
|
350
|
+
actividadVulnerable: {
|
|
351
|
+
TSC: tscFilter,
|
|
352
|
+
},
|
|
353
|
+
},
|
|
354
|
+
},
|
|
355
|
+
} as ReportItemFilter;
|
|
356
|
+
}
|
|
357
|
+
|
|
312
358
|
async addItems(
|
|
313
359
|
reportId: string,
|
|
314
360
|
items: CreateTSCReportItemInput[]
|
|
@@ -338,19 +384,28 @@ export class TSCReportsResource extends MexReportsResource {
|
|
|
338
384
|
*
|
|
339
385
|
* Uses TSC-scoped validation input (jurisdiction and activity are implicit).
|
|
340
386
|
*
|
|
387
|
+
* @param reportId - The report ID to validate
|
|
388
|
+
* @param defaults - TSC report defaults including rfc, alertType, etc.
|
|
389
|
+
*
|
|
341
390
|
* @example
|
|
342
391
|
* ```typescript
|
|
343
|
-
* const result = await tscSdk.reports.validateReport({
|
|
344
|
-
*
|
|
345
|
-
*
|
|
392
|
+
* const result = await tscSdk.reports.validateReport(report.id, {
|
|
393
|
+
* rfc: "ABC200101XXX",
|
|
394
|
+
* alertType: "100",
|
|
346
395
|
* });
|
|
347
396
|
* ```
|
|
348
397
|
*/
|
|
349
398
|
override async validateReport(
|
|
350
|
-
|
|
399
|
+
reportId: string,
|
|
400
|
+
defaults: TscReportDefaultsInput
|
|
351
401
|
): Promise<ValidationResult> {
|
|
352
|
-
const validated = this.validate(
|
|
353
|
-
|
|
402
|
+
const validated = this.validate(tscDefaultsInputSchema, defaults);
|
|
403
|
+
const nestedInput = this.transformTscDefaultsToNested(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 TSCReportsResource extends MexReportsResource {
|
|
|
361
416
|
* Generates XML for a TSC 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 - TSC report defaults including rfc, alertType, etc.
|
|
364
422
|
*/
|
|
365
423
|
override async generateReport(
|
|
366
|
-
|
|
424
|
+
reportId: string,
|
|
425
|
+
defaults: TscReportDefaultsInput
|
|
367
426
|
): Promise<GenerateResult> {
|
|
368
|
-
const validated = this.validate(
|
|
369
|
-
|
|
427
|
+
const validated = this.validate(tscDefaultsInputSchema, defaults);
|
|
428
|
+
const nestedInput = this.transformTscDefaultsToNested(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
|
// ─────────────────────────────────────────────────────────────────
|
|
@@ -486,4 +550,42 @@ export class TSCReportsResource extends MexReportsResource {
|
|
|
486
550
|
},
|
|
487
551
|
} as UpdateReportItemInput;
|
|
488
552
|
}
|
|
553
|
+
|
|
554
|
+
/**
|
|
555
|
+
* Transforms a flattened TSCReportSort to nested ReportSort format.
|
|
556
|
+
*
|
|
557
|
+
* Maps flattened field names to their full API paths using TSC-specific field mapping.
|
|
558
|
+
*/
|
|
559
|
+
protected override applyScopeToSort(sort?: TSCReportSort): ReportSort | undefined {
|
|
560
|
+
if (!sort || sort.length === 0) {
|
|
561
|
+
return undefined;
|
|
562
|
+
}
|
|
563
|
+
return transformSort(sort, tscReportFieldMapping);
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* Transforms TSC defaults to nested API format for validate/generate.
|
|
568
|
+
*/
|
|
569
|
+
protected transformTscDefaultsToNested(
|
|
570
|
+
reportId: string,
|
|
571
|
+
defaults: TscReportDefaultsInput
|
|
572
|
+
): { reportId: string; jurisdictions: unknown } {
|
|
573
|
+
const { rfc, collegiateEntityCode, exempt, priority, ...tscFields } =
|
|
574
|
+
defaults;
|
|
575
|
+
|
|
576
|
+
return {
|
|
577
|
+
reportId,
|
|
578
|
+
jurisdictions: {
|
|
579
|
+
MX: {
|
|
580
|
+
actividadVulnerable: {
|
|
581
|
+
rfc,
|
|
582
|
+
collegiateEntityCode,
|
|
583
|
+
exempt,
|
|
584
|
+
priority,
|
|
585
|
+
[CodigoActividad.TSC]: tscFields,
|
|
586
|
+
},
|
|
587
|
+
},
|
|
588
|
+
},
|
|
589
|
+
};
|
|
590
|
+
}
|
|
489
591
|
}
|
|
@@ -18,6 +18,7 @@ import type {
|
|
|
18
18
|
PartialBatchResult,
|
|
19
19
|
RelatedClient,
|
|
20
20
|
TSCTransactionFilter,
|
|
21
|
+
TSCTransactionSort,
|
|
21
22
|
} from "@artu-ai/shared";
|
|
22
23
|
import {
|
|
23
24
|
Jurisdiction,
|
|
@@ -25,7 +26,10 @@ import {
|
|
|
25
26
|
createTSCTransactionInputSchema,
|
|
26
27
|
updateTSCTransactionInputSchema,
|
|
27
28
|
ClientRole,
|
|
29
|
+
transformSort,
|
|
30
|
+
tscTransactionFieldMapping,
|
|
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 { MexTSCTransaction, type TransactionData } from "../../../../models";
|
|
@@ -59,7 +63,7 @@ import { MexTSCTransaction, type TransactionData } from "../../../../models";
|
|
|
59
63
|
* console.log(txn.cardType);
|
|
60
64
|
* ```
|
|
61
65
|
*/
|
|
62
|
-
export class TSCTransactionsResource extends MexTransactionsResource {
|
|
66
|
+
export class TSCTransactionsResource extends MexTransactionsResource<TSCTransactionSort> {
|
|
63
67
|
// ─────────────────────────────────────────────────────────────────
|
|
64
68
|
// CRUD Operations
|
|
65
69
|
// ─────────────────────────────────────────────────────────────────
|
|
@@ -115,14 +119,16 @@ export class TSCTransactionsResource extends MexTransactionsResource {
|
|
|
115
119
|
* Accepts flattened TSC filter (future TSC-specific transaction fields at root level).
|
|
116
120
|
*/
|
|
117
121
|
async list(
|
|
118
|
-
options?: ListOptions<TSCTransactionFilter>
|
|
122
|
+
options?: ListOptions<TSCTransactionFilter, TSCTransactionSort>
|
|
119
123
|
): Promise<PaginatedResponse<MexTSCTransaction>> {
|
|
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
|
|
|
@@ -383,4 +389,16 @@ export class TSCTransactionsResource extends MexTransactionsResource {
|
|
|
383
389
|
protected override instantiate(data: TransactionData): MexTSCTransaction {
|
|
384
390
|
return new MexTSCTransaction(data);
|
|
385
391
|
}
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* Transforms a flattened TSCTransactionSort to nested TransactionSort format.
|
|
395
|
+
*
|
|
396
|
+
* Maps flattened field names to their full API paths using TSC-specific field mapping.
|
|
397
|
+
*/
|
|
398
|
+
protected override applyScopeToSort(sort?: TSCTransactionSort): TransactionSort | undefined {
|
|
399
|
+
if (!sort || sort.length === 0) {
|
|
400
|
+
return undefined;
|
|
401
|
+
}
|
|
402
|
+
return transformSort(sort, tscTransactionFieldMapping);
|
|
403
|
+
}
|
|
386
404
|
}
|
|
@@ -13,6 +13,7 @@ import type {
|
|
|
13
13
|
CreateAddressInput,
|
|
14
14
|
UpdateAddressInput,
|
|
15
15
|
AddressFilter,
|
|
16
|
+
AddressSort,
|
|
16
17
|
AddressType,
|
|
17
18
|
ListOptions,
|
|
18
19
|
PaginatedResponse,
|
|
@@ -23,11 +24,14 @@ import type {
|
|
|
23
24
|
SyncItem,
|
|
24
25
|
SyncResult,
|
|
25
26
|
MexAddressFilter,
|
|
27
|
+
MexAddressSort,
|
|
26
28
|
} from "@artu-ai/shared";
|
|
27
29
|
import {
|
|
28
30
|
createMexAddressInputSchema,
|
|
29
31
|
updateMexAddressInputSchema,
|
|
30
32
|
replaceSyncItemSchema,
|
|
33
|
+
transformSort,
|
|
34
|
+
mexAddressFieldMapping,
|
|
31
35
|
} from "@artu-ai/shared";
|
|
32
36
|
import { AddressesResource } from "../addresses";
|
|
33
37
|
import { type BatchOptions } from "../clients";
|
|
@@ -71,7 +75,9 @@ import { MexAddress, type AddressData } from "../../models";
|
|
|
71
75
|
* console.log(address.formattedMexican);
|
|
72
76
|
* ```
|
|
73
77
|
*/
|
|
74
|
-
export class MexAddressesResource
|
|
78
|
+
export class MexAddressesResource<
|
|
79
|
+
TSort = MexAddressSort,
|
|
80
|
+
> extends AddressesResource<TSort> {
|
|
75
81
|
// ─────────────────────────────────────────────────────────────────
|
|
76
82
|
// CRUD Operations (override with flattened input types)
|
|
77
83
|
// ─────────────────────────────────────────────────────────────────
|
|
@@ -137,14 +143,16 @@ export class MexAddressesResource extends AddressesResource {
|
|
|
137
143
|
* Accepts flattened MX filter (MX-specific fields at root level).
|
|
138
144
|
*/
|
|
139
145
|
async list(
|
|
140
|
-
options?: ListOptions<MexAddressFilter>
|
|
146
|
+
options?: ListOptions<MexAddressFilter, TSort>
|
|
141
147
|
): Promise<PaginatedResponse<MexAddress>> {
|
|
142
148
|
const scopedFilter = this.applyScopeToFilter(options?.filter);
|
|
149
|
+
const scopedSort = this.applyScopeToSort(options?.sort);
|
|
143
150
|
|
|
144
151
|
const response = await this.execute(() =>
|
|
145
152
|
this.trpc.addresses.list.query({
|
|
146
153
|
...options,
|
|
147
154
|
filter: scopedFilter,
|
|
155
|
+
sort: scopedSort,
|
|
148
156
|
})
|
|
149
157
|
);
|
|
150
158
|
|
|
@@ -382,6 +390,20 @@ export class MexAddressesResource extends AddressesResource {
|
|
|
382
390
|
} as AddressFilter;
|
|
383
391
|
}
|
|
384
392
|
|
|
393
|
+
/**
|
|
394
|
+
* Transforms a flattened MexAddressSort to nested AddressSort format.
|
|
395
|
+
*
|
|
396
|
+
* Maps flattened field names to their full API paths.
|
|
397
|
+
*
|
|
398
|
+
* Note: Uses unknown parameter to allow derived classes to override with their own sort types.
|
|
399
|
+
*/
|
|
400
|
+
protected applyScopeToSort(sort?: TSort): AddressSort | undefined {
|
|
401
|
+
if (!sort || !Array.isArray(sort) || sort.length === 0) {
|
|
402
|
+
return undefined;
|
|
403
|
+
}
|
|
404
|
+
return transformSort(sort as MexAddressSort, mexAddressFieldMapping);
|
|
405
|
+
}
|
|
406
|
+
|
|
385
407
|
/**
|
|
386
408
|
* Transforms flattened MX input to nested API format.
|
|
387
409
|
*
|
|
@@ -9,6 +9,7 @@ import type {
|
|
|
9
9
|
CreateBankAccountInput,
|
|
10
10
|
UpdateBankAccountInput,
|
|
11
11
|
BankAccountFilter,
|
|
12
|
+
BankAccountSort,
|
|
12
13
|
ListOptions,
|
|
13
14
|
PaginatedResponse,
|
|
14
15
|
AtomicBatchResult,
|
|
@@ -16,6 +17,11 @@ import type {
|
|
|
16
17
|
SyncItem,
|
|
17
18
|
SyncResult,
|
|
18
19
|
MexBankAccountFilter,
|
|
20
|
+
MexBankAccountSort,
|
|
21
|
+
} from "@artu-ai/shared";
|
|
22
|
+
import {
|
|
23
|
+
transformSort,
|
|
24
|
+
mexBankAccountFieldMapping,
|
|
19
25
|
} from "@artu-ai/shared";
|
|
20
26
|
import { BankAccountsResource } from "../bank-accounts";
|
|
21
27
|
import { type BatchOptions } from "../clients";
|
|
@@ -51,7 +57,9 @@ import { MexBankAccount, type BankAccountData } from "../../models";
|
|
|
51
57
|
* console.log(account.maskedClabe); // "**************7890"
|
|
52
58
|
* ```
|
|
53
59
|
*/
|
|
54
|
-
export class MexBankAccountsResource
|
|
60
|
+
export class MexBankAccountsResource<
|
|
61
|
+
TSort = MexBankAccountSort,
|
|
62
|
+
> extends BankAccountsResource<TSort> {
|
|
55
63
|
// ─────────────────────────────────────────────────────────────────
|
|
56
64
|
// CRUD Operations (override return types)
|
|
57
65
|
// ─────────────────────────────────────────────────────────────────
|
|
@@ -94,14 +102,16 @@ export class MexBankAccountsResource extends BankAccountsResource {
|
|
|
94
102
|
* Accepts flattened MX filter (MX-specific fields at root level).
|
|
95
103
|
*/
|
|
96
104
|
async list(
|
|
97
|
-
options?: ListOptions<MexBankAccountFilter>
|
|
105
|
+
options?: ListOptions<MexBankAccountFilter, TSort>
|
|
98
106
|
): Promise<PaginatedResponse<MexBankAccount>> {
|
|
99
107
|
const scopedFilter = this.applyScopeToFilter(options?.filter);
|
|
108
|
+
const scopedSort = this.applyScopeToSort(options?.sort);
|
|
100
109
|
|
|
101
110
|
const response = await this.execute(() =>
|
|
102
111
|
this.trpc.bankAccounts.list.query({
|
|
103
112
|
...options,
|
|
104
113
|
filter: scopedFilter,
|
|
114
|
+
sort: scopedSort,
|
|
105
115
|
})
|
|
106
116
|
);
|
|
107
117
|
|
|
@@ -253,6 +263,20 @@ export class MexBankAccountsResource extends BankAccountsResource {
|
|
|
253
263
|
} as BankAccountFilter;
|
|
254
264
|
}
|
|
255
265
|
|
|
266
|
+
/**
|
|
267
|
+
* Transforms a flattened MexBankAccountSort to nested BankAccountSort format.
|
|
268
|
+
*
|
|
269
|
+
* Maps flattened field names to their full API paths.
|
|
270
|
+
*
|
|
271
|
+
* Note: Uses unknown parameter to allow derived classes to override with their own sort types.
|
|
272
|
+
*/
|
|
273
|
+
protected applyScopeToSort(sort?: TSort): BankAccountSort | undefined {
|
|
274
|
+
if (!sort || !Array.isArray(sort) || sort.length === 0) {
|
|
275
|
+
return undefined;
|
|
276
|
+
}
|
|
277
|
+
return transformSort(sort as MexBankAccountSort, mexBankAccountFieldMapping);
|
|
278
|
+
}
|
|
279
|
+
|
|
256
280
|
protected override instantiate(data: BankAccountData): MexBankAccount {
|
|
257
281
|
return new MexBankAccount(data);
|
|
258
282
|
}
|
|
@@ -13,6 +13,7 @@ import type {
|
|
|
13
13
|
CreateClientInput,
|
|
14
14
|
UpdateClientInput,
|
|
15
15
|
ClientFilter,
|
|
16
|
+
ClientSort,
|
|
16
17
|
ListOptions,
|
|
17
18
|
PaginatedResponse,
|
|
18
19
|
CreateMexClientInput,
|
|
@@ -32,6 +33,7 @@ import type {
|
|
|
32
33
|
SyncItem,
|
|
33
34
|
SyncResult,
|
|
34
35
|
MexClientFilter,
|
|
36
|
+
MexClientSort,
|
|
35
37
|
} from "@artu-ai/shared";
|
|
36
38
|
import {
|
|
37
39
|
Jurisdiction,
|
|
@@ -45,6 +47,8 @@ import {
|
|
|
45
47
|
createBankAccountInputSchema,
|
|
46
48
|
updateBankAccountInputSchema,
|
|
47
49
|
replaceSyncItemSchema,
|
|
50
|
+
transformSort,
|
|
51
|
+
mexClientFieldMapping,
|
|
48
52
|
} from "@artu-ai/shared";
|
|
49
53
|
import {
|
|
50
54
|
ClientsResource,
|
|
@@ -96,7 +100,9 @@ import {
|
|
|
96
100
|
* // data is MexClient[]
|
|
97
101
|
* ```
|
|
98
102
|
*/
|
|
99
|
-
export class MexClientsResource
|
|
103
|
+
export class MexClientsResource<
|
|
104
|
+
TSort = MexClientSort,
|
|
105
|
+
> extends ClientsResource<TSort> {
|
|
100
106
|
// ─────────────────────────────────────────────────────────────────
|
|
101
107
|
// CRUD Operations (override with flattened input types)
|
|
102
108
|
// ─────────────────────────────────────────────────────────────────
|
|
@@ -173,14 +179,16 @@ export class MexClientsResource extends ClientsResource {
|
|
|
173
179
|
* ```
|
|
174
180
|
*/
|
|
175
181
|
async list(
|
|
176
|
-
options?: ListOptions<MexClientFilter> & { includePrimaryContacts?: boolean }
|
|
182
|
+
options?: ListOptions<MexClientFilter, TSort> & { includePrimaryContacts?: boolean }
|
|
177
183
|
): Promise<PaginatedResponse<MexClient>> {
|
|
178
184
|
const scopedFilter = this.applyScopeToFilter(options?.filter);
|
|
185
|
+
const scopedSort = this.applyScopeToSort(options?.sort);
|
|
179
186
|
|
|
180
187
|
const response = await this.execute(() =>
|
|
181
188
|
this.trpc.clients.list.query({
|
|
182
189
|
...options,
|
|
183
190
|
filter: scopedFilter,
|
|
191
|
+
sort: scopedSort,
|
|
184
192
|
})
|
|
185
193
|
);
|
|
186
194
|
|
|
@@ -553,6 +561,21 @@ export class MexClientsResource extends ClientsResource {
|
|
|
553
561
|
} as ClientFilter;
|
|
554
562
|
}
|
|
555
563
|
|
|
564
|
+
/**
|
|
565
|
+
* Transforms a flattened MexClientSort to nested ClientSort format.
|
|
566
|
+
*
|
|
567
|
+
* Maps flattened field names (rfc, curp, actividadVulnerable.AVI.username)
|
|
568
|
+
* to their full API paths (jurisdictions.MX.rfc, etc.).
|
|
569
|
+
*
|
|
570
|
+
* Note: Uses unknown parameter to allow derived classes to override with their own sort types.
|
|
571
|
+
*/
|
|
572
|
+
protected applyScopeToSort(sort?: TSort): ClientSort | undefined {
|
|
573
|
+
if (!sort || !Array.isArray(sort) || sort.length === 0) {
|
|
574
|
+
return undefined;
|
|
575
|
+
}
|
|
576
|
+
return transformSort(sort as MexClientSort, mexClientFieldMapping);
|
|
577
|
+
}
|
|
578
|
+
|
|
556
579
|
/**
|
|
557
580
|
* Transforms flattened MX input to nested API format.
|
|
558
581
|
*/
|