@bizmap/sdk 0.0.74 → 0.0.76

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
@@ -815,6 +815,50 @@ declare const CompanyInviteList: z.ZodRecord<z.ZodEmail, z.ZodObject<{
815
815
  }, z.core.$strip>>;
816
816
  type CompanyInviteList = z.infer<typeof CompanyInviteList>;
817
817
 
818
+ declare const CreateCompanyForm: z.ZodPipe<z.ZodObject<{
819
+ type: z.ZodReadonly<z.ZodEnum<{
820
+ MEDICAL: "MEDICAL";
821
+ }>>;
822
+ address: z.ZodOptional<z.ZodObject<{
823
+ streetAddress: z.ZodString;
824
+ city: z.ZodOptional<z.ZodString>;
825
+ parish: z.ZodString;
826
+ country: z.ZodString;
827
+ }, z.core.$strip>>;
828
+ email: z.ZodEmail;
829
+ phoneNumber: z.ZodOptional<z.ZodString>;
830
+ domain: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
831
+ alias: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
832
+ picture: z.ZodOptional<z.ZodNullable<z.ZodString>>;
833
+ }, z.core.$strip>, z.ZodTransform<{
834
+ type: "MEDICAL";
835
+ email: string;
836
+ domain: string;
837
+ address?: {
838
+ streetAddress: string;
839
+ parish: string;
840
+ country: string;
841
+ city?: string | undefined;
842
+ } | undefined;
843
+ phoneNumber?: string | undefined;
844
+ alias?: string | undefined;
845
+ picture?: string | null | undefined;
846
+ }, {
847
+ type: "MEDICAL";
848
+ email: string;
849
+ domain: string;
850
+ address?: {
851
+ streetAddress: string;
852
+ parish: string;
853
+ country: string;
854
+ city?: string | undefined;
855
+ } | undefined;
856
+ phoneNumber?: string | undefined;
857
+ alias?: string | undefined;
858
+ picture?: string | null | undefined;
859
+ }>>;
860
+ type CreateCompanyForm = z.infer<typeof CreateCompanyForm>;
861
+
818
862
  declare const TierList: z.ZodRecord<z.ZodEnum<{
819
863
  basic: "basic";
820
864
  pro: "pro";
@@ -1000,6 +1044,8 @@ declare const UserDetails: z.ZodObject<{
1000
1044
  }, z.core.$strip>;
1001
1045
  createdAt: z.ZodInt;
1002
1046
  }, z.core.$strip>>;
1047
+ companyUids: z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
1048
+ resumeToken: z.ZodOptional<z.ZodUUID>;
1003
1049
  }, z.core.$strip>;
1004
1050
  type UserDetails = z.infer<typeof UserDetails>;
1005
1051
 
@@ -1011,6 +1057,8 @@ declare const ClientIdentity: z.ZodObject<{
1011
1057
  phoneNumber: z.ZodOptional<z.ZodString>;
1012
1058
  name: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
1013
1059
  photoUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1060
+ companyUids: z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
1061
+ resumeToken: z.ZodOptional<z.ZodUUID>;
1014
1062
  email: z.ZodOptional<z.ZodEmail>;
1015
1063
  dob: z.ZodOptional<z.ZodInt>;
1016
1064
  address: z.ZodOptional<z.ZodObject<{
@@ -1328,6 +1376,8 @@ declare const AppointmentDetails: z.ZodObject<{
1328
1376
  phoneNumber: z.ZodOptional<z.ZodString>;
1329
1377
  name: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
1330
1378
  photoUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1379
+ companyUids: z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
1380
+ resumeToken: z.ZodOptional<z.ZodUUID>;
1331
1381
  email: z.ZodOptional<z.ZodEmail>;
1332
1382
  dob: z.ZodOptional<z.ZodInt>;
1333
1383
  address: z.ZodOptional<z.ZodObject<{
@@ -1495,6 +1545,8 @@ declare const MutableAppointmentDetails: z.ZodObject<{
1495
1545
  phoneNumber: z.ZodOptional<z.ZodString>;
1496
1546
  name: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
1497
1547
  photoUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1548
+ companyUids: z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
1549
+ resumeToken: z.ZodOptional<z.ZodUUID>;
1498
1550
  email: z.ZodOptional<z.ZodEmail>;
1499
1551
  dob: z.ZodOptional<z.ZodInt>;
1500
1552
  address: z.ZodOptional<z.ZodObject<{
@@ -1697,6 +1749,8 @@ declare function scheduleAppointment(request: RequestParameter): Promise<{
1697
1749
  lastModified?: number | null | undefined;
1698
1750
  phoneNumber?: string | undefined;
1699
1751
  photoUrl?: string | null | undefined;
1752
+ companyUids?: string[] | undefined;
1753
+ resumeToken?: string | undefined;
1700
1754
  email?: string | undefined;
1701
1755
  dob?: number | undefined;
1702
1756
  address?: {
@@ -1800,10 +1854,11 @@ declare const findConflictingPartners: (...partners: (CompanyUser | MiniCompanyU
1800
1854
  * @returns {CompanyUserRole[]} The roles that are compatible with the selected role.
1801
1855
  * */
1802
1856
  declare const getCompatibleRoles: (role: CompanyUserRole) => CompanyUserRole[];
1857
+ declare const normalizeCompanyId: (id: string) => string;
1803
1858
 
1804
1859
  declare function createNotifId(options?: {
1805
1860
  from: string;
1806
1861
  to: string;
1807
1862
  }): string;
1808
1863
 
1809
- export { AppointmentDetails, type AppointmentDistAlg, ClientIdentity, CompanyBilling, CompanyDetails, CompanyIdentity, CompanyInviteList, CompanyNotifications, type CompanyPartnerRole, CompanyPreferences, type CompanyServiceSelector, CompanyStaff, CompanyState, type CompanyType, CompanyUser, type CompanyUserRole, CompanyUserSession, type CompanyUserStatus, 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, Version, Vitals, adminRoles, appointmentDistAlgs, companyPartnerRoles, companyServiceSelectors, companyTypes, companyUserRoles, companyUserStatus, createNotifId, employeeRoles, findAvailableStaff, findConflictingPartners, findNextAvailableStaff, getCompatibleRoles, healthcareProviderRoles, paymentMethods, scheduleAppointment, serviceProviders, tiers, vitalKeys };
1864
+ export { AppointmentDetails, type AppointmentDistAlg, ClientIdentity, CompanyBilling, CompanyDetails, CompanyIdentity, CompanyInviteList, CompanyNotifications, type CompanyPartnerRole, CompanyPreferences, type CompanyServiceSelector, CompanyStaff, CompanyState, type CompanyType, CompanyUser, type CompanyUserRole, CompanyUserSession, type CompanyUserStatus, CreateCompanyForm, 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, Version, Vitals, adminRoles, appointmentDistAlgs, companyPartnerRoles, companyServiceSelectors, companyTypes, companyUserRoles, companyUserStatus, createNotifId, employeeRoles, findAvailableStaff, findConflictingPartners, findNextAvailableStaff, getCompatibleRoles, healthcareProviderRoles, normalizeCompanyId, paymentMethods, scheduleAppointment, serviceProviders, tiers, vitalKeys };
package/dist/main.js CHANGED
@@ -112,12 +112,20 @@ var Receipts = z6.array(
112
112
  // src/schemas/company/components/State.ts
113
113
  import * as z7 from "zod";
114
114
  var CompanyState = z7.object({
115
- _id: z7.string().toLowerCase().trim().min(3).max(63).regex(/[a-z1-9\-]/).transform((data) => data.replace(/-+/g, "-").replace(/\s+/g, "")).superRefine((data, ctx) => {
116
- if (!/[a-z]/.test(data[0]) || !/[a-z]/.test(data[data.length - 1])) {
115
+ _id: z7.string().toLowerCase().trim().min(3).max(63).transform((data) => data.replace(/-+/g, "-").replace(/\s+/g, "")).superRefine((data, ctx) => {
116
+ const getTemplate = (subject) => `Invalid format: expected ${subject} character to be a letter.`;
117
+ const invalidCharIdx = data.search(/[^a-z1-9\-]/);
118
+ if (invalidCharIdx >= 0) {
117
119
  ctx.addIssue(
118
- "The first and last character of a company's name must be a letter."
120
+ `Invalid format: expected character to either be a "-" or a character between a-z or 1-9, but received " ${data[invalidCharIdx]} ".`
119
121
  );
120
122
  }
123
+ if (!/[a-z]/.test(data[0])) {
124
+ ctx.addIssue(getTemplate("first"));
125
+ }
126
+ if (!/[a-z]/.test(data[data.length - 1])) {
127
+ ctx.addIssue(getTemplate("last"));
128
+ }
121
129
  }),
122
130
  credits: z7.object({
123
131
  current: z7.number(),
@@ -188,9 +196,16 @@ import * as z9 from "zod";
188
196
  import { Address, PhoneNumber } from "@wavy/util";
189
197
  var CompanyIdentity = z9.object({
190
198
  _id: CompanyState.shape._id,
191
- alias: z9.string().trim().min(3).max(63).regex(/[a-z1-9 ]/gi).transform(
199
+ alias: z9.string().trim().min(3).max(63).transform(
192
200
  (data) => data.replace(/[^a-z1-9 ]/gi, "").replace(/\s+/g, " ")
193
- ),
201
+ ).superRefine((data, ctx) => {
202
+ const invalidCharIdx = data.search(/[^a-z1-9 ]/i);
203
+ if (invalidCharIdx >= 0) {
204
+ ctx.addIssue(
205
+ `Invalid format: expected a character between a-z or 1-9, but received " ${data[invalidCharIdx]} ".`
206
+ );
207
+ }
208
+ }),
194
209
  address: Address.optional(),
195
210
  logo: z9.string().nullish(),
196
211
  type: companyTypes.readonly(),
@@ -373,6 +388,7 @@ import * as z15 from "zod";
373
388
  import * as z14 from "zod";
374
389
 
375
390
  // src/functions/helper-functions.ts
391
+ import { upperFirst } from "@wavy/fn";
376
392
  var findConflictingPartners = (...partners) => {
377
393
  let hasSingleDoctor = false;
378
394
  const conflicts = [];
@@ -402,6 +418,9 @@ var getCompatibleRoles = (role) => {
402
418
  }
403
419
  return companyUserRoles.exclude([role]).options;
404
420
  };
421
+ var normalizeCompanyId = (id) => {
422
+ return id.split("-").map((value) => upperFirst(value.toLowerCase())).join(" ");
423
+ };
405
424
 
406
425
  // src/schemas/profiles/User.ts
407
426
  import { UserModel } from "@wavy/util";
@@ -427,6 +446,8 @@ var UserDetails = z13.object({
427
446
  publicKey: z13.string().nullable(),
428
447
  notifications: z13.array(Notification),
429
448
  version: Version,
449
+ companyUids: z13.array(CompanyState.shape._id).min(1).optional(),
450
+ resumeToken: z13.uuidv4().optional(),
430
451
  ...TimeLog.shape
431
452
  }).omit({ uid: true });
432
453
 
@@ -510,8 +531,8 @@ var RawCompanyStaff = z15.object({
510
531
  ...MiniRawCompanyStaff.shape,
511
532
  members: z15.record(CompanyUser.shape._id, CompanyUser.omit({ _id: true }))
512
533
  });
513
- var transformStaff = (object16) => {
514
- return object16.transform((d) => {
534
+ var transformStaff = (object17) => {
535
+ return object17.transform((d) => {
515
536
  const copy = structuredClone(d);
516
537
  for (const uid of Object.keys(copy.updateQueue)) {
517
538
  if (uid in copy.members) {
@@ -597,50 +618,66 @@ var CompanyInviteList = z17.record(
597
618
  "Insufficient amount of members invited."
598
619
  );
599
620
 
600
- // src/schemas/appointment/components/Medical.ts
621
+ // src/schemas/company/utils/CreateCompanyForm.ts
601
622
  import * as z18 from "zod";
602
- var Vitals = z18.record(
623
+ var CreateCompanyForm = z18.object({
624
+ domain: CompanyIdentity.shape._id,
625
+ alias: CompanyIdentity.shape.alias.optional(),
626
+ picture: CompanyIdentity.shape.logo,
627
+ ...CompanyIdentity.shape.contact.pick({ email: true, phoneNumber: true }).shape,
628
+ type: CompanyIdentity.shape.type,
629
+ address: CompanyIdentity.shape.address
630
+ }).transform((data) => {
631
+ if (!("alias" in data)) {
632
+ data.alias = normalizeCompanyId(data.domain);
633
+ }
634
+ return data;
635
+ });
636
+
637
+ // src/schemas/appointment/components/Medical.ts
638
+ import * as z19 from "zod";
639
+ var Vitals = z19.record(
603
640
  vitalKeys,
604
- z18.object({
605
- value: z18.string().trim().regex(/^\d{0,3}((\/|\.)\d{1,3})?/),
641
+ z19.object({
642
+ value: z19.string().trim().regex(/^\d{0,3}((\/|\.)\d{1,3})?/),
606
643
  lastModified: Timestamp.nullable()
607
644
  })
608
645
  );
609
- var Medicine = z18.object({
610
- brand: z18.string().trim(),
646
+ var Medicine = z19.object({
647
+ brand: z19.string().trim(),
611
648
  expiresAt: Timestamp.nullish(),
612
- quantity: z18.string().trim().regex(/^\d+(\.\d{1,3})? ?[a-zA-Z]{1,20}/, {
649
+ quantity: z19.string().trim().regex(/^\d+(\.\d{1,3})? ?[a-zA-Z]{1,20}/, {
613
650
  error: "Failed to match the pattern <number>+(.<number>{1,3})? ?[a-zA-Z]{1,20}"
614
651
  }),
615
- refills: z18.string().trim().regex(/^[0-8]/, { error: "Must be between 0 and 8" }),
616
- directions: z18.string().trim().max(100, { error: "Must be 100 characters or less" }),
652
+ refills: z19.string().trim().regex(/^[0-8]/, { error: "Must be between 0 and 8" }),
653
+ directions: z19.string().trim().max(100, { error: "Must be 100 characters or less" }),
617
654
  ...TimeLog.shape
618
655
  });
619
- var MedicalDetails = z18.object({
656
+ var MedicalDetails = z19.object({
620
657
  vitals: Vitals,
621
- prescriptions: z18.array(z18.array(Medicine)).nullish(),
622
- doctorNote: z18.object({
623
- value: z18.string(),
658
+ prescriptions: z19.array(z19.array(Medicine)).nullish(),
659
+ doctorNote: z19.object({
660
+ value: z19.string(),
624
661
  lastModified: Timestamp.nullable()
625
662
  }),
626
- physAsstNotes: z18.array(
627
- z18.object({
628
- title: z18.string(),
629
- content: z18.string(),
663
+ physAsstNotes: z19.array(
664
+ z19.object({
665
+ title: z19.string(),
666
+ content: z19.string(),
630
667
  ...TimeLog.shape
631
668
  })
632
669
  ).optional()
633
670
  });
634
671
 
635
672
  // src/schemas/profiles/Client.ts
636
- import * as z19 from "zod";
673
+ import * as z20 from "zod";
637
674
  import { Address as Address2 } from "@wavy/util";
638
675
  var ClientIdentity = UserDetails.omit({
639
676
  notifications: true,
640
677
  publicKey: true,
641
678
  email: true
642
679
  }).safeExtend(
643
- z19.object({
680
+ z20.object({
644
681
  email: UserDetails.shape.email.optional(),
645
682
  dob: Timestamp.optional(),
646
683
  address: Address2.optional(),
@@ -649,20 +686,20 @@ var ClientIdentity = UserDetails.omit({
649
686
  );
650
687
 
651
688
  // src/schemas/appointment/Appointment.ts
652
- import * as z20 from "zod";
653
- var TimelineActivity = z20.object({
689
+ import * as z21 from "zod";
690
+ var TimelineActivity = z21.object({
654
691
  postedAt: Timestamp.nullish(),
655
692
  userUid: CompanyUser.shape._id.nonoptional()
656
693
  });
657
- var MiniAppointmentDetails = z20.object({
694
+ var MiniAppointmentDetails = z21.object({
658
695
  /** A random uid that identifies the document. */
659
- _id: z20.uuidv4(),
696
+ _id: z21.uuidv4(),
660
697
  /** The company's uid */
661
698
  src: CompanyState.shape._id,
662
699
  /** The ticket number */
663
700
  tkt: TicketNo,
664
701
  /**The reason for the service */
665
- reason: z20.object({
702
+ reason: z21.object({
666
703
  value: Reason.shape.value,
667
704
  ...TimeLog.shape
668
705
  }).optional(),
@@ -674,24 +711,24 @@ var MiniAppointmentDetails = z20.object({
674
711
  */
675
712
  invoiceNo: InvoiceNo.optional(),
676
713
  /** The services that the client has done/will do. */
677
- charges: z20.array(PriceTag.omit({ uid: true })).max(4),
714
+ charges: z21.array(PriceTag.omit({ uid: true })).max(4),
678
715
  /**Required to calculate the accurate grandTotal of the charges */
679
- additionalFees: z20.array(PriceAdjustment).nullable().readonly(),
716
+ additionalFees: z21.array(PriceAdjustment).nullable().readonly(),
680
717
  /**Required to calculate the accurate grandTotal of the charges */
681
- discounts: z20.array(PriceAdjustment).nullable().readonly(),
682
- prepayments: z20.array(PriceAdjustment).nullable(),
718
+ discounts: z21.array(PriceAdjustment).nullable().readonly(),
719
+ prepayments: z21.array(PriceAdjustment).nullable(),
683
720
  /** The client's identity */
684
721
  clientUid: ClientIdentity.shape._id,
685
722
  /**
686
723
  * Data that is specific to the entity (for now it's just medical data).
687
724
  * It will only be defined for the participants that have access to it.
688
725
  */
689
- payload: z20.object({
726
+ payload: z21.object({
690
727
  ...MedicalDetails.shape,
691
- lastModified: z20.number().nullable()
728
+ lastModified: z21.number().nullable()
692
729
  }).nullish(),
693
730
  /** Only defined when either the service provider or the client cancelled their appointment */
694
- cancelled: z20.object({
731
+ cancelled: z21.object({
695
732
  /** The time that the confirm cancel button was clicked */
696
733
  doneAt: Timestamp,
697
734
  reason: Reason,
@@ -699,16 +736,16 @@ var MiniAppointmentDetails = z20.object({
699
736
  }).optional(),
700
737
  /** Add this after consulting with company owners about payment expectations */
701
738
  // paymentDueDate: Timestamp.nullish(),
702
- payments: z20.array(
703
- z20.object({
739
+ payments: z21.array(
740
+ z21.object({
704
741
  method: paymentMethods,
705
- amount: z20.number().positive(),
742
+ amount: z21.number().positive(),
706
743
  ...TimeLog.shape
707
744
  })
708
745
  ).max(100).nullish(),
709
- timeline: z20.object({
746
+ timeline: z21.object({
710
747
  scheduler: TimelineActivity,
711
- physAsst: TimelineActivity.or(z20.literal("none")),
748
+ physAsst: TimelineActivity.or(z21.literal("none")),
712
749
  doctor: TimelineActivity,
713
750
  cashier: TimelineActivity.nullable()
714
751
  }),
@@ -716,17 +753,17 @@ var MiniAppointmentDetails = z20.object({
716
753
  });
717
754
  var AppointmentDetails = MiniAppointmentDetails.omit({
718
755
  clientUid: true
719
- }).extend(z20.object({ client: ClientIdentity }).shape);
756
+ }).extend(z21.object({ client: ClientIdentity }).shape);
720
757
  var MutableAppointmentDetails = AppointmentDetails.safeExtend(
721
- z20.object({
758
+ z21.object({
722
759
  /**
723
760
  * @description An encrypted copy of the last state of the appointment.
724
761
  * @note Used to accurately update the appointment without having to query the database
725
762
  */
726
- _hash: z20.string()
763
+ _hash: z21.string()
727
764
  }).shape
728
765
  );
729
- var ScheduleAppointmentForm = z20.object({
766
+ var ScheduleAppointmentForm = z21.object({
730
767
  clientUid: ClientIdentity.shape._id,
731
768
  /** A nullish value === next_available */
732
769
  serviceProviderUid: CompanyUser.shape._id.nullish(),
@@ -936,6 +973,7 @@ export {
936
973
  CompanyState,
937
974
  CompanyUser,
938
975
  CompanyUserSession,
976
+ CreateCompanyForm,
939
977
  CreditCurrency,
940
978
  InviteResponse,
941
979
  InvoiceNo,
@@ -976,6 +1014,7 @@ export {
976
1014
  findNextAvailableStaff,
977
1015
  getCompatibleRoles,
978
1016
  healthcareProviderRoles,
1017
+ normalizeCompanyId,
979
1018
  paymentMethods,
980
1019
  scheduleAppointment,
981
1020
  serviceProviders,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bizmap/sdk",
3
- "version": "0.0.74",
3
+ "version": "0.0.76",
4
4
  "main": "./dist/main.js",
5
5
  "types": "./dist/main.d.ts",
6
6
  "type": "module",