@bizmap/sdk 0.0.13 → 0.0.15

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 +208 -16
  2. package/dist/main.js +158 -24
  3. package/package.json +1 -1
package/dist/main.d.ts CHANGED
@@ -54,6 +54,8 @@ declare const CompanyOpState: z.ZodObject<{
54
54
  uid: z.ZodReadonly<z.ZodString>;
55
55
  availableBalance: z.ZodNumber;
56
56
  preferences: z.ZodObject<{
57
+ createdAt: z.ZodReadonly<z.ZodNumber>;
58
+ lastModified: z.ZodNullable<z.ZodNumber>;
57
59
  userProvisions: z.ZodNumber;
58
60
  apptDistAlg: z.ZodEnum<{
59
61
  RR: "RR";
@@ -67,16 +69,14 @@ declare const CompanyBillingModel: z.ZodObject<{
67
69
  lastModified: z.ZodNullable<z.ZodNumber>;
68
70
  uid: z.ZodReadonly<z.ZodString>;
69
71
  preferences: z.ZodObject<{
72
+ createdAt: z.ZodReadonly<z.ZodNumber>;
73
+ lastModified: z.ZodNullable<z.ZodNumber>;
70
74
  allowInvoiceDist: z.ZodBoolean;
71
- serviceDecider: z.ZodEnum<{
75
+ serviceSelector: z.ZodEnum<{
72
76
  scheduler: "scheduler";
73
77
  doctor: "doctor";
74
78
  }>;
75
79
  enforcePaidAppts: z.ZodBoolean;
76
- paymentCollector: z.ZodNullable<z.ZodEnum<{
77
- doc: "doc";
78
- cshr: "cshr";
79
- }>>;
80
80
  primaryCurrency: z.ZodEnum<{
81
81
  JMD: "JMD";
82
82
  }>;
@@ -176,19 +176,19 @@ type CompanyRegistrationClaims = z.infer<typeof CompanyRegistrationClaims>;
176
176
  declare const CompanyUser: z.ZodObject<{
177
177
  createdAt: z.ZodReadonly<z.ZodNumber>;
178
178
  lastModified: z.ZodNullable<z.ZodNumber>;
179
- lastActive: z.ZodNumber;
180
179
  status: z.ZodEnum<{
181
180
  inviteSent: "inviteSent";
182
181
  active: "active";
183
182
  inactive: "inactive";
184
183
  }>;
185
- roles: z.ZodArray<z.ZodEnum<{
184
+ roles: z.ZodPipe<z.ZodArray<z.ZodEnum<{
186
185
  doc: "doc";
187
186
  physAsst: "physAsst";
188
187
  rcpst: "rcpst";
189
188
  cshr: "cshr";
190
189
  admin: "admin";
191
- }>>;
190
+ }>>, z.ZodTransform<("doc" | "physAsst" | "rcpst" | "cshr" | "admin")[], ("doc" | "physAsst" | "rcpst" | "cshr" | "admin")[]>>;
191
+ lastActive: z.ZodNumber;
192
192
  name: z.ZodRecord<z.ZodEnum<{
193
193
  first: "first";
194
194
  last: "last";
@@ -200,24 +200,24 @@ declare const CompanyUser: z.ZodObject<{
200
200
  }, z.core.$strip>;
201
201
  type CompanyUser = z.infer<typeof CompanyUser>;
202
202
  /** The unpacked Staff Details */
203
- declare const StaffDetails: z.ZodObject<{
203
+ declare const StaffDetails: z.ZodPipe<z.ZodObject<{
204
204
  uid: z.ZodReadonly<z.ZodString>;
205
205
  members: z.ZodArray<z.ZodObject<{
206
206
  createdAt: z.ZodReadonly<z.ZodNumber>;
207
207
  lastModified: z.ZodNullable<z.ZodNumber>;
208
- lastActive: z.ZodNumber;
209
208
  status: z.ZodEnum<{
210
209
  inviteSent: "inviteSent";
211
210
  active: "active";
212
211
  inactive: "inactive";
213
212
  }>;
214
- roles: z.ZodArray<z.ZodEnum<{
213
+ roles: z.ZodPipe<z.ZodArray<z.ZodEnum<{
215
214
  doc: "doc";
216
215
  physAsst: "physAsst";
217
216
  rcpst: "rcpst";
218
217
  cshr: "cshr";
219
218
  admin: "admin";
220
- }>>;
219
+ }>>, z.ZodTransform<("doc" | "physAsst" | "rcpst" | "cshr" | "admin")[], ("doc" | "physAsst" | "rcpst" | "cshr" | "admin")[]>>;
220
+ lastActive: z.ZodNumber;
221
221
  name: z.ZodRecord<z.ZodEnum<{
222
222
  first: "first";
223
223
  last: "last";
@@ -227,10 +227,186 @@ declare const StaffDetails: z.ZodObject<{
227
227
  phoneNumber: z.ZodOptional<z.ZodString>;
228
228
  uid: z.ZodString;
229
229
  }, z.core.$strip>>;
230
- partnerMap: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>;
231
- blackList: z.ZodArray<z.ZodString>;
232
- }, z.core.$strip>;
230
+ partnerMap: z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodArray<z.ZodString>, z.ZodTransform<string[], string[]>>>;
231
+ blackList: z.ZodPipe<z.ZodArray<z.ZodString>, z.ZodTransform<string[], string[]>>;
232
+ }, z.core.$strip>, z.ZodTransform<{
233
+ uid: string;
234
+ members: {
235
+ createdAt: number;
236
+ lastModified: number | null;
237
+ status: "inviteSent" | "active" | "inactive";
238
+ roles: ("doc" | "physAsst" | "rcpst" | "cshr" | "admin")[];
239
+ lastActive: number;
240
+ name: Record<"first" | "last", string>;
241
+ email: string;
242
+ uid: string;
243
+ photoUrl?: string | undefined;
244
+ phoneNumber?: string | undefined;
245
+ }[];
246
+ partnerMap: Record<string, string[]>;
247
+ blackList: string[];
248
+ }, {
249
+ uid: string;
250
+ members: {
251
+ createdAt: number;
252
+ lastModified: number | null;
253
+ status: "inviteSent" | "active" | "inactive";
254
+ roles: ("doc" | "physAsst" | "rcpst" | "cshr" | "admin")[];
255
+ lastActive: number;
256
+ name: Record<"first" | "last", string>;
257
+ email: string;
258
+ uid: string;
259
+ photoUrl?: string | undefined;
260
+ phoneNumber?: string | undefined;
261
+ }[];
262
+ partnerMap: Record<string, string[]>;
263
+ blackList: string[];
264
+ }>>;
233
265
  type StaffDetails = z.infer<typeof StaffDetails>;
266
+ declare const CompanyDetails: z.ZodObject<{
267
+ uid: z.ZodString;
268
+ identity: z.ZodObject<{
269
+ createdAt: z.ZodReadonly<z.ZodNumber>;
270
+ lastModified: z.ZodNullable<z.ZodNumber>;
271
+ uid: z.ZodReadonly<z.ZodString>;
272
+ displayName: z.ZodString;
273
+ logo: z.ZodOptional<z.ZodString>;
274
+ contact: z.ZodObject<{
275
+ email: z.ZodEmail;
276
+ phoneNumber: z.ZodOptional<z.ZodString>;
277
+ }, z.core.$strip>;
278
+ address: z.ZodRecord<z.ZodEnum<{
279
+ streetAddress: "streetAddress";
280
+ city: "city";
281
+ parish: "parish";
282
+ country: "country";
283
+ }>, z.ZodString>;
284
+ legal: z.ZodObject<{
285
+ regNo: z.ZodReadonly<z.ZodString>;
286
+ trn: z.ZodOptional<z.ZodString>;
287
+ gctRegNo: z.ZodOptional<z.ZodString>;
288
+ }, z.core.$strip>;
289
+ }, z.core.$strip>;
290
+ opState: z.ZodObject<{
291
+ createdAt: z.ZodReadonly<z.ZodNumber>;
292
+ lastModified: z.ZodNullable<z.ZodNumber>;
293
+ uid: z.ZodReadonly<z.ZodString>;
294
+ availableBalance: z.ZodNumber;
295
+ preferences: z.ZodObject<{
296
+ createdAt: z.ZodReadonly<z.ZodNumber>;
297
+ lastModified: z.ZodNullable<z.ZodNumber>;
298
+ userProvisions: z.ZodNumber;
299
+ apptDistAlg: z.ZodEnum<{
300
+ RR: "RR";
301
+ LOR: "LOR";
302
+ }>;
303
+ }, z.core.$strip>;
304
+ }, z.core.$strip>;
305
+ billing: z.ZodObject<{
306
+ createdAt: z.ZodReadonly<z.ZodNumber>;
307
+ lastModified: z.ZodNullable<z.ZodNumber>;
308
+ uid: z.ZodReadonly<z.ZodString>;
309
+ preferences: z.ZodObject<{
310
+ createdAt: z.ZodReadonly<z.ZodNumber>;
311
+ lastModified: z.ZodNullable<z.ZodNumber>;
312
+ allowInvoiceDist: z.ZodBoolean;
313
+ serviceSelector: z.ZodEnum<{
314
+ scheduler: "scheduler";
315
+ doctor: "doctor";
316
+ }>;
317
+ enforcePaidAppts: z.ZodBoolean;
318
+ primaryCurrency: z.ZodEnum<{
319
+ JMD: "JMD";
320
+ }>;
321
+ acceptedCurrencies: z.ZodArray<z.ZodEnum<{
322
+ JMD: "JMD";
323
+ }>>;
324
+ }, z.core.$strip>;
325
+ additionalFees: z.ZodOptional<z.ZodArray<z.ZodObject<{
326
+ createdAt: z.ZodReadonly<z.ZodNumber>;
327
+ lastModified: z.ZodNullable<z.ZodNumber>;
328
+ description: z.ZodOptional<z.ZodString>;
329
+ fixedAmount: z.ZodNumber;
330
+ percentage: z.ZodNumber;
331
+ }, z.core.$strip>>>;
332
+ discounts: z.ZodOptional<z.ZodArray<z.ZodObject<{
333
+ createdAt: z.ZodReadonly<z.ZodNumber>;
334
+ lastModified: z.ZodNullable<z.ZodNumber>;
335
+ description: z.ZodOptional<z.ZodString>;
336
+ fixedAmount: z.ZodNumber;
337
+ percentage: z.ZodNumber;
338
+ }, z.core.$strip>>>;
339
+ services: z.ZodOptional<z.ZodArray<z.ZodObject<{
340
+ createdAt: z.ZodReadonly<z.ZodNumber>;
341
+ lastModified: z.ZodNullable<z.ZodNumber>;
342
+ item: z.ZodString;
343
+ cost: z.ZodNumber;
344
+ }, z.core.$strip>>>;
345
+ }, z.core.$strip>;
346
+ staffDetails: z.ZodPipe<z.ZodObject<{
347
+ uid: z.ZodReadonly<z.ZodString>;
348
+ members: z.ZodArray<z.ZodObject<{
349
+ createdAt: z.ZodReadonly<z.ZodNumber>;
350
+ lastModified: z.ZodNullable<z.ZodNumber>;
351
+ status: z.ZodEnum<{
352
+ inviteSent: "inviteSent";
353
+ active: "active";
354
+ inactive: "inactive";
355
+ }>;
356
+ roles: z.ZodPipe<z.ZodArray<z.ZodEnum<{
357
+ doc: "doc";
358
+ physAsst: "physAsst";
359
+ rcpst: "rcpst";
360
+ cshr: "cshr";
361
+ admin: "admin";
362
+ }>>, z.ZodTransform<("doc" | "physAsst" | "rcpst" | "cshr" | "admin")[], ("doc" | "physAsst" | "rcpst" | "cshr" | "admin")[]>>;
363
+ lastActive: z.ZodNumber;
364
+ name: z.ZodRecord<z.ZodEnum<{
365
+ first: "first";
366
+ last: "last";
367
+ }>, z.ZodString>;
368
+ photoUrl: z.ZodOptional<z.ZodString>;
369
+ email: z.ZodEmail;
370
+ phoneNumber: z.ZodOptional<z.ZodString>;
371
+ uid: z.ZodString;
372
+ }, z.core.$strip>>;
373
+ partnerMap: z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodArray<z.ZodString>, z.ZodTransform<string[], string[]>>>;
374
+ blackList: z.ZodPipe<z.ZodArray<z.ZodString>, z.ZodTransform<string[], string[]>>;
375
+ }, z.core.$strip>, z.ZodTransform<{
376
+ uid: string;
377
+ members: {
378
+ createdAt: number;
379
+ lastModified: number | null;
380
+ status: "inviteSent" | "active" | "inactive";
381
+ roles: ("doc" | "physAsst" | "rcpst" | "cshr" | "admin")[];
382
+ lastActive: number;
383
+ name: Record<"first" | "last", string>;
384
+ email: string;
385
+ uid: string;
386
+ photoUrl?: string | undefined;
387
+ phoneNumber?: string | undefined;
388
+ }[];
389
+ partnerMap: Record<string, string[]>;
390
+ blackList: string[];
391
+ }, {
392
+ uid: string;
393
+ members: {
394
+ createdAt: number;
395
+ lastModified: number | null;
396
+ status: "inviteSent" | "active" | "inactive";
397
+ roles: ("doc" | "physAsst" | "rcpst" | "cshr" | "admin")[];
398
+ lastActive: number;
399
+ name: Record<"first" | "last", string>;
400
+ email: string;
401
+ uid: string;
402
+ photoUrl?: string | undefined;
403
+ phoneNumber?: string | undefined;
404
+ }[];
405
+ partnerMap: Record<string, string[]>;
406
+ blackList: string[];
407
+ }>>;
408
+ }, z.core.$strip>;
409
+ type CompanyDetails = z.infer<typeof CompanyDetails>;
234
410
 
235
411
  declare const TimeLog: z.ZodObject<{
236
412
  createdAt: z.ZodReadonly<z.ZodNumber>;
@@ -265,4 +441,20 @@ declare const appointmentDistAlgs: z.ZodEnum<{
265
441
  }>;
266
442
  type AppointmentDistAlg = z.infer<typeof appointmentDistAlgs>;
267
443
 
268
- export { type AppointmentDistAlg, CompanyBillingModel, CompanyIdentity, CompanyOpState, type CompanyPartnerRole, CompanyRegistrationClaims, CompanyUser, type CompanyUserRole, type EmployeeRole, PriceAdjustment, PriceTag, PricingRate, RegisterCompanyForm, StaffDetails, Time, TimeLog, appointmentDistAlgs, companyPartnerRoles, companyUserRoles, employeeRoles };
444
+ /**@returns an array of the users that have conflicting roles or are incompatible with the other partners, or null if none was found. */
445
+ declare const findConflictingPartners: (...partners: CompanyUser[]) => {
446
+ createdAt: number;
447
+ lastModified: number | null;
448
+ status: "inviteSent" | "active" | "inactive";
449
+ roles: ("doc" | "physAsst" | "rcpst" | "cshr" | "admin")[];
450
+ lastActive: number;
451
+ name: Record<"first" | "last", string>;
452
+ email: string;
453
+ uid: string;
454
+ photoUrl?: string | undefined;
455
+ phoneNumber?: string | undefined;
456
+ }[] | null;
457
+ /**@returns the roles that are compatible with the selected role. */
458
+ declare const getCompatibleRoles: (role: CompanyUserRole) => CompanyUserRole[];
459
+
460
+ export { type AppointmentDistAlg, CompanyBillingModel, CompanyDetails, CompanyIdentity, CompanyOpState, type CompanyPartnerRole, CompanyRegistrationClaims, CompanyUser, type CompanyUserRole, type EmployeeRole, PriceAdjustment, PriceTag, PricingRate, RegisterCompanyForm, StaffDetails, Time, TimeLog, appointmentDistAlgs, companyPartnerRoles, companyUserRoles, employeeRoles, findConflictingPartners, getCompatibleRoles };
package/dist/main.js CHANGED
@@ -84,12 +84,13 @@ var CompanyOpState = z4.object({
84
84
  // This can be changed by the company's admin
85
85
  preferences: z4.object({
86
86
  /** The amount of user provisions made for this company */
87
- userProvisions: z4.number(),
87
+ userProvisions: z4.number().min(10, { error: "The total user provisions must atleast be 10." }).max(150, { error: "The total user provisions can't exceed 150" }),
88
88
  /**
89
89
  * @property RR (Round Robin): Even distribution.
90
90
  * @property LOR (Least Outstanding Requests): Distribute based on availability.
91
91
  */
92
- apptDistAlg: appointmentDistAlgs
92
+ apptDistAlg: appointmentDistAlgs,
93
+ ...TimeLog.shape
93
94
  }),
94
95
  ...TimeLog.shape
95
96
  });
@@ -99,7 +100,7 @@ var CompanyBillingModel = z4.object({
99
100
  /** Allows the serviceDecider to distribute invoices. */
100
101
  allowInvoiceDist: z4.boolean(),
101
102
  /** The user that's allowed to record the client's services. */
102
- serviceDecider: z4.enum(["scheduler", "doctor"]),
103
+ serviceSelector: z4.enum(["scheduler", "doctor"]),
103
104
  /** A record of the payments made must be attached before creating the
104
105
  * appointment
105
106
  * @note
@@ -107,27 +108,15 @@ var CompanyBillingModel = z4.object({
107
108
  * - removes the `cshr` role from the company's allowed user roles
108
109
  * */
109
110
  enforcePaidAppts: z4.boolean(),
110
- /**
111
- * Determines who collects & records payments made by clients.
112
- * @default "cshr"
113
- * @note
114
- * - if `collector === "doc"`, the `cshr` role will be removed from the company's allowed user roles.
115
- * - if `enforcePaidAppts === true`, this should be null.
116
- */
117
- paymentCollector: companyUserRoles.extract(["doc", "cshr"]).nullable(),
118
111
  primaryCurrency: currencies,
119
- acceptedCurrencies: z4.array(currencies)
112
+ acceptedCurrencies: z4.array(currencies),
113
+ ...TimeLog.shape
120
114
  }).superRefine((data, ctx) => {
121
- if (data.enforcePaidAppts && data.serviceDecider !== "scheduler") {
115
+ if (data.enforcePaidAppts && data.serviceSelector !== "scheduler") {
122
116
  ctx.addIssue(
123
117
  "serviceDecider must be scheduler when enforcePaidAppts is true."
124
118
  );
125
119
  }
126
- if (data.enforcePaidAppts && data.paymentCollector !== null) {
127
- ctx.addIssue(
128
- "paymentCollector must be null when enforcePaidAppts is true."
129
- );
130
- }
131
120
  }),
132
121
  additionalFees: z4.array(PriceAdjustment).optional(),
133
122
  discounts: z4.array(PriceAdjustment).optional(),
@@ -151,22 +140,165 @@ var CompanyRegistrationClaims = z4.object({
151
140
  });
152
141
  var CompanyUser = z4.object({
153
142
  ...UserModel.shape,
154
- lastActive: z4.number(),
155
143
  status: z4.enum(["inviteSent", "active", "inactive"]),
156
- roles: z4.array(companyUserRoles),
144
+ roles: z4.array(companyUserRoles).transform((roles) => {
145
+ const newRoles = [];
146
+ for (const role of roles) {
147
+ if (!role || typeof role !== "string") continue;
148
+ if (!newRoles.includes(role)) newRoles.push(role);
149
+ }
150
+ return newRoles;
151
+ }).refine((roles) => {
152
+ const compatibleRoles = getCompatibleRoles(roles[0]);
153
+ return roles.every(
154
+ (role, i) => i === 0 || compatibleRoles.includes(role)
155
+ );
156
+ }, "A user is not allowed to have conflicting roles."),
157
+ lastActive: z4.number(),
157
158
  ...TimeLog.shape
158
159
  });
159
160
  var StaffDetails = z4.object({
160
161
  uid: CompanyIdentity.shape.uid,
161
- members: z4.array(CompanyUser),
162
+ members: z4.array(CompanyUser).superRefine((users, ctx) => {
163
+ const duplicateUids = [];
164
+ const duplicateEmails = [];
165
+ const uids = [];
166
+ const emails = [];
167
+ for (const user of users) {
168
+ if (uids.includes(user.uid)) {
169
+ duplicateUids.push(user.uid);
170
+ } else {
171
+ uids.push(user.uid);
172
+ }
173
+ if (emails.includes(user.email)) {
174
+ duplicateEmails.push(user.email);
175
+ } else {
176
+ emails.push(user.email);
177
+ }
178
+ }
179
+ if (duplicateUids.length > 0) {
180
+ ctx.addIssue(
181
+ `Having multiple members with the same uid is prohibited (${duplicateUids.join()}).`
182
+ );
183
+ }
184
+ if (duplicateEmails.length > 0) {
185
+ ctx.addIssue(
186
+ `Having multiple members with the same email is prohibited (${duplicateEmails.join()}).`
187
+ );
188
+ }
189
+ }),
162
190
  /**
163
191
  * @relationship one -> many
164
192
  *@description A map of doctor `uids` to their assistants `uids` */
165
- partnerMap: z4.record(CompanyUser.shape.uid, z4.array(CompanyUser.shape.uid)),
166
- blackList: z4.array(CompanyUser.shape.uid)
193
+ partnerMap: z4.record(
194
+ CompanyUser.shape.uid,
195
+ z4.array(CompanyUser.shape.uid).min(
196
+ 1,
197
+ "At least (1) partner, excluding the leader, is required to create a partner group."
198
+ ).transform((pUids) => {
199
+ const partners = [];
200
+ for (const uid of pUids) {
201
+ if (!uid || typeof uid !== "string") continue;
202
+ if (!partners.some((p) => p.toLowerCase() === uid.toLowerCase())) {
203
+ partners.push(uid);
204
+ }
205
+ }
206
+ return partners;
207
+ })
208
+ ),
209
+ blackList: z4.array(CompanyUser.shape.uid).transform((list) => {
210
+ const newList = [];
211
+ for (const uid of list) {
212
+ if (!uid || typeof uid !== "string") continue;
213
+ if (!newList.some(
214
+ (newUid) => newUid.toLowerCase() === uid.toLowerCase()
215
+ )) {
216
+ newList.push(uid);
217
+ }
218
+ }
219
+ return newList;
220
+ })
221
+ // ...TimeLog.shape,
222
+ }).transform((d) => {
223
+ let blackListWithExisitingUsers = [];
224
+ for (const uid of d.blackList) {
225
+ if (!uid || typeof uid !== "string") continue;
226
+ if (d.members.find((m) => m.uid.toLowerCase() === uid.toLowerCase())) {
227
+ blackListWithExisitingUsers.push(uid);
228
+ }
229
+ }
230
+ if (blackListWithExisitingUsers.length !== d.blackList.length) {
231
+ d.blackList = blackListWithExisitingUsers;
232
+ }
233
+ return d;
234
+ }).superRefine((details, ctx) => {
235
+ const findMember = (uid) => details.members.find((m) => m.uid === uid);
236
+ for (const [docUid, physAssts] of Object.entries(details.partnerMap)) {
237
+ const queriedDoc = findMember(docUid);
238
+ if (!queriedDoc) {
239
+ ctx.addIssue(
240
+ `Only existing members of a company are allowed to be leaders of a partner group (${docUid}).`
241
+ );
242
+ } else if (!queriedDoc?.roles?.includes?.("doc")) {
243
+ ctx.addIssue(
244
+ `A partner group leader must have the "doc" role (${docUid}).`
245
+ );
246
+ }
247
+ for (const asstUid of physAssts) {
248
+ const queriedAsst = findMember(asstUid);
249
+ if (!queriedAsst) {
250
+ ctx.addIssue(
251
+ `Only existing members of a company are allowed to be apart of a partner group (${asstUid}).`
252
+ );
253
+ } else if (!queriedAsst?.roles?.includes?.("physAsst")) {
254
+ ctx.addIssue(
255
+ `A partner group member must have the "physAsst" role (${asstUid}).`
256
+ );
257
+ }
258
+ }
259
+ }
167
260
  });
261
+ var CompanyDetails = z4.object({
262
+ uid: z4.string(),
263
+ identity: CompanyIdentity,
264
+ opState: CompanyOpState,
265
+ billing: CompanyBillingModel,
266
+ staffDetails: StaffDetails
267
+ });
268
+
269
+ // src/functions/helper-functions.ts
270
+ var findConflictingPartners = (...partners) => {
271
+ let hasSingleDoctor = false;
272
+ const conflicts = [];
273
+ if (!partners) return partners;
274
+ for (const partner of partners) {
275
+ if (!partner.roles || partner.roles.some(
276
+ (r) => !companyPartnerRoles.options.includes(r)
277
+ ) || !CompanyUser.shape.roles.safeParse(partner.roles).success) {
278
+ conflicts.push(partner);
279
+ continue;
280
+ }
281
+ if (partner.roles.includes("doc") && !hasSingleDoctor) {
282
+ hasSingleDoctor = true;
283
+ } else if (partner.roles.includes("doc")) {
284
+ conflicts.push(partner);
285
+ continue;
286
+ }
287
+ }
288
+ return conflicts.length === 0 ? null : conflicts;
289
+ };
290
+ var getCompatibleRoles = (role) => {
291
+ if (role === "physAsst") {
292
+ return companyUserRoles.exclude(["admin", "doc", role]).options;
293
+ }
294
+ if (role === "admin" || role === "doc") {
295
+ return companyUserRoles.exclude(["physAsst", role]).options;
296
+ }
297
+ return companyUserRoles.exclude([role]).options;
298
+ };
168
299
  export {
169
300
  CompanyBillingModel,
301
+ CompanyDetails,
170
302
  CompanyIdentity,
171
303
  CompanyOpState,
172
304
  CompanyRegistrationClaims,
@@ -181,5 +313,7 @@ export {
181
313
  appointmentDistAlgs,
182
314
  companyPartnerRoles,
183
315
  companyUserRoles,
184
- employeeRoles
316
+ employeeRoles,
317
+ findConflictingPartners,
318
+ getCompatibleRoles
185
319
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bizmap/sdk",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
4
4
  "main": "./dist/main.js",
5
5
  "types": "./dist/main.d.ts",
6
6
  "type": "module",