@bizmap/sdk 0.0.106 → 0.0.108

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
@@ -45,12 +45,6 @@ declare const industries: z.ZodEnum<{
45
45
  healthcare: "healthcare";
46
46
  }>;
47
47
  type Industry = z.infer<typeof industries>;
48
- declare const companyUserStatus: z.ZodEnum<{
49
- inviteSent: "inviteSent";
50
- active: "active";
51
- inactive: "inactive";
52
- }>;
53
- type CompanyUserStatus = z.infer<typeof companyUserStatus>;
54
48
 
55
49
  declare const tiers: z.ZodEnum<{
56
50
  basic: "basic";
@@ -239,15 +233,9 @@ declare const CompanyDetails: z.ZodObject<{
239
233
  lastModified: z.ZodNullable<z.ZodISODateTime>;
240
234
  version: z.ZodInt;
241
235
  members: z.ZodRecord<z.ZodUUID, z.ZodObject<{
242
- inviteSent: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
243
236
  lastModified: z.ZodNullable<z.ZodISODateTime>;
244
237
  email: z.ZodEmail;
245
238
  name: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
246
- status: z.ZodEnum<{
247
- inviteSent: "inviteSent";
248
- active: "active";
249
- inactive: "inactive";
250
- }>;
251
239
  isBusy: z.ZodObject<{
252
240
  value: z.ZodBoolean;
253
241
  lastModified: z.ZodNullable<z.ZodISODateTime>;
@@ -261,8 +249,10 @@ declare const CompanyDetails: z.ZodObject<{
261
249
  "a/r": "a/r";
262
250
  founder: "founder";
263
251
  }>>, z.ZodTransform<("doc" | "physAsst" | "rcpst" | "cshr" | "a/r" | "founder")[], ("doc" | "physAsst" | "rcpst" | "cshr" | "a/r" | "founder")[]>>;
264
- lastActive: z.ZodNullable<z.ZodISODateTime>;
252
+ lastOnline: z.ZodNullable<z.ZodISODateTime>;
253
+ inviteSent: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
265
254
  inviteAccepted: z.ZodNullable<z.ZodISODateTime>;
255
+ isOnline: z.ZodBoolean;
266
256
  }, z.core.$strip>>;
267
257
  partnerMap: z.ZodRecord<z.ZodUUID, z.ZodRecord<z.ZodUUID, z.ZodObject<{
268
258
  addedAt: z.ZodISODateTime;
@@ -615,15 +605,9 @@ type MutableCompanyPreferences = z.infer<typeof MutableCompanyPreferences>;
615
605
 
616
606
  declare const CompanyStaff: z.ZodObject<{
617
607
  members: z.ZodRecord<z.ZodUUID, z.ZodObject<{
618
- inviteSent: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
619
608
  lastModified: z.ZodNullable<z.ZodISODateTime>;
620
609
  email: z.ZodEmail;
621
610
  name: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
622
- status: z.ZodEnum<{
623
- inviteSent: "inviteSent";
624
- active: "active";
625
- inactive: "inactive";
626
- }>;
627
611
  isBusy: z.ZodObject<{
628
612
  value: z.ZodBoolean;
629
613
  lastModified: z.ZodNullable<z.ZodISODateTime>;
@@ -637,8 +621,10 @@ declare const CompanyStaff: z.ZodObject<{
637
621
  "a/r": "a/r";
638
622
  founder: "founder";
639
623
  }>>, z.ZodTransform<("doc" | "physAsst" | "rcpst" | "cshr" | "a/r" | "founder")[], ("doc" | "physAsst" | "rcpst" | "cshr" | "a/r" | "founder")[]>>;
640
- lastActive: z.ZodNullable<z.ZodISODateTime>;
624
+ lastOnline: z.ZodNullable<z.ZodISODateTime>;
625
+ inviteSent: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
641
626
  inviteAccepted: z.ZodNullable<z.ZodISODateTime>;
627
+ isOnline: z.ZodBoolean;
642
628
  }, z.core.$strip>>;
643
629
  _id: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
644
630
  partnerMap: z.ZodRecord<z.ZodUUID, z.ZodRecord<z.ZodUUID, z.ZodObject<{
@@ -722,7 +708,7 @@ declare const CompanyUserSession: z.ZodObject<{
722
708
  }, z.core.$strip>;
723
709
  type CompanyUserSession = z.infer<typeof CompanyUserSession>;
724
710
  declare const MiniCompanyUser: z.ZodObject<{
725
- lastActive: z.ZodNullable<z.ZodISODateTime>;
711
+ lastOnline: z.ZodNullable<z.ZodISODateTime>;
726
712
  inviteSent: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
727
713
  inviteAccepted: z.ZodNullable<z.ZodISODateTime>;
728
714
  lastModified: z.ZodNullable<z.ZodISODateTime>;
@@ -743,15 +729,11 @@ declare const MiniCompanyUser: z.ZodObject<{
743
729
  }, z.core.$strip>;
744
730
  type MiniCompanyUser = z.infer<typeof MiniCompanyUser>;
745
731
  declare const CompanyUser: z.ZodObject<{
746
- status: z.ZodEnum<{
747
- inviteSent: "inviteSent";
748
- active: "active";
749
- inactive: "inactive";
750
- }>;
732
+ isOnline: z.ZodBoolean;
751
733
  _id: z.ZodUUID;
752
734
  email: z.ZodEmail;
753
735
  name: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
754
- lastActive: z.ZodNullable<z.ZodISODateTime>;
736
+ lastOnline: z.ZodNullable<z.ZodISODateTime>;
755
737
  inviteSent: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
756
738
  inviteAccepted: z.ZodNullable<z.ZodISODateTime>;
757
739
  lastModified: z.ZodNullable<z.ZodISODateTime>;
@@ -1688,15 +1670,15 @@ declare function scheduleAppointment(request: RequestParameter): Promise<{
1688
1670
  lastModified: string | null;
1689
1671
  email: string;
1690
1672
  name: string;
1691
- status: "inviteSent" | "active" | "inactive";
1692
1673
  isBusy: {
1693
1674
  value: boolean;
1694
1675
  lastModified: string | null;
1695
1676
  };
1696
1677
  appointments: Record<"ongoing" | "completed", number>;
1697
1678
  roles: ("doc" | "physAsst" | "rcpst" | "cshr" | "a/r" | "founder")[];
1698
- lastActive: string | null;
1679
+ lastOnline: string | null;
1699
1680
  inviteAccepted: string | null;
1681
+ isOnline: boolean;
1700
1682
  inviteSent?: string | null | undefined;
1701
1683
  }>;
1702
1684
  _id: string;
@@ -1897,11 +1879,11 @@ declare function findNextAvailableStaff(userUids: string[], algorithm: CompanyPr
1897
1879
  * @returns {(CompanyUser|MiniCompanyUser)[]|null} an array of the users that have conflicting roles or roles that are
1898
1880
  * incompatible with the other partners, or null if none was found. */
1899
1881
  declare const findConflictingPartners: (...partners: (CompanyUser | MiniCompanyUser)[]) => ({
1900
- status: "inviteSent" | "active" | "inactive";
1882
+ isOnline: boolean;
1901
1883
  _id: string;
1902
1884
  email: string;
1903
1885
  name: string;
1904
- lastActive: string | null;
1886
+ lastOnline: string | null;
1905
1887
  inviteAccepted: string | null;
1906
1888
  lastModified: string | null;
1907
1889
  isBusy: {
@@ -1912,7 +1894,7 @@ declare const findConflictingPartners: (...partners: (CompanyUser | MiniCompanyU
1912
1894
  roles: ("doc" | "physAsst" | "rcpst" | "cshr" | "a/r" | "founder")[];
1913
1895
  inviteSent?: string | null | undefined;
1914
1896
  } | {
1915
- lastActive: string | null;
1897
+ lastOnline: string | null;
1916
1898
  inviteAccepted: string | null;
1917
1899
  lastModified: string | null;
1918
1900
  isBusy: {
@@ -1929,6 +1911,7 @@ declare const findConflictingPartners: (...partners: (CompanyUser | MiniCompanyU
1929
1911
  * @returns {CompanyUserRole[]} The roles that are compatible with the selected role.
1930
1912
  * */
1931
1913
  declare const getCompatibleRoles: (role: CompanyUserRole) => CompanyUserRole[];
1914
+ declare const getIncompatibleRoles: (role: CompanyUserRole) => CompanyUserRole[];
1932
1915
  declare const normalizeCompanyId: (id: string) => string;
1933
1916
  declare const normalizeNidKey: (value: keyof NonNullable<ClientIdentity["nid"]>) => string;
1934
1917
  declare const parseClientName: ({ firstName, middleName, lastName, }: Pick<ClientIdentity, "firstName" | "middleName" | "lastName">) => string;
@@ -1938,4 +1921,4 @@ declare function createNotifId(options?: {
1938
1921
  to: string;
1939
1922
  }): string;
1940
1923
 
1941
- export { type AcceptedCurrency, AlphaNumeric, AppointmentDetails, type AppointmentDistAlg, AppointmentSeverity, ClientForm, ClientIdentity, CompanyBilling, CompanyDetails, CompanyIdentity, CompanyInviteList, CompanyNotifications, type CompanyPartnerRole, CompanyPreferences, type CompanyServiceSelector, CompanyStaff, CompanyState, CompanyUser, type CompanyUserRole, CompanyUserSession, type CompanyUserStatus, CreateCompanyForm, CreditCurrency, type EmployeeRole, type Gender, type HealthcareProviderRole, type Industry, InviteResponse, InvoiceNo, MAX_COMPANY_PRICE_MODS, MedicalDetails, Medicine, MiniAppointmentDetails, MiniCompanyUser, MutableAppointmentDetails, MutableCompanyBilling, MutableCompanyDetails, MutableCompanyIdentity, MutableCompanyPreferences, Notification, PaymentDetails, type PaymentMethod, PriceMod, PriceModList, PriceTag, Reason, Receipts, ScheduleAppointmentForm, StandardTime, TicketNo, type Tier, TierList, TimeLog, Timestamp, Trn, UserDetails, Version, Vitals, acceptedCurrencies, adminRoles, appointmentDistAlgs, calcBalance, calcPriceMod, companyPartnerRoles, companyServiceSelectors, companyUserRoles, companyUserStatus, createNotifId, employeeRoles, findAvailableStaff, findConflictingPartners, findNextAvailableStaff, genders, getCompatibleRoles, healthcareProviderRoles, industries, normalizeCompanyId, normalizeNidKey, parseClientName, paymentMethods, scheduleAppointment, serviceProviders, tiers, vitalKeys };
1924
+ export { type AcceptedCurrency, AlphaNumeric, AppointmentDetails, type AppointmentDistAlg, AppointmentSeverity, ClientForm, ClientIdentity, CompanyBilling, CompanyDetails, CompanyIdentity, CompanyInviteList, CompanyNotifications, type CompanyPartnerRole, CompanyPreferences, type CompanyServiceSelector, CompanyStaff, CompanyState, CompanyUser, type CompanyUserRole, CompanyUserSession, CreateCompanyForm, CreditCurrency, type EmployeeRole, type Gender, type HealthcareProviderRole, type Industry, InviteResponse, InvoiceNo, MAX_COMPANY_PRICE_MODS, MedicalDetails, Medicine, MiniAppointmentDetails, MiniCompanyUser, MutableAppointmentDetails, MutableCompanyBilling, MutableCompanyDetails, MutableCompanyIdentity, MutableCompanyPreferences, Notification, PaymentDetails, type PaymentMethod, PriceMod, PriceModList, PriceTag, Reason, Receipts, ScheduleAppointmentForm, StandardTime, TicketNo, type Tier, TierList, TimeLog, Timestamp, Trn, UserDetails, Version, Vitals, acceptedCurrencies, adminRoles, appointmentDistAlgs, calcBalance, calcPriceMod, companyPartnerRoles, companyServiceSelectors, companyUserRoles, createNotifId, employeeRoles, findAvailableStaff, findConflictingPartners, findNextAvailableStaff, genders, getCompatibleRoles, getIncompatibleRoles, healthcareProviderRoles, industries, normalizeCompanyId, normalizeNidKey, parseClientName, paymentMethods, scheduleAppointment, serviceProviders, tiers, vitalKeys };
package/dist/main.js CHANGED
@@ -25,7 +25,6 @@ var industries = z.enum([
25
25
  "healthcare"
26
26
  // "Pharmaceutical",
27
27
  ]);
28
- var companyUserStatus = z.enum(["inviteSent", "active", "inactive"]);
29
28
 
30
29
  // src/enums/Global.ts
31
30
  import { currencies } from "@wavy/util";
@@ -536,6 +535,10 @@ var getCompatibleRoles = (role) => {
536
535
  }
537
536
  return companyUserRoles.exclude([role]).options;
538
537
  };
538
+ var getIncompatibleRoles = (role) => {
539
+ const compatibleRoles = getCompatibleRoles(role);
540
+ return companyUserRoles.options.filter((r) => !compatibleRoles.includes(r) && r !== role);
541
+ };
539
542
  var normalizeCompanyId = (id) => {
540
543
  return id.split("-").map((value) => upperFirst2(value.toLowerCase())).join(" ");
541
544
  };
@@ -573,8 +576,8 @@ var CompanyUserSession = z15.object({
573
576
  }
574
577
  return newRoles.sort();
575
578
  }).refine((roles) => {
576
- return roles.every(
577
- (role, i) => i === 0 || getCompatibleRoles(roles[0]).includes(role)
579
+ return !roles.find(
580
+ (role) => getIncompatibleRoles(role).some((r) => roles.includes(r))
578
581
  );
579
582
  }, "A user is not allowed to have conflicting roles."),
580
583
  ttl: z15.number(),
@@ -591,18 +594,16 @@ var MiniCompanyUser2 = z15.object({
591
594
  appointments: true
592
595
  }).shape,
593
596
  /** The time before the company session gets deleted */
594
- lastActive: Timestamp.nullable(),
597
+ lastOnline: Timestamp.nullable(),
595
598
  inviteSent: Timestamp.nullish(),
596
599
  inviteAccepted: Timestamp.nullable()
597
600
  });
598
601
  var CompanyUser = z15.object({
599
602
  ...MiniCompanyUser2.shape,
600
603
  ...CompanyUserSession.shape.user.shape,
601
- // Determined based on:
602
- // [1] where the data was retrieved from (if it is from the session pool then status === "active")
603
- // [2] user's roles
604
- // [3] inviteSent timestamp (if it )
605
- status: companyUserStatus
604
+ // Only true when the user's data is retrieved from the session pool
605
+ // NB: This property is purely cosmetic (so need to store this on the server)
606
+ isOnline: z15.boolean()
606
607
  });
607
608
 
608
609
  // src/schemas/company/components/Staff.ts
@@ -926,7 +927,7 @@ function findAvailableStaff(role, staff) {
926
927
  return Object.keys(role === "doc" ? staff.partnerMap : staff.members).filter(
927
928
  (uid) => {
928
929
  const user = staff.members[uid];
929
- return !(uid in staff.updateQueue) && user.roles.includes(role) && user.status === "active";
930
+ return !(uid in staff.updateQueue) && user.roles.includes(role) && user.isOnline;
930
931
  }
931
932
  );
932
933
  }
@@ -1170,7 +1171,6 @@ export {
1170
1171
  companyPartnerRoles,
1171
1172
  companyServiceSelectors,
1172
1173
  companyUserRoles,
1173
- companyUserStatus,
1174
1174
  createNotifId,
1175
1175
  employeeRoles,
1176
1176
  findAvailableStaff,
@@ -1178,6 +1178,7 @@ export {
1178
1178
  findNextAvailableStaff,
1179
1179
  genders,
1180
1180
  getCompatibleRoles,
1181
+ getIncompatibleRoles,
1181
1182
  healthcareProviderRoles,
1182
1183
  industries,
1183
1184
  normalizeCompanyId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bizmap/sdk",
3
- "version": "0.0.106",
3
+ "version": "0.0.108",
4
4
  "main": "./dist/main.js",
5
5
  "types": "./dist/main.d.ts",
6
6
  "type": "module",