@bookinglab/booking-journey-api 2.6.0 → 2.8.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 +8 -1
- package/dist/index.d.cts +41 -4
- package/dist/index.d.ts +41 -4
- package/dist/index.js +77 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +74 -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
|
);
|
|
@@ -310,12 +321,33 @@ var BookingLabClient = class extends ApiClient {
|
|
|
310
321
|
}
|
|
311
322
|
);
|
|
312
323
|
}
|
|
324
|
+
/**
|
|
325
|
+
* Request a password reset for a client
|
|
326
|
+
* @param companyId - The company ID
|
|
327
|
+
* @param request - Forgot password request with email, path, and token_based_reset
|
|
328
|
+
* @param clientToken - Client token for authentication
|
|
329
|
+
*/
|
|
330
|
+
async forgotPassword(companyId, request, clientToken) {
|
|
331
|
+
return this.post(
|
|
332
|
+
`/company/${companyId}/forgot-password`,
|
|
333
|
+
request,
|
|
334
|
+
{
|
|
335
|
+
headers: {
|
|
336
|
+
"x-company-id": String(companyId),
|
|
337
|
+
"clienttoken": clientToken
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
);
|
|
341
|
+
}
|
|
313
342
|
};
|
|
314
|
-
function createBookingLabClient(baseUrl, authToken) {
|
|
343
|
+
function createBookingLabClient(baseUrl, authToken, appId) {
|
|
315
344
|
const client = new BookingLabClient({ baseUrl });
|
|
316
345
|
if (authToken) {
|
|
317
346
|
client.setAuthToken(authToken);
|
|
318
347
|
}
|
|
348
|
+
if (appId) {
|
|
349
|
+
client.setAppId(appId);
|
|
350
|
+
}
|
|
319
351
|
return client;
|
|
320
352
|
}
|
|
321
353
|
|
|
@@ -684,8 +716,11 @@ function ApiClientProvider({
|
|
|
684
716
|
if (authToken) {
|
|
685
717
|
clientInstance.setAuthToken(authToken);
|
|
686
718
|
}
|
|
719
|
+
if (jrniConfig?.appId) {
|
|
720
|
+
clientInstance.setAppId(jrniConfig.appId);
|
|
721
|
+
}
|
|
687
722
|
return clientInstance;
|
|
688
|
-
}, [bookingLabBaseUrl, authToken]);
|
|
723
|
+
}, [bookingLabBaseUrl, authToken, jrniConfig?.appId]);
|
|
689
724
|
const jrniClient = useMemo(() => {
|
|
690
725
|
if (jrniBaseUrl && jrniConfig) {
|
|
691
726
|
return new JrniClient(jrniBaseUrl, jrniConfig);
|
|
@@ -712,15 +747,19 @@ var BookingLabContext = createContext(void 0);
|
|
|
712
747
|
function BookingLabProvider({
|
|
713
748
|
children,
|
|
714
749
|
baseUrl,
|
|
715
|
-
authToken
|
|
750
|
+
authToken,
|
|
751
|
+
appId
|
|
716
752
|
}) {
|
|
717
753
|
const client = useMemo(() => {
|
|
718
754
|
const clientInstance = new BookingLabClient({ baseUrl });
|
|
719
755
|
if (authToken) {
|
|
720
756
|
clientInstance.setAuthToken(authToken);
|
|
721
757
|
}
|
|
758
|
+
if (appId) {
|
|
759
|
+
clientInstance.setAppId(appId);
|
|
760
|
+
}
|
|
722
761
|
return clientInstance;
|
|
723
|
-
}, [baseUrl, authToken]);
|
|
762
|
+
}, [baseUrl, authToken, appId]);
|
|
724
763
|
const value = useMemo(() => ({ client }), [client]);
|
|
725
764
|
return /* @__PURE__ */ jsx(BookingLabContext.Provider, { value, children });
|
|
726
765
|
}
|
|
@@ -746,33 +785,31 @@ function useJrniContext() {
|
|
|
746
785
|
}
|
|
747
786
|
return context.client;
|
|
748
787
|
}
|
|
749
|
-
|
|
750
|
-
// src/hooks/useApiClient.ts
|
|
751
788
|
function useBookingLabClient() {
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
);
|
|
760
|
-
}
|
|
761
|
-
return context.bookingLabClient;
|
|
789
|
+
const standaloneContext = useContext(BookingLabContext);
|
|
790
|
+
const combinedContext = useContext(ApiClientContext);
|
|
791
|
+
if (standaloneContext) {
|
|
792
|
+
return standaloneContext.client;
|
|
793
|
+
}
|
|
794
|
+
if (combinedContext?.bookingLabClient) {
|
|
795
|
+
return combinedContext.bookingLabClient;
|
|
762
796
|
}
|
|
797
|
+
throw new Error(
|
|
798
|
+
"BookingLab client not configured. Wrap your app with ApiClientProvider or BookingLabProvider."
|
|
799
|
+
);
|
|
763
800
|
}
|
|
764
801
|
function useJrniClient() {
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
if (!context.jrniClient) {
|
|
770
|
-
throw new Error(
|
|
771
|
-
"JRNI client not configured. Wrap your app with ApiClientProvider or JrniProvider."
|
|
772
|
-
);
|
|
773
|
-
}
|
|
774
|
-
return context.jrniClient;
|
|
802
|
+
const standaloneContext = useContext(JrniContext);
|
|
803
|
+
const combinedContext = useContext(ApiClientContext);
|
|
804
|
+
if (standaloneContext) {
|
|
805
|
+
return standaloneContext.client;
|
|
775
806
|
}
|
|
807
|
+
if (combinedContext?.jrniClient) {
|
|
808
|
+
return combinedContext.jrniClient;
|
|
809
|
+
}
|
|
810
|
+
throw new Error(
|
|
811
|
+
"JRNI client not configured. Wrap your app with ApiClientProvider or JrniProvider."
|
|
812
|
+
);
|
|
776
813
|
}
|
|
777
814
|
function useLogin() {
|
|
778
815
|
const client = useJrniClient();
|
|
@@ -1021,7 +1058,16 @@ function useSendCustomEmail(companyId, clientToken) {
|
|
|
1021
1058
|
}
|
|
1022
1059
|
});
|
|
1023
1060
|
}
|
|
1061
|
+
function useBookingLabForgotPassword(companyId, clientToken) {
|
|
1062
|
+
const client = useBookingLabClient();
|
|
1063
|
+
return useMutation({
|
|
1064
|
+
mutationFn: async (request) => {
|
|
1065
|
+
const response = await client.forgotPassword(companyId, request, clientToken);
|
|
1066
|
+
return response.data;
|
|
1067
|
+
}
|
|
1068
|
+
});
|
|
1069
|
+
}
|
|
1024
1070
|
|
|
1025
|
-
export { ApiClient, ApiClientProvider, BookingLabClient, BookingLabProvider, JrniClient, JrniProvider, MemberType, createBookingLabClient, createJrniClient, useAddServiceItem, useApiClientContext, useBookingLabClient, useBookingLabContext, 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 };
|
|
1071
|
+
export { ApiClient, ApiClientContext, ApiClientProvider, BookingLabClient, BookingLabContext, BookingLabProvider, JrniClient, JrniContext, 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 };
|
|
1026
1072
|
//# sourceMappingURL=index.mjs.map
|
|
1027
1073
|
//# sourceMappingURL=index.mjs.map
|