@scryme/sdk 9.64.2 → 9.65.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.
@@ -306,10 +306,10 @@ var getScrymeV3API = (axiosInstance = axios) => {
306
306
  options
307
307
  );
308
308
  };
309
- const invoiceControllerCreateTemplate = (options) => {
309
+ const invoiceControllerCreateTemplate = (createInvoiceTemplateDto, options) => {
310
310
  return axiosInstance.post(
311
311
  `/v3/finance/invoices/templates`,
312
- void 0,
312
+ createInvoiceTemplateDto,
313
313
  options
314
314
  );
315
315
  };
@@ -842,6 +842,54 @@ var getScrymeV3API = (axiosInstance = axios) => {
842
842
  }
843
843
  );
844
844
  };
845
+ const publicServicesListServices = (orgSlug, options) => {
846
+ return axiosInstance.get(
847
+ `/v3/public/${orgSlug}/services`,
848
+ options
849
+ );
850
+ };
851
+ const publicServicesGetCategories = (orgSlug, options) => {
852
+ return axiosInstance.get(
853
+ `/v3/public/${orgSlug}/services/categories`,
854
+ options
855
+ );
856
+ };
857
+ const publicServicesGetService = (orgSlug, id, options) => {
858
+ return axiosInstance.get(
859
+ `/v3/public/${orgSlug}/services/${id}`,
860
+ options
861
+ );
862
+ };
863
+ const publicServicesGetAvailability = (orgSlug, id, params, options) => {
864
+ return axiosInstance.get(
865
+ `/v3/public/${orgSlug}/services/${id}/availability`,
866
+ {
867
+ ...options,
868
+ params: { ...params, ...options?.params }
869
+ }
870
+ );
871
+ };
872
+ const publicServicesRequestOtp = (orgSlug, requestOtpDto, options) => {
873
+ return axiosInstance.post(
874
+ `/v3/public/${orgSlug}/services/otp/request`,
875
+ requestOtpDto,
876
+ options
877
+ );
878
+ };
879
+ const publicServicesVerifyOtp = (orgSlug, verifyOtpDto, options) => {
880
+ return axiosInstance.post(
881
+ `/v3/public/${orgSlug}/services/otp/verify`,
882
+ verifyOtpDto,
883
+ options
884
+ );
885
+ };
886
+ const publicServicesCreatePublicBooking = (orgSlug, publicBookingDto, options) => {
887
+ return axiosInstance.post(
888
+ `/v3/public/${orgSlug}/services/bookings`,
889
+ publicBookingDto,
890
+ options
891
+ );
892
+ };
845
893
  const customersProvisionZitadel = (orgSlug, provisionZitadelDto, options) => {
846
894
  return axiosInstance.post(
847
895
  `/v3/${orgSlug}/customers/zitadel/provision`,
@@ -865,6 +913,40 @@ var getScrymeV3API = (axiosInstance = axios) => {
865
913
  options
866
914
  );
867
915
  };
916
+ const customersLogin = (orgSlug, customerLoginDto, options) => {
917
+ return axiosInstance.post(
918
+ `/v3/${orgSlug}/customers/auth/login`,
919
+ customerLoginDto,
920
+ options
921
+ );
922
+ };
923
+ const customersGetCurrentSession = (orgSlug, options) => {
924
+ return axiosInstance.get(
925
+ `/v3/${orgSlug}/customers/auth/session`,
926
+ options
927
+ );
928
+ };
929
+ const customersGetSessions = (orgSlug, options) => {
930
+ return axiosInstance.get(
931
+ `/v3/${orgSlug}/customers/auth/sessions`,
932
+ options
933
+ );
934
+ };
935
+ const customersRevokeAllSessions = (orgSlug, params, options) => {
936
+ return axiosInstance.delete(
937
+ `/v3/${orgSlug}/customers/auth/sessions`,
938
+ {
939
+ ...options,
940
+ params: { ...params, ...options?.params }
941
+ }
942
+ );
943
+ };
944
+ const customersRevokeSession = (orgSlug, id, options) => {
945
+ return axiosInstance.delete(
946
+ `/v3/${orgSlug}/customers/auth/sessions/${id}`,
947
+ options
948
+ );
949
+ };
868
950
  const customersUpdate = (orgSlug, id, updateCustomerDto, options) => {
869
951
  return axiosInstance.patch(
870
952
  `/v3/${orgSlug}/customers/${id}`,
@@ -1776,7 +1858,7 @@ var getScrymeV3API = (axiosInstance = axios) => {
1776
1858
  }
1777
1859
  );
1778
1860
  };
1779
- return { inventoryVerifyIntegrity, inventoryFixIntegrity, inventoryGetInventory, inventoryTraceBatch, inventorySplitBatch, inventoryMergeBatches, inventoryCreateAssembly, inventoryCompleteAssembly, inventoryRequestAdjustment, inventoryGetAdjustments, inventoryApproveAdjustment, inventoryRejectAdjustment, inventoryGetLeadTime, inventoryGetWasteAnalysis, inventoryCheckB2BAvailability, inventoryUnpackBatch, inventoryScanUnpackBatch, inventoryQuickStockInquiry, expenseControllerCreateExpense, expenseControllerGetExpenses, expenseControllerGetExpenseCategories, expenseControllerGetExpense, pettyCashControllerCreateFund, pettyCashControllerGetFunds, pettyCashControllerGetFund, pettyCashControllerTopUpFund, pettyCashControllerGetFundTransactions, utilityAccountControllerCreateAccount, utilityAccountControllerGetAccounts, utilityAccountControllerGetAccount, accountingInitialize, accountingGetProfitLoss, accountingGetBalanceSheet, accountingGetCashFlow, accountingGetTaxSummary, invoiceControllerCreateInvoice, invoiceControllerGetInvoices, invoiceControllerGetInvoice, invoiceControllerUpdateInvoice, invoiceControllerDeleteInvoice, invoiceControllerFinalizeInvoice, invoiceControllerGetTemplates, invoiceControllerCreateTemplate, invoiceControllerGetConfig, invoiceControllerUpdateConfig, publicInvoiceControllerDownloadInvoice, publicInvoiceControllerDownloadInvoiceByTransaction, publicInvoiceControllerDownloadReceipt, publicInvoiceControllerGeneratePublicLink, authExchangeToken, authControllerHandleOAuth2, adminControllerGetStats, adminControllerListOrganizations, adminControllerCreateOrganization, adminControllerGetOrganizationDetails, adminControllerUpdateOrganization, adminControllerDeleteOrganization, adminControllerListMembers, adminControllerListUsers, adminControllerBanUser, adminControllerUnbanUser, adminControllerListConnectedApps, adminControllerListSystemLogs, adminControllerListGlobalSettings, adminControllerSetGlobalSetting, adminControllerDeleteGlobalSetting, adminControllerListTiers, adminControllerDefineTier, adminControllerDeleteTier, adminControllerGetOrganizationSubscription, adminControllerUpdateOrganizationSubscription, adminControllerListSystemPayments, adminControllerRecordCustomPayment, adminControllerListIntegrationDefinitions, adminControllerCreateIntegrationDefinition, adminControllerUpdateIntegrationDefinition, adminControllerDeleteIntegrationDefinition, adminControllerListActiveOrganizationIntegrations, webhooksCreate, webhooksList, webhooksDelete, windmillCallbackControllerHandleCallback, windmillCallbackControllerHandleApprovalCallback, windmillCallbackControllerHandleBakeryDisposalCallback, windmillCallbackControllerHandleOutcomeCallback, catalogGetProducts, catalogCreateProduct, catalogGetServices, catalogUpdateProduct, catalogUpdateSupplierVariant, catalogGetPriceChangeRequests, catalogReviewPriceChangeRequest, servicesCreateCategory, servicesGetCategories, servicesUpdateCategory, servicesDeleteCategory, servicesCreateService, servicesGetServices, servicesGetCurrentMemberShifts, servicesGetShifts, servicesGetService, servicesUpdateService, servicesDeleteService, servicesCreateResource, servicesGetResources, servicesUpdateResource, servicesDeleteResource, servicesCreateBooking, servicesGetBookings, servicesGetBooking, servicesUpdateBookingStatus, servicesCompleteBooking, servicesCreateShift, servicesGetStaffShifts, servicesAddBreak, servicesRegisterCustomerApp, servicesGetUtilization, servicesGetPerformance, servicesGetFunnel, customersProvisionZitadel, customersGetCustomers, customersRegister, customersUpdate, customersGetCustomerById, customersDelete, customersGetAddresses, customersAddAddress, businessAccountControllerCreate, businessAccountControllerGetOne, crmControllerCreateRecord, crmControllerGetRecord, crmControllerUpdateRecord, crmControllerCreateNote, crmControllerGetRecordNotes, crmControllerCreateActivity, crmControllerGetTimeline, crmControllerCreateObject, crmControllerListObjects, crmControllerCreateField, crmControllerListFields, crmControllerCreateRelationship, crmControllerListRelationships, crmControllerCreateAssociation, crmControllerListRecordAssociations, loyaltyRedeemReward, loyaltyGetCustomerStatus, loyaltyValidateVoucher, ordersCreateOrder, ordersGetOrders, ordersUpdateStatus, ordersRequestB2BQuote, ordersConvertQuoteToOrder, paymentsControllerHandleStkCallback, pOSProvision, pOSLogin, pOSGetMe, pOSProcessSale, pOSSync, pOSGetTransactions, pOSRegisterPettyCash, pOSGetPettyCashFunds, pOSGetPettyCashTransactions, membersControllerGetMembers, membersControllerCreateMember, membersControllerGetMember, membersControllerUpdateMember, membersControllerDeleteMember, membersControllerGetMemberActivity, membersControllerUpdateStatus, membersControllerAdminCheckOut, terminalMembersControllerLogin, invitationsList, invitationsCreate, invitationsRevoke, invitationsAccept, roleManagementControllerGetCustomRoles, roleManagementControllerCreateCustomRole, roleManagementControllerUpdateCustomRole, roleManagementControllerDeleteCustomRole, roleManagementControllerGetPermissionSets, roleManagementControllerCreatePermissionSet, roleManagementControllerGetRoleGroups, roleManagementControllerCreateRoleGroup, roleManagementControllerAssignRoles, roleManagementControllerRemoveRoles, departmentsList, departmentsCreate, departmentsGet, departmentsUpdate, departmentsDelete, departmentsAddMember, departmentsRemoveMember, attendanceControllerGetLogs, attendanceControllerCheckIn, attendanceControllerCheckOut, attendanceControllerGetMyStatus, attendanceControllerGetStatus, announcementControllerBroadcastAnnouncement, cartControllerGetCart, cartControllerClearCart, cartControllerAddToCart, cartControllerRemoveFromCart, favoritesControllerGetFavorites, favoritesControllerAddFavorite, favoritesControllerRemoveFavorite, stockingGetPurchases, stockingCreatePurchase, stockingReceivePurchase, stockingGetTransfers, stockingCreateTransfer, stockingShipTransfer, stockingReceiveTransfer, stockingGetRequests, stockingGetPendingDispatch, stockingDispatchOrders, stockingGetActiveDeliveries, stockingReconcilePod, stockingGetPhysicalReconciliations, stockingSubmitPhysicalReconciliation, stockingGetReconciliationReport, stockingGetPartners, stockingCreatePartner, stockingGetPartner, stockingUpdatePartner, stockingAdjustPartnerWallet, standalonePosControllerCreateSetupKey, standalonePosControllerActivateDevice, standalonePosControllerValidateKey, standalonePosControllerLinkOrganization, b2BGetCatalog, b2BGetInvoices, b2BGetOrders, b2BCreateOrder, b2BCreateQuote, crmIntegrationsGetAuthUrl, crmIntegrationsHandleCallback, crmIntegrationsHandleWebhook, crmIntegrationsReplyToActivity, unitsGetUnits, strapiCreateConnection, strapiListConnections, strapiGetConnection, strapiUpdateConnection, strapiDeleteConnection, strapiTriggerSync, strapiEnqueueSync, strapiGetWebhookLogs, strapiGetSyncLogs, strapiExchangeCustomerToken, strapiRegisterCustomer, strapiReceiveWebhook, analyticsControllerGetDashboardAnalytics, analyticsControllerGetResourceUtilization };
1861
+ return { inventoryVerifyIntegrity, inventoryFixIntegrity, inventoryGetInventory, inventoryTraceBatch, inventorySplitBatch, inventoryMergeBatches, inventoryCreateAssembly, inventoryCompleteAssembly, inventoryRequestAdjustment, inventoryGetAdjustments, inventoryApproveAdjustment, inventoryRejectAdjustment, inventoryGetLeadTime, inventoryGetWasteAnalysis, inventoryCheckB2BAvailability, inventoryUnpackBatch, inventoryScanUnpackBatch, inventoryQuickStockInquiry, expenseControllerCreateExpense, expenseControllerGetExpenses, expenseControllerGetExpenseCategories, expenseControllerGetExpense, pettyCashControllerCreateFund, pettyCashControllerGetFunds, pettyCashControllerGetFund, pettyCashControllerTopUpFund, pettyCashControllerGetFundTransactions, utilityAccountControllerCreateAccount, utilityAccountControllerGetAccounts, utilityAccountControllerGetAccount, accountingInitialize, accountingGetProfitLoss, accountingGetBalanceSheet, accountingGetCashFlow, accountingGetTaxSummary, invoiceControllerCreateInvoice, invoiceControllerGetInvoices, invoiceControllerGetInvoice, invoiceControllerUpdateInvoice, invoiceControllerDeleteInvoice, invoiceControllerFinalizeInvoice, invoiceControllerGetTemplates, invoiceControllerCreateTemplate, invoiceControllerGetConfig, invoiceControllerUpdateConfig, publicInvoiceControllerDownloadInvoice, publicInvoiceControllerDownloadInvoiceByTransaction, publicInvoiceControllerDownloadReceipt, publicInvoiceControllerGeneratePublicLink, authExchangeToken, authControllerHandleOAuth2, adminControllerGetStats, adminControllerListOrganizations, adminControllerCreateOrganization, adminControllerGetOrganizationDetails, adminControllerUpdateOrganization, adminControllerDeleteOrganization, adminControllerListMembers, adminControllerListUsers, adminControllerBanUser, adminControllerUnbanUser, adminControllerListConnectedApps, adminControllerListSystemLogs, adminControllerListGlobalSettings, adminControllerSetGlobalSetting, adminControllerDeleteGlobalSetting, adminControllerListTiers, adminControllerDefineTier, adminControllerDeleteTier, adminControllerGetOrganizationSubscription, adminControllerUpdateOrganizationSubscription, adminControllerListSystemPayments, adminControllerRecordCustomPayment, adminControllerListIntegrationDefinitions, adminControllerCreateIntegrationDefinition, adminControllerUpdateIntegrationDefinition, adminControllerDeleteIntegrationDefinition, adminControllerListActiveOrganizationIntegrations, webhooksCreate, webhooksList, webhooksDelete, windmillCallbackControllerHandleCallback, windmillCallbackControllerHandleApprovalCallback, windmillCallbackControllerHandleBakeryDisposalCallback, windmillCallbackControllerHandleOutcomeCallback, catalogGetProducts, catalogCreateProduct, catalogGetServices, catalogUpdateProduct, catalogUpdateSupplierVariant, catalogGetPriceChangeRequests, catalogReviewPriceChangeRequest, servicesCreateCategory, servicesGetCategories, servicesUpdateCategory, servicesDeleteCategory, servicesCreateService, servicesGetServices, servicesGetCurrentMemberShifts, servicesGetShifts, servicesGetService, servicesUpdateService, servicesDeleteService, servicesCreateResource, servicesGetResources, servicesUpdateResource, servicesDeleteResource, servicesCreateBooking, servicesGetBookings, servicesGetBooking, servicesUpdateBookingStatus, servicesCompleteBooking, servicesCreateShift, servicesGetStaffShifts, servicesAddBreak, servicesRegisterCustomerApp, servicesGetUtilization, servicesGetPerformance, servicesGetFunnel, publicServicesListServices, publicServicesGetCategories, publicServicesGetService, publicServicesGetAvailability, publicServicesRequestOtp, publicServicesVerifyOtp, publicServicesCreatePublicBooking, customersProvisionZitadel, customersGetCustomers, customersRegister, customersLogin, customersGetCurrentSession, customersGetSessions, customersRevokeAllSessions, customersRevokeSession, customersUpdate, customersGetCustomerById, customersDelete, customersGetAddresses, customersAddAddress, businessAccountControllerCreate, businessAccountControllerGetOne, crmControllerCreateRecord, crmControllerGetRecord, crmControllerUpdateRecord, crmControllerCreateNote, crmControllerGetRecordNotes, crmControllerCreateActivity, crmControllerGetTimeline, crmControllerCreateObject, crmControllerListObjects, crmControllerCreateField, crmControllerListFields, crmControllerCreateRelationship, crmControllerListRelationships, crmControllerCreateAssociation, crmControllerListRecordAssociations, loyaltyRedeemReward, loyaltyGetCustomerStatus, loyaltyValidateVoucher, ordersCreateOrder, ordersGetOrders, ordersUpdateStatus, ordersRequestB2BQuote, ordersConvertQuoteToOrder, paymentsControllerHandleStkCallback, pOSProvision, pOSLogin, pOSGetMe, pOSProcessSale, pOSSync, pOSGetTransactions, pOSRegisterPettyCash, pOSGetPettyCashFunds, pOSGetPettyCashTransactions, membersControllerGetMembers, membersControllerCreateMember, membersControllerGetMember, membersControllerUpdateMember, membersControllerDeleteMember, membersControllerGetMemberActivity, membersControllerUpdateStatus, membersControllerAdminCheckOut, terminalMembersControllerLogin, invitationsList, invitationsCreate, invitationsRevoke, invitationsAccept, roleManagementControllerGetCustomRoles, roleManagementControllerCreateCustomRole, roleManagementControllerUpdateCustomRole, roleManagementControllerDeleteCustomRole, roleManagementControllerGetPermissionSets, roleManagementControllerCreatePermissionSet, roleManagementControllerGetRoleGroups, roleManagementControllerCreateRoleGroup, roleManagementControllerAssignRoles, roleManagementControllerRemoveRoles, departmentsList, departmentsCreate, departmentsGet, departmentsUpdate, departmentsDelete, departmentsAddMember, departmentsRemoveMember, attendanceControllerGetLogs, attendanceControllerCheckIn, attendanceControllerCheckOut, attendanceControllerGetMyStatus, attendanceControllerGetStatus, announcementControllerBroadcastAnnouncement, cartControllerGetCart, cartControllerClearCart, cartControllerAddToCart, cartControllerRemoveFromCart, favoritesControllerGetFavorites, favoritesControllerAddFavorite, favoritesControllerRemoveFavorite, stockingGetPurchases, stockingCreatePurchase, stockingReceivePurchase, stockingGetTransfers, stockingCreateTransfer, stockingShipTransfer, stockingReceiveTransfer, stockingGetRequests, stockingGetPendingDispatch, stockingDispatchOrders, stockingGetActiveDeliveries, stockingReconcilePod, stockingGetPhysicalReconciliations, stockingSubmitPhysicalReconciliation, stockingGetReconciliationReport, stockingGetPartners, stockingCreatePartner, stockingGetPartner, stockingUpdatePartner, stockingAdjustPartnerWallet, standalonePosControllerCreateSetupKey, standalonePosControllerActivateDevice, standalonePosControllerValidateKey, standalonePosControllerLinkOrganization, b2BGetCatalog, b2BGetInvoices, b2BGetOrders, b2BCreateOrder, b2BCreateQuote, crmIntegrationsGetAuthUrl, crmIntegrationsHandleCallback, crmIntegrationsHandleWebhook, crmIntegrationsReplyToActivity, unitsGetUnits, strapiCreateConnection, strapiListConnections, strapiGetConnection, strapiUpdateConnection, strapiDeleteConnection, strapiTriggerSync, strapiEnqueueSync, strapiGetWebhookLogs, strapiGetSyncLogs, strapiExchangeCustomerToken, strapiRegisterCustomer, strapiReceiveWebhook, analyticsControllerGetDashboardAnalytics, analyticsControllerGetResourceUtilization };
1780
1862
  };
1781
1863
 
1782
1864
  // src/generated/model/addDepartmentMemberDtoRole.ts
@@ -2192,6 +2274,13 @@ var UpdateStrapiConnectionDtoSyncDirection = {
2192
2274
 
2193
2275
  // src/base.ts
2194
2276
  var methodsWithOrgSlugSet = /* @__PURE__ */ new Set([
2277
+ "publicServicesListServices",
2278
+ "publicServicesGetCategories",
2279
+ "publicServicesGetService",
2280
+ "publicServicesGetAvailability",
2281
+ "publicServicesRequestOtp",
2282
+ "publicServicesVerifyOtp",
2283
+ "publicServicesCreatePublicBooking",
2195
2284
  "inventoryVerifyIntegrity",
2196
2285
  "inventoryFixIntegrity",
2197
2286
  "inventoryGetInventory",
@@ -2260,6 +2349,7 @@ var methodsWithOrgSlugSet = /* @__PURE__ */ new Set([
2260
2349
  "customersDelete",
2261
2350
  "customersGetAddresses",
2262
2351
  "customersAddAddress",
2352
+ "customersGetCurrentSession",
2263
2353
  "businessAccountControllerCreate",
2264
2354
  "businessAccountControllerGetOne",
2265
2355
  "crmControllerCreateRecord",
@@ -2317,7 +2407,14 @@ var methodsWithOrgSlugSet = /* @__PURE__ */ new Set([
2317
2407
  "roleManagementControllerCreateRoleGroup",
2318
2408
  "roleManagementControllerAssignRoles",
2319
2409
  "roleManagementControllerRemoveRoles",
2320
- "departmentsList"
2410
+ "departmentsList",
2411
+ "cartControllerGetCart",
2412
+ "cartControllerClearCart",
2413
+ "cartControllerAddToCart",
2414
+ "cartControllerRemoveFromCart",
2415
+ "favoritesControllerGetFavorites",
2416
+ "favoritesControllerAddFavorite",
2417
+ "favoritesControllerRemoveFavorite"
2321
2418
  ]);
2322
2419
  var catalogMapping = {
2323
2420
  getProducts: "catalogGetProducts",
@@ -2544,6 +2641,46 @@ var membersMapping = {
2544
2641
  getAttendanceStatus: "attendanceControllerGetStatus",
2545
2642
  broadcastAnnouncement: "announcementControllerBroadcastAnnouncement"
2546
2643
  };
2644
+ var publicServicesMapping = {
2645
+ listServices: "publicServicesListServices",
2646
+ getCategories: "publicServicesGetCategories",
2647
+ getService: "publicServicesGetService",
2648
+ getAvailability: "publicServicesGetAvailability",
2649
+ requestOtp: "publicServicesRequestOtp",
2650
+ verifyOtp: "publicServicesVerifyOtp",
2651
+ createBooking: "publicServicesCreatePublicBooking"
2652
+ };
2653
+ var servicesMapping = {
2654
+ ...publicServicesMapping,
2655
+ // Admin / Staff scheduling endpoints
2656
+ createCategory: "servicesCreateCategory",
2657
+ getCategoriesAdmin: "servicesGetCategories",
2658
+ updateCategory: "servicesUpdateCategory",
2659
+ deleteCategory: "servicesDeleteCategory",
2660
+ createService: "servicesCreateService",
2661
+ getServicesAdmin: "servicesGetServices",
2662
+ getCurrentMemberShifts: "servicesGetCurrentMemberShifts",
2663
+ getShifts: "servicesGetShifts",
2664
+ getServiceAdmin: "servicesGetService",
2665
+ updateService: "servicesUpdateService",
2666
+ deleteService: "servicesDeleteService",
2667
+ createResource: "servicesCreateResource",
2668
+ getResources: "servicesGetResources",
2669
+ updateResource: "servicesUpdateResource",
2670
+ deleteResource: "servicesDeleteResource",
2671
+ createBookingAdmin: "servicesCreateBooking",
2672
+ getBookings: "servicesGetBookings",
2673
+ getBookingAdmin: "servicesGetBooking",
2674
+ updateBookingStatus: "servicesUpdateBookingStatus",
2675
+ completeBooking: "servicesCompleteBooking",
2676
+ createShift: "servicesCreateShift",
2677
+ getStaffShifts: "servicesGetStaffShifts",
2678
+ addBreak: "servicesAddBreak",
2679
+ registerCustomerApp: "servicesRegisterCustomerApp",
2680
+ getServiceUtilization: "servicesGetUtilization",
2681
+ getServicePerformance: "servicesGetPerformance",
2682
+ getServiceFunnel: "servicesGetFunnel"
2683
+ };
2547
2684
  var adminMapping = {
2548
2685
  getStats: "adminControllerGetStats",
2549
2686
  listOrganizations: "adminControllerListOrganizations",
@@ -2631,8 +2768,10 @@ function getJwtExpiry(token) {
2631
2768
  return null;
2632
2769
  }
2633
2770
 
2634
- // src/client.ts
2771
+ // src/client.tsx
2772
+ import { createContext, useContext, useEffect, useState } from "react";
2635
2773
  import axios2 from "axios";
2774
+ import { jsx } from "react/jsx-runtime";
2636
2775
  var InMemoryStorage = class {
2637
2776
  constructor() {
2638
2777
  this.cache = /* @__PURE__ */ new Map();
@@ -2652,11 +2791,17 @@ var SCRYME_USER_KEY = "scryme_user";
2652
2791
  var SCRYME_EXPIRES_AT_KEY = "scryme_expires_at";
2653
2792
  var ScrymeClientSDK = class {
2654
2793
  constructor(config) {
2655
- if (!config || !config.clientId || !config.clientSecret || !config.orgSlug) {
2656
- throw new Error("clientId, clientSecret, and orgSlug are required to initialize the SDK.");
2794
+ if (!config || !config.clientId || !config.orgSlug) {
2795
+ throw new Error(
2796
+ "clientId and orgSlug are required to initialize the SDK."
2797
+ );
2798
+ }
2799
+ let finalBaseURL = config.baseURL || "https://api.scryme.tech";
2800
+ if (finalBaseURL && !finalBaseURL.includes("/api") && !finalBaseURL.endsWith("/api")) {
2801
+ finalBaseURL = finalBaseURL.replace(/\/$/, "") + "/api";
2657
2802
  }
2658
2803
  this.axiosInstance = axios2.create({
2659
- baseURL: config.baseURL || "https://api.scryme.tech"
2804
+ baseURL: finalBaseURL
2660
2805
  });
2661
2806
  let storage;
2662
2807
  if (config.storage) {
@@ -2706,7 +2851,7 @@ var ScrymeClientSDK = class {
2706
2851
  try {
2707
2852
  state.user = JSON.parse(storedUser);
2708
2853
  } catch {
2709
- state.user = storedUser;
2854
+ state.user = null;
2710
2855
  }
2711
2856
  }
2712
2857
  notify("INITIAL_SESSION");
@@ -2724,7 +2869,7 @@ var ScrymeClientSDK = class {
2724
2869
  try {
2725
2870
  const response = await this.api.authExchangeToken({
2726
2871
  clientId: config.clientId,
2727
- clientSecret: config.clientSecret
2872
+ clientSecret: config.clientSecret || ""
2728
2873
  });
2729
2874
  const tokenData = response.data?.data;
2730
2875
  const accessToken = tokenData?.access_token;
@@ -2733,7 +2878,10 @@ var ScrymeClientSDK = class {
2733
2878
  state.token = accessToken;
2734
2879
  if (expiresIn) {
2735
2880
  state.expiresAt = Date.now() + expiresIn * 1e3;
2736
- await storage.setItem(SCRYME_EXPIRES_AT_KEY, String(state.expiresAt));
2881
+ await storage.setItem(
2882
+ SCRYME_EXPIRES_AT_KEY,
2883
+ String(state.expiresAt)
2884
+ );
2737
2885
  } else {
2738
2886
  const jwtExp = getJwtExpiry(accessToken);
2739
2887
  if (jwtExp) {
@@ -2755,14 +2903,28 @@ var ScrymeClientSDK = class {
2755
2903
  };
2756
2904
  this.axiosInstance.interceptors.request.use(async (req) => {
2757
2905
  await initPromise;
2758
- const isAuthTokenRequest = req.url && (req.url.endsWith("/auth/token") || req.url.includes("/auth/token"));
2906
+ const isAuthTokenRequest = req.url && (req.url.endsWith("/auth/token") || req.url.includes("/auth/token") || req.url.includes("/customers/auth/refresh") || req.url.includes("/customers/auth/swap-zitadel"));
2759
2907
  if (!isAuthTokenRequest) {
2760
- const isExpired = !state.token || state.expiresAt && Date.now() >= state.expiresAt - 3e4;
2761
- if (isExpired && config.clientId && config.clientSecret) {
2762
- try {
2763
- await performExchange();
2764
- } catch (e) {
2765
- console.error("Auto-authentication failed in request interceptor:", e);
2908
+ const isExpired = !state.token || state.expiresAt && Date.now() >= (state.expiresAt || 0) - 3e4;
2909
+ if (isExpired) {
2910
+ if (state.token) {
2911
+ try {
2912
+ await this.auth.refreshSession();
2913
+ } catch (e) {
2914
+ console.error(
2915
+ "Proactive customer session refresh failed in request interceptor:",
2916
+ e
2917
+ );
2918
+ }
2919
+ } else if (config.clientId && config.clientSecret) {
2920
+ try {
2921
+ await performExchange();
2922
+ } catch (e) {
2923
+ console.error(
2924
+ "Auto-authentication failed in request interceptor:",
2925
+ e
2926
+ );
2927
+ }
2766
2928
  }
2767
2929
  }
2768
2930
  }
@@ -2775,15 +2937,23 @@ var ScrymeClientSDK = class {
2775
2937
  (response) => response,
2776
2938
  async (error) => {
2777
2939
  const originalRequest = error.config;
2778
- const isAuthTokenRequest = originalRequest && originalRequest.url && (originalRequest.url.endsWith("/auth/token") || originalRequest.url.includes("/auth/token"));
2779
- if (error.response && error.response.status === 401 && originalRequest && !originalRequest._retry && !isAuthTokenRequest && config.clientId && config.clientSecret) {
2940
+ const isAuthTokenRequest = originalRequest && originalRequest.url && (originalRequest.url.endsWith("/auth/token") || originalRequest.url.includes("/auth/token") || originalRequest.url.includes("/customers/auth/refresh") || originalRequest.url.includes("/customers/auth/swap-zitadel"));
2941
+ if (error.response && error.response.status === 401 && originalRequest && !originalRequest._retry && !isAuthTokenRequest) {
2780
2942
  originalRequest._retry = true;
2781
2943
  try {
2782
- await performExchange();
2783
2944
  if (state.token) {
2784
- originalRequest.headers["Authorization"] = `Bearer ${state.token}`;
2945
+ await this.auth.refreshSession();
2946
+ if (state.token) {
2947
+ originalRequest.headers["Authorization"] = `Bearer ${state.token}`;
2948
+ }
2949
+ return this.axiosInstance(originalRequest);
2950
+ } else if (config.clientId && config.clientSecret) {
2951
+ await performExchange();
2952
+ if (state.token) {
2953
+ originalRequest.headers["Authorization"] = `Bearer ${state.token}`;
2954
+ }
2955
+ return this.axiosInstance(originalRequest);
2785
2956
  }
2786
- return this.axiosInstance(originalRequest);
2787
2957
  } catch (e) {
2788
2958
  return Promise.reject(error);
2789
2959
  }
@@ -2801,6 +2971,149 @@ var ScrymeClientSDK = class {
2801
2971
  this.loyalty = buildModule(this.api, config.orgSlug, loyaltyMapping);
2802
2972
  this.members = buildModule(this.api, config.orgSlug, membersMapping);
2803
2973
  this.admin = buildModule(this.api, config.orgSlug, adminMapping);
2974
+ this.cart = {
2975
+ get: async (params) => {
2976
+ return this.orders.getCart(params || {});
2977
+ },
2978
+ add: async (dto) => {
2979
+ return this.orders.addToCart(dto);
2980
+ },
2981
+ remove: async (dto) => {
2982
+ return this.orders.removeFromCart(dto);
2983
+ },
2984
+ clear: async (params) => {
2985
+ return this.orders.clearCart(params || {});
2986
+ },
2987
+ update: async (dto) => {
2988
+ const response = await this.orders.getCart({
2989
+ sessionId: dto.sessionId
2990
+ });
2991
+ const data = response.data;
2992
+ const items = data?.data?.items || data?.items || [];
2993
+ let existingItem = null;
2994
+ if (dto.productId) {
2995
+ existingItem = items.find(
2996
+ (item) => item.productId === dto.productId && (item.variantId || null) === (dto.variantId || null)
2997
+ );
2998
+ } else if (dto.serviceId) {
2999
+ existingItem = items.find(
3000
+ (item) => item.serviceId === dto.serviceId
3001
+ );
3002
+ }
3003
+ if (existingItem) {
3004
+ const currentQty = existingItem.quantity || 0;
3005
+ if (dto.quantity <= 0) {
3006
+ return this.orders.removeFromCart({
3007
+ productId: dto.productId,
3008
+ variantId: dto.variantId,
3009
+ serviceId: dto.serviceId,
3010
+ sessionId: dto.sessionId,
3011
+ customerId: dto.customerId
3012
+ });
3013
+ } else {
3014
+ const diff = dto.quantity - currentQty;
3015
+ if (diff !== 0) {
3016
+ return this.orders.addToCart({
3017
+ ...dto,
3018
+ quantity: diff
3019
+ });
3020
+ }
3021
+ return response;
3022
+ }
3023
+ } else {
3024
+ if (dto.quantity > 0) {
3025
+ return this.orders.addToCart(dto);
3026
+ }
3027
+ }
3028
+ },
3029
+ getItems: async (params) => {
3030
+ const res = await this.orders.getCart(params || {});
3031
+ const data = res?.data || res;
3032
+ return data?.items || data?.data?.items || [];
3033
+ },
3034
+ getTotals: async (params) => {
3035
+ const res = await this.orders.getCart(params || {});
3036
+ const data = res?.data || res;
3037
+ const items = data?.items || data?.data?.items || [];
3038
+ const itemsCount = items.reduce(
3039
+ (sum, item) => sum + (item.quantity || 0),
3040
+ 0
3041
+ );
3042
+ return {
3043
+ itemsCount,
3044
+ items,
3045
+ raw: data
3046
+ };
3047
+ },
3048
+ mergeGuestCart: async (guestSessionId, customerId) => {
3049
+ return this.orders.getCart({ sessionId: guestSessionId });
3050
+ },
3051
+ checkout: async (params) => {
3052
+ const session = await this.auth.getSession();
3053
+ const user = session.user;
3054
+ const customerId = user?.customerId || user?.id || user?.customer?.id;
3055
+ if (!customerId)
3056
+ throw new Error("No authenticated customer found for checkout.");
3057
+ const items = await this.cart.getItems();
3058
+ if (!items || items.length === 0) {
3059
+ throw new Error("Cannot checkout an empty cart.");
3060
+ }
3061
+ const orderItems = items.map((item) => ({
3062
+ variantId: item.variantId || "",
3063
+ quantity: item.quantity,
3064
+ unitPrice: item.unitPrice
3065
+ }));
3066
+ const orderResponse = await this.orders.createOrder({
3067
+ customerId,
3068
+ locationId: params.locationId,
3069
+ items: orderItems,
3070
+ notes: params.notes,
3071
+ channel: params.channel
3072
+ });
3073
+ await this.cart.clear();
3074
+ return orderResponse?.data || orderResponse;
3075
+ }
3076
+ };
3077
+ this.customer = {
3078
+ getProfile: async () => {
3079
+ return this.auth.getCurrentSession();
3080
+ },
3081
+ updateProfile: async (dto) => {
3082
+ const session = await this.auth.getSession();
3083
+ const user = session.user;
3084
+ const customerId = user?.customerId || user?.id || user?.customer?.id;
3085
+ if (!customerId) throw new Error("No authenticated customer found.");
3086
+ return this.admin.updateCustomer(customerId, dto);
3087
+ },
3088
+ getAddresses: async () => {
3089
+ const session = await this.auth.getSession();
3090
+ const user = session.user;
3091
+ const customerId = user?.customerId || user?.id || user?.customer?.id;
3092
+ if (!customerId) throw new Error("No authenticated customer found.");
3093
+ return this.admin.getCustomerAddresses(customerId);
3094
+ },
3095
+ addAddress: async (dto) => {
3096
+ const session = await this.auth.getSession();
3097
+ const user = session.user;
3098
+ const customerId = user?.customerId || user?.id || user?.customer?.id;
3099
+ if (!customerId) throw new Error("No authenticated customer found.");
3100
+ return this.admin.addCustomerAddress(customerId, dto);
3101
+ }
3102
+ };
3103
+ this.bookings = {
3104
+ create: async (dto) => {
3105
+ return this.catalog.createBooking(dto);
3106
+ },
3107
+ get: async (id) => {
3108
+ return this.catalog.getBooking(id);
3109
+ },
3110
+ list: async () => {
3111
+ return this.catalog.getBookings();
3112
+ },
3113
+ cancel: async (id) => {
3114
+ return this.catalog.updateBookingStatus(id, "CANCELLED");
3115
+ }
3116
+ };
2804
3117
  const baseAuth = buildModule(this.api, config.orgSlug, authMapping);
2805
3118
  this.auth = {
2806
3119
  ...baseAuth,
@@ -2811,10 +3124,45 @@ var ScrymeClientSDK = class {
2811
3124
  return performExchange();
2812
3125
  },
2813
3126
  signIn: async (credentials) => {
2814
- const response = await this.axiosInstance.post("/auth/sign-in/email", credentials);
2815
- const data = response.data;
2816
- const token = data?.session?.token || data?.token || null;
2817
- const user = data?.user || null;
3127
+ try {
3128
+ const authServiceUrl = process.env.CUSTOMER_AUTH_URL || `${this.axiosInstance.defaults.baseURL || "http://localhost:3002"}/api/customer-auth`;
3129
+ const postUrl = authServiceUrl.endsWith("/api/auth") ? `${authServiceUrl}/sign-in/email` : authServiceUrl.endsWith("/api/customer-auth") ? `${authServiceUrl}/sign-in/email` : `${authServiceUrl}/api/auth/sign-in/email`;
3130
+ const response2 = await axios2.post(postUrl, credentials);
3131
+ const data2 = response2.data;
3132
+ const token2 = data2?.session?.token || data2?.token || null;
3133
+ const user2 = data2?.user || null;
3134
+ if (token2) {
3135
+ state.token = token2;
3136
+ state.user = user2;
3137
+ const jwtExp = getJwtExpiry(token2);
3138
+ await storage.setItem(SCRYME_SESSION_TOKEN_KEY, token2);
3139
+ if (jwtExp) {
3140
+ state.expiresAt = jwtExp;
3141
+ await storage.setItem(
3142
+ SCRYME_EXPIRES_AT_KEY,
3143
+ String(state.expiresAt)
3144
+ );
3145
+ } else {
3146
+ delete state.expiresAt;
3147
+ await storage.removeItem(SCRYME_EXPIRES_AT_KEY);
3148
+ }
3149
+ if (user2) {
3150
+ await storage.setItem(SCRYME_USER_KEY, JSON.stringify(user2));
3151
+ }
3152
+ notify("SIGNED_IN");
3153
+ return data2;
3154
+ } else {
3155
+ throw new Error("No token returned");
3156
+ }
3157
+ } catch (e) {
3158
+ }
3159
+ const response = await this.axiosInstance.post(
3160
+ `/${config.orgSlug}/customers/auth/login`,
3161
+ credentials
3162
+ );
3163
+ const data = response.data?.data || response.data;
3164
+ const token = data?.token || null;
3165
+ const user = data?.session || null;
2818
3166
  if (token) {
2819
3167
  state.token = token;
2820
3168
  state.user = user;
@@ -2822,7 +3170,10 @@ var ScrymeClientSDK = class {
2822
3170
  await storage.setItem(SCRYME_SESSION_TOKEN_KEY, token);
2823
3171
  if (jwtExp) {
2824
3172
  state.expiresAt = jwtExp;
2825
- await storage.setItem(SCRYME_EXPIRES_AT_KEY, String(state.expiresAt));
3173
+ await storage.setItem(
3174
+ SCRYME_EXPIRES_AT_KEY,
3175
+ String(state.expiresAt)
3176
+ );
2826
3177
  } else {
2827
3178
  delete state.expiresAt;
2828
3179
  await storage.removeItem(SCRYME_EXPIRES_AT_KEY);
@@ -2865,6 +3216,88 @@ var ScrymeClientSDK = class {
2865
3216
  listeners.delete(callback);
2866
3217
  }
2867
3218
  };
3219
+ },
3220
+ getSessions: async () => {
3221
+ const res = await this.axiosInstance.get(
3222
+ `/${config.orgSlug}/customers/auth/sessions`
3223
+ );
3224
+ return res.data?.data || res.data;
3225
+ },
3226
+ revokeSession: async (id) => {
3227
+ const res = await this.axiosInstance.delete(
3228
+ `/${config.orgSlug}/customers/auth/sessions/${id}`
3229
+ );
3230
+ return res.data?.data || res.data;
3231
+ },
3232
+ revokeAllSessions: async (mode) => {
3233
+ const url = mode ? `/${config.orgSlug}/customers/auth/sessions?mode=${mode}` : `/${config.orgSlug}/customers/auth/sessions`;
3234
+ const res = await this.axiosInstance.delete(url);
3235
+ return res.data?.data || res.data;
3236
+ },
3237
+ getCurrentSession: async () => {
3238
+ const res = await this.axiosInstance.get(
3239
+ `/${config.orgSlug}/customers/auth/session`
3240
+ );
3241
+ return res.data?.data || res.data;
3242
+ },
3243
+ refreshSession: async () => {
3244
+ const response = await this.axiosInstance.post(
3245
+ `/${config.orgSlug}/customers/auth/refresh`
3246
+ );
3247
+ const data = response.data?.data || response.data;
3248
+ const token = data?.token || null;
3249
+ const user = data?.session || null;
3250
+ if (token) {
3251
+ state.token = token;
3252
+ state.user = user;
3253
+ const jwtExp = getJwtExpiry(token);
3254
+ await storage.setItem(SCRYME_SESSION_TOKEN_KEY, token);
3255
+ if (jwtExp) {
3256
+ state.expiresAt = jwtExp;
3257
+ await storage.setItem(
3258
+ SCRYME_EXPIRES_AT_KEY,
3259
+ String(state.expiresAt)
3260
+ );
3261
+ } else {
3262
+ delete state.expiresAt;
3263
+ await storage.removeItem(SCRYME_EXPIRES_AT_KEY);
3264
+ }
3265
+ if (user) {
3266
+ await storage.setItem(SCRYME_USER_KEY, JSON.stringify(user));
3267
+ }
3268
+ notify("SIGNED_IN");
3269
+ }
3270
+ return data;
3271
+ },
3272
+ swapZitadel: async (zitadelToken) => {
3273
+ const response = await this.axiosInstance.post(
3274
+ `/${config.orgSlug}/customers/auth/swap-zitadel`,
3275
+ { zitadelToken }
3276
+ );
3277
+ const data = response.data?.data || response.data;
3278
+ const token = data?.token || null;
3279
+ const user = data?.session || null;
3280
+ if (token) {
3281
+ state.token = token;
3282
+ state.user = user;
3283
+ const jwtExp = getJwtExpiry(token);
3284
+ await storage.setItem(SCRYME_SESSION_TOKEN_KEY, token);
3285
+ if (jwtExp) {
3286
+ state.expiresAt = jwtExp;
3287
+ await storage.setItem(
3288
+ SCRYME_EXPIRES_AT_KEY,
3289
+ String(state.expiresAt)
3290
+ );
3291
+ } else {
3292
+ delete state.expiresAt;
3293
+ await storage.removeItem(SCRYME_EXPIRES_AT_KEY);
3294
+ }
3295
+ if (user) {
3296
+ await storage.setItem(SCRYME_USER_KEY, JSON.stringify(user));
3297
+ }
3298
+ notify("SIGNED_IN");
3299
+ }
3300
+ return data;
2868
3301
  }
2869
3302
  };
2870
3303
  }
@@ -2878,6 +3311,199 @@ function createClientSDK(config = {}) {
2878
3311
  };
2879
3312
  return new ScrymeClientSDK(finalConfig);
2880
3313
  }
3314
+ var AuthContext = createContext(void 0);
3315
+ var ScrymeAuthProvider = ({
3316
+ sdk,
3317
+ children
3318
+ }) => {
3319
+ const [session, setSession] = useState({
3320
+ token: null,
3321
+ user: null
3322
+ });
3323
+ const [isLoading, setIsLoading] = useState(true);
3324
+ const [cart, setCart] = useState(null);
3325
+ const [cartLoading, setCartLoading] = useState(false);
3326
+ const [customerProfile, setCustomerProfile] = useState(null);
3327
+ const [customerAddresses, setCustomerAddresses] = useState([]);
3328
+ const [bookingsList, setBookingsList] = useState([]);
3329
+ const [bookingsLoading, setBookingsLoading] = useState(false);
3330
+ useEffect(() => {
3331
+ const { unsubscribe } = sdk.auth.onAuthStateChange((event, newSession) => {
3332
+ setSession(newSession);
3333
+ setIsLoading(false);
3334
+ });
3335
+ return () => unsubscribe();
3336
+ }, [sdk]);
3337
+ const refreshCart = async () => {
3338
+ if (!session.token) {
3339
+ setCart(null);
3340
+ return;
3341
+ }
3342
+ setCartLoading(true);
3343
+ try {
3344
+ const res = await sdk.cart.get();
3345
+ setCart(res.data?.data || res.data || null);
3346
+ } catch (err) {
3347
+ console.error("Failed to fetch cart:", err);
3348
+ } finally {
3349
+ setCartLoading(false);
3350
+ }
3351
+ };
3352
+ const refreshProfile = async () => {
3353
+ if (!session.token) {
3354
+ setCustomerProfile(null);
3355
+ setCustomerAddresses([]);
3356
+ return;
3357
+ }
3358
+ try {
3359
+ const profile = await sdk.customer.getProfile();
3360
+ setCustomerProfile(profile || null);
3361
+ const addresses = await sdk.customer.getAddresses();
3362
+ setCustomerAddresses(addresses?.data || addresses || []);
3363
+ } catch (err) {
3364
+ console.error("Failed to fetch customer profile or addresses:", err);
3365
+ }
3366
+ };
3367
+ const refreshBookings = async () => {
3368
+ if (!session.token) {
3369
+ setBookingsList([]);
3370
+ return;
3371
+ }
3372
+ setBookingsLoading(true);
3373
+ try {
3374
+ const res = await sdk.bookings.list();
3375
+ setBookingsList(res?.data || res || []);
3376
+ } catch (err) {
3377
+ console.error("Failed to fetch bookings:", err);
3378
+ } finally {
3379
+ setBookingsLoading(false);
3380
+ }
3381
+ };
3382
+ useEffect(() => {
3383
+ if (session.token) {
3384
+ refreshCart();
3385
+ refreshProfile();
3386
+ refreshBookings();
3387
+ } else {
3388
+ setCart(null);
3389
+ setCustomerProfile(null);
3390
+ setCustomerAddresses([]);
3391
+ setBookingsList([]);
3392
+ }
3393
+ }, [session.token]);
3394
+ const signIn = async (credentials) => {
3395
+ const res = await sdk.auth.signIn(credentials);
3396
+ return res;
3397
+ };
3398
+ const signUp = async (dto) => {
3399
+ const res = await sdk.auth.signUp(dto);
3400
+ return res;
3401
+ };
3402
+ const signOut = async () => {
3403
+ await sdk.auth.signOut();
3404
+ };
3405
+ const addToCart = async (dto) => {
3406
+ if (!session.token)
3407
+ throw new Error("Customer must be logged in to manage cart");
3408
+ await sdk.cart.add(dto);
3409
+ await refreshCart();
3410
+ };
3411
+ const removeFromCart = async (dto) => {
3412
+ if (!session.token)
3413
+ throw new Error("Customer must be logged in to manage cart");
3414
+ await sdk.cart.remove(dto);
3415
+ await refreshCart();
3416
+ };
3417
+ const updateCartItem = async (dto) => {
3418
+ if (!session.token)
3419
+ throw new Error("Customer must be logged in to manage cart");
3420
+ await sdk.cart.update(dto);
3421
+ await refreshCart();
3422
+ };
3423
+ const clearCart = async (params) => {
3424
+ if (!session.token)
3425
+ throw new Error("Customer must be logged in to manage cart");
3426
+ await sdk.cart.clear(params);
3427
+ await refreshCart();
3428
+ };
3429
+ const addAddress = async (dto) => {
3430
+ if (!session.token)
3431
+ throw new Error("Customer must be logged in to manage addresses");
3432
+ const res = await sdk.customer.addAddress(dto);
3433
+ await refreshProfile();
3434
+ return res;
3435
+ };
3436
+ const updateProfile = async (dto) => {
3437
+ if (!session.token)
3438
+ throw new Error("Customer must be logged in to update profile");
3439
+ const res = await sdk.customer.updateProfile(dto);
3440
+ await refreshProfile();
3441
+ return res;
3442
+ };
3443
+ const createBooking = async (dto) => {
3444
+ if (!session.token)
3445
+ throw new Error("Customer must be logged in to create bookings");
3446
+ const res = await sdk.bookings.create(dto);
3447
+ await refreshBookings();
3448
+ return res;
3449
+ };
3450
+ const cancelBooking = async (id) => {
3451
+ if (!session.token)
3452
+ throw new Error("Customer must be logged in to cancel bookings");
3453
+ const res = await sdk.bookings.cancel(id);
3454
+ await refreshBookings();
3455
+ return res;
3456
+ };
3457
+ const checkoutCart = async (params) => {
3458
+ if (!session.token)
3459
+ throw new Error("Customer must be logged in to checkout");
3460
+ const res = await sdk.cart.checkout(params);
3461
+ await refreshCart();
3462
+ await refreshBookings();
3463
+ return res;
3464
+ };
3465
+ return /* @__PURE__ */ jsx(
3466
+ AuthContext.Provider,
3467
+ {
3468
+ value: {
3469
+ sdk,
3470
+ session,
3471
+ user: session.user,
3472
+ token: session.token,
3473
+ isLoading,
3474
+ signIn,
3475
+ signUp,
3476
+ signOut,
3477
+ cart,
3478
+ cartLoading,
3479
+ addToCart,
3480
+ removeFromCart,
3481
+ updateCartItem,
3482
+ clearCart,
3483
+ refreshCart,
3484
+ customerProfile,
3485
+ customerAddresses,
3486
+ bookings: bookingsList,
3487
+ bookingsLoading,
3488
+ addAddress,
3489
+ updateProfile,
3490
+ createBooking,
3491
+ cancelBooking,
3492
+ checkoutCart,
3493
+ refreshProfile,
3494
+ refreshBookings
3495
+ },
3496
+ children
3497
+ }
3498
+ );
3499
+ };
3500
+ var useScrymeAuth = () => {
3501
+ const context = useContext(AuthContext);
3502
+ if (context === void 0) {
3503
+ throw new Error("useScrymeAuth must be used within a ScrymeAuthProvider");
3504
+ }
3505
+ return context;
3506
+ };
2881
3507
 
2882
3508
  // src/index.ts
2883
3509
  function getEnvOrgSlug() {
@@ -2952,10 +3578,16 @@ var ScrymeServerSDK = class {
2952
3578
  this.expiresAt = null;
2953
3579
  this.activeAuthPromise = null;
2954
3580
  if (!config || !config.clientId || !config.clientSecret || !config.orgSlug) {
2955
- throw new Error("clientId, clientSecret, and orgSlug are required to initialize the SDK.");
3581
+ throw new Error(
3582
+ "clientId, clientSecret, and orgSlug are required to initialize the SDK."
3583
+ );
3584
+ }
3585
+ let finalBaseURL = config.baseURL || "https://api.scryme.tech";
3586
+ if (finalBaseURL && !finalBaseURL.includes("/api") && !finalBaseURL.endsWith("/api")) {
3587
+ finalBaseURL = finalBaseURL.replace(/\/$/, "") + "/api";
2956
3588
  }
2957
3589
  this.axiosInstance = axios3.create({
2958
- baseURL: config.baseURL || "https://api.scryme.tech"
3590
+ baseURL: finalBaseURL
2959
3591
  });
2960
3592
  if (config.token) {
2961
3593
  this.token = config.token;
@@ -2995,14 +3627,29 @@ var ScrymeServerSDK = class {
2995
3627
  return this.activeAuthPromise;
2996
3628
  };
2997
3629
  this.axiosInstance.interceptors.request.use(async (req) => {
2998
- const isAuthTokenRequest = req.url && (req.url.endsWith("/auth/token") || req.url.includes("/auth/token"));
3630
+ const isAuthTokenRequest = req.url && (req.url.endsWith("/auth/token") || req.url.includes("/auth/token") || req.url.includes("/customers/auth/refresh") || req.url.includes("/customers/auth/swap-zitadel"));
2999
3631
  if (!isAuthTokenRequest && !config.apiKey) {
3000
3632
  const isExpired = !this.token || this.expiresAt && Date.now() >= this.expiresAt - 3e4;
3001
- if (isExpired && config.clientId && config.clientSecret) {
3002
- try {
3003
- await performExchange();
3004
- } catch (e) {
3005
- console.error("Auto-authentication failed in request interceptor:", e);
3633
+ if (isExpired) {
3634
+ const isCustomerToken = this.token && getJwtExpiry(this.token) && !config.clientSecret;
3635
+ if (isCustomerToken || this.token && !config.clientSecret) {
3636
+ try {
3637
+ await this.auth.refreshSession();
3638
+ } catch (e) {
3639
+ console.error(
3640
+ "Proactive customer session refresh failed in request interceptor:",
3641
+ e
3642
+ );
3643
+ }
3644
+ } else if (config.clientId && config.clientSecret) {
3645
+ try {
3646
+ await performExchange();
3647
+ } catch (e) {
3648
+ console.error(
3649
+ "Auto-authentication failed in request interceptor:",
3650
+ e
3651
+ );
3652
+ }
3006
3653
  }
3007
3654
  }
3008
3655
  }
@@ -3015,15 +3662,24 @@ var ScrymeServerSDK = class {
3015
3662
  (response) => response,
3016
3663
  async (error) => {
3017
3664
  const originalRequest = error.config;
3018
- const isAuthTokenRequest = originalRequest && originalRequest.url && (originalRequest.url.endsWith("/auth/token") || originalRequest.url.includes("/auth/token"));
3019
- if (error.response && error.response.status === 401 && originalRequest && !originalRequest._retry && !isAuthTokenRequest && !config.apiKey && config.clientId && config.clientSecret) {
3665
+ const isAuthTokenRequest = originalRequest && originalRequest.url && (originalRequest.url.endsWith("/auth/token") || originalRequest.url.includes("/auth/token") || originalRequest.url.includes("/customers/auth/refresh") || originalRequest.url.includes("/customers/auth/swap-zitadel"));
3666
+ if (error.response && error.response.status === 401 && originalRequest && !originalRequest._retry && !isAuthTokenRequest && !config.apiKey) {
3020
3667
  originalRequest._retry = true;
3021
3668
  try {
3022
- await performExchange();
3023
- if (this.token) {
3024
- originalRequest.headers["Authorization"] = `Bearer ${this.token}`;
3669
+ const isCustomerToken = this.token && getJwtExpiry(this.token) && !config.clientSecret;
3670
+ if (isCustomerToken || this.token && !config.clientSecret) {
3671
+ await this.auth.refreshSession();
3672
+ if (this.token) {
3673
+ originalRequest.headers["Authorization"] = `Bearer ${this.token}`;
3674
+ }
3675
+ return this.axiosInstance(originalRequest);
3676
+ } else if (config.clientId && config.clientSecret) {
3677
+ await performExchange();
3678
+ if (this.token) {
3679
+ originalRequest.headers["Authorization"] = `Bearer ${this.token}`;
3680
+ }
3681
+ return this.axiosInstance(originalRequest);
3025
3682
  }
3026
- return this.axiosInstance(originalRequest);
3027
3683
  } catch (e) {
3028
3684
  return Promise.reject(error);
3029
3685
  }
@@ -3041,6 +3697,141 @@ var ScrymeServerSDK = class {
3041
3697
  this.loyalty = buildModule(this.api, config.orgSlug, loyaltyMapping);
3042
3698
  this.members = buildModule(this.api, config.orgSlug, membersMapping);
3043
3699
  this.admin = buildModule(this.api, config.orgSlug, adminMapping);
3700
+ this.services = buildModule(this.api, config.orgSlug, servicesMapping);
3701
+ this.cart = {
3702
+ get: async (params) => {
3703
+ return this.orders.getCart(params || {});
3704
+ },
3705
+ add: async (dto) => {
3706
+ return this.orders.addToCart(dto);
3707
+ },
3708
+ remove: async (dto) => {
3709
+ return this.orders.removeFromCart(dto);
3710
+ },
3711
+ clear: async (params) => {
3712
+ return this.orders.clearCart(params || {});
3713
+ },
3714
+ update: async (dto) => {
3715
+ const response = await this.orders.getCart({
3716
+ sessionId: dto.sessionId
3717
+ });
3718
+ const data = response.data;
3719
+ const items = data?.data?.items || data?.items || [];
3720
+ let existingItem = null;
3721
+ if (dto.productId) {
3722
+ existingItem = items.find(
3723
+ (item) => item.productId === dto.productId && (item.variantId || null) === (dto.variantId || null)
3724
+ );
3725
+ } else if (dto.serviceId) {
3726
+ existingItem = items.find(
3727
+ (item) => item.serviceId === dto.serviceId
3728
+ );
3729
+ }
3730
+ if (existingItem) {
3731
+ const currentQty = existingItem.quantity || 0;
3732
+ if (dto.quantity <= 0) {
3733
+ return this.orders.removeFromCart({
3734
+ productId: dto.productId,
3735
+ variantId: dto.variantId,
3736
+ serviceId: dto.serviceId,
3737
+ sessionId: dto.sessionId,
3738
+ customerId: dto.customerId
3739
+ });
3740
+ } else {
3741
+ const diff = dto.quantity - currentQty;
3742
+ if (diff !== 0) {
3743
+ return this.orders.addToCart({
3744
+ ...dto,
3745
+ quantity: diff
3746
+ });
3747
+ }
3748
+ return response;
3749
+ }
3750
+ } else {
3751
+ if (dto.quantity > 0) {
3752
+ return this.orders.addToCart(dto);
3753
+ }
3754
+ }
3755
+ },
3756
+ getItems: async (params) => {
3757
+ const res = await this.orders.getCart(params || {});
3758
+ const data = res?.data || res;
3759
+ return data?.items || data?.data?.items || [];
3760
+ },
3761
+ getTotals: async (params) => {
3762
+ const res = await this.orders.getCart(params || {});
3763
+ const data = res?.data || res;
3764
+ const items = data?.items || data?.data?.items || [];
3765
+ const itemsCount = items.reduce(
3766
+ (sum, item) => sum + (item.quantity || 0),
3767
+ 0
3768
+ );
3769
+ return {
3770
+ itemsCount,
3771
+ items,
3772
+ raw: data
3773
+ };
3774
+ },
3775
+ checkout: async (params) => {
3776
+ if (!params.customerId)
3777
+ throw new Error("customerId is required for server checkout.");
3778
+ const items = await this.cart.getItems({
3779
+ sessionId: params.sessionId,
3780
+ customerId: params.customerId
3781
+ });
3782
+ if (!items || items.length === 0) {
3783
+ throw new Error("Cannot checkout an empty cart.");
3784
+ }
3785
+ const orderItems = items.map((item) => ({
3786
+ variantId: item.variantId || "",
3787
+ quantity: item.quantity,
3788
+ unitPrice: item.unitPrice
3789
+ }));
3790
+ const orderResponse = await this.orders.createOrder({
3791
+ customerId: params.customerId,
3792
+ locationId: params.locationId,
3793
+ items: orderItems,
3794
+ notes: params.notes,
3795
+ channel: params.channel
3796
+ });
3797
+ await this.cart.clear({
3798
+ sessionId: params.sessionId || "",
3799
+ customerId: params.customerId
3800
+ });
3801
+ return orderResponse?.data || orderResponse;
3802
+ }
3803
+ };
3804
+ this.customer = {
3805
+ getProfile: async (customerId) => {
3806
+ return this.admin.getCustomerById(customerId);
3807
+ },
3808
+ updateProfile: async (customerId, dto) => {
3809
+ return this.admin.updateCustomer(customerId, dto);
3810
+ },
3811
+ getAddresses: async (customerId) => {
3812
+ return this.admin.getCustomerAddresses(customerId);
3813
+ },
3814
+ addAddress: async (customerId, dto) => {
3815
+ return this.admin.addCustomerAddress(customerId, dto);
3816
+ }
3817
+ };
3818
+ this.bookings = {
3819
+ create: async (dto) => {
3820
+ return this.catalog.createBooking(dto);
3821
+ },
3822
+ get: async (id) => {
3823
+ return this.catalog.getBooking(id);
3824
+ },
3825
+ list: async () => {
3826
+ return this.catalog.getBookings();
3827
+ },
3828
+ cancel: async (id) => {
3829
+ return this.catalog.updateBookingStatus(id, "CANCELLED");
3830
+ },
3831
+ complete: async (id, dto) => {
3832
+ return this.catalog.completeBooking(id, dto);
3833
+ }
3834
+ };
3044
3835
  const baseAuth = buildModule(this.api, config.orgSlug, authMapping);
3045
3836
  this.auth = {
3046
3837
  ...baseAuth,
@@ -3051,7 +3842,10 @@ var ScrymeServerSDK = class {
3051
3842
  return performExchange();
3052
3843
  },
3053
3844
  signIn: async (credentials) => {
3054
- const response = await this.axiosInstance.post("/auth/sign-in/email", credentials);
3845
+ const response = await this.axiosInstance.post(
3846
+ "/auth/sign-in/email",
3847
+ credentials
3848
+ );
3055
3849
  const data = response.data;
3056
3850
  const token = data?.session?.token || data?.token || null;
3057
3851
  if (token) {
@@ -3060,6 +3854,39 @@ var ScrymeServerSDK = class {
3060
3854
  this.axiosInstance.defaults.headers.common["Authorization"] = `Bearer ${token}`;
3061
3855
  }
3062
3856
  return data;
3857
+ },
3858
+ getCurrentSession: async () => {
3859
+ const response = await this.axiosInstance.get(
3860
+ `/${config.orgSlug}/customers/auth/session`
3861
+ );
3862
+ return response.data?.data || response.data;
3863
+ },
3864
+ refreshSession: async () => {
3865
+ const response = await this.axiosInstance.post(
3866
+ `/${config.orgSlug}/customers/auth/refresh`
3867
+ );
3868
+ const data = response.data?.data || response.data;
3869
+ const token = data?.token || null;
3870
+ if (token) {
3871
+ this.token = token;
3872
+ this.expiresAt = getJwtExpiry(token);
3873
+ this.axiosInstance.defaults.headers.common["Authorization"] = `Bearer ${token}`;
3874
+ }
3875
+ return data;
3876
+ },
3877
+ swapZitadel: async (zitadelToken) => {
3878
+ const response = await this.axiosInstance.post(
3879
+ `/${config.orgSlug}/customers/auth/swap-zitadel`,
3880
+ { zitadelToken }
3881
+ );
3882
+ const data = response.data?.data || response.data;
3883
+ const token = data?.token || null;
3884
+ if (token) {
3885
+ this.token = token;
3886
+ this.expiresAt = getJwtExpiry(token);
3887
+ this.axiosInstance.defaults.headers.common["Authorization"] = `Bearer ${token}`;
3888
+ }
3889
+ return data;
3063
3890
  }
3064
3891
  };
3065
3892
  }
@@ -3132,6 +3959,8 @@ export {
3132
3959
  accountingMapping,
3133
3960
  loyaltyMapping,
3134
3961
  membersMapping,
3962
+ publicServicesMapping,
3963
+ servicesMapping,
3135
3964
  adminMapping,
3136
3965
  buildModule,
3137
3966
  getJwtExpiry,
@@ -3139,5 +3968,7 @@ export {
3139
3968
  createServerSDK,
3140
3969
  getScrymeV3API2 as getScrymeV3API,
3141
3970
  ScrymeClientSDK,
3142
- createClientSDK
3971
+ createClientSDK,
3972
+ ScrymeAuthProvider,
3973
+ useScrymeAuth
3143
3974
  };