@viu/emporix-sdk-react 2.3.0 → 2.5.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/dist/hooks.d.ts CHANGED
@@ -1,615 +1,25 @@
1
- import { Customer, AuthContext, Product, PaginatedItems, ShoppingListItem, ShoppingListDraft, ShoppingList, 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
- import * as _tanstack_react_query from '@tanstack/react-query';
3
- import { UseQueryResult, UseInfiniteQueryResult, UseMutationResult } from '@tanstack/react-query';
4
- import { S as SiteContextValue } from './provider-fvcYdqqX.js';
1
+ export { A as AddressMutationsApi, C as CartMutationsApi, a as CheckoutApi, b as CompanySwitcherApi, c as CouponActionVars, d as CustomerSessionApi, P as PasswordResetApi, U as UseAvailabilitiesOptions, e as UseAvailabilityOptions, f as UseCancelOrderVars, g as UseMyOrdersInfiniteOptions, h as UseMyOrdersOptions, i as UseOrderOptions, j as UseOrderTransitionVars, k as UseReorderResult, l as UseReorderVars, m as UseUpdateSalesOrderVars, n as UseVariantChildrenOptions, u as useActiveCart, o as useAddToShoppingList, p as useAddressMutations, q as useAssignContact, r as useAvailabilities, s as useAvailability, t as useCancelOrder, v as useCart, w as useCartMutations, x as useCategories, y as useCategoriesInfinite, z as useCategory, B as useCategoryTree, D as useChangePassword, E as useCheckout, F as useCompany, G as useCompanyContacts, H as useCompanyGroups, I as useCompanyLocations, J as useCompanySwitcher, K as useCreateCart, L as useCreateCompany, M as useCreateLocation, N as useCreateReturn, O as useCreateShoppingList, Q as useCustomerAddresses, R as useCustomerSession, S as useDefaultSite, T as useDeleteCompany, V as useDeleteLocation, W as useDeleteShoppingList, X as useMatchPrices, Y as useMatchPricesChunked, Z as useMyCompanies, _ as useMyOrders, $ as useMyOrdersInfinite, a0 as useMyReturns, a1 as useMyRewardPoints, a2 as useMyRewardPointsSummary, a3 as useMySegmentCategories, a4 as useMySegmentCategoriesInfinite, a5 as useMySegmentCategoryTree, a6 as useMySegmentItems, a7 as useMySegmentProducts, a8 as useMySegmentProductsInfinite, a9 as useMySegments, aa as useOrder, ab as useOrderTransition, ac as usePasswordReset, ad as usePaymentModes, ae as useProduct, af as useProductByCode, ag as useProductMedia, ah as useProductSearch, ai as useProducts, aj as useProductsByCodes, ak as useProductsInCategory, al as useProductsInCategoryInfinite, am as useProductsInfinite, an as useRedeemCoupon, ao as useRedeemOptions, ap as useRedeemRewardPoints, aq as useRemoveFromShoppingList, ar as useReorder, as as useReturn, at as useSalesOrder, au as useSetShoppingListItemQuantity, av as useShoppingLists, aw as useSiteContext, ax as useSites, ay as useUnassignContact, az as useUpdateCompany, aA as useUpdateContactAssignment, aB as useUpdateCustomer, aC as useUpdateLocation, aD as useUpdateSalesOrder, aE as useValidateCoupon, aF as useVariantChildren } from './use-returns-Dspo-4xb.js';
2
+ import { UseQueryResult, UseMutationResult } from '@tanstack/react-query';
3
+ import { ApprovalPatch, Approval, ApprovalList, ApprovalCreated, ApprovalInput } from '@viu/emporix-sdk';
4
+ import './provider-fvcYdqqX.js';
5
5
  import 'react';
6
6
  import './storage.js';
7
7
 
8
- /** Customer authentication state and actions. */
9
- interface CustomerSessionApi {
10
- customerToken: string | null;
11
- customer: Customer | null;
12
- isAuthenticated: boolean;
13
- isLoading: boolean;
14
- /** Current refresh token (in-session; set by `login`). */
15
- refreshToken: string | null;
16
- login: (input: {
17
- email: string;
18
- password: string;
19
- }) => Promise<void>;
20
- signup: (input: {
21
- email: string;
22
- password: string;
23
- }) => Promise<void>;
24
- /** Authorization-Code SSO: exchanges an IdP `code` for a customer session. */
25
- socialLogin: (input: {
26
- code: string;
27
- redirectUri: string;
28
- codeVerifier?: string;
29
- sessionId?: string;
30
- }) => Promise<void>;
31
- /** RFC 8693 token exchange: exchanges an external IdP JWT for a session. */
32
- exchangeToken: (input: {
33
- subjectToken: string;
34
- config?: string;
35
- }) => Promise<void>;
36
- /** Server-side logout (best-effort), then clears the local session. */
37
- logout: () => Promise<void>;
38
- /** Refetches the `me` profile query. */
39
- refresh: () => Promise<void>;
40
- /**
41
- * Exchanges the stored refresh token for a fresh customer token (same
42
- * sessionId) and updates the stored token. No-op if there is no refresh
43
- * token. Throws if the refresh itself fails.
44
- */
45
- refreshSession: () => Promise<void>;
46
- }
47
- /** Manages the customer session: login/signup/logout and the `me` query. */
48
- declare function useCustomerSession(): CustomerSessionApi;
49
-
50
- /** Options accepted by every read hook to override the per-call auth context. */
51
- interface QueryOpts {
52
- auth?: AuthContext;
53
- }
54
-
55
- /** Fetches one product. Default auth: customer if logged in, else anonymous. */
56
- declare function useProduct(productId: string, options?: QueryOpts): UseQueryResult<Product>;
57
- /** Fetches one page of products. */
58
- declare function useProducts(params?: {
59
- pageNumber?: number;
60
- pageSize?: number;
61
- }, options?: QueryOpts): UseQueryResult<PaginatedItems<Product>>;
62
- /** Infinite product list — terminates on `hasNextPage=false`. */
63
- declare function useProductsInfinite(params?: {
64
- pageSize?: number;
65
- }, options?: QueryOpts): UseInfiniteQueryResult<{
66
- pages: PaginatedItems<Product>[];
67
- pageParams: number[];
68
- }>;
69
- /** Fetches one product by its `code` (URL slug). Disabled when code is empty. */
70
- declare function useProductByCode(code: string | undefined, options?: QueryOpts): UseQueryResult<Product>;
71
- /** Full-text product search. Disabled when query is empty/whitespace. */
72
- declare function useProductSearch(query: string | undefined, params?: {
73
- pageNumber?: number;
74
- pageSize?: number;
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
- /** The caller's shopping lists (customer-only). Optionally filtered by name. */
85
- declare function useShoppingLists(opts?: {
86
- name?: string;
87
- }): UseQueryResult<ShoppingList[]>;
88
- /** Create a shopping list. */
89
- declare function useCreateShoppingList(): UseMutationResult<{
90
- id: string;
91
- }, unknown, ShoppingListDraft>;
92
- /** Delete a named list (or all the customer's lists when `name` is omitted). */
93
- declare function useDeleteShoppingList(): UseMutationResult<void, unknown, {
94
- customerId: string;
95
- name?: string;
96
- }>;
97
- /** Add/replace an item in a list. */
98
- declare function useAddToShoppingList(): UseMutationResult<void, unknown, {
99
- customerId: string;
100
- listName: string;
101
- item: ShoppingListItem;
102
- }>;
103
- /** Remove an item from a list by productId. */
104
- declare function useRemoveFromShoppingList(): UseMutationResult<void, unknown, {
105
- customerId: string;
106
- listName: string;
107
- productId: string;
108
- }>;
109
- /** Set an item's quantity (0 removes it). */
110
- declare function useSetShoppingListItemQuantity(): UseMutationResult<void, unknown, {
111
- customerId: string;
112
- listName: string;
113
- productId: string;
114
- quantity: number;
115
- }>;
116
-
117
- type UseVariantChildrenOptions = QueryOpts & {
118
- pageSize?: number;
119
- };
120
- /**
121
- * Resolves the VARIANT children of a PARENT_VARIANT product via
122
- * `products.listVariantChildren`. The cache key contains `parentVariantId`.
123
- * Disabled until `parentVariantId` is a non-empty string.
124
- */
125
- declare function useVariantChildren(parentVariantId: string | undefined, options?: UseVariantChildrenOptions): UseQueryResult<Product[]>;
126
-
127
- /** Fetches one category. */
128
- declare function useCategory(categoryId: string, options?: QueryOpts): UseQueryResult<Category>;
129
- /** Fetches one page of categories. */
130
- declare function useCategories(params?: {
131
- pageNumber?: number;
132
- pageSize?: number;
133
- }, options?: QueryOpts): UseQueryResult<PaginatedItems<Category>>;
134
- /** Infinite category list — terminates on `hasNextPage=false`. */
135
- declare function useCategoriesInfinite(params?: {
136
- pageSize?: number;
137
- }, options?: QueryOpts): UseInfiniteQueryResult<{
138
- pages: PaginatedItems<Category>[];
139
- pageParams: number[];
140
- }>;
141
- /** Fetches the category tree. */
142
- declare function useCategoryTree(rootId?: string, options?: QueryOpts): UseQueryResult<CategoryNode>;
143
- /** One page of products in a category. Disabled when categoryId is empty. */
144
- declare function useProductsInCategory(categoryId: string | undefined, params?: {
145
- pageNumber?: number;
146
- pageSize?: number;
147
- }, options?: QueryOpts): UseQueryResult<PaginatedItems<Product>>;
148
- /** Infinite-scroll product list for a category. Terminates on `hasNextPage=false`. */
149
- declare function useProductsInCategoryInfinite(categoryId: string | undefined, params?: {
150
- pageSize?: number;
151
- }, options?: QueryOpts): UseInfiniteQueryResult<{
152
- pages: PaginatedItems<Product>[];
153
- pageParams: number[];
154
- }>;
155
-
156
- /** Fetches a cart by id. Falls back to `storage.getCartId()` when no argument is passed; disabled when neither is set. */
157
- declare function useCart(cartId?: string, options?: QueryOpts): UseQueryResult<Cart>;
158
- type Mut<TVars> = UseMutationResult<Cart, unknown, TVars, {
159
- previous: Cart | undefined;
160
- }>;
161
- /** Cart write operations with optimistic cache updates and rollback. */
162
- interface CartMutationsApi {
163
- addItem: Mut<CartItemInput>;
164
- updateItem: Mut<{
165
- itemId: string;
166
- patch: CartItemUpdate;
167
- }>;
168
- removeItem: Mut<{
169
- itemId: string;
170
- }>;
171
- clear: Mut<void>;
172
- applyCoupon: Mut<{
173
- code: string;
174
- }>;
175
- removeCoupon: Mut<{
176
- code: string;
177
- }>;
178
- setShippingAddress: Mut<CartAddress>;
179
- setBillingAddress: Mut<CartAddress>;
180
- }
181
- /**
182
- * Cart write operations with optimistic cache updates and rollback.
183
- *
184
- * `cartId` is optional — when omitted, `storage.getCartId()` is resolved at
185
- * **mutate-time** (inside `mutationFn`/`onMutate`), so post-mount writes from
186
- * `useActiveCart({ create: true })` work without a render race. Throws
187
- * `EmporixError("useCartMutations: no cartId available — …")` when storage
188
- * is still empty at mutate-time.
189
- */
190
- declare function useCartMutations(cartId?: string): CartMutationsApi;
191
- /**
192
- * Creates a cart. Auto-detects auth (customer if a token is stored, else
193
- * anonymous). On success, persists `cartId` via `storage.setCartId` so a later
194
- * page reload can resume the same cart with the same anonymous session, then
195
- * invalidates `["emporix","cart"]` so `useActiveCart` re-reads storage on the
196
- * next render.
197
- *
198
- * Note: the SDK's `carts.create` returns `CartCreated = { cartId, yrn }`, not
199
- * the full `Cart`. The full cart is loaded on demand by `useCart(cartId)` /
200
- * `useActiveCart()`.
201
- */
202
- declare function useCreateCart(): UseMutationResult<CartCreated, unknown, CreateCartInput | undefined>;
203
- /**
204
- * Resolves to "the active cart": the cart matching `storage.cartId` if one is
205
- * present. With `create: true`, bootstraps a new cart via
206
- * `client.carts.getCurrent({siteCode, create: true})` when storage is empty —
207
- * useful on cart-page mounts where you want a cart unconditionally.
208
- *
209
- * Internally delegates to `useCart` so both hooks share the canonical
210
- * `["emporix","cart", id, …]` cache entry — optimistic updates from
211
- * `useCartMutations` propagate automatically.
212
- *
213
- * Returns `UseQueryResult<Cart | null>`. `data: null` means "no cart yet and
214
- * create was not requested" — a deliberate signal so an empty-state can
215
- * render without confusing it with the loading state.
216
- */
217
- declare function useActiveCart(opts?: {
218
- create?: boolean;
219
- type?: string;
220
- legalEntityId?: string;
221
- auth?: AuthContext;
222
- }): UseQueryResult<Cart | null>;
223
-
224
- /** Checkout actions bound to the stored customer session. */
225
- interface CheckoutApi {
226
- placeOrder: UseMutationResult<CheckoutResult, unknown, {
227
- input: CheckoutInput;
228
- saasToken?: string;
229
- siteCode?: string;
230
- }>;
231
- placeOrderFromQuote: UseMutationResult<CheckoutResult, unknown, {
232
- input: QuoteCheckoutInput;
233
- saasToken?: string;
234
- siteCode?: string;
235
- }>;
236
- }
237
- /** React bindings for the checkout flow. */
238
- declare function useCheckout(): CheckoutApi;
239
- /** Lists frontend payment modes for the logged-in customer. */
240
- declare function usePaymentModes(options?: {
241
- enabled?: boolean;
242
- }): UseQueryResult<PaymentMode[]>;
243
-
244
- /**
245
- * Resolves prices for `input.items` via `prices.matchByContext`. Defaults to
246
- * the anonymous session token (context bound at anonymous-login); pass a
247
- * customer token for personalized pricing. The SDK does not cache prices —
248
- * control freshness via the query key / `enabled` (re-run before checkout).
249
- */
250
- declare function useMatchPrices(input: PriceMatchByContextInput, options?: {
251
- enabled?: boolean;
252
- customerToken?: string | null;
253
- }): UseQueryResult<PriceMatch[]>;
254
-
255
- /**
256
- * Like {@link useMatchPrices} but chunks large `items` arrays via
257
- * `prices.matchByContextChunked` (default 50 items per request, 4 in flight).
258
- * Result order is not guaranteed — match by `priceId` / `itemRef.id`.
259
- */
260
- declare function useMatchPricesChunked(input: PriceMatchByContextInput, options?: {
261
- enabled?: boolean;
262
- customerToken?: string | null;
263
- chunkSize?: number;
264
- concurrency?: number;
265
- }): UseQueryResult<PriceMatch[]>;
266
-
267
- /**
268
- * Reads `productMedia` from the existing product query — no Media-Service
269
- * call (those need a server-only scope). For admin/server flows, use
270
- * `client.media.listForProduct(productId)` instead.
271
- */
272
- declare function useProductMedia(productId: string): {
273
- data: Media[] | undefined;
274
- isLoading: boolean;
275
- error: unknown;
276
- };
277
-
278
- /** Segments the logged-in customer belongs to (`segment_read_own`). */
279
- declare function useMySegments(query?: {
280
- q?: string;
281
- pageNumber?: number;
282
- pageSize?: number;
283
- }): UseQueryResult<Segment[]>;
284
- /** Item assignments (PRODUCT + CATEGORY) across the caller's active segments. */
285
- declare function useMySegmentItems(query?: {
286
- q?: string;
287
- siteCode?: string;
288
- legalEntityId?: string;
289
- onlyActive?: boolean;
290
- }): UseQueryResult<SegmentItem[]>;
291
- /** Category tree filtered to the caller's segments. */
292
- declare function useMySegmentCategoryTree(query?: {
293
- siteCode?: string;
294
- legalEntityId?: string;
295
- }): UseQueryResult<SegmentCategoryTree>;
296
- /** Hydrated PRODUCT page for the caller's segments (single-page). */
297
- declare function useMySegmentProducts(query?: {
298
- q?: string;
299
- siteCode?: string;
300
- legalEntityId?: string;
301
- onlyActive?: boolean;
302
- pageNumber?: number;
303
- pageSize?: number;
304
- }): UseQueryResult<PaginatedItems<Product>>;
305
- /**
306
- * Hydrated PRODUCT pages — infinite scroll. `data.pages` is an array of
307
- * pages; call `fetchNextPage()` to load the next one. Terminates when
308
- * the source segment-items page is not full.
309
- */
310
- declare function useMySegmentProductsInfinite(query?: {
311
- q?: string;
312
- siteCode?: string;
313
- legalEntityId?: string;
314
- onlyActive?: boolean;
315
- pageSize?: number;
316
- }): _tanstack_react_query.UseInfiniteQueryResult<{
317
- pages: PaginatedItems<Product>[];
318
- pageParams: number[];
319
- }>;
320
- /** Hydrated CATEGORY page for the caller's segments (single-page). */
321
- declare function useMySegmentCategories(query?: {
322
- q?: string;
323
- siteCode?: string;
324
- legalEntityId?: string;
325
- onlyActive?: boolean;
326
- pageNumber?: number;
327
- pageSize?: number;
328
- }): UseQueryResult<PaginatedItems<Category>>;
329
- /**
330
- * Hydrated CATEGORY pages — infinite scroll. Same semantics as
331
- * {@link useMySegmentProductsInfinite}.
332
- */
333
- declare function useMySegmentCategoriesInfinite(query?: {
334
- q?: string;
335
- siteCode?: string;
336
- legalEntityId?: string;
337
- onlyActive?: boolean;
338
- pageSize?: number;
339
- }): _tanstack_react_query.UseInfiniteQueryResult<{
340
- pages: PaginatedItems<{
341
- id: string;
342
- parentId?: string | null;
343
- localizedName: {
344
- [key: string]: string;
345
- };
346
- localizedDescription?: {
347
- [key: string]: string;
348
- };
349
- localizedSlug?: {
350
- [key: string]: string;
351
- };
352
- name?: string;
353
- description?: string;
354
- code?: string;
355
- ecn?: Array<string>;
356
- validity?: {
357
- from?: string;
358
- to?: string;
359
- };
360
- position: number;
361
- published: boolean;
362
- supercategoriesIds?: Array<string>;
363
- ownClassificationMixins?: Array<{
364
- name: string;
365
- schemaUrl: string;
366
- required?: boolean;
367
- }>;
368
- classificationMixins?: Array<{
369
- name: string;
370
- mixinPath?: string;
371
- schemaUrl: string;
372
- required?: boolean;
373
- sourceCategoryId?: string;
374
- }>;
375
- mixins?: {
376
- [key: string]: unknown;
377
- };
378
- metadata: {
379
- createdAt?: string;
380
- modifiedAt?: string;
381
- } & {
382
- version?: number;
383
- } & {
384
- mixins?: {
385
- [key: string]: string;
386
- };
387
- };
388
- media: Array<{
389
- id?: string;
390
- url?: string;
391
- contentType?: string;
392
- metadata?: {
393
- createdAt?: string;
394
- modifiedAt?: string;
395
- } & unknown;
396
- customAttributes?: {
397
- id?: string;
398
- height?: number;
399
- width?: number;
400
- sizeKB?: number;
401
- type?: string;
402
- name?: string;
403
- } & unknown;
404
- }>;
405
- }>[];
406
- pageParams: number[];
407
- }>;
408
-
409
- /** Updates the logged-in customer's profile and invalidates the `me` query. */
410
- declare function useUpdateCustomer(): UseMutationResult<Customer, unknown, CustomerUpdateInput>;
411
- /**
412
- * Changes the customer's password. No cache invalidation — no read query
413
- * surfaces the password.
414
- */
415
- declare function useChangePassword(): UseMutationResult<void, unknown, PasswordChangeInput>;
416
-
417
- /**
418
- * Lists the logged-in customer's addresses. Disabled when no customer token
419
- * is in storage (returns idle state, not an error).
420
- */
421
- declare function useCustomerAddresses(options?: QueryOpts): UseQueryResult<Address[]>;
422
- /** Address CRUD mutations. Each invalidates `customer.addresses` on success. */
423
- interface AddressMutationsApi {
424
- add: UseMutationResult<Address, unknown, AddressCreateInput>;
425
- update: UseMutationResult<Address, unknown, {
426
- id: string;
427
- patch: AddressUpdateInput;
428
- }>;
429
- remove: UseMutationResult<void, unknown, {
430
- id: string;
431
- }>;
432
- }
433
- declare function useAddressMutations(): AddressMutationsApi;
434
-
435
- /**
436
- * The 2-step anonymous password-reset flow. `request` triggers the reset
437
- * email; `confirm` consumes the token + new password. Both use anonymous
438
- * auth — the user is by definition locked out when running this flow.
439
- */
440
- interface PasswordResetApi {
441
- request: UseMutationResult<void, unknown, PasswordResetRequestInput>;
442
- confirm: UseMutationResult<void, unknown, PasswordResetConfirmInput>;
443
- }
444
- declare function usePasswordReset(): PasswordResetApi;
445
-
446
- /** Lists active sites for the tenant. */
447
- declare function useSites(options?: QueryOpts): UseQueryResult<Site[]>;
448
- /** Convenience: the tenant's default site (the one flagged `default: true`). */
449
- declare function useDefaultSite(options?: QueryOpts): UseQueryResult<Site>;
450
-
451
- /**
452
- * Returns the active site context: `{ siteCode, currency, targetLocation,
453
- * setSite }`. In MS-2, `currency` and `targetLocation` are always `null`;
454
- * they auto-populate in MS-4. `setSite(code)` is sync void in MS-2; it
455
- * becomes async in MS-3 (PATCHing `/session-context/{tenant}/me/context`).
456
- */
457
- declare function useSiteContext(): SiteContextValue;
458
-
459
- /** Lists the legal entities the calling customer is assigned to. */
460
- declare function useMyCompanies(): UseQueryResult<LegalEntity[]>;
461
-
462
- /** Fetches one legal entity by id. Disabled until a customer token is stored. */
463
- declare function useCompany(legalEntityId: string | undefined): UseQueryResult<LegalEntity>;
464
-
465
- /** Lists contact assignments for one legal entity. */
466
- declare function useCompanyContacts(legalEntityId: string | undefined): UseQueryResult<ContactAssignment[]>;
467
-
468
- /** Lists locations owned by one legal entity. */
469
- declare function useCompanyLocations(legalEntityId: string | undefined): UseQueryResult<Location[]>;
470
-
471
- /** Lists IAM customer-groups for one legal entity. */
472
- declare function useCompanyGroups(legalEntityId: string | undefined): UseQueryResult<IamGroup[]>;
473
-
474
- declare function useCreateCompany(): UseMutationResult<{
475
- id: string;
476
- }, unknown, LegalEntityCreate>;
477
- declare function useUpdateCompany(): UseMutationResult<LegalEntity, unknown, {
478
- id: string;
479
- patch: LegalEntityUpdate;
480
- }>;
481
- declare function useDeleteCompany(): UseMutationResult<void, unknown, string>;
482
- declare function useAssignContact(): UseMutationResult<{
483
- id: string;
484
- }, unknown, ContactAssignmentCreate>;
485
- declare function useUpdateContactAssignment(): UseMutationResult<ContactAssignment, unknown, {
486
- id: string;
487
- patch: ContactAssignmentUpdate;
488
- }>;
489
- declare function useUnassignContact(): UseMutationResult<void, unknown, string>;
490
- declare function useCreateLocation(): UseMutationResult<{
491
- id: string;
492
- }, unknown, LocationCreate>;
493
- declare function useUpdateLocation(): UseMutationResult<Location, unknown, {
494
- id: string;
495
- patch: LocationUpdate;
496
- }>;
497
- declare function useDeleteLocation(): UseMutationResult<void, unknown, string>;
498
-
499
- interface CompanySwitcherApi {
500
- companies: LegalEntity[];
501
- active: LegalEntity | null;
502
- status: "idle" | "loading" | "switching" | "error";
503
- switch: (legalEntityId: string) => Promise<void>;
504
- clear: () => Promise<void>;
505
- }
506
- /** UI-friendly wrapper around useActiveCompany — exposes switch/clear pair. */
507
- declare function useCompanySwitcher(): CompanySwitcherApi;
508
-
509
- /** Options for `useMyOrders`. Passing `legalEntityId: null` disables the active-company auto-default. */
510
- interface UseMyOrdersOptions {
511
- pageNumber?: number;
512
- pageSize?: number;
513
- status?: OrderStatus;
514
- /** `undefined` = default from `useActiveCompany`. `null` = no filter. */
515
- legalEntityId?: string | null;
516
- saasToken?: string;
517
- }
518
- /** Paginated read of the customer's own orders. Disabled without a customer token. */
519
- declare function useMyOrders(options?: UseMyOrdersOptions): UseQueryResult<PaginatedItems<Order>>;
520
-
521
- interface UseMyOrdersInfiniteOptions {
522
- pageSize?: number;
523
- status?: OrderStatus;
524
- legalEntityId?: string | null;
525
- saasToken?: string;
526
- }
527
- /** Infinite paginated read of customer orders. Same defaulting rules as useMyOrders. */
528
- declare function useMyOrdersInfinite(options?: UseMyOrdersInfiniteOptions): UseInfiniteQueryResult<{
529
- pages: PaginatedItems<Order>[];
530
- pageParams: number[];
531
- }>;
532
-
533
- interface UseOrderOptions {
534
- saasToken?: string;
535
- }
536
- /** Single-order read by id. Disabled without a customer token or when orderId is undefined. */
537
- declare function useOrder(orderId: string | undefined, options?: UseOrderOptions): UseQueryResult<Order>;
538
-
539
- interface UseCancelOrderVars {
540
- orderId: string;
541
- saasToken?: string;
542
- }
543
- /** Cancels (transitions to DECLINED) a customer's order. Invalidates ["emporix","orders"] on success. */
544
- declare function useCancelOrder(): UseMutationResult<void, unknown, string | UseCancelOrderVars>;
545
-
546
- interface UseOrderTransitionVars {
547
- orderId: string;
548
- status: OrderStatus;
549
- comment?: string;
550
- saasToken?: string;
551
- }
552
- /** Generic status transition. Server enforces legality. Invalidates ["emporix","orders"] on success. */
553
- declare function useOrderTransition(): UseMutationResult<void, unknown, UseOrderTransitionVars>;
554
-
555
- interface UseReorderVars {
556
- orderId: string;
557
- saasToken?: string;
558
- }
559
- interface UseReorderResult {
560
- added: number;
561
- errors: unknown[];
562
- }
563
- /**
564
- * Re-populates the active cart from a past order via a single
565
- * `cart.addItemsBatch` call. Best-effort: item-level failures land in
566
- * `errors[]` instead of throwing; partial-success result shape stays
567
- * `{ added, errors }`.
568
- *
569
- * Emporix's batch endpoint caps at 200 items per request. Orders with more
570
- * line-items are not supported here — extend with chunking if a real use
571
- * case appears.
572
- */
573
- declare function useReorder(): UseMutationResult<UseReorderResult, unknown, UseReorderVars>;
574
-
575
- /** Service-account read of a single sales-order. Disabled when `auth` is undefined. */
576
- declare function useSalesOrder(orderId: string | undefined, authCtx: AuthContext | undefined): UseQueryResult<Order>;
577
-
578
- interface UseUpdateSalesOrderVars {
579
- orderId: string;
580
- patch: SalesOrderPatch;
581
- auth: AuthContext;
582
- recalculate?: boolean;
583
- }
584
- /**
585
- * Service-account update of a sales-order. Invalidates both
586
- * ["emporix","salesorders",id] and ["emporix","orders",id] (the customer-view
587
- * cache for the same order) on success.
588
- */
589
- declare function useUpdateSalesOrder(): UseMutationResult<Order, unknown, UseUpdateSalesOrderVars>;
590
-
591
- interface UseAvailabilityOptions {
592
- enabled?: boolean;
593
- customerToken?: string | null;
594
- defaultAvailableOnNotFound?: boolean;
595
- }
596
- /**
597
- * Reads availability for one product on one site via `availability.get`.
598
- * Defaults to the anonymous token; pass `customerToken` for a customer context.
599
- */
600
- declare function useAvailability(productId: string, siteCode: string, options?: UseAvailabilityOptions): UseQueryResult<Availability>;
601
-
602
- interface UseAvailabilitiesOptions {
603
- enabled?: boolean;
604
- customerToken?: string | null;
605
- defaultAvailableOnNotFound?: boolean;
606
- }
607
- /**
608
- * Reads availability for many products on one site via `availability.getMany`
609
- * (a single batch request). Returns records in input order; missing products
610
- * are `{ available: false }` (or `{ available: true }` with
611
- * `defaultAvailableOnNotFound`).
612
- */
613
- declare function useAvailabilities(productIds: string[], siteCode: string, options?: UseAvailabilitiesOptions): UseQueryResult<Availability[]>;
614
-
615
- 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, useAddToShoppingList, useAddressMutations, useAssignContact, useAvailabilities, useAvailability, useCancelOrder, useCart, useCartMutations, useCategories, useCategoriesInfinite, useCategory, useCategoryTree, useChangePassword, useCheckout, useCompany, useCompanyContacts, useCompanyGroups, useCompanyLocations, useCompanySwitcher, useCreateCart, useCreateCompany, useCreateLocation, useCreateShoppingList, useCustomerAddresses, useCustomerSession, useDefaultSite, useDeleteCompany, useDeleteLocation, useDeleteShoppingList, 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, useRemoveFromShoppingList, useReorder, useSalesOrder, useSetShoppingListItemQuantity, useShoppingLists, useSiteContext, useSites, useUnassignContact, useUpdateCompany, useUpdateContactAssignment, useUpdateCustomer, useUpdateLocation, useUpdateSalesOrder, useVariantChildren };
8
+ /** The signed-in customer's approvals (customer-only). */
9
+ declare function useApprovals(opts?: {
10
+ query?: Record<string, string | number>;
11
+ }): UseQueryResult<ApprovalList>;
12
+ /** A single approval by id (customer-only). */
13
+ declare function useApproval(approvalId: string | undefined): UseQueryResult<Approval>;
14
+ /** Create an approval request for the signed-in customer. Invalidates the list. */
15
+ declare function useCreateApproval(): UseMutationResult<ApprovalCreated, unknown, ApprovalInput>;
16
+ /** Variables for {@link useUpdateApproval}. */
17
+ interface UseUpdateApprovalVars {
18
+ approvalId: string;
19
+ /** JSON-Patch op-array — e.g. `[{ op: "replace", path: "/status", value: "APPROVED" }]`. */
20
+ ops: ApprovalPatch;
21
+ }
22
+ /** Approve/reject/amend an approval via JSON-Patch (customer-only). Invalidates the list. */
23
+ declare function useUpdateApproval(): UseMutationResult<void, unknown, UseUpdateApprovalVars>;
24
+
25
+ export { type UseUpdateApprovalVars, useApproval, useApprovals, useCreateApproval, useUpdateApproval };
package/dist/hooks.js CHANGED
@@ -1,4 +1,4 @@
1
- export { useActiveCart, useAddToShoppingList, useAddressMutations, useAssignContact, useAvailabilities, useAvailability, useCancelOrder, useCart, useCartMutations, useCategories, useCategoriesInfinite, useCategory, useCategoryTree, useChangePassword, useCheckout, useCompany, useCompanyContacts, useCompanyGroups, useCompanyLocations, useCompanySwitcher, useCreateCart, useCreateCompany, useCreateLocation, useCreateShoppingList, useCustomerAddresses, useCustomerSession, useDefaultSite, useDeleteCompany, useDeleteLocation, useDeleteShoppingList, 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, useRemoveFromShoppingList, useReorder, useSalesOrder, useSetShoppingListItemQuantity, useShoppingLists, useSiteContext, useSites, useUnassignContact, useUpdateCompany, useUpdateContactAssignment, useUpdateCustomer, useUpdateLocation, useUpdateSalesOrder, useVariantChildren } from './chunk-AZDCAJLL.js';
1
+ export { useActiveCart, useAddToShoppingList, useAddressMutations, useApproval, useApprovals, useAssignContact, useAvailabilities, useAvailability, useCancelOrder, useCart, useCartMutations, useCategories, useCategoriesInfinite, useCategory, useCategoryTree, useChangePassword, useCheckout, useCompany, useCompanyContacts, useCompanyGroups, useCompanyLocations, useCompanySwitcher, useCreateApproval, useCreateCart, useCreateCompany, useCreateLocation, useCreateReturn, useCreateShoppingList, useCustomerAddresses, useCustomerSession, useDefaultSite, useDeleteCompany, useDeleteLocation, useDeleteShoppingList, useMatchPrices, useMatchPricesChunked, useMyCompanies, useMyOrders, useMyOrdersInfinite, useMyReturns, useMyRewardPoints, useMyRewardPointsSummary, useMySegmentCategories, useMySegmentCategoriesInfinite, useMySegmentCategoryTree, useMySegmentItems, useMySegmentProducts, useMySegmentProductsInfinite, useMySegments, useOrder, useOrderTransition, usePasswordReset, usePaymentModes, useProduct, useProductByCode, useProductMedia, useProductSearch, useProducts, useProductsByCodes, useProductsInCategory, useProductsInCategoryInfinite, useProductsInfinite, useRedeemCoupon, useRedeemOptions, useRedeemRewardPoints, useRemoveFromShoppingList, useReorder, useReturn, useSalesOrder, useSetShoppingListItemQuantity, useShoppingLists, useSiteContext, useSites, useUnassignContact, useUpdateApproval, useUpdateCompany, useUpdateContactAssignment, useUpdateCustomer, useUpdateLocation, useUpdateSalesOrder, useValidateCoupon, useVariantChildren } from './chunk-QMBRDYLW.js';
2
2
  import './chunk-D43CSHK3.js';
3
3
  import './chunk-FBQY2N7S.js';
4
4
  //# sourceMappingURL=hooks.js.map