@artu-ai/compliance-sdk 0.5.4 → 0.6.1
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/errors/validation.d.ts.map +1 -1
- package/dist/errors/validation.js +19 -1
- package/dist/resources/addresses.d.ts +29 -2
- package/dist/resources/addresses.d.ts.map +1 -1
- package/dist/resources/addresses.js +65 -4
- package/dist/resources/bank-accounts.d.ts +29 -2
- package/dist/resources/bank-accounts.d.ts.map +1 -1
- package/dist/resources/bank-accounts.js +65 -4
- package/dist/resources/clients.d.ts +59 -4
- package/dist/resources/clients.d.ts.map +1 -1
- package/dist/resources/clients.js +85 -8
- package/dist/resources/contact-methods.d.ts +29 -2
- package/dist/resources/contact-methods.d.ts.map +1 -1
- package/dist/resources/contact-methods.js +65 -4
- package/dist/resources/documents.d.ts +24 -19
- package/dist/resources/documents.d.ts.map +1 -1
- package/dist/resources/documents.js +51 -1
- package/dist/resources/mex/actividad-vulnerable/avi/clients.d.ts +31 -5
- package/dist/resources/mex/actividad-vulnerable/avi/clients.d.ts.map +1 -1
- package/dist/resources/mex/actividad-vulnerable/avi/clients.js +65 -9
- package/dist/resources/mex/actividad-vulnerable/avi/reports.d.ts +26 -2
- package/dist/resources/mex/actividad-vulnerable/avi/reports.d.ts.map +1 -1
- package/dist/resources/mex/actividad-vulnerable/avi/reports.js +58 -4
- package/dist/resources/mex/actividad-vulnerable/avi/transactions.d.ts +26 -2
- package/dist/resources/mex/actividad-vulnerable/avi/transactions.d.ts.map +1 -1
- package/dist/resources/mex/actividad-vulnerable/avi/transactions.js +58 -4
- package/dist/resources/mex/actividad-vulnerable/jys/clients.d.ts +26 -2
- package/dist/resources/mex/actividad-vulnerable/jys/clients.d.ts.map +1 -1
- package/dist/resources/mex/actividad-vulnerable/jys/clients.js +58 -4
- package/dist/resources/mex/actividad-vulnerable/jys/reports.d.ts +26 -2
- package/dist/resources/mex/actividad-vulnerable/jys/reports.d.ts.map +1 -1
- package/dist/resources/mex/actividad-vulnerable/jys/reports.js +58 -4
- package/dist/resources/mex/actividad-vulnerable/jys/transactions.d.ts +26 -2
- package/dist/resources/mex/actividad-vulnerable/jys/transactions.d.ts.map +1 -1
- package/dist/resources/mex/actividad-vulnerable/jys/transactions.js +58 -4
- package/dist/resources/mex/actividad-vulnerable/tsc/clients.d.ts +26 -2
- package/dist/resources/mex/actividad-vulnerable/tsc/clients.d.ts.map +1 -1
- package/dist/resources/mex/actividad-vulnerable/tsc/clients.js +58 -4
- package/dist/resources/mex/actividad-vulnerable/tsc/reports.d.ts +26 -2
- package/dist/resources/mex/actividad-vulnerable/tsc/reports.d.ts.map +1 -1
- package/dist/resources/mex/actividad-vulnerable/tsc/reports.js +58 -4
- package/dist/resources/mex/actividad-vulnerable/tsc/transactions.d.ts +26 -2
- package/dist/resources/mex/actividad-vulnerable/tsc/transactions.d.ts.map +1 -1
- package/dist/resources/mex/actividad-vulnerable/tsc/transactions.js +58 -4
- package/dist/resources/mex/addresses.d.ts +26 -2
- package/dist/resources/mex/addresses.d.ts.map +1 -1
- package/dist/resources/mex/addresses.js +66 -5
- package/dist/resources/mex/bank-accounts.d.ts +13 -2
- package/dist/resources/mex/bank-accounts.d.ts.map +1 -1
- package/dist/resources/mex/bank-accounts.js +17 -3
- package/dist/resources/mex/clients.d.ts +39 -11
- package/dist/resources/mex/clients.d.ts.map +1 -1
- package/dist/resources/mex/clients.js +82 -20
- package/dist/resources/mex/reports.d.ts +37 -12
- package/dist/resources/mex/reports.d.ts.map +1 -1
- package/dist/resources/mex/reports.js +71 -21
- package/dist/resources/mex/transactions.d.ts +38 -10
- package/dist/resources/mex/transactions.d.ts.map +1 -1
- package/dist/resources/mex/transactions.js +73 -20
- package/dist/resources/reports.d.ts +29 -2
- package/dist/resources/reports.d.ts.map +1 -1
- package/dist/resources/reports.js +57 -3
- package/dist/resources/transactions.d.ts +29 -2
- package/dist/resources/transactions.d.ts.map +1 -1
- package/dist/resources/transactions.js +57 -3
- package/dist/sdk/ComplianceSDK.d.ts.map +1 -1
- package/dist/sdk/ComplianceSDK.js +2 -0
- package/dist/utils/trpc-client.d.ts +1 -19879
- package/dist/utils/trpc-client.d.ts.map +1 -1
- package/dist/utils/upload.d.ts +6 -0
- package/dist/utils/upload.d.ts.map +1 -1
- package/dist/utils/upload.js +2 -1
- package/package.json +2 -2
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Extends ReportsResource with Mexico-specific behavior:
|
|
5
5
|
* - Accepts flattened CreateMexReportInput (MX fields at root level)
|
|
6
|
-
* -
|
|
6
|
+
* - Transforms flattened filters to nested format
|
|
7
7
|
* - Returns MexReport models
|
|
8
8
|
*/
|
|
9
9
|
import { z } from "zod";
|
|
10
|
-
import {
|
|
10
|
+
import { createMexReportInputSchema, updateMexReportInputSchema, upsertMexReportInputSchema, createMexReportItemInputSchema, updateMexReportItemInputSchema, mexSubmitReportInputSchema, transformSort, mexReportFieldMapping, mexReportDefaultsInputSchema, } from "@artu-ai/shared";
|
|
11
11
|
import { ReportsResource, } from "../reports";
|
|
12
12
|
import { MexReport } from "../../models";
|
|
13
13
|
import { MexReportItem } from "../../models/mex";
|
|
@@ -24,10 +24,12 @@ import { MexReportItem } from "../../models/mex";
|
|
|
24
24
|
*
|
|
25
25
|
* @example
|
|
26
26
|
* ```typescript
|
|
27
|
+
* // Using the Mexico SDK entry point
|
|
28
|
+
* import { ComplianceSDK } from "@artu-ai/compliance-sdk/mexico";
|
|
29
|
+
*
|
|
27
30
|
* const mexSdk = new ComplianceSDK({
|
|
28
31
|
* apiKey,
|
|
29
32
|
* environment: "test",
|
|
30
|
-
* jurisdiction: Jurisdiction.Mexico,
|
|
31
33
|
* });
|
|
32
34
|
*
|
|
33
35
|
* // Create with flattened input
|
|
@@ -37,7 +39,7 @@ import { MexReportItem } from "../../models/mex";
|
|
|
37
39
|
* },
|
|
38
40
|
* });
|
|
39
41
|
*
|
|
40
|
-
* // List
|
|
42
|
+
* // List reports
|
|
41
43
|
* const { data } = await mexSdk.reports.list();
|
|
42
44
|
* // data is MexReport[]
|
|
43
45
|
* ```
|
|
@@ -86,7 +88,6 @@ export class MexReportsResource extends ReportsResource {
|
|
|
86
88
|
* Lists Mexico reports with optional filtering.
|
|
87
89
|
*
|
|
88
90
|
* Accepts flattened MX filter (future MX-specific report fields at root level).
|
|
89
|
-
* Automatically filters to reports with Mexico jurisdiction data.
|
|
90
91
|
*/
|
|
91
92
|
async list(options) {
|
|
92
93
|
const scopedFilter = this.applyScopeToFilter(options?.filter);
|
|
@@ -105,11 +106,15 @@ export class MexReportsResource extends ReportsResource {
|
|
|
105
106
|
* Iterates over Mexico reports.
|
|
106
107
|
*
|
|
107
108
|
* Accepts flattened MX filter (future MX-specific report fields at root level).
|
|
108
|
-
* Automatically filters to reports with Mexico jurisdiction data.
|
|
109
109
|
*/
|
|
110
|
-
iterate(
|
|
111
|
-
const scopedFilter = this.applyScopeToFilter(filter);
|
|
112
|
-
|
|
110
|
+
iterate(options) {
|
|
111
|
+
const scopedFilter = this.applyScopeToFilter(options?.filter);
|
|
112
|
+
// Note: sort is passed through - createIterator calls list() which handles transformation
|
|
113
|
+
return this.createIterator({
|
|
114
|
+
filter: scopedFilter,
|
|
115
|
+
sort: options?.sort,
|
|
116
|
+
pageSize: options?.pageSize,
|
|
117
|
+
});
|
|
113
118
|
}
|
|
114
119
|
async createMany(reports, options = {}) {
|
|
115
120
|
const atomic = options.atomic ?? true;
|
|
@@ -163,6 +168,55 @@ export class MexReportsResource extends ReportsResource {
|
|
|
163
168
|
}
|
|
164
169
|
}
|
|
165
170
|
// ─────────────────────────────────────────────────────────────────
|
|
171
|
+
// Upsert Operations
|
|
172
|
+
// ─────────────────────────────────────────────────────────────────
|
|
173
|
+
/**
|
|
174
|
+
* Creates or updates a Mexico report by externalId.
|
|
175
|
+
*
|
|
176
|
+
* @param data - Report upsert data with MX fields at root level (must include externalId)
|
|
177
|
+
* @returns The created or updated report with action indicator
|
|
178
|
+
*/
|
|
179
|
+
async upsertByExternalId(data) {
|
|
180
|
+
const validated = this.validate(upsertMexReportInputSchema, data);
|
|
181
|
+
const nestedData = this.transformToNested(validated);
|
|
182
|
+
const response = await this.execute(() => this.trpc.reports.upsertByExternalId.mutate(nestedData));
|
|
183
|
+
return {
|
|
184
|
+
data: this.instantiate(response.data),
|
|
185
|
+
action: response.action,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
async upsertManyByExternalId(reports, options = {}) {
|
|
189
|
+
const atomic = options.atomic ?? true;
|
|
190
|
+
const validated = this.validate(z.array(upsertMexReportInputSchema), reports);
|
|
191
|
+
const nestedItems = validated.map((r) => this.transformToNested(r));
|
|
192
|
+
const response = await this.execute(() => this.trpc.reports.upsertManyByExternalId.mutate({
|
|
193
|
+
items: nestedItems,
|
|
194
|
+
atomic,
|
|
195
|
+
}));
|
|
196
|
+
if (response.atomic) {
|
|
197
|
+
return {
|
|
198
|
+
atomic: true,
|
|
199
|
+
data: response.data.map((item) => ({
|
|
200
|
+
data: this.instantiate(item.data),
|
|
201
|
+
action: item.action,
|
|
202
|
+
})),
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
return {
|
|
207
|
+
atomic: false,
|
|
208
|
+
succeeded: response.succeeded.map((item) => ({
|
|
209
|
+
index: item.index,
|
|
210
|
+
data: {
|
|
211
|
+
data: this.instantiate(item.data.data),
|
|
212
|
+
action: item.data.action,
|
|
213
|
+
},
|
|
214
|
+
})),
|
|
215
|
+
failed: response.failed,
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
// ─────────────────────────────────────────────────────────────────
|
|
166
220
|
// Report Items
|
|
167
221
|
// ─────────────────────────────────────────────────────────────────
|
|
168
222
|
/**
|
|
@@ -318,24 +372,20 @@ export class MexReportsResource extends ReportsResource {
|
|
|
318
372
|
// Protected Helpers
|
|
319
373
|
// ─────────────────────────────────────────────────────────────────
|
|
320
374
|
/**
|
|
321
|
-
*
|
|
375
|
+
* Transforms a flattened MexReportFilter to nested ReportFilter format.
|
|
322
376
|
*
|
|
323
|
-
* Currently MexReportFilter has the same fields as the base filter
|
|
324
|
-
*
|
|
325
|
-
*
|
|
377
|
+
* Currently MexReportFilter has the same fields as the base filter.
|
|
378
|
+
*
|
|
379
|
+
* Note: This method only transforms filters, it does not automatically add
|
|
380
|
+
* jurisdiction scoping. Use explicit filters if you need to scope by jurisdiction.
|
|
326
381
|
*/
|
|
327
382
|
applyScopeToFilter(filter) {
|
|
328
383
|
if (!filter) {
|
|
329
|
-
return
|
|
330
|
-
availableJurisdictions: Jurisdiction.Mexico,
|
|
331
|
-
};
|
|
384
|
+
return undefined;
|
|
332
385
|
}
|
|
333
386
|
// Currently no MX-specific report filter fields to nest
|
|
334
|
-
// Just pass through
|
|
335
|
-
return
|
|
336
|
-
...filter,
|
|
337
|
-
availableJurisdictions: Jurisdiction.Mexico,
|
|
338
|
-
};
|
|
387
|
+
// Just pass through the filter
|
|
388
|
+
return filter;
|
|
339
389
|
}
|
|
340
390
|
/**
|
|
341
391
|
* Transforms a flattened MexReportSort to nested ReportSort format.
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* Extends TransactionsResource with Mexico-specific behavior:
|
|
5
5
|
* - Accepts flattened CreateMexTransactionInput (MX fields at root level)
|
|
6
6
|
* - Automatically sets primaryJurisdiction to Mexico
|
|
7
|
-
* -
|
|
7
|
+
* - Transforms flattened filters to nested format
|
|
8
8
|
* - Returns MexTransaction models
|
|
9
9
|
*/
|
|
10
|
-
import type { CreateTransactionInput, UpdateTransactionInput, TransactionFilter, TransactionSort, ListOptions, PaginatedResponse, CreateMexTransactionInput, UpdateMexTransactionInput, AtomicBatchResult, PartialBatchResult, RelatedClient, MexTransactionFilter, MexTransactionSort } from "@artu-ai/shared";
|
|
10
|
+
import type { CreateTransactionInput, UpdateTransactionInput, TransactionFilter, TransactionSort, ListOptions, PaginatedResponse, CreateMexTransactionInput, UpdateMexTransactionInput, UpsertMexTransactionInput, AtomicBatchResult, PartialBatchResult, RelatedClient, MexTransactionFilter, MexTransactionSort, UpsertResult } from "@artu-ai/shared";
|
|
11
11
|
import { ClientRole } from "@artu-ai/shared";
|
|
12
12
|
import { TransactionsResource } from "../transactions";
|
|
13
13
|
import { MexTransaction, type TransactionData } from "../../models";
|
|
@@ -16,15 +16,17 @@ import { MexTransaction, type TransactionData } from "../../models";
|
|
|
16
16
|
*
|
|
17
17
|
* Provides the same operations as TransactionsResource but with:
|
|
18
18
|
* - Flattened input types (MX fields at root level)
|
|
19
|
-
* - Automatic
|
|
19
|
+
* - Automatic primaryJurisdiction setting on create
|
|
20
20
|
* - MexTransaction model return type
|
|
21
21
|
*
|
|
22
22
|
* @example
|
|
23
23
|
* ```typescript
|
|
24
|
+
* // Using the Mexico SDK entry point
|
|
25
|
+
* import { ComplianceSDK } from "@artu-ai/compliance-sdk/mexico";
|
|
26
|
+
*
|
|
24
27
|
* const mexSdk = new ComplianceSDK({
|
|
25
28
|
* apiKey,
|
|
26
29
|
* environment: "test",
|
|
27
|
-
* jurisdiction: Jurisdiction.Mexico,
|
|
28
30
|
* });
|
|
29
31
|
*
|
|
30
32
|
* // Create with flattened input
|
|
@@ -37,7 +39,7 @@ import { MexTransaction, type TransactionData } from "../../models";
|
|
|
37
39
|
* },
|
|
38
40
|
* });
|
|
39
41
|
*
|
|
40
|
-
* // List
|
|
42
|
+
* // List transactions
|
|
41
43
|
* const { data } = await mexSdk.transactions.list();
|
|
42
44
|
* // data is MexTransaction[]
|
|
43
45
|
* ```
|
|
@@ -68,7 +70,11 @@ export declare class MexTransactionsResource<TSort = MexTransactionSort> extends
|
|
|
68
70
|
*
|
|
69
71
|
* Accepts flattened MX filter (future MX-specific transaction fields at root level).
|
|
70
72
|
*/
|
|
71
|
-
iterate(
|
|
73
|
+
iterate(options?: {
|
|
74
|
+
filter?: MexTransactionFilter;
|
|
75
|
+
sort?: TSort;
|
|
76
|
+
pageSize?: number;
|
|
77
|
+
}): AsyncGenerator<MexTransaction, void, undefined>;
|
|
72
78
|
listByClient(clientId: string, options?: {
|
|
73
79
|
cursor?: string;
|
|
74
80
|
limit?: number;
|
|
@@ -95,12 +101,34 @@ export declare class MexTransactionsResource<TSort = MexTransactionSort> extends
|
|
|
95
101
|
atomic: false;
|
|
96
102
|
}): Promise<PartialBatchResult<MexTransaction>>;
|
|
97
103
|
/**
|
|
98
|
-
*
|
|
104
|
+
* Creates or updates a Mexico transaction by externalId.
|
|
105
|
+
*
|
|
106
|
+
* @param data - Transaction upsert data with MX fields at root level (must include externalId)
|
|
107
|
+
* @returns The created or updated transaction with action indicator
|
|
108
|
+
*/
|
|
109
|
+
upsertByExternalId(data: UpsertMexTransactionInput): Promise<UpsertResult<MexTransaction>>;
|
|
110
|
+
/**
|
|
111
|
+
* Creates or updates multiple Mexico transactions by externalId.
|
|
112
|
+
*
|
|
113
|
+
* @param transactions - Array of transaction upsert data (each must include externalId)
|
|
114
|
+
* @param options - Batch options (atomic: true by default)
|
|
115
|
+
* @returns Atomic result with data array, or partial result with succeeded/failed
|
|
116
|
+
*/
|
|
117
|
+
upsertManyByExternalId(transactions: UpsertMexTransactionInput[], options?: {
|
|
118
|
+
atomic?: true;
|
|
119
|
+
}): Promise<AtomicBatchResult<UpsertResult<MexTransaction>>>;
|
|
120
|
+
upsertManyByExternalId(transactions: UpsertMexTransactionInput[], options: {
|
|
121
|
+
atomic: false;
|
|
122
|
+
}): Promise<PartialBatchResult<UpsertResult<MexTransaction>>>;
|
|
123
|
+
/**
|
|
124
|
+
* Transforms a flattened MexTransactionFilter to nested TransactionFilter format.
|
|
125
|
+
*
|
|
126
|
+
* Currently MexTransactionFilter has the same fields as the base filter.
|
|
99
127
|
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
128
|
+
* Note: This method only transforms filters, it does not automatically add
|
|
129
|
+
* jurisdiction scoping. Use explicit filters if you need to scope by jurisdiction.
|
|
102
130
|
*/
|
|
103
|
-
protected applyScopeToFilter(filter?: MexTransactionFilter): TransactionFilter;
|
|
131
|
+
protected applyScopeToFilter(filter?: MexTransactionFilter): TransactionFilter | undefined;
|
|
104
132
|
/**
|
|
105
133
|
* Transforms a flattened MexTransactionSort to nested TransactionSort format.
|
|
106
134
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transactions.d.ts","sourceRoot":"","sources":["../../../src/resources/mex/transactions.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EACV,sBAAsB,EACtB,sBAAsB,
|
|
1
|
+
{"version":3,"file":"transactions.d.ts","sourceRoot":"","sources":["../../../src/resources/mex/transactions.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EACV,sBAAsB,EACtB,sBAAsB,EAEtB,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,yBAAyB,EACzB,yBAAyB,EACzB,yBAAyB,EACzB,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,oBAAoB,EACpB,kBAAkB,EAClB,YAAY,EACb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAKL,UAAU,EAGX,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAEvD,OAAO,EAAE,cAAc,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAMpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,qBAAa,uBAAuB,CAClC,KAAK,GAAG,kBAAkB,CAC1B,SAAQ,oBAAoB,CAAC,KAAK,CAAC;IAKnC;;OAEG;IACG,MAAM,CAAC,IAAI,EAAE,yBAAyB,GAAG,OAAO,CAAC,cAAc,CAAC;IAWtE;;OAEG;IACG,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAO7C,kBAAkB,CACtB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,GACZ,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AAE,KAAK,GAAG,eAAe,GAAG,SAAS;IAUrE;;OAEG;IACH,SAAS,CAAC,iBAAiB,CACzB,IAAI,EAAE,yBAAyB,GAC9B,sBAAsB;IAqBzB;;OAEG;IACH,SAAS,CAAC,uBAAuB,CAC/B,IAAI,EAAE,yBAAyB,GAC9B,sBAAsB;IAezB;;OAEG;cACgB,WAAW,CAAC,IAAI,EAAE,eAAe,GAAG,cAAc;CAGtE"}
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
* Extends TransactionsResource with Mexico-specific behavior:
|
|
5
5
|
* - Accepts flattened CreateMexTransactionInput (MX fields at root level)
|
|
6
6
|
* - Automatically sets primaryJurisdiction to Mexico
|
|
7
|
-
* -
|
|
7
|
+
* - Transforms flattened filters to nested format
|
|
8
8
|
* - Returns MexTransaction models
|
|
9
9
|
*/
|
|
10
10
|
import { z } from "zod";
|
|
11
|
-
import { Jurisdiction, createMexTransactionInputSchema, updateMexTransactionInputSchema, transformSort, mexTransactionFieldMapping, } from "@artu-ai/shared";
|
|
11
|
+
import { Jurisdiction, createMexTransactionInputSchema, updateMexTransactionInputSchema, upsertMexTransactionInputSchema, transformSort, mexTransactionFieldMapping, } from "@artu-ai/shared";
|
|
12
12
|
import { TransactionsResource } from "../transactions";
|
|
13
13
|
import { MexTransaction } from "../../models";
|
|
14
14
|
// ===========================
|
|
@@ -19,15 +19,17 @@ import { MexTransaction } from "../../models";
|
|
|
19
19
|
*
|
|
20
20
|
* Provides the same operations as TransactionsResource but with:
|
|
21
21
|
* - Flattened input types (MX fields at root level)
|
|
22
|
-
* - Automatic
|
|
22
|
+
* - Automatic primaryJurisdiction setting on create
|
|
23
23
|
* - MexTransaction model return type
|
|
24
24
|
*
|
|
25
25
|
* @example
|
|
26
26
|
* ```typescript
|
|
27
|
+
* // Using the Mexico SDK entry point
|
|
28
|
+
* import { ComplianceSDK } from "@artu-ai/compliance-sdk/mexico";
|
|
29
|
+
*
|
|
27
30
|
* const mexSdk = new ComplianceSDK({
|
|
28
31
|
* apiKey,
|
|
29
32
|
* environment: "test",
|
|
30
|
-
* jurisdiction: Jurisdiction.Mexico,
|
|
31
33
|
* });
|
|
32
34
|
*
|
|
33
35
|
* // Create with flattened input
|
|
@@ -40,7 +42,7 @@ import { MexTransaction } from "../../models";
|
|
|
40
42
|
* },
|
|
41
43
|
* });
|
|
42
44
|
*
|
|
43
|
-
* // List
|
|
45
|
+
* // List transactions
|
|
44
46
|
* const { data } = await mexSdk.transactions.list();
|
|
45
47
|
* // data is MexTransaction[]
|
|
46
48
|
* ```
|
|
@@ -83,7 +85,7 @@ export class MexTransactionsResource extends TransactionsResource {
|
|
|
83
85
|
return this.instantiate(response);
|
|
84
86
|
}
|
|
85
87
|
// ─────────────────────────────────────────────────────────────────
|
|
86
|
-
// List & Pagination
|
|
88
|
+
// List & Pagination
|
|
87
89
|
// ─────────────────────────────────────────────────────────────────
|
|
88
90
|
/**
|
|
89
91
|
* Lists Mexico transactions with optional filtering.
|
|
@@ -108,9 +110,14 @@ export class MexTransactionsResource extends TransactionsResource {
|
|
|
108
110
|
*
|
|
109
111
|
* Accepts flattened MX filter (future MX-specific transaction fields at root level).
|
|
110
112
|
*/
|
|
111
|
-
iterate(
|
|
112
|
-
const scopedFilter = this.applyScopeToFilter(filter);
|
|
113
|
-
|
|
113
|
+
iterate(options) {
|
|
114
|
+
const scopedFilter = this.applyScopeToFilter(options?.filter);
|
|
115
|
+
// Note: sort is passed through - createIterator calls list() which handles transformation
|
|
116
|
+
return this.createIterator({
|
|
117
|
+
filter: scopedFilter,
|
|
118
|
+
sort: options?.sort,
|
|
119
|
+
pageSize: options?.pageSize,
|
|
120
|
+
});
|
|
114
121
|
}
|
|
115
122
|
// ─────────────────────────────────────────────────────────────────
|
|
116
123
|
// Client Relationship Management (scoped returns)
|
|
@@ -199,26 +206,72 @@ export class MexTransactionsResource extends TransactionsResource {
|
|
|
199
206
|
}
|
|
200
207
|
}
|
|
201
208
|
// ─────────────────────────────────────────────────────────────────
|
|
209
|
+
// Upsert Operations
|
|
210
|
+
// ─────────────────────────────────────────────────────────────────
|
|
211
|
+
/**
|
|
212
|
+
* Creates or updates a Mexico transaction by externalId.
|
|
213
|
+
*
|
|
214
|
+
* @param data - Transaction upsert data with MX fields at root level (must include externalId)
|
|
215
|
+
* @returns The created or updated transaction with action indicator
|
|
216
|
+
*/
|
|
217
|
+
async upsertByExternalId(data) {
|
|
218
|
+
const validated = this.validate(upsertMexTransactionInputSchema, data);
|
|
219
|
+
const nestedData = this.transformToNested(validated);
|
|
220
|
+
const response = await this.execute(() => this.trpc.transactions.upsertByExternalId.mutate(nestedData));
|
|
221
|
+
return {
|
|
222
|
+
data: this.instantiate(response.data),
|
|
223
|
+
action: response.action,
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
async upsertManyByExternalId(transactions, options = {}) {
|
|
227
|
+
const atomic = options.atomic ?? true;
|
|
228
|
+
const validated = this.validate(z.array(upsertMexTransactionInputSchema), transactions);
|
|
229
|
+
const nestedItems = validated.map((t) => this.transformToNested(t));
|
|
230
|
+
const response = await this.execute(() => this.trpc.transactions.upsertManyByExternalId.mutate({
|
|
231
|
+
items: nestedItems,
|
|
232
|
+
atomic,
|
|
233
|
+
}));
|
|
234
|
+
if (response.atomic) {
|
|
235
|
+
return {
|
|
236
|
+
atomic: true,
|
|
237
|
+
data: response.data.map((item) => ({
|
|
238
|
+
data: this.instantiate(item.data),
|
|
239
|
+
action: item.action,
|
|
240
|
+
})),
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
return {
|
|
245
|
+
atomic: false,
|
|
246
|
+
succeeded: response.succeeded.map((item) => ({
|
|
247
|
+
index: item.index,
|
|
248
|
+
data: {
|
|
249
|
+
data: this.instantiate(item.data.data),
|
|
250
|
+
action: item.data.action,
|
|
251
|
+
},
|
|
252
|
+
})),
|
|
253
|
+
failed: response.failed,
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
// ─────────────────────────────────────────────────────────────────
|
|
202
258
|
// Protected Helpers
|
|
203
259
|
// ─────────────────────────────────────────────────────────────────
|
|
204
260
|
/**
|
|
205
|
-
*
|
|
261
|
+
* Transforms a flattened MexTransactionFilter to nested TransactionFilter format.
|
|
262
|
+
*
|
|
263
|
+
* Currently MexTransactionFilter has the same fields as the base filter.
|
|
206
264
|
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
265
|
+
* Note: This method only transforms filters, it does not automatically add
|
|
266
|
+
* jurisdiction scoping. Use explicit filters if you need to scope by jurisdiction.
|
|
209
267
|
*/
|
|
210
268
|
applyScopeToFilter(filter) {
|
|
211
269
|
if (!filter) {
|
|
212
|
-
return
|
|
213
|
-
availableJurisdictions: Jurisdiction.Mexico,
|
|
214
|
-
};
|
|
270
|
+
return undefined;
|
|
215
271
|
}
|
|
216
272
|
// Currently no MX-specific transaction filter fields to nest
|
|
217
|
-
// Just pass through
|
|
218
|
-
return
|
|
219
|
-
...filter,
|
|
220
|
-
availableJurisdictions: Jurisdiction.Mexico,
|
|
221
|
-
};
|
|
273
|
+
// Just pass through the filter
|
|
274
|
+
return filter;
|
|
222
275
|
}
|
|
223
276
|
/**
|
|
224
277
|
* Transforms a flattened MexTransactionSort to nested TransactionSort format.
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* - JYSReportsResource - Mexico JYS-scoped with flattened JYS fields
|
|
10
10
|
* - TSCReportsResource - Mexico TSC-scoped with flattened TSC fields
|
|
11
11
|
*/
|
|
12
|
-
import type { CreateReportInput, UpdateReportInput, UpdateReportStatusInput, CreateReportItemInput, UpdateReportItemInput, ReportFilter, ReportSort, ReportItemFilter, ReportItemSort, ValidationResult, GenerateResult, SubmitReportInput, SubmissionResult, ListOptions, PaginatedResponse, AtomicBatchResult, PartialBatchResult, ReportDefaultsInput } from "@artu-ai/shared";
|
|
12
|
+
import type { CreateReportInput, UpdateReportInput, UpsertReportInput, UpdateReportStatusInput, CreateReportItemInput, UpdateReportItemInput, ReportFilter, ReportSort, ReportItemFilter, ReportItemSort, ValidationResult, GenerateResult, SubmitReportInput, SubmissionResult, ListOptions, PaginatedResponse, AtomicBatchResult, PartialBatchResult, ReportDefaultsInput, UpsertResult } from "@artu-ai/shared";
|
|
13
13
|
import { BaseResource } from "./base";
|
|
14
14
|
import { Report, ReportItem, type ReportData, type ReportItemData } from "../models";
|
|
15
15
|
export type { ReportFilter, ReportItemFilter, ReportItemSort };
|
|
@@ -99,7 +99,11 @@ export declare class ReportsResource<TSort = ReportSort, TDefaults = ReportDefau
|
|
|
99
99
|
/**
|
|
100
100
|
* Returns an async iterator over all reports matching the filter.
|
|
101
101
|
*/
|
|
102
|
-
iterate(
|
|
102
|
+
iterate(options?: {
|
|
103
|
+
filter?: ReportFilter;
|
|
104
|
+
sort?: TSort;
|
|
105
|
+
pageSize?: number;
|
|
106
|
+
}): AsyncGenerator<Report, void, undefined>;
|
|
103
107
|
/**
|
|
104
108
|
* Adds an item to a report.
|
|
105
109
|
*/
|
|
@@ -165,6 +169,29 @@ export declare class ReportsResource<TSort = ReportSort, TDefaults = ReportDefau
|
|
|
165
169
|
* @param input - Submission data with jurisdiction-specific structure
|
|
166
170
|
*/
|
|
167
171
|
submit(input: SubmitReportInput): Promise<SubmissionResult>;
|
|
172
|
+
/**
|
|
173
|
+
* Creates or updates a report by externalId.
|
|
174
|
+
*
|
|
175
|
+
* If a report with the given externalId exists, it will be updated.
|
|
176
|
+
* Otherwise, a new report will be created.
|
|
177
|
+
*
|
|
178
|
+
* @param data - Report upsert data (must include externalId)
|
|
179
|
+
* @returns The created or updated report with action indicator
|
|
180
|
+
*/
|
|
181
|
+
upsertByExternalId(data: UpsertReportInput): Promise<UpsertResult<Report>>;
|
|
182
|
+
/**
|
|
183
|
+
* Creates or updates multiple reports by externalId in a single request.
|
|
184
|
+
*
|
|
185
|
+
* @param reports - Array of report upsert data (each must include externalId)
|
|
186
|
+
* @param options - Batch options (atomic: true by default)
|
|
187
|
+
* @returns Atomic result with data array, or partial result with succeeded/failed
|
|
188
|
+
*/
|
|
189
|
+
upsertManyByExternalId(reports: UpsertReportInput[], options?: {
|
|
190
|
+
atomic?: true;
|
|
191
|
+
}): Promise<AtomicBatchResult<UpsertResult<Report>>>;
|
|
192
|
+
upsertManyByExternalId(reports: UpsertReportInput[], options: {
|
|
193
|
+
atomic: false;
|
|
194
|
+
}): Promise<PartialBatchResult<UpsertResult<Report>>>;
|
|
168
195
|
/**
|
|
169
196
|
* Creates multiple reports in a single request.
|
|
170
197
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reports.d.ts","sourceRoot":"","sources":["../../src/resources/reports.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,uBAAuB,EACvB,qBAAqB,EACrB,qBAAqB,EACrB,YAAY,EACZ,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,
|
|
1
|
+
{"version":3,"file":"reports.d.ts","sourceRoot":"","sources":["../../src/resources/reports.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,uBAAuB,EACvB,qBAAqB,EACrB,qBAAqB,EACrB,YAAY,EACZ,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,YAAY,EACb,MAAM,iBAAiB,CAAC;AAYzB,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EACL,MAAM,EACN,UAAU,EACV,KAAK,UAAU,EACf,KA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E,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,iBAAiB,CAAA;KAAE,EAAE,EAClD,OAAO,EAAE;QAAE,MAAM,EAAE,KAAK,CAAA;KAAE,GACzB,OAAO,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAsCtC;;;OAGG;IACH,SAAS,CAAC,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM;IAI/C;;;OAGG;IACH,SAAS,CAAC,eAAe,CAAC,IAAI,EAAE,cAAc,GAAG,UAAU;CAG5D"}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* - TSCReportsResource - Mexico TSC-scoped with flattened TSC fields
|
|
11
11
|
*/
|
|
12
12
|
import { z } from "zod";
|
|
13
|
-
import { createReportInputSchema, updateReportInputSchema, updateReportStatusInputSchema, createReportItemInputSchema, updateReportItemInputSchema, reportDefaultsInputSchema, submitReportInputSchema, } from "@artu-ai/shared";
|
|
13
|
+
import { createReportInputSchema, updateReportInputSchema, upsertReportInputSchema, updateReportStatusInputSchema, createReportItemInputSchema, updateReportItemInputSchema, reportDefaultsInputSchema, submitReportInputSchema, } from "@artu-ai/shared";
|
|
14
14
|
import { BaseResource } from "./base";
|
|
15
15
|
import { Report, ReportItem, } from "../models";
|
|
16
16
|
// ===========================
|
|
@@ -127,8 +127,12 @@ export class ReportsResource extends BaseResource {
|
|
|
127
127
|
/**
|
|
128
128
|
* Returns an async iterator over all reports matching the filter.
|
|
129
129
|
*/
|
|
130
|
-
iterate(
|
|
131
|
-
return this.createIterator({
|
|
130
|
+
iterate(options) {
|
|
131
|
+
return this.createIterator({
|
|
132
|
+
filter: options?.filter,
|
|
133
|
+
sort: options?.sort,
|
|
134
|
+
pageSize: options?.pageSize,
|
|
135
|
+
});
|
|
132
136
|
}
|
|
133
137
|
// ─────────────────────────────────────────────────────────────────
|
|
134
138
|
// Report Items
|
|
@@ -246,6 +250,56 @@ export class ReportsResource extends BaseResource {
|
|
|
246
250
|
const validated = this.validate(submitReportInputSchema, input);
|
|
247
251
|
return this.execute(() => this.trpc.reports.submit.mutate(validated));
|
|
248
252
|
}
|
|
253
|
+
// ─────────────────────────────────────────────────────────────────
|
|
254
|
+
// Upsert Operations
|
|
255
|
+
// ─────────────────────────────────────────────────────────────────
|
|
256
|
+
/**
|
|
257
|
+
* Creates or updates a report by externalId.
|
|
258
|
+
*
|
|
259
|
+
* If a report with the given externalId exists, it will be updated.
|
|
260
|
+
* Otherwise, a new report will be created.
|
|
261
|
+
*
|
|
262
|
+
* @param data - Report upsert data (must include externalId)
|
|
263
|
+
* @returns The created or updated report with action indicator
|
|
264
|
+
*/
|
|
265
|
+
async upsertByExternalId(data) {
|
|
266
|
+
const validated = this.validate(upsertReportInputSchema, data);
|
|
267
|
+
const response = await this.execute(() => this.trpc.reports.upsertByExternalId.mutate(validated));
|
|
268
|
+
return {
|
|
269
|
+
data: this.instantiate(response.data),
|
|
270
|
+
action: response.action,
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
async upsertManyByExternalId(reports, options = {}) {
|
|
274
|
+
const atomic = options.atomic ?? true;
|
|
275
|
+
const validated = this.validate(z.array(upsertReportInputSchema), reports);
|
|
276
|
+
const response = await this.execute(() => this.trpc.reports.upsertManyByExternalId.mutate({
|
|
277
|
+
items: validated,
|
|
278
|
+
atomic,
|
|
279
|
+
}));
|
|
280
|
+
if (response.atomic) {
|
|
281
|
+
return {
|
|
282
|
+
atomic: true,
|
|
283
|
+
data: response.data.map((item) => ({
|
|
284
|
+
data: this.instantiate(item.data),
|
|
285
|
+
action: item.action,
|
|
286
|
+
})),
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
return {
|
|
291
|
+
atomic: false,
|
|
292
|
+
succeeded: response.succeeded.map((item) => ({
|
|
293
|
+
index: item.index,
|
|
294
|
+
data: {
|
|
295
|
+
data: this.instantiate(item.data.data),
|
|
296
|
+
action: item.data.action,
|
|
297
|
+
},
|
|
298
|
+
})),
|
|
299
|
+
failed: response.failed,
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
}
|
|
249
303
|
async createMany(reports, options = {}) {
|
|
250
304
|
const atomic = options.atomic ?? true;
|
|
251
305
|
const validated = this.validate(z.array(createReportInputSchema), reports);
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* - JYSTransactionsResource - Mexico JYS-scoped with flattened JYS fields
|
|
10
10
|
* - TSCTransactionsResource - Mexico TSC-scoped with flattened TSC fields
|
|
11
11
|
*/
|
|
12
|
-
import type { CreateTransactionInput, UpdateTransactionInput, TransactionFilter, TransactionSort, ListOptions, PaginatedResponse, AtomicBatchResult, PartialBatchResult, RelatedClient } from "@artu-ai/shared";
|
|
12
|
+
import type { CreateTransactionInput, UpdateTransactionInput, UpsertTransactionInput, TransactionFilter, TransactionSort, ListOptions, PaginatedResponse, AtomicBatchResult, PartialBatchResult, RelatedClient, UpsertResult } from "@artu-ai/shared";
|
|
13
13
|
import { ClientRole } from "@artu-ai/shared";
|
|
14
14
|
import { BaseResource } from "./base";
|
|
15
15
|
import { Transaction, type TransactionData } from "../models";
|
|
@@ -88,7 +88,11 @@ export declare class TransactionsResource<TSort = TransactionSort> extends BaseR
|
|
|
88
88
|
/**
|
|
89
89
|
* Returns an async iterator over all transactions matching the filter.
|
|
90
90
|
*/
|
|
91
|
-
iterate(
|
|
91
|
+
iterate(options?: {
|
|
92
|
+
filter?: TransactionFilter;
|
|
93
|
+
sort?: TSort;
|
|
94
|
+
pageSize?: number;
|
|
95
|
+
}): AsyncGenerator<Transaction, void, undefined>;
|
|
92
96
|
/**
|
|
93
97
|
* Links a client to a transaction with an optional role.
|
|
94
98
|
*/
|
|
@@ -133,6 +137,29 @@ export declare class TransactionsResource<TSort = TransactionSort> extends BaseR
|
|
|
133
137
|
}[], options: {
|
|
134
138
|
atomic: false;
|
|
135
139
|
}): Promise<PartialBatchResult<Transaction>>;
|
|
140
|
+
/**
|
|
141
|
+
* Creates or updates a transaction by externalId.
|
|
142
|
+
*
|
|
143
|
+
* If a transaction with the given externalId exists, it will be updated.
|
|
144
|
+
* Otherwise, a new transaction will be created.
|
|
145
|
+
*
|
|
146
|
+
* @param data - Transaction upsert data (must include externalId)
|
|
147
|
+
* @returns The created or updated transaction with action indicator
|
|
148
|
+
*/
|
|
149
|
+
upsertByExternalId(data: UpsertTransactionInput): Promise<UpsertResult<Transaction>>;
|
|
150
|
+
/**
|
|
151
|
+
* Creates or updates multiple transactions by externalId in a single request.
|
|
152
|
+
*
|
|
153
|
+
* @param transactions - Array of transaction upsert data (each must include externalId)
|
|
154
|
+
* @param options - Batch options (atomic: true by default)
|
|
155
|
+
* @returns Atomic result with data array, or partial result with succeeded/failed
|
|
156
|
+
*/
|
|
157
|
+
upsertManyByExternalId(transactions: UpsertTransactionInput[], options?: {
|
|
158
|
+
atomic?: true;
|
|
159
|
+
}): Promise<AtomicBatchResult<UpsertResult<Transaction>>>;
|
|
160
|
+
upsertManyByExternalId(transactions: UpsertTransactionInput[], options: {
|
|
161
|
+
atomic: false;
|
|
162
|
+
}): Promise<PartialBatchResult<UpsertResult<Transaction>>>;
|
|
136
163
|
/**
|
|
137
164
|
* Instantiates a Transaction model from API response data.
|
|
138
165
|
* Subclasses override this to return their specific model type.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transactions.d.ts","sourceRoot":"","sources":["../../src/resources/transactions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EACV,sBAAsB,EACtB,sBAAsB,EACtB,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,
|
|
1
|
+
{"version":3,"file":"transactions.d.ts","sourceRoot":"","sources":["../../src/resources/transactions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EACV,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,iBAAiB,EACjB,eAAe,EACf,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