@blackcode_sa/metaestetics-api 1.5.1 → 1.5.3
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.d.mts +13 -13
- package/dist/index.d.ts +13 -13
- package/dist/index.js +4 -20
- package/dist/index.mjs +4 -20
- package/package.json +1 -1
- package/src/services/user.service.ts +2 -22
- package/src/types/index.ts +3 -3
- package/src/validations/schemas.ts +9 -3
package/dist/index.d.mts
CHANGED
|
@@ -3658,9 +3658,9 @@ interface User {
|
|
|
3658
3658
|
email: string | null;
|
|
3659
3659
|
roles: UserRole[];
|
|
3660
3660
|
isAnonymous: boolean;
|
|
3661
|
-
createdAt: Timestamp;
|
|
3662
|
-
updatedAt: Timestamp;
|
|
3663
|
-
lastLoginAt: Timestamp;
|
|
3661
|
+
createdAt: Timestamp | FieldValue;
|
|
3662
|
+
updatedAt: Timestamp | FieldValue;
|
|
3663
|
+
lastLoginAt: Timestamp | FieldValue;
|
|
3664
3664
|
patientProfile?: string;
|
|
3665
3665
|
practitionerProfile?: string;
|
|
3666
3666
|
adminProfile?: string;
|
|
@@ -5012,7 +5012,7 @@ declare const emailSchema: z.ZodString;
|
|
|
5012
5012
|
declare const passwordSchema: z.ZodString;
|
|
5013
5013
|
declare const userRoleSchema: z.ZodNativeEnum<typeof UserRole>;
|
|
5014
5014
|
declare const userRolesSchema: z.ZodArray<z.ZodNativeEnum<typeof UserRole>, "many">;
|
|
5015
|
-
declare const timestampSchema: z.ZodType<Timestamp, z.ZodTypeDef, Timestamp>;
|
|
5015
|
+
declare const timestampSchema: z.ZodType<Timestamp | FieldValue, z.ZodTypeDef, Timestamp | FieldValue>;
|
|
5016
5016
|
/**
|
|
5017
5017
|
* Validaciona šema za clinic admin opcije pri kreiranju
|
|
5018
5018
|
*/
|
|
@@ -5080,31 +5080,31 @@ declare const userSchema: z.ZodObject<{
|
|
|
5080
5080
|
email: z.ZodNullable<z.ZodString>;
|
|
5081
5081
|
roles: z.ZodArray<z.ZodNativeEnum<typeof UserRole>, "many">;
|
|
5082
5082
|
isAnonymous: z.ZodBoolean;
|
|
5083
|
-
createdAt: z.ZodType<Timestamp, z.ZodTypeDef, Timestamp>;
|
|
5084
|
-
updatedAt: z.ZodType<Timestamp, z.ZodTypeDef, Timestamp>;
|
|
5085
|
-
lastLoginAt: z.ZodType<Timestamp, z.ZodTypeDef, Timestamp>;
|
|
5083
|
+
createdAt: z.ZodType<Timestamp | FieldValue, z.ZodTypeDef, Timestamp | FieldValue>;
|
|
5084
|
+
updatedAt: z.ZodType<Timestamp | FieldValue, z.ZodTypeDef, Timestamp | FieldValue>;
|
|
5085
|
+
lastLoginAt: z.ZodType<Timestamp | FieldValue, z.ZodTypeDef, Timestamp | FieldValue>;
|
|
5086
5086
|
patientProfile: z.ZodOptional<z.ZodString>;
|
|
5087
5087
|
practitionerProfile: z.ZodOptional<z.ZodString>;
|
|
5088
5088
|
adminProfile: z.ZodOptional<z.ZodString>;
|
|
5089
5089
|
}, "strip", z.ZodTypeAny, {
|
|
5090
|
-
updatedAt: Timestamp;
|
|
5090
|
+
updatedAt: Timestamp | FieldValue;
|
|
5091
5091
|
email: string | null;
|
|
5092
|
-
createdAt: Timestamp;
|
|
5092
|
+
createdAt: Timestamp | FieldValue;
|
|
5093
5093
|
uid: string;
|
|
5094
5094
|
roles: UserRole[];
|
|
5095
5095
|
isAnonymous: boolean;
|
|
5096
|
-
lastLoginAt: Timestamp;
|
|
5096
|
+
lastLoginAt: Timestamp | FieldValue;
|
|
5097
5097
|
patientProfile?: string | undefined;
|
|
5098
5098
|
practitionerProfile?: string | undefined;
|
|
5099
5099
|
adminProfile?: string | undefined;
|
|
5100
5100
|
}, {
|
|
5101
|
-
updatedAt: Timestamp;
|
|
5101
|
+
updatedAt: Timestamp | FieldValue;
|
|
5102
5102
|
email: string | null;
|
|
5103
|
-
createdAt: Timestamp;
|
|
5103
|
+
createdAt: Timestamp | FieldValue;
|
|
5104
5104
|
uid: string;
|
|
5105
5105
|
roles: UserRole[];
|
|
5106
5106
|
isAnonymous: boolean;
|
|
5107
|
-
lastLoginAt: Timestamp;
|
|
5107
|
+
lastLoginAt: Timestamp | FieldValue;
|
|
5108
5108
|
patientProfile?: string | undefined;
|
|
5109
5109
|
practitionerProfile?: string | undefined;
|
|
5110
5110
|
adminProfile?: string | undefined;
|
package/dist/index.d.ts
CHANGED
|
@@ -3658,9 +3658,9 @@ interface User {
|
|
|
3658
3658
|
email: string | null;
|
|
3659
3659
|
roles: UserRole[];
|
|
3660
3660
|
isAnonymous: boolean;
|
|
3661
|
-
createdAt: Timestamp;
|
|
3662
|
-
updatedAt: Timestamp;
|
|
3663
|
-
lastLoginAt: Timestamp;
|
|
3661
|
+
createdAt: Timestamp | FieldValue;
|
|
3662
|
+
updatedAt: Timestamp | FieldValue;
|
|
3663
|
+
lastLoginAt: Timestamp | FieldValue;
|
|
3664
3664
|
patientProfile?: string;
|
|
3665
3665
|
practitionerProfile?: string;
|
|
3666
3666
|
adminProfile?: string;
|
|
@@ -5012,7 +5012,7 @@ declare const emailSchema: z.ZodString;
|
|
|
5012
5012
|
declare const passwordSchema: z.ZodString;
|
|
5013
5013
|
declare const userRoleSchema: z.ZodNativeEnum<typeof UserRole>;
|
|
5014
5014
|
declare const userRolesSchema: z.ZodArray<z.ZodNativeEnum<typeof UserRole>, "many">;
|
|
5015
|
-
declare const timestampSchema: z.ZodType<Timestamp, z.ZodTypeDef, Timestamp>;
|
|
5015
|
+
declare const timestampSchema: z.ZodType<Timestamp | FieldValue, z.ZodTypeDef, Timestamp | FieldValue>;
|
|
5016
5016
|
/**
|
|
5017
5017
|
* Validaciona šema za clinic admin opcije pri kreiranju
|
|
5018
5018
|
*/
|
|
@@ -5080,31 +5080,31 @@ declare const userSchema: z.ZodObject<{
|
|
|
5080
5080
|
email: z.ZodNullable<z.ZodString>;
|
|
5081
5081
|
roles: z.ZodArray<z.ZodNativeEnum<typeof UserRole>, "many">;
|
|
5082
5082
|
isAnonymous: z.ZodBoolean;
|
|
5083
|
-
createdAt: z.ZodType<Timestamp, z.ZodTypeDef, Timestamp>;
|
|
5084
|
-
updatedAt: z.ZodType<Timestamp, z.ZodTypeDef, Timestamp>;
|
|
5085
|
-
lastLoginAt: z.ZodType<Timestamp, z.ZodTypeDef, Timestamp>;
|
|
5083
|
+
createdAt: z.ZodType<Timestamp | FieldValue, z.ZodTypeDef, Timestamp | FieldValue>;
|
|
5084
|
+
updatedAt: z.ZodType<Timestamp | FieldValue, z.ZodTypeDef, Timestamp | FieldValue>;
|
|
5085
|
+
lastLoginAt: z.ZodType<Timestamp | FieldValue, z.ZodTypeDef, Timestamp | FieldValue>;
|
|
5086
5086
|
patientProfile: z.ZodOptional<z.ZodString>;
|
|
5087
5087
|
practitionerProfile: z.ZodOptional<z.ZodString>;
|
|
5088
5088
|
adminProfile: z.ZodOptional<z.ZodString>;
|
|
5089
5089
|
}, "strip", z.ZodTypeAny, {
|
|
5090
|
-
updatedAt: Timestamp;
|
|
5090
|
+
updatedAt: Timestamp | FieldValue;
|
|
5091
5091
|
email: string | null;
|
|
5092
|
-
createdAt: Timestamp;
|
|
5092
|
+
createdAt: Timestamp | FieldValue;
|
|
5093
5093
|
uid: string;
|
|
5094
5094
|
roles: UserRole[];
|
|
5095
5095
|
isAnonymous: boolean;
|
|
5096
|
-
lastLoginAt: Timestamp;
|
|
5096
|
+
lastLoginAt: Timestamp | FieldValue;
|
|
5097
5097
|
patientProfile?: string | undefined;
|
|
5098
5098
|
practitionerProfile?: string | undefined;
|
|
5099
5099
|
adminProfile?: string | undefined;
|
|
5100
5100
|
}, {
|
|
5101
|
-
updatedAt: Timestamp;
|
|
5101
|
+
updatedAt: Timestamp | FieldValue;
|
|
5102
5102
|
email: string | null;
|
|
5103
|
-
createdAt: Timestamp;
|
|
5103
|
+
createdAt: Timestamp | FieldValue;
|
|
5104
5104
|
uid: string;
|
|
5105
5105
|
roles: UserRole[];
|
|
5106
5106
|
isAnonymous: boolean;
|
|
5107
|
-
lastLoginAt: Timestamp;
|
|
5107
|
+
lastLoginAt: Timestamp | FieldValue;
|
|
5108
5108
|
patientProfile?: string | undefined;
|
|
5109
5109
|
practitionerProfile?: string | undefined;
|
|
5110
5110
|
adminProfile?: string | undefined;
|
package/dist/index.js
CHANGED
|
@@ -460,8 +460,11 @@ var passwordSchema = import_zod2.z.string().min(8, "Password must be at least 8
|
|
|
460
460
|
var userRoleSchema = import_zod2.z.nativeEnum(UserRole);
|
|
461
461
|
var userRolesSchema = import_zod2.z.array(userRoleSchema).min(1, "User must have at least one role").max(3, "User cannot have more than 3 roles");
|
|
462
462
|
var timestampSchema = import_zod2.z.custom((data) => {
|
|
463
|
+
if (data && typeof data === "object" && "isEqual" in data) {
|
|
464
|
+
return true;
|
|
465
|
+
}
|
|
463
466
|
return data && typeof data === "object" && "toDate" in data && "seconds" in data && "nanoseconds" in data;
|
|
464
|
-
}, "Must be a Timestamp object");
|
|
467
|
+
}, "Must be a Timestamp object or serverTimestamp");
|
|
465
468
|
var clinicAdminOptionsSchema = import_zod2.z.object({
|
|
466
469
|
isGroupOwner: import_zod2.z.boolean(),
|
|
467
470
|
groupToken: import_zod2.z.string().optional(),
|
|
@@ -3976,25 +3979,6 @@ var UserService = class extends BaseService {
|
|
|
3976
3979
|
...updates,
|
|
3977
3980
|
updatedAt: (0, import_firestore14.serverTimestamp)()
|
|
3978
3981
|
};
|
|
3979
|
-
updatedUser.roles.forEach((role) => {
|
|
3980
|
-
switch (role) {
|
|
3981
|
-
case "patient" /* PATIENT */:
|
|
3982
|
-
if (!updatedUser.patientProfile) {
|
|
3983
|
-
throw new Error(`Missing patient profile for role ${role}`);
|
|
3984
|
-
}
|
|
3985
|
-
break;
|
|
3986
|
-
case "practitioner" /* PRACTITIONER */:
|
|
3987
|
-
if (!updatedUser.practitionerProfile) {
|
|
3988
|
-
throw new Error(`Missing practitioner profile for role ${role}`);
|
|
3989
|
-
}
|
|
3990
|
-
break;
|
|
3991
|
-
case "clinic_admin" /* CLINIC_ADMIN */:
|
|
3992
|
-
if (!updatedUser.adminProfile) {
|
|
3993
|
-
throw new Error(`Missing admin profile for role ${role}`);
|
|
3994
|
-
}
|
|
3995
|
-
break;
|
|
3996
|
-
}
|
|
3997
|
-
});
|
|
3998
3982
|
userSchema.parse(updatedUser);
|
|
3999
3983
|
await (0, import_firestore14.updateDoc)(userRef, {
|
|
4000
3984
|
...updates,
|
package/dist/index.mjs
CHANGED
|
@@ -288,8 +288,11 @@ var passwordSchema = z2.string().min(8, "Password must be at least 8 characters"
|
|
|
288
288
|
var userRoleSchema = z2.nativeEnum(UserRole);
|
|
289
289
|
var userRolesSchema = z2.array(userRoleSchema).min(1, "User must have at least one role").max(3, "User cannot have more than 3 roles");
|
|
290
290
|
var timestampSchema = z2.custom((data) => {
|
|
291
|
+
if (data && typeof data === "object" && "isEqual" in data) {
|
|
292
|
+
return true;
|
|
293
|
+
}
|
|
291
294
|
return data && typeof data === "object" && "toDate" in data && "seconds" in data && "nanoseconds" in data;
|
|
292
|
-
}, "Must be a Timestamp object");
|
|
295
|
+
}, "Must be a Timestamp object or serverTimestamp");
|
|
293
296
|
var clinicAdminOptionsSchema = z2.object({
|
|
294
297
|
isGroupOwner: z2.boolean(),
|
|
295
298
|
groupToken: z2.string().optional(),
|
|
@@ -3888,25 +3891,6 @@ var UserService = class extends BaseService {
|
|
|
3888
3891
|
...updates,
|
|
3889
3892
|
updatedAt: serverTimestamp10()
|
|
3890
3893
|
};
|
|
3891
|
-
updatedUser.roles.forEach((role) => {
|
|
3892
|
-
switch (role) {
|
|
3893
|
-
case "patient" /* PATIENT */:
|
|
3894
|
-
if (!updatedUser.patientProfile) {
|
|
3895
|
-
throw new Error(`Missing patient profile for role ${role}`);
|
|
3896
|
-
}
|
|
3897
|
-
break;
|
|
3898
|
-
case "practitioner" /* PRACTITIONER */:
|
|
3899
|
-
if (!updatedUser.practitionerProfile) {
|
|
3900
|
-
throw new Error(`Missing practitioner profile for role ${role}`);
|
|
3901
|
-
}
|
|
3902
|
-
break;
|
|
3903
|
-
case "clinic_admin" /* CLINIC_ADMIN */:
|
|
3904
|
-
if (!updatedUser.adminProfile) {
|
|
3905
|
-
throw new Error(`Missing admin profile for role ${role}`);
|
|
3906
|
-
}
|
|
3907
|
-
break;
|
|
3908
|
-
}
|
|
3909
|
-
});
|
|
3910
3894
|
userSchema.parse(updatedUser);
|
|
3911
3895
|
await updateDoc9(userRef, {
|
|
3912
3896
|
...updates,
|
package/package.json
CHANGED
|
@@ -343,30 +343,10 @@ export class UserService extends BaseService {
|
|
|
343
343
|
updatedAt: serverTimestamp(),
|
|
344
344
|
};
|
|
345
345
|
|
|
346
|
-
//
|
|
347
|
-
// Ovo je samo provera - kreiranje profila se radi kroz addRole metodu
|
|
348
|
-
updatedUser.roles.forEach((role: UserRole) => {
|
|
349
|
-
switch (role) {
|
|
350
|
-
case UserRole.PATIENT:
|
|
351
|
-
if (!updatedUser.patientProfile) {
|
|
352
|
-
throw new Error(`Missing patient profile for role ${role}`);
|
|
353
|
-
}
|
|
354
|
-
break;
|
|
355
|
-
case UserRole.PRACTITIONER:
|
|
356
|
-
if (!updatedUser.practitionerProfile) {
|
|
357
|
-
throw new Error(`Missing practitioner profile for role ${role}`);
|
|
358
|
-
}
|
|
359
|
-
break;
|
|
360
|
-
case UserRole.CLINIC_ADMIN:
|
|
361
|
-
if (!updatedUser.adminProfile) {
|
|
362
|
-
throw new Error(`Missing admin profile for role ${role}`);
|
|
363
|
-
}
|
|
364
|
-
break;
|
|
365
|
-
}
|
|
366
|
-
});
|
|
367
|
-
|
|
346
|
+
// Validate the complete updated user object
|
|
368
347
|
userSchema.parse(updatedUser);
|
|
369
348
|
|
|
349
|
+
// Update only the specified fields plus updatedAt
|
|
370
350
|
await updateDoc(userRef, {
|
|
371
351
|
...updates,
|
|
372
352
|
updatedAt: serverTimestamp(),
|
package/src/types/index.ts
CHANGED
|
@@ -14,9 +14,9 @@ export interface User {
|
|
|
14
14
|
email: string | null;
|
|
15
15
|
roles: UserRole[];
|
|
16
16
|
isAnonymous: boolean;
|
|
17
|
-
createdAt: Timestamp;
|
|
18
|
-
updatedAt: Timestamp;
|
|
19
|
-
lastLoginAt: Timestamp;
|
|
17
|
+
createdAt: Timestamp | FieldValue;
|
|
18
|
+
updatedAt: Timestamp | FieldValue;
|
|
19
|
+
lastLoginAt: Timestamp | FieldValue;
|
|
20
20
|
patientProfile?: string;
|
|
21
21
|
practitionerProfile?: string;
|
|
22
22
|
adminProfile?: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { UserRole } from "../types";
|
|
3
|
-
import { Timestamp } from "firebase/firestore";
|
|
3
|
+
import { Timestamp, FieldValue } from "firebase/firestore";
|
|
4
4
|
|
|
5
5
|
export const emailSchema = z
|
|
6
6
|
.string()
|
|
@@ -24,7 +24,13 @@ 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>((data) => {
|
|
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
|
+
}
|
|
32
|
+
|
|
33
|
+
// If it's a Timestamp object, validate its structure
|
|
28
34
|
return (
|
|
29
35
|
data &&
|
|
30
36
|
typeof data === "object" &&
|
|
@@ -32,7 +38,7 @@ export const timestampSchema = z.custom<Timestamp>((data) => {
|
|
|
32
38
|
"seconds" in data &&
|
|
33
39
|
"nanoseconds" in data
|
|
34
40
|
);
|
|
35
|
-
}, "Must be a Timestamp object");
|
|
41
|
+
}, "Must be a Timestamp object or serverTimestamp");
|
|
36
42
|
|
|
37
43
|
/**
|
|
38
44
|
* Validaciona šema za clinic admin opcije pri kreiranju
|