@devizovaburza/mdm-sdk 0.0.11 → 0.0.13
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/v1/index.cjs +2856 -502
- package/dist/v1/index.d.cts +6879 -6925
- package/dist/v1/index.d.mts +6879 -6925
- package/dist/v1/index.d.ts +6879 -6925
- package/dist/v1/index.mjs +2936 -582
- package/package.json +1 -1
package/dist/v1/index.mjs
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { hc } from 'hono/client';
|
|
2
|
-
import { z as z$
|
|
2
|
+
import { z as z$3, createRoute, OpenAPIHono } from '@hono/zod-openapi';
|
|
3
3
|
import { COUNTRY_CODES_2, CURRENCY_CODES, BANK_CODES, LANGUAGE_CODES } from '@develit-io/general-codes';
|
|
4
|
-
import { z as z$
|
|
5
|
-
import { z as z$
|
|
4
|
+
import { z as z$1 } from 'zod/v4';
|
|
5
|
+
import { z as z$2 } from 'zod';
|
|
6
6
|
import * as z from 'zod/v4/core';
|
|
7
7
|
import 'node:fs';
|
|
8
8
|
import 'node:crypto';
|
|
9
9
|
import 'node:path';
|
|
10
|
+
import { createMiddleware } from 'hono/factory';
|
|
11
|
+
import { HTTPException } from 'hono/http-exception';
|
|
10
12
|
|
|
11
13
|
const createMdmClient = (baseUrl, options) => {
|
|
12
14
|
return hc(baseUrl, options);
|
|
@@ -17,7 +19,7 @@ const AddressTypeZod$1 = [
|
|
|
17
19
|
"REGISTERED_OFFICE",
|
|
18
20
|
"CONTACT_ADDRESS"
|
|
19
21
|
];
|
|
20
|
-
const ContactTypeZod = [
|
|
22
|
+
const ContactTypeZod$1 = [
|
|
21
23
|
"EMAIL",
|
|
22
24
|
"PHONE_AUTH",
|
|
23
25
|
"PHONE_CONTACT",
|
|
@@ -30,7 +32,7 @@ const IdDocStatusZod$1 = [
|
|
|
30
32
|
"EXPIRE_SOON",
|
|
31
33
|
"REVOKED"
|
|
32
34
|
];
|
|
33
|
-
const PartyRelationshipTypeZod = [
|
|
35
|
+
const PartyRelationshipTypeZod$1 = [
|
|
34
36
|
"AUTHORIZED_SIGNATORY",
|
|
35
37
|
"POA_HOLDER",
|
|
36
38
|
"BOARD_MEMBER",
|
|
@@ -58,7 +60,7 @@ const PartyTypeZod$1 = [
|
|
|
58
60
|
"SELF_EMPLOYED",
|
|
59
61
|
"ORGANIZATION"
|
|
60
62
|
];
|
|
61
|
-
const AmlScoreTypeZod = [
|
|
63
|
+
const AmlScoreTypeZod$1 = [
|
|
62
64
|
"LOW",
|
|
63
65
|
"MEDIUM",
|
|
64
66
|
"HIGH",
|
|
@@ -71,19 +73,25 @@ const IdentificationTypeZod = [
|
|
|
71
73
|
"REMOTE_IDENTIFICATION"
|
|
72
74
|
];
|
|
73
75
|
const GenderZod$1 = ["M", "F", "OTHER"];
|
|
74
|
-
const KycStatusZod = [
|
|
76
|
+
const KycStatusZod$1 = [
|
|
75
77
|
"NOT_APPROVED",
|
|
76
78
|
"VERIFIED",
|
|
77
79
|
"UNVERIFIED",
|
|
78
80
|
"REJECTED"
|
|
79
81
|
];
|
|
80
|
-
const TRADER_TYPE = ["PERSON", "COMPANY", "OSVC"];
|
|
82
|
+
const TRADER_TYPE$1 = ["PERSON", "COMPANY", "OSVC"];
|
|
81
83
|
|
|
82
84
|
const AddressTypeZod = [
|
|
83
85
|
"PERMANENT_ADDRESS",
|
|
84
86
|
"REGISTERED_OFFICE",
|
|
85
87
|
"CONTACT_ADDRESS"
|
|
86
88
|
];
|
|
89
|
+
const ContactTypeZod = [
|
|
90
|
+
"EMAIL",
|
|
91
|
+
"PHONE_AUTH",
|
|
92
|
+
"PHONE_CONTACT",
|
|
93
|
+
"PHONE_WORK"
|
|
94
|
+
];
|
|
87
95
|
const IdDocTypeZod = ["PASSPORT", "ID", "DRIVING_LICENSE"];
|
|
88
96
|
const IdDocStatusZod = [
|
|
89
97
|
"ACTIVE",
|
|
@@ -91,6 +99,12 @@ const IdDocStatusZod = [
|
|
|
91
99
|
"EXPIRE_SOON",
|
|
92
100
|
"REVOKED"
|
|
93
101
|
];
|
|
102
|
+
const PartyRelationshipTypeZod = [
|
|
103
|
+
"AUTHORIZED_SIGNATORY",
|
|
104
|
+
"POA_HOLDER",
|
|
105
|
+
"BOARD_MEMBER",
|
|
106
|
+
"UBO"
|
|
107
|
+
];
|
|
94
108
|
const CustomerStatusZod = [
|
|
95
109
|
// 'LEAD',
|
|
96
110
|
"NEW",
|
|
@@ -105,264 +119,22 @@ const PartyTypeZod = [
|
|
|
105
119
|
"SELF_EMPLOYED",
|
|
106
120
|
"ORGANIZATION"
|
|
107
121
|
];
|
|
122
|
+
const AmlScoreTypeZod = [
|
|
123
|
+
"LOW",
|
|
124
|
+
"MEDIUM",
|
|
125
|
+
"HIGH",
|
|
126
|
+
"UNACCEPTABLE",
|
|
127
|
+
"UNVERIFIED",
|
|
128
|
+
"UNCLASSIFIED"
|
|
129
|
+
];
|
|
108
130
|
const GenderZod = ["M", "F", "OTHER"];
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
phone: z$1.string().optional(),
|
|
117
|
-
birthDate: z$1.string().optional(),
|
|
118
|
-
birthPlace: z$1.string(),
|
|
119
|
-
countryOfBirth: z$1.enum(COUNTRY_CODES_2).optional(),
|
|
120
|
-
personalId: z$1.uuid(),
|
|
121
|
-
gender: z$1.enum(GenderZod),
|
|
122
|
-
citizenship: z$1.enum(COUNTRY_CODES_2),
|
|
123
|
-
citizenshipOther: z$1.enum(COUNTRY_CODES_2).optional(),
|
|
124
|
-
employer: z$1.string().optional(),
|
|
125
|
-
employerCountry: z$1.enum(COUNTRY_CODES_2).optional(),
|
|
126
|
-
registeredNumber: z$1.string(),
|
|
127
|
-
isPep: z$1.boolean(),
|
|
128
|
-
titleBefore: z$1.string().optional(),
|
|
129
|
-
titleAfter: z$1.string().optional(),
|
|
130
|
-
birthSurname: z$1.string().optional(),
|
|
131
|
-
vocativeTitle: z$1.string().optional(),
|
|
132
|
-
deathDate: z$1.date().optional(),
|
|
133
|
-
deathNotification: z$1.date().optional(),
|
|
134
|
-
pin: z$1.string().optional(),
|
|
135
|
-
stayAbroad: z$1.boolean().optional(),
|
|
136
|
-
stayAbroadCountries: z$1.enum(COUNTRY_CODES_2).optional()
|
|
137
|
-
});
|
|
138
|
-
const individualUpdateSchema = z$1.object({
|
|
139
|
-
id: z$1.uuid(),
|
|
140
|
-
partyId: z$1.uuid(),
|
|
141
|
-
internalId: z$1.string().optional(),
|
|
142
|
-
name: z$1.string().optional(),
|
|
143
|
-
surname: z$1.string().optional(),
|
|
144
|
-
email: z$1.string().optional(),
|
|
145
|
-
phone: z$1.string().optional(),
|
|
146
|
-
birthDate: z$1.string().optional(),
|
|
147
|
-
birthPlace: z$1.string().optional(),
|
|
148
|
-
countryOfBirth: z$1.enum(COUNTRY_CODES_2).optional(),
|
|
149
|
-
personalId: z$1.uuid().optional(),
|
|
150
|
-
gender: z$1.enum(GenderZod).optional(),
|
|
151
|
-
citizenship: z$1.enum(COUNTRY_CODES_2).optional(),
|
|
152
|
-
citizenshipOther: z$1.enum(COUNTRY_CODES_2).optional(),
|
|
153
|
-
employer: z$1.string().optional(),
|
|
154
|
-
employerCountry: z$1.enum(COUNTRY_CODES_2).optional(),
|
|
155
|
-
registeredNumber: z$1.string().optional(),
|
|
156
|
-
isPep: z$1.boolean().optional(),
|
|
157
|
-
titleBefore: z$1.string().optional(),
|
|
158
|
-
titleAfter: z$1.string().optional(),
|
|
159
|
-
birthSurname: z$1.string().optional(),
|
|
160
|
-
vocativeTitle: z$1.string().optional(),
|
|
161
|
-
deathDate: z$1.date().optional(),
|
|
162
|
-
deathNotification: z$1.date().optional(),
|
|
163
|
-
pin: z$1.string().optional(),
|
|
164
|
-
stayAbroad: z$1.boolean().optional(),
|
|
165
|
-
stayAbroadCountries: z$1.enum(COUNTRY_CODES_2).optional()
|
|
166
|
-
});
|
|
167
|
-
const individualOutputSchema = z$1.object({
|
|
168
|
-
id: z$1.uuid(),
|
|
169
|
-
partyId: z$1.uuid().nullable(),
|
|
170
|
-
internalId: z$1.string().nullable(),
|
|
171
|
-
name: z$1.string(),
|
|
172
|
-
surname: z$1.string(),
|
|
173
|
-
email: z$1.string().nullable(),
|
|
174
|
-
phone: z$1.string().nullable(),
|
|
175
|
-
birthDate: z$1.string().nullable(),
|
|
176
|
-
birthPlace: z$1.string(),
|
|
177
|
-
countryOfBirth: z$1.enum(COUNTRY_CODES_2).nullable(),
|
|
178
|
-
personalId: z$1.uuid(),
|
|
179
|
-
gender: z$1.enum(GenderZod),
|
|
180
|
-
citizenship: z$1.enum(COUNTRY_CODES_2),
|
|
181
|
-
citizenshipOther: z$1.enum(COUNTRY_CODES_2).nullable(),
|
|
182
|
-
employer: z$1.string().nullable(),
|
|
183
|
-
employerCountry: z$1.enum(COUNTRY_CODES_2).nullable(),
|
|
184
|
-
registeredNumber: z$1.string(),
|
|
185
|
-
isPep: z$1.boolean(),
|
|
186
|
-
titleBefore: z$1.string().nullable(),
|
|
187
|
-
titleAfter: z$1.string().nullable(),
|
|
188
|
-
birthSurname: z$1.string().nullable(),
|
|
189
|
-
vocativeTitle: z$1.string().nullable(),
|
|
190
|
-
deathDate: z$1.coerce.date().nullable(),
|
|
191
|
-
deathNotification: z$1.coerce.date().nullable(),
|
|
192
|
-
pin: z$1.string().nullable(),
|
|
193
|
-
stayAbroad: z$1.boolean().nullable(),
|
|
194
|
-
stayAbroadCountries: z$1.enum(COUNTRY_CODES_2).nullable(),
|
|
195
|
-
createdAt: z$1.coerce.date().nullable(),
|
|
196
|
-
updatedAt: z$1.coerce.date().nullable()
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
z$1.object({
|
|
200
|
-
partyId: z$1.uuid().optional(),
|
|
201
|
-
internalId: z$1.string().optional(),
|
|
202
|
-
businessName: z$1.string(),
|
|
203
|
-
email: z$1.email("Invalid email format").optional(),
|
|
204
|
-
phone: z$1.string().optional(),
|
|
205
|
-
registeredNumber: z$1.string(),
|
|
206
|
-
registeredIn: z$1.enum(COUNTRY_CODES_2),
|
|
207
|
-
operatesIn: z$1.enum(COUNTRY_CODES_2),
|
|
208
|
-
presentIn: z$1.enum(COUNTRY_CODES_2),
|
|
209
|
-
monthlyVolumeIn: z$1.number(),
|
|
210
|
-
monthlyVolumeOut: z$1.number(),
|
|
211
|
-
ownedBy: z$1.string(),
|
|
212
|
-
companyObjects: z$1.string(),
|
|
213
|
-
annualTurnover: z$1.number(),
|
|
214
|
-
numberOfEmployees: z$1.number().optional(),
|
|
215
|
-
prosecuted: z$1.string().optional(),
|
|
216
|
-
location: z$1.string().optional(),
|
|
217
|
-
fileNumber: z$1.string().optional(),
|
|
218
|
-
websiteUrl: z$1.url("Invalid website URL").optional(),
|
|
219
|
-
vatPayer: z$1.boolean(),
|
|
220
|
-
companyObjectsDescription: z$1.string(),
|
|
221
|
-
turnover3years: z$1.number(),
|
|
222
|
-
operationCountries: z$1.string(),
|
|
223
|
-
riskyBusinessTypes: z$1.string().optional()
|
|
224
|
-
});
|
|
225
|
-
const organizationUpdateSchema = z$1.object({
|
|
226
|
-
id: z$1.uuid(),
|
|
227
|
-
partyId: z$1.uuid().optional(),
|
|
228
|
-
internalId: z$1.string().optional(),
|
|
229
|
-
businessName: z$1.string().optional(),
|
|
230
|
-
email: z$1.email("Invalid email format").optional(),
|
|
231
|
-
phone: z$1.string().optional(),
|
|
232
|
-
registeredNumber: z$1.string().optional(),
|
|
233
|
-
registeredIn: z$1.enum(COUNTRY_CODES_2).optional(),
|
|
234
|
-
operatesIn: z$1.enum(COUNTRY_CODES_2).optional(),
|
|
235
|
-
presentIn: z$1.enum(COUNTRY_CODES_2).optional(),
|
|
236
|
-
monthlyVolumeIn: z$1.number().optional(),
|
|
237
|
-
monthlyVolumeOut: z$1.number().optional(),
|
|
238
|
-
ownedBy: z$1.string().optional(),
|
|
239
|
-
companyObjects: z$1.string().optional(),
|
|
240
|
-
annualTurnover: z$1.number().optional(),
|
|
241
|
-
numberOfEmployees: z$1.number().optional(),
|
|
242
|
-
prosecuted: z$1.string().optional(),
|
|
243
|
-
location: z$1.string().optional(),
|
|
244
|
-
fileNumber: z$1.string().optional(),
|
|
245
|
-
websiteUrl: z$1.url("Invalid website URL").optional(),
|
|
246
|
-
vatPayer: z$1.boolean().optional(),
|
|
247
|
-
companyObjectsDescription: z$1.string(),
|
|
248
|
-
turnover3years: z$1.number(),
|
|
249
|
-
operationCountries: z$1.string(),
|
|
250
|
-
riskyBusinessTypes: z$1.string().optional()
|
|
251
|
-
});
|
|
252
|
-
z$1.object({
|
|
253
|
-
id: z$1.uuid(),
|
|
254
|
-
partyId: z$1.uuid(),
|
|
255
|
-
internalId: z$1.string().nullable(),
|
|
256
|
-
businessName: z$1.string(),
|
|
257
|
-
email: z$1.string().nullable(),
|
|
258
|
-
phone: z$1.string().nullable(),
|
|
259
|
-
registeredNumber: z$1.string(),
|
|
260
|
-
registeredIn: z$1.enum(COUNTRY_CODES_2),
|
|
261
|
-
operatesIn: z$1.enum(COUNTRY_CODES_2),
|
|
262
|
-
presentIn: z$1.enum(COUNTRY_CODES_2),
|
|
263
|
-
monthlyVolumeIn: z$1.number(),
|
|
264
|
-
monthlyVolumeOut: z$1.number(),
|
|
265
|
-
ownedBy: z$1.string(),
|
|
266
|
-
companyObjects: z$1.string(),
|
|
267
|
-
annualTurnover: z$1.number(),
|
|
268
|
-
numberOfEmployees: z$1.number().nullable(),
|
|
269
|
-
prosecuted: z$1.string().nullable(),
|
|
270
|
-
location: z$1.string().nullable(),
|
|
271
|
-
fileNumber: z$1.string().nullable(),
|
|
272
|
-
websiteUrl: z$1.string().nullable(),
|
|
273
|
-
vatPayer: z$1.boolean(),
|
|
274
|
-
companyObjectsDescription: z$1.string(),
|
|
275
|
-
turnover3years: z$1.number(),
|
|
276
|
-
operationCountries: z$1.string(),
|
|
277
|
-
riskyBusinessTypes: z$1.string().nullable(),
|
|
278
|
-
createdAt: z$1.coerce.date().nullable(),
|
|
279
|
-
updatedAt: z$1.coerce.date().nullable()
|
|
280
|
-
});
|
|
281
|
-
const createOrganizationInputSchema = z$1.object({
|
|
282
|
-
partyId: z$1.uuid().optional(),
|
|
283
|
-
internalId: z$1.string().optional(),
|
|
284
|
-
businessName: z$1.string(),
|
|
285
|
-
email: z$1.string().optional(),
|
|
286
|
-
phone: z$1.string().optional(),
|
|
287
|
-
registeredNumber: z$1.string(),
|
|
288
|
-
registeredIn: z$1.enum(COUNTRY_CODES_2),
|
|
289
|
-
operatesIn: z$1.enum(COUNTRY_CODES_2),
|
|
290
|
-
presentIn: z$1.enum(COUNTRY_CODES_2),
|
|
291
|
-
monthlyVolumeIn: z$1.number(),
|
|
292
|
-
monthlyVolumeOut: z$1.number(),
|
|
293
|
-
ownedBy: z$1.string(),
|
|
294
|
-
companyObjects: z$1.string(),
|
|
295
|
-
annualTurnover: z$1.number(),
|
|
296
|
-
numberOfEmployees: z$1.number(),
|
|
297
|
-
prosecuted: z$1.string().optional(),
|
|
298
|
-
location: z$1.string().optional(),
|
|
299
|
-
fileNumber: z$1.string().optional(),
|
|
300
|
-
websiteUrl: z$1.string().optional(),
|
|
301
|
-
vatPayer: z$1.boolean(),
|
|
302
|
-
message: z$1.string(),
|
|
303
|
-
companyObjectsDescription: z$1.string(),
|
|
304
|
-
turnover3years: z$1.number(),
|
|
305
|
-
operationCountries: z$1.string(),
|
|
306
|
-
riskyBusinessTypes: z$1.string().optional()
|
|
307
|
-
});
|
|
308
|
-
const createOrganizationOutputSchema = z$1.object({
|
|
309
|
-
partyId: z$1.uuid(),
|
|
310
|
-
internalId: z$1.string().nullable(),
|
|
311
|
-
businessName: z$1.string(),
|
|
312
|
-
email: z$1.string().nullable(),
|
|
313
|
-
phone: z$1.string().nullable(),
|
|
314
|
-
registeredNumber: z$1.string(),
|
|
315
|
-
registeredIn: z$1.enum(COUNTRY_CODES_2),
|
|
316
|
-
operatesIn: z$1.enum(COUNTRY_CODES_2),
|
|
317
|
-
presentIn: z$1.enum(COUNTRY_CODES_2),
|
|
318
|
-
monthlyVolumeIn: z$1.number(),
|
|
319
|
-
monthlyVolumeOut: z$1.number(),
|
|
320
|
-
ownedBy: z$1.string(),
|
|
321
|
-
companyObjects: z$1.string(),
|
|
322
|
-
annualTurnover: z$1.number(),
|
|
323
|
-
numberOfEmployees: z$1.number().nullable(),
|
|
324
|
-
prosecuted: z$1.string().nullable(),
|
|
325
|
-
location: z$1.string().nullable(),
|
|
326
|
-
fileNumber: z$1.string().nullable(),
|
|
327
|
-
websiteUrl: z$1.string().nullable(),
|
|
328
|
-
vatPayer: z$1.boolean(),
|
|
329
|
-
message: z$1.string().nullable(),
|
|
330
|
-
companyObjectsDescription: z$1.string(),
|
|
331
|
-
turnover3years: z$1.number(),
|
|
332
|
-
operationCountries: z$1.string(),
|
|
333
|
-
riskyBusinessTypes: z$1.string().nullable()
|
|
334
|
-
});
|
|
335
|
-
|
|
336
|
-
const disponentSchema = z$1.discriminatedUnion("partyType", [
|
|
337
|
-
z$1.object({
|
|
338
|
-
partyType: z$1.literal("INDIVIDUAL"),
|
|
339
|
-
data: individualInsertSchema
|
|
340
|
-
}),
|
|
341
|
-
z$1.object({
|
|
342
|
-
partyType: z$1.literal("ORGANIZATION"),
|
|
343
|
-
data: createOrganizationInputSchema
|
|
344
|
-
})
|
|
345
|
-
]);
|
|
346
|
-
const disponentUpdateSchema = z$1.discriminatedUnion("partyType", [
|
|
347
|
-
z$1.object({
|
|
348
|
-
partyType: z$1.literal("INDIVIDUAL"),
|
|
349
|
-
data: individualUpdateSchema
|
|
350
|
-
}),
|
|
351
|
-
z$1.object({
|
|
352
|
-
partyType: z$1.literal("ORGANIZATION"),
|
|
353
|
-
data: organizationUpdateSchema
|
|
354
|
-
})
|
|
355
|
-
]);
|
|
356
|
-
const disponentOutputSchema = z$1.discriminatedUnion("partyType", [
|
|
357
|
-
z$1.object({
|
|
358
|
-
partyType: z$1.literal("INDIVIDUAL"),
|
|
359
|
-
data: individualOutputSchema.nullable()
|
|
360
|
-
}),
|
|
361
|
-
z$1.object({
|
|
362
|
-
partyType: z$1.literal("ORGANIZATION"),
|
|
363
|
-
data: createOrganizationOutputSchema.nullable()
|
|
364
|
-
})
|
|
365
|
-
]);
|
|
131
|
+
const KycStatusZod = [
|
|
132
|
+
"NOT_APPROVED",
|
|
133
|
+
"VERIFIED",
|
|
134
|
+
"UNVERIFIED",
|
|
135
|
+
"REJECTED"
|
|
136
|
+
];
|
|
137
|
+
const TRADER_TYPE = ["PERSON", "COMPANY", "OSVC"];
|
|
366
138
|
|
|
367
139
|
const entityKind = Symbol.for("drizzle:entityKind");
|
|
368
140
|
function is(value, type) {
|
|
@@ -544,7 +316,7 @@ class ColumnBuilder {
|
|
|
544
316
|
const TableName = Symbol.for("drizzle:Name");
|
|
545
317
|
|
|
546
318
|
const isPgEnumSym = Symbol.for("drizzle:isPgEnum");
|
|
547
|
-
function isPgEnum(obj) {
|
|
319
|
+
function isPgEnum$1(obj) {
|
|
548
320
|
return !!obj && typeof obj === "function" && isPgEnumSym in obj && obj[isPgEnumSym] === true;
|
|
549
321
|
}
|
|
550
322
|
|
|
@@ -629,6 +401,9 @@ class Table {
|
|
|
629
401
|
this[BaseName] = baseName;
|
|
630
402
|
}
|
|
631
403
|
}
|
|
404
|
+
function isTable(table) {
|
|
405
|
+
return typeof table === "object" && table !== null && IsDrizzleTable in table;
|
|
406
|
+
}
|
|
632
407
|
|
|
633
408
|
function isSQLWrapper(value) {
|
|
634
409
|
return value !== null && value !== void 0 && typeof value.getSQL === "function";
|
|
@@ -790,7 +565,7 @@ class SQL {
|
|
|
790
565
|
new Name(chunk._.alias)
|
|
791
566
|
], config);
|
|
792
567
|
}
|
|
793
|
-
if (isPgEnum(chunk)) {
|
|
568
|
+
if (isPgEnum$1(chunk)) {
|
|
794
569
|
if (chunk.schema) {
|
|
795
570
|
return { sql: escapeName(chunk.schema) + "." + escapeName(chunk.enumName), params: [] };
|
|
796
571
|
}
|
|
@@ -990,6 +765,9 @@ class View {
|
|
|
990
765
|
return new SQL([this]);
|
|
991
766
|
}
|
|
992
767
|
}
|
|
768
|
+
function isView(view) {
|
|
769
|
+
return typeof view === "object" && view !== null && IsDrizzleView in view;
|
|
770
|
+
}
|
|
993
771
|
Column.prototype.getSQL = function() {
|
|
994
772
|
return new SQL([this]);
|
|
995
773
|
};
|
|
@@ -1000,13 +778,19 @@ Subquery.prototype.getSQL = function() {
|
|
|
1000
778
|
return new SQL([this]);
|
|
1001
779
|
};
|
|
1002
780
|
|
|
781
|
+
function getTableColumns(table) {
|
|
782
|
+
return table[Table.Symbol.Columns];
|
|
783
|
+
}
|
|
784
|
+
function getViewSelectedFields(view) {
|
|
785
|
+
return view[ViewBaseConfig].selectedFields;
|
|
786
|
+
}
|
|
1003
787
|
function getColumnNameAndConfig(a, b) {
|
|
1004
788
|
return {
|
|
1005
789
|
name: typeof a === "string" && a.length > 0 ? a : "",
|
|
1006
790
|
config: typeof a === "object" ? a : b
|
|
1007
791
|
};
|
|
1008
792
|
}
|
|
1009
|
-
typeof TextDecoder === "undefined" ? null : new TextDecoder();
|
|
793
|
+
const textDecoder = typeof TextDecoder === "undefined" ? null : new TextDecoder();
|
|
1010
794
|
|
|
1011
795
|
class ForeignKeyBuilder {
|
|
1012
796
|
static [entityKind] = "SQLiteForeignKeyBuilder";
|
|
@@ -1118,6 +902,141 @@ class SQLiteColumn extends Column {
|
|
|
1118
902
|
static [entityKind] = "SQLiteColumn";
|
|
1119
903
|
}
|
|
1120
904
|
|
|
905
|
+
class SQLiteBigIntBuilder extends SQLiteColumnBuilder {
|
|
906
|
+
static [entityKind] = "SQLiteBigIntBuilder";
|
|
907
|
+
constructor(name) {
|
|
908
|
+
super(name, "bigint", "SQLiteBigInt");
|
|
909
|
+
}
|
|
910
|
+
/** @internal */
|
|
911
|
+
build(table) {
|
|
912
|
+
return new SQLiteBigInt(table, this.config);
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
class SQLiteBigInt extends SQLiteColumn {
|
|
916
|
+
static [entityKind] = "SQLiteBigInt";
|
|
917
|
+
getSQLType() {
|
|
918
|
+
return "blob";
|
|
919
|
+
}
|
|
920
|
+
mapFromDriverValue(value) {
|
|
921
|
+
if (typeof Buffer !== "undefined" && Buffer.from) {
|
|
922
|
+
const buf = Buffer.isBuffer(value) ? value : value instanceof ArrayBuffer ? Buffer.from(value) : value.buffer ? Buffer.from(value.buffer, value.byteOffset, value.byteLength) : Buffer.from(value);
|
|
923
|
+
return BigInt(buf.toString("utf8"));
|
|
924
|
+
}
|
|
925
|
+
return BigInt(textDecoder.decode(value));
|
|
926
|
+
}
|
|
927
|
+
mapToDriverValue(value) {
|
|
928
|
+
return Buffer.from(value.toString());
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
class SQLiteBlobJsonBuilder extends SQLiteColumnBuilder {
|
|
932
|
+
static [entityKind] = "SQLiteBlobJsonBuilder";
|
|
933
|
+
constructor(name) {
|
|
934
|
+
super(name, "json", "SQLiteBlobJson");
|
|
935
|
+
}
|
|
936
|
+
/** @internal */
|
|
937
|
+
build(table) {
|
|
938
|
+
return new SQLiteBlobJson(
|
|
939
|
+
table,
|
|
940
|
+
this.config
|
|
941
|
+
);
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
class SQLiteBlobJson extends SQLiteColumn {
|
|
945
|
+
static [entityKind] = "SQLiteBlobJson";
|
|
946
|
+
getSQLType() {
|
|
947
|
+
return "blob";
|
|
948
|
+
}
|
|
949
|
+
mapFromDriverValue(value) {
|
|
950
|
+
if (typeof Buffer !== "undefined" && Buffer.from) {
|
|
951
|
+
const buf = Buffer.isBuffer(value) ? value : value instanceof ArrayBuffer ? Buffer.from(value) : value.buffer ? Buffer.from(value.buffer, value.byteOffset, value.byteLength) : Buffer.from(value);
|
|
952
|
+
return JSON.parse(buf.toString("utf8"));
|
|
953
|
+
}
|
|
954
|
+
return JSON.parse(textDecoder.decode(value));
|
|
955
|
+
}
|
|
956
|
+
mapToDriverValue(value) {
|
|
957
|
+
return Buffer.from(JSON.stringify(value));
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
class SQLiteBlobBufferBuilder extends SQLiteColumnBuilder {
|
|
961
|
+
static [entityKind] = "SQLiteBlobBufferBuilder";
|
|
962
|
+
constructor(name) {
|
|
963
|
+
super(name, "buffer", "SQLiteBlobBuffer");
|
|
964
|
+
}
|
|
965
|
+
/** @internal */
|
|
966
|
+
build(table) {
|
|
967
|
+
return new SQLiteBlobBuffer(table, this.config);
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
class SQLiteBlobBuffer extends SQLiteColumn {
|
|
971
|
+
static [entityKind] = "SQLiteBlobBuffer";
|
|
972
|
+
mapFromDriverValue(value) {
|
|
973
|
+
if (Buffer.isBuffer(value)) {
|
|
974
|
+
return value;
|
|
975
|
+
}
|
|
976
|
+
return Buffer.from(value);
|
|
977
|
+
}
|
|
978
|
+
getSQLType() {
|
|
979
|
+
return "blob";
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
function blob(a, b) {
|
|
983
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
984
|
+
if (config?.mode === "json") {
|
|
985
|
+
return new SQLiteBlobJsonBuilder(name);
|
|
986
|
+
}
|
|
987
|
+
if (config?.mode === "bigint") {
|
|
988
|
+
return new SQLiteBigIntBuilder(name);
|
|
989
|
+
}
|
|
990
|
+
return new SQLiteBlobBufferBuilder(name);
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
class SQLiteCustomColumnBuilder extends SQLiteColumnBuilder {
|
|
994
|
+
static [entityKind] = "SQLiteCustomColumnBuilder";
|
|
995
|
+
constructor(name, fieldConfig, customTypeParams) {
|
|
996
|
+
super(name, "custom", "SQLiteCustomColumn");
|
|
997
|
+
this.config.fieldConfig = fieldConfig;
|
|
998
|
+
this.config.customTypeParams = customTypeParams;
|
|
999
|
+
}
|
|
1000
|
+
/** @internal */
|
|
1001
|
+
build(table) {
|
|
1002
|
+
return new SQLiteCustomColumn(
|
|
1003
|
+
table,
|
|
1004
|
+
this.config
|
|
1005
|
+
);
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
class SQLiteCustomColumn extends SQLiteColumn {
|
|
1009
|
+
static [entityKind] = "SQLiteCustomColumn";
|
|
1010
|
+
sqlName;
|
|
1011
|
+
mapTo;
|
|
1012
|
+
mapFrom;
|
|
1013
|
+
constructor(table, config) {
|
|
1014
|
+
super(table, config);
|
|
1015
|
+
this.sqlName = config.customTypeParams.dataType(config.fieldConfig);
|
|
1016
|
+
this.mapTo = config.customTypeParams.toDriver;
|
|
1017
|
+
this.mapFrom = config.customTypeParams.fromDriver;
|
|
1018
|
+
}
|
|
1019
|
+
getSQLType() {
|
|
1020
|
+
return this.sqlName;
|
|
1021
|
+
}
|
|
1022
|
+
mapFromDriverValue(value) {
|
|
1023
|
+
return typeof this.mapFrom === "function" ? this.mapFrom(value) : value;
|
|
1024
|
+
}
|
|
1025
|
+
mapToDriverValue(value) {
|
|
1026
|
+
return typeof this.mapTo === "function" ? this.mapTo(value) : value;
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
function customType(customTypeParams) {
|
|
1030
|
+
return (a, b) => {
|
|
1031
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
1032
|
+
return new SQLiteCustomColumnBuilder(
|
|
1033
|
+
name,
|
|
1034
|
+
config,
|
|
1035
|
+
customTypeParams
|
|
1036
|
+
);
|
|
1037
|
+
};
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1121
1040
|
class SQLiteBaseIntegerBuilder extends SQLiteColumnBuilder {
|
|
1122
1041
|
static [entityKind] = "SQLiteBaseIntegerBuilder";
|
|
1123
1042
|
constructor(name, dataType, columnType) {
|
|
@@ -1226,6 +1145,100 @@ function integer(a, b) {
|
|
|
1226
1145
|
return new SQLiteIntegerBuilder(name);
|
|
1227
1146
|
}
|
|
1228
1147
|
|
|
1148
|
+
class SQLiteNumericBuilder extends SQLiteColumnBuilder {
|
|
1149
|
+
static [entityKind] = "SQLiteNumericBuilder";
|
|
1150
|
+
constructor(name) {
|
|
1151
|
+
super(name, "string", "SQLiteNumeric");
|
|
1152
|
+
}
|
|
1153
|
+
/** @internal */
|
|
1154
|
+
build(table) {
|
|
1155
|
+
return new SQLiteNumeric(
|
|
1156
|
+
table,
|
|
1157
|
+
this.config
|
|
1158
|
+
);
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
class SQLiteNumeric extends SQLiteColumn {
|
|
1162
|
+
static [entityKind] = "SQLiteNumeric";
|
|
1163
|
+
mapFromDriverValue(value) {
|
|
1164
|
+
if (typeof value === "string") return value;
|
|
1165
|
+
return String(value);
|
|
1166
|
+
}
|
|
1167
|
+
getSQLType() {
|
|
1168
|
+
return "numeric";
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
class SQLiteNumericNumberBuilder extends SQLiteColumnBuilder {
|
|
1172
|
+
static [entityKind] = "SQLiteNumericNumberBuilder";
|
|
1173
|
+
constructor(name) {
|
|
1174
|
+
super(name, "number", "SQLiteNumericNumber");
|
|
1175
|
+
}
|
|
1176
|
+
/** @internal */
|
|
1177
|
+
build(table) {
|
|
1178
|
+
return new SQLiteNumericNumber(
|
|
1179
|
+
table,
|
|
1180
|
+
this.config
|
|
1181
|
+
);
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
class SQLiteNumericNumber extends SQLiteColumn {
|
|
1185
|
+
static [entityKind] = "SQLiteNumericNumber";
|
|
1186
|
+
mapFromDriverValue(value) {
|
|
1187
|
+
if (typeof value === "number") return value;
|
|
1188
|
+
return Number(value);
|
|
1189
|
+
}
|
|
1190
|
+
mapToDriverValue = String;
|
|
1191
|
+
getSQLType() {
|
|
1192
|
+
return "numeric";
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
class SQLiteNumericBigIntBuilder extends SQLiteColumnBuilder {
|
|
1196
|
+
static [entityKind] = "SQLiteNumericBigIntBuilder";
|
|
1197
|
+
constructor(name) {
|
|
1198
|
+
super(name, "bigint", "SQLiteNumericBigInt");
|
|
1199
|
+
}
|
|
1200
|
+
/** @internal */
|
|
1201
|
+
build(table) {
|
|
1202
|
+
return new SQLiteNumericBigInt(
|
|
1203
|
+
table,
|
|
1204
|
+
this.config
|
|
1205
|
+
);
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
class SQLiteNumericBigInt extends SQLiteColumn {
|
|
1209
|
+
static [entityKind] = "SQLiteNumericBigInt";
|
|
1210
|
+
mapFromDriverValue = BigInt;
|
|
1211
|
+
mapToDriverValue = String;
|
|
1212
|
+
getSQLType() {
|
|
1213
|
+
return "numeric";
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
function numeric(a, b) {
|
|
1217
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
1218
|
+
const mode = config?.mode;
|
|
1219
|
+
return mode === "number" ? new SQLiteNumericNumberBuilder(name) : mode === "bigint" ? new SQLiteNumericBigIntBuilder(name) : new SQLiteNumericBuilder(name);
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
class SQLiteRealBuilder extends SQLiteColumnBuilder {
|
|
1223
|
+
static [entityKind] = "SQLiteRealBuilder";
|
|
1224
|
+
constructor(name) {
|
|
1225
|
+
super(name, "number", "SQLiteReal");
|
|
1226
|
+
}
|
|
1227
|
+
/** @internal */
|
|
1228
|
+
build(table) {
|
|
1229
|
+
return new SQLiteReal(table, this.config);
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
class SQLiteReal extends SQLiteColumn {
|
|
1233
|
+
static [entityKind] = "SQLiteReal";
|
|
1234
|
+
getSQLType() {
|
|
1235
|
+
return "real";
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
function real(name) {
|
|
1239
|
+
return new SQLiteRealBuilder(name ?? "");
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1229
1242
|
class SQLiteTextBuilder extends SQLiteColumnBuilder {
|
|
1230
1243
|
static [entityKind] = "SQLiteTextBuilder";
|
|
1231
1244
|
constructor(name, config) {
|
|
@@ -1285,37 +1298,382 @@ function text(a, b = {}) {
|
|
|
1285
1298
|
return new SQLiteTextBuilder(name, config);
|
|
1286
1299
|
}
|
|
1287
1300
|
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1301
|
+
function getSQLiteColumnBuilders() {
|
|
1302
|
+
return {
|
|
1303
|
+
blob,
|
|
1304
|
+
customType,
|
|
1305
|
+
integer,
|
|
1306
|
+
numeric,
|
|
1307
|
+
real,
|
|
1308
|
+
text
|
|
1309
|
+
};
|
|
1310
|
+
}
|
|
1297
1311
|
|
|
1298
|
-
|
|
1312
|
+
const InlineForeignKeys = Symbol.for("drizzle:SQLiteInlineForeignKeys");
|
|
1313
|
+
class SQLiteTable extends Table {
|
|
1314
|
+
static [entityKind] = "SQLiteTable";
|
|
1315
|
+
/** @internal */
|
|
1316
|
+
static Symbol = Object.assign({}, Table.Symbol, {
|
|
1317
|
+
InlineForeignKeys
|
|
1318
|
+
});
|
|
1319
|
+
/** @internal */
|
|
1320
|
+
[Table.Symbol.Columns];
|
|
1321
|
+
/** @internal */
|
|
1322
|
+
[InlineForeignKeys] = [];
|
|
1323
|
+
/** @internal */
|
|
1324
|
+
[Table.Symbol.ExtraConfigBuilder] = void 0;
|
|
1325
|
+
}
|
|
1326
|
+
function sqliteTableBase(name, columns, extraConfig, schema, baseName = name) {
|
|
1327
|
+
const rawTable = new SQLiteTable(name, schema, baseName);
|
|
1328
|
+
const parsedColumns = typeof columns === "function" ? columns(getSQLiteColumnBuilders()) : columns;
|
|
1329
|
+
const builtColumns = Object.fromEntries(
|
|
1330
|
+
Object.entries(parsedColumns).map(([name2, colBuilderBase]) => {
|
|
1331
|
+
const colBuilder = colBuilderBase;
|
|
1332
|
+
colBuilder.setName(name2);
|
|
1333
|
+
const column = colBuilder.build(rawTable);
|
|
1334
|
+
rawTable[InlineForeignKeys].push(...colBuilder.buildForeignKeys(column, rawTable));
|
|
1335
|
+
return [name2, column];
|
|
1336
|
+
})
|
|
1337
|
+
);
|
|
1338
|
+
const table = Object.assign(rawTable, builtColumns);
|
|
1339
|
+
table[Table.Symbol.Columns] = builtColumns;
|
|
1340
|
+
table[Table.Symbol.ExtraConfigColumns] = builtColumns;
|
|
1341
|
+
return table;
|
|
1342
|
+
}
|
|
1343
|
+
const sqliteTable = (name, columns, extraConfig) => {
|
|
1344
|
+
return sqliteTableBase(name, columns);
|
|
1345
|
+
};
|
|
1299
1346
|
|
|
1300
|
-
|
|
1347
|
+
const CONSTANTS = {
|
|
1348
|
+
INT8_MIN: -128,
|
|
1349
|
+
INT8_MAX: 127,
|
|
1350
|
+
INT8_UNSIGNED_MAX: 255,
|
|
1351
|
+
INT16_MIN: -32768,
|
|
1352
|
+
INT16_MAX: 32767,
|
|
1353
|
+
INT16_UNSIGNED_MAX: 65535,
|
|
1354
|
+
INT24_MIN: -8388608,
|
|
1355
|
+
INT24_MAX: 8388607,
|
|
1356
|
+
INT24_UNSIGNED_MAX: 16777215,
|
|
1357
|
+
INT32_MIN: -2147483648,
|
|
1358
|
+
INT32_MAX: 2147483647,
|
|
1359
|
+
INT32_UNSIGNED_MAX: 4294967295,
|
|
1360
|
+
INT48_MIN: -140737488355328,
|
|
1361
|
+
INT48_MAX: 140737488355327,
|
|
1362
|
+
INT48_UNSIGNED_MAX: 281474976710655,
|
|
1363
|
+
INT64_MIN: -9223372036854775808n,
|
|
1364
|
+
INT64_MAX: 9223372036854775807n,
|
|
1365
|
+
INT64_UNSIGNED_MAX: 18446744073709551615n,
|
|
1366
|
+
};
|
|
1301
1367
|
|
|
1302
|
-
function
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
})(esprima, function() {
|
|
1310
|
-
return /******/ (function(modules) { // webpackBootstrap
|
|
1311
|
-
/******/ // The module cache
|
|
1312
|
-
/******/ var installedModules = {};
|
|
1368
|
+
function isColumnType(column, columnTypes) {
|
|
1369
|
+
return columnTypes.includes(column.columnType);
|
|
1370
|
+
}
|
|
1371
|
+
function isWithEnum(column) {
|
|
1372
|
+
return 'enumValues' in column && Array.isArray(column.enumValues) && column.enumValues.length > 0;
|
|
1373
|
+
}
|
|
1374
|
+
const isPgEnum = isWithEnum;
|
|
1313
1375
|
|
|
1314
|
-
|
|
1315
|
-
|
|
1376
|
+
const literalSchema = z$1.union([z$1.string(), z$1.number(), z$1.boolean(), z$1.null()]);
|
|
1377
|
+
const jsonSchema = z$1.union([
|
|
1378
|
+
literalSchema,
|
|
1379
|
+
z$1.record(z$1.string(), z$1.any()),
|
|
1380
|
+
z$1.array(z$1.any()),
|
|
1381
|
+
]);
|
|
1382
|
+
const bufferSchema = z$1.custom((v) => v instanceof Buffer); // eslint-disable-line no-instanceof/no-instanceof
|
|
1383
|
+
function columnToSchema(column, factory) {
|
|
1384
|
+
const z$1$1 = z$1;
|
|
1385
|
+
const coerce = {};
|
|
1386
|
+
let schema;
|
|
1387
|
+
if (isWithEnum(column)) {
|
|
1388
|
+
schema = column.enumValues.length ? z$1$1.enum(column.enumValues) : z$1$1.string();
|
|
1389
|
+
}
|
|
1390
|
+
if (!schema) {
|
|
1391
|
+
// Handle specific types
|
|
1392
|
+
if (isColumnType(column, ['PgGeometry', 'PgPointTuple'])) {
|
|
1393
|
+
schema = z$1$1.tuple([z$1$1.number(), z$1$1.number()]);
|
|
1394
|
+
}
|
|
1395
|
+
else if (isColumnType(column, ['PgGeometryObject', 'PgPointObject'])) {
|
|
1396
|
+
schema = z$1$1.object({ x: z$1$1.number(), y: z$1$1.number() });
|
|
1397
|
+
}
|
|
1398
|
+
else if (isColumnType(column, ['PgHalfVector', 'PgVector'])) {
|
|
1399
|
+
schema = z$1$1.array(z$1$1.number());
|
|
1400
|
+
schema = column.dimensions ? schema.length(column.dimensions) : schema;
|
|
1401
|
+
}
|
|
1402
|
+
else if (isColumnType(column, ['PgLine'])) {
|
|
1403
|
+
schema = z$1$1.tuple([z$1$1.number(), z$1$1.number(), z$1$1.number()]);
|
|
1404
|
+
}
|
|
1405
|
+
else if (isColumnType(column, ['PgLineABC'])) {
|
|
1406
|
+
schema = z$1$1.object({
|
|
1407
|
+
a: z$1$1.number(),
|
|
1408
|
+
b: z$1$1.number(),
|
|
1409
|
+
c: z$1$1.number(),
|
|
1410
|
+
});
|
|
1411
|
+
} // Handle other types
|
|
1412
|
+
else if (isColumnType(column, ['PgArray'])) {
|
|
1413
|
+
schema = z$1$1.array(columnToSchema(column.baseColumn));
|
|
1414
|
+
schema = column.size ? schema.length(column.size) : schema;
|
|
1415
|
+
}
|
|
1416
|
+
else if (column.dataType === 'array') {
|
|
1417
|
+
schema = z$1$1.array(z$1$1.any());
|
|
1418
|
+
}
|
|
1419
|
+
else if (column.dataType === 'number') {
|
|
1420
|
+
schema = numberColumnToSchema(column, z$1$1, coerce);
|
|
1421
|
+
}
|
|
1422
|
+
else if (column.dataType === 'bigint') {
|
|
1423
|
+
schema = bigintColumnToSchema(column, z$1$1, coerce);
|
|
1424
|
+
}
|
|
1425
|
+
else if (column.dataType === 'boolean') {
|
|
1426
|
+
schema = coerce === true || coerce.boolean ? z$1$1.coerce.boolean() : z$1$1.boolean();
|
|
1427
|
+
}
|
|
1428
|
+
else if (column.dataType === 'date') {
|
|
1429
|
+
schema = coerce === true || coerce.date ? z$1$1.coerce.date() : z$1$1.date();
|
|
1430
|
+
}
|
|
1431
|
+
else if (column.dataType === 'string') {
|
|
1432
|
+
schema = stringColumnToSchema(column, z$1$1, coerce);
|
|
1433
|
+
}
|
|
1434
|
+
else if (column.dataType === 'json') {
|
|
1435
|
+
schema = jsonSchema;
|
|
1436
|
+
}
|
|
1437
|
+
else if (column.dataType === 'custom') {
|
|
1438
|
+
schema = z$1$1.any();
|
|
1439
|
+
}
|
|
1440
|
+
else if (column.dataType === 'buffer') {
|
|
1441
|
+
schema = bufferSchema;
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
if (!schema) {
|
|
1445
|
+
schema = z$1$1.any();
|
|
1446
|
+
}
|
|
1447
|
+
return schema;
|
|
1448
|
+
}
|
|
1449
|
+
function numberColumnToSchema(column, z, coerce) {
|
|
1450
|
+
let unsigned = column.getSQLType().includes('unsigned');
|
|
1451
|
+
let min;
|
|
1452
|
+
let max;
|
|
1453
|
+
let integer = false;
|
|
1454
|
+
if (isColumnType(column, ['MySqlTinyInt', 'SingleStoreTinyInt'])) {
|
|
1455
|
+
min = unsigned ? 0 : CONSTANTS.INT8_MIN;
|
|
1456
|
+
max = unsigned ? CONSTANTS.INT8_UNSIGNED_MAX : CONSTANTS.INT8_MAX;
|
|
1457
|
+
integer = true;
|
|
1458
|
+
}
|
|
1459
|
+
else if (isColumnType(column, [
|
|
1460
|
+
'PgSmallInt',
|
|
1461
|
+
'PgSmallSerial',
|
|
1462
|
+
'MySqlSmallInt',
|
|
1463
|
+
'SingleStoreSmallInt',
|
|
1464
|
+
])) {
|
|
1465
|
+
min = unsigned ? 0 : CONSTANTS.INT16_MIN;
|
|
1466
|
+
max = unsigned ? CONSTANTS.INT16_UNSIGNED_MAX : CONSTANTS.INT16_MAX;
|
|
1467
|
+
integer = true;
|
|
1468
|
+
}
|
|
1469
|
+
else if (isColumnType(column, [
|
|
1470
|
+
'PgReal',
|
|
1471
|
+
'MySqlFloat',
|
|
1472
|
+
'MySqlMediumInt',
|
|
1473
|
+
'SingleStoreMediumInt',
|
|
1474
|
+
'SingleStoreFloat',
|
|
1475
|
+
])) {
|
|
1476
|
+
min = unsigned ? 0 : CONSTANTS.INT24_MIN;
|
|
1477
|
+
max = unsigned ? CONSTANTS.INT24_UNSIGNED_MAX : CONSTANTS.INT24_MAX;
|
|
1478
|
+
integer = isColumnType(column, ['MySqlMediumInt', 'SingleStoreMediumInt']);
|
|
1479
|
+
}
|
|
1480
|
+
else if (isColumnType(column, [
|
|
1481
|
+
'PgInteger',
|
|
1482
|
+
'PgSerial',
|
|
1483
|
+
'MySqlInt',
|
|
1484
|
+
'SingleStoreInt',
|
|
1485
|
+
])) {
|
|
1486
|
+
min = unsigned ? 0 : CONSTANTS.INT32_MIN;
|
|
1487
|
+
max = unsigned ? CONSTANTS.INT32_UNSIGNED_MAX : CONSTANTS.INT32_MAX;
|
|
1488
|
+
integer = true;
|
|
1489
|
+
}
|
|
1490
|
+
else if (isColumnType(column, [
|
|
1491
|
+
'PgDoublePrecision',
|
|
1492
|
+
'MySqlReal',
|
|
1493
|
+
'MySqlDouble',
|
|
1494
|
+
'SingleStoreReal',
|
|
1495
|
+
'SingleStoreDouble',
|
|
1496
|
+
'SQLiteReal',
|
|
1497
|
+
])) {
|
|
1498
|
+
min = unsigned ? 0 : CONSTANTS.INT48_MIN;
|
|
1499
|
+
max = unsigned ? CONSTANTS.INT48_UNSIGNED_MAX : CONSTANTS.INT48_MAX;
|
|
1500
|
+
}
|
|
1501
|
+
else if (isColumnType(column, [
|
|
1502
|
+
'PgBigInt53',
|
|
1503
|
+
'PgBigSerial53',
|
|
1504
|
+
'MySqlBigInt53',
|
|
1505
|
+
'MySqlSerial',
|
|
1506
|
+
'SingleStoreBigInt53',
|
|
1507
|
+
'SingleStoreSerial',
|
|
1508
|
+
'SQLiteInteger',
|
|
1509
|
+
])) {
|
|
1510
|
+
unsigned = unsigned || isColumnType(column, ['MySqlSerial', 'SingleStoreSerial']);
|
|
1511
|
+
min = unsigned ? 0 : Number.MIN_SAFE_INTEGER;
|
|
1512
|
+
max = Number.MAX_SAFE_INTEGER;
|
|
1513
|
+
integer = true;
|
|
1514
|
+
}
|
|
1515
|
+
else if (isColumnType(column, ['MySqlYear', 'SingleStoreYear'])) {
|
|
1516
|
+
min = 1901;
|
|
1517
|
+
max = 2155;
|
|
1518
|
+
integer = true;
|
|
1519
|
+
}
|
|
1520
|
+
else {
|
|
1521
|
+
min = Number.MIN_SAFE_INTEGER;
|
|
1522
|
+
max = Number.MAX_SAFE_INTEGER;
|
|
1523
|
+
}
|
|
1524
|
+
let schema = coerce === true || coerce?.number
|
|
1525
|
+
? integer ? z.coerce.number() : z.coerce.number().int()
|
|
1526
|
+
: integer
|
|
1527
|
+
? z.int()
|
|
1528
|
+
: z.number();
|
|
1529
|
+
schema = schema.gte(min).lte(max);
|
|
1530
|
+
return schema;
|
|
1531
|
+
}
|
|
1532
|
+
function bigintColumnToSchema(column, z, coerce) {
|
|
1533
|
+
const unsigned = column.getSQLType().includes('unsigned');
|
|
1534
|
+
const min = unsigned ? 0n : CONSTANTS.INT64_MIN;
|
|
1535
|
+
const max = unsigned ? CONSTANTS.INT64_UNSIGNED_MAX : CONSTANTS.INT64_MAX;
|
|
1536
|
+
const schema = coerce === true || coerce?.bigint ? z.coerce.bigint() : z.bigint();
|
|
1537
|
+
return schema.gte(min).lte(max);
|
|
1538
|
+
}
|
|
1539
|
+
function stringColumnToSchema(column, z, coerce) {
|
|
1540
|
+
if (isColumnType(column, ['PgUUID'])) {
|
|
1541
|
+
return z.uuid();
|
|
1542
|
+
}
|
|
1543
|
+
let max;
|
|
1544
|
+
let regex;
|
|
1545
|
+
let fixed = false;
|
|
1546
|
+
if (isColumnType(column, ['PgVarchar', 'SQLiteText'])) {
|
|
1547
|
+
max = column.length;
|
|
1548
|
+
}
|
|
1549
|
+
else if (isColumnType(column, ['MySqlVarChar', 'SingleStoreVarChar'])) {
|
|
1550
|
+
max = column.length ?? CONSTANTS.INT16_UNSIGNED_MAX;
|
|
1551
|
+
}
|
|
1552
|
+
else if (isColumnType(column, ['MySqlText', 'SingleStoreText'])) {
|
|
1553
|
+
if (column.textType === 'longtext') {
|
|
1554
|
+
max = CONSTANTS.INT32_UNSIGNED_MAX;
|
|
1555
|
+
}
|
|
1556
|
+
else if (column.textType === 'mediumtext') {
|
|
1557
|
+
max = CONSTANTS.INT24_UNSIGNED_MAX;
|
|
1558
|
+
}
|
|
1559
|
+
else if (column.textType === 'text') {
|
|
1560
|
+
max = CONSTANTS.INT16_UNSIGNED_MAX;
|
|
1561
|
+
}
|
|
1562
|
+
else {
|
|
1563
|
+
max = CONSTANTS.INT8_UNSIGNED_MAX;
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
if (isColumnType(column, [
|
|
1567
|
+
'PgChar',
|
|
1568
|
+
'MySqlChar',
|
|
1569
|
+
'SingleStoreChar',
|
|
1570
|
+
])) {
|
|
1571
|
+
max = column.length;
|
|
1572
|
+
fixed = true;
|
|
1573
|
+
}
|
|
1574
|
+
if (isColumnType(column, ['PgBinaryVector'])) {
|
|
1575
|
+
regex = /^[01]+$/;
|
|
1576
|
+
max = column.dimensions;
|
|
1577
|
+
}
|
|
1578
|
+
let schema = coerce === true || coerce?.string ? z.coerce.string() : z.string();
|
|
1579
|
+
schema = regex ? schema.regex(regex) : schema;
|
|
1580
|
+
return max && fixed ? schema.length(max) : max ? schema.max(max) : schema;
|
|
1581
|
+
}
|
|
1316
1582
|
|
|
1317
|
-
|
|
1318
|
-
|
|
1583
|
+
function getColumns(tableLike) {
|
|
1584
|
+
return isTable(tableLike) ? getTableColumns(tableLike) : getViewSelectedFields(tableLike);
|
|
1585
|
+
}
|
|
1586
|
+
function handleColumns(columns, refinements, conditions, factory) {
|
|
1587
|
+
const columnSchemas = {};
|
|
1588
|
+
for (const [key, selected] of Object.entries(columns)) {
|
|
1589
|
+
if (!is(selected, Column) && !is(selected, SQL) && !is(selected, SQL.Aliased) && typeof selected === 'object') {
|
|
1590
|
+
const columns = isTable(selected) || isView(selected) ? getColumns(selected) : selected;
|
|
1591
|
+
columnSchemas[key] = handleColumns(columns, refinements[key] ?? {}, conditions);
|
|
1592
|
+
continue;
|
|
1593
|
+
}
|
|
1594
|
+
const refinement = refinements[key];
|
|
1595
|
+
if (refinement !== undefined && typeof refinement !== 'function') {
|
|
1596
|
+
columnSchemas[key] = refinement;
|
|
1597
|
+
continue;
|
|
1598
|
+
}
|
|
1599
|
+
const column = is(selected, Column) ? selected : undefined;
|
|
1600
|
+
const schema = column ? columnToSchema(column) : z$1.any();
|
|
1601
|
+
const refined = typeof refinement === 'function' ? refinement(schema) : schema;
|
|
1602
|
+
if (conditions.never(column)) {
|
|
1603
|
+
continue;
|
|
1604
|
+
}
|
|
1605
|
+
else {
|
|
1606
|
+
columnSchemas[key] = refined;
|
|
1607
|
+
}
|
|
1608
|
+
if (column) {
|
|
1609
|
+
if (conditions.nullable(column)) {
|
|
1610
|
+
columnSchemas[key] = columnSchemas[key].nullable();
|
|
1611
|
+
}
|
|
1612
|
+
if (conditions.optional(column)) {
|
|
1613
|
+
columnSchemas[key] = columnSchemas[key].optional();
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1616
|
+
}
|
|
1617
|
+
return z$1.object(columnSchemas);
|
|
1618
|
+
}
|
|
1619
|
+
function handleEnum(enum_, factory) {
|
|
1620
|
+
const zod = z$1;
|
|
1621
|
+
return zod.enum(enum_.enumValues);
|
|
1622
|
+
}
|
|
1623
|
+
const selectConditions = {
|
|
1624
|
+
never: () => false,
|
|
1625
|
+
optional: () => false,
|
|
1626
|
+
nullable: (column) => !column.notNull,
|
|
1627
|
+
};
|
|
1628
|
+
const insertConditions = {
|
|
1629
|
+
never: (column) => column?.generated?.type === 'always' || column?.generatedIdentity?.type === 'always',
|
|
1630
|
+
optional: (column) => !column.notNull || (column.notNull && column.hasDefault),
|
|
1631
|
+
nullable: (column) => !column.notNull,
|
|
1632
|
+
};
|
|
1633
|
+
const updateConditions = {
|
|
1634
|
+
never: (column) => column?.generated?.type === 'always' || column?.generatedIdentity?.type === 'always',
|
|
1635
|
+
optional: () => true,
|
|
1636
|
+
nullable: (column) => !column.notNull,
|
|
1637
|
+
};
|
|
1638
|
+
const createSelectSchema = (entity, refine) => {
|
|
1639
|
+
if (isPgEnum(entity)) {
|
|
1640
|
+
return handleEnum(entity);
|
|
1641
|
+
}
|
|
1642
|
+
const columns = getColumns(entity);
|
|
1643
|
+
return handleColumns(columns, {}, selectConditions);
|
|
1644
|
+
};
|
|
1645
|
+
const createInsertSchema = (entity, refine) => {
|
|
1646
|
+
const columns = getColumns(entity);
|
|
1647
|
+
return handleColumns(columns, {}, insertConditions);
|
|
1648
|
+
};
|
|
1649
|
+
const createUpdateSchema = (entity, refine) => {
|
|
1650
|
+
const columns = getColumns(entity);
|
|
1651
|
+
return handleColumns(columns, {}, updateConditions);
|
|
1652
|
+
};
|
|
1653
|
+
|
|
1654
|
+
var esprima$1 = {exports: {}};
|
|
1655
|
+
|
|
1656
|
+
var esprima = esprima$1.exports;
|
|
1657
|
+
|
|
1658
|
+
var hasRequiredEsprima;
|
|
1659
|
+
|
|
1660
|
+
function requireEsprima () {
|
|
1661
|
+
if (hasRequiredEsprima) return esprima$1.exports;
|
|
1662
|
+
hasRequiredEsprima = 1;
|
|
1663
|
+
(function (module, exports$1) {
|
|
1664
|
+
(function webpackUniversalModuleDefinition(root, factory) {
|
|
1665
|
+
/* istanbul ignore next */
|
|
1666
|
+
module.exports = factory();
|
|
1667
|
+
})(esprima, function() {
|
|
1668
|
+
return /******/ (function(modules) { // webpackBootstrap
|
|
1669
|
+
/******/ // The module cache
|
|
1670
|
+
/******/ var installedModules = {};
|
|
1671
|
+
|
|
1672
|
+
/******/ // The require function
|
|
1673
|
+
/******/ function __webpack_require__(moduleId) {
|
|
1674
|
+
|
|
1675
|
+
/******/ // Check if module is in cache
|
|
1676
|
+
/* istanbul ignore if */
|
|
1319
1677
|
/******/ if(installedModules[moduleId])
|
|
1320
1678
|
/******/ return installedModules[moduleId].exports;
|
|
1321
1679
|
|
|
@@ -11729,7 +12087,7 @@ SuperJSON.registerSymbol = SuperJSON.defaultInstance.registerSymbol.bind(SuperJS
|
|
|
11729
12087
|
SuperJSON.registerCustom = SuperJSON.defaultInstance.registerCustom.bind(SuperJSON.defaultInstance);
|
|
11730
12088
|
SuperJSON.allowErrorProps = SuperJSON.defaultInstance.allowErrorProps.bind(SuperJSON.defaultInstance);
|
|
11731
12089
|
|
|
11732
|
-
|
|
12090
|
+
const base = {
|
|
11733
12091
|
id: text("id").primaryKey(),
|
|
11734
12092
|
createdAt: integer("created_at", { mode: "timestamp_ms" }).default(
|
|
11735
12093
|
sql`(unixepoch('subsec') * 1000)`
|
|
@@ -11739,9 +12097,9 @@ SuperJSON.allowErrorProps = SuperJSON.defaultInstance.allowErrorProps.bind(Super
|
|
|
11739
12097
|
updatedBy: text("updated_by").default(sql`null`),
|
|
11740
12098
|
deletedAt: integer("deleted_at", { mode: "timestamp_ms" }).default(sql`null`),
|
|
11741
12099
|
deletedBy: text("deleted_by").default(sql`null`)
|
|
11742
|
-
}
|
|
12100
|
+
};
|
|
11743
12101
|
|
|
11744
|
-
|
|
12102
|
+
const bankAccount$1 = {
|
|
11745
12103
|
holderName: text("holder_name").notNull(),
|
|
11746
12104
|
number: text("number"),
|
|
11747
12105
|
bankCode: text("bank_code", { enum: BANK_CODES }),
|
|
@@ -11761,39 +12119,39 @@ SuperJSON.allowErrorProps = SuperJSON.defaultInstance.allowErrorProps.bind(Super
|
|
|
11761
12119
|
// Australia
|
|
11762
12120
|
brBankNumber: text("br_bank_number")
|
|
11763
12121
|
// Brazil
|
|
11764
|
-
}
|
|
12122
|
+
};
|
|
11765
12123
|
|
|
11766
|
-
const ibanSchema = z$
|
|
12124
|
+
const ibanSchema = z$2.string().min(1).regex(/^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$/, {
|
|
11767
12125
|
message: "Invalid IBAN format"
|
|
11768
12126
|
});
|
|
11769
|
-
const bicSchema = z$
|
|
12127
|
+
const bicSchema = z$2.string().min(1).regex(/^[A-Z]{6}[A-Z0-9]{2}([A-Z0-9]{3})?$/, {
|
|
11770
12128
|
message: "Invalid SWIFT/BIC format"
|
|
11771
12129
|
});
|
|
11772
|
-
const bankAccountMetadataSchema = z$
|
|
11773
|
-
id: z$
|
|
11774
|
-
number: z$
|
|
11775
|
-
bankCode: z$
|
|
11776
|
-
holderName: z$
|
|
12130
|
+
const bankAccountMetadataSchema = z$2.object({
|
|
12131
|
+
id: z$2.string().optional(),
|
|
12132
|
+
number: z$2.string().optional(),
|
|
12133
|
+
bankCode: z$2.enum(BANK_CODES).optional(),
|
|
12134
|
+
holderName: z$2.string().optional(),
|
|
11777
12135
|
iban: ibanSchema.optional(),
|
|
11778
|
-
address: z$
|
|
12136
|
+
address: z$2.string().optional(),
|
|
11779
12137
|
swiftBic: bicSchema.optional(),
|
|
11780
12138
|
bicCor: bicSchema.optional(),
|
|
11781
|
-
currency: z$
|
|
11782
|
-
countryCode: z$
|
|
11783
|
-
routingNumber: z$
|
|
12139
|
+
currency: z$2.enum(CURRENCY_CODES).optional(),
|
|
12140
|
+
countryCode: z$2.enum(COUNTRY_CODES_2).optional(),
|
|
12141
|
+
routingNumber: z$2.string().optional(),
|
|
11784
12142
|
// US
|
|
11785
|
-
sortCode: z$
|
|
12143
|
+
sortCode: z$2.string().optional(),
|
|
11786
12144
|
// UK
|
|
11787
|
-
clabe: z$
|
|
12145
|
+
clabe: z$2.string().optional(),
|
|
11788
12146
|
// Mexico
|
|
11789
|
-
bsb: z$
|
|
12147
|
+
bsb: z$2.string().optional(),
|
|
11790
12148
|
// Australia
|
|
11791
|
-
brBankNumber: z$
|
|
12149
|
+
brBankNumber: z$2.string().optional()
|
|
11792
12150
|
// Brazil
|
|
11793
12151
|
});
|
|
11794
12152
|
|
|
11795
|
-
z$
|
|
11796
|
-
status: z$
|
|
12153
|
+
z$2.object({
|
|
12154
|
+
status: z$2.enum([
|
|
11797
12155
|
"queued",
|
|
11798
12156
|
// means that instance is waiting to be started (see concurrency limits)
|
|
11799
12157
|
"running",
|
|
@@ -11808,11 +12166,11 @@ z$3.object({
|
|
|
11808
12166
|
// instance is finishing the current work to pause
|
|
11809
12167
|
"unknown"
|
|
11810
12168
|
]),
|
|
11811
|
-
error: z$
|
|
11812
|
-
message: z$
|
|
11813
|
-
name: z$
|
|
12169
|
+
error: z$2.object({
|
|
12170
|
+
message: z$2.string(),
|
|
12171
|
+
name: z$2.string().optional()
|
|
11814
12172
|
}).optional(),
|
|
11815
|
-
output: z$
|
|
12173
|
+
output: z$2.unknown().optional()
|
|
11816
12174
|
});
|
|
11817
12175
|
|
|
11818
12176
|
new z.$ZodObject({
|
|
@@ -11900,287 +12258,2283 @@ new z.$ZodObject({
|
|
|
11900
12258
|
}
|
|
11901
12259
|
});
|
|
11902
12260
|
|
|
11903
|
-
const
|
|
12261
|
+
const baseMdmSqlite = {
|
|
12262
|
+
...base
|
|
12263
|
+
};
|
|
12264
|
+
|
|
12265
|
+
const party = sqliteTable("party", {
|
|
12266
|
+
...base,
|
|
12267
|
+
internalId: text("internal_id"),
|
|
12268
|
+
note: text("note"),
|
|
12269
|
+
customerStatus: text("customer_status", {
|
|
12270
|
+
enum: CustomerStatusZod
|
|
12271
|
+
}).notNull(),
|
|
12272
|
+
partyType: text("party_type", { enum: PartyTypeZod }).notNull(),
|
|
12273
|
+
language: text("language", { enum: LANGUAGE_CODES }).notNull(),
|
|
12274
|
+
countryCode: text("country_code", { enum: COUNTRY_CODES_2 }),
|
|
12275
|
+
isClient: integer("is_client", { mode: "boolean" }).notNull().default(false),
|
|
12276
|
+
legacyId: text("legacy_id")
|
|
12277
|
+
});
|
|
12278
|
+
|
|
12279
|
+
const address = sqliteTable("address", {
|
|
12280
|
+
...base,
|
|
12281
|
+
internalId: text("internal_id"),
|
|
12282
|
+
partyId: text("party_id").notNull().references(() => party.id),
|
|
12283
|
+
ruianCode: text("ruian_code"),
|
|
12284
|
+
addressType: text("address_type", { enum: AddressTypeZod }).notNull(),
|
|
12285
|
+
street: text("street"),
|
|
12286
|
+
orientationNumber: text("orientation_number"),
|
|
12287
|
+
descriptiveNumber: text("descriptive_number"),
|
|
12288
|
+
municipality: text("municipality").notNull(),
|
|
12289
|
+
municipalityPart: text("municipality_part"),
|
|
12290
|
+
zipCode: text("zip_code").notNull(),
|
|
12291
|
+
district: text("district"),
|
|
12292
|
+
region: text("region"),
|
|
12293
|
+
countryCode: text("state", { enum: COUNTRY_CODES_2 }).notNull()
|
|
12294
|
+
});
|
|
12295
|
+
|
|
12296
|
+
const contact = sqliteTable("contact", {
|
|
12297
|
+
...base,
|
|
12298
|
+
internalId: text("internal_id"),
|
|
12299
|
+
partyId: text("party_id").notNull().references(() => party.id),
|
|
12300
|
+
contactType: text("contact_type", { enum: ContactTypeZod }),
|
|
12301
|
+
email: text("email").notNull(),
|
|
12302
|
+
phoneNumber: text("phone_number").notNull()
|
|
12303
|
+
});
|
|
12304
|
+
|
|
12305
|
+
const idDocument = sqliteTable("id_document", {
|
|
12306
|
+
...base,
|
|
12307
|
+
internalId: text("internal_id"),
|
|
12308
|
+
partyId: text("party_id").notNull().references(() => party.id),
|
|
12309
|
+
idDocType: text("id_doc_type", { enum: IdDocTypeZod }).notNull(),
|
|
12310
|
+
idDocNumber: text("id_doc_number").notNull(),
|
|
12311
|
+
idDocHolderName: text("id_doc_holder_name").notNull(),
|
|
12312
|
+
issueDate: integer("issue_date", { mode: "timestamp_ms" }),
|
|
12313
|
+
expirationDate: integer("expiration_date", { mode: "timestamp_ms" }),
|
|
12314
|
+
issuer: text("issuer"),
|
|
12315
|
+
countryOfIssue: text("country_of_issue", { enum: COUNTRY_CODES_2 }),
|
|
12316
|
+
frontImageUri: text("front_image_uri"),
|
|
12317
|
+
backImageUri: text("back_image_uri"),
|
|
12318
|
+
idDocStatus: text("id_doc_status", { enum: IdDocStatusZod })
|
|
12319
|
+
});
|
|
12320
|
+
|
|
12321
|
+
const individual = sqliteTable("individual", {
|
|
12322
|
+
...base,
|
|
12323
|
+
internalId: text("internal_id"),
|
|
12324
|
+
partyId: text("party_id").notNull().unique().references(() => party.id),
|
|
12325
|
+
name: text("name").notNull(),
|
|
12326
|
+
email: text("email"),
|
|
12327
|
+
phone: text("phone"),
|
|
12328
|
+
surname: text("surname").notNull(),
|
|
12329
|
+
birthDate: text("birth_date"),
|
|
12330
|
+
birthPlace: text("birth_place").notNull(),
|
|
12331
|
+
countryOfBirth: text("country_of_birth", { enum: COUNTRY_CODES_2 }),
|
|
12332
|
+
personalId: text("personal_id").notNull(),
|
|
12333
|
+
gender: text("gender", { enum: GenderZod }).notNull(),
|
|
12334
|
+
citizenship: text("citizenship", { enum: COUNTRY_CODES_2 }).notNull(),
|
|
12335
|
+
citizenshipOther: text("citizenship_other", { enum: COUNTRY_CODES_2 }),
|
|
12336
|
+
employer: text("employer"),
|
|
12337
|
+
employerCountry: text("employer_country", { enum: COUNTRY_CODES_2 }),
|
|
12338
|
+
registeredNumber: text("registered_number").notNull(),
|
|
12339
|
+
isPep: integer("is_pep", { mode: "boolean" }).notNull(),
|
|
12340
|
+
titleBefore: text("title_before"),
|
|
12341
|
+
titleAfter: text("title_after"),
|
|
12342
|
+
birthSurname: text("birth_surname"),
|
|
12343
|
+
vocativeTitle: text("vocative_title"),
|
|
12344
|
+
deathDate: integer("death_date", { mode: "timestamp_ms" }),
|
|
12345
|
+
deathNotification: integer("death_notification", { mode: "timestamp_ms" }),
|
|
12346
|
+
pin: text("pin"),
|
|
12347
|
+
stayAbroad: integer("stay_abroad", { mode: "boolean" }),
|
|
12348
|
+
stayAbroadCountries: text("stay_abroad_countries", {
|
|
12349
|
+
enum: COUNTRY_CODES_2
|
|
12350
|
+
})
|
|
12351
|
+
});
|
|
12352
|
+
|
|
12353
|
+
const organization = sqliteTable("organization", {
|
|
12354
|
+
...base,
|
|
12355
|
+
internalId: text("internal_id"),
|
|
12356
|
+
partyId: text("party_id").notNull().unique().references(() => party.id),
|
|
12357
|
+
businessName: text("business_name").notNull(),
|
|
12358
|
+
email: text("email"),
|
|
12359
|
+
phone: text("phone"),
|
|
12360
|
+
registeredNumber: text("registered_number").notNull(),
|
|
12361
|
+
registeredIn: text("registered_in", { enum: COUNTRY_CODES_2 }).notNull(),
|
|
12362
|
+
operatesIn: text("operates_in", { enum: COUNTRY_CODES_2 }).notNull(),
|
|
12363
|
+
presentIn: text("present_in", { enum: COUNTRY_CODES_2 }).notNull(),
|
|
12364
|
+
monthlyVolumeIn: integer("monthly_volume_in").notNull(),
|
|
12365
|
+
monthlyVolumeOut: integer("monthly_volume_out").notNull(),
|
|
12366
|
+
ownedBy: text("owned_by").notNull(),
|
|
12367
|
+
// UBO, skutecny majitel, podle Marianovy tabulky by toto mela byt mozna relace na party
|
|
12368
|
+
companyObjects: text("company_objects").notNull(),
|
|
12369
|
+
// predmet cinnosti
|
|
12370
|
+
companyObjectsDescription: text("company_objects_description").notNull(),
|
|
12371
|
+
turnover3years: integer("turnover_3_years").notNull(),
|
|
12372
|
+
operationCountries: text("operation_countries").notNull(),
|
|
12373
|
+
annualTurnover: integer("annual_turnover").notNull(),
|
|
12374
|
+
riskyBusinessType: text("risky_business_type"),
|
|
12375
|
+
numberOfEmployees: integer("number_of_employees"),
|
|
12376
|
+
prosecuted: text("prosecuted"),
|
|
12377
|
+
// vedeno u soudu
|
|
12378
|
+
location: text("location"),
|
|
12379
|
+
// v lokalite
|
|
12380
|
+
fileNumber: text("file_number"),
|
|
12381
|
+
// spisova znacka
|
|
12382
|
+
websiteUrl: text("website_url"),
|
|
12383
|
+
vatPayer: integer("vat_payer", { mode: "boolean" }).notNull(),
|
|
12384
|
+
stayAbroad: integer("stay_abroad", { mode: "boolean" }),
|
|
12385
|
+
stayAbroadCountries: text("stay_abroad_countries", {
|
|
12386
|
+
enum: COUNTRY_CODES_2
|
|
12387
|
+
})
|
|
12388
|
+
});
|
|
12389
|
+
|
|
12390
|
+
const partyRelationship = sqliteTable("party_relationship", {
|
|
12391
|
+
...base,
|
|
12392
|
+
internalId: text("internal_id"),
|
|
12393
|
+
relationshipType: text("relationship_type", {
|
|
12394
|
+
enum: PartyRelationshipTypeZod
|
|
12395
|
+
}),
|
|
12396
|
+
fromPartyId: text("from_party_id").references(() => party.id),
|
|
12397
|
+
toPartyId: text("to_party_id").references(() => party.id),
|
|
12398
|
+
fromDate: integer("from_date", { mode: "timestamp_ms" }),
|
|
12399
|
+
// FIXME: Treba se doptat https://develitio.slack.com/archives/C09VAF0G70E/p1769766644943189
|
|
12400
|
+
// viz
|
|
12401
|
+
// - Celé pole `owner[]`
|
|
12402
|
+
// - `titleBefore`, `firstName`, `lastName`, `titleAfter`
|
|
12403
|
+
// - `dateOfBirth`, `idNumber`, `address`
|
|
12404
|
+
// - `sharePercentage`
|
|
12405
|
+
// - `dateOfEstablishmentOfShare`
|
|
12406
|
+
// - `pep`
|
|
12407
|
+
sharePercentage: integer("share_percentage")
|
|
12408
|
+
});
|
|
12409
|
+
|
|
12410
|
+
const taxResidence = sqliteTable("tax_residence", {
|
|
12411
|
+
...base,
|
|
12412
|
+
internalId: text("internal_id"),
|
|
12413
|
+
partyId: text("party_id").notNull().unique().references(() => party.id),
|
|
12414
|
+
country: text("country", { enum: COUNTRY_CODES_2 }).notNull(),
|
|
12415
|
+
taxIdentificationNumber: text("tax_identification_number").notNull()
|
|
12416
|
+
});
|
|
12417
|
+
|
|
12418
|
+
const partyChange = sqliteTable("party_change", {
|
|
12419
|
+
...base,
|
|
12420
|
+
internalId: text("internal_id"),
|
|
12421
|
+
partyId: text("party_id").notNull().references(() => party.id),
|
|
12422
|
+
operation: text("operation").notNull(),
|
|
12423
|
+
diff: text("diff", { mode: "json" }).notNull(),
|
|
12424
|
+
snapshotBefore: text("snapshot_before", { mode: "json" }).notNull(),
|
|
12425
|
+
snapshotAfter: text("snapshot_after", { mode: "json" }).notNull()
|
|
12426
|
+
});
|
|
12427
|
+
|
|
12428
|
+
const bankAccount = sqliteTable("bank_account", {
|
|
12429
|
+
...base,
|
|
12430
|
+
internalId: text("internal_id"),
|
|
12431
|
+
...bankAccount$1,
|
|
12432
|
+
partyId: text("party_id").notNull().references(() => party.id)
|
|
12433
|
+
});
|
|
12434
|
+
|
|
12435
|
+
const aml = sqliteTable("aml", {
|
|
12436
|
+
...base,
|
|
12437
|
+
internalId: text("internal_id"),
|
|
12438
|
+
partyId: text("party_id").notNull().unique().references(() => party.id),
|
|
12439
|
+
sourceOfWealth: text("source_of_wealth").notNull(),
|
|
12440
|
+
yearlyIncome: text("yearly_income").notNull(),
|
|
12441
|
+
tradesPurpose: text("trades_purpose"),
|
|
12442
|
+
sourceOfIncome: text("source_of_income").notNull(),
|
|
12443
|
+
transactionType: text("transaction_type"),
|
|
12444
|
+
transactionTypeExpiry: integer("transaction_type_expiry", {
|
|
12445
|
+
mode: "timestamp_ms"
|
|
12446
|
+
}),
|
|
12447
|
+
estTxsVolumeMonth: text("est_txs_volume_month").notNull(),
|
|
12448
|
+
estTxsVolumeYear: text("est_txs_volume_year").notNull(),
|
|
12449
|
+
tradingCountries: text("trading_countries").notNull(),
|
|
12450
|
+
tradingSide: text("trading_side").notNull(),
|
|
12451
|
+
acceptedAMLTermsAndConditions: integer("accepted_aml_terms_and_conditions", {
|
|
12452
|
+
mode: "boolean"
|
|
12453
|
+
}).notNull(),
|
|
12454
|
+
signatureMethod: text("signature_method"),
|
|
12455
|
+
existencePeriod: text("existence_period"),
|
|
12456
|
+
reputation: text("reputation"),
|
|
12457
|
+
isDistraint: integer("is_distraint", { mode: "boolean" }).notNull().default(false),
|
|
12458
|
+
riskLevel: text("risk_level", { enum: AmlScoreTypeZod }).notNull(),
|
|
12459
|
+
kycStatus: text("kyc_status", { enum: KycStatusZod })
|
|
12460
|
+
});
|
|
12461
|
+
|
|
12462
|
+
const recipient = sqliteTable("recipient", {
|
|
12463
|
+
...base,
|
|
12464
|
+
internalId: text("internal_id"),
|
|
12465
|
+
...bankAccount$1,
|
|
12466
|
+
partyId: text("party_id").notNull().references(() => party.id)
|
|
12467
|
+
});
|
|
12468
|
+
|
|
12469
|
+
const trader = sqliteTable("trader", {
|
|
12470
|
+
...base,
|
|
12471
|
+
internalId: text("internal_id"),
|
|
12472
|
+
type: text("trader", { length: 50, enum: TRADER_TYPE }).$type().notNull(),
|
|
12473
|
+
firstName: text("first_name", { length: 255 }),
|
|
12474
|
+
lastName: text("last_name", { length: 255 }),
|
|
12475
|
+
companyName: text("company_name", { length: 255 }),
|
|
12476
|
+
ico: text("ico", { length: 255 }),
|
|
12477
|
+
dic: text("dic", { length: 255 }),
|
|
12478
|
+
commission: real("commission").notNull(),
|
|
12479
|
+
legacyId: text("legacy_id")
|
|
12480
|
+
});
|
|
12481
|
+
|
|
12482
|
+
sqliteTable("trader_client", {
|
|
12483
|
+
...base,
|
|
12484
|
+
clientId: text("client_id").references(() => party.id),
|
|
12485
|
+
traderId: text("trader_id").references(() => trader.id),
|
|
12486
|
+
internalId: text("internal_id"),
|
|
12487
|
+
legacyId: text("legacy_id")
|
|
12488
|
+
});
|
|
12489
|
+
|
|
12490
|
+
sqliteTable("base", baseMdmSqlite);
|
|
12491
|
+
|
|
12492
|
+
createInsertSchema(address);
|
|
12493
|
+
createUpdateSchema(address);
|
|
12494
|
+
createSelectSchema(address);
|
|
12495
|
+
const addressInsertSchema = z$3.object({
|
|
12496
|
+
id: z$3.uuid().optional(),
|
|
12497
|
+
partyId: z$3.uuid(),
|
|
12498
|
+
internalId: z$3.string().optional().nullable(),
|
|
12499
|
+
ruianCode: z$3.string().optional().nullable(),
|
|
12500
|
+
addressType: z$3.enum(AddressTypeZod),
|
|
12501
|
+
street: z$3.string().optional().nullable(),
|
|
12502
|
+
orientationNumber: z$3.string().optional().nullable(),
|
|
12503
|
+
descriptiveNumber: z$3.string().optional().nullable(),
|
|
12504
|
+
municipality: z$3.string(),
|
|
12505
|
+
municipalityPart: z$3.string().optional().nullable(),
|
|
12506
|
+
zipCode: z$3.string(),
|
|
12507
|
+
district: z$3.string().optional().nullable(),
|
|
12508
|
+
region: z$3.string().optional().nullable(),
|
|
12509
|
+
countryCode: z$3.enum(COUNTRY_CODES_2)
|
|
12510
|
+
});
|
|
12511
|
+
const addressUpdateSchema = z$3.object({
|
|
12512
|
+
id: z$3.uuid(),
|
|
12513
|
+
partyId: z$3.uuid().optional(),
|
|
12514
|
+
internalId: z$3.string().optional().nullable(),
|
|
12515
|
+
ruianCode: z$3.string().optional().nullable(),
|
|
12516
|
+
addressType: z$3.enum(AddressTypeZod).optional(),
|
|
12517
|
+
street: z$3.string().optional().nullable(),
|
|
12518
|
+
orientationNumber: z$3.string().optional().nullable(),
|
|
12519
|
+
descriptiveNumber: z$3.string().optional().nullable(),
|
|
12520
|
+
municipality: z$3.string().optional(),
|
|
12521
|
+
municipalityPart: z$3.string().optional().nullable(),
|
|
12522
|
+
zipCode: z$3.string().optional(),
|
|
12523
|
+
district: z$3.string().optional().nullable(),
|
|
12524
|
+
region: z$3.string().optional().nullable(),
|
|
12525
|
+
countryCode: z$3.enum(COUNTRY_CODES_2).optional(),
|
|
12526
|
+
createdAt: z$3.coerce.date().nullable().optional()
|
|
12527
|
+
});
|
|
12528
|
+
const addressSelectSchema = z$3.object({
|
|
12529
|
+
id: z$3.uuid(),
|
|
12530
|
+
partyId: z$3.uuid(),
|
|
12531
|
+
internalId: z$3.string().nullable(),
|
|
12532
|
+
ruianCode: z$3.string().nullable(),
|
|
12533
|
+
addressType: z$3.enum(AddressTypeZod),
|
|
12534
|
+
street: z$3.string().nullable(),
|
|
12535
|
+
orientationNumber: z$3.string().nullable(),
|
|
12536
|
+
descriptiveNumber: z$3.string().nullable(),
|
|
12537
|
+
municipality: z$3.string(),
|
|
12538
|
+
municipalityPart: z$3.string().nullable(),
|
|
12539
|
+
zipCode: z$3.string(),
|
|
12540
|
+
district: z$3.string().nullable(),
|
|
12541
|
+
region: z$3.string().nullable(),
|
|
12542
|
+
countryCode: z$3.enum(COUNTRY_CODES_2),
|
|
12543
|
+
createdAt: z$3.coerce.date().nullable(),
|
|
12544
|
+
updatedAt: z$3.coerce.date().nullable()
|
|
12545
|
+
});
|
|
12546
|
+
|
|
12547
|
+
createInsertSchema(aml);
|
|
12548
|
+
createUpdateSchema(aml);
|
|
12549
|
+
const amlBaseSelectSchema = createSelectSchema(aml);
|
|
12550
|
+
const amlInsertSchema = z$3.object({
|
|
12551
|
+
partyId: z$3.uuid(),
|
|
12552
|
+
internalId: z$3.string().optional().nullable(),
|
|
12553
|
+
sourceOfWealth: z$3.string(),
|
|
12554
|
+
yearlyIncome: z$3.string(),
|
|
12555
|
+
tradesPurpose: z$3.string().optional().nullable(),
|
|
12556
|
+
sourceOfIncome: z$3.string(),
|
|
12557
|
+
transactionType: z$3.string().optional().nullable(),
|
|
12558
|
+
transactionTypeExpiry: z$3.date().optional().nullable(),
|
|
12559
|
+
isDistraint: z$3.boolean().default(false),
|
|
12560
|
+
estTxsVolumeMonth: z$3.string(),
|
|
12561
|
+
estTxsVolumeYear: z$3.string(),
|
|
12562
|
+
tradingCountries: z$3.string(),
|
|
12563
|
+
tradingSide: z$3.string(),
|
|
12564
|
+
acceptedAMLTermsAndConditions: z$3.boolean(),
|
|
12565
|
+
signatureMethod: z$3.string().nullable().optional(),
|
|
12566
|
+
existencePeriod: z$3.string().nullable().optional(),
|
|
12567
|
+
reputation: z$3.string().nullable().optional(),
|
|
12568
|
+
riskLevel: z$3.enum(AmlScoreTypeZod).nullable().optional(),
|
|
12569
|
+
kycStatus: z$3.enum(KycStatusZod).nullable().optional()
|
|
12570
|
+
});
|
|
12571
|
+
const amlUpdateSchema = z$3.object({
|
|
12572
|
+
id: z$3.uuid(),
|
|
12573
|
+
partyId: z$3.uuid().optional(),
|
|
12574
|
+
internalId: z$3.string().optional().nullable(),
|
|
12575
|
+
sourceOfWealth: z$3.string().optional(),
|
|
12576
|
+
yearlyIncome: z$3.string().optional(),
|
|
12577
|
+
tradesPurpose: z$3.string().optional().nullable(),
|
|
12578
|
+
sourceOfIncome: z$3.string().optional(),
|
|
12579
|
+
transactionType: z$3.string().optional().nullable(),
|
|
12580
|
+
transactionTypeExpiry: z$3.date().optional().nullable(),
|
|
12581
|
+
isDistraint: z$3.boolean().optional(),
|
|
12582
|
+
estTxsVolumeMonth: z$3.string(),
|
|
12583
|
+
estTxsVolumeYear: z$3.string(),
|
|
12584
|
+
tradingCountries: z$3.string(),
|
|
12585
|
+
tradingSide: z$3.string(),
|
|
12586
|
+
acceptedAMLTermsAndConditions: z$3.boolean(),
|
|
12587
|
+
signatureMethod: z$3.string().nullable().optional(),
|
|
12588
|
+
existencePeriod: z$3.string().nullable().optional(),
|
|
12589
|
+
reputation: z$3.string().nullable().optional(),
|
|
12590
|
+
riskLevel: z$3.enum(AmlScoreTypeZod).nullable().optional(),
|
|
12591
|
+
kycStatus: z$3.enum(KycStatusZod).nullable().optional()
|
|
12592
|
+
});
|
|
12593
|
+
const amlSelectSchema = amlBaseSelectSchema;
|
|
12594
|
+
|
|
12595
|
+
const bankAccountBaseInsertSchema = createInsertSchema(bankAccount);
|
|
12596
|
+
createUpdateSchema(bankAccount);
|
|
12597
|
+
createSelectSchema(bankAccount);
|
|
12598
|
+
const bankAccountUpdateSchema = bankAccountBaseInsertSchema.extend({ partyId: z$3.uuid() }).omit({});
|
|
12599
|
+
const bankAccountInsertSchema = bankAccountUpdateSchema.omit({
|
|
12600
|
+
id: true
|
|
12601
|
+
});
|
|
12602
|
+
const bankAccountUpsertSchema = bankAccountBaseInsertSchema.required({
|
|
12603
|
+
id: true
|
|
12604
|
+
});
|
|
12605
|
+
const bankAccountSelectSchema = bankAccountUpdateSchema.required();
|
|
12606
|
+
z$3.array(bankAccountSelectSchema);
|
|
12607
|
+
|
|
12608
|
+
createInsertSchema(contact);
|
|
12609
|
+
createUpdateSchema(contact);
|
|
12610
|
+
createSelectSchema(contact);
|
|
12611
|
+
const contactInsertSchema = z$3.object({
|
|
12612
|
+
partyId: z$3.uuid(),
|
|
12613
|
+
internalId: z$3.string().optional().nullable(),
|
|
12614
|
+
contactType: z$3.enum(ContactTypeZod).optional(),
|
|
12615
|
+
email: z$3.email("Invalid email format"),
|
|
12616
|
+
phoneNumber: z$3.string()
|
|
12617
|
+
});
|
|
12618
|
+
const contactUpdateSchema = z$3.object({
|
|
12619
|
+
id: z$3.uuid(),
|
|
12620
|
+
partyId: z$3.uuid().optional(),
|
|
12621
|
+
internalId: z$3.string().optional().nullable(),
|
|
12622
|
+
contactType: z$3.enum(ContactTypeZod).optional(),
|
|
12623
|
+
email: z$3.email("Invalid email format").optional(),
|
|
12624
|
+
phoneNumber: z$3.string().optional()
|
|
12625
|
+
});
|
|
12626
|
+
|
|
12627
|
+
createInsertSchema(individual);
|
|
12628
|
+
createUpdateSchema(individual);
|
|
12629
|
+
createSelectSchema(individual);
|
|
12630
|
+
const individualInsertSchema$1 = z$3.object({
|
|
12631
|
+
partyId: z$3.uuid(),
|
|
12632
|
+
name: z$3.string(),
|
|
12633
|
+
surname: z$3.string(),
|
|
12634
|
+
email: z$3.email("Invalid email format").optional().nullable(),
|
|
12635
|
+
phone: z$3.string().optional().nullable(),
|
|
12636
|
+
birthDate: z$3.string().optional().nullable(),
|
|
12637
|
+
birthPlace: z$3.string(),
|
|
12638
|
+
countryOfBirth: z$3.enum(COUNTRY_CODES_2).optional().nullable(),
|
|
12639
|
+
personalId: z$3.string(),
|
|
12640
|
+
gender: z$3.enum(GenderZod),
|
|
12641
|
+
citizenship: z$3.enum(COUNTRY_CODES_2),
|
|
12642
|
+
citizenshipOther: z$3.enum(COUNTRY_CODES_2).optional().nullable(),
|
|
12643
|
+
employer: z$3.string().optional().nullable(),
|
|
12644
|
+
employerCountry: z$3.enum(COUNTRY_CODES_2).optional().nullable(),
|
|
12645
|
+
registeredNumber: z$3.string(),
|
|
12646
|
+
isPep: z$3.boolean(),
|
|
12647
|
+
titleBefore: z$3.string().optional().nullable(),
|
|
12648
|
+
titleAfter: z$3.string().optional().nullable(),
|
|
12649
|
+
birthSurname: z$3.string().optional().nullable(),
|
|
12650
|
+
vocativeTitle: z$3.string().optional().nullable(),
|
|
12651
|
+
deathDate: z$3.date().optional().nullable(),
|
|
12652
|
+
deathNotification: z$3.date().optional().nullable(),
|
|
12653
|
+
pin: z$3.string().optional().nullable(),
|
|
12654
|
+
stayAbroad: z$3.boolean().optional().nullable(),
|
|
12655
|
+
stayAbroadCountries: z$3.enum(COUNTRY_CODES_2).optional().nullable()
|
|
12656
|
+
});
|
|
12657
|
+
const individualUpdateSchema$1 = z$3.object({
|
|
12658
|
+
partyId: z$3.uuid(),
|
|
12659
|
+
id: z$3.uuid(),
|
|
12660
|
+
name: z$3.string().optional(),
|
|
12661
|
+
surname: z$3.string().optional(),
|
|
12662
|
+
email: z$3.email("Invalid email format").optional().nullable(),
|
|
12663
|
+
phone: z$3.string().optional().nullable(),
|
|
12664
|
+
birthDate: z$3.string().optional().nullable(),
|
|
12665
|
+
birthPlace: z$3.string().optional(),
|
|
12666
|
+
countryOfBirth: z$3.enum(COUNTRY_CODES_2).optional().nullable(),
|
|
12667
|
+
personalId: z$3.string().optional(),
|
|
12668
|
+
gender: z$3.enum(GenderZod).optional(),
|
|
12669
|
+
citizenship: z$3.enum(COUNTRY_CODES_2).optional(),
|
|
12670
|
+
citizenshipOther: z$3.enum(COUNTRY_CODES_2).optional().nullable(),
|
|
12671
|
+
employer: z$3.string().optional().nullable(),
|
|
12672
|
+
employerCountry: z$3.enum(COUNTRY_CODES_2).optional().nullable(),
|
|
12673
|
+
registeredNumber: z$3.string().optional(),
|
|
12674
|
+
isPep: z$3.boolean().optional(),
|
|
12675
|
+
titleBefore: z$3.string().optional().nullable(),
|
|
12676
|
+
titleAfter: z$3.string().optional().nullable(),
|
|
12677
|
+
birthSurname: z$3.string().optional().nullable(),
|
|
12678
|
+
vocativeTitle: z$3.string().optional().nullable(),
|
|
12679
|
+
deathDate: z$3.date().optional().nullable(),
|
|
12680
|
+
deathNotification: z$3.date().optional().nullable(),
|
|
12681
|
+
pin: z$3.string().optional().nullable(),
|
|
12682
|
+
stayAbroad: z$3.boolean().optional().nullable(),
|
|
12683
|
+
stayAbroadCountries: z$3.enum(COUNTRY_CODES_2).optional().nullable()
|
|
12684
|
+
});
|
|
12685
|
+
const individualSelectSchema = z$3.object({
|
|
12686
|
+
id: z$3.uuid(),
|
|
12687
|
+
partyId: z$3.uuid(),
|
|
12688
|
+
internalId: z$3.string().nullable(),
|
|
12689
|
+
name: z$3.string(),
|
|
12690
|
+
surname: z$3.string(),
|
|
12691
|
+
email: z$3.string().nullable(),
|
|
12692
|
+
phone: z$3.string().nullable(),
|
|
12693
|
+
birthDate: z$3.string().nullable(),
|
|
12694
|
+
birthPlace: z$3.string(),
|
|
12695
|
+
countryOfBirth: z$3.enum(COUNTRY_CODES_2).nullable(),
|
|
12696
|
+
personalId: z$3.string(),
|
|
12697
|
+
gender: z$3.enum(GenderZod),
|
|
12698
|
+
citizenship: z$3.enum(COUNTRY_CODES_2),
|
|
12699
|
+
citizenshipOther: z$3.enum(COUNTRY_CODES_2).nullable(),
|
|
12700
|
+
employer: z$3.string().nullable(),
|
|
12701
|
+
employerCountry: z$3.enum(COUNTRY_CODES_2).nullable(),
|
|
12702
|
+
registeredNumber: z$3.string(),
|
|
12703
|
+
isPep: z$3.boolean(),
|
|
12704
|
+
titleBefore: z$3.string().nullable(),
|
|
12705
|
+
titleAfter: z$3.string().nullable(),
|
|
12706
|
+
birthSurname: z$3.string().nullable(),
|
|
12707
|
+
vocativeTitle: z$3.string().nullable(),
|
|
12708
|
+
deathDate: z$3.coerce.date().nullable(),
|
|
12709
|
+
deathNotification: z$3.coerce.date().nullable(),
|
|
12710
|
+
pin: z$3.string().nullable(),
|
|
12711
|
+
stayAbroad: z$3.boolean().nullable(),
|
|
12712
|
+
stayAbroadCountries: z$3.enum(COUNTRY_CODES_2).nullable(),
|
|
12713
|
+
createdAt: z$3.coerce.date().nullable(),
|
|
12714
|
+
updatedAt: z$3.coerce.date().nullable()
|
|
12715
|
+
});
|
|
12716
|
+
|
|
12717
|
+
createInsertSchema(organization);
|
|
12718
|
+
createUpdateSchema(organization);
|
|
12719
|
+
createSelectSchema(organization);
|
|
12720
|
+
const organizationInsertSchema = z$3.object({
|
|
12721
|
+
partyId: z$3.uuid(),
|
|
12722
|
+
businessName: z$3.string(),
|
|
12723
|
+
email: z$3.email("Invalid email format").optional().nullable(),
|
|
12724
|
+
phone: z$3.string().optional().nullable(),
|
|
12725
|
+
registeredNumber: z$3.string(),
|
|
12726
|
+
registeredIn: z$3.enum(COUNTRY_CODES_2),
|
|
12727
|
+
operatesIn: z$3.enum(COUNTRY_CODES_2),
|
|
12728
|
+
presentIn: z$3.enum(COUNTRY_CODES_2),
|
|
12729
|
+
monthlyVolumeIn: z$3.number(),
|
|
12730
|
+
monthlyVolumeOut: z$3.number(),
|
|
12731
|
+
ownedBy: z$3.string(),
|
|
12732
|
+
companyObjects: z$3.string(),
|
|
12733
|
+
annualTurnover: z$3.number(),
|
|
12734
|
+
numberOfEmployees: z$3.number().optional().nullable(),
|
|
12735
|
+
prosecuted: z$3.string().optional().nullable(),
|
|
12736
|
+
location: z$3.string().optional().nullable(),
|
|
12737
|
+
fileNumber: z$3.string().optional().nullable(),
|
|
12738
|
+
websiteUrl: z$3.url("Invalid website URL").optional().nullable(),
|
|
12739
|
+
vatPayer: z$3.boolean(),
|
|
12740
|
+
companyObjectsDescription: z$3.string(),
|
|
12741
|
+
turnover3years: z$3.number(),
|
|
12742
|
+
operationCountries: z$3.string(),
|
|
12743
|
+
riskyBusinessType: z$3.string().optional().nullable()
|
|
12744
|
+
});
|
|
12745
|
+
const organizationUpdateSchema$1 = z$3.object({
|
|
12746
|
+
partyId: z$3.uuid().optional(),
|
|
12747
|
+
id: z$3.uuid(),
|
|
12748
|
+
businessName: z$3.string().optional(),
|
|
12749
|
+
email: z$3.email("Invalid email format").optional().nullable(),
|
|
12750
|
+
phone: z$3.string().optional().nullable(),
|
|
12751
|
+
registeredNumber: z$3.string().optional(),
|
|
12752
|
+
registeredIn: z$3.enum(COUNTRY_CODES_2).optional(),
|
|
12753
|
+
operatesIn: z$3.enum(COUNTRY_CODES_2).optional(),
|
|
12754
|
+
presentIn: z$3.enum(COUNTRY_CODES_2).optional(),
|
|
12755
|
+
monthlyVolumeIn: z$3.number().optional(),
|
|
12756
|
+
monthlyVolumeOut: z$3.number().optional(),
|
|
12757
|
+
ownedBy: z$3.string().optional(),
|
|
12758
|
+
companyObjects: z$3.string().optional(),
|
|
12759
|
+
annualTurnover: z$3.number().optional(),
|
|
12760
|
+
numberOfEmployees: z$3.number().optional().nullable(),
|
|
12761
|
+
prosecuted: z$3.string().optional().nullable(),
|
|
12762
|
+
location: z$3.string().optional().nullable(),
|
|
12763
|
+
fileNumber: z$3.string().optional().nullable(),
|
|
12764
|
+
websiteUrl: z$3.url("Invalid website URL").optional().nullable(),
|
|
12765
|
+
vatPayer: z$3.boolean().optional(),
|
|
12766
|
+
companyObjectsDescription: z$3.string(),
|
|
12767
|
+
turnover3years: z$3.number(),
|
|
12768
|
+
operationCountries: z$3.string(),
|
|
12769
|
+
riskyBusinessType: z$3.string().optional().nullable()
|
|
12770
|
+
});
|
|
12771
|
+
const organizationOutputSchema = z$3.object({
|
|
12772
|
+
id: z$3.uuid(),
|
|
12773
|
+
partyId: z$3.uuid(),
|
|
12774
|
+
internalId: z$3.string().nullable(),
|
|
12775
|
+
businessName: z$3.string(),
|
|
12776
|
+
email: z$3.string().nullable(),
|
|
12777
|
+
phone: z$3.string().nullable(),
|
|
12778
|
+
registeredNumber: z$3.string(),
|
|
12779
|
+
registeredIn: z$3.enum(COUNTRY_CODES_2),
|
|
12780
|
+
operatesIn: z$3.enum(COUNTRY_CODES_2),
|
|
12781
|
+
presentIn: z$3.enum(COUNTRY_CODES_2),
|
|
12782
|
+
monthlyVolumeIn: z$3.number(),
|
|
12783
|
+
monthlyVolumeOut: z$3.number(),
|
|
12784
|
+
ownedBy: z$3.string(),
|
|
12785
|
+
companyObjects: z$3.string(),
|
|
12786
|
+
annualTurnover: z$3.number(),
|
|
12787
|
+
numberOfEmployees: z$3.number().nullable(),
|
|
12788
|
+
prosecuted: z$3.string().nullable(),
|
|
12789
|
+
location: z$3.string().nullable(),
|
|
12790
|
+
fileNumber: z$3.string().nullable(),
|
|
12791
|
+
websiteUrl: z$3.string().nullable(),
|
|
12792
|
+
vatPayer: z$3.boolean(),
|
|
12793
|
+
companyObjectsDescription: z$3.string(),
|
|
12794
|
+
turnover3years: z$3.number(),
|
|
12795
|
+
operationCountries: z$3.string(),
|
|
12796
|
+
riskyBusinessType: z$3.string().nullable(),
|
|
12797
|
+
stayAbroad: z$3.boolean().nullable(),
|
|
12798
|
+
stayAbroadCountries: z$3.enum(COUNTRY_CODES_2).nullable(),
|
|
12799
|
+
createdAt: z$3.coerce.date().nullable(),
|
|
12800
|
+
updatedAt: z$3.coerce.date().nullable()
|
|
12801
|
+
});
|
|
12802
|
+
const organizationSelectSchema = organizationOutputSchema;
|
|
12803
|
+
z$3.array(organizationOutputSchema);
|
|
12804
|
+
|
|
12805
|
+
z$3.discriminatedUnion("partyType", [
|
|
12806
|
+
z$3.object({
|
|
12807
|
+
partyType: z$3.literal("INDIVIDUAL"),
|
|
12808
|
+
data: individualInsertSchema$1
|
|
12809
|
+
}),
|
|
12810
|
+
z$3.object({
|
|
12811
|
+
partyType: z$3.literal("ORGANIZATION"),
|
|
12812
|
+
data: organizationInsertSchema
|
|
12813
|
+
})
|
|
12814
|
+
]);
|
|
12815
|
+
const disponentCreateSchema = z$3.discriminatedUnion("partyType", [
|
|
12816
|
+
z$3.object({
|
|
12817
|
+
partyType: z$3.literal("INDIVIDUAL"),
|
|
12818
|
+
data: individualInsertSchema$1.omit({ partyId: true })
|
|
12819
|
+
}),
|
|
12820
|
+
z$3.object({
|
|
12821
|
+
partyType: z$3.literal("ORGANIZATION"),
|
|
12822
|
+
data: organizationInsertSchema.omit({ partyId: true })
|
|
12823
|
+
})
|
|
12824
|
+
]);
|
|
12825
|
+
const disponentUpdateSchema$1 = z$3.discriminatedUnion("partyType", [
|
|
12826
|
+
z$3.object({
|
|
12827
|
+
partyType: z$3.literal("INDIVIDUAL"),
|
|
12828
|
+
data: individualUpdateSchema$1
|
|
12829
|
+
}),
|
|
12830
|
+
z$3.object({
|
|
12831
|
+
partyType: z$3.literal("ORGANIZATION"),
|
|
12832
|
+
data: organizationUpdateSchema$1
|
|
12833
|
+
})
|
|
12834
|
+
]);
|
|
12835
|
+
const disponentSelectSchema = z$3.discriminatedUnion("partyType", [
|
|
12836
|
+
z$3.object({
|
|
12837
|
+
partyType: z$3.literal("INDIVIDUAL"),
|
|
12838
|
+
data: individualSelectSchema
|
|
12839
|
+
}),
|
|
12840
|
+
z$3.object({
|
|
12841
|
+
partyType: z$3.literal("ORGANIZATION"),
|
|
12842
|
+
data: organizationSelectSchema
|
|
12843
|
+
})
|
|
12844
|
+
]);
|
|
12845
|
+
z$3.array(disponentSelectSchema).optional();
|
|
12846
|
+
z$3.array(disponentUpdateSchema$1).optional();
|
|
12847
|
+
|
|
12848
|
+
createInsertSchema(idDocument);
|
|
12849
|
+
createUpdateSchema(idDocument);
|
|
12850
|
+
createSelectSchema(idDocument);
|
|
12851
|
+
const idDocumentInsertSchema = z$3.object({
|
|
12852
|
+
partyId: z$3.uuid(),
|
|
12853
|
+
internalId: z$3.string().optional().nullable(),
|
|
12854
|
+
idDocType: z$3.enum(IdDocTypeZod),
|
|
12855
|
+
idDocNumber: z$3.string(),
|
|
12856
|
+
idDocHolderName: z$3.string(),
|
|
12857
|
+
issueDate: z$3.date().optional().nullable(),
|
|
12858
|
+
expirationDate: z$3.date().optional().nullable(),
|
|
12859
|
+
issuer: z$3.string().optional().nullable(),
|
|
12860
|
+
countryOfIssue: z$3.enum(COUNTRY_CODES_2).optional().nullable(),
|
|
12861
|
+
frontImageUri: z$3.url().optional().nullable(),
|
|
12862
|
+
backImageUri: z$3.url().optional().nullable(),
|
|
12863
|
+
idDocStatus: z$3.enum(IdDocStatusZod).optional().nullable()
|
|
12864
|
+
});
|
|
12865
|
+
const idDocumentUpdateSchema = z$3.object({
|
|
12866
|
+
id: z$3.uuid(),
|
|
12867
|
+
partyId: z$3.uuid().optional(),
|
|
12868
|
+
internalId: z$3.string().optional().nullable(),
|
|
12869
|
+
idDocType: z$3.enum(IdDocTypeZod).optional(),
|
|
12870
|
+
idDocNumber: z$3.string().optional(),
|
|
12871
|
+
idDocHolderName: z$3.string().optional(),
|
|
12872
|
+
issueDate: z$3.date().optional().nullable(),
|
|
12873
|
+
expirationDate: z$3.date().optional().nullable(),
|
|
12874
|
+
issuer: z$3.string().optional().nullable(),
|
|
12875
|
+
countryOfIssue: z$3.enum(COUNTRY_CODES_2).optional().nullable(),
|
|
12876
|
+
frontImageUri: z$3.url("Invalid URL format").optional().nullable(),
|
|
12877
|
+
backImageUri: z$3.url("Invalid URL format").optional().nullable(),
|
|
12878
|
+
idDocStatus: z$3.enum(IdDocStatusZod).optional().nullable()
|
|
12879
|
+
});
|
|
12880
|
+
|
|
12881
|
+
const recipientBaseInsertSchema = createInsertSchema(recipient);
|
|
12882
|
+
createUpdateSchema(recipient);
|
|
12883
|
+
createSelectSchema(recipient);
|
|
12884
|
+
const recipientUpsertSchema = recipientBaseInsertSchema.required({
|
|
12885
|
+
id: true
|
|
12886
|
+
});
|
|
12887
|
+
const recipientInsertSchema = bankAccountInsertSchema;
|
|
12888
|
+
const recipientUpdateSchema = bankAccountUpdateSchema;
|
|
12889
|
+
const recipientSelectSchema = bankAccountSelectSchema;
|
|
12890
|
+
|
|
12891
|
+
createInsertSchema(party);
|
|
12892
|
+
createUpdateSchema(party);
|
|
12893
|
+
const partySchema$2 = z$3.object({
|
|
12894
|
+
partyType: z$3.enum(PartyTypeZod),
|
|
12895
|
+
language: z$3.enum(LANGUAGE_CODES),
|
|
12896
|
+
id: z$3.uuid().nullable(),
|
|
12897
|
+
note: z$3.string().optional(),
|
|
12898
|
+
countryCode: z$3.enum(COUNTRY_CODES_2).optional(),
|
|
12899
|
+
customerStatus: z$3.enum(CustomerStatusZod).optional(),
|
|
12900
|
+
legacyId: z$3.string().optional()
|
|
12901
|
+
});
|
|
12902
|
+
const partyOutputSchema$1 = z$3.object({
|
|
12903
|
+
internalId: z$3.string().nullable(),
|
|
12904
|
+
customerStatus: z$3.enum(CustomerStatusZod),
|
|
12905
|
+
partyType: z$3.enum(PartyTypeZod),
|
|
12906
|
+
language: z$3.enum(LANGUAGE_CODES),
|
|
12907
|
+
id: z$3.uuid(),
|
|
12908
|
+
note: z$3.string().nullable(),
|
|
12909
|
+
countryCode: z$3.enum(COUNTRY_CODES_2).nullable(),
|
|
12910
|
+
isClient: z$3.boolean(),
|
|
12911
|
+
createdAt: z$3.date().nullable(),
|
|
12912
|
+
updatedAt: z$3.date().nullable()
|
|
12913
|
+
});
|
|
12914
|
+
const createPartySchema = partySchema$2.omit({ id: true });
|
|
12915
|
+
z$3.object({
|
|
12916
|
+
party: createPartySchema,
|
|
12917
|
+
personalData: individualInsertSchema$1.omit({ partyId: true }).nullable(),
|
|
12918
|
+
organizationData: organizationInsertSchema.omit({ partyId: true }).nullable(),
|
|
12919
|
+
bankAccounts: z$3.array(bankAccountInsertSchema.omit({ partyId: true })).nullable(),
|
|
12920
|
+
recipients: z$3.array(recipientInsertSchema.omit({ partyId: true })).nullable(),
|
|
12921
|
+
disponents: z$3.array(disponentCreateSchema).nullable(),
|
|
12922
|
+
addresses: z$3.array(addressInsertSchema.omit({ partyId: true })),
|
|
12923
|
+
aml: amlInsertSchema.omit({ partyId: true })
|
|
12924
|
+
});
|
|
12925
|
+
z$3.object({
|
|
12926
|
+
partyId: z$3.uuid(),
|
|
12927
|
+
party: partySchema$2,
|
|
12928
|
+
personalData: individualUpdateSchema$1.optional(),
|
|
12929
|
+
organizationData: organizationUpdateSchema$1.optional(),
|
|
12930
|
+
bankAccounts: z$3.array(bankAccountUpsertSchema).optional(),
|
|
12931
|
+
recipients: z$3.array(recipientUpsertSchema).optional(),
|
|
12932
|
+
disponents: z$3.array(disponentUpdateSchema$1).optional(),
|
|
12933
|
+
addresses: z$3.array(addressUpdateSchema).optional(),
|
|
12934
|
+
aml: amlUpdateSchema.optional()
|
|
12935
|
+
});
|
|
12936
|
+
const partySelectOutputSchema = z$3.object({
|
|
12937
|
+
party: partyOutputSchema$1.nullable(),
|
|
12938
|
+
personalData: individualSelectSchema.nullable(),
|
|
12939
|
+
organizationData: organizationSelectSchema.nullable(),
|
|
12940
|
+
aml: amlSelectSchema.nullable(),
|
|
12941
|
+
bankAccounts: z$3.array(bankAccountSelectSchema).nullable(),
|
|
12942
|
+
disponents: z$3.array(disponentSelectSchema).nullable(),
|
|
12943
|
+
addresses: z$3.array(addressSelectSchema).nullable(),
|
|
12944
|
+
recipients: z$3.array(recipientSelectSchema).nullable()
|
|
12945
|
+
});
|
|
12946
|
+
z$3.array(partySelectOutputSchema);
|
|
12947
|
+
const partySelectDataSchema = z$3.object({
|
|
12948
|
+
party: partyOutputSchema$1.nullable(),
|
|
12949
|
+
personalData: individualSelectSchema.nullable(),
|
|
12950
|
+
organizationData: organizationSelectSchema.nullable(),
|
|
12951
|
+
aml: amlSelectSchema.nullable()
|
|
12952
|
+
});
|
|
12953
|
+
const partySelectArrayDataSchema = z$3.object({
|
|
12954
|
+
bankAccounts: z$3.array(bankAccountSelectSchema).nullable(),
|
|
12955
|
+
addresses: z$3.array(addressSelectSchema).nullable(),
|
|
12956
|
+
disponents: z$3.array(disponentSelectSchema).nullable(),
|
|
12957
|
+
recipients: z$3.array(recipientSelectSchema).nullable()
|
|
12958
|
+
});
|
|
12959
|
+
z$3.object({
|
|
12960
|
+
...partySelectDataSchema.shape,
|
|
12961
|
+
...partySelectArrayDataSchema.shape
|
|
12962
|
+
});
|
|
12963
|
+
|
|
12964
|
+
createInsertSchema(partyChange);
|
|
12965
|
+
createUpdateSchema(partyChange);
|
|
12966
|
+
createSelectSchema(partyChange);
|
|
12967
|
+
z$3.object({
|
|
12968
|
+
partyId: z$3.uuid().optional().nullable(),
|
|
12969
|
+
internalId: z$3.string().optional().nullable(),
|
|
12970
|
+
operation: z$3.string(),
|
|
12971
|
+
diff: z$3.json(),
|
|
12972
|
+
snapshotBefore: z$3.json(),
|
|
12973
|
+
snapshotAfter: z$3.json()
|
|
12974
|
+
});
|
|
12975
|
+
z$3.object({
|
|
12976
|
+
id: z$3.uuid(),
|
|
12977
|
+
partyId: z$3.uuid().optional().nullable(),
|
|
12978
|
+
internalId: z$3.string().optional().nullable(),
|
|
12979
|
+
operation: z$3.string().optional(),
|
|
12980
|
+
diff: z$3.json().optional(),
|
|
12981
|
+
snapshotBefore: z$3.json().optional(),
|
|
12982
|
+
snapshotAfter: z$3.json().optional()
|
|
12983
|
+
});
|
|
12984
|
+
|
|
12985
|
+
createInsertSchema(partyRelationship);
|
|
12986
|
+
createUpdateSchema(partyRelationship);
|
|
12987
|
+
createSelectSchema(partyRelationship);
|
|
12988
|
+
z$3.object({
|
|
12989
|
+
relationshipType: z$3.enum(PartyRelationshipTypeZod).optional(),
|
|
12990
|
+
frompartyId: z$3.uuid().optional().nullable(),
|
|
12991
|
+
internalId: z$3.string().optional().nullable(),
|
|
12992
|
+
topartyId: z$3.uuid().optional().nullable(),
|
|
12993
|
+
fromDate: z$3.date().optional().nullable(),
|
|
12994
|
+
sharePercentage: z$3.number().max(100).optional().nullable()
|
|
12995
|
+
});
|
|
12996
|
+
z$3.object({
|
|
12997
|
+
id: z$3.uuid(),
|
|
12998
|
+
relationshipType: z$3.enum(PartyRelationshipTypeZod).optional(),
|
|
12999
|
+
frompartyId: z$3.uuid().optional().nullable(),
|
|
13000
|
+
internalId: z$3.string().optional().nullable(),
|
|
13001
|
+
topartyId: z$3.uuid().optional().nullable(),
|
|
13002
|
+
fromDate: z$3.date().optional().nullable(),
|
|
13003
|
+
sharePercentage: z$3.number().max(100).optional().nullable()
|
|
13004
|
+
});
|
|
13005
|
+
|
|
13006
|
+
createInsertSchema(taxResidence);
|
|
13007
|
+
createUpdateSchema(taxResidence);
|
|
13008
|
+
createSelectSchema(taxResidence);
|
|
13009
|
+
z$3.object({
|
|
13010
|
+
partyId: z$3.uuid(),
|
|
13011
|
+
country: z$3.enum(COUNTRY_CODES_2),
|
|
13012
|
+
taxIdentificationNumber: z$3.string()
|
|
13013
|
+
});
|
|
13014
|
+
z$3.object({
|
|
13015
|
+
id: z$3.uuid(),
|
|
13016
|
+
partyId: z$3.uuid().optional(),
|
|
13017
|
+
country: z$3.enum(COUNTRY_CODES_2).optional(),
|
|
13018
|
+
taxIdentificationNumber: z$3.string().optional()
|
|
13019
|
+
});
|
|
13020
|
+
|
|
13021
|
+
createInsertSchema(trader);
|
|
13022
|
+
createUpdateSchema(trader);
|
|
13023
|
+
createSelectSchema(trader);
|
|
13024
|
+
const traderInsertSchema = z$3.object({
|
|
13025
|
+
type: z$3.enum(TRADER_TYPE),
|
|
13026
|
+
commission: z$3.number(),
|
|
13027
|
+
firstName: z$3.string().optional(),
|
|
13028
|
+
lastName: z$3.string().optional(),
|
|
13029
|
+
companyName: z$3.string().optional(),
|
|
13030
|
+
ico: z$3.string().optional(),
|
|
13031
|
+
dic: z$3.string().optional(),
|
|
13032
|
+
legacyId: z$3.string().optional()
|
|
13033
|
+
});
|
|
13034
|
+
const traderUpdateSchema = z$3.object({
|
|
13035
|
+
id: z$3.uuid(),
|
|
13036
|
+
type: z$3.enum(TRADER_TYPE).optional(),
|
|
13037
|
+
commission: z$3.number().optional(),
|
|
13038
|
+
internalId: z$3.string().optional(),
|
|
13039
|
+
firstName: z$3.string().optional(),
|
|
13040
|
+
lastName: z$3.string().optional(),
|
|
13041
|
+
companyName: z$3.string().optional(),
|
|
13042
|
+
ico: z$3.string().optional(),
|
|
13043
|
+
dic: z$3.string().optional(),
|
|
13044
|
+
legacyId: z$3.string().optional()
|
|
13045
|
+
});
|
|
13046
|
+
z$3.object({
|
|
13047
|
+
id: z$3.uuid(),
|
|
13048
|
+
createdAt: z$3.coerce.date().nullable(),
|
|
13049
|
+
updatedAt: z$3.coerce.date().nullable(),
|
|
13050
|
+
deletedAt: z$3.coerce.date().nullable(),
|
|
13051
|
+
type: z$3.enum(TRADER_TYPE),
|
|
13052
|
+
commission: z$3.number(),
|
|
13053
|
+
internalId: z$3.string().nullable(),
|
|
13054
|
+
firstName: z$3.string().nullable(),
|
|
13055
|
+
lastName: z$3.string().nullable(),
|
|
13056
|
+
companyName: z$3.string().nullable(),
|
|
13057
|
+
ico: z$3.string().nullable(),
|
|
13058
|
+
dic: z$3.string().nullable(),
|
|
13059
|
+
legacyId: z$3.string().nullable()
|
|
13060
|
+
});
|
|
13061
|
+
|
|
13062
|
+
z$2.object({
|
|
13063
|
+
recipient: recipientInsertSchema,
|
|
13064
|
+
partyId: z$2.string().uuid()
|
|
13065
|
+
});
|
|
13066
|
+
|
|
13067
|
+
z$2.object({
|
|
13068
|
+
recipient: recipientUpdateSchema
|
|
13069
|
+
});
|
|
13070
|
+
|
|
13071
|
+
z$2.object({
|
|
13072
|
+
id: z$2.uuid()
|
|
13073
|
+
});
|
|
13074
|
+
|
|
13075
|
+
const ALLOWED_RECIPIENTS_FILTERS = {
|
|
13076
|
+
NAME: "filterRecipientName",
|
|
13077
|
+
BANK_CODE: "filterRecipientBankCode",
|
|
13078
|
+
CURRENCY: "filterRecipientCurrency"
|
|
13079
|
+
};
|
|
13080
|
+
z$2.object({
|
|
13081
|
+
page: z$2.number().positive(),
|
|
13082
|
+
limit: z$2.number().positive(),
|
|
13083
|
+
sort: z$2.object({
|
|
13084
|
+
column: z$2.string(),
|
|
13085
|
+
direction: z$2.enum(["asc", "desc"])
|
|
13086
|
+
}),
|
|
13087
|
+
[ALLOWED_RECIPIENTS_FILTERS.NAME]: z$2.union([z$2.string(), z$2.string().array()]).optional(),
|
|
13088
|
+
[ALLOWED_RECIPIENTS_FILTERS.BANK_CODE]: z$2.union([z$2.enum(BANK_CODES), z$2.enum(BANK_CODES).array()]).optional(),
|
|
13089
|
+
[ALLOWED_RECIPIENTS_FILTERS.CURRENCY]: z$2.union([z$2.enum(CURRENCY_CODES), z$2.enum(CURRENCY_CODES).array()]).optional(),
|
|
13090
|
+
search: z$2.string().optional()
|
|
13091
|
+
});
|
|
13092
|
+
|
|
13093
|
+
z$2.object({
|
|
13094
|
+
id: z$2.uuid()
|
|
13095
|
+
});
|
|
13096
|
+
|
|
13097
|
+
z$2.object({
|
|
13098
|
+
trader: traderInsertSchema
|
|
13099
|
+
});
|
|
13100
|
+
|
|
13101
|
+
z$2.object({
|
|
13102
|
+
trader: traderUpdateSchema
|
|
13103
|
+
});
|
|
13104
|
+
|
|
13105
|
+
z$2.object({
|
|
13106
|
+
id: z$2.uuid()
|
|
13107
|
+
});
|
|
13108
|
+
|
|
13109
|
+
z$2.object({
|
|
13110
|
+
page: z$2.number().positive(),
|
|
13111
|
+
limit: z$2.number().positive(),
|
|
13112
|
+
sort: z$2.object({
|
|
13113
|
+
column: z$2.string(),
|
|
13114
|
+
direction: z$2.enum(["asc", "desc"])
|
|
13115
|
+
}),
|
|
13116
|
+
search: z$2.string().optional(),
|
|
13117
|
+
ids: z$2.array(z$2.uuid()).optional()
|
|
13118
|
+
});
|
|
13119
|
+
|
|
13120
|
+
z$2.object({
|
|
13121
|
+
id: z$2.uuid()
|
|
13122
|
+
});
|
|
13123
|
+
|
|
13124
|
+
z$2.object({
|
|
13125
|
+
traderId: z$2.uuid(),
|
|
13126
|
+
clientId: z$2.uuid()
|
|
13127
|
+
});
|
|
13128
|
+
z$2.object({
|
|
13129
|
+
id: z$2.uuid()
|
|
13130
|
+
});
|
|
13131
|
+
|
|
13132
|
+
z$2.object({
|
|
13133
|
+
id: z$2.uuid()
|
|
13134
|
+
});
|
|
13135
|
+
|
|
13136
|
+
z$2.object({
|
|
13137
|
+
bankAccount: bankAccountInsertSchema,
|
|
13138
|
+
partyId: z$2.string().uuid()
|
|
13139
|
+
});
|
|
13140
|
+
|
|
13141
|
+
z$2.object({
|
|
13142
|
+
bankAccount: bankAccountUpsertSchema
|
|
13143
|
+
});
|
|
13144
|
+
|
|
13145
|
+
z$2.object({
|
|
13146
|
+
id: z$2.uuid()
|
|
13147
|
+
});
|
|
13148
|
+
|
|
13149
|
+
z$2.object({
|
|
13150
|
+
id: z$2.uuid()
|
|
13151
|
+
});
|
|
13152
|
+
|
|
13153
|
+
z$2.object({
|
|
13154
|
+
address: addressInsertSchema,
|
|
13155
|
+
partyId: z$2.uuid()
|
|
13156
|
+
});
|
|
13157
|
+
|
|
13158
|
+
z$2.object({
|
|
13159
|
+
address: addressUpdateSchema
|
|
13160
|
+
});
|
|
13161
|
+
|
|
13162
|
+
z$2.object({
|
|
13163
|
+
id: z$2.uuid()
|
|
13164
|
+
});
|
|
13165
|
+
|
|
13166
|
+
z$2.object({
|
|
13167
|
+
contact: contactInsertSchema,
|
|
13168
|
+
partyId: z$2.string().uuid()
|
|
13169
|
+
});
|
|
13170
|
+
|
|
13171
|
+
z$2.object({
|
|
13172
|
+
contact: contactUpdateSchema
|
|
13173
|
+
});
|
|
13174
|
+
|
|
13175
|
+
z$2.object({
|
|
13176
|
+
idDocument: idDocumentInsertSchema,
|
|
13177
|
+
partyId: z$2.string()
|
|
13178
|
+
});
|
|
13179
|
+
|
|
13180
|
+
z$2.object({
|
|
13181
|
+
idDocument: idDocumentUpdateSchema
|
|
13182
|
+
});
|
|
13183
|
+
|
|
13184
|
+
z$2.object({
|
|
13185
|
+
id: z$2.uuid()
|
|
13186
|
+
});
|
|
13187
|
+
|
|
13188
|
+
const ALLOWED_ID_DOCUMENTS_FILTERS$1 = {
|
|
13189
|
+
PARTY_ID: "filterIdDocumentPartyId",
|
|
13190
|
+
ISSUER: "filterIdDocumentIssuer"
|
|
13191
|
+
};
|
|
13192
|
+
z$2.object({
|
|
13193
|
+
pagination: z$2.object({
|
|
13194
|
+
page: z$2.number().positive(),
|
|
13195
|
+
limit: z$2.number().positive(),
|
|
13196
|
+
sort: z$2.object({
|
|
13197
|
+
column: z$2.string(),
|
|
13198
|
+
direction: z$2.enum(["asc", "desc"])
|
|
13199
|
+
}),
|
|
13200
|
+
[ALLOWED_ID_DOCUMENTS_FILTERS$1.PARTY_ID]: z$2.union([z$2.uuid(), z$2.uuid().array()]).optional(),
|
|
13201
|
+
[ALLOWED_ID_DOCUMENTS_FILTERS$1.ISSUER]: z$2.union([z$2.string(), z$2.string().array()]).optional(),
|
|
13202
|
+
search: z$2.string().optional()
|
|
13203
|
+
})
|
|
13204
|
+
});
|
|
13205
|
+
|
|
13206
|
+
z$2.object({
|
|
13207
|
+
id: z$2.uuid()
|
|
13208
|
+
});
|
|
13209
|
+
|
|
13210
|
+
z$2.object({
|
|
13211
|
+
id: z$2.uuid()
|
|
13212
|
+
});
|
|
13213
|
+
|
|
13214
|
+
z$2.object({
|
|
13215
|
+
organization: organizationInsertSchema
|
|
13216
|
+
});
|
|
13217
|
+
|
|
13218
|
+
z$2.object({
|
|
13219
|
+
organization: organizationInsertSchema
|
|
13220
|
+
});
|
|
13221
|
+
|
|
13222
|
+
z$2.object({
|
|
13223
|
+
id: z$2.uuid()
|
|
13224
|
+
});
|
|
13225
|
+
|
|
13226
|
+
z$2.object({
|
|
13227
|
+
id: z$2.uuid()
|
|
13228
|
+
});
|
|
13229
|
+
|
|
13230
|
+
z$2.object({
|
|
13231
|
+
individual: individualInsertSchema$1
|
|
13232
|
+
});
|
|
13233
|
+
|
|
13234
|
+
z$2.object({
|
|
13235
|
+
individual: individualInsertSchema$1
|
|
13236
|
+
});
|
|
13237
|
+
|
|
13238
|
+
z$2.object({
|
|
13239
|
+
id: z$2.uuid()
|
|
13240
|
+
});
|
|
13241
|
+
|
|
13242
|
+
z$2.object({
|
|
13243
|
+
id: z$2.uuid()
|
|
13244
|
+
});
|
|
13245
|
+
|
|
13246
|
+
z$2.object({
|
|
13247
|
+
aml: amlInsertSchema
|
|
13248
|
+
});
|
|
13249
|
+
|
|
13250
|
+
z$2.object({
|
|
13251
|
+
aml: amlInsertSchema
|
|
13252
|
+
});
|
|
13253
|
+
|
|
13254
|
+
z$2.object({
|
|
13255
|
+
id: z$2.uuid()
|
|
13256
|
+
});
|
|
13257
|
+
|
|
13258
|
+
const routeError = z$3.object({
|
|
13259
|
+
message: z$3.string(),
|
|
13260
|
+
data: z$3.null(),
|
|
13261
|
+
errorDetail: z$3.object({
|
|
13262
|
+
message: z$3.string(),
|
|
13263
|
+
code: z$3.number()
|
|
13264
|
+
}).optional(),
|
|
13265
|
+
error: z$3.boolean()
|
|
13266
|
+
});
|
|
13267
|
+
const errorResponse = (entityName, action = "creation") => ({
|
|
13268
|
+
404: {
|
|
13269
|
+
content: {
|
|
13270
|
+
"application/json": {
|
|
13271
|
+
schema: z$3.object({
|
|
13272
|
+
message: z$3.string(),
|
|
13273
|
+
stackTrace: z$3.string().optional()
|
|
13274
|
+
})
|
|
13275
|
+
}
|
|
13276
|
+
},
|
|
13277
|
+
description: `Not Found. This can occur when the ${entityName} is not found.`
|
|
13278
|
+
},
|
|
13279
|
+
500: {
|
|
13280
|
+
content: {
|
|
13281
|
+
"application/json": {
|
|
13282
|
+
schema: z$3.object({
|
|
13283
|
+
message: z$3.string(),
|
|
13284
|
+
stackTrace: z$3.string().optional()
|
|
13285
|
+
})
|
|
13286
|
+
}
|
|
13287
|
+
},
|
|
13288
|
+
description: `Internal Server Error. This can occur when the ${entityName} ${action} fails.`
|
|
13289
|
+
}
|
|
13290
|
+
});
|
|
13291
|
+
|
|
13292
|
+
const partySchema$1 = z$3.object({
|
|
13293
|
+
partyType: z$3.enum(PartyTypeZod),
|
|
13294
|
+
language: z$3.enum(LANGUAGE_CODES),
|
|
13295
|
+
id: z$3.uuid(),
|
|
13296
|
+
internalId: z$3.string().optional(),
|
|
13297
|
+
note: z$3.string().optional(),
|
|
13298
|
+
countryCode: z$3.enum(COUNTRY_CODES_2).optional()
|
|
13299
|
+
});
|
|
13300
|
+
const individualInsertSchema = z$3.object({
|
|
13301
|
+
internalId: z$3.string().optional(),
|
|
13302
|
+
name: z$3.string(),
|
|
13303
|
+
surname: z$3.string(),
|
|
13304
|
+
email: z$3.string().optional(),
|
|
13305
|
+
phone: z$3.string().optional(),
|
|
13306
|
+
birthDate: z$3.string().optional(),
|
|
13307
|
+
birthPlace: z$3.string(),
|
|
13308
|
+
countryOfBirth: z$3.enum(COUNTRY_CODES_2).optional(),
|
|
13309
|
+
personalId: z$3.string(),
|
|
13310
|
+
gender: z$3.enum(GenderZod),
|
|
13311
|
+
citizenship: z$3.enum(COUNTRY_CODES_2),
|
|
13312
|
+
citizenshipOther: z$3.enum(COUNTRY_CODES_2).optional(),
|
|
13313
|
+
employer: z$3.string().optional(),
|
|
13314
|
+
employerCountry: z$3.enum(COUNTRY_CODES_2).optional(),
|
|
13315
|
+
registeredNumber: z$3.string(),
|
|
13316
|
+
isPep: z$3.boolean(),
|
|
13317
|
+
titleBefore: z$3.string().optional(),
|
|
13318
|
+
titleAfter: z$3.string().optional(),
|
|
13319
|
+
birthSurname: z$3.string().optional(),
|
|
13320
|
+
vocativeTitle: z$3.string().optional(),
|
|
13321
|
+
deathDate: z$3.date().optional(),
|
|
13322
|
+
deathNotification: z$3.date().optional(),
|
|
13323
|
+
pin: z$3.string().optional(),
|
|
13324
|
+
stayAbroad: z$3.boolean().optional(),
|
|
13325
|
+
stayAbroadCountries: z$3.enum(COUNTRY_CODES_2).optional()
|
|
13326
|
+
});
|
|
13327
|
+
const createOrganizationInputSchema = z$3.object({
|
|
13328
|
+
internalId: z$3.string().optional(),
|
|
13329
|
+
businessName: z$3.string(),
|
|
13330
|
+
email: z$3.string().optional(),
|
|
13331
|
+
phone: z$3.string().optional(),
|
|
13332
|
+
registeredNumber: z$3.string(),
|
|
13333
|
+
registeredIn: z$3.enum(COUNTRY_CODES_2),
|
|
13334
|
+
operatesIn: z$3.enum(COUNTRY_CODES_2),
|
|
13335
|
+
presentIn: z$3.enum(COUNTRY_CODES_2),
|
|
13336
|
+
monthlyVolumeIn: z$3.number(),
|
|
13337
|
+
monthlyVolumeOut: z$3.number(),
|
|
13338
|
+
ownedBy: z$3.string(),
|
|
13339
|
+
companyObjects: z$3.string(),
|
|
13340
|
+
annualTurnover: z$3.number(),
|
|
13341
|
+
numberOfEmployees: z$3.number(),
|
|
13342
|
+
prosecuted: z$3.string().optional(),
|
|
13343
|
+
location: z$3.string().optional(),
|
|
13344
|
+
fileNumber: z$3.string().optional(),
|
|
13345
|
+
websiteUrl: z$3.string().optional(),
|
|
13346
|
+
vatPayer: z$3.boolean(),
|
|
13347
|
+
companyObjectsDescription: z$3.string(),
|
|
13348
|
+
turnover3years: z$3.number(),
|
|
13349
|
+
operationCountries: z$3.string(),
|
|
13350
|
+
riskyBusinessType: z$3.string().optional()
|
|
13351
|
+
});
|
|
13352
|
+
const updateBankAccountSchema$1 = z$3.object({
|
|
11904
13353
|
...bankAccountMetadataSchema.shape,
|
|
11905
|
-
partyId: z$
|
|
11906
|
-
internalId: z$
|
|
11907
|
-
holderName: z$
|
|
11908
|
-
number: z$
|
|
13354
|
+
partyId: z$3.uuid(),
|
|
13355
|
+
internalId: z$3.string().optional(),
|
|
13356
|
+
holderName: z$3.string(),
|
|
13357
|
+
number: z$3.string().optional(),
|
|
11909
13358
|
currency: bankAccountMetadataSchema.shape.currency.nonoptional(),
|
|
11910
13359
|
countryCode: bankAccountMetadataSchema.shape.countryCode.nonoptional(),
|
|
11911
13360
|
id: bankAccountMetadataSchema.shape.id.nonoptional()
|
|
11912
13361
|
});
|
|
11913
|
-
const bankAccountInputSchema = updateBankAccountSchema.required({
|
|
13362
|
+
const bankAccountInputSchema = updateBankAccountSchema$1.required({
|
|
11914
13363
|
holderName: true,
|
|
11915
13364
|
currency: true,
|
|
11916
13365
|
countryCode: true
|
|
11917
13366
|
}).omit({ id: true, partyId: true });
|
|
11918
|
-
const
|
|
11919
|
-
|
|
11920
|
-
|
|
11921
|
-
|
|
11922
|
-
|
|
11923
|
-
|
|
11924
|
-
|
|
11925
|
-
|
|
11926
|
-
|
|
11927
|
-
|
|
11928
|
-
|
|
11929
|
-
|
|
11930
|
-
|
|
11931
|
-
|
|
11932
|
-
|
|
11933
|
-
|
|
11934
|
-
|
|
11935
|
-
|
|
11936
|
-
|
|
11937
|
-
|
|
11938
|
-
|
|
11939
|
-
|
|
11940
|
-
|
|
11941
|
-
|
|
11942
|
-
|
|
11943
|
-
|
|
11944
|
-
|
|
11945
|
-
|
|
11946
|
-
|
|
11947
|
-
|
|
11948
|
-
|
|
11949
|
-
|
|
11950
|
-
|
|
11951
|
-
|
|
11952
|
-
|
|
11953
|
-
|
|
11954
|
-
|
|
11955
|
-
|
|
11956
|
-
|
|
11957
|
-
|
|
11958
|
-
|
|
11959
|
-
|
|
11960
|
-
|
|
11961
|
-
|
|
11962
|
-
|
|
11963
|
-
|
|
11964
|
-
sourceOfWealth: z$1.string().optional(),
|
|
11965
|
-
yearlyIncome: z$1.string().optional(),
|
|
11966
|
-
tradesPurpose: z$1.string().optional(),
|
|
11967
|
-
sourceOfIncome: z$1.string().optional(),
|
|
11968
|
-
transactionType: z$1.string().optional(),
|
|
11969
|
-
transactionTypeExpiry: z$1.date().optional(),
|
|
11970
|
-
isDistraint: z$1.boolean().optional(),
|
|
11971
|
-
estTxsVolumeMonth: z$1.string(),
|
|
11972
|
-
estTxsVolumeYear: z$1.string(),
|
|
11973
|
-
tradingCountries: z$1.string(),
|
|
11974
|
-
tradingSide: z$1.string(),
|
|
11975
|
-
acceptedAMLTermsAndConditions: z$1.boolean(),
|
|
11976
|
-
signatureMethod: z$1.string().optional(),
|
|
11977
|
-
existencePeriod: z$1.string().optional(),
|
|
11978
|
-
reputation: z$1.string().optional(),
|
|
11979
|
-
riskLevel: z$1.enum(AmlScoreTypeZod).optional(),
|
|
11980
|
-
kycStatus: z$1.enum(KycStatusZod).optional()
|
|
11981
|
-
});
|
|
11982
|
-
const createAmlOutputSchema = z$1.object({
|
|
11983
|
-
id: z$1.uuid(),
|
|
11984
|
-
partyId: z$1.uuid().nullable(),
|
|
11985
|
-
internalId: z$1.string().nullable(),
|
|
11986
|
-
sourceOfWealth: z$1.string(),
|
|
11987
|
-
yearlyIncome: z$1.string(),
|
|
11988
|
-
tradesPurpose: z$1.string().nullable(),
|
|
11989
|
-
sourceOfIncome: z$1.string(),
|
|
11990
|
-
transactionType: z$1.string().nullable(),
|
|
11991
|
-
transactionTypeExpiry: z$1.date().nullable(),
|
|
11992
|
-
isDistraint: z$1.boolean(),
|
|
11993
|
-
estTxsVolumeMonth: z$1.string(),
|
|
11994
|
-
estTxsVolumeYear: z$1.string(),
|
|
11995
|
-
tradingCountries: z$1.string(),
|
|
11996
|
-
tradingSide: z$1.string(),
|
|
11997
|
-
acceptedAMLTermsAndConditions: z$1.boolean(),
|
|
11998
|
-
signatureMethod: z$1.string().nullable(),
|
|
11999
|
-
existencePeriod: z$1.string().nullable(),
|
|
12000
|
-
reputation: z$1.string().nullable(),
|
|
12001
|
-
riskLevel: z$1.enum(AmlScoreTypeZod),
|
|
12002
|
-
kycStatus: z$1.enum(KycStatusZod).nullable(),
|
|
12003
|
-
createdAt: z$1.date().nullable(),
|
|
12004
|
-
updatedAt: z$1.date().nullable()
|
|
12005
|
-
});
|
|
12006
|
-
|
|
12007
|
-
const createAddressInputSchema = z$1.object({
|
|
12008
|
-
addressType: z$1.enum(AddressTypeZod),
|
|
12009
|
-
internalId: z$1.string().optional(),
|
|
12010
|
-
street: z$1.string(),
|
|
12011
|
-
orientationNumber: z$1.string().optional(),
|
|
12012
|
-
descriptiveNumber: z$1.string().optional(),
|
|
12013
|
-
municipality: z$1.string().max(255),
|
|
12014
|
-
municipalityPart: z$1.string().optional(),
|
|
12015
|
-
zipCode: z$1.string().max(20),
|
|
12016
|
-
district: z$1.string().max(255),
|
|
12017
|
-
region: z$1.string().max(255),
|
|
12018
|
-
countryCode: z$1.enum(COUNTRY_CODES_2),
|
|
12019
|
-
ruianCode: z$1.string().optional()
|
|
12020
|
-
});
|
|
12021
|
-
const createAddressOutputSchema = z$1.object({
|
|
12022
|
-
id: z$1.uuid(),
|
|
12023
|
-
partyId: z$1.uuid().nullable(),
|
|
12024
|
-
internalId: z$1.string().nullable(),
|
|
12025
|
-
addressType: z$1.enum(AddressTypeZod),
|
|
12026
|
-
street: z$1.string().nullable(),
|
|
12027
|
-
orientationNumber: z$1.string().nullable(),
|
|
12028
|
-
descriptiveNumber: z$1.string().nullable(),
|
|
12029
|
-
municipality: z$1.string(),
|
|
12030
|
-
municipalityPart: z$1.string().nullable(),
|
|
12031
|
-
zipCode: z$1.string(),
|
|
12032
|
-
district: z$1.string().nullable(),
|
|
12033
|
-
region: z$1.string().nullable(),
|
|
12034
|
-
countryCode: z$1.enum(COUNTRY_CODES_2),
|
|
12035
|
-
externalId: z$1.uuid().nullable(),
|
|
12036
|
-
ruianCode: z$1.string().nullable(),
|
|
12037
|
-
createdAt: z$1.date().nullable(),
|
|
12038
|
-
updatedAt: z$1.date().nullable()
|
|
12039
|
-
});
|
|
12040
|
-
const updateAddressInputSchema = z$1.object({
|
|
12041
|
-
id: z$1.uuid(),
|
|
12042
|
-
partyId: z$1.uuid(),
|
|
12043
|
-
internalId: z$1.string().optional(),
|
|
12044
|
-
addressType: z$1.enum(AddressTypeZod),
|
|
12045
|
-
street: z$1.string(),
|
|
12046
|
-
orientationNumber: z$1.string().optional(),
|
|
12047
|
-
descriptiveNumber: z$1.string().optional(),
|
|
12048
|
-
municipality: z$1.string().max(255),
|
|
12049
|
-
municipalityPart: z$1.string().optional(),
|
|
12050
|
-
zipCode: z$1.string().max(20),
|
|
12051
|
-
district: z$1.string().max(255),
|
|
12052
|
-
region: z$1.string().max(255),
|
|
12053
|
-
countryCode: z$1.enum(COUNTRY_CODES_2),
|
|
12054
|
-
ruianCode: z$1.string().optional()
|
|
12055
|
-
});
|
|
12056
|
-
|
|
12057
|
-
const partySchema = z$1.object({
|
|
12058
|
-
partyType: z$1.enum(PartyTypeZod),
|
|
12059
|
-
language: z$1.enum(LANGUAGE_CODES),
|
|
12060
|
-
id: z$1.uuid(),
|
|
12061
|
-
internalId: z$1.string().optional(),
|
|
12062
|
-
note: z$1.string().optional(),
|
|
12063
|
-
countryCode: z$1.enum(COUNTRY_CODES_2).optional()
|
|
12064
|
-
});
|
|
12065
|
-
const partyCreateOutputSchema = z$1.object({
|
|
12066
|
-
customerStatus: z$1.enum(CustomerStatusZod),
|
|
12067
|
-
partyType: z$1.enum(PartyTypeZod),
|
|
12068
|
-
language: z$1.enum(LANGUAGE_CODES),
|
|
12069
|
-
id: z$1.uuid(),
|
|
12070
|
-
internalId: z$1.string().nullable(),
|
|
12071
|
-
note: z$1.string().nullable(),
|
|
12072
|
-
countryCode: z$1.enum(COUNTRY_CODES_2).nullable(),
|
|
12073
|
-
createdAt: z$1.date().nullable(),
|
|
12074
|
-
updatedAt: z$1.date().nullable()
|
|
12075
|
-
});
|
|
12076
|
-
z$1.object({
|
|
12077
|
-
customerStatus: z$1.enum(CustomerStatusZod),
|
|
12078
|
-
partyType: z$1.enum(PartyTypeZod),
|
|
12079
|
-
language: z$1.enum(LANGUAGE_CODES),
|
|
12080
|
-
id: z$1.uuid(),
|
|
12081
|
-
internalId: z$1.string().nullable(),
|
|
12082
|
-
note: z$1.string().nullable(),
|
|
12083
|
-
countryCode: z$1.enum(COUNTRY_CODES_2).nullable(),
|
|
12084
|
-
createdAt: z$1.date().nullable(),
|
|
12085
|
-
updatedAt: z$1.date().nullable()
|
|
12086
|
-
});
|
|
12087
|
-
const createPartyInputSchema = z$1.object({
|
|
12088
|
-
party: partySchema.omit({ id: true }),
|
|
13367
|
+
const disponentSchema = z$3.discriminatedUnion("partyType", [
|
|
13368
|
+
z$3.object({
|
|
13369
|
+
partyType: z$3.literal("INDIVIDUAL"),
|
|
13370
|
+
data: individualInsertSchema
|
|
13371
|
+
}),
|
|
13372
|
+
z$3.object({
|
|
13373
|
+
partyType: z$3.literal("ORGANIZATION"),
|
|
13374
|
+
data: createOrganizationInputSchema
|
|
13375
|
+
})
|
|
13376
|
+
]);
|
|
13377
|
+
const createAddressInputSchema = z$3.object({
|
|
13378
|
+
addressType: z$3.enum(AddressTypeZod),
|
|
13379
|
+
internalId: z$3.string().optional(),
|
|
13380
|
+
street: z$3.string(),
|
|
13381
|
+
orientationNumber: z$3.string().optional(),
|
|
13382
|
+
descriptiveNumber: z$3.string().optional(),
|
|
13383
|
+
municipality: z$3.string().max(255),
|
|
13384
|
+
municipalityPart: z$3.string().optional(),
|
|
13385
|
+
zipCode: z$3.string().max(20),
|
|
13386
|
+
district: z$3.string().max(255),
|
|
13387
|
+
region: z$3.string().max(255),
|
|
13388
|
+
countryCode: z$3.enum(COUNTRY_CODES_2),
|
|
13389
|
+
ruianCode: z$3.string().optional()
|
|
13390
|
+
});
|
|
13391
|
+
const createAmlInputSchema = z$3.object({
|
|
13392
|
+
internalId: z$3.string().optional(),
|
|
13393
|
+
sourceOfWealth: z$3.string(),
|
|
13394
|
+
yearlyIncome: z$3.string(),
|
|
13395
|
+
tradesPurpose: z$3.string().optional(),
|
|
13396
|
+
sourceOfIncome: z$3.string(),
|
|
13397
|
+
transactionType: z$3.string().optional(),
|
|
13398
|
+
transactionTypeExpiry: z$3.date().optional(),
|
|
13399
|
+
isDistraint: z$3.boolean().default(false),
|
|
13400
|
+
estTxsVolumeMonth: z$3.string(),
|
|
13401
|
+
estTxsVolumeYear: z$3.string(),
|
|
13402
|
+
tradingCountries: z$3.string(),
|
|
13403
|
+
tradingSide: z$3.string(),
|
|
13404
|
+
acceptedAMLTermsAndConditions: z$3.boolean(),
|
|
13405
|
+
signatureMethod: z$3.string().optional(),
|
|
13406
|
+
existencePeriod: z$3.string().optional(),
|
|
13407
|
+
reputation: z$3.string().optional(),
|
|
13408
|
+
riskLevel: z$3.enum(AmlScoreTypeZod).optional(),
|
|
13409
|
+
kycStatus: z$3.enum(KycStatusZod).optional()
|
|
13410
|
+
});
|
|
13411
|
+
const createPartyInputSchema = z$3.object({
|
|
13412
|
+
party: partySchema$1.omit({ id: true }),
|
|
12089
13413
|
personalData: individualInsertSchema.nullable(),
|
|
12090
13414
|
organizationData: createOrganizationInputSchema.nullable(),
|
|
12091
|
-
bankAccounts: z$
|
|
12092
|
-
disponents: z$
|
|
12093
|
-
addresses: z$
|
|
13415
|
+
bankAccounts: z$3.array(bankAccountInputSchema),
|
|
13416
|
+
disponents: z$3.array(disponentSchema),
|
|
13417
|
+
addresses: z$3.array(createAddressInputSchema),
|
|
12094
13418
|
aml: createAmlInputSchema,
|
|
12095
|
-
recipients: z$
|
|
13419
|
+
recipients: z$3.array(bankAccountInputSchema)
|
|
12096
13420
|
});
|
|
12097
|
-
const
|
|
12098
|
-
|
|
12099
|
-
|
|
12100
|
-
|
|
12101
|
-
|
|
12102
|
-
|
|
12103
|
-
|
|
12104
|
-
|
|
12105
|
-
|
|
12106
|
-
|
|
12107
|
-
aml: createAmlOutputSchema.nullable(),
|
|
12108
|
-
recipients: z$1.array(bankAccountOutputSchema).nullable()
|
|
13421
|
+
const partyCreateOutputSchema = z$3.object({
|
|
13422
|
+
customerStatus: z$3.enum(CustomerStatusZod),
|
|
13423
|
+
partyType: z$3.enum(PartyTypeZod),
|
|
13424
|
+
language: z$3.enum(LANGUAGE_CODES),
|
|
13425
|
+
id: z$3.uuid(),
|
|
13426
|
+
internalId: z$3.string().nullable(),
|
|
13427
|
+
note: z$3.string().nullable(),
|
|
13428
|
+
countryCode: z$3.enum(COUNTRY_CODES_2).nullable(),
|
|
13429
|
+
createdAt: z$3.date().nullable(),
|
|
13430
|
+
updatedAt: z$3.date().nullable()
|
|
12109
13431
|
});
|
|
12110
|
-
const
|
|
12111
|
-
|
|
13432
|
+
const responseBodySchema$5 = z$3.object({
|
|
13433
|
+
message: z$3.string(),
|
|
13434
|
+
party: partyCreateOutputSchema
|
|
13435
|
+
});
|
|
13436
|
+
const createPartyRoute = createRoute({
|
|
13437
|
+
method: "post",
|
|
13438
|
+
path: "/",
|
|
13439
|
+
summary: "Create party",
|
|
13440
|
+
tags: ["Parties"],
|
|
13441
|
+
request: {
|
|
13442
|
+
body: {
|
|
13443
|
+
content: {
|
|
13444
|
+
"application/json": {
|
|
13445
|
+
schema: createPartyInputSchema
|
|
13446
|
+
}
|
|
13447
|
+
},
|
|
13448
|
+
required: true
|
|
13449
|
+
}
|
|
13450
|
+
},
|
|
13451
|
+
responses: {
|
|
13452
|
+
200: {
|
|
13453
|
+
content: {
|
|
13454
|
+
"application/json": {
|
|
13455
|
+
schema: responseBodySchema$5
|
|
13456
|
+
}
|
|
13457
|
+
},
|
|
13458
|
+
description: "Creates a Party."
|
|
13459
|
+
},
|
|
13460
|
+
...errorResponse("Party", "Creation")
|
|
13461
|
+
}
|
|
13462
|
+
});
|
|
13463
|
+
new OpenAPIHono().openapi(
|
|
13464
|
+
createPartyRoute,
|
|
13465
|
+
async (context) => {
|
|
13466
|
+
const party = context.req.valid("json");
|
|
13467
|
+
const { data: partyData, error } = await context.env.MASTER_DATA_MANAGEMENT_SERVICE.createParty(party);
|
|
13468
|
+
if (!partyData || error) {
|
|
13469
|
+
return context.json(
|
|
13470
|
+
{
|
|
13471
|
+
message: "Could not create a party"
|
|
13472
|
+
},
|
|
13473
|
+
500
|
|
13474
|
+
);
|
|
13475
|
+
}
|
|
13476
|
+
return context.json(
|
|
13477
|
+
{
|
|
13478
|
+
message: "party created",
|
|
13479
|
+
party: partyData
|
|
13480
|
+
},
|
|
13481
|
+
200
|
|
13482
|
+
);
|
|
13483
|
+
}
|
|
13484
|
+
);
|
|
13485
|
+
|
|
13486
|
+
const partySchema = z$3.object({
|
|
13487
|
+
partyType: z$3.enum(PartyTypeZod),
|
|
13488
|
+
language: z$3.enum(LANGUAGE_CODES),
|
|
13489
|
+
id: z$3.uuid(),
|
|
13490
|
+
internalId: z$3.string().optional(),
|
|
13491
|
+
note: z$3.string().optional(),
|
|
13492
|
+
countryCode: z$3.enum(COUNTRY_CODES_2).optional()
|
|
13493
|
+
});
|
|
13494
|
+
const individualUpdateSchema = z$3.object({
|
|
13495
|
+
id: z$3.uuid(),
|
|
13496
|
+
partyId: z$3.uuid(),
|
|
13497
|
+
internalId: z$3.string().optional(),
|
|
13498
|
+
name: z$3.string().optional(),
|
|
13499
|
+
surname: z$3.string().optional(),
|
|
13500
|
+
email: z$3.string().optional(),
|
|
13501
|
+
phone: z$3.string().optional(),
|
|
13502
|
+
birthDate: z$3.string().optional(),
|
|
13503
|
+
birthPlace: z$3.string().optional(),
|
|
13504
|
+
countryOfBirth: z$3.enum(COUNTRY_CODES_2).optional(),
|
|
13505
|
+
personalId: z$3.string().optional(),
|
|
13506
|
+
gender: z$3.enum(GenderZod).optional(),
|
|
13507
|
+
citizenship: z$3.enum(COUNTRY_CODES_2).optional(),
|
|
13508
|
+
citizenshipOther: z$3.enum(COUNTRY_CODES_2).optional(),
|
|
13509
|
+
employer: z$3.string().optional(),
|
|
13510
|
+
employerCountry: z$3.enum(COUNTRY_CODES_2).optional(),
|
|
13511
|
+
registeredNumber: z$3.string().optional(),
|
|
13512
|
+
isPep: z$3.boolean().optional(),
|
|
13513
|
+
titleBefore: z$3.string().optional(),
|
|
13514
|
+
titleAfter: z$3.string().optional(),
|
|
13515
|
+
birthSurname: z$3.string().optional(),
|
|
13516
|
+
vocativeTitle: z$3.string().optional(),
|
|
13517
|
+
deathDate: z$3.date().optional(),
|
|
13518
|
+
deathNotification: z$3.date().optional(),
|
|
13519
|
+
pin: z$3.string().optional(),
|
|
13520
|
+
stayAbroad: z$3.boolean().optional(),
|
|
13521
|
+
stayAbroadCountries: z$3.enum(COUNTRY_CODES_2).optional()
|
|
13522
|
+
});
|
|
13523
|
+
const organizationUpdateSchema = z$3.object({
|
|
13524
|
+
id: z$3.uuid(),
|
|
13525
|
+
partyId: z$3.uuid().optional(),
|
|
13526
|
+
internalId: z$3.string().optional(),
|
|
13527
|
+
businessName: z$3.string().optional(),
|
|
13528
|
+
email: z$3.email("Invalid email format").optional(),
|
|
13529
|
+
phone: z$3.string().optional(),
|
|
13530
|
+
registeredNumber: z$3.string().optional(),
|
|
13531
|
+
registeredIn: z$3.enum(COUNTRY_CODES_2).optional(),
|
|
13532
|
+
operatesIn: z$3.enum(COUNTRY_CODES_2).optional(),
|
|
13533
|
+
presentIn: z$3.enum(COUNTRY_CODES_2).optional(),
|
|
13534
|
+
monthlyVolumeIn: z$3.number().optional(),
|
|
13535
|
+
monthlyVolumeOut: z$3.number().optional(),
|
|
13536
|
+
ownedBy: z$3.string().optional(),
|
|
13537
|
+
companyObjects: z$3.string().optional(),
|
|
13538
|
+
annualTurnover: z$3.number().optional(),
|
|
13539
|
+
numberOfEmployees: z$3.number().optional(),
|
|
13540
|
+
prosecuted: z$3.string().optional(),
|
|
13541
|
+
location: z$3.string().optional(),
|
|
13542
|
+
fileNumber: z$3.string().optional(),
|
|
13543
|
+
websiteUrl: z$3.url("Invalid website URL").optional(),
|
|
13544
|
+
vatPayer: z$3.boolean().optional(),
|
|
13545
|
+
companyObjectsDescription: z$3.string(),
|
|
13546
|
+
turnover3years: z$3.number(),
|
|
13547
|
+
operationCountries: z$3.string(),
|
|
13548
|
+
riskyBusinessType: z$3.string().optional()
|
|
13549
|
+
});
|
|
13550
|
+
const updateBankAccountSchema = z$3.object({
|
|
13551
|
+
...bankAccountMetadataSchema.shape,
|
|
13552
|
+
partyId: z$3.uuid(),
|
|
13553
|
+
internalId: z$3.string().optional(),
|
|
13554
|
+
holderName: z$3.string(),
|
|
13555
|
+
number: z$3.string().optional(),
|
|
13556
|
+
currency: bankAccountMetadataSchema.shape.currency.nonoptional(),
|
|
13557
|
+
countryCode: bankAccountMetadataSchema.shape.countryCode.nonoptional(),
|
|
13558
|
+
id: bankAccountMetadataSchema.shape.id.nonoptional()
|
|
13559
|
+
});
|
|
13560
|
+
const disponentUpdateSchema = z$3.discriminatedUnion("partyType", [
|
|
13561
|
+
z$3.object({
|
|
13562
|
+
partyType: z$3.literal("INDIVIDUAL"),
|
|
13563
|
+
data: individualUpdateSchema
|
|
13564
|
+
}),
|
|
13565
|
+
z$3.object({
|
|
13566
|
+
partyType: z$3.literal("ORGANIZATION"),
|
|
13567
|
+
data: organizationUpdateSchema
|
|
13568
|
+
})
|
|
13569
|
+
]);
|
|
13570
|
+
const updateAddressInputSchema = z$3.object({
|
|
13571
|
+
id: z$3.uuid(),
|
|
13572
|
+
partyId: z$3.uuid(),
|
|
13573
|
+
internalId: z$3.string().optional(),
|
|
13574
|
+
addressType: z$3.enum(AddressTypeZod),
|
|
13575
|
+
street: z$3.string(),
|
|
13576
|
+
orientationNumber: z$3.string().optional(),
|
|
13577
|
+
descriptiveNumber: z$3.string().optional(),
|
|
13578
|
+
municipality: z$3.string().max(255),
|
|
13579
|
+
municipalityPart: z$3.string().optional(),
|
|
13580
|
+
zipCode: z$3.string().max(20),
|
|
13581
|
+
district: z$3.string().max(255),
|
|
13582
|
+
region: z$3.string().max(255),
|
|
13583
|
+
countryCode: z$3.enum(COUNTRY_CODES_2),
|
|
13584
|
+
ruianCode: z$3.string().optional()
|
|
13585
|
+
});
|
|
13586
|
+
const updateAmlInputSchema = z$3.object({
|
|
13587
|
+
id: z$3.uuid(),
|
|
13588
|
+
partyId: z$3.uuid().optional(),
|
|
13589
|
+
internalId: z$3.string().optional(),
|
|
13590
|
+
sourceOfWealth: z$3.string().optional(),
|
|
13591
|
+
yearlyIncome: z$3.string().optional(),
|
|
13592
|
+
tradesPurpose: z$3.string().optional(),
|
|
13593
|
+
sourceOfIncome: z$3.string().optional(),
|
|
13594
|
+
transactionType: z$3.string().optional(),
|
|
13595
|
+
transactionTypeExpiry: z$3.date().optional(),
|
|
13596
|
+
isDistraint: z$3.boolean().optional(),
|
|
13597
|
+
estTxsVolumeMonth: z$3.string(),
|
|
13598
|
+
estTxsVolumeYear: z$3.string(),
|
|
13599
|
+
tradingCountries: z$3.string(),
|
|
13600
|
+
tradingSide: z$3.string(),
|
|
13601
|
+
acceptedAMLTermsAndConditions: z$3.boolean(),
|
|
13602
|
+
signatureMethod: z$3.string().optional(),
|
|
13603
|
+
existencePeriod: z$3.string().optional(),
|
|
13604
|
+
reputation: z$3.string().optional(),
|
|
13605
|
+
riskLevel: z$3.enum(AmlScoreTypeZod).optional(),
|
|
13606
|
+
kycStatus: z$3.enum(KycStatusZod).optional()
|
|
13607
|
+
});
|
|
13608
|
+
const partyUpdateInputSchema = z$3.object({
|
|
12112
13609
|
party: partySchema,
|
|
12113
13610
|
personalData: individualUpdateSchema.nullable(),
|
|
12114
13611
|
organizationData: organizationUpdateSchema.nullable(),
|
|
12115
|
-
bankAccounts: z$
|
|
12116
|
-
disponents: z$
|
|
12117
|
-
addresses: z$
|
|
12118
|
-
recipients: z$
|
|
13612
|
+
bankAccounts: z$3.array(updateBankAccountSchema),
|
|
13613
|
+
disponents: z$3.array(disponentUpdateSchema).optional(),
|
|
13614
|
+
addresses: z$3.array(updateAddressInputSchema),
|
|
13615
|
+
recipients: z$3.array(updateBankAccountSchema).nullable(),
|
|
12119
13616
|
aml: updateAmlInputSchema.optional()
|
|
12120
13617
|
});
|
|
12121
|
-
const updatePartyOuputSchema = z$
|
|
12122
|
-
id: z$
|
|
12123
|
-
customerStatus: z$
|
|
12124
|
-
partyType: z$
|
|
12125
|
-
language: z$
|
|
12126
|
-
note: z$
|
|
12127
|
-
countryCode: z$
|
|
12128
|
-
});
|
|
12129
|
-
|
|
12130
|
-
|
|
12131
|
-
|
|
12132
|
-
|
|
12133
|
-
|
|
12134
|
-
|
|
12135
|
-
|
|
12136
|
-
|
|
12137
|
-
|
|
12138
|
-
|
|
12139
|
-
|
|
12140
|
-
|
|
12141
|
-
|
|
12142
|
-
|
|
12143
|
-
|
|
12144
|
-
|
|
12145
|
-
|
|
12146
|
-
|
|
12147
|
-
|
|
12148
|
-
|
|
12149
|
-
|
|
13618
|
+
const updatePartyOuputSchema = z$3.object({
|
|
13619
|
+
id: z$3.uuid(),
|
|
13620
|
+
customerStatus: z$3.enum(CustomerStatusZod),
|
|
13621
|
+
partyType: z$3.enum(PartyTypeZod),
|
|
13622
|
+
language: z$3.enum(LANGUAGE_CODES),
|
|
13623
|
+
note: z$3.string().nullable(),
|
|
13624
|
+
countryCode: z$3.enum(COUNTRY_CODES_2).nullable()
|
|
13625
|
+
});
|
|
13626
|
+
const responseBodySchema$4 = z$3.object({
|
|
13627
|
+
message: z$3.string(),
|
|
13628
|
+
party: updatePartyOuputSchema
|
|
13629
|
+
});
|
|
13630
|
+
const updatePartyRoute = createRoute({
|
|
13631
|
+
method: "put",
|
|
13632
|
+
path: "/{partyId}",
|
|
13633
|
+
summary: "Update party",
|
|
13634
|
+
tags: ["Parties"],
|
|
13635
|
+
security: [
|
|
13636
|
+
{
|
|
13637
|
+
JwtAuth: []
|
|
13638
|
+
}
|
|
13639
|
+
],
|
|
13640
|
+
request: {
|
|
13641
|
+
params: z$3.object({ partyId: z$3.uuid() }),
|
|
13642
|
+
body: {
|
|
13643
|
+
content: {
|
|
13644
|
+
"application/json": {
|
|
13645
|
+
schema: partyUpdateInputSchema
|
|
13646
|
+
}
|
|
13647
|
+
},
|
|
13648
|
+
required: true
|
|
13649
|
+
}
|
|
13650
|
+
},
|
|
13651
|
+
responses: {
|
|
13652
|
+
200: {
|
|
13653
|
+
content: {
|
|
13654
|
+
"application/json": {
|
|
13655
|
+
schema: responseBodySchema$4
|
|
13656
|
+
}
|
|
13657
|
+
},
|
|
13658
|
+
description: "Updates a Party."
|
|
13659
|
+
},
|
|
13660
|
+
...errorResponse("Party", "Update")
|
|
13661
|
+
}
|
|
13662
|
+
});
|
|
13663
|
+
new OpenAPIHono().openapi(
|
|
13664
|
+
updatePartyRoute,
|
|
13665
|
+
async (context) => {
|
|
13666
|
+
const party = context.req.valid("json");
|
|
13667
|
+
const { partyId } = context.req.valid("param");
|
|
13668
|
+
const { data: updatedParty, error: partyError } = await context.env.MASTER_DATA_MANAGEMENT_SERVICE.updateParty({
|
|
13669
|
+
partyId,
|
|
13670
|
+
party: party.party,
|
|
13671
|
+
personalData: party.personalData ?? void 0,
|
|
13672
|
+
organizationData: party.organizationData ?? void 0,
|
|
13673
|
+
bankAccounts: party.bankAccounts ?? void 0,
|
|
13674
|
+
disponents: party.disponents ?? void 0,
|
|
13675
|
+
addresses: party.addresses ?? void 0,
|
|
13676
|
+
recipients: party.recipients ?? void 0,
|
|
13677
|
+
aml: party.aml ?? void 0
|
|
13678
|
+
});
|
|
13679
|
+
if (!updatedParty || partyError) {
|
|
13680
|
+
return context.json({ message: "Could not update a Party" }, 404);
|
|
13681
|
+
}
|
|
13682
|
+
return context.json(
|
|
13683
|
+
{
|
|
13684
|
+
message: "Party updated successfully",
|
|
13685
|
+
party: updatedParty
|
|
13686
|
+
},
|
|
13687
|
+
200
|
|
13688
|
+
);
|
|
13689
|
+
}
|
|
13690
|
+
);
|
|
13691
|
+
|
|
13692
|
+
const partyBaseOutputSchema = z$3.object({
|
|
13693
|
+
customerStatus: z$3.enum(CustomerStatusZod),
|
|
13694
|
+
partyType: z$3.enum(PartyTypeZod),
|
|
13695
|
+
language: z$3.enum(LANGUAGE_CODES),
|
|
13696
|
+
id: z$3.uuid(),
|
|
13697
|
+
internalId: z$3.string().nullable(),
|
|
13698
|
+
note: z$3.string().nullable(),
|
|
13699
|
+
countryCode: z$3.enum(COUNTRY_CODES_2).nullable(),
|
|
13700
|
+
createdAt: z$3.date().nullable(),
|
|
13701
|
+
updatedAt: z$3.date().nullable(),
|
|
13702
|
+
isClient: z$3.boolean()
|
|
13703
|
+
});
|
|
13704
|
+
const individualOutputSchema = z$3.object({
|
|
13705
|
+
id: z$3.uuid(),
|
|
13706
|
+
partyId: z$3.uuid(),
|
|
13707
|
+
internalId: z$3.string().nullable(),
|
|
13708
|
+
name: z$3.string(),
|
|
13709
|
+
surname: z$3.string(),
|
|
13710
|
+
email: z$3.string().nullable(),
|
|
13711
|
+
phone: z$3.string().nullable(),
|
|
13712
|
+
birthDate: z$3.string().nullable(),
|
|
13713
|
+
birthPlace: z$3.string(),
|
|
13714
|
+
countryOfBirth: z$3.enum(COUNTRY_CODES_2).nullable(),
|
|
13715
|
+
personalId: z$3.string(),
|
|
13716
|
+
gender: z$3.enum(GenderZod),
|
|
13717
|
+
citizenship: z$3.enum(COUNTRY_CODES_2),
|
|
13718
|
+
citizenshipOther: z$3.enum(COUNTRY_CODES_2).nullable(),
|
|
13719
|
+
employer: z$3.string().nullable(),
|
|
13720
|
+
employerCountry: z$3.enum(COUNTRY_CODES_2).nullable(),
|
|
13721
|
+
registeredNumber: z$3.string(),
|
|
13722
|
+
isPep: z$3.boolean(),
|
|
13723
|
+
titleBefore: z$3.string().nullable(),
|
|
13724
|
+
titleAfter: z$3.string().nullable(),
|
|
13725
|
+
birthSurname: z$3.string().nullable(),
|
|
13726
|
+
vocativeTitle: z$3.string().nullable(),
|
|
13727
|
+
deathDate: z$3.coerce.date().nullable(),
|
|
13728
|
+
deathNotification: z$3.coerce.date().nullable(),
|
|
13729
|
+
pin: z$3.string().nullable(),
|
|
13730
|
+
stayAbroad: z$3.boolean().nullable(),
|
|
13731
|
+
stayAbroadCountries: z$3.enum(COUNTRY_CODES_2).nullable(),
|
|
13732
|
+
createdAt: z$3.coerce.date().nullable(),
|
|
13733
|
+
updatedAt: z$3.coerce.date().nullable()
|
|
13734
|
+
});
|
|
13735
|
+
const createOrganizationOutputSchema = z$3.object({
|
|
13736
|
+
partyId: z$3.uuid(),
|
|
13737
|
+
internalId: z$3.string().nullable(),
|
|
13738
|
+
businessName: z$3.string(),
|
|
13739
|
+
email: z$3.string().nullable(),
|
|
13740
|
+
phone: z$3.string().nullable(),
|
|
13741
|
+
registeredNumber: z$3.string(),
|
|
13742
|
+
registeredIn: z$3.enum(COUNTRY_CODES_2),
|
|
13743
|
+
operatesIn: z$3.enum(COUNTRY_CODES_2),
|
|
13744
|
+
presentIn: z$3.enum(COUNTRY_CODES_2),
|
|
13745
|
+
monthlyVolumeIn: z$3.number(),
|
|
13746
|
+
monthlyVolumeOut: z$3.number(),
|
|
13747
|
+
ownedBy: z$3.string(),
|
|
13748
|
+
companyObjects: z$3.string(),
|
|
13749
|
+
annualTurnover: z$3.number(),
|
|
13750
|
+
numberOfEmployees: z$3.number().nullable(),
|
|
13751
|
+
prosecuted: z$3.string().nullable(),
|
|
13752
|
+
location: z$3.string().nullable(),
|
|
13753
|
+
fileNumber: z$3.string().nullable(),
|
|
13754
|
+
websiteUrl: z$3.string().nullable(),
|
|
13755
|
+
vatPayer: z$3.boolean(),
|
|
13756
|
+
companyObjectsDescription: z$3.string(),
|
|
13757
|
+
turnover3years: z$3.number(),
|
|
13758
|
+
operationCountries: z$3.string(),
|
|
13759
|
+
riskyBusinessType: z$3.string().nullable()
|
|
13760
|
+
});
|
|
13761
|
+
const bankAccountOutputSchema = z$3.object({
|
|
13762
|
+
id: z$3.string(),
|
|
13763
|
+
partyId: z$3.uuid(),
|
|
13764
|
+
internalId: z$3.string().nullable(),
|
|
13765
|
+
holderName: z$3.string(),
|
|
13766
|
+
number: z$3.string().nullable(),
|
|
13767
|
+
bankCode: z$3.string().nullable(),
|
|
13768
|
+
currency: z$3.string(),
|
|
13769
|
+
countryCode: z$3.string(),
|
|
13770
|
+
iban: z$3.string().nullable(),
|
|
13771
|
+
address: z$3.string().nullable(),
|
|
13772
|
+
swiftBic: z$3.string().nullable(),
|
|
13773
|
+
bicCor: z$3.string().nullable(),
|
|
13774
|
+
routingNumber: z$3.string().nullable(),
|
|
13775
|
+
sortCode: z$3.string().nullable(),
|
|
13776
|
+
clabe: z$3.string().nullable(),
|
|
13777
|
+
bsb: z$3.string().nullable(),
|
|
13778
|
+
brBankNumber: z$3.string().nullable(),
|
|
13779
|
+
updatedAt: z$3.coerce.date().nullable()
|
|
13780
|
+
});
|
|
13781
|
+
const disponentOutputSchema = z$3.discriminatedUnion("partyType", [
|
|
13782
|
+
z$3.object({
|
|
13783
|
+
partyType: z$3.literal("INDIVIDUAL"),
|
|
13784
|
+
data: individualOutputSchema.nullable()
|
|
13785
|
+
}),
|
|
13786
|
+
z$3.object({
|
|
13787
|
+
partyType: z$3.literal("ORGANIZATION"),
|
|
13788
|
+
data: createOrganizationOutputSchema.nullable()
|
|
13789
|
+
})
|
|
13790
|
+
]);
|
|
13791
|
+
const createAddressOutputSchema = z$3.object({
|
|
13792
|
+
id: z$3.uuid(),
|
|
13793
|
+
partyId: z$3.uuid(),
|
|
13794
|
+
internalId: z$3.string().nullable(),
|
|
13795
|
+
addressType: z$3.enum(AddressTypeZod),
|
|
13796
|
+
street: z$3.string().nullable(),
|
|
13797
|
+
orientationNumber: z$3.string().nullable(),
|
|
13798
|
+
descriptiveNumber: z$3.string().nullable(),
|
|
13799
|
+
municipality: z$3.string(),
|
|
13800
|
+
municipalityPart: z$3.string().nullable(),
|
|
13801
|
+
zipCode: z$3.string(),
|
|
13802
|
+
district: z$3.string().nullable(),
|
|
13803
|
+
region: z$3.string().nullable(),
|
|
13804
|
+
countryCode: z$3.enum(COUNTRY_CODES_2),
|
|
13805
|
+
ruianCode: z$3.string().nullable(),
|
|
13806
|
+
createdAt: z$3.date().nullable(),
|
|
13807
|
+
updatedAt: z$3.date().nullable()
|
|
13808
|
+
});
|
|
13809
|
+
const createAmlOutputSchema = z$3.object({
|
|
13810
|
+
id: z$3.uuid(),
|
|
13811
|
+
partyId: z$3.uuid(),
|
|
13812
|
+
internalId: z$3.string().nullable(),
|
|
13813
|
+
sourceOfWealth: z$3.string(),
|
|
13814
|
+
yearlyIncome: z$3.string(),
|
|
13815
|
+
tradesPurpose: z$3.string().nullable(),
|
|
13816
|
+
sourceOfIncome: z$3.string(),
|
|
13817
|
+
transactionType: z$3.string().nullable(),
|
|
13818
|
+
transactionTypeExpiry: z$3.date().nullable(),
|
|
13819
|
+
isDistraint: z$3.boolean(),
|
|
13820
|
+
estTxsVolumeMonth: z$3.string(),
|
|
13821
|
+
estTxsVolumeYear: z$3.string(),
|
|
13822
|
+
tradingCountries: z$3.string(),
|
|
13823
|
+
tradingSide: z$3.string(),
|
|
13824
|
+
acceptedAMLTermsAndConditions: z$3.boolean(),
|
|
13825
|
+
signatureMethod: z$3.string().nullable(),
|
|
13826
|
+
existencePeriod: z$3.string().nullable(),
|
|
13827
|
+
reputation: z$3.string().nullable(),
|
|
13828
|
+
riskLevel: z$3.enum(AmlScoreTypeZod),
|
|
13829
|
+
kycStatus: z$3.enum(KycStatusZod).nullable(),
|
|
13830
|
+
createdAt: z$3.date().nullable(),
|
|
13831
|
+
updatedAt: z$3.date().nullable()
|
|
13832
|
+
});
|
|
13833
|
+
const partyOutputSchema = z$3.object({
|
|
13834
|
+
party: partyBaseOutputSchema.nullable(),
|
|
13835
|
+
personalData: individualOutputSchema.nullable(),
|
|
13836
|
+
organizationData: createOrganizationOutputSchema.nullable(),
|
|
13837
|
+
bankAccounts: z$3.array(bankAccountOutputSchema).nullable(),
|
|
13838
|
+
disponents: z$3.array(disponentOutputSchema).nullable(),
|
|
13839
|
+
addresses: z$3.array(createAddressOutputSchema).nullable(),
|
|
13840
|
+
aml: createAmlOutputSchema.nullable(),
|
|
13841
|
+
recipients: z$3.array(bankAccountOutputSchema).nullable()
|
|
12150
13842
|
});
|
|
13843
|
+
const responseBodySchema$3 = z$3.object({
|
|
13844
|
+
message: z$3.string(),
|
|
13845
|
+
party: partyOutputSchema
|
|
13846
|
+
});
|
|
13847
|
+
const getPartyByPartyIdRoute = createRoute({
|
|
13848
|
+
method: "get",
|
|
13849
|
+
path: "/{partyId}",
|
|
13850
|
+
summary: "Get party",
|
|
13851
|
+
tags: ["Parties"],
|
|
13852
|
+
request: {
|
|
13853
|
+
params: z$3.object({ partyId: z$3.uuid() })
|
|
13854
|
+
},
|
|
13855
|
+
responses: {
|
|
13856
|
+
200: {
|
|
13857
|
+
content: {
|
|
13858
|
+
"application/json": {
|
|
13859
|
+
schema: responseBodySchema$3
|
|
13860
|
+
}
|
|
13861
|
+
},
|
|
13862
|
+
description: "Get party by party Id"
|
|
13863
|
+
},
|
|
13864
|
+
...errorResponse("party", "Get")
|
|
13865
|
+
}
|
|
13866
|
+
});
|
|
13867
|
+
new OpenAPIHono().openapi(
|
|
13868
|
+
getPartyByPartyIdRoute,
|
|
13869
|
+
async (context) => {
|
|
13870
|
+
const { partyId } = context.req.valid("param");
|
|
13871
|
+
const { data: partyData, error: partyError } = await context.env.MASTER_DATA_MANAGEMENT_SERVICE.getParty({ partyId });
|
|
13872
|
+
if (partyData == null || partyError) {
|
|
13873
|
+
return context.json({ message: "Party not found" }, 404);
|
|
13874
|
+
}
|
|
13875
|
+
return context.json(
|
|
13876
|
+
{
|
|
13877
|
+
message: "Party Found",
|
|
13878
|
+
party: partyData
|
|
13879
|
+
},
|
|
13880
|
+
200
|
|
13881
|
+
);
|
|
13882
|
+
}
|
|
13883
|
+
);
|
|
13884
|
+
|
|
13885
|
+
const paginationSchema = z$3.object({
|
|
13886
|
+
offset: z$3.number().default(1),
|
|
13887
|
+
limit: z$3.number().default(10)
|
|
13888
|
+
});
|
|
13889
|
+
const paginationAndSearchSchema = z$3.object({
|
|
13890
|
+
page: z$3.coerce.number().positive().default(1),
|
|
13891
|
+
limit: z$3.coerce.number().positive().default(20),
|
|
13892
|
+
column: z$3.string(),
|
|
13893
|
+
direction: z$3.enum(["asc", "desc"]),
|
|
13894
|
+
search: z$3.string().optional(),
|
|
13895
|
+
ids: z$3.string().array().optional()
|
|
13896
|
+
});
|
|
13897
|
+
paginationSchema.extend({
|
|
13898
|
+
partyId: z$3.uuid()
|
|
13899
|
+
});
|
|
13900
|
+
paginationSchema.extend({
|
|
13901
|
+
id: z$3.uuid()
|
|
13902
|
+
});
|
|
13903
|
+
z$3.object({ partyId: z$3.uuid() });
|
|
13904
|
+
|
|
13905
|
+
const partiesOutputDataSchema = z$3.array(partyOutputSchema);
|
|
13906
|
+
const getPartiesRoute = createRoute({
|
|
13907
|
+
method: "get",
|
|
13908
|
+
path: "/",
|
|
13909
|
+
summary: "List parties",
|
|
13910
|
+
tags: ["Parties"],
|
|
13911
|
+
request: { query: paginationAndSearchSchema },
|
|
13912
|
+
responses: {
|
|
13913
|
+
500: {
|
|
13914
|
+
description: "Internal Server Error",
|
|
13915
|
+
content: {
|
|
13916
|
+
"application/json": {
|
|
13917
|
+
schema: routeError
|
|
13918
|
+
}
|
|
13919
|
+
}
|
|
13920
|
+
},
|
|
13921
|
+
200: {
|
|
13922
|
+
content: {
|
|
13923
|
+
"application/json": {
|
|
13924
|
+
schema: z$3.object({
|
|
13925
|
+
message: z$3.string(),
|
|
13926
|
+
data: z$3.object({
|
|
13927
|
+
parties: partiesOutputDataSchema,
|
|
13928
|
+
totalCount: z$3.number()
|
|
13929
|
+
})
|
|
13930
|
+
})
|
|
13931
|
+
}
|
|
13932
|
+
},
|
|
13933
|
+
description: "Get Parties."
|
|
13934
|
+
}
|
|
13935
|
+
}
|
|
13936
|
+
});
|
|
13937
|
+
new OpenAPIHono().openapi(
|
|
13938
|
+
getPartiesRoute,
|
|
13939
|
+
async (context) => {
|
|
13940
|
+
const query = context.req.query();
|
|
13941
|
+
const validatedQuery = {
|
|
13942
|
+
page: query.page ? Number(query.page) : 1,
|
|
13943
|
+
limit: query.limit ? Number(query.limit) : 10,
|
|
13944
|
+
column: query.column || "createdAt",
|
|
13945
|
+
direction: query.direction || "desc",
|
|
13946
|
+
search: query.search,
|
|
13947
|
+
ids: query.ids ? Array.isArray(query.ids) ? query.ids : [query.ids] : void 0
|
|
13948
|
+
};
|
|
13949
|
+
const {
|
|
13950
|
+
data: parties,
|
|
13951
|
+
error,
|
|
13952
|
+
message,
|
|
13953
|
+
status
|
|
13954
|
+
} = await context.env.MASTER_DATA_MANAGEMENT_SERVICE.getParties(
|
|
13955
|
+
validatedQuery
|
|
13956
|
+
);
|
|
13957
|
+
if (error || !parties) {
|
|
13958
|
+
return context.json(
|
|
13959
|
+
{
|
|
13960
|
+
message: "Failed to get parties",
|
|
13961
|
+
data: null,
|
|
13962
|
+
errorDetail: {
|
|
13963
|
+
message,
|
|
13964
|
+
code: status
|
|
13965
|
+
},
|
|
13966
|
+
error: true
|
|
13967
|
+
},
|
|
13968
|
+
500
|
|
13969
|
+
);
|
|
13970
|
+
}
|
|
13971
|
+
return context.json({ message, data: parties }, 200);
|
|
13972
|
+
}
|
|
13973
|
+
);
|
|
13974
|
+
|
|
12151
13975
|
const DOCUMENT_SIDE = ["front", "back"];
|
|
12152
|
-
const
|
|
12153
|
-
partyId: z$
|
|
12154
|
-
|
|
12155
|
-
|
|
12156
|
-
|
|
12157
|
-
|
|
12158
|
-
|
|
12159
|
-
|
|
12160
|
-
|
|
12161
|
-
|
|
12162
|
-
|
|
12163
|
-
|
|
12164
|
-
|
|
12165
|
-
|
|
12166
|
-
|
|
12167
|
-
|
|
12168
|
-
|
|
12169
|
-
|
|
12170
|
-
|
|
12171
|
-
|
|
12172
|
-
|
|
12173
|
-
|
|
12174
|
-
|
|
12175
|
-
|
|
12176
|
-
|
|
12177
|
-
|
|
12178
|
-
|
|
12179
|
-
|
|
12180
|
-
});
|
|
12181
|
-
|
|
12182
|
-
|
|
12183
|
-
|
|
12184
|
-
|
|
12185
|
-
|
|
12186
|
-
|
|
13976
|
+
const paramsSchema$2 = z$3.object({
|
|
13977
|
+
partyId: z$3.uuid()
|
|
13978
|
+
});
|
|
13979
|
+
const idDocumentCreateInputSchema = z$3.object({
|
|
13980
|
+
partyId: z$3.uuid(),
|
|
13981
|
+
idDocType: z$3.enum(IdDocTypeZod),
|
|
13982
|
+
idDocNumber: z$3.string(),
|
|
13983
|
+
idDocHolderName: z$3.string(),
|
|
13984
|
+
issueDate: z$3.coerce.date().optional(),
|
|
13985
|
+
expirationDate: z$3.coerce.date().optional(),
|
|
13986
|
+
issuer: z$3.string().optional(),
|
|
13987
|
+
countryOfIssue: z$3.enum(COUNTRY_CODES_2).optional(),
|
|
13988
|
+
idDocStatus: z$3.enum(IdDocStatusZod).optional()
|
|
13989
|
+
});
|
|
13990
|
+
const idDocumentMultipartSchema = z$3.object({
|
|
13991
|
+
idDocument: z$3.string(),
|
|
13992
|
+
documentSide: z$3.enum(DOCUMENT_SIDE),
|
|
13993
|
+
file: z$3.any()
|
|
13994
|
+
});
|
|
13995
|
+
const multipartOpenApiSchema = z$3.object({
|
|
13996
|
+
idDocument: z$3.string().openapi({
|
|
13997
|
+
description: "JSON stringified IdDocument payload"
|
|
13998
|
+
}),
|
|
13999
|
+
documentSide: z$3.enum(DOCUMENT_SIDE),
|
|
14000
|
+
file: z$3.any().openapi({
|
|
14001
|
+
type: "string",
|
|
14002
|
+
format: "binary"
|
|
14003
|
+
})
|
|
14004
|
+
});
|
|
14005
|
+
const idDocumentOutputSchema = z$3.object({
|
|
14006
|
+
id: z$3.uuid(),
|
|
14007
|
+
createdAt: z$3.iso.datetime().nullable(),
|
|
14008
|
+
updatedAt: z$3.iso.datetime().nullable(),
|
|
14009
|
+
deletedAt: z$3.iso.datetime().nullable(),
|
|
14010
|
+
partyId: z$3.uuid(),
|
|
14011
|
+
idDocType: z$3.enum(IdDocTypeZod),
|
|
14012
|
+
idDocNumber: z$3.string(),
|
|
14013
|
+
idDocHolderName: z$3.string(),
|
|
14014
|
+
issueDate: z$3.iso.datetime().nullable(),
|
|
14015
|
+
expirationDate: z$3.iso.datetime().nullable(),
|
|
14016
|
+
issuer: z$3.string().nullable(),
|
|
14017
|
+
countryOfIssue: z$3.enum(COUNTRY_CODES_2).nullable(),
|
|
14018
|
+
frontImageUri: z$3.string().nullable(),
|
|
14019
|
+
backImageUri: z$3.string().nullable(),
|
|
14020
|
+
idDocStatus: z$3.enum(IdDocStatusZod).nullable()
|
|
14021
|
+
});
|
|
14022
|
+
const responseBodySchema$2 = z$3.object({
|
|
14023
|
+
message: z$3.string(),
|
|
14024
|
+
idDocument: idDocumentOutputSchema
|
|
14025
|
+
});
|
|
14026
|
+
const createDocumentRoute = createRoute({
|
|
14027
|
+
method: "post",
|
|
14028
|
+
path: "/{partyId}/id-documents",
|
|
14029
|
+
summary: "Create ID document and upload file",
|
|
14030
|
+
tags: ["Documents"],
|
|
14031
|
+
// middleware: [jwt, signature(), idempotency()],
|
|
14032
|
+
// security: [{ JwtAuth: [] }],
|
|
14033
|
+
request: {
|
|
14034
|
+
// headers: z.object({
|
|
14035
|
+
// 'X-Idempotency-Key': XIdempotencyKeyHeaderSchema,
|
|
14036
|
+
// 'X-Signature': XSignatureHeaderSchema,
|
|
14037
|
+
// 'X-Signature-Key': XSignatureKeyHeaderSchema,
|
|
14038
|
+
// }),
|
|
14039
|
+
body: {
|
|
14040
|
+
content: {
|
|
14041
|
+
"multipart/form-data": {
|
|
14042
|
+
schema: multipartOpenApiSchema
|
|
14043
|
+
}
|
|
14044
|
+
},
|
|
14045
|
+
required: true
|
|
14046
|
+
},
|
|
14047
|
+
params: paramsSchema$2
|
|
14048
|
+
},
|
|
14049
|
+
responses: {
|
|
14050
|
+
200: {
|
|
14051
|
+
description: "Document created and file uploaded",
|
|
14052
|
+
content: {
|
|
14053
|
+
"application/json": {
|
|
14054
|
+
schema: responseBodySchema$2
|
|
14055
|
+
}
|
|
14056
|
+
}
|
|
14057
|
+
},
|
|
14058
|
+
400: {
|
|
14059
|
+
description: "Invalid request",
|
|
14060
|
+
content: {
|
|
14061
|
+
"application/json": {
|
|
14062
|
+
schema: z$3.object({ message: z$3.string() })
|
|
14063
|
+
}
|
|
14064
|
+
}
|
|
14065
|
+
},
|
|
14066
|
+
500: {
|
|
14067
|
+
description: "Internal server error",
|
|
14068
|
+
content: {
|
|
14069
|
+
"application/json": {
|
|
14070
|
+
schema: z$3.object({ message: z$3.string() })
|
|
14071
|
+
}
|
|
14072
|
+
}
|
|
14073
|
+
}
|
|
14074
|
+
}
|
|
14075
|
+
});
|
|
14076
|
+
new OpenAPIHono().openapi(
|
|
14077
|
+
createDocumentRoute,
|
|
14078
|
+
async (context) => {
|
|
14079
|
+
const rawBody = await context.req.parseBody();
|
|
14080
|
+
const { partyId } = await context.req.param();
|
|
14081
|
+
const idDocumentRaw = rawBody.idDocument;
|
|
14082
|
+
const documentSide = rawBody.documentSide;
|
|
14083
|
+
const file = rawBody.file;
|
|
14084
|
+
if (typeof idDocumentRaw !== "string" || !DOCUMENT_SIDE.includes(documentSide) || !(file instanceof File)) {
|
|
14085
|
+
return context.json({ message: "Invalid multipart payload" }, 400);
|
|
14086
|
+
}
|
|
14087
|
+
const idDocumentJson = JSON.parse(JSON.parse(idDocumentRaw));
|
|
14088
|
+
const idDocumentResult = idDocumentCreateInputSchema.safeParse(idDocumentJson);
|
|
14089
|
+
if (!idDocumentResult.success) {
|
|
14090
|
+
console.error(idDocumentResult.error);
|
|
14091
|
+
return context.json({ message: "Could not parse IdDocument" }, 400);
|
|
14092
|
+
}
|
|
14093
|
+
const {
|
|
14094
|
+
data: createdIdDocument,
|
|
14095
|
+
error: createError,
|
|
14096
|
+
message
|
|
14097
|
+
} = await context.env.MASTER_DATA_MANAGEMENT_SERVICE.createIdDocument({
|
|
14098
|
+
idDocument: idDocumentResult.data,
|
|
14099
|
+
partyId
|
|
14100
|
+
});
|
|
14101
|
+
if (!createdIdDocument || createError) {
|
|
14102
|
+
console.error(message);
|
|
14103
|
+
return context.json({ message: "Could not create IdDocument" }, 500);
|
|
14104
|
+
}
|
|
14105
|
+
const bytes = new Uint8Array(await file.arrayBuffer());
|
|
14106
|
+
const { data: uploadResult, error: uploadError } = await context.env.DOCUMENT_SERVICE.uploadDocument({
|
|
14107
|
+
entityType: "client",
|
|
14108
|
+
entityId: createdIdDocument.id,
|
|
14109
|
+
type: "kyc",
|
|
14110
|
+
metadata: {},
|
|
14111
|
+
file: {
|
|
14112
|
+
bytes,
|
|
14113
|
+
type: file.type,
|
|
14114
|
+
name: file.name,
|
|
14115
|
+
size: file.size
|
|
14116
|
+
}
|
|
14117
|
+
});
|
|
14118
|
+
if (!uploadResult || uploadError) {
|
|
14119
|
+
return context.json({ message: "File upload failed" }, 500);
|
|
14120
|
+
}
|
|
14121
|
+
return context.json(
|
|
14122
|
+
{
|
|
14123
|
+
message: "IdDocument created successfully",
|
|
14124
|
+
idDocument: {
|
|
14125
|
+
...createdIdDocument,
|
|
14126
|
+
frontImageUri: documentSide === "front" ? uploadResult.storageUrl : createdIdDocument.frontImageUri,
|
|
14127
|
+
backImageUri: documentSide === "back" ? uploadResult.storageUrl : createdIdDocument.backImageUri
|
|
14128
|
+
}
|
|
14129
|
+
},
|
|
14130
|
+
200
|
|
14131
|
+
);
|
|
14132
|
+
}
|
|
14133
|
+
);
|
|
14134
|
+
|
|
14135
|
+
const XIdempotencyKeyHeaderSchema = z$3.string().openapi({
|
|
14136
|
+
description: "Unique identifier header to ensure the request is processed only once.",
|
|
14137
|
+
example: "4ac15c22-2bd3-426f-b915-bfd5febdb7df"
|
|
14138
|
+
});
|
|
14139
|
+
const XSignatureHeaderSchema = z$3.string().openapi({
|
|
14140
|
+
description: "Payload signature header to verify request body integrity.",
|
|
14141
|
+
example: "FIXAxHO6QqH3M7t4MatM8U6l/nIqWj7jIEW2U6/771MGUorSywy+GmKIG3B1mxT1jR7qPtBHQ5YSO8O53iCvOh6kIhbGXtVe/3C61dsEykLbmntV3nF4DY8/HyfF8a6c2Asc5bvgHrhosGi3s/ouoNowMpsckyq66We8H5gRbXlqJm4Bl1zWWQah4aQLX548L8DLx5+EIgArNMVVG8ryCES99aovJBKrQQMpQLwss1sSFuUZ1kdBCodtvxgTOXOugnZ1UNCmUNFXryQ6bn7wY7Punml/rwR/zTQ9j4SX07iFeQC5rgm9/zi29DBluegu+b8/G8oXrf6L4hugbMEKJfLRfKjNHCrjCooKtInoYxwNEfJyJ9mhqdBoeIBca9zgPpewdbwFLXVV82TYR+xZiywDcHKQ62IzQp07NOMCl4xArSJ3vIWUftSYpLIwomyjQEbY27oGiubUF4krEKgHnMYalCn0ruYOwFik2Pa6FEfIZo0TSXDC24UHQb5mJNPYpv2hny7U5CZPmBvjaRGMVnE+WgRUT19cwqlSL3pWAfeSn1Wro7lYBp/PmlRPgYIxl9GJwNlQ0G+NzP9cMSJbmI5fwErDNgJAaPaMwZbJ3y8ikmbBkkXNPKvQrWVGCJ4nP+/f8yYzMZq272EFx984pSoo2yAeBJnrxbW+AlZxyIo="
|
|
14142
|
+
});
|
|
14143
|
+
const XSignatureKeyHeaderSchema = z$3.string().openapi({
|
|
14144
|
+
description: "Signature key identifier header to specify which key was used for payload signing.",
|
|
14145
|
+
example: "ixtal"
|
|
14146
|
+
});
|
|
14147
|
+
const ALLOWED_ID_DOCUMENTS_FILTERS = {
|
|
14148
|
+
PARTY_ID: "filterIdDocumentPartyId",
|
|
14149
|
+
ISSUER: "filterIdDocumentIssuer"
|
|
14150
|
+
};
|
|
14151
|
+
|
|
14152
|
+
const idDocumentsListOutputSchema = z$3.object({
|
|
14153
|
+
totalCount: z$3.number(),
|
|
14154
|
+
idDocuments: z$3.array(idDocumentOutputSchema)
|
|
14155
|
+
});
|
|
14156
|
+
const paramsSchema$1 = z$3.object({
|
|
14157
|
+
partyId: z$3.uuid()
|
|
14158
|
+
});
|
|
14159
|
+
const arrayQuery = (schema) => z$3.preprocess((val) => {
|
|
14160
|
+
if (typeof val === "string") {
|
|
14161
|
+
return val.includes(",") ? val.split(",") : [val];
|
|
14162
|
+
}
|
|
14163
|
+
return val;
|
|
14164
|
+
}, schema.array()).optional();
|
|
14165
|
+
const querySchema = z$3.object({
|
|
14166
|
+
page: z$3.coerce.number().positive().default(1),
|
|
14167
|
+
limit: z$3.coerce.number().positive().default(20),
|
|
14168
|
+
sortColumn: z$3.string().default("updatedAt"),
|
|
14169
|
+
sortDirection: z$3.enum(["asc", "desc"]).default("desc"),
|
|
14170
|
+
[ALLOWED_ID_DOCUMENTS_FILTERS.PARTY_ID]: arrayQuery(z$3.uuid()),
|
|
14171
|
+
[ALLOWED_ID_DOCUMENTS_FILTERS.ISSUER]: arrayQuery(z$3.string()),
|
|
14172
|
+
search: z$3.string().optional()
|
|
14173
|
+
});
|
|
14174
|
+
const responseBodySchema$1 = z$3.object({
|
|
14175
|
+
message: z$3.string(),
|
|
14176
|
+
idDocumentsList: idDocumentsListOutputSchema
|
|
14177
|
+
});
|
|
14178
|
+
const getIdDocumentsListRoute = createRoute({
|
|
14179
|
+
method: "get",
|
|
14180
|
+
path: "/{partyId}/id-documents",
|
|
14181
|
+
summary: "List party ID documents",
|
|
14182
|
+
tags: ["Documents"],
|
|
14183
|
+
request: {
|
|
14184
|
+
params: paramsSchema$1,
|
|
14185
|
+
query: querySchema
|
|
14186
|
+
},
|
|
14187
|
+
responses: {
|
|
14188
|
+
200: {
|
|
14189
|
+
description: "ID documents list fetched",
|
|
14190
|
+
content: {
|
|
14191
|
+
"application/json": {
|
|
14192
|
+
schema: responseBodySchema$1
|
|
14193
|
+
}
|
|
14194
|
+
}
|
|
14195
|
+
},
|
|
14196
|
+
404: {
|
|
14197
|
+
description: "ID documents not found",
|
|
14198
|
+
content: {
|
|
14199
|
+
"application/json": {
|
|
14200
|
+
schema: z$3.object({ message: z$3.string() })
|
|
14201
|
+
}
|
|
14202
|
+
}
|
|
14203
|
+
},
|
|
14204
|
+
500: {
|
|
14205
|
+
description: "Internal server error",
|
|
14206
|
+
content: {
|
|
14207
|
+
"application/json": {
|
|
14208
|
+
schema: z$3.object({ message: z$3.string() })
|
|
14209
|
+
}
|
|
14210
|
+
}
|
|
14211
|
+
}
|
|
14212
|
+
}
|
|
14213
|
+
});
|
|
14214
|
+
new OpenAPIHono().openapi(
|
|
14215
|
+
getIdDocumentsListRoute,
|
|
14216
|
+
async (context) => {
|
|
14217
|
+
const { partyId } = context.req.valid("param");
|
|
14218
|
+
const { sortColumn, sortDirection, limit, page, ...filters } = context.req.valid("query");
|
|
14219
|
+
const { data: idDocumentsList, error } = await context.env.MASTER_DATA_MANAGEMENT_SERVICE.getIdDocumentsList({
|
|
14220
|
+
pagination: {
|
|
14221
|
+
page,
|
|
14222
|
+
limit,
|
|
14223
|
+
sort: {
|
|
14224
|
+
column: sortColumn,
|
|
14225
|
+
direction: sortDirection
|
|
14226
|
+
},
|
|
14227
|
+
filterIdDocumentPartyId: partyId,
|
|
14228
|
+
...filters
|
|
14229
|
+
}
|
|
14230
|
+
});
|
|
14231
|
+
if (!idDocumentsList || error) {
|
|
14232
|
+
return context.json({ message: "Could not list id documents" }, 404);
|
|
14233
|
+
}
|
|
14234
|
+
return context.json(
|
|
14235
|
+
{
|
|
14236
|
+
message: "ID documents listed successfully",
|
|
14237
|
+
idDocumentsList
|
|
14238
|
+
},
|
|
14239
|
+
200
|
|
14240
|
+
);
|
|
14241
|
+
}
|
|
14242
|
+
);
|
|
14243
|
+
|
|
14244
|
+
const algParams = {
|
|
14245
|
+
RSA: {
|
|
14246
|
+
name: "RSASSA-PKCS1-v1_5",
|
|
14247
|
+
hash: { name: "SHA-256" }
|
|
14248
|
+
},
|
|
14249
|
+
EC: {
|
|
14250
|
+
name: "ECDSA",
|
|
14251
|
+
namedCurve: "P-256"
|
|
14252
|
+
},
|
|
14253
|
+
HMAC: {
|
|
14254
|
+
name: "HMAC",
|
|
14255
|
+
hash: { name: "SHA-256" }
|
|
14256
|
+
}
|
|
14257
|
+
};
|
|
14258
|
+
const verifyPayloadSignature = async ({
|
|
14259
|
+
signature,
|
|
14260
|
+
data,
|
|
14261
|
+
publicKey,
|
|
14262
|
+
algorithm = "RSA"
|
|
14263
|
+
}) => {
|
|
14264
|
+
const binaryPublicKey = Uint8Array.from(
|
|
14265
|
+
atob(publicKey),
|
|
14266
|
+
(c) => c.charCodeAt(0)
|
|
14267
|
+
);
|
|
14268
|
+
const format = algorithm === "HMAC" ? "raw" : "spki";
|
|
14269
|
+
const importedPublicKey = await crypto.subtle.importKey(
|
|
14270
|
+
format,
|
|
14271
|
+
binaryPublicKey,
|
|
14272
|
+
algParams[algorithm],
|
|
14273
|
+
false,
|
|
14274
|
+
["verify"]
|
|
14275
|
+
);
|
|
14276
|
+
const encodedPayload = new TextEncoder().encode(data);
|
|
14277
|
+
const decodedSignature = Uint8Array.from(
|
|
14278
|
+
atob(signature),
|
|
14279
|
+
(c) => c.charCodeAt(0)
|
|
14280
|
+
);
|
|
14281
|
+
const isValid = await crypto.subtle.verify(
|
|
14282
|
+
algParams[algorithm],
|
|
14283
|
+
importedPublicKey,
|
|
14284
|
+
decodedSignature,
|
|
14285
|
+
encodedPayload
|
|
14286
|
+
);
|
|
14287
|
+
return isValid;
|
|
14288
|
+
};
|
|
14289
|
+
|
|
14290
|
+
const validateBearerScheme = (header) => {
|
|
14291
|
+
return header.startsWith("Bearer ") && header.length > 7 && !header.slice(7).includes(" ");
|
|
14292
|
+
};
|
|
14293
|
+
const extractBearerToken = (header) => {
|
|
14294
|
+
return header.slice(7).trim();
|
|
14295
|
+
};
|
|
14296
|
+
const validateBearerToken = (bearerToken) => {
|
|
14297
|
+
return z$2.jwt().safeParse(bearerToken).success;
|
|
14298
|
+
};
|
|
14299
|
+
|
|
14300
|
+
const idempotency = () => {
|
|
14301
|
+
return createMiddleware(async (context, next) => {
|
|
14302
|
+
if (!context.env.MIDDLEWARE_IDEMPOTENCY_DISABLED) {
|
|
14303
|
+
const idempotencyKeyHeader = context.req.header("x-idempotency-key");
|
|
14304
|
+
if (!idempotencyKeyHeader) {
|
|
14305
|
+
throw new HTTPException(401, {
|
|
14306
|
+
message: `The 'x-idempotency-key' header must exist and must have a value.`
|
|
14307
|
+
});
|
|
14308
|
+
}
|
|
14309
|
+
const existingIdempotencyRecord = await context.env.IDEMPOTENCY_KV.get(idempotencyKeyHeader);
|
|
14310
|
+
if (existingIdempotencyRecord) {
|
|
14311
|
+
throw new HTTPException(409, {
|
|
14312
|
+
message: "The identical request has already been processed. The idempotency key is not unique."
|
|
14313
|
+
});
|
|
14314
|
+
}
|
|
14315
|
+
await context.env.IDEMPOTENCY_KV.put(
|
|
14316
|
+
idempotencyKeyHeader,
|
|
14317
|
+
idempotencyKeyHeader,
|
|
14318
|
+
{
|
|
14319
|
+
expirationTtl: 60 * 60 * 24 * 3
|
|
14320
|
+
// 3 days
|
|
14321
|
+
}
|
|
14322
|
+
);
|
|
14323
|
+
context.set("idempotency", {
|
|
14324
|
+
key: idempotencyKeyHeader
|
|
14325
|
+
});
|
|
14326
|
+
}
|
|
14327
|
+
await next();
|
|
14328
|
+
});
|
|
14329
|
+
};
|
|
14330
|
+
|
|
14331
|
+
const jwt = () => {
|
|
14332
|
+
return createMiddleware(async (context, next) => {
|
|
14333
|
+
if (!context.env.MIDDLEWARE_JWT_DISABLED) {
|
|
14334
|
+
const authorizationHeader = context.req.header("authorization");
|
|
14335
|
+
if (!authorizationHeader) {
|
|
14336
|
+
throw new HTTPException(401, {
|
|
14337
|
+
message: `The 'authorization' header must exist and must have a value.`
|
|
14338
|
+
});
|
|
14339
|
+
}
|
|
14340
|
+
if (!validateBearerScheme(authorizationHeader)) {
|
|
14341
|
+
throw new HTTPException(401, {
|
|
14342
|
+
message: `The 'authorization' header value must use the Bearer scheme.`
|
|
14343
|
+
});
|
|
14344
|
+
}
|
|
14345
|
+
const bearerToken = extractBearerToken(authorizationHeader);
|
|
14346
|
+
if (!validateBearerToken(bearerToken)) {
|
|
14347
|
+
throw new HTTPException(401, {
|
|
14348
|
+
message: `The Bearer token in the 'authorization' header value must be a JWT.`
|
|
14349
|
+
});
|
|
14350
|
+
}
|
|
14351
|
+
const { data, error } = await context.env.AUTH_SERVICE.verifyAccessToken({
|
|
14352
|
+
accessToken: bearerToken
|
|
14353
|
+
});
|
|
14354
|
+
if (!data || error) {
|
|
14355
|
+
throw new HTTPException(401, {
|
|
14356
|
+
message: "The JWT must contain valid user information."
|
|
14357
|
+
});
|
|
14358
|
+
}
|
|
14359
|
+
const rawUserMetaDataString = data.payload.user.rawUserMetaData;
|
|
14360
|
+
const rawUserMetaData = rawUserMetaDataString ? JSON.parse(rawUserMetaDataString) : null;
|
|
14361
|
+
const identityId = rawUserMetaData.organizationId ?? rawUserMetaData.exchangeOfficeId;
|
|
14362
|
+
if (!identityId) {
|
|
14363
|
+
throw new HTTPException(422, {
|
|
14364
|
+
message: "User data integrity check failed."
|
|
14365
|
+
});
|
|
14366
|
+
}
|
|
14367
|
+
context.set("identity", {
|
|
14368
|
+
...data.payload,
|
|
14369
|
+
user: {
|
|
14370
|
+
...data.payload.user,
|
|
14371
|
+
organizationId: rawUserMetaData.organizationId,
|
|
14372
|
+
exchangeOfficeId: rawUserMetaData.exchangeOfficeId
|
|
14373
|
+
}
|
|
14374
|
+
});
|
|
14375
|
+
}
|
|
14376
|
+
await next();
|
|
14377
|
+
});
|
|
14378
|
+
};
|
|
14379
|
+
|
|
14380
|
+
const signature = () => {
|
|
14381
|
+
return createMiddleware(async (context, next) => {
|
|
14382
|
+
if (!context.env.MIDDLEWARE_SIGNATURE_DISABLED) {
|
|
14383
|
+
const signatureHeader = context.req.header("x-signature");
|
|
14384
|
+
if (!signatureHeader) {
|
|
14385
|
+
throw new HTTPException(401, {
|
|
14386
|
+
message: `The 'x-signature' header must exist and must have a value.`
|
|
14387
|
+
});
|
|
14388
|
+
}
|
|
14389
|
+
const signatureKeyHeader = context.req.header("X-Signature-Key");
|
|
14390
|
+
if (!signatureKeyHeader) {
|
|
14391
|
+
throw new HTTPException(401, {
|
|
14392
|
+
message: `The 'x-signature-key' header must exist and must have a value.`
|
|
14393
|
+
});
|
|
14394
|
+
}
|
|
14395
|
+
const payload = JSON.stringify(await context.req.json().catch(() => null));
|
|
14396
|
+
const identityContext = context.get("identity");
|
|
14397
|
+
const organizationId = identityContext.user.organizationId;
|
|
14398
|
+
const exchangeOfficeId = identityContext.user.exchangeOfficeId;
|
|
14399
|
+
const identityId = organizationId ?? exchangeOfficeId;
|
|
14400
|
+
if (!identityId) {
|
|
14401
|
+
throw new HTTPException(401, {
|
|
14402
|
+
message: "Failed to retrieve request identity ID."
|
|
14403
|
+
});
|
|
14404
|
+
}
|
|
14405
|
+
const { data: organization, error } = await context.env.ORGANIZATION_SERVICE.getOrganization({
|
|
14406
|
+
organizationId: identityId
|
|
14407
|
+
});
|
|
14408
|
+
if (!organization || error) {
|
|
14409
|
+
throw new HTTPException(404, {
|
|
14410
|
+
message: "Failed to retrieve organization."
|
|
14411
|
+
});
|
|
14412
|
+
}
|
|
14413
|
+
const signatureKey = organization.signatureKeys.filter(
|
|
14414
|
+
(signatureKey2) => signatureKey2.name === signatureKeyHeader
|
|
14415
|
+
)[0];
|
|
14416
|
+
if (!signatureKey) {
|
|
14417
|
+
throw new HTTPException(404, {
|
|
14418
|
+
message: "Signature key not found."
|
|
14419
|
+
});
|
|
14420
|
+
}
|
|
14421
|
+
const isVerified = await verifyPayloadSignature({
|
|
14422
|
+
signature: signatureHeader,
|
|
14423
|
+
publicKey: signatureKey.publicKey,
|
|
14424
|
+
data: payload
|
|
14425
|
+
});
|
|
14426
|
+
if (!isVerified) {
|
|
14427
|
+
throw new HTTPException(401, {
|
|
14428
|
+
message: "Invalid signature key or signature."
|
|
14429
|
+
});
|
|
14430
|
+
}
|
|
14431
|
+
}
|
|
14432
|
+
await next();
|
|
14433
|
+
});
|
|
14434
|
+
};
|
|
14435
|
+
|
|
14436
|
+
const paramsSchema = z$3.object({
|
|
14437
|
+
id: z$3.uuid()
|
|
14438
|
+
});
|
|
14439
|
+
const idDocumentUpdateInputSchema = z$3.object({
|
|
14440
|
+
partyId: z$3.uuid().optional(),
|
|
14441
|
+
idDocType: z$3.enum(IdDocTypeZod).optional(),
|
|
14442
|
+
idDocNumber: z$3.string().optional(),
|
|
14443
|
+
idDocHolderName: z$3.string().optional(),
|
|
14444
|
+
issueDate: z$3.coerce.date().optional(),
|
|
14445
|
+
expirationDate: z$3.coerce.date().optional(),
|
|
14446
|
+
issuer: z$3.string().optional(),
|
|
14447
|
+
countryOfIssue: z$3.enum(COUNTRY_CODES_2).optional(),
|
|
14448
|
+
frontImageUri: z$3.string().optional(),
|
|
14449
|
+
backImageUri: z$3.string().optional(),
|
|
14450
|
+
idDocStatus: z$3.enum(IdDocStatusZod).optional()
|
|
14451
|
+
});
|
|
14452
|
+
const responseBodySchema = z$3.object({
|
|
14453
|
+
message: z$3.string(),
|
|
14454
|
+
idDocument: idDocumentOutputSchema
|
|
14455
|
+
});
|
|
14456
|
+
const updateIdDocumentRoute = createRoute({
|
|
14457
|
+
method: "put",
|
|
14458
|
+
path: "/{partyId}/id-documents/{id}",
|
|
14459
|
+
summary: "Update party document",
|
|
14460
|
+
tags: ["Documents"],
|
|
14461
|
+
middleware: [jwt, signature(), idempotency()],
|
|
14462
|
+
security: [{ JwtAuth: [] }],
|
|
14463
|
+
request: {
|
|
14464
|
+
headers: z$3.object({
|
|
14465
|
+
"X-Idempotency-Key": XIdempotencyKeyHeaderSchema,
|
|
14466
|
+
"X-Signature": XSignatureHeaderSchema,
|
|
14467
|
+
"X-Signature-Key": XSignatureKeyHeaderSchema
|
|
14468
|
+
}),
|
|
14469
|
+
params: paramsSchema,
|
|
14470
|
+
body: {
|
|
14471
|
+
content: {
|
|
14472
|
+
"application/json": {
|
|
14473
|
+
schema: idDocumentUpdateInputSchema
|
|
14474
|
+
}
|
|
14475
|
+
},
|
|
14476
|
+
required: true
|
|
14477
|
+
}
|
|
14478
|
+
},
|
|
14479
|
+
responses: {
|
|
14480
|
+
200: {
|
|
14481
|
+
description: "ID document updated successfully",
|
|
14482
|
+
content: {
|
|
14483
|
+
"application/json": {
|
|
14484
|
+
schema: responseBodySchema
|
|
14485
|
+
}
|
|
14486
|
+
}
|
|
14487
|
+
},
|
|
14488
|
+
404: {
|
|
14489
|
+
description: "ID document not found",
|
|
14490
|
+
content: {
|
|
14491
|
+
"application/json": {
|
|
14492
|
+
schema: z$3.object({ message: z$3.string() })
|
|
14493
|
+
}
|
|
14494
|
+
}
|
|
14495
|
+
},
|
|
14496
|
+
500: {
|
|
14497
|
+
description: "Internal server error",
|
|
14498
|
+
content: {
|
|
14499
|
+
"application/json": {
|
|
14500
|
+
schema: z$3.object({ message: z$3.string() })
|
|
14501
|
+
}
|
|
14502
|
+
}
|
|
14503
|
+
}
|
|
14504
|
+
}
|
|
14505
|
+
});
|
|
14506
|
+
new OpenAPIHono().openapi(
|
|
14507
|
+
updateIdDocumentRoute,
|
|
14508
|
+
async (context) => {
|
|
14509
|
+
const { id } = context.req.valid("param");
|
|
14510
|
+
const patch = context.req.valid("json");
|
|
14511
|
+
const { data: existingDocument, error: fetchError } = await context.env.MASTER_DATA_MANAGEMENT_SERVICE.getIdDocument({ id });
|
|
14512
|
+
if (!existingDocument || fetchError) {
|
|
14513
|
+
return context.json({ message: "ID document not found" }, 404);
|
|
14514
|
+
}
|
|
14515
|
+
const fullIdDocument = {
|
|
14516
|
+
...existingDocument,
|
|
14517
|
+
...patch,
|
|
14518
|
+
id
|
|
14519
|
+
};
|
|
14520
|
+
const { data: updatedIdDocument, error: updateError } = await context.env.MASTER_DATA_MANAGEMENT_SERVICE.updateIdDocument({
|
|
14521
|
+
idDocument: fullIdDocument
|
|
14522
|
+
});
|
|
14523
|
+
if (!updatedIdDocument || updateError) {
|
|
14524
|
+
return context.json({ message: "Could not update ID document" }, 500);
|
|
14525
|
+
}
|
|
14526
|
+
return context.json(
|
|
14527
|
+
{
|
|
14528
|
+
message: "ID document updated successfully",
|
|
14529
|
+
idDocument: updatedIdDocument
|
|
14530
|
+
},
|
|
14531
|
+
200
|
|
14532
|
+
);
|
|
14533
|
+
}
|
|
14534
|
+
);
|
|
14535
|
+
|
|
14536
|
+
const messageResponseSchema = z$3.object({
|
|
14537
|
+
message: z$3.string()
|
|
14538
|
+
});
|
|
14539
|
+
|
|
14540
|
+
export { AddressTypeZod$1 as AddressTypeZod, AmlScoreTypeZod$1 as AmlScoreTypeZod, ClientStatusActionZod, ContactTypeZod$1 as ContactTypeZod, CustomerStatusZod$1 as CustomerStatusZod, DOCUMENT_SIDE, GenderZod$1 as GenderZod, IdDocStatusZod$1 as IdDocStatusZod, IdDocTypeZod$1 as IdDocTypeZod, IdentificationTypeZod, KycStatusZod$1 as KycStatusZod, PartyRelationshipTypeZod$1 as PartyRelationshipTypeZod, PartyTypeZod$1 as PartyTypeZod, TRADER_TYPE$1 as TRADER_TYPE, createMdmClient, createPartyInputSchema, idDocumentCreateInputSchema, idDocumentMultipartSchema, idDocumentOutputSchema, idDocumentUpdateInputSchema, idDocumentsListOutputSchema, messageResponseSchema, partiesOutputDataSchema, partyCreateOutputSchema, partyOutputSchema, partySchema$1 as partySchema, partyUpdateInputSchema, updatePartyOuputSchema };
|