@bookinglab/booking-journey-api 2.7.0 → 2.9.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/README.md +6 -1
- package/dist/index.d.cts +89 -4
- package/dist/index.d.ts +89 -4
- package/dist/index.js +97 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +93 -28
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -212,6 +212,7 @@ Creates a new BookingLab client instance.
|
|
|
212
212
|
```typescript
|
|
213
213
|
const client = createBookingLabClient({ baseUrl: 'https://api.bookinglab.com' });
|
|
214
214
|
client.setAuthToken('your-auth-token');
|
|
215
|
+
client.setAppId('your-app-id'); // Sets x-app-id header for resetPassword requests
|
|
215
216
|
```
|
|
216
217
|
|
|
217
218
|
**Methods:**
|
|
@@ -220,13 +221,14 @@ client.setAuthToken('your-auth-token');
|
|
|
220
221
|
- `client.createBooking(data)` - Create a new booking
|
|
221
222
|
- `client.updateBooking(id, data)` - Update a booking
|
|
222
223
|
- `client.cancelBooking(companyId, bookingId, request, clientToken)` - Cancel a booking
|
|
223
|
-
- `client.resetPassword(memberId, companyId, request, authToken, clientToken)` - Reset a member's password
|
|
224
|
+
- `client.resetPassword(memberId, companyId, request, authToken, clientToken)` - Reset a member's password (includes `x-app-id` header when set)
|
|
224
225
|
- `client.sendCustomEmail(companyId, request, clientToken)` - Send a custom email
|
|
225
226
|
- `client.forgotPassword(companyId, request, clientToken)` - Request a password reset email
|
|
226
227
|
- `client.deleteBooking(id)` - Delete a booking
|
|
227
228
|
- `client.getServices()` - Get all services
|
|
228
229
|
- `client.getService(id)` - Get a specific service
|
|
229
230
|
- `client.setAuthToken(token)` - Set auth token for subsequent requests
|
|
231
|
+
- `client.setAppId(appId)` - Set app ID for `x-app-id` header
|
|
230
232
|
|
|
231
233
|
### React Providers
|
|
232
234
|
|
|
@@ -251,6 +253,7 @@ Provides BookingLab client context to React components.
|
|
|
251
253
|
<BookingLabProvider
|
|
252
254
|
baseUrl="https://api.bookinglab.com"
|
|
253
255
|
authToken="your-auth-token"
|
|
256
|
+
appId="your-app-id"
|
|
254
257
|
>
|
|
255
258
|
{children}
|
|
256
259
|
</BookingLabProvider>
|
|
@@ -409,6 +412,8 @@ const client = useJrniClient();
|
|
|
409
412
|
- `useService(id)` - Get a specific service
|
|
410
413
|
- `useSendCustomEmail(companyId, clientToken)` - Send a custom email
|
|
411
414
|
- `useBookingLabForgotPassword(companyId, clientToken)` - Request a password reset email
|
|
415
|
+
- `useBookingLabConfig(request, clientToken, enabled?)` - Fetch company configuration and branding
|
|
416
|
+
- `useBookingLabGetToken(request, clientToken, enabled?)` - Fetch a token for a client/company
|
|
412
417
|
- `useBookingLabClient()` - Access the BookingLab client directly
|
|
413
418
|
|
|
414
419
|
```typescript
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
2
|
+
import React, { ReactNode } from 'react';
|
|
3
3
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
4
4
|
import { QueryClient } from '@tanstack/react-query';
|
|
5
5
|
|
|
@@ -1074,6 +1074,50 @@ interface BookingLabForgotPasswordResponse {
|
|
|
1074
1074
|
result: string;
|
|
1075
1075
|
message: string;
|
|
1076
1076
|
}
|
|
1077
|
+
interface BookingLabConfigRequest {
|
|
1078
|
+
client: string;
|
|
1079
|
+
company: number;
|
|
1080
|
+
}
|
|
1081
|
+
interface BookingLabConfigPage {
|
|
1082
|
+
pageTitle?: string;
|
|
1083
|
+
pageGuidance?: string;
|
|
1084
|
+
termsAndConditions?: string;
|
|
1085
|
+
privacyStatment?: string;
|
|
1086
|
+
[key: string]: unknown;
|
|
1087
|
+
}
|
|
1088
|
+
interface BookingLabConfigUserJourney {
|
|
1089
|
+
pages?: Record<string, BookingLabConfigPage>;
|
|
1090
|
+
[key: string]: unknown;
|
|
1091
|
+
}
|
|
1092
|
+
interface BookingLabConfigProduct {
|
|
1093
|
+
userJourney?: BookingLabConfigUserJourney;
|
|
1094
|
+
[key: string]: unknown;
|
|
1095
|
+
}
|
|
1096
|
+
interface BookingLabConfigResponse {
|
|
1097
|
+
company: number;
|
|
1098
|
+
companyName: string;
|
|
1099
|
+
requireLogin?: boolean;
|
|
1100
|
+
favicon?: string;
|
|
1101
|
+
favicon_link?: string;
|
|
1102
|
+
footer_colour?: string;
|
|
1103
|
+
header_colour?: string;
|
|
1104
|
+
header_text?: string;
|
|
1105
|
+
host?: string;
|
|
1106
|
+
logo?: string;
|
|
1107
|
+
logo_link?: string;
|
|
1108
|
+
page_title?: string;
|
|
1109
|
+
text_colour?: string;
|
|
1110
|
+
terms?: string;
|
|
1111
|
+
cache?: Record<string, unknown>;
|
|
1112
|
+
[key: string]: unknown;
|
|
1113
|
+
}
|
|
1114
|
+
interface BookingLabGetTokenRequest {
|
|
1115
|
+
client: string;
|
|
1116
|
+
company: number;
|
|
1117
|
+
}
|
|
1118
|
+
interface BookingLabGetTokenResponse {
|
|
1119
|
+
[key: string]: unknown;
|
|
1120
|
+
}
|
|
1077
1121
|
|
|
1078
1122
|
/**
|
|
1079
1123
|
* Core API Client
|
|
@@ -1129,6 +1173,11 @@ declare class ApiClient {
|
|
|
1129
1173
|
*/
|
|
1130
1174
|
|
|
1131
1175
|
declare class BookingLabClient extends ApiClient {
|
|
1176
|
+
private appId;
|
|
1177
|
+
/**
|
|
1178
|
+
* Set the App ID for x-app-id header
|
|
1179
|
+
*/
|
|
1180
|
+
setAppId(appId: string): void;
|
|
1132
1181
|
/**
|
|
1133
1182
|
* Get all bookings
|
|
1134
1183
|
*/
|
|
@@ -1211,11 +1260,23 @@ declare class BookingLabClient extends ApiClient {
|
|
|
1211
1260
|
* @param clientToken - Client token for authentication
|
|
1212
1261
|
*/
|
|
1213
1262
|
forgotPassword(companyId: number, request: BookingLabForgotPasswordRequest, clientToken: string): Promise<ApiResponse<BookingLabForgotPasswordResponse>>;
|
|
1263
|
+
/**
|
|
1264
|
+
* Get company configuration
|
|
1265
|
+
* @param request - Config request with client and company
|
|
1266
|
+
* @param clientToken - Client token for authentication
|
|
1267
|
+
*/
|
|
1268
|
+
getConfig(request: BookingLabConfigRequest, clientToken: string): Promise<ApiResponse<BookingLabConfigResponse>>;
|
|
1269
|
+
/**
|
|
1270
|
+
* Get a token for a client/company
|
|
1271
|
+
* @param request - Token request with client and company
|
|
1272
|
+
* @param clientToken - Client token for authentication
|
|
1273
|
+
*/
|
|
1274
|
+
getToken(request: BookingLabGetTokenRequest, clientToken: string): Promise<ApiResponse<BookingLabGetTokenResponse>>;
|
|
1214
1275
|
}
|
|
1215
1276
|
/**
|
|
1216
1277
|
* Create a new BookingLab client instance
|
|
1217
1278
|
*/
|
|
1218
|
-
declare function createBookingLabClient(baseUrl: string, authToken?: string): BookingLabClient;
|
|
1279
|
+
declare function createBookingLabClient(baseUrl: string, authToken?: string, appId?: string): BookingLabClient;
|
|
1219
1280
|
|
|
1220
1281
|
/**
|
|
1221
1282
|
* JRNI API Client
|
|
@@ -1373,6 +1434,7 @@ interface ApiClientProviderProps {
|
|
|
1373
1434
|
authToken?: string;
|
|
1374
1435
|
queryClient?: QueryClient;
|
|
1375
1436
|
}
|
|
1437
|
+
declare const ApiClientContext: React.Context<ApiClientContextValue | undefined>;
|
|
1376
1438
|
/**
|
|
1377
1439
|
* Combined provider for multiple API clients
|
|
1378
1440
|
* Includes QueryClientProvider for React Query hooks
|
|
@@ -1383,25 +1445,34 @@ declare function ApiClientProvider({ children, bookingLabBaseUrl, jrniBaseUrl, j
|
|
|
1383
1445
|
*/
|
|
1384
1446
|
declare function useApiClientContext(): ApiClientContextValue;
|
|
1385
1447
|
|
|
1448
|
+
interface BookingLabContextValue {
|
|
1449
|
+
client: BookingLabClient;
|
|
1450
|
+
}
|
|
1386
1451
|
interface BookingLabProviderProps {
|
|
1387
1452
|
children: ReactNode;
|
|
1388
1453
|
baseUrl: string;
|
|
1389
1454
|
authToken?: string;
|
|
1455
|
+
appId?: string;
|
|
1390
1456
|
}
|
|
1457
|
+
declare const BookingLabContext: React.Context<BookingLabContextValue | undefined>;
|
|
1391
1458
|
/**
|
|
1392
1459
|
* Provider component for BookingLab client
|
|
1393
1460
|
*/
|
|
1394
|
-
declare function BookingLabProvider({ children, baseUrl, authToken, }: BookingLabProviderProps): react_jsx_runtime.JSX.Element;
|
|
1461
|
+
declare function BookingLabProvider({ children, baseUrl, authToken, appId, }: BookingLabProviderProps): react_jsx_runtime.JSX.Element;
|
|
1395
1462
|
/**
|
|
1396
1463
|
* Hook to access BookingLab client from context
|
|
1397
1464
|
*/
|
|
1398
1465
|
declare function useBookingLabContext(): BookingLabClient;
|
|
1399
1466
|
|
|
1467
|
+
interface JrniContextValue {
|
|
1468
|
+
client: JrniClient;
|
|
1469
|
+
}
|
|
1400
1470
|
interface JrniProviderProps {
|
|
1401
1471
|
children: ReactNode;
|
|
1402
1472
|
baseUrl: string;
|
|
1403
1473
|
config: JrniConfig;
|
|
1404
1474
|
}
|
|
1475
|
+
declare const JrniContext: React.Context<JrniContextValue | undefined>;
|
|
1405
1476
|
/**
|
|
1406
1477
|
* Provider component for JRNI client
|
|
1407
1478
|
*/
|
|
@@ -1597,5 +1668,19 @@ declare function useSendCustomEmail(companyId: number, clientToken: string): _ta
|
|
|
1597
1668
|
* @param clientToken - Client token for authentication
|
|
1598
1669
|
*/
|
|
1599
1670
|
declare function useBookingLabForgotPassword(companyId: number, clientToken: string): _tanstack_react_query.UseMutationResult<BookingLabForgotPasswordResponse, Error, BookingLabForgotPasswordRequest, unknown>;
|
|
1671
|
+
/**
|
|
1672
|
+
* Hook for fetching BookingLab company configuration
|
|
1673
|
+
* @param request - Config request with client and company
|
|
1674
|
+
* @param clientToken - Client token for authentication
|
|
1675
|
+
* @param enabled - Whether the query should run
|
|
1676
|
+
*/
|
|
1677
|
+
declare function useBookingLabConfig(request: BookingLabConfigRequest, clientToken: string, enabled?: boolean): _tanstack_react_query.UseQueryResult<BookingLabConfigResponse, Error>;
|
|
1678
|
+
/**
|
|
1679
|
+
* Hook for getting a BookingLab token
|
|
1680
|
+
* @param request - Token request with client and company
|
|
1681
|
+
* @param clientToken - Client token for authentication
|
|
1682
|
+
* @param enabled - Whether the query should run
|
|
1683
|
+
*/
|
|
1684
|
+
declare function useBookingLabGetToken(request: BookingLabGetTokenRequest, clientToken: string, enabled?: boolean): _tanstack_react_query.UseQueryResult<BookingLabGetTokenResponse, Error>;
|
|
1600
1685
|
|
|
1601
|
-
export { type AddBasketItemRequest, type AddServiceItemAssets, type AddServiceItemQuestion, type AddServiceItemRequest, ApiClient, type ApiClientConfig, ApiClientProvider, type ApiError, type ApiResponse, type AvailabilityTime, type AvailabilityTimesResponse, type Booking, type BookingAnswer, BookingLabClient, type BookingLabForgotPasswordRequest, type BookingLabForgotPasswordResponse, BookingLabProvider, type BookingPaymentItem, type BookingSettings, type CancelBookingRequest, type CancelBookingResponse, type CancelMemberBookingResponse, type CheckoutBasketClient, type CheckoutBasketRequest, type CheckoutBasketResponse, type ChildCompaniesResponse, type ChildCompany, type ChildCompanyAddress, type ChildCompanySettings, type ClearBasketsResponse, type ClientDetailsQuestion, type ClientDetailsResponse, type CompanyResponse, type CompanySettings, type CreateBasketRequest, type CreateBasketResponse, type CreateBookingRequest, type CreateClientRequest, type CreateClientResponse, type DateSlot, type DatesResponse, type FindClientByEmailResponse, type ForgottenPasswordRequest, type ForgottenPasswordResponse, type GetChildCompaniesParams, type GetDatesParams, type GetMemberResponse, type GetQuestionsParams, type GetTimesParams, type JrniBooking, JrniClient, type JrniConfig, JrniProvider, type JrniService, type ListBookingsParams, type ListBookingsResponse, type Location, type LocationsResponse, type LoginRequest, type LoginResponse, type MemberBooking, type MemberBookingsResponse, MemberType, type PersonImage, type PersonImagesResponse, type Question, type QuestionOption, type QuestionsResponse, type RequestOptions, type RescheduleBookingRequest, type RescheduleBookingResponse, type ResetPasswordRequest, type Resource, type ResourceLinks, type ResourcesResponse, type SendCustomEmailRequest, type SendCustomEmailResponse, type Service, type ServiceItemResponse, type ServicesResponse, type TimeSlot, type TimesResponse, type UpdateClientAnswer, type UpdateClientAnswerEntry, type UpdateClientDetailsData, type UpdateClientExtraInfo, type UpdateClientNotificationPreferences, type UpdateClientQuestionEntry, type UpdateClientRequest, type UpdateClientResponse, type UpdateMemberDetailsData, type UpdateMemberRequest, type UpdateMemberResponse, type Vehicle, type VehiclesResponse, createBookingLabClient, createJrniClient, useAddServiceItem, useApiClientContext, useBookingLabClient, useBookingLabContext, useBookingLabForgotPassword, useCancelBooking, useCancelMemberBooking, useCheckoutBasket, useChildCompanies, useClearBaskets, useClientDetails, useCompany, useCreateBasket, useCreateClient, useDates, useFindClientByEmail, useForgottenPassword, useGetMember, useJrniClient, useJrniContext, useListBookings, useLogin, useQuestions, useRescheduleBooking, useResetPassword, useResources, useSendCustomEmail, useServices, useTimes, useUpdateClient, useUpdateMember };
|
|
1686
|
+
export { type AddBasketItemRequest, type AddServiceItemAssets, type AddServiceItemQuestion, type AddServiceItemRequest, ApiClient, type ApiClientConfig, ApiClientContext, ApiClientProvider, type ApiError, type ApiResponse, type AvailabilityTime, type AvailabilityTimesResponse, type Booking, type BookingAnswer, BookingLabClient, type BookingLabConfigPage, type BookingLabConfigProduct, type BookingLabConfigRequest, type BookingLabConfigResponse, type BookingLabConfigUserJourney, BookingLabContext, type BookingLabForgotPasswordRequest, type BookingLabForgotPasswordResponse, type BookingLabGetTokenRequest, type BookingLabGetTokenResponse, BookingLabProvider, type BookingPaymentItem, type BookingSettings, type CancelBookingRequest, type CancelBookingResponse, type CancelMemberBookingResponse, type CheckoutBasketClient, type CheckoutBasketRequest, type CheckoutBasketResponse, type ChildCompaniesResponse, type ChildCompany, type ChildCompanyAddress, type ChildCompanySettings, type ClearBasketsResponse, type ClientDetailsQuestion, type ClientDetailsResponse, type CompanyResponse, type CompanySettings, type CreateBasketRequest, type CreateBasketResponse, type CreateBookingRequest, type CreateClientRequest, type CreateClientResponse, type DateSlot, type DatesResponse, type FindClientByEmailResponse, type ForgottenPasswordRequest, type ForgottenPasswordResponse, type GetChildCompaniesParams, type GetDatesParams, type GetMemberResponse, type GetQuestionsParams, type GetTimesParams, type JrniBooking, JrniClient, type JrniConfig, JrniContext, JrniProvider, type JrniService, type ListBookingsParams, type ListBookingsResponse, type Location, type LocationsResponse, type LoginRequest, type LoginResponse, type MemberBooking, type MemberBookingsResponse, MemberType, type PersonImage, type PersonImagesResponse, type Question, type QuestionOption, type QuestionsResponse, type RequestOptions, type RescheduleBookingRequest, type RescheduleBookingResponse, type ResetPasswordRequest, type Resource, type ResourceLinks, type ResourcesResponse, type SendCustomEmailRequest, type SendCustomEmailResponse, type Service, type ServiceItemResponse, type ServicesResponse, type TimeSlot, type TimesResponse, type UpdateClientAnswer, type UpdateClientAnswerEntry, type UpdateClientDetailsData, type UpdateClientExtraInfo, type UpdateClientNotificationPreferences, type UpdateClientQuestionEntry, type UpdateClientRequest, type UpdateClientResponse, type UpdateMemberDetailsData, type UpdateMemberRequest, type UpdateMemberResponse, type Vehicle, type VehiclesResponse, createBookingLabClient, createJrniClient, useAddServiceItem, useApiClientContext, useBookingLabClient, useBookingLabConfig, useBookingLabContext, useBookingLabForgotPassword, useBookingLabGetToken, useCancelBooking, useCancelMemberBooking, useCheckoutBasket, useChildCompanies, useClearBaskets, useClientDetails, useCompany, useCreateBasket, useCreateClient, useDates, useFindClientByEmail, useForgottenPassword, useGetMember, useJrniClient, useJrniContext, useListBookings, useLogin, useQuestions, useRescheduleBooking, useResetPassword, useResources, useSendCustomEmail, useServices, useTimes, useUpdateClient, useUpdateMember };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
2
|
+
import React, { ReactNode } from 'react';
|
|
3
3
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
4
4
|
import { QueryClient } from '@tanstack/react-query';
|
|
5
5
|
|
|
@@ -1074,6 +1074,50 @@ interface BookingLabForgotPasswordResponse {
|
|
|
1074
1074
|
result: string;
|
|
1075
1075
|
message: string;
|
|
1076
1076
|
}
|
|
1077
|
+
interface BookingLabConfigRequest {
|
|
1078
|
+
client: string;
|
|
1079
|
+
company: number;
|
|
1080
|
+
}
|
|
1081
|
+
interface BookingLabConfigPage {
|
|
1082
|
+
pageTitle?: string;
|
|
1083
|
+
pageGuidance?: string;
|
|
1084
|
+
termsAndConditions?: string;
|
|
1085
|
+
privacyStatment?: string;
|
|
1086
|
+
[key: string]: unknown;
|
|
1087
|
+
}
|
|
1088
|
+
interface BookingLabConfigUserJourney {
|
|
1089
|
+
pages?: Record<string, BookingLabConfigPage>;
|
|
1090
|
+
[key: string]: unknown;
|
|
1091
|
+
}
|
|
1092
|
+
interface BookingLabConfigProduct {
|
|
1093
|
+
userJourney?: BookingLabConfigUserJourney;
|
|
1094
|
+
[key: string]: unknown;
|
|
1095
|
+
}
|
|
1096
|
+
interface BookingLabConfigResponse {
|
|
1097
|
+
company: number;
|
|
1098
|
+
companyName: string;
|
|
1099
|
+
requireLogin?: boolean;
|
|
1100
|
+
favicon?: string;
|
|
1101
|
+
favicon_link?: string;
|
|
1102
|
+
footer_colour?: string;
|
|
1103
|
+
header_colour?: string;
|
|
1104
|
+
header_text?: string;
|
|
1105
|
+
host?: string;
|
|
1106
|
+
logo?: string;
|
|
1107
|
+
logo_link?: string;
|
|
1108
|
+
page_title?: string;
|
|
1109
|
+
text_colour?: string;
|
|
1110
|
+
terms?: string;
|
|
1111
|
+
cache?: Record<string, unknown>;
|
|
1112
|
+
[key: string]: unknown;
|
|
1113
|
+
}
|
|
1114
|
+
interface BookingLabGetTokenRequest {
|
|
1115
|
+
client: string;
|
|
1116
|
+
company: number;
|
|
1117
|
+
}
|
|
1118
|
+
interface BookingLabGetTokenResponse {
|
|
1119
|
+
[key: string]: unknown;
|
|
1120
|
+
}
|
|
1077
1121
|
|
|
1078
1122
|
/**
|
|
1079
1123
|
* Core API Client
|
|
@@ -1129,6 +1173,11 @@ declare class ApiClient {
|
|
|
1129
1173
|
*/
|
|
1130
1174
|
|
|
1131
1175
|
declare class BookingLabClient extends ApiClient {
|
|
1176
|
+
private appId;
|
|
1177
|
+
/**
|
|
1178
|
+
* Set the App ID for x-app-id header
|
|
1179
|
+
*/
|
|
1180
|
+
setAppId(appId: string): void;
|
|
1132
1181
|
/**
|
|
1133
1182
|
* Get all bookings
|
|
1134
1183
|
*/
|
|
@@ -1211,11 +1260,23 @@ declare class BookingLabClient extends ApiClient {
|
|
|
1211
1260
|
* @param clientToken - Client token for authentication
|
|
1212
1261
|
*/
|
|
1213
1262
|
forgotPassword(companyId: number, request: BookingLabForgotPasswordRequest, clientToken: string): Promise<ApiResponse<BookingLabForgotPasswordResponse>>;
|
|
1263
|
+
/**
|
|
1264
|
+
* Get company configuration
|
|
1265
|
+
* @param request - Config request with client and company
|
|
1266
|
+
* @param clientToken - Client token for authentication
|
|
1267
|
+
*/
|
|
1268
|
+
getConfig(request: BookingLabConfigRequest, clientToken: string): Promise<ApiResponse<BookingLabConfigResponse>>;
|
|
1269
|
+
/**
|
|
1270
|
+
* Get a token for a client/company
|
|
1271
|
+
* @param request - Token request with client and company
|
|
1272
|
+
* @param clientToken - Client token for authentication
|
|
1273
|
+
*/
|
|
1274
|
+
getToken(request: BookingLabGetTokenRequest, clientToken: string): Promise<ApiResponse<BookingLabGetTokenResponse>>;
|
|
1214
1275
|
}
|
|
1215
1276
|
/**
|
|
1216
1277
|
* Create a new BookingLab client instance
|
|
1217
1278
|
*/
|
|
1218
|
-
declare function createBookingLabClient(baseUrl: string, authToken?: string): BookingLabClient;
|
|
1279
|
+
declare function createBookingLabClient(baseUrl: string, authToken?: string, appId?: string): BookingLabClient;
|
|
1219
1280
|
|
|
1220
1281
|
/**
|
|
1221
1282
|
* JRNI API Client
|
|
@@ -1373,6 +1434,7 @@ interface ApiClientProviderProps {
|
|
|
1373
1434
|
authToken?: string;
|
|
1374
1435
|
queryClient?: QueryClient;
|
|
1375
1436
|
}
|
|
1437
|
+
declare const ApiClientContext: React.Context<ApiClientContextValue | undefined>;
|
|
1376
1438
|
/**
|
|
1377
1439
|
* Combined provider for multiple API clients
|
|
1378
1440
|
* Includes QueryClientProvider for React Query hooks
|
|
@@ -1383,25 +1445,34 @@ declare function ApiClientProvider({ children, bookingLabBaseUrl, jrniBaseUrl, j
|
|
|
1383
1445
|
*/
|
|
1384
1446
|
declare function useApiClientContext(): ApiClientContextValue;
|
|
1385
1447
|
|
|
1448
|
+
interface BookingLabContextValue {
|
|
1449
|
+
client: BookingLabClient;
|
|
1450
|
+
}
|
|
1386
1451
|
interface BookingLabProviderProps {
|
|
1387
1452
|
children: ReactNode;
|
|
1388
1453
|
baseUrl: string;
|
|
1389
1454
|
authToken?: string;
|
|
1455
|
+
appId?: string;
|
|
1390
1456
|
}
|
|
1457
|
+
declare const BookingLabContext: React.Context<BookingLabContextValue | undefined>;
|
|
1391
1458
|
/**
|
|
1392
1459
|
* Provider component for BookingLab client
|
|
1393
1460
|
*/
|
|
1394
|
-
declare function BookingLabProvider({ children, baseUrl, authToken, }: BookingLabProviderProps): react_jsx_runtime.JSX.Element;
|
|
1461
|
+
declare function BookingLabProvider({ children, baseUrl, authToken, appId, }: BookingLabProviderProps): react_jsx_runtime.JSX.Element;
|
|
1395
1462
|
/**
|
|
1396
1463
|
* Hook to access BookingLab client from context
|
|
1397
1464
|
*/
|
|
1398
1465
|
declare function useBookingLabContext(): BookingLabClient;
|
|
1399
1466
|
|
|
1467
|
+
interface JrniContextValue {
|
|
1468
|
+
client: JrniClient;
|
|
1469
|
+
}
|
|
1400
1470
|
interface JrniProviderProps {
|
|
1401
1471
|
children: ReactNode;
|
|
1402
1472
|
baseUrl: string;
|
|
1403
1473
|
config: JrniConfig;
|
|
1404
1474
|
}
|
|
1475
|
+
declare const JrniContext: React.Context<JrniContextValue | undefined>;
|
|
1405
1476
|
/**
|
|
1406
1477
|
* Provider component for JRNI client
|
|
1407
1478
|
*/
|
|
@@ -1597,5 +1668,19 @@ declare function useSendCustomEmail(companyId: number, clientToken: string): _ta
|
|
|
1597
1668
|
* @param clientToken - Client token for authentication
|
|
1598
1669
|
*/
|
|
1599
1670
|
declare function useBookingLabForgotPassword(companyId: number, clientToken: string): _tanstack_react_query.UseMutationResult<BookingLabForgotPasswordResponse, Error, BookingLabForgotPasswordRequest, unknown>;
|
|
1671
|
+
/**
|
|
1672
|
+
* Hook for fetching BookingLab company configuration
|
|
1673
|
+
* @param request - Config request with client and company
|
|
1674
|
+
* @param clientToken - Client token for authentication
|
|
1675
|
+
* @param enabled - Whether the query should run
|
|
1676
|
+
*/
|
|
1677
|
+
declare function useBookingLabConfig(request: BookingLabConfigRequest, clientToken: string, enabled?: boolean): _tanstack_react_query.UseQueryResult<BookingLabConfigResponse, Error>;
|
|
1678
|
+
/**
|
|
1679
|
+
* Hook for getting a BookingLab token
|
|
1680
|
+
* @param request - Token request with client and company
|
|
1681
|
+
* @param clientToken - Client token for authentication
|
|
1682
|
+
* @param enabled - Whether the query should run
|
|
1683
|
+
*/
|
|
1684
|
+
declare function useBookingLabGetToken(request: BookingLabGetTokenRequest, clientToken: string, enabled?: boolean): _tanstack_react_query.UseQueryResult<BookingLabGetTokenResponse, Error>;
|
|
1600
1685
|
|
|
1601
|
-
export { type AddBasketItemRequest, type AddServiceItemAssets, type AddServiceItemQuestion, type AddServiceItemRequest, ApiClient, type ApiClientConfig, ApiClientProvider, type ApiError, type ApiResponse, type AvailabilityTime, type AvailabilityTimesResponse, type Booking, type BookingAnswer, BookingLabClient, type BookingLabForgotPasswordRequest, type BookingLabForgotPasswordResponse, BookingLabProvider, type BookingPaymentItem, type BookingSettings, type CancelBookingRequest, type CancelBookingResponse, type CancelMemberBookingResponse, type CheckoutBasketClient, type CheckoutBasketRequest, type CheckoutBasketResponse, type ChildCompaniesResponse, type ChildCompany, type ChildCompanyAddress, type ChildCompanySettings, type ClearBasketsResponse, type ClientDetailsQuestion, type ClientDetailsResponse, type CompanyResponse, type CompanySettings, type CreateBasketRequest, type CreateBasketResponse, type CreateBookingRequest, type CreateClientRequest, type CreateClientResponse, type DateSlot, type DatesResponse, type FindClientByEmailResponse, type ForgottenPasswordRequest, type ForgottenPasswordResponse, type GetChildCompaniesParams, type GetDatesParams, type GetMemberResponse, type GetQuestionsParams, type GetTimesParams, type JrniBooking, JrniClient, type JrniConfig, JrniProvider, type JrniService, type ListBookingsParams, type ListBookingsResponse, type Location, type LocationsResponse, type LoginRequest, type LoginResponse, type MemberBooking, type MemberBookingsResponse, MemberType, type PersonImage, type PersonImagesResponse, type Question, type QuestionOption, type QuestionsResponse, type RequestOptions, type RescheduleBookingRequest, type RescheduleBookingResponse, type ResetPasswordRequest, type Resource, type ResourceLinks, type ResourcesResponse, type SendCustomEmailRequest, type SendCustomEmailResponse, type Service, type ServiceItemResponse, type ServicesResponse, type TimeSlot, type TimesResponse, type UpdateClientAnswer, type UpdateClientAnswerEntry, type UpdateClientDetailsData, type UpdateClientExtraInfo, type UpdateClientNotificationPreferences, type UpdateClientQuestionEntry, type UpdateClientRequest, type UpdateClientResponse, type UpdateMemberDetailsData, type UpdateMemberRequest, type UpdateMemberResponse, type Vehicle, type VehiclesResponse, createBookingLabClient, createJrniClient, useAddServiceItem, useApiClientContext, useBookingLabClient, useBookingLabContext, useBookingLabForgotPassword, useCancelBooking, useCancelMemberBooking, useCheckoutBasket, useChildCompanies, useClearBaskets, useClientDetails, useCompany, useCreateBasket, useCreateClient, useDates, useFindClientByEmail, useForgottenPassword, useGetMember, useJrniClient, useJrniContext, useListBookings, useLogin, useQuestions, useRescheduleBooking, useResetPassword, useResources, useSendCustomEmail, useServices, useTimes, useUpdateClient, useUpdateMember };
|
|
1686
|
+
export { type AddBasketItemRequest, type AddServiceItemAssets, type AddServiceItemQuestion, type AddServiceItemRequest, ApiClient, type ApiClientConfig, ApiClientContext, ApiClientProvider, type ApiError, type ApiResponse, type AvailabilityTime, type AvailabilityTimesResponse, type Booking, type BookingAnswer, BookingLabClient, type BookingLabConfigPage, type BookingLabConfigProduct, type BookingLabConfigRequest, type BookingLabConfigResponse, type BookingLabConfigUserJourney, BookingLabContext, type BookingLabForgotPasswordRequest, type BookingLabForgotPasswordResponse, type BookingLabGetTokenRequest, type BookingLabGetTokenResponse, BookingLabProvider, type BookingPaymentItem, type BookingSettings, type CancelBookingRequest, type CancelBookingResponse, type CancelMemberBookingResponse, type CheckoutBasketClient, type CheckoutBasketRequest, type CheckoutBasketResponse, type ChildCompaniesResponse, type ChildCompany, type ChildCompanyAddress, type ChildCompanySettings, type ClearBasketsResponse, type ClientDetailsQuestion, type ClientDetailsResponse, type CompanyResponse, type CompanySettings, type CreateBasketRequest, type CreateBasketResponse, type CreateBookingRequest, type CreateClientRequest, type CreateClientResponse, type DateSlot, type DatesResponse, type FindClientByEmailResponse, type ForgottenPasswordRequest, type ForgottenPasswordResponse, type GetChildCompaniesParams, type GetDatesParams, type GetMemberResponse, type GetQuestionsParams, type GetTimesParams, type JrniBooking, JrniClient, type JrniConfig, JrniContext, JrniProvider, type JrniService, type ListBookingsParams, type ListBookingsResponse, type Location, type LocationsResponse, type LoginRequest, type LoginResponse, type MemberBooking, type MemberBookingsResponse, MemberType, type PersonImage, type PersonImagesResponse, type Question, type QuestionOption, type QuestionsResponse, type RequestOptions, type RescheduleBookingRequest, type RescheduleBookingResponse, type ResetPasswordRequest, type Resource, type ResourceLinks, type ResourcesResponse, type SendCustomEmailRequest, type SendCustomEmailResponse, type Service, type ServiceItemResponse, type ServicesResponse, type TimeSlot, type TimesResponse, type UpdateClientAnswer, type UpdateClientAnswerEntry, type UpdateClientDetailsData, type UpdateClientExtraInfo, type UpdateClientNotificationPreferences, type UpdateClientQuestionEntry, type UpdateClientRequest, type UpdateClientResponse, type UpdateMemberDetailsData, type UpdateMemberRequest, type UpdateMemberResponse, type Vehicle, type VehiclesResponse, createBookingLabClient, createJrniClient, useAddServiceItem, useApiClientContext, useBookingLabClient, useBookingLabConfig, useBookingLabContext, useBookingLabForgotPassword, useBookingLabGetToken, useCancelBooking, useCancelMemberBooking, useCheckoutBasket, useChildCompanies, useClearBaskets, useClientDetails, useCompany, useCreateBasket, useCreateClient, useDates, useFindClientByEmail, useForgottenPassword, useGetMember, useJrniClient, useJrniContext, useListBookings, useLogin, useQuestions, useRescheduleBooking, useResetPassword, useResources, useSendCustomEmail, useServices, useTimes, useUpdateClient, useUpdateMember };
|
package/dist/index.js
CHANGED
|
@@ -160,6 +160,16 @@ var MemberType = /* @__PURE__ */ ((MemberType2) => {
|
|
|
160
160
|
|
|
161
161
|
// src/booking-lab.ts
|
|
162
162
|
var BookingLabClient = class extends ApiClient {
|
|
163
|
+
constructor() {
|
|
164
|
+
super(...arguments);
|
|
165
|
+
this.appId = "";
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Set the App ID for x-app-id header
|
|
169
|
+
*/
|
|
170
|
+
setAppId(appId) {
|
|
171
|
+
this.appId = appId;
|
|
172
|
+
}
|
|
163
173
|
/**
|
|
164
174
|
* Get all bookings
|
|
165
175
|
*/
|
|
@@ -273,7 +283,8 @@ var BookingLabClient = class extends ApiClient {
|
|
|
273
283
|
"X-member-id": String(memberId),
|
|
274
284
|
"x-company-id": String(companyId),
|
|
275
285
|
"authtoken": authToken,
|
|
276
|
-
"clienttoken": clientToken
|
|
286
|
+
"clienttoken": clientToken,
|
|
287
|
+
...this.appId && { "x-app-id": this.appId }
|
|
277
288
|
}
|
|
278
289
|
}
|
|
279
290
|
);
|
|
@@ -330,12 +341,39 @@ var BookingLabClient = class extends ApiClient {
|
|
|
330
341
|
}
|
|
331
342
|
);
|
|
332
343
|
}
|
|
344
|
+
/**
|
|
345
|
+
* Get company configuration
|
|
346
|
+
* @param request - Config request with client and company
|
|
347
|
+
* @param clientToken - Client token for authentication
|
|
348
|
+
*/
|
|
349
|
+
async getConfig(request, clientToken) {
|
|
350
|
+
return this.post("/config", request, {
|
|
351
|
+
headers: {
|
|
352
|
+
"clienttoken": clientToken
|
|
353
|
+
}
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Get a token for a client/company
|
|
358
|
+
* @param request - Token request with client and company
|
|
359
|
+
* @param clientToken - Client token for authentication
|
|
360
|
+
*/
|
|
361
|
+
async getToken(request, clientToken) {
|
|
362
|
+
return this.post("/token", request, {
|
|
363
|
+
headers: {
|
|
364
|
+
"clienttoken": clientToken
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
}
|
|
333
368
|
};
|
|
334
|
-
function createBookingLabClient(baseUrl, authToken) {
|
|
369
|
+
function createBookingLabClient(baseUrl, authToken, appId) {
|
|
335
370
|
const client = new BookingLabClient({ baseUrl });
|
|
336
371
|
if (authToken) {
|
|
337
372
|
client.setAuthToken(authToken);
|
|
338
373
|
}
|
|
374
|
+
if (appId) {
|
|
375
|
+
client.setAppId(appId);
|
|
376
|
+
}
|
|
339
377
|
return client;
|
|
340
378
|
}
|
|
341
379
|
|
|
@@ -704,8 +742,11 @@ function ApiClientProvider({
|
|
|
704
742
|
if (authToken) {
|
|
705
743
|
clientInstance.setAuthToken(authToken);
|
|
706
744
|
}
|
|
745
|
+
if (jrniConfig?.appId) {
|
|
746
|
+
clientInstance.setAppId(jrniConfig.appId);
|
|
747
|
+
}
|
|
707
748
|
return clientInstance;
|
|
708
|
-
}, [bookingLabBaseUrl, authToken]);
|
|
749
|
+
}, [bookingLabBaseUrl, authToken, jrniConfig?.appId]);
|
|
709
750
|
const jrniClient = react.useMemo(() => {
|
|
710
751
|
if (jrniBaseUrl && jrniConfig) {
|
|
711
752
|
return new JrniClient(jrniBaseUrl, jrniConfig);
|
|
@@ -732,15 +773,19 @@ var BookingLabContext = react.createContext(void 0);
|
|
|
732
773
|
function BookingLabProvider({
|
|
733
774
|
children,
|
|
734
775
|
baseUrl,
|
|
735
|
-
authToken
|
|
776
|
+
authToken,
|
|
777
|
+
appId
|
|
736
778
|
}) {
|
|
737
779
|
const client = react.useMemo(() => {
|
|
738
780
|
const clientInstance = new BookingLabClient({ baseUrl });
|
|
739
781
|
if (authToken) {
|
|
740
782
|
clientInstance.setAuthToken(authToken);
|
|
741
783
|
}
|
|
784
|
+
if (appId) {
|
|
785
|
+
clientInstance.setAppId(appId);
|
|
786
|
+
}
|
|
742
787
|
return clientInstance;
|
|
743
|
-
}, [baseUrl, authToken]);
|
|
788
|
+
}, [baseUrl, authToken, appId]);
|
|
744
789
|
const value = react.useMemo(() => ({ client }), [client]);
|
|
745
790
|
return /* @__PURE__ */ jsxRuntime.jsx(BookingLabContext.Provider, { value, children });
|
|
746
791
|
}
|
|
@@ -766,33 +811,31 @@ function useJrniContext() {
|
|
|
766
811
|
}
|
|
767
812
|
return context.client;
|
|
768
813
|
}
|
|
769
|
-
|
|
770
|
-
// src/hooks/useApiClient.ts
|
|
771
814
|
function useBookingLabClient() {
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
if (!context.bookingLabClient) {
|
|
777
|
-
throw new Error(
|
|
778
|
-
"BookingLab client not configured. Wrap your app with ApiClientProvider or BookingLabProvider."
|
|
779
|
-
);
|
|
780
|
-
}
|
|
781
|
-
return context.bookingLabClient;
|
|
815
|
+
const standaloneContext = react.useContext(BookingLabContext);
|
|
816
|
+
const combinedContext = react.useContext(ApiClientContext);
|
|
817
|
+
if (standaloneContext) {
|
|
818
|
+
return standaloneContext.client;
|
|
782
819
|
}
|
|
820
|
+
if (combinedContext?.bookingLabClient) {
|
|
821
|
+
return combinedContext.bookingLabClient;
|
|
822
|
+
}
|
|
823
|
+
throw new Error(
|
|
824
|
+
"BookingLab client not configured. Wrap your app with ApiClientProvider or BookingLabProvider."
|
|
825
|
+
);
|
|
783
826
|
}
|
|
784
827
|
function useJrniClient() {
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
if (!context.jrniClient) {
|
|
790
|
-
throw new Error(
|
|
791
|
-
"JRNI client not configured. Wrap your app with ApiClientProvider or JrniProvider."
|
|
792
|
-
);
|
|
793
|
-
}
|
|
794
|
-
return context.jrniClient;
|
|
828
|
+
const standaloneContext = react.useContext(JrniContext);
|
|
829
|
+
const combinedContext = react.useContext(ApiClientContext);
|
|
830
|
+
if (standaloneContext) {
|
|
831
|
+
return standaloneContext.client;
|
|
795
832
|
}
|
|
833
|
+
if (combinedContext?.jrniClient) {
|
|
834
|
+
return combinedContext.jrniClient;
|
|
835
|
+
}
|
|
836
|
+
throw new Error(
|
|
837
|
+
"JRNI client not configured. Wrap your app with ApiClientProvider or JrniProvider."
|
|
838
|
+
);
|
|
796
839
|
}
|
|
797
840
|
function useLogin() {
|
|
798
841
|
const client = useJrniClient();
|
|
@@ -1050,12 +1093,37 @@ function useBookingLabForgotPassword(companyId, clientToken) {
|
|
|
1050
1093
|
}
|
|
1051
1094
|
});
|
|
1052
1095
|
}
|
|
1096
|
+
function useBookingLabConfig(request, clientToken, enabled = true) {
|
|
1097
|
+
const client = useBookingLabClient();
|
|
1098
|
+
return reactQuery.useQuery({
|
|
1099
|
+
queryKey: ["bookingLabConfig", request.client, request.company],
|
|
1100
|
+
queryFn: async () => {
|
|
1101
|
+
const response = await client.getConfig(request, clientToken);
|
|
1102
|
+
return response.data;
|
|
1103
|
+
},
|
|
1104
|
+
enabled: enabled && !!request.client && !!request.company && !!clientToken
|
|
1105
|
+
});
|
|
1106
|
+
}
|
|
1107
|
+
function useBookingLabGetToken(request, clientToken, enabled = true) {
|
|
1108
|
+
const client = useBookingLabClient();
|
|
1109
|
+
return reactQuery.useQuery({
|
|
1110
|
+
queryKey: ["bookingLabGetToken", request.client, request.company],
|
|
1111
|
+
queryFn: async () => {
|
|
1112
|
+
const response = await client.getToken(request, clientToken);
|
|
1113
|
+
return response.data;
|
|
1114
|
+
},
|
|
1115
|
+
enabled: enabled && !!request.client && !!request.company && !!clientToken
|
|
1116
|
+
});
|
|
1117
|
+
}
|
|
1053
1118
|
|
|
1054
1119
|
exports.ApiClient = ApiClient;
|
|
1120
|
+
exports.ApiClientContext = ApiClientContext;
|
|
1055
1121
|
exports.ApiClientProvider = ApiClientProvider;
|
|
1056
1122
|
exports.BookingLabClient = BookingLabClient;
|
|
1123
|
+
exports.BookingLabContext = BookingLabContext;
|
|
1057
1124
|
exports.BookingLabProvider = BookingLabProvider;
|
|
1058
1125
|
exports.JrniClient = JrniClient;
|
|
1126
|
+
exports.JrniContext = JrniContext;
|
|
1059
1127
|
exports.JrniProvider = JrniProvider;
|
|
1060
1128
|
exports.MemberType = MemberType;
|
|
1061
1129
|
exports.createBookingLabClient = createBookingLabClient;
|
|
@@ -1063,8 +1131,10 @@ exports.createJrniClient = createJrniClient;
|
|
|
1063
1131
|
exports.useAddServiceItem = useAddServiceItem;
|
|
1064
1132
|
exports.useApiClientContext = useApiClientContext;
|
|
1065
1133
|
exports.useBookingLabClient = useBookingLabClient;
|
|
1134
|
+
exports.useBookingLabConfig = useBookingLabConfig;
|
|
1066
1135
|
exports.useBookingLabContext = useBookingLabContext;
|
|
1067
1136
|
exports.useBookingLabForgotPassword = useBookingLabForgotPassword;
|
|
1137
|
+
exports.useBookingLabGetToken = useBookingLabGetToken;
|
|
1068
1138
|
exports.useCancelBooking = useCancelBooking;
|
|
1069
1139
|
exports.useCancelMemberBooking = useCancelMemberBooking;
|
|
1070
1140
|
exports.useCheckoutBasket = useCheckoutBasket;
|