@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,445 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* JYS (Juegos y Sorteos) Clients Resource
|
|
3
|
-
*
|
|
4
|
-
* Extends MexClientsResource with JYS-specific behavior.
|
|
5
|
-
* JYS clients have the same fields as Mexico clients (no additional activity fields).
|
|
6
|
-
* Returns MexJYSClient models.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { z } from "zod";
|
|
10
|
-
import type {
|
|
11
|
-
CreateClientInput,
|
|
12
|
-
UpdateClientInput,
|
|
13
|
-
ListOptions,
|
|
14
|
-
PaginatedResponse,
|
|
15
|
-
CreateJYSClientInput,
|
|
16
|
-
UpdateJYSClientInput,
|
|
17
|
-
CreateMexClientInput,
|
|
18
|
-
UpdateMexClientInput,
|
|
19
|
-
AtomicBatchResult,
|
|
20
|
-
PartialBatchResult,
|
|
21
|
-
ClientRelationshipType,
|
|
22
|
-
LinkedClient as LinkedClientInput,
|
|
23
|
-
CreateMexAddressInput,
|
|
24
|
-
UpdateMexAddressInput,
|
|
25
|
-
CreateContactMethodInput,
|
|
26
|
-
UpdateContactMethodInput,
|
|
27
|
-
CreateBankAccountInput,
|
|
28
|
-
UpdateBankAccountInput,
|
|
29
|
-
SyncItem,
|
|
30
|
-
SyncResult,
|
|
31
|
-
JYSClientFilter,
|
|
32
|
-
JYSClientSort,
|
|
33
|
-
} from "@artu-ai/shared";
|
|
34
|
-
import {
|
|
35
|
-
CodigoActividad,
|
|
36
|
-
createJYSClientInputSchema,
|
|
37
|
-
updateJYSClientInputSchema,
|
|
38
|
-
linkedClientSchema,
|
|
39
|
-
transformSort,
|
|
40
|
-
jysClientFieldMapping,
|
|
41
|
-
} from "@artu-ai/shared";
|
|
42
|
-
import type { ClientSort } from "@artu-ai/shared";
|
|
43
|
-
import { MexClientsResource } from "../../clients";
|
|
44
|
-
import { type BatchOptions, type ClientIncludeMap } from "../../../clients";
|
|
45
|
-
import {
|
|
46
|
-
MexJYSClient,
|
|
47
|
-
MexAddress,
|
|
48
|
-
MexBankAccount,
|
|
49
|
-
ContactMethod,
|
|
50
|
-
LinkedClient,
|
|
51
|
-
type ClientData,
|
|
52
|
-
} from "../../../../models";
|
|
53
|
-
|
|
54
|
-
// ===========================
|
|
55
|
-
// JYSClientsResource
|
|
56
|
-
// ===========================
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* JYS (Juegos y Sorteos) scoped clients resource.
|
|
60
|
-
*
|
|
61
|
-
* @example
|
|
62
|
-
* ```typescript
|
|
63
|
-
* const jysSdk = new ComplianceSDK({
|
|
64
|
-
* apiKey,
|
|
65
|
-
* environment: "test",
|
|
66
|
-
* jurisdiction: Jurisdiction.Mexico,
|
|
67
|
-
* actividadVulnerable: CodigoActividad.JYS,
|
|
68
|
-
* });
|
|
69
|
-
*
|
|
70
|
-
* const client = await jysSdk.clients.create({
|
|
71
|
-
* type: ClientType.Person,
|
|
72
|
-
* name: "Juan García",
|
|
73
|
-
* rfc: "GAJL850101ABC",
|
|
74
|
-
* });
|
|
75
|
-
*
|
|
76
|
-
* // Returns MexJYSClient
|
|
77
|
-
* ```
|
|
78
|
-
*/
|
|
79
|
-
export class JYSClientsResource extends MexClientsResource<JYSClientSort> {
|
|
80
|
-
// ─────────────────────────────────────────────────────────────────
|
|
81
|
-
// CRUD Operations
|
|
82
|
-
// ─────────────────────────────────────────────────────────────────
|
|
83
|
-
|
|
84
|
-
async create(data: CreateJYSClientInput): Promise<MexJYSClient> {
|
|
85
|
-
const validated = this.validate(createJYSClientInputSchema, data);
|
|
86
|
-
const nestedData = this.transformToNested(validated);
|
|
87
|
-
|
|
88
|
-
const response = await this.execute(() =>
|
|
89
|
-
this.trpc.clients.create.mutate(nestedData)
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
return this.instantiate(response);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
async retrieve(
|
|
96
|
-
id: string,
|
|
97
|
-
include?: ClientIncludeMap
|
|
98
|
-
): Promise<MexJYSClient> {
|
|
99
|
-
const response = await this.execute(() =>
|
|
100
|
-
this.trpc.clients.retrieve.query({ id, include })
|
|
101
|
-
);
|
|
102
|
-
return this.instantiate(response);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
async retrieveByExternalId(externalId: string): Promise<MexJYSClient> {
|
|
106
|
-
const response = await this.execute(() =>
|
|
107
|
-
this.trpc.clients.retrieveByExternalId.query({ externalId })
|
|
108
|
-
);
|
|
109
|
-
return this.instantiate(response);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
async update(id: string, data: UpdateJYSClientInput): Promise<MexJYSClient> {
|
|
113
|
-
const validated = this.validate(updateJYSClientInputSchema, data);
|
|
114
|
-
const nestedData = this.transformUpdateToNested(validated);
|
|
115
|
-
|
|
116
|
-
const response = await this.execute(() =>
|
|
117
|
-
this.trpc.clients.update.mutate({ id, data: nestedData })
|
|
118
|
-
);
|
|
119
|
-
return this.instantiate(response);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// ─────────────────────────────────────────────────────────────────
|
|
123
|
-
// List & Pagination
|
|
124
|
-
// ─────────────────────────────────────────────────────────────────
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Lists JYS clients with optional filtering.
|
|
128
|
-
*
|
|
129
|
-
* Accepts flattened JYS filter (MX fields at root level) and automatically
|
|
130
|
-
* transforms to nested format before calling the API.
|
|
131
|
-
*/
|
|
132
|
-
async list(
|
|
133
|
-
options?: ListOptions<JYSClientFilter, JYSClientSort> & { includePrimaryContacts?: boolean }
|
|
134
|
-
): Promise<PaginatedResponse<MexJYSClient>> {
|
|
135
|
-
const scopedFilter = this.applyScopeToFilter(options?.filter);
|
|
136
|
-
const scopedSort = this.applyScopeToSort(options?.sort);
|
|
137
|
-
|
|
138
|
-
const response = await this.execute(() =>
|
|
139
|
-
this.trpc.clients.list.query({
|
|
140
|
-
...options,
|
|
141
|
-
filter: scopedFilter,
|
|
142
|
-
sort: scopedSort,
|
|
143
|
-
})
|
|
144
|
-
);
|
|
145
|
-
|
|
146
|
-
return {
|
|
147
|
-
data: response.data.map((c) => this.instantiate(c)),
|
|
148
|
-
pagination: response.pagination,
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Iterates over JYS clients.
|
|
154
|
-
*
|
|
155
|
-
* Accepts flattened JYS filter (MX fields at root level) and automatically
|
|
156
|
-
* transforms to nested format before calling the API.
|
|
157
|
-
*/
|
|
158
|
-
iterate(
|
|
159
|
-
filter?: JYSClientFilter
|
|
160
|
-
): AsyncGenerator<MexJYSClient, void, undefined> {
|
|
161
|
-
const scopedFilter = this.applyScopeToFilter(filter);
|
|
162
|
-
return this.createIterator<MexJYSClient>({ filter: scopedFilter });
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
// ─────────────────────────────────────────────────────────────────
|
|
166
|
-
// Batch Operations
|
|
167
|
-
// ─────────────────────────────────────────────────────────────────
|
|
168
|
-
|
|
169
|
-
async createMany(
|
|
170
|
-
clients: CreateJYSClientInput[],
|
|
171
|
-
options?: { atomic?: true }
|
|
172
|
-
): Promise<AtomicBatchResult<MexJYSClient>>;
|
|
173
|
-
async createMany(
|
|
174
|
-
clients: CreateJYSClientInput[],
|
|
175
|
-
options: { atomic: false }
|
|
176
|
-
): Promise<PartialBatchResult<MexJYSClient>>;
|
|
177
|
-
async createMany(
|
|
178
|
-
clients: CreateJYSClientInput[],
|
|
179
|
-
options: BatchOptions = {}
|
|
180
|
-
): Promise<
|
|
181
|
-
AtomicBatchResult<MexJYSClient> | PartialBatchResult<MexJYSClient>
|
|
182
|
-
> {
|
|
183
|
-
const atomic = options.atomic ?? true;
|
|
184
|
-
const validated = this.validate(
|
|
185
|
-
z.array(createJYSClientInputSchema),
|
|
186
|
-
clients
|
|
187
|
-
);
|
|
188
|
-
const nestedClients = validated.map((c) => this.transformToNested(c));
|
|
189
|
-
|
|
190
|
-
const response = await this.execute(() =>
|
|
191
|
-
this.trpc.clients.createMany.mutate({ items: nestedClients, atomic })
|
|
192
|
-
);
|
|
193
|
-
|
|
194
|
-
if (response.atomic) {
|
|
195
|
-
return {
|
|
196
|
-
atomic: true,
|
|
197
|
-
data: response.data.map((c) => this.instantiate(c)),
|
|
198
|
-
};
|
|
199
|
-
} else {
|
|
200
|
-
return {
|
|
201
|
-
atomic: false,
|
|
202
|
-
succeeded: response.succeeded.map((item) => ({
|
|
203
|
-
index: item.index,
|
|
204
|
-
data: this.instantiate(item.data),
|
|
205
|
-
})),
|
|
206
|
-
failed: response.failed,
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
async updateMany(
|
|
212
|
-
updates: { id: string; data: UpdateJYSClientInput }[],
|
|
213
|
-
options?: { atomic?: true }
|
|
214
|
-
): Promise<AtomicBatchResult<MexJYSClient>>;
|
|
215
|
-
async updateMany(
|
|
216
|
-
updates: { id: string; data: UpdateJYSClientInput }[],
|
|
217
|
-
options: { atomic: false }
|
|
218
|
-
): Promise<PartialBatchResult<MexJYSClient>>;
|
|
219
|
-
async updateMany(
|
|
220
|
-
updates: { id: string; data: UpdateJYSClientInput }[],
|
|
221
|
-
options: BatchOptions = {}
|
|
222
|
-
): Promise<
|
|
223
|
-
AtomicBatchResult<MexJYSClient> | PartialBatchResult<MexJYSClient>
|
|
224
|
-
> {
|
|
225
|
-
const atomic = options.atomic ?? true;
|
|
226
|
-
const updateItemSchema = z.object({
|
|
227
|
-
id: z.uuid(),
|
|
228
|
-
data: updateJYSClientInputSchema,
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
const validated = this.validate(z.array(updateItemSchema), updates);
|
|
232
|
-
const nestedUpdates = validated.map((u) => ({
|
|
233
|
-
id: u.id,
|
|
234
|
-
data: this.transformUpdateToNested(u.data),
|
|
235
|
-
}));
|
|
236
|
-
|
|
237
|
-
const response = await this.execute(() =>
|
|
238
|
-
this.trpc.clients.updateMany.mutate({ items: nestedUpdates, atomic })
|
|
239
|
-
);
|
|
240
|
-
|
|
241
|
-
if (response.atomic) {
|
|
242
|
-
return {
|
|
243
|
-
atomic: true,
|
|
244
|
-
data: response.data.map((c) => this.instantiate(c)),
|
|
245
|
-
};
|
|
246
|
-
} else {
|
|
247
|
-
return {
|
|
248
|
-
atomic: false,
|
|
249
|
-
succeeded: response.succeeded.map((item) => ({
|
|
250
|
-
index: item.index,
|
|
251
|
-
data: this.instantiate(item.data),
|
|
252
|
-
})),
|
|
253
|
-
failed: response.failed,
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
// ─────────────────────────────────────────────────────────────────
|
|
259
|
-
// Client-to-Client Relationship Management (scoped returns)
|
|
260
|
-
// ─────────────────────────────────────────────────────────────────
|
|
261
|
-
|
|
262
|
-
async linkClient(
|
|
263
|
-
parentClientId: string,
|
|
264
|
-
childClientId: string,
|
|
265
|
-
relationshipType: ClientRelationshipType,
|
|
266
|
-
metadata?: Record<string, unknown>
|
|
267
|
-
): Promise<MexJYSClient> {
|
|
268
|
-
const response = await this.execute(() =>
|
|
269
|
-
this.trpc.clients.linkClient.mutate({
|
|
270
|
-
parentClientId,
|
|
271
|
-
childClientId,
|
|
272
|
-
relationshipType,
|
|
273
|
-
metadata,
|
|
274
|
-
})
|
|
275
|
-
);
|
|
276
|
-
return this.instantiate(response);
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
async unlinkClient(
|
|
280
|
-
parentClientId: string,
|
|
281
|
-
childClientId: string,
|
|
282
|
-
relationshipType: ClientRelationshipType
|
|
283
|
-
): Promise<MexJYSClient> {
|
|
284
|
-
const response = await this.execute(() =>
|
|
285
|
-
this.trpc.clients.unlinkClient.mutate({
|
|
286
|
-
parentClientId,
|
|
287
|
-
childClientId,
|
|
288
|
-
relationshipType,
|
|
289
|
-
})
|
|
290
|
-
);
|
|
291
|
-
return this.instantiate(response);
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
async listLinkedClients(
|
|
295
|
-
parentClientId: string,
|
|
296
|
-
relationshipType?: ClientRelationshipType
|
|
297
|
-
): Promise<LinkedClient[]> {
|
|
298
|
-
return super.listLinkedClients(parentClientId, relationshipType);
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
async setLinkedClients(
|
|
302
|
-
parentClientId: string,
|
|
303
|
-
linkedClients: LinkedClientInput[]
|
|
304
|
-
): Promise<MexJYSClient> {
|
|
305
|
-
const validated = this.validate(z.array(linkedClientSchema), linkedClients);
|
|
306
|
-
|
|
307
|
-
const response = await this.execute(() =>
|
|
308
|
-
this.trpc.clients.setLinkedClients.mutate({
|
|
309
|
-
parentClientId,
|
|
310
|
-
linkedClients: validated,
|
|
311
|
-
})
|
|
312
|
-
);
|
|
313
|
-
return this.instantiate(response);
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
// ─────────────────────────────────────────────────────────────────
|
|
317
|
-
// Sync All (Atomic)
|
|
318
|
-
// ─────────────────────────────────────────────────────────────────
|
|
319
|
-
|
|
320
|
-
async syncAll(
|
|
321
|
-
clientId: string,
|
|
322
|
-
data: {
|
|
323
|
-
client?: UpdateJYSClientInput;
|
|
324
|
-
addresses?: SyncItem<CreateMexAddressInput>[];
|
|
325
|
-
contactMethods?: SyncItem<CreateContactMethodInput>[];
|
|
326
|
-
bankAccounts?: SyncItem<CreateBankAccountInput>[];
|
|
327
|
-
linkedClients?: LinkedClientInput[];
|
|
328
|
-
},
|
|
329
|
-
options: { replaceMode: true }
|
|
330
|
-
): Promise<{
|
|
331
|
-
client: MexJYSClient;
|
|
332
|
-
addresses: SyncResult<MexAddress>;
|
|
333
|
-
contactMethods: SyncResult<ContactMethod>;
|
|
334
|
-
bankAccounts: SyncResult<MexBankAccount>;
|
|
335
|
-
}>;
|
|
336
|
-
async syncAll(
|
|
337
|
-
clientId: string,
|
|
338
|
-
data: {
|
|
339
|
-
client?: UpdateJYSClientInput;
|
|
340
|
-
addresses?: SyncItem<UpdateMexAddressInput>[];
|
|
341
|
-
contactMethods?: SyncItem<UpdateContactMethodInput>[];
|
|
342
|
-
bankAccounts?: SyncItem<UpdateBankAccountInput>[];
|
|
343
|
-
linkedClients?: LinkedClientInput[];
|
|
344
|
-
},
|
|
345
|
-
options?: { replaceMode?: boolean }
|
|
346
|
-
): Promise<{
|
|
347
|
-
client: MexJYSClient;
|
|
348
|
-
addresses: SyncResult<MexAddress>;
|
|
349
|
-
contactMethods: SyncResult<ContactMethod>;
|
|
350
|
-
bankAccounts: SyncResult<MexBankAccount>;
|
|
351
|
-
}>;
|
|
352
|
-
async syncAll(
|
|
353
|
-
clientId: string,
|
|
354
|
-
data: {
|
|
355
|
-
client?: UpdateJYSClientInput;
|
|
356
|
-
addresses?: SyncItem<UpdateMexAddressInput | CreateMexAddressInput>[];
|
|
357
|
-
contactMethods?: SyncItem<UpdateContactMethodInput | CreateContactMethodInput>[];
|
|
358
|
-
bankAccounts?: SyncItem<UpdateBankAccountInput | CreateBankAccountInput>[];
|
|
359
|
-
linkedClients?: LinkedClientInput[];
|
|
360
|
-
},
|
|
361
|
-
options?: { replaceMode?: boolean }
|
|
362
|
-
): Promise<{
|
|
363
|
-
client: MexJYSClient;
|
|
364
|
-
addresses: SyncResult<MexAddress>;
|
|
365
|
-
contactMethods: SyncResult<ContactMethod>;
|
|
366
|
-
bankAccounts: SyncResult<MexBankAccount>;
|
|
367
|
-
}> {
|
|
368
|
-
// Transform client input using JYS-specific transform
|
|
369
|
-
const transformedClient = data.client
|
|
370
|
-
? this.transformUpdateToNested(data.client)
|
|
371
|
-
: undefined;
|
|
372
|
-
|
|
373
|
-
// Call parent syncAll with transformed client data
|
|
374
|
-
const result = await super.syncAll(
|
|
375
|
-
clientId,
|
|
376
|
-
{
|
|
377
|
-
...data,
|
|
378
|
-
client: transformedClient as UpdateMexClientInput,
|
|
379
|
-
},
|
|
380
|
-
options as { replaceMode?: boolean }
|
|
381
|
-
);
|
|
382
|
-
|
|
383
|
-
// Re-instantiate client with JYS-specific model
|
|
384
|
-
return {
|
|
385
|
-
...result,
|
|
386
|
-
client: this.instantiate(result.client as unknown as ClientData),
|
|
387
|
-
};
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
// ─────────────────────────────────────────────────────────────────
|
|
391
|
-
// Protected Helpers
|
|
392
|
-
// ─────────────────────────────────────────────────────────────────
|
|
393
|
-
|
|
394
|
-
/**
|
|
395
|
-
* Transforms a flattened JYSClientSort to nested ClientSort format.
|
|
396
|
-
*
|
|
397
|
-
* Maps flattened field names to their full API paths.
|
|
398
|
-
*/
|
|
399
|
-
protected override applyScopeToSort(sort?: JYSClientSort): ClientSort | undefined {
|
|
400
|
-
if (!sort || sort.length === 0) {
|
|
401
|
-
return undefined;
|
|
402
|
-
}
|
|
403
|
-
return transformSort(sort, jysClientFieldMapping);
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
/**
|
|
407
|
-
* Transforms JYS input to nested API format.
|
|
408
|
-
* JYS has no additional fields, but we add the JYS activity marker.
|
|
409
|
-
*/
|
|
410
|
-
protected override transformToNested(
|
|
411
|
-
data: CreateJYSClientInput
|
|
412
|
-
): CreateClientInput {
|
|
413
|
-
// Use parent transform for base + MX fields (cast needed for discriminated union)
|
|
414
|
-
const nested = super.transformToNested(
|
|
415
|
-
data as unknown as CreateMexClientInput
|
|
416
|
-
);
|
|
417
|
-
|
|
418
|
-
// Add JYS activity marker (parent always provides jurisdictions.MX)
|
|
419
|
-
const mexData = nested.jurisdictions?.MX;
|
|
420
|
-
|
|
421
|
-
return {
|
|
422
|
-
...nested,
|
|
423
|
-
jurisdictions: {
|
|
424
|
-
MX: {
|
|
425
|
-
...mexData,
|
|
426
|
-
actividadVulnerable: {
|
|
427
|
-
[CodigoActividad.JYS]: {},
|
|
428
|
-
},
|
|
429
|
-
},
|
|
430
|
-
},
|
|
431
|
-
} as CreateClientInput;
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
protected override transformUpdateToNested(
|
|
435
|
-
data: UpdateJYSClientInput
|
|
436
|
-
): UpdateClientInput {
|
|
437
|
-
return super.transformUpdateToNested(
|
|
438
|
-
data as unknown as UpdateMexClientInput
|
|
439
|
-
);
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
protected override instantiate(data: ClientData): MexJYSClient {
|
|
443
|
-
return new MexJYSClient(data);
|
|
444
|
-
}
|
|
445
|
-
}
|