@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/index.js
CHANGED
|
@@ -64,6 +64,7 @@ __export(index_exports, {
|
|
|
64
64
|
RegisterPettyCashDtoPaymentMethod: () => RegisterPettyCashDtoPaymentMethod,
|
|
65
65
|
ReviewPriceChangeDtoStatus: () => ReviewPriceChangeDtoStatus,
|
|
66
66
|
RoleManagementControllerGetCustomRolesSortOrder: () => RoleManagementControllerGetCustomRolesSortOrder,
|
|
67
|
+
ScrymeAuthProvider: () => ScrymeAuthProvider,
|
|
67
68
|
ScrymeClientSDK: () => ScrymeClientSDK,
|
|
68
69
|
ScrymeServerSDK: () => ScrymeServerSDK,
|
|
69
70
|
ServicesUpdateBookingStatusBodyStatus: () => ServicesUpdateBookingStatusBodyStatus,
|
|
@@ -94,7 +95,10 @@ __export(index_exports, {
|
|
|
94
95
|
membersMapping: () => membersMapping,
|
|
95
96
|
methodsWithOrgSlugSet: () => methodsWithOrgSlugSet,
|
|
96
97
|
ordersMapping: () => ordersMapping,
|
|
97
|
-
posMapping: () => posMapping
|
|
98
|
+
posMapping: () => posMapping,
|
|
99
|
+
publicServicesMapping: () => publicServicesMapping,
|
|
100
|
+
servicesMapping: () => servicesMapping,
|
|
101
|
+
useScrymeAuth: () => useScrymeAuth
|
|
98
102
|
});
|
|
99
103
|
module.exports = __toCommonJS(index_exports);
|
|
100
104
|
|
|
@@ -403,10 +407,10 @@ var getScrymeV3API = (axiosInstance = import_axios.default) => {
|
|
|
403
407
|
options
|
|
404
408
|
);
|
|
405
409
|
};
|
|
406
|
-
const invoiceControllerCreateTemplate = (options) => {
|
|
410
|
+
const invoiceControllerCreateTemplate = (createInvoiceTemplateDto, options) => {
|
|
407
411
|
return axiosInstance.post(
|
|
408
412
|
`/v3/finance/invoices/templates`,
|
|
409
|
-
|
|
413
|
+
createInvoiceTemplateDto,
|
|
410
414
|
options
|
|
411
415
|
);
|
|
412
416
|
};
|
|
@@ -939,6 +943,54 @@ var getScrymeV3API = (axiosInstance = import_axios.default) => {
|
|
|
939
943
|
}
|
|
940
944
|
);
|
|
941
945
|
};
|
|
946
|
+
const publicServicesListServices = (orgSlug, options) => {
|
|
947
|
+
return axiosInstance.get(
|
|
948
|
+
`/v3/public/${orgSlug}/services`,
|
|
949
|
+
options
|
|
950
|
+
);
|
|
951
|
+
};
|
|
952
|
+
const publicServicesGetCategories = (orgSlug, options) => {
|
|
953
|
+
return axiosInstance.get(
|
|
954
|
+
`/v3/public/${orgSlug}/services/categories`,
|
|
955
|
+
options
|
|
956
|
+
);
|
|
957
|
+
};
|
|
958
|
+
const publicServicesGetService = (orgSlug, id, options) => {
|
|
959
|
+
return axiosInstance.get(
|
|
960
|
+
`/v3/public/${orgSlug}/services/${id}`,
|
|
961
|
+
options
|
|
962
|
+
);
|
|
963
|
+
};
|
|
964
|
+
const publicServicesGetAvailability = (orgSlug, id, params, options) => {
|
|
965
|
+
return axiosInstance.get(
|
|
966
|
+
`/v3/public/${orgSlug}/services/${id}/availability`,
|
|
967
|
+
{
|
|
968
|
+
...options,
|
|
969
|
+
params: { ...params, ...options?.params }
|
|
970
|
+
}
|
|
971
|
+
);
|
|
972
|
+
};
|
|
973
|
+
const publicServicesRequestOtp = (orgSlug, requestOtpDto, options) => {
|
|
974
|
+
return axiosInstance.post(
|
|
975
|
+
`/v3/public/${orgSlug}/services/otp/request`,
|
|
976
|
+
requestOtpDto,
|
|
977
|
+
options
|
|
978
|
+
);
|
|
979
|
+
};
|
|
980
|
+
const publicServicesVerifyOtp = (orgSlug, verifyOtpDto, options) => {
|
|
981
|
+
return axiosInstance.post(
|
|
982
|
+
`/v3/public/${orgSlug}/services/otp/verify`,
|
|
983
|
+
verifyOtpDto,
|
|
984
|
+
options
|
|
985
|
+
);
|
|
986
|
+
};
|
|
987
|
+
const publicServicesCreatePublicBooking = (orgSlug, publicBookingDto, options) => {
|
|
988
|
+
return axiosInstance.post(
|
|
989
|
+
`/v3/public/${orgSlug}/services/bookings`,
|
|
990
|
+
publicBookingDto,
|
|
991
|
+
options
|
|
992
|
+
);
|
|
993
|
+
};
|
|
942
994
|
const customersProvisionZitadel = (orgSlug, provisionZitadelDto, options) => {
|
|
943
995
|
return axiosInstance.post(
|
|
944
996
|
`/v3/${orgSlug}/customers/zitadel/provision`,
|
|
@@ -962,6 +1014,40 @@ var getScrymeV3API = (axiosInstance = import_axios.default) => {
|
|
|
962
1014
|
options
|
|
963
1015
|
);
|
|
964
1016
|
};
|
|
1017
|
+
const customersLogin = (orgSlug, customerLoginDto, options) => {
|
|
1018
|
+
return axiosInstance.post(
|
|
1019
|
+
`/v3/${orgSlug}/customers/auth/login`,
|
|
1020
|
+
customerLoginDto,
|
|
1021
|
+
options
|
|
1022
|
+
);
|
|
1023
|
+
};
|
|
1024
|
+
const customersGetCurrentSession = (orgSlug, options) => {
|
|
1025
|
+
return axiosInstance.get(
|
|
1026
|
+
`/v3/${orgSlug}/customers/auth/session`,
|
|
1027
|
+
options
|
|
1028
|
+
);
|
|
1029
|
+
};
|
|
1030
|
+
const customersGetSessions = (orgSlug, options) => {
|
|
1031
|
+
return axiosInstance.get(
|
|
1032
|
+
`/v3/${orgSlug}/customers/auth/sessions`,
|
|
1033
|
+
options
|
|
1034
|
+
);
|
|
1035
|
+
};
|
|
1036
|
+
const customersRevokeAllSessions = (orgSlug, params, options) => {
|
|
1037
|
+
return axiosInstance.delete(
|
|
1038
|
+
`/v3/${orgSlug}/customers/auth/sessions`,
|
|
1039
|
+
{
|
|
1040
|
+
...options,
|
|
1041
|
+
params: { ...params, ...options?.params }
|
|
1042
|
+
}
|
|
1043
|
+
);
|
|
1044
|
+
};
|
|
1045
|
+
const customersRevokeSession = (orgSlug, id, options) => {
|
|
1046
|
+
return axiosInstance.delete(
|
|
1047
|
+
`/v3/${orgSlug}/customers/auth/sessions/${id}`,
|
|
1048
|
+
options
|
|
1049
|
+
);
|
|
1050
|
+
};
|
|
965
1051
|
const customersUpdate = (orgSlug, id, updateCustomerDto, options) => {
|
|
966
1052
|
return axiosInstance.patch(
|
|
967
1053
|
`/v3/${orgSlug}/customers/${id}`,
|
|
@@ -1873,7 +1959,7 @@ var getScrymeV3API = (axiosInstance = import_axios.default) => {
|
|
|
1873
1959
|
}
|
|
1874
1960
|
);
|
|
1875
1961
|
};
|
|
1876
|
-
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 };
|
|
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 };
|
|
1877
1963
|
};
|
|
1878
1964
|
|
|
1879
1965
|
// src/generated/model/addDepartmentMemberDtoRole.ts
|
|
@@ -2289,6 +2375,13 @@ var UpdateStrapiConnectionDtoSyncDirection = {
|
|
|
2289
2375
|
|
|
2290
2376
|
// src/base.ts
|
|
2291
2377
|
var methodsWithOrgSlugSet = /* @__PURE__ */ new Set([
|
|
2378
|
+
"publicServicesListServices",
|
|
2379
|
+
"publicServicesGetCategories",
|
|
2380
|
+
"publicServicesGetService",
|
|
2381
|
+
"publicServicesGetAvailability",
|
|
2382
|
+
"publicServicesRequestOtp",
|
|
2383
|
+
"publicServicesVerifyOtp",
|
|
2384
|
+
"publicServicesCreatePublicBooking",
|
|
2292
2385
|
"inventoryVerifyIntegrity",
|
|
2293
2386
|
"inventoryFixIntegrity",
|
|
2294
2387
|
"inventoryGetInventory",
|
|
@@ -2357,6 +2450,7 @@ var methodsWithOrgSlugSet = /* @__PURE__ */ new Set([
|
|
|
2357
2450
|
"customersDelete",
|
|
2358
2451
|
"customersGetAddresses",
|
|
2359
2452
|
"customersAddAddress",
|
|
2453
|
+
"customersGetCurrentSession",
|
|
2360
2454
|
"businessAccountControllerCreate",
|
|
2361
2455
|
"businessAccountControllerGetOne",
|
|
2362
2456
|
"crmControllerCreateRecord",
|
|
@@ -2414,7 +2508,14 @@ var methodsWithOrgSlugSet = /* @__PURE__ */ new Set([
|
|
|
2414
2508
|
"roleManagementControllerCreateRoleGroup",
|
|
2415
2509
|
"roleManagementControllerAssignRoles",
|
|
2416
2510
|
"roleManagementControllerRemoveRoles",
|
|
2417
|
-
"departmentsList"
|
|
2511
|
+
"departmentsList",
|
|
2512
|
+
"cartControllerGetCart",
|
|
2513
|
+
"cartControllerClearCart",
|
|
2514
|
+
"cartControllerAddToCart",
|
|
2515
|
+
"cartControllerRemoveFromCart",
|
|
2516
|
+
"favoritesControllerGetFavorites",
|
|
2517
|
+
"favoritesControllerAddFavorite",
|
|
2518
|
+
"favoritesControllerRemoveFavorite"
|
|
2418
2519
|
]);
|
|
2419
2520
|
var catalogMapping = {
|
|
2420
2521
|
getProducts: "catalogGetProducts",
|
|
@@ -2641,6 +2742,46 @@ var membersMapping = {
|
|
|
2641
2742
|
getAttendanceStatus: "attendanceControllerGetStatus",
|
|
2642
2743
|
broadcastAnnouncement: "announcementControllerBroadcastAnnouncement"
|
|
2643
2744
|
};
|
|
2745
|
+
var publicServicesMapping = {
|
|
2746
|
+
listServices: "publicServicesListServices",
|
|
2747
|
+
getCategories: "publicServicesGetCategories",
|
|
2748
|
+
getService: "publicServicesGetService",
|
|
2749
|
+
getAvailability: "publicServicesGetAvailability",
|
|
2750
|
+
requestOtp: "publicServicesRequestOtp",
|
|
2751
|
+
verifyOtp: "publicServicesVerifyOtp",
|
|
2752
|
+
createBooking: "publicServicesCreatePublicBooking"
|
|
2753
|
+
};
|
|
2754
|
+
var servicesMapping = {
|
|
2755
|
+
...publicServicesMapping,
|
|
2756
|
+
// Admin / Staff scheduling endpoints
|
|
2757
|
+
createCategory: "servicesCreateCategory",
|
|
2758
|
+
getCategoriesAdmin: "servicesGetCategories",
|
|
2759
|
+
updateCategory: "servicesUpdateCategory",
|
|
2760
|
+
deleteCategory: "servicesDeleteCategory",
|
|
2761
|
+
createService: "servicesCreateService",
|
|
2762
|
+
getServicesAdmin: "servicesGetServices",
|
|
2763
|
+
getCurrentMemberShifts: "servicesGetCurrentMemberShifts",
|
|
2764
|
+
getShifts: "servicesGetShifts",
|
|
2765
|
+
getServiceAdmin: "servicesGetService",
|
|
2766
|
+
updateService: "servicesUpdateService",
|
|
2767
|
+
deleteService: "servicesDeleteService",
|
|
2768
|
+
createResource: "servicesCreateResource",
|
|
2769
|
+
getResources: "servicesGetResources",
|
|
2770
|
+
updateResource: "servicesUpdateResource",
|
|
2771
|
+
deleteResource: "servicesDeleteResource",
|
|
2772
|
+
createBookingAdmin: "servicesCreateBooking",
|
|
2773
|
+
getBookings: "servicesGetBookings",
|
|
2774
|
+
getBookingAdmin: "servicesGetBooking",
|
|
2775
|
+
updateBookingStatus: "servicesUpdateBookingStatus",
|
|
2776
|
+
completeBooking: "servicesCompleteBooking",
|
|
2777
|
+
createShift: "servicesCreateShift",
|
|
2778
|
+
getStaffShifts: "servicesGetStaffShifts",
|
|
2779
|
+
addBreak: "servicesAddBreak",
|
|
2780
|
+
registerCustomerApp: "servicesRegisterCustomerApp",
|
|
2781
|
+
getServiceUtilization: "servicesGetUtilization",
|
|
2782
|
+
getServicePerformance: "servicesGetPerformance",
|
|
2783
|
+
getServiceFunnel: "servicesGetFunnel"
|
|
2784
|
+
};
|
|
2644
2785
|
var adminMapping = {
|
|
2645
2786
|
getStats: "adminControllerGetStats",
|
|
2646
2787
|
listOrganizations: "adminControllerListOrganizations",
|
|
@@ -2728,8 +2869,10 @@ function getJwtExpiry(token) {
|
|
|
2728
2869
|
return null;
|
|
2729
2870
|
}
|
|
2730
2871
|
|
|
2731
|
-
// src/client.
|
|
2872
|
+
// src/client.tsx
|
|
2873
|
+
var import_react = require("react");
|
|
2732
2874
|
var import_axios2 = __toESM(require("axios"));
|
|
2875
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
2733
2876
|
var InMemoryStorage = class {
|
|
2734
2877
|
constructor() {
|
|
2735
2878
|
this.cache = /* @__PURE__ */ new Map();
|
|
@@ -2749,11 +2892,17 @@ var SCRYME_USER_KEY = "scryme_user";
|
|
|
2749
2892
|
var SCRYME_EXPIRES_AT_KEY = "scryme_expires_at";
|
|
2750
2893
|
var ScrymeClientSDK = class {
|
|
2751
2894
|
constructor(config) {
|
|
2752
|
-
if (!config || !config.clientId || !config.
|
|
2753
|
-
throw new Error(
|
|
2895
|
+
if (!config || !config.clientId || !config.orgSlug) {
|
|
2896
|
+
throw new Error(
|
|
2897
|
+
"clientId and orgSlug are required to initialize the SDK."
|
|
2898
|
+
);
|
|
2899
|
+
}
|
|
2900
|
+
let finalBaseURL = config.baseURL || "https://api.scryme.tech";
|
|
2901
|
+
if (finalBaseURL && !finalBaseURL.includes("/api") && !finalBaseURL.endsWith("/api")) {
|
|
2902
|
+
finalBaseURL = finalBaseURL.replace(/\/$/, "") + "/api";
|
|
2754
2903
|
}
|
|
2755
2904
|
this.axiosInstance = import_axios2.default.create({
|
|
2756
|
-
baseURL:
|
|
2905
|
+
baseURL: finalBaseURL
|
|
2757
2906
|
});
|
|
2758
2907
|
let storage;
|
|
2759
2908
|
if (config.storage) {
|
|
@@ -2803,7 +2952,7 @@ var ScrymeClientSDK = class {
|
|
|
2803
2952
|
try {
|
|
2804
2953
|
state.user = JSON.parse(storedUser);
|
|
2805
2954
|
} catch {
|
|
2806
|
-
state.user =
|
|
2955
|
+
state.user = null;
|
|
2807
2956
|
}
|
|
2808
2957
|
}
|
|
2809
2958
|
notify("INITIAL_SESSION");
|
|
@@ -2821,7 +2970,7 @@ var ScrymeClientSDK = class {
|
|
|
2821
2970
|
try {
|
|
2822
2971
|
const response = await this.api.authExchangeToken({
|
|
2823
2972
|
clientId: config.clientId,
|
|
2824
|
-
clientSecret: config.clientSecret
|
|
2973
|
+
clientSecret: config.clientSecret || ""
|
|
2825
2974
|
});
|
|
2826
2975
|
const tokenData = response.data?.data;
|
|
2827
2976
|
const accessToken = tokenData?.access_token;
|
|
@@ -2830,7 +2979,10 @@ var ScrymeClientSDK = class {
|
|
|
2830
2979
|
state.token = accessToken;
|
|
2831
2980
|
if (expiresIn) {
|
|
2832
2981
|
state.expiresAt = Date.now() + expiresIn * 1e3;
|
|
2833
|
-
await storage.setItem(
|
|
2982
|
+
await storage.setItem(
|
|
2983
|
+
SCRYME_EXPIRES_AT_KEY,
|
|
2984
|
+
String(state.expiresAt)
|
|
2985
|
+
);
|
|
2834
2986
|
} else {
|
|
2835
2987
|
const jwtExp = getJwtExpiry(accessToken);
|
|
2836
2988
|
if (jwtExp) {
|
|
@@ -2852,14 +3004,28 @@ var ScrymeClientSDK = class {
|
|
|
2852
3004
|
};
|
|
2853
3005
|
this.axiosInstance.interceptors.request.use(async (req) => {
|
|
2854
3006
|
await initPromise;
|
|
2855
|
-
const isAuthTokenRequest = req.url && (req.url.endsWith("/auth/token") || req.url.includes("/auth/token"));
|
|
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"));
|
|
2856
3008
|
if (!isAuthTokenRequest) {
|
|
2857
|
-
const isExpired = !state.token || state.expiresAt && Date.now() >= state.expiresAt - 3e4;
|
|
2858
|
-
if (isExpired
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
3009
|
+
const isExpired = !state.token || state.expiresAt && Date.now() >= (state.expiresAt || 0) - 3e4;
|
|
3010
|
+
if (isExpired) {
|
|
3011
|
+
if (state.token) {
|
|
3012
|
+
try {
|
|
3013
|
+
await this.auth.refreshSession();
|
|
3014
|
+
} catch (e) {
|
|
3015
|
+
console.error(
|
|
3016
|
+
"Proactive customer session refresh failed in request interceptor:",
|
|
3017
|
+
e
|
|
3018
|
+
);
|
|
3019
|
+
}
|
|
3020
|
+
} else if (config.clientId && config.clientSecret) {
|
|
3021
|
+
try {
|
|
3022
|
+
await performExchange();
|
|
3023
|
+
} catch (e) {
|
|
3024
|
+
console.error(
|
|
3025
|
+
"Auto-authentication failed in request interceptor:",
|
|
3026
|
+
e
|
|
3027
|
+
);
|
|
3028
|
+
}
|
|
2863
3029
|
}
|
|
2864
3030
|
}
|
|
2865
3031
|
}
|
|
@@ -2872,15 +3038,23 @@ var ScrymeClientSDK = class {
|
|
|
2872
3038
|
(response) => response,
|
|
2873
3039
|
async (error) => {
|
|
2874
3040
|
const originalRequest = error.config;
|
|
2875
|
-
const isAuthTokenRequest = originalRequest && originalRequest.url && (originalRequest.url.endsWith("/auth/token") || originalRequest.url.includes("/auth/token"));
|
|
2876
|
-
if (error.response && error.response.status === 401 && originalRequest && !originalRequest._retry && !isAuthTokenRequest
|
|
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"));
|
|
3042
|
+
if (error.response && error.response.status === 401 && originalRequest && !originalRequest._retry && !isAuthTokenRequest) {
|
|
2877
3043
|
originalRequest._retry = true;
|
|
2878
3044
|
try {
|
|
2879
|
-
await performExchange();
|
|
2880
3045
|
if (state.token) {
|
|
2881
|
-
|
|
3046
|
+
await this.auth.refreshSession();
|
|
3047
|
+
if (state.token) {
|
|
3048
|
+
originalRequest.headers["Authorization"] = `Bearer ${state.token}`;
|
|
3049
|
+
}
|
|
3050
|
+
return this.axiosInstance(originalRequest);
|
|
3051
|
+
} else if (config.clientId && config.clientSecret) {
|
|
3052
|
+
await performExchange();
|
|
3053
|
+
if (state.token) {
|
|
3054
|
+
originalRequest.headers["Authorization"] = `Bearer ${state.token}`;
|
|
3055
|
+
}
|
|
3056
|
+
return this.axiosInstance(originalRequest);
|
|
2882
3057
|
}
|
|
2883
|
-
return this.axiosInstance(originalRequest);
|
|
2884
3058
|
} catch (e) {
|
|
2885
3059
|
return Promise.reject(error);
|
|
2886
3060
|
}
|
|
@@ -2898,6 +3072,149 @@ var ScrymeClientSDK = class {
|
|
|
2898
3072
|
this.loyalty = buildModule(this.api, config.orgSlug, loyaltyMapping);
|
|
2899
3073
|
this.members = buildModule(this.api, config.orgSlug, membersMapping);
|
|
2900
3074
|
this.admin = buildModule(this.api, config.orgSlug, adminMapping);
|
|
3075
|
+
this.cart = {
|
|
3076
|
+
get: async (params) => {
|
|
3077
|
+
return this.orders.getCart(params || {});
|
|
3078
|
+
},
|
|
3079
|
+
add: async (dto) => {
|
|
3080
|
+
return this.orders.addToCart(dto);
|
|
3081
|
+
},
|
|
3082
|
+
remove: async (dto) => {
|
|
3083
|
+
return this.orders.removeFromCart(dto);
|
|
3084
|
+
},
|
|
3085
|
+
clear: async (params) => {
|
|
3086
|
+
return this.orders.clearCart(params || {});
|
|
3087
|
+
},
|
|
3088
|
+
update: async (dto) => {
|
|
3089
|
+
const response = await this.orders.getCart({
|
|
3090
|
+
sessionId: dto.sessionId
|
|
3091
|
+
});
|
|
3092
|
+
const data = response.data;
|
|
3093
|
+
const items = data?.data?.items || data?.items || [];
|
|
3094
|
+
let existingItem = null;
|
|
3095
|
+
if (dto.productId) {
|
|
3096
|
+
existingItem = items.find(
|
|
3097
|
+
(item) => item.productId === dto.productId && (item.variantId || null) === (dto.variantId || null)
|
|
3098
|
+
);
|
|
3099
|
+
} else if (dto.serviceId) {
|
|
3100
|
+
existingItem = items.find(
|
|
3101
|
+
(item) => item.serviceId === dto.serviceId
|
|
3102
|
+
);
|
|
3103
|
+
}
|
|
3104
|
+
if (existingItem) {
|
|
3105
|
+
const currentQty = existingItem.quantity || 0;
|
|
3106
|
+
if (dto.quantity <= 0) {
|
|
3107
|
+
return this.orders.removeFromCart({
|
|
3108
|
+
productId: dto.productId,
|
|
3109
|
+
variantId: dto.variantId,
|
|
3110
|
+
serviceId: dto.serviceId,
|
|
3111
|
+
sessionId: dto.sessionId,
|
|
3112
|
+
customerId: dto.customerId
|
|
3113
|
+
});
|
|
3114
|
+
} else {
|
|
3115
|
+
const diff = dto.quantity - currentQty;
|
|
3116
|
+
if (diff !== 0) {
|
|
3117
|
+
return this.orders.addToCart({
|
|
3118
|
+
...dto,
|
|
3119
|
+
quantity: diff
|
|
3120
|
+
});
|
|
3121
|
+
}
|
|
3122
|
+
return response;
|
|
3123
|
+
}
|
|
3124
|
+
} else {
|
|
3125
|
+
if (dto.quantity > 0) {
|
|
3126
|
+
return this.orders.addToCart(dto);
|
|
3127
|
+
}
|
|
3128
|
+
}
|
|
3129
|
+
},
|
|
3130
|
+
getItems: async (params) => {
|
|
3131
|
+
const res = await this.orders.getCart(params || {});
|
|
3132
|
+
const data = res?.data || res;
|
|
3133
|
+
return data?.items || data?.data?.items || [];
|
|
3134
|
+
},
|
|
3135
|
+
getTotals: async (params) => {
|
|
3136
|
+
const res = await this.orders.getCart(params || {});
|
|
3137
|
+
const data = res?.data || res;
|
|
3138
|
+
const items = data?.items || data?.data?.items || [];
|
|
3139
|
+
const itemsCount = items.reduce(
|
|
3140
|
+
(sum, item) => sum + (item.quantity || 0),
|
|
3141
|
+
0
|
|
3142
|
+
);
|
|
3143
|
+
return {
|
|
3144
|
+
itemsCount,
|
|
3145
|
+
items,
|
|
3146
|
+
raw: data
|
|
3147
|
+
};
|
|
3148
|
+
},
|
|
3149
|
+
mergeGuestCart: async (guestSessionId, customerId) => {
|
|
3150
|
+
return this.orders.getCart({ sessionId: guestSessionId });
|
|
3151
|
+
},
|
|
3152
|
+
checkout: async (params) => {
|
|
3153
|
+
const session = await this.auth.getSession();
|
|
3154
|
+
const user = session.user;
|
|
3155
|
+
const customerId = user?.customerId || user?.id || user?.customer?.id;
|
|
3156
|
+
if (!customerId)
|
|
3157
|
+
throw new Error("No authenticated customer found for checkout.");
|
|
3158
|
+
const items = await this.cart.getItems();
|
|
3159
|
+
if (!items || items.length === 0) {
|
|
3160
|
+
throw new Error("Cannot checkout an empty cart.");
|
|
3161
|
+
}
|
|
3162
|
+
const orderItems = items.map((item) => ({
|
|
3163
|
+
variantId: item.variantId || "",
|
|
3164
|
+
quantity: item.quantity,
|
|
3165
|
+
unitPrice: item.unitPrice
|
|
3166
|
+
}));
|
|
3167
|
+
const orderResponse = await this.orders.createOrder({
|
|
3168
|
+
customerId,
|
|
3169
|
+
locationId: params.locationId,
|
|
3170
|
+
items: orderItems,
|
|
3171
|
+
notes: params.notes,
|
|
3172
|
+
channel: params.channel
|
|
3173
|
+
});
|
|
3174
|
+
await this.cart.clear();
|
|
3175
|
+
return orderResponse?.data || orderResponse;
|
|
3176
|
+
}
|
|
3177
|
+
};
|
|
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();
|
|
3213
|
+
},
|
|
3214
|
+
cancel: async (id) => {
|
|
3215
|
+
return this.catalog.updateBookingStatus(id, "CANCELLED");
|
|
3216
|
+
}
|
|
3217
|
+
};
|
|
2901
3218
|
const baseAuth = buildModule(this.api, config.orgSlug, authMapping);
|
|
2902
3219
|
this.auth = {
|
|
2903
3220
|
...baseAuth,
|
|
@@ -2908,10 +3225,45 @@ var ScrymeClientSDK = class {
|
|
|
2908
3225
|
return performExchange();
|
|
2909
3226
|
},
|
|
2910
3227
|
signIn: async (credentials) => {
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
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");
|
|
3257
|
+
}
|
|
3258
|
+
} catch (e) {
|
|
3259
|
+
}
|
|
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;
|
|
2915
3267
|
if (token) {
|
|
2916
3268
|
state.token = token;
|
|
2917
3269
|
state.user = user;
|
|
@@ -2919,7 +3271,10 @@ var ScrymeClientSDK = class {
|
|
|
2919
3271
|
await storage.setItem(SCRYME_SESSION_TOKEN_KEY, token);
|
|
2920
3272
|
if (jwtExp) {
|
|
2921
3273
|
state.expiresAt = jwtExp;
|
|
2922
|
-
await storage.setItem(
|
|
3274
|
+
await storage.setItem(
|
|
3275
|
+
SCRYME_EXPIRES_AT_KEY,
|
|
3276
|
+
String(state.expiresAt)
|
|
3277
|
+
);
|
|
2923
3278
|
} else {
|
|
2924
3279
|
delete state.expiresAt;
|
|
2925
3280
|
await storage.removeItem(SCRYME_EXPIRES_AT_KEY);
|
|
@@ -2962,6 +3317,88 @@ var ScrymeClientSDK = class {
|
|
|
2962
3317
|
listeners.delete(callback);
|
|
2963
3318
|
}
|
|
2964
3319
|
};
|
|
3320
|
+
},
|
|
3321
|
+
getSessions: async () => {
|
|
3322
|
+
const res = await this.axiosInstance.get(
|
|
3323
|
+
`/${config.orgSlug}/customers/auth/sessions`
|
|
3324
|
+
);
|
|
3325
|
+
return res.data?.data || res.data;
|
|
3326
|
+
},
|
|
3327
|
+
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;
|
|
3332
|
+
},
|
|
3333
|
+
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;
|
|
3337
|
+
},
|
|
3338
|
+
getCurrentSession: async () => {
|
|
3339
|
+
const res = await this.axiosInstance.get(
|
|
3340
|
+
`/${config.orgSlug}/customers/auth/session`
|
|
3341
|
+
);
|
|
3342
|
+
return res.data?.data || res.data;
|
|
3343
|
+
},
|
|
3344
|
+
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;
|
|
3351
|
+
if (token) {
|
|
3352
|
+
state.token = token;
|
|
3353
|
+
state.user = user;
|
|
3354
|
+
const jwtExp = getJwtExpiry(token);
|
|
3355
|
+
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);
|
|
3365
|
+
}
|
|
3366
|
+
if (user) {
|
|
3367
|
+
await storage.setItem(SCRYME_USER_KEY, JSON.stringify(user));
|
|
3368
|
+
}
|
|
3369
|
+
notify("SIGNED_IN");
|
|
3370
|
+
}
|
|
3371
|
+
return data;
|
|
3372
|
+
},
|
|
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);
|
|
3395
|
+
}
|
|
3396
|
+
if (user) {
|
|
3397
|
+
await storage.setItem(SCRYME_USER_KEY, JSON.stringify(user));
|
|
3398
|
+
}
|
|
3399
|
+
notify("SIGNED_IN");
|
|
3400
|
+
}
|
|
3401
|
+
return data;
|
|
2965
3402
|
}
|
|
2966
3403
|
};
|
|
2967
3404
|
}
|
|
@@ -2975,6 +3412,199 @@ function createClientSDK(config = {}) {
|
|
|
2975
3412
|
};
|
|
2976
3413
|
return new ScrymeClientSDK(finalConfig);
|
|
2977
3414
|
}
|
|
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
|
+
};
|
|
2978
3608
|
|
|
2979
3609
|
// src/server.ts
|
|
2980
3610
|
var import_axios3 = __toESM(require("axios"));
|
|
@@ -2984,10 +3614,16 @@ var ScrymeServerSDK = class {
|
|
|
2984
3614
|
this.expiresAt = null;
|
|
2985
3615
|
this.activeAuthPromise = null;
|
|
2986
3616
|
if (!config || !config.clientId || !config.clientSecret || !config.orgSlug) {
|
|
2987
|
-
throw new Error(
|
|
3617
|
+
throw new Error(
|
|
3618
|
+
"clientId, clientSecret, and orgSlug are required to initialize the SDK."
|
|
3619
|
+
);
|
|
3620
|
+
}
|
|
3621
|
+
let finalBaseURL = config.baseURL || "https://api.scryme.tech";
|
|
3622
|
+
if (finalBaseURL && !finalBaseURL.includes("/api") && !finalBaseURL.endsWith("/api")) {
|
|
3623
|
+
finalBaseURL = finalBaseURL.replace(/\/$/, "") + "/api";
|
|
2988
3624
|
}
|
|
2989
3625
|
this.axiosInstance = import_axios3.default.create({
|
|
2990
|
-
baseURL:
|
|
3626
|
+
baseURL: finalBaseURL
|
|
2991
3627
|
});
|
|
2992
3628
|
if (config.token) {
|
|
2993
3629
|
this.token = config.token;
|
|
@@ -3027,14 +3663,29 @@ var ScrymeServerSDK = class {
|
|
|
3027
3663
|
return this.activeAuthPromise;
|
|
3028
3664
|
};
|
|
3029
3665
|
this.axiosInstance.interceptors.request.use(async (req) => {
|
|
3030
|
-
const isAuthTokenRequest = req.url && (req.url.endsWith("/auth/token") || req.url.includes("/auth/token"));
|
|
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"));
|
|
3031
3667
|
if (!isAuthTokenRequest && !config.apiKey) {
|
|
3032
3668
|
const isExpired = !this.token || this.expiresAt && Date.now() >= this.expiresAt - 3e4;
|
|
3033
|
-
if (isExpired
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3669
|
+
if (isExpired) {
|
|
3670
|
+
const isCustomerToken = this.token && getJwtExpiry(this.token) && !config.clientSecret;
|
|
3671
|
+
if (isCustomerToken || this.token && !config.clientSecret) {
|
|
3672
|
+
try {
|
|
3673
|
+
await this.auth.refreshSession();
|
|
3674
|
+
} catch (e) {
|
|
3675
|
+
console.error(
|
|
3676
|
+
"Proactive customer session refresh failed in request interceptor:",
|
|
3677
|
+
e
|
|
3678
|
+
);
|
|
3679
|
+
}
|
|
3680
|
+
} else if (config.clientId && config.clientSecret) {
|
|
3681
|
+
try {
|
|
3682
|
+
await performExchange();
|
|
3683
|
+
} catch (e) {
|
|
3684
|
+
console.error(
|
|
3685
|
+
"Auto-authentication failed in request interceptor:",
|
|
3686
|
+
e
|
|
3687
|
+
);
|
|
3688
|
+
}
|
|
3038
3689
|
}
|
|
3039
3690
|
}
|
|
3040
3691
|
}
|
|
@@ -3047,15 +3698,24 @@ var ScrymeServerSDK = class {
|
|
|
3047
3698
|
(response) => response,
|
|
3048
3699
|
async (error) => {
|
|
3049
3700
|
const originalRequest = error.config;
|
|
3050
|
-
const isAuthTokenRequest = originalRequest && originalRequest.url && (originalRequest.url.endsWith("/auth/token") || originalRequest.url.includes("/auth/token"));
|
|
3051
|
-
if (error.response && error.response.status === 401 && originalRequest && !originalRequest._retry && !isAuthTokenRequest && !config.apiKey
|
|
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"));
|
|
3702
|
+
if (error.response && error.response.status === 401 && originalRequest && !originalRequest._retry && !isAuthTokenRequest && !config.apiKey) {
|
|
3052
3703
|
originalRequest._retry = true;
|
|
3053
3704
|
try {
|
|
3054
|
-
|
|
3055
|
-
if (this.token) {
|
|
3056
|
-
|
|
3705
|
+
const isCustomerToken = this.token && getJwtExpiry(this.token) && !config.clientSecret;
|
|
3706
|
+
if (isCustomerToken || this.token && !config.clientSecret) {
|
|
3707
|
+
await this.auth.refreshSession();
|
|
3708
|
+
if (this.token) {
|
|
3709
|
+
originalRequest.headers["Authorization"] = `Bearer ${this.token}`;
|
|
3710
|
+
}
|
|
3711
|
+
return this.axiosInstance(originalRequest);
|
|
3712
|
+
} else if (config.clientId && config.clientSecret) {
|
|
3713
|
+
await performExchange();
|
|
3714
|
+
if (this.token) {
|
|
3715
|
+
originalRequest.headers["Authorization"] = `Bearer ${this.token}`;
|
|
3716
|
+
}
|
|
3717
|
+
return this.axiosInstance(originalRequest);
|
|
3057
3718
|
}
|
|
3058
|
-
return this.axiosInstance(originalRequest);
|
|
3059
3719
|
} catch (e) {
|
|
3060
3720
|
return Promise.reject(error);
|
|
3061
3721
|
}
|
|
@@ -3073,6 +3733,141 @@ var ScrymeServerSDK = class {
|
|
|
3073
3733
|
this.loyalty = buildModule(this.api, config.orgSlug, loyaltyMapping);
|
|
3074
3734
|
this.members = buildModule(this.api, config.orgSlug, membersMapping);
|
|
3075
3735
|
this.admin = buildModule(this.api, config.orgSlug, adminMapping);
|
|
3736
|
+
this.services = buildModule(this.api, config.orgSlug, servicesMapping);
|
|
3737
|
+
this.cart = {
|
|
3738
|
+
get: async (params) => {
|
|
3739
|
+
return this.orders.getCart(params || {});
|
|
3740
|
+
},
|
|
3741
|
+
add: async (dto) => {
|
|
3742
|
+
return this.orders.addToCart(dto);
|
|
3743
|
+
},
|
|
3744
|
+
remove: async (dto) => {
|
|
3745
|
+
return this.orders.removeFromCart(dto);
|
|
3746
|
+
},
|
|
3747
|
+
clear: async (params) => {
|
|
3748
|
+
return this.orders.clearCart(params || {});
|
|
3749
|
+
},
|
|
3750
|
+
update: async (dto) => {
|
|
3751
|
+
const response = await this.orders.getCart({
|
|
3752
|
+
sessionId: dto.sessionId
|
|
3753
|
+
});
|
|
3754
|
+
const data = response.data;
|
|
3755
|
+
const items = data?.data?.items || data?.items || [];
|
|
3756
|
+
let existingItem = null;
|
|
3757
|
+
if (dto.productId) {
|
|
3758
|
+
existingItem = items.find(
|
|
3759
|
+
(item) => item.productId === dto.productId && (item.variantId || null) === (dto.variantId || null)
|
|
3760
|
+
);
|
|
3761
|
+
} else if (dto.serviceId) {
|
|
3762
|
+
existingItem = items.find(
|
|
3763
|
+
(item) => item.serviceId === dto.serviceId
|
|
3764
|
+
);
|
|
3765
|
+
}
|
|
3766
|
+
if (existingItem) {
|
|
3767
|
+
const currentQty = existingItem.quantity || 0;
|
|
3768
|
+
if (dto.quantity <= 0) {
|
|
3769
|
+
return this.orders.removeFromCart({
|
|
3770
|
+
productId: dto.productId,
|
|
3771
|
+
variantId: dto.variantId,
|
|
3772
|
+
serviceId: dto.serviceId,
|
|
3773
|
+
sessionId: dto.sessionId,
|
|
3774
|
+
customerId: dto.customerId
|
|
3775
|
+
});
|
|
3776
|
+
} else {
|
|
3777
|
+
const diff = dto.quantity - currentQty;
|
|
3778
|
+
if (diff !== 0) {
|
|
3779
|
+
return this.orders.addToCart({
|
|
3780
|
+
...dto,
|
|
3781
|
+
quantity: diff
|
|
3782
|
+
});
|
|
3783
|
+
}
|
|
3784
|
+
return response;
|
|
3785
|
+
}
|
|
3786
|
+
} else {
|
|
3787
|
+
if (dto.quantity > 0) {
|
|
3788
|
+
return this.orders.addToCart(dto);
|
|
3789
|
+
}
|
|
3790
|
+
}
|
|
3791
|
+
},
|
|
3792
|
+
getItems: async (params) => {
|
|
3793
|
+
const res = await this.orders.getCart(params || {});
|
|
3794
|
+
const data = res?.data || res;
|
|
3795
|
+
return data?.items || data?.data?.items || [];
|
|
3796
|
+
},
|
|
3797
|
+
getTotals: async (params) => {
|
|
3798
|
+
const res = await this.orders.getCart(params || {});
|
|
3799
|
+
const data = res?.data || res;
|
|
3800
|
+
const items = data?.items || data?.data?.items || [];
|
|
3801
|
+
const itemsCount = items.reduce(
|
|
3802
|
+
(sum, item) => sum + (item.quantity || 0),
|
|
3803
|
+
0
|
|
3804
|
+
);
|
|
3805
|
+
return {
|
|
3806
|
+
itemsCount,
|
|
3807
|
+
items,
|
|
3808
|
+
raw: data
|
|
3809
|
+
};
|
|
3810
|
+
},
|
|
3811
|
+
checkout: async (params) => {
|
|
3812
|
+
if (!params.customerId)
|
|
3813
|
+
throw new Error("customerId is required for server checkout.");
|
|
3814
|
+
const items = await this.cart.getItems({
|
|
3815
|
+
sessionId: params.sessionId,
|
|
3816
|
+
customerId: params.customerId
|
|
3817
|
+
});
|
|
3818
|
+
if (!items || items.length === 0) {
|
|
3819
|
+
throw new Error("Cannot checkout an empty cart.");
|
|
3820
|
+
}
|
|
3821
|
+
const orderItems = items.map((item) => ({
|
|
3822
|
+
variantId: item.variantId || "",
|
|
3823
|
+
quantity: item.quantity,
|
|
3824
|
+
unitPrice: item.unitPrice
|
|
3825
|
+
}));
|
|
3826
|
+
const orderResponse = await this.orders.createOrder({
|
|
3827
|
+
customerId: params.customerId,
|
|
3828
|
+
locationId: params.locationId,
|
|
3829
|
+
items: orderItems,
|
|
3830
|
+
notes: params.notes,
|
|
3831
|
+
channel: params.channel
|
|
3832
|
+
});
|
|
3833
|
+
await this.cart.clear({
|
|
3834
|
+
sessionId: params.sessionId || "",
|
|
3835
|
+
customerId: params.customerId
|
|
3836
|
+
});
|
|
3837
|
+
return orderResponse?.data || orderResponse;
|
|
3838
|
+
}
|
|
3839
|
+
};
|
|
3840
|
+
this.customer = {
|
|
3841
|
+
getProfile: async (customerId) => {
|
|
3842
|
+
return this.admin.getCustomerById(customerId);
|
|
3843
|
+
},
|
|
3844
|
+
updateProfile: async (customerId, dto) => {
|
|
3845
|
+
return this.admin.updateCustomer(customerId, dto);
|
|
3846
|
+
},
|
|
3847
|
+
getAddresses: async (customerId) => {
|
|
3848
|
+
return this.admin.getCustomerAddresses(customerId);
|
|
3849
|
+
},
|
|
3850
|
+
addAddress: async (customerId, dto) => {
|
|
3851
|
+
return this.admin.addCustomerAddress(customerId, dto);
|
|
3852
|
+
}
|
|
3853
|
+
};
|
|
3854
|
+
this.bookings = {
|
|
3855
|
+
create: async (dto) => {
|
|
3856
|
+
return this.catalog.createBooking(dto);
|
|
3857
|
+
},
|
|
3858
|
+
get: async (id) => {
|
|
3859
|
+
return this.catalog.getBooking(id);
|
|
3860
|
+
},
|
|
3861
|
+
list: async () => {
|
|
3862
|
+
return this.catalog.getBookings();
|
|
3863
|
+
},
|
|
3864
|
+
cancel: async (id) => {
|
|
3865
|
+
return this.catalog.updateBookingStatus(id, "CANCELLED");
|
|
3866
|
+
},
|
|
3867
|
+
complete: async (id, dto) => {
|
|
3868
|
+
return this.catalog.completeBooking(id, dto);
|
|
3869
|
+
}
|
|
3870
|
+
};
|
|
3076
3871
|
const baseAuth = buildModule(this.api, config.orgSlug, authMapping);
|
|
3077
3872
|
this.auth = {
|
|
3078
3873
|
...baseAuth,
|
|
@@ -3083,7 +3878,10 @@ var ScrymeServerSDK = class {
|
|
|
3083
3878
|
return performExchange();
|
|
3084
3879
|
},
|
|
3085
3880
|
signIn: async (credentials) => {
|
|
3086
|
-
const response = await this.axiosInstance.post(
|
|
3881
|
+
const response = await this.axiosInstance.post(
|
|
3882
|
+
"/auth/sign-in/email",
|
|
3883
|
+
credentials
|
|
3884
|
+
);
|
|
3087
3885
|
const data = response.data;
|
|
3088
3886
|
const token = data?.session?.token || data?.token || null;
|
|
3089
3887
|
if (token) {
|
|
@@ -3092,6 +3890,39 @@ var ScrymeServerSDK = class {
|
|
|
3092
3890
|
this.axiosInstance.defaults.headers.common["Authorization"] = `Bearer ${token}`;
|
|
3093
3891
|
}
|
|
3094
3892
|
return data;
|
|
3893
|
+
},
|
|
3894
|
+
getCurrentSession: async () => {
|
|
3895
|
+
const response = await this.axiosInstance.get(
|
|
3896
|
+
`/${config.orgSlug}/customers/auth/session`
|
|
3897
|
+
);
|
|
3898
|
+
return response.data?.data || response.data;
|
|
3899
|
+
},
|
|
3900
|
+
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;
|
|
3095
3926
|
}
|
|
3096
3927
|
};
|
|
3097
3928
|
}
|
|
@@ -3207,6 +4038,7 @@ var getScrymeV3API2 = (axiosInstance, defaultOrgSlug) => {
|
|
|
3207
4038
|
RegisterPettyCashDtoPaymentMethod,
|
|
3208
4039
|
ReviewPriceChangeDtoStatus,
|
|
3209
4040
|
RoleManagementControllerGetCustomRolesSortOrder,
|
|
4041
|
+
ScrymeAuthProvider,
|
|
3210
4042
|
ScrymeClientSDK,
|
|
3211
4043
|
ScrymeServerSDK,
|
|
3212
4044
|
ServicesUpdateBookingStatusBodyStatus,
|
|
@@ -3237,5 +4069,8 @@ var getScrymeV3API2 = (axiosInstance, defaultOrgSlug) => {
|
|
|
3237
4069
|
membersMapping,
|
|
3238
4070
|
methodsWithOrgSlugSet,
|
|
3239
4071
|
ordersMapping,
|
|
3240
|
-
posMapping
|
|
4072
|
+
posMapping,
|
|
4073
|
+
publicServicesMapping,
|
|
4074
|
+
servicesMapping,
|
|
4075
|
+
useScrymeAuth
|
|
3241
4076
|
});
|