@blackcode_sa/metaestetics-api 1.5.38 → 1.5.39
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 +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +79 -0
- package/dist/index.mjs +79 -0
- package/package.json +1 -1
- package/src/services/appointment/appointment.service.ts +113 -0
package/dist/index.d.mts
CHANGED
|
@@ -6385,6 +6385,18 @@ declare class AppointmentService extends BaseService {
|
|
|
6385
6385
|
* @returns Array of available booking slots
|
|
6386
6386
|
*/
|
|
6387
6387
|
getAvailableBookingSlots(clinicId: string, practitionerId: string, procedureId: string, startDate: Date, endDate: Date): Promise<AvailableSlot[]>;
|
|
6388
|
+
/**
|
|
6389
|
+
* Gets available booking slots for a specific clinic, practitioner, and procedure using HTTP request.
|
|
6390
|
+
* This is an alternative implementation using direct HTTP request instead of callable function.
|
|
6391
|
+
*
|
|
6392
|
+
* @param clinicId ID of the clinic
|
|
6393
|
+
* @param practitionerId ID of the practitioner
|
|
6394
|
+
* @param procedureId ID of the procedure
|
|
6395
|
+
* @param startDate Start date of the time range to check
|
|
6396
|
+
* @param endDate End date of the time range to check
|
|
6397
|
+
* @returns Array of available booking slots
|
|
6398
|
+
*/
|
|
6399
|
+
getAvailableBookingSlotsHttp(clinicId: string, practitionerId: string, procedureId: string, startDate: Date, endDate: Date): Promise<AvailableSlot[]>;
|
|
6388
6400
|
/**
|
|
6389
6401
|
* Creates a new appointment.
|
|
6390
6402
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -6385,6 +6385,18 @@ declare class AppointmentService extends BaseService {
|
|
|
6385
6385
|
* @returns Array of available booking slots
|
|
6386
6386
|
*/
|
|
6387
6387
|
getAvailableBookingSlots(clinicId: string, practitionerId: string, procedureId: string, startDate: Date, endDate: Date): Promise<AvailableSlot[]>;
|
|
6388
|
+
/**
|
|
6389
|
+
* Gets available booking slots for a specific clinic, practitioner, and procedure using HTTP request.
|
|
6390
|
+
* This is an alternative implementation using direct HTTP request instead of callable function.
|
|
6391
|
+
*
|
|
6392
|
+
* @param clinicId ID of the clinic
|
|
6393
|
+
* @param practitionerId ID of the practitioner
|
|
6394
|
+
* @param procedureId ID of the procedure
|
|
6395
|
+
* @param startDate Start date of the time range to check
|
|
6396
|
+
* @param endDate End date of the time range to check
|
|
6397
|
+
* @returns Array of available booking slots
|
|
6398
|
+
*/
|
|
6399
|
+
getAvailableBookingSlotsHttp(clinicId: string, practitionerId: string, procedureId: string, startDate: Date, endDate: Date): Promise<AvailableSlot[]>;
|
|
6388
6400
|
/**
|
|
6389
6401
|
* Creates a new appointment.
|
|
6390
6402
|
*
|
package/dist/index.js
CHANGED
|
@@ -11838,6 +11838,85 @@ var AppointmentService = class extends BaseService {
|
|
|
11838
11838
|
throw error;
|
|
11839
11839
|
}
|
|
11840
11840
|
}
|
|
11841
|
+
/**
|
|
11842
|
+
* Gets available booking slots for a specific clinic, practitioner, and procedure using HTTP request.
|
|
11843
|
+
* This is an alternative implementation using direct HTTP request instead of callable function.
|
|
11844
|
+
*
|
|
11845
|
+
* @param clinicId ID of the clinic
|
|
11846
|
+
* @param practitionerId ID of the practitioner
|
|
11847
|
+
* @param procedureId ID of the procedure
|
|
11848
|
+
* @param startDate Start date of the time range to check
|
|
11849
|
+
* @param endDate End date of the time range to check
|
|
11850
|
+
* @returns Array of available booking slots
|
|
11851
|
+
*/
|
|
11852
|
+
async getAvailableBookingSlotsHttp(clinicId, practitionerId, procedureId, startDate, endDate) {
|
|
11853
|
+
try {
|
|
11854
|
+
console.log(
|
|
11855
|
+
`[APPOINTMENT_SERVICE] Getting available booking slots via HTTP for clinic: ${clinicId}, practitioner: ${practitionerId}, procedure: ${procedureId}`
|
|
11856
|
+
);
|
|
11857
|
+
if (!clinicId || !practitionerId || !procedureId || !startDate || !endDate) {
|
|
11858
|
+
throw new Error(
|
|
11859
|
+
"Missing required parameters for booking slots calculation"
|
|
11860
|
+
);
|
|
11861
|
+
}
|
|
11862
|
+
if (endDate <= startDate) {
|
|
11863
|
+
throw new Error("End date must be after start date");
|
|
11864
|
+
}
|
|
11865
|
+
const currentUser = this.auth.currentUser;
|
|
11866
|
+
if (!currentUser) {
|
|
11867
|
+
throw new Error(
|
|
11868
|
+
"User must be authenticated to get available booking slots"
|
|
11869
|
+
);
|
|
11870
|
+
}
|
|
11871
|
+
const idToken = await currentUser.getIdToken();
|
|
11872
|
+
const functionUrl = `https://europe-west6-metaestetics.cloudfunctions.net/getAvailableBookingSlotsHttp`;
|
|
11873
|
+
const requestData = {
|
|
11874
|
+
clinicId,
|
|
11875
|
+
practitionerId,
|
|
11876
|
+
procedureId,
|
|
11877
|
+
timeframe: {
|
|
11878
|
+
start: startDate.getTime(),
|
|
11879
|
+
// Convert to timestamp
|
|
11880
|
+
end: endDate.getTime()
|
|
11881
|
+
}
|
|
11882
|
+
};
|
|
11883
|
+
const response = await fetch(functionUrl, {
|
|
11884
|
+
method: "POST",
|
|
11885
|
+
headers: {
|
|
11886
|
+
"Content-Type": "application/json",
|
|
11887
|
+
Authorization: `Bearer ${idToken}`
|
|
11888
|
+
},
|
|
11889
|
+
body: JSON.stringify(requestData)
|
|
11890
|
+
});
|
|
11891
|
+
if (!response.ok) {
|
|
11892
|
+
const errorText = await response.text();
|
|
11893
|
+
throw new Error(
|
|
11894
|
+
`Failed to get available booking slots: ${response.status} ${errorText}`
|
|
11895
|
+
);
|
|
11896
|
+
}
|
|
11897
|
+
const result = await response.json();
|
|
11898
|
+
if (!result.success) {
|
|
11899
|
+
throw new Error(
|
|
11900
|
+
result.error || "Failed to get available booking slots"
|
|
11901
|
+
);
|
|
11902
|
+
}
|
|
11903
|
+
const slots = result.availableSlots.map(
|
|
11904
|
+
(slot) => ({
|
|
11905
|
+
start: new Date(slot.start)
|
|
11906
|
+
})
|
|
11907
|
+
);
|
|
11908
|
+
console.log(
|
|
11909
|
+
`[APPOINTMENT_SERVICE] Found ${slots.length} available booking slots via HTTP`
|
|
11910
|
+
);
|
|
11911
|
+
return slots;
|
|
11912
|
+
} catch (error) {
|
|
11913
|
+
console.error(
|
|
11914
|
+
"[APPOINTMENT_SERVICE] Error getting available booking slots via HTTP:",
|
|
11915
|
+
error
|
|
11916
|
+
);
|
|
11917
|
+
throw error;
|
|
11918
|
+
}
|
|
11919
|
+
}
|
|
11841
11920
|
/**
|
|
11842
11921
|
* Creates a new appointment.
|
|
11843
11922
|
*
|
package/dist/index.mjs
CHANGED
|
@@ -11927,6 +11927,85 @@ var AppointmentService = class extends BaseService {
|
|
|
11927
11927
|
throw error;
|
|
11928
11928
|
}
|
|
11929
11929
|
}
|
|
11930
|
+
/**
|
|
11931
|
+
* Gets available booking slots for a specific clinic, practitioner, and procedure using HTTP request.
|
|
11932
|
+
* This is an alternative implementation using direct HTTP request instead of callable function.
|
|
11933
|
+
*
|
|
11934
|
+
* @param clinicId ID of the clinic
|
|
11935
|
+
* @param practitionerId ID of the practitioner
|
|
11936
|
+
* @param procedureId ID of the procedure
|
|
11937
|
+
* @param startDate Start date of the time range to check
|
|
11938
|
+
* @param endDate End date of the time range to check
|
|
11939
|
+
* @returns Array of available booking slots
|
|
11940
|
+
*/
|
|
11941
|
+
async getAvailableBookingSlotsHttp(clinicId, practitionerId, procedureId, startDate, endDate) {
|
|
11942
|
+
try {
|
|
11943
|
+
console.log(
|
|
11944
|
+
`[APPOINTMENT_SERVICE] Getting available booking slots via HTTP for clinic: ${clinicId}, practitioner: ${practitionerId}, procedure: ${procedureId}`
|
|
11945
|
+
);
|
|
11946
|
+
if (!clinicId || !practitionerId || !procedureId || !startDate || !endDate) {
|
|
11947
|
+
throw new Error(
|
|
11948
|
+
"Missing required parameters for booking slots calculation"
|
|
11949
|
+
);
|
|
11950
|
+
}
|
|
11951
|
+
if (endDate <= startDate) {
|
|
11952
|
+
throw new Error("End date must be after start date");
|
|
11953
|
+
}
|
|
11954
|
+
const currentUser = this.auth.currentUser;
|
|
11955
|
+
if (!currentUser) {
|
|
11956
|
+
throw new Error(
|
|
11957
|
+
"User must be authenticated to get available booking slots"
|
|
11958
|
+
);
|
|
11959
|
+
}
|
|
11960
|
+
const idToken = await currentUser.getIdToken();
|
|
11961
|
+
const functionUrl = `https://europe-west6-metaestetics.cloudfunctions.net/getAvailableBookingSlotsHttp`;
|
|
11962
|
+
const requestData = {
|
|
11963
|
+
clinicId,
|
|
11964
|
+
practitionerId,
|
|
11965
|
+
procedureId,
|
|
11966
|
+
timeframe: {
|
|
11967
|
+
start: startDate.getTime(),
|
|
11968
|
+
// Convert to timestamp
|
|
11969
|
+
end: endDate.getTime()
|
|
11970
|
+
}
|
|
11971
|
+
};
|
|
11972
|
+
const response = await fetch(functionUrl, {
|
|
11973
|
+
method: "POST",
|
|
11974
|
+
headers: {
|
|
11975
|
+
"Content-Type": "application/json",
|
|
11976
|
+
Authorization: `Bearer ${idToken}`
|
|
11977
|
+
},
|
|
11978
|
+
body: JSON.stringify(requestData)
|
|
11979
|
+
});
|
|
11980
|
+
if (!response.ok) {
|
|
11981
|
+
const errorText = await response.text();
|
|
11982
|
+
throw new Error(
|
|
11983
|
+
`Failed to get available booking slots: ${response.status} ${errorText}`
|
|
11984
|
+
);
|
|
11985
|
+
}
|
|
11986
|
+
const result = await response.json();
|
|
11987
|
+
if (!result.success) {
|
|
11988
|
+
throw new Error(
|
|
11989
|
+
result.error || "Failed to get available booking slots"
|
|
11990
|
+
);
|
|
11991
|
+
}
|
|
11992
|
+
const slots = result.availableSlots.map(
|
|
11993
|
+
(slot) => ({
|
|
11994
|
+
start: new Date(slot.start)
|
|
11995
|
+
})
|
|
11996
|
+
);
|
|
11997
|
+
console.log(
|
|
11998
|
+
`[APPOINTMENT_SERVICE] Found ${slots.length} available booking slots via HTTP`
|
|
11999
|
+
);
|
|
12000
|
+
return slots;
|
|
12001
|
+
} catch (error) {
|
|
12002
|
+
console.error(
|
|
12003
|
+
"[APPOINTMENT_SERVICE] Error getting available booking slots via HTTP:",
|
|
12004
|
+
error
|
|
12005
|
+
);
|
|
12006
|
+
throw error;
|
|
12007
|
+
}
|
|
12008
|
+
}
|
|
11930
12009
|
/**
|
|
11931
12010
|
* Creates a new appointment.
|
|
11932
12011
|
*
|
package/package.json
CHANGED
|
@@ -185,6 +185,119 @@ export class AppointmentService extends BaseService {
|
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
+
/**
|
|
189
|
+
* Gets available booking slots for a specific clinic, practitioner, and procedure using HTTP request.
|
|
190
|
+
* This is an alternative implementation using direct HTTP request instead of callable function.
|
|
191
|
+
*
|
|
192
|
+
* @param clinicId ID of the clinic
|
|
193
|
+
* @param practitionerId ID of the practitioner
|
|
194
|
+
* @param procedureId ID of the procedure
|
|
195
|
+
* @param startDate Start date of the time range to check
|
|
196
|
+
* @param endDate End date of the time range to check
|
|
197
|
+
* @returns Array of available booking slots
|
|
198
|
+
*/
|
|
199
|
+
async getAvailableBookingSlotsHttp(
|
|
200
|
+
clinicId: string,
|
|
201
|
+
practitionerId: string,
|
|
202
|
+
procedureId: string,
|
|
203
|
+
startDate: Date,
|
|
204
|
+
endDate: Date
|
|
205
|
+
): Promise<AvailableSlot[]> {
|
|
206
|
+
try {
|
|
207
|
+
console.log(
|
|
208
|
+
`[APPOINTMENT_SERVICE] Getting available booking slots via HTTP for clinic: ${clinicId}, practitioner: ${practitionerId}, procedure: ${procedureId}`
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
// Validate input parameters
|
|
212
|
+
if (
|
|
213
|
+
!clinicId ||
|
|
214
|
+
!practitionerId ||
|
|
215
|
+
!procedureId ||
|
|
216
|
+
!startDate ||
|
|
217
|
+
!endDate
|
|
218
|
+
) {
|
|
219
|
+
throw new Error(
|
|
220
|
+
"Missing required parameters for booking slots calculation"
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
if (endDate <= startDate) {
|
|
225
|
+
throw new Error("End date must be after start date");
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// Check if user is authenticated
|
|
229
|
+
const currentUser = this.auth.currentUser;
|
|
230
|
+
if (!currentUser) {
|
|
231
|
+
throw new Error(
|
|
232
|
+
"User must be authenticated to get available booking slots"
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Get the authenticated user's ID token
|
|
237
|
+
const idToken = await currentUser.getIdToken();
|
|
238
|
+
|
|
239
|
+
// Construct the function URL - using the europe-west6 region
|
|
240
|
+
const functionUrl = `https://europe-west6-metaestetics.cloudfunctions.net/getAvailableBookingSlotsHttp`;
|
|
241
|
+
|
|
242
|
+
// Request data
|
|
243
|
+
const requestData = {
|
|
244
|
+
clinicId,
|
|
245
|
+
practitionerId,
|
|
246
|
+
procedureId,
|
|
247
|
+
timeframe: {
|
|
248
|
+
start: startDate.getTime(), // Convert to timestamp
|
|
249
|
+
end: endDate.getTime(),
|
|
250
|
+
},
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
// Make the HTTP request
|
|
254
|
+
const response = await fetch(functionUrl, {
|
|
255
|
+
method: "POST",
|
|
256
|
+
headers: {
|
|
257
|
+
"Content-Type": "application/json",
|
|
258
|
+
Authorization: `Bearer ${idToken}`,
|
|
259
|
+
},
|
|
260
|
+
body: JSON.stringify(requestData),
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
// Check if the request was successful
|
|
264
|
+
if (!response.ok) {
|
|
265
|
+
const errorText = await response.text();
|
|
266
|
+
throw new Error(
|
|
267
|
+
`Failed to get available booking slots: ${response.status} ${errorText}`
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// Parse the response
|
|
272
|
+
const result = await response.json();
|
|
273
|
+
|
|
274
|
+
if (!result.success) {
|
|
275
|
+
throw new Error(
|
|
276
|
+
result.error || "Failed to get available booking slots"
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// Convert timestamp numbers to Date objects
|
|
281
|
+
const slots: AvailableSlot[] = result.availableSlots.map(
|
|
282
|
+
(slot: { start: number }) => ({
|
|
283
|
+
start: new Date(slot.start),
|
|
284
|
+
})
|
|
285
|
+
);
|
|
286
|
+
|
|
287
|
+
console.log(
|
|
288
|
+
`[APPOINTMENT_SERVICE] Found ${slots.length} available booking slots via HTTP`
|
|
289
|
+
);
|
|
290
|
+
|
|
291
|
+
return slots;
|
|
292
|
+
} catch (error) {
|
|
293
|
+
console.error(
|
|
294
|
+
"[APPOINTMENT_SERVICE] Error getting available booking slots via HTTP:",
|
|
295
|
+
error
|
|
296
|
+
);
|
|
297
|
+
throw error;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
188
301
|
/**
|
|
189
302
|
* Creates a new appointment.
|
|
190
303
|
*
|