@scryme/sdk 9.66.0 → 9.68.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -64,7 +64,6 @@ __export(index_exports, {
64
64
  RegisterPettyCashDtoPaymentMethod: () => RegisterPettyCashDtoPaymentMethod,
65
65
  ReviewPriceChangeDtoStatus: () => ReviewPriceChangeDtoStatus,
66
66
  RoleManagementControllerGetCustomRolesSortOrder: () => RoleManagementControllerGetCustomRolesSortOrder,
67
- ScrymeAuthProvider: () => ScrymeAuthProvider,
68
67
  ScrymeClientSDK: () => ScrymeClientSDK,
69
68
  ScrymeServerSDK: () => ScrymeServerSDK,
70
69
  ServicesUpdateBookingStatusBodyStatus: () => ServicesUpdateBookingStatusBodyStatus,
@@ -97,8 +96,7 @@ __export(index_exports, {
97
96
  ordersMapping: () => ordersMapping,
98
97
  posMapping: () => posMapping,
99
98
  publicServicesMapping: () => publicServicesMapping,
100
- servicesMapping: () => servicesMapping,
101
- useScrymeAuth: () => useScrymeAuth
99
+ servicesMapping: () => servicesMapping
102
100
  });
103
101
  module.exports = __toCommonJS(index_exports);
104
102
 
@@ -715,6 +713,12 @@ var getScrymeV3API = (axiosInstance = import_axios.default) => {
715
713
  options
716
714
  );
717
715
  };
716
+ const catalogGetProduct = (orgSlug, idOrSlug, options) => {
717
+ return axiosInstance.get(
718
+ `/v3/${orgSlug}/catalog/products/${idOrSlug}`,
719
+ options
720
+ );
721
+ };
718
722
  const catalogGetServices = (orgSlug, params, options) => {
719
723
  return axiosInstance.get(
720
724
  `/v3/${orgSlug}/catalog/services`,
@@ -754,6 +758,29 @@ var getScrymeV3API = (axiosInstance = import_axios.default) => {
754
758
  options
755
759
  );
756
760
  };
761
+ const catalogCreateReview = (orgSlug, productId, createProductReviewDto, options) => {
762
+ return axiosInstance.post(
763
+ `/v3/${orgSlug}/catalog/products/${productId}/reviews`,
764
+ createProductReviewDto,
765
+ options
766
+ );
767
+ };
768
+ const catalogUpdateReview = (orgSlug, reviewId, updateProductReviewDto, options) => {
769
+ return axiosInstance.patch(
770
+ `/v3/${orgSlug}/catalog/reviews/${reviewId}`,
771
+ updateProductReviewDto,
772
+ options
773
+ );
774
+ };
775
+ const catalogDeleteReview = (orgSlug, reviewId, params, options) => {
776
+ return axiosInstance.delete(
777
+ `/v3/${orgSlug}/catalog/reviews/${reviewId}`,
778
+ {
779
+ ...options,
780
+ params: { ...params, ...options?.params }
781
+ }
782
+ );
783
+ };
757
784
  const servicesCreateCategory = (orgSlug, createServiceCategoryDto, options) => {
758
785
  return axiosInstance.post(
759
786
  `/v3/${orgSlug}/services/categories`,
@@ -991,13 +1018,6 @@ var getScrymeV3API = (axiosInstance = import_axios.default) => {
991
1018
  options
992
1019
  );
993
1020
  };
994
- const customersProvisionZitadel = (orgSlug, provisionZitadelDto, options) => {
995
- return axiosInstance.post(
996
- `/v3/${orgSlug}/customers/zitadel/provision`,
997
- provisionZitadelDto,
998
- options
999
- );
1000
- };
1001
1021
  const customersGetCustomers = (orgSlug, params, options) => {
1002
1022
  return axiosInstance.get(
1003
1023
  `/v3/${orgSlug}/customers`,
@@ -1014,6 +1034,13 @@ var getScrymeV3API = (axiosInstance = import_axios.default) => {
1014
1034
  options
1015
1035
  );
1016
1036
  };
1037
+ const customerRegister = (orgSlug, registerCustomerDto, options) => {
1038
+ return axiosInstance.post(
1039
+ `/v3/${orgSlug}/customers/../customer/register`,
1040
+ registerCustomerDto,
1041
+ options
1042
+ );
1043
+ };
1017
1044
  const customersLogin = (orgSlug, customerLoginDto, options) => {
1018
1045
  return axiosInstance.post(
1019
1046
  `/v3/${orgSlug}/customers/auth/login`,
@@ -1021,6 +1048,13 @@ var getScrymeV3API = (axiosInstance = import_axios.default) => {
1021
1048
  options
1022
1049
  );
1023
1050
  };
1051
+ const customersRefreshSession = (orgSlug, options) => {
1052
+ return axiosInstance.post(
1053
+ `/v3/${orgSlug}/customers/auth/refresh`,
1054
+ void 0,
1055
+ options
1056
+ );
1057
+ };
1024
1058
  const customersGetCurrentSession = (orgSlug, options) => {
1025
1059
  return axiosInstance.get(
1026
1060
  `/v3/${orgSlug}/customers/auth/session`,
@@ -1959,7 +1993,7 @@ var getScrymeV3API = (axiosInstance = import_axios.default) => {
1959
1993
  }
1960
1994
  );
1961
1995
  };
1962
- 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 };
1996
+ 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, catalogCreateReview, catalogUpdateReview, catalogDeleteReview, 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, customerRegister, 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 };
1963
1997
  };
1964
1998
 
1965
1999
  // src/generated/model/addDepartmentMemberDtoRole.ts
@@ -2409,12 +2443,16 @@ var methodsWithOrgSlugSet = /* @__PURE__ */ new Set([
2409
2443
  "webhooksList",
2410
2444
  "webhooksDelete",
2411
2445
  "catalogGetProducts",
2446
+ "catalogGetProduct",
2412
2447
  "catalogCreateProduct",
2413
2448
  "catalogGetServices",
2414
2449
  "catalogUpdateProduct",
2415
2450
  "catalogUpdateSupplierVariant",
2416
2451
  "catalogGetPriceChangeRequests",
2417
2452
  "catalogReviewPriceChangeRequest",
2453
+ "catalogCreateReview",
2454
+ "catalogUpdateReview",
2455
+ "catalogDeleteReview",
2418
2456
  "servicesCreateCategory",
2419
2457
  "servicesGetCategories",
2420
2458
  "servicesUpdateCategory",
@@ -2442,7 +2480,6 @@ var methodsWithOrgSlugSet = /* @__PURE__ */ new Set([
2442
2480
  "servicesGetUtilization",
2443
2481
  "servicesGetPerformance",
2444
2482
  "servicesGetFunnel",
2445
- "customersProvisionZitadel",
2446
2483
  "customersGetCustomers",
2447
2484
  "customersRegister",
2448
2485
  "customersUpdate",
@@ -2451,6 +2488,10 @@ var methodsWithOrgSlugSet = /* @__PURE__ */ new Set([
2451
2488
  "customersGetAddresses",
2452
2489
  "customersAddAddress",
2453
2490
  "customersGetCurrentSession",
2491
+ "customersGetSessions",
2492
+ "customersRevokeSession",
2493
+ "customersRevokeAllSessions",
2494
+ "customersRefreshSession",
2454
2495
  "businessAccountControllerCreate",
2455
2496
  "businessAccountControllerGetOne",
2456
2497
  "crmControllerCreateRecord",
@@ -2519,12 +2560,16 @@ var methodsWithOrgSlugSet = /* @__PURE__ */ new Set([
2519
2560
  ]);
2520
2561
  var catalogMapping = {
2521
2562
  getProducts: "catalogGetProducts",
2563
+ getProduct: "catalogGetProduct",
2522
2564
  createProduct: "catalogCreateProduct",
2523
2565
  getServices: "catalogGetServices",
2524
2566
  updateProduct: "catalogUpdateProduct",
2525
2567
  updateSupplierVariant: "catalogUpdateSupplierVariant",
2526
2568
  getPriceChangeRequests: "catalogGetPriceChangeRequests",
2527
2569
  reviewPriceChangeRequest: "catalogReviewPriceChangeRequest",
2570
+ createReview: "catalogCreateReview",
2571
+ updateReview: "catalogUpdateReview",
2572
+ deleteReview: "catalogDeleteReview",
2528
2573
  createServiceCategory: "servicesCreateCategory",
2529
2574
  getServiceCategories: "servicesGetCategories",
2530
2575
  updateServiceCategory: "servicesUpdateCategory",
@@ -2817,7 +2862,6 @@ var adminMapping = {
2817
2862
  handleWindmillApprovalCallback: "windmillCallbackControllerHandleApprovalCallback",
2818
2863
  handleWindmillBakeryDisposalCallback: "windmillCallbackControllerHandleBakeryDisposalCallback",
2819
2864
  handleWindmillOutcomeCallback: "windmillCallbackControllerHandleOutcomeCallback",
2820
- provisionZitadel: "customersProvisionZitadel",
2821
2865
  getCustomers: "customersGetCustomers",
2822
2866
  registerCustomer: "customersRegister",
2823
2867
  updateCustomer: "customersUpdate",
@@ -2872,7 +2916,6 @@ function getJwtExpiry(token) {
2872
2916
  // src/client.tsx
2873
2917
  var import_react = require("react");
2874
2918
  var import_axios2 = __toESM(require("axios"));
2875
- var import_jsx_runtime = require("react/jsx-runtime");
2876
2919
  var InMemoryStorage = class {
2877
2920
  constructor() {
2878
2921
  this.cache = /* @__PURE__ */ new Map();
@@ -2891,6 +2934,10 @@ var SCRYME_SESSION_TOKEN_KEY = "scryme_session_token";
2891
2934
  var SCRYME_USER_KEY = "scryme_user";
2892
2935
  var SCRYME_EXPIRES_AT_KEY = "scryme_expires_at";
2893
2936
  var ScrymeClientSDK = class {
2937
+ /**
2938
+ * Initializes the ScrymeClientSDK.
2939
+ * @param config Application and organization configuration parameters.
2940
+ */
2894
2941
  constructor(config) {
2895
2942
  if (!config || !config.clientId || !config.orgSlug) {
2896
2943
  throw new Error(
@@ -2955,8 +3002,8 @@ var ScrymeClientSDK = class {
2955
3002
  state.user = null;
2956
3003
  }
2957
3004
  }
2958
- notify("INITIAL_SESSION");
2959
3005
  }
3006
+ notify("INITIAL_SESSION");
2960
3007
  } catch (e) {
2961
3008
  console.error("Failed to initialize Scryme Client SDK session:", e);
2962
3009
  }
@@ -3004,13 +3051,13 @@ var ScrymeClientSDK = class {
3004
3051
  };
3005
3052
  this.axiosInstance.interceptors.request.use(async (req) => {
3006
3053
  await initPromise;
3007
- 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"));
3054
+ const isAuthTokenRequest = req.url && (req.url.endsWith("/auth/token") || req.url.includes("/auth/token") || req.url.includes("/customers/auth/refresh"));
3008
3055
  if (!isAuthTokenRequest) {
3009
3056
  const isExpired = !state.token || state.expiresAt && Date.now() >= (state.expiresAt || 0) - 3e4;
3010
3057
  if (isExpired) {
3011
3058
  if (state.token) {
3012
3059
  try {
3013
- await this.auth.refreshSession();
3060
+ await this.customer.auth.refreshSession();
3014
3061
  } catch (e) {
3015
3062
  console.error(
3016
3063
  "Proactive customer session refresh failed in request interceptor:",
@@ -3038,12 +3085,12 @@ var ScrymeClientSDK = class {
3038
3085
  (response) => response,
3039
3086
  async (error) => {
3040
3087
  const originalRequest = error.config;
3041
- 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"));
3088
+ const isAuthTokenRequest = originalRequest && originalRequest.url && (originalRequest.url.endsWith("/auth/token") || originalRequest.url.includes("/auth/token") || originalRequest.url.includes("/customers/auth/refresh"));
3042
3089
  if (error.response && error.response.status === 401 && originalRequest && !originalRequest._retry && !isAuthTokenRequest) {
3043
3090
  originalRequest._retry = true;
3044
3091
  try {
3045
3092
  if (state.token) {
3046
- await this.auth.refreshSession();
3093
+ await this.customer.auth.refreshSession();
3047
3094
  if (state.token) {
3048
3095
  originalRequest.headers["Authorization"] = `Bearer ${state.token}`;
3049
3096
  }
@@ -3063,7 +3110,87 @@ var ScrymeClientSDK = class {
3063
3110
  }
3064
3111
  );
3065
3112
  this.api = getScrymeV3API2(this.axiosInstance, config.orgSlug);
3066
- this.catalog = buildModule(this.api, config.orgSlug, catalogMapping);
3113
+ const baseCatalog = buildModule(this.api, config.orgSlug, catalogMapping);
3114
+ this.catalog = {
3115
+ ...baseCatalog,
3116
+ getProduct: async (idOrSlug, options) => {
3117
+ const response = await this.catalog.getProducts(void 0, options);
3118
+ const products = response.data || [];
3119
+ const product = products.find((p) => {
3120
+ if (typeof idOrSlug === "string") {
3121
+ return p.id === idOrSlug || p.slug === idOrSlug;
3122
+ } else {
3123
+ const { id, slug } = idOrSlug;
3124
+ if (id && p.id === id) return true;
3125
+ if (slug && p.slug === slug) return true;
3126
+ return false;
3127
+ }
3128
+ });
3129
+ if (!product) {
3130
+ const criteria = typeof idOrSlug === "string" ? idOrSlug : JSON.stringify(idOrSlug);
3131
+ throw new Error(`Product not found matching criteria: ${criteria}`);
3132
+ }
3133
+ return {
3134
+ ...response,
3135
+ data: product
3136
+ };
3137
+ },
3138
+ getService: async (idOrSlug, options) => {
3139
+ const response = await this.catalog.getServices(void 0, options);
3140
+ const services = response.data || [];
3141
+ const service = services.find((s) => {
3142
+ if (typeof idOrSlug === "string") {
3143
+ return s.id === idOrSlug || s.slug === idOrSlug;
3144
+ } else {
3145
+ const { id, slug } = idOrSlug;
3146
+ if (id && s.id === id) return true;
3147
+ if (slug && s.slug === slug) return true;
3148
+ return false;
3149
+ }
3150
+ });
3151
+ if (!service) {
3152
+ const criteria = typeof idOrSlug === "string" ? idOrSlug : JSON.stringify(idOrSlug);
3153
+ throw new Error(`Service not found matching criteria: ${criteria}`);
3154
+ }
3155
+ return {
3156
+ ...response,
3157
+ data: service
3158
+ };
3159
+ },
3160
+ createReview: async (productId, dto, options) => {
3161
+ if (!dto.customerId) {
3162
+ const session = await this.auth.getSession();
3163
+ const user = session?.user;
3164
+ const customerId = user?.customerId || user?.id || user?.customer?.id;
3165
+ if (customerId) {
3166
+ dto = { ...dto, customerId };
3167
+ }
3168
+ }
3169
+ return baseCatalog.createReview(productId, dto, options);
3170
+ },
3171
+ updateReview: async (reviewId, dto, options) => {
3172
+ if (!dto.customerId) {
3173
+ const session = await this.auth.getSession();
3174
+ const user = session?.user;
3175
+ const customerId = user?.customerId || user?.id || user?.customer?.id;
3176
+ if (customerId) {
3177
+ dto = { ...dto, customerId };
3178
+ }
3179
+ }
3180
+ return baseCatalog.updateReview(reviewId, dto, options);
3181
+ },
3182
+ deleteReview: async (reviewId, params, options) => {
3183
+ if (!params || !params.customerId) {
3184
+ const session = await this.auth.getSession();
3185
+ const user = session?.user;
3186
+ const customerId = user?.customerId || user?.id || user?.customer?.id;
3187
+ if (customerId) {
3188
+ params = { ...params, customerId };
3189
+ }
3190
+ }
3191
+ return baseCatalog.deleteReview(reviewId, params, options);
3192
+ }
3193
+ };
3067
3194
  this.inventory = buildModule(this.api, config.orgSlug, inventoryMapping);
3068
3195
  this.orders = buildModule(this.api, config.orgSlug, ordersMapping);
3069
3196
  this.crm = buildModule(this.api, config.orgSlug, crmMapping);
@@ -3074,20 +3201,47 @@ var ScrymeClientSDK = class {
3074
3201
  this.admin = buildModule(this.api, config.orgSlug, adminMapping);
3075
3202
  this.cart = {
3076
3203
  get: async (params) => {
3077
- return this.orders.getCart(params || {});
3204
+ return this.orders.getCart(params);
3078
3205
  },
3079
3206
  add: async (dto) => {
3207
+ if (!dto.customerId) {
3208
+ const session = await this.auth.getSession();
3209
+ const user = session?.user;
3210
+ const customerId = user?.customerId || user?.id || user?.customer?.id;
3211
+ if (!customerId) {
3212
+ throw new Error("Unauthorized: customerId is required.");
3213
+ }
3214
+ dto = { ...dto, customerId };
3215
+ }
3080
3216
  return this.orders.addToCart(dto);
3081
3217
  },
3082
3218
  remove: async (dto) => {
3219
+ if (!dto.customerId) {
3220
+ const session = await this.auth.getSession();
3221
+ const user = session?.user;
3222
+ const customerId = user?.customerId || user?.id || user?.customer?.id;
3223
+ if (!customerId) {
3224
+ throw new Error("Unauthorized: customerId is required.");
3225
+ }
3226
+ dto = { ...dto, customerId };
3227
+ }
3083
3228
  return this.orders.removeFromCart(dto);
3084
3229
  },
3085
3230
  clear: async (params) => {
3086
- return this.orders.clearCart(params || {});
3231
+ return this.orders.clearCart(params);
3087
3232
  },
3088
3233
  update: async (dto) => {
3234
+ if (!dto.customerId) {
3235
+ const session = await this.auth.getSession();
3236
+ const user = session?.user;
3237
+ const customerId = user?.customerId || user?.id || user?.customer?.id;
3238
+ if (!customerId) {
3239
+ throw new Error("Unauthorized: customerId is required.");
3240
+ }
3241
+ dto = { ...dto, customerId };
3242
+ }
3089
3243
  const response = await this.orders.getCart({
3090
- sessionId: dto.sessionId
3244
+ sessionId: dto.sessionId || ""
3091
3245
  });
3092
3246
  const data = response.data;
3093
3247
  const items = data?.data?.items || data?.items || [];
@@ -3108,7 +3262,7 @@ var ScrymeClientSDK = class {
3108
3262
  productId: dto.productId,
3109
3263
  variantId: dto.variantId,
3110
3264
  serviceId: dto.serviceId,
3111
- sessionId: dto.sessionId,
3265
+ sessionId: dto.sessionId || "",
3112
3266
  customerId: dto.customerId
3113
3267
  });
3114
3268
  } else {
@@ -3128,12 +3282,12 @@ var ScrymeClientSDK = class {
3128
3282
  }
3129
3283
  },
3130
3284
  getItems: async (params) => {
3131
- const res = await this.orders.getCart(params || {});
3285
+ const res = await this.orders.getCart(params);
3132
3286
  const data = res?.data || res;
3133
3287
  return data?.items || data?.data?.items || [];
3134
3288
  },
3135
3289
  getTotals: async (params) => {
3136
- const res = await this.orders.getCart(params || {});
3290
+ const res = await this.orders.getCart(params);
3137
3291
  const data = res?.data || res;
3138
3292
  const items = data?.items || data?.data?.items || [];
3139
3293
  const itemsCount = items.reduce(
@@ -3175,122 +3329,65 @@ var ScrymeClientSDK = class {
3175
3329
  return orderResponse?.data || orderResponse;
3176
3330
  }
3177
3331
  };
3178
- this.customer = {
3179
- getProfile: async () => {
3180
- return this.auth.getCurrentSession();
3181
- },
3182
- updateProfile: async (dto) => {
3183
- const session = await this.auth.getSession();
3184
- const user = session.user;
3185
- const customerId = user?.customerId || user?.id || user?.customer?.id;
3186
- if (!customerId) throw new Error("No authenticated customer found.");
3187
- return this.admin.updateCustomer(customerId, dto);
3188
- },
3189
- getAddresses: async () => {
3190
- const session = await this.auth.getSession();
3191
- const user = session.user;
3192
- const customerId = user?.customerId || user?.id || user?.customer?.id;
3193
- if (!customerId) throw new Error("No authenticated customer found.");
3194
- return this.admin.getCustomerAddresses(customerId);
3195
- },
3196
- addAddress: async (dto) => {
3197
- const session = await this.auth.getSession();
3198
- const user = session.user;
3199
- const customerId = user?.customerId || user?.id || user?.customer?.id;
3200
- if (!customerId) throw new Error("No authenticated customer found.");
3201
- return this.admin.addCustomerAddress(customerId, dto);
3202
- }
3203
- };
3204
- this.bookings = {
3205
- create: async (dto) => {
3206
- return this.catalog.createBooking(dto);
3207
- },
3208
- get: async (id) => {
3209
- return this.catalog.getBooking(id);
3210
- },
3211
- list: async () => {
3212
- return this.catalog.getBookings();
3332
+ const customerAuth = {
3333
+ get session() {
3334
+ if (!state.token) {
3335
+ return {
3336
+ data: null,
3337
+ isPending: false,
3338
+ error: null
3339
+ };
3340
+ }
3341
+ const userId = state.user?.id || state.user?.userId || state.user?.customerId || "";
3342
+ return {
3343
+ data: {
3344
+ session: {
3345
+ id: userId || state.token,
3346
+ userId,
3347
+ expiresAt: state.expiresAt ? new Date(state.expiresAt) : null,
3348
+ token: state.token
3349
+ },
3350
+ user: state.user
3351
+ },
3352
+ isPending: false,
3353
+ error: null
3354
+ };
3213
3355
  },
3214
- cancel: async (id) => {
3215
- return this.catalog.updateBookingStatus(id, "CANCELLED");
3216
- }
3217
- };
3218
- const baseAuth = buildModule(this.api, config.orgSlug, authMapping);
3219
- this.auth = {
3220
- ...baseAuth,
3221
3356
  signUp: async (dto) => {
3222
- return this.api.customersRegister(config.orgSlug, dto);
3223
- },
3224
- authenticate: async () => {
3225
- return performExchange();
3226
- },
3227
- signIn: async (credentials) => {
3228
- try {
3229
- const authServiceUrl = process.env.CUSTOMER_AUTH_URL || `${this.axiosInstance.defaults.baseURL || "http://localhost:3002"}/api/customer-auth`;
3230
- 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`;
3231
- const response2 = await import_axios2.default.post(postUrl, credentials);
3232
- const data2 = response2.data;
3233
- const token2 = data2?.session?.token || data2?.token || null;
3234
- const user2 = data2?.user || null;
3235
- if (token2) {
3236
- state.token = token2;
3237
- state.user = user2;
3238
- const jwtExp = getJwtExpiry(token2);
3239
- await storage.setItem(SCRYME_SESSION_TOKEN_KEY, token2);
3240
- if (jwtExp) {
3241
- state.expiresAt = jwtExp;
3242
- await storage.setItem(
3243
- SCRYME_EXPIRES_AT_KEY,
3244
- String(state.expiresAt)
3245
- );
3246
- } else {
3247
- delete state.expiresAt;
3248
- await storage.removeItem(SCRYME_EXPIRES_AT_KEY);
3249
- }
3250
- if (user2) {
3251
- await storage.setItem(SCRYME_USER_KEY, JSON.stringify(user2));
3252
- }
3253
- notify("SIGNED_IN");
3254
- return data2;
3255
- } else {
3256
- throw new Error("No token returned");
3357
+ const res = await this.api.customersRegister(config.orgSlug, dto);
3358
+ if (dto.password) {
3359
+ try {
3360
+ await customerAuth.signIn({
3361
+ email: dto.email,
3362
+ password: dto.password
3363
+ });
3364
+ } catch (e) {
3365
+ console.error("Auto sign-in after sign-up failed:", e);
3257
3366
  }
3258
- } catch (e) {
3259
3367
  }
3260
- const response = await this.axiosInstance.post(
3261
- `/${config.orgSlug}/customers/auth/login`,
3262
- credentials
3263
- );
3264
- const data = response.data?.data || response.data;
3265
- const token = data?.token || null;
3266
- const user = data?.session || null;
3368
+ return res;
3369
+ },
3370
+ signIn: async (credentials) => {
3371
+ const res = await this.api.customersLogin(config.orgSlug, credentials);
3372
+ const authData = res.data;
3373
+ const token = authData?.accessToken || authData?.token;
3267
3374
  if (token) {
3268
3375
  state.token = token;
3269
- state.user = user;
3376
+ state.user = authData?.user || authData?.customer || authData?.session;
3270
3377
  const jwtExp = getJwtExpiry(token);
3378
+ if (jwtExp) state.expiresAt = jwtExp;
3271
3379
  await storage.setItem(SCRYME_SESSION_TOKEN_KEY, token);
3272
- if (jwtExp) {
3273
- state.expiresAt = jwtExp;
3274
- await storage.setItem(
3275
- SCRYME_EXPIRES_AT_KEY,
3276
- String(state.expiresAt)
3277
- );
3278
- } else {
3279
- delete state.expiresAt;
3280
- await storage.removeItem(SCRYME_EXPIRES_AT_KEY);
3380
+ if (state.user) {
3381
+ await storage.setItem(SCRYME_USER_KEY, JSON.stringify(state.user));
3281
3382
  }
3282
- if (user) {
3283
- await storage.setItem(SCRYME_USER_KEY, JSON.stringify(user));
3383
+ if (state.expiresAt) {
3384
+ await storage.setItem(SCRYME_EXPIRES_AT_KEY, String(state.expiresAt));
3284
3385
  }
3285
3386
  notify("SIGNED_IN");
3286
3387
  }
3287
- return data;
3388
+ return authData;
3288
3389
  },
3289
3390
  signOut: async () => {
3290
- try {
3291
- await this.axiosInstance.post("/auth/sign-out");
3292
- } catch {
3293
- }
3294
3391
  state.token = null;
3295
3392
  state.user = null;
3296
3393
  delete state.expiresAt;
@@ -3305,13 +3402,6 @@ var ScrymeClientSDK = class {
3305
3402
  },
3306
3403
  onAuthStateChange: (callback) => {
3307
3404
  listeners.add(callback);
3308
- initPromise.then(() => {
3309
- try {
3310
- callback("INITIAL_SESSION", { ...state });
3311
- } catch (e) {
3312
- console.error("Error in immediate auth state listener call:", e);
3313
- }
3314
- });
3315
3405
  return {
3316
3406
  unsubscribe: () => {
3317
3407
  listeners.delete(callback);
@@ -3319,86 +3409,158 @@ var ScrymeClientSDK = class {
3319
3409
  };
3320
3410
  },
3321
3411
  getSessions: async () => {
3322
- const res = await this.axiosInstance.get(
3323
- `/${config.orgSlug}/customers/auth/sessions`
3324
- );
3412
+ const res = await this.api.customersGetSessions(config.orgSlug);
3325
3413
  return res.data?.data || res.data;
3326
3414
  },
3327
3415
  revokeSession: async (id) => {
3328
- const res = await this.axiosInstance.delete(
3329
- `/${config.orgSlug}/customers/auth/sessions/${id}`
3330
- );
3331
- return res.data?.data || res.data;
3416
+ return this.api.customersRevokeSession(config.orgSlug, id);
3332
3417
  },
3333
3418
  revokeAllSessions: async (mode) => {
3334
- const url = mode ? `/${config.orgSlug}/customers/auth/sessions?mode=${mode}` : `/${config.orgSlug}/customers/auth/sessions`;
3335
- const res = await this.axiosInstance.delete(url);
3336
- return res.data?.data || res.data;
3419
+ return this.api.customersRevokeAllSessions(config.orgSlug, { mode });
3337
3420
  },
3338
3421
  getCurrentSession: async () => {
3339
- const res = await this.axiosInstance.get(
3340
- `/${config.orgSlug}/customers/auth/session`
3341
- );
3422
+ const res = await this.api.customersGetCurrentSession(config.orgSlug);
3342
3423
  return res.data?.data || res.data;
3343
3424
  },
3344
3425
  refreshSession: async () => {
3345
- const response = await this.axiosInstance.post(
3346
- `/${config.orgSlug}/customers/auth/refresh`
3347
- );
3348
- const data = response.data?.data || response.data;
3349
- const token = data?.token || null;
3350
- const user = data?.session || null;
3426
+ const res = await this.api.customersRefreshSession(config.orgSlug);
3427
+ const authData = res.data;
3428
+ const token = authData?.accessToken || authData?.token;
3351
3429
  if (token) {
3352
3430
  state.token = token;
3353
- state.user = user;
3431
+ if (authData?.user || authData?.customer) {
3432
+ state.user = authData.user || authData.customer;
3433
+ }
3354
3434
  const jwtExp = getJwtExpiry(token);
3435
+ if (jwtExp) state.expiresAt = jwtExp;
3355
3436
  await storage.setItem(SCRYME_SESSION_TOKEN_KEY, token);
3356
- if (jwtExp) {
3357
- state.expiresAt = jwtExp;
3358
- await storage.setItem(
3359
- SCRYME_EXPIRES_AT_KEY,
3360
- String(state.expiresAt)
3361
- );
3362
- } else {
3363
- delete state.expiresAt;
3364
- await storage.removeItem(SCRYME_EXPIRES_AT_KEY);
3437
+ if (state.user) {
3438
+ await storage.setItem(SCRYME_USER_KEY, JSON.stringify(state.user));
3365
3439
  }
3366
- if (user) {
3367
- await storage.setItem(SCRYME_USER_KEY, JSON.stringify(user));
3440
+ if (state.expiresAt) {
3441
+ await storage.setItem(SCRYME_EXPIRES_AT_KEY, String(state.expiresAt));
3368
3442
  }
3369
3443
  notify("SIGNED_IN");
3370
3444
  }
3371
- return data;
3445
+ return authData;
3372
3446
  },
3373
- swapZitadel: async (zitadelToken) => {
3374
- const response = await this.axiosInstance.post(
3375
- `/${config.orgSlug}/customers/auth/swap-zitadel`,
3376
- { zitadelToken }
3377
- );
3378
- const data = response.data?.data || response.data;
3379
- const token = data?.token || null;
3380
- const user = data?.session || null;
3381
- if (token) {
3382
- state.token = token;
3383
- state.user = user;
3384
- const jwtExp = getJwtExpiry(token);
3385
- await storage.setItem(SCRYME_SESSION_TOKEN_KEY, token);
3386
- if (jwtExp) {
3387
- state.expiresAt = jwtExp;
3388
- await storage.setItem(
3389
- SCRYME_EXPIRES_AT_KEY,
3390
- String(state.expiresAt)
3391
- );
3392
- } else {
3393
- delete state.expiresAt;
3394
- await storage.removeItem(SCRYME_EXPIRES_AT_KEY);
3447
+ useSession: () => {
3448
+ const currentSession = customerAuth.session;
3449
+ const [data, setData] = (0, import_react.useState)(currentSession.data);
3450
+ const [isPending, setIsPending] = (0, import_react.useState)(false);
3451
+ const [error, setError] = (0, import_react.useState)(null);
3452
+ const fetchSessionSync = () => {
3453
+ const s = customerAuth.session;
3454
+ setData(s.data);
3455
+ setError(s.error);
3456
+ setIsPending(s.isPending);
3457
+ };
3458
+ const fetchSessionAsync = async () => {
3459
+ setIsPending(true);
3460
+ try {
3461
+ const res = await customerAuth.getCurrentSession();
3462
+ if (res && (res.session || res.customer || res.user)) {
3463
+ setData({
3464
+ session: res.session,
3465
+ user: res.customer || res.user
3466
+ });
3467
+ } else {
3468
+ const sessionState = await customerAuth.getSession();
3469
+ setData({
3470
+ session: {
3471
+ id: sessionState.user?.id || sessionState.user?.userId || sessionState.user?.customerId || sessionState.token,
3472
+ userId: sessionState.user?.id || sessionState.user?.userId || sessionState.user?.customerId || "",
3473
+ expiresAt: sessionState.expiresAt ? new Date(sessionState.expiresAt) : null,
3474
+ token: sessionState.token
3475
+ },
3476
+ user: sessionState.user
3477
+ });
3478
+ }
3479
+ setError(null);
3480
+ } catch (e) {
3481
+ setError(e instanceof Error ? e : new Error(String(e)));
3482
+ setData(null);
3483
+ } finally {
3484
+ setIsPending(false);
3395
3485
  }
3396
- if (user) {
3397
- await storage.setItem(SCRYME_USER_KEY, JSON.stringify(user));
3486
+ };
3487
+ (0, import_react.useEffect)(() => {
3488
+ fetchSessionSync();
3489
+ const { unsubscribe } = customerAuth.onAuthStateChange(() => {
3490
+ fetchSessionSync();
3491
+ });
3492
+ return () => unsubscribe();
3493
+ }, []);
3494
+ return {
3495
+ data,
3496
+ isPending,
3497
+ error,
3498
+ refetch: fetchSessionAsync
3499
+ };
3500
+ }
3501
+ };
3502
+ this.customer = {
3503
+ getProfile: async () => {
3504
+ return this.customer.auth.getCurrentSession();
3505
+ },
3506
+ updateProfile: async (dto) => {
3507
+ const session = await this.auth.getSession();
3508
+ const user = session.user;
3509
+ const customerId = user?.customerId || user?.id || user?.customer?.id;
3510
+ if (!customerId) throw new Error("No authenticated customer found.");
3511
+ return this.admin.updateCustomer(customerId, dto);
3512
+ },
3513
+ getAddresses: async () => {
3514
+ const session = await this.auth.getSession();
3515
+ const user = session.user;
3516
+ const customerId = user?.customerId || user?.id || user?.customer?.id;
3517
+ if (!customerId) throw new Error("No authenticated customer found.");
3518
+ return this.admin.getCustomerAddresses(customerId);
3519
+ },
3520
+ addAddress: async (dto) => {
3521
+ const session = await this.auth.getSession();
3522
+ const user = session.user;
3523
+ const customerId = user?.customerId || user?.id || user?.customer?.id;
3524
+ if (!customerId) throw new Error("No authenticated customer found.");
3525
+ return this.admin.addCustomerAddress(customerId, dto);
3526
+ },
3527
+ auth: customerAuth
3528
+ };
3529
+ const baseAuth = buildModule(this.api, config.orgSlug, authMapping);
3530
+ this.auth = {
3531
+ ...baseAuth,
3532
+ ...customerAuth,
3533
+ authenticate: async () => {
3534
+ return performExchange();
3535
+ },
3536
+ get session() {
3537
+ return customerAuth.session;
3538
+ },
3539
+ useSession() {
3540
+ return customerAuth.useSession();
3541
+ }
3542
+ };
3543
+ this.bookings = {
3544
+ create: async (dto) => {
3545
+ if (!dto.customerId) {
3546
+ const session = await this.auth.getSession();
3547
+ const user = session?.user;
3548
+ const customerId = user?.customerId || user?.id || user?.customer?.id;
3549
+ if (!customerId) {
3550
+ throw new Error("Unauthorized: customerId is required.");
3398
3551
  }
3399
- notify("SIGNED_IN");
3552
+ dto = { ...dto, customerId };
3400
3553
  }
3401
- return data;
3554
+ return this.catalog.createBooking(dto);
3555
+ },
3556
+ get: async (id) => {
3557
+ return this.catalog.getBooking(id);
3558
+ },
3559
+ list: async () => {
3560
+ return this.catalog.getBookings();
3561
+ },
3562
+ cancel: async (id) => {
3563
+ return this.catalog.updateBookingStatus(id, "CANCELLED");
3402
3564
  }
3403
3565
  };
3404
3566
  }
@@ -3406,205 +3568,11 @@ var ScrymeClientSDK = class {
3406
3568
  function createClientSDK(config = {}) {
3407
3569
  const finalConfig = {
3408
3570
  clientId: config.clientId || "mock-client-id",
3409
- clientSecret: config.clientSecret || "mock-client-secret",
3410
3571
  orgSlug: config.orgSlug || "mock-org-slug",
3411
3572
  ...config
3412
3573
  };
3413
3574
  return new ScrymeClientSDK(finalConfig);
3414
3575
  }
3415
- var AuthContext = (0, import_react.createContext)(void 0);
3416
- var ScrymeAuthProvider = ({
3417
- sdk,
3418
- children
3419
- }) => {
3420
- const [session, setSession] = (0, import_react.useState)({
3421
- token: null,
3422
- user: null
3423
- });
3424
- const [isLoading, setIsLoading] = (0, import_react.useState)(true);
3425
- const [cart, setCart] = (0, import_react.useState)(null);
3426
- const [cartLoading, setCartLoading] = (0, import_react.useState)(false);
3427
- const [customerProfile, setCustomerProfile] = (0, import_react.useState)(null);
3428
- const [customerAddresses, setCustomerAddresses] = (0, import_react.useState)([]);
3429
- const [bookingsList, setBookingsList] = (0, import_react.useState)([]);
3430
- const [bookingsLoading, setBookingsLoading] = (0, import_react.useState)(false);
3431
- (0, import_react.useEffect)(() => {
3432
- const { unsubscribe } = sdk.auth.onAuthStateChange((event, newSession) => {
3433
- setSession(newSession);
3434
- setIsLoading(false);
3435
- });
3436
- return () => unsubscribe();
3437
- }, [sdk]);
3438
- const refreshCart = async () => {
3439
- if (!session.token) {
3440
- setCart(null);
3441
- return;
3442
- }
3443
- setCartLoading(true);
3444
- try {
3445
- const res = await sdk.cart.get();
3446
- setCart(res.data?.data || res.data || null);
3447
- } catch (err) {
3448
- console.error("Failed to fetch cart:", err);
3449
- } finally {
3450
- setCartLoading(false);
3451
- }
3452
- };
3453
- const refreshProfile = async () => {
3454
- if (!session.token) {
3455
- setCustomerProfile(null);
3456
- setCustomerAddresses([]);
3457
- return;
3458
- }
3459
- try {
3460
- const profile = await sdk.customer.getProfile();
3461
- setCustomerProfile(profile || null);
3462
- const addresses = await sdk.customer.getAddresses();
3463
- setCustomerAddresses(addresses?.data || addresses || []);
3464
- } catch (err) {
3465
- console.error("Failed to fetch customer profile or addresses:", err);
3466
- }
3467
- };
3468
- const refreshBookings = async () => {
3469
- if (!session.token) {
3470
- setBookingsList([]);
3471
- return;
3472
- }
3473
- setBookingsLoading(true);
3474
- try {
3475
- const res = await sdk.bookings.list();
3476
- setBookingsList(res?.data || res || []);
3477
- } catch (err) {
3478
- console.error("Failed to fetch bookings:", err);
3479
- } finally {
3480
- setBookingsLoading(false);
3481
- }
3482
- };
3483
- (0, import_react.useEffect)(() => {
3484
- if (session.token) {
3485
- refreshCart();
3486
- refreshProfile();
3487
- refreshBookings();
3488
- } else {
3489
- setCart(null);
3490
- setCustomerProfile(null);
3491
- setCustomerAddresses([]);
3492
- setBookingsList([]);
3493
- }
3494
- }, [session.token]);
3495
- const signIn = async (credentials) => {
3496
- const res = await sdk.auth.signIn(credentials);
3497
- return res;
3498
- };
3499
- const signUp = async (dto) => {
3500
- const res = await sdk.auth.signUp(dto);
3501
- return res;
3502
- };
3503
- const signOut = async () => {
3504
- await sdk.auth.signOut();
3505
- };
3506
- const addToCart = async (dto) => {
3507
- if (!session.token)
3508
- throw new Error("Customer must be logged in to manage cart");
3509
- await sdk.cart.add(dto);
3510
- await refreshCart();
3511
- };
3512
- const removeFromCart = async (dto) => {
3513
- if (!session.token)
3514
- throw new Error("Customer must be logged in to manage cart");
3515
- await sdk.cart.remove(dto);
3516
- await refreshCart();
3517
- };
3518
- const updateCartItem = async (dto) => {
3519
- if (!session.token)
3520
- throw new Error("Customer must be logged in to manage cart");
3521
- await sdk.cart.update(dto);
3522
- await refreshCart();
3523
- };
3524
- const clearCart = async (params) => {
3525
- if (!session.token)
3526
- throw new Error("Customer must be logged in to manage cart");
3527
- await sdk.cart.clear(params);
3528
- await refreshCart();
3529
- };
3530
- const addAddress = async (dto) => {
3531
- if (!session.token)
3532
- throw new Error("Customer must be logged in to manage addresses");
3533
- const res = await sdk.customer.addAddress(dto);
3534
- await refreshProfile();
3535
- return res;
3536
- };
3537
- const updateProfile = async (dto) => {
3538
- if (!session.token)
3539
- throw new Error("Customer must be logged in to update profile");
3540
- const res = await sdk.customer.updateProfile(dto);
3541
- await refreshProfile();
3542
- return res;
3543
- };
3544
- const createBooking = async (dto) => {
3545
- if (!session.token)
3546
- throw new Error("Customer must be logged in to create bookings");
3547
- const res = await sdk.bookings.create(dto);
3548
- await refreshBookings();
3549
- return res;
3550
- };
3551
- const cancelBooking = async (id) => {
3552
- if (!session.token)
3553
- throw new Error("Customer must be logged in to cancel bookings");
3554
- const res = await sdk.bookings.cancel(id);
3555
- await refreshBookings();
3556
- return res;
3557
- };
3558
- const checkoutCart = async (params) => {
3559
- if (!session.token)
3560
- throw new Error("Customer must be logged in to checkout");
3561
- const res = await sdk.cart.checkout(params);
3562
- await refreshCart();
3563
- await refreshBookings();
3564
- return res;
3565
- };
3566
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
3567
- AuthContext.Provider,
3568
- {
3569
- value: {
3570
- sdk,
3571
- session,
3572
- user: session.user,
3573
- token: session.token,
3574
- isLoading,
3575
- signIn,
3576
- signUp,
3577
- signOut,
3578
- cart,
3579
- cartLoading,
3580
- addToCart,
3581
- removeFromCart,
3582
- updateCartItem,
3583
- clearCart,
3584
- refreshCart,
3585
- customerProfile,
3586
- customerAddresses,
3587
- bookings: bookingsList,
3588
- bookingsLoading,
3589
- addAddress,
3590
- updateProfile,
3591
- createBooking,
3592
- cancelBooking,
3593
- checkoutCart,
3594
- refreshProfile,
3595
- refreshBookings
3596
- },
3597
- children
3598
- }
3599
- );
3600
- };
3601
- var useScrymeAuth = () => {
3602
- const context = (0, import_react.useContext)(AuthContext);
3603
- if (context === void 0) {
3604
- throw new Error("useScrymeAuth must be used within a ScrymeAuthProvider");
3605
- }
3606
- return context;
3607
- };
3608
3576
 
3609
3577
  // src/server.ts
3610
3578
  var import_axios3 = __toESM(require("axios"));
@@ -3663,7 +3631,7 @@ var ScrymeServerSDK = class {
3663
3631
  return this.activeAuthPromise;
3664
3632
  };
3665
3633
  this.axiosInstance.interceptors.request.use(async (req) => {
3666
- 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"));
3634
+ const isAuthTokenRequest = req.url && (req.url.endsWith("/auth/token") || req.url.includes("/auth/token") || req.url.includes("/customers/auth/refresh"));
3667
3635
  if (!isAuthTokenRequest && !config.apiKey) {
3668
3636
  const isExpired = !this.token || this.expiresAt && Date.now() >= this.expiresAt - 3e4;
3669
3637
  if (isExpired) {
@@ -3698,7 +3666,7 @@ var ScrymeServerSDK = class {
3698
3666
  (response) => response,
3699
3667
  async (error) => {
3700
3668
  const originalRequest = error.config;
3701
- 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"));
3669
+ const isAuthTokenRequest = originalRequest && originalRequest.url && (originalRequest.url.endsWith("/auth/token") || originalRequest.url.includes("/auth/token") || originalRequest.url.includes("/customers/auth/refresh"));
3702
3670
  if (error.response && error.response.status === 401 && originalRequest && !originalRequest._retry && !isAuthTokenRequest && !config.apiKey) {
3703
3671
  originalRequest._retry = true;
3704
3672
  try {
@@ -3724,7 +3692,54 @@ var ScrymeServerSDK = class {
3724
3692
  }
3725
3693
  );
3726
3694
  this.api = getScrymeV3API2(this.axiosInstance, config.orgSlug);
3727
- this.catalog = buildModule(this.api, config.orgSlug, catalogMapping);
3695
+ const baseCatalog = buildModule(this.api, config.orgSlug, catalogMapping);
3696
+ this.catalog = {
3697
+ ...baseCatalog,
3698
+ getProduct: async (idOrSlug, options) => {
3699
+ const response = await this.catalog.getProducts(void 0, options);
3700
+ const products = response.data || [];
3701
+ const product = products.find((p) => {
3702
+ if (typeof idOrSlug === "string") {
3703
+ return p.id === idOrSlug || p.slug === idOrSlug;
3704
+ } else {
3705
+ const { id, slug } = idOrSlug;
3706
+ if (id && p.id === id) return true;
3707
+ if (slug && p.slug === slug) return true;
3708
+ return false;
3709
+ }
3710
+ });
3711
+ if (!product) {
3712
+ const criteria = typeof idOrSlug === "string" ? idOrSlug : JSON.stringify(idOrSlug);
3713
+ throw new Error(`Product not found matching criteria: ${criteria}`);
3714
+ }
3715
+ return {
3716
+ ...response,
3717
+ data: product
3718
+ };
3719
+ },
3720
+ getService: async (idOrSlug, options) => {
3721
+ const response = await this.catalog.getServices(void 0, options);
3722
+ const services = response.data || [];
3723
+ const service = services.find((s) => {
3724
+ if (typeof idOrSlug === "string") {
3725
+ return s.id === idOrSlug || s.slug === idOrSlug;
3726
+ } else {
3727
+ const { id, slug } = idOrSlug;
3728
+ if (id && s.id === id) return true;
3729
+ if (slug && s.slug === slug) return true;
3730
+ return false;
3731
+ }
3732
+ });
3733
+ if (!service) {
3734
+ const criteria = typeof idOrSlug === "string" ? idOrSlug : JSON.stringify(idOrSlug);
3735
+ throw new Error(`Service not found matching criteria: ${criteria}`);
3736
+ }
3737
+ return {
3738
+ ...response,
3739
+ data: service
3740
+ };
3741
+ }
3742
+ };
3728
3743
  this.inventory = buildModule(this.api, config.orgSlug, inventoryMapping);
3729
3744
  this.orders = buildModule(this.api, config.orgSlug, ordersMapping);
3730
3745
  this.crm = buildModule(this.api, config.orgSlug, crmMapping);
@@ -3736,7 +3751,9 @@ var ScrymeServerSDK = class {
3736
3751
  this.services = buildModule(this.api, config.orgSlug, servicesMapping);
3737
3752
  this.cart = {
3738
3753
  get: async (params) => {
3739
- return this.orders.getCart(params || {});
3754
+ return this.orders.getCart(
3755
+ params
3756
+ );
3740
3757
  },
3741
3758
  add: async (dto) => {
3742
3759
  return this.orders.addToCart(dto);
@@ -3745,11 +3762,11 @@ var ScrymeServerSDK = class {
3745
3762
  return this.orders.removeFromCart(dto);
3746
3763
  },
3747
3764
  clear: async (params) => {
3748
- return this.orders.clearCart(params || {});
3765
+ return this.orders.clearCart(params);
3749
3766
  },
3750
3767
  update: async (dto) => {
3751
3768
  const response = await this.orders.getCart({
3752
- sessionId: dto.sessionId
3769
+ sessionId: dto.sessionId || ""
3753
3770
  });
3754
3771
  const data = response.data;
3755
3772
  const items = data?.data?.items || data?.items || [];
@@ -3770,7 +3787,7 @@ var ScrymeServerSDK = class {
3770
3787
  productId: dto.productId,
3771
3788
  variantId: dto.variantId,
3772
3789
  serviceId: dto.serviceId,
3773
- sessionId: dto.sessionId,
3790
+ sessionId: dto.sessionId || "",
3774
3791
  customerId: dto.customerId
3775
3792
  });
3776
3793
  } else {
@@ -3790,12 +3807,16 @@ var ScrymeServerSDK = class {
3790
3807
  }
3791
3808
  },
3792
3809
  getItems: async (params) => {
3793
- const res = await this.orders.getCart(params || {});
3810
+ const res = await this.orders.getCart(
3811
+ params
3812
+ );
3794
3813
  const data = res?.data || res;
3795
3814
  return data?.items || data?.data?.items || [];
3796
3815
  },
3797
3816
  getTotals: async (params) => {
3798
- const res = await this.orders.getCart(params || {});
3817
+ const res = await this.orders.getCart(
3818
+ params
3819
+ );
3799
3820
  const data = res?.data || res;
3800
3821
  const items = data?.items || data?.data?.items || [];
3801
3822
  const itemsCount = items.reduce(
@@ -3849,6 +3870,72 @@ var ScrymeServerSDK = class {
3849
3870
  },
3850
3871
  addAddress: async (customerId, dto) => {
3851
3872
  return this.admin.addCustomerAddress(customerId, dto);
3873
+ },
3874
+ auth: {
3875
+ signUp: async (dto) => {
3876
+ const res = await this.api.customersRegister(config.orgSlug, dto);
3877
+ if (dto.password) {
3878
+ try {
3879
+ await this.customer.auth.signIn({
3880
+ email: dto.email,
3881
+ password: dto.password
3882
+ });
3883
+ } catch (e) {
3884
+ console.error("Auto sign-in after sign-up failed on server SDK:", e);
3885
+ }
3886
+ }
3887
+ return res;
3888
+ },
3889
+ signIn: async (credentials) => {
3890
+ const response = await this.axiosInstance.post(
3891
+ "/auth/sign-in/email",
3892
+ credentials
3893
+ );
3894
+ const data = response.data;
3895
+ const token = data?.session?.token || data?.token || null;
3896
+ if (token) {
3897
+ this.token = token;
3898
+ this.expiresAt = getJwtExpiry(token);
3899
+ this.axiosInstance.defaults.headers.common["Authorization"] = `Bearer ${token}`;
3900
+ }
3901
+ return data;
3902
+ },
3903
+ getCurrentSession: async (headers) => {
3904
+ const requestConfig = {};
3905
+ if (headers) {
3906
+ const requestHeaders = {};
3907
+ if (typeof headers.forEach === "function") {
3908
+ headers.forEach((value, key) => {
3909
+ requestHeaders[key] = value;
3910
+ });
3911
+ } else {
3912
+ for (const [key, value] of Object.entries(headers)) {
3913
+ if (value !== void 0) {
3914
+ requestHeaders[key] = Array.isArray(value) ? value.join(", ") : String(value);
3915
+ }
3916
+ }
3917
+ }
3918
+ requestConfig.headers = requestHeaders;
3919
+ }
3920
+ const response = await this.axiosInstance.get(
3921
+ `/${config.orgSlug}/customers/auth/session`,
3922
+ requestConfig
3923
+ );
3924
+ return response.data?.data || response.data;
3925
+ },
3926
+ refreshSession: async () => {
3927
+ const response = await this.axiosInstance.post(
3928
+ `/${config.orgSlug}/customers/auth/refresh`
3929
+ );
3930
+ const data = response.data?.data || response.data;
3931
+ const token = data?.token || null;
3932
+ if (token) {
3933
+ this.token = token;
3934
+ this.expiresAt = getJwtExpiry(token);
3935
+ this.axiosInstance.defaults.headers.common["Authorization"] = `Bearer ${token}`;
3936
+ }
3937
+ return data;
3938
+ }
3852
3939
  }
3853
3940
  };
3854
3941
  this.bookings = {
@@ -3871,58 +3958,21 @@ var ScrymeServerSDK = class {
3871
3958
  const baseAuth = buildModule(this.api, config.orgSlug, authMapping);
3872
3959
  this.auth = {
3873
3960
  ...baseAuth,
3874
- signUp: async (dto) => {
3875
- return this.api.customersRegister(config.orgSlug, dto);
3876
- },
3961
+ ...this.customer.auth,
3877
3962
  authenticate: async () => {
3878
3963
  return performExchange();
3879
3964
  },
3965
+ signUp: async (dto) => {
3966
+ return this.customer.auth.signUp(dto);
3967
+ },
3880
3968
  signIn: async (credentials) => {
3881
- const response = await this.axiosInstance.post(
3882
- "/auth/sign-in/email",
3883
- credentials
3884
- );
3885
- const data = response.data;
3886
- const token = data?.session?.token || data?.token || null;
3887
- if (token) {
3888
- this.token = token;
3889
- this.expiresAt = getJwtExpiry(token);
3890
- this.axiosInstance.defaults.headers.common["Authorization"] = `Bearer ${token}`;
3891
- }
3892
- return data;
3969
+ return this.customer.auth.signIn(credentials);
3893
3970
  },
3894
- getCurrentSession: async () => {
3895
- const response = await this.axiosInstance.get(
3896
- `/${config.orgSlug}/customers/auth/session`
3897
- );
3898
- return response.data?.data || response.data;
3971
+ getCurrentSession: async (headers) => {
3972
+ return this.customer.auth.getCurrentSession(headers);
3899
3973
  },
3900
3974
  refreshSession: async () => {
3901
- const response = await this.axiosInstance.post(
3902
- `/${config.orgSlug}/customers/auth/refresh`
3903
- );
3904
- const data = response.data?.data || response.data;
3905
- const token = data?.token || null;
3906
- if (token) {
3907
- this.token = token;
3908
- this.expiresAt = getJwtExpiry(token);
3909
- this.axiosInstance.defaults.headers.common["Authorization"] = `Bearer ${token}`;
3910
- }
3911
- return data;
3912
- },
3913
- swapZitadel: async (zitadelToken) => {
3914
- const response = await this.axiosInstance.post(
3915
- `/${config.orgSlug}/customers/auth/swap-zitadel`,
3916
- { zitadelToken }
3917
- );
3918
- const data = response.data?.data || response.data;
3919
- const token = data?.token || null;
3920
- if (token) {
3921
- this.token = token;
3922
- this.expiresAt = getJwtExpiry(token);
3923
- this.axiosInstance.defaults.headers.common["Authorization"] = `Bearer ${token}`;
3924
- }
3925
- return data;
3975
+ return this.customer.auth.refreshSession();
3926
3976
  }
3927
3977
  };
3928
3978
  }
@@ -4038,7 +4088,6 @@ var getScrymeV3API2 = (axiosInstance, defaultOrgSlug) => {
4038
4088
  RegisterPettyCashDtoPaymentMethod,
4039
4089
  ReviewPriceChangeDtoStatus,
4040
4090
  RoleManagementControllerGetCustomRolesSortOrder,
4041
- ScrymeAuthProvider,
4042
4091
  ScrymeClientSDK,
4043
4092
  ScrymeServerSDK,
4044
4093
  ServicesUpdateBookingStatusBodyStatus,
@@ -4071,6 +4120,5 @@ var getScrymeV3API2 = (axiosInstance, defaultOrgSlug) => {
4071
4120
  ordersMapping,
4072
4121
  posMapping,
4073
4122
  publicServicesMapping,
4074
- servicesMapping,
4075
- useScrymeAuth
4123
+ servicesMapping
4076
4124
  });