@bizmap/sdk 0.0.94 → 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.
package/dist/main.d.ts CHANGED
@@ -1031,7 +1031,6 @@ declare const ClientIdentity: z.ZodObject<{
1031
1031
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
1032
1032
  version: z.ZodInt;
1033
1033
  _id: z.ZodUUID;
1034
- phoneNumber: z.ZodOptional<z.ZodString>;
1035
1034
  photoUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1036
1035
  firstName: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
1037
1036
  middleName: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
@@ -1044,6 +1043,8 @@ declare const ClientIdentity: z.ZodObject<{
1044
1043
  }>;
1045
1044
  isGlobal: z.ZodBoolean;
1046
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>;
1047
1048
  nid: z.ZodOptional<z.ZodObject<{
1048
1049
  trn: z.ZodOptional<z.ZodString>;
1049
1050
  nin: z.ZodOptional<z.ZodString>;
@@ -1081,6 +1082,7 @@ declare const MiniAppointmentDetails: z.ZodObject<{
1081
1082
  createdAt: z.ZodReadonly<z.ZodInt>;
1082
1083
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
1083
1084
  _id: z.ZodUUID;
1085
+ category: z.ZodInt;
1084
1086
  src: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
1085
1087
  tkt: z.ZodReadonly<z.ZodInt>;
1086
1088
  reason: z.ZodOptional<z.ZodObject<{
@@ -1295,6 +1297,7 @@ declare const AppointmentDetails: z.ZodObject<{
1295
1297
  }, z.core.$strip>>>;
1296
1298
  src: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
1297
1299
  tkt: z.ZodReadonly<z.ZodInt>;
1300
+ category: z.ZodInt;
1298
1301
  reason: z.ZodOptional<z.ZodObject<{
1299
1302
  createdAt: z.ZodReadonly<z.ZodInt>;
1300
1303
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
@@ -1361,7 +1364,6 @@ declare const AppointmentDetails: z.ZodObject<{
1361
1364
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
1362
1365
  version: z.ZodInt;
1363
1366
  _id: z.ZodUUID;
1364
- phoneNumber: z.ZodOptional<z.ZodString>;
1365
1367
  photoUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1366
1368
  firstName: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
1367
1369
  middleName: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
@@ -1374,6 +1376,8 @@ declare const AppointmentDetails: z.ZodObject<{
1374
1376
  }>;
1375
1377
  isGlobal: z.ZodBoolean;
1376
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>;
1377
1381
  nid: z.ZodOptional<z.ZodObject<{
1378
1382
  trn: z.ZodOptional<z.ZodString>;
1379
1383
  nin: z.ZodOptional<z.ZodString>;
@@ -1473,6 +1477,7 @@ declare const MutableAppointmentDetails: z.ZodObject<{
1473
1477
  }, z.core.$strip>>>;
1474
1478
  src: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
1475
1479
  tkt: z.ZodReadonly<z.ZodInt>;
1480
+ category: z.ZodInt;
1476
1481
  reason: z.ZodOptional<z.ZodObject<{
1477
1482
  createdAt: z.ZodReadonly<z.ZodInt>;
1478
1483
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
@@ -1539,7 +1544,6 @@ declare const MutableAppointmentDetails: z.ZodObject<{
1539
1544
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
1540
1545
  version: z.ZodInt;
1541
1546
  _id: z.ZodUUID;
1542
- phoneNumber: z.ZodOptional<z.ZodString>;
1543
1547
  photoUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1544
1548
  firstName: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
1545
1549
  middleName: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
@@ -1552,6 +1556,8 @@ declare const MutableAppointmentDetails: z.ZodObject<{
1552
1556
  }>;
1553
1557
  isGlobal: z.ZodBoolean;
1554
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>;
1555
1561
  nid: z.ZodOptional<z.ZodObject<{
1556
1562
  trn: z.ZodOptional<z.ZodString>;
1557
1563
  nin: z.ZodOptional<z.ZodString>;
@@ -1578,8 +1584,14 @@ type MutableAppointmentDetails = z.infer<typeof MutableAppointmentDetails>;
1578
1584
  declare const ScheduleAppointmentForm: z.ZodObject<{
1579
1585
  createdAt: z.ZodReadonly<z.ZodInt>;
1580
1586
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
1581
- clientUid: z.ZodUUID;
1582
- 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>>;
1583
1595
  charges: z.ZodOptional<z.ZodArray<z.ZodObject<{
1584
1596
  createdAt: z.ZodReadonly<z.ZodInt>;
1585
1597
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
@@ -1733,6 +1745,7 @@ declare function scheduleAppointment(request: RequestParameter): Promise<{
1733
1745
  }[] | null;
1734
1746
  src: string;
1735
1747
  tkt: number;
1748
+ category: number;
1736
1749
  charges: {
1737
1750
  createdAt: number;
1738
1751
  uid: string;
@@ -1779,9 +1792,10 @@ declare function scheduleAppointment(request: RequestParameter): Promise<{
1779
1792
  firstSchoolName?: string | undefined;
1780
1793
  };
1781
1794
  lastModified?: number | null | undefined;
1782
- phoneNumber?: string | undefined;
1783
1795
  photoUrl?: string | null | undefined;
1784
1796
  email?: string | undefined;
1797
+ visits?: Record<string, number[]> | undefined;
1798
+ phoneNumber?: string | undefined;
1785
1799
  nid?: {
1786
1800
  trn?: string | undefined;
1787
1801
  nin?: string | undefined;
package/dist/main.js CHANGED
@@ -460,7 +460,7 @@ var UserDetails = z13.object({
460
460
  }).omit({ uid: true });
461
461
 
462
462
  // src/schemas/profiles/Client.ts
463
- import { Address as Address2 } from "@wavy/util";
463
+ import { Address as Address2, PhoneNumber as PhoneNumber2 } from "@wavy/util";
464
464
  var Name = z14.string().trim().min(2).max(MAX_NAME_LENGTH).transform((d) => d.replace(/-+/g, "-").replace(/'+/g, "'")).superRefine((data, ctx) => {
465
465
  const invalidCharIdx = data.search(/[^a-z'-]/i);
466
466
  if (invalidCharIdx >= 0) {
@@ -485,6 +485,8 @@ var ClientIdentity = UserDetails.pick({
485
485
  sex: genders,
486
486
  isGlobal: z14.boolean(),
487
487
  origin: CompanyIdentity.shape._id,
488
+ visits: z14.record(CompanyIdentity.shape._id, z14.array(Timestamp).min(1)).optional(),
489
+ phoneNumber: PhoneNumber2.optional(),
488
490
  // aka. National id
489
491
  nid: z14.object({
490
492
  trn: Trn,
@@ -499,7 +501,6 @@ var ClientIdentity = UserDetails.pick({
499
501
  motherMiddleName: Name,
500
502
  oldestSiblingMiddleName: Name,
501
503
  firstSchoolName: z14.string().trim().min(3).max(60)
502
- // nickname: z.string().trim().min(1).max(40),
503
504
  }).partial().refine(
504
505
  (data) => Object.keys(data).length > 0,
505
506
  "At least (1) attribute must be defined."
@@ -816,6 +817,9 @@ var TimelineActivity = z21.object({
816
817
  var MiniAppointmentDetails = z21.object({
817
818
  /** A random uid that identifies the document. */
818
819
  _id: z21.uuidv4(),
820
+ // This helps to identify the urgency of the appointment
821
+ // 3
822
+ category: z21.int().min(1).max(3),
819
823
  /** The company's uid */
820
824
  src: CompanyState.shape._id,
821
825
  /** The ticket number */
@@ -900,9 +904,10 @@ var MutableAppointmentDetails = AppointmentDetails.safeExtend(
900
904
  }).shape
901
905
  );
902
906
  var ScheduleAppointmentForm = z21.object({
903
- clientUid: ClientIdentity.shape._id,
904
- /** A nullish value === next_available */
905
- 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,
906
911
  charges: AppointmentDetails.shape.charges.optional(),
907
912
  prepayments: AppointmentDetails.shape.prepayments.optional(),
908
913
  payments: AppointmentDetails.shape.payments.optional(),
@@ -910,7 +915,7 @@ var ScheduleAppointmentForm = z21.object({
910
915
  });
911
916
 
912
917
  // src/functions/scheduleAppointment.ts
913
- import { findChanges, omit } from "@wavy/fn";
918
+ import { findChanges, omit, TODO } from "@wavy/fn";
914
919
  import { v4 } from "uuid";
915
920
 
916
921
  // src/functions/findAvailableStaff.ts
@@ -952,6 +957,7 @@ function findNextAvailableStaff(userUids, algorithm, staff) {
952
957
 
953
958
  // src/functions/scheduleAppointment.ts
954
959
  async function scheduleAppointment(request) {
960
+ TODO("Revise this fn (some things have changed in the form etc.)");
955
961
  request.form = ScheduleAppointmentForm.parse(request.form);
956
962
  request.sender = UserDetails.parse(request.sender);
957
963
  request.preferences = CompanyPreferences.omit({
@@ -976,14 +982,16 @@ async function scheduleAppointment(request) {
976
982
  if (availableDoctors.length < 1) {
977
983
  throw new Error("Insufficient staff available.");
978
984
  }
979
- if (request.form.serviceProviderUid && availableDoctors.includes(request.form.serviceProviderUid)) {
980
- selectedDoctor = request.form.serviceProviderUid;
981
- } 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
+ )) {
982
990
  throw new Error("Unavailable doctor selected.");
983
- } else if (request.form.serviceProviderUid) {
991
+ } else if (request.form.serviceProviderId) {
984
992
  throw new Error("Invalid doctor selected.");
985
993
  }
986
- if (request.form.serviceProviderUid === null || request.form.serviceProviderUid === void 0) {
994
+ if (request.form.serviceProviderId === null || request.form.serviceProviderId === void 0) {
987
995
  selectedDoctor = findNextAvailableStaff(
988
996
  availableDoctors,
989
997
  request.preferences.apptDistAlg,
@@ -1047,6 +1055,7 @@ async function scheduleAppointment(request) {
1047
1055
  _id: v4(),
1048
1056
  src: stateCopy._id,
1049
1057
  tkt: request.state.tktNoCounter,
1058
+ category: request.form.category,
1050
1059
  discounts: Object.values(request.billing.discounts || {}).filter(
1051
1060
  (disc) => !disc.isOptional
1052
1061
  ),
@@ -1056,7 +1065,7 @@ async function scheduleAppointment(request) {
1056
1065
  payments: request.preferences.enforcePaidAppointments ? request.form.payments : null,
1057
1066
  prepayments: request.preferences.enforcePaidAppointments ? request.form.prepayments || [] : null,
1058
1067
  charges: request.preferences.serviceSelector === "scheduler" ? request.form.charges : [],
1059
- client: await request.findClient(request.form.clientUid),
1068
+ client: await request.findClient(request.form.clientId),
1060
1069
  _hash: "aa.aa.aa",
1061
1070
  lastModified: null,
1062
1071
  timeline: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bizmap/sdk",
3
- "version": "0.0.94",
3
+ "version": "0.0.95",
4
4
  "main": "./dist/main.js",
5
5
  "types": "./dist/main.d.ts",
6
6
  "type": "module",