@scryme/sdk 9.67.0 → 9.69.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 +12 -5
- package/dist/{base-1B2-e5i_.d.mts → base-CSVOv3Nr.d.mts} +187 -3
- package/dist/{base-1B2-e5i_.d.ts → base-CSVOv3Nr.d.ts} +187 -3
- package/dist/{chunk-QS5K7GIL.mjs → chunk-SYGBIPUK.mjs} +214 -3
- package/dist/client.d.mts +255 -3
- package/dist/client.d.ts +255 -3
- package/dist/client.js +202 -2
- package/dist/client.mjs +1 -1
- package/dist/index.d.mts +8 -4
- package/dist/index.d.ts +8 -4
- package/dist/index.js +214 -3
- package/dist/index.mjs +1 -1
- package/dist/server.d.mts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +50 -2
- package/dist/server.mjs +1 -1
- package/package.json +1 -1
|
@@ -659,6 +659,29 @@ var getScrymeV3API = (axiosInstance = axios) => {
|
|
|
659
659
|
options
|
|
660
660
|
);
|
|
661
661
|
};
|
|
662
|
+
const catalogCreateReview = (orgSlug, productId, createProductReviewDto, options) => {
|
|
663
|
+
return axiosInstance.post(
|
|
664
|
+
`/v3/${orgSlug}/catalog/products/${productId}/reviews`,
|
|
665
|
+
createProductReviewDto,
|
|
666
|
+
options
|
|
667
|
+
);
|
|
668
|
+
};
|
|
669
|
+
const catalogUpdateReview = (orgSlug, reviewId, updateProductReviewDto, options) => {
|
|
670
|
+
return axiosInstance.patch(
|
|
671
|
+
`/v3/${orgSlug}/catalog/reviews/${reviewId}`,
|
|
672
|
+
updateProductReviewDto,
|
|
673
|
+
options
|
|
674
|
+
);
|
|
675
|
+
};
|
|
676
|
+
const catalogDeleteReview = (orgSlug, reviewId, params, options) => {
|
|
677
|
+
return axiosInstance.delete(
|
|
678
|
+
`/v3/${orgSlug}/catalog/reviews/${reviewId}`,
|
|
679
|
+
{
|
|
680
|
+
...options,
|
|
681
|
+
params: { ...params, ...options?.params }
|
|
682
|
+
}
|
|
683
|
+
);
|
|
684
|
+
};
|
|
662
685
|
const servicesCreateCategory = (orgSlug, createServiceCategoryDto, options) => {
|
|
663
686
|
return axiosInstance.post(
|
|
664
687
|
`/v3/${orgSlug}/services/categories`,
|
|
@@ -912,6 +935,13 @@ var getScrymeV3API = (axiosInstance = axios) => {
|
|
|
912
935
|
options
|
|
913
936
|
);
|
|
914
937
|
};
|
|
938
|
+
const customerRegister = (orgSlug, registerCustomerDto, options) => {
|
|
939
|
+
return axiosInstance.post(
|
|
940
|
+
`/v3/${orgSlug}/customers/../customer/register`,
|
|
941
|
+
registerCustomerDto,
|
|
942
|
+
options
|
|
943
|
+
);
|
|
944
|
+
};
|
|
915
945
|
const customersLogin = (orgSlug, customerLoginDto, options) => {
|
|
916
946
|
return axiosInstance.post(
|
|
917
947
|
`/v3/${orgSlug}/customers/auth/login`,
|
|
@@ -1864,7 +1894,7 @@ var getScrymeV3API = (axiosInstance = axios) => {
|
|
|
1864
1894
|
}
|
|
1865
1895
|
);
|
|
1866
1896
|
};
|
|
1867
|
-
return { inventoryVerifyIntegrity, inventoryFixIntegrity, inventoryGetInventory, inventoryTraceBatch, inventorySplitBatch, inventoryMergeBatches, inventoryCreateAssembly, inventoryCompleteAssembly, inventoryRequestAdjustment, inventoryGetAdjustments, inventoryApproveAdjustment, inventoryRejectAdjustment, inventoryGetLeadTime, inventoryGetWasteAnalysis, inventoryCheckB2BAvailability, inventoryUnpackBatch, inventoryScanUnpackBatch, inventoryQuickStockInquiry, expenseControllerCreateExpense, expenseControllerGetExpenses, expenseControllerGetExpenseCategories, expenseControllerGetExpense, pettyCashControllerCreateFund, pettyCashControllerGetFunds, pettyCashControllerGetFund, pettyCashControllerTopUpFund, pettyCashControllerGetFundTransactions, utilityAccountControllerCreateAccount, utilityAccountControllerGetAccounts, utilityAccountControllerGetAccount, accountingInitialize, accountingGetProfitLoss, accountingGetBalanceSheet, accountingGetCashFlow, accountingGetTaxSummary, invoiceControllerCreateInvoice, invoiceControllerGetInvoices, invoiceControllerGetInvoice, invoiceControllerUpdateInvoice, invoiceControllerDeleteInvoice, invoiceControllerFinalizeInvoice, invoiceControllerGetTemplates, invoiceControllerCreateTemplate, invoiceControllerGetConfig, invoiceControllerUpdateConfig, publicInvoiceControllerDownloadInvoice, publicInvoiceControllerDownloadInvoiceByTransaction, publicInvoiceControllerDownloadReceipt, publicInvoiceControllerGeneratePublicLink, authExchangeToken, authControllerHandleOAuth2, adminControllerGetStats, adminControllerListOrganizations, adminControllerCreateOrganization, adminControllerGetOrganizationDetails, adminControllerUpdateOrganization, adminControllerDeleteOrganization, adminControllerListMembers, adminControllerListUsers, adminControllerBanUser, adminControllerUnbanUser, adminControllerListConnectedApps, adminControllerListSystemLogs, adminControllerListGlobalSettings, adminControllerSetGlobalSetting, adminControllerDeleteGlobalSetting, adminControllerListTiers, adminControllerDefineTier, adminControllerDeleteTier, adminControllerGetOrganizationSubscription, adminControllerUpdateOrganizationSubscription, adminControllerListSystemPayments, adminControllerRecordCustomPayment, adminControllerListIntegrationDefinitions, adminControllerCreateIntegrationDefinition, adminControllerUpdateIntegrationDefinition, adminControllerDeleteIntegrationDefinition, adminControllerListActiveOrganizationIntegrations, webhooksCreate, webhooksList, webhooksDelete, windmillCallbackControllerHandleCallback, windmillCallbackControllerHandleApprovalCallback, windmillCallbackControllerHandleBakeryDisposalCallback, windmillCallbackControllerHandleOutcomeCallback, catalogGetProducts, catalogCreateProduct, catalogGetProduct, catalogGetServices, catalogUpdateProduct, catalogUpdateSupplierVariant, catalogGetPriceChangeRequests, catalogReviewPriceChangeRequest, servicesCreateCategory, servicesGetCategories, servicesUpdateCategory, servicesDeleteCategory, servicesCreateService, servicesGetServices, servicesGetCurrentMemberShifts, servicesGetShifts, servicesGetService, servicesUpdateService, servicesDeleteService, servicesCreateResource, servicesGetResources, servicesUpdateResource, servicesDeleteResource, servicesCreateBooking, servicesGetBookings, servicesGetBooking, servicesUpdateBookingStatus, servicesCompleteBooking, servicesCreateShift, servicesGetStaffShifts, servicesAddBreak, servicesRegisterCustomerApp, servicesGetUtilization, servicesGetPerformance, servicesGetFunnel, publicServicesListServices, publicServicesGetCategories, publicServicesGetService, publicServicesGetAvailability, publicServicesRequestOtp, publicServicesVerifyOtp, publicServicesCreatePublicBooking, customersGetCustomers, customersRegister, customersLogin, customersRefreshSession, customersGetCurrentSession, customersGetSessions, customersRevokeAllSessions, customersRevokeSession, customersUpdate, customersGetCustomerById, customersDelete, customersGetAddresses, customersAddAddress, businessAccountControllerCreate, businessAccountControllerGetOne, crmControllerCreateRecord, crmControllerGetRecord, crmControllerUpdateRecord, crmControllerCreateNote, crmControllerGetRecordNotes, crmControllerCreateActivity, crmControllerGetTimeline, crmControllerCreateObject, crmControllerListObjects, crmControllerCreateField, crmControllerListFields, crmControllerCreateRelationship, crmControllerListRelationships, crmControllerCreateAssociation, crmControllerListRecordAssociations, loyaltyRedeemReward, loyaltyGetCustomerStatus, loyaltyValidateVoucher, ordersCreateOrder, ordersGetOrders, ordersUpdateStatus, ordersRequestB2BQuote, ordersConvertQuoteToOrder, paymentsControllerHandleStkCallback, pOSProvision, pOSLogin, pOSGetMe, pOSProcessSale, pOSSync, pOSGetTransactions, pOSRegisterPettyCash, pOSGetPettyCashFunds, pOSGetPettyCashTransactions, membersControllerGetMembers, membersControllerCreateMember, membersControllerGetMember, membersControllerUpdateMember, membersControllerDeleteMember, membersControllerGetMemberActivity, membersControllerUpdateStatus, membersControllerAdminCheckOut, terminalMembersControllerLogin, invitationsList, invitationsCreate, invitationsRevoke, invitationsAccept, roleManagementControllerGetCustomRoles, roleManagementControllerCreateCustomRole, roleManagementControllerUpdateCustomRole, roleManagementControllerDeleteCustomRole, roleManagementControllerGetPermissionSets, roleManagementControllerCreatePermissionSet, roleManagementControllerGetRoleGroups, roleManagementControllerCreateRoleGroup, roleManagementControllerAssignRoles, roleManagementControllerRemoveRoles, departmentsList, departmentsCreate, departmentsGet, departmentsUpdate, departmentsDelete, departmentsAddMember, departmentsRemoveMember, attendanceControllerGetLogs, attendanceControllerCheckIn, attendanceControllerCheckOut, attendanceControllerGetMyStatus, attendanceControllerGetStatus, announcementControllerBroadcastAnnouncement, cartControllerGetCart, cartControllerClearCart, cartControllerAddToCart, cartControllerRemoveFromCart, favoritesControllerGetFavorites, favoritesControllerAddFavorite, favoritesControllerRemoveFavorite, stockingGetPurchases, stockingCreatePurchase, stockingReceivePurchase, stockingGetTransfers, stockingCreateTransfer, stockingShipTransfer, stockingReceiveTransfer, stockingGetRequests, stockingGetPendingDispatch, stockingDispatchOrders, stockingGetActiveDeliveries, stockingReconcilePod, stockingGetPhysicalReconciliations, stockingSubmitPhysicalReconciliation, stockingGetReconciliationReport, stockingGetPartners, stockingCreatePartner, stockingGetPartner, stockingUpdatePartner, stockingAdjustPartnerWallet, standalonePosControllerCreateSetupKey, standalonePosControllerActivateDevice, standalonePosControllerValidateKey, standalonePosControllerLinkOrganization, b2BGetCatalog, b2BGetInvoices, b2BGetOrders, b2BCreateOrder, b2BCreateQuote, crmIntegrationsGetAuthUrl, crmIntegrationsHandleCallback, crmIntegrationsHandleWebhook, crmIntegrationsReplyToActivity, unitsGetUnits, strapiCreateConnection, strapiListConnections, strapiGetConnection, strapiUpdateConnection, strapiDeleteConnection, strapiTriggerSync, strapiEnqueueSync, strapiGetWebhookLogs, strapiGetSyncLogs, strapiExchangeCustomerToken, strapiRegisterCustomer, strapiReceiveWebhook, analyticsControllerGetDashboardAnalytics, analyticsControllerGetResourceUtilization };
|
|
1897
|
+
return { inventoryVerifyIntegrity, inventoryFixIntegrity, inventoryGetInventory, inventoryTraceBatch, inventorySplitBatch, inventoryMergeBatches, inventoryCreateAssembly, inventoryCompleteAssembly, inventoryRequestAdjustment, inventoryGetAdjustments, inventoryApproveAdjustment, inventoryRejectAdjustment, inventoryGetLeadTime, inventoryGetWasteAnalysis, inventoryCheckB2BAvailability, inventoryUnpackBatch, inventoryScanUnpackBatch, inventoryQuickStockInquiry, expenseControllerCreateExpense, expenseControllerGetExpenses, expenseControllerGetExpenseCategories, expenseControllerGetExpense, pettyCashControllerCreateFund, pettyCashControllerGetFunds, pettyCashControllerGetFund, pettyCashControllerTopUpFund, pettyCashControllerGetFundTransactions, utilityAccountControllerCreateAccount, utilityAccountControllerGetAccounts, utilityAccountControllerGetAccount, accountingInitialize, accountingGetProfitLoss, accountingGetBalanceSheet, accountingGetCashFlow, accountingGetTaxSummary, invoiceControllerCreateInvoice, invoiceControllerGetInvoices, invoiceControllerGetInvoice, invoiceControllerUpdateInvoice, invoiceControllerDeleteInvoice, invoiceControllerFinalizeInvoice, invoiceControllerGetTemplates, invoiceControllerCreateTemplate, invoiceControllerGetConfig, invoiceControllerUpdateConfig, publicInvoiceControllerDownloadInvoice, publicInvoiceControllerDownloadInvoiceByTransaction, publicInvoiceControllerDownloadReceipt, publicInvoiceControllerGeneratePublicLink, authExchangeToken, authControllerHandleOAuth2, adminControllerGetStats, adminControllerListOrganizations, adminControllerCreateOrganization, adminControllerGetOrganizationDetails, adminControllerUpdateOrganization, adminControllerDeleteOrganization, adminControllerListMembers, adminControllerListUsers, adminControllerBanUser, adminControllerUnbanUser, adminControllerListConnectedApps, adminControllerListSystemLogs, adminControllerListGlobalSettings, adminControllerSetGlobalSetting, adminControllerDeleteGlobalSetting, adminControllerListTiers, adminControllerDefineTier, adminControllerDeleteTier, adminControllerGetOrganizationSubscription, adminControllerUpdateOrganizationSubscription, adminControllerListSystemPayments, adminControllerRecordCustomPayment, adminControllerListIntegrationDefinitions, adminControllerCreateIntegrationDefinition, adminControllerUpdateIntegrationDefinition, adminControllerDeleteIntegrationDefinition, adminControllerListActiveOrganizationIntegrations, webhooksCreate, webhooksList, webhooksDelete, windmillCallbackControllerHandleCallback, windmillCallbackControllerHandleApprovalCallback, windmillCallbackControllerHandleBakeryDisposalCallback, windmillCallbackControllerHandleOutcomeCallback, catalogGetProducts, catalogCreateProduct, catalogGetProduct, catalogGetServices, catalogUpdateProduct, catalogUpdateSupplierVariant, catalogGetPriceChangeRequests, catalogReviewPriceChangeRequest, catalogCreateReview, catalogUpdateReview, catalogDeleteReview, servicesCreateCategory, servicesGetCategories, servicesUpdateCategory, servicesDeleteCategory, servicesCreateService, servicesGetServices, servicesGetCurrentMemberShifts, servicesGetShifts, servicesGetService, servicesUpdateService, servicesDeleteService, servicesCreateResource, servicesGetResources, servicesUpdateResource, servicesDeleteResource, servicesCreateBooking, servicesGetBookings, servicesGetBooking, servicesUpdateBookingStatus, servicesCompleteBooking, servicesCreateShift, servicesGetStaffShifts, servicesAddBreak, servicesRegisterCustomerApp, servicesGetUtilization, servicesGetPerformance, servicesGetFunnel, publicServicesListServices, publicServicesGetCategories, publicServicesGetService, publicServicesGetAvailability, publicServicesRequestOtp, publicServicesVerifyOtp, publicServicesCreatePublicBooking, customersGetCustomers, customersRegister, customerRegister, customersLogin, customersRefreshSession, customersGetCurrentSession, customersGetSessions, customersRevokeAllSessions, customersRevokeSession, customersUpdate, customersGetCustomerById, customersDelete, customersGetAddresses, customersAddAddress, businessAccountControllerCreate, businessAccountControllerGetOne, crmControllerCreateRecord, crmControllerGetRecord, crmControllerUpdateRecord, crmControllerCreateNote, crmControllerGetRecordNotes, crmControllerCreateActivity, crmControllerGetTimeline, crmControllerCreateObject, crmControllerListObjects, crmControllerCreateField, crmControllerListFields, crmControllerCreateRelationship, crmControllerListRelationships, crmControllerCreateAssociation, crmControllerListRecordAssociations, loyaltyRedeemReward, loyaltyGetCustomerStatus, loyaltyValidateVoucher, ordersCreateOrder, ordersGetOrders, ordersUpdateStatus, ordersRequestB2BQuote, ordersConvertQuoteToOrder, paymentsControllerHandleStkCallback, pOSProvision, pOSLogin, pOSGetMe, pOSProcessSale, pOSSync, pOSGetTransactions, pOSRegisterPettyCash, pOSGetPettyCashFunds, pOSGetPettyCashTransactions, membersControllerGetMembers, membersControllerCreateMember, membersControllerGetMember, membersControllerUpdateMember, membersControllerDeleteMember, membersControllerGetMemberActivity, membersControllerUpdateStatus, membersControllerAdminCheckOut, terminalMembersControllerLogin, invitationsList, invitationsCreate, invitationsRevoke, invitationsAccept, roleManagementControllerGetCustomRoles, roleManagementControllerCreateCustomRole, roleManagementControllerUpdateCustomRole, roleManagementControllerDeleteCustomRole, roleManagementControllerGetPermissionSets, roleManagementControllerCreatePermissionSet, roleManagementControllerGetRoleGroups, roleManagementControllerCreateRoleGroup, roleManagementControllerAssignRoles, roleManagementControllerRemoveRoles, departmentsList, departmentsCreate, departmentsGet, departmentsUpdate, departmentsDelete, departmentsAddMember, departmentsRemoveMember, attendanceControllerGetLogs, attendanceControllerCheckIn, attendanceControllerCheckOut, attendanceControllerGetMyStatus, attendanceControllerGetStatus, announcementControllerBroadcastAnnouncement, cartControllerGetCart, cartControllerClearCart, cartControllerAddToCart, cartControllerRemoveFromCart, favoritesControllerGetFavorites, favoritesControllerAddFavorite, favoritesControllerRemoveFavorite, stockingGetPurchases, stockingCreatePurchase, stockingReceivePurchase, stockingGetTransfers, stockingCreateTransfer, stockingShipTransfer, stockingReceiveTransfer, stockingGetRequests, stockingGetPendingDispatch, stockingDispatchOrders, stockingGetActiveDeliveries, stockingReconcilePod, stockingGetPhysicalReconciliations, stockingSubmitPhysicalReconciliation, stockingGetReconciliationReport, stockingGetPartners, stockingCreatePartner, stockingGetPartner, stockingUpdatePartner, stockingAdjustPartnerWallet, standalonePosControllerCreateSetupKey, standalonePosControllerActivateDevice, standalonePosControllerValidateKey, standalonePosControllerLinkOrganization, b2BGetCatalog, b2BGetInvoices, b2BGetOrders, b2BCreateOrder, b2BCreateQuote, crmIntegrationsGetAuthUrl, crmIntegrationsHandleCallback, crmIntegrationsHandleWebhook, crmIntegrationsReplyToActivity, unitsGetUnits, strapiCreateConnection, strapiListConnections, strapiGetConnection, strapiUpdateConnection, strapiDeleteConnection, strapiTriggerSync, strapiEnqueueSync, strapiGetWebhookLogs, strapiGetSyncLogs, strapiExchangeCustomerToken, strapiRegisterCustomer, strapiReceiveWebhook, analyticsControllerGetDashboardAnalytics, analyticsControllerGetResourceUtilization };
|
|
1868
1898
|
};
|
|
1869
1899
|
|
|
1870
1900
|
// src/generated/model/addDepartmentMemberDtoRole.ts
|
|
@@ -2321,6 +2351,9 @@ var methodsWithOrgSlugSet = /* @__PURE__ */ new Set([
|
|
|
2321
2351
|
"catalogUpdateSupplierVariant",
|
|
2322
2352
|
"catalogGetPriceChangeRequests",
|
|
2323
2353
|
"catalogReviewPriceChangeRequest",
|
|
2354
|
+
"catalogCreateReview",
|
|
2355
|
+
"catalogUpdateReview",
|
|
2356
|
+
"catalogDeleteReview",
|
|
2324
2357
|
"servicesCreateCategory",
|
|
2325
2358
|
"servicesGetCategories",
|
|
2326
2359
|
"servicesUpdateCategory",
|
|
@@ -2435,6 +2468,9 @@ var catalogMapping = {
|
|
|
2435
2468
|
updateSupplierVariant: "catalogUpdateSupplierVariant",
|
|
2436
2469
|
getPriceChangeRequests: "catalogGetPriceChangeRequests",
|
|
2437
2470
|
reviewPriceChangeRequest: "catalogReviewPriceChangeRequest",
|
|
2471
|
+
createReview: "catalogCreateReview",
|
|
2472
|
+
updateReview: "catalogUpdateReview",
|
|
2473
|
+
deleteReview: "catalogDeleteReview",
|
|
2438
2474
|
createServiceCategory: "servicesCreateCategory",
|
|
2439
2475
|
getServiceCategories: "servicesGetCategories",
|
|
2440
2476
|
updateServiceCategory: "servicesUpdateCategory",
|
|
@@ -2779,6 +2815,7 @@ function getJwtExpiry(token) {
|
|
|
2779
2815
|
}
|
|
2780
2816
|
|
|
2781
2817
|
// src/client.tsx
|
|
2818
|
+
import { useEffect, useState } from "react";
|
|
2782
2819
|
import axios2 from "axios";
|
|
2783
2820
|
var InMemoryStorage = class {
|
|
2784
2821
|
constructor() {
|
|
@@ -3020,6 +3057,39 @@ var ScrymeClientSDK = class {
|
|
|
3020
3057
|
...response,
|
|
3021
3058
|
data: service
|
|
3022
3059
|
};
|
|
3060
|
+
},
|
|
3061
|
+
createReview: async (productId, dto, options) => {
|
|
3062
|
+
if (!dto.customerId) {
|
|
3063
|
+
const session = await this.auth.getSession();
|
|
3064
|
+
const user = session?.user;
|
|
3065
|
+
const customerId = user?.customerId || user?.id || user?.customer?.id;
|
|
3066
|
+
if (customerId) {
|
|
3067
|
+
dto = { ...dto, customerId };
|
|
3068
|
+
}
|
|
3069
|
+
}
|
|
3070
|
+
return baseCatalog.createReview(productId, dto, options);
|
|
3071
|
+
},
|
|
3072
|
+
updateReview: async (reviewId, dto, options) => {
|
|
3073
|
+
if (!dto.customerId) {
|
|
3074
|
+
const session = await this.auth.getSession();
|
|
3075
|
+
const user = session?.user;
|
|
3076
|
+
const customerId = user?.customerId || user?.id || user?.customer?.id;
|
|
3077
|
+
if (customerId) {
|
|
3078
|
+
dto = { ...dto, customerId };
|
|
3079
|
+
}
|
|
3080
|
+
}
|
|
3081
|
+
return baseCatalog.updateReview(reviewId, dto, options);
|
|
3082
|
+
},
|
|
3083
|
+
deleteReview: async (reviewId, params, options) => {
|
|
3084
|
+
if (!params || !params.customerId) {
|
|
3085
|
+
const session = await this.auth.getSession();
|
|
3086
|
+
const user = session?.user;
|
|
3087
|
+
const customerId = user?.customerId || user?.id || user?.customer?.id;
|
|
3088
|
+
if (customerId) {
|
|
3089
|
+
params = { ...params, customerId };
|
|
3090
|
+
}
|
|
3091
|
+
}
|
|
3092
|
+
return baseCatalog.deleteReview(reviewId, params, options);
|
|
3023
3093
|
}
|
|
3024
3094
|
};
|
|
3025
3095
|
this.inventory = buildModule(this.api, config.orgSlug, inventoryMapping);
|
|
@@ -3035,15 +3105,42 @@ var ScrymeClientSDK = class {
|
|
|
3035
3105
|
return this.orders.getCart(params);
|
|
3036
3106
|
},
|
|
3037
3107
|
add: async (dto) => {
|
|
3108
|
+
if (!dto.customerId) {
|
|
3109
|
+
const session = await this.auth.getSession();
|
|
3110
|
+
const user = session?.user;
|
|
3111
|
+
const customerId = user?.customerId || user?.id || user?.customer?.id;
|
|
3112
|
+
if (!customerId) {
|
|
3113
|
+
throw new Error("Unauthorized: customerId is required.");
|
|
3114
|
+
}
|
|
3115
|
+
dto = { ...dto, customerId };
|
|
3116
|
+
}
|
|
3038
3117
|
return this.orders.addToCart(dto);
|
|
3039
3118
|
},
|
|
3040
3119
|
remove: async (dto) => {
|
|
3120
|
+
if (!dto.customerId) {
|
|
3121
|
+
const session = await this.auth.getSession();
|
|
3122
|
+
const user = session?.user;
|
|
3123
|
+
const customerId = user?.customerId || user?.id || user?.customer?.id;
|
|
3124
|
+
if (!customerId) {
|
|
3125
|
+
throw new Error("Unauthorized: customerId is required.");
|
|
3126
|
+
}
|
|
3127
|
+
dto = { ...dto, customerId };
|
|
3128
|
+
}
|
|
3041
3129
|
return this.orders.removeFromCart(dto);
|
|
3042
3130
|
},
|
|
3043
3131
|
clear: async (params) => {
|
|
3044
3132
|
return this.orders.clearCart(params);
|
|
3045
3133
|
},
|
|
3046
3134
|
update: async (dto) => {
|
|
3135
|
+
if (!dto.customerId) {
|
|
3136
|
+
const session = await this.auth.getSession();
|
|
3137
|
+
const user = session?.user;
|
|
3138
|
+
const customerId = user?.customerId || user?.id || user?.customer?.id;
|
|
3139
|
+
if (!customerId) {
|
|
3140
|
+
throw new Error("Unauthorized: customerId is required.");
|
|
3141
|
+
}
|
|
3142
|
+
dto = { ...dto, customerId };
|
|
3143
|
+
}
|
|
3047
3144
|
const response = await this.orders.getCart({
|
|
3048
3145
|
sessionId: dto.sessionId || ""
|
|
3049
3146
|
});
|
|
@@ -3134,8 +3231,42 @@ var ScrymeClientSDK = class {
|
|
|
3134
3231
|
}
|
|
3135
3232
|
};
|
|
3136
3233
|
const customerAuth = {
|
|
3234
|
+
get session() {
|
|
3235
|
+
if (!state.token) {
|
|
3236
|
+
return {
|
|
3237
|
+
data: null,
|
|
3238
|
+
isPending: false,
|
|
3239
|
+
error: null
|
|
3240
|
+
};
|
|
3241
|
+
}
|
|
3242
|
+
const userId = state.user?.id || state.user?.userId || state.user?.customerId || "";
|
|
3243
|
+
return {
|
|
3244
|
+
data: {
|
|
3245
|
+
session: {
|
|
3246
|
+
id: userId || state.token,
|
|
3247
|
+
userId,
|
|
3248
|
+
expiresAt: state.expiresAt ? new Date(state.expiresAt) : null,
|
|
3249
|
+
token: state.token
|
|
3250
|
+
},
|
|
3251
|
+
user: state.user
|
|
3252
|
+
},
|
|
3253
|
+
isPending: false,
|
|
3254
|
+
error: null
|
|
3255
|
+
};
|
|
3256
|
+
},
|
|
3137
3257
|
signUp: async (dto) => {
|
|
3138
|
-
|
|
3258
|
+
const res = await this.api.customersRegister(config.orgSlug, dto);
|
|
3259
|
+
if (dto.password) {
|
|
3260
|
+
try {
|
|
3261
|
+
await customerAuth.signIn({
|
|
3262
|
+
email: dto.email,
|
|
3263
|
+
password: dto.password
|
|
3264
|
+
});
|
|
3265
|
+
} catch (e) {
|
|
3266
|
+
console.error("Auto sign-in after sign-up failed:", e);
|
|
3267
|
+
}
|
|
3268
|
+
}
|
|
3269
|
+
return res;
|
|
3139
3270
|
},
|
|
3140
3271
|
signIn: async (credentials) => {
|
|
3141
3272
|
const res = await this.api.customersLogin(config.orgSlug, credentials);
|
|
@@ -3213,6 +3344,60 @@ var ScrymeClientSDK = class {
|
|
|
3213
3344
|
notify("SIGNED_IN");
|
|
3214
3345
|
}
|
|
3215
3346
|
return authData;
|
|
3347
|
+
},
|
|
3348
|
+
useSession: () => {
|
|
3349
|
+
const currentSession = customerAuth.session;
|
|
3350
|
+
const [data, setData] = useState(currentSession.data);
|
|
3351
|
+
const [isPending, setIsPending] = useState(false);
|
|
3352
|
+
const [error, setError] = useState(null);
|
|
3353
|
+
const fetchSessionSync = () => {
|
|
3354
|
+
const s = customerAuth.session;
|
|
3355
|
+
setData(s.data);
|
|
3356
|
+
setError(s.error);
|
|
3357
|
+
setIsPending(s.isPending);
|
|
3358
|
+
};
|
|
3359
|
+
const fetchSessionAsync = async () => {
|
|
3360
|
+
setIsPending(true);
|
|
3361
|
+
try {
|
|
3362
|
+
const res = await customerAuth.getCurrentSession();
|
|
3363
|
+
if (res && (res.session || res.customer || res.user)) {
|
|
3364
|
+
setData({
|
|
3365
|
+
session: res.session,
|
|
3366
|
+
user: res.customer || res.user
|
|
3367
|
+
});
|
|
3368
|
+
} else {
|
|
3369
|
+
const sessionState = await customerAuth.getSession();
|
|
3370
|
+
setData({
|
|
3371
|
+
session: {
|
|
3372
|
+
id: sessionState.user?.id || sessionState.user?.userId || sessionState.user?.customerId || sessionState.token,
|
|
3373
|
+
userId: sessionState.user?.id || sessionState.user?.userId || sessionState.user?.customerId || "",
|
|
3374
|
+
expiresAt: sessionState.expiresAt ? new Date(sessionState.expiresAt) : null,
|
|
3375
|
+
token: sessionState.token
|
|
3376
|
+
},
|
|
3377
|
+
user: sessionState.user
|
|
3378
|
+
});
|
|
3379
|
+
}
|
|
3380
|
+
setError(null);
|
|
3381
|
+
} catch (e) {
|
|
3382
|
+
setError(e instanceof Error ? e : new Error(String(e)));
|
|
3383
|
+
setData(null);
|
|
3384
|
+
} finally {
|
|
3385
|
+
setIsPending(false);
|
|
3386
|
+
}
|
|
3387
|
+
};
|
|
3388
|
+
useEffect(() => {
|
|
3389
|
+
fetchSessionSync();
|
|
3390
|
+
const { unsubscribe } = customerAuth.onAuthStateChange(() => {
|
|
3391
|
+
fetchSessionSync();
|
|
3392
|
+
});
|
|
3393
|
+
return () => unsubscribe();
|
|
3394
|
+
}, []);
|
|
3395
|
+
return {
|
|
3396
|
+
data,
|
|
3397
|
+
isPending,
|
|
3398
|
+
error,
|
|
3399
|
+
refetch: fetchSessionAsync
|
|
3400
|
+
};
|
|
3216
3401
|
}
|
|
3217
3402
|
};
|
|
3218
3403
|
this.customer = {
|
|
@@ -3248,10 +3433,25 @@ var ScrymeClientSDK = class {
|
|
|
3248
3433
|
...customerAuth,
|
|
3249
3434
|
authenticate: async () => {
|
|
3250
3435
|
return performExchange();
|
|
3436
|
+
},
|
|
3437
|
+
get session() {
|
|
3438
|
+
return customerAuth.session;
|
|
3439
|
+
},
|
|
3440
|
+
useSession() {
|
|
3441
|
+
return customerAuth.useSession();
|
|
3251
3442
|
}
|
|
3252
3443
|
};
|
|
3253
3444
|
this.bookings = {
|
|
3254
3445
|
create: async (dto) => {
|
|
3446
|
+
if (!dto.customerId) {
|
|
3447
|
+
const session = await this.auth.getSession();
|
|
3448
|
+
const user = session?.user;
|
|
3449
|
+
const customerId = user?.customerId || user?.id || user?.customer?.id;
|
|
3450
|
+
if (!customerId) {
|
|
3451
|
+
throw new Error("Unauthorized: customerId is required.");
|
|
3452
|
+
}
|
|
3453
|
+
dto = { ...dto, customerId };
|
|
3454
|
+
}
|
|
3255
3455
|
return this.catalog.createBooking(dto);
|
|
3256
3456
|
},
|
|
3257
3457
|
get: async (id) => {
|
|
@@ -3639,7 +3839,18 @@ var ScrymeServerSDK = class {
|
|
|
3639
3839
|
},
|
|
3640
3840
|
auth: {
|
|
3641
3841
|
signUp: async (dto) => {
|
|
3642
|
-
|
|
3842
|
+
const res = await this.api.customersRegister(config.orgSlug, dto);
|
|
3843
|
+
if (dto.password) {
|
|
3844
|
+
try {
|
|
3845
|
+
await this.customer.auth.signIn({
|
|
3846
|
+
email: dto.email,
|
|
3847
|
+
password: dto.password
|
|
3848
|
+
});
|
|
3849
|
+
} catch (e) {
|
|
3850
|
+
console.error("Auto sign-in after sign-up failed on server SDK:", e);
|
|
3851
|
+
}
|
|
3852
|
+
}
|
|
3853
|
+
return res;
|
|
3643
3854
|
},
|
|
3644
3855
|
signIn: async (credentials) => {
|
|
3645
3856
|
const response = await this.axiosInstance.post(
|