@blackcode_sa/metaestetics-api 1.7.42 → 1.7.43

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/index.js CHANGED
@@ -882,12 +882,21 @@ var passwordSchema = import_zod4.z.string().min(8, "Password must be at least 8
882
882
  );
883
883
  var userRoleSchema = import_zod4.z.nativeEnum(UserRole);
884
884
  var userRolesSchema = import_zod4.z.array(userRoleSchema).min(1, "User must have at least one role").max(3, "User cannot have more than 3 roles");
885
- var timestampSchema = import_zod4.z.custom((data) => {
886
- if (data && typeof data === "object" && "isEqual" in data) {
887
- return true;
888
- }
889
- return data && typeof data === "object" && "toDate" in data && "seconds" in data && "nanoseconds" in data;
890
- }, "Must be a Timestamp object or serverTimestamp");
885
+ var timestampSchema = import_zod4.z.custom(
886
+ (data) => {
887
+ if (data && typeof data === "object" && "isEqual" in data) {
888
+ return true;
889
+ }
890
+ if (data && typeof data === "object" && "toDate" in data && "seconds" in data && "nanoseconds" in data) {
891
+ return true;
892
+ }
893
+ if (data instanceof Date) {
894
+ return true;
895
+ }
896
+ return false;
897
+ },
898
+ "Must be a Timestamp object, Date object, or serverTimestamp"
899
+ );
891
900
  var clinicAdminOptionsSchema = import_zod4.z.object({
892
901
  isGroupOwner: import_zod4.z.boolean(),
893
902
  groupToken: import_zod4.z.string().optional(),
@@ -1700,11 +1709,16 @@ var timestampSchema2 = import_zod5.z.union([
1700
1709
  seconds: import_zod5.z.number(),
1701
1710
  nanoseconds: import_zod5.z.number()
1702
1711
  }),
1703
- import_zod5.z.instanceof(import_firestore4.Timestamp)
1712
+ import_zod5.z.instanceof(import_firestore4.Timestamp),
1713
+ import_zod5.z.instanceof(Date)
1714
+ // Add support for Date objects that Firestore returns on client
1704
1715
  ]).transform((data) => {
1705
1716
  if (data instanceof import_firestore4.Timestamp) {
1706
1717
  return data;
1707
1718
  }
1719
+ if (data instanceof Date) {
1720
+ return import_firestore4.Timestamp.fromDate(data);
1721
+ }
1708
1722
  return new import_firestore4.Timestamp(data.seconds, data.nanoseconds);
1709
1723
  });
1710
1724
 
package/dist/index.mjs CHANGED
@@ -657,12 +657,21 @@ var passwordSchema = z4.string().min(8, "Password must be at least 8 characters"
657
657
  );
658
658
  var userRoleSchema = z4.nativeEnum(UserRole);
659
659
  var userRolesSchema = z4.array(userRoleSchema).min(1, "User must have at least one role").max(3, "User cannot have more than 3 roles");
660
- var timestampSchema = z4.custom((data) => {
661
- if (data && typeof data === "object" && "isEqual" in data) {
662
- return true;
663
- }
664
- return data && typeof data === "object" && "toDate" in data && "seconds" in data && "nanoseconds" in data;
665
- }, "Must be a Timestamp object or serverTimestamp");
660
+ var timestampSchema = z4.custom(
661
+ (data) => {
662
+ if (data && typeof data === "object" && "isEqual" in data) {
663
+ return true;
664
+ }
665
+ if (data && typeof data === "object" && "toDate" in data && "seconds" in data && "nanoseconds" in data) {
666
+ return true;
667
+ }
668
+ if (data instanceof Date) {
669
+ return true;
670
+ }
671
+ return false;
672
+ },
673
+ "Must be a Timestamp object, Date object, or serverTimestamp"
674
+ );
666
675
  var clinicAdminOptionsSchema = z4.object({
667
676
  isGroupOwner: z4.boolean(),
668
677
  groupToken: z4.string().optional(),
@@ -1527,11 +1536,16 @@ var timestampSchema2 = z5.union([
1527
1536
  seconds: z5.number(),
1528
1537
  nanoseconds: z5.number()
1529
1538
  }),
1530
- z5.instanceof(Timestamp2)
1539
+ z5.instanceof(Timestamp2),
1540
+ z5.instanceof(Date)
1541
+ // Add support for Date objects that Firestore returns on client
1531
1542
  ]).transform((data) => {
1532
1543
  if (data instanceof Timestamp2) {
1533
1544
  return data;
1534
1545
  }
1546
+ if (data instanceof Date) {
1547
+ return Timestamp2.fromDate(data);
1548
+ }
1535
1549
  return new Timestamp2(data.seconds, data.nanoseconds);
1536
1550
  });
1537
1551
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@blackcode_sa/metaestetics-api",
3
3
  "private": false,
4
- "version": "1.7.42",
4
+ "version": "1.7.43",
5
5
  "description": "Firebase authentication service with anonymous upgrade support",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.mjs",
@@ -14,9 +14,9 @@ export interface User {
14
14
  email: string | null;
15
15
  roles: UserRole[];
16
16
  isAnonymous: boolean;
17
- createdAt: Timestamp | FieldValue;
18
- updatedAt: Timestamp | FieldValue;
19
- lastLoginAt: Timestamp | FieldValue;
17
+ createdAt: Timestamp | FieldValue | Date;
18
+ updatedAt: Timestamp | FieldValue | Date;
19
+ lastLoginAt: Timestamp | FieldValue | Date;
20
20
  patientProfile?: string;
21
21
  practitionerProfile?: string;
22
22
  adminProfile?: string;
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { Timestamp } from "firebase/firestore";
3
3
 
4
- // Create a custom schema for Timestamp that properly handles both raw objects and Timestamp instances
4
+ // Create a custom schema for Timestamp that properly handles Timestamp instances, raw objects, and Date objects
5
5
  export const timestampSchema = z
6
6
  .union([
7
7
  z.object({
@@ -9,11 +9,16 @@ export const timestampSchema = z
9
9
  nanoseconds: z.number(),
10
10
  }),
11
11
  z.instanceof(Timestamp),
12
+ z.instanceof(Date), // Add support for Date objects that Firestore returns on client
12
13
  ])
13
14
  .transform((data) => {
14
15
  if (data instanceof Timestamp) {
15
16
  return data;
16
17
  }
18
+ if (data instanceof Date) {
19
+ // Convert Date back to Timestamp for consistency
20
+ return Timestamp.fromDate(data);
21
+ }
17
22
  return new Timestamp(data.seconds, data.nanoseconds);
18
23
  });
19
24
 
@@ -24,21 +24,33 @@ export const userRolesSchema = z
24
24
  .min(1, "User must have at least one role")
25
25
  .max(3, "User cannot have more than 3 roles");
26
26
 
27
- export const timestampSchema = z.custom<Timestamp | FieldValue>((data) => {
28
- // If it's a serverTimestamp (FieldValue), it's valid
29
- if (data && typeof data === "object" && "isEqual" in data) {
30
- return true;
31
- }
27
+ export const timestampSchema = z.custom<Timestamp | FieldValue | Date>(
28
+ (data) => {
29
+ // If it's a serverTimestamp (FieldValue), it's valid
30
+ if (data && typeof data === "object" && "isEqual" in data) {
31
+ return true;
32
+ }
32
33
 
33
- // If it's a Timestamp object, validate its structure
34
- return (
35
- data &&
36
- typeof data === "object" &&
37
- "toDate" in data &&
38
- "seconds" in data &&
39
- "nanoseconds" in data
40
- );
41
- }, "Must be a Timestamp object or serverTimestamp");
34
+ // If it's a Timestamp object, validate its structure
35
+ if (
36
+ data &&
37
+ typeof data === "object" &&
38
+ "toDate" in data &&
39
+ "seconds" in data &&
40
+ "nanoseconds" in data
41
+ ) {
42
+ return true;
43
+ }
44
+
45
+ // If it's a JavaScript Date object (what Firestore returns on client), it's valid
46
+ if (data instanceof Date) {
47
+ return true;
48
+ }
49
+
50
+ return false;
51
+ },
52
+ "Must be a Timestamp object, Date object, or serverTimestamp"
53
+ );
42
54
 
43
55
  /**
44
56
  * Validaciona šema za clinic admin opcije pri kreiranju