@scryme/sdk 9.65.0 → 9.67.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{base-DZWqHn_L.d.mts → base-1B2-e5i_.d.mts} +78 -20
- package/dist/{base-DZWqHn_L.d.ts → base-1B2-e5i_.d.ts} +78 -20
- package/dist/{chunk-PPNV4D3M.mjs → chunk-QS5K7GIL.mjs} +284 -445
- package/dist/client.d.mts +149 -87
- package/dist/client.d.ts +149 -87
- package/dist/client.js +160 -394
- package/dist/client.mjs +3 -7
- package/dist/index.d.mts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +285 -448
- package/dist/index.mjs +3 -7
- package/dist/server.d.mts +199 -29
- package/dist/server.d.ts +199 -29
- package/dist/server.js +145 -67
- package/dist/server.mjs +1 -1
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -649,6 +649,12 @@ var getScrymeV3API = (axiosInstance = import_axios.default) => {
|
|
|
649
649
|
options
|
|
650
650
|
);
|
|
651
651
|
};
|
|
652
|
+
const catalogGetProduct = (orgSlug, idOrSlug, options) => {
|
|
653
|
+
return axiosInstance.get(
|
|
654
|
+
`/v3/${orgSlug}/catalog/products/${idOrSlug}`,
|
|
655
|
+
options
|
|
656
|
+
);
|
|
657
|
+
};
|
|
652
658
|
const catalogGetServices = (orgSlug, params, options) => {
|
|
653
659
|
return axiosInstance.get(
|
|
654
660
|
`/v3/${orgSlug}/catalog/services`,
|
|
@@ -925,13 +931,6 @@ var getScrymeV3API = (axiosInstance = import_axios.default) => {
|
|
|
925
931
|
options
|
|
926
932
|
);
|
|
927
933
|
};
|
|
928
|
-
const customersProvisionZitadel = (orgSlug, provisionZitadelDto, options) => {
|
|
929
|
-
return axiosInstance.post(
|
|
930
|
-
`/v3/${orgSlug}/customers/zitadel/provision`,
|
|
931
|
-
provisionZitadelDto,
|
|
932
|
-
options
|
|
933
|
-
);
|
|
934
|
-
};
|
|
935
934
|
const customersGetCustomers = (orgSlug, params, options) => {
|
|
936
935
|
return axiosInstance.get(
|
|
937
936
|
`/v3/${orgSlug}/customers`,
|
|
@@ -955,6 +954,13 @@ var getScrymeV3API = (axiosInstance = import_axios.default) => {
|
|
|
955
954
|
options
|
|
956
955
|
);
|
|
957
956
|
};
|
|
957
|
+
const customersRefreshSession = (orgSlug, options) => {
|
|
958
|
+
return axiosInstance.post(
|
|
959
|
+
`/v3/${orgSlug}/customers/auth/refresh`,
|
|
960
|
+
void 0,
|
|
961
|
+
options
|
|
962
|
+
);
|
|
963
|
+
};
|
|
958
964
|
const customersGetCurrentSession = (orgSlug, options) => {
|
|
959
965
|
return axiosInstance.get(
|
|
960
966
|
`/v3/${orgSlug}/customers/auth/session`,
|
|
@@ -1893,7 +1899,7 @@ var getScrymeV3API = (axiosInstance = import_axios.default) => {
|
|
|
1893
1899
|
}
|
|
1894
1900
|
);
|
|
1895
1901
|
};
|
|
1896
|
-
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,
|
|
1902
|
+
return { inventoryVerifyIntegrity, inventoryFixIntegrity, inventoryGetInventory, inventoryTraceBatch, inventorySplitBatch, inventoryMergeBatches, inventoryCreateAssembly, inventoryCompleteAssembly, inventoryRequestAdjustment, inventoryGetAdjustments, inventoryApproveAdjustment, inventoryRejectAdjustment, inventoryGetLeadTime, inventoryGetWasteAnalysis, inventoryCheckB2BAvailability, inventoryUnpackBatch, inventoryScanUnpackBatch, inventoryQuickStockInquiry, expenseControllerCreateExpense, expenseControllerGetExpenses, expenseControllerGetExpenseCategories, expenseControllerGetExpense, pettyCashControllerCreateFund, pettyCashControllerGetFunds, pettyCashControllerGetFund, pettyCashControllerTopUpFund, pettyCashControllerGetFundTransactions, utilityAccountControllerCreateAccount, utilityAccountControllerGetAccounts, utilityAccountControllerGetAccount, accountingInitialize, accountingGetProfitLoss, accountingGetBalanceSheet, accountingGetCashFlow, accountingGetTaxSummary, invoiceControllerCreateInvoice, invoiceControllerGetInvoices, invoiceControllerGetInvoice, invoiceControllerUpdateInvoice, invoiceControllerDeleteInvoice, invoiceControllerFinalizeInvoice, invoiceControllerGetTemplates, invoiceControllerCreateTemplate, invoiceControllerGetConfig, invoiceControllerUpdateConfig, publicInvoiceControllerDownloadInvoice, publicInvoiceControllerDownloadInvoiceByTransaction, publicInvoiceControllerDownloadReceipt, publicInvoiceControllerGeneratePublicLink, authExchangeToken, authControllerHandleOAuth2, adminControllerGetStats, adminControllerListOrganizations, adminControllerCreateOrganization, adminControllerGetOrganizationDetails, adminControllerUpdateOrganization, adminControllerDeleteOrganization, adminControllerListMembers, adminControllerListUsers, adminControllerBanUser, adminControllerUnbanUser, adminControllerListConnectedApps, adminControllerListSystemLogs, adminControllerListGlobalSettings, adminControllerSetGlobalSetting, adminControllerDeleteGlobalSetting, adminControllerListTiers, adminControllerDefineTier, adminControllerDeleteTier, adminControllerGetOrganizationSubscription, adminControllerUpdateOrganizationSubscription, adminControllerListSystemPayments, adminControllerRecordCustomPayment, adminControllerListIntegrationDefinitions, adminControllerCreateIntegrationDefinition, adminControllerUpdateIntegrationDefinition, adminControllerDeleteIntegrationDefinition, adminControllerListActiveOrganizationIntegrations, webhooksCreate, webhooksList, webhooksDelete, windmillCallbackControllerHandleCallback, windmillCallbackControllerHandleApprovalCallback, windmillCallbackControllerHandleBakeryDisposalCallback, windmillCallbackControllerHandleOutcomeCallback, catalogGetProducts, catalogCreateProduct, catalogGetProduct, catalogGetServices, catalogUpdateProduct, catalogUpdateSupplierVariant, catalogGetPriceChangeRequests, catalogReviewPriceChangeRequest, servicesCreateCategory, servicesGetCategories, servicesUpdateCategory, servicesDeleteCategory, servicesCreateService, servicesGetServices, servicesGetCurrentMemberShifts, servicesGetShifts, servicesGetService, servicesUpdateService, servicesDeleteService, servicesCreateResource, servicesGetResources, servicesUpdateResource, servicesDeleteResource, servicesCreateBooking, servicesGetBookings, servicesGetBooking, servicesUpdateBookingStatus, servicesCompleteBooking, servicesCreateShift, servicesGetStaffShifts, servicesAddBreak, servicesRegisterCustomerApp, servicesGetUtilization, servicesGetPerformance, servicesGetFunnel, publicServicesListServices, publicServicesGetCategories, publicServicesGetService, publicServicesGetAvailability, publicServicesRequestOtp, publicServicesVerifyOtp, publicServicesCreatePublicBooking, customersGetCustomers, customersRegister, customersLogin, customersRefreshSession, customersGetCurrentSession, customersGetSessions, customersRevokeAllSessions, customersRevokeSession, customersUpdate, customersGetCustomerById, customersDelete, customersGetAddresses, customersAddAddress, businessAccountControllerCreate, businessAccountControllerGetOne, crmControllerCreateRecord, crmControllerGetRecord, crmControllerUpdateRecord, crmControllerCreateNote, crmControllerGetRecordNotes, crmControllerCreateActivity, crmControllerGetTimeline, crmControllerCreateObject, crmControllerListObjects, crmControllerCreateField, crmControllerListFields, crmControllerCreateRelationship, crmControllerListRelationships, crmControllerCreateAssociation, crmControllerListRecordAssociations, loyaltyRedeemReward, loyaltyGetCustomerStatus, loyaltyValidateVoucher, ordersCreateOrder, ordersGetOrders, ordersUpdateStatus, ordersRequestB2BQuote, ordersConvertQuoteToOrder, paymentsControllerHandleStkCallback, pOSProvision, pOSLogin, pOSGetMe, pOSProcessSale, pOSSync, pOSGetTransactions, pOSRegisterPettyCash, pOSGetPettyCashFunds, pOSGetPettyCashTransactions, membersControllerGetMembers, membersControllerCreateMember, membersControllerGetMember, membersControllerUpdateMember, membersControllerDeleteMember, membersControllerGetMemberActivity, membersControllerUpdateStatus, membersControllerAdminCheckOut, terminalMembersControllerLogin, invitationsList, invitationsCreate, invitationsRevoke, invitationsAccept, roleManagementControllerGetCustomRoles, roleManagementControllerCreateCustomRole, roleManagementControllerUpdateCustomRole, roleManagementControllerDeleteCustomRole, roleManagementControllerGetPermissionSets, roleManagementControllerCreatePermissionSet, roleManagementControllerGetRoleGroups, roleManagementControllerCreateRoleGroup, roleManagementControllerAssignRoles, roleManagementControllerRemoveRoles, departmentsList, departmentsCreate, departmentsGet, departmentsUpdate, departmentsDelete, departmentsAddMember, departmentsRemoveMember, attendanceControllerGetLogs, attendanceControllerCheckIn, attendanceControllerCheckOut, attendanceControllerGetMyStatus, attendanceControllerGetStatus, announcementControllerBroadcastAnnouncement, cartControllerGetCart, cartControllerClearCart, cartControllerAddToCart, cartControllerRemoveFromCart, favoritesControllerGetFavorites, favoritesControllerAddFavorite, favoritesControllerRemoveFavorite, stockingGetPurchases, stockingCreatePurchase, stockingReceivePurchase, stockingGetTransfers, stockingCreateTransfer, stockingShipTransfer, stockingReceiveTransfer, stockingGetRequests, stockingGetPendingDispatch, stockingDispatchOrders, stockingGetActiveDeliveries, stockingReconcilePod, stockingGetPhysicalReconciliations, stockingSubmitPhysicalReconciliation, stockingGetReconciliationReport, stockingGetPartners, stockingCreatePartner, stockingGetPartner, stockingUpdatePartner, stockingAdjustPartnerWallet, standalonePosControllerCreateSetupKey, standalonePosControllerActivateDevice, standalonePosControllerValidateKey, standalonePosControllerLinkOrganization, b2BGetCatalog, b2BGetInvoices, b2BGetOrders, b2BCreateOrder, b2BCreateQuote, crmIntegrationsGetAuthUrl, crmIntegrationsHandleCallback, crmIntegrationsHandleWebhook, crmIntegrationsReplyToActivity, unitsGetUnits, strapiCreateConnection, strapiListConnections, strapiGetConnection, strapiUpdateConnection, strapiDeleteConnection, strapiTriggerSync, strapiEnqueueSync, strapiGetWebhookLogs, strapiGetSyncLogs, strapiExchangeCustomerToken, strapiRegisterCustomer, strapiReceiveWebhook, analyticsControllerGetDashboardAnalytics, analyticsControllerGetResourceUtilization };
|
|
1897
1903
|
};
|
|
1898
1904
|
|
|
1899
1905
|
// src/base.ts
|
|
@@ -1932,6 +1938,7 @@ var methodsWithOrgSlugSet = /* @__PURE__ */ new Set([
|
|
|
1932
1938
|
"webhooksList",
|
|
1933
1939
|
"webhooksDelete",
|
|
1934
1940
|
"catalogGetProducts",
|
|
1941
|
+
"catalogGetProduct",
|
|
1935
1942
|
"catalogCreateProduct",
|
|
1936
1943
|
"catalogGetServices",
|
|
1937
1944
|
"catalogUpdateProduct",
|
|
@@ -1965,7 +1972,6 @@ var methodsWithOrgSlugSet = /* @__PURE__ */ new Set([
|
|
|
1965
1972
|
"servicesGetUtilization",
|
|
1966
1973
|
"servicesGetPerformance",
|
|
1967
1974
|
"servicesGetFunnel",
|
|
1968
|
-
"customersProvisionZitadel",
|
|
1969
1975
|
"customersGetCustomers",
|
|
1970
1976
|
"customersRegister",
|
|
1971
1977
|
"customersUpdate",
|
|
@@ -1974,6 +1980,10 @@ var methodsWithOrgSlugSet = /* @__PURE__ */ new Set([
|
|
|
1974
1980
|
"customersGetAddresses",
|
|
1975
1981
|
"customersAddAddress",
|
|
1976
1982
|
"customersGetCurrentSession",
|
|
1983
|
+
"customersGetSessions",
|
|
1984
|
+
"customersRevokeSession",
|
|
1985
|
+
"customersRevokeAllSessions",
|
|
1986
|
+
"customersRefreshSession",
|
|
1977
1987
|
"businessAccountControllerCreate",
|
|
1978
1988
|
"businessAccountControllerGetOne",
|
|
1979
1989
|
"crmControllerCreateRecord",
|
|
@@ -2042,6 +2052,7 @@ var methodsWithOrgSlugSet = /* @__PURE__ */ new Set([
|
|
|
2042
2052
|
]);
|
|
2043
2053
|
var catalogMapping = {
|
|
2044
2054
|
getProducts: "catalogGetProducts",
|
|
2055
|
+
getProduct: "catalogGetProduct",
|
|
2045
2056
|
createProduct: "catalogCreateProduct",
|
|
2046
2057
|
getServices: "catalogGetServices",
|
|
2047
2058
|
updateProduct: "catalogUpdateProduct",
|
|
@@ -2340,7 +2351,6 @@ var adminMapping = {
|
|
|
2340
2351
|
handleWindmillApprovalCallback: "windmillCallbackControllerHandleApprovalCallback",
|
|
2341
2352
|
handleWindmillBakeryDisposalCallback: "windmillCallbackControllerHandleBakeryDisposalCallback",
|
|
2342
2353
|
handleWindmillOutcomeCallback: "windmillCallbackControllerHandleOutcomeCallback",
|
|
2343
|
-
provisionZitadel: "customersProvisionZitadel",
|
|
2344
2354
|
getCustomers: "customersGetCustomers",
|
|
2345
2355
|
registerCustomer: "customersRegister",
|
|
2346
2356
|
updateCustomer: "customersUpdate",
|
|
@@ -2393,10 +2403,7 @@ function getJwtExpiry(token) {
|
|
|
2393
2403
|
}
|
|
2394
2404
|
|
|
2395
2405
|
// src/client.tsx
|
|
2396
|
-
var import_react = require("react");
|
|
2397
2406
|
var import_axios2 = __toESM(require("axios"));
|
|
2398
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
2399
|
-
var AuthContext = (0, import_react.createContext)(void 0);
|
|
2400
2407
|
|
|
2401
2408
|
// src/index.ts
|
|
2402
2409
|
function getEnvOrgSlug() {
|
|
@@ -2520,7 +2527,7 @@ var ScrymeServerSDK = class {
|
|
|
2520
2527
|
return this.activeAuthPromise;
|
|
2521
2528
|
};
|
|
2522
2529
|
this.axiosInstance.interceptors.request.use(async (req) => {
|
|
2523
|
-
const isAuthTokenRequest = req.url && (req.url.endsWith("/auth/token") || req.url.includes("/auth/token") || req.url.includes("/customers/auth/refresh")
|
|
2530
|
+
const isAuthTokenRequest = req.url && (req.url.endsWith("/auth/token") || req.url.includes("/auth/token") || req.url.includes("/customers/auth/refresh"));
|
|
2524
2531
|
if (!isAuthTokenRequest && !config.apiKey) {
|
|
2525
2532
|
const isExpired = !this.token || this.expiresAt && Date.now() >= this.expiresAt - 3e4;
|
|
2526
2533
|
if (isExpired) {
|
|
@@ -2555,7 +2562,7 @@ var ScrymeServerSDK = class {
|
|
|
2555
2562
|
(response) => response,
|
|
2556
2563
|
async (error) => {
|
|
2557
2564
|
const originalRequest = error.config;
|
|
2558
|
-
const isAuthTokenRequest = originalRequest && originalRequest.url && (originalRequest.url.endsWith("/auth/token") || originalRequest.url.includes("/auth/token") || originalRequest.url.includes("/customers/auth/refresh")
|
|
2565
|
+
const isAuthTokenRequest = originalRequest && originalRequest.url && (originalRequest.url.endsWith("/auth/token") || originalRequest.url.includes("/auth/token") || originalRequest.url.includes("/customers/auth/refresh"));
|
|
2559
2566
|
if (error.response && error.response.status === 401 && originalRequest && !originalRequest._retry && !isAuthTokenRequest && !config.apiKey) {
|
|
2560
2567
|
originalRequest._retry = true;
|
|
2561
2568
|
try {
|
|
@@ -2581,7 +2588,54 @@ var ScrymeServerSDK = class {
|
|
|
2581
2588
|
}
|
|
2582
2589
|
);
|
|
2583
2590
|
this.api = getScrymeV3API2(this.axiosInstance, config.orgSlug);
|
|
2584
|
-
|
|
2591
|
+
const baseCatalog = buildModule(this.api, config.orgSlug, catalogMapping);
|
|
2592
|
+
this.catalog = {
|
|
2593
|
+
...baseCatalog,
|
|
2594
|
+
getProduct: async (idOrSlug, options) => {
|
|
2595
|
+
const response = await this.catalog.getProducts(void 0, options);
|
|
2596
|
+
const products = response.data || [];
|
|
2597
|
+
const product = products.find((p) => {
|
|
2598
|
+
if (typeof idOrSlug === "string") {
|
|
2599
|
+
return p.id === idOrSlug || p.slug === idOrSlug;
|
|
2600
|
+
} else {
|
|
2601
|
+
const { id, slug } = idOrSlug;
|
|
2602
|
+
if (id && p.id === id) return true;
|
|
2603
|
+
if (slug && p.slug === slug) return true;
|
|
2604
|
+
return false;
|
|
2605
|
+
}
|
|
2606
|
+
});
|
|
2607
|
+
if (!product) {
|
|
2608
|
+
const criteria = typeof idOrSlug === "string" ? idOrSlug : JSON.stringify(idOrSlug);
|
|
2609
|
+
throw new Error(`Product not found matching criteria: ${criteria}`);
|
|
2610
|
+
}
|
|
2611
|
+
return {
|
|
2612
|
+
...response,
|
|
2613
|
+
data: product
|
|
2614
|
+
};
|
|
2615
|
+
},
|
|
2616
|
+
getService: async (idOrSlug, options) => {
|
|
2617
|
+
const response = await this.catalog.getServices(void 0, options);
|
|
2618
|
+
const services = response.data || [];
|
|
2619
|
+
const service = services.find((s) => {
|
|
2620
|
+
if (typeof idOrSlug === "string") {
|
|
2621
|
+
return s.id === idOrSlug || s.slug === idOrSlug;
|
|
2622
|
+
} else {
|
|
2623
|
+
const { id, slug } = idOrSlug;
|
|
2624
|
+
if (id && s.id === id) return true;
|
|
2625
|
+
if (slug && s.slug === slug) return true;
|
|
2626
|
+
return false;
|
|
2627
|
+
}
|
|
2628
|
+
});
|
|
2629
|
+
if (!service) {
|
|
2630
|
+
const criteria = typeof idOrSlug === "string" ? idOrSlug : JSON.stringify(idOrSlug);
|
|
2631
|
+
throw new Error(`Service not found matching criteria: ${criteria}`);
|
|
2632
|
+
}
|
|
2633
|
+
return {
|
|
2634
|
+
...response,
|
|
2635
|
+
data: service
|
|
2636
|
+
};
|
|
2637
|
+
}
|
|
2638
|
+
};
|
|
2585
2639
|
this.inventory = buildModule(this.api, config.orgSlug, inventoryMapping);
|
|
2586
2640
|
this.orders = buildModule(this.api, config.orgSlug, ordersMapping);
|
|
2587
2641
|
this.crm = buildModule(this.api, config.orgSlug, crmMapping);
|
|
@@ -2593,7 +2647,9 @@ var ScrymeServerSDK = class {
|
|
|
2593
2647
|
this.services = buildModule(this.api, config.orgSlug, servicesMapping);
|
|
2594
2648
|
this.cart = {
|
|
2595
2649
|
get: async (params) => {
|
|
2596
|
-
return this.orders.getCart(
|
|
2650
|
+
return this.orders.getCart(
|
|
2651
|
+
params
|
|
2652
|
+
);
|
|
2597
2653
|
},
|
|
2598
2654
|
add: async (dto) => {
|
|
2599
2655
|
return this.orders.addToCart(dto);
|
|
@@ -2602,11 +2658,11 @@ var ScrymeServerSDK = class {
|
|
|
2602
2658
|
return this.orders.removeFromCart(dto);
|
|
2603
2659
|
},
|
|
2604
2660
|
clear: async (params) => {
|
|
2605
|
-
return this.orders.clearCart(params
|
|
2661
|
+
return this.orders.clearCart(params);
|
|
2606
2662
|
},
|
|
2607
2663
|
update: async (dto) => {
|
|
2608
2664
|
const response = await this.orders.getCart({
|
|
2609
|
-
sessionId: dto.sessionId
|
|
2665
|
+
sessionId: dto.sessionId || ""
|
|
2610
2666
|
});
|
|
2611
2667
|
const data = response.data;
|
|
2612
2668
|
const items = data?.data?.items || data?.items || [];
|
|
@@ -2627,7 +2683,7 @@ var ScrymeServerSDK = class {
|
|
|
2627
2683
|
productId: dto.productId,
|
|
2628
2684
|
variantId: dto.variantId,
|
|
2629
2685
|
serviceId: dto.serviceId,
|
|
2630
|
-
sessionId: dto.sessionId,
|
|
2686
|
+
sessionId: dto.sessionId || "",
|
|
2631
2687
|
customerId: dto.customerId
|
|
2632
2688
|
});
|
|
2633
2689
|
} else {
|
|
@@ -2647,12 +2703,16 @@ var ScrymeServerSDK = class {
|
|
|
2647
2703
|
}
|
|
2648
2704
|
},
|
|
2649
2705
|
getItems: async (params) => {
|
|
2650
|
-
const res = await this.orders.getCart(
|
|
2706
|
+
const res = await this.orders.getCart(
|
|
2707
|
+
params
|
|
2708
|
+
);
|
|
2651
2709
|
const data = res?.data || res;
|
|
2652
2710
|
return data?.items || data?.data?.items || [];
|
|
2653
2711
|
},
|
|
2654
2712
|
getTotals: async (params) => {
|
|
2655
|
-
const res = await this.orders.getCart(
|
|
2713
|
+
const res = await this.orders.getCart(
|
|
2714
|
+
params
|
|
2715
|
+
);
|
|
2656
2716
|
const data = res?.data || res;
|
|
2657
2717
|
const items = data?.items || data?.data?.items || [];
|
|
2658
2718
|
const itemsCount = items.reduce(
|
|
@@ -2706,6 +2766,61 @@ var ScrymeServerSDK = class {
|
|
|
2706
2766
|
},
|
|
2707
2767
|
addAddress: async (customerId, dto) => {
|
|
2708
2768
|
return this.admin.addCustomerAddress(customerId, dto);
|
|
2769
|
+
},
|
|
2770
|
+
auth: {
|
|
2771
|
+
signUp: async (dto) => {
|
|
2772
|
+
return this.api.customersRegister(config.orgSlug, dto);
|
|
2773
|
+
},
|
|
2774
|
+
signIn: async (credentials) => {
|
|
2775
|
+
const response = await this.axiosInstance.post(
|
|
2776
|
+
"/auth/sign-in/email",
|
|
2777
|
+
credentials
|
|
2778
|
+
);
|
|
2779
|
+
const data = response.data;
|
|
2780
|
+
const token = data?.session?.token || data?.token || null;
|
|
2781
|
+
if (token) {
|
|
2782
|
+
this.token = token;
|
|
2783
|
+
this.expiresAt = getJwtExpiry(token);
|
|
2784
|
+
this.axiosInstance.defaults.headers.common["Authorization"] = `Bearer ${token}`;
|
|
2785
|
+
}
|
|
2786
|
+
return data;
|
|
2787
|
+
},
|
|
2788
|
+
getCurrentSession: async (headers) => {
|
|
2789
|
+
const requestConfig = {};
|
|
2790
|
+
if (headers) {
|
|
2791
|
+
const requestHeaders = {};
|
|
2792
|
+
if (typeof headers.forEach === "function") {
|
|
2793
|
+
headers.forEach((value, key) => {
|
|
2794
|
+
requestHeaders[key] = value;
|
|
2795
|
+
});
|
|
2796
|
+
} else {
|
|
2797
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
2798
|
+
if (value !== void 0) {
|
|
2799
|
+
requestHeaders[key] = Array.isArray(value) ? value.join(", ") : String(value);
|
|
2800
|
+
}
|
|
2801
|
+
}
|
|
2802
|
+
}
|
|
2803
|
+
requestConfig.headers = requestHeaders;
|
|
2804
|
+
}
|
|
2805
|
+
const response = await this.axiosInstance.get(
|
|
2806
|
+
`/${config.orgSlug}/customers/auth/session`,
|
|
2807
|
+
requestConfig
|
|
2808
|
+
);
|
|
2809
|
+
return response.data?.data || response.data;
|
|
2810
|
+
},
|
|
2811
|
+
refreshSession: async () => {
|
|
2812
|
+
const response = await this.axiosInstance.post(
|
|
2813
|
+
`/${config.orgSlug}/customers/auth/refresh`
|
|
2814
|
+
);
|
|
2815
|
+
const data = response.data?.data || response.data;
|
|
2816
|
+
const token = data?.token || null;
|
|
2817
|
+
if (token) {
|
|
2818
|
+
this.token = token;
|
|
2819
|
+
this.expiresAt = getJwtExpiry(token);
|
|
2820
|
+
this.axiosInstance.defaults.headers.common["Authorization"] = `Bearer ${token}`;
|
|
2821
|
+
}
|
|
2822
|
+
return data;
|
|
2823
|
+
}
|
|
2709
2824
|
}
|
|
2710
2825
|
};
|
|
2711
2826
|
this.bookings = {
|
|
@@ -2728,58 +2843,21 @@ var ScrymeServerSDK = class {
|
|
|
2728
2843
|
const baseAuth = buildModule(this.api, config.orgSlug, authMapping);
|
|
2729
2844
|
this.auth = {
|
|
2730
2845
|
...baseAuth,
|
|
2731
|
-
|
|
2732
|
-
return this.api.customersRegister(config.orgSlug, dto);
|
|
2733
|
-
},
|
|
2846
|
+
...this.customer.auth,
|
|
2734
2847
|
authenticate: async () => {
|
|
2735
2848
|
return performExchange();
|
|
2736
2849
|
},
|
|
2850
|
+
signUp: async (dto) => {
|
|
2851
|
+
return this.customer.auth.signUp(dto);
|
|
2852
|
+
},
|
|
2737
2853
|
signIn: async (credentials) => {
|
|
2738
|
-
|
|
2739
|
-
"/auth/sign-in/email",
|
|
2740
|
-
credentials
|
|
2741
|
-
);
|
|
2742
|
-
const data = response.data;
|
|
2743
|
-
const token = data?.session?.token || data?.token || null;
|
|
2744
|
-
if (token) {
|
|
2745
|
-
this.token = token;
|
|
2746
|
-
this.expiresAt = getJwtExpiry(token);
|
|
2747
|
-
this.axiosInstance.defaults.headers.common["Authorization"] = `Bearer ${token}`;
|
|
2748
|
-
}
|
|
2749
|
-
return data;
|
|
2854
|
+
return this.customer.auth.signIn(credentials);
|
|
2750
2855
|
},
|
|
2751
|
-
getCurrentSession: async () => {
|
|
2752
|
-
|
|
2753
|
-
`/${config.orgSlug}/customers/auth/session`
|
|
2754
|
-
);
|
|
2755
|
-
return response.data?.data || response.data;
|
|
2856
|
+
getCurrentSession: async (headers) => {
|
|
2857
|
+
return this.customer.auth.getCurrentSession(headers);
|
|
2756
2858
|
},
|
|
2757
2859
|
refreshSession: async () => {
|
|
2758
|
-
|
|
2759
|
-
`/${config.orgSlug}/customers/auth/refresh`
|
|
2760
|
-
);
|
|
2761
|
-
const data = response.data?.data || response.data;
|
|
2762
|
-
const token = data?.token || null;
|
|
2763
|
-
if (token) {
|
|
2764
|
-
this.token = token;
|
|
2765
|
-
this.expiresAt = getJwtExpiry(token);
|
|
2766
|
-
this.axiosInstance.defaults.headers.common["Authorization"] = `Bearer ${token}`;
|
|
2767
|
-
}
|
|
2768
|
-
return data;
|
|
2769
|
-
},
|
|
2770
|
-
swapZitadel: async (zitadelToken) => {
|
|
2771
|
-
const response = await this.axiosInstance.post(
|
|
2772
|
-
`/${config.orgSlug}/customers/auth/swap-zitadel`,
|
|
2773
|
-
{ zitadelToken }
|
|
2774
|
-
);
|
|
2775
|
-
const data = response.data?.data || response.data;
|
|
2776
|
-
const token = data?.token || null;
|
|
2777
|
-
if (token) {
|
|
2778
|
-
this.token = token;
|
|
2779
|
-
this.expiresAt = getJwtExpiry(token);
|
|
2780
|
-
this.axiosInstance.defaults.headers.common["Authorization"] = `Bearer ${token}`;
|
|
2781
|
-
}
|
|
2782
|
-
return data;
|
|
2860
|
+
return this.customer.auth.refreshSession();
|
|
2783
2861
|
}
|
|
2784
2862
|
};
|
|
2785
2863
|
}
|
package/dist/server.mjs
CHANGED