@bookinglab/booking-journey-api 2.17.0 → 2.19.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 +54 -7
- package/dist/index.d.ts +54 -7
- package/dist/index.js +120 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +119 -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,79 @@ 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
|
+
}
|
|
648
|
+
/**
|
|
649
|
+
* Check Ordinance Survey (OS Places) service status via POST (BookingLab).
|
|
650
|
+
* Sends the host to the absolute serviceStatus endpoint on api.bookinglab.co.uk.
|
|
651
|
+
* @param token - Value for the X-BL-TOKEN header
|
|
652
|
+
* @param request - Body containing the host to check
|
|
653
|
+
*/
|
|
654
|
+
async getOrdinanceSurveyStatus(token, request) {
|
|
655
|
+
const url = "https://api.bookinglab.co.uk/serviceStatus/osplaces";
|
|
656
|
+
const controller = new AbortController();
|
|
657
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
658
|
+
try {
|
|
659
|
+
const response = await fetch(url, {
|
|
660
|
+
method: "POST",
|
|
661
|
+
headers: {
|
|
662
|
+
"Content-Type": "application/json",
|
|
663
|
+
"X-BL-TOKEN": token
|
|
664
|
+
},
|
|
665
|
+
body: JSON.stringify(request),
|
|
666
|
+
signal: controller.signal
|
|
667
|
+
});
|
|
668
|
+
clearTimeout(timeoutId);
|
|
669
|
+
if (!response.ok) {
|
|
670
|
+
throw {
|
|
671
|
+
message: `HTTP ${response.status}: ${response.statusText}`,
|
|
672
|
+
status: response.status
|
|
673
|
+
};
|
|
674
|
+
}
|
|
675
|
+
const data = await response.json();
|
|
676
|
+
return { data, status: response.status, headers: response.headers };
|
|
677
|
+
} catch (error) {
|
|
678
|
+
clearTimeout(timeoutId);
|
|
679
|
+
if (error.name === "AbortError") {
|
|
680
|
+
throw { message: "Request timeout", code: "TIMEOUT" };
|
|
681
|
+
}
|
|
682
|
+
throw error;
|
|
683
|
+
}
|
|
684
|
+
}
|
|
608
685
|
};
|
|
609
686
|
function createBookingLabClient(baseUrl, authToken, appId) {
|
|
610
687
|
const client = new BookingLabClient({ baseUrl });
|
|
@@ -1355,12 +1432,12 @@ function useBookingLabGetToken(request, clientToken, enabled = true) {
|
|
|
1355
1432
|
enabled: enabled && !!request.client && !!request.company && !!clientToken
|
|
1356
1433
|
});
|
|
1357
1434
|
}
|
|
1358
|
-
function useBookingLabServices(companyId, clientToken, enabled = true) {
|
|
1435
|
+
function useBookingLabServices(companyId, clientToken, enabled = true, bypassCacheToken) {
|
|
1359
1436
|
const client = useBookingLabClient();
|
|
1360
1437
|
return useQuery({
|
|
1361
|
-
queryKey: ["bookingLabServices", companyId],
|
|
1438
|
+
queryKey: ["bookingLabServices", companyId, bypassCacheToken],
|
|
1362
1439
|
queryFn: async () => {
|
|
1363
|
-
const response = await client.getCompanyServices(companyId, clientToken);
|
|
1440
|
+
const response = await client.getCompanyServices(companyId, clientToken, bypassCacheToken);
|
|
1364
1441
|
return response.data;
|
|
1365
1442
|
},
|
|
1366
1443
|
enabled: enabled && !!companyId && !!clientToken
|
|
@@ -1468,12 +1545,12 @@ function useOrdnanceAddressLookup(postcode, clientToken, enabled = true) {
|
|
|
1468
1545
|
enabled: enabled && !!postcode && !!clientToken
|
|
1469
1546
|
});
|
|
1470
1547
|
}
|
|
1471
|
-
function useListBookinglabBookings(companyId, clientToken, params, enabled = true) {
|
|
1548
|
+
function useListBookinglabBookings(companyId, clientToken, params, enabled = true, bypassCacheToken) {
|
|
1472
1549
|
const client = useBookingLabClient();
|
|
1473
1550
|
return useQuery({
|
|
1474
|
-
queryKey: ["bookingLabListBookings", companyId, params?.client_id, params?.member_id, params?.start_date, params?.end_date],
|
|
1551
|
+
queryKey: ["bookingLabListBookings", companyId, params?.client_id, params?.member_id, params?.start_date, params?.end_date, bypassCacheToken],
|
|
1475
1552
|
queryFn: async () => {
|
|
1476
|
-
const response = await client.listBookinglabBookings(companyId, clientToken, params);
|
|
1553
|
+
const response = await client.listBookinglabBookings(companyId, clientToken, params, bypassCacheToken);
|
|
1477
1554
|
return response.data;
|
|
1478
1555
|
},
|
|
1479
1556
|
enabled: enabled && !!companyId && !!clientToken
|
|
@@ -1499,7 +1576,30 @@ function useUpdateBookinglabBooking(companyId, bookingId, clientToken) {
|
|
|
1499
1576
|
}
|
|
1500
1577
|
});
|
|
1501
1578
|
}
|
|
1579
|
+
function useOsPlacesStatus(token, isStaging = false, enabled = true) {
|
|
1580
|
+
const client = useBookingLabClient();
|
|
1581
|
+
return useQuery({
|
|
1582
|
+
queryKey: ["osPlacesStatus", isStaging],
|
|
1583
|
+
queryFn: async () => {
|
|
1584
|
+
const response = await client.getOsPlacesStatus(token, isStaging);
|
|
1585
|
+
return response.data;
|
|
1586
|
+
},
|
|
1587
|
+
enabled: enabled && !!token
|
|
1588
|
+
});
|
|
1589
|
+
}
|
|
1590
|
+
function useOrdinanceSurveyStatus(token, host, enabled = true) {
|
|
1591
|
+
const client = useBookingLabClient();
|
|
1592
|
+
return useQuery({
|
|
1593
|
+
queryKey: ["ordinanceSurveyStatus", host],
|
|
1594
|
+
queryFn: async () => {
|
|
1595
|
+
const request = { host };
|
|
1596
|
+
const response = await client.getOrdinanceSurveyStatus(token, request);
|
|
1597
|
+
return response.data;
|
|
1598
|
+
},
|
|
1599
|
+
enabled: enabled && !!token && !!host
|
|
1600
|
+
});
|
|
1601
|
+
}
|
|
1502
1602
|
|
|
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 };
|
|
1603
|
+
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, useOrdinanceSurveyStatus, useOrdnanceAddressLookup, useOsPlacesStatus, useQuestions, useRescheduleBooking, useResetPassword, useResources, useSendCustomEmail, useServices, useTimes, useUpdateBookinglabBooking, useUpdateClient, useUpdateMember };
|
|
1504
1604
|
//# sourceMappingURL=index.mjs.map
|
|
1505
1605
|
//# sourceMappingURL=index.mjs.map
|