@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/dist/index.mjs
CHANGED
|
@@ -158,6 +158,16 @@ var MemberType = /* @__PURE__ */ ((MemberType2) => {
|
|
|
158
158
|
|
|
159
159
|
// src/booking-lab.ts
|
|
160
160
|
var BookingLabClient = class extends ApiClient {
|
|
161
|
+
constructor() {
|
|
162
|
+
super(...arguments);
|
|
163
|
+
this.appId = "";
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Set the App ID for x-app-id header
|
|
167
|
+
*/
|
|
168
|
+
setAppId(appId) {
|
|
169
|
+
this.appId = appId;
|
|
170
|
+
}
|
|
161
171
|
/**
|
|
162
172
|
* Get all bookings
|
|
163
173
|
*/
|
|
@@ -271,7 +281,8 @@ var BookingLabClient = class extends ApiClient {
|
|
|
271
281
|
"X-member-id": String(memberId),
|
|
272
282
|
"x-company-id": String(companyId),
|
|
273
283
|
"authtoken": authToken,
|
|
274
|
-
"clienttoken": clientToken
|
|
284
|
+
"clienttoken": clientToken,
|
|
285
|
+
...this.appId && { "x-app-id": this.appId }
|
|
275
286
|
}
|
|
276
287
|
}
|
|
277
288
|
);
|
|
@@ -328,12 +339,39 @@ var BookingLabClient = class extends ApiClient {
|
|
|
328
339
|
}
|
|
329
340
|
);
|
|
330
341
|
}
|
|
342
|
+
/**
|
|
343
|
+
* Get company configuration
|
|
344
|
+
* @param request - Config request with client and company
|
|
345
|
+
* @param clientToken - Client token for authentication
|
|
346
|
+
*/
|
|
347
|
+
async getConfig(request, clientToken) {
|
|
348
|
+
return this.post("/config", request, {
|
|
349
|
+
headers: {
|
|
350
|
+
"clienttoken": clientToken
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Get a token for a client/company
|
|
356
|
+
* @param request - Token request with client and company
|
|
357
|
+
* @param clientToken - Client token for authentication
|
|
358
|
+
*/
|
|
359
|
+
async getToken(request, clientToken) {
|
|
360
|
+
return this.post("/token", request, {
|
|
361
|
+
headers: {
|
|
362
|
+
"clienttoken": clientToken
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
}
|
|
331
366
|
};
|
|
332
|
-
function createBookingLabClient(baseUrl, authToken) {
|
|
367
|
+
function createBookingLabClient(baseUrl, authToken, appId) {
|
|
333
368
|
const client = new BookingLabClient({ baseUrl });
|
|
334
369
|
if (authToken) {
|
|
335
370
|
client.setAuthToken(authToken);
|
|
336
371
|
}
|
|
372
|
+
if (appId) {
|
|
373
|
+
client.setAppId(appId);
|
|
374
|
+
}
|
|
337
375
|
return client;
|
|
338
376
|
}
|
|
339
377
|
|
|
@@ -702,8 +740,11 @@ function ApiClientProvider({
|
|
|
702
740
|
if (authToken) {
|
|
703
741
|
clientInstance.setAuthToken(authToken);
|
|
704
742
|
}
|
|
743
|
+
if (jrniConfig?.appId) {
|
|
744
|
+
clientInstance.setAppId(jrniConfig.appId);
|
|
745
|
+
}
|
|
705
746
|
return clientInstance;
|
|
706
|
-
}, [bookingLabBaseUrl, authToken]);
|
|
747
|
+
}, [bookingLabBaseUrl, authToken, jrniConfig?.appId]);
|
|
707
748
|
const jrniClient = useMemo(() => {
|
|
708
749
|
if (jrniBaseUrl && jrniConfig) {
|
|
709
750
|
return new JrniClient(jrniBaseUrl, jrniConfig);
|
|
@@ -730,15 +771,19 @@ var BookingLabContext = createContext(void 0);
|
|
|
730
771
|
function BookingLabProvider({
|
|
731
772
|
children,
|
|
732
773
|
baseUrl,
|
|
733
|
-
authToken
|
|
774
|
+
authToken,
|
|
775
|
+
appId
|
|
734
776
|
}) {
|
|
735
777
|
const client = useMemo(() => {
|
|
736
778
|
const clientInstance = new BookingLabClient({ baseUrl });
|
|
737
779
|
if (authToken) {
|
|
738
780
|
clientInstance.setAuthToken(authToken);
|
|
739
781
|
}
|
|
782
|
+
if (appId) {
|
|
783
|
+
clientInstance.setAppId(appId);
|
|
784
|
+
}
|
|
740
785
|
return clientInstance;
|
|
741
|
-
}, [baseUrl, authToken]);
|
|
786
|
+
}, [baseUrl, authToken, appId]);
|
|
742
787
|
const value = useMemo(() => ({ client }), [client]);
|
|
743
788
|
return /* @__PURE__ */ jsx(BookingLabContext.Provider, { value, children });
|
|
744
789
|
}
|
|
@@ -764,33 +809,31 @@ function useJrniContext() {
|
|
|
764
809
|
}
|
|
765
810
|
return context.client;
|
|
766
811
|
}
|
|
767
|
-
|
|
768
|
-
// src/hooks/useApiClient.ts
|
|
769
812
|
function useBookingLabClient() {
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
if (!context.bookingLabClient) {
|
|
775
|
-
throw new Error(
|
|
776
|
-
"BookingLab client not configured. Wrap your app with ApiClientProvider or BookingLabProvider."
|
|
777
|
-
);
|
|
778
|
-
}
|
|
779
|
-
return context.bookingLabClient;
|
|
813
|
+
const standaloneContext = useContext(BookingLabContext);
|
|
814
|
+
const combinedContext = useContext(ApiClientContext);
|
|
815
|
+
if (standaloneContext) {
|
|
816
|
+
return standaloneContext.client;
|
|
780
817
|
}
|
|
818
|
+
if (combinedContext?.bookingLabClient) {
|
|
819
|
+
return combinedContext.bookingLabClient;
|
|
820
|
+
}
|
|
821
|
+
throw new Error(
|
|
822
|
+
"BookingLab client not configured. Wrap your app with ApiClientProvider or BookingLabProvider."
|
|
823
|
+
);
|
|
781
824
|
}
|
|
782
825
|
function useJrniClient() {
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
if (!context.jrniClient) {
|
|
788
|
-
throw new Error(
|
|
789
|
-
"JRNI client not configured. Wrap your app with ApiClientProvider or JrniProvider."
|
|
790
|
-
);
|
|
791
|
-
}
|
|
792
|
-
return context.jrniClient;
|
|
826
|
+
const standaloneContext = useContext(JrniContext);
|
|
827
|
+
const combinedContext = useContext(ApiClientContext);
|
|
828
|
+
if (standaloneContext) {
|
|
829
|
+
return standaloneContext.client;
|
|
793
830
|
}
|
|
831
|
+
if (combinedContext?.jrniClient) {
|
|
832
|
+
return combinedContext.jrniClient;
|
|
833
|
+
}
|
|
834
|
+
throw new Error(
|
|
835
|
+
"JRNI client not configured. Wrap your app with ApiClientProvider or JrniProvider."
|
|
836
|
+
);
|
|
794
837
|
}
|
|
795
838
|
function useLogin() {
|
|
796
839
|
const client = useJrniClient();
|
|
@@ -1048,7 +1091,29 @@ function useBookingLabForgotPassword(companyId, clientToken) {
|
|
|
1048
1091
|
}
|
|
1049
1092
|
});
|
|
1050
1093
|
}
|
|
1094
|
+
function useBookingLabConfig(request, clientToken, enabled = true) {
|
|
1095
|
+
const client = useBookingLabClient();
|
|
1096
|
+
return useQuery({
|
|
1097
|
+
queryKey: ["bookingLabConfig", request.client, request.company],
|
|
1098
|
+
queryFn: async () => {
|
|
1099
|
+
const response = await client.getConfig(request, clientToken);
|
|
1100
|
+
return response.data;
|
|
1101
|
+
},
|
|
1102
|
+
enabled: enabled && !!request.client && !!request.company && !!clientToken
|
|
1103
|
+
});
|
|
1104
|
+
}
|
|
1105
|
+
function useBookingLabGetToken(request, clientToken, enabled = true) {
|
|
1106
|
+
const client = useBookingLabClient();
|
|
1107
|
+
return useQuery({
|
|
1108
|
+
queryKey: ["bookingLabGetToken", request.client, request.company],
|
|
1109
|
+
queryFn: async () => {
|
|
1110
|
+
const response = await client.getToken(request, clientToken);
|
|
1111
|
+
return response.data;
|
|
1112
|
+
},
|
|
1113
|
+
enabled: enabled && !!request.client && !!request.company && !!clientToken
|
|
1114
|
+
});
|
|
1115
|
+
}
|
|
1051
1116
|
|
|
1052
|
-
export { ApiClient, ApiClientProvider, BookingLabClient, BookingLabProvider, JrniClient, JrniProvider, MemberType, 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 };
|
|
1117
|
+
export { ApiClient, ApiClientContext, ApiClientProvider, BookingLabClient, BookingLabContext, BookingLabProvider, JrniClient, JrniContext, JrniProvider, MemberType, 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 };
|
|
1053
1118
|
//# sourceMappingURL=index.mjs.map
|
|
1054
1119
|
//# sourceMappingURL=index.mjs.map
|