@bizmap/sdk 0.0.115 → 0.0.117

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 +206 -253
  2. package/dist/main.js +76 -96
  3. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -75,7 +75,7 @@ var Timestamp = z5.iso.datetime();
75
75
  var InviteResponse = z5.enum(["accepted", "declined"]);
76
76
  var TimeLog = z5.object({
77
77
  createdAt: Timestamp.readonly(),
78
- lastModified: Timestamp.nullish()
78
+ lastModified: Timestamp.optional()
79
79
  });
80
80
  var TicketNo = z5.int().positive().refine(
81
81
  (t) => t.toString().length <= 10,
@@ -145,26 +145,25 @@ var CompanyState = z7.object({
145
145
  }),
146
146
  credits: z7.object({
147
147
  current: z7.number(),
148
- lastModified: Timestamp.nullable()
148
+ lastModified: Timestamp.optional()
149
149
  }),
150
150
  maxStaff: z7.object({
151
151
  current: z7.int().min(1),
152
- lastModified: Timestamp.nullable()
152
+ lastModified: Timestamp.optional()
153
153
  }),
154
154
  usedStorageInBytes: z7.object({
155
155
  current: z7.number(),
156
- lastModified: Timestamp.nullable()
156
+ lastModified: Timestamp.optional()
157
157
  }),
158
158
  /** Data retention period in months */
159
- drpInMonths: z7.int().min(1),
159
+ // drpInMonths: z.int().min(1),
160
160
  /** A counter for the company's invoice no.
161
161
  * @note This should only be null when the cycle resets
162
162
  */
163
163
  invoiceNoCounter: z7.int().min(1),
164
164
  /** A counter for the company's ticket no. */
165
165
  tktNoCounter: z7.int().min(1),
166
- lastSavedAt: Timestamp.nullable(),
167
- lastModified: Timestamp.nullable(),
166
+ lastModified: Timestamp.optional(),
168
167
  version: Version,
169
168
  createdAt: Timestamp
170
169
  });
@@ -190,7 +189,7 @@ var CompanyBilling = z8.object({
190
189
  }
191
190
  }),
192
191
  version: Version,
193
- lastModified: Timestamp.nullable()
192
+ lastModified: Timestamp.optional()
194
193
  });
195
194
  var MutableCompanyBilling = CompanyBilling.omit({
196
195
  uid: true,
@@ -216,9 +215,7 @@ var getInvalidSectorError = (industry, sector) => `Invalid sector: "${sector}" i
216
215
  // src/schemas/company/components/Identity.ts
217
216
  var CompanyIdentity = z10.object({
218
217
  _id: CompanyState.shape._id,
219
- alias: z10.string().trim().min(3).max(63).transform(
220
- (data) => data.replace(/[^a-z1-9 ]/gi, "").replace(/\s+/g, " ")
221
- ).superRefine((data, ctx) => {
218
+ alias: z10.string().trim().min(3).max(63).transform((data) => data.replace(/\s+/g, " ")).superRefine((data, ctx) => {
222
219
  const invalidCharIdx = data.search(/[^a-z1-9 ]/i);
223
220
  if (invalidCharIdx >= 0) {
224
221
  ctx.addIssue(
@@ -227,18 +224,18 @@ var CompanyIdentity = z10.object({
227
224
  }
228
225
  }),
229
226
  address: Address.optional(),
230
- logo: z10.string().nullish(),
227
+ logo: z10.string().optional(),
231
228
  industry: CompanyIndustry.keyof().readonly(),
232
229
  sector: z10.string(),
233
230
  contact: z10.object({
234
- email: z10.email().max(25),
231
+ email: z10.email().max(45),
235
232
  phoneNumber: PhoneNumber.optional(),
236
233
  emailVerified: z10.boolean()
237
234
  }),
238
235
  // Can only be changed by the server
239
236
  tier: z10.object({
240
237
  current: tiers,
241
- lastModified: Timestamp.nullable()
238
+ lastModified: Timestamp.optional()
242
239
  }),
243
240
  isVerified: z10.boolean(),
244
241
  legal: z10.object({
@@ -248,7 +245,7 @@ var CompanyIdentity = z10.object({
248
245
  gctRegNo: z10.string().max(15).nullish()
249
246
  }).optional(),
250
247
  version: Version,
251
- lastModified: Timestamp.nullable()
248
+ lastModified: Timestamp.optional()
252
249
  }).superRefine((data, ctx) => {
253
250
  const hasLegalInfo = "legal" in data;
254
251
  if (data.isVerified && !hasLegalInfo) {
@@ -403,10 +400,10 @@ var CompanyPreferences = z13.object({
403
400
  * @property RR (Round Robin): Even distribution.
404
401
  * @property LOR (Least Outstanding Requests): Distribute based on availability.
405
402
  */
406
- apptDistAlg: appointmentDistAlgs.default("RR"),
403
+ apptDistAlg: appointmentDistAlgs,
407
404
  servicesDeployed: z13.boolean(),
408
405
  version: Version,
409
- lastModified: Timestamp.nullable()
406
+ lastModified: Timestamp.optional()
410
407
  }).refine(
411
408
  (data) => !data.enforcePaidAppointments || data.enforcePaidAppointments && data.serviceSelector === "scheduler",
412
409
  'Enforcing paid appointments is only allowed when the service selector is the "scheduler".'
@@ -451,13 +448,13 @@ var UserDetails = z14.object({
451
448
  });
452
449
  }),
453
450
  email: UserModel.shape.email,
454
- publicKey: z14.string().nullable(),
451
+ publicKey: z14.string().optional(),
455
452
  // notifications: z.array(Notification),
456
453
  version: Version.default(1),
457
454
  lastSignedIn: z14.object({
458
455
  auto: Timestamp,
459
456
  manual: Timestamp
460
- }).partial(),
457
+ }).partial().optional(),
461
458
  companyUids: z14.array(CompanyState.shape._id).min(1).optional(),
462
459
  // resumeToken: z.uuidv4().optional(),
463
460
  ...TimeLog.shape
@@ -508,7 +505,7 @@ var ClientIdentity = UserDetails.pick({
508
505
  }).partial().refine(
509
506
  (data) => Object.keys(data).length > 0,
510
507
  "At least (1) attribute must be defined."
511
- ),
508
+ ).optional(),
512
509
  address: Address2.optional(),
513
510
  linkedTo: UserDetails.shape._id.optional()
514
511
  }).shape
@@ -578,11 +575,11 @@ var CompanyUserSession = z16.object({
578
575
  deviceId: z16.string().trim().min(15),
579
576
  isAvailable: z16.object({
580
577
  value: z16.boolean(),
581
- lastModified: Timestamp.nullable()
578
+ lastModified: Timestamp.optional()
582
579
  }),
583
580
  isBusy: z16.object({
584
581
  value: z16.boolean(),
585
- lastModified: Timestamp.nullable()
582
+ lastModified: Timestamp.optional()
586
583
  }),
587
584
  appointments: z16.record(z16.literal(["ongoing", "completed"]), z16.int().min(0)),
588
585
  roles: z16.array(companyUserRoles).transform((roles) => {
@@ -597,7 +594,7 @@ var CompanyUserSession = z16.object({
597
594
  );
598
595
  }, "A user is not allowed to have conflicting roles."),
599
596
  ttl: z16.number(),
600
- lastModified: Timestamp.nullable(),
597
+ lastModified: Timestamp.optional(),
601
598
  expiresAfter: z16.date()
602
599
  });
603
600
  var MiniCompanyUser2 = z16.object({
@@ -610,9 +607,9 @@ var MiniCompanyUser2 = z16.object({
610
607
  appointments: true
611
608
  }).shape,
612
609
  /** The time before the company session gets deleted */
613
- lastActive: Timestamp.nullable(),
614
- inviteSent: Timestamp.nullish(),
615
- inviteAccepted: Timestamp.nullable()
610
+ lastActive: Timestamp.optional(),
611
+ inviteSent: Timestamp.optional(),
612
+ inviteAccepted: Timestamp.optional()
616
613
  });
617
614
  var CompanyUser2 = z16.object({
618
615
  ...MiniCompanyUser2.shape,
@@ -648,14 +645,14 @@ var MiniRawCompanyStaff = z17.object({
648
645
  }).partial()
649
646
  ),
650
647
  version: Version,
651
- lastModified: Timestamp.nullable()
648
+ lastModified: Timestamp.optional()
652
649
  });
653
650
  var RawCompanyStaff = z17.object({
654
651
  ...MiniRawCompanyStaff.shape,
655
652
  members: z17.record(CompanyUser2.shape._id, CompanyUser2.omit({ _id: true }))
656
653
  });
657
- var transformStaff = (object18) => {
658
- return object18.transform((d) => {
654
+ var transformStaff = (object17) => {
655
+ return object17.transform((d) => {
659
656
  const copy = structuredClone(d);
660
657
  for (const uid of Object.keys(copy.updateQueue)) {
661
658
  if (uid in copy.members) {
@@ -731,19 +728,9 @@ var MutableCompanyDetails = z18.object({
731
728
  staff: MutableCompanyStaff.partial().optional()
732
729
  });
733
730
 
734
- // src/schemas/company/utils/InviteList.ts
735
- import * as z19 from "zod";
736
- var CompanyInviteList = z19.record(
737
- CompanyUser2.shape.email,
738
- z19.object({ createdAt: Timestamp, roles: CompanyUser2.shape.roles })
739
- ).refine(
740
- (data) => Object.keys(data).length > 0,
741
- "Insufficient amount of members invited."
742
- );
743
-
744
731
  // src/schemas/company/utils/CreateCompanyForm.ts
745
- import * as z20 from "zod";
746
- var CreateCompanyForm = z20.object({
732
+ import * as z19 from "zod";
733
+ var CreateCompanyForm = z19.object({
747
734
  _id: CompanyIdentity.shape._id,
748
735
  alias: CompanyIdentity.shape.alias.optional(),
749
736
  logo: CompanyIdentity.shape.logo.optional(),
@@ -751,11 +738,6 @@ var CreateCompanyForm = z20.object({
751
738
  industry: CompanyIdentity.shape.industry,
752
739
  sector: CompanyIdentity.shape.sector,
753
740
  address: CompanyIdentity.shape.address.nonoptional()
754
- }).transform((data) => {
755
- if (!("alias" in data)) {
756
- data.alias = normalizeCompanyId(data._id);
757
- }
758
- return data;
759
741
  }).superRefine((data, ctx) => {
760
742
  if (!CompanyIndustry.shape[data.industry].safeParse(data.sector).success) {
761
743
  ctx.addIssue(getInvalidSectorError(data.industry, data.sector));
@@ -763,35 +745,35 @@ var CreateCompanyForm = z20.object({
763
745
  });
764
746
 
765
747
  // src/schemas/appointment/components/Medical.ts
766
- import * as z21 from "zod";
767
- var Vitals = z21.record(
748
+ import * as z20 from "zod";
749
+ var Vitals = z20.record(
768
750
  vitalKeys,
769
- z21.object({
770
- value: z21.string().trim().regex(/^\d{0,3}((\/|\.)\d{1,3})?/),
751
+ z20.object({
752
+ value: z20.string().trim().regex(/^\d{0,3}((\/|\.)\d{1,3})?/),
771
753
  lastModified: Timestamp.nullable()
772
754
  })
773
755
  );
774
- var Medicine = z21.object({
775
- brand: z21.string().trim(),
756
+ var Medicine = z20.object({
757
+ brand: z20.string().trim(),
776
758
  expiresAt: Timestamp.nullish(),
777
- quantity: z21.string().trim().regex(/^\d+(\.\d{1,3})? ?[a-zA-Z]{1,20}/, {
759
+ quantity: z20.string().trim().regex(/^\d+(\.\d{1,3})? ?[a-zA-Z]{1,20}/, {
778
760
  error: "Failed to match the pattern <number>+(.<number>{1,3})? ?[a-zA-Z]{1,20}"
779
761
  }),
780
- refills: z21.string().trim().regex(/^[0-8]/, { error: "Must be between 0 and 8" }),
781
- directions: z21.string().trim().max(100, { error: "Must be 100 characters or less" }),
762
+ refills: z20.string().trim().regex(/^[0-8]/, { error: "Must be between 0 and 8" }),
763
+ directions: z20.string().trim().max(100, { error: "Must be 100 characters or less" }),
782
764
  ...TimeLog.shape
783
765
  });
784
- var MedicalDetails = z21.object({
766
+ var MedicalDetails = z20.object({
785
767
  vitals: Vitals,
786
- prescriptions: z21.array(z21.array(Medicine)).nullish(),
787
- doctorNote: z21.object({
788
- value: z21.string(),
768
+ prescriptions: z20.array(z20.array(Medicine)).nullish(),
769
+ doctorNote: z20.object({
770
+ value: z20.string(),
789
771
  lastModified: Timestamp.nullable()
790
772
  }),
791
- physAsstNotes: z21.array(
792
- z21.object({
793
- title: z21.string(),
794
- content: z21.string(),
773
+ physAsstNotes: z20.array(
774
+ z20.object({
775
+ title: z20.string(),
776
+ content: z20.string(),
795
777
  ...TimeLog.shape
796
778
  })
797
779
  ).optional()
@@ -799,7 +781,7 @@ var MedicalDetails = z21.object({
799
781
 
800
782
  // src/schemas/appointment/Appointment.ts
801
783
  import { sumOf as sumOf2 } from "@wavy/fn";
802
- import * as z22 from "zod";
784
+ import * as z21 from "zod";
803
785
 
804
786
  // src/functions/calc.ts
805
787
  import { sumOf } from "@wavy/fn";
@@ -828,26 +810,26 @@ var calcPriceMod = (mods, subtotal) => {
828
810
  };
829
811
 
830
812
  // src/schemas/appointment/Appointment.ts
831
- var TimelineActivity = z22.object({
813
+ var TimelineActivity = z21.object({
832
814
  postedAt: Timestamp.nullish(),
833
815
  userUid: CompanyUser2.shape._id.nonoptional()
834
816
  });
835
- var AppointmentSeverity = z22.object({
836
- "1": z22.literal("Emergency"),
837
- "2": z22.literal("Important"),
838
- "3": z22.literal("Average")
817
+ var AppointmentSeverity = z21.object({
818
+ "1": z21.literal("Emergency"),
819
+ "2": z21.literal("Important"),
820
+ "3": z21.literal("Average")
839
821
  });
840
- var MiniAppointmentDetails = z22.object({
822
+ var MiniAppointmentDetails = z21.object({
841
823
  /** A random uid that identifies the document. */
842
- _id: z22.uuidv4(),
824
+ _id: z21.uuidv4(),
843
825
  // This helps to identify the urgency of the appointment
844
- severity: z22.string().refine((data) => AppointmentSeverity.keyof().safeParse(data).success),
826
+ severity: z21.string().refine((data) => AppointmentSeverity.keyof().safeParse(data).success),
845
827
  /** The company's uid */
846
828
  src: CompanyState.shape._id,
847
829
  /** The ticket number */
848
830
  tkt: TicketNo,
849
831
  /**The reason for the service */
850
- reason: z22.object({
832
+ reason: z21.object({
851
833
  value: Reason.shape.value,
852
834
  ...TimeLog.shape
853
835
  }),
@@ -864,23 +846,23 @@ var MiniAppointmentDetails = z22.object({
864
846
  "Expected no more than (20) charges."
865
847
  ),
866
848
  /**Required to calculate the accurate grandTotal of the charges */
867
- additionalFees: CompanyBilling.shape.additionalFees.nullish(),
849
+ additionalFees: CompanyBilling.shape.additionalFees.optional(),
868
850
  /**Required to calculate the accurate grandTotal of the charges */
869
- discounts: CompanyBilling.shape.discounts.nullish(),
870
- prepayments: CompanyBilling.shape.prepayments.nullish(),
871
- payments: z22.array(PaymentDetails).max(100).nullish(),
851
+ discounts: CompanyBilling.shape.discounts.optional(),
852
+ prepayments: CompanyBilling.shape.prepayments.optional(),
853
+ payments: z21.array(PaymentDetails).max(100).optional(),
872
854
  /** The client's identity */
873
855
  clientUid: ClientIdentity.shape._id,
874
856
  /**
875
857
  * Data that is specific to the entity (for now it's just medical data).
876
858
  * It will only be defined for the participants that have access to it.
877
859
  */
878
- payload: z22.object({
860
+ payload: z21.object({
879
861
  ...MedicalDetails.shape,
880
- lastModified: z22.number().nullable()
881
- }).nullish(),
862
+ lastModified: z21.number().nullable()
863
+ }).optional(),
882
864
  /** Only defined when either the service provider or the client cancelled their appointment */
883
- cancelled: z22.object({
865
+ cancelled: z21.object({
884
866
  /** The time that the confirm cancel button was clicked */
885
867
  doneAt: Timestamp,
886
868
  reason: Reason,
@@ -890,16 +872,16 @@ var MiniAppointmentDetails = z22.object({
890
872
  // paymentDueDate: Timestamp.nullish(),
891
873
  // The user that is currently modifying the appointment
892
874
  lockedBy: UserDetails.shape._id.optional(),
893
- timeline: z22.object({
875
+ timeline: z21.object({
894
876
  scheduler: TimelineActivity,
895
- physAsst: TimelineActivity.or(z22.literal("none")),
877
+ physAsst: TimelineActivity.or(z21.literal("none")),
896
878
  doctor: TimelineActivity,
897
879
  // Array used to accurately record payments made by the "a/r" and the "cshr"
898
- debtCollector: z22.array(
899
- z22.object({
880
+ debtCollector: z21.array(
881
+ z21.object({
900
882
  ...TimelineActivity.shape,
901
883
  // Payment uid -> collection time
902
- collectedPayments: z22.record(z22.uuidv4(), Timestamp)
884
+ collectedPayments: z21.record(z21.uuidv4(), Timestamp)
903
885
  })
904
886
  ).min(1).nullable()
905
887
  }),
@@ -918,19 +900,19 @@ var MiniAppointmentDetails = z22.object({
918
900
  });
919
901
  var AppointmentDetails = MiniAppointmentDetails.omit({
920
902
  clientUid: true
921
- }).extend(z22.object({ client: ClientIdentity }).shape);
903
+ }).extend(z21.object({ client: ClientIdentity }).shape);
922
904
  var MutableAppointmentDetails = AppointmentDetails.safeExtend(
923
- z22.object({
905
+ z21.object({
924
906
  /**
925
907
  * @description An encrypted copy of the last state of the appointment.
926
908
  * @note Used to accurately update the appointment without having to query the database
927
909
  */
928
- _hash: z22.string()
910
+ _hash: z21.string()
929
911
  }).shape
930
912
  );
931
- var ScheduleAppointmentForm = z22.object({
913
+ var ScheduleAppointmentForm = z21.object({
932
914
  clientId: ClientIdentity.shape._id,
933
- serviceProviderId: CompanyUser2.shape._id.or(z22.literal("next")),
915
+ serviceProviderId: CompanyUser2.shape._id.or(z21.literal("next")),
934
916
  category: AppointmentDetails.shape.severity,
935
917
  appointmentReason: AppointmentDetails.shape.reason,
936
918
  charges: AppointmentDetails.shape.charges.optional(),
@@ -940,7 +922,7 @@ var ScheduleAppointmentForm = z22.object({
940
922
  });
941
923
 
942
924
  // src/functions/scheduleAppointment.ts
943
- import { findChanges, omit, TODO } from "@wavy/fn";
925
+ import { findChanges, omit, omitNils, TODO } from "@wavy/fn";
944
926
  import { v4 } from "uuid";
945
927
 
946
928
  // src/functions/findAvailableStaff.ts
@@ -1077,7 +1059,7 @@ async function scheduleAppointment(request) {
1077
1059
  staffDetailsCopy.members[selectedPhysAsst].appointments.ongoing++;
1078
1060
  }
1079
1061
  staffDetailsCopy.lastModified = today;
1080
- const appointment = {
1062
+ const appointment = omitNils({
1081
1063
  _id: v4(),
1082
1064
  src: stateCopy._id,
1083
1065
  tkt: request.state.tktNoCounter,
@@ -1098,7 +1080,6 @@ async function scheduleAppointment(request) {
1098
1080
  charges: request.preferences.serviceSelector === "scheduler" ? request.form?.charges ?? null : null,
1099
1081
  client: await request.findClient(request.form.clientId),
1100
1082
  _hash: "aa.aa.aa",
1101
- lastModified: null,
1102
1083
  timeline: {
1103
1084
  scheduler: { userUid: request.sender._id, postedAt: today },
1104
1085
  doctor: { userUid: selectedDoctor },
@@ -1110,7 +1091,7 @@ async function scheduleAppointment(request) {
1110
1091
  }
1111
1092
  },
1112
1093
  createdAt: today
1113
- };
1094
+ });
1114
1095
  appointment._hash = request.createHash(omit(appointment, ["_hash"]));
1115
1096
  return {
1116
1097
  updates: {
@@ -1148,7 +1129,6 @@ export {
1148
1129
  CompanyDetails,
1149
1130
  CompanyIdentity,
1150
1131
  CompanyIndustry,
1151
- CompanyInviteList,
1152
1132
  CompanyNotifications,
1153
1133
  CompanyPreferences,
1154
1134
  CompanyStaff,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bizmap/sdk",
3
- "version": "0.0.115",
3
+ "version": "0.0.117",
4
4
  "main": "./dist/main.js",
5
5
  "types": "./dist/main.d.ts",
6
6
  "type": "module",