@bizmap/sdk 0.0.33 → 0.0.35

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
@@ -148,14 +148,14 @@ declare const CompanyDetails: z.ZodObject<{
148
148
  state: z.ZodObject<{
149
149
  availableBalance: z.ZodNumber;
150
150
  totalUploads: z.ZodNumber;
151
- lastInvoiceNo: z.ZodNullable<z.ZodString>;
152
- lastTktNo: z.ZodNumber;
151
+ invoiceNoCounter: z.ZodInt;
152
+ tktNoCounter: z.ZodInt;
153
153
  lastModified: z.ZodNullable<z.ZodInt>;
154
154
  }, z.core.$strip> | z.ZodOptional<z.ZodNullable<z.ZodObject<{
155
155
  availableBalance: z.ZodNumber;
156
156
  totalUploads: z.ZodNumber;
157
- lastInvoiceNo: z.ZodNullable<z.ZodString>;
158
- lastTktNo: z.ZodNumber;
157
+ invoiceNoCounter: z.ZodInt;
158
+ tktNoCounter: z.ZodInt;
159
159
  lastModified: z.ZodNullable<z.ZodInt>;
160
160
  }, z.core.$strip>>>;
161
161
  preferences: z.ZodObject<{
@@ -175,7 +175,6 @@ declare const CompanyDetails: z.ZodObject<{
175
175
  }, z.core.$strip>>>;
176
176
  billing: z.ZodObject<{
177
177
  preferences: z.ZodObject<{
178
- allowInvoiceDist: z.ZodBoolean;
179
178
  useCreatedServices: z.ZodBoolean;
180
179
  serviceSelector: z.ZodEnum<{
181
180
  scheduler: "scheduler";
@@ -213,7 +212,6 @@ declare const CompanyDetails: z.ZodObject<{
213
212
  lastModified: z.ZodNullable<z.ZodInt>;
214
213
  }, z.core.$strip> | z.ZodOptional<z.ZodNullable<z.ZodObject<{
215
214
  preferences: z.ZodObject<{
216
- allowInvoiceDist: z.ZodBoolean;
217
215
  useCreatedServices: z.ZodBoolean;
218
216
  serviceSelector: z.ZodEnum<{
219
217
  scheduler: "scheduler";
@@ -251,7 +249,7 @@ declare const CompanyDetails: z.ZodObject<{
251
249
  lastModified: z.ZodNullable<z.ZodInt>;
252
250
  }, z.core.$strip>>>;
253
251
  staffDetails: z.ZodPipe<z.ZodObject<{
254
- members: z.ZodArray<z.ZodObject<{
252
+ members: z.ZodRecord<z.ZodReadonly<z.ZodString>, z.ZodObject<{
255
253
  createdAt: z.ZodReadonly<z.ZodInt>;
256
254
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
257
255
  uid: z.ZodReadonly<z.ZodString>;
@@ -282,10 +280,12 @@ declare const CompanyDetails: z.ZodObject<{
282
280
  phoneNumber: z.ZodOptional<z.ZodString>;
283
281
  }, z.core.$strip>>;
284
282
  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[]>>;
283
+ blackList: z.ZodRecord<z.ZodReadonly<z.ZodString>, z.ZodObject<{
284
+ addedAt: z.ZodInt;
285
+ }, z.core.$strip>>;
286
286
  lastModified: z.ZodNullable<z.ZodInt>;
287
287
  }, z.core.$strip>, z.ZodTransform<{
288
- members: {
288
+ members: Record<string, {
289
289
  createdAt: number;
290
290
  uid: string;
291
291
  status: "inviteSent" | "active" | "inactive";
@@ -301,12 +301,14 @@ declare const CompanyDetails: z.ZodObject<{
301
301
  lastModified?: number | null | undefined;
302
302
  photoUrl?: string | null | undefined;
303
303
  phoneNumber?: string | undefined;
304
- }[];
304
+ }>;
305
305
  partnerMap: Record<string, string[]>;
306
- blackList: string[];
306
+ blackList: Record<string, {
307
+ addedAt: number;
308
+ }>;
307
309
  lastModified: number | null;
308
310
  }, {
309
- members: {
311
+ members: Record<string, {
310
312
  createdAt: number;
311
313
  uid: string;
312
314
  status: "inviteSent" | "active" | "inactive";
@@ -322,12 +324,14 @@ declare const CompanyDetails: z.ZodObject<{
322
324
  lastModified?: number | null | undefined;
323
325
  photoUrl?: string | null | undefined;
324
326
  phoneNumber?: string | undefined;
325
- }[];
327
+ }>;
326
328
  partnerMap: Record<string, string[]>;
327
- blackList: string[];
329
+ blackList: Record<string, {
330
+ addedAt: number;
331
+ }>;
328
332
  lastModified: number | null;
329
333
  }>> | z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodObject<{
330
- members: z.ZodArray<z.ZodObject<{
334
+ members: z.ZodRecord<z.ZodReadonly<z.ZodString>, z.ZodObject<{
331
335
  createdAt: z.ZodReadonly<z.ZodInt>;
332
336
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
333
337
  uid: z.ZodReadonly<z.ZodString>;
@@ -358,10 +362,12 @@ declare const CompanyDetails: z.ZodObject<{
358
362
  phoneNumber: z.ZodOptional<z.ZodString>;
359
363
  }, z.core.$strip>>;
360
364
  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[]>>;
365
+ blackList: z.ZodRecord<z.ZodReadonly<z.ZodString>, z.ZodObject<{
366
+ addedAt: z.ZodInt;
367
+ }, z.core.$strip>>;
362
368
  lastModified: z.ZodNullable<z.ZodInt>;
363
369
  }, z.core.$strip>, z.ZodTransform<{
364
- members: {
370
+ members: Record<string, {
365
371
  createdAt: number;
366
372
  uid: string;
367
373
  status: "inviteSent" | "active" | "inactive";
@@ -377,12 +383,14 @@ declare const CompanyDetails: z.ZodObject<{
377
383
  lastModified?: number | null | undefined;
378
384
  photoUrl?: string | null | undefined;
379
385
  phoneNumber?: string | undefined;
380
- }[];
386
+ }>;
381
387
  partnerMap: Record<string, string[]>;
382
- blackList: string[];
388
+ blackList: Record<string, {
389
+ addedAt: number;
390
+ }>;
383
391
  lastModified: number | null;
384
392
  }, {
385
- members: {
393
+ members: Record<string, {
386
394
  createdAt: number;
387
395
  uid: string;
388
396
  status: "inviteSent" | "active" | "inactive";
@@ -398,9 +406,11 @@ declare const CompanyDetails: z.ZodObject<{
398
406
  lastModified?: number | null | undefined;
399
407
  photoUrl?: string | null | undefined;
400
408
  phoneNumber?: string | undefined;
401
- }[];
409
+ }>;
402
410
  partnerMap: Record<string, string[]>;
403
- blackList: string[];
411
+ blackList: Record<string, {
412
+ addedAt: number;
413
+ }>;
404
414
  lastModified: number | null;
405
415
  }>>>>;
406
416
  createdAt: z.ZodInt | z.ZodOptional<z.ZodNullable<z.ZodInt>>;
@@ -431,14 +441,14 @@ declare const PartialCompanyDetails: z.ZodObject<{
431
441
  state: z.ZodObject<{
432
442
  availableBalance: z.ZodNumber;
433
443
  totalUploads: z.ZodNumber;
434
- lastInvoiceNo: z.ZodNullable<z.ZodString>;
435
- lastTktNo: z.ZodNumber;
444
+ invoiceNoCounter: z.ZodInt;
445
+ tktNoCounter: z.ZodInt;
436
446
  lastModified: z.ZodNullable<z.ZodInt>;
437
447
  }, z.core.$strip> | z.ZodOptional<z.ZodNullable<z.ZodObject<{
438
448
  availableBalance: z.ZodNumber;
439
449
  totalUploads: z.ZodNumber;
440
- lastInvoiceNo: z.ZodNullable<z.ZodString>;
441
- lastTktNo: z.ZodNumber;
450
+ invoiceNoCounter: z.ZodInt;
451
+ tktNoCounter: z.ZodInt;
442
452
  lastModified: z.ZodNullable<z.ZodInt>;
443
453
  }, z.core.$strip>>>;
444
454
  preferences: z.ZodObject<{
@@ -458,7 +468,6 @@ declare const PartialCompanyDetails: z.ZodObject<{
458
468
  }, z.core.$strip>>>;
459
469
  billing: z.ZodObject<{
460
470
  preferences: z.ZodObject<{
461
- allowInvoiceDist: z.ZodBoolean;
462
471
  useCreatedServices: z.ZodBoolean;
463
472
  serviceSelector: z.ZodEnum<{
464
473
  scheduler: "scheduler";
@@ -496,7 +505,6 @@ declare const PartialCompanyDetails: z.ZodObject<{
496
505
  lastModified: z.ZodNullable<z.ZodInt>;
497
506
  }, z.core.$strip> | z.ZodOptional<z.ZodNullable<z.ZodObject<{
498
507
  preferences: z.ZodObject<{
499
- allowInvoiceDist: z.ZodBoolean;
500
508
  useCreatedServices: z.ZodBoolean;
501
509
  serviceSelector: z.ZodEnum<{
502
510
  scheduler: "scheduler";
@@ -534,7 +542,7 @@ declare const PartialCompanyDetails: z.ZodObject<{
534
542
  lastModified: z.ZodNullable<z.ZodInt>;
535
543
  }, z.core.$strip>>>;
536
544
  staffDetails: z.ZodPipe<z.ZodObject<{
537
- members: z.ZodArray<z.ZodObject<{
545
+ members: z.ZodRecord<z.ZodReadonly<z.ZodString>, z.ZodObject<{
538
546
  createdAt: z.ZodReadonly<z.ZodInt>;
539
547
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
540
548
  uid: z.ZodReadonly<z.ZodString>;
@@ -565,10 +573,12 @@ declare const PartialCompanyDetails: z.ZodObject<{
565
573
  phoneNumber: z.ZodOptional<z.ZodString>;
566
574
  }, z.core.$strip>>;
567
575
  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[]>>;
576
+ blackList: z.ZodRecord<z.ZodReadonly<z.ZodString>, z.ZodObject<{
577
+ addedAt: z.ZodInt;
578
+ }, z.core.$strip>>;
569
579
  lastModified: z.ZodNullable<z.ZodInt>;
570
580
  }, z.core.$strip>, z.ZodTransform<{
571
- members: {
581
+ members: Record<string, {
572
582
  createdAt: number;
573
583
  uid: string;
574
584
  status: "inviteSent" | "active" | "inactive";
@@ -584,12 +594,14 @@ declare const PartialCompanyDetails: z.ZodObject<{
584
594
  lastModified?: number | null | undefined;
585
595
  photoUrl?: string | null | undefined;
586
596
  phoneNumber?: string | undefined;
587
- }[];
597
+ }>;
588
598
  partnerMap: Record<string, string[]>;
589
- blackList: string[];
599
+ blackList: Record<string, {
600
+ addedAt: number;
601
+ }>;
590
602
  lastModified: number | null;
591
603
  }, {
592
- members: {
604
+ members: Record<string, {
593
605
  createdAt: number;
594
606
  uid: string;
595
607
  status: "inviteSent" | "active" | "inactive";
@@ -605,12 +617,14 @@ declare const PartialCompanyDetails: z.ZodObject<{
605
617
  lastModified?: number | null | undefined;
606
618
  photoUrl?: string | null | undefined;
607
619
  phoneNumber?: string | undefined;
608
- }[];
620
+ }>;
609
621
  partnerMap: Record<string, string[]>;
610
- blackList: string[];
622
+ blackList: Record<string, {
623
+ addedAt: number;
624
+ }>;
611
625
  lastModified: number | null;
612
626
  }>> | z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodObject<{
613
- members: z.ZodArray<z.ZodObject<{
627
+ members: z.ZodRecord<z.ZodReadonly<z.ZodString>, z.ZodObject<{
614
628
  createdAt: z.ZodReadonly<z.ZodInt>;
615
629
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
616
630
  uid: z.ZodReadonly<z.ZodString>;
@@ -641,10 +655,12 @@ declare const PartialCompanyDetails: z.ZodObject<{
641
655
  phoneNumber: z.ZodOptional<z.ZodString>;
642
656
  }, z.core.$strip>>;
643
657
  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[]>>;
658
+ blackList: z.ZodRecord<z.ZodReadonly<z.ZodString>, z.ZodObject<{
659
+ addedAt: z.ZodInt;
660
+ }, z.core.$strip>>;
645
661
  lastModified: z.ZodNullable<z.ZodInt>;
646
662
  }, z.core.$strip>, z.ZodTransform<{
647
- members: {
663
+ members: Record<string, {
648
664
  createdAt: number;
649
665
  uid: string;
650
666
  status: "inviteSent" | "active" | "inactive";
@@ -660,12 +676,14 @@ declare const PartialCompanyDetails: z.ZodObject<{
660
676
  lastModified?: number | null | undefined;
661
677
  photoUrl?: string | null | undefined;
662
678
  phoneNumber?: string | undefined;
663
- }[];
679
+ }>;
664
680
  partnerMap: Record<string, string[]>;
665
- blackList: string[];
681
+ blackList: Record<string, {
682
+ addedAt: number;
683
+ }>;
666
684
  lastModified: number | null;
667
685
  }, {
668
- members: {
686
+ members: Record<string, {
669
687
  createdAt: number;
670
688
  uid: string;
671
689
  status: "inviteSent" | "active" | "inactive";
@@ -681,9 +699,11 @@ declare const PartialCompanyDetails: z.ZodObject<{
681
699
  lastModified?: number | null | undefined;
682
700
  photoUrl?: string | null | undefined;
683
701
  phoneNumber?: string | undefined;
684
- }[];
702
+ }>;
685
703
  partnerMap: Record<string, string[]>;
686
- blackList: string[];
704
+ blackList: Record<string, {
705
+ addedAt: number;
706
+ }>;
687
707
  lastModified: number | null;
688
708
  }>>>>;
689
709
  createdAt: z.ZodInt | z.ZodOptional<z.ZodNullable<z.ZodInt>>;
package/dist/main.js CHANGED
@@ -153,9 +153,9 @@ 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
- lastInvoiceNo: InvoiceNo.nullable(),
156
+ invoiceNoCounter: z4.int().positive().min(1),
157
157
  /** A counter for the company's ticket no. */
158
- lastTktNo: z4.number().positive(),
158
+ tktNoCounter: z4.int().positive().min(1),
159
159
  // distAppts: z.record(CompanyUser.shape.uid, z.number().positive().nullable()),
160
160
  lastModified: Timestamp.nullable()
161
161
  });
@@ -174,8 +174,6 @@ var CompanyPreferences = z4.object({
174
174
  });
175
175
  var CompanyBillingModel = z4.object({
176
176
  preferences: z4.object({
177
- /** Allows the serviceDecider to distribute invoices. */
178
- allowInvoiceDist: z4.boolean(),
179
177
  /** Forces service selectors to use the list of service(s) that you've created. */
180
178
  useCreatedServices: z4.boolean(),
181
179
  /** The user that's allowed to record the client's services. */
@@ -214,37 +212,22 @@ var CompanyBillingModel = z4.object({
214
212
  }
215
213
  });
216
214
  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 = [];
215
+ members: z4.record(CompanyUser.shape.uid, CompanyUser).superRefine((data, ctx) => {
225
216
  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);
217
+ for (const [uid, user] of Object.entries(data)) {
218
+ if (uid !== user.uid) {
219
+ ctx.addIssue(
220
+ `User found with a uid that doesn't match their respective key. (${uid} !== ${user.uid}).`
221
+ );
231
222
  }
232
- if (emails.includes(user.email)) {
233
- duplicateEmails.push(user.email);
234
- } else {
235
- emails.push(user.email);
223
+ if (!!user.email && emails.includes(user.email.toLowerCase())) {
224
+ ctx.addIssue(
225
+ `Having multiple members with the same email is prohibited. (${user.email})`
226
+ );
227
+ } else if (!!user.email) {
228
+ emails.push(user.email.toLowerCase());
236
229
  }
237
230
  }
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
231
  }),
249
232
  /**
250
233
  * @relationship one -> many
@@ -262,35 +245,21 @@ var StaffDetails = z4.object({
262
245
  return partners.sort();
263
246
  })
264
247
  ),
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
- }),
248
+ blackList: z4.record(
249
+ CompanyUser.shape.uid,
250
+ z4.object({ addedAt: Timestamp })
251
+ ),
277
252
  lastModified: Timestamp.nullable()
278
253
  }).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;
254
+ const copy = structuredClone(d);
255
+ for (const uid of Object.keys(copy.blackList)) {
256
+ if (uid in copy.members) continue;
257
+ delete copy.blackList[uid];
288
258
  }
289
- return d;
259
+ return copy;
290
260
  }).superRefine((details, ctx) => {
291
- const findMember = (uid) => details.members.find((m) => m.uid === uid);
292
261
  for (const [docUid, physAssts] of Object.entries(details.partnerMap)) {
293
- const queriedDoc = findMember(docUid);
262
+ const queriedDoc = details.members[docUid];
294
263
  if (!queriedDoc) {
295
264
  ctx.addIssue(
296
265
  `Only existing members of a company are allowed to be leaders of a partner group (${docUid}).`
@@ -301,7 +270,7 @@ var StaffDetails = z4.object({
301
270
  );
302
271
  }
303
272
  for (const asstUid of physAssts) {
304
- const queriedAsst = findMember(asstUid);
273
+ const queriedAsst = details.members[asstUid];
305
274
  if (!queriedAsst) {
306
275
  ctx.addIssue(
307
276
  `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.35",
4
4
  "main": "./dist/main.js",
5
5
  "types": "./dist/main.d.ts",
6
6
  "type": "module",