@bizmap/sdk 0.0.60 → 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 +61 -119
  2. package/dist/main.js +134 -133
  3. package/package.json +1 -1
package/dist/main.d.ts CHANGED
@@ -206,7 +206,7 @@ declare const CompanyDetails: z.ZodObject<{
206
206
  }, z.core.$strip>>;
207
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<{
@@ -361,7 +361,7 @@ declare const MutableCompanyDetails: z.ZodObject<{
361
361
  }, z.core.$strip>>>;
362
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<{
@@ -454,7 +454,7 @@ declare const CompanyBilling: z.ZodObject<{
454
454
  }, z.core.$strip>>;
455
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<{
@@ -525,7 +525,7 @@ declare const MutableCompanyBilling: z.ZodObject<{
525
525
  }, z.core.$strip>>;
526
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<{
@@ -633,8 +633,7 @@ declare const MutableCompanyPreferences: z.ZodObject<{
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<{
@@ -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
- appointments: 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
- appointments: 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<{
@@ -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";
@@ -1339,22 +1284,21 @@ declare const AppointmentDetails: 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
1304
  type AppointmentDetails = z.infer<typeof AppointmentDetails>;
@@ -1509,22 +1453,21 @@ declare const MutableAppointmentDetails: 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>;
@@ -1613,7 +1556,6 @@ declare function scheduleAppointment(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")[];
@@ -1629,6 +1571,7 @@ declare function scheduleAppointment(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 scheduleAppointment(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;
@@ -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 { 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, 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 };
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
@@ -151,7 +151,9 @@ var CompanyBilling = z8.object({
151
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
  });
@@ -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 = [];
@@ -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
@@ -544,58 +533,68 @@ var CompanyInviteList = z17.record(
544
533
  );
545
534
 
546
535
  // src/schemas/appointment/components/Client.ts
547
- var ClientIdentity = UserDetails.omit({ notifications: true });
536
+ import * as z18 from "zod";
537
+ import { Address as Address3 } from "@wavy/util";
538
+ var ClientIdentity = UserDetails.omit({
539
+ notifications: true,
540
+ publicKey: true
541
+ }).safeExtend(
542
+ z18.object({
543
+ dob: Timestamp.optional(),
544
+ address: Address3.optional()
545
+ }).shape
546
+ );
548
547
 
549
548
  // src/schemas/appointment/components/payload/Medical.ts
550
- import * as z18 from "zod";
551
- var Vitals = z18.record(
549
+ import * as z19 from "zod";
550
+ var Vitals = z19.record(
552
551
  vitalKeys,
553
- z18.object({
554
- value: z18.string().trim().regex(/^\d{0,3}((\/|\.)\d{1,3})?/),
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
583
  // src/schemas/appointment/Appointment.ts
585
- import * as z19 from "zod";
586
- var TimelineActivity = z19.object({
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 MiniAppointmentDetails = 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 MiniAppointmentDetails = 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,16 +631,16 @@ var MiniAppointmentDetails = 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
  }),
@@ -649,17 +648,17 @@ var MiniAppointmentDetails = z19.object({
649
648
  });
650
649
  var AppointmentDetails = MiniAppointmentDetails.omit({
651
650
  clientUid: true
652
- }).extend(z19.object({ client: ClientIdentity }).shape);
651
+ }).extend(z20.object({ client: ClientIdentity }).shape);
653
652
  var MutableAppointmentDetails = AppointmentDetails.safeExtend(
654
- z19.object({
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 ScheduleAppointmentForm = 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(),
@@ -689,9 +688,10 @@ 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].appointments.ongoing < staff.members[userUids[0]].appointments.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": {
@@ -856,6 +856,7 @@ export {
856
856
  MedicalDetails,
857
857
  Medicine,
858
858
  MiniAppointmentDetails,
859
+ MiniCompanyUser,
859
860
  MutableAppointmentDetails,
860
861
  MutableCompanyBilling,
861
862
  MutableCompanyDetails,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bizmap/sdk",
3
- "version": "0.0.60",
3
+ "version": "0.0.61",
4
4
  "main": "./dist/main.js",
5
5
  "types": "./dist/main.d.ts",
6
6
  "type": "module",