@bizmap/sdk 0.0.107 → 0.0.109

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
@@ -10,11 +10,6 @@ declare const companyUserRoles: z.ZodEnum<{
10
10
  founder: "founder";
11
11
  }>;
12
12
  type CompanyUserRole = z.infer<typeof companyUserRoles>;
13
- declare const companyPartnerRoles: z.ZodEnum<{
14
- doc: "doc";
15
- physAsst: "physAsst";
16
- }>;
17
- type CompanyPartnerRole = z.infer<typeof companyPartnerRoles>;
18
13
  declare const employeeRoles: z.ZodEnum<{
19
14
  doc: "doc";
20
15
  physAsst: "physAsst";
@@ -676,6 +671,7 @@ declare const CompanyState: z.ZodObject<{
676
671
  }, z.core.$strip>;
677
672
  type CompanyState = z.infer<typeof CompanyState>;
678
673
 
674
+ declare const COMPANY_USER_RELATIONSHIP: Partial<Record<CompanyUserRole, CompanyUserRole[]>>;
679
675
  declare const CompanyUserSession: z.ZodObject<{
680
676
  _id: z.ZodUUID;
681
677
  user: z.ZodObject<{
@@ -1875,6 +1871,7 @@ declare function findAvailableStaff(role: CompanyUserRole, staff: CompanyStaff):
1875
1871
  declare function findNextAvailableStaff(userUids: string[], algorithm: CompanyPreferences["apptDistAlg"], staff: CompanyStaff): string | null;
1876
1872
 
1877
1873
  /**
1874
+ * @deprecated I don't like this for some reason (please remove/replace it!)
1878
1875
  * @param {...CompanyUser|MiniCompanyUser} partners
1879
1876
  * @returns {(CompanyUser|MiniCompanyUser)[]|null} an array of the users that have conflicting roles or roles that are
1880
1877
  * incompatible with the other partners, or null if none was found. */
@@ -1911,6 +1908,7 @@ declare const findConflictingPartners: (...partners: (CompanyUser | MiniCompanyU
1911
1908
  * @returns {CompanyUserRole[]} The roles that are compatible with the selected role.
1912
1909
  * */
1913
1910
  declare const getCompatibleRoles: (role: CompanyUserRole) => CompanyUserRole[];
1911
+ declare const getIncompatibleRoles: (role: CompanyUserRole) => CompanyUserRole[];
1914
1912
  declare const normalizeCompanyId: (id: string) => string;
1915
1913
  declare const normalizeNidKey: (value: keyof NonNullable<ClientIdentity["nid"]>) => string;
1916
1914
  declare const parseClientName: ({ firstName, middleName, lastName, }: Pick<ClientIdentity, "firstName" | "middleName" | "lastName">) => string;
@@ -1920,4 +1918,4 @@ declare function createNotifId(options?: {
1920
1918
  to: string;
1921
1919
  }): string;
1922
1920
 
1923
- 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, healthcareProviderRoles, industries, normalizeCompanyId, normalizeNidKey, parseClientName, paymentMethods, scheduleAppointment, serviceProviders, tiers, vitalKeys };
1921
+ export { type AcceptedCurrency, AlphaNumeric, AppointmentDetails, type AppointmentDistAlg, AppointmentSeverity, COMPANY_USER_RELATIONSHIP, ClientForm, ClientIdentity, CompanyBilling, CompanyDetails, CompanyIdentity, CompanyInviteList, CompanyNotifications, 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, 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
@@ -9,10 +9,6 @@ var companyUserRoles = z.enum([
9
9
  "founder"
10
10
  // "admin",
11
11
  ]);
12
- var companyPartnerRoles = companyUserRoles.extract([
13
- "doc",
14
- "physAsst"
15
- ]);
16
12
  var employeeRoles = companyUserRoles.exclude(["founder"]);
17
13
  var adminRoles = companyUserRoles.extract(["founder"]);
18
14
  var healthcareProviderRoles = companyUserRoles.extract([
@@ -511,9 +507,7 @@ var findConflictingPartners = (...partners) => {
511
507
  const conflicts = [];
512
508
  if (!partners) return partners;
513
509
  for (const partner of partners) {
514
- if (!partner.roles || partner.roles.some(
515
- (r) => !companyPartnerRoles.options.includes(r)
516
- ) || !CompanyUser.shape.roles.safeParse(partner.roles).success) {
510
+ if (!partner.roles || partner.roles.some((r) => !(r in COMPANY_USER_RELATIONSHIP))) {
517
511
  conflicts.push(partner);
518
512
  continue;
519
513
  }
@@ -527,13 +521,15 @@ var findConflictingPartners = (...partners) => {
527
521
  return conflicts.length === 0 ? null : conflicts;
528
522
  };
529
523
  var getCompatibleRoles = (role) => {
530
- if (role === "physAsst") {
531
- return companyUserRoles.exclude([...adminRoles.options, "doc", role]).options;
532
- }
533
- if (adminRoles.safeParse(role).success || role === "doc") {
534
- return companyUserRoles.exclude(["physAsst", role]).options;
535
- }
536
- return companyUserRoles.exclude([role]).options;
524
+ return companyUserRoles.options.filter(
525
+ (r) => !COMPANY_USER_RELATIONSHIP[role]?.includes(r)
526
+ );
527
+ };
528
+ var getIncompatibleRoles = (role) => {
529
+ const compatibleRoles = getCompatibleRoles(role);
530
+ return companyUserRoles.options.filter(
531
+ (r) => !compatibleRoles.includes(r) && r !== role
532
+ );
537
533
  };
538
534
  var normalizeCompanyId = (id) => {
539
535
  return id.split("-").map((value) => upperFirst2(value.toLowerCase())).join(" ");
@@ -551,6 +547,10 @@ var parseClientName = ({
551
547
  }) => [firstName, middleName[0] + ".", lastName].join(" ");
552
548
 
553
549
  // src/schemas/company/components/User.ts
550
+ var COMPANY_USER_RELATIONSHIP = {
551
+ doc: ["physAsst"],
552
+ physAsst: ["doc"]
553
+ };
554
554
  var CompanyUserSession = z15.object({
555
555
  _id: z15.uuidv4(),
556
556
  user: UserDetails.pick({ _id: true, name: true, email: true }),
@@ -572,8 +572,8 @@ var CompanyUserSession = z15.object({
572
572
  }
573
573
  return newRoles.sort();
574
574
  }).refine((roles) => {
575
- return roles.every(
576
- (role, i) => i === 0 || getCompatibleRoles(roles[0]).includes(role)
575
+ return !roles.find(
576
+ (role) => getIncompatibleRoles(role).some((r) => roles.includes(r))
577
577
  );
578
578
  }, "A user is not allowed to have conflicting roles."),
579
579
  ttl: z15.number(),
@@ -594,7 +594,7 @@ var MiniCompanyUser2 = z15.object({
594
594
  inviteSent: Timestamp.nullish(),
595
595
  inviteAccepted: Timestamp.nullable()
596
596
  });
597
- var CompanyUser = z15.object({
597
+ var CompanyUser2 = z15.object({
598
598
  ...MiniCompanyUser2.shape,
599
599
  ...CompanyUserSession.shape.user.shape,
600
600
  // Only true when the user's data is retrieved from the session pool
@@ -614,15 +614,15 @@ var MiniRawCompanyStaff = z16.object({
614
614
  * @relationship one -> many
615
615
  *@description A map of doctor `uids` to their assistants `uids` */
616
616
  partnerMap: z16.record(
617
- CompanyUser.shape._id,
618
- z16.record(CompanyUser.shape._id, z16.object({ addedAt: Timestamp }))
617
+ CompanyUser2.shape._id,
618
+ z16.record(CompanyUser2.shape._id, z16.object({ addedAt: Timestamp }))
619
619
  ),
620
620
  updateQueue: z16.record(
621
- CompanyUser.shape._id,
621
+ CompanyUser2.shape._id,
622
622
  z16.object({
623
623
  $REMOVE: z16.object({ addedAt: Timestamp }),
624
624
  $CHANGE_ROLES: z16.object({
625
- newRoles: CompanyUser.shape.roles,
625
+ newRoles: CompanyUser2.shape.roles,
626
626
  addedAt: Timestamp
627
627
  })
628
628
  }).partial()
@@ -632,7 +632,7 @@ var MiniRawCompanyStaff = z16.object({
632
632
  });
633
633
  var RawCompanyStaff = z16.object({
634
634
  ...MiniRawCompanyStaff.shape,
635
- members: z16.record(CompanyUser.shape._id, CompanyUser.omit({ _id: true }))
635
+ members: z16.record(CompanyUser2.shape._id, CompanyUser2.omit({ _id: true }))
636
636
  });
637
637
  var transformStaff = (object17) => {
638
638
  return object17.transform((d) => {
@@ -714,8 +714,8 @@ var MutableCompanyDetails = z17.object({
714
714
  // src/schemas/company/utils/InviteList.ts
715
715
  import * as z18 from "zod";
716
716
  var CompanyInviteList = z18.record(
717
- CompanyUser.shape.email,
718
- z18.object({ createdAt: Timestamp, roles: CompanyUser.shape.roles })
717
+ CompanyUser2.shape.email,
718
+ z18.object({ createdAt: Timestamp, roles: CompanyUser2.shape.roles })
719
719
  ).refine(
720
720
  (data) => Object.keys(data).length > 0,
721
721
  "Insufficient amount of members invited."
@@ -805,7 +805,7 @@ var calcPriceMod = (mods, subtotal) => {
805
805
  // src/schemas/appointment/Appointment.ts
806
806
  var TimelineActivity = z21.object({
807
807
  postedAt: Timestamp.nullish(),
808
- userUid: CompanyUser.shape._id.nonoptional()
808
+ userUid: CompanyUser2.shape._id.nonoptional()
809
809
  });
810
810
  var AppointmentSeverity = z21.object({
811
811
  "1": z21.literal("Emergency"),
@@ -905,7 +905,7 @@ var MutableAppointmentDetails = AppointmentDetails.safeExtend(
905
905
  );
906
906
  var ScheduleAppointmentForm = z21.object({
907
907
  clientId: ClientIdentity.shape._id,
908
- serviceProviderId: CompanyUser.shape._id.or(z21.literal("next")),
908
+ serviceProviderId: CompanyUser2.shape._id.or(z21.literal("next")),
909
909
  category: AppointmentDetails.shape.severity,
910
910
  appointmentReason: AppointmentDetails.shape.reason,
911
911
  charges: AppointmentDetails.shape.charges.optional(),
@@ -1116,6 +1116,7 @@ export {
1116
1116
  AlphaNumeric,
1117
1117
  AppointmentDetails,
1118
1118
  AppointmentSeverity,
1119
+ COMPANY_USER_RELATIONSHIP,
1119
1120
  ClientForm,
1120
1121
  ClientIdentity,
1121
1122
  CompanyBilling,
@@ -1126,7 +1127,7 @@ export {
1126
1127
  CompanyPreferences,
1127
1128
  CompanyStaff,
1128
1129
  CompanyState,
1129
- CompanyUser,
1130
+ CompanyUser2 as CompanyUser,
1130
1131
  CompanyUserSession,
1131
1132
  CreateCompanyForm,
1132
1133
  CreditCurrency,
@@ -1164,7 +1165,6 @@ export {
1164
1165
  appointmentDistAlgs,
1165
1166
  calcBalance,
1166
1167
  calcPriceMod,
1167
- companyPartnerRoles,
1168
1168
  companyServiceSelectors,
1169
1169
  companyUserRoles,
1170
1170
  createNotifId,
@@ -1174,6 +1174,7 @@ export {
1174
1174
  findNextAvailableStaff,
1175
1175
  genders,
1176
1176
  getCompatibleRoles,
1177
+ getIncompatibleRoles,
1177
1178
  healthcareProviderRoles,
1178
1179
  industries,
1179
1180
  normalizeCompanyId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bizmap/sdk",
3
- "version": "0.0.107",
3
+ "version": "0.0.109",
4
4
  "main": "./dist/main.js",
5
5
  "types": "./dist/main.d.ts",
6
6
  "type": "module",