@devizovaburza/mdm-sdk 1.1.0 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/v1/index.mjs CHANGED
@@ -3,8 +3,9 @@ import { z as z$1, createRoute, OpenAPIHono } from '@hono/zod-openapi';
3
3
  import { COUNTRY_CODES_2, LANGUAGE_CODES, CZ_TRADE_LICENSE_CODES, CZ_NACE_CODES, CURRENCY_CODES, BANK_CODES } from '@develit-io/general-codes';
4
4
  import { z } from 'zod';
5
5
  import { base, bankAccount as bankAccount$1, bankAccountMetadataSchema } from '@develit-io/backend-sdk';
6
- import { sqliteTable, text, integer, real, uniqueIndex } from 'drizzle-orm/sqlite-core';
6
+ import { sqliteTable, text, integer, real, foreignKey, uniqueIndex } from 'drizzle-orm/sqlite-core';
7
7
  import { createInsertSchema, createUpdateSchema, createSelectSchema } from 'drizzle-zod';
8
+ import 'drizzle-orm';
8
9
  import { jwt, signature, idempotency } from '@develit-io/backend-sdk/middlewares';
9
10
 
10
11
  const createMdmClient = (baseUrl, options) => {
@@ -388,11 +389,11 @@ const individual = sqliteTable("individual", {
388
389
  internalId: text("internal_id"),
389
390
  partyId: text("party_id").notNull().unique().references(() => party.id),
390
391
  name: text("name").notNull(),
391
- email: text("email"),
392
+ email: text("email").notNull(),
392
393
  phone: text("phone"),
393
394
  surname: text("surname").notNull(),
394
- birthDate: text("birth_date"),
395
- birthPlace: text("birth_place").notNull(),
395
+ birthDate: text("birth_date").notNull(),
396
+ birthPlace: text("birth_place"),
396
397
  countryOfBirth: text("country_of_birth", { enum: COUNTRY_CODES_2 }),
397
398
  personalId: text("personal_id").notNull(),
398
399
  gender: text("gender", { enum: GENDER }).notNull(),
@@ -548,18 +549,25 @@ const recipient = sqliteTable("recipient", {
548
549
  partyId: text("party_id").notNull().references(() => party.id)
549
550
  });
550
551
 
551
- const trader = sqliteTable("trader", {
552
- ...base,
553
- internalId: text("internal_id"),
554
- type: text("trader", { length: 50, enum: TRADER_TYPE }).$type().notNull(),
555
- firstName: text("first_name", { length: 255 }),
556
- lastName: text("last_name", { length: 255 }),
557
- companyName: text("company_name", { length: 255 }),
558
- ico: text("ico", { length: 255 }),
559
- dic: text("dic", { length: 255 }),
560
- commission: real("commission").notNull(),
561
- legacyId: text("legacy_id")
562
- });
552
+ const trader = sqliteTable(
553
+ "trader",
554
+ {
555
+ ...base,
556
+ internalId: text("internal_id"),
557
+ type: text("trader", { length: 50, enum: TRADER_TYPE }).$type().notNull(),
558
+ firstName: text("first_name", { length: 255 }),
559
+ lastName: text("last_name", { length: 255 }),
560
+ companyName: text("company_name", { length: 255 }),
561
+ ico: text("ico", { length: 255 }),
562
+ dic: text("dic", { length: 255 }),
563
+ commission: real("commission").notNull(),
564
+ legacyId: text("legacy_id"),
565
+ parentTraderId: text("parent_trader_id")
566
+ },
567
+ (table) => [
568
+ foreignKey({ columns: [table.parentTraderId], foreignColumns: [table.id] })
569
+ ]
570
+ );
563
571
 
564
572
  sqliteTable("trader_client", {
565
573
  ...base,
@@ -836,7 +844,7 @@ const contactUpdateSchema = z.object({
836
844
  const insertOverrides = {
837
845
  id: z.uuid(),
838
846
  partyId: z.uuid(),
839
- email: z.email("Invalid email format").optional()
847
+ email: z.email("Invalid email format")
840
848
  };
841
849
  const selectOverrides = {
842
850
  id: z.uuid(),
@@ -850,10 +858,11 @@ const individualBaseInsertSchema = createInsertSchema(
850
858
  individual,
851
859
  insertOverrides
852
860
  );
853
- createUpdateSchema(
854
- individual,
855
- insertOverrides
856
- );
861
+ createUpdateSchema(individual, {
862
+ id: z.uuid(),
863
+ partyId: z.uuid(),
864
+ email: z.email("Invalid email format").optional()
865
+ });
857
866
  const individualBaseSelectSchema = createSelectSchema(
858
867
  individual,
859
868
  selectOverrides
@@ -1063,7 +1072,7 @@ const disponentSelectSchema = z.discriminatedUnion("partyType", [
1063
1072
  data: organizationSelectSchema
1064
1073
  })
1065
1074
  ]);
1066
- z.array(disponentSelectSchema).optional();
1075
+ const disponentsSelectSchema = z.array(disponentSelectSchema).optional();
1067
1076
  z.array(disponentUpdateSchema).optional();
1068
1077
 
1069
1078
  const recipientBaseInsertSchema = createInsertSchema(recipient);
@@ -1145,7 +1154,7 @@ const ownerSelectSchema = individualSelectSchema.extend({
1145
1154
  shareEstablishedAt: z.string().nullable(),
1146
1155
  address: addressSelectSchema.nullable()
1147
1156
  });
1148
- createInsertSchema(party);
1157
+ const partyInsertSchema = createInsertSchema(party);
1149
1158
  createUpdateSchema(party);
1150
1159
  const partySchema$2 = z.object({
1151
1160
  partyType: z.enum(PARTY_TYPE),
@@ -1309,7 +1318,8 @@ const traderInsertSchema = z.object({
1309
1318
  companyName: z.string().optional(),
1310
1319
  ico: z.string().optional(),
1311
1320
  dic: z.string().optional(),
1312
- legacyId: z.string().optional()
1321
+ legacyId: z.string().optional(),
1322
+ parentTraderId: z.uuid().optional()
1313
1323
  });
1314
1324
  const traderUpdateSchema = z.object({
1315
1325
  id: z.uuid(),
@@ -1321,7 +1331,8 @@ const traderUpdateSchema = z.object({
1321
1331
  companyName: z.string().optional(),
1322
1332
  ico: z.string().optional(),
1323
1333
  dic: z.string().optional(),
1324
- legacyId: z.string().optional()
1334
+ legacyId: z.string().optional(),
1335
+ parentTraderId: z.uuid().optional()
1325
1336
  });
1326
1337
  z.object({
1327
1338
  id: z.uuid(),
@@ -1336,27 +1347,42 @@ z.object({
1336
1347
  companyName: z.string().nullable(),
1337
1348
  ico: z.string().nullable(),
1338
1349
  dic: z.string().nullable(),
1339
- legacyId: z.string().nullable()
1350
+ legacyId: z.string().nullable(),
1351
+ parentTraderId: z.uuid().nullable()
1352
+ });
1353
+
1354
+ const paginationSchema = z.object({
1355
+ offset: z.number().default(1),
1356
+ limit: z.number().default(10)
1357
+ });
1358
+ const paginationAndSearchSchema = z.object({
1359
+ page: z.coerce.number().positive().default(1),
1360
+ limit: z.coerce.number().positive().default(20),
1361
+ column: z.string(),
1362
+ direction: z.enum(["asc", "desc"]),
1363
+ search: z.string().optional(),
1364
+ ids: z.string().array().optional()
1365
+ });
1366
+ paginationSchema.extend({
1367
+ partyId: z.uuid()
1340
1368
  });
1369
+ paginationSchema.extend({
1370
+ id: z.uuid()
1371
+ });
1372
+ z.object({ partyId: z.uuid() });
1341
1373
 
1342
1374
  z.object({
1343
- recipient: recipientInsertSchema,
1344
- partyId: z.string().uuid()
1375
+ trader: traderInsertSchema
1345
1376
  });
1346
1377
 
1347
1378
  z.object({
1348
- recipient: recipientUpdateSchema
1379
+ trader: traderUpdateSchema
1349
1380
  });
1350
1381
 
1351
1382
  z.object({
1352
1383
  id: z.uuid()
1353
1384
  });
1354
1385
 
1355
- const ALLOWED_RECIPIENTS_FILTERS = {
1356
- NAME: "filterRecipientName",
1357
- BANK_CODE: "filterRecipientBankCode",
1358
- CURRENCY: "filterRecipientCurrency"
1359
- };
1360
1386
  z.object({
1361
1387
  page: z.number().positive(),
1362
1388
  limit: z.number().positive(),
@@ -1364,10 +1390,8 @@ z.object({
1364
1390
  column: z.string(),
1365
1391
  direction: z.enum(["asc", "desc"])
1366
1392
  }),
1367
- [ALLOWED_RECIPIENTS_FILTERS.NAME]: z.union([z.string(), z.string().array()]).optional(),
1368
- [ALLOWED_RECIPIENTS_FILTERS.BANK_CODE]: z.union([z.enum(BANK_CODES), z.enum(BANK_CODES).array()]).optional(),
1369
- [ALLOWED_RECIPIENTS_FILTERS.CURRENCY]: z.union([z.enum(CURRENCY_CODES), z.enum(CURRENCY_CODES).array()]).optional(),
1370
- search: z.string().optional()
1393
+ search: z.string().optional(),
1394
+ ids: z.array(z.uuid()).optional()
1371
1395
  });
1372
1396
 
1373
1397
  z.object({
@@ -1375,17 +1399,31 @@ z.object({
1375
1399
  });
1376
1400
 
1377
1401
  z.object({
1378
- trader: traderInsertSchema
1402
+ traderId: z.uuid(),
1403
+ clientId: z.uuid()
1404
+ });
1405
+ z.object({
1406
+ id: z.uuid()
1379
1407
  });
1380
1408
 
1381
1409
  z.object({
1382
- trader: traderUpdateSchema
1410
+ recipient: recipientInsertSchema,
1411
+ partyId: z.string().uuid()
1412
+ });
1413
+
1414
+ z.object({
1415
+ recipient: recipientUpdateSchema
1383
1416
  });
1384
1417
 
1385
1418
  z.object({
1386
1419
  id: z.uuid()
1387
1420
  });
1388
1421
 
1422
+ const ALLOWED_RECIPIENTS_FILTERS = {
1423
+ NAME: "filterRecipientName",
1424
+ BANK_CODE: "filterRecipientBankCode",
1425
+ CURRENCY: "filterRecipientCurrency"
1426
+ };
1389
1427
  z.object({
1390
1428
  page: z.number().positive(),
1391
1429
  limit: z.number().positive(),
@@ -1393,20 +1431,10 @@ z.object({
1393
1431
  column: z.string(),
1394
1432
  direction: z.enum(["asc", "desc"])
1395
1433
  }),
1396
- search: z.string().optional(),
1397
- ids: z.array(z.uuid()).optional()
1398
- });
1399
-
1400
- z.object({
1401
- id: z.uuid()
1402
- });
1403
-
1404
- z.object({
1405
- traderId: z.uuid(),
1406
- clientId: z.uuid()
1407
- });
1408
- z.object({
1409
- id: z.uuid()
1434
+ [ALLOWED_RECIPIENTS_FILTERS.NAME]: z.union([z.string(), z.string().array()]).optional(),
1435
+ [ALLOWED_RECIPIENTS_FILTERS.BANK_CODE]: z.union([z.enum(BANK_CODES), z.enum(BANK_CODES).array()]).optional(),
1436
+ [ALLOWED_RECIPIENTS_FILTERS.CURRENCY]: z.union([z.enum(CURRENCY_CODES), z.enum(CURRENCY_CODES).array()]).optional(),
1437
+ search: z.string().optional()
1410
1438
  });
1411
1439
 
1412
1440
  z.object({
@@ -1443,6 +1471,10 @@ z.object({
1443
1471
  id: z.uuid()
1444
1472
  });
1445
1473
 
1474
+ z.object({
1475
+ id: z.uuid()
1476
+ });
1477
+
1446
1478
  z.object({
1447
1479
  contact: contactInsertSchema,
1448
1480
  partyId: z.string().uuid()
@@ -1488,15 +1520,15 @@ z.object({
1488
1520
  });
1489
1521
 
1490
1522
  z.object({
1491
- id: z.uuid()
1523
+ individual: individualInsertSchema$1
1492
1524
  });
1493
1525
 
1494
1526
  z.object({
1495
- organization: organizationInsertSchema
1527
+ individual: individualInsertSchema$1
1496
1528
  });
1497
1529
 
1498
1530
  z.object({
1499
- organization: organizationInsertSchema
1531
+ id: z.uuid()
1500
1532
  });
1501
1533
 
1502
1534
  z.object({
@@ -1508,11 +1540,11 @@ z.object({
1508
1540
  });
1509
1541
 
1510
1542
  z.object({
1511
- individual: individualInsertSchema$1
1543
+ id: z.uuid()
1512
1544
  });
1513
1545
 
1514
1546
  z.object({
1515
- individual: individualInsertSchema$1
1547
+ id: z.uuid()
1516
1548
  });
1517
1549
 
1518
1550
  z.object({
@@ -1522,19 +1554,34 @@ z.object({
1522
1554
  z.object({
1523
1555
  id: z.uuid()
1524
1556
  });
1557
+ z.object({
1558
+ disponents: disponentsSelectSchema
1559
+ });
1525
1560
 
1526
1561
  z.object({
1527
- aml: amlInsertSchema
1562
+ party: partyInsertSchema
1528
1563
  });
1529
1564
 
1530
1565
  z.object({
1531
- aml: amlInsertSchema
1566
+ party: partyInsertSchema
1532
1567
  });
1533
1568
 
1534
1569
  z.object({
1535
1570
  id: z.uuid()
1536
1571
  });
1537
1572
 
1573
+ z.object({
1574
+ id: z.uuid()
1575
+ });
1576
+
1577
+ z.object({
1578
+ fromPartyId: z.uuid(),
1579
+ toPartyId: z.uuid(),
1580
+ relationshipType: z.enum(PARTY_RELATIONSHIP_TYPE),
1581
+ fromDate: z.date().optional(),
1582
+ sharePercentage: z.number().max(100).optional()
1583
+ });
1584
+
1538
1585
  const routeError = z$1.object({
1539
1586
  message: z$1.string(),
1540
1587
  data: z$1.null(),
@@ -1590,10 +1637,10 @@ const individualInsertSchema = z$1.object({
1590
1637
  internalId: z$1.string().optional(),
1591
1638
  name: z$1.string().min(1, "Jm\xE9no je povinn\xE9"),
1592
1639
  surname: z$1.string().min(1, "P\u0159\xEDjmen\xED je povinn\xE9"),
1593
- email: z$1.string().optional(),
1640
+ email: z$1.email("E-mail je povinn\xFD"),
1594
1641
  phone: z$1.string().optional(),
1595
- birthDate: z$1.string().optional(),
1596
- birthPlace: z$1.string().min(1, "M\u011Bsto narozen\xED je povinn\xE9"),
1642
+ birthDate: z$1.string().min(1, "Datum narozen\xED je povinn\xE9"),
1643
+ birthPlace: z$1.string().optional(),
1597
1644
  countryOfBirth: z$1.enum(COUNTRY_CODES_2).optional(),
1598
1645
  personalId: z$1.string().min(1, "\u010C\xEDslo identifika\u010Dn\xEDho dokumentu je povinn\xE9"),
1599
1646
  gender: z$1.enum(GENDER, "Pohlav\xED je povinn\xE9"),
@@ -1772,6 +1819,7 @@ const ownerInputSchema = z$1.object({
1772
1819
  name: z$1.string().min(1, "Jm\xE9no je povinn\xE9"),
1773
1820
  surname: z$1.string().min(1, "P\u0159\xEDjmen\xED je povinn\xE9"),
1774
1821
  titleAfter: z$1.string().optional(),
1822
+ email: z$1.email("E-mail je povinn\xFD"),
1775
1823
  birthDate: z$1.string().min(1, "Datum narozen\xED je povinn\xE9"),
1776
1824
  birthPlace: z$1.string().min(1, "M\xEDsto narozen\xED je povinn\xE9"),
1777
1825
  personalId: z$1.string().min(1, "Rodn\xE9 \u010D\xEDslo je povinn\xE9"),
@@ -1787,6 +1835,7 @@ const legalRepresentativeInputSchema = z$1.object({
1787
1835
  name: z$1.string().min(1, "Jm\xE9no je povinn\xE9"),
1788
1836
  surname: z$1.string().min(1, "P\u0159\xEDjmen\xED je povinn\xE9"),
1789
1837
  titleAfter: z$1.string().optional(),
1838
+ email: z$1.email("E-mail je povinn\xFD"),
1790
1839
  birthDate: z$1.string().min(1, "Datum narozen\xED je povinn\xE9"),
1791
1840
  birthPlace: z$1.string().min(1, "M\xEDsto narozen\xED je povinn\xE9"),
1792
1841
  personalId: z$1.string().min(1, "Rodn\xE9 \u010D\xEDslo je povinn\xE9"),
@@ -1794,7 +1843,6 @@ const legalRepresentativeInputSchema = z$1.object({
1794
1843
  citizenship: z$1.enum(COUNTRY_CODES_2, "St\xE1tn\xED p\u0159\xEDslu\u0161nost je povinn\xE1"),
1795
1844
  isPep: z$1.boolean({ error: "Politicky exponovan\xE1 osoba je povinn\xE1" }),
1796
1845
  phone: z$1.string().optional(),
1797
- email: z$1.string().optional(),
1798
1846
  pin: z$1.string().optional(),
1799
1847
  identityDocuments: z$1.array(idDocumentInputSchema$1).optional(),
1800
1848
  address: createAddressInputSchema,
@@ -2188,9 +2236,9 @@ const disponentIndividualSyncDataSchema = z$1.object({
2188
2236
  id: z$1.uuid().optional(),
2189
2237
  name: z$1.string(),
2190
2238
  surname: z$1.string(),
2191
- email: z$1.string().optional(),
2239
+ email: z$1.email("E-mail je povinn\xFD"),
2192
2240
  phone: z$1.string().optional(),
2193
- birthDate: z$1.string().optional(),
2241
+ birthDate: z$1.string().min(1, "Datum narozen\xED je povinn\xE9"),
2194
2242
  birthPlace: z$1.string(),
2195
2243
  countryOfBirth: z$1.enum(COUNTRY_CODES_2).optional(),
2196
2244
  personalId: z$1.string(),
@@ -2341,6 +2389,7 @@ const ownerSyncSchema = z$1.object({
2341
2389
  name: z$1.string(),
2342
2390
  surname: z$1.string(),
2343
2391
  titleAfter: z$1.string().optional(),
2392
+ email: z$1.email("E-mail je povinn\xFD"),
2344
2393
  birthDate: z$1.string(),
2345
2394
  birthPlace: z$1.string(),
2346
2395
  personalId: z$1.string(),
@@ -2357,6 +2406,7 @@ const legalRepresentativeSyncSchema = z$1.object({
2357
2406
  name: z$1.string(),
2358
2407
  surname: z$1.string(),
2359
2408
  titleAfter: z$1.string().optional(),
2409
+ email: z$1.email("E-mail je povinn\xFD"),
2360
2410
  birthDate: z$1.string(),
2361
2411
  birthPlace: z$1.string(),
2362
2412
  personalId: z$1.string(),
@@ -2364,7 +2414,6 @@ const legalRepresentativeSyncSchema = z$1.object({
2364
2414
  citizenship: z$1.enum(COUNTRY_CODES_2),
2365
2415
  isPep: z$1.boolean(),
2366
2416
  phone: z$1.string().optional(),
2367
- email: z$1.string().optional(),
2368
2417
  pin: z$1.string().optional(),
2369
2418
  identityDocuments: z$1.array(idDocumentInputSchema).optional(),
2370
2419
  address: syncAddressInputSchema,
@@ -2714,10 +2763,10 @@ const individualOutputSchema = z$1.object({
2714
2763
  internalId: z$1.string().nullable(),
2715
2764
  name: z$1.string(),
2716
2765
  surname: z$1.string(),
2717
- email: z$1.string().nullable(),
2766
+ email: z$1.string(),
2718
2767
  phone: z$1.string().nullable(),
2719
- birthDate: z$1.string().nullable(),
2720
- birthPlace: z$1.string(),
2768
+ birthDate: z$1.string(),
2769
+ birthPlace: z$1.string().nullable(),
2721
2770
  countryOfBirth: z$1.enum(COUNTRY_CODES_2).nullable(),
2722
2771
  personalId: z$1.string(),
2723
2772
  gender: z$1.enum(GENDER),
@@ -2888,8 +2937,9 @@ const ownerOutputSchema = z$1.object({
2888
2937
  surname: z$1.string(),
2889
2938
  titleBefore: z$1.string().nullable(),
2890
2939
  titleAfter: z$1.string().nullable(),
2891
- birthDate: z$1.string().nullable(),
2892
- birthPlace: z$1.string(),
2940
+ email: z$1.string(),
2941
+ birthDate: z$1.string(),
2942
+ birthPlace: z$1.string().nullable(),
2893
2943
  personalId: z$1.string(),
2894
2944
  gender: z$1.enum(GENDER),
2895
2945
  citizenship: z$1.enum(COUNTRY_CODES_2),
@@ -2904,14 +2954,14 @@ const legalRepresentativeOutputSchema = z$1.object({
2904
2954
  surname: z$1.string(),
2905
2955
  titleBefore: z$1.string().nullable(),
2906
2956
  titleAfter: z$1.string().nullable(),
2907
- birthDate: z$1.string().nullable(),
2908
- birthPlace: z$1.string(),
2957
+ email: z$1.string(),
2958
+ birthDate: z$1.string(),
2959
+ birthPlace: z$1.string().nullable(),
2909
2960
  personalId: z$1.string(),
2910
2961
  gender: z$1.enum(GENDER),
2911
2962
  citizenship: z$1.enum(COUNTRY_CODES_2),
2912
2963
  isPep: z$1.boolean(),
2913
2964
  phone: z$1.string().nullable(),
2914
- email: z$1.string().nullable(),
2915
2965
  pin: z$1.string().nullable(),
2916
2966
  dateOfEstablishment: z$1.string().nullable(),
2917
2967
  address: createAddressOutputSchema.nullable()
@@ -2985,26 +3035,6 @@ new OpenAPIHono().openapi(
2985
3035
  }
2986
3036
  );
2987
3037
 
2988
- const paginationSchema = z.object({
2989
- offset: z.number().default(1),
2990
- limit: z.number().default(10)
2991
- });
2992
- const paginationAndSearchSchema = z.object({
2993
- page: z.coerce.number().positive().default(1),
2994
- limit: z.coerce.number().positive().default(20),
2995
- column: z.string(),
2996
- direction: z.enum(["asc", "desc"]),
2997
- search: z.string().optional(),
2998
- ids: z.string().array().optional()
2999
- });
3000
- paginationSchema.extend({
3001
- partyId: z.uuid()
3002
- });
3003
- paginationSchema.extend({
3004
- id: z.uuid()
3005
- });
3006
- z.object({ partyId: z.uuid() });
3007
-
3008
3038
  const partiesOutputDataSchema = z$1.array(partyOutputSchema);
3009
3039
  const getPartiesRoute = createRoute({
3010
3040
  method: "get",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devizovaburza/mdm-sdk",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "prepare": "bun run build",