@devizovaburza/mdm-sdk 0.0.18 → 0.0.20
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 +510 -266
- package/dist/v1/index.d.cts +3379 -2043
- package/dist/v1/index.d.mts +3379 -2043
- package/dist/v1/index.d.ts +3379 -2043
- package/dist/v1/index.mjs +510 -266
- package/package.json +1 -1
package/dist/v1/index.mjs
CHANGED
|
@@ -12623,7 +12623,8 @@ const organization = sqliteTable("organization", {
|
|
|
12623
12623
|
enum: COUNTRY_CODES_2
|
|
12624
12624
|
}),
|
|
12625
12625
|
vatId: text("vat_id"),
|
|
12626
|
-
court: text("court", { enum: COURT })
|
|
12626
|
+
court: text("court", { enum: COURT }),
|
|
12627
|
+
registerUri: text("register_uri")
|
|
12627
12628
|
});
|
|
12628
12629
|
|
|
12629
12630
|
const partyRelationship = sqliteTable("party_relationship", {
|
|
@@ -12668,7 +12669,8 @@ const bankAccount = sqliteTable("bank_account", {
|
|
|
12668
12669
|
...base,
|
|
12669
12670
|
internalId: text("internal_id"),
|
|
12670
12671
|
...bankAccount$1,
|
|
12671
|
-
partyId: text("party_id").notNull().references(() => party.id)
|
|
12672
|
+
partyId: text("party_id").notNull().references(() => party.id),
|
|
12673
|
+
statementUri: text("statement_uri")
|
|
12672
12674
|
});
|
|
12673
12675
|
|
|
12674
12676
|
const aml = sqliteTable("aml", {
|
|
@@ -12980,7 +12982,8 @@ const bankAccountUpsertSchema = bankAccountBaseInsertSchema.required({
|
|
|
12980
12982
|
id: true
|
|
12981
12983
|
});
|
|
12982
12984
|
const bankAccountSelectSchema = bankAccountUpdateSchema.required().extend({
|
|
12983
|
-
bankCode: z$3.string().nullable()
|
|
12985
|
+
bankCode: z$3.string().nullable(),
|
|
12986
|
+
statementUri: z$3.string().nullable()
|
|
12984
12987
|
});
|
|
12985
12988
|
z$3.array(bankAccountSelectSchema);
|
|
12986
12989
|
|
|
@@ -13068,7 +13071,8 @@ const organizationInsertSchema = z$3.object({
|
|
|
13068
13071
|
operationCountries: z$3.string(),
|
|
13069
13072
|
riskyBusinessType: z$3.string().optional().nullable(),
|
|
13070
13073
|
vatId: z$3.string().optional().nullable(),
|
|
13071
|
-
court: z$3.enum(COURT).optional().nullable()
|
|
13074
|
+
court: z$3.enum(COURT).optional().nullable(),
|
|
13075
|
+
registerUri: z$3.string().optional().nullable()
|
|
13072
13076
|
});
|
|
13073
13077
|
const organizationUpdateSchema$1 = z$3.object({
|
|
13074
13078
|
partyId: z$3.uuid().optional(),
|
|
@@ -13096,7 +13100,8 @@ const organizationUpdateSchema$1 = z$3.object({
|
|
|
13096
13100
|
operationCountries: z$3.string(),
|
|
13097
13101
|
riskyBusinessType: z$3.string().optional().nullable(),
|
|
13098
13102
|
vatId: z$3.string().optional().nullable(),
|
|
13099
|
-
court: z$3.enum(COURT).optional().nullable()
|
|
13103
|
+
court: z$3.enum(COURT).optional().nullable(),
|
|
13104
|
+
registerUri: z$3.string().optional().nullable()
|
|
13100
13105
|
});
|
|
13101
13106
|
const organizationOutputSchema = z$3.object({
|
|
13102
13107
|
id: z$3.uuid(),
|
|
@@ -13128,12 +13133,48 @@ const organizationOutputSchema = z$3.object({
|
|
|
13128
13133
|
stayAbroadCountries: z$3.enum(COUNTRY_CODES_2).nullable(),
|
|
13129
13134
|
vatId: z$3.string().nullable(),
|
|
13130
13135
|
court: z$3.enum(COURT).nullable(),
|
|
13136
|
+
registerUri: z$3.string().nullable(),
|
|
13131
13137
|
createdAt: z$3.coerce.date().nullable(),
|
|
13132
13138
|
updatedAt: z$3.coerce.date().nullable()
|
|
13133
13139
|
});
|
|
13134
13140
|
const organizationSelectSchema = organizationOutputSchema;
|
|
13135
13141
|
z$3.array(organizationOutputSchema);
|
|
13136
13142
|
|
|
13143
|
+
createInsertSchema(idDocument);
|
|
13144
|
+
createUpdateSchema(idDocument);
|
|
13145
|
+
const idDocumentBaseSelectSchema = createSelectSchema(idDocument);
|
|
13146
|
+
const idDocumentInsertSchema = z$3.object({
|
|
13147
|
+
partyId: z$3.uuid(),
|
|
13148
|
+
internalId: z$3.string().optional().nullable(),
|
|
13149
|
+
idDocType: z$3.enum(ID_DOC_TYPE),
|
|
13150
|
+
idDocNumber: z$3.string(),
|
|
13151
|
+
idDocHolderName: z$3.string(),
|
|
13152
|
+
issueDate: z$3.date().optional().nullable(),
|
|
13153
|
+
expirationDate: z$3.date().optional().nullable(),
|
|
13154
|
+
issuer: z$3.string().optional().nullable(),
|
|
13155
|
+
countryOfIssue: z$3.enum(COUNTRY_CODES_2).optional().nullable(),
|
|
13156
|
+
frontImageUri: z$3.url().optional().nullable(),
|
|
13157
|
+
backImageUri: z$3.url().optional().nullable(),
|
|
13158
|
+
idDocStatus: z$3.enum(ID_DOC_STATUS).optional().nullable()
|
|
13159
|
+
});
|
|
13160
|
+
const idDocumentUpdateSchema = z$3.object({
|
|
13161
|
+
id: z$3.uuid(),
|
|
13162
|
+
partyId: z$3.uuid().optional(),
|
|
13163
|
+
internalId: z$3.string().optional().nullable(),
|
|
13164
|
+
idDocType: z$3.enum(ID_DOC_TYPE).optional(),
|
|
13165
|
+
idDocNumber: z$3.string().optional(),
|
|
13166
|
+
idDocHolderName: z$3.string().optional(),
|
|
13167
|
+
issueDate: z$3.date().optional().nullable(),
|
|
13168
|
+
expirationDate: z$3.date().optional().nullable(),
|
|
13169
|
+
issuer: z$3.string().optional().nullable(),
|
|
13170
|
+
countryOfIssue: z$3.enum(COUNTRY_CODES_2).optional().nullable(),
|
|
13171
|
+
frontImageUri: z$3.url("Invalid URL format").optional().nullable(),
|
|
13172
|
+
backImageUri: z$3.url("Invalid URL format").optional().nullable(),
|
|
13173
|
+
idDocStatus: z$3.enum(ID_DOC_STATUS).optional().nullable()
|
|
13174
|
+
});
|
|
13175
|
+
const idDocumentSelectSchema = idDocumentBaseSelectSchema;
|
|
13176
|
+
const idDocumentSyncSchema = idDocumentInsertSchema.omit({ partyId: true }).extend({ id: z$3.uuid().optional(), idDocHolderName: z$3.string().optional() });
|
|
13177
|
+
|
|
13137
13178
|
z$3.discriminatedUnion("partyType", [
|
|
13138
13179
|
z$3.object({
|
|
13139
13180
|
partyType: z$3.literal("INDIVIDUAL"),
|
|
@@ -13148,7 +13189,9 @@ const disponentCreateSchema = z$3.discriminatedUnion("partyType", [
|
|
|
13148
13189
|
z$3.object({
|
|
13149
13190
|
partyType: z$3.literal("INDIVIDUAL"),
|
|
13150
13191
|
relationshipType: z$3.enum(PARTY_RELATIONSHIP_TYPE).optional(),
|
|
13151
|
-
data: individualInsertSchema$1.omit({ partyId: true })
|
|
13192
|
+
data: individualInsertSchema$1.omit({ partyId: true }).extend({
|
|
13193
|
+
identityDocuments: z$3.array(idDocumentSyncSchema).nullable().optional()
|
|
13194
|
+
})
|
|
13152
13195
|
}),
|
|
13153
13196
|
z$3.object({
|
|
13154
13197
|
partyType: z$3.literal("ORGANIZATION"),
|
|
@@ -13170,7 +13213,10 @@ const disponentSyncSchema$1 = z$3.discriminatedUnion("partyType", [
|
|
|
13170
13213
|
z$3.object({
|
|
13171
13214
|
partyType: z$3.literal("INDIVIDUAL"),
|
|
13172
13215
|
relationshipType: z$3.enum(PARTY_RELATIONSHIP_TYPE).optional(),
|
|
13173
|
-
data: individualInsertSchema$1.omit({ partyId: true }).extend({
|
|
13216
|
+
data: individualInsertSchema$1.omit({ partyId: true }).extend({
|
|
13217
|
+
id: z$3.uuid().optional(),
|
|
13218
|
+
identityDocuments: z$3.array(idDocumentSyncSchema).nullable().optional()
|
|
13219
|
+
})
|
|
13174
13220
|
}),
|
|
13175
13221
|
z$3.object({
|
|
13176
13222
|
partyType: z$3.literal("ORGANIZATION"),
|
|
@@ -13181,7 +13227,9 @@ const disponentSyncSchema$1 = z$3.discriminatedUnion("partyType", [
|
|
|
13181
13227
|
const disponentSelectSchema = z$3.discriminatedUnion("partyType", [
|
|
13182
13228
|
z$3.object({
|
|
13183
13229
|
partyType: z$3.literal("INDIVIDUAL"),
|
|
13184
|
-
data: individualSelectSchema
|
|
13230
|
+
data: individualSelectSchema.extend({
|
|
13231
|
+
identityDocuments: z$3.array(idDocumentSelectSchema).nullable()
|
|
13232
|
+
})
|
|
13185
13233
|
}),
|
|
13186
13234
|
z$3.object({
|
|
13187
13235
|
partyType: z$3.literal("ORGANIZATION"),
|
|
@@ -13191,39 +13239,6 @@ const disponentSelectSchema = z$3.discriminatedUnion("partyType", [
|
|
|
13191
13239
|
z$3.array(disponentSelectSchema).optional();
|
|
13192
13240
|
z$3.array(disponentUpdateSchema).optional();
|
|
13193
13241
|
|
|
13194
|
-
createInsertSchema(idDocument);
|
|
13195
|
-
createUpdateSchema(idDocument);
|
|
13196
|
-
createSelectSchema(idDocument);
|
|
13197
|
-
const idDocumentInsertSchema = z$3.object({
|
|
13198
|
-
partyId: z$3.uuid(),
|
|
13199
|
-
internalId: z$3.string().optional().nullable(),
|
|
13200
|
-
idDocType: z$3.enum(ID_DOC_TYPE),
|
|
13201
|
-
idDocNumber: z$3.string(),
|
|
13202
|
-
idDocHolderName: z$3.string(),
|
|
13203
|
-
issueDate: z$3.date().optional().nullable(),
|
|
13204
|
-
expirationDate: z$3.date().optional().nullable(),
|
|
13205
|
-
issuer: z$3.string().optional().nullable(),
|
|
13206
|
-
countryOfIssue: z$3.enum(COUNTRY_CODES_2).optional().nullable(),
|
|
13207
|
-
frontImageUri: z$3.url().optional().nullable(),
|
|
13208
|
-
backImageUri: z$3.url().optional().nullable(),
|
|
13209
|
-
idDocStatus: z$3.enum(ID_DOC_STATUS).optional().nullable()
|
|
13210
|
-
});
|
|
13211
|
-
const idDocumentUpdateSchema = z$3.object({
|
|
13212
|
-
id: z$3.uuid(),
|
|
13213
|
-
partyId: z$3.uuid().optional(),
|
|
13214
|
-
internalId: z$3.string().optional().nullable(),
|
|
13215
|
-
idDocType: z$3.enum(ID_DOC_TYPE).optional(),
|
|
13216
|
-
idDocNumber: z$3.string().optional(),
|
|
13217
|
-
idDocHolderName: z$3.string().optional(),
|
|
13218
|
-
issueDate: z$3.date().optional().nullable(),
|
|
13219
|
-
expirationDate: z$3.date().optional().nullable(),
|
|
13220
|
-
issuer: z$3.string().optional().nullable(),
|
|
13221
|
-
countryOfIssue: z$3.enum(COUNTRY_CODES_2).optional().nullable(),
|
|
13222
|
-
frontImageUri: z$3.url("Invalid URL format").optional().nullable(),
|
|
13223
|
-
backImageUri: z$3.url("Invalid URL format").optional().nullable(),
|
|
13224
|
-
idDocStatus: z$3.enum(ID_DOC_STATUS).optional().nullable()
|
|
13225
|
-
});
|
|
13226
|
-
|
|
13227
13242
|
const recipientBaseInsertSchema = createInsertSchema(recipient);
|
|
13228
13243
|
const recipientBaseUpdateSchema = createUpdateSchema(recipient);
|
|
13229
13244
|
createSelectSchema(recipient);
|
|
@@ -13234,7 +13249,9 @@ const recipientInsertSchema = bankAccountInsertSchema;
|
|
|
13234
13249
|
const recipientUpdateSchema = recipientBaseUpdateSchema.required({
|
|
13235
13250
|
id: true
|
|
13236
13251
|
});
|
|
13237
|
-
const recipientSelectSchema = bankAccountSelectSchema
|
|
13252
|
+
const recipientSelectSchema = bankAccountSelectSchema.omit({
|
|
13253
|
+
statementUri: true
|
|
13254
|
+
});
|
|
13238
13255
|
|
|
13239
13256
|
const productTxsConfigSchema = z$3.object({
|
|
13240
13257
|
fee: z$3.number(),
|
|
@@ -13279,7 +13296,6 @@ const productsOutputSchema$1 = z$3.object({
|
|
|
13279
13296
|
cbs: productCbsConfigSchema.nullable()
|
|
13280
13297
|
});
|
|
13281
13298
|
|
|
13282
|
-
const idDocumentSyncSchema = idDocumentInsertSchema.omit({ partyId: true }).extend({ id: z$3.uuid().optional(), idDocHolderName: z$3.string().optional() });
|
|
13283
13299
|
const legalRepresentativeSyncSchema$1 = individualInsertSchema$1.omit({ partyId: true }).extend({
|
|
13284
13300
|
id: z$3.uuid().optional(),
|
|
13285
13301
|
dateOfEstablishment: z$3.string(),
|
|
@@ -13328,20 +13344,24 @@ const partyOutputSchema$1 = z$3.object({
|
|
|
13328
13344
|
const createPartySchema = partySchema$2.omit({ id: true });
|
|
13329
13345
|
z$3.object({
|
|
13330
13346
|
party: createPartySchema,
|
|
13331
|
-
personalData: individualInsertSchema$1.omit({ partyId: true }).
|
|
13347
|
+
personalData: individualInsertSchema$1.omit({ partyId: true }).extend({
|
|
13348
|
+
identityDocuments: z$3.array(idDocumentSyncSchema).nullable().optional()
|
|
13349
|
+
}).nullable(),
|
|
13332
13350
|
organizationData: organizationInsertSchema.omit({ partyId: true }).nullable(),
|
|
13333
13351
|
bankAccounts: z$3.array(bankAccountInsertSchema.omit({ partyId: true })).nullable(),
|
|
13334
13352
|
recipients: z$3.array(recipientInsertSchema.omit({ partyId: true })).nullable(),
|
|
13335
13353
|
disponents: z$3.array(disponentCreateSchema).nullable(),
|
|
13336
13354
|
addresses: z$3.array(addressInsertSchema.omit({ partyId: true })),
|
|
13337
|
-
aml: amlInsertSchema.omit({ partyId: true }),
|
|
13355
|
+
aml: amlInsertSchema.omit({ partyId: true }).optional().nullable(),
|
|
13338
13356
|
products: productsInputSchema$2.optional(),
|
|
13339
13357
|
traderIds: z$3.array(z$3.uuid()).optional()
|
|
13340
13358
|
});
|
|
13341
13359
|
z$3.object({
|
|
13342
13360
|
partyId: z$3.uuid(),
|
|
13343
13361
|
party: partySchema$2,
|
|
13344
|
-
personalData: individualUpdateSchema$1.
|
|
13362
|
+
personalData: individualUpdateSchema$1.extend({
|
|
13363
|
+
identityDocuments: z$3.array(idDocumentSyncSchema).nullable().optional()
|
|
13364
|
+
}).optional(),
|
|
13345
13365
|
organizationData: organizationUpdateSchema$1.optional(),
|
|
13346
13366
|
bankAccounts: z$3.array(bankAccountUpsertSchema.partial({ id: true })).optional(),
|
|
13347
13367
|
recipients: z$3.array(recipientUpsertSchema.partial({ id: true })).optional(),
|
|
@@ -13355,7 +13375,9 @@ z$3.object({
|
|
|
13355
13375
|
});
|
|
13356
13376
|
const partySelectOutputSchema = z$3.object({
|
|
13357
13377
|
party: partyOutputSchema$1.nullable(),
|
|
13358
|
-
personalData: individualSelectSchema.
|
|
13378
|
+
personalData: individualSelectSchema.extend({
|
|
13379
|
+
identityDocuments: z$3.array(idDocumentSelectSchema).nullable()
|
|
13380
|
+
}).nullable(),
|
|
13359
13381
|
organizationData: organizationSelectSchema.nullable(),
|
|
13360
13382
|
aml: amlSelectSchema.nullable(),
|
|
13361
13383
|
bankAccounts: z$3.array(bankAccountSelectSchema).nullable(),
|
|
@@ -13370,7 +13392,9 @@ const partySelectOutputSchema = z$3.object({
|
|
|
13370
13392
|
z$3.array(partySelectOutputSchema);
|
|
13371
13393
|
const partySelectDataSchema = z$3.object({
|
|
13372
13394
|
party: partyOutputSchema$1.nullable(),
|
|
13373
|
-
personalData: individualSelectSchema.
|
|
13395
|
+
personalData: individualSelectSchema.extend({
|
|
13396
|
+
identityDocuments: z$3.array(idDocumentSelectSchema).nullable()
|
|
13397
|
+
}).nullable(),
|
|
13374
13398
|
organizationData: organizationSelectSchema.nullable(),
|
|
13375
13399
|
aml: amlSelectSchema.nullable()
|
|
13376
13400
|
});
|
|
@@ -13725,6 +13749,15 @@ const partySchema$1 = z$3.object({
|
|
|
13725
13749
|
note: z$3.string().optional(),
|
|
13726
13750
|
countryCode: z$3.enum(COUNTRY_CODES_2).optional()
|
|
13727
13751
|
});
|
|
13752
|
+
const idDocumentInputSchema$1 = z$3.object({
|
|
13753
|
+
idDocType: z$3.enum(ID_DOC_TYPE),
|
|
13754
|
+
idDocNumber: z$3.string(),
|
|
13755
|
+
issueDate: z$3.date().optional(),
|
|
13756
|
+
expirationDate: z$3.date().optional(),
|
|
13757
|
+
issuer: z$3.string().optional(),
|
|
13758
|
+
frontImageUri: z$3.string().optional(),
|
|
13759
|
+
backImageUri: z$3.string().optional()
|
|
13760
|
+
});
|
|
13728
13761
|
const individualInsertSchema = z$3.object({
|
|
13729
13762
|
internalId: z$3.string().optional(),
|
|
13730
13763
|
name: z$3.string().min(1, "Jm\xE9no je povinn\xE9"),
|
|
@@ -13750,7 +13783,8 @@ const individualInsertSchema = z$3.object({
|
|
|
13750
13783
|
deathNotification: z$3.date().optional(),
|
|
13751
13784
|
pin: z$3.string().optional(),
|
|
13752
13785
|
stayAbroad: z$3.boolean().optional(),
|
|
13753
|
-
stayAbroadCountries: z$3.enum(COUNTRY_CODES_2).optional()
|
|
13786
|
+
stayAbroadCountries: z$3.enum(COUNTRY_CODES_2).optional(),
|
|
13787
|
+
identityDocuments: z$3.array(idDocumentInputSchema$1).optional()
|
|
13754
13788
|
});
|
|
13755
13789
|
const createOrganizationInputSchema = z$3.object({
|
|
13756
13790
|
internalId: z$3.string().optional(),
|
|
@@ -13777,7 +13811,8 @@ const createOrganizationInputSchema = z$3.object({
|
|
|
13777
13811
|
operationCountries: z$3.string(),
|
|
13778
13812
|
riskyBusinessType: z$3.string().optional(),
|
|
13779
13813
|
vatId: z$3.string().optional(),
|
|
13780
|
-
court: z$3.enum(COURT).optional()
|
|
13814
|
+
court: z$3.enum(COURT).optional(),
|
|
13815
|
+
registerUri: z$3.string().optional()
|
|
13781
13816
|
});
|
|
13782
13817
|
const updateBankAccountSchema = z$3.object({
|
|
13783
13818
|
...bankAccountMetadataSchema.shape,
|
|
@@ -13790,7 +13825,8 @@ const updateBankAccountSchema = z$3.object({
|
|
|
13790
13825
|
number: z$3.string().min(1, "\u010C\xEDslo \xFA\u010Dtu je povinn\xE9").optional(),
|
|
13791
13826
|
currency: z$3.enum(CURRENCY_CODES, "M\u011Bna je povinn\xE1"),
|
|
13792
13827
|
countryCode: bankAccountMetadataSchema.shape.countryCode.nonoptional(),
|
|
13793
|
-
id: bankAccountMetadataSchema.shape.id.nonoptional()
|
|
13828
|
+
id: bankAccountMetadataSchema.shape.id.nonoptional(),
|
|
13829
|
+
statementUri: z$3.string().optional()
|
|
13794
13830
|
});
|
|
13795
13831
|
const bankAccountInputSchema = updateBankAccountSchema.required({
|
|
13796
13832
|
holderName: true,
|
|
@@ -13918,15 +13954,6 @@ const ownerInputSchema = z$3.object({
|
|
|
13918
13954
|
sharePercentage: z$3.number({ error: "Pod\xEDl na spole\u010Dnosti je povinn\xFD" }).min(1, "Pod\xEDl na spole\u010Dnosti je povinn\xFD").max(100),
|
|
13919
13955
|
shareEstablishedAt: z$3.string().min(1, "Datum vzniku pod\xEDlu je povinn\xFD")
|
|
13920
13956
|
});
|
|
13921
|
-
const idDocumentInputSchema$1 = z$3.object({
|
|
13922
|
-
idDocType: z$3.enum(ID_DOC_TYPE),
|
|
13923
|
-
idDocNumber: z$3.string(),
|
|
13924
|
-
issueDate: z$3.date().optional(),
|
|
13925
|
-
expirationDate: z$3.date().optional(),
|
|
13926
|
-
issuer: z$3.string().optional(),
|
|
13927
|
-
frontImageUri: z$3.string().optional(),
|
|
13928
|
-
backImageUri: z$3.string().optional()
|
|
13929
|
-
});
|
|
13930
13957
|
const legalRepresentativeInputSchema = z$3.object({
|
|
13931
13958
|
titleBefore: z$3.string().optional(),
|
|
13932
13959
|
name: z$3.string().min(1, "Jm\xE9no je povinn\xE9"),
|
|
@@ -14006,8 +14033,15 @@ new OpenAPIHono().openapi(
|
|
|
14006
14033
|
createPartyRoute,
|
|
14007
14034
|
async (context) => {
|
|
14008
14035
|
const { owners, legalRepresentatives, ...partyInput } = context.req.valid("json");
|
|
14036
|
+
const disponentsWithDocs = (partyInput.disponents ?? []).filter(
|
|
14037
|
+
(d) => d.partyType === "INDIVIDUAL" && !!d.data.identityDocuments?.length
|
|
14038
|
+
);
|
|
14039
|
+
const disponentsForBatch = (partyInput.disponents ?? []).filter(
|
|
14040
|
+
(d) => !(d.partyType === "INDIVIDUAL" && !!d.data.identityDocuments?.length)
|
|
14041
|
+
);
|
|
14009
14042
|
const { data: partyData, error } = await context.env.MASTER_DATA_MANAGEMENT_SERVICE.createParty({
|
|
14010
14043
|
...partyInput,
|
|
14044
|
+
disponents: disponentsForBatch,
|
|
14011
14045
|
party: { ...partyInput.party, isRoot: true }
|
|
14012
14046
|
});
|
|
14013
14047
|
if (!partyData || error) {
|
|
@@ -14019,6 +14053,104 @@ new OpenAPIHono().openapi(
|
|
|
14019
14053
|
);
|
|
14020
14054
|
}
|
|
14021
14055
|
const mdm = context.env.MASTER_DATA_MANAGEMENT_SERVICE;
|
|
14056
|
+
const docService = context.env.DOCUMENT_SERVICE;
|
|
14057
|
+
if (partyInput.organizationData?.registerUri) {
|
|
14058
|
+
await docService.acknowledgeDocument({
|
|
14059
|
+
storageUrl: partyInput.organizationData.registerUri,
|
|
14060
|
+
entityId: partyData.id
|
|
14061
|
+
});
|
|
14062
|
+
}
|
|
14063
|
+
for (const ba of partyInput.bankAccounts ?? []) {
|
|
14064
|
+
if (ba.statementUri) {
|
|
14065
|
+
await docService.acknowledgeDocument({
|
|
14066
|
+
storageUrl: ba.statementUri,
|
|
14067
|
+
entityId: partyData.id
|
|
14068
|
+
});
|
|
14069
|
+
}
|
|
14070
|
+
}
|
|
14071
|
+
for (const [i, doc] of (partyInput.personalData?.identityDocuments ?? []).entries()) {
|
|
14072
|
+
const idDocId = partyData.personalIdDocIds?.[i] ?? partyData.id;
|
|
14073
|
+
if (doc.frontImageUri) {
|
|
14074
|
+
await docService.acknowledgeDocument({
|
|
14075
|
+
storageUrl: doc.frontImageUri,
|
|
14076
|
+
entityId: idDocId
|
|
14077
|
+
});
|
|
14078
|
+
}
|
|
14079
|
+
if (doc.backImageUri) {
|
|
14080
|
+
await docService.acknowledgeDocument({
|
|
14081
|
+
storageUrl: doc.backImageUri,
|
|
14082
|
+
entityId: idDocId
|
|
14083
|
+
});
|
|
14084
|
+
}
|
|
14085
|
+
}
|
|
14086
|
+
for (const disponent of disponentsWithDocs) {
|
|
14087
|
+
const { identityDocuments, ...individualData } = disponent.data;
|
|
14088
|
+
const { data: disponentParty, error: disponentError } = await mdm.createParty({
|
|
14089
|
+
party: {
|
|
14090
|
+
partyType: "INDIVIDUAL",
|
|
14091
|
+
language: partyInput.party.language,
|
|
14092
|
+
customerStatus: "NEW"
|
|
14093
|
+
},
|
|
14094
|
+
personalData: individualData,
|
|
14095
|
+
organizationData: null,
|
|
14096
|
+
bankAccounts: null,
|
|
14097
|
+
recipients: null,
|
|
14098
|
+
disponents: null,
|
|
14099
|
+
addresses: [],
|
|
14100
|
+
aml: null
|
|
14101
|
+
});
|
|
14102
|
+
if (!disponentParty || disponentError) {
|
|
14103
|
+
return context.json(
|
|
14104
|
+
{ message: "Could not create disponent party" },
|
|
14105
|
+
500
|
|
14106
|
+
);
|
|
14107
|
+
}
|
|
14108
|
+
const { error: linkDisponentError } = await mdm.linkPartyToParty({
|
|
14109
|
+
fromPartyId: disponentParty.id,
|
|
14110
|
+
toPartyId: partyData.id,
|
|
14111
|
+
relationshipType: "AUTHORIZED_SIGNATORY"
|
|
14112
|
+
});
|
|
14113
|
+
if (linkDisponentError) {
|
|
14114
|
+
return context.json(
|
|
14115
|
+
{ message: "Could not link disponent to party" },
|
|
14116
|
+
500
|
|
14117
|
+
);
|
|
14118
|
+
}
|
|
14119
|
+
for (const doc of identityDocuments ?? []) {
|
|
14120
|
+
const { data: createdIdDoc, error: idDocError } = await mdm.createIdDocument({
|
|
14121
|
+
partyId: disponentParty.id,
|
|
14122
|
+
idDocument: {
|
|
14123
|
+
partyId: disponentParty.id,
|
|
14124
|
+
idDocType: doc.idDocType,
|
|
14125
|
+
idDocNumber: doc.idDocNumber,
|
|
14126
|
+
idDocHolderName: `${individualData.name} ${individualData.surname}`,
|
|
14127
|
+
issueDate: doc.issueDate,
|
|
14128
|
+
expirationDate: doc.expirationDate,
|
|
14129
|
+
issuer: doc.issuer,
|
|
14130
|
+
frontImageUri: doc.frontImageUri,
|
|
14131
|
+
backImageUri: doc.backImageUri
|
|
14132
|
+
}
|
|
14133
|
+
});
|
|
14134
|
+
if (!createdIdDoc || idDocError) {
|
|
14135
|
+
return context.json(
|
|
14136
|
+
{ message: "Could not create disponent identity document" },
|
|
14137
|
+
500
|
|
14138
|
+
);
|
|
14139
|
+
}
|
|
14140
|
+
if (doc.frontImageUri) {
|
|
14141
|
+
await docService.acknowledgeDocument({
|
|
14142
|
+
storageUrl: doc.frontImageUri,
|
|
14143
|
+
entityId: createdIdDoc.id
|
|
14144
|
+
});
|
|
14145
|
+
}
|
|
14146
|
+
if (doc.backImageUri) {
|
|
14147
|
+
await docService.acknowledgeDocument({
|
|
14148
|
+
storageUrl: doc.backImageUri,
|
|
14149
|
+
entityId: createdIdDoc.id
|
|
14150
|
+
});
|
|
14151
|
+
}
|
|
14152
|
+
}
|
|
14153
|
+
}
|
|
14022
14154
|
if (owners?.length) {
|
|
14023
14155
|
for (const owner of owners) {
|
|
14024
14156
|
const { address, sharePercentage, shareEstablishedAt, ...individual } = owner;
|
|
@@ -14034,7 +14166,7 @@ new OpenAPIHono().openapi(
|
|
|
14034
14166
|
recipients: null,
|
|
14035
14167
|
disponents: null,
|
|
14036
14168
|
addresses: [{ ...address, addressType: "PERMANENT_ADDRESS" }],
|
|
14037
|
-
aml:
|
|
14169
|
+
aml: null
|
|
14038
14170
|
});
|
|
14039
14171
|
if (ownerParty && !ownerError) {
|
|
14040
14172
|
await mdm.linkPartyToParty({
|
|
@@ -14067,32 +14199,60 @@ new OpenAPIHono().openapi(
|
|
|
14067
14199
|
recipients: null,
|
|
14068
14200
|
disponents: null,
|
|
14069
14201
|
addresses: [{ ...address, addressType: "PERMANENT_ADDRESS" }],
|
|
14070
|
-
aml:
|
|
14202
|
+
aml: null
|
|
14071
14203
|
});
|
|
14072
|
-
if (repParty
|
|
14073
|
-
|
|
14074
|
-
|
|
14075
|
-
|
|
14076
|
-
|
|
14077
|
-
|
|
14078
|
-
|
|
14079
|
-
|
|
14080
|
-
|
|
14081
|
-
|
|
14082
|
-
|
|
14083
|
-
|
|
14084
|
-
|
|
14085
|
-
|
|
14086
|
-
|
|
14087
|
-
|
|
14088
|
-
|
|
14089
|
-
|
|
14090
|
-
|
|
14091
|
-
|
|
14092
|
-
|
|
14093
|
-
|
|
14094
|
-
|
|
14204
|
+
if (!repParty || repError) {
|
|
14205
|
+
return context.json(
|
|
14206
|
+
{ message: "Could not create legal representative party" },
|
|
14207
|
+
500
|
|
14208
|
+
);
|
|
14209
|
+
}
|
|
14210
|
+
const { error: linkRepError } = await mdm.linkPartyToParty({
|
|
14211
|
+
fromPartyId: repParty.id,
|
|
14212
|
+
toPartyId: partyData.id,
|
|
14213
|
+
relationshipType: "BOARD_MEMBER",
|
|
14214
|
+
fromDate: new Date(dateOfEstablishment)
|
|
14215
|
+
});
|
|
14216
|
+
if (linkRepError) {
|
|
14217
|
+
return context.json(
|
|
14218
|
+
{ message: "Could not link legal representative to party" },
|
|
14219
|
+
500
|
|
14220
|
+
);
|
|
14221
|
+
}
|
|
14222
|
+
for (const doc of identityDocuments ?? []) {
|
|
14223
|
+
const { data: createdIdDoc, error: idDocError } = await mdm.createIdDocument({
|
|
14224
|
+
partyId: repParty.id,
|
|
14225
|
+
idDocument: {
|
|
14226
|
+
partyId: repParty.id,
|
|
14227
|
+
idDocType: doc.idDocType,
|
|
14228
|
+
idDocNumber: doc.idDocNumber,
|
|
14229
|
+
idDocHolderName: `${individual.name} ${individual.surname}`,
|
|
14230
|
+
issueDate: doc.issueDate,
|
|
14231
|
+
expirationDate: doc.expirationDate,
|
|
14232
|
+
issuer: doc.issuer,
|
|
14233
|
+
frontImageUri: doc.frontImageUri,
|
|
14234
|
+
backImageUri: doc.backImageUri
|
|
14095
14235
|
}
|
|
14236
|
+
});
|
|
14237
|
+
if (!createdIdDoc || idDocError) {
|
|
14238
|
+
return context.json(
|
|
14239
|
+
{
|
|
14240
|
+
message: "Could not create legal representative identity document"
|
|
14241
|
+
},
|
|
14242
|
+
500
|
|
14243
|
+
);
|
|
14244
|
+
}
|
|
14245
|
+
if (doc.frontImageUri) {
|
|
14246
|
+
await docService.acknowledgeDocument({
|
|
14247
|
+
storageUrl: doc.frontImageUri,
|
|
14248
|
+
entityId: createdIdDoc.id
|
|
14249
|
+
});
|
|
14250
|
+
}
|
|
14251
|
+
if (doc.backImageUri) {
|
|
14252
|
+
await docService.acknowledgeDocument({
|
|
14253
|
+
storageUrl: doc.backImageUri,
|
|
14254
|
+
entityId: createdIdDoc.id
|
|
14255
|
+
});
|
|
14096
14256
|
}
|
|
14097
14257
|
}
|
|
14098
14258
|
}
|
|
@@ -14115,6 +14275,16 @@ const partySchema = z$3.object({
|
|
|
14115
14275
|
note: z$3.string().optional(),
|
|
14116
14276
|
countryCode: z$3.enum(COUNTRY_CODES_2).optional()
|
|
14117
14277
|
});
|
|
14278
|
+
const idDocumentInputSchema = z$3.object({
|
|
14279
|
+
id: z$3.uuid().optional(),
|
|
14280
|
+
idDocType: z$3.enum(ID_DOC_TYPE),
|
|
14281
|
+
idDocNumber: z$3.string(),
|
|
14282
|
+
issueDate: z$3.date().optional(),
|
|
14283
|
+
expirationDate: z$3.date().optional(),
|
|
14284
|
+
issuer: z$3.string().optional(),
|
|
14285
|
+
frontImageUri: z$3.string().optional(),
|
|
14286
|
+
backImageUri: z$3.string().optional()
|
|
14287
|
+
});
|
|
14118
14288
|
const individualUpdateSchema = z$3.object({
|
|
14119
14289
|
id: z$3.uuid(),
|
|
14120
14290
|
partyId: z$3.uuid(),
|
|
@@ -14142,7 +14312,8 @@ const individualUpdateSchema = z$3.object({
|
|
|
14142
14312
|
deathNotification: z$3.date().optional(),
|
|
14143
14313
|
pin: z$3.string().optional(),
|
|
14144
14314
|
stayAbroad: z$3.boolean().optional(),
|
|
14145
|
-
stayAbroadCountries: z$3.enum(COUNTRY_CODES_2).optional()
|
|
14315
|
+
stayAbroadCountries: z$3.enum(COUNTRY_CODES_2).optional(),
|
|
14316
|
+
identityDocuments: z$3.array(idDocumentInputSchema).optional()
|
|
14146
14317
|
});
|
|
14147
14318
|
const organizationUpdateSchema = z$3.object({
|
|
14148
14319
|
id: z$3.uuid(),
|
|
@@ -14171,7 +14342,8 @@ const organizationUpdateSchema = z$3.object({
|
|
|
14171
14342
|
operationCountries: z$3.string(),
|
|
14172
14343
|
riskyBusinessType: z$3.string().optional(),
|
|
14173
14344
|
vatId: z$3.string().nullable().optional(),
|
|
14174
|
-
court: z$3.enum(COURT).nullable().optional()
|
|
14345
|
+
court: z$3.enum(COURT).nullable().optional(),
|
|
14346
|
+
registerUri: z$3.string().optional()
|
|
14175
14347
|
});
|
|
14176
14348
|
const syncBankAccountSchema = z$3.object({
|
|
14177
14349
|
...bankAccountMetadataSchema.shape,
|
|
@@ -14181,7 +14353,8 @@ const syncBankAccountSchema = z$3.object({
|
|
|
14181
14353
|
number: z$3.string().optional(),
|
|
14182
14354
|
currency: bankAccountMetadataSchema.shape.currency.nonoptional(),
|
|
14183
14355
|
countryCode: bankAccountMetadataSchema.shape.countryCode.nonoptional(),
|
|
14184
|
-
id: z$3.uuid().optional()
|
|
14356
|
+
id: z$3.uuid().optional(),
|
|
14357
|
+
statementUri: z$3.string().optional()
|
|
14185
14358
|
});
|
|
14186
14359
|
const disponentIndividualSyncDataSchema = z$3.object({
|
|
14187
14360
|
id: z$3.uuid().optional(),
|
|
@@ -14208,7 +14381,8 @@ const disponentIndividualSyncDataSchema = z$3.object({
|
|
|
14208
14381
|
deathNotification: z$3.date().optional(),
|
|
14209
14382
|
pin: z$3.string().optional(),
|
|
14210
14383
|
stayAbroad: z$3.boolean().optional(),
|
|
14211
|
-
stayAbroadCountries: z$3.enum(COUNTRY_CODES_2).optional()
|
|
14384
|
+
stayAbroadCountries: z$3.enum(COUNTRY_CODES_2).optional(),
|
|
14385
|
+
identityDocuments: z$3.array(idDocumentInputSchema).optional()
|
|
14212
14386
|
});
|
|
14213
14387
|
const disponentOrganizationSyncDataSchema = z$3.object({
|
|
14214
14388
|
id: z$3.uuid().optional(),
|
|
@@ -14233,7 +14407,8 @@ const disponentOrganizationSyncDataSchema = z$3.object({
|
|
|
14233
14407
|
companyObjectsDescription: z$3.string(),
|
|
14234
14408
|
turnover3years: z$3.number(),
|
|
14235
14409
|
operationCountries: z$3.string(),
|
|
14236
|
-
riskyBusinessType: z$3.string().optional()
|
|
14410
|
+
riskyBusinessType: z$3.string().optional(),
|
|
14411
|
+
registerUri: z$3.string().optional()
|
|
14237
14412
|
});
|
|
14238
14413
|
const disponentSyncSchema = z$3.discriminatedUnion("partyType", [
|
|
14239
14414
|
z$3.object({
|
|
@@ -14348,15 +14523,6 @@ const ownerSyncSchema = z$3.object({
|
|
|
14348
14523
|
sharePercentage: z$3.number().max(100),
|
|
14349
14524
|
shareEstablishedAt: z$3.string().min(1, "Datum vzniku pod\xEDlu je povinn\xFD")
|
|
14350
14525
|
});
|
|
14351
|
-
const idDocumentInputSchema = z$3.object({
|
|
14352
|
-
idDocType: z$3.enum(ID_DOC_TYPE),
|
|
14353
|
-
idDocNumber: z$3.string(),
|
|
14354
|
-
issueDate: z$3.date().optional(),
|
|
14355
|
-
expirationDate: z$3.date().optional(),
|
|
14356
|
-
issuer: z$3.string().optional(),
|
|
14357
|
-
frontImageUri: z$3.string().optional(),
|
|
14358
|
-
backImageUri: z$3.string().optional()
|
|
14359
|
-
});
|
|
14360
14526
|
const legalRepresentativeSyncSchema = z$3.object({
|
|
14361
14527
|
id: z$3.uuid().optional(),
|
|
14362
14528
|
titleBefore: z$3.string().optional(),
|
|
@@ -14459,6 +14625,78 @@ new OpenAPIHono().openapi(
|
|
|
14459
14625
|
if (!updatedParty || partyError) {
|
|
14460
14626
|
return context.json({ message: "Could not update a Party" }, 404);
|
|
14461
14627
|
}
|
|
14628
|
+
const docService = context.env.DOCUMENT_SERVICE;
|
|
14629
|
+
if (party.organizationData?.registerUri) {
|
|
14630
|
+
await docService.acknowledgeDocument({
|
|
14631
|
+
storageUrl: party.organizationData.registerUri,
|
|
14632
|
+
entityId: partyId
|
|
14633
|
+
});
|
|
14634
|
+
}
|
|
14635
|
+
for (const ba of party.bankAccounts ?? []) {
|
|
14636
|
+
if (ba.statementUri) {
|
|
14637
|
+
await docService.acknowledgeDocument({
|
|
14638
|
+
storageUrl: ba.statementUri,
|
|
14639
|
+
entityId: partyId
|
|
14640
|
+
});
|
|
14641
|
+
}
|
|
14642
|
+
}
|
|
14643
|
+
if (party.personalData?.identityDocuments?.length) {
|
|
14644
|
+
let newDocIdx = 0;
|
|
14645
|
+
for (const doc of party.personalData.identityDocuments) {
|
|
14646
|
+
const idDocEntityId = doc.id ? doc.id : updatedParty.newPersonalIdDocIds?.[newDocIdx++] ?? partyId;
|
|
14647
|
+
if (doc.frontImageUri) {
|
|
14648
|
+
await docService.acknowledgeDocument({
|
|
14649
|
+
storageUrl: doc.frontImageUri,
|
|
14650
|
+
entityId: idDocEntityId
|
|
14651
|
+
});
|
|
14652
|
+
}
|
|
14653
|
+
if (doc.backImageUri) {
|
|
14654
|
+
await docService.acknowledgeDocument({
|
|
14655
|
+
storageUrl: doc.backImageUri,
|
|
14656
|
+
entityId: idDocEntityId
|
|
14657
|
+
});
|
|
14658
|
+
}
|
|
14659
|
+
}
|
|
14660
|
+
}
|
|
14661
|
+
if (party.legalRepresentatives?.length) {
|
|
14662
|
+
let newBmDocIdx = 0;
|
|
14663
|
+
for (const rep of party.legalRepresentatives) {
|
|
14664
|
+
if (rep.id) continue;
|
|
14665
|
+
for (const doc of rep.identityDocuments ?? []) {
|
|
14666
|
+
const idDocEntityId = updatedParty.newBoardMemberIdDocIds?.[newBmDocIdx++] ?? partyId;
|
|
14667
|
+
if (doc.frontImageUri) {
|
|
14668
|
+
await docService.acknowledgeDocument({
|
|
14669
|
+
storageUrl: doc.frontImageUri,
|
|
14670
|
+
entityId: idDocEntityId
|
|
14671
|
+
});
|
|
14672
|
+
}
|
|
14673
|
+
if (doc.backImageUri) {
|
|
14674
|
+
await docService.acknowledgeDocument({
|
|
14675
|
+
storageUrl: doc.backImageUri,
|
|
14676
|
+
entityId: idDocEntityId
|
|
14677
|
+
});
|
|
14678
|
+
}
|
|
14679
|
+
}
|
|
14680
|
+
}
|
|
14681
|
+
for (const rep of party.legalRepresentatives) {
|
|
14682
|
+
if (!rep.id) continue;
|
|
14683
|
+
for (const doc of rep.identityDocuments ?? []) {
|
|
14684
|
+
const idDocEntityId = doc.id ? doc.id : updatedParty.newBoardMemberIdDocIds?.[newBmDocIdx++] ?? partyId;
|
|
14685
|
+
if (doc.frontImageUri) {
|
|
14686
|
+
await docService.acknowledgeDocument({
|
|
14687
|
+
storageUrl: doc.frontImageUri,
|
|
14688
|
+
entityId: idDocEntityId
|
|
14689
|
+
});
|
|
14690
|
+
}
|
|
14691
|
+
if (doc.backImageUri) {
|
|
14692
|
+
await docService.acknowledgeDocument({
|
|
14693
|
+
storageUrl: doc.backImageUri,
|
|
14694
|
+
entityId: idDocEntityId
|
|
14695
|
+
});
|
|
14696
|
+
}
|
|
14697
|
+
}
|
|
14698
|
+
}
|
|
14699
|
+
}
|
|
14462
14700
|
return context.json(
|
|
14463
14701
|
{
|
|
14464
14702
|
message: "Party updated successfully",
|
|
@@ -14469,6 +14707,167 @@ new OpenAPIHono().openapi(
|
|
|
14469
14707
|
}
|
|
14470
14708
|
);
|
|
14471
14709
|
|
|
14710
|
+
const DOCUMENT_SIDE = ["front", "back"];
|
|
14711
|
+
const paramsSchema$2 = z$3.object({
|
|
14712
|
+
partyId: z$3.uuid()
|
|
14713
|
+
});
|
|
14714
|
+
const idDocumentCreateInputSchema = z$3.object({
|
|
14715
|
+
partyId: z$3.uuid(),
|
|
14716
|
+
idDocType: z$3.enum(ID_DOC_TYPE),
|
|
14717
|
+
idDocNumber: z$3.string(),
|
|
14718
|
+
idDocHolderName: z$3.string(),
|
|
14719
|
+
issueDate: z$3.coerce.date().optional(),
|
|
14720
|
+
expirationDate: z$3.coerce.date().optional(),
|
|
14721
|
+
issuer: z$3.string().optional(),
|
|
14722
|
+
countryOfIssue: z$3.enum(COUNTRY_CODES_2).optional(),
|
|
14723
|
+
idDocStatus: z$3.enum(ID_DOC_STATUS).optional()
|
|
14724
|
+
});
|
|
14725
|
+
const idDocumentMultipartSchema = z$3.object({
|
|
14726
|
+
idDocument: z$3.string(),
|
|
14727
|
+
documentSide: z$3.enum(DOCUMENT_SIDE),
|
|
14728
|
+
file: z$3.any()
|
|
14729
|
+
});
|
|
14730
|
+
const multipartOpenApiSchema = z$3.object({
|
|
14731
|
+
idDocument: z$3.string().openapi({
|
|
14732
|
+
description: "JSON stringified IdDocument payload"
|
|
14733
|
+
}),
|
|
14734
|
+
documentSide: z$3.enum(DOCUMENT_SIDE),
|
|
14735
|
+
file: z$3.any().openapi({
|
|
14736
|
+
type: "string",
|
|
14737
|
+
format: "binary"
|
|
14738
|
+
})
|
|
14739
|
+
});
|
|
14740
|
+
const idDocumentOutputSchema = z$3.object({
|
|
14741
|
+
id: z$3.uuid(),
|
|
14742
|
+
createdAt: z$3.iso.datetime().nullable(),
|
|
14743
|
+
updatedAt: z$3.iso.datetime().nullable(),
|
|
14744
|
+
deletedAt: z$3.iso.datetime().nullable(),
|
|
14745
|
+
partyId: z$3.uuid(),
|
|
14746
|
+
idDocType: z$3.enum(ID_DOC_TYPE),
|
|
14747
|
+
idDocNumber: z$3.string(),
|
|
14748
|
+
idDocHolderName: z$3.string(),
|
|
14749
|
+
issueDate: z$3.iso.datetime().nullable(),
|
|
14750
|
+
expirationDate: z$3.iso.datetime().nullable(),
|
|
14751
|
+
issuer: z$3.string().nullable(),
|
|
14752
|
+
countryOfIssue: z$3.enum(COUNTRY_CODES_2).nullable(),
|
|
14753
|
+
frontImageUri: z$3.string().nullable(),
|
|
14754
|
+
backImageUri: z$3.string().nullable(),
|
|
14755
|
+
idDocStatus: z$3.enum(ID_DOC_STATUS).nullable()
|
|
14756
|
+
});
|
|
14757
|
+
const responseBodySchema$3 = z$3.object({
|
|
14758
|
+
message: z$3.string(),
|
|
14759
|
+
idDocument: idDocumentOutputSchema
|
|
14760
|
+
});
|
|
14761
|
+
const createDocumentRoute = createRoute({
|
|
14762
|
+
method: "post",
|
|
14763
|
+
path: "/",
|
|
14764
|
+
summary: "Create ID Document",
|
|
14765
|
+
tags: ["ID Documents"],
|
|
14766
|
+
description: "Creates a new identification document for the specified party and uploads the document image (front or back side). Accepts multipart form data with the document metadata as a JSON string and the file as a binary attachment.",
|
|
14767
|
+
// middleware: [jwt, signature(), idempotency()],
|
|
14768
|
+
// security: [{ JwtAuth: [] }],
|
|
14769
|
+
request: {
|
|
14770
|
+
// headers: z.object({
|
|
14771
|
+
// 'X-Idempotency-Key': XIdempotencyKeyHeaderSchema,
|
|
14772
|
+
// 'X-Signature': XSignatureHeaderSchema,
|
|
14773
|
+
// 'X-Signature-Key': XSignatureKeyHeaderSchema,
|
|
14774
|
+
// }),
|
|
14775
|
+
body: {
|
|
14776
|
+
content: {
|
|
14777
|
+
"multipart/form-data": {
|
|
14778
|
+
schema: multipartOpenApiSchema
|
|
14779
|
+
}
|
|
14780
|
+
},
|
|
14781
|
+
required: true
|
|
14782
|
+
},
|
|
14783
|
+
params: paramsSchema$2
|
|
14784
|
+
},
|
|
14785
|
+
responses: {
|
|
14786
|
+
200: {
|
|
14787
|
+
description: "Document created and file uploaded",
|
|
14788
|
+
content: {
|
|
14789
|
+
"application/json": {
|
|
14790
|
+
schema: responseBodySchema$3
|
|
14791
|
+
}
|
|
14792
|
+
}
|
|
14793
|
+
},
|
|
14794
|
+
400: {
|
|
14795
|
+
description: "Invalid request",
|
|
14796
|
+
content: {
|
|
14797
|
+
"application/json": {
|
|
14798
|
+
schema: z$3.object({ message: z$3.string() })
|
|
14799
|
+
}
|
|
14800
|
+
}
|
|
14801
|
+
},
|
|
14802
|
+
500: {
|
|
14803
|
+
description: "Internal server error",
|
|
14804
|
+
content: {
|
|
14805
|
+
"application/json": {
|
|
14806
|
+
schema: z$3.object({ message: z$3.string() })
|
|
14807
|
+
}
|
|
14808
|
+
}
|
|
14809
|
+
}
|
|
14810
|
+
}
|
|
14811
|
+
});
|
|
14812
|
+
new OpenAPIHono().openapi(
|
|
14813
|
+
createDocumentRoute,
|
|
14814
|
+
async (context) => {
|
|
14815
|
+
const rawBody = await context.req.parseBody();
|
|
14816
|
+
const { partyId } = context.req.valid("param");
|
|
14817
|
+
const idDocumentRaw = rawBody.idDocument;
|
|
14818
|
+
const documentSide = rawBody.documentSide;
|
|
14819
|
+
const file = rawBody.file;
|
|
14820
|
+
if (typeof idDocumentRaw !== "string" || !DOCUMENT_SIDE.includes(documentSide) || !(file instanceof File)) {
|
|
14821
|
+
return context.json({ message: "Invalid multipart payload" }, 400);
|
|
14822
|
+
}
|
|
14823
|
+
const idDocumentJson = JSON.parse(JSON.parse(idDocumentRaw));
|
|
14824
|
+
const idDocumentResult = idDocumentCreateInputSchema.safeParse(idDocumentJson);
|
|
14825
|
+
if (!idDocumentResult.success) {
|
|
14826
|
+
console.error(idDocumentResult.error);
|
|
14827
|
+
return context.json({ message: "Could not parse IdDocument" }, 400);
|
|
14828
|
+
}
|
|
14829
|
+
const {
|
|
14830
|
+
data: createdIdDocument,
|
|
14831
|
+
error: createError,
|
|
14832
|
+
message
|
|
14833
|
+
} = await context.env.MASTER_DATA_MANAGEMENT_SERVICE.createIdDocument({
|
|
14834
|
+
idDocument: idDocumentResult.data,
|
|
14835
|
+
partyId
|
|
14836
|
+
});
|
|
14837
|
+
if (!createdIdDocument || createError) {
|
|
14838
|
+
console.error(message);
|
|
14839
|
+
return context.json({ message: "Could not create IdDocument" }, 500);
|
|
14840
|
+
}
|
|
14841
|
+
const bytes = new Uint8Array(await file.arrayBuffer());
|
|
14842
|
+
const { data: uploadResult, error: uploadError } = await context.env.DOCUMENT_SERVICE.uploadDocument({
|
|
14843
|
+
entityType: "client",
|
|
14844
|
+
entityId: createdIdDocument.id,
|
|
14845
|
+
type: "kyc",
|
|
14846
|
+
metadata: {},
|
|
14847
|
+
file: {
|
|
14848
|
+
bytes,
|
|
14849
|
+
type: file.type,
|
|
14850
|
+
name: file.name,
|
|
14851
|
+
size: file.size
|
|
14852
|
+
}
|
|
14853
|
+
});
|
|
14854
|
+
if (!uploadResult || uploadError) {
|
|
14855
|
+
return context.json({ message: "File upload failed" }, 500);
|
|
14856
|
+
}
|
|
14857
|
+
return context.json(
|
|
14858
|
+
{
|
|
14859
|
+
message: "IdDocument created successfully",
|
|
14860
|
+
idDocument: {
|
|
14861
|
+
...createdIdDocument,
|
|
14862
|
+
frontImageUri: documentSide === "front" ? uploadResult.storageUrl : createdIdDocument.frontImageUri,
|
|
14863
|
+
backImageUri: documentSide === "back" ? uploadResult.storageUrl : createdIdDocument.backImageUri
|
|
14864
|
+
}
|
|
14865
|
+
},
|
|
14866
|
+
200
|
|
14867
|
+
);
|
|
14868
|
+
}
|
|
14869
|
+
);
|
|
14870
|
+
|
|
14472
14871
|
const partyBaseOutputSchema = z$3.object({
|
|
14473
14872
|
customerStatus: z$3.enum(CUSTOMER_STATUS),
|
|
14474
14873
|
partyType: z$3.enum(PARTY_TYPE),
|
|
@@ -14510,7 +14909,8 @@ const individualOutputSchema = z$3.object({
|
|
|
14510
14909
|
stayAbroad: z$3.boolean().nullable(),
|
|
14511
14910
|
stayAbroadCountries: z$3.enum(COUNTRY_CODES_2).nullable(),
|
|
14512
14911
|
createdAt: z$3.coerce.date().nullable(),
|
|
14513
|
-
updatedAt: z$3.coerce.date().nullable()
|
|
14912
|
+
updatedAt: z$3.coerce.date().nullable(),
|
|
14913
|
+
identityDocuments: z$3.array(idDocumentOutputSchema).nullable()
|
|
14514
14914
|
});
|
|
14515
14915
|
const createOrganizationOutputSchema = z$3.object({
|
|
14516
14916
|
partyId: z$3.uuid(),
|
|
@@ -14538,7 +14938,8 @@ const createOrganizationOutputSchema = z$3.object({
|
|
|
14538
14938
|
operationCountries: z$3.string(),
|
|
14539
14939
|
riskyBusinessType: z$3.string().nullable(),
|
|
14540
14940
|
vatId: z$3.string().nullable(),
|
|
14541
|
-
court: z$3.enum(COURT).nullable()
|
|
14941
|
+
court: z$3.enum(COURT).nullable(),
|
|
14942
|
+
registerUri: z$3.string().nullable()
|
|
14542
14943
|
});
|
|
14543
14944
|
const bankAccountOutputSchema = z$3.object({
|
|
14544
14945
|
id: z$3.string(),
|
|
@@ -14558,7 +14959,8 @@ const bankAccountOutputSchema = z$3.object({
|
|
|
14558
14959
|
clabe: z$3.string().nullable(),
|
|
14559
14960
|
bsb: z$3.string().nullable(),
|
|
14560
14961
|
brBankNumber: z$3.string().nullable(),
|
|
14561
|
-
updatedAt: z$3.coerce.date().nullable()
|
|
14962
|
+
updatedAt: z$3.coerce.date().nullable(),
|
|
14963
|
+
statementUri: z$3.string().nullable()
|
|
14562
14964
|
});
|
|
14563
14965
|
const disponentOutputSchema = z$3.discriminatedUnion("partyType", [
|
|
14564
14966
|
z$3.object({
|
|
@@ -14695,6 +15097,9 @@ const productsOutputSchema = z$3.object({
|
|
|
14695
15097
|
}).nullable(),
|
|
14696
15098
|
cbs: z$3.object({}).nullable()
|
|
14697
15099
|
});
|
|
15100
|
+
const recipientOutputSchema = bankAccountOutputSchema.omit({
|
|
15101
|
+
statementUri: true
|
|
15102
|
+
});
|
|
14698
15103
|
const partyOutputSchema = z$3.object({
|
|
14699
15104
|
party: partyBaseOutputSchema.nullable(),
|
|
14700
15105
|
personalData: individualOutputSchema.nullable(),
|
|
@@ -14703,13 +15108,13 @@ const partyOutputSchema = z$3.object({
|
|
|
14703
15108
|
disponents: z$3.array(disponentOutputSchema).nullable(),
|
|
14704
15109
|
addresses: z$3.array(createAddressOutputSchema).nullable(),
|
|
14705
15110
|
aml: createAmlOutputSchema.nullable(),
|
|
14706
|
-
recipients: z$3.array(
|
|
15111
|
+
recipients: z$3.array(recipientOutputSchema).nullable(),
|
|
14707
15112
|
products: productsOutputSchema.nullable(),
|
|
14708
15113
|
traderIds: z$3.array(z$3.uuid()).nullable(),
|
|
14709
15114
|
owners: z$3.array(ownerOutputSchema).nullable(),
|
|
14710
15115
|
legalRepresentatives: z$3.array(legalRepresentativeOutputSchema).nullable()
|
|
14711
15116
|
});
|
|
14712
|
-
const responseBodySchema$
|
|
15117
|
+
const responseBodySchema$2 = z$3.object({
|
|
14713
15118
|
message: z$3.string(),
|
|
14714
15119
|
party: partyOutputSchema
|
|
14715
15120
|
});
|
|
@@ -14726,7 +15131,7 @@ const getPartyByPartyIdRoute = createRoute({
|
|
|
14726
15131
|
200: {
|
|
14727
15132
|
content: {
|
|
14728
15133
|
"application/json": {
|
|
14729
|
-
schema: responseBodySchema$
|
|
15134
|
+
schema: responseBodySchema$2
|
|
14730
15135
|
}
|
|
14731
15136
|
},
|
|
14732
15137
|
description: "Get party by party Id"
|
|
@@ -14843,167 +15248,6 @@ new OpenAPIHono().openapi(
|
|
|
14843
15248
|
}
|
|
14844
15249
|
);
|
|
14845
15250
|
|
|
14846
|
-
const DOCUMENT_SIDE = ["front", "back"];
|
|
14847
|
-
const paramsSchema$2 = z$3.object({
|
|
14848
|
-
partyId: z$3.uuid()
|
|
14849
|
-
});
|
|
14850
|
-
const idDocumentCreateInputSchema = z$3.object({
|
|
14851
|
-
partyId: z$3.uuid(),
|
|
14852
|
-
idDocType: z$3.enum(ID_DOC_TYPE),
|
|
14853
|
-
idDocNumber: z$3.string(),
|
|
14854
|
-
idDocHolderName: z$3.string(),
|
|
14855
|
-
issueDate: z$3.coerce.date().optional(),
|
|
14856
|
-
expirationDate: z$3.coerce.date().optional(),
|
|
14857
|
-
issuer: z$3.string().optional(),
|
|
14858
|
-
countryOfIssue: z$3.enum(COUNTRY_CODES_2).optional(),
|
|
14859
|
-
idDocStatus: z$3.enum(ID_DOC_STATUS).optional()
|
|
14860
|
-
});
|
|
14861
|
-
const idDocumentMultipartSchema = z$3.object({
|
|
14862
|
-
idDocument: z$3.string(),
|
|
14863
|
-
documentSide: z$3.enum(DOCUMENT_SIDE),
|
|
14864
|
-
file: z$3.any()
|
|
14865
|
-
});
|
|
14866
|
-
const multipartOpenApiSchema = z$3.object({
|
|
14867
|
-
idDocument: z$3.string().openapi({
|
|
14868
|
-
description: "JSON stringified IdDocument payload"
|
|
14869
|
-
}),
|
|
14870
|
-
documentSide: z$3.enum(DOCUMENT_SIDE),
|
|
14871
|
-
file: z$3.any().openapi({
|
|
14872
|
-
type: "string",
|
|
14873
|
-
format: "binary"
|
|
14874
|
-
})
|
|
14875
|
-
});
|
|
14876
|
-
const idDocumentOutputSchema = z$3.object({
|
|
14877
|
-
id: z$3.uuid(),
|
|
14878
|
-
createdAt: z$3.iso.datetime().nullable(),
|
|
14879
|
-
updatedAt: z$3.iso.datetime().nullable(),
|
|
14880
|
-
deletedAt: z$3.iso.datetime().nullable(),
|
|
14881
|
-
partyId: z$3.uuid(),
|
|
14882
|
-
idDocType: z$3.enum(ID_DOC_TYPE),
|
|
14883
|
-
idDocNumber: z$3.string(),
|
|
14884
|
-
idDocHolderName: z$3.string(),
|
|
14885
|
-
issueDate: z$3.iso.datetime().nullable(),
|
|
14886
|
-
expirationDate: z$3.iso.datetime().nullable(),
|
|
14887
|
-
issuer: z$3.string().nullable(),
|
|
14888
|
-
countryOfIssue: z$3.enum(COUNTRY_CODES_2).nullable(),
|
|
14889
|
-
frontImageUri: z$3.string().nullable(),
|
|
14890
|
-
backImageUri: z$3.string().nullable(),
|
|
14891
|
-
idDocStatus: z$3.enum(ID_DOC_STATUS).nullable()
|
|
14892
|
-
});
|
|
14893
|
-
const responseBodySchema$2 = z$3.object({
|
|
14894
|
-
message: z$3.string(),
|
|
14895
|
-
idDocument: idDocumentOutputSchema
|
|
14896
|
-
});
|
|
14897
|
-
const createDocumentRoute = createRoute({
|
|
14898
|
-
method: "post",
|
|
14899
|
-
path: "/",
|
|
14900
|
-
summary: "Create ID Document",
|
|
14901
|
-
tags: ["ID Documents"],
|
|
14902
|
-
description: "Creates a new identification document for the specified party and uploads the document image (front or back side). Accepts multipart form data with the document metadata as a JSON string and the file as a binary attachment.",
|
|
14903
|
-
// middleware: [jwt, signature(), idempotency()],
|
|
14904
|
-
// security: [{ JwtAuth: [] }],
|
|
14905
|
-
request: {
|
|
14906
|
-
// headers: z.object({
|
|
14907
|
-
// 'X-Idempotency-Key': XIdempotencyKeyHeaderSchema,
|
|
14908
|
-
// 'X-Signature': XSignatureHeaderSchema,
|
|
14909
|
-
// 'X-Signature-Key': XSignatureKeyHeaderSchema,
|
|
14910
|
-
// }),
|
|
14911
|
-
body: {
|
|
14912
|
-
content: {
|
|
14913
|
-
"multipart/form-data": {
|
|
14914
|
-
schema: multipartOpenApiSchema
|
|
14915
|
-
}
|
|
14916
|
-
},
|
|
14917
|
-
required: true
|
|
14918
|
-
},
|
|
14919
|
-
params: paramsSchema$2
|
|
14920
|
-
},
|
|
14921
|
-
responses: {
|
|
14922
|
-
200: {
|
|
14923
|
-
description: "Document created and file uploaded",
|
|
14924
|
-
content: {
|
|
14925
|
-
"application/json": {
|
|
14926
|
-
schema: responseBodySchema$2
|
|
14927
|
-
}
|
|
14928
|
-
}
|
|
14929
|
-
},
|
|
14930
|
-
400: {
|
|
14931
|
-
description: "Invalid request",
|
|
14932
|
-
content: {
|
|
14933
|
-
"application/json": {
|
|
14934
|
-
schema: z$3.object({ message: z$3.string() })
|
|
14935
|
-
}
|
|
14936
|
-
}
|
|
14937
|
-
},
|
|
14938
|
-
500: {
|
|
14939
|
-
description: "Internal server error",
|
|
14940
|
-
content: {
|
|
14941
|
-
"application/json": {
|
|
14942
|
-
schema: z$3.object({ message: z$3.string() })
|
|
14943
|
-
}
|
|
14944
|
-
}
|
|
14945
|
-
}
|
|
14946
|
-
}
|
|
14947
|
-
});
|
|
14948
|
-
new OpenAPIHono().openapi(
|
|
14949
|
-
createDocumentRoute,
|
|
14950
|
-
async (context) => {
|
|
14951
|
-
const rawBody = await context.req.parseBody();
|
|
14952
|
-
const { partyId } = context.req.valid("param");
|
|
14953
|
-
const idDocumentRaw = rawBody.idDocument;
|
|
14954
|
-
const documentSide = rawBody.documentSide;
|
|
14955
|
-
const file = rawBody.file;
|
|
14956
|
-
if (typeof idDocumentRaw !== "string" || !DOCUMENT_SIDE.includes(documentSide) || !(file instanceof File)) {
|
|
14957
|
-
return context.json({ message: "Invalid multipart payload" }, 400);
|
|
14958
|
-
}
|
|
14959
|
-
const idDocumentJson = JSON.parse(JSON.parse(idDocumentRaw));
|
|
14960
|
-
const idDocumentResult = idDocumentCreateInputSchema.safeParse(idDocumentJson);
|
|
14961
|
-
if (!idDocumentResult.success) {
|
|
14962
|
-
console.error(idDocumentResult.error);
|
|
14963
|
-
return context.json({ message: "Could not parse IdDocument" }, 400);
|
|
14964
|
-
}
|
|
14965
|
-
const {
|
|
14966
|
-
data: createdIdDocument,
|
|
14967
|
-
error: createError,
|
|
14968
|
-
message
|
|
14969
|
-
} = await context.env.MASTER_DATA_MANAGEMENT_SERVICE.createIdDocument({
|
|
14970
|
-
idDocument: idDocumentResult.data,
|
|
14971
|
-
partyId
|
|
14972
|
-
});
|
|
14973
|
-
if (!createdIdDocument || createError) {
|
|
14974
|
-
console.error(message);
|
|
14975
|
-
return context.json({ message: "Could not create IdDocument" }, 500);
|
|
14976
|
-
}
|
|
14977
|
-
const bytes = new Uint8Array(await file.arrayBuffer());
|
|
14978
|
-
const { data: uploadResult, error: uploadError } = await context.env.DOCUMENT_SERVICE.uploadDocument({
|
|
14979
|
-
entityType: "client",
|
|
14980
|
-
entityId: createdIdDocument.id,
|
|
14981
|
-
type: "kyc",
|
|
14982
|
-
metadata: {},
|
|
14983
|
-
file: {
|
|
14984
|
-
bytes,
|
|
14985
|
-
type: file.type,
|
|
14986
|
-
name: file.name,
|
|
14987
|
-
size: file.size
|
|
14988
|
-
}
|
|
14989
|
-
});
|
|
14990
|
-
if (!uploadResult || uploadError) {
|
|
14991
|
-
return context.json({ message: "File upload failed" }, 500);
|
|
14992
|
-
}
|
|
14993
|
-
return context.json(
|
|
14994
|
-
{
|
|
14995
|
-
message: "IdDocument created successfully",
|
|
14996
|
-
idDocument: {
|
|
14997
|
-
...createdIdDocument,
|
|
14998
|
-
frontImageUri: documentSide === "front" ? uploadResult.storageUrl : createdIdDocument.frontImageUri,
|
|
14999
|
-
backImageUri: documentSide === "back" ? uploadResult.storageUrl : createdIdDocument.backImageUri
|
|
15000
|
-
}
|
|
15001
|
-
},
|
|
15002
|
-
200
|
|
15003
|
-
);
|
|
15004
|
-
}
|
|
15005
|
-
);
|
|
15006
|
-
|
|
15007
15251
|
const XIdempotencyKeyHeaderSchema = z$3.string().openapi({
|
|
15008
15252
|
description: "Unique identifier header to ensure the request is processed only once.",
|
|
15009
15253
|
example: "4ac15c22-2bd3-426f-b915-bfd5febdb7df"
|