@devizovaburza/mdm-sdk 0.0.12 → 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 +1082 -336
- package/dist/v1/index.d.cts +5436 -5458
- package/dist/v1/index.d.mts +5436 -5458
- package/dist/v1/index.d.ts +5436 -5458
- package/dist/v1/index.mjs +1083 -337
- package/package.json +1 -1
package/dist/v1/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { hc } from 'hono/client';
|
|
2
|
-
import { z as z$3 } from '@hono/zod-openapi';
|
|
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
4
|
import { z as z$1 } from 'zod/v4';
|
|
5
5
|
import { z as z$2 } from 'zod';
|
|
@@ -7,6 +7,8 @@ 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);
|
|
@@ -12888,7 +12890,7 @@ const recipientSelectSchema = bankAccountSelectSchema;
|
|
|
12888
12890
|
|
|
12889
12891
|
createInsertSchema(party);
|
|
12890
12892
|
createUpdateSchema(party);
|
|
12891
|
-
const partySchema$
|
|
12893
|
+
const partySchema$2 = z$3.object({
|
|
12892
12894
|
partyType: z$3.enum(PartyTypeZod),
|
|
12893
12895
|
language: z$3.enum(LANGUAGE_CODES),
|
|
12894
12896
|
id: z$3.uuid().nullable(),
|
|
@@ -12909,7 +12911,7 @@ const partyOutputSchema$1 = z$3.object({
|
|
|
12909
12911
|
createdAt: z$3.date().nullable(),
|
|
12910
12912
|
updatedAt: z$3.date().nullable()
|
|
12911
12913
|
});
|
|
12912
|
-
const createPartySchema = partySchema$
|
|
12914
|
+
const createPartySchema = partySchema$2.omit({ id: true });
|
|
12913
12915
|
z$3.object({
|
|
12914
12916
|
party: createPartySchema,
|
|
12915
12917
|
personalData: individualInsertSchema$1.omit({ partyId: true }).nullable(),
|
|
@@ -12922,7 +12924,7 @@ z$3.object({
|
|
|
12922
12924
|
});
|
|
12923
12925
|
z$3.object({
|
|
12924
12926
|
partyId: z$3.uuid(),
|
|
12925
|
-
party: partySchema$
|
|
12927
|
+
party: partySchema$2,
|
|
12926
12928
|
personalData: individualUpdateSchema$1.optional(),
|
|
12927
12929
|
organizationData: organizationUpdateSchema$1.optional(),
|
|
12928
12930
|
bankAccounts: z$3.array(bankAccountUpsertSchema).optional(),
|
|
@@ -13183,7 +13185,7 @@ z$2.object({
|
|
|
13183
13185
|
id: z$2.uuid()
|
|
13184
13186
|
});
|
|
13185
13187
|
|
|
13186
|
-
const ALLOWED_ID_DOCUMENTS_FILTERS = {
|
|
13188
|
+
const ALLOWED_ID_DOCUMENTS_FILTERS$1 = {
|
|
13187
13189
|
PARTY_ID: "filterIdDocumentPartyId",
|
|
13188
13190
|
ISSUER: "filterIdDocumentIssuer"
|
|
13189
13191
|
};
|
|
@@ -13195,8 +13197,8 @@ z$2.object({
|
|
|
13195
13197
|
column: z$2.string(),
|
|
13196
13198
|
direction: z$2.enum(["asc", "desc"])
|
|
13197
13199
|
}),
|
|
13198
|
-
[ALLOWED_ID_DOCUMENTS_FILTERS.PARTY_ID]: z$2.union([z$2.uuid(), z$2.uuid().array()]).optional(),
|
|
13199
|
-
[ALLOWED_ID_DOCUMENTS_FILTERS.ISSUER]: z$2.union([z$2.string(), z$2.string().array()]).optional(),
|
|
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(),
|
|
13200
13202
|
search: z$2.string().optional()
|
|
13201
13203
|
})
|
|
13202
13204
|
});
|
|
@@ -13253,8 +13255,49 @@ z$2.object({
|
|
|
13253
13255
|
id: z$2.uuid()
|
|
13254
13256
|
});
|
|
13255
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
|
+
});
|
|
13256
13300
|
const individualInsertSchema = z$3.object({
|
|
13257
|
-
partyId: z$3.uuid(),
|
|
13258
13301
|
internalId: z$3.string().optional(),
|
|
13259
13302
|
name: z$3.string(),
|
|
13260
13303
|
surname: z$3.string(),
|
|
@@ -13281,6 +13324,173 @@ const individualInsertSchema = z$3.object({
|
|
|
13281
13324
|
stayAbroad: z$3.boolean().optional(),
|
|
13282
13325
|
stayAbroadCountries: z$3.enum(COUNTRY_CODES_2).optional()
|
|
13283
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({
|
|
13353
|
+
...bankAccountMetadataSchema.shape,
|
|
13354
|
+
partyId: z$3.uuid(),
|
|
13355
|
+
internalId: z$3.string().optional(),
|
|
13356
|
+
holderName: z$3.string(),
|
|
13357
|
+
number: z$3.string().optional(),
|
|
13358
|
+
currency: bankAccountMetadataSchema.shape.currency.nonoptional(),
|
|
13359
|
+
countryCode: bankAccountMetadataSchema.shape.countryCode.nonoptional(),
|
|
13360
|
+
id: bankAccountMetadataSchema.shape.id.nonoptional()
|
|
13361
|
+
});
|
|
13362
|
+
const bankAccountInputSchema = updateBankAccountSchema$1.required({
|
|
13363
|
+
holderName: true,
|
|
13364
|
+
currency: true,
|
|
13365
|
+
countryCode: true
|
|
13366
|
+
}).omit({ id: true, partyId: 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 }),
|
|
13413
|
+
personalData: individualInsertSchema.nullable(),
|
|
13414
|
+
organizationData: createOrganizationInputSchema.nullable(),
|
|
13415
|
+
bankAccounts: z$3.array(bankAccountInputSchema),
|
|
13416
|
+
disponents: z$3.array(disponentSchema),
|
|
13417
|
+
addresses: z$3.array(createAddressInputSchema),
|
|
13418
|
+
aml: createAmlInputSchema,
|
|
13419
|
+
recipients: z$3.array(bankAccountInputSchema)
|
|
13420
|
+
});
|
|
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()
|
|
13431
|
+
});
|
|
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
|
+
});
|
|
13284
13494
|
const individualUpdateSchema = z$3.object({
|
|
13285
13495
|
id: z$3.uuid(),
|
|
13286
13496
|
partyId: z$3.uuid(),
|
|
@@ -13310,6 +13520,187 @@ const individualUpdateSchema = z$3.object({
|
|
|
13310
13520
|
stayAbroad: z$3.boolean().optional(),
|
|
13311
13521
|
stayAbroadCountries: z$3.enum(COUNTRY_CODES_2).optional()
|
|
13312
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({
|
|
13609
|
+
party: partySchema,
|
|
13610
|
+
personalData: individualUpdateSchema.nullable(),
|
|
13611
|
+
organizationData: organizationUpdateSchema.nullable(),
|
|
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(),
|
|
13616
|
+
aml: updateAmlInputSchema.optional()
|
|
13617
|
+
});
|
|
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
|
+
});
|
|
13313
13704
|
const individualOutputSchema = z$3.object({
|
|
13314
13705
|
id: z$3.uuid(),
|
|
13315
13706
|
partyId: z$3.uuid(),
|
|
@@ -13341,116 +13732,7 @@ const individualOutputSchema = z$3.object({
|
|
|
13341
13732
|
createdAt: z$3.coerce.date().nullable(),
|
|
13342
13733
|
updatedAt: z$3.coerce.date().nullable()
|
|
13343
13734
|
});
|
|
13344
|
-
|
|
13345
|
-
z$3.object({
|
|
13346
|
-
partyId: z$3.uuid(),
|
|
13347
|
-
internalId: z$3.string().optional(),
|
|
13348
|
-
businessName: z$3.string(),
|
|
13349
|
-
email: z$3.email("Invalid email format").optional(),
|
|
13350
|
-
phone: z$3.string().optional(),
|
|
13351
|
-
registeredNumber: z$3.string(),
|
|
13352
|
-
registeredIn: z$3.enum(COUNTRY_CODES_2),
|
|
13353
|
-
operatesIn: z$3.enum(COUNTRY_CODES_2),
|
|
13354
|
-
presentIn: z$3.enum(COUNTRY_CODES_2),
|
|
13355
|
-
monthlyVolumeIn: z$3.number(),
|
|
13356
|
-
monthlyVolumeOut: z$3.number(),
|
|
13357
|
-
ownedBy: z$3.string(),
|
|
13358
|
-
companyObjects: z$3.string(),
|
|
13359
|
-
annualTurnover: z$3.number(),
|
|
13360
|
-
numberOfEmployees: z$3.number().optional(),
|
|
13361
|
-
prosecuted: z$3.string().optional(),
|
|
13362
|
-
location: z$3.string().optional(),
|
|
13363
|
-
fileNumber: z$3.string().optional(),
|
|
13364
|
-
websiteUrl: z$3.url("Invalid website URL").optional(),
|
|
13365
|
-
vatPayer: z$3.boolean(),
|
|
13366
|
-
companyObjectsDescription: z$3.string(),
|
|
13367
|
-
turnover3years: z$3.number(),
|
|
13368
|
-
operationCountries: z$3.string(),
|
|
13369
|
-
riskyBusinessType: z$3.string().optional()
|
|
13370
|
-
});
|
|
13371
|
-
const organizationUpdateSchema = z$3.object({
|
|
13372
|
-
id: z$3.uuid(),
|
|
13373
|
-
partyId: z$3.uuid().optional(),
|
|
13374
|
-
internalId: z$3.string().optional(),
|
|
13375
|
-
businessName: z$3.string().optional(),
|
|
13376
|
-
email: z$3.email("Invalid email format").optional(),
|
|
13377
|
-
phone: z$3.string().optional(),
|
|
13378
|
-
registeredNumber: z$3.string().optional(),
|
|
13379
|
-
registeredIn: z$3.enum(COUNTRY_CODES_2).optional(),
|
|
13380
|
-
operatesIn: z$3.enum(COUNTRY_CODES_2).optional(),
|
|
13381
|
-
presentIn: z$3.enum(COUNTRY_CODES_2).optional(),
|
|
13382
|
-
monthlyVolumeIn: z$3.number().optional(),
|
|
13383
|
-
monthlyVolumeOut: z$3.number().optional(),
|
|
13384
|
-
ownedBy: z$3.string().optional(),
|
|
13385
|
-
companyObjects: z$3.string().optional(),
|
|
13386
|
-
annualTurnover: z$3.number().optional(),
|
|
13387
|
-
numberOfEmployees: z$3.number().optional(),
|
|
13388
|
-
prosecuted: z$3.string().optional(),
|
|
13389
|
-
location: z$3.string().optional(),
|
|
13390
|
-
fileNumber: z$3.string().optional(),
|
|
13391
|
-
websiteUrl: z$3.url("Invalid website URL").optional(),
|
|
13392
|
-
vatPayer: z$3.boolean().optional(),
|
|
13393
|
-
companyObjectsDescription: z$3.string(),
|
|
13394
|
-
turnover3years: z$3.number(),
|
|
13395
|
-
operationCountries: z$3.string(),
|
|
13396
|
-
riskyBusinessType: z$3.string().optional()
|
|
13397
|
-
});
|
|
13398
|
-
z$3.object({
|
|
13399
|
-
id: z$3.uuid(),
|
|
13400
|
-
partyId: z$3.uuid(),
|
|
13401
|
-
internalId: z$3.string().nullable(),
|
|
13402
|
-
businessName: z$3.string(),
|
|
13403
|
-
email: z$3.string().nullable(),
|
|
13404
|
-
phone: z$3.string().nullable(),
|
|
13405
|
-
registeredNumber: z$3.string(),
|
|
13406
|
-
registeredIn: z$3.enum(COUNTRY_CODES_2),
|
|
13407
|
-
operatesIn: z$3.enum(COUNTRY_CODES_2),
|
|
13408
|
-
presentIn: z$3.enum(COUNTRY_CODES_2),
|
|
13409
|
-
monthlyVolumeIn: z$3.number(),
|
|
13410
|
-
monthlyVolumeOut: z$3.number(),
|
|
13411
|
-
ownedBy: z$3.string(),
|
|
13412
|
-
companyObjects: z$3.string(),
|
|
13413
|
-
annualTurnover: z$3.number(),
|
|
13414
|
-
numberOfEmployees: z$3.number().nullable(),
|
|
13415
|
-
prosecuted: z$3.string().nullable(),
|
|
13416
|
-
location: z$3.string().nullable(),
|
|
13417
|
-
fileNumber: z$3.string().nullable(),
|
|
13418
|
-
websiteUrl: z$3.string().nullable(),
|
|
13419
|
-
vatPayer: z$3.boolean(),
|
|
13420
|
-
companyObjectsDescription: z$3.string(),
|
|
13421
|
-
turnover3years: z$3.number(),
|
|
13422
|
-
operationCountries: z$3.string(),
|
|
13423
|
-
riskyBusinessType: z$3.string().nullable(),
|
|
13424
|
-
createdAt: z$3.coerce.date().nullable(),
|
|
13425
|
-
updatedAt: z$3.coerce.date().nullable()
|
|
13426
|
-
});
|
|
13427
|
-
const createOrganizationInputSchema = z$3.object({
|
|
13428
|
-
partyId: z$3.uuid(),
|
|
13429
|
-
internalId: z$3.string().optional(),
|
|
13430
|
-
businessName: z$3.string(),
|
|
13431
|
-
email: z$3.string().optional(),
|
|
13432
|
-
phone: z$3.string().optional(),
|
|
13433
|
-
registeredNumber: z$3.string(),
|
|
13434
|
-
registeredIn: z$3.enum(COUNTRY_CODES_2),
|
|
13435
|
-
operatesIn: z$3.enum(COUNTRY_CODES_2),
|
|
13436
|
-
presentIn: z$3.enum(COUNTRY_CODES_2),
|
|
13437
|
-
monthlyVolumeIn: z$3.number(),
|
|
13438
|
-
monthlyVolumeOut: z$3.number(),
|
|
13439
|
-
ownedBy: z$3.string(),
|
|
13440
|
-
companyObjects: z$3.string(),
|
|
13441
|
-
annualTurnover: z$3.number(),
|
|
13442
|
-
numberOfEmployees: z$3.number(),
|
|
13443
|
-
prosecuted: z$3.string().optional(),
|
|
13444
|
-
location: z$3.string().optional(),
|
|
13445
|
-
fileNumber: z$3.string().optional(),
|
|
13446
|
-
websiteUrl: z$3.string().optional(),
|
|
13447
|
-
vatPayer: z$3.boolean(),
|
|
13448
|
-
companyObjectsDescription: z$3.string(),
|
|
13449
|
-
turnover3years: z$3.number(),
|
|
13450
|
-
operationCountries: z$3.string(),
|
|
13451
|
-
riskyBusinessType: z$3.string().optional()
|
|
13452
|
-
});
|
|
13453
|
-
const createOrganizationOutputSchema = z$3.object({
|
|
13735
|
+
const createOrganizationOutputSchema = z$3.object({
|
|
13454
13736
|
partyId: z$3.uuid(),
|
|
13455
13737
|
internalId: z$3.string().nullable(),
|
|
13456
13738
|
businessName: z$3.string(),
|
|
@@ -13476,53 +13758,6 @@ const createOrganizationOutputSchema = z$3.object({
|
|
|
13476
13758
|
operationCountries: z$3.string(),
|
|
13477
13759
|
riskyBusinessType: z$3.string().nullable()
|
|
13478
13760
|
});
|
|
13479
|
-
|
|
13480
|
-
const disponentSchema = z$3.discriminatedUnion("partyType", [
|
|
13481
|
-
z$3.object({
|
|
13482
|
-
partyType: z$3.literal("INDIVIDUAL"),
|
|
13483
|
-
data: individualInsertSchema.omit({ partyId: true })
|
|
13484
|
-
}),
|
|
13485
|
-
z$3.object({
|
|
13486
|
-
partyType: z$3.literal("ORGANIZATION"),
|
|
13487
|
-
data: createOrganizationInputSchema.omit({ partyId: true })
|
|
13488
|
-
})
|
|
13489
|
-
]);
|
|
13490
|
-
const disponentUpdateSchema = z$3.discriminatedUnion("partyType", [
|
|
13491
|
-
z$3.object({
|
|
13492
|
-
partyType: z$3.literal("INDIVIDUAL"),
|
|
13493
|
-
data: individualUpdateSchema
|
|
13494
|
-
}),
|
|
13495
|
-
z$3.object({
|
|
13496
|
-
partyType: z$3.literal("ORGANIZATION"),
|
|
13497
|
-
data: organizationUpdateSchema
|
|
13498
|
-
})
|
|
13499
|
-
]);
|
|
13500
|
-
const disponentOutputSchema = z$3.discriminatedUnion("partyType", [
|
|
13501
|
-
z$3.object({
|
|
13502
|
-
partyType: z$3.literal("INDIVIDUAL"),
|
|
13503
|
-
data: individualOutputSchema.nullable()
|
|
13504
|
-
}),
|
|
13505
|
-
z$3.object({
|
|
13506
|
-
partyType: z$3.literal("ORGANIZATION"),
|
|
13507
|
-
data: createOrganizationOutputSchema.nullable()
|
|
13508
|
-
})
|
|
13509
|
-
]);
|
|
13510
|
-
|
|
13511
|
-
const updateBankAccountSchema = z$3.object({
|
|
13512
|
-
...bankAccountMetadataSchema.shape,
|
|
13513
|
-
partyId: z$3.uuid(),
|
|
13514
|
-
internalId: z$3.string().optional(),
|
|
13515
|
-
holderName: z$3.string(),
|
|
13516
|
-
number: z$3.string().optional(),
|
|
13517
|
-
currency: bankAccountMetadataSchema.shape.currency.nonoptional(),
|
|
13518
|
-
countryCode: bankAccountMetadataSchema.shape.countryCode.nonoptional(),
|
|
13519
|
-
id: bankAccountMetadataSchema.shape.id.nonoptional()
|
|
13520
|
-
});
|
|
13521
|
-
const bankAccountInputSchema = updateBankAccountSchema.required({
|
|
13522
|
-
holderName: true,
|
|
13523
|
-
currency: true,
|
|
13524
|
-
countryCode: true
|
|
13525
|
-
}).omit({ id: true, partyId: true });
|
|
13526
13761
|
const bankAccountOutputSchema = z$3.object({
|
|
13527
13762
|
id: z$3.string(),
|
|
13528
13763
|
partyId: z$3.uuid(),
|
|
@@ -13543,90 +13778,16 @@ const bankAccountOutputSchema = z$3.object({
|
|
|
13543
13778
|
brBankNumber: z$3.string().nullable(),
|
|
13544
13779
|
updatedAt: z$3.coerce.date().nullable()
|
|
13545
13780
|
});
|
|
13546
|
-
|
|
13547
|
-
|
|
13548
|
-
|
|
13549
|
-
|
|
13550
|
-
|
|
13551
|
-
|
|
13552
|
-
|
|
13553
|
-
|
|
13554
|
-
|
|
13555
|
-
|
|
13556
|
-
isDistraint: z$3.boolean().default(false),
|
|
13557
|
-
estTxsVolumeMonth: z$3.string(),
|
|
13558
|
-
estTxsVolumeYear: z$3.string(),
|
|
13559
|
-
tradingCountries: z$3.string(),
|
|
13560
|
-
tradingSide: z$3.string(),
|
|
13561
|
-
acceptedAMLTermsAndConditions: z$3.boolean(),
|
|
13562
|
-
signatureMethod: z$3.string().optional(),
|
|
13563
|
-
existencePeriod: z$3.string().optional(),
|
|
13564
|
-
reputation: z$3.string().optional(),
|
|
13565
|
-
riskLevel: z$3.enum(AmlScoreTypeZod$1).optional(),
|
|
13566
|
-
kycStatus: z$3.enum(KycStatusZod$1).optional()
|
|
13567
|
-
});
|
|
13568
|
-
const updateAmlInputSchema = z$3.object({
|
|
13569
|
-
id: z$3.uuid(),
|
|
13570
|
-
partyId: z$3.uuid().optional(),
|
|
13571
|
-
internalId: z$3.string().optional(),
|
|
13572
|
-
sourceOfWealth: z$3.string().optional(),
|
|
13573
|
-
yearlyIncome: z$3.string().optional(),
|
|
13574
|
-
tradesPurpose: z$3.string().optional(),
|
|
13575
|
-
sourceOfIncome: z$3.string().optional(),
|
|
13576
|
-
transactionType: z$3.string().optional(),
|
|
13577
|
-
transactionTypeExpiry: z$3.date().optional(),
|
|
13578
|
-
isDistraint: z$3.boolean().optional(),
|
|
13579
|
-
estTxsVolumeMonth: z$3.string(),
|
|
13580
|
-
estTxsVolumeYear: z$3.string(),
|
|
13581
|
-
tradingCountries: z$3.string(),
|
|
13582
|
-
tradingSide: z$3.string(),
|
|
13583
|
-
acceptedAMLTermsAndConditions: z$3.boolean(),
|
|
13584
|
-
signatureMethod: z$3.string().optional(),
|
|
13585
|
-
existencePeriod: z$3.string().optional(),
|
|
13586
|
-
reputation: z$3.string().optional(),
|
|
13587
|
-
riskLevel: z$3.enum(AmlScoreTypeZod$1).optional(),
|
|
13588
|
-
kycStatus: z$3.enum(KycStatusZod$1).optional()
|
|
13589
|
-
});
|
|
13590
|
-
const createAmlOutputSchema = z$3.object({
|
|
13591
|
-
id: z$3.uuid(),
|
|
13592
|
-
partyId: z$3.uuid(),
|
|
13593
|
-
internalId: z$3.string().nullable(),
|
|
13594
|
-
sourceOfWealth: z$3.string(),
|
|
13595
|
-
yearlyIncome: z$3.string(),
|
|
13596
|
-
tradesPurpose: z$3.string().nullable(),
|
|
13597
|
-
sourceOfIncome: z$3.string(),
|
|
13598
|
-
transactionType: z$3.string().nullable(),
|
|
13599
|
-
transactionTypeExpiry: z$3.date().nullable(),
|
|
13600
|
-
isDistraint: z$3.boolean(),
|
|
13601
|
-
estTxsVolumeMonth: z$3.string(),
|
|
13602
|
-
estTxsVolumeYear: z$3.string(),
|
|
13603
|
-
tradingCountries: z$3.string(),
|
|
13604
|
-
tradingSide: z$3.string(),
|
|
13605
|
-
acceptedAMLTermsAndConditions: z$3.boolean(),
|
|
13606
|
-
signatureMethod: z$3.string().nullable(),
|
|
13607
|
-
existencePeriod: z$3.string().nullable(),
|
|
13608
|
-
reputation: z$3.string().nullable(),
|
|
13609
|
-
riskLevel: z$3.enum(AmlScoreTypeZod$1),
|
|
13610
|
-
kycStatus: z$3.enum(KycStatusZod$1).nullable(),
|
|
13611
|
-
createdAt: z$3.date().nullable(),
|
|
13612
|
-
updatedAt: z$3.date().nullable()
|
|
13613
|
-
});
|
|
13614
|
-
|
|
13615
|
-
const createAddressInputSchema = z$3.object({
|
|
13616
|
-
partyId: z$3.uuid(),
|
|
13617
|
-
addressType: z$3.enum(AddressTypeZod),
|
|
13618
|
-
internalId: z$3.string().optional(),
|
|
13619
|
-
street: z$3.string(),
|
|
13620
|
-
orientationNumber: z$3.string().optional(),
|
|
13621
|
-
descriptiveNumber: z$3.string().optional(),
|
|
13622
|
-
municipality: z$3.string().max(255),
|
|
13623
|
-
municipalityPart: z$3.string().optional(),
|
|
13624
|
-
zipCode: z$3.string().max(20),
|
|
13625
|
-
district: z$3.string().max(255),
|
|
13626
|
-
region: z$3.string().max(255),
|
|
13627
|
-
countryCode: z$3.enum(COUNTRY_CODES_2),
|
|
13628
|
-
ruianCode: z$3.string().optional()
|
|
13629
|
-
});
|
|
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
|
+
]);
|
|
13630
13791
|
const createAddressOutputSchema = z$3.object({
|
|
13631
13792
|
id: z$3.uuid(),
|
|
13632
13793
|
partyId: z$3.uuid(),
|
|
@@ -13645,68 +13806,32 @@ const createAddressOutputSchema = z$3.object({
|
|
|
13645
13806
|
createdAt: z$3.date().nullable(),
|
|
13646
13807
|
updatedAt: z$3.date().nullable()
|
|
13647
13808
|
});
|
|
13648
|
-
const
|
|
13809
|
+
const createAmlOutputSchema = z$3.object({
|
|
13649
13810
|
id: z$3.uuid(),
|
|
13650
13811
|
partyId: z$3.uuid(),
|
|
13651
|
-
internalId: z$3.string().optional(),
|
|
13652
|
-
addressType: z$3.enum(AddressTypeZod),
|
|
13653
|
-
street: z$3.string(),
|
|
13654
|
-
orientationNumber: z$3.string().optional(),
|
|
13655
|
-
descriptiveNumber: z$3.string().optional(),
|
|
13656
|
-
municipality: z$3.string().max(255),
|
|
13657
|
-
municipalityPart: z$3.string().optional(),
|
|
13658
|
-
zipCode: z$3.string().max(20),
|
|
13659
|
-
district: z$3.string().max(255),
|
|
13660
|
-
region: z$3.string().max(255),
|
|
13661
|
-
countryCode: z$3.enum(COUNTRY_CODES_2),
|
|
13662
|
-
ruianCode: z$3.string().optional()
|
|
13663
|
-
});
|
|
13664
|
-
|
|
13665
|
-
const partySchema = z$3.object({
|
|
13666
|
-
partyType: z$3.enum(PartyTypeZod),
|
|
13667
|
-
language: z$3.enum(LANGUAGE_CODES),
|
|
13668
|
-
id: z$3.uuid(),
|
|
13669
|
-
internalId: z$3.string().optional(),
|
|
13670
|
-
note: z$3.string().optional(),
|
|
13671
|
-
countryCode: z$3.enum(COUNTRY_CODES_2).optional()
|
|
13672
|
-
});
|
|
13673
|
-
const partyCreateOutputSchema = z$3.object({
|
|
13674
|
-
customerStatus: z$3.enum(CustomerStatusZod),
|
|
13675
|
-
partyType: z$3.enum(PartyTypeZod),
|
|
13676
|
-
language: z$3.enum(LANGUAGE_CODES),
|
|
13677
|
-
id: z$3.uuid(),
|
|
13678
|
-
internalId: z$3.string().nullable(),
|
|
13679
|
-
note: z$3.string().nullable(),
|
|
13680
|
-
countryCode: z$3.enum(COUNTRY_CODES_2).nullable(),
|
|
13681
|
-
createdAt: z$3.date().nullable(),
|
|
13682
|
-
updatedAt: z$3.date().nullable()
|
|
13683
|
-
});
|
|
13684
|
-
z$3.object({
|
|
13685
|
-
customerStatus: z$3.enum(CustomerStatusZod),
|
|
13686
|
-
partyType: z$3.enum(PartyTypeZod),
|
|
13687
|
-
language: z$3.enum(LANGUAGE_CODES),
|
|
13688
|
-
id: z$3.uuid(),
|
|
13689
13812
|
internalId: z$3.string().nullable(),
|
|
13690
|
-
|
|
13691
|
-
|
|
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(),
|
|
13692
13830
|
createdAt: z$3.date().nullable(),
|
|
13693
13831
|
updatedAt: z$3.date().nullable()
|
|
13694
13832
|
});
|
|
13695
|
-
const createPartyInputSchema = z$3.object({
|
|
13696
|
-
party: partySchema.omit({ id: true }),
|
|
13697
|
-
personalData: individualInsertSchema.omit({ partyId: true }).nullable(),
|
|
13698
|
-
organizationData: createOrganizationInputSchema.omit({ partyId: true }).nullable(),
|
|
13699
|
-
bankAccounts: z$3.array(bankAccountInputSchema),
|
|
13700
|
-
disponents: z$3.array(disponentSchema),
|
|
13701
|
-
addresses: z$3.array(createAddressInputSchema.omit({ partyId: true })),
|
|
13702
|
-
aml: createAmlInputSchema.omit({ partyId: true }),
|
|
13703
|
-
recipients: z$3.array(bankAccountInputSchema)
|
|
13704
|
-
});
|
|
13705
13833
|
const partyOutputSchema = z$3.object({
|
|
13706
|
-
party:
|
|
13707
|
-
id: z$3.uuid(),
|
|
13708
|
-
isClient: z$3.boolean()
|
|
13709
|
-
}).nullable(),
|
|
13834
|
+
party: partyBaseOutputSchema.nullable(),
|
|
13710
13835
|
personalData: individualOutputSchema.nullable(),
|
|
13711
13836
|
organizationData: createOrganizationOutputSchema.nullable(),
|
|
13712
13837
|
bankAccounts: z$3.array(bankAccountOutputSchema).nullable(),
|
|
@@ -13715,26 +13840,168 @@ const partyOutputSchema = z$3.object({
|
|
|
13715
13840
|
aml: createAmlOutputSchema.nullable(),
|
|
13716
13841
|
recipients: z$3.array(bankAccountOutputSchema).nullable()
|
|
13717
13842
|
});
|
|
13718
|
-
const
|
|
13719
|
-
|
|
13720
|
-
party:
|
|
13721
|
-
|
|
13722
|
-
|
|
13723
|
-
|
|
13724
|
-
|
|
13725
|
-
|
|
13726
|
-
|
|
13727
|
-
|
|
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
|
+
}
|
|
13728
13866
|
});
|
|
13729
|
-
|
|
13730
|
-
|
|
13731
|
-
|
|
13732
|
-
|
|
13733
|
-
|
|
13734
|
-
|
|
13735
|
-
|
|
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)
|
|
13736
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() });
|
|
13737
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
|
+
|
|
13975
|
+
const DOCUMENT_SIDE = ["front", "back"];
|
|
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
|
+
});
|
|
13738
14005
|
const idDocumentOutputSchema = z$3.object({
|
|
13739
14006
|
id: z$3.uuid(),
|
|
13740
14007
|
createdAt: z$3.iso.datetime().nullable(),
|
|
@@ -13752,21 +14019,422 @@ const idDocumentOutputSchema = z$3.object({
|
|
|
13752
14019
|
backImageUri: z$3.string().nullable(),
|
|
13753
14020
|
idDocStatus: z$3.enum(IdDocStatusZod).nullable()
|
|
13754
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
|
+
|
|
13755
14152
|
const idDocumentsListOutputSchema = z$3.object({
|
|
13756
14153
|
totalCount: z$3.number(),
|
|
13757
14154
|
idDocuments: z$3.array(idDocumentOutputSchema)
|
|
13758
14155
|
});
|
|
13759
|
-
const
|
|
13760
|
-
|
|
13761
|
-
|
|
13762
|
-
|
|
13763
|
-
|
|
13764
|
-
|
|
13765
|
-
|
|
13766
|
-
|
|
13767
|
-
|
|
13768
|
-
|
|
13769
|
-
|
|
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()
|
|
13770
14438
|
});
|
|
13771
14439
|
const idDocumentUpdateInputSchema = z$3.object({
|
|
13772
14440
|
partyId: z$3.uuid().optional(),
|
|
@@ -13781,14 +14449,92 @@ const idDocumentUpdateInputSchema = z$3.object({
|
|
|
13781
14449
|
backImageUri: z$3.string().optional(),
|
|
13782
14450
|
idDocStatus: z$3.enum(IdDocStatusZod).optional()
|
|
13783
14451
|
});
|
|
13784
|
-
const
|
|
13785
|
-
|
|
13786
|
-
|
|
13787
|
-
|
|
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
|
+
}
|
|
13788
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
|
+
);
|
|
13789
14535
|
|
|
13790
14536
|
const messageResponseSchema = z$3.object({
|
|
13791
14537
|
message: z$3.string()
|
|
13792
14538
|
});
|
|
13793
14539
|
|
|
13794
|
-
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, partyUpdateInputSchema, updatePartyOuputSchema };
|
|
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 };
|