@viu/emporix-sdk-react 2.0.0 → 2.2.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/CHANGELOG.md +27 -0
- package/README.md +3 -0
- package/dist/{chunk-N3VDSKCT.js → chunk-P6QTUYBT.js} +121 -6
- package/dist/chunk-P6QTUYBT.js.map +1 -0
- package/dist/hooks.cjs +123 -3
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +55 -2
- package/dist/hooks.d.ts +55 -2
- package/dist/hooks.js +1 -1
- package/dist/index.cjs +123 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +3 -3
- package/dist/chunk-N3VDSKCT.js.map +0 -1
package/dist/hooks.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Customer, AuthContext, Product, PaginatedItems, Category, CategoryNode, Cart, CartItemInput, CartItemUpdate, CartAddress, CartCreated, CreateCartInput, CheckoutResult, CheckoutInput, QuoteCheckoutInput, PaymentMode, PriceMatchByContextInput, PriceMatch, Media, SegmentCategoryTree, SegmentItem, Segment, PasswordChangeInput, CustomerUpdateInput, Address, AddressCreateInput, AddressUpdateInput, PasswordResetRequestInput, PasswordResetConfirmInput, Site, LegalEntity, ContactAssignment, Location, IamGroup, ContactAssignmentCreate, LegalEntityCreate, LocationCreate, LegalEntityUpdate, ContactAssignmentUpdate, LocationUpdate, OrderStatus, Order, SalesOrderPatch } from '@viu/emporix-sdk';
|
|
1
|
+
import { Customer, AuthContext, Product, PaginatedItems, Category, CategoryNode, Cart, CartItemInput, CartItemUpdate, CartAddress, CartCreated, CreateCartInput, CheckoutResult, CheckoutInput, QuoteCheckoutInput, PaymentMode, PriceMatchByContextInput, PriceMatch, Media, SegmentCategoryTree, SegmentItem, Segment, PasswordChangeInput, CustomerUpdateInput, Address, AddressCreateInput, AddressUpdateInput, PasswordResetRequestInput, PasswordResetConfirmInput, Site, LegalEntity, ContactAssignment, Location, IamGroup, ContactAssignmentCreate, LegalEntityCreate, LocationCreate, LegalEntityUpdate, ContactAssignmentUpdate, LocationUpdate, OrderStatus, Order, SalesOrderPatch, Availability } from '@viu/emporix-sdk';
|
|
2
2
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
3
3
|
import { UseQueryResult, UseInfiniteQueryResult, UseMutationResult } from '@tanstack/react-query';
|
|
4
4
|
import { S as SiteContextValue } from './provider-BhvQWnnh.cjs';
|
|
@@ -73,6 +73,23 @@ declare function useProductSearch(query: string | undefined, params?: {
|
|
|
73
73
|
pageNumber?: number;
|
|
74
74
|
pageSize?: number;
|
|
75
75
|
}, options?: QueryOpts): UseQueryResult<PaginatedItems<Product>>;
|
|
76
|
+
/**
|
|
77
|
+
* Bulk-fetches products by `code`. Order is not guaranteed — re-index by
|
|
78
|
+
* `code` if needed. Disabled when `codes` is empty.
|
|
79
|
+
*/
|
|
80
|
+
declare function useProductsByCodes(codes: string[], options?: {
|
|
81
|
+
chunkSize?: number;
|
|
82
|
+
} & QueryOpts): UseQueryResult<Product[]>;
|
|
83
|
+
|
|
84
|
+
type UseVariantChildrenOptions = QueryOpts & {
|
|
85
|
+
pageSize?: number;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Resolves the VARIANT children of a PARENT_VARIANT product via
|
|
89
|
+
* `products.listVariantChildren`. The cache key contains `parentVariantId`.
|
|
90
|
+
* Disabled until `parentVariantId` is a non-empty string.
|
|
91
|
+
*/
|
|
92
|
+
declare function useVariantChildren(parentVariantId: string | undefined, options?: UseVariantChildrenOptions): UseQueryResult<Product[]>;
|
|
76
93
|
|
|
77
94
|
/** Fetches one category. */
|
|
78
95
|
declare function useCategory(categoryId: string, options?: QueryOpts): UseQueryResult<Category>;
|
|
@@ -202,6 +219,18 @@ declare function useMatchPrices(input: PriceMatchByContextInput, options?: {
|
|
|
202
219
|
customerToken?: string | null;
|
|
203
220
|
}): UseQueryResult<PriceMatch[]>;
|
|
204
221
|
|
|
222
|
+
/**
|
|
223
|
+
* Like {@link useMatchPrices} but chunks large `items` arrays via
|
|
224
|
+
* `prices.matchByContextChunked` (default 50 items per request, 4 in flight).
|
|
225
|
+
* Result order is not guaranteed — match by `priceId` / `itemRef.id`.
|
|
226
|
+
*/
|
|
227
|
+
declare function useMatchPricesChunked(input: PriceMatchByContextInput, options?: {
|
|
228
|
+
enabled?: boolean;
|
|
229
|
+
customerToken?: string | null;
|
|
230
|
+
chunkSize?: number;
|
|
231
|
+
concurrency?: number;
|
|
232
|
+
}): UseQueryResult<PriceMatch[]>;
|
|
233
|
+
|
|
205
234
|
/**
|
|
206
235
|
* Reads `productMedia` from the existing product query — no Media-Service
|
|
207
236
|
* call (those need a server-only scope). For admin/server flows, use
|
|
@@ -526,4 +555,28 @@ interface UseUpdateSalesOrderVars {
|
|
|
526
555
|
*/
|
|
527
556
|
declare function useUpdateSalesOrder(): UseMutationResult<Order, unknown, UseUpdateSalesOrderVars>;
|
|
528
557
|
|
|
529
|
-
|
|
558
|
+
interface UseAvailabilityOptions {
|
|
559
|
+
enabled?: boolean;
|
|
560
|
+
customerToken?: string | null;
|
|
561
|
+
defaultAvailableOnNotFound?: boolean;
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* Reads availability for one product on one site via `availability.get`.
|
|
565
|
+
* Defaults to the anonymous token; pass `customerToken` for a customer context.
|
|
566
|
+
*/
|
|
567
|
+
declare function useAvailability(productId: string, siteCode: string, options?: UseAvailabilityOptions): UseQueryResult<Availability>;
|
|
568
|
+
|
|
569
|
+
interface UseAvailabilitiesOptions {
|
|
570
|
+
enabled?: boolean;
|
|
571
|
+
customerToken?: string | null;
|
|
572
|
+
defaultAvailableOnNotFound?: boolean;
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* Reads availability for many products on one site via `availability.getMany`
|
|
576
|
+
* (a single batch request). Returns records in input order; missing products
|
|
577
|
+
* are `{ available: false }` (or `{ available: true }` with
|
|
578
|
+
* `defaultAvailableOnNotFound`).
|
|
579
|
+
*/
|
|
580
|
+
declare function useAvailabilities(productIds: string[], siteCode: string, options?: UseAvailabilitiesOptions): UseQueryResult<Availability[]>;
|
|
581
|
+
|
|
582
|
+
export { type AddressMutationsApi, type CartMutationsApi, type CheckoutApi, type CompanySwitcherApi, type CustomerSessionApi, type PasswordResetApi, type UseAvailabilitiesOptions, type UseAvailabilityOptions, type UseCancelOrderVars, type UseMyOrdersInfiniteOptions, type UseMyOrdersOptions, type UseOrderOptions, type UseOrderTransitionVars, type UseReorderResult, type UseReorderVars, type UseUpdateSalesOrderVars, type UseVariantChildrenOptions, useActiveCart, useAddressMutations, useAssignContact, useAvailabilities, useAvailability, useCancelOrder, useCart, useCartMutations, useCategories, useCategoriesInfinite, useCategory, useCategoryTree, useChangePassword, useCheckout, useCompany, useCompanyContacts, useCompanyGroups, useCompanyLocations, useCompanySwitcher, useCreateCart, useCreateCompany, useCreateLocation, useCustomerAddresses, useCustomerSession, useDefaultSite, useDeleteCompany, useDeleteLocation, useMatchPrices, useMatchPricesChunked, useMyCompanies, useMyOrders, useMyOrdersInfinite, useMySegmentCategories, useMySegmentCategoriesInfinite, useMySegmentCategoryTree, useMySegmentItems, useMySegmentProducts, useMySegmentProductsInfinite, useMySegments, useOrder, useOrderTransition, usePasswordReset, usePaymentModes, useProduct, useProductByCode, useProductMedia, useProductSearch, useProducts, useProductsByCodes, useProductsInCategory, useProductsInCategoryInfinite, useProductsInfinite, useReorder, useSalesOrder, useSiteContext, useSites, useUnassignContact, useUpdateCompany, useUpdateContactAssignment, useUpdateCustomer, useUpdateLocation, useUpdateSalesOrder, useVariantChildren };
|
package/dist/hooks.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Customer, AuthContext, Product, PaginatedItems, Category, CategoryNode, Cart, CartItemInput, CartItemUpdate, CartAddress, CartCreated, CreateCartInput, CheckoutResult, CheckoutInput, QuoteCheckoutInput, PaymentMode, PriceMatchByContextInput, PriceMatch, Media, SegmentCategoryTree, SegmentItem, Segment, PasswordChangeInput, CustomerUpdateInput, Address, AddressCreateInput, AddressUpdateInput, PasswordResetRequestInput, PasswordResetConfirmInput, Site, LegalEntity, ContactAssignment, Location, IamGroup, ContactAssignmentCreate, LegalEntityCreate, LocationCreate, LegalEntityUpdate, ContactAssignmentUpdate, LocationUpdate, OrderStatus, Order, SalesOrderPatch } from '@viu/emporix-sdk';
|
|
1
|
+
import { Customer, AuthContext, Product, PaginatedItems, Category, CategoryNode, Cart, CartItemInput, CartItemUpdate, CartAddress, CartCreated, CreateCartInput, CheckoutResult, CheckoutInput, QuoteCheckoutInput, PaymentMode, PriceMatchByContextInput, PriceMatch, Media, SegmentCategoryTree, SegmentItem, Segment, PasswordChangeInput, CustomerUpdateInput, Address, AddressCreateInput, AddressUpdateInput, PasswordResetRequestInput, PasswordResetConfirmInput, Site, LegalEntity, ContactAssignment, Location, IamGroup, ContactAssignmentCreate, LegalEntityCreate, LocationCreate, LegalEntityUpdate, ContactAssignmentUpdate, LocationUpdate, OrderStatus, Order, SalesOrderPatch, Availability } from '@viu/emporix-sdk';
|
|
2
2
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
3
3
|
import { UseQueryResult, UseInfiniteQueryResult, UseMutationResult } from '@tanstack/react-query';
|
|
4
4
|
import { S as SiteContextValue } from './provider-fvcYdqqX.js';
|
|
@@ -73,6 +73,23 @@ declare function useProductSearch(query: string | undefined, params?: {
|
|
|
73
73
|
pageNumber?: number;
|
|
74
74
|
pageSize?: number;
|
|
75
75
|
}, options?: QueryOpts): UseQueryResult<PaginatedItems<Product>>;
|
|
76
|
+
/**
|
|
77
|
+
* Bulk-fetches products by `code`. Order is not guaranteed — re-index by
|
|
78
|
+
* `code` if needed. Disabled when `codes` is empty.
|
|
79
|
+
*/
|
|
80
|
+
declare function useProductsByCodes(codes: string[], options?: {
|
|
81
|
+
chunkSize?: number;
|
|
82
|
+
} & QueryOpts): UseQueryResult<Product[]>;
|
|
83
|
+
|
|
84
|
+
type UseVariantChildrenOptions = QueryOpts & {
|
|
85
|
+
pageSize?: number;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Resolves the VARIANT children of a PARENT_VARIANT product via
|
|
89
|
+
* `products.listVariantChildren`. The cache key contains `parentVariantId`.
|
|
90
|
+
* Disabled until `parentVariantId` is a non-empty string.
|
|
91
|
+
*/
|
|
92
|
+
declare function useVariantChildren(parentVariantId: string | undefined, options?: UseVariantChildrenOptions): UseQueryResult<Product[]>;
|
|
76
93
|
|
|
77
94
|
/** Fetches one category. */
|
|
78
95
|
declare function useCategory(categoryId: string, options?: QueryOpts): UseQueryResult<Category>;
|
|
@@ -202,6 +219,18 @@ declare function useMatchPrices(input: PriceMatchByContextInput, options?: {
|
|
|
202
219
|
customerToken?: string | null;
|
|
203
220
|
}): UseQueryResult<PriceMatch[]>;
|
|
204
221
|
|
|
222
|
+
/**
|
|
223
|
+
* Like {@link useMatchPrices} but chunks large `items` arrays via
|
|
224
|
+
* `prices.matchByContextChunked` (default 50 items per request, 4 in flight).
|
|
225
|
+
* Result order is not guaranteed — match by `priceId` / `itemRef.id`.
|
|
226
|
+
*/
|
|
227
|
+
declare function useMatchPricesChunked(input: PriceMatchByContextInput, options?: {
|
|
228
|
+
enabled?: boolean;
|
|
229
|
+
customerToken?: string | null;
|
|
230
|
+
chunkSize?: number;
|
|
231
|
+
concurrency?: number;
|
|
232
|
+
}): UseQueryResult<PriceMatch[]>;
|
|
233
|
+
|
|
205
234
|
/**
|
|
206
235
|
* Reads `productMedia` from the existing product query — no Media-Service
|
|
207
236
|
* call (those need a server-only scope). For admin/server flows, use
|
|
@@ -526,4 +555,28 @@ interface UseUpdateSalesOrderVars {
|
|
|
526
555
|
*/
|
|
527
556
|
declare function useUpdateSalesOrder(): UseMutationResult<Order, unknown, UseUpdateSalesOrderVars>;
|
|
528
557
|
|
|
529
|
-
|
|
558
|
+
interface UseAvailabilityOptions {
|
|
559
|
+
enabled?: boolean;
|
|
560
|
+
customerToken?: string | null;
|
|
561
|
+
defaultAvailableOnNotFound?: boolean;
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* Reads availability for one product on one site via `availability.get`.
|
|
565
|
+
* Defaults to the anonymous token; pass `customerToken` for a customer context.
|
|
566
|
+
*/
|
|
567
|
+
declare function useAvailability(productId: string, siteCode: string, options?: UseAvailabilityOptions): UseQueryResult<Availability>;
|
|
568
|
+
|
|
569
|
+
interface UseAvailabilitiesOptions {
|
|
570
|
+
enabled?: boolean;
|
|
571
|
+
customerToken?: string | null;
|
|
572
|
+
defaultAvailableOnNotFound?: boolean;
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* Reads availability for many products on one site via `availability.getMany`
|
|
576
|
+
* (a single batch request). Returns records in input order; missing products
|
|
577
|
+
* are `{ available: false }` (or `{ available: true }` with
|
|
578
|
+
* `defaultAvailableOnNotFound`).
|
|
579
|
+
*/
|
|
580
|
+
declare function useAvailabilities(productIds: string[], siteCode: string, options?: UseAvailabilitiesOptions): UseQueryResult<Availability[]>;
|
|
581
|
+
|
|
582
|
+
export { type AddressMutationsApi, type CartMutationsApi, type CheckoutApi, type CompanySwitcherApi, type CustomerSessionApi, type PasswordResetApi, type UseAvailabilitiesOptions, type UseAvailabilityOptions, type UseCancelOrderVars, type UseMyOrdersInfiniteOptions, type UseMyOrdersOptions, type UseOrderOptions, type UseOrderTransitionVars, type UseReorderResult, type UseReorderVars, type UseUpdateSalesOrderVars, type UseVariantChildrenOptions, useActiveCart, useAddressMutations, useAssignContact, useAvailabilities, useAvailability, useCancelOrder, useCart, useCartMutations, useCategories, useCategoriesInfinite, useCategory, useCategoryTree, useChangePassword, useCheckout, useCompany, useCompanyContacts, useCompanyGroups, useCompanyLocations, useCompanySwitcher, useCreateCart, useCreateCompany, useCreateLocation, useCustomerAddresses, useCustomerSession, useDefaultSite, useDeleteCompany, useDeleteLocation, useMatchPrices, useMatchPricesChunked, useMyCompanies, useMyOrders, useMyOrdersInfinite, useMySegmentCategories, useMySegmentCategoriesInfinite, useMySegmentCategoryTree, useMySegmentItems, useMySegmentProducts, useMySegmentProductsInfinite, useMySegments, useOrder, useOrderTransition, usePasswordReset, usePaymentModes, useProduct, useProductByCode, useProductMedia, useProductSearch, useProducts, useProductsByCodes, useProductsInCategory, useProductsInCategoryInfinite, useProductsInfinite, useReorder, useSalesOrder, useSiteContext, useSites, useUnassignContact, useUpdateCompany, useUpdateContactAssignment, useUpdateCustomer, useUpdateLocation, useUpdateSalesOrder, useVariantChildren };
|
package/dist/hooks.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { useActiveCart, useAddressMutations, useAssignContact, useCancelOrder, useCart, useCartMutations, useCategories, useCategoriesInfinite, useCategory, useCategoryTree, useChangePassword, useCheckout, useCompany, useCompanyContacts, useCompanyGroups, useCompanyLocations, useCompanySwitcher, useCreateCart, useCreateCompany, useCreateLocation, useCustomerAddresses, useCustomerSession, useDefaultSite, useDeleteCompany, useDeleteLocation, useMatchPrices, useMyCompanies, useMyOrders, useMyOrdersInfinite, useMySegmentCategories, useMySegmentCategoriesInfinite, useMySegmentCategoryTree, useMySegmentItems, useMySegmentProducts, useMySegmentProductsInfinite, useMySegments, useOrder, useOrderTransition, usePasswordReset, usePaymentModes, useProduct, useProductByCode, useProductMedia, useProductSearch, useProducts, useProductsInCategory, useProductsInCategoryInfinite, useProductsInfinite, useReorder, useSalesOrder, useSiteContext, useSites, useUnassignContact, useUpdateCompany, useUpdateContactAssignment, useUpdateCustomer, useUpdateLocation, useUpdateSalesOrder } from './chunk-
|
|
1
|
+
export { useActiveCart, useAddressMutations, useAssignContact, useAvailabilities, useAvailability, useCancelOrder, useCart, useCartMutations, useCategories, useCategoriesInfinite, useCategory, useCategoryTree, useChangePassword, useCheckout, useCompany, useCompanyContacts, useCompanyGroups, useCompanyLocations, useCompanySwitcher, useCreateCart, useCreateCompany, useCreateLocation, useCustomerAddresses, useCustomerSession, useDefaultSite, useDeleteCompany, useDeleteLocation, useMatchPrices, useMatchPricesChunked, useMyCompanies, useMyOrders, useMyOrdersInfinite, useMySegmentCategories, useMySegmentCategoriesInfinite, useMySegmentCategoryTree, useMySegmentItems, useMySegmentProducts, useMySegmentProductsInfinite, useMySegments, useOrder, useOrderTransition, usePasswordReset, usePaymentModes, useProduct, useProductByCode, useProductMedia, useProductSearch, useProducts, useProductsByCodes, useProductsInCategory, useProductsInCategoryInfinite, useProductsInfinite, useReorder, useSalesOrder, useSiteContext, useSites, useUnassignContact, useUpdateCompany, useUpdateContactAssignment, useUpdateCustomer, useUpdateLocation, useUpdateSalesOrder, useVariantChildren } from './chunk-P6QTUYBT.js';
|
|
2
2
|
import './chunk-D43CSHK3.js';
|
|
3
3
|
import './chunk-FBQY2N7S.js';
|
|
4
4
|
//# sourceMappingURL=hooks.js.map
|
package/dist/index.cjs
CHANGED
|
@@ -931,6 +931,45 @@ function useProductSearch(query, params = {}, options = {}) {
|
|
|
931
931
|
staleTime: PRODUCTS_STALE_TIME
|
|
932
932
|
});
|
|
933
933
|
}
|
|
934
|
+
function useProductsByCodes(codes, options = {}) {
|
|
935
|
+
const { client } = useEmporix();
|
|
936
|
+
const { ctx } = useReadAuth(options.auth);
|
|
937
|
+
const { siteCode } = useReadSite();
|
|
938
|
+
return reactQuery.useQuery({
|
|
939
|
+
queryKey: emporixKey("products-by-codes", [codes, options.chunkSize], {
|
|
940
|
+
tenant: client.tenant,
|
|
941
|
+
authKind: ctx.kind,
|
|
942
|
+
siteCode
|
|
943
|
+
}),
|
|
944
|
+
enabled: codes.length > 0,
|
|
945
|
+
queryFn: () => client.products.searchByCodes(
|
|
946
|
+
codes,
|
|
947
|
+
options.chunkSize !== void 0 ? { chunkSize: options.chunkSize } : {},
|
|
948
|
+
ctx
|
|
949
|
+
),
|
|
950
|
+
staleTime: 3e4
|
|
951
|
+
});
|
|
952
|
+
}
|
|
953
|
+
var VARIANT_CHILDREN_STALE_TIME = 6e4;
|
|
954
|
+
function useVariantChildren(parentVariantId, options = {}) {
|
|
955
|
+
const { client } = useEmporix();
|
|
956
|
+
const { ctx } = useReadAuth(options.auth);
|
|
957
|
+
const { siteCode } = useReadSite();
|
|
958
|
+
return reactQuery.useQuery({
|
|
959
|
+
queryKey: emporixKey(
|
|
960
|
+
"variant-children",
|
|
961
|
+
[parentVariantId, { pageSize: options.pageSize }],
|
|
962
|
+
{ tenant: client.tenant, authKind: ctx.kind, siteCode }
|
|
963
|
+
),
|
|
964
|
+
enabled: typeof parentVariantId === "string" && parentVariantId !== "",
|
|
965
|
+
queryFn: () => client.products.listVariantChildren(
|
|
966
|
+
parentVariantId,
|
|
967
|
+
options.pageSize !== void 0 ? { pageSize: options.pageSize } : {},
|
|
968
|
+
ctx
|
|
969
|
+
),
|
|
970
|
+
staleTime: VARIANT_CHILDREN_STALE_TIME
|
|
971
|
+
});
|
|
972
|
+
}
|
|
934
973
|
var CATEGORIES_STALE_TIME = 5 * 6e4;
|
|
935
974
|
function useCategory(categoryId, options = {}) {
|
|
936
975
|
const { client } = useEmporix();
|
|
@@ -1195,6 +1234,36 @@ function useMatchPrices(input, options = {}) {
|
|
|
1195
1234
|
staleTime: PRICES_STALE_TIME
|
|
1196
1235
|
});
|
|
1197
1236
|
}
|
|
1237
|
+
var PRICES_STALE_TIME2 = 6e4;
|
|
1238
|
+
function useMatchPricesChunked(input, options = {}) {
|
|
1239
|
+
const { client } = useEmporix();
|
|
1240
|
+
const { siteCode } = useReadSite();
|
|
1241
|
+
const ctx = options.customerToken ? emporixSdk.auth.customer(options.customerToken) : emporixSdk.auth.anonymous();
|
|
1242
|
+
return reactQuery.useQuery({
|
|
1243
|
+
queryKey: [
|
|
1244
|
+
"emporix",
|
|
1245
|
+
"match-prices-chunked",
|
|
1246
|
+
{
|
|
1247
|
+
tenant: client.tenant,
|
|
1248
|
+
input,
|
|
1249
|
+
anon: !options.customerToken,
|
|
1250
|
+
siteCode,
|
|
1251
|
+
chunkSize: options.chunkSize,
|
|
1252
|
+
concurrency: options.concurrency
|
|
1253
|
+
}
|
|
1254
|
+
],
|
|
1255
|
+
enabled: (options.enabled ?? true) && (input.items?.length ?? 0) > 0,
|
|
1256
|
+
queryFn: () => client.prices.matchByContextChunked(
|
|
1257
|
+
input,
|
|
1258
|
+
{
|
|
1259
|
+
...options.chunkSize !== void 0 ? { chunkSize: options.chunkSize } : {},
|
|
1260
|
+
...options.concurrency !== void 0 ? { concurrency: options.concurrency } : {}
|
|
1261
|
+
},
|
|
1262
|
+
ctx
|
|
1263
|
+
),
|
|
1264
|
+
staleTime: PRICES_STALE_TIME2
|
|
1265
|
+
});
|
|
1266
|
+
}
|
|
1198
1267
|
|
|
1199
1268
|
// src/hooks/use-product-media.ts
|
|
1200
1269
|
function useProductMedia(productId) {
|
|
@@ -1719,12 +1788,12 @@ function useUpdateSalesOrder() {
|
|
|
1719
1788
|
const qc = reactQuery.useQueryClient();
|
|
1720
1789
|
return reactQuery.useMutation({
|
|
1721
1790
|
mutationKey: ["emporix", "salesorders", "update"],
|
|
1722
|
-
mutationFn: async ({ orderId, patch, auth:
|
|
1723
|
-
if (!
|
|
1791
|
+
mutationFn: async ({ orderId, patch, auth: auth26, recalculate }) => {
|
|
1792
|
+
if (!auth26) throw new Error("useUpdateSalesOrder: requires an auth context");
|
|
1724
1793
|
return client.salesOrders.update(
|
|
1725
1794
|
orderId,
|
|
1726
1795
|
patch,
|
|
1727
|
-
|
|
1796
|
+
auth26,
|
|
1728
1797
|
recalculate !== void 0 ? { recalculate } : {}
|
|
1729
1798
|
);
|
|
1730
1799
|
},
|
|
@@ -1735,6 +1804,52 @@ function useUpdateSalesOrder() {
|
|
|
1735
1804
|
}
|
|
1736
1805
|
});
|
|
1737
1806
|
}
|
|
1807
|
+
var AVAILABILITY_STALE_TIME = 3e4;
|
|
1808
|
+
function useAvailability(productId, siteCode, options = {}) {
|
|
1809
|
+
const { client } = useEmporix();
|
|
1810
|
+
const ctx = options.customerToken ? emporixSdk.auth.customer(options.customerToken) : emporixSdk.auth.anonymous();
|
|
1811
|
+
return reactQuery.useQuery({
|
|
1812
|
+
queryKey: [
|
|
1813
|
+
"emporix",
|
|
1814
|
+
"availability",
|
|
1815
|
+
{
|
|
1816
|
+
tenant: client.tenant,
|
|
1817
|
+
productId,
|
|
1818
|
+
siteCode,
|
|
1819
|
+
anon: !options.customerToken,
|
|
1820
|
+
defaultAvailableOnNotFound: options.defaultAvailableOnNotFound ?? false
|
|
1821
|
+
}
|
|
1822
|
+
],
|
|
1823
|
+
enabled: (options.enabled ?? true) && Boolean(productId) && Boolean(siteCode),
|
|
1824
|
+
queryFn: () => client.availability.get(productId, siteCode, ctx, {
|
|
1825
|
+
defaultAvailableOnNotFound: options.defaultAvailableOnNotFound ?? false
|
|
1826
|
+
}),
|
|
1827
|
+
staleTime: AVAILABILITY_STALE_TIME
|
|
1828
|
+
});
|
|
1829
|
+
}
|
|
1830
|
+
var AVAILABILITY_STALE_TIME2 = 3e4;
|
|
1831
|
+
function useAvailabilities(productIds, siteCode, options = {}) {
|
|
1832
|
+
const { client } = useEmporix();
|
|
1833
|
+
const ctx = options.customerToken ? emporixSdk.auth.customer(options.customerToken) : emporixSdk.auth.anonymous();
|
|
1834
|
+
return reactQuery.useQuery({
|
|
1835
|
+
queryKey: [
|
|
1836
|
+
"emporix",
|
|
1837
|
+
"availabilities",
|
|
1838
|
+
{
|
|
1839
|
+
tenant: client.tenant,
|
|
1840
|
+
productIds,
|
|
1841
|
+
siteCode,
|
|
1842
|
+
anon: !options.customerToken,
|
|
1843
|
+
defaultAvailableOnNotFound: options.defaultAvailableOnNotFound ?? false
|
|
1844
|
+
}
|
|
1845
|
+
],
|
|
1846
|
+
enabled: (options.enabled ?? true) && productIds.length > 0 && Boolean(siteCode),
|
|
1847
|
+
queryFn: () => client.availability.getMany(productIds, siteCode, ctx, {
|
|
1848
|
+
defaultAvailableOnNotFound: options.defaultAvailableOnNotFound ?? false
|
|
1849
|
+
}),
|
|
1850
|
+
staleTime: AVAILABILITY_STALE_TIME2
|
|
1851
|
+
});
|
|
1852
|
+
}
|
|
1738
1853
|
var EmporixErrorBoundary = class extends react.Component {
|
|
1739
1854
|
state = { error: null };
|
|
1740
1855
|
static getDerivedStateFromError(error) {
|
|
@@ -1787,6 +1902,8 @@ exports.useActiveCart = useActiveCart;
|
|
|
1787
1902
|
exports.useActiveCompany = useActiveCompany;
|
|
1788
1903
|
exports.useAddressMutations = useAddressMutations;
|
|
1789
1904
|
exports.useAssignContact = useAssignContact;
|
|
1905
|
+
exports.useAvailabilities = useAvailabilities;
|
|
1906
|
+
exports.useAvailability = useAvailability;
|
|
1790
1907
|
exports.useCancelOrder = useCancelOrder;
|
|
1791
1908
|
exports.useCart = useCart;
|
|
1792
1909
|
exports.useCartMutations = useCartMutations;
|
|
@@ -1813,6 +1930,7 @@ exports.useEmporix = useEmporix;
|
|
|
1813
1930
|
exports.useEmporixErrorHandler = useEmporixErrorHandler;
|
|
1814
1931
|
exports.useEmporixTelemetry = useEmporixTelemetry;
|
|
1815
1932
|
exports.useMatchPrices = useMatchPrices;
|
|
1933
|
+
exports.useMatchPricesChunked = useMatchPricesChunked;
|
|
1816
1934
|
exports.useMyCompanies = useMyCompanies;
|
|
1817
1935
|
exports.useMyOrders = useMyOrders;
|
|
1818
1936
|
exports.useMyOrdersInfinite = useMyOrdersInfinite;
|
|
@@ -1832,6 +1950,7 @@ exports.useProductByCode = useProductByCode;
|
|
|
1832
1950
|
exports.useProductMedia = useProductMedia;
|
|
1833
1951
|
exports.useProductSearch = useProductSearch;
|
|
1834
1952
|
exports.useProducts = useProducts;
|
|
1953
|
+
exports.useProductsByCodes = useProductsByCodes;
|
|
1835
1954
|
exports.useProductsInCategory = useProductsInCategory;
|
|
1836
1955
|
exports.useProductsInCategoryInfinite = useProductsInCategoryInfinite;
|
|
1837
1956
|
exports.useProductsInfinite = useProductsInfinite;
|
|
@@ -1845,5 +1964,6 @@ exports.useUpdateContactAssignment = useUpdateContactAssignment;
|
|
|
1845
1964
|
exports.useUpdateCustomer = useUpdateCustomer;
|
|
1846
1965
|
exports.useUpdateLocation = useUpdateLocation;
|
|
1847
1966
|
exports.useUpdateSalesOrder = useUpdateSalesOrder;
|
|
1967
|
+
exports.useVariantChildren = useVariantChildren;
|
|
1848
1968
|
//# sourceMappingURL=index.cjs.map
|
|
1849
1969
|
//# sourceMappingURL=index.cjs.map
|