@bookinglab/booking-journey-api 2.17.0 → 2.18.0
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.cts +31 -7
- package/dist/index.d.ts +31 -7
- package/dist/index.js +70 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +70 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -367,15 +367,16 @@ var BookingLabClient = class extends ApiClient {
|
|
|
367
367
|
* Get services for a company
|
|
368
368
|
* @param companyId - The company ID
|
|
369
369
|
* @param clientToken - Client token for authentication
|
|
370
|
+
* @param bypassCacheToken - Optional. When provided, sent as `X-Bypass-Cache` header
|
|
370
371
|
*/
|
|
371
|
-
async getCompanyServices(companyId, clientToken) {
|
|
372
|
+
async getCompanyServices(companyId, clientToken, bypassCacheToken) {
|
|
373
|
+
const headers = {
|
|
374
|
+
"clienttoken": clientToken
|
|
375
|
+
};
|
|
376
|
+
if (bypassCacheToken) headers["X-Bypass-Cache"] = bypassCacheToken;
|
|
372
377
|
return this.get(
|
|
373
378
|
`/company/${companyId}/services`,
|
|
374
|
-
{
|
|
375
|
-
headers: {
|
|
376
|
-
"clienttoken": clientToken
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
+
{ headers }
|
|
379
380
|
);
|
|
380
381
|
}
|
|
381
382
|
/**
|
|
@@ -567,22 +568,25 @@ var BookingLabClient = class extends ApiClient {
|
|
|
567
568
|
* List bookings for a company
|
|
568
569
|
* @param companyId - The company ID
|
|
569
570
|
* @param clientToken - Client token for authentication
|
|
570
|
-
* @param params - Optional query params (client_id, member_id)
|
|
571
|
+
* @param params - Optional query params (client_id, member_id, start_date, end_date)
|
|
572
|
+
* @param bypassCacheToken - Optional. When provided, sent as `X-Bypass-Cache` header
|
|
571
573
|
*/
|
|
572
|
-
async listBookinglabBookings(companyId, clientToken, params) {
|
|
574
|
+
async listBookinglabBookings(companyId, clientToken, params, bypassCacheToken) {
|
|
573
575
|
const queryParams = {};
|
|
574
576
|
if (params?.client_id !== void 0) queryParams.client_id = params.client_id;
|
|
575
577
|
if (params?.member_id !== void 0) queryParams.member_id = params.member_id;
|
|
576
578
|
if (params?.start_date !== void 0) queryParams.start_date = params.start_date;
|
|
577
579
|
if (params?.end_date !== void 0) queryParams.end_date = params.end_date;
|
|
580
|
+
const headers = {
|
|
581
|
+
"clienttoken": clientToken,
|
|
582
|
+
"x-company-id": String(companyId)
|
|
583
|
+
};
|
|
584
|
+
if (bypassCacheToken) headers["X-Bypass-Cache"] = bypassCacheToken;
|
|
578
585
|
return this.get(
|
|
579
586
|
`/company/${companyId}/bookings`,
|
|
580
587
|
{
|
|
581
588
|
params: Object.keys(queryParams).length ? queryParams : void 0,
|
|
582
|
-
headers
|
|
583
|
-
"clienttoken": clientToken,
|
|
584
|
-
"x-company-id": String(companyId)
|
|
585
|
-
}
|
|
589
|
+
headers
|
|
586
590
|
}
|
|
587
591
|
);
|
|
588
592
|
}
|
|
@@ -605,6 +609,42 @@ var BookingLabClient = class extends ApiClient {
|
|
|
605
609
|
}
|
|
606
610
|
);
|
|
607
611
|
}
|
|
612
|
+
/**
|
|
613
|
+
* Get OS Places service status (BookingLab).
|
|
614
|
+
* Calls the absolute serviceStatus endpoint on staging.bookinglab.co.uk.
|
|
615
|
+
* @param token - Value for the X-BL-TOKEN header
|
|
616
|
+
* @param isStaging - When true, hits the `osplaces-staging` variant
|
|
617
|
+
*/
|
|
618
|
+
async getOsPlacesStatus(token, isStaging = false) {
|
|
619
|
+
const url = `https://staging.bookinglab.co.uk/serviceStatus/osplaces${isStaging ? "-staging" : ""}`;
|
|
620
|
+
const controller = new AbortController();
|
|
621
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
622
|
+
try {
|
|
623
|
+
const response = await fetch(url, {
|
|
624
|
+
method: "GET",
|
|
625
|
+
headers: {
|
|
626
|
+
"Content-Type": "application/json",
|
|
627
|
+
"X-BL-TOKEN": token
|
|
628
|
+
},
|
|
629
|
+
signal: controller.signal
|
|
630
|
+
});
|
|
631
|
+
clearTimeout(timeoutId);
|
|
632
|
+
if (!response.ok) {
|
|
633
|
+
throw {
|
|
634
|
+
message: `HTTP ${response.status}: ${response.statusText}`,
|
|
635
|
+
status: response.status
|
|
636
|
+
};
|
|
637
|
+
}
|
|
638
|
+
const data = await response.json();
|
|
639
|
+
return { data, status: response.status, headers: response.headers };
|
|
640
|
+
} catch (error) {
|
|
641
|
+
clearTimeout(timeoutId);
|
|
642
|
+
if (error.name === "AbortError") {
|
|
643
|
+
throw { message: "Request timeout", code: "TIMEOUT" };
|
|
644
|
+
}
|
|
645
|
+
throw error;
|
|
646
|
+
}
|
|
647
|
+
}
|
|
608
648
|
};
|
|
609
649
|
function createBookingLabClient(baseUrl, authToken, appId) {
|
|
610
650
|
const client = new BookingLabClient({ baseUrl });
|
|
@@ -1355,12 +1395,12 @@ function useBookingLabGetToken(request, clientToken, enabled = true) {
|
|
|
1355
1395
|
enabled: enabled && !!request.client && !!request.company && !!clientToken
|
|
1356
1396
|
});
|
|
1357
1397
|
}
|
|
1358
|
-
function useBookingLabServices(companyId, clientToken, enabled = true) {
|
|
1398
|
+
function useBookingLabServices(companyId, clientToken, enabled = true, bypassCacheToken) {
|
|
1359
1399
|
const client = useBookingLabClient();
|
|
1360
1400
|
return useQuery({
|
|
1361
|
-
queryKey: ["bookingLabServices", companyId],
|
|
1401
|
+
queryKey: ["bookingLabServices", companyId, bypassCacheToken],
|
|
1362
1402
|
queryFn: async () => {
|
|
1363
|
-
const response = await client.getCompanyServices(companyId, clientToken);
|
|
1403
|
+
const response = await client.getCompanyServices(companyId, clientToken, bypassCacheToken);
|
|
1364
1404
|
return response.data;
|
|
1365
1405
|
},
|
|
1366
1406
|
enabled: enabled && !!companyId && !!clientToken
|
|
@@ -1468,12 +1508,12 @@ function useOrdnanceAddressLookup(postcode, clientToken, enabled = true) {
|
|
|
1468
1508
|
enabled: enabled && !!postcode && !!clientToken
|
|
1469
1509
|
});
|
|
1470
1510
|
}
|
|
1471
|
-
function useListBookinglabBookings(companyId, clientToken, params, enabled = true) {
|
|
1511
|
+
function useListBookinglabBookings(companyId, clientToken, params, enabled = true, bypassCacheToken) {
|
|
1472
1512
|
const client = useBookingLabClient();
|
|
1473
1513
|
return useQuery({
|
|
1474
|
-
queryKey: ["bookingLabListBookings", companyId, params?.client_id, params?.member_id, params?.start_date, params?.end_date],
|
|
1514
|
+
queryKey: ["bookingLabListBookings", companyId, params?.client_id, params?.member_id, params?.start_date, params?.end_date, bypassCacheToken],
|
|
1475
1515
|
queryFn: async () => {
|
|
1476
|
-
const response = await client.listBookinglabBookings(companyId, clientToken, params);
|
|
1516
|
+
const response = await client.listBookinglabBookings(companyId, clientToken, params, bypassCacheToken);
|
|
1477
1517
|
return response.data;
|
|
1478
1518
|
},
|
|
1479
1519
|
enabled: enabled && !!companyId && !!clientToken
|
|
@@ -1499,7 +1539,18 @@ function useUpdateBookinglabBooking(companyId, bookingId, clientToken) {
|
|
|
1499
1539
|
}
|
|
1500
1540
|
});
|
|
1501
1541
|
}
|
|
1542
|
+
function useOsPlacesStatus(token, isStaging = false, enabled = true) {
|
|
1543
|
+
const client = useBookingLabClient();
|
|
1544
|
+
return useQuery({
|
|
1545
|
+
queryKey: ["osPlacesStatus", isStaging],
|
|
1546
|
+
queryFn: async () => {
|
|
1547
|
+
const response = await client.getOsPlacesStatus(token, isStaging);
|
|
1548
|
+
return response.data;
|
|
1549
|
+
},
|
|
1550
|
+
enabled: enabled && !!token
|
|
1551
|
+
});
|
|
1552
|
+
}
|
|
1502
1553
|
|
|
1503
|
-
export { ApiClient, ApiClientContext, ApiClientProvider, BookingLabClient, BookingLabContext, BookingLabProvider, JrniClient, JrniContext, JrniProvider, MemberType, createBookingLabClient, createJrniClient, useAddServiceItem, useApiClientContext, useBookingLabAddBasketServiceItem, useBookingLabCheckoutBasket, useBookingLabClient, useBookingLabCompanies, useBookingLabConfig, useBookingLabContext, useBookingLabCreateBasket, useBookingLabDays, useBookingLabDeleteBasket, useBookingLabForgotPassword, useBookingLabGetToken, useBookingLabQuestions, useBookingLabService, useBookingLabServices, useBookingLabTimes, useCancelBooking, useCancelMemberBooking, useCheckoutBasket, useChildCompanies, useClearBaskets, useClientDetails, useCompany, useCreateBasket, useCreateClient, useDates, useFindClientByEmail, useForgottenPassword, useGetMember, useGetPurchase, useJrniClient, useJrniContext, useListBookinglabBookings, useListBookings, useLogin, useOrdnanceAddressLookup, useQuestions, useRescheduleBooking, useResetPassword, useResources, useSendCustomEmail, useServices, useTimes, useUpdateBookinglabBooking, useUpdateClient, useUpdateMember };
|
|
1554
|
+
export { ApiClient, ApiClientContext, ApiClientProvider, BookingLabClient, BookingLabContext, BookingLabProvider, JrniClient, JrniContext, JrniProvider, MemberType, createBookingLabClient, createJrniClient, useAddServiceItem, useApiClientContext, useBookingLabAddBasketServiceItem, useBookingLabCheckoutBasket, useBookingLabClient, useBookingLabCompanies, useBookingLabConfig, useBookingLabContext, useBookingLabCreateBasket, useBookingLabDays, useBookingLabDeleteBasket, useBookingLabForgotPassword, useBookingLabGetToken, useBookingLabQuestions, useBookingLabService, useBookingLabServices, useBookingLabTimes, useCancelBooking, useCancelMemberBooking, useCheckoutBasket, useChildCompanies, useClearBaskets, useClientDetails, useCompany, useCreateBasket, useCreateClient, useDates, useFindClientByEmail, useForgottenPassword, useGetMember, useGetPurchase, useJrniClient, useJrniContext, useListBookinglabBookings, useListBookings, useLogin, useOrdnanceAddressLookup, useOsPlacesStatus, useQuestions, useRescheduleBooking, useResetPassword, useResources, useSendCustomEmail, useServices, useTimes, useUpdateBookinglabBooking, useUpdateClient, useUpdateMember };
|
|
1504
1555
|
//# sourceMappingURL=index.mjs.map
|
|
1505
1556
|
//# sourceMappingURL=index.mjs.map
|