@bizmap/sdk 0.0.36 → 0.0.38

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 CHANGED
@@ -248,7 +248,7 @@ declare const CompanyDetails: z.ZodObject<{
248
248
  }, z.core.$strip>>>;
249
249
  lastModified: z.ZodNullable<z.ZodInt>;
250
250
  }, z.core.$strip>>>;
251
- staffDetails: z.ZodPipe<z.ZodObject<{
251
+ staff: z.ZodPipe<z.ZodObject<{
252
252
  members: z.ZodRecord<z.ZodReadonly<z.ZodString>, z.ZodObject<{
253
253
  createdAt: z.ZodReadonly<z.ZodInt>;
254
254
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
@@ -279,7 +279,9 @@ declare const CompanyDetails: z.ZodObject<{
279
279
  email: z.ZodEmail;
280
280
  phoneNumber: z.ZodOptional<z.ZodString>;
281
281
  }, z.core.$strip>>;
282
- partnerMap: z.ZodRecord<z.ZodReadonly<z.ZodString>, z.ZodPipe<z.ZodArray<z.ZodReadonly<z.ZodString>>, z.ZodTransform<string[], string[]>>>;
282
+ partnerMap: z.ZodRecord<z.ZodReadonly<z.ZodString>, z.ZodRecord<z.ZodReadonly<z.ZodString>, z.ZodObject<{
283
+ addedAt: z.ZodInt;
284
+ }, z.core.$strip>>>;
283
285
  blackList: z.ZodRecord<z.ZodReadonly<z.ZodString>, z.ZodObject<{
284
286
  addedAt: z.ZodInt;
285
287
  }, z.core.$strip>>;
@@ -302,7 +304,9 @@ declare const CompanyDetails: z.ZodObject<{
302
304
  photoUrl?: string | null | undefined;
303
305
  phoneNumber?: string | undefined;
304
306
  }>;
305
- partnerMap: Record<string, string[]>;
307
+ partnerMap: Record<string, Record<string, {
308
+ addedAt: number;
309
+ }>>;
306
310
  blackList: Record<string, {
307
311
  addedAt: number;
308
312
  }>;
@@ -325,7 +329,9 @@ declare const CompanyDetails: z.ZodObject<{
325
329
  photoUrl?: string | null | undefined;
326
330
  phoneNumber?: string | undefined;
327
331
  }>;
328
- partnerMap: Record<string, string[]>;
332
+ partnerMap: Record<string, Record<string, {
333
+ addedAt: number;
334
+ }>>;
329
335
  blackList: Record<string, {
330
336
  addedAt: number;
331
337
  }>;
@@ -361,7 +367,9 @@ declare const CompanyDetails: z.ZodObject<{
361
367
  email: z.ZodEmail;
362
368
  phoneNumber: z.ZodOptional<z.ZodString>;
363
369
  }, z.core.$strip>>;
364
- partnerMap: z.ZodRecord<z.ZodReadonly<z.ZodString>, z.ZodPipe<z.ZodArray<z.ZodReadonly<z.ZodString>>, z.ZodTransform<string[], string[]>>>;
370
+ partnerMap: z.ZodRecord<z.ZodReadonly<z.ZodString>, z.ZodRecord<z.ZodReadonly<z.ZodString>, z.ZodObject<{
371
+ addedAt: z.ZodInt;
372
+ }, z.core.$strip>>>;
365
373
  blackList: z.ZodRecord<z.ZodReadonly<z.ZodString>, z.ZodObject<{
366
374
  addedAt: z.ZodInt;
367
375
  }, z.core.$strip>>;
@@ -384,7 +392,9 @@ declare const CompanyDetails: z.ZodObject<{
384
392
  photoUrl?: string | null | undefined;
385
393
  phoneNumber?: string | undefined;
386
394
  }>;
387
- partnerMap: Record<string, string[]>;
395
+ partnerMap: Record<string, Record<string, {
396
+ addedAt: number;
397
+ }>>;
388
398
  blackList: Record<string, {
389
399
  addedAt: number;
390
400
  }>;
@@ -407,7 +417,9 @@ declare const CompanyDetails: z.ZodObject<{
407
417
  photoUrl?: string | null | undefined;
408
418
  phoneNumber?: string | undefined;
409
419
  }>;
410
- partnerMap: Record<string, string[]>;
420
+ partnerMap: Record<string, Record<string, {
421
+ addedAt: number;
422
+ }>>;
411
423
  blackList: Record<string, {
412
424
  addedAt: number;
413
425
  }>;
@@ -541,7 +553,7 @@ declare const PartialCompanyDetails: z.ZodObject<{
541
553
  }, z.core.$strip>>>;
542
554
  lastModified: z.ZodNullable<z.ZodInt>;
543
555
  }, z.core.$strip>>>;
544
- staffDetails: z.ZodPipe<z.ZodObject<{
556
+ staff: z.ZodPipe<z.ZodObject<{
545
557
  members: z.ZodRecord<z.ZodReadonly<z.ZodString>, z.ZodObject<{
546
558
  createdAt: z.ZodReadonly<z.ZodInt>;
547
559
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
@@ -572,7 +584,9 @@ declare const PartialCompanyDetails: z.ZodObject<{
572
584
  email: z.ZodEmail;
573
585
  phoneNumber: z.ZodOptional<z.ZodString>;
574
586
  }, z.core.$strip>>;
575
- partnerMap: z.ZodRecord<z.ZodReadonly<z.ZodString>, z.ZodPipe<z.ZodArray<z.ZodReadonly<z.ZodString>>, z.ZodTransform<string[], string[]>>>;
587
+ partnerMap: z.ZodRecord<z.ZodReadonly<z.ZodString>, z.ZodRecord<z.ZodReadonly<z.ZodString>, z.ZodObject<{
588
+ addedAt: z.ZodInt;
589
+ }, z.core.$strip>>>;
576
590
  blackList: z.ZodRecord<z.ZodReadonly<z.ZodString>, z.ZodObject<{
577
591
  addedAt: z.ZodInt;
578
592
  }, z.core.$strip>>;
@@ -595,7 +609,9 @@ declare const PartialCompanyDetails: z.ZodObject<{
595
609
  photoUrl?: string | null | undefined;
596
610
  phoneNumber?: string | undefined;
597
611
  }>;
598
- partnerMap: Record<string, string[]>;
612
+ partnerMap: Record<string, Record<string, {
613
+ addedAt: number;
614
+ }>>;
599
615
  blackList: Record<string, {
600
616
  addedAt: number;
601
617
  }>;
@@ -618,7 +634,9 @@ declare const PartialCompanyDetails: z.ZodObject<{
618
634
  photoUrl?: string | null | undefined;
619
635
  phoneNumber?: string | undefined;
620
636
  }>;
621
- partnerMap: Record<string, string[]>;
637
+ partnerMap: Record<string, Record<string, {
638
+ addedAt: number;
639
+ }>>;
622
640
  blackList: Record<string, {
623
641
  addedAt: number;
624
642
  }>;
@@ -654,7 +672,9 @@ declare const PartialCompanyDetails: z.ZodObject<{
654
672
  email: z.ZodEmail;
655
673
  phoneNumber: z.ZodOptional<z.ZodString>;
656
674
  }, z.core.$strip>>;
657
- partnerMap: z.ZodRecord<z.ZodReadonly<z.ZodString>, z.ZodPipe<z.ZodArray<z.ZodReadonly<z.ZodString>>, z.ZodTransform<string[], string[]>>>;
675
+ partnerMap: z.ZodRecord<z.ZodReadonly<z.ZodString>, z.ZodRecord<z.ZodReadonly<z.ZodString>, z.ZodObject<{
676
+ addedAt: z.ZodInt;
677
+ }, z.core.$strip>>>;
658
678
  blackList: z.ZodRecord<z.ZodReadonly<z.ZodString>, z.ZodObject<{
659
679
  addedAt: z.ZodInt;
660
680
  }, z.core.$strip>>;
@@ -677,7 +697,9 @@ declare const PartialCompanyDetails: z.ZodObject<{
677
697
  photoUrl?: string | null | undefined;
678
698
  phoneNumber?: string | undefined;
679
699
  }>;
680
- partnerMap: Record<string, string[]>;
700
+ partnerMap: Record<string, Record<string, {
701
+ addedAt: number;
702
+ }>>;
681
703
  blackList: Record<string, {
682
704
  addedAt: number;
683
705
  }>;
@@ -700,7 +722,9 @@ declare const PartialCompanyDetails: z.ZodObject<{
700
722
  photoUrl?: string | null | undefined;
701
723
  phoneNumber?: string | undefined;
702
724
  }>;
703
- partnerMap: Record<string, string[]>;
725
+ partnerMap: Record<string, Record<string, {
726
+ addedAt: number;
727
+ }>>;
704
728
  blackList: Record<string, {
705
729
  addedAt: number;
706
730
  }>;
package/dist/main.js CHANGED
@@ -31,15 +31,15 @@ var TimeLog = z.object({
31
31
  // src/schemas/Billing.ts
32
32
  var PricingRate = z2.object({
33
33
  companyRegistration: z2.object({
34
- flatFee: z2.number().gte(0),
35
- feePerUser: z2.number().gte(0),
34
+ flatFee: z2.number().min(0),
35
+ feePerUser: z2.number().min(0),
36
36
  lastModified: Timestamp
37
37
  })
38
38
  });
39
39
  var PriceAdjustment = z2.object({
40
40
  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(),
41
- fixedAmount: z2.number().gte(0).max(1e6, "The max fixed amount is $1,000,000.00"),
42
- percentage: z2.number().gte(0).max(1e3, "The max percentage is 1,000%"),
41
+ fixedAmount: z2.number().min(0).max(1e6, "The max fixed amount is $1,000,000.00"),
42
+ percentage: z2.number().min(0).max(1e3, "The max percentage is 1,000%"),
43
43
  ...TimeLog.shape
44
44
  });
45
45
  var PriceTag = z2.object({
@@ -113,7 +113,7 @@ var CompanyUser = z4.object({
113
113
  );
114
114
  }, "A user is not allowed to have conflicting roles."),
115
115
  /** This should reset at the end of every cycle. */
116
- totalAppts: z4.int().gte(0),
116
+ totalAppts: z4.int().min(0),
117
117
  lastActive: Timestamp,
118
118
  ...TimeLog.shape
119
119
  }).superRefine((data, ctx) => {
@@ -126,7 +126,7 @@ var CompanyUser = z4.object({
126
126
  );
127
127
  }
128
128
  });
129
- var CompanyIdentity = z4.object({
129
+ var IdentityDetails = z4.object({
130
130
  displayName: z4.string().min(3).max(20),
131
131
  logo: z4.string().max(2500).nullish(),
132
132
  contact: z4.object({
@@ -142,7 +142,7 @@ var CompanyIdentity = z4.object({
142
142
  }),
143
143
  lastModified: Timestamp.nullable()
144
144
  });
145
- var CompanyState = z4.object({
145
+ var StateDetails = z4.object({
146
146
  // This can only be changed by the server/app admin
147
147
  availableBalance: z4.number(),
148
148
  /**
@@ -153,12 +153,12 @@ var CompanyState = z4.object({
153
153
  /** A counter for the company's invoice no.
154
154
  * @note This should only be null when the cycle resets
155
155
  */
156
- invoiceNoCounter: z4.int().gte(1),
156
+ invoiceNoCounter: z4.int().min(1),
157
157
  /** A counter for the company's ticket no. */
158
- tktNoCounter: z4.int().gte(1),
158
+ tktNoCounter: z4.int().min(1),
159
159
  lastModified: Timestamp.nullable()
160
160
  });
161
- var CompanyPreferences = z4.object({
161
+ var PreferenceDetails = z4.object({
162
162
  /** The amount of user provisions made for this company */
163
163
  userProvisions: z4.number().max(150, { error: "The total user provisions can't exceed 150" }).refine(
164
164
  (p) => !(p > 1 && p < 10),
@@ -171,7 +171,7 @@ var CompanyPreferences = z4.object({
171
171
  apptDistAlg: appointmentDistAlgs.default("RR"),
172
172
  lastModified: Timestamp.nullable()
173
173
  });
174
- var CompanyBillingModel = z4.object({
174
+ var BillingDetails = z4.object({
175
175
  preferences: z4.object({
176
176
  /** Forces service selectors to use the list of service(s) that you've created. */
177
177
  useCreatedServices: z4.boolean(),
@@ -233,16 +233,19 @@ var StaffDetails = z4.object({
233
233
  *@description A map of doctor `uids` to their assistants `uids` */
234
234
  partnerMap: z4.record(
235
235
  CompanyUser.shape.uid,
236
- z4.array(CompanyUser.shape.uid).transform((pUids) => {
237
- const partners = [];
238
- for (const uid of pUids) {
239
- if (!uid || typeof uid !== "string") continue;
240
- if (!partners.some((p) => p.toLowerCase() === uid.toLowerCase())) {
241
- partners.push(uid);
242
- }
243
- }
244
- return partners.sort();
245
- })
236
+ z4.record(CompanyUser.shape.uid, z4.object({ addedAt: Timestamp }))
237
+ // z
238
+ // .array(CompanyUser.shape.uid)
239
+ // .transform((pUids) => {
240
+ // const partners: string[] = [];
241
+ // for (const uid of pUids) {
242
+ // if (!uid || typeof uid !== "string") continue;
243
+ // if (!partners.some((p) => p.toLowerCase() === uid.toLowerCase())) {
244
+ // partners.push(uid);
245
+ // }
246
+ // }
247
+ // return partners.sort();
248
+ // }),
246
249
  ),
247
250
  blackList: z4.record(
248
251
  CompanyUser.shape.uid,
@@ -255,41 +258,46 @@ var StaffDetails = z4.object({
255
258
  if (uid in copy.members) continue;
256
259
  delete copy.blackList[uid];
257
260
  }
261
+ for (const [docUid, assts] of Object.entries(copy.partnerMap)) {
262
+ if (docUid in d.members) {
263
+ for (const asstUid of Object.keys(assts)) {
264
+ if (asstUid in d.members) continue;
265
+ delete copy.partnerMap[docUid][asstUid];
266
+ }
267
+ } else {
268
+ delete copy.partnerMap[docUid];
269
+ }
270
+ }
258
271
  return copy;
259
272
  }).superRefine((details, ctx) => {
260
- for (const [docUid, physAssts] of Object.entries(details.partnerMap)) {
261
- const queriedDoc = details.members[docUid];
262
- if (!queriedDoc) {
273
+ for (const user of Object.values(details.members)) {
274
+ if (user.roles.includes("doc") && user.uid in details.partnerMap) {
275
+ for (const asstUid of Object.keys(details.partnerMap[user.uid])) {
276
+ if (!details.members[asstUid].roles.includes("physAsst")) {
277
+ ctx.addIssue(
278
+ `A partner group member must have the "physAsst" role (${user.uid}) -> (${asstUid}).`
279
+ );
280
+ }
281
+ }
282
+ } else if (user.uid in details.partnerMap) {
263
283
  ctx.addIssue(
264
- `Only existing members of a company are allowed to be leaders of a partner group (${docUid}).`
284
+ `A partner group leader must have the "doc" role. (${user.uid})`
265
285
  );
266
- } else if (!queriedDoc?.roles?.includes?.("doc")) {
286
+ } else if (user.roles.includes("doc")) {
267
287
  ctx.addIssue(
268
- `A partner group leader must have the "doc" role (${docUid}).`
288
+ `All users that have the "doc" role must be the leader of a partner group. (${user.uid})`
269
289
  );
270
290
  }
271
- for (const asstUid of physAssts) {
272
- const queriedAsst = details.members[asstUid];
273
- if (!queriedAsst) {
274
- ctx.addIssue(
275
- `Only existing members of a company are allowed to be apart of a partner group (${asstUid}).`
276
- );
277
- } else if (!queriedAsst?.roles?.includes?.("physAsst")) {
278
- ctx.addIssue(
279
- `A partner group member must have the "physAsst" role (${asstUid}).`
280
- );
281
- }
282
- }
283
291
  }
284
292
  });
285
293
  var createCompanyDetails = (options) => {
286
294
  return z4.object({
287
295
  uid: UuidV7,
288
- identity: CompanyIdentity,
289
- state: options.partial ? CompanyState.nullish() : CompanyState,
290
- preferences: options.partial ? CompanyPreferences.nullish() : CompanyPreferences,
291
- billing: options.partial ? CompanyBillingModel.nullish() : CompanyBillingModel,
292
- staffDetails: options.partial ? StaffDetails.nullish() : StaffDetails,
296
+ identity: IdentityDetails,
297
+ state: options.partial ? StateDetails.nullish() : StateDetails,
298
+ preferences: options.partial ? PreferenceDetails.nullish() : PreferenceDetails,
299
+ billing: options.partial ? BillingDetails.nullish() : BillingDetails,
300
+ staff: options.partial ? StaffDetails.nullish() : StaffDetails,
293
301
  createdAt: options.partial ? Timestamp.nullish() : Timestamp
294
302
  });
295
303
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bizmap/sdk",
3
- "version": "0.0.36",
3
+ "version": "0.0.38",
4
4
  "main": "./dist/main.js",
5
5
  "types": "./dist/main.d.ts",
6
6
  "type": "module",