@artu-ai/compliance-sdk 0.4.1 → 0.4.3
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/package.json +3 -4
- package/src/errors/api.ts +0 -305
- package/src/errors/base.ts +0 -127
- package/src/errors/index.ts +0 -63
- package/src/errors/upload.ts +0 -204
- package/src/errors/validation.ts +0 -163
- package/src/exports/base.ts +0 -139
- package/src/exports/index.ts +0 -187
- package/src/exports/mexico/actividad-vulnerable/avi.ts +0 -207
- package/src/exports/mexico/actividad-vulnerable/jys.ts +0 -214
- package/src/exports/mexico/actividad-vulnerable/tsc.ts +0 -202
- package/src/exports/mexico/index.ts +0 -215
- package/src/models/Address.ts +0 -235
- package/src/models/BankAccount.ts +0 -235
- package/src/models/Client.ts +0 -363
- package/src/models/ContactMethod.ts +0 -197
- package/src/models/Document.ts +0 -355
- package/src/models/LinkedClient.ts +0 -84
- package/src/models/Report.ts +0 -193
- package/src/models/ReportItem.ts +0 -211
- package/src/models/Transaction.ts +0 -219
- package/src/models/base.ts +0 -56
- package/src/models/index.ts +0 -148
- package/src/models/mex/MexAddress.ts +0 -184
- package/src/models/mex/MexBankAccount.ts +0 -121
- package/src/models/mex/MexClient.ts +0 -177
- package/src/models/mex/MexDocument.ts +0 -890
- package/src/models/mex/MexReport.ts +0 -99
- package/src/models/mex/MexReportItem.ts +0 -79
- package/src/models/mex/MexTransaction.ts +0 -105
- package/src/models/mex/actividad-vulnerable/MexActividadVulnerableClient.ts +0 -66
- package/src/models/mex/actividad-vulnerable/MexActividadVulnerableReport.ts +0 -73
- package/src/models/mex/actividad-vulnerable/MexActividadVulnerableReportItem.ts +0 -74
- package/src/models/mex/actividad-vulnerable/MexActividadVulnerableTransaction.ts +0 -50
- package/src/models/mex/actividad-vulnerable/avi/MexAVIClient.ts +0 -80
- package/src/models/mex/actividad-vulnerable/avi/MexAVIReport.ts +0 -114
- package/src/models/mex/actividad-vulnerable/avi/MexAVIReportItem.ts +0 -105
- package/src/models/mex/actividad-vulnerable/avi/MexAVITransaction.ts +0 -157
- package/src/models/mex/actividad-vulnerable/index.ts +0 -78
- package/src/models/mex/actividad-vulnerable/jys/MexJYSClient.ts +0 -73
- package/src/models/mex/actividad-vulnerable/jys/MexJYSReport.ts +0 -114
- package/src/models/mex/actividad-vulnerable/jys/MexJYSReportItem.ts +0 -105
- package/src/models/mex/actividad-vulnerable/jys/MexJYSTransaction.ts +0 -178
- package/src/models/mex/actividad-vulnerable/tsc/MexTSCClient.ts +0 -73
- package/src/models/mex/actividad-vulnerable/tsc/MexTSCReport.ts +0 -114
- package/src/models/mex/actividad-vulnerable/tsc/MexTSCReportItem.ts +0 -105
- package/src/models/mex/actividad-vulnerable/tsc/MexTSCTransaction.ts +0 -104
- package/src/models/mex/index.ts +0 -57
- package/src/models/types.ts +0 -196
- package/src/namespaces/index.ts +0 -29
- package/src/namespaces/mexico/actividad-vulnerable/avi/index.ts +0 -62
- package/src/namespaces/mexico/actividad-vulnerable/index.ts +0 -79
- package/src/namespaces/mexico/actividad-vulnerable/jys/index.ts +0 -72
- package/src/namespaces/mexico/actividad-vulnerable/tsc/index.ts +0 -60
- package/src/namespaces/mexico/index.ts +0 -325
- package/src/resources/addresses.ts +0 -391
- package/src/resources/bank-accounts.ts +0 -417
- package/src/resources/base.ts +0 -327
- package/src/resources/clients.ts +0 -808
- package/src/resources/contact-methods.ts +0 -412
- package/src/resources/documents.ts +0 -688
- package/src/resources/index.ts +0 -40
- package/src/resources/mex/actividad-vulnerable/avi/clients.ts +0 -559
- package/src/resources/mex/actividad-vulnerable/avi/index.ts +0 -7
- package/src/resources/mex/actividad-vulnerable/avi/reports.ts +0 -609
- package/src/resources/mex/actividad-vulnerable/avi/transactions.ts +0 -404
- package/src/resources/mex/actividad-vulnerable/index.ts +0 -12
- package/src/resources/mex/actividad-vulnerable/jys/clients.ts +0 -445
- package/src/resources/mex/actividad-vulnerable/jys/index.ts +0 -7
- package/src/resources/mex/actividad-vulnerable/jys/reports.ts +0 -591
- package/src/resources/mex/actividad-vulnerable/jys/transactions.ts +0 -395
- package/src/resources/mex/actividad-vulnerable/tsc/clients.ts +0 -445
- package/src/resources/mex/actividad-vulnerable/tsc/index.ts +0 -7
- package/src/resources/mex/actividad-vulnerable/tsc/reports.ts +0 -591
- package/src/resources/mex/actividad-vulnerable/tsc/transactions.ts +0 -404
- package/src/resources/mex/addresses.ts +0 -493
- package/src/resources/mex/bank-accounts.ts +0 -283
- package/src/resources/mex/clients.ts +0 -758
- package/src/resources/mex/ebr.ts +0 -621
- package/src/resources/mex/index.ts +0 -23
- package/src/resources/mex/reports.ts +0 -643
- package/src/resources/mex/transactions.ts +0 -422
- package/src/resources/reports.ts +0 -515
- package/src/resources/transactions.ts +0 -358
- package/src/sdk/ComplianceSDK.ts +0 -812
- package/src/sdk/base.ts +0 -43
- package/src/sdk/index.ts +0 -98
- package/src/sdk/mex/ComplianceSDK.ts +0 -147
- package/src/sdk/mex/actividad-vulnerable/avi/ComplianceSDK.ts +0 -55
- package/src/sdk/mex/actividad-vulnerable/avi/index.ts +0 -16
- package/src/sdk/mex/actividad-vulnerable/avi/types.ts +0 -86
- package/src/sdk/mex/actividad-vulnerable/index.ts +0 -58
- package/src/sdk/mex/actividad-vulnerable/jys/ComplianceSDK.ts +0 -54
- package/src/sdk/mex/actividad-vulnerable/jys/index.ts +0 -16
- package/src/sdk/mex/actividad-vulnerable/jys/types.ts +0 -86
- package/src/sdk/mex/actividad-vulnerable/tsc/ComplianceSDK.ts +0 -54
- package/src/sdk/mex/actividad-vulnerable/tsc/index.ts +0 -16
- package/src/sdk/mex/actividad-vulnerable/tsc/types.ts +0 -86
- package/src/sdk/mex/index.ts +0 -66
- package/src/sdk/mex/types.ts +0 -88
- package/src/sdk/resource-registry.ts +0 -204
- package/src/sdk/sdk-registry.ts +0 -99
- package/src/sdk/types.ts +0 -304
- package/src/utils/environment.ts +0 -187
- package/src/utils/filters.ts +0 -412
- package/src/utils/index.ts +0 -134
- package/src/utils/pagination.ts +0 -143
- package/src/utils/session.ts +0 -303
- package/src/utils/trpc-client.ts +0 -242
- package/src/utils/upload.ts +0 -388
|
@@ -1,493 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Mexico Addresses Resource
|
|
3
|
-
*
|
|
4
|
-
* Extends AddressesResource with Mexico-specific behavior:
|
|
5
|
-
* - Accepts flattened CreateMexAddressInput (MX fields at root level)
|
|
6
|
-
* - Returns MexAddress models with Mexico-specific accessors
|
|
7
|
-
*
|
|
8
|
-
* Note: Mexican address format can be used for addresses in any country.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { z } from "zod";
|
|
12
|
-
import type {
|
|
13
|
-
CreateAddressInput,
|
|
14
|
-
UpdateAddressInput,
|
|
15
|
-
AddressFilter,
|
|
16
|
-
AddressSort,
|
|
17
|
-
AddressType,
|
|
18
|
-
ListOptions,
|
|
19
|
-
PaginatedResponse,
|
|
20
|
-
CreateMexAddressInput,
|
|
21
|
-
UpdateMexAddressInput,
|
|
22
|
-
AtomicBatchResult,
|
|
23
|
-
PartialBatchResult,
|
|
24
|
-
SyncItem,
|
|
25
|
-
SyncResult,
|
|
26
|
-
MexAddressFilter,
|
|
27
|
-
MexAddressSort,
|
|
28
|
-
} from "@artu-ai/shared";
|
|
29
|
-
import {
|
|
30
|
-
createMexAddressInputSchema,
|
|
31
|
-
updateMexAddressInputSchema,
|
|
32
|
-
replaceSyncItemSchema,
|
|
33
|
-
transformSort,
|
|
34
|
-
mexAddressFieldMapping,
|
|
35
|
-
} from "@artu-ai/shared";
|
|
36
|
-
import { AddressesResource } from "../addresses";
|
|
37
|
-
import { type BatchOptions } from "../clients";
|
|
38
|
-
import { MexAddress, type AddressData } from "../../models";
|
|
39
|
-
|
|
40
|
-
// ===========================
|
|
41
|
-
// MexAddressesResource
|
|
42
|
-
// ===========================
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Mexico-scoped addresses resource.
|
|
46
|
-
*
|
|
47
|
-
* Provides the same operations as AddressesResource but with:
|
|
48
|
-
* - Flattened input types (MX fields like exteriorNumber, neighborhood at root level)
|
|
49
|
-
* - MexAddress model return type with Mexico-specific accessors
|
|
50
|
-
*
|
|
51
|
-
* @example
|
|
52
|
-
* ```typescript
|
|
53
|
-
* const mexSdk = new ComplianceSDK({
|
|
54
|
-
* apiKey,
|
|
55
|
-
* environment: "test",
|
|
56
|
-
* jurisdiction: Jurisdiction.Mexico,
|
|
57
|
-
* });
|
|
58
|
-
*
|
|
59
|
-
* // Create with flattened input
|
|
60
|
-
* const address = await mexSdk.addresses.create({
|
|
61
|
-
* clientId: "client_123",
|
|
62
|
-
* street: "Paseo de la Reforma",
|
|
63
|
-
* exteriorNumber: "222",
|
|
64
|
-
* interiorNumber: "Piso 5",
|
|
65
|
-
* neighborhood: "Juárez",
|
|
66
|
-
* city: "Ciudad de México",
|
|
67
|
-
* state: "CDMX",
|
|
68
|
-
* postalCode: "06600",
|
|
69
|
-
* country: "MX",
|
|
70
|
-
* type: "home",
|
|
71
|
-
* });
|
|
72
|
-
*
|
|
73
|
-
* // Returns MexAddress
|
|
74
|
-
* console.log(address.exteriorNumber);
|
|
75
|
-
* console.log(address.formattedMexican);
|
|
76
|
-
* ```
|
|
77
|
-
*/
|
|
78
|
-
export class MexAddressesResource<
|
|
79
|
-
TSort = MexAddressSort,
|
|
80
|
-
> extends AddressesResource<TSort> {
|
|
81
|
-
// ─────────────────────────────────────────────────────────────────
|
|
82
|
-
// CRUD Operations (override with flattened input types)
|
|
83
|
-
// ─────────────────────────────────────────────────────────────────
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Creates a new address with Mexico-format fields.
|
|
87
|
-
*/
|
|
88
|
-
async create(data: CreateMexAddressInput): Promise<MexAddress> {
|
|
89
|
-
const validated = this.validate(createMexAddressInputSchema, data);
|
|
90
|
-
const nestedData = this.transformToNested(validated);
|
|
91
|
-
|
|
92
|
-
const response = await this.execute(() =>
|
|
93
|
-
this.trpc.addresses.create.mutate(nestedData)
|
|
94
|
-
);
|
|
95
|
-
|
|
96
|
-
return this.instantiate(response);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Retrieves an address by ID.
|
|
101
|
-
*/
|
|
102
|
-
async retrieve(id: string): Promise<MexAddress> {
|
|
103
|
-
const response = await this.execute(() =>
|
|
104
|
-
this.trpc.addresses.retrieve.query({ id })
|
|
105
|
-
);
|
|
106
|
-
return this.instantiate(response);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
async retrieveByMetadata(key: string, value: string): Promise<MexAddress> {
|
|
110
|
-
const response = await this.execute(() =>
|
|
111
|
-
this.trpc.addresses.retrieveByMetadata.query({ key, value })
|
|
112
|
-
);
|
|
113
|
-
return this.instantiate(response);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
async retrieveByExternalId(externalId: string): Promise<MexAddress> {
|
|
117
|
-
const response = await this.execute(() =>
|
|
118
|
-
this.trpc.addresses.retrieveByExternalId.query({ externalId })
|
|
119
|
-
);
|
|
120
|
-
return this.instantiate(response);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Updates an address with Mexico-format fields.
|
|
125
|
-
*/
|
|
126
|
-
async update(id: string, data: UpdateMexAddressInput): Promise<MexAddress> {
|
|
127
|
-
const validated = this.validate(updateMexAddressInputSchema, data);
|
|
128
|
-
const nestedData = this.transformUpdateToNested(validated);
|
|
129
|
-
|
|
130
|
-
const response = await this.execute(() =>
|
|
131
|
-
this.trpc.addresses.update.mutate({ id, data: nestedData })
|
|
132
|
-
);
|
|
133
|
-
return this.instantiate(response);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// ─────────────────────────────────────────────────────────────────
|
|
137
|
-
// List & Pagination
|
|
138
|
-
// ─────────────────────────────────────────────────────────────────
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Lists addresses with optional filtering.
|
|
142
|
-
*
|
|
143
|
-
* Accepts flattened MX filter (MX-specific fields at root level).
|
|
144
|
-
*/
|
|
145
|
-
async list(
|
|
146
|
-
options?: ListOptions<MexAddressFilter, TSort>
|
|
147
|
-
): Promise<PaginatedResponse<MexAddress>> {
|
|
148
|
-
const scopedFilter = this.applyScopeToFilter(options?.filter);
|
|
149
|
-
const scopedSort = this.applyScopeToSort(options?.sort);
|
|
150
|
-
|
|
151
|
-
const response = await this.execute(() =>
|
|
152
|
-
this.trpc.addresses.list.query({
|
|
153
|
-
...options,
|
|
154
|
-
filter: scopedFilter,
|
|
155
|
-
sort: scopedSort,
|
|
156
|
-
})
|
|
157
|
-
);
|
|
158
|
-
|
|
159
|
-
return {
|
|
160
|
-
data: response.data.map((a) => this.instantiate(a)),
|
|
161
|
-
pagination: response.pagination,
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Lists all addresses for a specific client.
|
|
167
|
-
*/
|
|
168
|
-
async listByClient(
|
|
169
|
-
clientId: string,
|
|
170
|
-
options?: { cursor?: string; limit?: number }
|
|
171
|
-
): Promise<PaginatedResponse<MexAddress>> {
|
|
172
|
-
const response = await this.execute(() =>
|
|
173
|
-
this.trpc.addresses.listByClient.query({ clientId, ...options })
|
|
174
|
-
);
|
|
175
|
-
|
|
176
|
-
return {
|
|
177
|
-
data: response.data.map((a) => this.instantiate(a)),
|
|
178
|
-
pagination: response.pagination,
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* Gets the primary address for a client.
|
|
184
|
-
*/
|
|
185
|
-
async getPrimary(
|
|
186
|
-
clientId: string,
|
|
187
|
-
type?: AddressType
|
|
188
|
-
): Promise<MexAddress | null> {
|
|
189
|
-
const response = await this.execute(() =>
|
|
190
|
-
this.trpc.addresses.getPrimary.query({ clientId, type })
|
|
191
|
-
);
|
|
192
|
-
return response ? this.instantiate(response) : null;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Iterates over addresses.
|
|
197
|
-
*
|
|
198
|
-
* Accepts flattened MX filter (MX-specific fields at root level).
|
|
199
|
-
*/
|
|
200
|
-
iterate(filter?: MexAddressFilter): AsyncGenerator<MexAddress, void, undefined> {
|
|
201
|
-
const scopedFilter = this.applyScopeToFilter(filter);
|
|
202
|
-
return this.createIterator<MexAddress>({ filter: scopedFilter });
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
// ─────────────────────────────────────────────────────────────────
|
|
206
|
-
// Batch Operations
|
|
207
|
-
// ─────────────────────────────────────────────────────────────────
|
|
208
|
-
|
|
209
|
-
async createMany(
|
|
210
|
-
addresses: CreateMexAddressInput[],
|
|
211
|
-
options?: { atomic?: true }
|
|
212
|
-
): Promise<AtomicBatchResult<MexAddress>>;
|
|
213
|
-
async createMany(
|
|
214
|
-
addresses: CreateMexAddressInput[],
|
|
215
|
-
options: { atomic: false }
|
|
216
|
-
): Promise<PartialBatchResult<MexAddress>>;
|
|
217
|
-
async createMany(
|
|
218
|
-
addresses: CreateMexAddressInput[],
|
|
219
|
-
options: BatchOptions = {}
|
|
220
|
-
): Promise<AtomicBatchResult<MexAddress> | PartialBatchResult<MexAddress>> {
|
|
221
|
-
const atomic = options.atomic ?? true;
|
|
222
|
-
const validated = this.validate(
|
|
223
|
-
z.array(createMexAddressInputSchema),
|
|
224
|
-
addresses
|
|
225
|
-
);
|
|
226
|
-
const nestedItems = validated.map((a) => this.transformToNested(a));
|
|
227
|
-
|
|
228
|
-
const response = await this.execute(() =>
|
|
229
|
-
this.trpc.addresses.createMany.mutate({ items: nestedItems, atomic })
|
|
230
|
-
);
|
|
231
|
-
|
|
232
|
-
if (response.atomic) {
|
|
233
|
-
return {
|
|
234
|
-
atomic: true,
|
|
235
|
-
data: response.data.map((a) => this.instantiate(a)),
|
|
236
|
-
};
|
|
237
|
-
} else {
|
|
238
|
-
return {
|
|
239
|
-
atomic: false,
|
|
240
|
-
succeeded: response.succeeded.map((item) => ({
|
|
241
|
-
index: item.index,
|
|
242
|
-
data: this.instantiate(item.data),
|
|
243
|
-
})),
|
|
244
|
-
failed: response.failed,
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
async updateMany(
|
|
250
|
-
updates: { id: string; data: UpdateMexAddressInput }[],
|
|
251
|
-
options?: { atomic?: true }
|
|
252
|
-
): Promise<AtomicBatchResult<MexAddress>>;
|
|
253
|
-
async updateMany(
|
|
254
|
-
updates: { id: string; data: UpdateMexAddressInput }[],
|
|
255
|
-
options: { atomic: false }
|
|
256
|
-
): Promise<PartialBatchResult<MexAddress>>;
|
|
257
|
-
async updateMany(
|
|
258
|
-
updates: { id: string; data: UpdateMexAddressInput }[],
|
|
259
|
-
options: BatchOptions = {}
|
|
260
|
-
): Promise<AtomicBatchResult<MexAddress> | PartialBatchResult<MexAddress>> {
|
|
261
|
-
const atomic = options.atomic ?? true;
|
|
262
|
-
const updateItemSchema = z.object({
|
|
263
|
-
id: z.uuid(),
|
|
264
|
-
data: updateMexAddressInputSchema,
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
const validated = this.validate(z.array(updateItemSchema), updates);
|
|
268
|
-
const nestedUpdates = validated.map((u) => ({
|
|
269
|
-
id: u.id,
|
|
270
|
-
data: this.transformUpdateToNested(u.data),
|
|
271
|
-
}));
|
|
272
|
-
|
|
273
|
-
const response = await this.execute(() =>
|
|
274
|
-
this.trpc.addresses.updateMany.mutate({ items: nestedUpdates, atomic })
|
|
275
|
-
);
|
|
276
|
-
|
|
277
|
-
if (response.atomic) {
|
|
278
|
-
return {
|
|
279
|
-
atomic: true,
|
|
280
|
-
data: response.data.map((a) => this.instantiate(a)),
|
|
281
|
-
};
|
|
282
|
-
} else {
|
|
283
|
-
return {
|
|
284
|
-
atomic: false,
|
|
285
|
-
succeeded: response.succeeded.map((item) => ({
|
|
286
|
-
index: item.index,
|
|
287
|
-
data: this.instantiate(item.data),
|
|
288
|
-
})),
|
|
289
|
-
failed: response.failed,
|
|
290
|
-
};
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
// ─────────────────────────────────────────────────────────────────
|
|
295
|
-
// Sync Operations
|
|
296
|
-
// ─────────────────────────────────────────────────────────────────
|
|
297
|
-
|
|
298
|
-
/**
|
|
299
|
-
* Syncs addresses for a client with Mexico-format flattened input.
|
|
300
|
-
*/
|
|
301
|
-
async sync(
|
|
302
|
-
clientId: string,
|
|
303
|
-
items: SyncItem<CreateMexAddressInput>[],
|
|
304
|
-
options: { replaceMode: true }
|
|
305
|
-
): Promise<SyncResult<MexAddress>>;
|
|
306
|
-
async sync(
|
|
307
|
-
clientId: string,
|
|
308
|
-
items: SyncItem<UpdateMexAddressInput>[],
|
|
309
|
-
options?: { replaceMode?: boolean }
|
|
310
|
-
): Promise<SyncResult<MexAddress>>;
|
|
311
|
-
async sync(
|
|
312
|
-
clientId: string,
|
|
313
|
-
items: SyncItem<UpdateMexAddressInput | CreateMexAddressInput>[],
|
|
314
|
-
options?: { replaceMode?: boolean }
|
|
315
|
-
): Promise<SyncResult<MexAddress>> {
|
|
316
|
-
const validated = this.validate(
|
|
317
|
-
z.array(
|
|
318
|
-
replaceSyncItemSchema(
|
|
319
|
-
createMexAddressInputSchema,
|
|
320
|
-
updateMexAddressInputSchema
|
|
321
|
-
)
|
|
322
|
-
),
|
|
323
|
-
items
|
|
324
|
-
);
|
|
325
|
-
|
|
326
|
-
// Transform each item to nested format
|
|
327
|
-
const nestedItems: SyncItem<UpdateAddressInput | CreateAddressInput>[] = [];
|
|
328
|
-
for (const item of validated) {
|
|
329
|
-
if ("_delete" in item && item._delete) {
|
|
330
|
-
// Delete items pass through unchanged
|
|
331
|
-
nestedItems.push(item as SyncItem<UpdateAddressInput>);
|
|
332
|
-
} else if ("id" in item && item.id) {
|
|
333
|
-
// Update items - transform the data fields
|
|
334
|
-
const { id, ...data } = item;
|
|
335
|
-
const transformed = this.transformUpdateToNested(
|
|
336
|
-
data as UpdateMexAddressInput
|
|
337
|
-
);
|
|
338
|
-
nestedItems.push({
|
|
339
|
-
id,
|
|
340
|
-
...transformed,
|
|
341
|
-
} as SyncItem<UpdateAddressInput>);
|
|
342
|
-
} else {
|
|
343
|
-
// Create items - transform full item
|
|
344
|
-
const transformed = this.transformToNested(
|
|
345
|
-
item as CreateMexAddressInput
|
|
346
|
-
);
|
|
347
|
-
nestedItems.push(transformed as SyncItem<CreateAddressInput>);
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
// Call parent sync with transformed items
|
|
352
|
-
// Parent already uses our overridden instantiate(), so result contains MexAddress
|
|
353
|
-
const result = await super.sync(
|
|
354
|
-
clientId,
|
|
355
|
-
nestedItems,
|
|
356
|
-
options as { replaceMode?: boolean }
|
|
357
|
-
);
|
|
358
|
-
|
|
359
|
-
return result as SyncResult<MexAddress>;
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
// ─────────────────────────────────────────────────────────────────
|
|
363
|
-
// Protected Helpers
|
|
364
|
-
// ─────────────────────────────────────────────────────────────────
|
|
365
|
-
|
|
366
|
-
/**
|
|
367
|
-
* Transforms flattened MX filter to nested API format.
|
|
368
|
-
*
|
|
369
|
-
* Mexico-specific filter fields (neighborhood, municipality) are stored
|
|
370
|
-
* in `jurisdictions.MX`. Base fields pass through unchanged.
|
|
371
|
-
*/
|
|
372
|
-
protected applyScopeToFilter(filter?: MexAddressFilter): AddressFilter {
|
|
373
|
-
if (!filter) return {};
|
|
374
|
-
|
|
375
|
-
const { neighborhood, municipality, ...baseFields } = filter;
|
|
376
|
-
|
|
377
|
-
const hasMexFields = neighborhood !== undefined || municipality !== undefined;
|
|
378
|
-
|
|
379
|
-
if (!hasMexFields) {
|
|
380
|
-
return baseFields as AddressFilter;
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
const mexData: Record<string, unknown> = {};
|
|
384
|
-
if (neighborhood !== undefined) mexData.neighborhood = neighborhood;
|
|
385
|
-
if (municipality !== undefined) mexData.municipality = municipality;
|
|
386
|
-
|
|
387
|
-
return {
|
|
388
|
-
...baseFields,
|
|
389
|
-
jurisdictions: { MX: mexData },
|
|
390
|
-
} as AddressFilter;
|
|
391
|
-
}
|
|
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
|
-
|
|
407
|
-
/**
|
|
408
|
-
* Transforms flattened MX input to nested API format.
|
|
409
|
-
*
|
|
410
|
-
* Mexico-specific fields (exteriorNumber, interiorNumber, neighborhood, etc.)
|
|
411
|
-
* are stored in `jurisdictions.MX`. The base `street` field is passed through.
|
|
412
|
-
*/
|
|
413
|
-
protected transformToNested(data: CreateMexAddressInput): CreateAddressInput {
|
|
414
|
-
const {
|
|
415
|
-
// Mexico-specific fields go into `jurisdictions.MX`
|
|
416
|
-
exteriorNumber,
|
|
417
|
-
interiorNumber,
|
|
418
|
-
neighborhood,
|
|
419
|
-
municipality,
|
|
420
|
-
betweenStreets,
|
|
421
|
-
reference,
|
|
422
|
-
// Base fields pass through
|
|
423
|
-
...baseFields
|
|
424
|
-
} = data;
|
|
425
|
-
|
|
426
|
-
// Build Mexico-specific data for the `jurisdictions.MX` column
|
|
427
|
-
// exteriorNumber and neighborhood are required by schema validation
|
|
428
|
-
const mexData: Record<string, unknown> = {
|
|
429
|
-
exteriorNumber,
|
|
430
|
-
neighborhood,
|
|
431
|
-
};
|
|
432
|
-
if (interiorNumber !== undefined) mexData.interiorNumber = interiorNumber;
|
|
433
|
-
if (municipality !== undefined) mexData.municipality = municipality;
|
|
434
|
-
if (betweenStreets !== undefined) mexData.betweenStreets = betweenStreets;
|
|
435
|
-
if (reference !== undefined) mexData.reference = reference;
|
|
436
|
-
|
|
437
|
-
return {
|
|
438
|
-
...baseFields,
|
|
439
|
-
jurisdictions: { MX: mexData },
|
|
440
|
-
} as CreateAddressInput;
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
/**
|
|
444
|
-
* Transforms flattened MX update input to nested API format.
|
|
445
|
-
*/
|
|
446
|
-
protected transformUpdateToNested(
|
|
447
|
-
data: UpdateMexAddressInput
|
|
448
|
-
): UpdateAddressInput {
|
|
449
|
-
const {
|
|
450
|
-
// Mexico-specific fields go into `jurisdictions.MX`
|
|
451
|
-
exteriorNumber,
|
|
452
|
-
interiorNumber,
|
|
453
|
-
neighborhood,
|
|
454
|
-
municipality,
|
|
455
|
-
betweenStreets,
|
|
456
|
-
reference,
|
|
457
|
-
// Base fields pass through
|
|
458
|
-
...baseFields
|
|
459
|
-
} = data;
|
|
460
|
-
|
|
461
|
-
const hasMexFields =
|
|
462
|
-
exteriorNumber !== undefined ||
|
|
463
|
-
interiorNumber !== undefined ||
|
|
464
|
-
neighborhood !== undefined ||
|
|
465
|
-
municipality !== undefined ||
|
|
466
|
-
betweenStreets !== undefined ||
|
|
467
|
-
reference !== undefined;
|
|
468
|
-
|
|
469
|
-
if (!hasMexFields) {
|
|
470
|
-
return baseFields as UpdateAddressInput;
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
const mexData: Record<string, unknown> = {};
|
|
474
|
-
if (exteriorNumber !== undefined) mexData.exteriorNumber = exteriorNumber;
|
|
475
|
-
if (interiorNumber !== undefined) mexData.interiorNumber = interiorNumber;
|
|
476
|
-
if (neighborhood !== undefined) mexData.neighborhood = neighborhood;
|
|
477
|
-
if (municipality !== undefined) mexData.municipality = municipality;
|
|
478
|
-
if (betweenStreets !== undefined) mexData.betweenStreets = betweenStreets;
|
|
479
|
-
if (reference !== undefined) mexData.reference = reference;
|
|
480
|
-
|
|
481
|
-
return {
|
|
482
|
-
...baseFields,
|
|
483
|
-
jurisdictions: { MX: mexData },
|
|
484
|
-
} as UpdateAddressInput;
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
/**
|
|
488
|
-
* Instantiates a MexAddress model.
|
|
489
|
-
*/
|
|
490
|
-
protected override instantiate(data: AddressData): MexAddress {
|
|
491
|
-
return new MexAddress(data);
|
|
492
|
-
}
|
|
493
|
-
}
|