@bizmap/sdk 0.0.121 → 0.0.122

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 +3 -10
  2. package/dist/main.js +170 -180
  3. package/package.json +1 -1
package/dist/main.d.ts CHANGED
@@ -68,13 +68,6 @@ declare const vitalKeys: z.ZodEnum<{
68
68
  bodyTemp: "bodyTemp";
69
69
  }>;
70
70
 
71
- declare const serviceProviders: z.ZodEnum<{
72
- physAsst: "physAsst";
73
- scheduler: "scheduler";
74
- doctor: "doctor";
75
- debtCollector: "debtCollector";
76
- }>;
77
-
78
71
  declare const CompanyDetails: z.ZodObject<{
79
72
  _id: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
80
73
  identity: z.ZodObject<{
@@ -1028,7 +1021,7 @@ declare const TaskDetails: z.ZodObject<{
1028
1021
  }, z.core.$strip>>>;
1029
1022
  }, z.core.$strip>;
1030
1023
  type TaskDetails = z.infer<typeof TaskDetails>;
1031
- declare const MutableAppointmentDetails: z.ZodObject<{
1024
+ declare const MutableTaskDetails: z.ZodObject<{
1032
1025
  createdAt: z.ZodReadonly<z.ZodISODateTime>;
1033
1026
  lastModified: z.ZodOptional<z.ZodISODateTime>;
1034
1027
  _id: z.ZodUUID;
@@ -1164,7 +1157,7 @@ declare const MutableAppointmentDetails: z.ZodObject<{
1164
1157
  }, z.core.$strip>>>;
1165
1158
  _hash: z.ZodString;
1166
1159
  }, z.core.$strip>;
1167
- type MutableAppointmentDetails = z.infer<typeof MutableAppointmentDetails>;
1160
+ type MutableTaskDetails = z.infer<typeof MutableTaskDetails>;
1168
1161
 
1169
1162
  /** @disclaimer This doesn't handle currency conversion */
1170
1163
  declare function calcBalance(components: Prettify<Partial<Pick<TaskDetails, "charges" | "discounts" | "additionalFees" | "prepayments" | "payments">>>, options?: {
@@ -1187,4 +1180,4 @@ declare function createNotifId(options?: {
1187
1180
  to: string;
1188
1181
  }): string;
1189
1182
 
1190
- export { type AcceptedCurrency, AlphaNumeric, COMPANY_USER_RELATIONSHIP, ClientDetails, ClientForm, CompanyBilling, CompanyDetails, CompanyIdentity, CompanyIndustry, CompanyNotifications, CompanyPreferences, type CompanyServiceSelector, CompanyStaff, CompanyState, type CompanyUserRole, CreateCompanyForm, CreditCurrency, type EmployeeRole, type Gender, type HealthcareProviderRole, InviteResponse, InvoiceNo, MAX_COMPANY_PRICE_MODS, MedicalDetails, Medicine, MutableAppointmentDetails, MutableCompanyBilling, MutableCompanyDetails, MutableCompanyIdentity, MutableCompanyPreferences, MutableCompanyStaff, Notification, PaymentDetails, type PaymentMethod, PriceMod, PriceModList, PriceTag, Reason, Receipts, StandardTime, TaskDetails, type TaskDistAlg, TaskSeverity, TicketNo, type Tier, TierList, TimeLog, Timestamp, Trn, UserDetails, Vitals, acceptedCurrencies, adminRoles, calcBalance, calcPriceMod, companyServiceSelectors, companyUserRoles, createNotifId, employeeRoles, genders, getCompatibleRoles, getIncompatibleRoles, healthcareProviderRoles, normalizeCompanyId, normalizeNidKey, parseClientName, paymentMethods, serviceProviders, taskDistAlgs, tiers, vitalKeys };
1183
+ export { type AcceptedCurrency, AlphaNumeric, COMPANY_USER_RELATIONSHIP, ClientDetails, ClientForm, CompanyBilling, CompanyDetails, CompanyIdentity, CompanyIndustry, CompanyNotifications, CompanyPreferences, type CompanyServiceSelector, CompanyStaff, CompanyState, type CompanyUserRole, CreateCompanyForm, CreditCurrency, type EmployeeRole, type Gender, type HealthcareProviderRole, InviteResponse, InvoiceNo, MAX_COMPANY_PRICE_MODS, MedicalDetails, Medicine, MutableCompanyBilling, MutableCompanyDetails, MutableCompanyIdentity, MutableCompanyPreferences, MutableCompanyStaff, MutableTaskDetails, Notification, PaymentDetails, type PaymentMethod, PriceMod, PriceModList, PriceTag, Reason, Receipts, StandardTime, TaskDetails, type TaskDistAlg, TaskSeverity, TicketNo, type Tier, TierList, TimeLog, Timestamp, Trn, UserDetails, Vitals, acceptedCurrencies, adminRoles, calcBalance, calcPriceMod, companyServiceSelectors, companyUserRoles, createNotifId, employeeRoles, genders, getCompatibleRoles, getIncompatibleRoles, healthcareProviderRoles, normalizeCompanyId, normalizeNidKey, parseClientName, paymentMethods, taskDistAlgs, tiers, vitalKeys };
package/dist/main.js CHANGED
@@ -36,56 +36,47 @@ var vitalKeys = z3.enum([
36
36
  "bodyTemp"
37
37
  ]);
38
38
 
39
- // src/enums/Appointments.ts
40
- import * as z4 from "zod";
41
- var serviceProviders = z4.enum([
42
- "scheduler",
43
- "doctor",
44
- "physAsst",
45
- "debtCollector"
46
- ]);
47
-
48
39
  // src/schemas/company/CompanyDetails.ts
49
- import * as z16 from "zod";
40
+ import * as z15 from "zod";
50
41
 
51
42
  // src/schemas/company/components/Billing.ts
52
- import * as z8 from "zod";
43
+ import * as z7 from "zod";
53
44
 
54
45
  // src/schemas/utils/billing.ts
55
- import * as z6 from "zod";
46
+ import * as z5 from "zod";
56
47
 
57
48
  // src/schemas/utils/core.ts
58
- import * as z5 from "zod";
59
- var InvoiceNo = z5.string().trim().refine(
49
+ import * as z4 from "zod";
50
+ var InvoiceNo = z4.string().trim().refine(
60
51
  (d) => d && d.replace(
61
52
  /^[0-9]{4}-(01|(0[2-9])|(1[0-2]))-(30|31|([1-2][0-9])|0[1-9])-[0-9]{7}/,
62
53
  ""
63
54
  ).length === 0,
64
55
  'Invalid invoice no.: must match the pattern "yyyy-mm-dd-0000000"'
65
56
  );
66
- var Trn = z5.string().trim().refine(
57
+ var Trn = z4.string().trim().refine(
67
58
  (data) => data && data.replace(/^[0-9]{3}-[0-9]{3}-[0-9]{3}/, "").length === 0,
68
59
  'Invalid trn: must match the pattern "000-000-000"'
69
60
  );
70
- var StandardTime = z5.string().trim().refine(
61
+ var StandardTime = z4.string().trim().refine(
71
62
  (d) => d && d.replace(/^(01|(0[2-9])|(1[0-2])):(([1-5][0-9])|0[0-9]) (am|pm)/i, "").length === 0,
72
63
  'Invalid standard time: must match the pattern "hh:mm A"'
73
64
  );
74
- var Timestamp = z5.iso.datetime();
75
- var InviteResponse = z5.enum(["accepted", "declined"]);
76
- var TimeLog = z5.object({
65
+ var Timestamp = z4.iso.datetime();
66
+ var InviteResponse = z4.enum(["accepted", "declined"]);
67
+ var TimeLog = z4.object({
77
68
  createdAt: Timestamp.readonly(),
78
69
  lastModified: Timestamp.optional()
79
70
  });
80
- var TicketNo = z5.int().positive().refine(
71
+ var TicketNo = z4.int().positive().refine(
81
72
  (t) => t.toString().length <= 10,
82
73
  "A ticket no. can only have (10) max digits."
83
74
  ).readonly();
84
- var Reason = z5.object({
85
- value: z5.string().trim().min(3).max(100),
75
+ var Reason = z4.object({
76
+ value: z4.string().trim().min(3).max(100),
86
77
  lastModified: Timestamp
87
78
  });
88
- var AlphaNumeric = z5.string().trim().superRefine((data, ctx) => {
79
+ var AlphaNumeric = z4.string().trim().superRefine((data, ctx) => {
89
80
  const invalidCharIdx = data.search(/[^a-z0-9]/i);
90
81
  if (invalidCharIdx > -1) {
91
82
  const char = `"'`.includes(data[invalidCharIdx]) ? `(${data[invalidCharIdx]})` : `"${data[invalidCharIdx]}"`;
@@ -94,38 +85,38 @@ var AlphaNumeric = z5.string().trim().superRefine((data, ctx) => {
94
85
  });
95
86
 
96
87
  // src/schemas/utils/billing.ts
97
- var PriceMod = z6.object({
98
- description: z6.string().trim().min(3, "A description must have atleast (3) characters.").max(25, "A description can't have more that (25) characters.").superRefine((data, ctx) => {
88
+ var PriceMod = z5.object({
89
+ description: z5.string().trim().min(3, "A description must have atleast (3) characters.").max(25, "A description can't have more that (25) characters.").superRefine((data, ctx) => {
99
90
  const invalidCharIdx = data.search(/[^a-zA-Z0-9-\.:\(\)]/);
100
91
  if (invalidCharIdx > -1) {
101
92
  ctx.addIssue("");
102
93
  }
103
94
  }),
104
- fixedAmount: z6.object({
105
- value: z6.number().min(0).max(1e6, "The max fixed amount is $1,000,000.00"),
95
+ fixedAmount: z5.object({
96
+ value: z5.number().min(0).max(1e6, "The max fixed amount is $1,000,000.00"),
106
97
  currency: acceptedCurrencies
107
98
  }),
108
- percentage: z6.number().min(0).max(1e3, "The max percentage is 1,000%"),
109
- isOptional: z6.boolean(),
99
+ percentage: z5.number().min(0).max(1e3, "The max percentage is 1,000%"),
100
+ isOptional: z5.boolean(),
110
101
  ...TimeLog.shape
111
102
  });
112
- var PriceModList = z6.record(z6.uuidv4(), PriceMod);
113
- var PriceTag = z6.object({
114
- uid: z6.uuidv4(),
103
+ var PriceModList = z5.record(z5.uuidv4(), PriceMod);
104
+ var PriceTag = z5.object({
105
+ uid: z5.uuidv4(),
115
106
  /**The name of the item that's being priced */
116
- item: z6.string().trim().min(3, "The price item must be atleast (3) characters long.").max(50, "The price item can't be more than (50) characters long."),
117
- cost: z6.number().min(1, "The minimum allowed cost is $1.00").max(1e9, "The max allowed cost is $1,000,000,000.00."),
107
+ item: z5.string().trim().min(3, "The price item must be atleast (3) characters long.").max(50, "The price item can't be more than (50) characters long."),
108
+ cost: z5.number().min(1, "The minimum allowed cost is $1.00").max(1e9, "The max allowed cost is $1,000,000,000.00."),
118
109
  currency: acceptedCurrencies,
119
110
  ...TimeLog.shape
120
111
  });
121
- var Receipts = z6.array(
112
+ var Receipts = z5.array(
122
113
  PriceTag.omit({ uid: true, lastModified: true })
123
114
  );
124
115
 
125
116
  // src/schemas/company/components/State.ts
126
- import * as z7 from "zod";
127
- var CompanyState = z7.object({
128
- _id: z7.string().toLowerCase().trim().min(3).max(63).transform(
117
+ import * as z6 from "zod";
118
+ var CompanyState = z6.object({
119
+ _id: z6.string().toLowerCase().trim().min(3).max(63).transform(
129
120
  (data) => data.replace(/-+/g, "-").replace(/_+/g, "_").replace(/\.+/g, ".").replace(/\s+/g, "")
130
121
  ).superRefine((data, ctx) => {
131
122
  const invalidCharIdx = data.search(/[^a-z0-9\-_\.]/);
@@ -142,21 +133,21 @@ var CompanyState = z7.object({
142
133
  ctx.addIssue("The last character must either be a letter or a number.");
143
134
  }
144
135
  }),
145
- credits: z7.object({
146
- current: z7.number(),
136
+ credits: z6.object({
137
+ current: z6.number(),
147
138
  lastModified: Timestamp.optional()
148
139
  }),
149
- usedStorageInBytes: z7.object({
150
- current: z7.number(),
140
+ usedStorageInBytes: z6.object({
141
+ current: z6.number(),
151
142
  lastModified: Timestamp.optional()
152
143
  }),
153
- tierId: z7.object({
154
- current: z7.string(),
144
+ tierId: z6.object({
145
+ current: z6.string(),
155
146
  lastModified: Timestamp.optional()
156
147
  }),
157
- count: z7.object({
158
- invoiceNo: z7.int().positive(),
159
- tktNo: z7.int().min(1)
148
+ count: z6.object({
149
+ invoiceNo: z6.int().positive(),
150
+ tktNo: z6.int().min(1)
160
151
  }),
161
152
  // distRoleIds: z.array(z.string()),
162
153
  /** Data retention period in months */
@@ -170,13 +161,13 @@ var createMod = (resource) => PriceModList.refine(
170
161
  (d) => Object.values(d).length <= MAX_COMPANY_PRICE_MODS,
171
162
  `Adding more than 100 ${resource}s is prohibited.`
172
163
  );
173
- var CompanyBilling = z8.object({
164
+ var CompanyBilling = z7.object({
174
165
  _id: CompanyState.shape._id,
175
166
  additionalFees: createMod("additional fee").optional(),
176
167
  discounts: createMod("discount").optional(),
177
168
  /** Optionally deductable from bills */
178
169
  prepayments: createMod("pre-payment").optional(),
179
- offeredServices: z8.record(z8.uuidv4(), PriceTag.omit({ uid: true })).superRefine((data, ctx) => {
170
+ offeredServices: z7.record(z7.uuidv4(), PriceTag.omit({ uid: true })).superRefine((data, ctx) => {
180
171
  const services = Object.entries(data);
181
172
  if (services.length > 150) {
182
173
  ctx.addIssue(
@@ -192,15 +183,15 @@ var MutableCompanyBilling = CompanyBilling.omit({
192
183
  });
193
184
 
194
185
  // src/schemas/company/components/Identity.ts
195
- import * as z10 from "zod";
186
+ import * as z9 from "zod";
196
187
  import { Address, PhoneNumber } from "@wavy/util";
197
188
 
198
189
  // src/schemas/company/utils/CompanyIndustry.ts
199
- import * as z9 from "zod";
200
- var CompanyIndustry = z9.object({
201
- healthcare: z9.object({
202
- medicalCare: z9.object({
203
- roles: z9.enum(["doc", "physAsst"])
190
+ import * as z8 from "zod";
191
+ var CompanyIndustry = z8.object({
192
+ healthcare: z8.object({
193
+ medicalCare: z8.object({
194
+ roles: z8.enum(["doc", "physAsst"])
204
195
  })
205
196
  // "pharmaceuticals": z.object({
206
197
  // })
@@ -215,9 +206,9 @@ var COMPANY_USER_RELATIONSHIP = {
215
206
  };
216
207
 
217
208
  // src/schemas/company/components/Identity.ts
218
- var CompanyIdentity = z10.object({
209
+ var CompanyIdentity = z9.object({
219
210
  _id: CompanyState.shape._id,
220
- alias: z10.string().trim().min(3).max(63).transform((data) => data.replace(/\s+/g, " ")).superRefine((data, ctx) => {
211
+ alias: z9.string().trim().min(3).max(63).transform((data) => data.replace(/\s+/g, " ")).superRefine((data, ctx) => {
221
212
  const invalidCharIdx = data.search(/[^a-z1-9 ]/i);
222
213
  if (invalidCharIdx >= 0) {
223
214
  ctx.addIssue(
@@ -226,18 +217,18 @@ var CompanyIdentity = z10.object({
226
217
  }
227
218
  }),
228
219
  address: Address,
229
- logo: z10.string().optional(),
220
+ logo: z9.string().optional(),
230
221
  industry: CompanyIndustry.keyof(),
231
- sector: z10.string(),
232
- email: z10.email().max(45),
222
+ sector: z9.string(),
223
+ email: z9.email().max(45),
233
224
  phoneNumber: PhoneNumber.optional(),
234
- emailVerified: z10.boolean(),
235
- verified: z10.boolean(),
236
- legal: z10.object({
237
- regNo: z10.string().max(20).readonly(),
225
+ emailVerified: z9.boolean(),
226
+ verified: z9.boolean(),
227
+ legal: z9.object({
228
+ regNo: z9.string().max(20).readonly(),
238
229
  // The company's registration number
239
- trn: z10.string().regex(/[0-9]{3}-[0-9]{3}-[0-9]{3}/).nullish(),
240
- gctRegNo: z10.string().max(15).nullish()
230
+ trn: z9.string().regex(/[0-9]{3}-[0-9]{3}-[0-9]{3}/).nullish(),
231
+ gctRegNo: z9.string().max(15).nullish()
241
232
  }).optional(),
242
233
  ...TimeLog.shape
243
234
  }).superRefine((data, ctx) => {
@@ -260,19 +251,19 @@ var MutableCompanyIdentity = CompanyIdentity.pick({
260
251
  });
261
252
 
262
253
  // src/schemas/company/components/Preferences.ts
263
- import * as z11 from "zod";
264
- var CompanyPreferences = z11.object({
254
+ import * as z10 from "zod";
255
+ var CompanyPreferences = z10.object({
265
256
  _id: CompanyState.shape._id,
266
257
  /** The user that's allowed to record the client's services. */
267
258
  serviceSelector: companyServiceSelectors,
268
259
  /** Pay per task */
269
- ppt: z11.boolean(),
260
+ ppt: z10.boolean(),
270
261
  /**
271
262
  * @property RR (Round Robin): Even distribution.
272
263
  * @property LOR (Least Outstanding Requests): Distribute based on availability.
273
264
  */
274
265
  taskDistAlg: taskDistAlgs,
275
- servicesDeployed: z11.boolean(),
266
+ servicesDeployed: z10.boolean(),
276
267
  ...TimeLog.shape
277
268
  }).refine(
278
269
  (data) => !data.ppt || data.ppt && data.serviceSelector === "scheduler",
@@ -285,27 +276,27 @@ var MutableCompanyPreferences = CompanyPreferences.omit({
285
276
 
286
277
  // src/schemas/company/components/Staff.ts
287
278
  import { distinct } from "@wavy/fn";
288
- import * as z15 from "zod";
279
+ import * as z14 from "zod";
289
280
 
290
281
  // src/functions/helper-functions.ts
291
282
  import { camelCaseToLetter, upperFirst } from "@wavy/fn";
292
283
 
293
284
  // src/schemas/profiles/Client.ts
294
- import * as z13 from "zod";
285
+ import * as z12 from "zod";
295
286
 
296
287
  // src/schemas/profiles/User.ts
297
288
  import { UserModel } from "@wavy/util";
298
- import * as z12 from "zod";
289
+ import * as z11 from "zod";
299
290
 
300
291
  // src/constants.ts
301
292
  var NOTIF_ID_DELIM = "::";
302
293
  var MAX_NAME_LENGTH = 21;
303
294
 
304
295
  // src/schemas/profiles/User.ts
305
- var UserDetails = z12.object({
296
+ var UserDetails = z11.object({
306
297
  ...UserModel.shape,
307
- _id: z12.uuidv4(),
308
- name: z12.string().transform((data) => {
298
+ _id: z11.uuidv4(),
299
+ name: z11.string().transform((data) => {
309
300
  const [firstName = "", lastName = ""] = data.split(" ");
310
301
  return (firstName + " " + lastName).trim();
311
302
  }).superRefine((data, ctx) => {
@@ -322,21 +313,21 @@ var UserDetails = z12.object({
322
313
  });
323
314
  }),
324
315
  email: UserModel.shape.email,
325
- publicKey: z12.string().optional(),
326
- availableStorageInBytes: z12.number().optional(),
316
+ publicKey: z11.string().optional(),
317
+ availableStorageInBytes: z11.number().optional(),
327
318
  // notifications: z.array(Notification),
328
- lastSignedIn: z12.object({
319
+ lastSignedIn: z11.object({
329
320
  auto: Timestamp,
330
321
  manual: Timestamp
331
322
  }).partial(),
332
- companyUids: z12.array(CompanyState.shape._id).min(1).optional(),
323
+ companyUids: z11.array(CompanyState.shape._id).min(1).optional(),
333
324
  // resumeToken: z.uuidv4().optional(),
334
325
  ...TimeLog.shape
335
326
  }).omit({ uid: true });
336
327
 
337
328
  // src/schemas/profiles/Client.ts
338
329
  import { Address as Address2, PhoneNumber as PhoneNumber2 } from "@wavy/util";
339
- var Name = z13.string().trim().min(2).max(MAX_NAME_LENGTH).transform((d) => d.replace(/-+/g, "-").replace(/'+/g, "'")).superRefine((data, ctx) => {
330
+ var Name = z12.string().trim().min(2).max(MAX_NAME_LENGTH).transform((d) => d.replace(/-+/g, "-").replace(/'+/g, "'")).superRefine((data, ctx) => {
340
331
  const invalidCharIdx = data.search(/[^a-z'-]/i);
341
332
  if (invalidCharIdx >= 0) {
342
333
  const char = data[invalidCharIdx].includes('"') ? `(${data[invalidCharIdx]})` : `"${data[invalidCharIdx]}"`;
@@ -350,31 +341,31 @@ var ClientDetails = UserDetails.pick({
350
341
  phoneNumber: true,
351
342
  photoUrl: true
352
343
  }).safeExtend(
353
- z13.object({
344
+ z12.object({
354
345
  firstName: Name,
355
346
  middleName: Name,
356
347
  lastName: Name,
357
348
  email: UserDetails.shape.email.optional(),
358
349
  dob: Timestamp,
359
350
  sex: genders,
360
- isGlobal: z13.boolean(),
351
+ isGlobal: z12.boolean(),
361
352
  origin: CompanyIdentity.shape._id,
362
- visits: z13.record(CompanyIdentity.shape._id, z13.array(Timestamp).min(1)).optional(),
353
+ visits: z12.record(CompanyIdentity.shape._id, z12.array(Timestamp).min(1)).optional(),
363
354
  phoneNumber: PhoneNumber2.optional(),
364
355
  // aka. National id
365
- nid: z13.object({
356
+ nid: z12.object({
366
357
  trn: Trn,
367
358
  nin: AlphaNumeric.toLowerCase().min(5).max(20),
368
359
  passportNo: AlphaNumeric.toLowerCase().min(5).max(15)
369
360
  }).partial().optional(),
370
361
  // Don't hash the attributes, they can be used to help accurately identify a client by whoever is searching for
371
362
  // the client
372
- attributes: z13.object({
363
+ attributes: z12.object({
373
364
  motherMaidenName: Name,
374
365
  fatherMiddleName: Name,
375
366
  motherMiddleName: Name,
376
367
  oldestSiblingMiddleName: Name,
377
- firstSchoolName: z13.string().trim().min(3).max(60)
368
+ firstSchoolName: z12.string().trim().min(3).max(60)
378
369
  }).partial().refine(
379
370
  (data) => Object.keys(data).length > 0,
380
371
  "At least (1) attribute must be defined."
@@ -419,39 +410,39 @@ var parseClientName = ({
419
410
  }) => [firstName, middleName[0] + ".", lastName].join(" ");
420
411
 
421
412
  // src/schemas/company/utils/CompanySession.ts
422
- import * as z14 from "zod";
423
- var CompanySession = z14.object({
424
- _id: z14.uuidv4(),
413
+ import * as z13 from "zod";
414
+ var CompanySession = z13.object({
415
+ _id: z13.uuidv4(),
425
416
  userId: UserDetails.shape._id,
426
417
  // user: UserDetails.pick({ _id: true, name: true, email: true }),
427
418
  companyId: CompanyState.shape._id,
428
- deviceId: z14.string().trim().min(15),
429
- isAvailable: z14.object({
430
- value: z14.boolean(),
419
+ deviceId: z13.string().trim().min(15),
420
+ isAvailable: z13.object({
421
+ value: z13.boolean(),
431
422
  lastModified: Timestamp.optional()
432
423
  }),
433
- isBusy: z14.object({
434
- value: z14.boolean(),
424
+ isBusy: z13.object({
425
+ value: z13.boolean(),
435
426
  lastModified: Timestamp.optional()
436
427
  }),
437
- taskCounter: z14.record(z14.literal(["undone", "done"]), z14.int().min(0)),
428
+ taskCounter: z13.record(z13.literal(["undone", "done"]), z13.int().min(0)),
438
429
  roles: CompanyMemberRoles,
439
- ttl: z14.number(),
440
- expiresAfter: z14.date(),
430
+ ttl: z13.number(),
431
+ expiresAfter: z13.date(),
441
432
  ...TimeLog.shape
442
433
  });
443
434
 
444
435
  // src/schemas/company/components/Staff.ts
445
- var CompanyMemberRoles = z15.array(companyUserRoles).transform((roles) => distinct(roles).sort()).refine((roles) => {
436
+ var CompanyMemberRoles = z14.array(companyUserRoles).transform((roles) => distinct(roles).sort()).refine((roles) => {
446
437
  return !roles.find(
447
438
  (role) => getIncompatibleRoles(role).some((r) => roles.includes(r))
448
439
  );
449
440
  }, "A user is not allowed to have conflicting roles.");
450
- var CompanyStaff2 = z15.object({
441
+ var CompanyStaff2 = z14.object({
451
442
  _id: CompanyState.shape._id,
452
- members: z15.record(
443
+ members: z14.record(
453
444
  UserDetails.shape._id,
454
- z15.object({
445
+ z14.object({
455
446
  invitedAt: Timestamp.optional(),
456
447
  joinedAt: Timestamp,
457
448
  lastActive: Timestamp,
@@ -462,15 +453,15 @@ var CompanyStaff2 = z15.object({
462
453
  /**
463
454
  * @relationship one -> many
464
455
  *@description A map of doctor `uids` to their assistants `uids` */
465
- partnerMap: z15.record(
456
+ partnerMap: z14.record(
466
457
  UserDetails.shape._id,
467
- z15.record(UserDetails.shape._id, z15.object({ addedAt: Timestamp }))
458
+ z14.record(UserDetails.shape._id, z14.object({ addedAt: Timestamp }))
468
459
  ).optional(),
469
- updateQueue: z15.record(
460
+ updateQueue: z14.record(
470
461
  UserDetails.shape._id,
471
- z15.object({
472
- $REMOVE: z15.object({ addedAt: Timestamp }),
473
- $CHANGE_ROLES: z15.object({
462
+ z14.object({
463
+ $REMOVE: z14.object({ addedAt: Timestamp }),
464
+ $CHANGE_ROLES: z14.object({
474
465
  newRoles: CompanyMemberRoles,
475
466
  addedAt: Timestamp
476
467
  })
@@ -504,7 +495,7 @@ var MutableCompanyStaff = CompanyStaff2.pick({
504
495
  });
505
496
 
506
497
  // src/schemas/company/CompanyDetails.ts
507
- var CompanyDetails = z16.object({
498
+ var CompanyDetails = z15.object({
508
499
  _id: CompanyState.shape._id,
509
500
  identity: CompanyIdentity.omit({ _id: true }),
510
501
  // notifications: CompanyNotifications,
@@ -514,7 +505,7 @@ var CompanyDetails = z16.object({
514
505
  billing: CompanyBilling.omit({ _id: true }),
515
506
  staff: CompanyStaff2.omit({ _id: true })
516
507
  });
517
- var MutableCompanyDetails = z16.object({
508
+ var MutableCompanyDetails = z15.object({
518
509
  _id: CompanyDetails.shape._id,
519
510
  identity: MutableCompanyIdentity.partial().optional(),
520
511
  preferences: MutableCompanyPreferences.partial().optional(),
@@ -523,28 +514,28 @@ var MutableCompanyDetails = z16.object({
523
514
  });
524
515
 
525
516
  // src/schemas/company/components/Notifications.ts
526
- import * as z18 from "zod";
517
+ import * as z17 from "zod";
527
518
 
528
519
  // src/schemas/Global.ts
529
- import * as z17 from "zod";
530
- var TierList = z17.record(
520
+ import * as z16 from "zod";
521
+ var TierList = z16.record(
531
522
  tiers,
532
- z17.object({
533
- cost: z17.number().min(0),
534
- perks: z17.array(z17.string()).min(1)
523
+ z16.object({
524
+ cost: z16.number().min(0),
525
+ perks: z16.array(z16.string()).min(1)
535
526
  })
536
527
  ).superRefine((data, ctx) => {
537
528
  if (data.basic.cost !== 0) {
538
529
  ctx.addIssue("The basic tier must always cost $0.00");
539
530
  }
540
531
  });
541
- var Notification = z17.object({
542
- _id: z17.string().superRefine((data, ctx) => {
543
- const isUUidV4 = z17.uuidv4().safeParse(data).success;
532
+ var Notification = z16.object({
533
+ _id: z16.string().superRefine((data, ctx) => {
534
+ const isUUidV4 = z16.uuidv4().safeParse(data).success;
544
535
  if (isUUidV4) return;
545
536
  let [from, to, nonce] = data.split(NOTIF_ID_DELIM);
546
537
  nonce = nonce?.trim() || "";
547
- const parsedFrom = z17.uuidv4().or(z17.uuidv7()).safeParse(from);
538
+ const parsedFrom = z16.uuidv4().or(z16.uuidv7()).safeParse(from);
548
539
  if (!parsedFrom.success) {
549
540
  ctx.addIssue({
550
541
  code: "custom",
@@ -552,7 +543,7 @@ var Notification = z17.object({
552
543
  path: ["from"]
553
544
  });
554
545
  }
555
- const parsedTo = z17.uuidv4().safeParse(to);
546
+ const parsedTo = z16.uuidv4().safeParse(to);
556
547
  if (!parsedTo.success) {
557
548
  ctx.addIssue({
558
549
  code: "custom",
@@ -568,19 +559,19 @@ var Notification = z17.object({
568
559
  });
569
560
  }
570
561
  }),
571
- code: z17.literal([
562
+ code: z16.literal([
572
563
  "INVITE_RESPONSE",
573
564
  "COMPANY_INVITE",
574
565
  "DEV_MESSAGE",
575
566
  "ALERT"
576
567
  ]),
577
- payload: z17.string(),
578
- isArchived: z17.boolean().optional(),
579
- rcpt: z17.uuidv4().or(z17.uuidv7()).nullable(),
580
- src: z17.object({
581
- _id: z17.uuidv4().or(z17.uuidv7()),
582
- name: z17.string(),
583
- photoUrl: z17.string().nullish()
568
+ payload: z16.string(),
569
+ isArchived: z16.boolean().optional(),
570
+ rcpt: z16.uuidv4().or(z16.uuidv7()).nullable(),
571
+ src: z16.object({
572
+ _id: z16.uuidv4().or(z16.uuidv7()),
573
+ name: z16.string(),
574
+ photoUrl: z16.string().nullish()
584
575
  }),
585
576
  createdAt: Timestamp
586
577
  }).superRefine((data, ctx) => {
@@ -591,7 +582,7 @@ var Notification = z17.object({
591
582
  };
592
583
  switch (data.code) {
593
584
  case "COMPANY_INVITE":
594
- if (!z17.jwt().safeParse(data.payload).success) {
585
+ if (!z16.jwt().safeParse(data.payload).success) {
595
586
  ctx.addIssue("The payload of company invite must be a valid jwt.");
596
587
  }
597
588
  break;
@@ -612,32 +603,32 @@ var Notification = z17.object({
612
603
  return data.code;
613
604
  }
614
605
  });
615
- var CreditCurrency = z17.object({
616
- uid: z17.uuidv4(),
617
- cost: z17.object({ value: z17.number().min(0), currency: acceptedCurrencies }),
618
- value: z17.int().min(0),
606
+ var CreditCurrency = z16.object({
607
+ uid: z16.uuidv4(),
608
+ cost: z16.object({ value: z16.number().min(0), currency: acceptedCurrencies }),
609
+ value: z16.int().min(0),
619
610
  ...TimeLog.shape
620
611
  });
621
- var PaymentDetails = z17.object({
612
+ var PaymentDetails = z16.object({
622
613
  // Used to track the payments recorded by each paymentCollector
623
- uid: z17.uuidv4(),
614
+ uid: z16.uuidv4(),
624
615
  method: paymentMethods,
625
616
  currency: acceptedCurrencies,
626
- amount: z17.number().min(1),
617
+ amount: z16.number().min(1),
627
618
  // Rate chart id (used to identify the rate chart used to convert the amount )
628
619
  // rcid: z.uuidv4(),
629
620
  ...TimeLog.shape
630
621
  });
631
622
 
632
623
  // src/schemas/company/components/Notifications.ts
633
- var CompanyNotifications = z18.array(Notification).refine(
624
+ var CompanyNotifications = z17.array(Notification).refine(
634
625
  (data) => data.every((notif) => notif.code !== "COMPANY_INVITE"),
635
626
  "A company can't receive a company invite."
636
627
  );
637
628
 
638
629
  // src/schemas/company/utils/CreateCompanyForm.ts
639
- import * as z19 from "zod";
640
- var CreateCompanyForm = z19.object({
630
+ import * as z18 from "zod";
631
+ var CreateCompanyForm = z18.object({
641
632
  alias: CompanyIdentity.shape.alias.optional(),
642
633
  ...CompanyIdentity.pick({
643
634
  _id: true,
@@ -655,60 +646,60 @@ var CreateCompanyForm = z19.object({
655
646
  });
656
647
 
657
648
  // src/schemas/task/components/Medical.ts
658
- import * as z20 from "zod";
659
- var Vitals = z20.record(
649
+ import * as z19 from "zod";
650
+ var Vitals = z19.record(
660
651
  vitalKeys,
661
- z20.object({
662
- value: z20.string().trim().regex(/^\d{0,3}((\/|\.)\d{1,3})?/),
652
+ z19.object({
653
+ value: z19.string().trim().regex(/^\d{0,3}((\/|\.)\d{1,3})?/),
663
654
  lastModified: Timestamp.nullable()
664
655
  })
665
656
  );
666
- var Medicine = z20.object({
667
- brand: z20.string().trim(),
657
+ var Medicine = z19.object({
658
+ brand: z19.string().trim(),
668
659
  expiresAt: Timestamp.nullish(),
669
- quantity: z20.string().trim().regex(/^\d+(\.\d{1,3})? ?[a-zA-Z]{1,20}/, {
660
+ quantity: z19.string().trim().regex(/^\d+(\.\d{1,3})? ?[a-zA-Z]{1,20}/, {
670
661
  error: "Failed to match the pattern <number>+(.<number>{1,3})? ?[a-zA-Z]{1,20}"
671
662
  }),
672
- refills: z20.string().trim().regex(/^[0-8]/, { error: "Must be between 0 and 8" }),
673
- directions: z20.string().trim().max(100, { error: "Must be 100 characters or less" }),
663
+ refills: z19.string().trim().regex(/^[0-8]/, { error: "Must be between 0 and 8" }),
664
+ directions: z19.string().trim().max(100, { error: "Must be 100 characters or less" }),
674
665
  ...TimeLog.shape
675
666
  });
676
- var MedicalDetails = z20.object({
667
+ var MedicalDetails = z19.object({
677
668
  vitals: Vitals,
678
- prescriptions: z20.array(z20.array(Medicine)).nullish(),
679
- doctorNote: z20.object({
680
- value: z20.string(),
669
+ prescriptions: z19.array(z19.array(Medicine)).nullish(),
670
+ doctorNote: z19.object({
671
+ value: z19.string(),
681
672
  lastModified: Timestamp.nullable()
682
673
  }),
683
- physAsstNotes: z20.array(
684
- z20.object({
685
- title: z20.string(),
686
- content: z20.string(),
674
+ physAsstNotes: z19.array(
675
+ z19.object({
676
+ title: z19.string(),
677
+ content: z19.string(),
687
678
  ...TimeLog.shape
688
679
  })
689
680
  ).optional()
690
681
  });
691
682
 
692
683
  // src/schemas/task/Task.ts
693
- import * as z21 from "zod";
694
- var TaskSeverity = z21.object({
695
- "1": z21.literal("Emergency"),
696
- "2": z21.literal("Important"),
697
- "3": z21.literal("Average")
684
+ import * as z20 from "zod";
685
+ var TaskSeverity = z20.object({
686
+ "1": z20.literal("Emergency"),
687
+ "2": z20.literal("Important"),
688
+ "3": z20.literal("Average")
698
689
  });
699
- var TaskDetails = z21.object({
690
+ var TaskDetails = z20.object({
700
691
  /** A random uid that identifies the document. */
701
- _id: z21.uuidv4(),
692
+ _id: z20.uuidv4(),
702
693
  /** The amount of credits used to create the appointment */
703
- _cost: z21.number().readonly(),
694
+ _cost: z20.number().readonly(),
704
695
  // This helps to identify the urgency of the appointment
705
- severity: z21.string().refine((data) => TaskSeverity.keyof().safeParse(data).success),
696
+ severity: z20.string().refine((data) => TaskSeverity.keyof().safeParse(data).success),
706
697
  /** The company's uid */
707
698
  src: CompanyState.shape._id,
708
699
  /** The ticket number */
709
700
  tkt: TicketNo,
710
701
  /**The reason for the service */
711
- reason: z21.object({
702
+ reason: z20.object({
712
703
  value: Reason.shape.value,
713
704
  ...TimeLog.shape
714
705
  }),
@@ -729,23 +720,23 @@ var TaskDetails = z21.object({
729
720
  /**Required to calculate the accurate grandTotal of the charges */
730
721
  discounts: CompanyBilling.shape.discounts.optional(),
731
722
  prepayments: CompanyBilling.shape.prepayments.optional(),
732
- payments: z21.array(PaymentDetails).max(100).optional(),
723
+ payments: z20.array(PaymentDetails).max(100).optional(),
733
724
  /** The client's identity */
734
725
  clientId: ClientDetails.shape._id,
735
726
  /**
736
727
  * Data that is specific to the entity (for now it's just medical data).
737
728
  * It will only be defined for the participants that have access to it.
738
729
  */
739
- payload: z21.object({
730
+ payload: z20.object({
740
731
  ...MedicalDetails.shape,
741
732
  lastModified: Timestamp.optional()
742
733
  }).optional(),
743
734
  /** Only defined when either the service provider or the client cancelled their appointment */
744
- cancelled: z21.object({
735
+ cancelled: z20.object({
745
736
  /** The time that the confirm cancel button was clicked */
746
737
  doneAt: Timestamp,
747
738
  reason: Reason,
748
- doneBy: companyUserRoles.extract(["doc", "physAsst", "rcpst"]).or(z21.literal("client"))
739
+ doneBy: companyUserRoles.extract(["doc", "physAsst", "rcpst"]).or(z20.literal("client"))
749
740
  }).optional(),
750
741
  //** Add this after consulting with company owners about payment expectations */
751
742
  // paymentDueDate: Timestamp.nullish(),
@@ -756,17 +747,17 @@ var TaskDetails = z21.object({
756
747
  * [1] Ommitted -> any user with that role that's from the same company can access the TaskDetails.
757
748
  * [1] Addded -> only the users that have that role and an id in the respective array can access the TaskDetails.
758
749
  */
759
- rbac: z21.record(companyUserRoles, z21.array(UserDetails.shape._id).optional()),
760
- timeline: z21.record(
750
+ rbac: z20.record(companyUserRoles, z20.array(UserDetails.shape._id).optional()),
751
+ timeline: z20.record(
761
752
  UserDetails.shape._id,
762
- z21.object({
753
+ z20.object({
763
754
  /** Removed to rely on a single source of truth (audit logs stored in s3)
764
755
  * as it relates to a user's roles at any given time.
765
756
  */
766
757
  // roles: CompanyMemberRoles,
767
758
  postedAt: Timestamp,
768
759
  // Use null as an indicator that this is intentionally undefined.
769
- changes: z21.record(z21.string(), z21.any()).nullable()
760
+ changes: z20.record(z20.string(), z20.any()).nullable()
770
761
  }).optional()
771
762
  ),
772
763
  // z.object({
@@ -787,13 +778,13 @@ var TaskDetails = z21.object({
787
778
  // } satisfies Record<z.infer<typeof serviceProviders>, any>),
788
779
  ...TimeLog.shape
789
780
  });
790
- var MutableAppointmentDetails = TaskDetails.safeExtend(
791
- z21.object({
781
+ var MutableTaskDetails = TaskDetails.safeExtend(
782
+ z20.object({
792
783
  /**
793
784
  * @description An encrypted copy of the last state of the appointment.
794
785
  * @note Used to accurately update the appointment without having to query the database
795
786
  */
796
- _hash: z21.string()
787
+ _hash: z20.string()
797
788
  }).shape
798
789
  );
799
790
 
@@ -859,12 +850,12 @@ export {
859
850
  MAX_COMPANY_PRICE_MODS,
860
851
  MedicalDetails,
861
852
  Medicine,
862
- MutableAppointmentDetails,
863
853
  MutableCompanyBilling,
864
854
  MutableCompanyDetails,
865
855
  MutableCompanyIdentity,
866
856
  MutableCompanyPreferences,
867
857
  MutableCompanyStaff,
858
+ MutableTaskDetails,
868
859
  Notification,
869
860
  PaymentDetails,
870
861
  PriceMod,
@@ -898,7 +889,6 @@ export {
898
889
  normalizeNidKey,
899
890
  parseClientName,
900
891
  paymentMethods,
901
- serviceProviders,
902
892
  taskDistAlgs,
903
893
  tiers,
904
894
  vitalKeys
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bizmap/sdk",
3
- "version": "0.0.121",
3
+ "version": "0.0.122",
4
4
  "main": "./dist/main.js",
5
5
  "types": "./dist/main.d.ts",
6
6
  "type": "module",