@scryme/sdk 9.64.2 → 9.65.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -0
- package/README.md +1 -1
- package/dist/{base-DZXCyXwH.d.mts → base-DZWqHn_L.d.mts} +234 -51
- package/dist/{base-DZXCyXwH.d.ts → base-DZWqHn_L.d.ts} +234 -51
- package/dist/{chunk-CBV4VTNE.mjs → chunk-PPNV4D3M.mjs} +875 -44
- package/dist/client.d.mts +105 -8
- package/dist/client.d.ts +105 -8
- package/dist/client.js +661 -31
- package/dist/client.mjs +7 -3
- package/dist/index.d.mts +18 -5
- package/dist/index.d.ts +18 -5
- package/dist/index.js +880 -45
- package/dist/index.mjs +11 -3
- package/dist/server.d.mts +54 -5
- package/dist/server.d.ts +54 -5
- package/dist/server.js +361 -20
- package/dist/server.mjs +1 -1
- package/package.json +13 -3
package/dist/client.js
CHANGED
|
@@ -27,13 +27,16 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
|
|
30
|
-
// src/client.
|
|
30
|
+
// src/client.tsx
|
|
31
31
|
var client_exports = {};
|
|
32
32
|
__export(client_exports, {
|
|
33
|
+
ScrymeAuthProvider: () => ScrymeAuthProvider,
|
|
33
34
|
ScrymeClientSDK: () => ScrymeClientSDK,
|
|
34
|
-
createClientSDK: () => createClientSDK
|
|
35
|
+
createClientSDK: () => createClientSDK,
|
|
36
|
+
useScrymeAuth: () => useScrymeAuth
|
|
35
37
|
});
|
|
36
38
|
module.exports = __toCommonJS(client_exports);
|
|
39
|
+
var import_react = require("react");
|
|
37
40
|
var import_axios3 = __toESM(require("axios"));
|
|
38
41
|
|
|
39
42
|
// src/generated/scryme.ts
|
|
@@ -341,10 +344,10 @@ var getScrymeV3API = (axiosInstance = import_axios.default) => {
|
|
|
341
344
|
options
|
|
342
345
|
);
|
|
343
346
|
};
|
|
344
|
-
const invoiceControllerCreateTemplate = (options) => {
|
|
347
|
+
const invoiceControllerCreateTemplate = (createInvoiceTemplateDto, options) => {
|
|
345
348
|
return axiosInstance.post(
|
|
346
349
|
`/v3/finance/invoices/templates`,
|
|
347
|
-
|
|
350
|
+
createInvoiceTemplateDto,
|
|
348
351
|
options
|
|
349
352
|
);
|
|
350
353
|
};
|
|
@@ -877,6 +880,54 @@ var getScrymeV3API = (axiosInstance = import_axios.default) => {
|
|
|
877
880
|
}
|
|
878
881
|
);
|
|
879
882
|
};
|
|
883
|
+
const publicServicesListServices = (orgSlug, options) => {
|
|
884
|
+
return axiosInstance.get(
|
|
885
|
+
`/v3/public/${orgSlug}/services`,
|
|
886
|
+
options
|
|
887
|
+
);
|
|
888
|
+
};
|
|
889
|
+
const publicServicesGetCategories = (orgSlug, options) => {
|
|
890
|
+
return axiosInstance.get(
|
|
891
|
+
`/v3/public/${orgSlug}/services/categories`,
|
|
892
|
+
options
|
|
893
|
+
);
|
|
894
|
+
};
|
|
895
|
+
const publicServicesGetService = (orgSlug, id, options) => {
|
|
896
|
+
return axiosInstance.get(
|
|
897
|
+
`/v3/public/${orgSlug}/services/${id}`,
|
|
898
|
+
options
|
|
899
|
+
);
|
|
900
|
+
};
|
|
901
|
+
const publicServicesGetAvailability = (orgSlug, id, params, options) => {
|
|
902
|
+
return axiosInstance.get(
|
|
903
|
+
`/v3/public/${orgSlug}/services/${id}/availability`,
|
|
904
|
+
{
|
|
905
|
+
...options,
|
|
906
|
+
params: { ...params, ...options?.params }
|
|
907
|
+
}
|
|
908
|
+
);
|
|
909
|
+
};
|
|
910
|
+
const publicServicesRequestOtp = (orgSlug, requestOtpDto, options) => {
|
|
911
|
+
return axiosInstance.post(
|
|
912
|
+
`/v3/public/${orgSlug}/services/otp/request`,
|
|
913
|
+
requestOtpDto,
|
|
914
|
+
options
|
|
915
|
+
);
|
|
916
|
+
};
|
|
917
|
+
const publicServicesVerifyOtp = (orgSlug, verifyOtpDto, options) => {
|
|
918
|
+
return axiosInstance.post(
|
|
919
|
+
`/v3/public/${orgSlug}/services/otp/verify`,
|
|
920
|
+
verifyOtpDto,
|
|
921
|
+
options
|
|
922
|
+
);
|
|
923
|
+
};
|
|
924
|
+
const publicServicesCreatePublicBooking = (orgSlug, publicBookingDto, options) => {
|
|
925
|
+
return axiosInstance.post(
|
|
926
|
+
`/v3/public/${orgSlug}/services/bookings`,
|
|
927
|
+
publicBookingDto,
|
|
928
|
+
options
|
|
929
|
+
);
|
|
930
|
+
};
|
|
880
931
|
const customersProvisionZitadel = (orgSlug, provisionZitadelDto, options) => {
|
|
881
932
|
return axiosInstance.post(
|
|
882
933
|
`/v3/${orgSlug}/customers/zitadel/provision`,
|
|
@@ -900,6 +951,40 @@ var getScrymeV3API = (axiosInstance = import_axios.default) => {
|
|
|
900
951
|
options
|
|
901
952
|
);
|
|
902
953
|
};
|
|
954
|
+
const customersLogin = (orgSlug, customerLoginDto, options) => {
|
|
955
|
+
return axiosInstance.post(
|
|
956
|
+
`/v3/${orgSlug}/customers/auth/login`,
|
|
957
|
+
customerLoginDto,
|
|
958
|
+
options
|
|
959
|
+
);
|
|
960
|
+
};
|
|
961
|
+
const customersGetCurrentSession = (orgSlug, options) => {
|
|
962
|
+
return axiosInstance.get(
|
|
963
|
+
`/v3/${orgSlug}/customers/auth/session`,
|
|
964
|
+
options
|
|
965
|
+
);
|
|
966
|
+
};
|
|
967
|
+
const customersGetSessions = (orgSlug, options) => {
|
|
968
|
+
return axiosInstance.get(
|
|
969
|
+
`/v3/${orgSlug}/customers/auth/sessions`,
|
|
970
|
+
options
|
|
971
|
+
);
|
|
972
|
+
};
|
|
973
|
+
const customersRevokeAllSessions = (orgSlug, params, options) => {
|
|
974
|
+
return axiosInstance.delete(
|
|
975
|
+
`/v3/${orgSlug}/customers/auth/sessions`,
|
|
976
|
+
{
|
|
977
|
+
...options,
|
|
978
|
+
params: { ...params, ...options?.params }
|
|
979
|
+
}
|
|
980
|
+
);
|
|
981
|
+
};
|
|
982
|
+
const customersRevokeSession = (orgSlug, id, options) => {
|
|
983
|
+
return axiosInstance.delete(
|
|
984
|
+
`/v3/${orgSlug}/customers/auth/sessions/${id}`,
|
|
985
|
+
options
|
|
986
|
+
);
|
|
987
|
+
};
|
|
903
988
|
const customersUpdate = (orgSlug, id, updateCustomerDto, options) => {
|
|
904
989
|
return axiosInstance.patch(
|
|
905
990
|
`/v3/${orgSlug}/customers/${id}`,
|
|
@@ -1811,11 +1896,18 @@ var getScrymeV3API = (axiosInstance = import_axios.default) => {
|
|
|
1811
1896
|
}
|
|
1812
1897
|
);
|
|
1813
1898
|
};
|
|
1814
|
-
return { inventoryVerifyIntegrity, inventoryFixIntegrity, inventoryGetInventory, inventoryTraceBatch, inventorySplitBatch, inventoryMergeBatches, inventoryCreateAssembly, inventoryCompleteAssembly, inventoryRequestAdjustment, inventoryGetAdjustments, inventoryApproveAdjustment, inventoryRejectAdjustment, inventoryGetLeadTime, inventoryGetWasteAnalysis, inventoryCheckB2BAvailability, inventoryUnpackBatch, inventoryScanUnpackBatch, inventoryQuickStockInquiry, expenseControllerCreateExpense, expenseControllerGetExpenses, expenseControllerGetExpenseCategories, expenseControllerGetExpense, pettyCashControllerCreateFund, pettyCashControllerGetFunds, pettyCashControllerGetFund, pettyCashControllerTopUpFund, pettyCashControllerGetFundTransactions, utilityAccountControllerCreateAccount, utilityAccountControllerGetAccounts, utilityAccountControllerGetAccount, accountingInitialize, accountingGetProfitLoss, accountingGetBalanceSheet, accountingGetCashFlow, accountingGetTaxSummary, invoiceControllerCreateInvoice, invoiceControllerGetInvoices, invoiceControllerGetInvoice, invoiceControllerUpdateInvoice, invoiceControllerDeleteInvoice, invoiceControllerFinalizeInvoice, invoiceControllerGetTemplates, invoiceControllerCreateTemplate, invoiceControllerGetConfig, invoiceControllerUpdateConfig, publicInvoiceControllerDownloadInvoice, publicInvoiceControllerDownloadInvoiceByTransaction, publicInvoiceControllerDownloadReceipt, publicInvoiceControllerGeneratePublicLink, authExchangeToken, authControllerHandleOAuth2, adminControllerGetStats, adminControllerListOrganizations, adminControllerCreateOrganization, adminControllerGetOrganizationDetails, adminControllerUpdateOrganization, adminControllerDeleteOrganization, adminControllerListMembers, adminControllerListUsers, adminControllerBanUser, adminControllerUnbanUser, adminControllerListConnectedApps, adminControllerListSystemLogs, adminControllerListGlobalSettings, adminControllerSetGlobalSetting, adminControllerDeleteGlobalSetting, adminControllerListTiers, adminControllerDefineTier, adminControllerDeleteTier, adminControllerGetOrganizationSubscription, adminControllerUpdateOrganizationSubscription, adminControllerListSystemPayments, adminControllerRecordCustomPayment, adminControllerListIntegrationDefinitions, adminControllerCreateIntegrationDefinition, adminControllerUpdateIntegrationDefinition, adminControllerDeleteIntegrationDefinition, adminControllerListActiveOrganizationIntegrations, webhooksCreate, webhooksList, webhooksDelete, windmillCallbackControllerHandleCallback, windmillCallbackControllerHandleApprovalCallback, windmillCallbackControllerHandleBakeryDisposalCallback, windmillCallbackControllerHandleOutcomeCallback, catalogGetProducts, catalogCreateProduct, catalogGetServices, catalogUpdateProduct, catalogUpdateSupplierVariant, catalogGetPriceChangeRequests, catalogReviewPriceChangeRequest, servicesCreateCategory, servicesGetCategories, servicesUpdateCategory, servicesDeleteCategory, servicesCreateService, servicesGetServices, servicesGetCurrentMemberShifts, servicesGetShifts, servicesGetService, servicesUpdateService, servicesDeleteService, servicesCreateResource, servicesGetResources, servicesUpdateResource, servicesDeleteResource, servicesCreateBooking, servicesGetBookings, servicesGetBooking, servicesUpdateBookingStatus, servicesCompleteBooking, servicesCreateShift, servicesGetStaffShifts, servicesAddBreak, servicesRegisterCustomerApp, servicesGetUtilization, servicesGetPerformance, servicesGetFunnel, customersProvisionZitadel, customersGetCustomers, customersRegister, customersUpdate, customersGetCustomerById, customersDelete, customersGetAddresses, customersAddAddress, businessAccountControllerCreate, businessAccountControllerGetOne, crmControllerCreateRecord, crmControllerGetRecord, crmControllerUpdateRecord, crmControllerCreateNote, crmControllerGetRecordNotes, crmControllerCreateActivity, crmControllerGetTimeline, crmControllerCreateObject, crmControllerListObjects, crmControllerCreateField, crmControllerListFields, crmControllerCreateRelationship, crmControllerListRelationships, crmControllerCreateAssociation, crmControllerListRecordAssociations, loyaltyRedeemReward, loyaltyGetCustomerStatus, loyaltyValidateVoucher, ordersCreateOrder, ordersGetOrders, ordersUpdateStatus, ordersRequestB2BQuote, ordersConvertQuoteToOrder, paymentsControllerHandleStkCallback, pOSProvision, pOSLogin, pOSGetMe, pOSProcessSale, pOSSync, pOSGetTransactions, pOSRegisterPettyCash, pOSGetPettyCashFunds, pOSGetPettyCashTransactions, membersControllerGetMembers, membersControllerCreateMember, membersControllerGetMember, membersControllerUpdateMember, membersControllerDeleteMember, membersControllerGetMemberActivity, membersControllerUpdateStatus, membersControllerAdminCheckOut, terminalMembersControllerLogin, invitationsList, invitationsCreate, invitationsRevoke, invitationsAccept, roleManagementControllerGetCustomRoles, roleManagementControllerCreateCustomRole, roleManagementControllerUpdateCustomRole, roleManagementControllerDeleteCustomRole, roleManagementControllerGetPermissionSets, roleManagementControllerCreatePermissionSet, roleManagementControllerGetRoleGroups, roleManagementControllerCreateRoleGroup, roleManagementControllerAssignRoles, roleManagementControllerRemoveRoles, departmentsList, departmentsCreate, departmentsGet, departmentsUpdate, departmentsDelete, departmentsAddMember, departmentsRemoveMember, attendanceControllerGetLogs, attendanceControllerCheckIn, attendanceControllerCheckOut, attendanceControllerGetMyStatus, attendanceControllerGetStatus, announcementControllerBroadcastAnnouncement, cartControllerGetCart, cartControllerClearCart, cartControllerAddToCart, cartControllerRemoveFromCart, favoritesControllerGetFavorites, favoritesControllerAddFavorite, favoritesControllerRemoveFavorite, stockingGetPurchases, stockingCreatePurchase, stockingReceivePurchase, stockingGetTransfers, stockingCreateTransfer, stockingShipTransfer, stockingReceiveTransfer, stockingGetRequests, stockingGetPendingDispatch, stockingDispatchOrders, stockingGetActiveDeliveries, stockingReconcilePod, stockingGetPhysicalReconciliations, stockingSubmitPhysicalReconciliation, stockingGetReconciliationReport, stockingGetPartners, stockingCreatePartner, stockingGetPartner, stockingUpdatePartner, stockingAdjustPartnerWallet, standalonePosControllerCreateSetupKey, standalonePosControllerActivateDevice, standalonePosControllerValidateKey, standalonePosControllerLinkOrganization, b2BGetCatalog, b2BGetInvoices, b2BGetOrders, b2BCreateOrder, b2BCreateQuote, crmIntegrationsGetAuthUrl, crmIntegrationsHandleCallback, crmIntegrationsHandleWebhook, crmIntegrationsReplyToActivity, unitsGetUnits, strapiCreateConnection, strapiListConnections, strapiGetConnection, strapiUpdateConnection, strapiDeleteConnection, strapiTriggerSync, strapiEnqueueSync, strapiGetWebhookLogs, strapiGetSyncLogs, strapiExchangeCustomerToken, strapiRegisterCustomer, strapiReceiveWebhook, analyticsControllerGetDashboardAnalytics, analyticsControllerGetResourceUtilization };
|
|
1899
|
+
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 };
|
|
1815
1900
|
};
|
|
1816
1901
|
|
|
1817
1902
|
// src/base.ts
|
|
1818
1903
|
var methodsWithOrgSlugSet = /* @__PURE__ */ new Set([
|
|
1904
|
+
"publicServicesListServices",
|
|
1905
|
+
"publicServicesGetCategories",
|
|
1906
|
+
"publicServicesGetService",
|
|
1907
|
+
"publicServicesGetAvailability",
|
|
1908
|
+
"publicServicesRequestOtp",
|
|
1909
|
+
"publicServicesVerifyOtp",
|
|
1910
|
+
"publicServicesCreatePublicBooking",
|
|
1819
1911
|
"inventoryVerifyIntegrity",
|
|
1820
1912
|
"inventoryFixIntegrity",
|
|
1821
1913
|
"inventoryGetInventory",
|
|
@@ -1884,6 +1976,7 @@ var methodsWithOrgSlugSet = /* @__PURE__ */ new Set([
|
|
|
1884
1976
|
"customersDelete",
|
|
1885
1977
|
"customersGetAddresses",
|
|
1886
1978
|
"customersAddAddress",
|
|
1979
|
+
"customersGetCurrentSession",
|
|
1887
1980
|
"businessAccountControllerCreate",
|
|
1888
1981
|
"businessAccountControllerGetOne",
|
|
1889
1982
|
"crmControllerCreateRecord",
|
|
@@ -1941,7 +2034,14 @@ var methodsWithOrgSlugSet = /* @__PURE__ */ new Set([
|
|
|
1941
2034
|
"roleManagementControllerCreateRoleGroup",
|
|
1942
2035
|
"roleManagementControllerAssignRoles",
|
|
1943
2036
|
"roleManagementControllerRemoveRoles",
|
|
1944
|
-
"departmentsList"
|
|
2037
|
+
"departmentsList",
|
|
2038
|
+
"cartControllerGetCart",
|
|
2039
|
+
"cartControllerClearCart",
|
|
2040
|
+
"cartControllerAddToCart",
|
|
2041
|
+
"cartControllerRemoveFromCart",
|
|
2042
|
+
"favoritesControllerGetFavorites",
|
|
2043
|
+
"favoritesControllerAddFavorite",
|
|
2044
|
+
"favoritesControllerRemoveFavorite"
|
|
1945
2045
|
]);
|
|
1946
2046
|
var catalogMapping = {
|
|
1947
2047
|
getProducts: "catalogGetProducts",
|
|
@@ -2168,6 +2268,46 @@ var membersMapping = {
|
|
|
2168
2268
|
getAttendanceStatus: "attendanceControllerGetStatus",
|
|
2169
2269
|
broadcastAnnouncement: "announcementControllerBroadcastAnnouncement"
|
|
2170
2270
|
};
|
|
2271
|
+
var publicServicesMapping = {
|
|
2272
|
+
listServices: "publicServicesListServices",
|
|
2273
|
+
getCategories: "publicServicesGetCategories",
|
|
2274
|
+
getService: "publicServicesGetService",
|
|
2275
|
+
getAvailability: "publicServicesGetAvailability",
|
|
2276
|
+
requestOtp: "publicServicesRequestOtp",
|
|
2277
|
+
verifyOtp: "publicServicesVerifyOtp",
|
|
2278
|
+
createBooking: "publicServicesCreatePublicBooking"
|
|
2279
|
+
};
|
|
2280
|
+
var servicesMapping = {
|
|
2281
|
+
...publicServicesMapping,
|
|
2282
|
+
// Admin / Staff scheduling endpoints
|
|
2283
|
+
createCategory: "servicesCreateCategory",
|
|
2284
|
+
getCategoriesAdmin: "servicesGetCategories",
|
|
2285
|
+
updateCategory: "servicesUpdateCategory",
|
|
2286
|
+
deleteCategory: "servicesDeleteCategory",
|
|
2287
|
+
createService: "servicesCreateService",
|
|
2288
|
+
getServicesAdmin: "servicesGetServices",
|
|
2289
|
+
getCurrentMemberShifts: "servicesGetCurrentMemberShifts",
|
|
2290
|
+
getShifts: "servicesGetShifts",
|
|
2291
|
+
getServiceAdmin: "servicesGetService",
|
|
2292
|
+
updateService: "servicesUpdateService",
|
|
2293
|
+
deleteService: "servicesDeleteService",
|
|
2294
|
+
createResource: "servicesCreateResource",
|
|
2295
|
+
getResources: "servicesGetResources",
|
|
2296
|
+
updateResource: "servicesUpdateResource",
|
|
2297
|
+
deleteResource: "servicesDeleteResource",
|
|
2298
|
+
createBookingAdmin: "servicesCreateBooking",
|
|
2299
|
+
getBookings: "servicesGetBookings",
|
|
2300
|
+
getBookingAdmin: "servicesGetBooking",
|
|
2301
|
+
updateBookingStatus: "servicesUpdateBookingStatus",
|
|
2302
|
+
completeBooking: "servicesCompleteBooking",
|
|
2303
|
+
createShift: "servicesCreateShift",
|
|
2304
|
+
getStaffShifts: "servicesGetStaffShifts",
|
|
2305
|
+
addBreak: "servicesAddBreak",
|
|
2306
|
+
registerCustomerApp: "servicesRegisterCustomerApp",
|
|
2307
|
+
getServiceUtilization: "servicesGetUtilization",
|
|
2308
|
+
getServicePerformance: "servicesGetPerformance",
|
|
2309
|
+
getServiceFunnel: "servicesGetFunnel"
|
|
2310
|
+
};
|
|
2171
2311
|
var adminMapping = {
|
|
2172
2312
|
getStats: "adminControllerGetStats",
|
|
2173
2313
|
listOrganizations: "adminControllerListOrganizations",
|
|
@@ -2324,7 +2464,8 @@ var getScrymeV3API2 = (axiosInstance, defaultOrgSlug) => {
|
|
|
2324
2464
|
});
|
|
2325
2465
|
};
|
|
2326
2466
|
|
|
2327
|
-
// src/client.
|
|
2467
|
+
// src/client.tsx
|
|
2468
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
2328
2469
|
var InMemoryStorage = class {
|
|
2329
2470
|
constructor() {
|
|
2330
2471
|
this.cache = /* @__PURE__ */ new Map();
|
|
@@ -2344,11 +2485,17 @@ var SCRYME_USER_KEY = "scryme_user";
|
|
|
2344
2485
|
var SCRYME_EXPIRES_AT_KEY = "scryme_expires_at";
|
|
2345
2486
|
var ScrymeClientSDK = class {
|
|
2346
2487
|
constructor(config) {
|
|
2347
|
-
if (!config || !config.clientId || !config.
|
|
2348
|
-
throw new Error(
|
|
2488
|
+
if (!config || !config.clientId || !config.orgSlug) {
|
|
2489
|
+
throw new Error(
|
|
2490
|
+
"clientId and orgSlug are required to initialize the SDK."
|
|
2491
|
+
);
|
|
2492
|
+
}
|
|
2493
|
+
let finalBaseURL = config.baseURL || "https://api.scryme.tech";
|
|
2494
|
+
if (finalBaseURL && !finalBaseURL.includes("/api") && !finalBaseURL.endsWith("/api")) {
|
|
2495
|
+
finalBaseURL = finalBaseURL.replace(/\/$/, "") + "/api";
|
|
2349
2496
|
}
|
|
2350
2497
|
this.axiosInstance = import_axios3.default.create({
|
|
2351
|
-
baseURL:
|
|
2498
|
+
baseURL: finalBaseURL
|
|
2352
2499
|
});
|
|
2353
2500
|
let storage;
|
|
2354
2501
|
if (config.storage) {
|
|
@@ -2398,7 +2545,7 @@ var ScrymeClientSDK = class {
|
|
|
2398
2545
|
try {
|
|
2399
2546
|
state.user = JSON.parse(storedUser);
|
|
2400
2547
|
} catch {
|
|
2401
|
-
state.user =
|
|
2548
|
+
state.user = null;
|
|
2402
2549
|
}
|
|
2403
2550
|
}
|
|
2404
2551
|
notify("INITIAL_SESSION");
|
|
@@ -2416,7 +2563,7 @@ var ScrymeClientSDK = class {
|
|
|
2416
2563
|
try {
|
|
2417
2564
|
const response = await this.api.authExchangeToken({
|
|
2418
2565
|
clientId: config.clientId,
|
|
2419
|
-
clientSecret: config.clientSecret
|
|
2566
|
+
clientSecret: config.clientSecret || ""
|
|
2420
2567
|
});
|
|
2421
2568
|
const tokenData = response.data?.data;
|
|
2422
2569
|
const accessToken = tokenData?.access_token;
|
|
@@ -2425,7 +2572,10 @@ var ScrymeClientSDK = class {
|
|
|
2425
2572
|
state.token = accessToken;
|
|
2426
2573
|
if (expiresIn) {
|
|
2427
2574
|
state.expiresAt = Date.now() + expiresIn * 1e3;
|
|
2428
|
-
await storage.setItem(
|
|
2575
|
+
await storage.setItem(
|
|
2576
|
+
SCRYME_EXPIRES_AT_KEY,
|
|
2577
|
+
String(state.expiresAt)
|
|
2578
|
+
);
|
|
2429
2579
|
} else {
|
|
2430
2580
|
const jwtExp = getJwtExpiry(accessToken);
|
|
2431
2581
|
if (jwtExp) {
|
|
@@ -2447,14 +2597,28 @@ var ScrymeClientSDK = class {
|
|
|
2447
2597
|
};
|
|
2448
2598
|
this.axiosInstance.interceptors.request.use(async (req) => {
|
|
2449
2599
|
await initPromise;
|
|
2450
|
-
const isAuthTokenRequest = req.url && (req.url.endsWith("/auth/token") || req.url.includes("/auth/token"));
|
|
2600
|
+
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"));
|
|
2451
2601
|
if (!isAuthTokenRequest) {
|
|
2452
|
-
const isExpired = !state.token || state.expiresAt && Date.now() >= state.expiresAt - 3e4;
|
|
2453
|
-
if (isExpired
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2602
|
+
const isExpired = !state.token || state.expiresAt && Date.now() >= (state.expiresAt || 0) - 3e4;
|
|
2603
|
+
if (isExpired) {
|
|
2604
|
+
if (state.token) {
|
|
2605
|
+
try {
|
|
2606
|
+
await this.auth.refreshSession();
|
|
2607
|
+
} catch (e) {
|
|
2608
|
+
console.error(
|
|
2609
|
+
"Proactive customer session refresh failed in request interceptor:",
|
|
2610
|
+
e
|
|
2611
|
+
);
|
|
2612
|
+
}
|
|
2613
|
+
} else if (config.clientId && config.clientSecret) {
|
|
2614
|
+
try {
|
|
2615
|
+
await performExchange();
|
|
2616
|
+
} catch (e) {
|
|
2617
|
+
console.error(
|
|
2618
|
+
"Auto-authentication failed in request interceptor:",
|
|
2619
|
+
e
|
|
2620
|
+
);
|
|
2621
|
+
}
|
|
2458
2622
|
}
|
|
2459
2623
|
}
|
|
2460
2624
|
}
|
|
@@ -2467,15 +2631,23 @@ var ScrymeClientSDK = class {
|
|
|
2467
2631
|
(response) => response,
|
|
2468
2632
|
async (error) => {
|
|
2469
2633
|
const originalRequest = error.config;
|
|
2470
|
-
const isAuthTokenRequest = originalRequest && originalRequest.url && (originalRequest.url.endsWith("/auth/token") || originalRequest.url.includes("/auth/token"));
|
|
2471
|
-
if (error.response && error.response.status === 401 && originalRequest && !originalRequest._retry && !isAuthTokenRequest
|
|
2634
|
+
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"));
|
|
2635
|
+
if (error.response && error.response.status === 401 && originalRequest && !originalRequest._retry && !isAuthTokenRequest) {
|
|
2472
2636
|
originalRequest._retry = true;
|
|
2473
2637
|
try {
|
|
2474
|
-
await performExchange();
|
|
2475
2638
|
if (state.token) {
|
|
2476
|
-
|
|
2639
|
+
await this.auth.refreshSession();
|
|
2640
|
+
if (state.token) {
|
|
2641
|
+
originalRequest.headers["Authorization"] = `Bearer ${state.token}`;
|
|
2642
|
+
}
|
|
2643
|
+
return this.axiosInstance(originalRequest);
|
|
2644
|
+
} else if (config.clientId && config.clientSecret) {
|
|
2645
|
+
await performExchange();
|
|
2646
|
+
if (state.token) {
|
|
2647
|
+
originalRequest.headers["Authorization"] = `Bearer ${state.token}`;
|
|
2648
|
+
}
|
|
2649
|
+
return this.axiosInstance(originalRequest);
|
|
2477
2650
|
}
|
|
2478
|
-
return this.axiosInstance(originalRequest);
|
|
2479
2651
|
} catch (e) {
|
|
2480
2652
|
return Promise.reject(error);
|
|
2481
2653
|
}
|
|
@@ -2493,6 +2665,149 @@ var ScrymeClientSDK = class {
|
|
|
2493
2665
|
this.loyalty = buildModule(this.api, config.orgSlug, loyaltyMapping);
|
|
2494
2666
|
this.members = buildModule(this.api, config.orgSlug, membersMapping);
|
|
2495
2667
|
this.admin = buildModule(this.api, config.orgSlug, adminMapping);
|
|
2668
|
+
this.cart = {
|
|
2669
|
+
get: async (params) => {
|
|
2670
|
+
return this.orders.getCart(params || {});
|
|
2671
|
+
},
|
|
2672
|
+
add: async (dto) => {
|
|
2673
|
+
return this.orders.addToCart(dto);
|
|
2674
|
+
},
|
|
2675
|
+
remove: async (dto) => {
|
|
2676
|
+
return this.orders.removeFromCart(dto);
|
|
2677
|
+
},
|
|
2678
|
+
clear: async (params) => {
|
|
2679
|
+
return this.orders.clearCart(params || {});
|
|
2680
|
+
},
|
|
2681
|
+
update: async (dto) => {
|
|
2682
|
+
const response = await this.orders.getCart({
|
|
2683
|
+
sessionId: dto.sessionId
|
|
2684
|
+
});
|
|
2685
|
+
const data = response.data;
|
|
2686
|
+
const items = data?.data?.items || data?.items || [];
|
|
2687
|
+
let existingItem = null;
|
|
2688
|
+
if (dto.productId) {
|
|
2689
|
+
existingItem = items.find(
|
|
2690
|
+
(item) => item.productId === dto.productId && (item.variantId || null) === (dto.variantId || null)
|
|
2691
|
+
);
|
|
2692
|
+
} else if (dto.serviceId) {
|
|
2693
|
+
existingItem = items.find(
|
|
2694
|
+
(item) => item.serviceId === dto.serviceId
|
|
2695
|
+
);
|
|
2696
|
+
}
|
|
2697
|
+
if (existingItem) {
|
|
2698
|
+
const currentQty = existingItem.quantity || 0;
|
|
2699
|
+
if (dto.quantity <= 0) {
|
|
2700
|
+
return this.orders.removeFromCart({
|
|
2701
|
+
productId: dto.productId,
|
|
2702
|
+
variantId: dto.variantId,
|
|
2703
|
+
serviceId: dto.serviceId,
|
|
2704
|
+
sessionId: dto.sessionId,
|
|
2705
|
+
customerId: dto.customerId
|
|
2706
|
+
});
|
|
2707
|
+
} else {
|
|
2708
|
+
const diff = dto.quantity - currentQty;
|
|
2709
|
+
if (diff !== 0) {
|
|
2710
|
+
return this.orders.addToCart({
|
|
2711
|
+
...dto,
|
|
2712
|
+
quantity: diff
|
|
2713
|
+
});
|
|
2714
|
+
}
|
|
2715
|
+
return response;
|
|
2716
|
+
}
|
|
2717
|
+
} else {
|
|
2718
|
+
if (dto.quantity > 0) {
|
|
2719
|
+
return this.orders.addToCart(dto);
|
|
2720
|
+
}
|
|
2721
|
+
}
|
|
2722
|
+
},
|
|
2723
|
+
getItems: async (params) => {
|
|
2724
|
+
const res = await this.orders.getCart(params || {});
|
|
2725
|
+
const data = res?.data || res;
|
|
2726
|
+
return data?.items || data?.data?.items || [];
|
|
2727
|
+
},
|
|
2728
|
+
getTotals: async (params) => {
|
|
2729
|
+
const res = await this.orders.getCart(params || {});
|
|
2730
|
+
const data = res?.data || res;
|
|
2731
|
+
const items = data?.items || data?.data?.items || [];
|
|
2732
|
+
const itemsCount = items.reduce(
|
|
2733
|
+
(sum, item) => sum + (item.quantity || 0),
|
|
2734
|
+
0
|
|
2735
|
+
);
|
|
2736
|
+
return {
|
|
2737
|
+
itemsCount,
|
|
2738
|
+
items,
|
|
2739
|
+
raw: data
|
|
2740
|
+
};
|
|
2741
|
+
},
|
|
2742
|
+
mergeGuestCart: async (guestSessionId, customerId) => {
|
|
2743
|
+
return this.orders.getCart({ sessionId: guestSessionId });
|
|
2744
|
+
},
|
|
2745
|
+
checkout: async (params) => {
|
|
2746
|
+
const session = await this.auth.getSession();
|
|
2747
|
+
const user = session.user;
|
|
2748
|
+
const customerId = user?.customerId || user?.id || user?.customer?.id;
|
|
2749
|
+
if (!customerId)
|
|
2750
|
+
throw new Error("No authenticated customer found for checkout.");
|
|
2751
|
+
const items = await this.cart.getItems();
|
|
2752
|
+
if (!items || items.length === 0) {
|
|
2753
|
+
throw new Error("Cannot checkout an empty cart.");
|
|
2754
|
+
}
|
|
2755
|
+
const orderItems = items.map((item) => ({
|
|
2756
|
+
variantId: item.variantId || "",
|
|
2757
|
+
quantity: item.quantity,
|
|
2758
|
+
unitPrice: item.unitPrice
|
|
2759
|
+
}));
|
|
2760
|
+
const orderResponse = await this.orders.createOrder({
|
|
2761
|
+
customerId,
|
|
2762
|
+
locationId: params.locationId,
|
|
2763
|
+
items: orderItems,
|
|
2764
|
+
notes: params.notes,
|
|
2765
|
+
channel: params.channel
|
|
2766
|
+
});
|
|
2767
|
+
await this.cart.clear();
|
|
2768
|
+
return orderResponse?.data || orderResponse;
|
|
2769
|
+
}
|
|
2770
|
+
};
|
|
2771
|
+
this.customer = {
|
|
2772
|
+
getProfile: async () => {
|
|
2773
|
+
return this.auth.getCurrentSession();
|
|
2774
|
+
},
|
|
2775
|
+
updateProfile: async (dto) => {
|
|
2776
|
+
const session = await this.auth.getSession();
|
|
2777
|
+
const user = session.user;
|
|
2778
|
+
const customerId = user?.customerId || user?.id || user?.customer?.id;
|
|
2779
|
+
if (!customerId) throw new Error("No authenticated customer found.");
|
|
2780
|
+
return this.admin.updateCustomer(customerId, dto);
|
|
2781
|
+
},
|
|
2782
|
+
getAddresses: async () => {
|
|
2783
|
+
const session = await this.auth.getSession();
|
|
2784
|
+
const user = session.user;
|
|
2785
|
+
const customerId = user?.customerId || user?.id || user?.customer?.id;
|
|
2786
|
+
if (!customerId) throw new Error("No authenticated customer found.");
|
|
2787
|
+
return this.admin.getCustomerAddresses(customerId);
|
|
2788
|
+
},
|
|
2789
|
+
addAddress: async (dto) => {
|
|
2790
|
+
const session = await this.auth.getSession();
|
|
2791
|
+
const user = session.user;
|
|
2792
|
+
const customerId = user?.customerId || user?.id || user?.customer?.id;
|
|
2793
|
+
if (!customerId) throw new Error("No authenticated customer found.");
|
|
2794
|
+
return this.admin.addCustomerAddress(customerId, dto);
|
|
2795
|
+
}
|
|
2796
|
+
};
|
|
2797
|
+
this.bookings = {
|
|
2798
|
+
create: async (dto) => {
|
|
2799
|
+
return this.catalog.createBooking(dto);
|
|
2800
|
+
},
|
|
2801
|
+
get: async (id) => {
|
|
2802
|
+
return this.catalog.getBooking(id);
|
|
2803
|
+
},
|
|
2804
|
+
list: async () => {
|
|
2805
|
+
return this.catalog.getBookings();
|
|
2806
|
+
},
|
|
2807
|
+
cancel: async (id) => {
|
|
2808
|
+
return this.catalog.updateBookingStatus(id, "CANCELLED");
|
|
2809
|
+
}
|
|
2810
|
+
};
|
|
2496
2811
|
const baseAuth = buildModule(this.api, config.orgSlug, authMapping);
|
|
2497
2812
|
this.auth = {
|
|
2498
2813
|
...baseAuth,
|
|
@@ -2503,10 +2818,45 @@ var ScrymeClientSDK = class {
|
|
|
2503
2818
|
return performExchange();
|
|
2504
2819
|
},
|
|
2505
2820
|
signIn: async (credentials) => {
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2821
|
+
try {
|
|
2822
|
+
const authServiceUrl = process.env.CUSTOMER_AUTH_URL || `${this.axiosInstance.defaults.baseURL || "http://localhost:3002"}/api/customer-auth`;
|
|
2823
|
+
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`;
|
|
2824
|
+
const response2 = await import_axios3.default.post(postUrl, credentials);
|
|
2825
|
+
const data2 = response2.data;
|
|
2826
|
+
const token2 = data2?.session?.token || data2?.token || null;
|
|
2827
|
+
const user2 = data2?.user || null;
|
|
2828
|
+
if (token2) {
|
|
2829
|
+
state.token = token2;
|
|
2830
|
+
state.user = user2;
|
|
2831
|
+
const jwtExp = getJwtExpiry(token2);
|
|
2832
|
+
await storage.setItem(SCRYME_SESSION_TOKEN_KEY, token2);
|
|
2833
|
+
if (jwtExp) {
|
|
2834
|
+
state.expiresAt = jwtExp;
|
|
2835
|
+
await storage.setItem(
|
|
2836
|
+
SCRYME_EXPIRES_AT_KEY,
|
|
2837
|
+
String(state.expiresAt)
|
|
2838
|
+
);
|
|
2839
|
+
} else {
|
|
2840
|
+
delete state.expiresAt;
|
|
2841
|
+
await storage.removeItem(SCRYME_EXPIRES_AT_KEY);
|
|
2842
|
+
}
|
|
2843
|
+
if (user2) {
|
|
2844
|
+
await storage.setItem(SCRYME_USER_KEY, JSON.stringify(user2));
|
|
2845
|
+
}
|
|
2846
|
+
notify("SIGNED_IN");
|
|
2847
|
+
return data2;
|
|
2848
|
+
} else {
|
|
2849
|
+
throw new Error("No token returned");
|
|
2850
|
+
}
|
|
2851
|
+
} catch (e) {
|
|
2852
|
+
}
|
|
2853
|
+
const response = await this.axiosInstance.post(
|
|
2854
|
+
`/${config.orgSlug}/customers/auth/login`,
|
|
2855
|
+
credentials
|
|
2856
|
+
);
|
|
2857
|
+
const data = response.data?.data || response.data;
|
|
2858
|
+
const token = data?.token || null;
|
|
2859
|
+
const user = data?.session || null;
|
|
2510
2860
|
if (token) {
|
|
2511
2861
|
state.token = token;
|
|
2512
2862
|
state.user = user;
|
|
@@ -2514,7 +2864,10 @@ var ScrymeClientSDK = class {
|
|
|
2514
2864
|
await storage.setItem(SCRYME_SESSION_TOKEN_KEY, token);
|
|
2515
2865
|
if (jwtExp) {
|
|
2516
2866
|
state.expiresAt = jwtExp;
|
|
2517
|
-
await storage.setItem(
|
|
2867
|
+
await storage.setItem(
|
|
2868
|
+
SCRYME_EXPIRES_AT_KEY,
|
|
2869
|
+
String(state.expiresAt)
|
|
2870
|
+
);
|
|
2518
2871
|
} else {
|
|
2519
2872
|
delete state.expiresAt;
|
|
2520
2873
|
await storage.removeItem(SCRYME_EXPIRES_AT_KEY);
|
|
@@ -2557,6 +2910,88 @@ var ScrymeClientSDK = class {
|
|
|
2557
2910
|
listeners.delete(callback);
|
|
2558
2911
|
}
|
|
2559
2912
|
};
|
|
2913
|
+
},
|
|
2914
|
+
getSessions: async () => {
|
|
2915
|
+
const res = await this.axiosInstance.get(
|
|
2916
|
+
`/${config.orgSlug}/customers/auth/sessions`
|
|
2917
|
+
);
|
|
2918
|
+
return res.data?.data || res.data;
|
|
2919
|
+
},
|
|
2920
|
+
revokeSession: async (id) => {
|
|
2921
|
+
const res = await this.axiosInstance.delete(
|
|
2922
|
+
`/${config.orgSlug}/customers/auth/sessions/${id}`
|
|
2923
|
+
);
|
|
2924
|
+
return res.data?.data || res.data;
|
|
2925
|
+
},
|
|
2926
|
+
revokeAllSessions: async (mode) => {
|
|
2927
|
+
const url = mode ? `/${config.orgSlug}/customers/auth/sessions?mode=${mode}` : `/${config.orgSlug}/customers/auth/sessions`;
|
|
2928
|
+
const res = await this.axiosInstance.delete(url);
|
|
2929
|
+
return res.data?.data || res.data;
|
|
2930
|
+
},
|
|
2931
|
+
getCurrentSession: async () => {
|
|
2932
|
+
const res = await this.axiosInstance.get(
|
|
2933
|
+
`/${config.orgSlug}/customers/auth/session`
|
|
2934
|
+
);
|
|
2935
|
+
return res.data?.data || res.data;
|
|
2936
|
+
},
|
|
2937
|
+
refreshSession: async () => {
|
|
2938
|
+
const response = await this.axiosInstance.post(
|
|
2939
|
+
`/${config.orgSlug}/customers/auth/refresh`
|
|
2940
|
+
);
|
|
2941
|
+
const data = response.data?.data || response.data;
|
|
2942
|
+
const token = data?.token || null;
|
|
2943
|
+
const user = data?.session || null;
|
|
2944
|
+
if (token) {
|
|
2945
|
+
state.token = token;
|
|
2946
|
+
state.user = user;
|
|
2947
|
+
const jwtExp = getJwtExpiry(token);
|
|
2948
|
+
await storage.setItem(SCRYME_SESSION_TOKEN_KEY, token);
|
|
2949
|
+
if (jwtExp) {
|
|
2950
|
+
state.expiresAt = jwtExp;
|
|
2951
|
+
await storage.setItem(
|
|
2952
|
+
SCRYME_EXPIRES_AT_KEY,
|
|
2953
|
+
String(state.expiresAt)
|
|
2954
|
+
);
|
|
2955
|
+
} else {
|
|
2956
|
+
delete state.expiresAt;
|
|
2957
|
+
await storage.removeItem(SCRYME_EXPIRES_AT_KEY);
|
|
2958
|
+
}
|
|
2959
|
+
if (user) {
|
|
2960
|
+
await storage.setItem(SCRYME_USER_KEY, JSON.stringify(user));
|
|
2961
|
+
}
|
|
2962
|
+
notify("SIGNED_IN");
|
|
2963
|
+
}
|
|
2964
|
+
return data;
|
|
2965
|
+
},
|
|
2966
|
+
swapZitadel: async (zitadelToken) => {
|
|
2967
|
+
const response = await this.axiosInstance.post(
|
|
2968
|
+
`/${config.orgSlug}/customers/auth/swap-zitadel`,
|
|
2969
|
+
{ zitadelToken }
|
|
2970
|
+
);
|
|
2971
|
+
const data = response.data?.data || response.data;
|
|
2972
|
+
const token = data?.token || null;
|
|
2973
|
+
const user = data?.session || null;
|
|
2974
|
+
if (token) {
|
|
2975
|
+
state.token = token;
|
|
2976
|
+
state.user = user;
|
|
2977
|
+
const jwtExp = getJwtExpiry(token);
|
|
2978
|
+
await storage.setItem(SCRYME_SESSION_TOKEN_KEY, token);
|
|
2979
|
+
if (jwtExp) {
|
|
2980
|
+
state.expiresAt = jwtExp;
|
|
2981
|
+
await storage.setItem(
|
|
2982
|
+
SCRYME_EXPIRES_AT_KEY,
|
|
2983
|
+
String(state.expiresAt)
|
|
2984
|
+
);
|
|
2985
|
+
} else {
|
|
2986
|
+
delete state.expiresAt;
|
|
2987
|
+
await storage.removeItem(SCRYME_EXPIRES_AT_KEY);
|
|
2988
|
+
}
|
|
2989
|
+
if (user) {
|
|
2990
|
+
await storage.setItem(SCRYME_USER_KEY, JSON.stringify(user));
|
|
2991
|
+
}
|
|
2992
|
+
notify("SIGNED_IN");
|
|
2993
|
+
}
|
|
2994
|
+
return data;
|
|
2560
2995
|
}
|
|
2561
2996
|
};
|
|
2562
2997
|
}
|
|
@@ -2570,8 +3005,203 @@ function createClientSDK(config = {}) {
|
|
|
2570
3005
|
};
|
|
2571
3006
|
return new ScrymeClientSDK(finalConfig);
|
|
2572
3007
|
}
|
|
3008
|
+
var AuthContext = (0, import_react.createContext)(void 0);
|
|
3009
|
+
var ScrymeAuthProvider = ({
|
|
3010
|
+
sdk,
|
|
3011
|
+
children
|
|
3012
|
+
}) => {
|
|
3013
|
+
const [session, setSession] = (0, import_react.useState)({
|
|
3014
|
+
token: null,
|
|
3015
|
+
user: null
|
|
3016
|
+
});
|
|
3017
|
+
const [isLoading, setIsLoading] = (0, import_react.useState)(true);
|
|
3018
|
+
const [cart, setCart] = (0, import_react.useState)(null);
|
|
3019
|
+
const [cartLoading, setCartLoading] = (0, import_react.useState)(false);
|
|
3020
|
+
const [customerProfile, setCustomerProfile] = (0, import_react.useState)(null);
|
|
3021
|
+
const [customerAddresses, setCustomerAddresses] = (0, import_react.useState)([]);
|
|
3022
|
+
const [bookingsList, setBookingsList] = (0, import_react.useState)([]);
|
|
3023
|
+
const [bookingsLoading, setBookingsLoading] = (0, import_react.useState)(false);
|
|
3024
|
+
(0, import_react.useEffect)(() => {
|
|
3025
|
+
const { unsubscribe } = sdk.auth.onAuthStateChange((event, newSession) => {
|
|
3026
|
+
setSession(newSession);
|
|
3027
|
+
setIsLoading(false);
|
|
3028
|
+
});
|
|
3029
|
+
return () => unsubscribe();
|
|
3030
|
+
}, [sdk]);
|
|
3031
|
+
const refreshCart = async () => {
|
|
3032
|
+
if (!session.token) {
|
|
3033
|
+
setCart(null);
|
|
3034
|
+
return;
|
|
3035
|
+
}
|
|
3036
|
+
setCartLoading(true);
|
|
3037
|
+
try {
|
|
3038
|
+
const res = await sdk.cart.get();
|
|
3039
|
+
setCart(res.data?.data || res.data || null);
|
|
3040
|
+
} catch (err) {
|
|
3041
|
+
console.error("Failed to fetch cart:", err);
|
|
3042
|
+
} finally {
|
|
3043
|
+
setCartLoading(false);
|
|
3044
|
+
}
|
|
3045
|
+
};
|
|
3046
|
+
const refreshProfile = async () => {
|
|
3047
|
+
if (!session.token) {
|
|
3048
|
+
setCustomerProfile(null);
|
|
3049
|
+
setCustomerAddresses([]);
|
|
3050
|
+
return;
|
|
3051
|
+
}
|
|
3052
|
+
try {
|
|
3053
|
+
const profile = await sdk.customer.getProfile();
|
|
3054
|
+
setCustomerProfile(profile || null);
|
|
3055
|
+
const addresses = await sdk.customer.getAddresses();
|
|
3056
|
+
setCustomerAddresses(addresses?.data || addresses || []);
|
|
3057
|
+
} catch (err) {
|
|
3058
|
+
console.error("Failed to fetch customer profile or addresses:", err);
|
|
3059
|
+
}
|
|
3060
|
+
};
|
|
3061
|
+
const refreshBookings = async () => {
|
|
3062
|
+
if (!session.token) {
|
|
3063
|
+
setBookingsList([]);
|
|
3064
|
+
return;
|
|
3065
|
+
}
|
|
3066
|
+
setBookingsLoading(true);
|
|
3067
|
+
try {
|
|
3068
|
+
const res = await sdk.bookings.list();
|
|
3069
|
+
setBookingsList(res?.data || res || []);
|
|
3070
|
+
} catch (err) {
|
|
3071
|
+
console.error("Failed to fetch bookings:", err);
|
|
3072
|
+
} finally {
|
|
3073
|
+
setBookingsLoading(false);
|
|
3074
|
+
}
|
|
3075
|
+
};
|
|
3076
|
+
(0, import_react.useEffect)(() => {
|
|
3077
|
+
if (session.token) {
|
|
3078
|
+
refreshCart();
|
|
3079
|
+
refreshProfile();
|
|
3080
|
+
refreshBookings();
|
|
3081
|
+
} else {
|
|
3082
|
+
setCart(null);
|
|
3083
|
+
setCustomerProfile(null);
|
|
3084
|
+
setCustomerAddresses([]);
|
|
3085
|
+
setBookingsList([]);
|
|
3086
|
+
}
|
|
3087
|
+
}, [session.token]);
|
|
3088
|
+
const signIn = async (credentials) => {
|
|
3089
|
+
const res = await sdk.auth.signIn(credentials);
|
|
3090
|
+
return res;
|
|
3091
|
+
};
|
|
3092
|
+
const signUp = async (dto) => {
|
|
3093
|
+
const res = await sdk.auth.signUp(dto);
|
|
3094
|
+
return res;
|
|
3095
|
+
};
|
|
3096
|
+
const signOut = async () => {
|
|
3097
|
+
await sdk.auth.signOut();
|
|
3098
|
+
};
|
|
3099
|
+
const addToCart = async (dto) => {
|
|
3100
|
+
if (!session.token)
|
|
3101
|
+
throw new Error("Customer must be logged in to manage cart");
|
|
3102
|
+
await sdk.cart.add(dto);
|
|
3103
|
+
await refreshCart();
|
|
3104
|
+
};
|
|
3105
|
+
const removeFromCart = async (dto) => {
|
|
3106
|
+
if (!session.token)
|
|
3107
|
+
throw new Error("Customer must be logged in to manage cart");
|
|
3108
|
+
await sdk.cart.remove(dto);
|
|
3109
|
+
await refreshCart();
|
|
3110
|
+
};
|
|
3111
|
+
const updateCartItem = async (dto) => {
|
|
3112
|
+
if (!session.token)
|
|
3113
|
+
throw new Error("Customer must be logged in to manage cart");
|
|
3114
|
+
await sdk.cart.update(dto);
|
|
3115
|
+
await refreshCart();
|
|
3116
|
+
};
|
|
3117
|
+
const clearCart = async (params) => {
|
|
3118
|
+
if (!session.token)
|
|
3119
|
+
throw new Error("Customer must be logged in to manage cart");
|
|
3120
|
+
await sdk.cart.clear(params);
|
|
3121
|
+
await refreshCart();
|
|
3122
|
+
};
|
|
3123
|
+
const addAddress = async (dto) => {
|
|
3124
|
+
if (!session.token)
|
|
3125
|
+
throw new Error("Customer must be logged in to manage addresses");
|
|
3126
|
+
const res = await sdk.customer.addAddress(dto);
|
|
3127
|
+
await refreshProfile();
|
|
3128
|
+
return res;
|
|
3129
|
+
};
|
|
3130
|
+
const updateProfile = async (dto) => {
|
|
3131
|
+
if (!session.token)
|
|
3132
|
+
throw new Error("Customer must be logged in to update profile");
|
|
3133
|
+
const res = await sdk.customer.updateProfile(dto);
|
|
3134
|
+
await refreshProfile();
|
|
3135
|
+
return res;
|
|
3136
|
+
};
|
|
3137
|
+
const createBooking = async (dto) => {
|
|
3138
|
+
if (!session.token)
|
|
3139
|
+
throw new Error("Customer must be logged in to create bookings");
|
|
3140
|
+
const res = await sdk.bookings.create(dto);
|
|
3141
|
+
await refreshBookings();
|
|
3142
|
+
return res;
|
|
3143
|
+
};
|
|
3144
|
+
const cancelBooking = async (id) => {
|
|
3145
|
+
if (!session.token)
|
|
3146
|
+
throw new Error("Customer must be logged in to cancel bookings");
|
|
3147
|
+
const res = await sdk.bookings.cancel(id);
|
|
3148
|
+
await refreshBookings();
|
|
3149
|
+
return res;
|
|
3150
|
+
};
|
|
3151
|
+
const checkoutCart = async (params) => {
|
|
3152
|
+
if (!session.token)
|
|
3153
|
+
throw new Error("Customer must be logged in to checkout");
|
|
3154
|
+
const res = await sdk.cart.checkout(params);
|
|
3155
|
+
await refreshCart();
|
|
3156
|
+
await refreshBookings();
|
|
3157
|
+
return res;
|
|
3158
|
+
};
|
|
3159
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
3160
|
+
AuthContext.Provider,
|
|
3161
|
+
{
|
|
3162
|
+
value: {
|
|
3163
|
+
sdk,
|
|
3164
|
+
session,
|
|
3165
|
+
user: session.user,
|
|
3166
|
+
token: session.token,
|
|
3167
|
+
isLoading,
|
|
3168
|
+
signIn,
|
|
3169
|
+
signUp,
|
|
3170
|
+
signOut,
|
|
3171
|
+
cart,
|
|
3172
|
+
cartLoading,
|
|
3173
|
+
addToCart,
|
|
3174
|
+
removeFromCart,
|
|
3175
|
+
updateCartItem,
|
|
3176
|
+
clearCart,
|
|
3177
|
+
refreshCart,
|
|
3178
|
+
customerProfile,
|
|
3179
|
+
customerAddresses,
|
|
3180
|
+
bookings: bookingsList,
|
|
3181
|
+
bookingsLoading,
|
|
3182
|
+
addAddress,
|
|
3183
|
+
updateProfile,
|
|
3184
|
+
createBooking,
|
|
3185
|
+
cancelBooking,
|
|
3186
|
+
checkoutCart,
|
|
3187
|
+
refreshProfile,
|
|
3188
|
+
refreshBookings
|
|
3189
|
+
},
|
|
3190
|
+
children
|
|
3191
|
+
}
|
|
3192
|
+
);
|
|
3193
|
+
};
|
|
3194
|
+
var useScrymeAuth = () => {
|
|
3195
|
+
const context = (0, import_react.useContext)(AuthContext);
|
|
3196
|
+
if (context === void 0) {
|
|
3197
|
+
throw new Error("useScrymeAuth must be used within a ScrymeAuthProvider");
|
|
3198
|
+
}
|
|
3199
|
+
return context;
|
|
3200
|
+
};
|
|
2573
3201
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2574
3202
|
0 && (module.exports = {
|
|
3203
|
+
ScrymeAuthProvider,
|
|
2575
3204
|
ScrymeClientSDK,
|
|
2576
|
-
createClientSDK
|
|
3205
|
+
createClientSDK,
|
|
3206
|
+
useScrymeAuth
|
|
2577
3207
|
});
|