@viu/emporix-sdk 2.21.0 → 2.23.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 +146 -0
- package/dist/availability.cjs +118 -0
- package/dist/availability.cjs.map +1 -1
- package/dist/availability.d.cts +178 -2
- package/dist/availability.d.ts +178 -2
- package/dist/availability.js +1 -1
- package/dist/cart.cjs +215 -9
- package/dist/cart.cjs.map +1 -1
- package/dist/cart.d.cts +281 -3
- package/dist/cart.d.ts +281 -3
- package/dist/cart.js +1 -1
- package/dist/category.cjs +220 -2
- package/dist/category.cjs.map +1 -1
- package/dist/category.d.cts +408 -1
- package/dist/category.d.ts +408 -1
- package/dist/category.js +1 -1
- package/dist/{chunk-HD5RBCM6.js → chunk-27NLS646.js} +10 -2
- package/dist/chunk-27NLS646.js.map +1 -0
- package/dist/{chunk-PYLWZZC4.js → chunk-6PJFOX3A.js} +126 -2
- package/dist/chunk-6PJFOX3A.js.map +1 -0
- package/dist/chunk-HWVFF6B2.js +378 -0
- package/dist/chunk-HWVFF6B2.js.map +1 -0
- package/dist/chunk-LQFRJSVT.js +224 -0
- package/dist/chunk-LQFRJSVT.js.map +1 -0
- package/dist/chunk-P7G4LOOV.js +264 -0
- package/dist/chunk-P7G4LOOV.js.map +1 -0
- package/dist/{chunk-HBEQEIT6.js → chunk-PRN3T6TY.js} +63 -3
- package/dist/chunk-PRN3T6TY.js.map +1 -0
- package/dist/{chunk-44F52KRE.js → chunk-QQMLN76U.js} +27 -2
- package/dist/chunk-QQMLN76U.js.map +1 -0
- package/dist/chunk-UNW6SFSB.js +363 -0
- package/dist/chunk-UNW6SFSB.js.map +1 -0
- package/dist/chunk-V3275BA7.js +181 -0
- package/dist/chunk-V3275BA7.js.map +1 -0
- package/dist/chunk-W2KBVWJ2.js +323 -0
- package/dist/chunk-W2KBVWJ2.js.map +1 -0
- package/dist/chunk-YVZ6GOLE.js +399 -0
- package/dist/chunk-YVZ6GOLE.js.map +1 -0
- package/dist/chunk-ZOFGDNSX.js +305 -0
- package/dist/chunk-ZOFGDNSX.js.map +1 -0
- package/dist/companies.cjs +25 -0
- package/dist/companies.cjs.map +1 -1
- package/dist/companies.d.cts +14 -0
- package/dist/companies.d.ts +14 -0
- package/dist/companies.js +1 -1
- package/dist/contacts.cjs +8 -0
- package/dist/contacts.cjs.map +1 -1
- package/dist/contacts.d.cts +2 -0
- package/dist/contacts.d.ts +2 -0
- package/dist/contacts.js +1 -1
- package/dist/customer-groups-BxSNFHq1.d.cts +706 -0
- package/dist/customer-groups-GlzWhDsi.d.ts +706 -0
- package/dist/customer-groups.cjs +200 -17
- package/dist/customer-groups.cjs.map +1 -1
- package/dist/customer-groups.d.cts +2 -110
- package/dist/customer-groups.d.ts +2 -110
- package/dist/customer-groups.js +1 -1
- package/dist/customer.cjs +61 -1
- package/dist/customer.cjs.map +1 -1
- package/dist/customer.d.cts +48 -1
- package/dist/customer.d.ts +48 -1
- package/dist/customer.js +1 -1
- package/dist/index.cjs +2566 -554
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +455 -12
- package/dist/index.d.ts +455 -12
- package/dist/index.js +687 -342
- package/dist/index.js.map +1 -1
- package/dist/orders.cjs +160 -2
- package/dist/orders.cjs.map +1 -1
- package/dist/orders.d.cts +221 -1
- package/dist/orders.d.ts +221 -1
- package/dist/orders.js +1 -1
- package/dist/payment.cjs +124 -0
- package/dist/payment.cjs.map +1 -1
- package/dist/payment.d.cts +335 -1
- package/dist/payment.d.ts +335 -1
- package/dist/payment.js +1 -1
- package/dist/price.cjs +197 -0
- package/dist/price.cjs.map +1 -1
- package/dist/price.d.cts +577 -1
- package/dist/price.d.ts +577 -1
- package/dist/price.js +1 -1
- package/dist/product.cjs +190 -0
- package/dist/product.cjs.map +1 -1
- package/dist/product.d.cts +503 -1
- package/dist/product.d.ts +503 -1
- package/dist/product.js +1 -1
- package/dist/segment.cjs +179 -0
- package/dist/segment.cjs.map +1 -1
- package/dist/segment.d.cts +181 -1
- package/dist/segment.d.ts +181 -1
- package/dist/segment.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-36T4YPQJ.js +0 -106
- package/dist/chunk-36T4YPQJ.js.map +0 -1
- package/dist/chunk-3BTPX7IJ.js +0 -41
- package/dist/chunk-3BTPX7IJ.js.map +0 -1
- package/dist/chunk-44F52KRE.js.map +0 -1
- package/dist/chunk-A3LYJUD4.js +0 -108
- package/dist/chunk-A3LYJUD4.js.map +0 -1
- package/dist/chunk-FZMP5NQZ.js +0 -173
- package/dist/chunk-FZMP5NQZ.js.map +0 -1
- package/dist/chunk-HBEQEIT6.js.map +0 -1
- package/dist/chunk-HD5RBCM6.js.map +0 -1
- package/dist/chunk-HUEMYP2L.js +0 -193
- package/dist/chunk-HUEMYP2L.js.map +0 -1
- package/dist/chunk-IVCCGJN5.js +0 -63
- package/dist/chunk-IVCCGJN5.js.map +0 -1
- package/dist/chunk-NE7MIZPR.js +0 -144
- package/dist/chunk-NE7MIZPR.js.map +0 -1
- package/dist/chunk-PYLWZZC4.js.map +0 -1
- package/dist/chunk-ZNLHLFQM.js +0 -160
- package/dist/chunk-ZNLHLFQM.js.map +0 -1
package/dist/cart.d.ts
CHANGED
|
@@ -17,6 +17,15 @@ import { C as ClientContext, b as AuthContext } from './context-CfXJcYKP.js';
|
|
|
17
17
|
*
|
|
18
18
|
*/
|
|
19
19
|
type Restriction = string | null;
|
|
20
|
+
type Search = {
|
|
21
|
+
/**
|
|
22
|
+
* A standard query parameter is used to search for specific values.
|
|
23
|
+
*
|
|
24
|
+
* See: [Standard practises - Query parameter](https://developer.emporix.io/api-references/standard-practices/q-param/)
|
|
25
|
+
*
|
|
26
|
+
*/
|
|
27
|
+
q?: string;
|
|
28
|
+
};
|
|
20
29
|
type BaseCart = {
|
|
21
30
|
/**
|
|
22
31
|
* Cart unique identifier generated when a cart is created.
|
|
@@ -106,6 +115,16 @@ type BaseCart = {
|
|
|
106
115
|
*/
|
|
107
116
|
nonDelivery?: Array<string>;
|
|
108
117
|
};
|
|
118
|
+
type CartGetAll = BaseCart & {
|
|
119
|
+
/**
|
|
120
|
+
* Items added to the cart.
|
|
121
|
+
*/
|
|
122
|
+
items?: Array<BaseCartItemResponse>;
|
|
123
|
+
/**
|
|
124
|
+
* Informs whether cart is still open or it is already closed.
|
|
125
|
+
*/
|
|
126
|
+
status?: 'OPEN' | 'CLOSED';
|
|
127
|
+
};
|
|
109
128
|
type Cart$1 = BaseCart & {
|
|
110
129
|
/**
|
|
111
130
|
* Items added to the cart.
|
|
@@ -180,6 +199,19 @@ type Cart$1 = BaseCart & {
|
|
|
180
199
|
[key: string]: unknown;
|
|
181
200
|
};
|
|
182
201
|
};
|
|
202
|
+
/**
|
|
203
|
+
* Cart delivery time restrictions.
|
|
204
|
+
*/
|
|
205
|
+
type CartDtRestrictions = {
|
|
206
|
+
/**
|
|
207
|
+
* Time needed to prepare the products for the delivery, expressed in hours. Time is calculated based on the products added to the cart. It is equal to the maximum lead time of all the products - `mixins.productCustomAttributes.leadTime`.
|
|
208
|
+
*/
|
|
209
|
+
leadTime?: number;
|
|
210
|
+
/**
|
|
211
|
+
* List of days on which the products cannot be delivered. Days are presented by numbers where Monday is `0`, Tuesday is `1` etc. `nonDelivery` list is the union of all `mixins.productCustomAttributes.nonDelivery` products values.
|
|
212
|
+
*/
|
|
213
|
+
nonDelivery?: Array<string>;
|
|
214
|
+
};
|
|
183
215
|
type CartItemRequest = {
|
|
184
216
|
/**
|
|
185
217
|
* Cart item's unique identifier.
|
|
@@ -998,6 +1030,40 @@ type SingleBatchResponse = {
|
|
|
998
1030
|
};
|
|
999
1031
|
yrn?: Yrn;
|
|
1000
1032
|
};
|
|
1033
|
+
/**
|
|
1034
|
+
* Result for a single cart item in a batch update, aligned with bulk operation entry responses.
|
|
1035
|
+
*/
|
|
1036
|
+
type UpdateCartItemsBatchEntryResponse = {
|
|
1037
|
+
/**
|
|
1038
|
+
* Index of the processed cart item, matching the position in the request body.
|
|
1039
|
+
*
|
|
1040
|
+
*/
|
|
1041
|
+
index?: number;
|
|
1042
|
+
/**
|
|
1043
|
+
* Cart item unique identifier.
|
|
1044
|
+
*/
|
|
1045
|
+
id?: string;
|
|
1046
|
+
/**
|
|
1047
|
+
* HTTP status code for this entry.
|
|
1048
|
+
*/
|
|
1049
|
+
code?: number;
|
|
1050
|
+
/**
|
|
1051
|
+
* HTTP status description for this entry.
|
|
1052
|
+
*/
|
|
1053
|
+
status?: string;
|
|
1054
|
+
/**
|
|
1055
|
+
* Message describing the outcome or error for this entry.
|
|
1056
|
+
*/
|
|
1057
|
+
message?: string;
|
|
1058
|
+
/**
|
|
1059
|
+
* Additional detail messages for this entry.
|
|
1060
|
+
*/
|
|
1061
|
+
details?: Array<string>;
|
|
1062
|
+
};
|
|
1063
|
+
/**
|
|
1064
|
+
* Per-entry results for batch cart item updates.
|
|
1065
|
+
*/
|
|
1066
|
+
type CartItemsBatchUpdateResponse = Array<UpdateCartItemsBatchEntryResponse>;
|
|
1001
1067
|
/**
|
|
1002
1068
|
* Shipping cost information.
|
|
1003
1069
|
*/
|
|
@@ -1077,6 +1143,63 @@ type Total = {
|
|
|
1077
1143
|
*/
|
|
1078
1144
|
discount?: number;
|
|
1079
1145
|
};
|
|
1146
|
+
type UpdateCart = {
|
|
1147
|
+
/**
|
|
1148
|
+
* Customer unique identifier generated when a customer account is created through the Customer Service.
|
|
1149
|
+
*/
|
|
1150
|
+
customerId?: string;
|
|
1151
|
+
restriction?: Restriction;
|
|
1152
|
+
/**
|
|
1153
|
+
* Three-letter currency code, compliant with the ISO 4217 standard.
|
|
1154
|
+
*/
|
|
1155
|
+
currency?: string;
|
|
1156
|
+
/**
|
|
1157
|
+
* ID of the legal entity to which customer is assigned.
|
|
1158
|
+
*/
|
|
1159
|
+
legalEntityId?: string;
|
|
1160
|
+
/**
|
|
1161
|
+
* Delivery window unique identifier, as defined in the Shipping Service.
|
|
1162
|
+
*/
|
|
1163
|
+
deliveryWindowId?: string;
|
|
1164
|
+
deliveryWindow?: DeliveryWindow;
|
|
1165
|
+
/**
|
|
1166
|
+
* Cart type. You can use this field if your store offers different types of carts, such as shopping carts and wishlists.
|
|
1167
|
+
*/
|
|
1168
|
+
type?: string;
|
|
1169
|
+
/**
|
|
1170
|
+
* Customer address - zip code.
|
|
1171
|
+
*/
|
|
1172
|
+
zipCode?: string;
|
|
1173
|
+
/**
|
|
1174
|
+
* Two-letter country code, compliant with the ISO 3166 standard.
|
|
1175
|
+
*/
|
|
1176
|
+
countryCode?: string;
|
|
1177
|
+
/**
|
|
1178
|
+
* Order unique identifier generated when a checkout is triggered through the Checkout Service.
|
|
1179
|
+
*/
|
|
1180
|
+
orderId?: string;
|
|
1181
|
+
/**
|
|
1182
|
+
* Quote unique identifier generated when a quote is created through the Quote Service out of a cart.
|
|
1183
|
+
*/
|
|
1184
|
+
quoteId?: string;
|
|
1185
|
+
/**
|
|
1186
|
+
* Cart status.
|
|
1187
|
+
*/
|
|
1188
|
+
status?: 'OPEN' | 'CLOSED';
|
|
1189
|
+
channel?: Channel;
|
|
1190
|
+
/**
|
|
1191
|
+
* External discounts that should be applied to this cart. Requires `cart.cart_manage_external_prices` scope
|
|
1192
|
+
*/
|
|
1193
|
+
externalDiscounts?: Array<ExternalCartDiscount>;
|
|
1194
|
+
/**
|
|
1195
|
+
* List of addresses that should be associated with the cart and used for tax determination and shipping cost. There can be one address of type `BILLING` and one of type `SHIPPING` - others are ignored. These addresses are returned with the origin `REQUEST` in the cart response.
|
|
1196
|
+
*/
|
|
1197
|
+
addresses?: Array<AddressRequest>;
|
|
1198
|
+
metadata?: MetadataRequest;
|
|
1199
|
+
mixins?: {
|
|
1200
|
+
[key: string]: unknown;
|
|
1201
|
+
};
|
|
1202
|
+
};
|
|
1080
1203
|
type UpdateCartItem = {
|
|
1081
1204
|
externalFees?: Array<ExternalFee>;
|
|
1082
1205
|
/**
|
|
@@ -1149,6 +1272,9 @@ type UpdateProduct = {
|
|
|
1149
1272
|
[key: string]: unknown;
|
|
1150
1273
|
};
|
|
1151
1274
|
};
|
|
1275
|
+
type CartItemsBatchUpdateRequest = Array<CartItemRequest & {
|
|
1276
|
+
[key: string]: unknown;
|
|
1277
|
+
}>;
|
|
1152
1278
|
type BatchResponse = Array<SingleBatchResponse>;
|
|
1153
1279
|
/**
|
|
1154
1280
|
* A unique identifier of a global resource, which stores information about the resource, such as its type, ID or name of the tenant.
|
|
@@ -1728,6 +1854,50 @@ type CalculatedTotalDiscount = {
|
|
|
1728
1854
|
*/
|
|
1729
1855
|
appliedDiscounts?: Array<CalculatedAppliedDiscount>;
|
|
1730
1856
|
};
|
|
1857
|
+
/**
|
|
1858
|
+
* Result of cart validation showing any errors in the cart items.
|
|
1859
|
+
*/
|
|
1860
|
+
type CartValidationResult$1 = {
|
|
1861
|
+
/**
|
|
1862
|
+
* Flag indicating if the cart is valid or contains validation errors.
|
|
1863
|
+
*/
|
|
1864
|
+
isValid?: boolean;
|
|
1865
|
+
/**
|
|
1866
|
+
* Detailed list of validation errors for specific cart items.
|
|
1867
|
+
*/
|
|
1868
|
+
itemsValidationDetails?: Array<ItemValidationDetails>;
|
|
1869
|
+
};
|
|
1870
|
+
/**
|
|
1871
|
+
* Validation details for a specific cart item.
|
|
1872
|
+
*/
|
|
1873
|
+
type ItemValidationDetails = {
|
|
1874
|
+
/**
|
|
1875
|
+
* Identifier of the cart item.
|
|
1876
|
+
*/
|
|
1877
|
+
id?: string;
|
|
1878
|
+
/**
|
|
1879
|
+
* List of validation errors for this cart item.
|
|
1880
|
+
*/
|
|
1881
|
+
errors?: Array<ValidationError>;
|
|
1882
|
+
};
|
|
1883
|
+
/**
|
|
1884
|
+
* Details of a specific validation error.
|
|
1885
|
+
*/
|
|
1886
|
+
type ValidationError = {
|
|
1887
|
+
/**
|
|
1888
|
+
* Error code for the validation issue. Common codes include: - CART-ITEM-UNIT-PRICE-100001: Item's price was not found in the price match - CART-ITEM-UNIT-PRICE-100002: Duplicated prices found for the same product - CART-ITEM-EXTERNAL-DISCOUNT-100001: Invalid external discount configuration - CART-ITEM-EXTERNAL-DISCOUNT-100002: External discount amount exceeds item price
|
|
1889
|
+
*
|
|
1890
|
+
*/
|
|
1891
|
+
errorCode?: string;
|
|
1892
|
+
/**
|
|
1893
|
+
* Human-readable message describing the error.
|
|
1894
|
+
*/
|
|
1895
|
+
message?: string;
|
|
1896
|
+
/**
|
|
1897
|
+
* Field path where the error occurred.
|
|
1898
|
+
*/
|
|
1899
|
+
field?: string;
|
|
1900
|
+
};
|
|
1731
1901
|
|
|
1732
1902
|
/** A cart as returned by the Cart service (all generated fields). */
|
|
1733
1903
|
type Cart = Cart$1;
|
|
@@ -1743,6 +1913,24 @@ type CartItemBatchEntry = SingleBatchResponse;
|
|
|
1743
1913
|
type CartItemsBatchResponse = BatchResponse;
|
|
1744
1914
|
/** An address payload for cart shipping/billing (generated). */
|
|
1745
1915
|
type CartAddress = AddressRequest;
|
|
1916
|
+
/** Result of validating a cart's items (generated). */
|
|
1917
|
+
type CartValidationResult = CartValidationResult$1;
|
|
1918
|
+
/** A single cart item as returned by the Cart service (generated). */
|
|
1919
|
+
type CartItem = CartItemResponse;
|
|
1920
|
+
/** Request body for updating multiple cart items (generated). */
|
|
1921
|
+
type CartItemsBatchUpdateInput = CartItemsBatchUpdateRequest;
|
|
1922
|
+
/** Per-entry response for a multi-item update (generated). */
|
|
1923
|
+
type CartItemsBatchUpdateResult = CartItemsBatchUpdateResponse;
|
|
1924
|
+
/** Body for searching carts (`POST /carts/search`) — a `q` filter. */
|
|
1925
|
+
type CartSearchInput = Search;
|
|
1926
|
+
/** A cart summary as returned by `POST /carts/search`. */
|
|
1927
|
+
type CartSummary = CartGetAll;
|
|
1928
|
+
/** Body for a full cart update (`PUT /carts/{id}`). */
|
|
1929
|
+
type CartUpdateInput = UpdateCart;
|
|
1930
|
+
/** A discount entry as returned by `GET /carts/{id}/discounts`. */
|
|
1931
|
+
type CartDiscount = DiscountResponse;
|
|
1932
|
+
/** Lead-time and non-delivery-time restrictions for a cart (`GET …/dtRestrictions`). */
|
|
1933
|
+
type CartDeliveryRestrictions = CartDtRestrictions;
|
|
1746
1934
|
/** Cart operations. Every method requires an explicit customer/anonymous context. */
|
|
1747
1935
|
declare class CartService {
|
|
1748
1936
|
private readonly ctx;
|
|
@@ -1807,10 +1995,56 @@ declare class CartService {
|
|
|
1807
1995
|
* the updated cart is re-fetched and returned.
|
|
1808
1996
|
*/
|
|
1809
1997
|
removeCoupon(cartId: string, code: string, auth: AuthContext): Promise<Cart>;
|
|
1810
|
-
/**
|
|
1998
|
+
/** Validates the cart's items (pricing/consistency checks). */
|
|
1999
|
+
validate(cartId: string, auth: AuthContext): Promise<CartValidationResult>;
|
|
2000
|
+
/** Lists the items in a cart with calculated prices. */
|
|
2001
|
+
listItems(cartId: string, auth: AuthContext): Promise<CartItem[]>;
|
|
2002
|
+
/** Refreshes a cart and its items (re-prices), then returns the updated cart. */
|
|
2003
|
+
refresh(cartId: string, auth: AuthContext): Promise<Cart>;
|
|
2004
|
+
/** Changes the cart's site (re-prices to the new site's currency), then returns the updated cart. */
|
|
2005
|
+
changeSite(cartId: string, siteCode: string, auth: AuthContext): Promise<Cart>;
|
|
2006
|
+
/** Changes the cart's currency (re-prices), then returns the updated cart. */
|
|
2007
|
+
changeCurrency(cartId: string, currency: string, auth: AuthContext): Promise<Cart>;
|
|
2008
|
+
/**
|
|
2009
|
+
* Updates multiple cart items in one request (`PUT …/itemsBatch`). Like
|
|
2010
|
+
* `addItemsBatch`, the response carries a per-entry `status`; partial failures
|
|
2011
|
+
* do not throw — inspect each entry.
|
|
2012
|
+
*/
|
|
2013
|
+
updateItemsBatch(cartId: string, items: CartItemsBatchUpdateInput, auth: AuthContext): Promise<CartItemsBatchUpdateResult>;
|
|
2014
|
+
/**
|
|
2015
|
+
* Sets the cart's shipping address, preserving the billing address.
|
|
2016
|
+
*
|
|
2017
|
+
* The API has no per-type address endpoint: addresses live in the cart's
|
|
2018
|
+
* `addresses` array, written via `PUT /carts/{cartId}`. That array is a **full
|
|
2019
|
+
* replace** — sending only one type leaves the other as an empty stub — so
|
|
2020
|
+
* this method reads the cart, merges, writes, and re-fetches. Use
|
|
2021
|
+
* {@link setAddresses} to set both in a single request.
|
|
2022
|
+
*/
|
|
1811
2023
|
setShippingAddress(cartId: string, address: CartAddress, auth: AuthContext): Promise<Cart>;
|
|
1812
|
-
/**
|
|
2024
|
+
/**
|
|
2025
|
+
* Sets the cart's billing address, preserving the shipping address. See
|
|
2026
|
+
* {@link setShippingAddress} for why this reads before writing.
|
|
2027
|
+
*/
|
|
1813
2028
|
setBillingAddress(cartId: string, address: CartAddress, auth: AuthContext): Promise<Cart>;
|
|
2029
|
+
/**
|
|
2030
|
+
* Sets both cart addresses in one request (`PUT /carts/{cartId}`), skipping
|
|
2031
|
+
* the read that {@link setShippingAddress} needs.
|
|
2032
|
+
*
|
|
2033
|
+
* **This replaces the cart's address set**: a type you omit is cleared, and
|
|
2034
|
+
* `{}` clears both. Use it when you already hold both addresses (a checkout
|
|
2035
|
+
* form submitting them together); use the per-type setters to change one and
|
|
2036
|
+
* keep the other.
|
|
2037
|
+
*/
|
|
2038
|
+
setAddresses(cartId: string, addresses: {
|
|
2039
|
+
shipping?: CartAddress;
|
|
2040
|
+
billing?: CartAddress;
|
|
2041
|
+
}, auth: AuthContext): Promise<Cart>;
|
|
2042
|
+
/**
|
|
2043
|
+
* Reads the cart, replaces the entry of `type` with `address` (keeping every
|
|
2044
|
+
* other type verbatim — resending it unchanged is what stops the server from
|
|
2045
|
+
* wiping it), writes, and returns the re-fetched cart.
|
|
2046
|
+
*/
|
|
2047
|
+
private mergeAddress;
|
|
1814
2048
|
/**
|
|
1815
2049
|
* Merges one or more anonymous carts into the specified customer cart.
|
|
1816
2050
|
* Per Emporix: the target cart in the path **must belong to the logged-in
|
|
@@ -1820,6 +2054,50 @@ declare class CartService {
|
|
|
1820
2054
|
* Requires a customer `AuthContext`.
|
|
1821
2055
|
*/
|
|
1822
2056
|
merge(customerCartId: string, anonymousCartIds: string[], auth: AuthContext): Promise<Cart>;
|
|
2057
|
+
/**
|
|
2058
|
+
* Searches carts tenant-wide (`POST /carts/search`, body `{ q }`). This is a
|
|
2059
|
+
* backend/admin operation — a customer token cannot scan other customers'
|
|
2060
|
+
* carts, so `auth` is forwarded unguarded (pass a service token for admin
|
|
2061
|
+
* use). The server enforces scope (403 on insufficient).
|
|
2062
|
+
*/
|
|
2063
|
+
search(query: CartSearchInput, auth: AuthContext, params?: {
|
|
2064
|
+
pageNumber?: number;
|
|
2065
|
+
pageSize?: number;
|
|
2066
|
+
sort?: string;
|
|
2067
|
+
fields?: string;
|
|
2068
|
+
}): Promise<CartSummary[]>;
|
|
2069
|
+
/**
|
|
2070
|
+
* Deletes a cart (`DELETE /carts/{cartId}`). Backend/admin or owner
|
|
2071
|
+
* operation — `auth` is forwarded unguarded (service or customer). Returns
|
|
2072
|
+
* nothing; the cart no longer exists.
|
|
2073
|
+
*/
|
|
2074
|
+
delete(cartId: string, auth: AuthContext): Promise<void>;
|
|
2075
|
+
/**
|
|
2076
|
+
* Full-updates a cart (`PUT /carts/{cartId}`, body `UpdateCart`). Backend or
|
|
2077
|
+
* owner operation — `auth` is forwarded unguarded. The endpoint returns 204,
|
|
2078
|
+
* so the cart is re-fetched with the same `auth` (via a direct GET, not
|
|
2079
|
+
* `get()`, so a service token is not rejected by the cart-auth guard) and
|
|
2080
|
+
* returned.
|
|
2081
|
+
*/
|
|
2082
|
+
update(cartId: string, input: CartUpdateInput, auth: AuthContext): Promise<Cart>;
|
|
2083
|
+
/** Fetches a single cart item's details (`GET /carts/{cartId}/items/{itemId}`). */
|
|
2084
|
+
getItem(cartId: string, itemId: string, auth: AuthContext): Promise<CartItem>;
|
|
2085
|
+
/** Lists the discounts applied to a cart (`GET /carts/{cartId}/discounts`). */
|
|
2086
|
+
listDiscounts(cartId: string, auth: AuthContext): Promise<CartDiscount[]>;
|
|
2087
|
+
/**
|
|
2088
|
+
* Removes all discounts from a cart (`DELETE /carts/{cartId}/discounts` with
|
|
2089
|
+
* no `codes` filter), then re-fetches and returns the updated cart. Use
|
|
2090
|
+
* `removeCoupon(code)` to remove a specific coupon by code.
|
|
2091
|
+
*/
|
|
2092
|
+
removeAllDiscounts(cartId: string, auth: AuthContext): Promise<Cart>;
|
|
2093
|
+
/**
|
|
2094
|
+
* Removes a single discount by its index (`DELETE
|
|
2095
|
+
* /carts/{cartId}/discounts/{discountIndex}`), then re-fetches and returns
|
|
2096
|
+
* the updated cart.
|
|
2097
|
+
*/
|
|
2098
|
+
removeDiscountByIndex(cartId: string, discountIndex: string, auth: AuthContext): Promise<Cart>;
|
|
2099
|
+
/** Retrieves the cart's lead-time and non-delivery-time restrictions (`GET /carts/{cartId}/dtRestrictions`). */
|
|
2100
|
+
getDeliveryRestrictions(cartId: string, auth: AuthContext): Promise<CartDeliveryRestrictions>;
|
|
1823
2101
|
}
|
|
1824
2102
|
|
|
1825
|
-
export { type Cart, type CartAddress, type CartCreated, type CartItemBatchEntry, type CartItemInput, type CartItemUpdate, type CartItemsBatchResponse, CartService, type CreateCartInput };
|
|
2103
|
+
export { type Cart, type CartAddress, type CartCreated, type CartDeliveryRestrictions, type CartDiscount, type CartItem, type CartItemBatchEntry, type CartItemInput, type CartItemUpdate, type CartItemsBatchResponse, type CartItemsBatchUpdateInput, type CartItemsBatchUpdateResult, type CartSearchInput, CartService, type CartSummary, type CartUpdateInput, type CartValidationResult, type CreateCartInput };
|
package/dist/cart.js
CHANGED
package/dist/category.cjs
CHANGED
|
@@ -14,7 +14,7 @@ async function* iterateAll(fetchPage, start = 1) {
|
|
|
14
14
|
// src/core/query.ts
|
|
15
15
|
function resolveQuery(q, cap) {
|
|
16
16
|
if (typeof q === "string") return q;
|
|
17
|
-
if (q.usesCompound === true &&
|
|
17
|
+
if (q.usesCompound === true && !cap.compoundLogicalQuery) {
|
|
18
18
|
throw new Error(
|
|
19
19
|
"This filter uses or()/compoundLogicalQuery, which the target service does not support. Combine conditions with and() (space-separated AND) instead."
|
|
20
20
|
);
|
|
@@ -57,7 +57,7 @@ var CategoryService = class {
|
|
|
57
57
|
* support `compoundLogicalQuery`, so `or()` filters are rejected.
|
|
58
58
|
*/
|
|
59
59
|
async search(query, params = {}, auth = ANON) {
|
|
60
|
-
const q = resolveQuery(query);
|
|
60
|
+
const q = resolveQuery(query, { compoundLogicalQuery: false });
|
|
61
61
|
const pageNumber = params.pageNumber ?? 1;
|
|
62
62
|
const pageSize = params.pageSize ?? 50;
|
|
63
63
|
const items = await this.ctx.http.request({
|
|
@@ -174,6 +174,224 @@ var CategoryService = class {
|
|
|
174
174
|
);
|
|
175
175
|
return pages.flat();
|
|
176
176
|
}
|
|
177
|
+
/** Lists a category's ancestor categories (breadcrumb-up). Default auth: anonymous. */
|
|
178
|
+
async parents(categoryId, auth = ANON) {
|
|
179
|
+
return this.ctx.http.request({
|
|
180
|
+
method: "GET",
|
|
181
|
+
path: `/category/${this.ctx.tenant}/categories/${categoryId}/parents`,
|
|
182
|
+
auth
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Lists a category's direct child categories via the dedicated
|
|
187
|
+
* `…/subcategories` endpoint. (The older `subcategories()` reads `/assignments`
|
|
188
|
+
* and is kept for backward compatibility.) Default auth: anonymous.
|
|
189
|
+
*/
|
|
190
|
+
async childCategories(categoryId, auth = ANON) {
|
|
191
|
+
return this.ctx.http.request({
|
|
192
|
+
method: "GET",
|
|
193
|
+
path: `/category/${this.ctx.tenant}/categories/${categoryId}/subcategories`,
|
|
194
|
+
auth
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
/** Retrieves one category tree by its root category id. Default auth: anonymous. */
|
|
198
|
+
async getTree(categoryId, auth = ANON) {
|
|
199
|
+
return this.ctx.http.request({
|
|
200
|
+
method: "GET",
|
|
201
|
+
path: `/category/${this.ctx.tenant}/category-trees/${encodeURIComponent(categoryId)}`,
|
|
202
|
+
auth
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
// --- Admin write CRUD. Default auth: service. ---
|
|
206
|
+
/**
|
|
207
|
+
* Creates a category (`POST /categories`). Default auth: service.
|
|
208
|
+
* `options.publish` sets the `publish` query flag (needs the
|
|
209
|
+
* `category.category_publish` scope).
|
|
210
|
+
*/
|
|
211
|
+
async create(input, options = {}, auth = SERVICE) {
|
|
212
|
+
return this.ctx.http.request({
|
|
213
|
+
method: "POST",
|
|
214
|
+
path: `/category/${this.ctx.tenant}/categories`,
|
|
215
|
+
...options.publish === void 0 ? {} : { query: { publish: String(options.publish) } },
|
|
216
|
+
body: input,
|
|
217
|
+
auth
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Full-replaces a category (`PUT /categories/{categoryId}`). This is an
|
|
222
|
+
* upsert: with a caller-supplied id it may create (201, returns the id) or
|
|
223
|
+
* update an existing one (204, returns nothing). Default auth: service.
|
|
224
|
+
*/
|
|
225
|
+
async update(categoryId, input, options = {}, auth = SERVICE) {
|
|
226
|
+
return this.ctx.http.request({
|
|
227
|
+
method: "PUT",
|
|
228
|
+
path: `/category/${this.ctx.tenant}/categories/${categoryId}`,
|
|
229
|
+
...options.publish === void 0 ? {} : { query: { publish: String(options.publish) } },
|
|
230
|
+
body: input,
|
|
231
|
+
auth
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Partially updates a category (`PATCH /categories/{categoryId}`). Default
|
|
236
|
+
* auth: service. `options.publish` sets the `publish` query flag.
|
|
237
|
+
*/
|
|
238
|
+
async patch(categoryId, input, options = {}, auth = SERVICE) {
|
|
239
|
+
await this.ctx.http.request({
|
|
240
|
+
method: "PATCH",
|
|
241
|
+
path: `/category/${this.ctx.tenant}/categories/${categoryId}`,
|
|
242
|
+
...options.publish === void 0 ? {} : { query: { publish: String(options.publish) } },
|
|
243
|
+
body: input,
|
|
244
|
+
auth
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
/** Deletes a category (`DELETE /categories/{categoryId}`). Default auth: service. */
|
|
248
|
+
async delete(categoryId, auth = SERVICE) {
|
|
249
|
+
await this.ctx.http.request({
|
|
250
|
+
method: "DELETE",
|
|
251
|
+
path: `/category/${this.ctx.tenant}/categories/${categoryId}`,
|
|
252
|
+
auth
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Searches categories via `POST /categories/search`. Same query capability
|
|
257
|
+
* as {@link search} (`compoundLogicalQuery: false` — Category rejects `or()`
|
|
258
|
+
* filters); the POST body avoids URL-length limits for large `q` filters.
|
|
259
|
+
* `params.showRoots` / `params.showUnpublished` are POST-only flags. Default
|
|
260
|
+
* auth: anonymous.
|
|
261
|
+
*/
|
|
262
|
+
async searchByQuery(query, params = {}, auth = ANON) {
|
|
263
|
+
const q = resolveQuery(query, { compoundLogicalQuery: false });
|
|
264
|
+
const pageNumber = params.pageNumber ?? 1;
|
|
265
|
+
const pageSize = params.pageSize ?? 50;
|
|
266
|
+
const items = await this.ctx.http.request({
|
|
267
|
+
method: "POST",
|
|
268
|
+
path: `/category/${this.ctx.tenant}/categories/search`,
|
|
269
|
+
query: {
|
|
270
|
+
pageNumber,
|
|
271
|
+
pageSize,
|
|
272
|
+
...params.sort === void 0 ? {} : { sort: params.sort },
|
|
273
|
+
...params.showRoots === void 0 ? {} : { showRoots: String(params.showRoots) },
|
|
274
|
+
...params.showUnpublished === void 0 ? {} : { showUnpublished: String(params.showUnpublished) }
|
|
275
|
+
},
|
|
276
|
+
body: { q },
|
|
277
|
+
idempotent: true,
|
|
278
|
+
// pure read over POST — safe to replay on 5xx/429
|
|
279
|
+
auth
|
|
280
|
+
});
|
|
281
|
+
return { items, pageNumber, pageSize, hasNextPage: items.length === pageSize };
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Searches category trees via `POST /category-trees/search` — returns the
|
|
285
|
+
* trees that include at least one of the given `categoryIds`. Default auth:
|
|
286
|
+
* anonymous.
|
|
287
|
+
*/
|
|
288
|
+
async searchTrees(input, options = {}, auth = ANON) {
|
|
289
|
+
return this.ctx.http.request({
|
|
290
|
+
method: "POST",
|
|
291
|
+
path: `/category/${this.ctx.tenant}/category-trees/search`,
|
|
292
|
+
...options.showUnpublished === void 0 ? {} : { query: { showUnpublished: String(options.showUnpublished) } },
|
|
293
|
+
body: input,
|
|
294
|
+
idempotent: true,
|
|
295
|
+
// pure read over POST — safe to replay on 5xx/429
|
|
296
|
+
auth
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Category ↔ resource assignments. Writes default to service auth. The
|
|
301
|
+
* assignment `ref.type` is `'PRODUCT'` (per the API); category hierarchy is
|
|
302
|
+
* managed via `parentId` on the category, not via assignments.
|
|
303
|
+
*/
|
|
304
|
+
assignments = {
|
|
305
|
+
/** One page of a category's assignments. Default auth: anonymous. */
|
|
306
|
+
list: async (categoryId, params = {}, auth = ANON) => this.ctx.http.request({
|
|
307
|
+
method: "GET",
|
|
308
|
+
path: `/category/${this.ctx.tenant}/categories/${categoryId}/assignments`,
|
|
309
|
+
query: {
|
|
310
|
+
...params.pageNumber === void 0 ? {} : { pageNumber: params.pageNumber },
|
|
311
|
+
...params.pageSize === void 0 ? {} : { pageSize: params.pageSize },
|
|
312
|
+
...params.sort === void 0 ? {} : { sort: params.sort },
|
|
313
|
+
...params.expandSupercategoriesIds === void 0 ? {} : { expandSupercategoriesIds: String(params.expandSupercategoriesIds) },
|
|
314
|
+
...params.showUnpublished === void 0 ? {} : { showUnpublished: String(params.showUnpublished) }
|
|
315
|
+
},
|
|
316
|
+
auth
|
|
317
|
+
}),
|
|
318
|
+
/** Assigns a single resource to a category (`POST …/assignments`). Default auth: service. */
|
|
319
|
+
create: async (categoryId, input, auth = SERVICE) => this.ctx.http.request({
|
|
320
|
+
method: "POST",
|
|
321
|
+
path: `/category/${this.ctx.tenant}/categories/${categoryId}/assignments`,
|
|
322
|
+
body: input,
|
|
323
|
+
auth
|
|
324
|
+
}),
|
|
325
|
+
/** Bulk-assigns resources to a category (`POST …/assignments/bulk`). Default auth: service. */
|
|
326
|
+
bulkCreate: async (categoryId, input, auth = SERVICE) => this.ctx.http.request({
|
|
327
|
+
method: "POST",
|
|
328
|
+
path: `/category/${this.ctx.tenant}/categories/${categoryId}/assignments/bulk`,
|
|
329
|
+
body: input,
|
|
330
|
+
auth
|
|
331
|
+
}),
|
|
332
|
+
/** Removes one assignment by id (`DELETE …/assignments/{assignmentId}`). Default auth: service. */
|
|
333
|
+
remove: async (categoryId, assignmentId, auth = SERVICE) => {
|
|
334
|
+
await this.ctx.http.request({
|
|
335
|
+
method: "DELETE",
|
|
336
|
+
path: `/category/${this.ctx.tenant}/categories/${categoryId}/assignments/${assignmentId}`,
|
|
337
|
+
auth
|
|
338
|
+
});
|
|
339
|
+
},
|
|
340
|
+
/** Removes all of a category's assignments (`DELETE …/assignments`). Default auth: service. */
|
|
341
|
+
removeAll: async (categoryId, options = {}, auth = SERVICE) => {
|
|
342
|
+
await this.ctx.http.request({
|
|
343
|
+
method: "DELETE",
|
|
344
|
+
path: `/category/${this.ctx.tenant}/categories/${categoryId}/assignments`,
|
|
345
|
+
...options.assignmentType === void 0 ? {} : { query: { assignmentType: options.assignmentType } },
|
|
346
|
+
auth
|
|
347
|
+
});
|
|
348
|
+
},
|
|
349
|
+
/** Upserts an assignment by reference id — no body (`PUT …/assignments/references/{referenceId}`). Default auth: service. */
|
|
350
|
+
upsertByReference: async (categoryId, referenceId, auth = SERVICE) => this.ctx.http.request({
|
|
351
|
+
method: "PUT",
|
|
352
|
+
path: `/category/${this.ctx.tenant}/categories/${categoryId}/assignments/references/${referenceId}`,
|
|
353
|
+
auth
|
|
354
|
+
}),
|
|
355
|
+
/** Removes an assignment by reference id (`DELETE …/assignments/references/{referenceId}`). Default auth: service. */
|
|
356
|
+
removeByReference: async (categoryId, referenceId, auth = SERVICE) => {
|
|
357
|
+
await this.ctx.http.request({
|
|
358
|
+
method: "DELETE",
|
|
359
|
+
path: `/category/${this.ctx.tenant}/categories/${categoryId}/assignments/references/${referenceId}`,
|
|
360
|
+
auth
|
|
361
|
+
});
|
|
362
|
+
},
|
|
363
|
+
/** Bulk-upserts assignment references (`PUT …/assignments/references/bulk`). Default auth: service. */
|
|
364
|
+
bulkUpsertByReference: async (categoryId, input, auth = SERVICE) => this.ctx.http.request({
|
|
365
|
+
method: "PUT",
|
|
366
|
+
path: `/category/${this.ctx.tenant}/categories/${categoryId}/assignments/references/bulk`,
|
|
367
|
+
body: input,
|
|
368
|
+
auth
|
|
369
|
+
}),
|
|
370
|
+
/**
|
|
371
|
+
* Lists every category assigned to the given reference id — tenant-wide
|
|
372
|
+
* (`GET /assignments/references/{referenceId}`). Default auth: anonymous.
|
|
373
|
+
*/
|
|
374
|
+
listCategoriesByReference: async (referenceId, params = {}, auth = ANON) => this.ctx.http.request({
|
|
375
|
+
method: "GET",
|
|
376
|
+
path: `/category/${this.ctx.tenant}/assignments/references/${referenceId}`,
|
|
377
|
+
query: {
|
|
378
|
+
...params.pageNumber === void 0 ? {} : { pageNumber: params.pageNumber },
|
|
379
|
+
...params.pageSize === void 0 ? {} : { pageSize: params.pageSize },
|
|
380
|
+
...params.sort === void 0 ? {} : { sort: params.sort },
|
|
381
|
+
...params.showUnpublished === void 0 ? {} : { showUnpublished: String(params.showUnpublished) },
|
|
382
|
+
...params.expandSupercategoriesIds === void 0 ? {} : { expandSupercategoriesIds: String(params.expandSupercategoriesIds) }
|
|
383
|
+
},
|
|
384
|
+
auth
|
|
385
|
+
}),
|
|
386
|
+
/** Removes all assignments to a given reference id — tenant-wide (`DELETE /assignments/references/{referenceId}`). Default auth: service. */
|
|
387
|
+
removeAllByReference: async (referenceId, auth = SERVICE) => {
|
|
388
|
+
await this.ctx.http.request({
|
|
389
|
+
method: "DELETE",
|
|
390
|
+
path: `/category/${this.ctx.tenant}/assignments/references/${referenceId}`,
|
|
391
|
+
auth
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
};
|
|
177
395
|
};
|
|
178
396
|
|
|
179
397
|
exports.CategoryService = CategoryService;
|