@bizmap/sdk 0.0.112 → 0.0.114

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 +13 -15
  2. package/dist/main.js +163 -144
  3. package/package.json +1 -1
package/dist/main.d.ts CHANGED
@@ -36,10 +36,6 @@ declare const companyServiceSelectors: z.ZodEnum<{
36
36
  doctor: "doctor";
37
37
  }>;
38
38
  type CompanyServiceSelector = z.infer<typeof companyServiceSelectors>;
39
- declare const industries: z.ZodEnum<{
40
- healthcare: "healthcare";
41
- }>;
42
- type Industry = z.infer<typeof industries>;
43
39
 
44
40
  declare const tiers: z.ZodEnum<{
45
41
  basic: "basic";
@@ -95,6 +91,7 @@ declare const CompanyDetails: z.ZodObject<{
95
91
  industry: z.ZodReadonly<z.ZodEnum<{
96
92
  healthcare: "healthcare";
97
93
  }>>;
94
+ sector: z.ZodString;
98
95
  contact: z.ZodObject<{
99
96
  email: z.ZodEmail;
100
97
  phoneNumber: z.ZodOptional<z.ZodString>;
@@ -287,11 +284,6 @@ declare const MutableCompanyDetails: z.ZodObject<{
287
284
  phoneNumber: z.ZodOptional<z.ZodString>;
288
285
  emailVerified: z.ZodBoolean;
289
286
  }, z.core.$strip>>;
290
- legal: z.ZodOptional<z.ZodOptional<z.ZodObject<{
291
- regNo: z.ZodReadonly<z.ZodString>;
292
- trn: z.ZodOptional<z.ZodNullable<z.ZodString>>;
293
- gctRegNo: z.ZodOptional<z.ZodNullable<z.ZodString>>;
294
- }, z.core.$strip>>>;
295
287
  }, z.core.$strip>>;
296
288
  preferences: z.ZodOptional<z.ZodObject<{
297
289
  version: z.ZodOptional<z.ZodInt>;
@@ -505,6 +497,7 @@ declare const CompanyIdentity: z.ZodObject<{
505
497
  industry: z.ZodReadonly<z.ZodEnum<{
506
498
  healthcare: "healthcare";
507
499
  }>>;
500
+ sector: z.ZodString;
508
501
  contact: z.ZodObject<{
509
502
  email: z.ZodEmail;
510
503
  phoneNumber: z.ZodOptional<z.ZodString>;
@@ -543,11 +536,6 @@ declare const MutableCompanyIdentity: z.ZodObject<{
543
536
  phoneNumber: z.ZodOptional<z.ZodString>;
544
537
  emailVerified: z.ZodBoolean;
545
538
  }, z.core.$strip>;
546
- legal: z.ZodOptional<z.ZodObject<{
547
- regNo: z.ZodReadonly<z.ZodString>;
548
- trn: z.ZodOptional<z.ZodNullable<z.ZodString>>;
549
- gctRegNo: z.ZodOptional<z.ZodNullable<z.ZodString>>;
550
- }, z.core.$strip>>;
551
539
  }, z.core.$strip>;
552
540
  type MutableCompanyIdentity = z.infer<typeof MutableCompanyIdentity>;
553
541
 
@@ -766,6 +754,7 @@ declare const CreateCompanyForm: z.ZodPipe<z.ZodObject<{
766
754
  industry: z.ZodReadonly<z.ZodEnum<{
767
755
  healthcare: "healthcare";
768
756
  }>>;
757
+ sector: z.ZodString;
769
758
  address: z.ZodNonOptional<z.ZodOptional<z.ZodObject<{
770
759
  streetAddress: z.ZodString;
771
760
  city: z.ZodOptional<z.ZodString>;
@@ -779,6 +768,7 @@ declare const CreateCompanyForm: z.ZodPipe<z.ZodObject<{
779
768
  logo: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
780
769
  }, z.core.$strip>, z.ZodTransform<{
781
770
  industry: "healthcare";
771
+ sector: string;
782
772
  address: {
783
773
  streetAddress: string;
784
774
  parish: string;
@@ -792,6 +782,7 @@ declare const CreateCompanyForm: z.ZodPipe<z.ZodObject<{
792
782
  logo?: string | null | undefined;
793
783
  }, {
794
784
  industry: "healthcare";
785
+ sector: string;
795
786
  address: {
796
787
  streetAddress: string;
797
788
  parish: string;
@@ -806,6 +797,13 @@ declare const CreateCompanyForm: z.ZodPipe<z.ZodObject<{
806
797
  }>>;
807
798
  type CreateCompanyForm = z.infer<typeof CreateCompanyForm>;
808
799
 
800
+ /** industry -> sectors */
801
+ declare const CompanyIndustry: z.ZodObject<{
802
+ healthcare: z.ZodEnum<{
803
+ medicalCare: "medicalCare";
804
+ }>;
805
+ }, z.core.$strip>;
806
+
809
807
  declare const TierList: z.ZodRecord<z.ZodEnum<{
810
808
  basic: "basic";
811
809
  pro: "pro";
@@ -1908,4 +1906,4 @@ declare function createNotifId(options?: {
1908
1906
  to: string;
1909
1907
  }): string;
1910
1908
 
1911
- 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 };
1909
+ export { type AcceptedCurrency, AlphaNumeric, AppointmentDetails, type AppointmentDistAlg, AppointmentSeverity, COMPANY_USER_RELATIONSHIP, ClientForm, ClientIdentity, CompanyBilling, CompanyDetails, CompanyIdentity, CompanyIndustry, CompanyInviteList, CompanyNotifications, CompanyPreferences, type CompanyServiceSelector, CompanyStaff, CompanyState, CompanyUser, type CompanyUserRole, CompanyUserSession, CreateCompanyForm, CreditCurrency, type EmployeeRole, type Gender, type HealthcareProviderRole, 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, normalizeCompanyId, normalizeNidKey, parseClientName, paymentMethods, scheduleAppointment, serviceProviders, tiers, vitalKeys };
package/dist/main.js CHANGED
@@ -17,10 +17,6 @@ var healthcareProviderRoles = companyUserRoles.extract([
17
17
  ]);
18
18
  var appointmentDistAlgs = z.enum(["RR", "LOR"]);
19
19
  var companyServiceSelectors = z.enum(["scheduler", "doctor"]);
20
- var industries = z.enum([
21
- "healthcare"
22
- // "Pharmaceutical",
23
- ]);
24
20
 
25
21
  // src/enums/Global.ts
26
22
  import { currencies } from "@wavy/util";
@@ -50,7 +46,7 @@ var serviceProviders = z4.enum([
50
46
  ]);
51
47
 
52
48
  // src/schemas/company/CompanyDetails.ts
53
- import * as z17 from "zod";
49
+ import * as z18 from "zod";
54
50
 
55
51
  // src/schemas/company/components/Billing.ts
56
52
  import * as z8 from "zod";
@@ -202,11 +198,25 @@ var MutableCompanyBilling = CompanyBilling.omit({
202
198
  });
203
199
 
204
200
  // src/schemas/company/components/Identity.ts
205
- import * as z9 from "zod";
201
+ import * as z10 from "zod";
206
202
  import { Address, PhoneNumber } from "@wavy/util";
207
- var CompanyIdentity = z9.object({
203
+
204
+ // src/schemas/company/utils/CompanyIndustry.ts
205
+ import * as z9 from "zod";
206
+ var CompanyIndustry = z9.object({
207
+ healthcare: z9.enum([
208
+ "medicalCare"
209
+ // "pharmaceuticals"
210
+ ])
211
+ });
212
+
213
+ // src/schemas/company/utils/utils.ts
214
+ var getInvalidSectorError = (industry, sector) => `Invalid sector: "${sector}" isn't a sector under the "${industry}" industry.`;
215
+
216
+ // src/schemas/company/components/Identity.ts
217
+ var CompanyIdentity = z10.object({
208
218
  _id: CompanyState.shape._id,
209
- alias: z9.string().trim().min(3).max(63).transform(
219
+ alias: z10.string().trim().min(3).max(63).transform(
210
220
  (data) => data.replace(/[^a-z1-9 ]/gi, "").replace(/\s+/g, " ")
211
221
  ).superRefine((data, ctx) => {
212
222
  const invalidCharIdx = data.search(/[^a-z1-9 ]/i);
@@ -217,24 +227,25 @@ var CompanyIdentity = z9.object({
217
227
  }
218
228
  }),
219
229
  address: Address.optional(),
220
- logo: z9.string().nullish(),
221
- industry: industries.readonly(),
222
- contact: z9.object({
223
- email: z9.email().max(25),
230
+ logo: z10.string().nullish(),
231
+ industry: CompanyIndustry.keyof().readonly(),
232
+ sector: z10.string(),
233
+ contact: z10.object({
234
+ email: z10.email().max(25),
224
235
  phoneNumber: PhoneNumber.optional(),
225
- emailVerified: z9.boolean()
236
+ emailVerified: z10.boolean()
226
237
  }),
227
238
  // Can only be changed by the server
228
- tier: z9.object({
239
+ tier: z10.object({
229
240
  current: tiers,
230
241
  lastModified: Timestamp.nullable()
231
242
  }),
232
- isVerified: z9.boolean(),
233
- legal: z9.object({
234
- regNo: z9.string().max(20).readonly(),
243
+ isVerified: z10.boolean(),
244
+ legal: z10.object({
245
+ regNo: z10.string().max(20).readonly(),
235
246
  // The company's registration number
236
- trn: z9.string().regex(/[0-9]{3}-[0-9]{3}-[0-9]{3}/).nullish(),
237
- gctRegNo: z9.string().max(15).nullish()
247
+ trn: z10.string().regex(/[0-9]{3}-[0-9]{3}-[0-9]{3}/).nullish(),
248
+ gctRegNo: z10.string().max(15).nullish()
238
249
  }).optional(),
239
250
  version: Version,
240
251
  lastModified: Timestamp.nullable()
@@ -245,44 +256,47 @@ var CompanyIdentity = z9.object({
245
256
  } else if (!data.isVerified && hasLegalInfo) {
246
257
  ctx.addIssue("Unverified companies can't have the legal field defined.");
247
258
  }
259
+ if (!CompanyIndustry.shape[data.industry].safeParse(data.sector).success) {
260
+ ctx.addIssue(getInvalidSectorError(data.industry, data.sector));
261
+ }
248
262
  });
249
263
  var MutableCompanyIdentity = CompanyIdentity.pick({
250
264
  address: true,
251
265
  contact: true,
252
266
  logo: true,
253
- legal: true,
267
+ // legal: true,
254
268
  alias: true
255
269
  });
256
270
 
257
271
  // src/schemas/company/components/Notifications.ts
258
- import * as z11 from "zod";
272
+ import * as z12 from "zod";
259
273
 
260
274
  // src/schemas/Global.ts
261
- import * as z10 from "zod";
275
+ import * as z11 from "zod";
262
276
 
263
277
  // src/constants.ts
264
278
  var NOTIF_ID_DELIM = "::";
265
279
  var MAX_NAME_LENGTH = 21;
266
280
 
267
281
  // src/schemas/Global.ts
268
- var TierList = z10.record(
282
+ var TierList = z11.record(
269
283
  tiers,
270
- z10.object({
271
- cost: z10.number().min(0),
272
- perks: z10.array(z10.string()).min(1)
284
+ z11.object({
285
+ cost: z11.number().min(0),
286
+ perks: z11.array(z11.string()).min(1)
273
287
  })
274
288
  ).superRefine((data, ctx) => {
275
289
  if (data.basic.cost !== 0) {
276
290
  ctx.addIssue("The basic tier must always cost $0.00");
277
291
  }
278
292
  });
279
- var Notification = z10.object({
280
- _id: z10.string().superRefine((data, ctx) => {
281
- const isUUidV4 = z10.uuidv4().safeParse(data).success;
293
+ var Notification = z11.object({
294
+ _id: z11.string().superRefine((data, ctx) => {
295
+ const isUUidV4 = z11.uuidv4().safeParse(data).success;
282
296
  if (isUUidV4) return;
283
297
  let [from, to, nonce] = data.split(NOTIF_ID_DELIM);
284
298
  nonce = nonce?.trim() || "";
285
- const parsedFrom = z10.uuidv4().or(z10.uuidv7()).safeParse(from);
299
+ const parsedFrom = z11.uuidv4().or(z11.uuidv7()).safeParse(from);
286
300
  if (!parsedFrom.success) {
287
301
  ctx.addIssue({
288
302
  code: "custom",
@@ -290,7 +304,7 @@ var Notification = z10.object({
290
304
  path: ["from"]
291
305
  });
292
306
  }
293
- const parsedTo = z10.uuidv4().safeParse(to);
307
+ const parsedTo = z11.uuidv4().safeParse(to);
294
308
  if (!parsedTo.success) {
295
309
  ctx.addIssue({
296
310
  code: "custom",
@@ -306,19 +320,19 @@ var Notification = z10.object({
306
320
  });
307
321
  }
308
322
  }),
309
- code: z10.literal([
323
+ code: z11.literal([
310
324
  "INVITE_RESPONSE",
311
325
  "COMPANY_INVITE",
312
326
  "DEV_MESSAGE",
313
327
  "ALERT"
314
328
  ]),
315
- payload: z10.string(),
316
- isArchived: z10.boolean().optional(),
317
- rcpt: z10.uuidv4().or(z10.uuidv7()).nullable(),
318
- src: z10.object({
319
- _id: z10.uuidv4().or(z10.uuidv7()),
320
- name: z10.string(),
321
- photoUrl: z10.string().nullish()
329
+ payload: z11.string(),
330
+ isArchived: z11.boolean().optional(),
331
+ rcpt: z11.uuidv4().or(z11.uuidv7()).nullable(),
332
+ src: z11.object({
333
+ _id: z11.uuidv4().or(z11.uuidv7()),
334
+ name: z11.string(),
335
+ photoUrl: z11.string().nullish()
322
336
  }),
323
337
  createdAt: Timestamp
324
338
  }).superRefine((data, ctx) => {
@@ -329,7 +343,7 @@ var Notification = z10.object({
329
343
  };
330
344
  switch (data.code) {
331
345
  case "COMPANY_INVITE":
332
- if (!z10.jwt().safeParse(data.payload).success) {
346
+ if (!z11.jwt().safeParse(data.payload).success) {
333
347
  ctx.addIssue("The payload of company invite must be a valid jwt.");
334
348
  }
335
349
  break;
@@ -350,32 +364,32 @@ var Notification = z10.object({
350
364
  return data.code;
351
365
  }
352
366
  });
353
- var CreditCurrency = z10.object({
354
- uid: z10.uuidv4(),
355
- cost: z10.object({ value: z10.number().min(0), currency: acceptedCurrencies }),
356
- value: z10.int().min(0),
367
+ var CreditCurrency = z11.object({
368
+ uid: z11.uuidv4(),
369
+ cost: z11.object({ value: z11.number().min(0), currency: acceptedCurrencies }),
370
+ value: z11.int().min(0),
357
371
  ...TimeLog.shape
358
372
  });
359
- var PaymentDetails = z10.object({
373
+ var PaymentDetails = z11.object({
360
374
  // Used to track the payments recorded by each paymentCollector
361
- uid: z10.uuidv4(),
375
+ uid: z11.uuidv4(),
362
376
  method: paymentMethods,
363
377
  currency: acceptedCurrencies,
364
- amount: z10.number().min(1),
378
+ amount: z11.number().min(1),
365
379
  // Rate chart id (used to identify the rate chart used to convert the amount )
366
380
  // rcid: z.uuidv4(),
367
381
  ...TimeLog.shape
368
382
  });
369
383
 
370
384
  // src/schemas/company/components/Notifications.ts
371
- var CompanyNotifications = z11.array(Notification).refine(
385
+ var CompanyNotifications = z12.array(Notification).refine(
372
386
  (data) => data.every((notif) => notif.code !== "COMPANY_INVITE"),
373
387
  "A company can't receive a company invite."
374
388
  );
375
389
 
376
390
  // src/schemas/company/components/Preferences.ts
377
- import * as z12 from "zod";
378
- var CompanyPreferences = z12.object({
391
+ import * as z13 from "zod";
392
+ var CompanyPreferences = z13.object({
379
393
  _id: CompanyState.shape._id,
380
394
  /** The user that's allowed to record the client's services. */
381
395
  serviceSelector: companyServiceSelectors,
@@ -384,13 +398,13 @@ var CompanyPreferences = z12.object({
384
398
  * @note
385
399
  * - only allowed when `serviceSelector === "scheduler"`
386
400
  * */
387
- enforcePaidAppointments: z12.boolean(),
401
+ enforcePaidAppointments: z13.boolean(),
388
402
  /**
389
403
  * @property RR (Round Robin): Even distribution.
390
404
  * @property LOR (Least Outstanding Requests): Distribute based on availability.
391
405
  */
392
406
  apptDistAlg: appointmentDistAlgs.default("RR"),
393
- servicesDeployed: z12.boolean(),
407
+ servicesDeployed: z13.boolean(),
394
408
  version: Version,
395
409
  lastModified: Timestamp.nullable()
396
410
  }).refine(
@@ -403,24 +417,24 @@ var MutableCompanyPreferences = CompanyPreferences.omit({
403
417
  });
404
418
 
405
419
  // src/schemas/company/components/Staff.ts
406
- import * as z16 from "zod";
420
+ import * as z17 from "zod";
407
421
 
408
422
  // src/schemas/company/components/User.ts
409
- import * as z15 from "zod";
423
+ import * as z16 from "zod";
410
424
 
411
425
  // src/functions/helper-functions.ts
412
426
  import { camelCaseToLetter, upperFirst as upperFirst2 } from "@wavy/fn";
413
427
 
414
428
  // src/schemas/profiles/Client.ts
415
- import * as z14 from "zod";
429
+ import * as z15 from "zod";
416
430
 
417
431
  // src/schemas/profiles/User.ts
418
432
  import { UserModel } from "@wavy/util";
419
- import * as z13 from "zod";
420
- var UserDetails = z13.object({
433
+ import * as z14 from "zod";
434
+ var UserDetails = z14.object({
421
435
  ...UserModel.shape,
422
- _id: z13.uuidv4(),
423
- name: z13.string().transform((data) => {
436
+ _id: z14.uuidv4(),
437
+ name: z14.string().transform((data) => {
424
438
  const [firstName = "", lastName = ""] = data.split(" ");
425
439
  return (firstName + " " + lastName).trim();
426
440
  }).superRefine((data, ctx) => {
@@ -437,21 +451,21 @@ var UserDetails = z13.object({
437
451
  });
438
452
  }),
439
453
  email: UserModel.shape.email,
440
- publicKey: z13.string().nullable(),
454
+ publicKey: z14.string().nullable(),
441
455
  // notifications: z.array(Notification),
442
456
  version: Version.default(1),
443
- lastSignedIn: z13.object({
457
+ lastSignedIn: z14.object({
444
458
  auto: Timestamp,
445
459
  manual: Timestamp
446
460
  }).partial(),
447
- companyUids: z13.array(CompanyState.shape._id).min(1).optional(),
461
+ companyUids: z14.array(CompanyState.shape._id).min(1).optional(),
448
462
  // resumeToken: z.uuidv4().optional(),
449
463
  ...TimeLog.shape
450
464
  }).omit({ uid: true });
451
465
 
452
466
  // src/schemas/profiles/Client.ts
453
467
  import { Address as Address2, PhoneNumber as PhoneNumber2 } from "@wavy/util";
454
- var Name = z14.string().trim().min(2).max(MAX_NAME_LENGTH).transform((d) => d.replace(/-+/g, "-").replace(/'+/g, "'")).superRefine((data, ctx) => {
468
+ var Name = z15.string().trim().min(2).max(MAX_NAME_LENGTH).transform((d) => d.replace(/-+/g, "-").replace(/'+/g, "'")).superRefine((data, ctx) => {
455
469
  const invalidCharIdx = data.search(/[^a-z'-]/i);
456
470
  if (invalidCharIdx >= 0) {
457
471
  const char = data[invalidCharIdx].includes('"') ? `(${data[invalidCharIdx]})` : `"${data[invalidCharIdx]}"`;
@@ -466,31 +480,31 @@ var ClientIdentity = UserDetails.pick({
466
480
  version: true,
467
481
  photoUrl: true
468
482
  }).safeExtend(
469
- z14.object({
483
+ z15.object({
470
484
  firstName: Name,
471
485
  middleName: Name,
472
486
  lastName: Name,
473
487
  email: UserDetails.shape.email.optional(),
474
488
  dob: Timestamp,
475
489
  sex: genders,
476
- isGlobal: z14.boolean(),
490
+ isGlobal: z15.boolean(),
477
491
  origin: CompanyIdentity.shape._id,
478
- visits: z14.record(CompanyIdentity.shape._id, z14.array(Timestamp).min(1)).optional(),
492
+ visits: z15.record(CompanyIdentity.shape._id, z15.array(Timestamp).min(1)).optional(),
479
493
  phoneNumber: PhoneNumber2.optional(),
480
494
  // aka. National id
481
- nid: z14.object({
495
+ nid: z15.object({
482
496
  trn: Trn,
483
497
  nin: AlphaNumeric.toLowerCase().min(5).max(20),
484
498
  passportNo: AlphaNumeric.toLowerCase().min(5).max(15)
485
499
  }).partial().optional(),
486
500
  // Don't hash the attributes, they can be used to help accurately identify a client by whoever is searching for
487
501
  // the client
488
- attributes: z14.object({
502
+ attributes: z15.object({
489
503
  motherMaidenName: Name,
490
504
  fatherMiddleName: Name,
491
505
  motherMiddleName: Name,
492
506
  oldestSiblingMiddleName: Name,
493
- firstSchoolName: z14.string().trim().min(3).max(60)
507
+ firstSchoolName: z15.string().trim().min(3).max(60)
494
508
  }).partial().refine(
495
509
  (data) => Object.keys(data).length > 0,
496
510
  "At least (1) attribute must be defined."
@@ -557,21 +571,21 @@ var COMPANY_USER_RELATIONSHIP = {
557
571
  doc: ["physAsst"],
558
572
  physAsst: ["doc"]
559
573
  };
560
- var CompanyUserSession = z15.object({
561
- _id: z15.uuidv4(),
574
+ var CompanyUserSession = z16.object({
575
+ _id: z16.uuidv4(),
562
576
  user: UserDetails.pick({ _id: true, name: true, email: true }),
563
577
  companyId: CompanyState.shape._id,
564
- deviceId: z15.string().trim().min(15),
565
- isAvailable: z15.object({
566
- value: z15.boolean(),
578
+ deviceId: z16.string().trim().min(15),
579
+ isAvailable: z16.object({
580
+ value: z16.boolean(),
567
581
  lastModified: Timestamp.nullable()
568
582
  }),
569
- isBusy: z15.object({
570
- value: z15.boolean(),
583
+ isBusy: z16.object({
584
+ value: z16.boolean(),
571
585
  lastModified: Timestamp.nullable()
572
586
  }),
573
- appointments: z15.record(z15.literal(["ongoing", "completed"]), z15.int().min(0)),
574
- roles: z15.array(companyUserRoles).transform((roles) => {
587
+ appointments: z16.record(z16.literal(["ongoing", "completed"]), z16.int().min(0)),
588
+ roles: z16.array(companyUserRoles).transform((roles) => {
575
589
  const newRoles = [];
576
590
  for (const role of roles) {
577
591
  if (!!role && !newRoles.includes(role)) newRoles.push(role);
@@ -582,11 +596,11 @@ var CompanyUserSession = z15.object({
582
596
  (role) => getIncompatibleRoles(role).some((r) => roles.includes(r))
583
597
  );
584
598
  }, "A user is not allowed to have conflicting roles."),
585
- ttl: z15.number(),
599
+ ttl: z16.number(),
586
600
  lastModified: Timestamp.nullable(),
587
- expiresAfter: z15.date()
601
+ expiresAfter: z16.date()
588
602
  });
589
- var MiniCompanyUser2 = z15.object({
603
+ var MiniCompanyUser2 = z16.object({
590
604
  _id: UserDetails.shape._id,
591
605
  ...CompanyUserSession.pick({
592
606
  roles: true,
@@ -600,18 +614,18 @@ var MiniCompanyUser2 = z15.object({
600
614
  inviteSent: Timestamp.nullish(),
601
615
  inviteAccepted: Timestamp.nullable()
602
616
  });
603
- var CompanyUser2 = z15.object({
617
+ var CompanyUser2 = z16.object({
604
618
  ...MiniCompanyUser2.shape,
605
619
  ...CompanyUserSession.shape.user.shape,
606
620
  // Only true when the user's data is retrieved from the session pool
607
621
  // NB: This property is purely cosmetic (so no need to store this on the server)
608
- isActive: z15.boolean()
622
+ isActive: z16.boolean()
609
623
  });
610
624
 
611
625
  // src/schemas/company/components/Staff.ts
612
- var MiniRawCompanyStaff = z16.object({
626
+ var MiniRawCompanyStaff = z17.object({
613
627
  _id: CompanyState.shape._id,
614
- members: z16.record(
628
+ members: z17.record(
615
629
  MiniCompanyUser2.shape._id,
616
630
  MiniCompanyUser2.omit({ _id: true })
617
631
  ),
@@ -619,15 +633,15 @@ var MiniRawCompanyStaff = z16.object({
619
633
  /**
620
634
  * @relationship one -> many
621
635
  *@description A map of doctor `uids` to their assistants `uids` */
622
- partnerMap: z16.record(
636
+ partnerMap: z17.record(
623
637
  CompanyUser2.shape._id,
624
- z16.record(CompanyUser2.shape._id, z16.object({ addedAt: Timestamp }))
638
+ z17.record(CompanyUser2.shape._id, z17.object({ addedAt: Timestamp }))
625
639
  ),
626
- updateQueue: z16.record(
640
+ updateQueue: z17.record(
627
641
  CompanyUser2.shape._id,
628
- z16.object({
629
- $REMOVE: z16.object({ addedAt: Timestamp }),
630
- $CHANGE_ROLES: z16.object({
642
+ z17.object({
643
+ $REMOVE: z17.object({ addedAt: Timestamp }),
644
+ $CHANGE_ROLES: z17.object({
631
645
  newRoles: CompanyUser2.shape.roles,
632
646
  addedAt: Timestamp
633
647
  })
@@ -636,12 +650,12 @@ var MiniRawCompanyStaff = z16.object({
636
650
  version: Version,
637
651
  lastModified: Timestamp.nullable()
638
652
  });
639
- var RawCompanyStaff = z16.object({
653
+ var RawCompanyStaff = z17.object({
640
654
  ...MiniRawCompanyStaff.shape,
641
- members: z16.record(CompanyUser2.shape._id, CompanyUser2.omit({ _id: true }))
655
+ members: z17.record(CompanyUser2.shape._id, CompanyUser2.omit({ _id: true }))
642
656
  });
643
- var transformStaff = (object17) => {
644
- return object17.transform((d) => {
657
+ var transformStaff = (object18) => {
658
+ return object18.transform((d) => {
645
659
  const copy = structuredClone(d);
646
660
  for (const uid of Object.keys(copy.updateQueue)) {
647
661
  if (uid in copy.members) {
@@ -699,7 +713,7 @@ var MutableCompanyStaff = RawCompanyStaff.pick({
699
713
  });
700
714
 
701
715
  // src/schemas/company/CompanyDetails.ts
702
- var CompanyDetails = z17.object({
716
+ var CompanyDetails = z18.object({
703
717
  _id: CompanyState.shape._id,
704
718
  identity: CompanyIdentity.omit({ _id: true }),
705
719
  notifications: CompanyNotifications,
@@ -709,7 +723,7 @@ var CompanyDetails = z17.object({
709
723
  billing: CompanyBilling.omit({ _id: true }),
710
724
  staff: RawCompanyStaff.omit({ _id: true })
711
725
  });
712
- var MutableCompanyDetails = z17.object({
726
+ var MutableCompanyDetails = z18.object({
713
727
  _id: CompanyDetails.shape._id,
714
728
  identity: MutableCompanyIdentity.partial().optional(),
715
729
  preferences: MutableCompanyPreferences.partial().optional(),
@@ -718,61 +732,66 @@ var MutableCompanyDetails = z17.object({
718
732
  });
719
733
 
720
734
  // src/schemas/company/utils/InviteList.ts
721
- import * as z18 from "zod";
722
- var CompanyInviteList = z18.record(
735
+ import * as z19 from "zod";
736
+ var CompanyInviteList = z19.record(
723
737
  CompanyUser2.shape.email,
724
- z18.object({ createdAt: Timestamp, roles: CompanyUser2.shape.roles })
738
+ z19.object({ createdAt: Timestamp, roles: CompanyUser2.shape.roles })
725
739
  ).refine(
726
740
  (data) => Object.keys(data).length > 0,
727
741
  "Insufficient amount of members invited."
728
742
  );
729
743
 
730
744
  // src/schemas/company/utils/CreateCompanyForm.ts
731
- import * as z19 from "zod";
732
- var CreateCompanyForm = z19.object({
745
+ import * as z20 from "zod";
746
+ var CreateCompanyForm = z20.object({
733
747
  _id: CompanyIdentity.shape._id,
734
748
  alias: CompanyIdentity.shape.alias.optional(),
735
749
  logo: CompanyIdentity.shape.logo.optional(),
736
750
  ...CompanyIdentity.shape.contact.pick({ email: true, phoneNumber: true }).shape,
737
751
  industry: CompanyIdentity.shape.industry,
752
+ sector: CompanyIdentity.shape.sector,
738
753
  address: CompanyIdentity.shape.address.nonoptional()
739
754
  }).transform((data) => {
740
755
  if (!("alias" in data)) {
741
756
  data.alias = normalizeCompanyId(data._id);
742
757
  }
743
758
  return data;
759
+ }).superRefine((data, ctx) => {
760
+ if (!CompanyIndustry.shape[data.industry].safeParse(data.sector).success) {
761
+ ctx.addIssue(getInvalidSectorError(data.industry, data.sector));
762
+ }
744
763
  });
745
764
 
746
765
  // src/schemas/appointment/components/Medical.ts
747
- import * as z20 from "zod";
748
- var Vitals = z20.record(
766
+ import * as z21 from "zod";
767
+ var Vitals = z21.record(
749
768
  vitalKeys,
750
- z20.object({
751
- value: z20.string().trim().regex(/^\d{0,3}((\/|\.)\d{1,3})?/),
769
+ z21.object({
770
+ value: z21.string().trim().regex(/^\d{0,3}((\/|\.)\d{1,3})?/),
752
771
  lastModified: Timestamp.nullable()
753
772
  })
754
773
  );
755
- var Medicine = z20.object({
756
- brand: z20.string().trim(),
774
+ var Medicine = z21.object({
775
+ brand: z21.string().trim(),
757
776
  expiresAt: Timestamp.nullish(),
758
- quantity: z20.string().trim().regex(/^\d+(\.\d{1,3})? ?[a-zA-Z]{1,20}/, {
777
+ quantity: z21.string().trim().regex(/^\d+(\.\d{1,3})? ?[a-zA-Z]{1,20}/, {
759
778
  error: "Failed to match the pattern <number>+(.<number>{1,3})? ?[a-zA-Z]{1,20}"
760
779
  }),
761
- refills: z20.string().trim().regex(/^[0-8]/, { error: "Must be between 0 and 8" }),
762
- directions: z20.string().trim().max(100, { error: "Must be 100 characters or less" }),
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" }),
763
782
  ...TimeLog.shape
764
783
  });
765
- var MedicalDetails = z20.object({
784
+ var MedicalDetails = z21.object({
766
785
  vitals: Vitals,
767
- prescriptions: z20.array(z20.array(Medicine)).nullish(),
768
- doctorNote: z20.object({
769
- value: z20.string(),
786
+ prescriptions: z21.array(z21.array(Medicine)).nullish(),
787
+ doctorNote: z21.object({
788
+ value: z21.string(),
770
789
  lastModified: Timestamp.nullable()
771
790
  }),
772
- physAsstNotes: z20.array(
773
- z20.object({
774
- title: z20.string(),
775
- content: z20.string(),
791
+ physAsstNotes: z21.array(
792
+ z21.object({
793
+ title: z21.string(),
794
+ content: z21.string(),
776
795
  ...TimeLog.shape
777
796
  })
778
797
  ).optional()
@@ -780,7 +799,7 @@ var MedicalDetails = z20.object({
780
799
 
781
800
  // src/schemas/appointment/Appointment.ts
782
801
  import { sumOf as sumOf2 } from "@wavy/fn";
783
- import * as z21 from "zod";
802
+ import * as z22 from "zod";
784
803
 
785
804
  // src/functions/calc.ts
786
805
  import { sumOf } from "@wavy/fn";
@@ -809,26 +828,26 @@ var calcPriceMod = (mods, subtotal) => {
809
828
  };
810
829
 
811
830
  // src/schemas/appointment/Appointment.ts
812
- var TimelineActivity = z21.object({
831
+ var TimelineActivity = z22.object({
813
832
  postedAt: Timestamp.nullish(),
814
833
  userUid: CompanyUser2.shape._id.nonoptional()
815
834
  });
816
- var AppointmentSeverity = z21.object({
817
- "1": z21.literal("Emergency"),
818
- "2": z21.literal("Important"),
819
- "3": z21.literal("Average")
835
+ var AppointmentSeverity = z22.object({
836
+ "1": z22.literal("Emergency"),
837
+ "2": z22.literal("Important"),
838
+ "3": z22.literal("Average")
820
839
  });
821
- var MiniAppointmentDetails = z21.object({
840
+ var MiniAppointmentDetails = z22.object({
822
841
  /** A random uid that identifies the document. */
823
- _id: z21.uuidv4(),
842
+ _id: z22.uuidv4(),
824
843
  // This helps to identify the urgency of the appointment
825
- severity: z21.string().refine((data) => AppointmentSeverity.keyof().safeParse(data).success),
844
+ severity: z22.string().refine((data) => AppointmentSeverity.keyof().safeParse(data).success),
826
845
  /** The company's uid */
827
846
  src: CompanyState.shape._id,
828
847
  /** The ticket number */
829
848
  tkt: TicketNo,
830
849
  /**The reason for the service */
831
- reason: z21.object({
850
+ reason: z22.object({
832
851
  value: Reason.shape.value,
833
852
  ...TimeLog.shape
834
853
  }),
@@ -849,19 +868,19 @@ var MiniAppointmentDetails = z21.object({
849
868
  /**Required to calculate the accurate grandTotal of the charges */
850
869
  discounts: CompanyBilling.shape.discounts.nullish(),
851
870
  prepayments: CompanyBilling.shape.prepayments.nullish(),
852
- payments: z21.array(PaymentDetails).max(100).nullish(),
871
+ payments: z22.array(PaymentDetails).max(100).nullish(),
853
872
  /** The client's identity */
854
873
  clientUid: ClientIdentity.shape._id,
855
874
  /**
856
875
  * Data that is specific to the entity (for now it's just medical data).
857
876
  * It will only be defined for the participants that have access to it.
858
877
  */
859
- payload: z21.object({
878
+ payload: z22.object({
860
879
  ...MedicalDetails.shape,
861
- lastModified: z21.number().nullable()
880
+ lastModified: z22.number().nullable()
862
881
  }).nullish(),
863
882
  /** Only defined when either the service provider or the client cancelled their appointment */
864
- cancelled: z21.object({
883
+ cancelled: z22.object({
865
884
  /** The time that the confirm cancel button was clicked */
866
885
  doneAt: Timestamp,
867
886
  reason: Reason,
@@ -871,16 +890,16 @@ var MiniAppointmentDetails = z21.object({
871
890
  // paymentDueDate: Timestamp.nullish(),
872
891
  // The user that is currently modifying the appointment
873
892
  lockedBy: UserDetails.shape._id.optional(),
874
- timeline: z21.object({
893
+ timeline: z22.object({
875
894
  scheduler: TimelineActivity,
876
- physAsst: TimelineActivity.or(z21.literal("none")),
895
+ physAsst: TimelineActivity.or(z22.literal("none")),
877
896
  doctor: TimelineActivity,
878
897
  // Array used to accurately record payments made by the "a/r" and the "cshr"
879
- debtCollector: z21.array(
880
- z21.object({
898
+ debtCollector: z22.array(
899
+ z22.object({
881
900
  ...TimelineActivity.shape,
882
901
  // Payment uid -> collection time
883
- collectedPayments: z21.record(z21.uuidv4(), Timestamp)
902
+ collectedPayments: z22.record(z22.uuidv4(), Timestamp)
884
903
  })
885
904
  ).min(1).nullable()
886
905
  }),
@@ -899,19 +918,19 @@ var MiniAppointmentDetails = z21.object({
899
918
  });
900
919
  var AppointmentDetails = MiniAppointmentDetails.omit({
901
920
  clientUid: true
902
- }).extend(z21.object({ client: ClientIdentity }).shape);
921
+ }).extend(z22.object({ client: ClientIdentity }).shape);
903
922
  var MutableAppointmentDetails = AppointmentDetails.safeExtend(
904
- z21.object({
923
+ z22.object({
905
924
  /**
906
925
  * @description An encrypted copy of the last state of the appointment.
907
926
  * @note Used to accurately update the appointment without having to query the database
908
927
  */
909
- _hash: z21.string()
928
+ _hash: z22.string()
910
929
  }).shape
911
930
  );
912
- var ScheduleAppointmentForm = z21.object({
931
+ var ScheduleAppointmentForm = z22.object({
913
932
  clientId: ClientIdentity.shape._id,
914
- serviceProviderId: CompanyUser2.shape._id.or(z21.literal("next")),
933
+ serviceProviderId: CompanyUser2.shape._id.or(z22.literal("next")),
915
934
  category: AppointmentDetails.shape.severity,
916
935
  appointmentReason: AppointmentDetails.shape.reason,
917
936
  charges: AppointmentDetails.shape.charges.optional(),
@@ -1128,6 +1147,7 @@ export {
1128
1147
  CompanyBilling,
1129
1148
  CompanyDetails,
1130
1149
  CompanyIdentity,
1150
+ CompanyIndustry,
1131
1151
  CompanyInviteList,
1132
1152
  CompanyNotifications,
1133
1153
  CompanyPreferences,
@@ -1182,7 +1202,6 @@ export {
1182
1202
  getCompatibleRoles,
1183
1203
  getIncompatibleRoles,
1184
1204
  healthcareProviderRoles,
1185
- industries,
1186
1205
  normalizeCompanyId,
1187
1206
  normalizeNidKey,
1188
1207
  parseClientName,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bizmap/sdk",
3
- "version": "0.0.112",
3
+ "version": "0.0.114",
4
4
  "main": "./dist/main.js",
5
5
  "types": "./dist/main.d.ts",
6
6
  "type": "module",