@bizmap/sdk 0.0.49 → 0.0.51

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 +55 -55
  2. package/dist/main.js +179 -168
  3. 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;
@@ -73,7 +117,7 @@ declare const CompanyDetails: z.ZodObject<{
73
117
  country: z.ZodString;
74
118
  }, z.core.$strip>;
75
119
  tier: z.ZodObject<{
76
- value: z.ZodEnum<{
120
+ current: z.ZodEnum<{
77
121
  free: "free";
78
122
  pro: "pro";
79
123
  premium: "premium";
@@ -89,7 +133,7 @@ declare const CompanyDetails: z.ZodObject<{
89
133
  lastModified: z.ZodNullable<z.ZodInt>;
90
134
  }, z.core.$strip>;
91
135
  notifications: z.ZodArray<z.ZodObject<{
92
- code: z.ZodLiteral<"COMPANY_INVITE" | "INVITE_RESPONSE" | "DEV_MESSAGE">;
136
+ code: z.ZodLiteral<"COMPANY_INVITE" | "INVITE_RESPONSE" | "DEV_MESSAGE" | "ALERT">;
93
137
  payload: z.ZodString;
94
138
  seen: z.ZodBoolean;
95
139
  src: z.ZodObject<{
@@ -99,7 +143,7 @@ declare const CompanyDetails: z.ZodObject<{
99
143
  expiresAt: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
100
144
  createdAt: z.ZodInt;
101
145
  }, z.core.$strip>> | z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
102
- code: z.ZodLiteral<"COMPANY_INVITE" | "INVITE_RESPONSE" | "DEV_MESSAGE">;
146
+ code: z.ZodLiteral<"COMPANY_INVITE" | "INVITE_RESPONSE" | "DEV_MESSAGE" | "ALERT">;
103
147
  payload: z.ZodString;
104
148
  seen: z.ZodBoolean;
105
149
  src: z.ZodObject<{
@@ -120,7 +164,7 @@ declare const CompanyDetails: z.ZodObject<{
120
164
  }, z.core.$strip>>>>;
121
165
  state: z.ZodObject<{
122
166
  availableBalance: z.ZodObject<{
123
- value: z.ZodNumber;
167
+ current: z.ZodNumber;
124
168
  lastModified: z.ZodNullable<z.ZodInt>;
125
169
  }, z.core.$strip>;
126
170
  invoiceNoCounter: z.ZodInt;
@@ -129,7 +173,7 @@ declare const CompanyDetails: z.ZodObject<{
129
173
  lastModified: z.ZodNullable<z.ZodInt>;
130
174
  }, z.core.$strip> | z.ZodOptional<z.ZodNullable<z.ZodObject<{
131
175
  availableBalance: z.ZodObject<{
132
- value: z.ZodNumber;
176
+ current: z.ZodNumber;
133
177
  lastModified: z.ZodNullable<z.ZodInt>;
134
178
  }, z.core.$strip>;
135
179
  invoiceNoCounter: z.ZodInt;
@@ -461,7 +505,7 @@ declare const PartialCompanyDetails: z.ZodObject<{
461
505
  country: z.ZodString;
462
506
  }, z.core.$strip>;
463
507
  tier: z.ZodObject<{
464
- value: z.ZodEnum<{
508
+ current: z.ZodEnum<{
465
509
  free: "free";
466
510
  pro: "pro";
467
511
  premium: "premium";
@@ -477,7 +521,7 @@ declare const PartialCompanyDetails: z.ZodObject<{
477
521
  lastModified: z.ZodNullable<z.ZodInt>;
478
522
  }, z.core.$strip>;
479
523
  notifications: z.ZodArray<z.ZodObject<{
480
- code: z.ZodLiteral<"COMPANY_INVITE" | "INVITE_RESPONSE" | "DEV_MESSAGE">;
524
+ code: z.ZodLiteral<"COMPANY_INVITE" | "INVITE_RESPONSE" | "DEV_MESSAGE" | "ALERT">;
481
525
  payload: z.ZodString;
482
526
  seen: z.ZodBoolean;
483
527
  src: z.ZodObject<{
@@ -487,7 +531,7 @@ declare const PartialCompanyDetails: z.ZodObject<{
487
531
  expiresAt: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
488
532
  createdAt: z.ZodInt;
489
533
  }, z.core.$strip>> | z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
490
- code: z.ZodLiteral<"COMPANY_INVITE" | "INVITE_RESPONSE" | "DEV_MESSAGE">;
534
+ code: z.ZodLiteral<"COMPANY_INVITE" | "INVITE_RESPONSE" | "DEV_MESSAGE" | "ALERT">;
491
535
  payload: z.ZodString;
492
536
  seen: z.ZodBoolean;
493
537
  src: z.ZodObject<{
@@ -508,7 +552,7 @@ declare const PartialCompanyDetails: z.ZodObject<{
508
552
  }, z.core.$strip>>>>;
509
553
  state: z.ZodObject<{
510
554
  availableBalance: z.ZodObject<{
511
- value: z.ZodNumber;
555
+ current: z.ZodNumber;
512
556
  lastModified: z.ZodNullable<z.ZodInt>;
513
557
  }, z.core.$strip>;
514
558
  invoiceNoCounter: z.ZodInt;
@@ -517,7 +561,7 @@ declare const PartialCompanyDetails: z.ZodObject<{
517
561
  lastModified: z.ZodNullable<z.ZodInt>;
518
562
  }, z.core.$strip> | z.ZodOptional<z.ZodNullable<z.ZodObject<{
519
563
  availableBalance: z.ZodObject<{
520
- value: z.ZodNumber;
564
+ current: z.ZodNumber;
521
565
  lastModified: z.ZodNullable<z.ZodInt>;
522
566
  }, z.core.$strip>;
523
567
  invoiceNoCounter: z.ZodInt;
@@ -845,7 +889,7 @@ declare const TierList: z.ZodRecord<z.ZodEnum<{
845
889
  }, z.core.$strip>>;
846
890
  type TierList = z.infer<typeof TierList>;
847
891
  declare const Notification: z.ZodObject<{
848
- code: z.ZodLiteral<"COMPANY_INVITE" | "INVITE_RESPONSE" | "DEV_MESSAGE">;
892
+ code: z.ZodLiteral<"COMPANY_INVITE" | "INVITE_RESPONSE" | "DEV_MESSAGE" | "ALERT">;
849
893
  payload: z.ZodString;
850
894
  seen: z.ZodBoolean;
851
895
  src: z.ZodObject<{
@@ -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,189 @@
1
- // src/schemas/Billing.ts
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 z from "zod";
7
- var InvoiceNo = z.string().regex(
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 = z.string().readonly().refine(
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 = z.string().readonly().refine(
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 = z.string().regex(
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 = z.string().regex(
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 = z.int().refine(
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 = z.enum(["accepted", "declined"]);
32
- var TimeLog = z.object({
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 = z2.object({
39
- companyRegistration: z2.object({
40
- flatFee: z2.number().min(0),
41
- feePerUser: z2.number().min(0),
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 = z2.object({
46
- description: z2.string().trim().min(3, "A description must have atleast (3) characters.").max(25, "A description can't have more that (25) characters.").optional(),
47
- fixedAmount: z2.number().min(0).max(1e6, "The max fixed amount is $1,000,000.00"),
48
- percentage: z2.number().min(0).max(1e3, "The max percentage is 1,000%"),
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 = z2.object({
76
+ var PriceTag = z4.object({
52
77
  uid: UuidV4,
53
78
  /**The name of the item that's being priced */
54
- item: z2.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."),
55
- cost: z2.number().min(1, "The minimum allowed cost is $1.00").max(1e9, "The max allowed cost is $1,000,000,000.00."),
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 z4 from "zod";
86
+ import * as z6 from "zod";
62
87
 
63
- // src/enums/CompanyEnums.ts
64
- import * as z3 from "zod";
65
- var companyUserRoles = z3.enum([
66
- "doc",
67
- "physAsst",
68
- "rcpst",
69
- "cshr",
70
- "admin"
71
- ]);
72
- var companyPartnerRoles = companyUserRoles.extract([
73
- "doc",
74
- "physAsst"
75
- ]);
76
- var employeeRoles = companyUserRoles.exclude(["admin"]);
77
- var healthcareProviderRoles = companyUserRoles.extract([
78
- "physAsst",
79
- "doc"
80
- ]);
81
- var appointmentDistAlgs = z3.enum(["RR", "LOR"]);
82
- var companyServiceSelectors = z3.enum(["scheduler", "doctor"]);
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([
103
+ "COMPANY_INVITE",
104
+ "INVITE_RESPONSE",
105
+ "DEV_MESSAGE",
106
+ "ALERT"
107
+ ]),
108
+ payload: z5.string(),
109
+ seen: z5.boolean(),
110
+ src: z5.object({
111
+ name: z5.string(),
112
+ photoUrl: z5.string().nullish()
113
+ }),
114
+ expiresAt: Timestamp.nullish(),
115
+ createdAt: Timestamp
116
+ }).superRefine((data, ctx) => {
117
+ const expectMessage = () => {
118
+ if ((data.payload?.length ?? 0) < 3) {
119
+ ctx.addIssue("The payload must have at least (3) characters.");
120
+ }
121
+ };
122
+ switch (data.code) {
123
+ case "COMPANY_INVITE":
124
+ if (!Jwt.safeParse(data.payload).success) {
125
+ ctx.addIssue("The payload of company invite must be a valid jwt.");
126
+ }
127
+ break;
128
+ case "DEV_MESSAGE":
129
+ expectMessage();
130
+ break;
131
+ case "ALERT":
132
+ expectMessage();
133
+ break;
134
+ case "INVITE_RESPONSE":
135
+ if (!InviteResponse.safeParse(data.payload).success) {
136
+ ctx.addIssue(
137
+ `An invite response must be one of the following: ${InviteResponse.options.join()}.`
138
+ );
139
+ }
140
+ break;
141
+ default:
142
+ return data.code;
143
+ }
144
+ });
145
+
146
+ // src/functions/helper-functions.ts
147
+ var findConflictingPartners = (...partners) => {
148
+ let hasSingleDoctor = false;
149
+ const conflicts = [];
150
+ if (!partners) return partners;
151
+ for (const partner of partners) {
152
+ if (!partner.roles || partner.roles.some(
153
+ (r) => !companyPartnerRoles.options.includes(r)
154
+ ) || !CompanyUser.shape.roles.safeParse(partner.roles).success) {
155
+ conflicts.push(partner);
156
+ continue;
157
+ }
158
+ if (partner.roles.includes("doc") && !hasSingleDoctor) {
159
+ hasSingleDoctor = true;
160
+ } else if (partner.roles.includes("doc")) {
161
+ conflicts.push(partner);
162
+ continue;
163
+ }
164
+ }
165
+ return conflicts.length === 0 ? null : conflicts;
166
+ };
167
+ var getCompatibleRoles = (role) => {
168
+ if (role === "physAsst") {
169
+ return companyUserRoles.exclude(["admin", "doc", role]).options;
170
+ }
171
+ if (role === "admin" || role === "doc") {
172
+ return companyUserRoles.exclude(["physAsst", role]).options;
173
+ }
174
+ return companyUserRoles.exclude([role]).options;
175
+ };
83
176
 
84
177
  // src/schemas/Company.ts
85
- var CompanyUser = z4.object({
178
+ var CompanyUser = z6.object({
86
179
  ...UserModel.shape,
87
180
  uid: UuidV7,
88
- status: z4.enum(["inviteSent", "active", "inactive"]),
89
- availability: z4.object({
90
- isAvailable: z4.boolean().default(true),
181
+ status: z6.enum(["inviteSent", "active", "inactive"]),
182
+ availability: z6.object({
183
+ isAvailable: z6.boolean().default(true),
91
184
  lastModified: Timestamp.nullable().default(null)
92
185
  }),
93
- roles: z4.array(companyUserRoles).transform((roles) => {
186
+ roles: z6.array(companyUserRoles).transform((roles) => {
94
187
  const newRoles = [];
95
188
  for (const role of roles) {
96
189
  if (!!role && !newRoles.includes(role)) newRoles.push(role);
@@ -101,11 +194,11 @@ var CompanyUser = z4.object({
101
194
  (role, i) => i === 0 || getCompatibleRoles(roles[0]).includes(role)
102
195
  );
103
196
  }, "A user is not allowed to have conflicting roles."),
104
- isBusy: z4.boolean(),
197
+ isBusy: z6.boolean(),
105
198
  /** This should reset at the end of every cycle. */
106
- appointmentCounter: z4.record(
107
- z4.literal(["ongoing", "completed"]),
108
- z4.int().min(0)
199
+ appointmentCounter: z6.record(
200
+ z6.literal(["ongoing", "completed"]),
201
+ z6.int().min(0)
109
202
  ),
110
203
  lastActive: Timestamp,
111
204
  ...TimeLog.shape
@@ -119,43 +212,43 @@ var CompanyUser = z4.object({
119
212
  );
120
213
  }
121
214
  });
122
- var CompanyIdentity = z4.object({
123
- displayName: z4.string().min(3).max(25),
124
- logo: z4.string().max(2500).nullish(),
125
- contact: z4.object({
126
- email: z4.email().max(25),
215
+ var CompanyIdentity = z6.object({
216
+ displayName: z6.string().min(3).max(25),
217
+ logo: z6.string().max(2500).nullish(),
218
+ contact: z6.object({
219
+ email: z6.email().max(25),
127
220
  phoneNumber: PhoneNumber.optional()
128
221
  }),
129
222
  address: Address,
130
223
  // Can only be changed by the server
131
- tier: z4.object({
132
- value: tiers,
224
+ tier: z6.object({
225
+ current: tiers,
133
226
  lastModified: Timestamp.nullable()
134
227
  }),
135
- legal: z4.object({
136
- regNo: z4.string().max(20).readonly(),
228
+ legal: z6.object({
229
+ regNo: z6.string().max(20).readonly(),
137
230
  // The company's registration number
138
- trn: z4.string().regex(/[0-9]{3}-[0-9]{3}-[0-9]{3}/).nullish(),
139
- gctRegNo: z4.string().max(15).nullish()
231
+ trn: z6.string().regex(/[0-9]{3}-[0-9]{3}-[0-9]{3}/).nullish(),
232
+ gctRegNo: z6.string().max(15).nullish()
140
233
  }),
141
234
  lastModified: Timestamp.nullable()
142
235
  });
143
- var CompanyState = z4.object({
236
+ var CompanyState = z6.object({
144
237
  // This can only be changed by the server/app admin
145
- availableBalance: z4.object({
146
- value: z4.number(),
238
+ availableBalance: z6.object({
239
+ current: z6.number(),
147
240
  lastModified: Timestamp.nullable()
148
241
  }),
149
242
  /** A counter for the company's invoice no.
150
243
  * @note This should only be null when the cycle resets
151
244
  */
152
- invoiceNoCounter: z4.int().min(1),
245
+ invoiceNoCounter: z6.int().min(1),
153
246
  /** A counter for the company's ticket no. */
154
- tktNoCounter: z4.int().min(1),
247
+ tktNoCounter: z6.int().min(1),
155
248
  lastSavedAt: Timestamp.nullable(),
156
249
  lastModified: Timestamp.nullable()
157
250
  });
158
- var CompanyPreferences = z4.object({
251
+ var CompanyPreferences = z6.object({
159
252
  /** The user that's allowed to record the client's services. */
160
253
  serviceSelector: companyServiceSelectors,
161
254
  /** A record of the payments made must be attached before creating the
@@ -163,7 +256,7 @@ var CompanyPreferences = z4.object({
163
256
  * @note
164
257
  * - only allowed when `serviceDecider === "scheduler"`
165
258
  * */
166
- enforcePaidAppts: z4.boolean(),
259
+ enforcePaidAppts: z6.boolean(),
167
260
  /**
168
261
  * @property RR (Round Robin): Even distribution.
169
262
  * @property LOR (Least Outstanding Requests): Distribute based on availability.
@@ -171,21 +264,21 @@ var CompanyPreferences = z4.object({
171
264
  apptDistAlg: appointmentDistAlgs.default("RR"),
172
265
  lastModified: Timestamp.nullable()
173
266
  });
174
- var Billing = z4.object({
175
- additionalFees: z4.array(PriceAdjustment).default([]),
176
- discounts: z4.array(PriceAdjustment).default([]),
177
- services: z4.object({
267
+ var Billing = z6.object({
268
+ additionalFees: z6.array(PriceAdjustment).default([]),
269
+ discounts: z6.array(PriceAdjustment).default([]),
270
+ services: z6.object({
178
271
  /** Forces service selectors to use the list of service(s) that you've created. */
179
- deployed: z4.boolean(),
180
- value: z4.array(PriceTag.omit({ uid: true })).max(100).default([])
272
+ deployed: z6.boolean(),
273
+ value: z6.array(PriceTag.omit({ uid: true })).max(100).default([])
181
274
  }).refine(
182
275
  (data) => !data.deployed || data.deployed && data.value.length > 0,
183
276
  "You must create at least (1) service in order to deploy your service list."
184
277
  ),
185
278
  lastModified: Timestamp.nullable()
186
279
  });
187
- var Staff = z4.object({
188
- members: z4.record(CompanyUser.shape.uid, CompanyUser).superRefine((data, ctx) => {
280
+ var Staff = z6.object({
281
+ members: z6.record(CompanyUser.shape.uid, CompanyUser).superRefine((data, ctx) => {
189
282
  const emails = [];
190
283
  for (const [uid, user] of Object.entries(data)) {
191
284
  if (uid !== user.uid) {
@@ -205,15 +298,15 @@ var Staff = z4.object({
205
298
  /**
206
299
  * @relationship one -> many
207
300
  *@description A map of doctor `uids` to their assistants `uids` */
208
- partnerMap: z4.record(
301
+ partnerMap: z6.record(
209
302
  CompanyUser.shape.uid,
210
- z4.record(CompanyUser.shape.uid, z4.object({ addedAt: Timestamp }))
303
+ z6.record(CompanyUser.shape.uid, z6.object({ addedAt: Timestamp }))
211
304
  ),
212
- updateQueue: z4.record(
305
+ updateQueue: z6.record(
213
306
  CompanyUser.shape.uid,
214
- z4.object({
215
- $REMOVE: z4.object({ addedAt: Timestamp }),
216
- $CHANGE_ROLES: z4.object({
307
+ z6.object({
308
+ $REMOVE: z6.object({ addedAt: Timestamp }),
309
+ $CHANGE_ROLES: z6.object({
217
310
  newRoles: CompanyUser.shape.roles,
218
311
  addedAt: Timestamp
219
312
  })
@@ -274,12 +367,12 @@ var Staff = z4.object({
274
367
  }
275
368
  }
276
369
  });
277
- var Receipts = z4.array(PriceTag.omit({ uid: true, lastModified: true }));
370
+ var Receipts = z6.array(PriceTag.omit({ uid: true, lastModified: true }));
278
371
  var createCompanyDetails = (options) => {
279
- return z4.object({
372
+ return z6.object({
280
373
  uid: UuidV7,
281
374
  identity: CompanyIdentity,
282
- notifications: options.partial ? z4.array(Notification).nullish() : z4.array(Notification),
375
+ notifications: options.partial ? z6.array(Notification).nullish() : z6.array(Notification),
283
376
  receipts: options.partial ? Receipts.nullish() : Receipts,
284
377
  state: options.partial ? CompanyState.nullish() : CompanyState,
285
378
  preferences: options.partial ? CompanyPreferences.nullish() : CompanyPreferences,
@@ -290,88 +383,6 @@ var createCompanyDetails = (options) => {
290
383
  };
291
384
  var CompanyDetails = createCompanyDetails({ partial: false });
292
385
  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
386
  export {
376
387
  CompanyDetails,
377
388
  CompanyUser,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bizmap/sdk",
3
- "version": "0.0.49",
3
+ "version": "0.0.51",
4
4
  "main": "./dist/main.js",
5
5
  "types": "./dist/main.d.ts",
6
6
  "type": "module",