@bizmap/sdk 0.0.59 → 0.0.61

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 +92 -150
  2. package/dist/main.js +175 -175
  3. package/package.json +1 -1
package/dist/main.d.ts CHANGED
@@ -26,11 +26,11 @@ declare const healthcareProviderRoles: z.ZodEnum<{
26
26
  physAsst: "physAsst";
27
27
  }>;
28
28
  type HealthcareProviderRole = z.infer<typeof healthcareProviderRoles>;
29
- declare const serviceDistAlgs: z.ZodEnum<{
29
+ declare const appointmentDistAlgs: z.ZodEnum<{
30
30
  RR: "RR";
31
31
  LOR: "LOR";
32
32
  }>;
33
- type ServiceDistAlg = z.infer<typeof serviceDistAlgs>;
33
+ type AppointmentDistAlg = z.infer<typeof appointmentDistAlgs>;
34
34
  declare const companyServiceSelectors: z.ZodEnum<{
35
35
  scheduler: "scheduler";
36
36
  doctor: "doctor";
@@ -145,8 +145,8 @@ declare const CompanyDetails: z.ZodObject<{
145
145
  scheduler: "scheduler";
146
146
  doctor: "doctor";
147
147
  }>;
148
- enforcePaidServices: z.ZodBoolean;
149
- serviceDistAlg: z.ZodDefault<z.ZodEnum<{
148
+ enforcePaidAppointments: z.ZodBoolean;
149
+ apptDistAlg: z.ZodDefault<z.ZodEnum<{
150
150
  RR: "RR";
151
151
  LOR: "LOR";
152
152
  }>>;
@@ -204,9 +204,9 @@ declare const CompanyDetails: z.ZodObject<{
204
204
  percentage: z.ZodNumber;
205
205
  isOptional: z.ZodBoolean;
206
206
  }, z.core.$strip>>;
207
- services: z.ZodObject<{
207
+ offeredServices: z.ZodObject<{
208
208
  deployed: z.ZodBoolean;
209
- value: z.ZodRecord<z.ZodString, z.ZodObject<{
209
+ value: z.ZodRecord<z.ZodUUID, z.ZodObject<{
210
210
  createdAt: z.ZodReadonly<z.ZodInt>;
211
211
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
212
212
  currency: z.ZodEnum<{
@@ -239,7 +239,7 @@ declare const CompanyDetails: z.ZodObject<{
239
239
  active: "active";
240
240
  inactive: "inactive";
241
241
  }>;
242
- services: z.ZodRecord<z.ZodLiteral<"ongoing" | "completed">, z.ZodInt>;
242
+ appointments: z.ZodRecord<z.ZodLiteral<"ongoing" | "completed">, z.ZodInt>;
243
243
  lastActive: z.ZodNullable<z.ZodInt>;
244
244
  isAvailableLastModified: z.ZodNullable<z.ZodInt>;
245
245
  isBusyLastModified: z.ZodNullable<z.ZodInt>;
@@ -301,8 +301,8 @@ declare const MutableCompanyDetails: z.ZodObject<{
301
301
  scheduler: "scheduler";
302
302
  doctor: "doctor";
303
303
  }>>;
304
- enforcePaidServices: z.ZodOptional<z.ZodBoolean>;
305
- serviceDistAlg: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
304
+ enforcePaidAppointments: z.ZodOptional<z.ZodBoolean>;
305
+ apptDistAlg: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
306
306
  RR: "RR";
307
307
  LOR: "LOR";
308
308
  }>>>;
@@ -359,9 +359,9 @@ declare const MutableCompanyDetails: z.ZodObject<{
359
359
  percentage: z.ZodNumber;
360
360
  isOptional: z.ZodBoolean;
361
361
  }, z.core.$strip>>>;
362
- services: z.ZodOptional<z.ZodObject<{
362
+ offeredServices: z.ZodOptional<z.ZodObject<{
363
363
  deployed: z.ZodBoolean;
364
- value: z.ZodRecord<z.ZodString, z.ZodObject<{
364
+ value: z.ZodRecord<z.ZodUUID, z.ZodObject<{
365
365
  createdAt: z.ZodReadonly<z.ZodInt>;
366
366
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
367
367
  currency: z.ZodEnum<{
@@ -452,9 +452,9 @@ declare const CompanyBilling: z.ZodObject<{
452
452
  percentage: z.ZodNumber;
453
453
  isOptional: z.ZodBoolean;
454
454
  }, z.core.$strip>>;
455
- services: z.ZodObject<{
455
+ offeredServices: z.ZodObject<{
456
456
  deployed: z.ZodBoolean;
457
- value: z.ZodRecord<z.ZodString, z.ZodObject<{
457
+ value: z.ZodRecord<z.ZodUUID, z.ZodObject<{
458
458
  createdAt: z.ZodReadonly<z.ZodInt>;
459
459
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
460
460
  currency: z.ZodEnum<{
@@ -523,9 +523,9 @@ declare const MutableCompanyBilling: z.ZodObject<{
523
523
  percentage: z.ZodNumber;
524
524
  isOptional: z.ZodBoolean;
525
525
  }, z.core.$strip>>;
526
- services: z.ZodObject<{
526
+ offeredServices: z.ZodObject<{
527
527
  deployed: z.ZodBoolean;
528
- value: z.ZodRecord<z.ZodString, z.ZodObject<{
528
+ value: z.ZodRecord<z.ZodUUID, z.ZodObject<{
529
529
  createdAt: z.ZodReadonly<z.ZodInt>;
530
530
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
531
531
  currency: z.ZodEnum<{
@@ -612,8 +612,8 @@ declare const CompanyPreferences: z.ZodObject<{
612
612
  scheduler: "scheduler";
613
613
  doctor: "doctor";
614
614
  }>;
615
- enforcePaidServices: z.ZodBoolean;
616
- serviceDistAlg: z.ZodDefault<z.ZodEnum<{
615
+ enforcePaidAppointments: z.ZodBoolean;
616
+ apptDistAlg: z.ZodDefault<z.ZodEnum<{
617
617
  RR: "RR";
618
618
  LOR: "LOR";
619
619
  }>>;
@@ -625,16 +625,15 @@ declare const MutableCompanyPreferences: z.ZodObject<{
625
625
  scheduler: "scheduler";
626
626
  doctor: "doctor";
627
627
  }>;
628
- enforcePaidServices: z.ZodBoolean;
629
- serviceDistAlg: z.ZodDefault<z.ZodEnum<{
628
+ enforcePaidAppointments: z.ZodBoolean;
629
+ apptDistAlg: z.ZodDefault<z.ZodEnum<{
630
630
  RR: "RR";
631
631
  LOR: "LOR";
632
632
  }>>;
633
633
  }, z.core.$strip>;
634
634
  type MutableCompanyPreferences = z.infer<typeof MutableCompanyPreferences>;
635
635
 
636
- declare const CompanyStaff: z.ZodPipe<z.ZodObject<{
637
- uid: z.ZodUUID;
636
+ declare const CompanyStaff: z.ZodObject<{
638
637
  members: z.ZodRecord<z.ZodUUID, z.ZodObject<{
639
638
  uid: z.ZodUUID;
640
639
  roles: z.ZodPipe<z.ZodArray<z.ZodEnum<{
@@ -651,7 +650,7 @@ declare const CompanyStaff: z.ZodPipe<z.ZodObject<{
651
650
  active: "active";
652
651
  inactive: "inactive";
653
652
  }>;
654
- services: z.ZodRecord<z.ZodLiteral<"ongoing" | "completed">, z.ZodInt>;
653
+ appointments: z.ZodRecord<z.ZodLiteral<"ongoing" | "completed">, z.ZodInt>;
655
654
  lastActive: z.ZodNullable<z.ZodInt>;
656
655
  isAvailableLastModified: z.ZodNullable<z.ZodInt>;
657
656
  isBusyLastModified: z.ZodNullable<z.ZodInt>;
@@ -663,6 +662,7 @@ declare const CompanyStaff: z.ZodPipe<z.ZodObject<{
663
662
  email: z.ZodEmail;
664
663
  phoneNumber: z.ZodOptional<z.ZodString>;
665
664
  }, z.core.$strip>>;
665
+ uid: z.ZodUUID;
666
666
  partnerMap: z.ZodRecord<z.ZodUUID, z.ZodRecord<z.ZodUUID, z.ZodObject<{
667
667
  addedAt: z.ZodInt;
668
668
  }, z.core.$strip>>>;
@@ -686,75 +686,7 @@ declare const CompanyStaff: z.ZodPipe<z.ZodObject<{
686
686
  inviteAccepted: z.ZodNullable<z.ZodInt>;
687
687
  }, z.core.$strip>>;
688
688
  lastModified: z.ZodNullable<z.ZodInt>;
689
- }, z.core.$strip>, z.ZodTransform<{
690
- uid: string;
691
- members: Record<string, {
692
- uid: string;
693
- roles: ("doc" | "physAsst" | "rcpst" | "cshr" | "admin")[];
694
- isAvailable: boolean;
695
- isBusy: boolean;
696
- status: "inviteSent" | "active" | "inactive";
697
- services: Record<"ongoing" | "completed", number>;
698
- lastActive: number | null;
699
- isAvailableLastModified: number | null;
700
- isBusyLastModified: number | null;
701
- name: Record<"first" | "last", string>;
702
- email: string;
703
- photoUrl?: string | null | undefined;
704
- phoneNumber?: string | undefined;
705
- }>;
706
- partnerMap: Record<string, Record<string, {
707
- addedAt: number;
708
- }>>;
709
- updateQueue: Record<string, {
710
- $REMOVE?: {
711
- addedAt: number;
712
- } | undefined;
713
- $CHANGE_ROLES?: {
714
- newRoles: ("doc" | "physAsst" | "rcpst" | "cshr" | "admin")[];
715
- addedAt: number;
716
- } | undefined;
717
- }>;
718
- timeline: Record<string, {
719
- inviteSent: number | null;
720
- inviteAccepted: number | null;
721
- }>;
722
- lastModified: number | null;
723
- }, {
724
- uid: string;
725
- members: Record<string, {
726
- uid: string;
727
- roles: ("doc" | "physAsst" | "rcpst" | "cshr" | "admin")[];
728
- isAvailable: boolean;
729
- isBusy: boolean;
730
- status: "inviteSent" | "active" | "inactive";
731
- services: Record<"ongoing" | "completed", number>;
732
- lastActive: number | null;
733
- isAvailableLastModified: number | null;
734
- isBusyLastModified: number | null;
735
- name: Record<"first" | "last", string>;
736
- email: string;
737
- photoUrl?: string | null | undefined;
738
- phoneNumber?: string | undefined;
739
- }>;
740
- partnerMap: Record<string, Record<string, {
741
- addedAt: number;
742
- }>>;
743
- updateQueue: Record<string, {
744
- $REMOVE?: {
745
- addedAt: number;
746
- } | undefined;
747
- $CHANGE_ROLES?: {
748
- newRoles: ("doc" | "physAsst" | "rcpst" | "cshr" | "admin")[];
749
- addedAt: number;
750
- } | undefined;
751
- }>;
752
- timeline: Record<string, {
753
- inviteSent: number | null;
754
- inviteAccepted: number | null;
755
- }>;
756
- lastModified: number | null;
757
- }>>;
689
+ }, z.core.$strip>;
758
690
  type CompanyStaff = z.infer<typeof CompanyStaff>;
759
691
 
760
692
  /** Can only be modifiede by the server */
@@ -780,6 +712,27 @@ declare const CompanyState: z.ZodObject<{
780
712
  }, z.core.$strip>;
781
713
  type CompanyState = z.infer<typeof CompanyState>;
782
714
 
715
+ declare const MiniCompanyUser: z.ZodObject<{
716
+ uid: z.ZodUUID;
717
+ roles: z.ZodPipe<z.ZodArray<z.ZodEnum<{
718
+ doc: "doc";
719
+ physAsst: "physAsst";
720
+ rcpst: "rcpst";
721
+ cshr: "cshr";
722
+ admin: "admin";
723
+ }>>, z.ZodTransform<("doc" | "physAsst" | "rcpst" | "cshr" | "admin")[], ("doc" | "physAsst" | "rcpst" | "cshr" | "admin")[]>>;
724
+ isAvailable: z.ZodBoolean;
725
+ isBusy: z.ZodBoolean;
726
+ status: z.ZodEnum<{
727
+ inviteSent: "inviteSent";
728
+ active: "active";
729
+ inactive: "inactive";
730
+ }>;
731
+ appointments: z.ZodRecord<z.ZodLiteral<"ongoing" | "completed">, z.ZodInt>;
732
+ lastActive: z.ZodNullable<z.ZodInt>;
733
+ isAvailableLastModified: z.ZodNullable<z.ZodInt>;
734
+ isBusyLastModified: z.ZodNullable<z.ZodInt>;
735
+ }, z.core.$strip>;
783
736
  declare const CompanyUser: z.ZodObject<{
784
737
  uid: z.ZodUUID;
785
738
  roles: z.ZodPipe<z.ZodArray<z.ZodEnum<{
@@ -796,7 +749,7 @@ declare const CompanyUser: z.ZodObject<{
796
749
  active: "active";
797
750
  inactive: "inactive";
798
751
  }>;
799
- services: z.ZodRecord<z.ZodLiteral<"ongoing" | "completed">, z.ZodInt>;
752
+ appointments: z.ZodRecord<z.ZodLiteral<"ongoing" | "completed">, z.ZodInt>;
800
753
  lastActive: z.ZodNullable<z.ZodInt>;
801
754
  isAvailableLastModified: z.ZodNullable<z.ZodInt>;
802
755
  isBusyLastModified: z.ZodNullable<z.ZodInt>;
@@ -872,22 +825,21 @@ declare const ClientIdentity: z.ZodObject<{
872
825
  createdAt: z.ZodReadonly<z.ZodInt>;
873
826
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
874
827
  uid: z.ZodUUID;
875
- email: z.ZodOptional<z.ZodNullable<z.ZodEmail>>;
876
- address: z.ZodOptional<z.ZodObject<{
877
- streetAddress: z.ZodString;
878
- city: z.ZodOptional<z.ZodString>;
879
- parish: z.ZodString;
880
- country: z.ZodString;
881
- }, z.core.$strip>>;
828
+ email: z.ZodEmail;
882
829
  phoneNumber: z.ZodOptional<z.ZodString>;
883
830
  name: z.ZodRecord<z.ZodEnum<{
884
831
  first: "first";
885
832
  last: "last";
886
833
  }>, z.ZodString>;
887
834
  photoUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
835
+ linked: z.ZodBoolean;
888
836
  dob: z.ZodOptional<z.ZodInt>;
889
- publicKey: z.ZodNullable<z.ZodString>;
890
- activated: z.ZodBoolean;
837
+ address: z.ZodOptional<z.ZodObject<{
838
+ streetAddress: z.ZodString;
839
+ city: z.ZodOptional<z.ZodString>;
840
+ parish: z.ZodString;
841
+ country: z.ZodString;
842
+ }, z.core.$strip>>;
891
843
  }, z.core.$strip>;
892
844
  type ClientIdentity = z.infer<typeof ClientIdentity>;
893
845
 
@@ -989,14 +941,7 @@ declare const UserDetails: z.ZodObject<{
989
941
  createdAt: z.ZodReadonly<z.ZodInt>;
990
942
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
991
943
  uid: z.ZodUUID;
992
- email: z.ZodOptional<z.ZodNullable<z.ZodEmail>>;
993
- dob: z.ZodOptional<z.ZodInt>;
994
- address: z.ZodOptional<z.ZodObject<{
995
- streetAddress: z.ZodString;
996
- city: z.ZodOptional<z.ZodString>;
997
- parish: z.ZodString;
998
- country: z.ZodString;
999
- }, z.core.$strip>>;
944
+ email: z.ZodEmail;
1000
945
  publicKey: z.ZodNullable<z.ZodString>;
1001
946
  notifications: z.ZodArray<z.ZodObject<{
1002
947
  code: z.ZodLiteral<"COMPANY_INVITE" | "INVITE_RESPONSE" | "DEV_MESSAGE" | "ALERT">;
@@ -1009,7 +954,7 @@ declare const UserDetails: z.ZodObject<{
1009
954
  expiresAt: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
1010
955
  createdAt: z.ZodInt;
1011
956
  }, z.core.$strip>>;
1012
- activated: z.ZodBoolean;
957
+ linked: z.ZodBoolean;
1013
958
  name: z.ZodRecord<z.ZodEnum<{
1014
959
  first: "first";
1015
960
  last: "last";
@@ -1038,7 +983,7 @@ declare const Reason: z.ZodObject<{
1038
983
  lastModified: z.ZodInt;
1039
984
  }, z.core.$strip>;
1040
985
 
1041
- declare const MiniServiceDetails: z.ZodObject<{
986
+ declare const MiniAppointmentDetails: z.ZodObject<{
1042
987
  createdAt: z.ZodReadonly<z.ZodInt>;
1043
988
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
1044
989
  _id: z.ZodUUID;
@@ -1187,8 +1132,8 @@ declare const MiniServiceDetails: z.ZodObject<{
1187
1132
  }, z.core.$strip>>;
1188
1133
  }, z.core.$strip>;
1189
1134
  }, z.core.$strip>;
1190
- type MiniServiceDetails = z.infer<typeof MiniServiceDetails>;
1191
- declare const ServiceDetails: z.ZodObject<{
1135
+ type MiniAppointmentDetails = z.infer<typeof MiniAppointmentDetails>;
1136
+ declare const AppointmentDetails: z.ZodObject<{
1192
1137
  createdAt: z.ZodReadonly<z.ZodInt>;
1193
1138
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
1194
1139
  additionalFees: z.ZodReadonly<z.ZodNullable<z.ZodArray<z.ZodObject<{
@@ -1339,26 +1284,25 @@ declare const ServiceDetails: z.ZodObject<{
1339
1284
  createdAt: z.ZodReadonly<z.ZodInt>;
1340
1285
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
1341
1286
  uid: z.ZodUUID;
1342
- email: z.ZodOptional<z.ZodNullable<z.ZodEmail>>;
1343
- address: z.ZodOptional<z.ZodObject<{
1344
- streetAddress: z.ZodString;
1345
- city: z.ZodOptional<z.ZodString>;
1346
- parish: z.ZodString;
1347
- country: z.ZodString;
1348
- }, z.core.$strip>>;
1287
+ email: z.ZodEmail;
1349
1288
  phoneNumber: z.ZodOptional<z.ZodString>;
1350
1289
  name: z.ZodRecord<z.ZodEnum<{
1351
1290
  first: "first";
1352
1291
  last: "last";
1353
1292
  }>, z.ZodString>;
1354
1293
  photoUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1294
+ linked: z.ZodBoolean;
1355
1295
  dob: z.ZodOptional<z.ZodInt>;
1356
- publicKey: z.ZodNullable<z.ZodString>;
1357
- activated: z.ZodBoolean;
1296
+ address: z.ZodOptional<z.ZodObject<{
1297
+ streetAddress: z.ZodString;
1298
+ city: z.ZodOptional<z.ZodString>;
1299
+ parish: z.ZodString;
1300
+ country: z.ZodString;
1301
+ }, z.core.$strip>>;
1358
1302
  }, z.core.$strip>;
1359
1303
  }, z.core.$strip>;
1360
- type ServiceDetails = z.infer<typeof ServiceDetails>;
1361
- declare const MutableServiceDetails: z.ZodObject<{
1304
+ type AppointmentDetails = z.infer<typeof AppointmentDetails>;
1305
+ declare const MutableAppointmentDetails: z.ZodObject<{
1362
1306
  createdAt: z.ZodReadonly<z.ZodInt>;
1363
1307
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
1364
1308
  additionalFees: z.ZodReadonly<z.ZodNullable<z.ZodArray<z.ZodObject<{
@@ -1509,27 +1453,26 @@ declare const MutableServiceDetails: z.ZodObject<{
1509
1453
  createdAt: z.ZodReadonly<z.ZodInt>;
1510
1454
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
1511
1455
  uid: z.ZodUUID;
1512
- email: z.ZodOptional<z.ZodNullable<z.ZodEmail>>;
1513
- address: z.ZodOptional<z.ZodObject<{
1514
- streetAddress: z.ZodString;
1515
- city: z.ZodOptional<z.ZodString>;
1516
- parish: z.ZodString;
1517
- country: z.ZodString;
1518
- }, z.core.$strip>>;
1456
+ email: z.ZodEmail;
1519
1457
  phoneNumber: z.ZodOptional<z.ZodString>;
1520
1458
  name: z.ZodRecord<z.ZodEnum<{
1521
1459
  first: "first";
1522
1460
  last: "last";
1523
1461
  }>, z.ZodString>;
1524
1462
  photoUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1463
+ linked: z.ZodBoolean;
1525
1464
  dob: z.ZodOptional<z.ZodInt>;
1526
- publicKey: z.ZodNullable<z.ZodString>;
1527
- activated: z.ZodBoolean;
1465
+ address: z.ZodOptional<z.ZodObject<{
1466
+ streetAddress: z.ZodString;
1467
+ city: z.ZodOptional<z.ZodString>;
1468
+ parish: z.ZodString;
1469
+ country: z.ZodString;
1470
+ }, z.core.$strip>>;
1528
1471
  }, z.core.$strip>;
1529
1472
  _hash: z.ZodString;
1530
1473
  }, z.core.$strip>;
1531
- type MutableServiceDetails = z.infer<typeof MutableServiceDetails>;
1532
- declare const CreateServiceForm: z.ZodObject<{
1474
+ type MutableAppointmentDetails = z.infer<typeof MutableAppointmentDetails>;
1475
+ declare const ScheduleAppointmentForm: z.ZodObject<{
1533
1476
  createdAt: z.ZodReadonly<z.ZodInt>;
1534
1477
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
1535
1478
  clientUid: z.ZodUUID;
@@ -1575,10 +1518,10 @@ declare const CreateServiceForm: z.ZodObject<{
1575
1518
  amount: z.ZodNumber;
1576
1519
  }, z.core.$strip>>>>>;
1577
1520
  }, z.core.$strip>;
1578
- type CreateServiceForm = z.infer<typeof CreateServiceForm>;
1521
+ type ScheduleAppointmentForm = z.infer<typeof ScheduleAppointmentForm>;
1579
1522
 
1580
- declare function createCompanyService(request: {
1581
- form: CreateServiceForm;
1523
+ declare function scheduleAppointment(request: {
1524
+ form: ScheduleAppointmentForm;
1582
1525
  sender: UserDetails;
1583
1526
  billing: SafeOmit<CompanyBilling, "uid" | "prepayments" | "lastModified">;
1584
1527
  preferences: SafeOmit<CompanyPreferences, "uid" | "lastModified">;
@@ -1586,7 +1529,7 @@ declare function createCompanyService(request: {
1586
1529
  staff: CompanyStaff;
1587
1530
  cost: number;
1588
1531
  findClient: (uid: string) => Promise<ClientIdentity>;
1589
- encryptCopy: (service: SafeOmit<MutableServiceDetails, "_hash">) => string;
1532
+ createHash: (appointment: SafeOmit<MutableAppointmentDetails, "_hash">) => string;
1590
1533
  options?: Partial<{
1591
1534
  ignoreBalanceCheck: boolean;
1592
1535
  }>;
@@ -1613,14 +1556,13 @@ declare function createCompanyService(request: {
1613
1556
  createdAt: number;
1614
1557
  };
1615
1558
  staffDetails: {
1616
- uid: string;
1617
1559
  members: Record<string, {
1618
1560
  uid: string;
1619
1561
  roles: ("doc" | "physAsst" | "rcpst" | "cshr" | "admin")[];
1620
1562
  isAvailable: boolean;
1621
1563
  isBusy: boolean;
1622
1564
  status: "inviteSent" | "active" | "inactive";
1623
- services: Record<"ongoing" | "completed", number>;
1565
+ appointments: Record<"ongoing" | "completed", number>;
1624
1566
  lastActive: number | null;
1625
1567
  isAvailableLastModified: number | null;
1626
1568
  isBusyLastModified: number | null;
@@ -1629,6 +1571,7 @@ declare function createCompanyService(request: {
1629
1571
  photoUrl?: string | null | undefined;
1630
1572
  phoneNumber?: string | undefined;
1631
1573
  }>;
1574
+ uid: string;
1632
1575
  partnerMap: Record<string, Record<string, {
1633
1576
  addedAt: number;
1634
1577
  }>>;
@@ -1714,20 +1657,19 @@ declare function createCompanyService(request: {
1714
1657
  client: {
1715
1658
  createdAt: number;
1716
1659
  uid: string;
1660
+ email: string;
1717
1661
  name: Record<"first" | "last", string>;
1718
- publicKey: string | null;
1719
- activated: boolean;
1662
+ linked: boolean;
1720
1663
  lastModified?: number | null | undefined;
1721
- email?: string | null | undefined;
1664
+ phoneNumber?: string | undefined;
1665
+ photoUrl?: string | null | undefined;
1666
+ dob?: number | undefined;
1722
1667
  address?: {
1723
1668
  streetAddress: string;
1724
1669
  parish: string;
1725
1670
  country: string;
1726
1671
  city?: string | undefined;
1727
1672
  } | undefined;
1728
- phoneNumber?: string | undefined;
1729
- photoUrl?: string | null | undefined;
1730
- dob?: number | undefined;
1731
1673
  };
1732
1674
  _hash: string;
1733
1675
  lastModified?: number | null | undefined;
@@ -1782,7 +1724,7 @@ declare function createCompanyService(request: {
1782
1724
 
1783
1725
  declare function findAvailableStaff(role: CompanyUserRole, staff: CompanyStaff): string[];
1784
1726
 
1785
- declare function findNextAvailableStaff(userUids: string[], algorithm: CompanyPreferences["serviceDistAlg"], staff: CompanyStaff): string | null;
1727
+ declare function findNextAvailableStaff(userUids: string[], algorithm: CompanyPreferences["apptDistAlg"], staff: CompanyStaff): string | null;
1786
1728
 
1787
1729
  /**@returns an array of the users that have conflicting roles or are incompatible with the other partners, or null if none was found. */
1788
1730
  declare const findConflictingPartners: (...partners: CompanyUser[]) => {
@@ -1791,7 +1733,7 @@ declare const findConflictingPartners: (...partners: CompanyUser[]) => {
1791
1733
  isAvailable: boolean;
1792
1734
  isBusy: boolean;
1793
1735
  status: "inviteSent" | "active" | "inactive";
1794
- services: Record<"ongoing" | "completed", number>;
1736
+ appointments: Record<"ongoing" | "completed", number>;
1795
1737
  lastActive: number | null;
1796
1738
  isAvailableLastModified: number | null;
1797
1739
  isBusyLastModified: number | null;
@@ -1803,4 +1745,4 @@ declare const findConflictingPartners: (...partners: CompanyUser[]) => {
1803
1745
  /**@returns the roles that are compatible with the selected role. */
1804
1746
  declare const getCompatibleRoles: (role: CompanyUserRole) => CompanyUserRole[];
1805
1747
 
1806
- export { ClientIdentity, CompanyBilling, CompanyDetails, CompanyIdentity, CompanyInviteList, CompanyNotifications, type CompanyPartnerRole, CompanyPreferences, type CompanyServiceSelector, CompanyStaff, CompanyState, CompanyUser, type CompanyUserRole, CreateServiceForm, CreditCurrency, type EmployeeRole, type HealthcareProviderRole, InviteResponse, InvoiceNo, MedicalDetails, Medicine, MiniServiceDetails, MutableCompanyBilling, MutableCompanyDetails, MutableCompanyIdentity, MutableCompanyPreferences, MutableServiceDetails, Notification, type PaymentMethod, PriceAdjustment, PriceTag, Reason, Receipts, ServiceDetails, type ServiceDistAlg, StandardTime, TicketNo, type Tier, TierList, TimeLog, Timestamp, UserDetails, Vitals, companyPartnerRoles, companyServiceSelectors, companyUserRoles, createCompanyService, employeeRoles, findAvailableStaff, findConflictingPartners, findNextAvailableStaff, getCompatibleRoles, healthcareProviderRoles, paymentMethods, serviceDistAlgs, serviceProviders, tiers, vitalKeys };
1748
+ export { AppointmentDetails, type AppointmentDistAlg, ClientIdentity, CompanyBilling, CompanyDetails, CompanyIdentity, CompanyInviteList, CompanyNotifications, type CompanyPartnerRole, CompanyPreferences, type CompanyServiceSelector, CompanyStaff, CompanyState, CompanyUser, type CompanyUserRole, CreditCurrency, type EmployeeRole, type HealthcareProviderRole, InviteResponse, InvoiceNo, MedicalDetails, Medicine, MiniAppointmentDetails, MiniCompanyUser, MutableAppointmentDetails, MutableCompanyBilling, MutableCompanyDetails, MutableCompanyIdentity, MutableCompanyPreferences, Notification, type PaymentMethod, PriceAdjustment, PriceTag, Reason, Receipts, ScheduleAppointmentForm, StandardTime, TicketNo, type Tier, TierList, TimeLog, Timestamp, UserDetails, Vitals, appointmentDistAlgs, companyPartnerRoles, companyServiceSelectors, companyUserRoles, employeeRoles, findAvailableStaff, findConflictingPartners, findNextAvailableStaff, getCompatibleRoles, healthcareProviderRoles, paymentMethods, scheduleAppointment, serviceProviders, tiers, vitalKeys };
package/dist/main.js CHANGED
@@ -16,7 +16,7 @@ var healthcareProviderRoles = companyUserRoles.extract([
16
16
  "physAsst",
17
17
  "doc"
18
18
  ]);
19
- var serviceDistAlgs = z.enum(["RR", "LOR"]);
19
+ var appointmentDistAlgs = z.enum(["RR", "LOR"]);
20
20
  var companyServiceSelectors = z.enum(["scheduler", "doctor"]);
21
21
 
22
22
  // src/enums/Global.ts
@@ -34,7 +34,7 @@ var vitalKeys = z3.enum([
34
34
  "bodyTemp"
35
35
  ]);
36
36
 
37
- // src/enums/Services.ts
37
+ // src/enums/Appointments.ts
38
38
  import * as z4 from "zod";
39
39
  var serviceProviders = z4.enum([
40
40
  "scheduler",
@@ -148,10 +148,12 @@ var CompanyBilling = z8.object({
148
148
  discounts: createAdjustments("discount"),
149
149
  /** Optionally deductable from bills */
150
150
  prepayments: createAdjustments("pre-payment"),
151
- services: z8.object({
151
+ offeredServices: z8.object({
152
152
  /** Forces service selectors to use the list of service(s) that you've created. */
153
153
  deployed: z8.boolean(),
154
- value: z8.record(z8.string(), PriceTag.omit({ uid: true }))
154
+ // An object is used instead of an array so that updates to a particular service is accurate
155
+ // and consistent.
156
+ value: z8.record(z8.uuidv4(), PriceTag.omit({ uid: true }))
155
157
  }).superRefine((data, ctx) => {
156
158
  const services = Object.entries(data.value);
157
159
  if (services.length > 150) {
@@ -164,13 +166,6 @@ var CompanyBilling = z8.object({
164
166
  "You must create at least (1) service in order to deploy your service list."
165
167
  );
166
168
  }
167
- for (const [key, value] of services) {
168
- if (key !== value.createdAt.toString()) {
169
- ctx.addIssue(
170
- `The key for every service must be the same its correlating "createdAt" timestamp.`
171
- );
172
- }
173
- }
174
169
  }),
175
170
  lastModified: Timestamp.nullable()
176
171
  });
@@ -298,15 +293,15 @@ var CompanyPreferences = z12.object({
298
293
  * @note
299
294
  * - only allowed when `serviceSelector === "scheduler"`
300
295
  * */
301
- enforcePaidServices: z12.boolean(),
296
+ enforcePaidAppointments: z12.boolean(),
302
297
  /**
303
298
  * @property RR (Round Robin): Even distribution.
304
299
  * @property LOR (Least Outstanding Requests): Distribute based on availability.
305
300
  */
306
- serviceDistAlg: serviceDistAlgs.default("RR"),
301
+ apptDistAlg: appointmentDistAlgs.default("RR"),
307
302
  lastModified: Timestamp.nullable()
308
303
  }).refine(
309
- (data) => !data.enforcePaidServices || data.enforcePaidServices && data.serviceSelector === "scheduler",
304
+ (data) => !data.enforcePaidAppointments || data.enforcePaidAppointments && data.serviceSelector === "scheduler",
310
305
  'Enforcing paid appointments is only allowed when the service selector is the "scheduler".'
311
306
  );
312
307
  var MutableCompanyPreferences = CompanyPreferences.omit({
@@ -322,27 +317,17 @@ import { UserModel as UserModel2 } from "@wavy/util";
322
317
  import * as z14 from "zod";
323
318
 
324
319
  // src/schemas/User.ts
325
- import { Address as Address2, UserModel } from "@wavy/util";
320
+ import { UserModel } from "@wavy/util";
326
321
  import * as z13 from "zod";
327
322
  var UserDetails = z13.object({
328
323
  ...UserModel.shape,
329
324
  uid: z13.uuidv4(),
330
- email: UserModel.shape.email.nullish(),
331
- dob: Timestamp.optional(),
332
- address: Address2.optional(),
325
+ email: UserModel.shape.email,
333
326
  publicKey: z13.string().nullable(),
334
327
  notifications: z13.array(Notification),
335
- activated: z13.boolean(),
328
+ /** Only true when linked to a client */
329
+ linked: z13.boolean(),
336
330
  ...TimeLog.shape
337
- }).superRefine((data, ctx) => {
338
- if (data.activated && data.publicKey === null) {
339
- ctx.addIssue("An activated user must have a valid public key.");
340
- } else if (!data.activated && data.publicKey !== null) {
341
- ctx.addIssue("An inactive user can't have a public key.");
342
- }
343
- if (data.activated && !data.email) {
344
- ctx.addIssue("An activated user must have a valid email.");
345
- }
346
331
  });
347
332
 
348
333
  // src/functions/helper-functions.ts
@@ -377,8 +362,7 @@ var getCompatibleRoles = (role) => {
377
362
  };
378
363
 
379
364
  // src/schemas/company/components/User.ts
380
- var CompanyUser = z14.object({
381
- ...UserModel2.shape,
365
+ var MiniCompanyUser = z14.object({
382
366
  uid: UserDetails.shape.uid,
383
367
  roles: z14.array(companyUserRoles).transform((roles) => {
384
368
  const newRoles = [];
@@ -394,7 +378,7 @@ var CompanyUser = z14.object({
394
378
  isAvailable: z14.boolean(),
395
379
  isBusy: z14.boolean(),
396
380
  status: z14.enum(["inviteSent", "active", "inactive"]),
397
- services: z14.record(z14.literal(["ongoing", "completed"]), z14.int().min(0)),
381
+ appointments: z14.record(z14.literal(["ongoing", "completed"]), z14.int().min(0)),
398
382
  lastActive: Timestamp.nullable(),
399
383
  isAvailableLastModified: Timestamp.nullable(),
400
384
  isBusyLastModified: Timestamp.nullable()
@@ -408,27 +392,24 @@ var CompanyUser = z14.object({
408
392
  );
409
393
  }
410
394
  });
395
+ var CompanyUser = z14.object({
396
+ ...UserModel2.shape,
397
+ ...MiniCompanyUser.shape
398
+ });
411
399
 
412
400
  // src/schemas/company/components/Staff.ts
413
- var RawCompanyStaff = z15.object({
414
- uid: CompanyState.shape.uid,
415
- members: z15.record(CompanyUser.shape.uid, CompanyUser).superRefine((data, ctx) => {
416
- const emails = [];
417
- for (const [uid, user] of Object.entries(data)) {
418
- if (uid !== user.uid) {
419
- ctx.addIssue(
420
- `User found with a uid that doesn't match their respective key. (${uid} !== ${user.uid}).`
421
- );
422
- }
423
- if (!!user.email && emails.includes(user.email.toLowerCase())) {
424
- ctx.addIssue(
425
- `Having multiple members with the same email is prohibited. (${user.email})`
426
- );
427
- } else if (!!user.email) {
428
- emails.push(user.email.toLowerCase());
429
- }
401
+ var refineMembers = (data, ctx) => {
402
+ for (const [uid, user] of Object.entries(data)) {
403
+ if (uid !== user.uid) {
404
+ ctx.addIssue(
405
+ `User found with a uid that doesn't match their respective key. (${uid} !== ${user.uid}).`
406
+ );
430
407
  }
431
- }),
408
+ }
409
+ };
410
+ var MiniRawCompanyStaff = z15.object({
411
+ uid: CompanyState.shape.uid,
412
+ members: z15.record(MiniCompanyUser.shape.uid, MiniCompanyUser).superRefine(refineMembers),
432
413
  /**
433
414
  * @relationship one -> many
434
415
  *@description A map of doctor `uids` to their assistants `uids` */
@@ -455,60 +436,68 @@ var RawCompanyStaff = z15.object({
455
436
  ),
456
437
  lastModified: Timestamp.nullable()
457
438
  });
458
- var CompanyStaff = RawCompanyStaff.transform((d) => {
459
- const copy = structuredClone(d);
460
- for (const uid of Object.keys(copy.updateQueue)) {
461
- if (uid in copy.members) {
462
- const userUpdates = copy.updateQueue[uid];
463
- if ("$REMOVE" in userUpdates) {
464
- copy.updateQueue[uid] = { $REMOVE: userUpdates.$REMOVE };
465
- } else if (userUpdates.$CHANGE_ROLES && userUpdates.$CHANGE_ROLES.newRoles.length === copy.members[uid].roles.length && userUpdates.$CHANGE_ROLES.newRoles.every(
466
- (role) => copy.members[uid].roles.includes(role)
467
- )) {
468
- delete copy.updateQueue[uid].$CHANGE_ROLES;
439
+ var RawCompanyStaff = z15.object({
440
+ ...MiniRawCompanyStaff.shape,
441
+ members: z15.record(CompanyUser.shape.uid, CompanyUser).superRefine(refineMembers)
442
+ });
443
+ var transformStaff = (object16) => {
444
+ return object16.transform((d) => {
445
+ const copy = structuredClone(d);
446
+ for (const uid of Object.keys(copy.updateQueue)) {
447
+ if (uid in copy.members) {
448
+ const userUpdates = copy.updateQueue[uid];
449
+ if ("$REMOVE" in userUpdates) {
450
+ copy.updateQueue[uid] = { $REMOVE: userUpdates.$REMOVE };
451
+ } else if (userUpdates.$CHANGE_ROLES && userUpdates.$CHANGE_ROLES.newRoles.length === copy.members[uid].roles.length && userUpdates.$CHANGE_ROLES.newRoles.every(
452
+ (role) => copy.members[uid].roles.includes(role)
453
+ )) {
454
+ delete copy.updateQueue[uid].$CHANGE_ROLES;
455
+ }
456
+ if (Object.keys(userUpdates).length < 1) delete copy.updateQueue[uid];
457
+ } else {
458
+ delete copy.updateQueue[uid];
469
459
  }
470
- if (Object.keys(userUpdates).length < 1) delete copy.updateQueue[uid];
471
- } else {
472
- delete copy.updateQueue[uid];
473
460
  }
474
- }
475
- for (const [docUid, assts] of Object.entries(copy.partnerMap)) {
476
- if (docUid in d.members) {
477
- for (const asstUid of Object.keys(assts)) {
478
- if (asstUid in d.members) continue;
479
- delete copy.partnerMap[docUid][asstUid];
461
+ for (const [docUid, assts] of Object.entries(copy.partnerMap)) {
462
+ if (docUid in d.members) {
463
+ for (const asstUid of Object.keys(assts)) {
464
+ if (asstUid in d.members) continue;
465
+ delete copy.partnerMap[docUid][asstUid];
466
+ }
467
+ } else {
468
+ delete copy.partnerMap[docUid];
480
469
  }
481
- } else {
482
- delete copy.partnerMap[docUid];
483
470
  }
484
- }
485
- return copy;
486
- }).superRefine((details, ctx) => {
487
- for (const user of Object.values(details.members)) {
488
- if (user.roles.includes("doc") && user.uid in details.partnerMap) {
489
- for (const asstUid of Object.keys(details.partnerMap[user.uid])) {
490
- if (!details.members[asstUid].roles.includes("physAsst")) {
491
- ctx.addIssue(
492
- `A partner group member must have the "physAsst" role (${user.uid}) -> (${asstUid}).`
493
- );
471
+ return copy;
472
+ }).superRefine((details, ctx) => {
473
+ for (const user of Object.values(details.members)) {
474
+ if (user.roles.includes("doc") && user.uid in details.partnerMap) {
475
+ for (const asstUid of Object.keys(details.partnerMap[user.uid])) {
476
+ if (!details.members[asstUid].roles.includes("physAsst")) {
477
+ ctx.addIssue(
478
+ `A partner group member must have the "physAsst" role (${user.uid}) -> (${asstUid}).`
479
+ );
480
+ }
494
481
  }
482
+ } else if (user.uid in details.partnerMap) {
483
+ ctx.addIssue(
484
+ `A partner group leader must have the "doc" role. (${user.uid})`
485
+ );
486
+ } else if (user.roles.includes("doc")) {
487
+ ctx.addIssue(
488
+ `All users that have the "doc" role must be the leader of a partner group. (${user.uid})`
489
+ );
490
+ }
491
+ if (!user.isBusy && user.uid in details.updateQueue) {
492
+ ctx.addIssue(
493
+ `Having users that aren't busy in the update queue is prohibited.`
494
+ );
495
495
  }
496
- } else if (user.uid in details.partnerMap) {
497
- ctx.addIssue(
498
- `A partner group leader must have the "doc" role. (${user.uid})`
499
- );
500
- } else if (user.roles.includes("doc")) {
501
- ctx.addIssue(
502
- `All users that have the "doc" role must be the leader of a partner group. (${user.uid})`
503
- );
504
- }
505
- if (!user.isBusy && user.uid in details.updateQueue) {
506
- ctx.addIssue(
507
- `Having users that aren't busy in the update queue is prohibited.`
508
- );
509
496
  }
510
- }
511
- });
497
+ });
498
+ };
499
+ var CompanyStaff = transformStaff(RawCompanyStaff);
500
+ var MiniCompanyStaff = transformStaff(MiniRawCompanyStaff);
512
501
  var MutableCompanyStaff = RawCompanyStaff.pick({
513
502
  updateQueue: true,
514
503
  partnerMap: true
@@ -543,59 +532,69 @@ var CompanyInviteList = z17.record(
543
532
  "Insufficient amount of members invited."
544
533
  );
545
534
 
546
- // src/schemas/Client.ts
547
- var ClientIdentity = UserDetails.omit({ notifications: true });
548
-
549
- // src/schemas/Medical.ts
535
+ // src/schemas/appointment/components/Client.ts
550
536
  import * as z18 from "zod";
551
- var Vitals = z18.record(
552
- vitalKeys,
537
+ import { Address as Address3 } from "@wavy/util";
538
+ var ClientIdentity = UserDetails.omit({
539
+ notifications: true,
540
+ publicKey: true
541
+ }).safeExtend(
553
542
  z18.object({
554
- value: z18.string().trim().regex(/^\d{0,3}((\/|\.)\d{1,3})?/),
543
+ dob: Timestamp.optional(),
544
+ address: Address3.optional()
545
+ }).shape
546
+ );
547
+
548
+ // src/schemas/appointment/components/payload/Medical.ts
549
+ import * as z19 from "zod";
550
+ var Vitals = z19.record(
551
+ vitalKeys,
552
+ z19.object({
553
+ value: z19.string().trim().regex(/^\d{0,3}((\/|\.)\d{1,3})?/),
555
554
  lastModified: Timestamp.nullable()
556
555
  })
557
556
  );
558
- var Medicine = z18.object({
559
- brand: z18.string().trim(),
557
+ var Medicine = z19.object({
558
+ brand: z19.string().trim(),
560
559
  expiresAt: Timestamp.nullish(),
561
- quantity: z18.string().trim().regex(/^\d+(\.\d{1,3})? ?[a-zA-Z]{1,20}/, {
560
+ quantity: z19.string().trim().regex(/^\d+(\.\d{1,3})? ?[a-zA-Z]{1,20}/, {
562
561
  error: "Failed to match the pattern <number>+(.<number>{1,3})? ?[a-zA-Z]{1,20}"
563
562
  }),
564
- refills: z18.string().trim().regex(/^[0-8]/, { error: "Must be between 0 and 8" }),
565
- directions: z18.string().trim().max(100, { error: "Must be 100 characters or less" }),
563
+ refills: z19.string().trim().regex(/^[0-8]/, { error: "Must be between 0 and 8" }),
564
+ directions: z19.string().trim().max(100, { error: "Must be 100 characters or less" }),
566
565
  ...TimeLog.shape
567
566
  });
568
- var MedicalDetails = z18.object({
567
+ var MedicalDetails = z19.object({
569
568
  vitals: Vitals,
570
- prescriptions: z18.array(z18.array(Medicine)).nullish(),
571
- doctorNote: z18.object({
572
- value: z18.string(),
569
+ prescriptions: z19.array(z19.array(Medicine)).nullish(),
570
+ doctorNote: z19.object({
571
+ value: z19.string(),
573
572
  lastModified: Timestamp.nullable()
574
573
  }),
575
- physAsstNotes: z18.array(
576
- z18.object({
577
- title: z18.string(),
578
- content: z18.string(),
574
+ physAsstNotes: z19.array(
575
+ z19.object({
576
+ title: z19.string(),
577
+ content: z19.string(),
579
578
  ...TimeLog.shape
580
579
  })
581
580
  ).optional()
582
581
  });
583
582
 
584
- // src/schemas/ServiceDetails.ts
585
- import * as z19 from "zod";
586
- var TimelineActivity = z19.object({
583
+ // src/schemas/appointment/Appointment.ts
584
+ import * as z20 from "zod";
585
+ var TimelineActivity = z20.object({
587
586
  postedAt: Timestamp.nullish(),
588
587
  userUid: CompanyUser.shape.uid.nonoptional()
589
588
  });
590
- var MiniServiceDetails = z19.object({
589
+ var MiniAppointmentDetails = z20.object({
591
590
  /** A random uid that identifies the document. */
592
- _id: z19.uuidv4(),
591
+ _id: z20.uuidv4(),
593
592
  /** The company's uid */
594
593
  src: CompanyState.shape.uid,
595
594
  /** The ticket number */
596
595
  tkt: TicketNo,
597
596
  /**The reason for the service */
598
- reason: z19.object({
597
+ reason: z20.object({
599
598
  value: Reason.shape.value,
600
599
  ...TimeLog.shape
601
600
  }).optional(),
@@ -607,24 +606,24 @@ var MiniServiceDetails = z19.object({
607
606
  */
608
607
  invoiceNo: InvoiceNo.optional(),
609
608
  /** The services that the client has done/will do. */
610
- charges: z19.array(PriceTag.omit({ uid: true })).max(4),
609
+ charges: z20.array(PriceTag.omit({ uid: true })).max(4),
611
610
  /**Required to calculate the accurate grandTotal of the charges */
612
- additionalFees: z19.array(PriceAdjustment).nullable().readonly(),
611
+ additionalFees: z20.array(PriceAdjustment).nullable().readonly(),
613
612
  /**Required to calculate the accurate grandTotal of the charges */
614
- discounts: z19.array(PriceAdjustment).nullable().readonly(),
615
- prepayments: z19.array(PriceAdjustment).nullable(),
613
+ discounts: z20.array(PriceAdjustment).nullable().readonly(),
614
+ prepayments: z20.array(PriceAdjustment).nullable(),
616
615
  /** The client's identity */
617
616
  clientUid: ClientIdentity.shape.uid,
618
617
  /**
619
618
  * Data that is specific to the entity (for now it's just medical data).
620
619
  * It will only be defined for the participants that have access to it.
621
620
  */
622
- payload: z19.object({
621
+ payload: z20.object({
623
622
  ...MedicalDetails.shape,
624
- lastModified: z19.number().nullable()
623
+ lastModified: z20.number().nullable()
625
624
  }).nullish(),
626
625
  /** Only defined when either the service provider or the client cancelled their appointment */
627
- cancelled: z19.object({
626
+ cancelled: z20.object({
628
627
  /** The time that the confirm cancel button was clicked */
629
628
  doneAt: Timestamp,
630
629
  reason: Reason,
@@ -632,45 +631,45 @@ var MiniServiceDetails = z19.object({
632
631
  }).optional(),
633
632
  /** Add this after consulting with company owners about payment expectations */
634
633
  // paymentDueDate: Timestamp.nullish(),
635
- payments: z19.array(
636
- z19.object({
634
+ payments: z20.array(
635
+ z20.object({
637
636
  method: paymentMethods,
638
- amount: z19.number().positive(),
637
+ amount: z20.number().positive(),
639
638
  ...TimeLog.shape
640
639
  })
641
640
  ).max(100).nullish(),
642
- timeline: z19.object({
641
+ timeline: z20.object({
643
642
  scheduler: TimelineActivity,
644
- physAsst: TimelineActivity.or(z19.literal("none")),
643
+ physAsst: TimelineActivity.or(z20.literal("none")),
645
644
  doctor: TimelineActivity,
646
645
  cashier: TimelineActivity.nullable()
647
646
  }),
648
647
  ...TimeLog.shape
649
648
  });
650
- var ServiceDetails = MiniServiceDetails.omit({
649
+ var AppointmentDetails = MiniAppointmentDetails.omit({
651
650
  clientUid: true
652
- }).extend(z19.object({ client: ClientIdentity }).shape);
653
- var MutableServiceDetails = ServiceDetails.safeExtend(
654
- z19.object({
651
+ }).extend(z20.object({ client: ClientIdentity }).shape);
652
+ var MutableAppointmentDetails = AppointmentDetails.safeExtend(
653
+ z20.object({
655
654
  /**
656
- * @description An encrypted copy of the last state of the service.
657
- * @note Used to accurately update the service without having to query the database
655
+ * @description An encrypted copy of the last state of the appointment.
656
+ * @note Used to accurately update the appointment without having to query the database
658
657
  */
659
- _hash: z19.string()
658
+ _hash: z20.string()
660
659
  }).shape
661
660
  );
662
- var CreateServiceForm = z19.object({
661
+ var ScheduleAppointmentForm = z20.object({
663
662
  clientUid: ClientIdentity.shape.uid,
664
663
  /** A nullish value === next_available */
665
664
  serviceProviderUid: CompanyUser.shape.uid.nullish(),
666
- charges: ServiceDetails.shape.charges.optional(),
667
- prepayments: ServiceDetails.shape.prepayments.optional(),
668
- payments: ServiceDetails.shape.payments.optional(),
665
+ charges: AppointmentDetails.shape.charges.optional(),
666
+ prepayments: AppointmentDetails.shape.prepayments.optional(),
667
+ payments: AppointmentDetails.shape.payments.optional(),
669
668
  ...TimeLog.shape
670
669
  });
671
670
 
672
- // src/functions/createCompanyService.ts
673
- import { findChanges, omit, TODO } from "@wavy/fn";
671
+ // src/functions/scheduleAppointment.ts
672
+ import { findChanges, omit } from "@wavy/fn";
674
673
  import { v4 } from "uuid";
675
674
 
676
675
  // src/functions/findAvailableStaff.ts
@@ -689,15 +688,16 @@ function findNextAvailableStaff(userUids, algorithm, staff) {
689
688
  if (userUids.length === 1) return userUids[0];
690
689
  switch (algorithm) {
691
690
  case "RR": {
692
- nextAvailable = userUids.find(
693
- (uid) => staff.members[uid].services.ongoing < staff.members[userUids[0]].services.ongoing
694
- ) || userUids[0];
691
+ nextAvailable = userUids.find((uid) => {
692
+ const calcTotalAppts = (appointments) => appointments.ongoing + appointments.completed;
693
+ return calcTotalAppts(staff.members[uid].appointments) < calcTotalAppts(staff.members[userUids[0]].appointments);
694
+ }) || userUids[0];
695
695
  break;
696
696
  }
697
697
  case "LOR": {
698
698
  for (const uid of userUids) {
699
699
  const user = staff.members[uid];
700
- if (!nextAvailable || user.services.ongoing < staff.members[nextAvailable].services.ongoing) {
700
+ if (!nextAvailable || user.appointments.ongoing < staff.members[nextAvailable].appointments.ongoing) {
701
701
  nextAvailable = uid;
702
702
  }
703
703
  }
@@ -709,9 +709,9 @@ function findNextAvailableStaff(userUids, algorithm, staff) {
709
709
  return nextAvailable;
710
710
  }
711
711
 
712
- // src/functions/createCompanyService.ts
713
- async function createCompanyService(request) {
714
- request.form = CreateServiceForm.parse(request.form);
712
+ // src/functions/scheduleAppointment.ts
713
+ async function scheduleAppointment(request) {
714
+ request.form = ScheduleAppointmentForm.parse(request.form);
715
715
  request.sender = UserDetails.parse(request.sender);
716
716
  request.preferences = CompanyPreferences.omit({
717
717
  uid: true,
@@ -745,7 +745,7 @@ async function createCompanyService(request) {
745
745
  if (request.form.serviceProviderUid === null || request.form.serviceProviderUid === void 0) {
746
746
  selectedDoctor = findNextAvailableStaff(
747
747
  availableDoctors,
748
- request.preferences.serviceDistAlg,
748
+ request.preferences.apptDistAlg,
749
749
  staffDetailsCopy
750
750
  );
751
751
  }
@@ -762,16 +762,16 @@ async function createCompanyService(request) {
762
762
  }
763
763
  if (request.preferences.serviceSelector === "scheduler" && (!request.form.charges || request.form.charges.length < 1)) {
764
764
  throw new Error("Insufficient services selected.");
765
- } else if (request.preferences.serviceSelector === "scheduler" && request.billing.services.deployed && request.form.charges.find(
766
- (service2) => !!Object.values(request.billing.services.value).find(
767
- (predefService) => findChanges(service2, predefService).length > 0
765
+ } else if (request.preferences.serviceSelector === "scheduler" && request.billing.offeredServices.deployed && request.form.charges.find(
766
+ (charge) => !!Object.values(request.billing.offeredServices.value).find(
767
+ (createdCharge) => findChanges(charge, createdCharge).length > 0
768
768
  )
769
769
  )) {
770
770
  throw new Error("Invalid service(s) selected.");
771
771
  }
772
- if (request.preferences.enforcePaidServices && (!request.form.payments || request.form.payments.length < 1)) {
772
+ if (request.preferences.enforcePaidAppointments && (!request.form.payments || request.form.payments.length < 1)) {
773
773
  throw new Error("Insufficient payment transactions recorded.");
774
- } else if (request.preferences.enforcePaidServices) {
774
+ } else if (request.preferences.enforcePaidAppointments) {
775
775
  const maxIterations = Math.max(
776
776
  request.form.charges.length,
777
777
  request.form.payments.length
@@ -797,12 +797,12 @@ async function createCompanyService(request) {
797
797
  stateCopy.credits.current -= request.cost;
798
798
  stateCopy.credits.lastModified = today;
799
799
  stateCopy.lastModified = today;
800
- staffDetailsCopy.members[selectedDoctor].services.ongoing++;
800
+ staffDetailsCopy.members[selectedDoctor].appointments.ongoing++;
801
801
  if (selectedPhysAsst) {
802
- staffDetailsCopy.members[selectedPhysAsst].services.ongoing++;
802
+ staffDetailsCopy.members[selectedPhysAsst].appointments.ongoing++;
803
803
  }
804
804
  staffDetailsCopy.lastModified = today;
805
- const service = {
805
+ const appointment = {
806
806
  _id: v4(),
807
807
  src: stateCopy.uid,
808
808
  tkt: request.state.tktNoCounter,
@@ -812,8 +812,8 @@ async function createCompanyService(request) {
812
812
  additionalFees: Object.values(request.billing.additionalFees || {}).filter(
813
813
  (fee) => !fee.isOptional
814
814
  ),
815
- payments: request.preferences.enforcePaidServices ? request.form.payments : null,
816
- prepayments: request.preferences.enforcePaidServices ? request.form.prepayments || [] : null,
815
+ payments: request.preferences.enforcePaidAppointments ? request.form.payments : null,
816
+ prepayments: request.preferences.enforcePaidAppointments ? request.form.prepayments || [] : null,
817
817
  charges: request.preferences.serviceSelector === "scheduler" ? request.form.charges : [],
818
818
  client: await request.findClient(request.form.clientUid),
819
819
  _hash: "aa.aa.aa",
@@ -823,23 +823,23 @@ async function createCompanyService(request) {
823
823
  doctor: { userUid: selectedDoctor },
824
824
  physAsst: selectedPhysAsst ? { userUid: selectedPhysAsst } : "none",
825
825
  get cashier() {
826
- if (request.preferences.enforcePaidServices) return this.scheduler;
826
+ if (request.preferences.enforcePaidAppointments) return this.scheduler;
827
827
  return null;
828
828
  }
829
829
  },
830
830
  createdAt: today
831
831
  };
832
- TODO("Encrypt the service and assign the cipher text to _hash...");
833
- service._hash = request.encryptCopy(omit(service, ["_hash"]));
832
+ appointment._hash = request.createHash(omit(appointment, ["_hash"]));
834
833
  return {
835
834
  updates: {
836
835
  state: stateCopy,
837
836
  staffDetails: staffDetailsCopy
838
837
  },
839
- appointment: MutableServiceDetails.parse(service)
838
+ appointment: MutableAppointmentDetails.parse(appointment)
840
839
  };
841
840
  }
842
841
  export {
842
+ AppointmentDetails,
843
843
  ClientIdentity,
844
844
  CompanyBilling,
845
845
  CompanyDetails,
@@ -850,24 +850,24 @@ export {
850
850
  CompanyStaff,
851
851
  CompanyState,
852
852
  CompanyUser,
853
- CreateServiceForm,
854
853
  CreditCurrency,
855
854
  InviteResponse,
856
855
  InvoiceNo,
857
856
  MedicalDetails,
858
857
  Medicine,
859
- MiniServiceDetails,
858
+ MiniAppointmentDetails,
859
+ MiniCompanyUser,
860
+ MutableAppointmentDetails,
860
861
  MutableCompanyBilling,
861
862
  MutableCompanyDetails,
862
863
  MutableCompanyIdentity,
863
864
  MutableCompanyPreferences,
864
- MutableServiceDetails,
865
865
  Notification,
866
866
  PriceAdjustment,
867
867
  PriceTag,
868
868
  Reason,
869
869
  Receipts,
870
- ServiceDetails,
870
+ ScheduleAppointmentForm,
871
871
  StandardTime,
872
872
  TicketNo,
873
873
  TierList,
@@ -875,10 +875,10 @@ export {
875
875
  Timestamp,
876
876
  UserDetails,
877
877
  Vitals,
878
+ appointmentDistAlgs,
878
879
  companyPartnerRoles,
879
880
  companyServiceSelectors,
880
881
  companyUserRoles,
881
- createCompanyService,
882
882
  employeeRoles,
883
883
  findAvailableStaff,
884
884
  findConflictingPartners,
@@ -886,7 +886,7 @@ export {
886
886
  getCompatibleRoles,
887
887
  healthcareProviderRoles,
888
888
  paymentMethods,
889
- serviceDistAlgs,
889
+ scheduleAppointment,
890
890
  serviceProviders,
891
891
  tiers,
892
892
  vitalKeys
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bizmap/sdk",
3
- "version": "0.0.59",
3
+ "version": "0.0.61",
4
4
  "main": "./dist/main.js",
5
5
  "types": "./dist/main.d.ts",
6
6
  "type": "module",