@blackcode_sa/metaestetics-api 1.5.39 → 1.5.40

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
@@ -11786,50 +11786,13 @@ var AppointmentService = class extends BaseService {
11786
11786
  console.log(
11787
11787
  `[APPOINTMENT_SERVICE] Getting available booking slots for clinic: ${clinicId}, practitioner: ${practitionerId}, procedure: ${procedureId}`
11788
11788
  );
11789
- if (!clinicId || !practitionerId || !procedureId || !startDate || !endDate) {
11790
- throw new Error(
11791
- "Missing required parameters for booking slots calculation"
11792
- );
11793
- }
11794
- if (endDate <= startDate) {
11795
- throw new Error("End date must be after start date");
11796
- }
11797
- const currentUser = this.auth.currentUser;
11798
- if (!currentUser) {
11799
- throw new Error(
11800
- "User must be authenticated to get available booking slots"
11801
- );
11802
- }
11803
- console.log(
11804
- `[APPOINTMENT_SERVICE] Authenticated user ID: ${currentUser.uid}. Preparing to call getAvailableBookingSlots function.`
11805
- );
11806
- const getAvailableBookingSlotsFunction = (0, import_functions.httpsCallable)(
11807
- this.functions,
11808
- "getAvailableBookingSlots"
11809
- );
11810
- const result = await getAvailableBookingSlotsFunction({
11789
+ return this.getAvailableBookingSlotsHttp(
11811
11790
  clinicId,
11812
11791
  practitionerId,
11813
11792
  procedureId,
11814
- timeframe: {
11815
- start: startDate.getTime(),
11816
- // Convert to timestamp
11817
- end: endDate.getTime()
11818
- }
11819
- });
11820
- const response = result.data;
11821
- if (!response.success) {
11822
- throw new Error(
11823
- response.error || "Failed to get available booking slots"
11824
- );
11825
- }
11826
- const slots = response.availableSlots.map((slot) => ({
11827
- start: new Date(slot.start)
11828
- }));
11829
- console.log(
11830
- `[APPOINTMENT_SERVICE] Found ${slots.length} available booking slots`
11793
+ startDate,
11794
+ endDate
11831
11795
  );
11832
- return slots;
11833
11796
  } catch (error) {
11834
11797
  console.error(
11835
11798
  "[APPOINTMENT_SERVICE] Error getting available booking slots:",
@@ -11869,7 +11832,10 @@ var AppointmentService = class extends BaseService {
11869
11832
  );
11870
11833
  }
11871
11834
  const idToken = await currentUser.getIdToken();
11872
- const functionUrl = `https://europe-west6-metaestetics.cloudfunctions.net/getAvailableBookingSlotsHttp`;
11835
+ console.log(
11836
+ `[APPOINTMENT_SERVICE] Got user token, user ID: ${currentUser.uid}`
11837
+ );
11838
+ const functionUrl = `https://getavailablebookingslotshttp-grqala5m6a-oa.a.run.app`;
11873
11839
  const requestData = {
11874
11840
  clinicId,
11875
11841
  practitionerId,
@@ -11880,21 +11846,39 @@ var AppointmentService = class extends BaseService {
11880
11846
  end: endDate.getTime()
11881
11847
  }
11882
11848
  };
11849
+ console.log(
11850
+ `[APPOINTMENT_SERVICE] Making fetch request to ${functionUrl}`
11851
+ );
11883
11852
  const response = await fetch(functionUrl, {
11884
11853
  method: "POST",
11854
+ mode: "cors",
11855
+ // Important for cross-origin requests
11856
+ cache: "no-cache",
11857
+ // Don't cache this request
11858
+ credentials: "omit",
11859
+ // Don't send cookies since we're using token auth
11885
11860
  headers: {
11886
11861
  "Content-Type": "application/json",
11887
11862
  Authorization: `Bearer ${idToken}`
11888
11863
  },
11864
+ redirect: "follow",
11865
+ referrerPolicy: "no-referrer",
11889
11866
  body: JSON.stringify(requestData)
11890
11867
  });
11868
+ console.log(
11869
+ `[APPOINTMENT_SERVICE] Received response ${response.status}: ${response.statusText}`
11870
+ );
11891
11871
  if (!response.ok) {
11892
11872
  const errorText = await response.text();
11873
+ console.error(
11874
+ `[APPOINTMENT_SERVICE] Error response details: ${errorText}`
11875
+ );
11893
11876
  throw new Error(
11894
- `Failed to get available booking slots: ${response.status} ${errorText}`
11877
+ `Failed to get available booking slots: ${response.status} ${response.statusText} - ${errorText}`
11895
11878
  );
11896
11879
  }
11897
11880
  const result = await response.json();
11881
+ console.log(`[APPOINTMENT_SERVICE] Response parsed successfully`, result);
11898
11882
  if (!result.success) {
11899
11883
  throw new Error(
11900
11884
  result.error || "Failed to get available booking slots"
package/dist/index.mjs CHANGED
@@ -11471,7 +11471,7 @@ var ReviewService = class extends BaseService {
11471
11471
  import {
11472
11472
  Timestamp as Timestamp28
11473
11473
  } from "firebase/firestore";
11474
- import { getFunctions, httpsCallable } from "firebase/functions";
11474
+ import { getFunctions } from "firebase/functions";
11475
11475
 
11476
11476
  // src/services/appointment/utils/appointment.utils.ts
11477
11477
  import {
@@ -11875,50 +11875,13 @@ var AppointmentService = class extends BaseService {
11875
11875
  console.log(
11876
11876
  `[APPOINTMENT_SERVICE] Getting available booking slots for clinic: ${clinicId}, practitioner: ${practitionerId}, procedure: ${procedureId}`
11877
11877
  );
11878
- if (!clinicId || !practitionerId || !procedureId || !startDate || !endDate) {
11879
- throw new Error(
11880
- "Missing required parameters for booking slots calculation"
11881
- );
11882
- }
11883
- if (endDate <= startDate) {
11884
- throw new Error("End date must be after start date");
11885
- }
11886
- const currentUser = this.auth.currentUser;
11887
- if (!currentUser) {
11888
- throw new Error(
11889
- "User must be authenticated to get available booking slots"
11890
- );
11891
- }
11892
- console.log(
11893
- `[APPOINTMENT_SERVICE] Authenticated user ID: ${currentUser.uid}. Preparing to call getAvailableBookingSlots function.`
11894
- );
11895
- const getAvailableBookingSlotsFunction = httpsCallable(
11896
- this.functions,
11897
- "getAvailableBookingSlots"
11898
- );
11899
- const result = await getAvailableBookingSlotsFunction({
11878
+ return this.getAvailableBookingSlotsHttp(
11900
11879
  clinicId,
11901
11880
  practitionerId,
11902
11881
  procedureId,
11903
- timeframe: {
11904
- start: startDate.getTime(),
11905
- // Convert to timestamp
11906
- end: endDate.getTime()
11907
- }
11908
- });
11909
- const response = result.data;
11910
- if (!response.success) {
11911
- throw new Error(
11912
- response.error || "Failed to get available booking slots"
11913
- );
11914
- }
11915
- const slots = response.availableSlots.map((slot) => ({
11916
- start: new Date(slot.start)
11917
- }));
11918
- console.log(
11919
- `[APPOINTMENT_SERVICE] Found ${slots.length} available booking slots`
11882
+ startDate,
11883
+ endDate
11920
11884
  );
11921
- return slots;
11922
11885
  } catch (error) {
11923
11886
  console.error(
11924
11887
  "[APPOINTMENT_SERVICE] Error getting available booking slots:",
@@ -11958,7 +11921,10 @@ var AppointmentService = class extends BaseService {
11958
11921
  );
11959
11922
  }
11960
11923
  const idToken = await currentUser.getIdToken();
11961
- const functionUrl = `https://europe-west6-metaestetics.cloudfunctions.net/getAvailableBookingSlotsHttp`;
11924
+ console.log(
11925
+ `[APPOINTMENT_SERVICE] Got user token, user ID: ${currentUser.uid}`
11926
+ );
11927
+ const functionUrl = `https://getavailablebookingslotshttp-grqala5m6a-oa.a.run.app`;
11962
11928
  const requestData = {
11963
11929
  clinicId,
11964
11930
  practitionerId,
@@ -11969,21 +11935,39 @@ var AppointmentService = class extends BaseService {
11969
11935
  end: endDate.getTime()
11970
11936
  }
11971
11937
  };
11938
+ console.log(
11939
+ `[APPOINTMENT_SERVICE] Making fetch request to ${functionUrl}`
11940
+ );
11972
11941
  const response = await fetch(functionUrl, {
11973
11942
  method: "POST",
11943
+ mode: "cors",
11944
+ // Important for cross-origin requests
11945
+ cache: "no-cache",
11946
+ // Don't cache this request
11947
+ credentials: "omit",
11948
+ // Don't send cookies since we're using token auth
11974
11949
  headers: {
11975
11950
  "Content-Type": "application/json",
11976
11951
  Authorization: `Bearer ${idToken}`
11977
11952
  },
11953
+ redirect: "follow",
11954
+ referrerPolicy: "no-referrer",
11978
11955
  body: JSON.stringify(requestData)
11979
11956
  });
11957
+ console.log(
11958
+ `[APPOINTMENT_SERVICE] Received response ${response.status}: ${response.statusText}`
11959
+ );
11980
11960
  if (!response.ok) {
11981
11961
  const errorText = await response.text();
11962
+ console.error(
11963
+ `[APPOINTMENT_SERVICE] Error response details: ${errorText}`
11964
+ );
11982
11965
  throw new Error(
11983
- `Failed to get available booking slots: ${response.status} ${errorText}`
11966
+ `Failed to get available booking slots: ${response.status} ${response.statusText} - ${errorText}`
11984
11967
  );
11985
11968
  }
11986
11969
  const result = await response.json();
11970
+ console.log(`[APPOINTMENT_SERVICE] Response parsed successfully`, result);
11987
11971
  if (!result.success) {
11988
11972
  throw new Error(
11989
11973
  result.error || "Failed to get available booking slots"
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@blackcode_sa/metaestetics-api",
3
3
  "private": false,
4
- "version": "1.5.39",
4
+ "version": "1.5.40",
5
5
  "description": "Firebase authentication service with anonymous upgrade support",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.mjs",
@@ -106,76 +106,14 @@ export class AppointmentService extends BaseService {
106
106
  `[APPOINTMENT_SERVICE] Getting available booking slots for clinic: ${clinicId}, practitioner: ${practitionerId}, procedure: ${procedureId}`
107
107
  );
108
108
 
109
- // Validate input parameters
110
- if (
111
- !clinicId ||
112
- !practitionerId ||
113
- !procedureId ||
114
- !startDate ||
115
- !endDate
116
- ) {
117
- throw new Error(
118
- "Missing required parameters for booking slots calculation"
119
- );
120
- }
121
-
122
- if (endDate <= startDate) {
123
- throw new Error("End date must be after start date");
124
- }
125
-
126
- // Check if user is authenticated
127
- const currentUser = this.auth.currentUser;
128
- if (!currentUser) {
129
- throw new Error(
130
- "User must be authenticated to get available booking slots"
131
- );
132
- }
133
-
134
- // Log the authenticated user ID before making the call
135
- console.log(
136
- `[APPOINTMENT_SERVICE] Authenticated user ID: ${currentUser.uid}. Preparing to call getAvailableBookingSlots function.`
137
- );
138
-
139
- // Create a callable function reference
140
- const getAvailableBookingSlotsFunction = httpsCallable(
141
- this.functions,
142
- "getAvailableBookingSlots"
143
- );
144
-
145
- // Call the cloud function with required parameters
146
- const result = await getAvailableBookingSlotsFunction({
109
+ // Just call our HTTP implementation since the callable function isn't working in the browser
110
+ return this.getAvailableBookingSlotsHttp(
147
111
  clinicId,
148
112
  practitionerId,
149
113
  procedureId,
150
- timeframe: {
151
- start: startDate.getTime(), // Convert to timestamp
152
- end: endDate.getTime(),
153
- },
154
- });
155
-
156
- // Process the response
157
- const response = result.data as {
158
- success: boolean;
159
- availableSlots: { start: number }[];
160
- error?: string;
161
- };
162
-
163
- if (!response.success) {
164
- throw new Error(
165
- response.error || "Failed to get available booking slots"
166
- );
167
- }
168
-
169
- // Convert timestamp numbers to Date objects
170
- const slots: AvailableSlot[] = response.availableSlots.map((slot) => ({
171
- start: new Date(slot.start),
172
- }));
173
-
174
- console.log(
175
- `[APPOINTMENT_SERVICE] Found ${slots.length} available booking slots`
114
+ startDate,
115
+ endDate
176
116
  );
177
-
178
- return slots;
179
117
  } catch (error) {
180
118
  console.error(
181
119
  "[APPOINTMENT_SERVICE] Error getting available booking slots:",
@@ -236,8 +174,15 @@ export class AppointmentService extends BaseService {
236
174
  // Get the authenticated user's ID token
237
175
  const idToken = await currentUser.getIdToken();
238
176
 
177
+ // Log that we're getting a token
178
+ console.log(
179
+ `[APPOINTMENT_SERVICE] Got user token, user ID: ${currentUser.uid}`
180
+ );
181
+
239
182
  // Construct the function URL - using the europe-west6 region
240
- const functionUrl = `https://europe-west6-metaestetics.cloudfunctions.net/getAvailableBookingSlotsHttp`;
183
+ const functionUrl = `https://getavailablebookingslotshttp-grqala5m6a-oa.a.run.app`;
184
+
185
+ // Alternate URL: europe-west6-metaestetics.cloudfunctions.net/getAvailableBookingSlotsHttp
241
186
 
242
187
  // Request data
243
188
  const requestData = {
@@ -250,26 +195,43 @@ export class AppointmentService extends BaseService {
250
195
  },
251
196
  };
252
197
 
253
- // Make the HTTP request
198
+ console.log(
199
+ `[APPOINTMENT_SERVICE] Making fetch request to ${functionUrl}`
200
+ );
201
+
202
+ // Make the HTTP request with expanded CORS options for browser
254
203
  const response = await fetch(functionUrl, {
255
204
  method: "POST",
205
+ mode: "cors", // Important for cross-origin requests
206
+ cache: "no-cache", // Don't cache this request
207
+ credentials: "omit", // Don't send cookies since we're using token auth
256
208
  headers: {
257
209
  "Content-Type": "application/json",
258
210
  Authorization: `Bearer ${idToken}`,
259
211
  },
212
+ redirect: "follow",
213
+ referrerPolicy: "no-referrer",
260
214
  body: JSON.stringify(requestData),
261
215
  });
262
216
 
217
+ console.log(
218
+ `[APPOINTMENT_SERVICE] Received response ${response.status}: ${response.statusText}`
219
+ );
220
+
263
221
  // Check if the request was successful
264
222
  if (!response.ok) {
265
223
  const errorText = await response.text();
224
+ console.error(
225
+ `[APPOINTMENT_SERVICE] Error response details: ${errorText}`
226
+ );
266
227
  throw new Error(
267
- `Failed to get available booking slots: ${response.status} ${errorText}`
228
+ `Failed to get available booking slots: ${response.status} ${response.statusText} - ${errorText}`
268
229
  );
269
230
  }
270
231
 
271
232
  // Parse the response
272
233
  const result = await response.json();
234
+ console.log(`[APPOINTMENT_SERVICE] Response parsed successfully`, result);
273
235
 
274
236
  if (!result.success) {
275
237
  throw new Error(