@blackcode_sa/metaestetics-api 1.4.12 → 1.4.14

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 CHANGED
@@ -876,8 +876,8 @@ declare const CLINICS_COLLECTION = "clinics";
876
876
  interface ClinicContactInfo {
877
877
  email: string;
878
878
  phoneNumber: string;
879
- alternativePhoneNumber?: string;
880
- website?: string;
879
+ alternativePhoneNumber?: string | null;
880
+ website?: string | null;
881
881
  }
882
882
  /**
883
883
  * Interface for clinic location
@@ -889,7 +889,7 @@ interface ClinicLocation {
889
889
  postalCode: string;
890
890
  latitude: number;
891
891
  longitude: number;
892
- geohash?: string;
892
+ geohash?: string | null;
893
893
  }
894
894
  /**
895
895
  * Interface for working hours
package/dist/index.d.ts CHANGED
@@ -876,8 +876,8 @@ declare const CLINICS_COLLECTION = "clinics";
876
876
  interface ClinicContactInfo {
877
877
  email: string;
878
878
  phoneNumber: string;
879
- alternativePhoneNumber?: string;
880
- website?: string;
879
+ alternativePhoneNumber?: string | null;
880
+ website?: string | null;
881
881
  }
882
882
  /**
883
883
  * Interface for clinic location
@@ -889,7 +889,7 @@ interface ClinicLocation {
889
889
  postalCode: string;
890
890
  latitude: number;
891
891
  longitude: number;
892
- geohash?: string;
892
+ geohash?: string | null;
893
893
  }
894
894
  /**
895
895
  * Interface for working hours
package/dist/index.js CHANGED
@@ -3780,20 +3780,19 @@ function generateId() {
3780
3780
  return `${randomPart}-${timestamp}`;
3781
3781
  }
3782
3782
  async function createClinicGroup(db, data, ownerId, isDefault = false, clinicAdminService, app) {
3783
- var _a, _b, _c, _d, _e;
3784
3783
  console.log("[CLINIC_GROUP] Starting clinic group creation", {
3785
3784
  ownerId,
3786
3785
  isDefault
3787
3786
  });
3788
3787
  console.log("[CLINIC_GROUP] Input data:", JSON.stringify(data, null, 2));
3788
+ let validatedData;
3789
3789
  try {
3790
- const validatedData2 = createClinicGroupSchema.parse(data);
3790
+ validatedData = createClinicGroupSchema.parse(data);
3791
3791
  console.log("[CLINIC_GROUP] Data validation passed");
3792
3792
  } catch (validationError) {
3793
3793
  console.error("[CLINIC_GROUP] Data validation failed:", validationError);
3794
3794
  throw validationError;
3795
3795
  }
3796
- const validatedData = createClinicGroupSchema.parse(data);
3797
3796
  try {
3798
3797
  console.log("[CLINIC_GROUP] Checking if owner exists", { ownerId });
3799
3798
  if (isDefault) {
@@ -3853,29 +3852,10 @@ async function createClinicGroup(db, data, ownerId, isDefault = false, clinicAdm
3853
3852
  name: validatedData.name,
3854
3853
  logo: logoUrl,
3855
3854
  // Use the uploaded logo URL or the original value
3856
- description: isDefault ? "" : validatedData.description || "",
3857
- hqLocation: {
3858
- address: validatedData.hqLocation.address || "",
3859
- city: validatedData.hqLocation.city || "",
3860
- country: validatedData.hqLocation.country || "",
3861
- postalCode: validatedData.hqLocation.postalCode || "",
3862
- latitude: validatedData.hqLocation.latitude || 0,
3863
- longitude: validatedData.hqLocation.longitude || 0,
3864
- geohash: validatedData.hqLocation.geohash || ""
3865
- },
3866
- contactInfo: {
3867
- email: validatedData.contactInfo.email || "",
3868
- phoneNumber: validatedData.contactInfo.phoneNumber || "",
3869
- alternativePhoneNumber: isDefault ? "" : validatedData.contactInfo.alternativePhoneNumber || "",
3870
- website: isDefault ? "" : validatedData.contactInfo.website || ""
3871
- },
3872
- contactPerson: {
3873
- firstName: ((_a = validatedData.contactPerson) == null ? void 0 : _a.firstName) || "",
3874
- lastName: ((_b = validatedData.contactPerson) == null ? void 0 : _b.lastName) || "",
3875
- email: ((_c = validatedData.contactPerson) == null ? void 0 : _c.email) || "",
3876
- title: ((_d = validatedData.contactPerson) == null ? void 0 : _d.title) || null,
3877
- phoneNumber: ((_e = validatedData.contactPerson) == null ? void 0 : _e.phoneNumber) || null
3878
- },
3855
+ description: validatedData.description || "",
3856
+ hqLocation: validatedData.hqLocation,
3857
+ contactInfo: validatedData.contactInfo,
3858
+ contactPerson: validatedData.contactPerson,
3879
3859
  subscriptionModel: validatedData.subscriptionModel || "no_subscription" /* NO_SUBSCRIPTION */,
3880
3860
  clinics: [],
3881
3861
  clinicsInfo: [],
@@ -3988,6 +3968,15 @@ async function updateClinicGroup(db, groupId, data, app) {
3988
3968
  console.error("[CLINIC_GROUP] Error processing logo for update:", error);
3989
3969
  }
3990
3970
  }
3971
+ if (updatedData.contactInfo) {
3972
+ updatedData.contactInfo = {
3973
+ ...updatedData.contactInfo,
3974
+ email: updatedData.contactInfo.email || "",
3975
+ phoneNumber: updatedData.contactInfo.phoneNumber || "",
3976
+ alternativePhoneNumber: updatedData.contactInfo.alternativePhoneNumber || "",
3977
+ website: updatedData.contactInfo.website || ""
3978
+ };
3979
+ }
3991
3980
  updatedData = {
3992
3981
  ...updatedData,
3993
3982
  updatedAt: import_firestore15.Timestamp.now()
package/dist/index.mjs CHANGED
@@ -3736,20 +3736,19 @@ function generateId() {
3736
3736
  return `${randomPart}-${timestamp}`;
3737
3737
  }
3738
3738
  async function createClinicGroup(db, data, ownerId, isDefault = false, clinicAdminService, app) {
3739
- var _a, _b, _c, _d, _e;
3740
3739
  console.log("[CLINIC_GROUP] Starting clinic group creation", {
3741
3740
  ownerId,
3742
3741
  isDefault
3743
3742
  });
3744
3743
  console.log("[CLINIC_GROUP] Input data:", JSON.stringify(data, null, 2));
3744
+ let validatedData;
3745
3745
  try {
3746
- const validatedData2 = createClinicGroupSchema.parse(data);
3746
+ validatedData = createClinicGroupSchema.parse(data);
3747
3747
  console.log("[CLINIC_GROUP] Data validation passed");
3748
3748
  } catch (validationError) {
3749
3749
  console.error("[CLINIC_GROUP] Data validation failed:", validationError);
3750
3750
  throw validationError;
3751
3751
  }
3752
- const validatedData = createClinicGroupSchema.parse(data);
3753
3752
  try {
3754
3753
  console.log("[CLINIC_GROUP] Checking if owner exists", { ownerId });
3755
3754
  if (isDefault) {
@@ -3809,29 +3808,10 @@ async function createClinicGroup(db, data, ownerId, isDefault = false, clinicAdm
3809
3808
  name: validatedData.name,
3810
3809
  logo: logoUrl,
3811
3810
  // Use the uploaded logo URL or the original value
3812
- description: isDefault ? "" : validatedData.description || "",
3813
- hqLocation: {
3814
- address: validatedData.hqLocation.address || "",
3815
- city: validatedData.hqLocation.city || "",
3816
- country: validatedData.hqLocation.country || "",
3817
- postalCode: validatedData.hqLocation.postalCode || "",
3818
- latitude: validatedData.hqLocation.latitude || 0,
3819
- longitude: validatedData.hqLocation.longitude || 0,
3820
- geohash: validatedData.hqLocation.geohash || ""
3821
- },
3822
- contactInfo: {
3823
- email: validatedData.contactInfo.email || "",
3824
- phoneNumber: validatedData.contactInfo.phoneNumber || "",
3825
- alternativePhoneNumber: isDefault ? "" : validatedData.contactInfo.alternativePhoneNumber || "",
3826
- website: isDefault ? "" : validatedData.contactInfo.website || ""
3827
- },
3828
- contactPerson: {
3829
- firstName: ((_a = validatedData.contactPerson) == null ? void 0 : _a.firstName) || "",
3830
- lastName: ((_b = validatedData.contactPerson) == null ? void 0 : _b.lastName) || "",
3831
- email: ((_c = validatedData.contactPerson) == null ? void 0 : _c.email) || "",
3832
- title: ((_d = validatedData.contactPerson) == null ? void 0 : _d.title) || null,
3833
- phoneNumber: ((_e = validatedData.contactPerson) == null ? void 0 : _e.phoneNumber) || null
3834
- },
3811
+ description: validatedData.description || "",
3812
+ hqLocation: validatedData.hqLocation,
3813
+ contactInfo: validatedData.contactInfo,
3814
+ contactPerson: validatedData.contactPerson,
3835
3815
  subscriptionModel: validatedData.subscriptionModel || "no_subscription" /* NO_SUBSCRIPTION */,
3836
3816
  clinics: [],
3837
3817
  clinicsInfo: [],
@@ -3944,6 +3924,15 @@ async function updateClinicGroup(db, groupId, data, app) {
3944
3924
  console.error("[CLINIC_GROUP] Error processing logo for update:", error);
3945
3925
  }
3946
3926
  }
3927
+ if (updatedData.contactInfo) {
3928
+ updatedData.contactInfo = {
3929
+ ...updatedData.contactInfo,
3930
+ email: updatedData.contactInfo.email || "",
3931
+ phoneNumber: updatedData.contactInfo.phoneNumber || "",
3932
+ alternativePhoneNumber: updatedData.contactInfo.alternativePhoneNumber || "",
3933
+ website: updatedData.contactInfo.website || ""
3934
+ };
3935
+ }
3947
3936
  updatedData = {
3948
3937
  ...updatedData,
3949
3938
  updatedAt: Timestamp10.now()
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@blackcode_sa/metaestetics-api",
3
3
  "private": false,
4
- "version": "1.4.12",
4
+ "version": "1.4.14",
5
5
  "description": "Firebase authentication service with anonymous upgrade support",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.mjs",
@@ -71,17 +71,16 @@ export async function createClinicGroup(
71
71
  });
72
72
  console.log("[CLINIC_GROUP] Input data:", JSON.stringify(data, null, 2));
73
73
 
74
+ let validatedData: CreateClinicGroupData;
74
75
  // Validacija podataka
75
76
  try {
76
- const validatedData = createClinicGroupSchema.parse(data);
77
+ validatedData = createClinicGroupSchema.parse(data);
77
78
  console.log("[CLINIC_GROUP] Data validation passed");
78
79
  } catch (validationError) {
79
80
  console.error("[CLINIC_GROUP] Data validation failed:", validationError);
80
81
  throw validationError;
81
82
  }
82
83
 
83
- const validatedData = createClinicGroupSchema.parse(data);
84
-
85
84
  // Proveravamo da li owner postoji i da li je clinic admin
86
85
  try {
87
86
  console.log("[CLINIC_GROUP] Checking if owner exists", { ownerId });
@@ -152,31 +151,10 @@ export async function createClinicGroup(
152
151
  id: groupId,
153
152
  name: validatedData.name,
154
153
  logo: logoUrl, // Use the uploaded logo URL or the original value
155
- description: isDefault ? "" : validatedData.description || "",
156
- hqLocation: {
157
- address: validatedData.hqLocation.address || "",
158
- city: validatedData.hqLocation.city || "",
159
- country: validatedData.hqLocation.country || "",
160
- postalCode: validatedData.hqLocation.postalCode || "",
161
- latitude: validatedData.hqLocation.latitude || 0,
162
- longitude: validatedData.hqLocation.longitude || 0,
163
- geohash: validatedData.hqLocation.geohash || "",
164
- },
165
- contactInfo: {
166
- email: validatedData.contactInfo.email || "",
167
- phoneNumber: validatedData.contactInfo.phoneNumber || "",
168
- alternativePhoneNumber: isDefault
169
- ? ""
170
- : validatedData.contactInfo.alternativePhoneNumber || "",
171
- website: isDefault ? "" : validatedData.contactInfo.website || "",
172
- },
173
- contactPerson: {
174
- firstName: validatedData.contactPerson?.firstName || "",
175
- lastName: validatedData.contactPerson?.lastName || "",
176
- email: validatedData.contactPerson?.email || "",
177
- title: validatedData.contactPerson?.title || null,
178
- phoneNumber: validatedData.contactPerson?.phoneNumber || null,
179
- },
154
+ description: validatedData.description || "",
155
+ hqLocation: validatedData.hqLocation,
156
+ contactInfo: validatedData.contactInfo,
157
+ contactPerson: validatedData.contactPerson,
180
158
  subscriptionModel:
181
159
  validatedData.subscriptionModel || SubscriptionModel.NO_SUBSCRIPTION,
182
160
  clinics: [],
@@ -344,6 +322,18 @@ export async function updateClinicGroup(
344
322
  }
345
323
  }
346
324
 
325
+ // Ensure contactInfo fields are never undefined
326
+ if (updatedData.contactInfo) {
327
+ updatedData.contactInfo = {
328
+ ...updatedData.contactInfo,
329
+ email: updatedData.contactInfo.email || "",
330
+ phoneNumber: updatedData.contactInfo.phoneNumber || "",
331
+ alternativePhoneNumber:
332
+ updatedData.contactInfo.alternativePhoneNumber || "",
333
+ website: updatedData.contactInfo.website || "",
334
+ };
335
+ }
336
+
347
337
  // Add timestamp
348
338
  updatedData = {
349
339
  ...updatedData,
@@ -20,8 +20,8 @@ export * from "./preferences.types";
20
20
  export interface ClinicContactInfo {
21
21
  email: string;
22
22
  phoneNumber: string;
23
- alternativePhoneNumber?: string;
24
- website?: string;
23
+ alternativePhoneNumber?: string | null;
24
+ website?: string | null;
25
25
  }
26
26
 
27
27
  /**
@@ -34,7 +34,7 @@ export interface ClinicLocation {
34
34
  postalCode: string;
35
35
  latitude: number;
36
36
  longitude: number;
37
- geohash?: string;
37
+ geohash?: string | null;
38
38
  }
39
39
 
40
40
  /**