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