@scryme/sdk 9.65.0 → 9.67.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.
@@ -614,6 +614,12 @@ var getScrymeV3API = (axiosInstance = axios) => {
614
614
  options
615
615
  );
616
616
  };
617
+ const catalogGetProduct = (orgSlug, idOrSlug, options) => {
618
+ return axiosInstance.get(
619
+ `/v3/${orgSlug}/catalog/products/${idOrSlug}`,
620
+ options
621
+ );
622
+ };
617
623
  const catalogGetServices = (orgSlug, params, options) => {
618
624
  return axiosInstance.get(
619
625
  `/v3/${orgSlug}/catalog/services`,
@@ -890,13 +896,6 @@ var getScrymeV3API = (axiosInstance = axios) => {
890
896
  options
891
897
  );
892
898
  };
893
- const customersProvisionZitadel = (orgSlug, provisionZitadelDto, options) => {
894
- return axiosInstance.post(
895
- `/v3/${orgSlug}/customers/zitadel/provision`,
896
- provisionZitadelDto,
897
- options
898
- );
899
- };
900
899
  const customersGetCustomers = (orgSlug, params, options) => {
901
900
  return axiosInstance.get(
902
901
  `/v3/${orgSlug}/customers`,
@@ -920,6 +919,13 @@ var getScrymeV3API = (axiosInstance = axios) => {
920
919
  options
921
920
  );
922
921
  };
922
+ const customersRefreshSession = (orgSlug, options) => {
923
+ return axiosInstance.post(
924
+ `/v3/${orgSlug}/customers/auth/refresh`,
925
+ void 0,
926
+ options
927
+ );
928
+ };
923
929
  const customersGetCurrentSession = (orgSlug, options) => {
924
930
  return axiosInstance.get(
925
931
  `/v3/${orgSlug}/customers/auth/session`,
@@ -1858,7 +1864,7 @@ var getScrymeV3API = (axiosInstance = axios) => {
1858
1864
  }
1859
1865
  );
1860
1866
  };
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 };
1867
+ 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, catalogGetProduct, 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, customersGetCustomers, customersRegister, customersLogin, customersRefreshSession, 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 };
1862
1868
  };
1863
1869
 
1864
1870
  // src/generated/model/addDepartmentMemberDtoRole.ts
@@ -2308,6 +2314,7 @@ var methodsWithOrgSlugSet = /* @__PURE__ */ new Set([
2308
2314
  "webhooksList",
2309
2315
  "webhooksDelete",
2310
2316
  "catalogGetProducts",
2317
+ "catalogGetProduct",
2311
2318
  "catalogCreateProduct",
2312
2319
  "catalogGetServices",
2313
2320
  "catalogUpdateProduct",
@@ -2341,7 +2348,6 @@ var methodsWithOrgSlugSet = /* @__PURE__ */ new Set([
2341
2348
  "servicesGetUtilization",
2342
2349
  "servicesGetPerformance",
2343
2350
  "servicesGetFunnel",
2344
- "customersProvisionZitadel",
2345
2351
  "customersGetCustomers",
2346
2352
  "customersRegister",
2347
2353
  "customersUpdate",
@@ -2350,6 +2356,10 @@ var methodsWithOrgSlugSet = /* @__PURE__ */ new Set([
2350
2356
  "customersGetAddresses",
2351
2357
  "customersAddAddress",
2352
2358
  "customersGetCurrentSession",
2359
+ "customersGetSessions",
2360
+ "customersRevokeSession",
2361
+ "customersRevokeAllSessions",
2362
+ "customersRefreshSession",
2353
2363
  "businessAccountControllerCreate",
2354
2364
  "businessAccountControllerGetOne",
2355
2365
  "crmControllerCreateRecord",
@@ -2418,6 +2428,7 @@ var methodsWithOrgSlugSet = /* @__PURE__ */ new Set([
2418
2428
  ]);
2419
2429
  var catalogMapping = {
2420
2430
  getProducts: "catalogGetProducts",
2431
+ getProduct: "catalogGetProduct",
2421
2432
  createProduct: "catalogCreateProduct",
2422
2433
  getServices: "catalogGetServices",
2423
2434
  updateProduct: "catalogUpdateProduct",
@@ -2716,7 +2727,6 @@ var adminMapping = {
2716
2727
  handleWindmillApprovalCallback: "windmillCallbackControllerHandleApprovalCallback",
2717
2728
  handleWindmillBakeryDisposalCallback: "windmillCallbackControllerHandleBakeryDisposalCallback",
2718
2729
  handleWindmillOutcomeCallback: "windmillCallbackControllerHandleOutcomeCallback",
2719
- provisionZitadel: "customersProvisionZitadel",
2720
2730
  getCustomers: "customersGetCustomers",
2721
2731
  registerCustomer: "customersRegister",
2722
2732
  updateCustomer: "customersUpdate",
@@ -2769,9 +2779,7 @@ function getJwtExpiry(token) {
2769
2779
  }
2770
2780
 
2771
2781
  // src/client.tsx
2772
- import { createContext, useContext, useEffect, useState } from "react";
2773
2782
  import axios2 from "axios";
2774
- import { jsx } from "react/jsx-runtime";
2775
2783
  var InMemoryStorage = class {
2776
2784
  constructor() {
2777
2785
  this.cache = /* @__PURE__ */ new Map();
@@ -2790,6 +2798,10 @@ var SCRYME_SESSION_TOKEN_KEY = "scryme_session_token";
2790
2798
  var SCRYME_USER_KEY = "scryme_user";
2791
2799
  var SCRYME_EXPIRES_AT_KEY = "scryme_expires_at";
2792
2800
  var ScrymeClientSDK = class {
2801
+ /**
2802
+ * Initializes the ScrymeClientSDK.
2803
+ * @param config Application and organization configuration parameters.
2804
+ */
2793
2805
  constructor(config) {
2794
2806
  if (!config || !config.clientId || !config.orgSlug) {
2795
2807
  throw new Error(
@@ -2854,8 +2866,8 @@ var ScrymeClientSDK = class {
2854
2866
  state.user = null;
2855
2867
  }
2856
2868
  }
2857
- notify("INITIAL_SESSION");
2858
2869
  }
2870
+ notify("INITIAL_SESSION");
2859
2871
  } catch (e) {
2860
2872
  console.error("Failed to initialize Scryme Client SDK session:", e);
2861
2873
  }
@@ -2903,13 +2915,13 @@ var ScrymeClientSDK = class {
2903
2915
  };
2904
2916
  this.axiosInstance.interceptors.request.use(async (req) => {
2905
2917
  await initPromise;
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"));
2918
+ const isAuthTokenRequest = req.url && (req.url.endsWith("/auth/token") || req.url.includes("/auth/token") || req.url.includes("/customers/auth/refresh"));
2907
2919
  if (!isAuthTokenRequest) {
2908
2920
  const isExpired = !state.token || state.expiresAt && Date.now() >= (state.expiresAt || 0) - 3e4;
2909
2921
  if (isExpired) {
2910
2922
  if (state.token) {
2911
2923
  try {
2912
- await this.auth.refreshSession();
2924
+ await this.customer.auth.refreshSession();
2913
2925
  } catch (e) {
2914
2926
  console.error(
2915
2927
  "Proactive customer session refresh failed in request interceptor:",
@@ -2937,12 +2949,12 @@ var ScrymeClientSDK = class {
2937
2949
  (response) => response,
2938
2950
  async (error) => {
2939
2951
  const originalRequest = error.config;
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"));
2952
+ const isAuthTokenRequest = originalRequest && originalRequest.url && (originalRequest.url.endsWith("/auth/token") || originalRequest.url.includes("/auth/token") || originalRequest.url.includes("/customers/auth/refresh"));
2941
2953
  if (error.response && error.response.status === 401 && originalRequest && !originalRequest._retry && !isAuthTokenRequest) {
2942
2954
  originalRequest._retry = true;
2943
2955
  try {
2944
2956
  if (state.token) {
2945
- await this.auth.refreshSession();
2957
+ await this.customer.auth.refreshSession();
2946
2958
  if (state.token) {
2947
2959
  originalRequest.headers["Authorization"] = `Bearer ${state.token}`;
2948
2960
  }
@@ -2962,7 +2974,54 @@ var ScrymeClientSDK = class {
2962
2974
  }
2963
2975
  );
2964
2976
  this.api = getScrymeV3API2(this.axiosInstance, config.orgSlug);
2965
- this.catalog = buildModule(this.api, config.orgSlug, catalogMapping);
2977
+ const baseCatalog = buildModule(this.api, config.orgSlug, catalogMapping);
2978
+ this.catalog = {
2979
+ ...baseCatalog,
2980
+ getProduct: async (idOrSlug, options) => {
2981
+ const response = await this.catalog.getProducts(void 0, options);
2982
+ const products = response.data || [];
2983
+ const product = products.find((p) => {
2984
+ if (typeof idOrSlug === "string") {
2985
+ return p.id === idOrSlug || p.slug === idOrSlug;
2986
+ } else {
2987
+ const { id, slug } = idOrSlug;
2988
+ if (id && p.id === id) return true;
2989
+ if (slug && p.slug === slug) return true;
2990
+ return false;
2991
+ }
2992
+ });
2993
+ if (!product) {
2994
+ const criteria = typeof idOrSlug === "string" ? idOrSlug : JSON.stringify(idOrSlug);
2995
+ throw new Error(`Product not found matching criteria: ${criteria}`);
2996
+ }
2997
+ return {
2998
+ ...response,
2999
+ data: product
3000
+ };
3001
+ },
3002
+ getService: async (idOrSlug, options) => {
3003
+ const response = await this.catalog.getServices(void 0, options);
3004
+ const services = response.data || [];
3005
+ const service = services.find((s) => {
3006
+ if (typeof idOrSlug === "string") {
3007
+ return s.id === idOrSlug || s.slug === idOrSlug;
3008
+ } else {
3009
+ const { id, slug } = idOrSlug;
3010
+ if (id && s.id === id) return true;
3011
+ if (slug && s.slug === slug) return true;
3012
+ return false;
3013
+ }
3014
+ });
3015
+ if (!service) {
3016
+ const criteria = typeof idOrSlug === "string" ? idOrSlug : JSON.stringify(idOrSlug);
3017
+ throw new Error(`Service not found matching criteria: ${criteria}`);
3018
+ }
3019
+ return {
3020
+ ...response,
3021
+ data: service
3022
+ };
3023
+ }
3024
+ };
2966
3025
  this.inventory = buildModule(this.api, config.orgSlug, inventoryMapping);
2967
3026
  this.orders = buildModule(this.api, config.orgSlug, ordersMapping);
2968
3027
  this.crm = buildModule(this.api, config.orgSlug, crmMapping);
@@ -2973,7 +3032,7 @@ var ScrymeClientSDK = class {
2973
3032
  this.admin = buildModule(this.api, config.orgSlug, adminMapping);
2974
3033
  this.cart = {
2975
3034
  get: async (params) => {
2976
- return this.orders.getCart(params || {});
3035
+ return this.orders.getCart(params);
2977
3036
  },
2978
3037
  add: async (dto) => {
2979
3038
  return this.orders.addToCart(dto);
@@ -2982,11 +3041,11 @@ var ScrymeClientSDK = class {
2982
3041
  return this.orders.removeFromCart(dto);
2983
3042
  },
2984
3043
  clear: async (params) => {
2985
- return this.orders.clearCart(params || {});
3044
+ return this.orders.clearCart(params);
2986
3045
  },
2987
3046
  update: async (dto) => {
2988
3047
  const response = await this.orders.getCart({
2989
- sessionId: dto.sessionId
3048
+ sessionId: dto.sessionId || ""
2990
3049
  });
2991
3050
  const data = response.data;
2992
3051
  const items = data?.data?.items || data?.items || [];
@@ -3007,7 +3066,7 @@ var ScrymeClientSDK = class {
3007
3066
  productId: dto.productId,
3008
3067
  variantId: dto.variantId,
3009
3068
  serviceId: dto.serviceId,
3010
- sessionId: dto.sessionId,
3069
+ sessionId: dto.sessionId || "",
3011
3070
  customerId: dto.customerId
3012
3071
  });
3013
3072
  } else {
@@ -3027,12 +3086,12 @@ var ScrymeClientSDK = class {
3027
3086
  }
3028
3087
  },
3029
3088
  getItems: async (params) => {
3030
- const res = await this.orders.getCart(params || {});
3089
+ const res = await this.orders.getCart(params);
3031
3090
  const data = res?.data || res;
3032
3091
  return data?.items || data?.data?.items || [];
3033
3092
  },
3034
3093
  getTotals: async (params) => {
3035
- const res = await this.orders.getCart(params || {});
3094
+ const res = await this.orders.getCart(params);
3036
3095
  const data = res?.data || res;
3037
3096
  const items = data?.items || data?.data?.items || [];
3038
3097
  const itemsCount = items.reduce(
@@ -3074,122 +3133,31 @@ var ScrymeClientSDK = class {
3074
3133
  return orderResponse?.data || orderResponse;
3075
3134
  }
3076
3135
  };
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
- };
3117
- const baseAuth = buildModule(this.api, config.orgSlug, authMapping);
3118
- this.auth = {
3119
- ...baseAuth,
3136
+ const customerAuth = {
3120
3137
  signUp: async (dto) => {
3121
3138
  return this.api.customersRegister(config.orgSlug, dto);
3122
3139
  },
3123
- authenticate: async () => {
3124
- return performExchange();
3125
- },
3126
3140
  signIn: async (credentials) => {
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;
3141
+ const res = await this.api.customersLogin(config.orgSlug, credentials);
3142
+ const authData = res.data;
3143
+ const token = authData?.accessToken || authData?.token;
3166
3144
  if (token) {
3167
3145
  state.token = token;
3168
- state.user = user;
3146
+ state.user = authData?.user || authData?.customer || authData?.session;
3169
3147
  const jwtExp = getJwtExpiry(token);
3148
+ if (jwtExp) state.expiresAt = jwtExp;
3170
3149
  await storage.setItem(SCRYME_SESSION_TOKEN_KEY, token);
3171
- if (jwtExp) {
3172
- state.expiresAt = jwtExp;
3173
- await storage.setItem(
3174
- SCRYME_EXPIRES_AT_KEY,
3175
- String(state.expiresAt)
3176
- );
3177
- } else {
3178
- delete state.expiresAt;
3179
- await storage.removeItem(SCRYME_EXPIRES_AT_KEY);
3150
+ if (state.user) {
3151
+ await storage.setItem(SCRYME_USER_KEY, JSON.stringify(state.user));
3180
3152
  }
3181
- if (user) {
3182
- await storage.setItem(SCRYME_USER_KEY, JSON.stringify(user));
3153
+ if (state.expiresAt) {
3154
+ await storage.setItem(SCRYME_EXPIRES_AT_KEY, String(state.expiresAt));
3183
3155
  }
3184
3156
  notify("SIGNED_IN");
3185
3157
  }
3186
- return data;
3158
+ return authData;
3187
3159
  },
3188
3160
  signOut: async () => {
3189
- try {
3190
- await this.axiosInstance.post("/auth/sign-out");
3191
- } catch {
3192
- }
3193
3161
  state.token = null;
3194
3162
  state.user = null;
3195
3163
  delete state.expiresAt;
@@ -3204,13 +3172,6 @@ var ScrymeClientSDK = class {
3204
3172
  },
3205
3173
  onAuthStateChange: (callback) => {
3206
3174
  listeners.add(callback);
3207
- initPromise.then(() => {
3208
- try {
3209
- callback("INITIAL_SESSION", { ...state });
3210
- } catch (e) {
3211
- console.error("Error in immediate auth state listener call:", e);
3212
- }
3213
- });
3214
3175
  return {
3215
3176
  unsubscribe: () => {
3216
3177
  listeners.delete(callback);
@@ -3218,86 +3179,89 @@ var ScrymeClientSDK = class {
3218
3179
  };
3219
3180
  },
3220
3181
  getSessions: async () => {
3221
- const res = await this.axiosInstance.get(
3222
- `/${config.orgSlug}/customers/auth/sessions`
3223
- );
3182
+ const res = await this.api.customersGetSessions(config.orgSlug);
3224
3183
  return res.data?.data || res.data;
3225
3184
  },
3226
3185
  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;
3186
+ return this.api.customersRevokeSession(config.orgSlug, id);
3231
3187
  },
3232
3188
  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;
3189
+ return this.api.customersRevokeAllSessions(config.orgSlug, { mode });
3236
3190
  },
3237
3191
  getCurrentSession: async () => {
3238
- const res = await this.axiosInstance.get(
3239
- `/${config.orgSlug}/customers/auth/session`
3240
- );
3192
+ const res = await this.api.customersGetCurrentSession(config.orgSlug);
3241
3193
  return res.data?.data || res.data;
3242
3194
  },
3243
3195
  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;
3196
+ const res = await this.api.customersRefreshSession(config.orgSlug);
3197
+ const authData = res.data;
3198
+ const token = authData?.accessToken || authData?.token;
3250
3199
  if (token) {
3251
3200
  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);
3201
+ if (authData?.user || authData?.customer) {
3202
+ state.user = authData.user || authData.customer;
3264
3203
  }
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
3204
  const jwtExp = getJwtExpiry(token);
3205
+ if (jwtExp) state.expiresAt = jwtExp;
3284
3206
  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);
3207
+ if (state.user) {
3208
+ await storage.setItem(SCRYME_USER_KEY, JSON.stringify(state.user));
3294
3209
  }
3295
- if (user) {
3296
- await storage.setItem(SCRYME_USER_KEY, JSON.stringify(user));
3210
+ if (state.expiresAt) {
3211
+ await storage.setItem(SCRYME_EXPIRES_AT_KEY, String(state.expiresAt));
3297
3212
  }
3298
3213
  notify("SIGNED_IN");
3299
3214
  }
3300
- return data;
3215
+ return authData;
3216
+ }
3217
+ };
3218
+ this.customer = {
3219
+ getProfile: async () => {
3220
+ return this.customer.auth.getCurrentSession();
3221
+ },
3222
+ updateProfile: async (dto) => {
3223
+ const session = await this.auth.getSession();
3224
+ const user = session.user;
3225
+ const customerId = user?.customerId || user?.id || user?.customer?.id;
3226
+ if (!customerId) throw new Error("No authenticated customer found.");
3227
+ return this.admin.updateCustomer(customerId, dto);
3228
+ },
3229
+ getAddresses: async () => {
3230
+ const session = await this.auth.getSession();
3231
+ const user = session.user;
3232
+ const customerId = user?.customerId || user?.id || user?.customer?.id;
3233
+ if (!customerId) throw new Error("No authenticated customer found.");
3234
+ return this.admin.getCustomerAddresses(customerId);
3235
+ },
3236
+ addAddress: async (dto) => {
3237
+ const session = await this.auth.getSession();
3238
+ const user = session.user;
3239
+ const customerId = user?.customerId || user?.id || user?.customer?.id;
3240
+ if (!customerId) throw new Error("No authenticated customer found.");
3241
+ return this.admin.addCustomerAddress(customerId, dto);
3242
+ },
3243
+ auth: customerAuth
3244
+ };
3245
+ const baseAuth = buildModule(this.api, config.orgSlug, authMapping);
3246
+ this.auth = {
3247
+ ...baseAuth,
3248
+ ...customerAuth,
3249
+ authenticate: async () => {
3250
+ return performExchange();
3251
+ }
3252
+ };
3253
+ this.bookings = {
3254
+ create: async (dto) => {
3255
+ return this.catalog.createBooking(dto);
3256
+ },
3257
+ get: async (id) => {
3258
+ return this.catalog.getBooking(id);
3259
+ },
3260
+ list: async () => {
3261
+ return this.catalog.getBookings();
3262
+ },
3263
+ cancel: async (id) => {
3264
+ return this.catalog.updateBookingStatus(id, "CANCELLED");
3301
3265
  }
3302
3266
  };
3303
3267
  }
@@ -3305,205 +3269,11 @@ var ScrymeClientSDK = class {
3305
3269
  function createClientSDK(config = {}) {
3306
3270
  const finalConfig = {
3307
3271
  clientId: config.clientId || "mock-client-id",
3308
- clientSecret: config.clientSecret || "mock-client-secret",
3309
3272
  orgSlug: config.orgSlug || "mock-org-slug",
3310
3273
  ...config
3311
3274
  };
3312
3275
  return new ScrymeClientSDK(finalConfig);
3313
3276
  }
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
- };
3507
3277
 
3508
3278
  // src/index.ts
3509
3279
  function getEnvOrgSlug() {
@@ -3627,7 +3397,7 @@ var ScrymeServerSDK = class {
3627
3397
  return this.activeAuthPromise;
3628
3398
  };
3629
3399
  this.axiosInstance.interceptors.request.use(async (req) => {
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"));
3400
+ const isAuthTokenRequest = req.url && (req.url.endsWith("/auth/token") || req.url.includes("/auth/token") || req.url.includes("/customers/auth/refresh"));
3631
3401
  if (!isAuthTokenRequest && !config.apiKey) {
3632
3402
  const isExpired = !this.token || this.expiresAt && Date.now() >= this.expiresAt - 3e4;
3633
3403
  if (isExpired) {
@@ -3662,7 +3432,7 @@ var ScrymeServerSDK = class {
3662
3432
  (response) => response,
3663
3433
  async (error) => {
3664
3434
  const originalRequest = error.config;
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"));
3435
+ const isAuthTokenRequest = originalRequest && originalRequest.url && (originalRequest.url.endsWith("/auth/token") || originalRequest.url.includes("/auth/token") || originalRequest.url.includes("/customers/auth/refresh"));
3666
3436
  if (error.response && error.response.status === 401 && originalRequest && !originalRequest._retry && !isAuthTokenRequest && !config.apiKey) {
3667
3437
  originalRequest._retry = true;
3668
3438
  try {
@@ -3688,7 +3458,54 @@ var ScrymeServerSDK = class {
3688
3458
  }
3689
3459
  );
3690
3460
  this.api = getScrymeV3API2(this.axiosInstance, config.orgSlug);
3691
- this.catalog = buildModule(this.api, config.orgSlug, catalogMapping);
3461
+ const baseCatalog = buildModule(this.api, config.orgSlug, catalogMapping);
3462
+ this.catalog = {
3463
+ ...baseCatalog,
3464
+ getProduct: async (idOrSlug, options) => {
3465
+ const response = await this.catalog.getProducts(void 0, options);
3466
+ const products = response.data || [];
3467
+ const product = products.find((p) => {
3468
+ if (typeof idOrSlug === "string") {
3469
+ return p.id === idOrSlug || p.slug === idOrSlug;
3470
+ } else {
3471
+ const { id, slug } = idOrSlug;
3472
+ if (id && p.id === id) return true;
3473
+ if (slug && p.slug === slug) return true;
3474
+ return false;
3475
+ }
3476
+ });
3477
+ if (!product) {
3478
+ const criteria = typeof idOrSlug === "string" ? idOrSlug : JSON.stringify(idOrSlug);
3479
+ throw new Error(`Product not found matching criteria: ${criteria}`);
3480
+ }
3481
+ return {
3482
+ ...response,
3483
+ data: product
3484
+ };
3485
+ },
3486
+ getService: async (idOrSlug, options) => {
3487
+ const response = await this.catalog.getServices(void 0, options);
3488
+ const services = response.data || [];
3489
+ const service = services.find((s) => {
3490
+ if (typeof idOrSlug === "string") {
3491
+ return s.id === idOrSlug || s.slug === idOrSlug;
3492
+ } else {
3493
+ const { id, slug } = idOrSlug;
3494
+ if (id && s.id === id) return true;
3495
+ if (slug && s.slug === slug) return true;
3496
+ return false;
3497
+ }
3498
+ });
3499
+ if (!service) {
3500
+ const criteria = typeof idOrSlug === "string" ? idOrSlug : JSON.stringify(idOrSlug);
3501
+ throw new Error(`Service not found matching criteria: ${criteria}`);
3502
+ }
3503
+ return {
3504
+ ...response,
3505
+ data: service
3506
+ };
3507
+ }
3508
+ };
3692
3509
  this.inventory = buildModule(this.api, config.orgSlug, inventoryMapping);
3693
3510
  this.orders = buildModule(this.api, config.orgSlug, ordersMapping);
3694
3511
  this.crm = buildModule(this.api, config.orgSlug, crmMapping);
@@ -3700,7 +3517,9 @@ var ScrymeServerSDK = class {
3700
3517
  this.services = buildModule(this.api, config.orgSlug, servicesMapping);
3701
3518
  this.cart = {
3702
3519
  get: async (params) => {
3703
- return this.orders.getCart(params || {});
3520
+ return this.orders.getCart(
3521
+ params
3522
+ );
3704
3523
  },
3705
3524
  add: async (dto) => {
3706
3525
  return this.orders.addToCart(dto);
@@ -3709,11 +3528,11 @@ var ScrymeServerSDK = class {
3709
3528
  return this.orders.removeFromCart(dto);
3710
3529
  },
3711
3530
  clear: async (params) => {
3712
- return this.orders.clearCart(params || {});
3531
+ return this.orders.clearCart(params);
3713
3532
  },
3714
3533
  update: async (dto) => {
3715
3534
  const response = await this.orders.getCart({
3716
- sessionId: dto.sessionId
3535
+ sessionId: dto.sessionId || ""
3717
3536
  });
3718
3537
  const data = response.data;
3719
3538
  const items = data?.data?.items || data?.items || [];
@@ -3734,7 +3553,7 @@ var ScrymeServerSDK = class {
3734
3553
  productId: dto.productId,
3735
3554
  variantId: dto.variantId,
3736
3555
  serviceId: dto.serviceId,
3737
- sessionId: dto.sessionId,
3556
+ sessionId: dto.sessionId || "",
3738
3557
  customerId: dto.customerId
3739
3558
  });
3740
3559
  } else {
@@ -3754,12 +3573,16 @@ var ScrymeServerSDK = class {
3754
3573
  }
3755
3574
  },
3756
3575
  getItems: async (params) => {
3757
- const res = await this.orders.getCart(params || {});
3576
+ const res = await this.orders.getCart(
3577
+ params
3578
+ );
3758
3579
  const data = res?.data || res;
3759
3580
  return data?.items || data?.data?.items || [];
3760
3581
  },
3761
3582
  getTotals: async (params) => {
3762
- const res = await this.orders.getCart(params || {});
3583
+ const res = await this.orders.getCart(
3584
+ params
3585
+ );
3763
3586
  const data = res?.data || res;
3764
3587
  const items = data?.items || data?.data?.items || [];
3765
3588
  const itemsCount = items.reduce(
@@ -3813,6 +3636,61 @@ var ScrymeServerSDK = class {
3813
3636
  },
3814
3637
  addAddress: async (customerId, dto) => {
3815
3638
  return this.admin.addCustomerAddress(customerId, dto);
3639
+ },
3640
+ auth: {
3641
+ signUp: async (dto) => {
3642
+ return this.api.customersRegister(config.orgSlug, dto);
3643
+ },
3644
+ signIn: async (credentials) => {
3645
+ const response = await this.axiosInstance.post(
3646
+ "/auth/sign-in/email",
3647
+ credentials
3648
+ );
3649
+ const data = response.data;
3650
+ const token = data?.session?.token || data?.token || null;
3651
+ if (token) {
3652
+ this.token = token;
3653
+ this.expiresAt = getJwtExpiry(token);
3654
+ this.axiosInstance.defaults.headers.common["Authorization"] = `Bearer ${token}`;
3655
+ }
3656
+ return data;
3657
+ },
3658
+ getCurrentSession: async (headers) => {
3659
+ const requestConfig = {};
3660
+ if (headers) {
3661
+ const requestHeaders = {};
3662
+ if (typeof headers.forEach === "function") {
3663
+ headers.forEach((value, key) => {
3664
+ requestHeaders[key] = value;
3665
+ });
3666
+ } else {
3667
+ for (const [key, value] of Object.entries(headers)) {
3668
+ if (value !== void 0) {
3669
+ requestHeaders[key] = Array.isArray(value) ? value.join(", ") : String(value);
3670
+ }
3671
+ }
3672
+ }
3673
+ requestConfig.headers = requestHeaders;
3674
+ }
3675
+ const response = await this.axiosInstance.get(
3676
+ `/${config.orgSlug}/customers/auth/session`,
3677
+ requestConfig
3678
+ );
3679
+ return response.data?.data || response.data;
3680
+ },
3681
+ refreshSession: async () => {
3682
+ const response = await this.axiosInstance.post(
3683
+ `/${config.orgSlug}/customers/auth/refresh`
3684
+ );
3685
+ const data = response.data?.data || response.data;
3686
+ const token = data?.token || null;
3687
+ if (token) {
3688
+ this.token = token;
3689
+ this.expiresAt = getJwtExpiry(token);
3690
+ this.axiosInstance.defaults.headers.common["Authorization"] = `Bearer ${token}`;
3691
+ }
3692
+ return data;
3693
+ }
3816
3694
  }
3817
3695
  };
3818
3696
  this.bookings = {
@@ -3835,58 +3713,21 @@ var ScrymeServerSDK = class {
3835
3713
  const baseAuth = buildModule(this.api, config.orgSlug, authMapping);
3836
3714
  this.auth = {
3837
3715
  ...baseAuth,
3838
- signUp: async (dto) => {
3839
- return this.api.customersRegister(config.orgSlug, dto);
3840
- },
3716
+ ...this.customer.auth,
3841
3717
  authenticate: async () => {
3842
3718
  return performExchange();
3843
3719
  },
3720
+ signUp: async (dto) => {
3721
+ return this.customer.auth.signUp(dto);
3722
+ },
3844
3723
  signIn: async (credentials) => {
3845
- const response = await this.axiosInstance.post(
3846
- "/auth/sign-in/email",
3847
- credentials
3848
- );
3849
- const data = response.data;
3850
- const token = data?.session?.token || data?.token || null;
3851
- if (token) {
3852
- this.token = token;
3853
- this.expiresAt = getJwtExpiry(token);
3854
- this.axiosInstance.defaults.headers.common["Authorization"] = `Bearer ${token}`;
3855
- }
3856
- return data;
3724
+ return this.customer.auth.signIn(credentials);
3857
3725
  },
3858
- getCurrentSession: async () => {
3859
- const response = await this.axiosInstance.get(
3860
- `/${config.orgSlug}/customers/auth/session`
3861
- );
3862
- return response.data?.data || response.data;
3726
+ getCurrentSession: async (headers) => {
3727
+ return this.customer.auth.getCurrentSession(headers);
3863
3728
  },
3864
3729
  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;
3730
+ return this.customer.auth.refreshSession();
3890
3731
  }
3891
3732
  };
3892
3733
  }
@@ -3968,7 +3809,5 @@ export {
3968
3809
  createServerSDK,
3969
3810
  getScrymeV3API2 as getScrymeV3API,
3970
3811
  ScrymeClientSDK,
3971
- createClientSDK,
3972
- ScrymeAuthProvider,
3973
- useScrymeAuth
3812
+ createClientSDK
3974
3813
  };