@bizmap/sdk 0.0.33 → 0.0.34

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
@@ -251,7 +251,7 @@ declare const CompanyDetails: z.ZodObject<{
251
251
  lastModified: z.ZodNullable<z.ZodInt>;
252
252
  }, z.core.$strip>>>;
253
253
  staffDetails: z.ZodPipe<z.ZodObject<{
254
- members: z.ZodArray<z.ZodObject<{
254
+ members: z.ZodRecord<z.ZodReadonly<z.ZodString>, z.ZodObject<{
255
255
  createdAt: z.ZodReadonly<z.ZodInt>;
256
256
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
257
257
  uid: z.ZodReadonly<z.ZodString>;
@@ -282,10 +282,12 @@ declare const CompanyDetails: z.ZodObject<{
282
282
  phoneNumber: z.ZodOptional<z.ZodString>;
283
283
  }, z.core.$strip>>;
284
284
  partnerMap: z.ZodRecord<z.ZodReadonly<z.ZodString>, z.ZodPipe<z.ZodArray<z.ZodReadonly<z.ZodString>>, z.ZodTransform<string[], string[]>>>;
285
- blackList: z.ZodPipe<z.ZodArray<z.ZodReadonly<z.ZodString>>, z.ZodTransform<string[], string[]>>;
285
+ blackList: z.ZodRecord<z.ZodReadonly<z.ZodString>, z.ZodObject<{
286
+ addedAt: z.ZodInt;
287
+ }, z.core.$strip>>;
286
288
  lastModified: z.ZodNullable<z.ZodInt>;
287
289
  }, z.core.$strip>, z.ZodTransform<{
288
- members: {
290
+ members: Record<string, {
289
291
  createdAt: number;
290
292
  uid: string;
291
293
  status: "inviteSent" | "active" | "inactive";
@@ -301,12 +303,14 @@ declare const CompanyDetails: z.ZodObject<{
301
303
  lastModified?: number | null | undefined;
302
304
  photoUrl?: string | null | undefined;
303
305
  phoneNumber?: string | undefined;
304
- }[];
306
+ }>;
305
307
  partnerMap: Record<string, string[]>;
306
- blackList: string[];
308
+ blackList: Record<string, {
309
+ addedAt: number;
310
+ }>;
307
311
  lastModified: number | null;
308
312
  }, {
309
- members: {
313
+ members: Record<string, {
310
314
  createdAt: number;
311
315
  uid: string;
312
316
  status: "inviteSent" | "active" | "inactive";
@@ -322,12 +326,14 @@ declare const CompanyDetails: z.ZodObject<{
322
326
  lastModified?: number | null | undefined;
323
327
  photoUrl?: string | null | undefined;
324
328
  phoneNumber?: string | undefined;
325
- }[];
329
+ }>;
326
330
  partnerMap: Record<string, string[]>;
327
- blackList: string[];
331
+ blackList: Record<string, {
332
+ addedAt: number;
333
+ }>;
328
334
  lastModified: number | null;
329
335
  }>> | z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodObject<{
330
- members: z.ZodArray<z.ZodObject<{
336
+ members: z.ZodRecord<z.ZodReadonly<z.ZodString>, z.ZodObject<{
331
337
  createdAt: z.ZodReadonly<z.ZodInt>;
332
338
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
333
339
  uid: z.ZodReadonly<z.ZodString>;
@@ -358,10 +364,12 @@ declare const CompanyDetails: z.ZodObject<{
358
364
  phoneNumber: z.ZodOptional<z.ZodString>;
359
365
  }, z.core.$strip>>;
360
366
  partnerMap: z.ZodRecord<z.ZodReadonly<z.ZodString>, z.ZodPipe<z.ZodArray<z.ZodReadonly<z.ZodString>>, z.ZodTransform<string[], string[]>>>;
361
- blackList: z.ZodPipe<z.ZodArray<z.ZodReadonly<z.ZodString>>, z.ZodTransform<string[], string[]>>;
367
+ blackList: z.ZodRecord<z.ZodReadonly<z.ZodString>, z.ZodObject<{
368
+ addedAt: z.ZodInt;
369
+ }, z.core.$strip>>;
362
370
  lastModified: z.ZodNullable<z.ZodInt>;
363
371
  }, z.core.$strip>, z.ZodTransform<{
364
- members: {
372
+ members: Record<string, {
365
373
  createdAt: number;
366
374
  uid: string;
367
375
  status: "inviteSent" | "active" | "inactive";
@@ -377,12 +385,14 @@ declare const CompanyDetails: z.ZodObject<{
377
385
  lastModified?: number | null | undefined;
378
386
  photoUrl?: string | null | undefined;
379
387
  phoneNumber?: string | undefined;
380
- }[];
388
+ }>;
381
389
  partnerMap: Record<string, string[]>;
382
- blackList: string[];
390
+ blackList: Record<string, {
391
+ addedAt: number;
392
+ }>;
383
393
  lastModified: number | null;
384
394
  }, {
385
- members: {
395
+ members: Record<string, {
386
396
  createdAt: number;
387
397
  uid: string;
388
398
  status: "inviteSent" | "active" | "inactive";
@@ -398,9 +408,11 @@ declare const CompanyDetails: z.ZodObject<{
398
408
  lastModified?: number | null | undefined;
399
409
  photoUrl?: string | null | undefined;
400
410
  phoneNumber?: string | undefined;
401
- }[];
411
+ }>;
402
412
  partnerMap: Record<string, string[]>;
403
- blackList: string[];
413
+ blackList: Record<string, {
414
+ addedAt: number;
415
+ }>;
404
416
  lastModified: number | null;
405
417
  }>>>>;
406
418
  createdAt: z.ZodInt | z.ZodOptional<z.ZodNullable<z.ZodInt>>;
@@ -534,7 +546,7 @@ declare const PartialCompanyDetails: z.ZodObject<{
534
546
  lastModified: z.ZodNullable<z.ZodInt>;
535
547
  }, z.core.$strip>>>;
536
548
  staffDetails: z.ZodPipe<z.ZodObject<{
537
- members: z.ZodArray<z.ZodObject<{
549
+ members: z.ZodRecord<z.ZodReadonly<z.ZodString>, z.ZodObject<{
538
550
  createdAt: z.ZodReadonly<z.ZodInt>;
539
551
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
540
552
  uid: z.ZodReadonly<z.ZodString>;
@@ -565,10 +577,12 @@ declare const PartialCompanyDetails: z.ZodObject<{
565
577
  phoneNumber: z.ZodOptional<z.ZodString>;
566
578
  }, z.core.$strip>>;
567
579
  partnerMap: z.ZodRecord<z.ZodReadonly<z.ZodString>, z.ZodPipe<z.ZodArray<z.ZodReadonly<z.ZodString>>, z.ZodTransform<string[], string[]>>>;
568
- blackList: z.ZodPipe<z.ZodArray<z.ZodReadonly<z.ZodString>>, z.ZodTransform<string[], string[]>>;
580
+ blackList: z.ZodRecord<z.ZodReadonly<z.ZodString>, z.ZodObject<{
581
+ addedAt: z.ZodInt;
582
+ }, z.core.$strip>>;
569
583
  lastModified: z.ZodNullable<z.ZodInt>;
570
584
  }, z.core.$strip>, z.ZodTransform<{
571
- members: {
585
+ members: Record<string, {
572
586
  createdAt: number;
573
587
  uid: string;
574
588
  status: "inviteSent" | "active" | "inactive";
@@ -584,12 +598,14 @@ declare const PartialCompanyDetails: z.ZodObject<{
584
598
  lastModified?: number | null | undefined;
585
599
  photoUrl?: string | null | undefined;
586
600
  phoneNumber?: string | undefined;
587
- }[];
601
+ }>;
588
602
  partnerMap: Record<string, string[]>;
589
- blackList: string[];
603
+ blackList: Record<string, {
604
+ addedAt: number;
605
+ }>;
590
606
  lastModified: number | null;
591
607
  }, {
592
- members: {
608
+ members: Record<string, {
593
609
  createdAt: number;
594
610
  uid: string;
595
611
  status: "inviteSent" | "active" | "inactive";
@@ -605,12 +621,14 @@ declare const PartialCompanyDetails: z.ZodObject<{
605
621
  lastModified?: number | null | undefined;
606
622
  photoUrl?: string | null | undefined;
607
623
  phoneNumber?: string | undefined;
608
- }[];
624
+ }>;
609
625
  partnerMap: Record<string, string[]>;
610
- blackList: string[];
626
+ blackList: Record<string, {
627
+ addedAt: number;
628
+ }>;
611
629
  lastModified: number | null;
612
630
  }>> | z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodObject<{
613
- members: z.ZodArray<z.ZodObject<{
631
+ members: z.ZodRecord<z.ZodReadonly<z.ZodString>, z.ZodObject<{
614
632
  createdAt: z.ZodReadonly<z.ZodInt>;
615
633
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
616
634
  uid: z.ZodReadonly<z.ZodString>;
@@ -641,10 +659,12 @@ declare const PartialCompanyDetails: z.ZodObject<{
641
659
  phoneNumber: z.ZodOptional<z.ZodString>;
642
660
  }, z.core.$strip>>;
643
661
  partnerMap: z.ZodRecord<z.ZodReadonly<z.ZodString>, z.ZodPipe<z.ZodArray<z.ZodReadonly<z.ZodString>>, z.ZodTransform<string[], string[]>>>;
644
- blackList: z.ZodPipe<z.ZodArray<z.ZodReadonly<z.ZodString>>, z.ZodTransform<string[], string[]>>;
662
+ blackList: z.ZodRecord<z.ZodReadonly<z.ZodString>, z.ZodObject<{
663
+ addedAt: z.ZodInt;
664
+ }, z.core.$strip>>;
645
665
  lastModified: z.ZodNullable<z.ZodInt>;
646
666
  }, z.core.$strip>, z.ZodTransform<{
647
- members: {
667
+ members: Record<string, {
648
668
  createdAt: number;
649
669
  uid: string;
650
670
  status: "inviteSent" | "active" | "inactive";
@@ -660,12 +680,14 @@ declare const PartialCompanyDetails: z.ZodObject<{
660
680
  lastModified?: number | null | undefined;
661
681
  photoUrl?: string | null | undefined;
662
682
  phoneNumber?: string | undefined;
663
- }[];
683
+ }>;
664
684
  partnerMap: Record<string, string[]>;
665
- blackList: string[];
685
+ blackList: Record<string, {
686
+ addedAt: number;
687
+ }>;
666
688
  lastModified: number | null;
667
689
  }, {
668
- members: {
690
+ members: Record<string, {
669
691
  createdAt: number;
670
692
  uid: string;
671
693
  status: "inviteSent" | "active" | "inactive";
@@ -681,9 +703,11 @@ declare const PartialCompanyDetails: z.ZodObject<{
681
703
  lastModified?: number | null | undefined;
682
704
  photoUrl?: string | null | undefined;
683
705
  phoneNumber?: string | undefined;
684
- }[];
706
+ }>;
685
707
  partnerMap: Record<string, string[]>;
686
- blackList: string[];
708
+ blackList: Record<string, {
709
+ addedAt: number;
710
+ }>;
687
711
  lastModified: number | null;
688
712
  }>>>>;
689
713
  createdAt: z.ZodInt | z.ZodOptional<z.ZodNullable<z.ZodInt>>;
package/dist/main.js CHANGED
@@ -214,37 +214,22 @@ var CompanyBillingModel = z4.object({
214
214
  }
215
215
  });
216
216
  var StaffDetails = z4.object({
217
- /** Doc -> total appointments
218
- * @note This should be reset at the end of every cycle.
219
- */
220
- // totalApptsMap: z.record(CompanyUser.shape.uid, z.number().positive()),
221
- members: z4.array(CompanyUser).superRefine((users, ctx) => {
222
- const duplicateUids = [];
223
- const duplicateEmails = [];
224
- const uids = [];
217
+ members: z4.record(CompanyUser.shape.uid, CompanyUser).superRefine((data, ctx) => {
225
218
  const emails = [];
226
- for (const user of users) {
227
- if (uids.includes(user.uid)) {
228
- duplicateUids.push(user.uid);
229
- } else {
230
- uids.push(user.uid);
219
+ for (const [uid, user] of Object.entries(data)) {
220
+ if (uid !== user.uid) {
221
+ ctx.addIssue(
222
+ `User found with a uid that doesn't match their respective key. (${uid} !== ${user.uid}).`
223
+ );
231
224
  }
232
- if (emails.includes(user.email)) {
233
- duplicateEmails.push(user.email);
234
- } else {
235
- emails.push(user.email);
225
+ if (!!user.email && emails.includes(user.email.toLowerCase())) {
226
+ ctx.addIssue(
227
+ `Having multiple members with the same email is prohibited. (${user.email})`
228
+ );
229
+ } else if (!!user.email) {
230
+ emails.push(user.email.toLowerCase());
236
231
  }
237
232
  }
238
- if (duplicateUids.length > 0) {
239
- ctx.addIssue(
240
- `Having multiple members with the same uid is prohibited (${duplicateUids.join()}).`
241
- );
242
- }
243
- if (duplicateEmails.length > 0) {
244
- ctx.addIssue(
245
- `Having multiple members with the same email is prohibited (${duplicateEmails.join()}).`
246
- );
247
- }
248
233
  }),
249
234
  /**
250
235
  * @relationship one -> many
@@ -262,35 +247,21 @@ var StaffDetails = z4.object({
262
247
  return partners.sort();
263
248
  })
264
249
  ),
265
- blackList: z4.array(CompanyUser.shape.uid).transform((list) => {
266
- const newList = [];
267
- for (const uid of list) {
268
- if (!uid || typeof uid !== "string") continue;
269
- if (!newList.some(
270
- (newUid) => newUid.toLowerCase() === uid.toLowerCase()
271
- )) {
272
- newList.push(uid);
273
- }
274
- }
275
- return newList.sort();
276
- }),
250
+ blackList: z4.record(
251
+ CompanyUser.shape.uid,
252
+ z4.object({ addedAt: Timestamp })
253
+ ),
277
254
  lastModified: Timestamp.nullable()
278
255
  }).transform((d) => {
279
- let blackListWithExisitingUsers = [];
280
- for (const uid of d.blackList) {
281
- if (!uid || typeof uid !== "string") continue;
282
- if (d.members.find((m) => m.uid.toLowerCase() === uid.toLowerCase())) {
283
- blackListWithExisitingUsers.push(uid);
284
- }
285
- }
286
- if (blackListWithExisitingUsers.length !== d.blackList.length) {
287
- d.blackList = blackListWithExisitingUsers;
256
+ const copy = structuredClone(d);
257
+ for (const uid of Object.keys(copy.blackList)) {
258
+ if (uid in copy.members) continue;
259
+ delete copy.blackList[uid];
288
260
  }
289
- return d;
261
+ return copy;
290
262
  }).superRefine((details, ctx) => {
291
- const findMember = (uid) => details.members.find((m) => m.uid === uid);
292
263
  for (const [docUid, physAssts] of Object.entries(details.partnerMap)) {
293
- const queriedDoc = findMember(docUid);
264
+ const queriedDoc = details.members[docUid];
294
265
  if (!queriedDoc) {
295
266
  ctx.addIssue(
296
267
  `Only existing members of a company are allowed to be leaders of a partner group (${docUid}).`
@@ -301,7 +272,7 @@ var StaffDetails = z4.object({
301
272
  );
302
273
  }
303
274
  for (const asstUid of physAssts) {
304
- const queriedAsst = findMember(asstUid);
275
+ const queriedAsst = details.members[asstUid];
305
276
  if (!queriedAsst) {
306
277
  ctx.addIssue(
307
278
  `Only existing members of a company are allowed to be apart of a partner group (${asstUid}).`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bizmap/sdk",
3
- "version": "0.0.33",
3
+ "version": "0.0.34",
4
4
  "main": "./dist/main.js",
5
5
  "types": "./dist/main.d.ts",
6
6
  "type": "module",