@artu-ai/compliance-sdk 0.4.1 → 0.4.2
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,591 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* JYS (Juegos y Sorteos) Reports Resource
|
|
3
|
-
*
|
|
4
|
-
* Extends MexReportsResource with JYS-specific behavior:
|
|
5
|
-
* - Accepts flattened CreateJYSReportInput (JYS fields at root level)
|
|
6
|
-
* - Returns MexJYSReport models
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { z } from "zod";
|
|
10
|
-
import type {
|
|
11
|
-
CreateReportInput,
|
|
12
|
-
UpdateReportInput,
|
|
13
|
-
CreateReportItemInput,
|
|
14
|
-
UpdateReportItemInput,
|
|
15
|
-
CreateJYSReportInput,
|
|
16
|
-
UpdateJYSReportInput,
|
|
17
|
-
CreateJYSReportItemInput,
|
|
18
|
-
UpdateJYSReportItemInput,
|
|
19
|
-
ListOptions,
|
|
20
|
-
PaginatedResponse,
|
|
21
|
-
AtomicBatchResult,
|
|
22
|
-
PartialBatchResult,
|
|
23
|
-
JysReportDefaultsInput,
|
|
24
|
-
ValidationResult,
|
|
25
|
-
GenerateResult,
|
|
26
|
-
SubmissionResult,
|
|
27
|
-
SubmitJYSSubmissionInput,
|
|
28
|
-
} from "@artu-ai/shared";
|
|
29
|
-
import {
|
|
30
|
-
CodigoActividad,
|
|
31
|
-
createJYSReportInputSchema,
|
|
32
|
-
updateJYSReportInputSchema,
|
|
33
|
-
createJYSReportItemInputSchema,
|
|
34
|
-
updateJYSReportItemInputSchema,
|
|
35
|
-
jysDefaultsInputSchema,
|
|
36
|
-
submitJYSSubmissionInputSchema,
|
|
37
|
-
transformSort,
|
|
38
|
-
jysReportFieldMapping,
|
|
39
|
-
} from "@artu-ai/shared";
|
|
40
|
-
import type {
|
|
41
|
-
JYSReportFilter,
|
|
42
|
-
JYSReportSort,
|
|
43
|
-
JYSReportItemFilter,
|
|
44
|
-
ReportSort,
|
|
45
|
-
ReportItemFilter,
|
|
46
|
-
ReportItemSort,
|
|
47
|
-
} from "@artu-ai/shared";
|
|
48
|
-
import { MexReportsResource } from "../../reports";
|
|
49
|
-
import { type BatchOptions } from "../../../clients";
|
|
50
|
-
import {
|
|
51
|
-
MexJYSReport,
|
|
52
|
-
MexJYSReportItem,
|
|
53
|
-
type ReportData,
|
|
54
|
-
type ReportItemData,
|
|
55
|
-
} from "../../../../models";
|
|
56
|
-
|
|
57
|
-
// ===========================
|
|
58
|
-
// JYSReportsResource
|
|
59
|
-
// ===========================
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* JYS (Juegos y Sorteos) scoped reports resource.
|
|
63
|
-
*
|
|
64
|
-
* @example
|
|
65
|
-
* ```typescript
|
|
66
|
-
* const jysSdk = new ComplianceSDK({
|
|
67
|
-
* apiKey,
|
|
68
|
-
* jurisdiction: Jurisdiction.Mexico,
|
|
69
|
-
* actividadVulnerable: CodigoActividad.JYS,
|
|
70
|
-
* });
|
|
71
|
-
*
|
|
72
|
-
* // Create with fully flattened input
|
|
73
|
-
* const report = await jysSdk.reports.create({
|
|
74
|
-
* mesReportado: "202401",
|
|
75
|
-
* });
|
|
76
|
-
*
|
|
77
|
-
* // Returns MexJYSReport
|
|
78
|
-
* console.log(report.mesReportado);
|
|
79
|
-
* ```
|
|
80
|
-
*/
|
|
81
|
-
export class JYSReportsResource extends MexReportsResource<JYSReportSort, JysReportDefaultsInput> {
|
|
82
|
-
// ─────────────────────────────────────────────────────────────────
|
|
83
|
-
// Report CRUD
|
|
84
|
-
// ─────────────────────────────────────────────────────────────────
|
|
85
|
-
|
|
86
|
-
async create(data: CreateJYSReportInput): Promise<MexJYSReport> {
|
|
87
|
-
const validated = this.validate(createJYSReportInputSchema, data);
|
|
88
|
-
const nestedData = this.transformToNested(validated);
|
|
89
|
-
|
|
90
|
-
const response = await this.execute(() =>
|
|
91
|
-
this.trpc.reports.create.mutate(nestedData)
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
return this.instantiate(response);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
async retrieve(id: string): Promise<MexJYSReport> {
|
|
98
|
-
const response = await this.execute(() =>
|
|
99
|
-
this.trpc.reports.retrieve.query({ id })
|
|
100
|
-
);
|
|
101
|
-
return this.instantiate(response);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
async retrieveByMetadata(key: string, value: string): Promise<MexJYSReport> {
|
|
105
|
-
const response = await this.execute(() =>
|
|
106
|
-
this.trpc.reports.retrieveByMetadata.query({ key, value })
|
|
107
|
-
);
|
|
108
|
-
return this.instantiate(response);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
async retrieveByExternalId(externalId: string): Promise<MexJYSReport> {
|
|
112
|
-
const response = await this.execute(() =>
|
|
113
|
-
this.trpc.reports.retrieveByExternalId.query({ externalId })
|
|
114
|
-
);
|
|
115
|
-
return this.instantiate(response);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
async update(id: string, data: UpdateJYSReportInput): Promise<MexJYSReport> {
|
|
119
|
-
const validated = this.validate(updateJYSReportInputSchema, data);
|
|
120
|
-
const nestedData = this.transformUpdateToNested(validated);
|
|
121
|
-
|
|
122
|
-
const response = await this.execute(() =>
|
|
123
|
-
this.trpc.reports.update.mutate({ id, data: nestedData })
|
|
124
|
-
);
|
|
125
|
-
return this.instantiate(response);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// ─────────────────────────────────────────────────────────────────
|
|
129
|
-
// List & Pagination
|
|
130
|
-
// ─────────────────────────────────────────────────────────────────
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Lists JYS reports with optional filtering.
|
|
134
|
-
*
|
|
135
|
-
* Accepts flattened JYS filter (future JYS-specific report fields at root level).
|
|
136
|
-
*/
|
|
137
|
-
async list(
|
|
138
|
-
options?: ListOptions<JYSReportFilter, JYSReportSort>
|
|
139
|
-
): Promise<PaginatedResponse<MexJYSReport>> {
|
|
140
|
-
const scopedFilter = this.applyScopeToFilter(options?.filter);
|
|
141
|
-
const scopedSort = this.applyScopeToSort(options?.sort);
|
|
142
|
-
|
|
143
|
-
const response = await this.execute(() =>
|
|
144
|
-
this.trpc.reports.list.query({
|
|
145
|
-
...options,
|
|
146
|
-
filter: scopedFilter,
|
|
147
|
-
sort: scopedSort,
|
|
148
|
-
})
|
|
149
|
-
);
|
|
150
|
-
|
|
151
|
-
return {
|
|
152
|
-
data: response.data.map((r) => this.instantiate(r)),
|
|
153
|
-
pagination: response.pagination,
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Iterates over JYS reports.
|
|
159
|
-
*
|
|
160
|
-
* Accepts flattened JYS filter (future JYS-specific report fields at root level).
|
|
161
|
-
*/
|
|
162
|
-
iterate(
|
|
163
|
-
filter?: JYSReportFilter
|
|
164
|
-
): AsyncGenerator<MexJYSReport, void, undefined> {
|
|
165
|
-
const scopedFilter = this.applyScopeToFilter(filter);
|
|
166
|
-
return this.createIterator<MexJYSReport>({ filter: scopedFilter });
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
// ─────────────────────────────────────────────────────────────────
|
|
170
|
-
// Batch Operations
|
|
171
|
-
// ─────────────────────────────────────────────────────────────────
|
|
172
|
-
|
|
173
|
-
async createMany(
|
|
174
|
-
reports: CreateJYSReportInput[],
|
|
175
|
-
options?: { atomic?: true }
|
|
176
|
-
): Promise<AtomicBatchResult<MexJYSReport>>;
|
|
177
|
-
async createMany(
|
|
178
|
-
reports: CreateJYSReportInput[],
|
|
179
|
-
options: { atomic: false }
|
|
180
|
-
): Promise<PartialBatchResult<MexJYSReport>>;
|
|
181
|
-
async createMany(
|
|
182
|
-
reports: CreateJYSReportInput[],
|
|
183
|
-
options: BatchOptions = {}
|
|
184
|
-
): Promise<
|
|
185
|
-
AtomicBatchResult<MexJYSReport> | PartialBatchResult<MexJYSReport>
|
|
186
|
-
> {
|
|
187
|
-
const atomic = options.atomic ?? true;
|
|
188
|
-
const validated = this.validate(
|
|
189
|
-
z.array(createJYSReportInputSchema),
|
|
190
|
-
reports
|
|
191
|
-
);
|
|
192
|
-
const nestedItems = validated.map((r) => this.transformToNested(r));
|
|
193
|
-
|
|
194
|
-
const response = await this.execute(() =>
|
|
195
|
-
this.trpc.reports.createMany.mutate({ items: nestedItems, atomic })
|
|
196
|
-
);
|
|
197
|
-
|
|
198
|
-
if (response.atomic) {
|
|
199
|
-
return {
|
|
200
|
-
atomic: true,
|
|
201
|
-
data: response.data.map((r) => this.instantiate(r)),
|
|
202
|
-
};
|
|
203
|
-
} else {
|
|
204
|
-
return {
|
|
205
|
-
atomic: false,
|
|
206
|
-
succeeded: response.succeeded.map((item) => ({
|
|
207
|
-
index: item.index,
|
|
208
|
-
data: this.instantiate(item.data),
|
|
209
|
-
})),
|
|
210
|
-
failed: response.failed,
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
async updateMany(
|
|
216
|
-
updates: { id: string; data: UpdateJYSReportInput }[],
|
|
217
|
-
options?: { atomic?: true }
|
|
218
|
-
): Promise<AtomicBatchResult<MexJYSReport>>;
|
|
219
|
-
async updateMany(
|
|
220
|
-
updates: { id: string; data: UpdateJYSReportInput }[],
|
|
221
|
-
options: { atomic: false }
|
|
222
|
-
): Promise<PartialBatchResult<MexJYSReport>>;
|
|
223
|
-
async updateMany(
|
|
224
|
-
updates: { id: string; data: UpdateJYSReportInput }[],
|
|
225
|
-
options: BatchOptions = {}
|
|
226
|
-
): Promise<
|
|
227
|
-
AtomicBatchResult<MexJYSReport> | PartialBatchResult<MexJYSReport>
|
|
228
|
-
> {
|
|
229
|
-
const atomic = options.atomic ?? true;
|
|
230
|
-
const updateItemSchema = z.object({
|
|
231
|
-
id: z.uuid(),
|
|
232
|
-
data: updateJYSReportInputSchema,
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
const validated = this.validate(z.array(updateItemSchema), updates);
|
|
236
|
-
const nestedUpdates = validated.map((u) => ({
|
|
237
|
-
id: u.id,
|
|
238
|
-
data: this.transformUpdateToNested(u.data),
|
|
239
|
-
}));
|
|
240
|
-
|
|
241
|
-
const response = await this.execute(() =>
|
|
242
|
-
this.trpc.reports.updateMany.mutate({ items: nestedUpdates, atomic })
|
|
243
|
-
);
|
|
244
|
-
|
|
245
|
-
if (response.atomic) {
|
|
246
|
-
return {
|
|
247
|
-
atomic: true,
|
|
248
|
-
data: response.data.map((r) => this.instantiate(r)),
|
|
249
|
-
};
|
|
250
|
-
} else {
|
|
251
|
-
return {
|
|
252
|
-
atomic: false,
|
|
253
|
-
succeeded: response.succeeded.map((item) => ({
|
|
254
|
-
index: item.index,
|
|
255
|
-
data: this.instantiate(item.data),
|
|
256
|
-
})),
|
|
257
|
-
failed: response.failed,
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
// ─────────────────────────────────────────────────────────────────
|
|
263
|
-
// Report Items
|
|
264
|
-
// ─────────────────────────────────────────────────────────────────
|
|
265
|
-
|
|
266
|
-
async addItem(
|
|
267
|
-
reportId: string,
|
|
268
|
-
data: CreateJYSReportItemInput
|
|
269
|
-
): Promise<MexJYSReportItem> {
|
|
270
|
-
const validated = this.validate(createJYSReportItemInputSchema, data);
|
|
271
|
-
const nestedData = this.transformItemToNested(validated);
|
|
272
|
-
|
|
273
|
-
const response = await this.execute(() =>
|
|
274
|
-
this.trpc.reports.addItem.mutate({ reportId, data: nestedData })
|
|
275
|
-
);
|
|
276
|
-
|
|
277
|
-
return this.instantiateItem(response);
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
async getItem(reportId: string, itemId: string): Promise<MexJYSReportItem> {
|
|
281
|
-
const response = await this.execute(() =>
|
|
282
|
-
this.trpc.reports.getItem.query({ reportId, itemId })
|
|
283
|
-
);
|
|
284
|
-
return this.instantiateItem(response);
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
async updateItem(
|
|
288
|
-
reportId: string,
|
|
289
|
-
itemId: string,
|
|
290
|
-
data: UpdateJYSReportItemInput
|
|
291
|
-
): Promise<MexJYSReportItem> {
|
|
292
|
-
const validated = this.validate(updateJYSReportItemInputSchema, data);
|
|
293
|
-
const nestedData = this.transformItemUpdateToNested(validated);
|
|
294
|
-
|
|
295
|
-
const response = await this.execute(() =>
|
|
296
|
-
this.trpc.reports.updateItem.mutate({
|
|
297
|
-
reportId,
|
|
298
|
-
itemId,
|
|
299
|
-
data: nestedData,
|
|
300
|
-
})
|
|
301
|
-
);
|
|
302
|
-
return this.instantiateItem(response);
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
async listItems(
|
|
306
|
-
reportId: string,
|
|
307
|
-
options?: ListOptions<JYSReportItemFilter, ReportItemSort>
|
|
308
|
-
): Promise<PaginatedResponse<MexJYSReportItem>> {
|
|
309
|
-
// Transform flattened JYS filter to nested format
|
|
310
|
-
const scopedFilter = this.applyScopeToItemFilter(options?.filter);
|
|
311
|
-
|
|
312
|
-
const response = await this.execute(() =>
|
|
313
|
-
this.trpc.reports.listItems.query({
|
|
314
|
-
reportId,
|
|
315
|
-
...options,
|
|
316
|
-
filter: scopedFilter,
|
|
317
|
-
})
|
|
318
|
-
);
|
|
319
|
-
|
|
320
|
-
return {
|
|
321
|
-
data: response.data.map((i) => this.instantiateItem(i)),
|
|
322
|
-
pagination: response.pagination,
|
|
323
|
-
};
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
/**
|
|
327
|
-
* Transforms a flattened JYSReportItemFilter to nested ReportItemFilter format.
|
|
328
|
-
*/
|
|
329
|
-
protected applyScopeToItemFilter(
|
|
330
|
-
filter?: JYSReportItemFilter
|
|
331
|
-
): ReportItemFilter | undefined {
|
|
332
|
-
if (!filter) return undefined;
|
|
333
|
-
|
|
334
|
-
const { alertType, alertDescription, ...baseFields } = filter;
|
|
335
|
-
|
|
336
|
-
// If no JYS-specific fields, return base filter as-is
|
|
337
|
-
if (alertType === undefined && alertDescription === undefined) {
|
|
338
|
-
return baseFields as ReportItemFilter;
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
// Build nested filter structure
|
|
342
|
-
const jysFilter: Record<string, unknown> = {};
|
|
343
|
-
if (alertType !== undefined) jysFilter.alertType = alertType;
|
|
344
|
-
if (alertDescription !== undefined) jysFilter.alertDescription = alertDescription;
|
|
345
|
-
|
|
346
|
-
return {
|
|
347
|
-
...baseFields,
|
|
348
|
-
jurisdictions: {
|
|
349
|
-
MX: {
|
|
350
|
-
actividadVulnerable: {
|
|
351
|
-
JYS: jysFilter,
|
|
352
|
-
},
|
|
353
|
-
},
|
|
354
|
-
},
|
|
355
|
-
} as ReportItemFilter;
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
async addItems(
|
|
359
|
-
reportId: string,
|
|
360
|
-
items: CreateJYSReportItemInput[]
|
|
361
|
-
): Promise<{ added: number; items: MexJYSReportItem[] }> {
|
|
362
|
-
const validated = this.validate(
|
|
363
|
-
z.array(createJYSReportItemInputSchema),
|
|
364
|
-
items
|
|
365
|
-
);
|
|
366
|
-
const nestedItems = validated.map((i) => this.transformItemToNested(i));
|
|
367
|
-
|
|
368
|
-
const response = await this.execute(() =>
|
|
369
|
-
this.trpc.reports.addItems.mutate({ reportId, items: nestedItems })
|
|
370
|
-
);
|
|
371
|
-
|
|
372
|
-
return {
|
|
373
|
-
added: response.added,
|
|
374
|
-
items: response.items.map((i) => this.instantiateItem(i)),
|
|
375
|
-
};
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
// ─────────────────────────────────────────────────────────────────
|
|
379
|
-
// Validation
|
|
380
|
-
// ─────────────────────────────────────────────────────────────────
|
|
381
|
-
|
|
382
|
-
/**
|
|
383
|
-
* Validates a JYS report.
|
|
384
|
-
*
|
|
385
|
-
* Uses JYS-scoped validation input (jurisdiction and activity are implicit).
|
|
386
|
-
*
|
|
387
|
-
* @param reportId - The report ID to validate
|
|
388
|
-
* @param defaults - JYS report defaults including rfc, alertType, etc.
|
|
389
|
-
*
|
|
390
|
-
* @example
|
|
391
|
-
* ```typescript
|
|
392
|
-
* const result = await jysSdk.reports.validateReport(report.id, {
|
|
393
|
-
* rfc: "ABC200101XXX",
|
|
394
|
-
* alertType: "100",
|
|
395
|
-
* });
|
|
396
|
-
* ```
|
|
397
|
-
*/
|
|
398
|
-
override async validateReport(
|
|
399
|
-
reportId: string,
|
|
400
|
-
defaults: JysReportDefaultsInput
|
|
401
|
-
): Promise<ValidationResult> {
|
|
402
|
-
const validated = this.validate(jysDefaultsInputSchema, defaults);
|
|
403
|
-
const nestedInput = this.transformJysDefaultsToNested(reportId, validated);
|
|
404
|
-
return this.execute(() =>
|
|
405
|
-
this.trpc.reports.validate.mutate(
|
|
406
|
-
nestedInput as Parameters<typeof this.trpc.reports.validate.mutate>[0]
|
|
407
|
-
)
|
|
408
|
-
);
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
// ─────────────────────────────────────────────────────────────────
|
|
412
|
-
// Generation
|
|
413
|
-
// ─────────────────────────────────────────────────────────────────
|
|
414
|
-
|
|
415
|
-
/**
|
|
416
|
-
* Generates XML for a JYS report.
|
|
417
|
-
*
|
|
418
|
-
* Uses the same input as validateReport.
|
|
419
|
-
*
|
|
420
|
-
* @param reportId - The report ID to generate XML for
|
|
421
|
-
* @param defaults - JYS report defaults including rfc, alertType, etc.
|
|
422
|
-
*/
|
|
423
|
-
override async generateReport(
|
|
424
|
-
reportId: string,
|
|
425
|
-
defaults: JysReportDefaultsInput
|
|
426
|
-
): Promise<GenerateResult> {
|
|
427
|
-
const validated = this.validate(jysDefaultsInputSchema, defaults);
|
|
428
|
-
const nestedInput = this.transformJysDefaultsToNested(reportId, validated);
|
|
429
|
-
return this.execute(() =>
|
|
430
|
-
this.trpc.reports.generate.mutate(
|
|
431
|
-
nestedInput as Parameters<typeof this.trpc.reports.generate.mutate>[0]
|
|
432
|
-
)
|
|
433
|
-
);
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
// ─────────────────────────────────────────────────────────────────
|
|
437
|
-
// Submission
|
|
438
|
-
// ─────────────────────────────────────────────────────────────────
|
|
439
|
-
|
|
440
|
-
/**
|
|
441
|
-
* Submits a validated JYS report.
|
|
442
|
-
*
|
|
443
|
-
* Uses JYS-scoped submission input (activity is implicit).
|
|
444
|
-
*/
|
|
445
|
-
override async submit(
|
|
446
|
-
input: SubmitJYSSubmissionInput
|
|
447
|
-
): Promise<SubmissionResult> {
|
|
448
|
-
const validated = this.validate(submitJYSSubmissionInputSchema, input);
|
|
449
|
-
|
|
450
|
-
const jurisdictions = {
|
|
451
|
-
MX: {
|
|
452
|
-
actividadVulnerable: {
|
|
453
|
-
[CodigoActividad.JYS]: {
|
|
454
|
-
acuseRecibo: validated.acuseRecibo,
|
|
455
|
-
notes: validated.notes,
|
|
456
|
-
},
|
|
457
|
-
},
|
|
458
|
-
},
|
|
459
|
-
};
|
|
460
|
-
|
|
461
|
-
return this.execute(() =>
|
|
462
|
-
this.trpc.reports.submit.mutate({
|
|
463
|
-
reportId: validated.reportId,
|
|
464
|
-
jurisdictions,
|
|
465
|
-
})
|
|
466
|
-
);
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
// ─────────────────────────────────────────────────────────────────
|
|
470
|
-
// Protected Helpers
|
|
471
|
-
// ─────────────────────────────────────────────────────────────────
|
|
472
|
-
|
|
473
|
-
/**
|
|
474
|
-
* Transforms a flattened JYSReportSort to nested ReportSort format.
|
|
475
|
-
*
|
|
476
|
-
* Maps flattened field names to their full API paths.
|
|
477
|
-
*/
|
|
478
|
-
protected override applyScopeToSort(sort?: JYSReportSort): ReportSort | undefined {
|
|
479
|
-
if (!sort || sort.length === 0) {
|
|
480
|
-
return undefined;
|
|
481
|
-
}
|
|
482
|
-
return transformSort(sort, jysReportFieldMapping);
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
protected override transformToNested(
|
|
486
|
-
data: CreateJYSReportInput
|
|
487
|
-
): CreateReportInput {
|
|
488
|
-
const { mesReportado, ...baseFields } = data;
|
|
489
|
-
|
|
490
|
-
return {
|
|
491
|
-
...baseFields,
|
|
492
|
-
jurisdictions: {
|
|
493
|
-
MX: {
|
|
494
|
-
actividadVulnerable: {
|
|
495
|
-
[CodigoActividad.JYS]: { mesReportado },
|
|
496
|
-
},
|
|
497
|
-
},
|
|
498
|
-
},
|
|
499
|
-
} as CreateReportInput;
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
protected override transformUpdateToNested(
|
|
503
|
-
data: UpdateJYSReportInput
|
|
504
|
-
): UpdateReportInput {
|
|
505
|
-
return data as UpdateReportInput;
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
protected override instantiate(data: ReportData): MexJYSReport {
|
|
509
|
-
return new MexJYSReport(data);
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
protected override instantiateItem(data: ReportItemData): MexJYSReportItem {
|
|
513
|
-
return new MexJYSReportItem(data);
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
protected transformItemToNested(
|
|
517
|
-
data: CreateJYSReportItemInput
|
|
518
|
-
): CreateReportItemInput {
|
|
519
|
-
const { alertType, alertDescription, amendment, ...baseFields } = data;
|
|
520
|
-
|
|
521
|
-
const jysData: Record<string, unknown> = {};
|
|
522
|
-
if (alertType !== undefined) jysData.alertType = alertType;
|
|
523
|
-
if (alertDescription !== undefined)
|
|
524
|
-
jysData.alertDescription = alertDescription;
|
|
525
|
-
if (amendment !== undefined) jysData.amendment = amendment;
|
|
526
|
-
|
|
527
|
-
return {
|
|
528
|
-
...baseFields,
|
|
529
|
-
jurisdictions: {
|
|
530
|
-
MX: {
|
|
531
|
-
actividadVulnerable: {
|
|
532
|
-
[CodigoActividad.JYS]: jysData,
|
|
533
|
-
},
|
|
534
|
-
},
|
|
535
|
-
},
|
|
536
|
-
} as CreateReportItemInput;
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
protected transformItemUpdateToNested(
|
|
540
|
-
data: UpdateJYSReportItemInput
|
|
541
|
-
): UpdateReportItemInput {
|
|
542
|
-
const { alertType, alertDescription, amendment, ...baseFields } = data;
|
|
543
|
-
|
|
544
|
-
const jysData: Record<string, unknown> = {};
|
|
545
|
-
if (alertType !== undefined) jysData.alertType = alertType;
|
|
546
|
-
if (alertDescription !== undefined)
|
|
547
|
-
jysData.alertDescription = alertDescription;
|
|
548
|
-
if (amendment !== undefined) jysData.amendment = amendment;
|
|
549
|
-
|
|
550
|
-
if (Object.keys(jysData).length === 0) {
|
|
551
|
-
return baseFields as UpdateReportItemInput;
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
return {
|
|
555
|
-
...baseFields,
|
|
556
|
-
jurisdictions: {
|
|
557
|
-
MX: {
|
|
558
|
-
actividadVulnerable: {
|
|
559
|
-
[CodigoActividad.JYS]: jysData,
|
|
560
|
-
},
|
|
561
|
-
},
|
|
562
|
-
},
|
|
563
|
-
} as UpdateReportItemInput;
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
/**
|
|
567
|
-
* Transforms JYS defaults to nested API format for validate/generate.
|
|
568
|
-
*/
|
|
569
|
-
protected transformJysDefaultsToNested(
|
|
570
|
-
reportId: string,
|
|
571
|
-
defaults: JysReportDefaultsInput
|
|
572
|
-
): { reportId: string; jurisdictions: unknown } {
|
|
573
|
-
const { rfc, collegiateEntityCode, exempt, priority, ...jysFields } =
|
|
574
|
-
defaults;
|
|
575
|
-
|
|
576
|
-
return {
|
|
577
|
-
reportId,
|
|
578
|
-
jurisdictions: {
|
|
579
|
-
MX: {
|
|
580
|
-
actividadVulnerable: {
|
|
581
|
-
rfc,
|
|
582
|
-
collegiateEntityCode,
|
|
583
|
-
exempt,
|
|
584
|
-
priority,
|
|
585
|
-
[CodigoActividad.JYS]: jysFields,
|
|
586
|
-
},
|
|
587
|
-
},
|
|
588
|
-
},
|
|
589
|
-
};
|
|
590
|
-
}
|
|
591
|
-
}
|