@bizmap/sdk 0.0.93 → 0.0.95

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.
Files changed (3) hide show
  1. package/dist/main.d.ts +47 -46
  2. package/dist/main.js +171 -166
  3. package/package.json +1 -1
package/dist/main.d.ts CHANGED
@@ -70,12 +70,6 @@ declare const genders: z.ZodEnum<{
70
70
  female: "female";
71
71
  }>;
72
72
  type Gender = z.infer<typeof genders>;
73
- declare const nidClasses: z.ZodEnum<{
74
- passportNo: "passportNo";
75
- trn: "trn";
76
- nin: "nin";
77
- }>;
78
- type NidClass = z.infer<typeof nidClasses>;
79
73
  declare const acceptedCurrencies: z.ZodEnum<{
80
74
  JMD: "JMD";
81
75
  }>;
@@ -968,6 +962,7 @@ declare const Reason: z.ZodObject<{
968
962
  lastModified: z.ZodInt;
969
963
  }, z.core.$strip>;
970
964
  declare const Version: z.ZodInt;
965
+ declare const AlphaNumeric: z.ZodString;
971
966
 
972
967
  declare const PriceAdjustment: z.ZodObject<{
973
968
  createdAt: z.ZodReadonly<z.ZodInt>;
@@ -1036,7 +1031,6 @@ declare const ClientIdentity: z.ZodObject<{
1036
1031
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
1037
1032
  version: z.ZodInt;
1038
1033
  _id: z.ZodUUID;
1039
- phoneNumber: z.ZodOptional<z.ZodString>;
1040
1034
  photoUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1041
1035
  firstName: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
1042
1036
  middleName: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
@@ -1049,18 +1043,17 @@ declare const ClientIdentity: z.ZodObject<{
1049
1043
  }>;
1050
1044
  isGlobal: z.ZodBoolean;
1051
1045
  origin: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
1046
+ visits: z.ZodOptional<z.ZodRecord<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodArray<z.ZodInt>>>;
1047
+ phoneNumber: z.ZodOptional<z.ZodString>;
1052
1048
  nid: z.ZodOptional<z.ZodObject<{
1053
- class: z.ZodEnum<{
1054
- passportNo: "passportNo";
1055
- trn: "trn";
1056
- nin: "nin";
1057
- }>;
1058
- value: z.ZodString;
1049
+ trn: z.ZodOptional<z.ZodString>;
1050
+ nin: z.ZodOptional<z.ZodString>;
1051
+ passportNo: z.ZodOptional<z.ZodString>;
1059
1052
  }, z.core.$strip>>;
1060
1053
  attributes: z.ZodObject<{
1061
- mothersMaidenName: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
1062
- fathersMiddleName: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
1063
- mothersMiddleName: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
1054
+ motherMaidenName: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
1055
+ fatherMiddleName: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
1056
+ motherMiddleName: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
1064
1057
  oldestSiblingMiddleName: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
1065
1058
  firstSchoolName: z.ZodOptional<z.ZodString>;
1066
1059
  }, z.core.$strip>;
@@ -1089,6 +1082,7 @@ declare const MiniAppointmentDetails: z.ZodObject<{
1089
1082
  createdAt: z.ZodReadonly<z.ZodInt>;
1090
1083
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
1091
1084
  _id: z.ZodUUID;
1085
+ category: z.ZodInt;
1092
1086
  src: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
1093
1087
  tkt: z.ZodReadonly<z.ZodInt>;
1094
1088
  reason: z.ZodOptional<z.ZodObject<{
@@ -1303,6 +1297,7 @@ declare const AppointmentDetails: z.ZodObject<{
1303
1297
  }, z.core.$strip>>>;
1304
1298
  src: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
1305
1299
  tkt: z.ZodReadonly<z.ZodInt>;
1300
+ category: z.ZodInt;
1306
1301
  reason: z.ZodOptional<z.ZodObject<{
1307
1302
  createdAt: z.ZodReadonly<z.ZodInt>;
1308
1303
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
@@ -1369,7 +1364,6 @@ declare const AppointmentDetails: z.ZodObject<{
1369
1364
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
1370
1365
  version: z.ZodInt;
1371
1366
  _id: z.ZodUUID;
1372
- phoneNumber: z.ZodOptional<z.ZodString>;
1373
1367
  photoUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1374
1368
  firstName: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
1375
1369
  middleName: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
@@ -1382,18 +1376,17 @@ declare const AppointmentDetails: z.ZodObject<{
1382
1376
  }>;
1383
1377
  isGlobal: z.ZodBoolean;
1384
1378
  origin: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
1379
+ visits: z.ZodOptional<z.ZodRecord<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodArray<z.ZodInt>>>;
1380
+ phoneNumber: z.ZodOptional<z.ZodString>;
1385
1381
  nid: z.ZodOptional<z.ZodObject<{
1386
- class: z.ZodEnum<{
1387
- passportNo: "passportNo";
1388
- trn: "trn";
1389
- nin: "nin";
1390
- }>;
1391
- value: z.ZodString;
1382
+ trn: z.ZodOptional<z.ZodString>;
1383
+ nin: z.ZodOptional<z.ZodString>;
1384
+ passportNo: z.ZodOptional<z.ZodString>;
1392
1385
  }, z.core.$strip>>;
1393
1386
  attributes: z.ZodObject<{
1394
- mothersMaidenName: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
1395
- fathersMiddleName: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
1396
- mothersMiddleName: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
1387
+ motherMaidenName: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
1388
+ fatherMiddleName: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
1389
+ motherMiddleName: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
1397
1390
  oldestSiblingMiddleName: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
1398
1391
  firstSchoolName: z.ZodOptional<z.ZodString>;
1399
1392
  }, z.core.$strip>;
@@ -1484,6 +1477,7 @@ declare const MutableAppointmentDetails: z.ZodObject<{
1484
1477
  }, z.core.$strip>>>;
1485
1478
  src: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
1486
1479
  tkt: z.ZodReadonly<z.ZodInt>;
1480
+ category: z.ZodInt;
1487
1481
  reason: z.ZodOptional<z.ZodObject<{
1488
1482
  createdAt: z.ZodReadonly<z.ZodInt>;
1489
1483
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
@@ -1550,7 +1544,6 @@ declare const MutableAppointmentDetails: z.ZodObject<{
1550
1544
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
1551
1545
  version: z.ZodInt;
1552
1546
  _id: z.ZodUUID;
1553
- phoneNumber: z.ZodOptional<z.ZodString>;
1554
1547
  photoUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1555
1548
  firstName: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
1556
1549
  middleName: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
@@ -1563,18 +1556,17 @@ declare const MutableAppointmentDetails: z.ZodObject<{
1563
1556
  }>;
1564
1557
  isGlobal: z.ZodBoolean;
1565
1558
  origin: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
1559
+ visits: z.ZodOptional<z.ZodRecord<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodArray<z.ZodInt>>>;
1560
+ phoneNumber: z.ZodOptional<z.ZodString>;
1566
1561
  nid: z.ZodOptional<z.ZodObject<{
1567
- class: z.ZodEnum<{
1568
- passportNo: "passportNo";
1569
- trn: "trn";
1570
- nin: "nin";
1571
- }>;
1572
- value: z.ZodString;
1562
+ trn: z.ZodOptional<z.ZodString>;
1563
+ nin: z.ZodOptional<z.ZodString>;
1564
+ passportNo: z.ZodOptional<z.ZodString>;
1573
1565
  }, z.core.$strip>>;
1574
1566
  attributes: z.ZodObject<{
1575
- mothersMaidenName: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
1576
- fathersMiddleName: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
1577
- mothersMiddleName: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
1567
+ motherMaidenName: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
1568
+ fatherMiddleName: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
1569
+ motherMiddleName: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
1578
1570
  oldestSiblingMiddleName: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
1579
1571
  firstSchoolName: z.ZodOptional<z.ZodString>;
1580
1572
  }, z.core.$strip>;
@@ -1592,8 +1584,14 @@ type MutableAppointmentDetails = z.infer<typeof MutableAppointmentDetails>;
1592
1584
  declare const ScheduleAppointmentForm: z.ZodObject<{
1593
1585
  createdAt: z.ZodReadonly<z.ZodInt>;
1594
1586
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
1595
- clientUid: z.ZodUUID;
1596
- serviceProviderUid: z.ZodOptional<z.ZodNullable<z.ZodUUID>>;
1587
+ clientId: z.ZodUUID;
1588
+ serviceProviderId: z.ZodUnion<[z.ZodUUID, z.ZodLiteral<"next">]>;
1589
+ category: z.ZodInt;
1590
+ appointmentReason: z.ZodOptional<z.ZodObject<{
1591
+ createdAt: z.ZodReadonly<z.ZodInt>;
1592
+ lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
1593
+ value: z.ZodString;
1594
+ }, z.core.$strip>>;
1597
1595
  charges: z.ZodOptional<z.ZodArray<z.ZodObject<{
1598
1596
  createdAt: z.ZodReadonly<z.ZodInt>;
1599
1597
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
@@ -1747,6 +1745,7 @@ declare function scheduleAppointment(request: RequestParameter): Promise<{
1747
1745
  }[] | null;
1748
1746
  src: string;
1749
1747
  tkt: number;
1748
+ category: number;
1750
1749
  charges: {
1751
1750
  createdAt: number;
1752
1751
  uid: string;
@@ -1786,19 +1785,21 @@ declare function scheduleAppointment(request: RequestParameter): Promise<{
1786
1785
  isGlobal: boolean;
1787
1786
  origin: string;
1788
1787
  attributes: {
1789
- mothersMaidenName?: string | undefined;
1790
- fathersMiddleName?: string | undefined;
1791
- mothersMiddleName?: string | undefined;
1788
+ motherMaidenName?: string | undefined;
1789
+ fatherMiddleName?: string | undefined;
1790
+ motherMiddleName?: string | undefined;
1792
1791
  oldestSiblingMiddleName?: string | undefined;
1793
1792
  firstSchoolName?: string | undefined;
1794
1793
  };
1795
1794
  lastModified?: number | null | undefined;
1796
- phoneNumber?: string | undefined;
1797
1795
  photoUrl?: string | null | undefined;
1798
1796
  email?: string | undefined;
1797
+ visits?: Record<string, number[]> | undefined;
1798
+ phoneNumber?: string | undefined;
1799
1799
  nid?: {
1800
- class: "passportNo" | "trn" | "nin";
1801
- value: string;
1800
+ trn?: string | undefined;
1801
+ nin?: string | undefined;
1802
+ passportNo?: string | undefined;
1802
1803
  } | undefined;
1803
1804
  address?: {
1804
1805
  streetAddress: string;
@@ -1918,7 +1919,7 @@ declare const findConflictingPartners: (...partners: (CompanyUser | MiniCompanyU
1918
1919
  * */
1919
1920
  declare const getCompatibleRoles: (role: CompanyUserRole) => CompanyUserRole[];
1920
1921
  declare const normalizeCompanyId: (id: string) => string;
1921
- declare const normalizeNidClass: (value: NidClass) => string;
1922
+ declare const normalizeNidKey: (value: keyof NonNullable<ClientIdentity["nid"]>) => string;
1922
1923
  declare const parseClientName: ({ firstName, middleName, lastName, }: Pick<ClientIdentity, "firstName" | "middleName" | "lastName">) => string;
1923
1924
 
1924
1925
  declare function createNotifId(options?: {
@@ -1926,4 +1927,4 @@ declare function createNotifId(options?: {
1926
1927
  to: string;
1927
1928
  }): string;
1928
1929
 
1929
- export { type AcceptedCurrency, AppointmentDetails, type AppointmentDistAlg, ClientForm, ClientIdentity, CompanyBilling, CompanyDetails, CompanyIdentity, CompanyInviteList, CompanyNotifications, type CompanyPartnerRole, CompanyPreferences, type CompanyServiceSelector, CompanyStaff, CompanyState, CompanyUser, type CompanyUserRole, CompanyUserSession, type CompanyUserStatus, CreateCompanyForm, CreditCurrency, type EmployeeRole, type Gender, type HealthcareProviderRole, type Industry, InviteResponse, InvoiceNo, MedicalDetails, Medicine, MiniAppointmentDetails, MiniCompanyUser, MutableAppointmentDetails, MutableCompanyBilling, MutableCompanyDetails, MutableCompanyIdentity, MutableCompanyPreferences, type NidClass, Notification, PaymentDetails, type PaymentMethod, PriceAdjustment, PriceTag, Reason, Receipts, ScheduleAppointmentForm, StandardTime, TicketNo, type Tier, TierList, TimeLog, Timestamp, Trn, UserDetails, Version, Vitals, acceptedCurrencies, adminRoles, appointmentDistAlgs, calcAppointmentFee, companyPartnerRoles, companyServiceSelectors, companyUserRoles, companyUserStatus, createNotifId, employeeRoles, findAvailableStaff, findConflictingPartners, findNextAvailableStaff, genders, getCompatibleRoles, healthcareProviderRoles, industries, nidClasses, normalizeCompanyId, normalizeNidClass, parseClientName, paymentMethods, scheduleAppointment, serviceProviders, tiers, vitalKeys };
1930
+ export { type AcceptedCurrency, AlphaNumeric, AppointmentDetails, type AppointmentDistAlg, ClientForm, ClientIdentity, CompanyBilling, CompanyDetails, CompanyIdentity, CompanyInviteList, CompanyNotifications, type CompanyPartnerRole, CompanyPreferences, type CompanyServiceSelector, CompanyStaff, CompanyState, CompanyUser, type CompanyUserRole, CompanyUserSession, type CompanyUserStatus, CreateCompanyForm, CreditCurrency, type EmployeeRole, type Gender, type HealthcareProviderRole, type Industry, InviteResponse, InvoiceNo, MedicalDetails, Medicine, MiniAppointmentDetails, MiniCompanyUser, MutableAppointmentDetails, MutableCompanyBilling, MutableCompanyDetails, MutableCompanyIdentity, MutableCompanyPreferences, Notification, PaymentDetails, type PaymentMethod, PriceAdjustment, PriceTag, Reason, Receipts, ScheduleAppointmentForm, StandardTime, TicketNo, type Tier, TierList, TimeLog, Timestamp, Trn, UserDetails, Version, Vitals, acceptedCurrencies, adminRoles, appointmentDistAlgs, calcAppointmentFee, companyPartnerRoles, companyServiceSelectors, companyUserRoles, companyUserStatus, createNotifId, employeeRoles, findAvailableStaff, findConflictingPartners, findNextAvailableStaff, genders, getCompatibleRoles, healthcareProviderRoles, industries, normalizeCompanyId, normalizeNidKey, parseClientName, paymentMethods, scheduleAppointment, serviceProviders, tiers, vitalKeys };
package/dist/main.js CHANGED
@@ -33,7 +33,6 @@ import * as z2 from "zod";
33
33
  var tiers = z2.enum(["basic", "pro", "premium", "gold"]);
34
34
  var paymentMethods = z2.enum(["cash", "card", "insurance"]);
35
35
  var genders = z2.enum(["male", "female"]);
36
- var nidClasses = z2.enum(["passportNo", "trn", "nin"]);
37
36
  var acceptedCurrencies = currencies.extract(["JMD"]);
38
37
 
39
38
  // src/enums/Medical.ts
@@ -56,7 +55,7 @@ var serviceProviders = z4.enum([
56
55
  ]);
57
56
 
58
57
  // src/schemas/company/CompanyDetails.ts
59
- import * as z16 from "zod";
58
+ import * as z17 from "zod";
60
59
 
61
60
  // src/schemas/company/components/Billing.ts
62
61
  import * as z8 from "zod";
@@ -99,6 +98,13 @@ var Reason = z5.object({
99
98
  lastModified: Timestamp
100
99
  });
101
100
  var Version = z5.int().min(1);
101
+ var AlphaNumeric = z5.string().trim().superRefine((data, ctx) => {
102
+ const invalidCharIdx = data.search(/[^a-z0-9]/i);
103
+ if (invalidCharIdx > -1) {
104
+ const char = `"'`.includes(data[invalidCharIdx]) ? `(${data[invalidCharIdx]})` : `"${data[invalidCharIdx]}"`;
105
+ ctx.addIssue(`${char} is not an alpha-numeric character.`);
106
+ }
107
+ });
102
108
 
103
109
  // src/schemas/utils/billing.ts
104
110
  var PriceAdjustment = z6.object({
@@ -413,13 +419,105 @@ var MutableCompanyPreferences = CompanyPreferences.omit({
413
419
  });
414
420
 
415
421
  // src/schemas/company/components/Staff.ts
416
- import * as z15 from "zod";
422
+ import * as z16 from "zod";
417
423
 
418
424
  // src/schemas/company/components/User.ts
419
- import * as z14 from "zod";
425
+ import * as z15 from "zod";
420
426
 
421
427
  // src/functions/helper-functions.ts
422
428
  import { camelCaseToLetter, upperFirst as upperFirst2 } from "@wavy/fn";
429
+
430
+ // src/schemas/profiles/Client.ts
431
+ import * as z14 from "zod";
432
+
433
+ // src/schemas/profiles/User.ts
434
+ import { UserModel } from "@wavy/util";
435
+ import * as z13 from "zod";
436
+ var UserDetails = z13.object({
437
+ ...UserModel.shape,
438
+ _id: z13.uuidv4(),
439
+ name: z13.string().transform((data) => {
440
+ const [firstName = "", lastName = ""] = data.split(" ");
441
+ return (firstName + " " + lastName).trim();
442
+ }).superRefine((data, ctx) => {
443
+ data.split(" ").forEach((name, idx) => {
444
+ const nty = idx === 0 ? "First" : "Last";
445
+ if (idx === 0 && name.length < 2) {
446
+ ctx.addIssue(`${nty} name must have at least (2) characters.`);
447
+ }
448
+ if (name.length > MAX_NAME_LENGTH) {
449
+ ctx.addIssue(`${nty} name can't have more than (${MAX_NAME_LENGTH}) characters.`);
450
+ }
451
+ });
452
+ }),
453
+ email: UserModel.shape.email,
454
+ publicKey: z13.string().nullable(),
455
+ notifications: z13.array(Notification),
456
+ version: Version,
457
+ companyUids: z13.array(CompanyState.shape._id).min(1).optional(),
458
+ resumeToken: z13.uuidv4().optional(),
459
+ ...TimeLog.shape
460
+ }).omit({ uid: true });
461
+
462
+ // src/schemas/profiles/Client.ts
463
+ import { Address as Address2, PhoneNumber as PhoneNumber2 } from "@wavy/util";
464
+ var Name = z14.string().trim().min(2).max(MAX_NAME_LENGTH).transform((d) => d.replace(/-+/g, "-").replace(/'+/g, "'")).superRefine((data, ctx) => {
465
+ const invalidCharIdx = data.search(/[^a-z'-]/i);
466
+ if (invalidCharIdx >= 0) {
467
+ const char = data[invalidCharIdx].includes('"') ? `(${data[invalidCharIdx]})` : `"${data[invalidCharIdx]}"`;
468
+ ctx.addIssue(`${char} is not an allowed character.`);
469
+ }
470
+ });
471
+ var ClientIdentity = UserDetails.pick({
472
+ _id: true,
473
+ createdAt: true,
474
+ lastModified: true,
475
+ phoneNumber: true,
476
+ version: true,
477
+ photoUrl: true
478
+ }).safeExtend(
479
+ z14.object({
480
+ firstName: Name,
481
+ middleName: Name,
482
+ lastName: Name,
483
+ email: UserDetails.shape.email.optional(),
484
+ dob: Timestamp,
485
+ sex: genders,
486
+ isGlobal: z14.boolean(),
487
+ origin: CompanyIdentity.shape._id,
488
+ visits: z14.record(CompanyIdentity.shape._id, z14.array(Timestamp).min(1)).optional(),
489
+ phoneNumber: PhoneNumber2.optional(),
490
+ // aka. National id
491
+ nid: z14.object({
492
+ trn: Trn,
493
+ nin: AlphaNumeric.toLowerCase().min(5).max(20),
494
+ passportNo: AlphaNumeric.toLowerCase().min(5).max(15)
495
+ }).partial().optional(),
496
+ // Don't hash the attributes, they can be used to help accurately identify a client by whoever is searching for
497
+ // the client
498
+ attributes: z14.object({
499
+ motherMaidenName: Name,
500
+ fatherMiddleName: Name,
501
+ motherMiddleName: Name,
502
+ oldestSiblingMiddleName: Name,
503
+ firstSchoolName: z14.string().trim().min(3).max(60)
504
+ }).partial().refine(
505
+ (data) => Object.keys(data).length > 0,
506
+ "At least (1) attribute must be defined."
507
+ ),
508
+ address: Address2.optional(),
509
+ linkedTo: UserDetails.shape._id.optional()
510
+ }).shape
511
+ );
512
+ var ClientForm = ClientIdentity.pick({
513
+ firstName: true,
514
+ middleName: true,
515
+ lastName: true,
516
+ dob: true,
517
+ sex: true
518
+ }).required();
519
+
520
+ // src/functions/helper-functions.ts
423
521
  var findConflictingPartners = (...partners) => {
424
522
  let hasSingleDoctor = false;
425
523
  const conflicts = [];
@@ -452,8 +550,8 @@ var getCompatibleRoles = (role) => {
452
550
  var normalizeCompanyId = (id) => {
453
551
  return id.split("-").map((value) => upperFirst2(value.toLowerCase())).join(" ");
454
552
  };
455
- var normalizeNidClass = (value) => {
456
- value = nidClasses.parse(value);
553
+ var normalizeNidKey = (value) => {
554
+ value = ClientIdentity.shape.nid.unwrap().keyof().parse(value);
457
555
  if (value === "nin") return "National Id No.";
458
556
  if (value === "trn") return "Tax Registration No.";
459
557
  return camelCaseToLetter(value.replace("No", "No."));
@@ -464,51 +562,22 @@ var parseClientName = ({
464
562
  lastName
465
563
  }) => [firstName, middleName[0] + ".", lastName].join(" ");
466
564
 
467
- // src/schemas/profiles/User.ts
468
- import { UserModel } from "@wavy/util";
469
- import * as z13 from "zod";
470
- var UserDetails = z13.object({
471
- ...UserModel.shape,
472
- _id: z13.uuidv4(),
473
- name: z13.string().transform((data) => {
474
- const [firstName = "", lastName = ""] = data.split(" ");
475
- return (firstName + " " + lastName).trim();
476
- }).superRefine((data, ctx) => {
477
- data.split(" ").forEach((name, idx) => {
478
- const nty = idx === 0 ? "First" : "Last";
479
- if (idx === 0 && name.length < 2) {
480
- ctx.addIssue(`${nty} name must have at least (2) characters.`);
481
- }
482
- if (name.length > MAX_NAME_LENGTH) {
483
- ctx.addIssue(`${nty} name can't have more than (${MAX_NAME_LENGTH}) characters.`);
484
- }
485
- });
486
- }),
487
- email: UserModel.shape.email,
488
- publicKey: z13.string().nullable(),
489
- notifications: z13.array(Notification),
490
- version: Version,
491
- companyUids: z13.array(CompanyState.shape._id).min(1).optional(),
492
- resumeToken: z13.uuidv4().optional(),
493
- ...TimeLog.shape
494
- }).omit({ uid: true });
495
-
496
565
  // src/schemas/company/components/User.ts
497
- var CompanyUserSession = z14.object({
498
- _id: z14.uuidv4(),
566
+ var CompanyUserSession = z15.object({
567
+ _id: z15.uuidv4(),
499
568
  user: UserDetails.pick({ _id: true, name: true, email: true }),
500
569
  companyId: CompanyState.shape._id,
501
- deviceId: z14.string().trim().min(15),
502
- isAvailable: z14.object({
503
- value: z14.boolean(),
570
+ deviceId: z15.string().trim().min(15),
571
+ isAvailable: z15.object({
572
+ value: z15.boolean(),
504
573
  lastModified: Timestamp.nullable()
505
574
  }),
506
- isBusy: z14.object({
507
- value: z14.boolean(),
575
+ isBusy: z15.object({
576
+ value: z15.boolean(),
508
577
  lastModified: Timestamp.nullable()
509
578
  }),
510
- appointments: z14.record(z14.literal(["ongoing", "completed"]), z14.int().min(0)),
511
- roles: z14.array(companyUserRoles).transform((roles) => {
579
+ appointments: z15.record(z15.literal(["ongoing", "completed"]), z15.int().min(0)),
580
+ roles: z15.array(companyUserRoles).transform((roles) => {
512
581
  const newRoles = [];
513
582
  for (const role of roles) {
514
583
  if (!!role && !newRoles.includes(role)) newRoles.push(role);
@@ -519,11 +588,11 @@ var CompanyUserSession = z14.object({
519
588
  (role, i) => i === 0 || getCompatibleRoles(roles[0]).includes(role)
520
589
  );
521
590
  }, "A user is not allowed to have conflicting roles."),
522
- ttl: z14.number(),
591
+ ttl: z15.number(),
523
592
  lastModified: Timestamp.nullable(),
524
- expiresAfter: z14.date()
593
+ expiresAfter: z15.date()
525
594
  });
526
- var MiniCompanyUser2 = z14.object({
595
+ var MiniCompanyUser2 = z15.object({
527
596
  _id: UserDetails.shape._id,
528
597
  ...CompanyUserSession.pick({
529
598
  roles: true,
@@ -537,7 +606,7 @@ var MiniCompanyUser2 = z14.object({
537
606
  inviteSent: Timestamp.nullish(),
538
607
  inviteAccepted: Timestamp.nullable()
539
608
  });
540
- var CompanyUser = z14.object({
609
+ var CompanyUser = z15.object({
541
610
  ...MiniCompanyUser2.shape,
542
611
  ...CompanyUserSession.shape.user.shape,
543
612
  // Determined based on:
@@ -548,9 +617,9 @@ var CompanyUser = z14.object({
548
617
  });
549
618
 
550
619
  // src/schemas/company/components/Staff.ts
551
- var MiniRawCompanyStaff = z15.object({
620
+ var MiniRawCompanyStaff = z16.object({
552
621
  _id: CompanyState.shape._id,
553
- members: z15.record(
622
+ members: z16.record(
554
623
  MiniCompanyUser2.shape._id,
555
624
  MiniCompanyUser2.omit({ _id: true })
556
625
  ),
@@ -558,15 +627,15 @@ var MiniRawCompanyStaff = z15.object({
558
627
  /**
559
628
  * @relationship one -> many
560
629
  *@description A map of doctor `uids` to their assistants `uids` */
561
- partnerMap: z15.record(
630
+ partnerMap: z16.record(
562
631
  CompanyUser.shape._id,
563
- z15.record(CompanyUser.shape._id, z15.object({ addedAt: Timestamp }))
632
+ z16.record(CompanyUser.shape._id, z16.object({ addedAt: Timestamp }))
564
633
  ),
565
- updateQueue: z15.record(
634
+ updateQueue: z16.record(
566
635
  CompanyUser.shape._id,
567
- z15.object({
568
- $REMOVE: z15.object({ addedAt: Timestamp }),
569
- $CHANGE_ROLES: z15.object({
636
+ z16.object({
637
+ $REMOVE: z16.object({ addedAt: Timestamp }),
638
+ $CHANGE_ROLES: z16.object({
570
639
  newRoles: CompanyUser.shape.roles,
571
640
  addedAt: Timestamp
572
641
  })
@@ -575,9 +644,9 @@ var MiniRawCompanyStaff = z15.object({
575
644
  version: Version,
576
645
  lastModified: Timestamp.nullable()
577
646
  });
578
- var RawCompanyStaff = z15.object({
647
+ var RawCompanyStaff = z16.object({
579
648
  ...MiniRawCompanyStaff.shape,
580
- members: z15.record(CompanyUser.shape._id, CompanyUser.omit({ _id: true }))
649
+ members: z16.record(CompanyUser.shape._id, CompanyUser.omit({ _id: true }))
581
650
  });
582
651
  var transformStaff = (object17) => {
583
652
  return object17.transform((d) => {
@@ -638,7 +707,7 @@ var MutableCompanyStaff = RawCompanyStaff.pick({
638
707
  });
639
708
 
640
709
  // src/schemas/company/CompanyDetails.ts
641
- var CompanyDetails = z16.object({
710
+ var CompanyDetails = z17.object({
642
711
  _id: CompanyState.shape._id,
643
712
  identity: CompanyIdentity.omit({ _id: true }),
644
713
  notifications: CompanyNotifications,
@@ -648,7 +717,7 @@ var CompanyDetails = z16.object({
648
717
  billing: CompanyBilling.omit({ _id: true }),
649
718
  staff: RawCompanyStaff.omit({ _id: true })
650
719
  });
651
- var MutableCompanyDetails = z16.object({
720
+ var MutableCompanyDetails = z17.object({
652
721
  _id: CompanyDetails.shape._id,
653
722
  identity: MutableCompanyIdentity.partial().optional(),
654
723
  preferences: MutableCompanyPreferences.partial().optional(),
@@ -657,18 +726,18 @@ var MutableCompanyDetails = z16.object({
657
726
  });
658
727
 
659
728
  // src/schemas/company/utils/InviteList.ts
660
- import * as z17 from "zod";
661
- var CompanyInviteList = z17.record(
729
+ import * as z18 from "zod";
730
+ var CompanyInviteList = z18.record(
662
731
  CompanyUser.shape.email,
663
- z17.object({ createdAt: Timestamp, roles: CompanyUser.shape.roles })
732
+ z18.object({ createdAt: Timestamp, roles: CompanyUser.shape.roles })
664
733
  ).refine(
665
734
  (data) => Object.keys(data).length > 0,
666
735
  "Insufficient amount of members invited."
667
736
  );
668
737
 
669
738
  // src/schemas/company/utils/CreateCompanyForm.ts
670
- import * as z18 from "zod";
671
- var CreateCompanyForm = z18.object({
739
+ import * as z19 from "zod";
740
+ var CreateCompanyForm = z19.object({
672
741
  domain: CompanyIdentity.shape._id,
673
742
  alias: CompanyIdentity.shape.alias.optional(),
674
743
  picture: CompanyIdentity.shape.logo,
@@ -683,112 +752,40 @@ var CreateCompanyForm = z18.object({
683
752
  });
684
753
 
685
754
  // src/schemas/appointment/components/Medical.ts
686
- import * as z19 from "zod";
687
- var Vitals = z19.record(
755
+ import * as z20 from "zod";
756
+ var Vitals = z20.record(
688
757
  vitalKeys,
689
- z19.object({
690
- value: z19.string().trim().regex(/^\d{0,3}((\/|\.)\d{1,3})?/),
758
+ z20.object({
759
+ value: z20.string().trim().regex(/^\d{0,3}((\/|\.)\d{1,3})?/),
691
760
  lastModified: Timestamp.nullable()
692
761
  })
693
762
  );
694
- var Medicine = z19.object({
695
- brand: z19.string().trim(),
763
+ var Medicine = z20.object({
764
+ brand: z20.string().trim(),
696
765
  expiresAt: Timestamp.nullish(),
697
- quantity: z19.string().trim().regex(/^\d+(\.\d{1,3})? ?[a-zA-Z]{1,20}/, {
766
+ quantity: z20.string().trim().regex(/^\d+(\.\d{1,3})? ?[a-zA-Z]{1,20}/, {
698
767
  error: "Failed to match the pattern <number>+(.<number>{1,3})? ?[a-zA-Z]{1,20}"
699
768
  }),
700
- refills: z19.string().trim().regex(/^[0-8]/, { error: "Must be between 0 and 8" }),
701
- directions: z19.string().trim().max(100, { error: "Must be 100 characters or less" }),
769
+ refills: z20.string().trim().regex(/^[0-8]/, { error: "Must be between 0 and 8" }),
770
+ directions: z20.string().trim().max(100, { error: "Must be 100 characters or less" }),
702
771
  ...TimeLog.shape
703
772
  });
704
- var MedicalDetails = z19.object({
773
+ var MedicalDetails = z20.object({
705
774
  vitals: Vitals,
706
- prescriptions: z19.array(z19.array(Medicine)).nullish(),
707
- doctorNote: z19.object({
708
- value: z19.string(),
775
+ prescriptions: z20.array(z20.array(Medicine)).nullish(),
776
+ doctorNote: z20.object({
777
+ value: z20.string(),
709
778
  lastModified: Timestamp.nullable()
710
779
  }),
711
- physAsstNotes: z19.array(
712
- z19.object({
713
- title: z19.string(),
714
- content: z19.string(),
780
+ physAsstNotes: z20.array(
781
+ z20.object({
782
+ title: z20.string(),
783
+ content: z20.string(),
715
784
  ...TimeLog.shape
716
785
  })
717
786
  ).optional()
718
787
  });
719
788
 
720
- // src/schemas/profiles/Client.ts
721
- import * as z20 from "zod";
722
- import { Address as Address2 } from "@wavy/util";
723
- var Name = z20.string().trim().min(2).max(MAX_NAME_LENGTH).transform((d) => d.replace(/-+/g, "-").replace(/'+/g, "'")).superRefine((data, ctx) => {
724
- const invalidCharIdx = data.search(/[^a-z'-]/i);
725
- if (invalidCharIdx >= 0) {
726
- const char = data[invalidCharIdx].includes('"') ? `(${data[invalidCharIdx]})` : `"${data[invalidCharIdx]}"`;
727
- ctx.addIssue(`${char} is not an allowed character.`);
728
- }
729
- });
730
- var ClientIdentity = UserDetails.pick({
731
- _id: true,
732
- createdAt: true,
733
- lastModified: true,
734
- phoneNumber: true,
735
- version: true,
736
- photoUrl: true
737
- }).safeExtend(
738
- z20.object({
739
- firstName: Name,
740
- middleName: Name,
741
- lastName: Name,
742
- email: UserDetails.shape.email.optional(),
743
- dob: Timestamp,
744
- sex: genders,
745
- isGlobal: z20.boolean(),
746
- origin: CompanyIdentity.shape._id,
747
- // National id
748
- nid: z20.object({
749
- class: nidClasses,
750
- // Hash this value
751
- value: z20.string().min(5).max(20)
752
- }).superRefine((data, ctx) => {
753
- const invalidCharIdx = data.value.search(/[^a-z0-9]/i);
754
- if (data.class === "trn") {
755
- const parsedData = Trn.safeParse(data.value);
756
- if (!parsedData.success) {
757
- ctx.addIssue(
758
- parsedData.error?.issues?.[0]?.message || parsedData.error.message
759
- );
760
- }
761
- } else if (invalidCharIdx >= 0) {
762
- const char = data.value[invalidCharIdx] === '"' ? `(${data.value[invalidCharIdx]})` : `"${data.value[invalidCharIdx]}"`;
763
- ctx.addIssue(`${char} is not an allowed character.`);
764
- }
765
- }).optional(),
766
- // Don't hash the attributes, they can be used to help accurately identify a client by whoever is searching for
767
- // the client
768
- attributes: z20.object({
769
- mothersMaidenName: Name,
770
- fathersMiddleName: Name,
771
- mothersMiddleName: Name,
772
- oldestSiblingMiddleName: Name,
773
- firstSchoolName: z20.string().trim().min(3).max(60)
774
- // nickname: z.string().trim().min(1).max(40),
775
- }).partial().refine(
776
- (data) => Object.keys(data).length > 0,
777
- "At least (1) attribute must be defined."
778
- ),
779
- address: Address2.optional(),
780
- linkedTo: UserDetails.shape._id.optional()
781
- }).shape
782
- );
783
- var ClientForm = ClientIdentity.pick({
784
- firstName: true,
785
- middleName: true,
786
- lastName: true,
787
- dob: true,
788
- sex: true
789
- // attributes: true,
790
- }).required();
791
-
792
789
  // src/schemas/appointment/Appointment.ts
793
790
  import * as z21 from "zod";
794
791
  import { sumOf as sumOf2 } from "@wavy/fn";
@@ -820,6 +817,9 @@ var TimelineActivity = z21.object({
820
817
  var MiniAppointmentDetails = z21.object({
821
818
  /** A random uid that identifies the document. */
822
819
  _id: z21.uuidv4(),
820
+ // This helps to identify the urgency of the appointment
821
+ // 3
822
+ category: z21.int().min(1).max(3),
823
823
  /** The company's uid */
824
824
  src: CompanyState.shape._id,
825
825
  /** The ticket number */
@@ -904,9 +904,10 @@ var MutableAppointmentDetails = AppointmentDetails.safeExtend(
904
904
  }).shape
905
905
  );
906
906
  var ScheduleAppointmentForm = z21.object({
907
- clientUid: ClientIdentity.shape._id,
908
- /** A nullish value === next_available */
909
- serviceProviderUid: CompanyUser.shape._id.nullish(),
907
+ clientId: ClientIdentity.shape._id,
908
+ serviceProviderId: CompanyUser.shape._id.or(z21.literal("next")),
909
+ category: AppointmentDetails.shape.category,
910
+ appointmentReason: AppointmentDetails.shape.reason,
910
911
  charges: AppointmentDetails.shape.charges.optional(),
911
912
  prepayments: AppointmentDetails.shape.prepayments.optional(),
912
913
  payments: AppointmentDetails.shape.payments.optional(),
@@ -914,7 +915,7 @@ var ScheduleAppointmentForm = z21.object({
914
915
  });
915
916
 
916
917
  // src/functions/scheduleAppointment.ts
917
- import { findChanges, omit } from "@wavy/fn";
918
+ import { findChanges, omit, TODO } from "@wavy/fn";
918
919
  import { v4 } from "uuid";
919
920
 
920
921
  // src/functions/findAvailableStaff.ts
@@ -956,6 +957,7 @@ function findNextAvailableStaff(userUids, algorithm, staff) {
956
957
 
957
958
  // src/functions/scheduleAppointment.ts
958
959
  async function scheduleAppointment(request) {
960
+ TODO("Revise this fn (some things have changed in the form etc.)");
959
961
  request.form = ScheduleAppointmentForm.parse(request.form);
960
962
  request.sender = UserDetails.parse(request.sender);
961
963
  request.preferences = CompanyPreferences.omit({
@@ -980,14 +982,16 @@ async function scheduleAppointment(request) {
980
982
  if (availableDoctors.length < 1) {
981
983
  throw new Error("Insufficient staff available.");
982
984
  }
983
- if (request.form.serviceProviderUid && availableDoctors.includes(request.form.serviceProviderUid)) {
984
- selectedDoctor = request.form.serviceProviderUid;
985
- } else if (request.form.serviceProviderUid && staffDetailsCopy.members[request.form.serviceProviderUid]?.roles?.includes?.("doc")) {
985
+ if (request.form.serviceProviderId && availableDoctors.includes(request.form.serviceProviderId)) {
986
+ selectedDoctor = request.form.serviceProviderId;
987
+ } else if (request.form.serviceProviderId && staffDetailsCopy.members[request.form.serviceProviderId]?.roles?.includes?.(
988
+ "doc"
989
+ )) {
986
990
  throw new Error("Unavailable doctor selected.");
987
- } else if (request.form.serviceProviderUid) {
991
+ } else if (request.form.serviceProviderId) {
988
992
  throw new Error("Invalid doctor selected.");
989
993
  }
990
- if (request.form.serviceProviderUid === null || request.form.serviceProviderUid === void 0) {
994
+ if (request.form.serviceProviderId === null || request.form.serviceProviderId === void 0) {
991
995
  selectedDoctor = findNextAvailableStaff(
992
996
  availableDoctors,
993
997
  request.preferences.apptDistAlg,
@@ -1051,6 +1055,7 @@ async function scheduleAppointment(request) {
1051
1055
  _id: v4(),
1052
1056
  src: stateCopy._id,
1053
1057
  tkt: request.state.tktNoCounter,
1058
+ category: request.form.category,
1054
1059
  discounts: Object.values(request.billing.discounts || {}).filter(
1055
1060
  (disc) => !disc.isOptional
1056
1061
  ),
@@ -1060,7 +1065,7 @@ async function scheduleAppointment(request) {
1060
1065
  payments: request.preferences.enforcePaidAppointments ? request.form.payments : null,
1061
1066
  prepayments: request.preferences.enforcePaidAppointments ? request.form.prepayments || [] : null,
1062
1067
  charges: request.preferences.serviceSelector === "scheduler" ? request.form.charges : [],
1063
- client: await request.findClient(request.form.clientUid),
1068
+ client: await request.findClient(request.form.clientId),
1064
1069
  _hash: "aa.aa.aa",
1065
1070
  lastModified: null,
1066
1071
  timeline: {
@@ -1102,6 +1107,7 @@ function createNotifId(options) {
1102
1107
  return nid;
1103
1108
  }
1104
1109
  export {
1110
+ AlphaNumeric,
1105
1111
  AppointmentDetails,
1106
1112
  ClientForm,
1107
1113
  ClientIdentity,
@@ -1161,9 +1167,8 @@ export {
1161
1167
  getCompatibleRoles,
1162
1168
  healthcareProviderRoles,
1163
1169
  industries,
1164
- nidClasses,
1165
1170
  normalizeCompanyId,
1166
- normalizeNidClass,
1171
+ normalizeNidKey,
1167
1172
  parseClientName,
1168
1173
  paymentMethods,
1169
1174
  scheduleAppointment,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bizmap/sdk",
3
- "version": "0.0.93",
3
+ "version": "0.0.95",
4
4
  "main": "./dist/main.js",
5
5
  "types": "./dist/main.d.ts",
6
6
  "type": "module",