@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
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* Note: Mexican address format can be used for addresses in any country.
|
|
9
9
|
*/
|
|
10
10
|
import { z } from "zod";
|
|
11
|
-
import { createMexAddressInputSchema, updateMexAddressInputSchema, replaceSyncItemSchema, transformSort, mexAddressFieldMapping, } from "@artu-ai/shared";
|
|
11
|
+
import { createMexAddressInputSchema, updateMexAddressInputSchema, upsertMexAddressInputSchema, replaceSyncItemSchema, transformSort, mexAddressFieldMapping, } from "@artu-ai/shared";
|
|
12
12
|
import { AddressesResource } from "../addresses";
|
|
13
13
|
import { MexAddress } from "../../models";
|
|
14
14
|
// ===========================
|
|
@@ -128,9 +128,14 @@ export class MexAddressesResource extends AddressesResource {
|
|
|
128
128
|
*
|
|
129
129
|
* Accepts flattened MX filter (MX-specific fields at root level).
|
|
130
130
|
*/
|
|
131
|
-
iterate(
|
|
132
|
-
const scopedFilter = this.applyScopeToFilter(filter);
|
|
133
|
-
|
|
131
|
+
iterate(options) {
|
|
132
|
+
const scopedFilter = this.applyScopeToFilter(options?.filter);
|
|
133
|
+
// Note: sort is passed through - createIterator calls list() which handles transformation
|
|
134
|
+
return this.createIterator({
|
|
135
|
+
filter: scopedFilter,
|
|
136
|
+
sort: options?.sort,
|
|
137
|
+
pageSize: options?.pageSize,
|
|
138
|
+
});
|
|
134
139
|
}
|
|
135
140
|
async createMany(addresses, options = {}) {
|
|
136
141
|
const atomic = options.atomic ?? true;
|
|
@@ -183,8 +188,64 @@ export class MexAddressesResource extends AddressesResource {
|
|
|
183
188
|
};
|
|
184
189
|
}
|
|
185
190
|
}
|
|
191
|
+
// ─────────────────────────────────────────────────────────────────
|
|
192
|
+
// Upsert Operations
|
|
193
|
+
// ─────────────────────────────────────────────────────────────────
|
|
194
|
+
/**
|
|
195
|
+
* Creates or updates a Mexico address by externalId.
|
|
196
|
+
*
|
|
197
|
+
* @param data - Address upsert data with MX fields at root level (must include externalId)
|
|
198
|
+
* @returns The created or updated address with action indicator
|
|
199
|
+
*/
|
|
200
|
+
async upsertByExternalId(data) {
|
|
201
|
+
const validated = this.validate(upsertMexAddressInputSchema, data);
|
|
202
|
+
const nestedData = this.transformToNested(validated);
|
|
203
|
+
const response = await this.execute(() => this.trpc.addresses.upsertByExternalId.mutate(nestedData));
|
|
204
|
+
return {
|
|
205
|
+
data: this.instantiate(response.data),
|
|
206
|
+
action: response.action,
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
async upsertManyByExternalId(addresses, options = {}) {
|
|
210
|
+
const atomic = options.atomic ?? true;
|
|
211
|
+
const validated = this.validate(z.array(upsertMexAddressInputSchema), addresses);
|
|
212
|
+
const nestedItems = validated.map((a) => this.transformToNested(a));
|
|
213
|
+
const response = await this.execute(() => this.trpc.addresses.upsertManyByExternalId.mutate({
|
|
214
|
+
items: nestedItems,
|
|
215
|
+
atomic,
|
|
216
|
+
}));
|
|
217
|
+
if (response.atomic) {
|
|
218
|
+
return {
|
|
219
|
+
atomic: true,
|
|
220
|
+
data: response.data.map((item) => ({
|
|
221
|
+
data: this.instantiate(item.data),
|
|
222
|
+
action: item.action,
|
|
223
|
+
})),
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
return {
|
|
228
|
+
atomic: false,
|
|
229
|
+
succeeded: response.succeeded.map((item) => ({
|
|
230
|
+
index: item.index,
|
|
231
|
+
data: {
|
|
232
|
+
data: this.instantiate(item.data.data),
|
|
233
|
+
action: item.data.action,
|
|
234
|
+
},
|
|
235
|
+
})),
|
|
236
|
+
failed: response.failed,
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
}
|
|
186
240
|
async sync(clientId, items, options) {
|
|
187
|
-
|
|
241
|
+
// Inject clientId into create items (items without id) before validation
|
|
242
|
+
const itemsWithClientId = items.map((item) => {
|
|
243
|
+
if (!("id" in item) || !item.id) {
|
|
244
|
+
return { ...item, clientId };
|
|
245
|
+
}
|
|
246
|
+
return item;
|
|
247
|
+
});
|
|
248
|
+
const validated = this.validate(z.array(replaceSyncItemSchema(createMexAddressInputSchema, updateMexAddressInputSchema)), itemsWithClientId);
|
|
188
249
|
// Transform each item to nested format
|
|
189
250
|
const nestedItems = [];
|
|
190
251
|
for (const item of validated) {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Extends BankAccountsResource to return MexBankAccount models
|
|
5
5
|
* with Mexico-specific helpers (CLABE formatting, etc.).
|
|
6
6
|
*/
|
|
7
|
-
import type { CreateBankAccountInput, UpdateBankAccountInput, BankAccountFilter, BankAccountSort, ListOptions, PaginatedResponse, AtomicBatchResult, PartialBatchResult, SyncItem, SyncResult, MexBankAccountFilter, MexBankAccountSort } from "@artu-ai/shared";
|
|
7
|
+
import type { CreateBankAccountInput, UpdateBankAccountInput, UpsertBankAccountInput, BankAccountFilter, BankAccountSort, ListOptions, PaginatedResponse, AtomicBatchResult, PartialBatchResult, SyncItem, SyncResult, MexBankAccountFilter, MexBankAccountSort, UpsertResult } from "@artu-ai/shared";
|
|
8
8
|
import { BankAccountsResource } from "../bank-accounts";
|
|
9
9
|
import { MexBankAccount, type BankAccountData } from "../../models";
|
|
10
10
|
/**
|
|
@@ -58,7 +58,11 @@ export declare class MexBankAccountsResource<TSort = MexBankAccountSort> extends
|
|
|
58
58
|
*
|
|
59
59
|
* Accepts flattened MX filter (MX-specific fields at root level).
|
|
60
60
|
*/
|
|
61
|
-
iterate(
|
|
61
|
+
iterate(options?: {
|
|
62
|
+
filter?: MexBankAccountFilter;
|
|
63
|
+
sort?: TSort;
|
|
64
|
+
pageSize?: number;
|
|
65
|
+
}): AsyncGenerator<MexBankAccount, void, undefined>;
|
|
62
66
|
createMany(accounts: CreateBankAccountInput[], options?: {
|
|
63
67
|
atomic?: true;
|
|
64
68
|
}): Promise<AtomicBatchResult<MexBankAccount>>;
|
|
@@ -83,6 +87,13 @@ export declare class MexBankAccountsResource<TSort = MexBankAccountSort> extends
|
|
|
83
87
|
sync(clientId: string, items: SyncItem<UpdateBankAccountInput>[], options?: {
|
|
84
88
|
replaceMode?: boolean;
|
|
85
89
|
}): Promise<SyncResult<MexBankAccount>>;
|
|
90
|
+
upsertByExternalId(data: UpsertBankAccountInput): Promise<UpsertResult<MexBankAccount>>;
|
|
91
|
+
upsertManyByExternalId(accounts: UpsertBankAccountInput[], options?: {
|
|
92
|
+
atomic?: true;
|
|
93
|
+
}): Promise<AtomicBatchResult<UpsertResult<MexBankAccount>>>;
|
|
94
|
+
upsertManyByExternalId(accounts: UpsertBankAccountInput[], options: {
|
|
95
|
+
atomic: false;
|
|
96
|
+
}): Promise<PartialBatchResult<UpsertResult<MexBankAccount>>>;
|
|
86
97
|
setPrimary(id: string): Promise<MexBankAccount>;
|
|
87
98
|
activate(id: string): Promise<MexBankAccount>;
|
|
88
99
|
deactivate(id: string): Promise<MexBankAccount>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bank-accounts.d.ts","sourceRoot":"","sources":["../../../src/resources/mex/bank-accounts.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,sBAAsB,EACtB,sBAAsB,EACtB,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,QAAQ,EACR,UAAU,EACV,oBAAoB,EACpB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"bank-accounts.d.ts","sourceRoot":"","sources":["../../../src/resources/mex/bank-accounts.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,iBAAiB,EACjB,eAAe,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AAC,UAAU,CAAC,cAAc,CAAC,CAAC;IAevB,kBAAkB,CAC/B,IAAI,EAAE,sBAAsB,GAC3B,OAAO,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;IAMzB,sBAAsB,CACnC,QAAQ,EAAE,sBAAsB,EAAE,EAClC,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,IAAI,CAAA;KAAE,GAC1B,OAAO,CAAC,iBAAiB,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC,CAAC;IAC5C,sBAAsB,CACnC,QAAQ,EAAE,sBAAsB,EAAE,EAClC,OAAO,EAAE;QAAE,MAAM,EAAE,KAAK,CAAA;KAAE,GACzB,OAAO,CAAC,kBAAkB,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC,CAAC;IAqB7C,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAI/C,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAI7C,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAI/C,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IAQ3E;;;;;OAKG;IACH,SAAS,CAAC,kBAAkB,CAC1B,MAAM,CAAC,EAAE,oBAAoB,GAC5B,iBAAiB;IAyBpB;;;;;;OAMG;IACH,SAAS,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,KAAK,GAAG,eAAe,GAAG,SAAS;cAUlD,WAAW,CAAC,IAAI,EAAE,eAAe,GAAG,cAAc;CAGtE"}
|
|
@@ -85,9 +85,14 @@ export class MexBankAccountsResource extends BankAccountsResource {
|
|
|
85
85
|
*
|
|
86
86
|
* Accepts flattened MX filter (MX-specific fields at root level).
|
|
87
87
|
*/
|
|
88
|
-
iterate(
|
|
89
|
-
const scopedFilter = this.applyScopeToFilter(filter);
|
|
90
|
-
|
|
88
|
+
iterate(options) {
|
|
89
|
+
const scopedFilter = this.applyScopeToFilter(options?.filter);
|
|
90
|
+
// Note: sort is passed through - createIterator calls list() which handles transformation
|
|
91
|
+
return this.createIterator({
|
|
92
|
+
filter: scopedFilter,
|
|
93
|
+
sort: options?.sort,
|
|
94
|
+
pageSize: options?.pageSize,
|
|
95
|
+
});
|
|
91
96
|
}
|
|
92
97
|
async createMany(accounts, options = {}) {
|
|
93
98
|
return super.createMany(accounts, options);
|
|
@@ -99,6 +104,15 @@ export class MexBankAccountsResource extends BankAccountsResource {
|
|
|
99
104
|
return super.sync(clientId, items, options);
|
|
100
105
|
}
|
|
101
106
|
// ─────────────────────────────────────────────────────────────────
|
|
107
|
+
// Upsert Operations (override return types)
|
|
108
|
+
// ─────────────────────────────────────────────────────────────────
|
|
109
|
+
async upsertByExternalId(data) {
|
|
110
|
+
return super.upsertByExternalId(data);
|
|
111
|
+
}
|
|
112
|
+
async upsertManyByExternalId(accounts, options = {}) {
|
|
113
|
+
return super.upsertManyByExternalId(accounts, options);
|
|
114
|
+
}
|
|
115
|
+
// ─────────────────────────────────────────────────────────────────
|
|
102
116
|
// Convenience Methods (override return types)
|
|
103
117
|
// ─────────────────────────────────────────────────────────────────
|
|
104
118
|
async setPrimary(id) {
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* Extends ClientsResource with Mexico-specific behavior:
|
|
5
5
|
* - Accepts flattened CreateMexClientInput (MX fields at root level)
|
|
6
6
|
* - Automatically sets primaryJurisdiction to Mexico
|
|
7
|
-
* -
|
|
7
|
+
* - Transforms flattened filters to nested format
|
|
8
8
|
* - Returns MexClient models
|
|
9
9
|
*/
|
|
10
|
-
import type { CreateClientInput, UpdateClientInput, ClientFilter, ClientSort, ListOptions, PaginatedResponse, CreateMexClientInput, UpdateMexClientInput, AtomicBatchResult, PartialBatchResult, ClientRelationshipType, LinkedClient as LinkedClientInput, CreateAddressInput, UpdateAddressInput, CreateMexAddressInput, UpdateMexAddressInput, CreateContactMethodInput, UpdateContactMethodInput, CreateBankAccountInput, UpdateBankAccountInput, SyncItem, SyncResult, MexClientFilter, MexClientSort } from "@artu-ai/shared";
|
|
10
|
+
import type { CreateClientInput, UpdateClientInput, ClientFilter, ClientSort, ListOptions, PaginatedResponse, CreateMexClientInput, UpdateMexClientInput, UpsertMexClientInput, AtomicBatchResult, PartialBatchResult, ClientRelationshipType, LinkedClient as LinkedClientInput, CreateAddressInput, UpdateAddressInput, CreateMexAddressInput, UpdateMexAddressInput, CreateContactMethodInput, UpdateContactMethodInput, CreateBankAccountInput, UpdateBankAccountInput, SyncItem, SyncResult, MexClientFilter, MexClientSort, UpsertResult } from "@artu-ai/shared";
|
|
11
11
|
import { ClientsResource, type ClientIncludeMap } from "../clients";
|
|
12
12
|
import { MexClient, MexAddress, MexBankAccount, ContactMethod, LinkedClient, type ClientData } from "../../models";
|
|
13
13
|
/**
|
|
@@ -15,15 +15,17 @@ import { MexClient, MexAddress, MexBankAccount, ContactMethod, LinkedClient, typ
|
|
|
15
15
|
*
|
|
16
16
|
* Provides the same operations as ClientsResource but with:
|
|
17
17
|
* - Flattened input types (MX fields at root level)
|
|
18
|
-
* - Automatic
|
|
18
|
+
* - Automatic primaryJurisdiction setting on create
|
|
19
19
|
* - MexClient model return type
|
|
20
20
|
*
|
|
21
21
|
* @example
|
|
22
22
|
* ```typescript
|
|
23
|
+
* // Using the Mexico SDK entry point
|
|
24
|
+
* import { ComplianceSDK } from "@artu-ai/compliance-sdk/mexico";
|
|
25
|
+
*
|
|
23
26
|
* const mexSdk = new ComplianceSDK({
|
|
24
27
|
* apiKey,
|
|
25
28
|
* environment: "test",
|
|
26
|
-
* jurisdiction: Jurisdiction.Mexico,
|
|
27
29
|
* });
|
|
28
30
|
*
|
|
29
31
|
* // Create with flattened input
|
|
@@ -37,7 +39,7 @@ import { MexClient, MexAddress, MexBankAccount, ContactMethod, LinkedClient, typ
|
|
|
37
39
|
* },
|
|
38
40
|
* });
|
|
39
41
|
*
|
|
40
|
-
* // List
|
|
42
|
+
* // List clients
|
|
41
43
|
* const { data } = await mexSdk.clients.list();
|
|
42
44
|
* // data is MexClient[]
|
|
43
45
|
* ```
|
|
@@ -65,7 +67,7 @@ export declare class MexClientsResource<TSort = MexClientSort> extends ClientsRe
|
|
|
65
67
|
/**
|
|
66
68
|
* Lists Mexico clients with optional filtering.
|
|
67
69
|
*
|
|
68
|
-
* Accepts flattened Mexico filter (MX fields at root level) and
|
|
70
|
+
* Accepts flattened Mexico filter (MX fields at root level) and
|
|
69
71
|
* transforms to nested format before calling the API.
|
|
70
72
|
*
|
|
71
73
|
* @example
|
|
@@ -85,10 +87,14 @@ export declare class MexClientsResource<TSort = MexClientSort> extends ClientsRe
|
|
|
85
87
|
/**
|
|
86
88
|
* Iterates over Mexico clients.
|
|
87
89
|
*
|
|
88
|
-
* Accepts flattened Mexico filter (MX fields at root level) and
|
|
90
|
+
* Accepts flattened Mexico filter (MX fields at root level) and
|
|
89
91
|
* transforms to nested format before calling the API.
|
|
90
92
|
*/
|
|
91
|
-
iterate(
|
|
93
|
+
iterate(options?: {
|
|
94
|
+
filter?: MexClientFilter;
|
|
95
|
+
sort?: TSort;
|
|
96
|
+
pageSize?: number;
|
|
97
|
+
}): AsyncGenerator<MexClient, void, undefined>;
|
|
92
98
|
/**
|
|
93
99
|
* Creates multiple Mexico clients with flattened input.
|
|
94
100
|
*/
|
|
@@ -113,6 +119,26 @@ export declare class MexClientsResource<TSort = MexClientSort> extends ClientsRe
|
|
|
113
119
|
}[], options: {
|
|
114
120
|
atomic: false;
|
|
115
121
|
}): Promise<PartialBatchResult<MexClient>>;
|
|
122
|
+
/**
|
|
123
|
+
* Creates or updates a Mexico client by externalId.
|
|
124
|
+
*
|
|
125
|
+
* @param data - Client upsert data with MX fields at root level (must include externalId)
|
|
126
|
+
* @returns The created or updated client with action indicator
|
|
127
|
+
*/
|
|
128
|
+
upsertByExternalId(data: UpsertMexClientInput): Promise<UpsertResult<MexClient>>;
|
|
129
|
+
/**
|
|
130
|
+
* Creates or updates multiple Mexico clients by externalId.
|
|
131
|
+
*
|
|
132
|
+
* @param clients - Array of client upsert data (each must include externalId)
|
|
133
|
+
* @param options - Batch options (atomic: true by default)
|
|
134
|
+
* @returns Atomic result with data array, or partial result with succeeded/failed
|
|
135
|
+
*/
|
|
136
|
+
upsertManyByExternalId(clients: UpsertMexClientInput[], options?: {
|
|
137
|
+
atomic?: true;
|
|
138
|
+
}): Promise<AtomicBatchResult<UpsertResult<MexClient>>>;
|
|
139
|
+
upsertManyByExternalId(clients: UpsertMexClientInput[], options: {
|
|
140
|
+
atomic: false;
|
|
141
|
+
}): Promise<PartialBatchResult<UpsertResult<MexClient>>>;
|
|
116
142
|
linkClient(parentClientId: string, childClientId: string, relationshipType: ClientRelationshipType, metadata?: Record<string, unknown>): Promise<MexClient>;
|
|
117
143
|
unlinkClient(parentClientId: string, childClientId: string, relationshipType: ClientRelationshipType): Promise<MexClient>;
|
|
118
144
|
listLinkedClients(parentClientId: string, relationshipType?: ClientRelationshipType): Promise<LinkedClient[]>;
|
|
@@ -151,13 +177,15 @@ export declare class MexClientsResource<TSort = MexClientSort> extends ClientsRe
|
|
|
151
177
|
bankAccounts: SyncResult<MexBankAccount>;
|
|
152
178
|
}>;
|
|
153
179
|
/**
|
|
154
|
-
* Transforms a flattened MexClientFilter to nested ClientFilter format
|
|
155
|
-
* and applies Mexico jurisdiction scoping.
|
|
180
|
+
* Transforms a flattened MexClientFilter to nested ClientFilter format.
|
|
156
181
|
*
|
|
157
182
|
* Extracts MX-specific fields (rfc, curp, actividadEconomica, giroMercantil,
|
|
158
183
|
* actividadVulnerable) from root level and nests them under jurisdictions.MX.
|
|
184
|
+
*
|
|
185
|
+
* Note: This method only transforms filters, it does not automatically add
|
|
186
|
+
* jurisdiction scoping. Use explicit filters if you need to scope by jurisdiction.
|
|
159
187
|
*/
|
|
160
|
-
protected applyScopeToFilter(filter?: MexClientFilter): ClientFilter;
|
|
188
|
+
protected applyScopeToFilter(filter?: MexClientFilter): ClientFilter | undefined;
|
|
161
189
|
/**
|
|
162
190
|
* Transforms a flattened MexClientSort to nested ClientSort format.
|
|
163
191
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clients.d.ts","sourceRoot":"","sources":["../../../src/resources/mex/clients.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"clients.d.ts","sourceRoot":"","sources":["../../../src/resources/mex/clients.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EAEjB,YAAY,EACZ,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,EACtB,YAAY,IAAI,iBAAiB,EACjC,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACxB,wBAAwB,EACxB,sBAAsB,EACtB,sBAAsB,EACtB,QAAQ,EACR,UAAU,EACV,eAAe,EACf,aAAa,EACb,YAAY,EACb,MAAM,iBAAiB,CAAC;AAiBzB,OAAO,EACL,eAAe,EAEf,KAAK,gBAAgB,EACtB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,SAAS,EACT,UAAU,EACV,cAAc,EACd,aAAa,EACb,YAAY,EACZ,KAAK,UAAU,EAChB,MAAM,cAAc,CAAC;AAMtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,qBAAa,kBAAkB,CAC7B,KAAK,GAAG,aAAa,CACrB,SAAQ,eAAe,CAAC,KAAK,CAAC;IAK9B;;;;;OAKG;IACG,MAAM,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,SAAS,CAAC;IAW5D;;OAEG;IACG,QAAQ,CAAC,EAAE,EAAE,MAAM,EA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kBAAkB,CAC1B,MAAM,CAAC,EAAE,eAAe,GACvB,YAAY,GAAG,SAAS;IAsC3B;;;;;;;OAOG;IACH,SAAS,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,KAAK,GAAG,UAAU,GAAG,SAAS;IAOhE;;OAEG;IACH,SAAS,CAAC,iBAAiB,CAAC,IAAI,EAAE,oBAAoB,GAAG,iBAAiB;IA6B1E;;OAEG;IACH,SAAS,CAAC,uBAAuB,CAC/B,IAAI,EAAE,oBAAoB,GACzB,iBAAiB;IAuCpB;;OAEG;IACH,SAAS,CAAC,wBAAwB,CAChC,IAAI,EAAE,QAAQ,CAAC,qBAAqB,GAAG,qBAAqB,CAAC,GAC5D,QAAQ,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;IAmBpD;;OAEG;IACH,SAAS,CAAC,wBAAwB,CAChC,IAAI,EAAE,qBAAqB,GAC1B,kBAAkB;IA0BrB;;OAEG;IACH,SAAS,CAAC,8BAA8B,CACtC,IAAI,EAAE,qBAAqB,GAC1B,kBAAkB;IAqCrB;;OAEG;cACgB,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,SAAS;CAG5D"}
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
* Extends ClientsResource with Mexico-specific behavior:
|
|
5
5
|
* - Accepts flattened CreateMexClientInput (MX fields at root level)
|
|
6
6
|
* - Automatically sets primaryJurisdiction to Mexico
|
|
7
|
-
* -
|
|
7
|
+
* - Transforms flattened filters to nested format
|
|
8
8
|
* - Returns MexClient models
|
|
9
9
|
*/
|
|
10
10
|
import { z } from "zod";
|
|
11
|
-
import { Jurisdiction, createMexClientInputSchema, updateMexClientInputSchema, linkedClientSchema, createMexAddressInputSchema, updateMexAddressInputSchema, createContactMethodInputSchema, updateContactMethodInputSchema, createBankAccountInputSchema, updateBankAccountInputSchema, replaceSyncItemSchema, transformSort, mexClientFieldMapping, } from "@artu-ai/shared";
|
|
11
|
+
import { Jurisdiction, createMexClientInputSchema, updateMexClientInputSchema, upsertMexClientInputSchema, linkedClientSchema, createMexAddressInputSchema, updateMexAddressInputSchema, createContactMethodInputSchema, updateContactMethodInputSchema, createBankAccountInputSchema, updateBankAccountInputSchema, replaceSyncItemSchema, transformSort, mexClientFieldMapping, } from "@artu-ai/shared";
|
|
12
12
|
import { ClientsResource, } from "../clients";
|
|
13
13
|
import { MexClient, MexAddress, MexBankAccount, ContactMethod, } from "../../models";
|
|
14
14
|
// ===========================
|
|
@@ -19,15 +19,17 @@ import { MexClient, MexAddress, MexBankAccount, ContactMethod, } from "../../mod
|
|
|
19
19
|
*
|
|
20
20
|
* Provides the same operations as ClientsResource but with:
|
|
21
21
|
* - Flattened input types (MX fields at root level)
|
|
22
|
-
* - Automatic
|
|
22
|
+
* - Automatic primaryJurisdiction setting on create
|
|
23
23
|
* - MexClient 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
|
|
@@ -41,7 +43,7 @@ import { MexClient, MexAddress, MexBankAccount, ContactMethod, } from "../../mod
|
|
|
41
43
|
* },
|
|
42
44
|
* });
|
|
43
45
|
*
|
|
44
|
-
* // List
|
|
46
|
+
* // List clients
|
|
45
47
|
* const { data } = await mexSdk.clients.list();
|
|
46
48
|
* // data is MexClient[]
|
|
47
49
|
* ```
|
|
@@ -86,12 +88,12 @@ export class MexClientsResource extends ClientsResource {
|
|
|
86
88
|
return this.instantiate(response);
|
|
87
89
|
}
|
|
88
90
|
// ─────────────────────────────────────────────────────────────────
|
|
89
|
-
// List & Pagination
|
|
91
|
+
// List & Pagination
|
|
90
92
|
// ─────────────────────────────────────────────────────────────────
|
|
91
93
|
/**
|
|
92
94
|
* Lists Mexico clients with optional filtering.
|
|
93
95
|
*
|
|
94
|
-
* Accepts flattened Mexico filter (MX fields at root level) and
|
|
96
|
+
* Accepts flattened Mexico filter (MX fields at root level) and
|
|
95
97
|
* transforms to nested format before calling the API.
|
|
96
98
|
*
|
|
97
99
|
* @example
|
|
@@ -121,12 +123,17 @@ export class MexClientsResource extends ClientsResource {
|
|
|
121
123
|
/**
|
|
122
124
|
* Iterates over Mexico clients.
|
|
123
125
|
*
|
|
124
|
-
* Accepts flattened Mexico filter (MX fields at root level) and
|
|
126
|
+
* Accepts flattened Mexico filter (MX fields at root level) and
|
|
125
127
|
* transforms to nested format before calling the API.
|
|
126
128
|
*/
|
|
127
|
-
iterate(
|
|
128
|
-
const scopedFilter = this.applyScopeToFilter(filter);
|
|
129
|
-
|
|
129
|
+
iterate(options) {
|
|
130
|
+
const scopedFilter = this.applyScopeToFilter(options?.filter);
|
|
131
|
+
// Note: sort is passed through - createIterator calls list() which handles transformation
|
|
132
|
+
return this.createIterator({
|
|
133
|
+
filter: scopedFilter,
|
|
134
|
+
sort: options?.sort,
|
|
135
|
+
pageSize: options?.pageSize,
|
|
136
|
+
});
|
|
130
137
|
}
|
|
131
138
|
async createMany(clients, options = {}) {
|
|
132
139
|
const atomic = options.atomic ?? true;
|
|
@@ -180,6 +187,55 @@ export class MexClientsResource extends ClientsResource {
|
|
|
180
187
|
}
|
|
181
188
|
}
|
|
182
189
|
// ─────────────────────────────────────────────────────────────────
|
|
190
|
+
// Upsert Operations
|
|
191
|
+
// ─────────────────────────────────────────────────────────────────
|
|
192
|
+
/**
|
|
193
|
+
* Creates or updates a Mexico client by externalId.
|
|
194
|
+
*
|
|
195
|
+
* @param data - Client upsert data with MX fields at root level (must include externalId)
|
|
196
|
+
* @returns The created or updated client with action indicator
|
|
197
|
+
*/
|
|
198
|
+
async upsertByExternalId(data) {
|
|
199
|
+
const validated = this.validate(upsertMexClientInputSchema, data);
|
|
200
|
+
const nestedData = this.transformToNested(validated);
|
|
201
|
+
const response = await this.execute(() => this.trpc.clients.upsertByExternalId.mutate(nestedData));
|
|
202
|
+
return {
|
|
203
|
+
data: this.instantiate(response.data),
|
|
204
|
+
action: response.action,
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
async upsertManyByExternalId(clients, options = {}) {
|
|
208
|
+
const atomic = options.atomic ?? true;
|
|
209
|
+
const validated = this.validate(z.array(upsertMexClientInputSchema), clients);
|
|
210
|
+
const nestedClients = validated.map((c) => this.transformToNested(c));
|
|
211
|
+
const response = await this.execute(() => this.trpc.clients.upsertManyByExternalId.mutate({
|
|
212
|
+
items: nestedClients,
|
|
213
|
+
atomic,
|
|
214
|
+
}));
|
|
215
|
+
if (response.atomic) {
|
|
216
|
+
return {
|
|
217
|
+
atomic: true,
|
|
218
|
+
data: response.data.map((item) => ({
|
|
219
|
+
data: this.instantiate(item.data),
|
|
220
|
+
action: item.action,
|
|
221
|
+
})),
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
return {
|
|
226
|
+
atomic: false,
|
|
227
|
+
succeeded: response.succeeded.map((item) => ({
|
|
228
|
+
index: item.index,
|
|
229
|
+
data: {
|
|
230
|
+
data: this.instantiate(item.data.data),
|
|
231
|
+
action: item.data.action,
|
|
232
|
+
},
|
|
233
|
+
})),
|
|
234
|
+
failed: response.failed,
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
// ─────────────────────────────────────────────────────────────────
|
|
183
239
|
// Client-to-Client Relationship Management (scoped returns)
|
|
184
240
|
// ─────────────────────────────────────────────────────────────────
|
|
185
241
|
async linkClient(parentClientId, childClientId, relationshipType, metadata) {
|
|
@@ -211,6 +267,13 @@ export class MexClientsResource extends ClientsResource {
|
|
|
211
267
|
return this.instantiate(response);
|
|
212
268
|
}
|
|
213
269
|
async syncAll(clientId, data, options) {
|
|
270
|
+
// Helper to inject clientId into create items (items without id)
|
|
271
|
+
const injectClientId = (items) => items.map((item) => {
|
|
272
|
+
if (!("id" in item) || !item.id) {
|
|
273
|
+
return { ...item, clientId };
|
|
274
|
+
}
|
|
275
|
+
return item;
|
|
276
|
+
});
|
|
214
277
|
// Validate and transform client input
|
|
215
278
|
const validatedClient = data.client
|
|
216
279
|
? this.transformUpdateToNested(this.validate(updateMexClientInputSchema, data.client))
|
|
@@ -218,16 +281,16 @@ export class MexClientsResource extends ClientsResource {
|
|
|
218
281
|
// Validate and transform addresses (flattened MX → nested)
|
|
219
282
|
let validatedAddresses;
|
|
220
283
|
if (data.addresses) {
|
|
221
|
-
const validated = this.validate(z.array(replaceSyncItemSchema(createMexAddressInputSchema, updateMexAddressInputSchema)), data.addresses);
|
|
284
|
+
const validated = this.validate(z.array(replaceSyncItemSchema(createMexAddressInputSchema, updateMexAddressInputSchema)), injectClientId(data.addresses));
|
|
222
285
|
validatedAddresses = validated.map((item) => this.transformAddressSyncItem(item));
|
|
223
286
|
}
|
|
224
287
|
// Validate contact methods (base types, no transform)
|
|
225
288
|
const validatedContactMethods = data.contactMethods
|
|
226
|
-
? this.validate(z.array(replaceSyncItemSchema(createContactMethodInputSchema, updateContactMethodInputSchema)), data.contactMethods)
|
|
289
|
+
? this.validate(z.array(replaceSyncItemSchema(createContactMethodInputSchema, updateContactMethodInputSchema)), injectClientId(data.contactMethods))
|
|
227
290
|
: undefined;
|
|
228
291
|
// Validate bank accounts (base types, no transform)
|
|
229
292
|
const validatedBankAccounts = data.bankAccounts
|
|
230
|
-
? this.validate(z.array(replaceSyncItemSchema(createBankAccountInputSchema, updateBankAccountInputSchema)), data.bankAccounts)
|
|
293
|
+
? this.validate(z.array(replaceSyncItemSchema(createBankAccountInputSchema, updateBankAccountInputSchema)), injectClientId(data.bankAccounts))
|
|
231
294
|
: undefined;
|
|
232
295
|
const validatedLinkedClients = data.linkedClients
|
|
233
296
|
? this.validate(z.array(linkedClientSchema), data.linkedClients)
|
|
@@ -264,17 +327,17 @@ export class MexClientsResource extends ClientsResource {
|
|
|
264
327
|
// Protected Helpers
|
|
265
328
|
// ─────────────────────────────────────────────────────────────────
|
|
266
329
|
/**
|
|
267
|
-
* Transforms a flattened MexClientFilter to nested ClientFilter format
|
|
268
|
-
* and applies Mexico jurisdiction scoping.
|
|
330
|
+
* Transforms a flattened MexClientFilter to nested ClientFilter format.
|
|
269
331
|
*
|
|
270
332
|
* Extracts MX-specific fields (rfc, curp, actividadEconomica, giroMercantil,
|
|
271
333
|
* actividadVulnerable) from root level and nests them under jurisdictions.MX.
|
|
334
|
+
*
|
|
335
|
+
* Note: This method only transforms filters, it does not automatically add
|
|
336
|
+
* jurisdiction scoping. Use explicit filters if you need to scope by jurisdiction.
|
|
272
337
|
*/
|
|
273
338
|
applyScopeToFilter(filter) {
|
|
274
339
|
if (!filter) {
|
|
275
|
-
return
|
|
276
|
-
availableJurisdictions: Jurisdiction.Mexico,
|
|
277
|
-
};
|
|
340
|
+
return undefined;
|
|
278
341
|
}
|
|
279
342
|
// Extract MX-specific filter fields
|
|
280
343
|
const { rfc, curp, actividadEconomica, giroMercantil, actividadVulnerable, ...baseFields } = filter;
|
|
@@ -297,7 +360,6 @@ export class MexClientsResource extends ClientsResource {
|
|
|
297
360
|
mexFilter.actividadVulnerable = actividadVulnerable;
|
|
298
361
|
return {
|
|
299
362
|
...baseFields,
|
|
300
|
-
availableJurisdictions: Jurisdiction.Mexico,
|
|
301
363
|
...(hasMexFields && { jurisdictions: { MX: mexFilter } }),
|
|
302
364
|
};
|
|
303
365
|
}
|
|
@@ -3,10 +3,10 @@
|
|
|
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
|
-
import type { CreateReportInput, UpdateReportInput, CreateReportItemInput, UpdateReportItemInput, CreateMexReportInput, UpdateMexReportInput, CreateMexReportItemInput, UpdateMexReportItemInput, ListOptions, PaginatedResponse, AtomicBatchResult, PartialBatchResult, MexSubmitReportInput, ValidationResult, GenerateResult, SubmissionResult, MexReportDefaultsInput, ReportDefaultsInput } from "@artu-ai/shared";
|
|
9
|
+
import type { CreateReportInput, UpdateReportInput, CreateReportItemInput, UpdateReportItemInput, CreateMexReportInput, UpdateMexReportInput, UpsertMexReportInput, CreateMexReportItemInput, UpdateMexReportItemInput, ListOptions, PaginatedResponse, AtomicBatchResult, PartialBatchResult, MexSubmitReportInput, ValidationResult, GenerateResult, SubmissionResult, MexReportDefaultsInput, ReportDefaultsInput, UpsertResult } from "@artu-ai/shared";
|
|
10
10
|
import type { ReportFilter, ReportSort, MexReportFilter, MexReportSort } from "@artu-ai/shared";
|
|
11
11
|
import { ReportsResource, type ReportItemFilter, type ReportItemSort } from "../reports";
|
|
12
12
|
import { MexReport, type ReportData, type ReportItemData } from "../../models";
|
|
@@ -21,10 +21,12 @@ import { MexReportItem } from "../../models/mex";
|
|
|
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
|
|
@@ -34,7 +36,7 @@ import { MexReportItem } from "../../models/mex";
|
|
|
34
36
|
* },
|
|
35
37
|
* });
|
|
36
38
|
*
|
|
37
|
-
* // List
|
|
39
|
+
* // List reports
|
|
38
40
|
* const { data } = await mexSdk.reports.list();
|
|
39
41
|
* // data is MexReport[]
|
|
40
42
|
* ```
|
|
@@ -58,16 +60,18 @@ export declare class MexReportsResource<TSort = MexReportSort, TDefaults = MexRe
|
|
|
58
60
|
* Lists Mexico reports with optional filtering.
|
|
59
61
|
*
|
|
60
62
|
* Accepts flattened MX filter (future MX-specific report fields at root level).
|
|
61
|
-
* Automatically filters to reports with Mexico jurisdiction data.
|
|
62
63
|
*/
|
|
63
64
|
list(options?: ListOptions<MexReportFilter, TSort>): Promise<PaginatedResponse<MexReport>>;
|
|
64
65
|
/**
|
|
65
66
|
* Iterates over Mexico reports.
|
|
66
67
|
*
|
|
67
68
|
* Accepts flattened MX filter (future MX-specific report fields at root level).
|
|
68
|
-
* Automatically filters to reports with Mexico jurisdiction data.
|
|
69
69
|
*/
|
|
70
|
-
iterate(
|
|
70
|
+
iterate(options?: {
|
|
71
|
+
filter?: MexReportFilter;
|
|
72
|
+
sort?: TSort;
|
|
73
|
+
pageSize?: number;
|
|
74
|
+
}): AsyncGenerator<MexReport, void, undefined>;
|
|
71
75
|
createMany(reports: CreateMexReportInput[], options?: {
|
|
72
76
|
atomic?: true;
|
|
73
77
|
}): Promise<AtomicBatchResult<MexReport>>;
|
|
@@ -86,6 +90,26 @@ export declare class MexReportsResource<TSort = MexReportSort, TDefaults = MexRe
|
|
|
86
90
|
}[], options: {
|
|
87
91
|
atomic: false;
|
|
88
92
|
}): Promise<PartialBatchResult<MexReport>>;
|
|
93
|
+
/**
|
|
94
|
+
* Creates or updates a Mexico report by externalId.
|
|
95
|
+
*
|
|
96
|
+
* @param data - Report upsert data with MX fields at root level (must include externalId)
|
|
97
|
+
* @returns The created or updated report with action indicator
|
|
98
|
+
*/
|
|
99
|
+
upsertByExternalId(data: UpsertMexReportInput): Promise<UpsertResult<MexReport>>;
|
|
100
|
+
/**
|
|
101
|
+
* Creates or updates multiple Mexico reports by externalId.
|
|
102
|
+
*
|
|
103
|
+
* @param reports - Array of report upsert data (each must include externalId)
|
|
104
|
+
* @param options - Batch options (atomic: true by default)
|
|
105
|
+
* @returns Atomic result with data array, or partial result with succeeded/failed
|
|
106
|
+
*/
|
|
107
|
+
upsertManyByExternalId(reports: UpsertMexReportInput[], options?: {
|
|
108
|
+
atomic?: true;
|
|
109
|
+
}): Promise<AtomicBatchResult<UpsertResult<MexReport>>>;
|
|
110
|
+
upsertManyByExternalId(reports: UpsertMexReportInput[], options: {
|
|
111
|
+
atomic: false;
|
|
112
|
+
}): Promise<PartialBatchResult<UpsertResult<MexReport>>>;
|
|
89
113
|
/**
|
|
90
114
|
* Adds an item to a report with flattened Mexico input.
|
|
91
115
|
*/
|
|
@@ -177,13 +201,14 @@ export declare class MexReportsResource<TSort = MexReportSort, TDefaults = MexRe
|
|
|
177
201
|
*/
|
|
178
202
|
submit(input: MexSubmitReportInput): Promise<SubmissionResult>;
|
|
179
203
|
/**
|
|
180
|
-
*
|
|
204
|
+
* Transforms a flattened MexReportFilter to nested ReportFilter format.
|
|
205
|
+
*
|
|
206
|
+
* Currently MexReportFilter has the same fields as the base filter.
|
|
181
207
|
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
* Uses `availableJurisdictions` to find any report that includes Mexico.
|
|
208
|
+
* Note: This method only transforms filters, it does not automatically add
|
|
209
|
+
* jurisdiction scoping. Use explicit filters if you need to scope by jurisdiction.
|
|
185
210
|
*/
|
|
186
|
-
protected applyScopeToFilter(filter?: MexReportFilter): ReportFilter;
|
|
211
|
+
protected applyScopeToFilter(filter?: MexReportFilter): ReportFilter | undefined;
|
|
187
212
|
/**
|
|
188
213
|
* Transforms a flattened MexReportSort to nested ReportSort format.
|
|
189
214
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reports.d.ts","sourceRoot":"","sources":["../../../src/resources/mex/reports.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"reports.d.ts","sourceRoot":"","sources":["../../../src/resources/mex/reports.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO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