@bizmap/sdk 0.0.48 → 0.0.50
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 +48 -48
- package/dist/main.js +168 -168
- package/package.json +1 -1
package/dist/main.d.ts
CHANGED
|
@@ -1,5 +1,49 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
|
|
3
|
+
declare const companyUserRoles: z.ZodEnum<{
|
|
4
|
+
doc: "doc";
|
|
5
|
+
physAsst: "physAsst";
|
|
6
|
+
rcpst: "rcpst";
|
|
7
|
+
cshr: "cshr";
|
|
8
|
+
admin: "admin";
|
|
9
|
+
}>;
|
|
10
|
+
type CompanyUserRole = z.infer<typeof companyUserRoles>;
|
|
11
|
+
declare const companyPartnerRoles: z.ZodEnum<{
|
|
12
|
+
doc: "doc";
|
|
13
|
+
physAsst: "physAsst";
|
|
14
|
+
}>;
|
|
15
|
+
type CompanyPartnerRole = z.infer<typeof companyPartnerRoles>;
|
|
16
|
+
declare const employeeRoles: z.ZodEnum<{
|
|
17
|
+
doc: "doc";
|
|
18
|
+
physAsst: "physAsst";
|
|
19
|
+
rcpst: "rcpst";
|
|
20
|
+
cshr: "cshr";
|
|
21
|
+
}>;
|
|
22
|
+
type EmployeeRole = z.infer<typeof employeeRoles>;
|
|
23
|
+
declare const healthcareProviderRoles: z.ZodEnum<{
|
|
24
|
+
doc: "doc";
|
|
25
|
+
physAsst: "physAsst";
|
|
26
|
+
}>;
|
|
27
|
+
type HealthcareProviderRole = z.infer<typeof healthcareProviderRoles>;
|
|
28
|
+
declare const appointmentDistAlgs: z.ZodEnum<{
|
|
29
|
+
RR: "RR";
|
|
30
|
+
LOR: "LOR";
|
|
31
|
+
}>;
|
|
32
|
+
type AppointmentDistAlg = z.infer<typeof appointmentDistAlgs>;
|
|
33
|
+
declare const companyServiceSelectors: z.ZodEnum<{
|
|
34
|
+
scheduler: "scheduler";
|
|
35
|
+
doctor: "doctor";
|
|
36
|
+
}>;
|
|
37
|
+
type CompanyServiceSelector = z.infer<typeof companyServiceSelectors>;
|
|
38
|
+
|
|
39
|
+
declare const tiers: z.ZodEnum<{
|
|
40
|
+
free: "free";
|
|
41
|
+
pro: "pro";
|
|
42
|
+
premium: "premium";
|
|
43
|
+
gold: "gold";
|
|
44
|
+
}>;
|
|
45
|
+
type Tier = z.infer<typeof tiers>;
|
|
46
|
+
|
|
3
47
|
declare const PricingRate: z.ZodObject<{
|
|
4
48
|
companyRegistration: z.ZodObject<{
|
|
5
49
|
flatFee: z.ZodNumber;
|
|
@@ -176,7 +220,7 @@ declare const CompanyDetails: z.ZodObject<{
|
|
|
176
220
|
percentage: z.ZodNumber;
|
|
177
221
|
}, z.core.$strip>>>;
|
|
178
222
|
services: z.ZodObject<{
|
|
179
|
-
|
|
223
|
+
deployed: z.ZodBoolean;
|
|
180
224
|
value: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
181
225
|
createdAt: z.ZodReadonly<z.ZodInt>;
|
|
182
226
|
lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
|
|
@@ -201,7 +245,7 @@ declare const CompanyDetails: z.ZodObject<{
|
|
|
201
245
|
percentage: z.ZodNumber;
|
|
202
246
|
}, z.core.$strip>>>;
|
|
203
247
|
services: z.ZodObject<{
|
|
204
|
-
|
|
248
|
+
deployed: z.ZodBoolean;
|
|
205
249
|
value: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
206
250
|
createdAt: z.ZodReadonly<z.ZodInt>;
|
|
207
251
|
lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
|
|
@@ -564,7 +608,7 @@ declare const PartialCompanyDetails: z.ZodObject<{
|
|
|
564
608
|
percentage: z.ZodNumber;
|
|
565
609
|
}, z.core.$strip>>>;
|
|
566
610
|
services: z.ZodObject<{
|
|
567
|
-
|
|
611
|
+
deployed: z.ZodBoolean;
|
|
568
612
|
value: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
569
613
|
createdAt: z.ZodReadonly<z.ZodInt>;
|
|
570
614
|
lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
|
|
@@ -589,7 +633,7 @@ declare const PartialCompanyDetails: z.ZodObject<{
|
|
|
589
633
|
percentage: z.ZodNumber;
|
|
590
634
|
}, z.core.$strip>>>;
|
|
591
635
|
services: z.ZodObject<{
|
|
592
|
-
|
|
636
|
+
deployed: z.ZodBoolean;
|
|
593
637
|
value: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
594
638
|
createdAt: z.ZodReadonly<z.ZodInt>;
|
|
595
639
|
lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
|
|
@@ -874,50 +918,6 @@ declare const TimeLog: z.ZodObject<{
|
|
|
874
918
|
}, z.core.$strip>;
|
|
875
919
|
type TimeLog = z.infer<typeof TimeLog>;
|
|
876
920
|
|
|
877
|
-
declare const companyUserRoles: z.ZodEnum<{
|
|
878
|
-
doc: "doc";
|
|
879
|
-
physAsst: "physAsst";
|
|
880
|
-
rcpst: "rcpst";
|
|
881
|
-
cshr: "cshr";
|
|
882
|
-
admin: "admin";
|
|
883
|
-
}>;
|
|
884
|
-
type CompanyUserRole = z.infer<typeof companyUserRoles>;
|
|
885
|
-
declare const companyPartnerRoles: z.ZodEnum<{
|
|
886
|
-
doc: "doc";
|
|
887
|
-
physAsst: "physAsst";
|
|
888
|
-
}>;
|
|
889
|
-
type CompanyPartnerRole = z.infer<typeof companyPartnerRoles>;
|
|
890
|
-
declare const employeeRoles: z.ZodEnum<{
|
|
891
|
-
doc: "doc";
|
|
892
|
-
physAsst: "physAsst";
|
|
893
|
-
rcpst: "rcpst";
|
|
894
|
-
cshr: "cshr";
|
|
895
|
-
}>;
|
|
896
|
-
type EmployeeRole = z.infer<typeof employeeRoles>;
|
|
897
|
-
declare const healthcareProviderRoles: z.ZodEnum<{
|
|
898
|
-
doc: "doc";
|
|
899
|
-
physAsst: "physAsst";
|
|
900
|
-
}>;
|
|
901
|
-
type HealthcareProviderRole = z.infer<typeof healthcareProviderRoles>;
|
|
902
|
-
declare const appointmentDistAlgs: z.ZodEnum<{
|
|
903
|
-
RR: "RR";
|
|
904
|
-
LOR: "LOR";
|
|
905
|
-
}>;
|
|
906
|
-
type AppointmentDistAlg = z.infer<typeof appointmentDistAlgs>;
|
|
907
|
-
declare const companyServiceSelectors: z.ZodEnum<{
|
|
908
|
-
scheduler: "scheduler";
|
|
909
|
-
doctor: "doctor";
|
|
910
|
-
}>;
|
|
911
|
-
type CompanyServiceSelector = z.infer<typeof companyServiceSelectors>;
|
|
912
|
-
|
|
913
|
-
declare const tiers: z.ZodEnum<{
|
|
914
|
-
free: "free";
|
|
915
|
-
pro: "pro";
|
|
916
|
-
premium: "premium";
|
|
917
|
-
gold: "gold";
|
|
918
|
-
}>;
|
|
919
|
-
type Tier = z.infer<typeof tiers>;
|
|
920
|
-
|
|
921
921
|
/**@returns an array of the users that have conflicting roles or are incompatible with the other partners, or null if none was found. */
|
|
922
922
|
declare const findConflictingPartners: (...partners: CompanyUser[]) => {
|
|
923
923
|
createdAt: number;
|
package/dist/main.js
CHANGED
|
@@ -1,96 +1,178 @@
|
|
|
1
|
-
// src/
|
|
1
|
+
// src/enums/CompanyEnums.ts
|
|
2
|
+
import * as z from "zod";
|
|
3
|
+
var companyUserRoles = z.enum([
|
|
4
|
+
"doc",
|
|
5
|
+
"physAsst",
|
|
6
|
+
"rcpst",
|
|
7
|
+
"cshr",
|
|
8
|
+
"admin"
|
|
9
|
+
]);
|
|
10
|
+
var companyPartnerRoles = companyUserRoles.extract([
|
|
11
|
+
"doc",
|
|
12
|
+
"physAsst"
|
|
13
|
+
]);
|
|
14
|
+
var employeeRoles = companyUserRoles.exclude(["admin"]);
|
|
15
|
+
var healthcareProviderRoles = companyUserRoles.extract([
|
|
16
|
+
"physAsst",
|
|
17
|
+
"doc"
|
|
18
|
+
]);
|
|
19
|
+
var appointmentDistAlgs = z.enum(["RR", "LOR"]);
|
|
20
|
+
var companyServiceSelectors = z.enum(["scheduler", "doctor"]);
|
|
21
|
+
|
|
22
|
+
// src/enums/Global.ts
|
|
2
23
|
import * as z2 from "zod";
|
|
24
|
+
var tiers = z2.enum(["free", "pro", "premium", "gold"]);
|
|
25
|
+
|
|
26
|
+
// src/schemas/Billing.ts
|
|
27
|
+
import * as z4 from "zod";
|
|
3
28
|
|
|
4
29
|
// src/schemas/utils.ts
|
|
5
30
|
import { validate, version } from "uuid";
|
|
6
|
-
import * as
|
|
7
|
-
var InvoiceNo =
|
|
31
|
+
import * as z3 from "zod";
|
|
32
|
+
var InvoiceNo = z3.string().regex(
|
|
8
33
|
/^[0-9]{4}-(01|(0[2-9])|(1[0-2]))-(30|31|([1-2][0-9])|0[1-9])-[0-9]{7}/,
|
|
9
34
|
'An invoice no. must match the pattern "yyyy-mm-dd-9999999".'
|
|
10
35
|
);
|
|
11
|
-
var UuidV4 =
|
|
36
|
+
var UuidV4 = z3.string().readonly().refine(
|
|
12
37
|
(uid) => validate(uid) && version(uid) === 4,
|
|
13
38
|
"Expected a v4 uuid but received an invalid uuid."
|
|
14
39
|
);
|
|
15
|
-
var UuidV7 =
|
|
40
|
+
var UuidV7 = z3.string().readonly().refine(
|
|
16
41
|
(uid) => validate(uid) && version(uid) === 7,
|
|
17
42
|
"Expected a v7 uuid but received an invalid uuid."
|
|
18
43
|
);
|
|
19
|
-
var Jwt =
|
|
44
|
+
var Jwt = z3.string().regex(
|
|
20
45
|
/^[A-Za-z0-9_-]{2,}(?:\.[A-Za-z0-9_-]{2,}){2}$/,
|
|
21
46
|
"An invalid jwt token was used."
|
|
22
47
|
);
|
|
23
|
-
var StandardTime =
|
|
48
|
+
var StandardTime = z3.string().regex(
|
|
24
49
|
/^(01|(0[2-9])|(1[0-2])):(([1-5][0-9])|0[0-9]) (am|pm)/i,
|
|
25
50
|
"A standard time must match the pattern hh:mm A."
|
|
26
51
|
);
|
|
27
|
-
var Timestamp =
|
|
52
|
+
var Timestamp = z3.int().refine(
|
|
28
53
|
(t) => t.toString().length === 13,
|
|
29
54
|
"A timestamp must have (13) digits."
|
|
30
55
|
).positive();
|
|
31
|
-
var InviteResponse =
|
|
32
|
-
var TimeLog =
|
|
56
|
+
var InviteResponse = z3.enum(["accepted", "declined"]);
|
|
57
|
+
var TimeLog = z3.object({
|
|
33
58
|
createdAt: Timestamp.readonly(),
|
|
34
59
|
lastModified: Timestamp.nullish()
|
|
35
60
|
});
|
|
36
61
|
|
|
37
62
|
// src/schemas/Billing.ts
|
|
38
|
-
var PricingRate =
|
|
39
|
-
companyRegistration:
|
|
40
|
-
flatFee:
|
|
41
|
-
feePerUser:
|
|
63
|
+
var PricingRate = z4.object({
|
|
64
|
+
companyRegistration: z4.object({
|
|
65
|
+
flatFee: z4.number().min(0),
|
|
66
|
+
feePerUser: z4.number().min(0),
|
|
42
67
|
lastModified: Timestamp
|
|
43
68
|
})
|
|
44
69
|
});
|
|
45
|
-
var PriceAdjustment =
|
|
46
|
-
description:
|
|
47
|
-
fixedAmount:
|
|
48
|
-
percentage:
|
|
70
|
+
var PriceAdjustment = z4.object({
|
|
71
|
+
description: z4.string().trim().min(3, "A description must have atleast (3) characters.").max(25, "A description can't have more that (25) characters.").optional(),
|
|
72
|
+
fixedAmount: z4.number().min(0).max(1e6, "The max fixed amount is $1,000,000.00"),
|
|
73
|
+
percentage: z4.number().min(0).max(1e3, "The max percentage is 1,000%"),
|
|
49
74
|
...TimeLog.shape
|
|
50
75
|
});
|
|
51
|
-
var PriceTag =
|
|
76
|
+
var PriceTag = z4.object({
|
|
52
77
|
uid: UuidV4,
|
|
53
78
|
/**The name of the item that's being priced */
|
|
54
|
-
item:
|
|
55
|
-
cost:
|
|
79
|
+
item: z4.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."),
|
|
80
|
+
cost: z4.number().min(1, "The minimum allowed cost is $1.00").max(1e9, "The max allowed cost is $1,000,000,000.00."),
|
|
56
81
|
...TimeLog.shape
|
|
57
82
|
});
|
|
58
83
|
|
|
59
84
|
// src/schemas/Company.ts
|
|
60
85
|
import { Address, PhoneNumber, UserModel } from "@wavy/util";
|
|
61
|
-
import * as
|
|
86
|
+
import * as z6 from "zod";
|
|
62
87
|
|
|
63
|
-
// src/
|
|
64
|
-
import * as
|
|
65
|
-
var
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
var
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
88
|
+
// src/schemas/Global.ts
|
|
89
|
+
import * as z5 from "zod";
|
|
90
|
+
var TierList = z5.record(
|
|
91
|
+
tiers,
|
|
92
|
+
z5.object({
|
|
93
|
+
cost: z5.number().min(0),
|
|
94
|
+
perks: z5.array(z5.string()).min(1)
|
|
95
|
+
})
|
|
96
|
+
).superRefine((data, ctx) => {
|
|
97
|
+
if (data.free.cost !== 0) {
|
|
98
|
+
ctx.addIssue("The free tier must always cost $0.00");
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
var Notification = z5.object({
|
|
102
|
+
code: z5.literal(["COMPANY_INVITE", "INVITE_RESPONSE", "DEV_MESSAGE"]),
|
|
103
|
+
payload: z5.string(),
|
|
104
|
+
seen: z5.boolean(),
|
|
105
|
+
src: z5.object({
|
|
106
|
+
name: z5.string(),
|
|
107
|
+
photoUrl: z5.string().nullish()
|
|
108
|
+
}),
|
|
109
|
+
expiresAt: Timestamp.nullish(),
|
|
110
|
+
createdAt: Timestamp
|
|
111
|
+
}).superRefine((data, ctx) => {
|
|
112
|
+
switch (data.code) {
|
|
113
|
+
case "COMPANY_INVITE":
|
|
114
|
+
if (!Jwt.safeParse(data.payload).success) {
|
|
115
|
+
ctx.addIssue("The payload of company invite must be a valid jwt.");
|
|
116
|
+
}
|
|
117
|
+
break;
|
|
118
|
+
case "DEV_MESSAGE":
|
|
119
|
+
if ((data.payload?.length ?? 0) < 3) {
|
|
120
|
+
ctx.addIssue("A dev message must have at least (3) characters.");
|
|
121
|
+
}
|
|
122
|
+
break;
|
|
123
|
+
case "INVITE_RESPONSE":
|
|
124
|
+
if (!InviteResponse.safeParse(data.payload).success) {
|
|
125
|
+
ctx.addIssue(
|
|
126
|
+
`An invite response must be one of the following: ${InviteResponse.options.join()}.`
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
break;
|
|
130
|
+
default:
|
|
131
|
+
return data.code;
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
// src/functions/helper-functions.ts
|
|
136
|
+
var findConflictingPartners = (...partners) => {
|
|
137
|
+
let hasSingleDoctor = false;
|
|
138
|
+
const conflicts = [];
|
|
139
|
+
if (!partners) return partners;
|
|
140
|
+
for (const partner of partners) {
|
|
141
|
+
if (!partner.roles || partner.roles.some(
|
|
142
|
+
(r) => !companyPartnerRoles.options.includes(r)
|
|
143
|
+
) || !CompanyUser.shape.roles.safeParse(partner.roles).success) {
|
|
144
|
+
conflicts.push(partner);
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
if (partner.roles.includes("doc") && !hasSingleDoctor) {
|
|
148
|
+
hasSingleDoctor = true;
|
|
149
|
+
} else if (partner.roles.includes("doc")) {
|
|
150
|
+
conflicts.push(partner);
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return conflicts.length === 0 ? null : conflicts;
|
|
155
|
+
};
|
|
156
|
+
var getCompatibleRoles = (role) => {
|
|
157
|
+
if (role === "physAsst") {
|
|
158
|
+
return companyUserRoles.exclude(["admin", "doc", role]).options;
|
|
159
|
+
}
|
|
160
|
+
if (role === "admin" || role === "doc") {
|
|
161
|
+
return companyUserRoles.exclude(["physAsst", role]).options;
|
|
162
|
+
}
|
|
163
|
+
return companyUserRoles.exclude([role]).options;
|
|
164
|
+
};
|
|
83
165
|
|
|
84
166
|
// src/schemas/Company.ts
|
|
85
|
-
var CompanyUser =
|
|
167
|
+
var CompanyUser = z6.object({
|
|
86
168
|
...UserModel.shape,
|
|
87
169
|
uid: UuidV7,
|
|
88
|
-
status:
|
|
89
|
-
availability:
|
|
90
|
-
isAvailable:
|
|
170
|
+
status: z6.enum(["inviteSent", "active", "inactive"]),
|
|
171
|
+
availability: z6.object({
|
|
172
|
+
isAvailable: z6.boolean().default(true),
|
|
91
173
|
lastModified: Timestamp.nullable().default(null)
|
|
92
174
|
}),
|
|
93
|
-
roles:
|
|
175
|
+
roles: z6.array(companyUserRoles).transform((roles) => {
|
|
94
176
|
const newRoles = [];
|
|
95
177
|
for (const role of roles) {
|
|
96
178
|
if (!!role && !newRoles.includes(role)) newRoles.push(role);
|
|
@@ -101,11 +183,11 @@ var CompanyUser = z4.object({
|
|
|
101
183
|
(role, i) => i === 0 || getCompatibleRoles(roles[0]).includes(role)
|
|
102
184
|
);
|
|
103
185
|
}, "A user is not allowed to have conflicting roles."),
|
|
104
|
-
isBusy:
|
|
186
|
+
isBusy: z6.boolean(),
|
|
105
187
|
/** This should reset at the end of every cycle. */
|
|
106
|
-
appointmentCounter:
|
|
107
|
-
|
|
108
|
-
|
|
188
|
+
appointmentCounter: z6.record(
|
|
189
|
+
z6.literal(["ongoing", "completed"]),
|
|
190
|
+
z6.int().min(0)
|
|
109
191
|
),
|
|
110
192
|
lastActive: Timestamp,
|
|
111
193
|
...TimeLog.shape
|
|
@@ -119,43 +201,43 @@ var CompanyUser = z4.object({
|
|
|
119
201
|
);
|
|
120
202
|
}
|
|
121
203
|
});
|
|
122
|
-
var CompanyIdentity =
|
|
123
|
-
displayName:
|
|
124
|
-
logo:
|
|
125
|
-
contact:
|
|
126
|
-
email:
|
|
204
|
+
var CompanyIdentity = z6.object({
|
|
205
|
+
displayName: z6.string().min(3).max(25),
|
|
206
|
+
logo: z6.string().max(2500).nullish(),
|
|
207
|
+
contact: z6.object({
|
|
208
|
+
email: z6.email().max(25),
|
|
127
209
|
phoneNumber: PhoneNumber.optional()
|
|
128
210
|
}),
|
|
129
211
|
address: Address,
|
|
130
212
|
// Can only be changed by the server
|
|
131
|
-
tier:
|
|
213
|
+
tier: z6.object({
|
|
132
214
|
current: tiers,
|
|
133
215
|
lastModified: Timestamp.nullable()
|
|
134
216
|
}),
|
|
135
|
-
legal:
|
|
136
|
-
regNo:
|
|
217
|
+
legal: z6.object({
|
|
218
|
+
regNo: z6.string().max(20).readonly(),
|
|
137
219
|
// The company's registration number
|
|
138
|
-
trn:
|
|
139
|
-
gctRegNo:
|
|
220
|
+
trn: z6.string().regex(/[0-9]{3}-[0-9]{3}-[0-9]{3}/).nullish(),
|
|
221
|
+
gctRegNo: z6.string().max(15).nullish()
|
|
140
222
|
}),
|
|
141
223
|
lastModified: Timestamp.nullable()
|
|
142
224
|
});
|
|
143
|
-
var CompanyState =
|
|
225
|
+
var CompanyState = z6.object({
|
|
144
226
|
// This can only be changed by the server/app admin
|
|
145
|
-
availableBalance:
|
|
146
|
-
current:
|
|
227
|
+
availableBalance: z6.object({
|
|
228
|
+
current: z6.number(),
|
|
147
229
|
lastModified: Timestamp.nullable()
|
|
148
230
|
}),
|
|
149
231
|
/** A counter for the company's invoice no.
|
|
150
232
|
* @note This should only be null when the cycle resets
|
|
151
233
|
*/
|
|
152
|
-
invoiceNoCounter:
|
|
234
|
+
invoiceNoCounter: z6.int().min(1),
|
|
153
235
|
/** A counter for the company's ticket no. */
|
|
154
|
-
tktNoCounter:
|
|
236
|
+
tktNoCounter: z6.int().min(1),
|
|
155
237
|
lastSavedAt: Timestamp.nullable(),
|
|
156
238
|
lastModified: Timestamp.nullable()
|
|
157
239
|
});
|
|
158
|
-
var CompanyPreferences =
|
|
240
|
+
var CompanyPreferences = z6.object({
|
|
159
241
|
/** The user that's allowed to record the client's services. */
|
|
160
242
|
serviceSelector: companyServiceSelectors,
|
|
161
243
|
/** A record of the payments made must be attached before creating the
|
|
@@ -163,7 +245,7 @@ var CompanyPreferences = z4.object({
|
|
|
163
245
|
* @note
|
|
164
246
|
* - only allowed when `serviceDecider === "scheduler"`
|
|
165
247
|
* */
|
|
166
|
-
enforcePaidAppts:
|
|
248
|
+
enforcePaidAppts: z6.boolean(),
|
|
167
249
|
/**
|
|
168
250
|
* @property RR (Round Robin): Even distribution.
|
|
169
251
|
* @property LOR (Least Outstanding Requests): Distribute based on availability.
|
|
@@ -171,21 +253,21 @@ var CompanyPreferences = z4.object({
|
|
|
171
253
|
apptDistAlg: appointmentDistAlgs.default("RR"),
|
|
172
254
|
lastModified: Timestamp.nullable()
|
|
173
255
|
});
|
|
174
|
-
var Billing =
|
|
175
|
-
additionalFees:
|
|
176
|
-
discounts:
|
|
177
|
-
services:
|
|
256
|
+
var Billing = z6.object({
|
|
257
|
+
additionalFees: z6.array(PriceAdjustment).default([]),
|
|
258
|
+
discounts: z6.array(PriceAdjustment).default([]),
|
|
259
|
+
services: z6.object({
|
|
178
260
|
/** Forces service selectors to use the list of service(s) that you've created. */
|
|
179
|
-
|
|
180
|
-
value:
|
|
261
|
+
deployed: z6.boolean(),
|
|
262
|
+
value: z6.array(PriceTag.omit({ uid: true })).max(100).default([])
|
|
181
263
|
}).refine(
|
|
182
|
-
(data) => !data.
|
|
264
|
+
(data) => !data.deployed || data.deployed && data.value.length > 0,
|
|
183
265
|
"You must create at least (1) service in order to deploy your service list."
|
|
184
266
|
),
|
|
185
267
|
lastModified: Timestamp.nullable()
|
|
186
268
|
});
|
|
187
|
-
var Staff =
|
|
188
|
-
members:
|
|
269
|
+
var Staff = z6.object({
|
|
270
|
+
members: z6.record(CompanyUser.shape.uid, CompanyUser).superRefine((data, ctx) => {
|
|
189
271
|
const emails = [];
|
|
190
272
|
for (const [uid, user] of Object.entries(data)) {
|
|
191
273
|
if (uid !== user.uid) {
|
|
@@ -205,15 +287,15 @@ var Staff = z4.object({
|
|
|
205
287
|
/**
|
|
206
288
|
* @relationship one -> many
|
|
207
289
|
*@description A map of doctor `uids` to their assistants `uids` */
|
|
208
|
-
partnerMap:
|
|
290
|
+
partnerMap: z6.record(
|
|
209
291
|
CompanyUser.shape.uid,
|
|
210
|
-
|
|
292
|
+
z6.record(CompanyUser.shape.uid, z6.object({ addedAt: Timestamp }))
|
|
211
293
|
),
|
|
212
|
-
updateQueue:
|
|
294
|
+
updateQueue: z6.record(
|
|
213
295
|
CompanyUser.shape.uid,
|
|
214
|
-
|
|
215
|
-
$REMOVE:
|
|
216
|
-
$CHANGE_ROLES:
|
|
296
|
+
z6.object({
|
|
297
|
+
$REMOVE: z6.object({ addedAt: Timestamp }),
|
|
298
|
+
$CHANGE_ROLES: z6.object({
|
|
217
299
|
newRoles: CompanyUser.shape.roles,
|
|
218
300
|
addedAt: Timestamp
|
|
219
301
|
})
|
|
@@ -274,12 +356,12 @@ var Staff = z4.object({
|
|
|
274
356
|
}
|
|
275
357
|
}
|
|
276
358
|
});
|
|
277
|
-
var Receipts =
|
|
359
|
+
var Receipts = z6.array(PriceTag.omit({ uid: true, lastModified: true }));
|
|
278
360
|
var createCompanyDetails = (options) => {
|
|
279
|
-
return
|
|
361
|
+
return z6.object({
|
|
280
362
|
uid: UuidV7,
|
|
281
363
|
identity: CompanyIdentity,
|
|
282
|
-
notifications: options.partial ?
|
|
364
|
+
notifications: options.partial ? z6.array(Notification).nullish() : z6.array(Notification),
|
|
283
365
|
receipts: options.partial ? Receipts.nullish() : Receipts,
|
|
284
366
|
state: options.partial ? CompanyState.nullish() : CompanyState,
|
|
285
367
|
preferences: options.partial ? CompanyPreferences.nullish() : CompanyPreferences,
|
|
@@ -290,88 +372,6 @@ var createCompanyDetails = (options) => {
|
|
|
290
372
|
};
|
|
291
373
|
var CompanyDetails = createCompanyDetails({ partial: false });
|
|
292
374
|
var PartialCompanyDetails = createCompanyDetails({ partial: true });
|
|
293
|
-
|
|
294
|
-
// src/schemas/Global.ts
|
|
295
|
-
import * as z5 from "zod";
|
|
296
|
-
var TierList = z5.record(
|
|
297
|
-
tiers,
|
|
298
|
-
z5.object({
|
|
299
|
-
cost: z5.number().min(0),
|
|
300
|
-
perks: z5.array(z5.string()).min(1)
|
|
301
|
-
})
|
|
302
|
-
).superRefine((data, ctx) => {
|
|
303
|
-
if (data.free.cost !== 0) {
|
|
304
|
-
ctx.addIssue("The free tier must always cost $0.00");
|
|
305
|
-
}
|
|
306
|
-
});
|
|
307
|
-
var Notification = z5.object({
|
|
308
|
-
code: z5.literal(["COMPANY_INVITE", "INVITE_RESPONSE", "DEV_MESSAGE"]),
|
|
309
|
-
payload: z5.string(),
|
|
310
|
-
seen: z5.boolean(),
|
|
311
|
-
src: z5.object({
|
|
312
|
-
name: z5.string(),
|
|
313
|
-
photoUrl: z5.string().nullish()
|
|
314
|
-
}),
|
|
315
|
-
expiresAt: Timestamp.nullish(),
|
|
316
|
-
createdAt: Timestamp
|
|
317
|
-
}).superRefine((data, ctx) => {
|
|
318
|
-
switch (data.code) {
|
|
319
|
-
case "COMPANY_INVITE":
|
|
320
|
-
if (!Jwt.safeParse(data.payload).success) {
|
|
321
|
-
ctx.addIssue("The payload of company invite must be a valid jwt.");
|
|
322
|
-
}
|
|
323
|
-
break;
|
|
324
|
-
case "DEV_MESSAGE":
|
|
325
|
-
if ((data.payload?.length ?? 0) < 3) {
|
|
326
|
-
ctx.addIssue("A dev message must have at least (3) characters.");
|
|
327
|
-
}
|
|
328
|
-
break;
|
|
329
|
-
case "INVITE_RESPONSE":
|
|
330
|
-
if (!InviteResponse.safeParse(data.payload).success) {
|
|
331
|
-
ctx.addIssue(
|
|
332
|
-
`An invite response must be one of the following: ${InviteResponse.options.join()}.`
|
|
333
|
-
);
|
|
334
|
-
}
|
|
335
|
-
break;
|
|
336
|
-
default:
|
|
337
|
-
return data.code;
|
|
338
|
-
}
|
|
339
|
-
});
|
|
340
|
-
|
|
341
|
-
// src/enums/Global.ts
|
|
342
|
-
import * as z6 from "zod";
|
|
343
|
-
var tiers = z6.enum(["free", "pro", "premium", "gold"]);
|
|
344
|
-
|
|
345
|
-
// src/functions/helper-functions.ts
|
|
346
|
-
var findConflictingPartners = (...partners) => {
|
|
347
|
-
let hasSingleDoctor = false;
|
|
348
|
-
const conflicts = [];
|
|
349
|
-
if (!partners) return partners;
|
|
350
|
-
for (const partner of partners) {
|
|
351
|
-
if (!partner.roles || partner.roles.some(
|
|
352
|
-
(r) => !companyPartnerRoles.options.includes(r)
|
|
353
|
-
) || !CompanyUser.shape.roles.safeParse(partner.roles).success) {
|
|
354
|
-
conflicts.push(partner);
|
|
355
|
-
continue;
|
|
356
|
-
}
|
|
357
|
-
if (partner.roles.includes("doc") && !hasSingleDoctor) {
|
|
358
|
-
hasSingleDoctor = true;
|
|
359
|
-
} else if (partner.roles.includes("doc")) {
|
|
360
|
-
conflicts.push(partner);
|
|
361
|
-
continue;
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
return conflicts.length === 0 ? null : conflicts;
|
|
365
|
-
};
|
|
366
|
-
var getCompatibleRoles = (role) => {
|
|
367
|
-
if (role === "physAsst") {
|
|
368
|
-
return companyUserRoles.exclude(["admin", "doc", role]).options;
|
|
369
|
-
}
|
|
370
|
-
if (role === "admin" || role === "doc") {
|
|
371
|
-
return companyUserRoles.exclude(["physAsst", role]).options;
|
|
372
|
-
}
|
|
373
|
-
return companyUserRoles.exclude([role]).options;
|
|
374
|
-
};
|
|
375
375
|
export {
|
|
376
376
|
CompanyDetails,
|
|
377
377
|
CompanyUser,
|