@viu/emporix-sdk 1.0.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 +407 -0
- package/LICENSE +21 -0
- package/README.md +115 -0
- package/dist/cart.cjs +214 -0
- package/dist/cart.cjs.map +1 -0
- package/dist/cart.d.cts +1807 -0
- package/dist/cart.d.ts +1807 -0
- package/dist/cart.js +4 -0
- package/dist/cart.js.map +1 -0
- package/dist/category.cjs +97 -0
- package/dist/category.cjs.map +1 -0
- package/dist/category.d.cts +313 -0
- package/dist/category.d.ts +313 -0
- package/dist/category.js +4 -0
- package/dist/category.js.map +1 -0
- package/dist/checkout.cjs +98 -0
- package/dist/checkout.cjs.map +1 -0
- package/dist/checkout.d.cts +252 -0
- package/dist/checkout.d.ts +252 -0
- package/dist/checkout.js +4 -0
- package/dist/checkout.js.map +1 -0
- package/dist/chunk-4BJUCCKJ.js +86 -0
- package/dist/chunk-4BJUCCKJ.js.map +1 -0
- package/dist/chunk-6UNFMCHZ.js +95 -0
- package/dist/chunk-6UNFMCHZ.js.map +1 -0
- package/dist/chunk-B56JZNI7.js +49 -0
- package/dist/chunk-B56JZNI7.js.map +1 -0
- package/dist/chunk-BFQ732VZ.js +11 -0
- package/dist/chunk-BFQ732VZ.js.map +1 -0
- package/dist/chunk-F3WAQH2E.js +120 -0
- package/dist/chunk-F3WAQH2E.js.map +1 -0
- package/dist/chunk-GWJ2U2CP.js +14 -0
- package/dist/chunk-GWJ2U2CP.js.map +1 -0
- package/dist/chunk-HEO34WLO.js +47 -0
- package/dist/chunk-HEO34WLO.js.map +1 -0
- package/dist/chunk-HKPZI7Y5.js +30 -0
- package/dist/chunk-HKPZI7Y5.js.map +1 -0
- package/dist/chunk-IEZHGU7F.js +171 -0
- package/dist/chunk-IEZHGU7F.js.map +1 -0
- package/dist/chunk-KTODT6DV.js +86 -0
- package/dist/chunk-KTODT6DV.js.map +1 -0
- package/dist/chunk-NM7VDXBR.js +57 -0
- package/dist/chunk-NM7VDXBR.js.map +1 -0
- package/dist/chunk-OMYVOOSX.js +57 -0
- package/dist/chunk-OMYVOOSX.js.map +1 -0
- package/dist/chunk-QDABAMVN.js +89 -0
- package/dist/chunk-QDABAMVN.js.map +1 -0
- package/dist/chunk-RXVVFNYN.js +56 -0
- package/dist/chunk-RXVVFNYN.js.map +1 -0
- package/dist/chunk-SKX7KCMH.js +23 -0
- package/dist/chunk-SKX7KCMH.js.map +1 -0
- package/dist/chunk-TLH6SLAF.js +215 -0
- package/dist/chunk-TLH6SLAF.js.map +1 -0
- package/dist/chunk-Z6PNI5VT.js +142 -0
- package/dist/chunk-Z6PNI5VT.js.map +1 -0
- package/dist/companies.cjs +58 -0
- package/dist/companies.cjs.map +1 -0
- package/dist/companies.d.cts +31 -0
- package/dist/companies.d.ts +31 -0
- package/dist/companies.js +3 -0
- package/dist/companies.js.map +1 -0
- package/dist/contacts.cjs +51 -0
- package/dist/contacts.cjs.map +1 -0
- package/dist/contacts.d.cts +28 -0
- package/dist/contacts.d.ts +28 -0
- package/dist/contacts.js +3 -0
- package/dist/contacts.js.map +1 -0
- package/dist/context-vKgzZ-5f.d.cts +329 -0
- package/dist/context-vKgzZ-5f.d.ts +329 -0
- package/dist/customer-groups.cjs +25 -0
- package/dist/customer-groups.cjs.map +1 -0
- package/dist/customer-groups.d.cts +36 -0
- package/dist/customer-groups.d.ts +36 -0
- package/dist/customer-groups.js +3 -0
- package/dist/customer-groups.js.map +1 -0
- package/dist/customer.cjs +262 -0
- package/dist/customer.cjs.map +1 -0
- package/dist/customer.d.cts +386 -0
- package/dist/customer.d.ts +386 -0
- package/dist/customer.js +5 -0
- package/dist/customer.js.map +1 -0
- package/dist/index.cjs +2075 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +218 -0
- package/dist/index.d.ts +218 -0
- package/dist/index.js +791 -0
- package/dist/index.js.map +1 -0
- package/dist/locations.cjs +59 -0
- package/dist/locations.cjs.map +1 -0
- package/dist/locations.d.cts +30 -0
- package/dist/locations.d.ts +30 -0
- package/dist/locations.js +3 -0
- package/dist/locations.js.map +1 -0
- package/dist/media.cjs +123 -0
- package/dist/media.cjs.map +1 -0
- package/dist/media.d.cts +219 -0
- package/dist/media.d.ts +219 -0
- package/dist/media.js +3 -0
- package/dist/media.js.map +1 -0
- package/dist/orders.cjs +98 -0
- package/dist/orders.cjs.map +1 -0
- package/dist/orders.d.cts +167 -0
- package/dist/orders.d.ts +167 -0
- package/dist/orders.js +3 -0
- package/dist/orders.js.map +1 -0
- package/dist/payment.cjs +77 -0
- package/dist/payment.cjs.map +1 -0
- package/dist/payment.d.cts +110 -0
- package/dist/payment.d.ts +110 -0
- package/dist/payment.js +5 -0
- package/dist/payment.js.map +1 -0
- package/dist/price.cjs +88 -0
- package/dist/price.cjs.map +1 -0
- package/dist/price.d.cts +445 -0
- package/dist/price.d.ts +445 -0
- package/dist/price.js +4 -0
- package/dist/price.js.map +1 -0
- package/dist/product.cjs +100 -0
- package/dist/product.cjs.map +1 -0
- package/dist/product.d.cts +400 -0
- package/dist/product.d.ts +400 -0
- package/dist/product.js +4 -0
- package/dist/product.js.map +1 -0
- package/dist/segment.cjs +189 -0
- package/dist/segment.cjs.map +1 -0
- package/dist/segment.d.cts +241 -0
- package/dist/segment.d.ts +241 -0
- package/dist/segment.js +5 -0
- package/dist/segment.js.map +1 -0
- package/dist/types.gen-D1QuqPLs.d.cts +166 -0
- package/dist/types.gen-D1QuqPLs.d.ts +166 -0
- package/package.json +141 -0
package/dist/price.d.ts
ADDED
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
import { C as ClientContext, b as AuthContext } from './context-vKgzZ-5f.js';
|
|
2
|
+
|
|
3
|
+
type Metadata = {
|
|
4
|
+
/**
|
|
5
|
+
* Date and time when the price was created.
|
|
6
|
+
*/
|
|
7
|
+
createdAt?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Date and time when the price was last modified.
|
|
10
|
+
*/
|
|
11
|
+
modifiedAt?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Version of the price object. If provided optimistic locking will be enabled and it has to match version in the database
|
|
14
|
+
*/
|
|
15
|
+
version?: number;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Measurement unit for which the price is defined.
|
|
19
|
+
*/
|
|
20
|
+
type MeasurementUnit = {
|
|
21
|
+
/**
|
|
22
|
+
* Quantity of the measurement unit.
|
|
23
|
+
*/
|
|
24
|
+
quantity: number;
|
|
25
|
+
/**
|
|
26
|
+
* Code of the measurement unit.
|
|
27
|
+
*/
|
|
28
|
+
unitCode: 'kg' | 'g' | 'mg' | 'l' | 'ml' | 'lb' | 'qt' | 'qtr' | 'gal' | 'pt' | 'oz' | 'MTR' | 'XRO' | 'MLT' | 'LTR' | 'H87' | 'KGM' | 'GRM' | 'HLT' | 'DL' | 'DAG' | 'RO';
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Measurement unit for which the price is defined.
|
|
32
|
+
*/
|
|
33
|
+
type MeasurementUnitV2 = {
|
|
34
|
+
/**
|
|
35
|
+
* Quantity of the measurement unit.
|
|
36
|
+
*/
|
|
37
|
+
quantity: number;
|
|
38
|
+
/**
|
|
39
|
+
* Code of the measurement unit, as defined in the Unit Handling Service.
|
|
40
|
+
*/
|
|
41
|
+
unitCode: string;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Measurement unit for which the price is defined.
|
|
45
|
+
*/
|
|
46
|
+
type MatchMeasurementUnitV2 = {
|
|
47
|
+
/**
|
|
48
|
+
* Quantity of the measurement unit.
|
|
49
|
+
*/
|
|
50
|
+
quantity: number;
|
|
51
|
+
/**
|
|
52
|
+
* Code of the measurement unit, as defined in the Unit Handling Service. This attribute is optional, if not provided the price model unit will be used.
|
|
53
|
+
*/
|
|
54
|
+
unitCode?: string;
|
|
55
|
+
};
|
|
56
|
+
type SalePrice = {
|
|
57
|
+
/**
|
|
58
|
+
* Discount expressed as a fixed amount.
|
|
59
|
+
*/
|
|
60
|
+
discountAmount?: number;
|
|
61
|
+
/**
|
|
62
|
+
* Discount expressed as a percentage of the original price.
|
|
63
|
+
*/
|
|
64
|
+
discountRate?: number;
|
|
65
|
+
/**
|
|
66
|
+
* Additional information about the discount.
|
|
67
|
+
*/
|
|
68
|
+
description?: string;
|
|
69
|
+
};
|
|
70
|
+
type MatchByContext = {
|
|
71
|
+
/**
|
|
72
|
+
* List of items (products or prices) for which the prices should be matched.
|
|
73
|
+
*/
|
|
74
|
+
items?: Array<{
|
|
75
|
+
/**
|
|
76
|
+
* Product or price for which a price should be matched.
|
|
77
|
+
*/
|
|
78
|
+
itemId?: {
|
|
79
|
+
/**
|
|
80
|
+
* Type of the referenced item. Possible values:
|
|
81
|
+
* * `PRODUCT`
|
|
82
|
+
* * `PRICE`
|
|
83
|
+
* * `SKU`
|
|
84
|
+
*
|
|
85
|
+
* **Note**: The `SKU` value is a `preview` value - the system does not fully operate on the SKU concept yet.
|
|
86
|
+
*/
|
|
87
|
+
itemType?: string;
|
|
88
|
+
/**
|
|
89
|
+
* Item's unique identifier, generated when the item is created.
|
|
90
|
+
*/
|
|
91
|
+
id?: string;
|
|
92
|
+
};
|
|
93
|
+
quantity?: MatchMeasurementUnitV2;
|
|
94
|
+
}>;
|
|
95
|
+
};
|
|
96
|
+
type Match = {
|
|
97
|
+
/**
|
|
98
|
+
* Code of the currency in which the prices should be matched, as defined in the Currency Service.
|
|
99
|
+
*
|
|
100
|
+
* **Note**: If the matched price is defined in another currency, a currency exchange algorithm will be used, but only if exchange rates between the two currencies have been defined.
|
|
101
|
+
*/
|
|
102
|
+
targetCurrency: string;
|
|
103
|
+
/**
|
|
104
|
+
* Code of the site to which the matched prices should apply.
|
|
105
|
+
*/
|
|
106
|
+
siteCode: string;
|
|
107
|
+
targetLocation: {
|
|
108
|
+
/**
|
|
109
|
+
* Code of the country for which the prices should be matched, as defined in the Country Service.
|
|
110
|
+
*
|
|
111
|
+
* **Note**: If the matched price is defined for another country, a tax calculation algorithm will be used, but only if tax classes for the two countries have been defined for relevant products.
|
|
112
|
+
*/
|
|
113
|
+
countryCode: string;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* List of items (products or prices) for which the prices should be matched.
|
|
117
|
+
*/
|
|
118
|
+
items: Array<{
|
|
119
|
+
/**
|
|
120
|
+
* Product or price for which a price should be matched.
|
|
121
|
+
*/
|
|
122
|
+
itemId?: {
|
|
123
|
+
/**
|
|
124
|
+
* Type of the referenced item. Possible values:
|
|
125
|
+
* * `PRODUCT`
|
|
126
|
+
* * `PRICE`
|
|
127
|
+
* * `SKU`
|
|
128
|
+
*
|
|
129
|
+
* **Note**: The `SKU` value is a `preview` value - the system does not fully operate on the SKU concept yet.
|
|
130
|
+
*/
|
|
131
|
+
itemType: string;
|
|
132
|
+
/**
|
|
133
|
+
* Item's unique identifier, generated when the item is created.
|
|
134
|
+
*/
|
|
135
|
+
id: string;
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* Quantity of the product for which a matched price should be calculated.
|
|
139
|
+
*/
|
|
140
|
+
quantity: {
|
|
141
|
+
/**
|
|
142
|
+
* Quantity of the product, expressed as a number.
|
|
143
|
+
*/
|
|
144
|
+
quantity: number;
|
|
145
|
+
/**
|
|
146
|
+
* Code of the measurement unit, as defined in the Unit Handling Service. This atribute is optional, if not provided the price model unit will be used.
|
|
147
|
+
*/
|
|
148
|
+
unitCode?: string;
|
|
149
|
+
};
|
|
150
|
+
}>;
|
|
151
|
+
/**
|
|
152
|
+
* Customer or customer group for whom the matched prices should be valid.
|
|
153
|
+
*/
|
|
154
|
+
principal?: {
|
|
155
|
+
/**
|
|
156
|
+
* Unique identifier of the customer or customer group.
|
|
157
|
+
*/
|
|
158
|
+
id?: string;
|
|
159
|
+
/**
|
|
160
|
+
* Customer or customer group for whom the matched should be valid. Possible values:
|
|
161
|
+
* * `CUSTOMER`
|
|
162
|
+
* * `GROUP`
|
|
163
|
+
*
|
|
164
|
+
* **Note**: The `GROUP` value is a `preview` value - the system does not fully operate on the customer groups concept yet.
|
|
165
|
+
*/
|
|
166
|
+
type?: string;
|
|
167
|
+
};
|
|
168
|
+
/**
|
|
169
|
+
* If no price that matches the criteria is found for the specified site, the price matching functionality will try to find the best price for the `main` site. To enable this option, this field needs to be set to `true`.
|
|
170
|
+
*
|
|
171
|
+
* **Note**: Using the fallback mechanism may impact the performance as the price matching has to run a second time. If the fallback mechanism is used, the response's `siteCode` field will be set to `main`.
|
|
172
|
+
*/
|
|
173
|
+
useFallback?: boolean;
|
|
174
|
+
/**
|
|
175
|
+
* Legal entity for which price lists are included in the price match.
|
|
176
|
+
* **Note**: Price lists for the entity's parent legal entities are also included.
|
|
177
|
+
*/
|
|
178
|
+
legalEntityId?: string;
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* Price model holds additional attributes that are extending price. For example it's possible to define a price which will be specific for a given customer or customer group.
|
|
182
|
+
*
|
|
183
|
+
*/
|
|
184
|
+
type PriceModelRetrieval = {
|
|
185
|
+
/**
|
|
186
|
+
* Price model's unique identifier, generated when the price model is created.
|
|
187
|
+
*
|
|
188
|
+
*/
|
|
189
|
+
id?: string;
|
|
190
|
+
name?: {
|
|
191
|
+
[key: string]: unknown;
|
|
192
|
+
} | string;
|
|
193
|
+
description?: {
|
|
194
|
+
[key: string]: unknown;
|
|
195
|
+
} | string;
|
|
196
|
+
/**
|
|
197
|
+
* Flag indicating whether prices assigned to the price model are expressed as net or gross.
|
|
198
|
+
*
|
|
199
|
+
* | Value | Description |
|
|
200
|
+
* | --- | --- |
|
|
201
|
+
* | `true` | Prices are expressed as gross values. |
|
|
202
|
+
* | `false` | Prices are expressed as net values. |
|
|
203
|
+
*
|
|
204
|
+
*/
|
|
205
|
+
includesTax?: boolean;
|
|
206
|
+
/**
|
|
207
|
+
* Flag indicating whether prices assigned to the price model include markup.
|
|
208
|
+
*
|
|
209
|
+
* **Note**: This is a **preview** field.
|
|
210
|
+
*
|
|
211
|
+
*/
|
|
212
|
+
includesMarkup?: boolean;
|
|
213
|
+
measurementUnit?: MeasurementUnitV2;
|
|
214
|
+
tierDefinition?: {
|
|
215
|
+
/**
|
|
216
|
+
* If the price is created based on a price model (the `priceModelId` is provided, the field should stay null. Otherwise the provided value will override a value from price model.
|
|
217
|
+
*
|
|
218
|
+
* Possible values:
|
|
219
|
+
* * `BASIC`
|
|
220
|
+
* * `VOLUME`
|
|
221
|
+
* * `TIERED`
|
|
222
|
+
*
|
|
223
|
+
* `BASIC`: Used to offer the same price per unit, regardless of the ordered quantity.
|
|
224
|
+
*
|
|
225
|
+
* **Note**: When using basic pricing, you need to define a single tier and set its `minQuantity` field to `0`.
|
|
226
|
+
*
|
|
227
|
+
* `VOLUME`: Used to offer a lower price per unit depending on the total ordered quantity.
|
|
228
|
+
*
|
|
229
|
+
* `TIERED`: Used to offer a lower price per unit based on the tiers that the total ordered quantity falls into.
|
|
230
|
+
*
|
|
231
|
+
* **Example**: You defined three tiers, starting at 5, 10, and 15 pieces respectively. A customer orders 16 pieces. In this pricing model, the first 5 pieces will be priced according to the first tier, the next 5 according to the second tier, and the 16th piece will be priced according to the third tier.
|
|
232
|
+
*/
|
|
233
|
+
tierType?: string;
|
|
234
|
+
tiers?: Array<{
|
|
235
|
+
minQuantity?: MeasurementUnit;
|
|
236
|
+
/**
|
|
237
|
+
* Identifier of a given tier.
|
|
238
|
+
*/
|
|
239
|
+
id?: string;
|
|
240
|
+
}>;
|
|
241
|
+
};
|
|
242
|
+
/**
|
|
243
|
+
* Indicates if the price model is a default price model.
|
|
244
|
+
*/
|
|
245
|
+
isDefault?: boolean;
|
|
246
|
+
metadata?: Metadata;
|
|
247
|
+
};
|
|
248
|
+
type MatchResponse = {
|
|
249
|
+
/**
|
|
250
|
+
* Price's unique identifier, generated when the price is created.
|
|
251
|
+
*
|
|
252
|
+
*/
|
|
253
|
+
priceId?: string;
|
|
254
|
+
/**
|
|
255
|
+
* Price list's unique identifier. The property is populated only in case when the return price belongs to any price list.
|
|
256
|
+
*
|
|
257
|
+
*/
|
|
258
|
+
priceListId?: string;
|
|
259
|
+
/**
|
|
260
|
+
* Item (product or price) for which the price was matched.
|
|
261
|
+
*/
|
|
262
|
+
itemRef?: {
|
|
263
|
+
/**
|
|
264
|
+
* Type of the retrieved item. Possible values:
|
|
265
|
+
* * `PRODUCT`
|
|
266
|
+
* * `SKU`
|
|
267
|
+
*
|
|
268
|
+
* **Note**: The `SKU` value is a `preview` value - the system does not fully operate on the SKU concept yet.
|
|
269
|
+
*/
|
|
270
|
+
itemType?: string;
|
|
271
|
+
/**
|
|
272
|
+
* Item's unique identifier, generated when the item is created.
|
|
273
|
+
*
|
|
274
|
+
*/
|
|
275
|
+
id?: string;
|
|
276
|
+
};
|
|
277
|
+
/**
|
|
278
|
+
* Site to which the matched price applies.
|
|
279
|
+
*/
|
|
280
|
+
site?: {
|
|
281
|
+
/**
|
|
282
|
+
* Code of the site to which the matched price applies.
|
|
283
|
+
*/
|
|
284
|
+
code?: string;
|
|
285
|
+
/**
|
|
286
|
+
* Flag indicating whether prices assigned to the site are expressed as net or gross.
|
|
287
|
+
*
|
|
288
|
+
* | Value | Description |
|
|
289
|
+
* | --- | --- |
|
|
290
|
+
* | `true` | Prices are expressed as gross values. |
|
|
291
|
+
* | `false` | Prices are expressed as net values. |
|
|
292
|
+
*
|
|
293
|
+
* **Note**: If not specified, the retrieved price is net or gross depending on the `includesTax` field in the price's model.
|
|
294
|
+
*/
|
|
295
|
+
includesTax?: boolean;
|
|
296
|
+
};
|
|
297
|
+
/**
|
|
298
|
+
* Currency related to the price.
|
|
299
|
+
*/
|
|
300
|
+
currency?: string;
|
|
301
|
+
/**
|
|
302
|
+
* Location for which the matched price is defined.
|
|
303
|
+
*/
|
|
304
|
+
location?: {
|
|
305
|
+
/**
|
|
306
|
+
* Code of the country to which the matched price applies.
|
|
307
|
+
*/
|
|
308
|
+
countryCode?: string;
|
|
309
|
+
};
|
|
310
|
+
/**
|
|
311
|
+
* Represents an original value without any discounts for a single unit of the requested item (PRODUCT or SKU). The value is a gross price (if includesTax is true) or net price (if includesTax is false).
|
|
312
|
+
*
|
|
313
|
+
* It's worth to mention that the cent part is not limited just to two digits. For example, if the price is for one piece of screw, it could look like this: 0.0000317
|
|
314
|
+
*/
|
|
315
|
+
originalValue?: number;
|
|
316
|
+
/**
|
|
317
|
+
* Represents a value with a discount (if applicable) for a single unit of the requested item (PRODUCT or SKU). The value is a gross price (if includesTax is true) or net price (if includesTax is false).
|
|
318
|
+
*
|
|
319
|
+
* It's worth to mention that the cent part is not limited just to two digits. For example, if the price is for one piece of screw, it could look like this: 0.0000317
|
|
320
|
+
*/
|
|
321
|
+
effectiveValue?: number;
|
|
322
|
+
/**
|
|
323
|
+
* Represents a total value with a discount (if applicable) for all units of the requested item (PRODUCT or SKU). The value is a gross price (if includesTax is true) or net price (if includesTax is false).
|
|
324
|
+
*
|
|
325
|
+
* It's worth to mention that the cent part is not limited just to two digits. For example, if the price is for one piece of screw, it could look like this: 0.0000317
|
|
326
|
+
*/
|
|
327
|
+
totalValue?: number;
|
|
328
|
+
quantity?: MeasurementUnitV2;
|
|
329
|
+
salePrice?: SalePrice;
|
|
330
|
+
/**
|
|
331
|
+
* Flag indicating whether prices assigned to the price model are expressed as net or gross.
|
|
332
|
+
*
|
|
333
|
+
* | Value | Description |
|
|
334
|
+
* | --- | --- |
|
|
335
|
+
* | `true` | Prices are expressed as gross values. |
|
|
336
|
+
* | `false` | Prices are expressed as net values. |
|
|
337
|
+
*/
|
|
338
|
+
includesTax?: boolean;
|
|
339
|
+
priceModel?: PriceModelRetrieval;
|
|
340
|
+
/**
|
|
341
|
+
* Sales tax applicable to the product.
|
|
342
|
+
*/
|
|
343
|
+
tax?: {
|
|
344
|
+
/**
|
|
345
|
+
* Tax class's code, as defined in the Tax Service.
|
|
346
|
+
*
|
|
347
|
+
*/
|
|
348
|
+
taxClass?: string;
|
|
349
|
+
/**
|
|
350
|
+
* Tax rate expressed as a number.
|
|
351
|
+
*/
|
|
352
|
+
taxRate?: number;
|
|
353
|
+
/**
|
|
354
|
+
* Tax details containing all prices with tax.
|
|
355
|
+
*/
|
|
356
|
+
prices?: {
|
|
357
|
+
/**
|
|
358
|
+
* Original price with taxes.
|
|
359
|
+
*/
|
|
360
|
+
originalValue?: {
|
|
361
|
+
netValue?: number;
|
|
362
|
+
grossValue?: number;
|
|
363
|
+
taxValue?: number;
|
|
364
|
+
};
|
|
365
|
+
/**
|
|
366
|
+
* Effective price with taxes.
|
|
367
|
+
*/
|
|
368
|
+
effectiveValue?: {
|
|
369
|
+
netValue?: number;
|
|
370
|
+
grossValue?: number;
|
|
371
|
+
taxValue?: number;
|
|
372
|
+
};
|
|
373
|
+
/**
|
|
374
|
+
* Total price with taxes.
|
|
375
|
+
*/
|
|
376
|
+
totalValue?: {
|
|
377
|
+
netValue?: number;
|
|
378
|
+
grossValue?: number;
|
|
379
|
+
taxValue?: number;
|
|
380
|
+
};
|
|
381
|
+
};
|
|
382
|
+
};
|
|
383
|
+
/**
|
|
384
|
+
* Custom price attributes.
|
|
385
|
+
*/
|
|
386
|
+
mixins?: {
|
|
387
|
+
[key: string]: unknown;
|
|
388
|
+
};
|
|
389
|
+
metadata?: {
|
|
390
|
+
/**
|
|
391
|
+
* Version of the price object.
|
|
392
|
+
*/
|
|
393
|
+
version?: string;
|
|
394
|
+
/**
|
|
395
|
+
* Date and time when the matched price was created.
|
|
396
|
+
*/
|
|
397
|
+
createdAt?: string;
|
|
398
|
+
/**
|
|
399
|
+
* Date and time when the matched price was last modified.
|
|
400
|
+
*/
|
|
401
|
+
modifiedAt?: string;
|
|
402
|
+
};
|
|
403
|
+
/**
|
|
404
|
+
* A price tiers values for a matched price
|
|
405
|
+
*/
|
|
406
|
+
tierValues?: Array<{
|
|
407
|
+
/**
|
|
408
|
+
* Identifier of a tier
|
|
409
|
+
*/
|
|
410
|
+
id?: string;
|
|
411
|
+
/**
|
|
412
|
+
* A price value for a particular tier
|
|
413
|
+
*/
|
|
414
|
+
priceValue?: number;
|
|
415
|
+
}>;
|
|
416
|
+
};
|
|
417
|
+
|
|
418
|
+
/** Session-context match request body (generated). */
|
|
419
|
+
type PriceMatchByContextInput = MatchByContext;
|
|
420
|
+
/** Explicit-context match request body (generated). */
|
|
421
|
+
type PriceMatchInput = Match;
|
|
422
|
+
/** A resolved price (full generated match-response schema). */
|
|
423
|
+
type PriceMatch = MatchResponse;
|
|
424
|
+
/**
|
|
425
|
+
* Price matching. The Cart service does not resolve prices — call this
|
|
426
|
+
* explicitly before rendering money and again right before placing an order.
|
|
427
|
+
* The SDK is stateless: it never caches or revalidates prices.
|
|
428
|
+
*/
|
|
429
|
+
declare class PriceService {
|
|
430
|
+
private readonly ctx;
|
|
431
|
+
constructor(ctx: ClientContext);
|
|
432
|
+
/**
|
|
433
|
+
* Resolves prices using the session context bound to the bearer token
|
|
434
|
+
* (currency/site/country were set at anonymous-login time). Default auth:
|
|
435
|
+
* anonymous; pass a customer/raw context for personalized pricing.
|
|
436
|
+
*/
|
|
437
|
+
matchByContext(input: PriceMatchByContextInput, auth?: AuthContext): Promise<PriceMatch[]>;
|
|
438
|
+
/**
|
|
439
|
+
* Resolves prices from an explicit context. Default auth: service
|
|
440
|
+
* (requires `price.price_read` / `price.price_manage`).
|
|
441
|
+
*/
|
|
442
|
+
match(input: PriceMatchInput, auth?: AuthContext): Promise<PriceMatch[]>;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
export { type PriceMatch, type PriceMatchByContextInput, type PriceMatchInput, PriceService };
|
package/dist/price.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"price.js"}
|
package/dist/product.cjs
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/core/context.ts
|
|
4
|
+
async function* iterateAll(fetchPage, start = 1) {
|
|
5
|
+
let p = start;
|
|
6
|
+
for (; ; ) {
|
|
7
|
+
const page = await fetchPage(p);
|
|
8
|
+
for (const it of page.items) yield it;
|
|
9
|
+
if (!page.hasNextPage) return;
|
|
10
|
+
p += 1;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// src/services/product.ts
|
|
15
|
+
var ANON = { kind: "anonymous" };
|
|
16
|
+
var ProductService = class {
|
|
17
|
+
constructor(ctx) {
|
|
18
|
+
this.ctx = ctx;
|
|
19
|
+
}
|
|
20
|
+
ctx;
|
|
21
|
+
/** Fetches one product by id. */
|
|
22
|
+
async get(productId, _opts, auth = ANON) {
|
|
23
|
+
return this.ctx.http.request({
|
|
24
|
+
method: "GET",
|
|
25
|
+
path: `/product/${this.ctx.tenant}/products/${productId}`,
|
|
26
|
+
auth
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
/** Fetches one product by its code. */
|
|
30
|
+
async getByCode(code, auth = ANON) {
|
|
31
|
+
const rows = await this.ctx.http.request({
|
|
32
|
+
method: "GET",
|
|
33
|
+
path: `/product/${this.ctx.tenant}/products`,
|
|
34
|
+
query: { q: `code:${code}` },
|
|
35
|
+
auth
|
|
36
|
+
});
|
|
37
|
+
const first = rows[0];
|
|
38
|
+
if (!first) throw new Error(`No product with code "${code}"`);
|
|
39
|
+
return first;
|
|
40
|
+
}
|
|
41
|
+
/** One page of products. */
|
|
42
|
+
async list(params = {}, auth = ANON) {
|
|
43
|
+
const pageNumber = params.pageNumber ?? 1;
|
|
44
|
+
const pageSize = params.pageSize ?? 50;
|
|
45
|
+
const items = await this.ctx.http.request({
|
|
46
|
+
method: "GET",
|
|
47
|
+
path: `/product/${this.ctx.tenant}/products`,
|
|
48
|
+
query: { pageNumber, pageSize },
|
|
49
|
+
auth
|
|
50
|
+
});
|
|
51
|
+
return { items, pageNumber, pageSize, hasNextPage: items.length === pageSize };
|
|
52
|
+
}
|
|
53
|
+
/** Async-iterates every product across pages. */
|
|
54
|
+
listAll(params = {}, auth = ANON) {
|
|
55
|
+
const pageSize = params.pageSize ?? 50;
|
|
56
|
+
return iterateAll((pageNumber) => this.list({ pageNumber, pageSize }, auth));
|
|
57
|
+
}
|
|
58
|
+
/** Searches products by free-text query. */
|
|
59
|
+
async search(query, params = {}, auth = ANON) {
|
|
60
|
+
const pageNumber = params.pageNumber ?? 1;
|
|
61
|
+
const pageSize = params.pageSize ?? 50;
|
|
62
|
+
const items = await this.ctx.http.request({
|
|
63
|
+
method: "GET",
|
|
64
|
+
path: `/product/${this.ctx.tenant}/products`,
|
|
65
|
+
query: { q: query, pageNumber, pageSize },
|
|
66
|
+
auth
|
|
67
|
+
});
|
|
68
|
+
return { items, pageNumber, pageSize, hasNextPage: items.length === pageSize };
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Bulk fetch by id. POSTs `/products/search` with `q="id:(id1,id2,…)"`,
|
|
72
|
+
* chunking when the list is larger than `options.chunkSize` (default
|
|
73
|
+
* 100). An empty list short-circuits with no HTTP call. **Order is not
|
|
74
|
+
* guaranteed** across chunks — re-index by `id` if order matters.
|
|
75
|
+
*/
|
|
76
|
+
async searchByIds(ids, options = {}, auth = ANON) {
|
|
77
|
+
if (ids.length === 0) return [];
|
|
78
|
+
const chunkSize = options.chunkSize ?? 100;
|
|
79
|
+
const chunks = [];
|
|
80
|
+
for (let i = 0; i < ids.length; i += chunkSize) {
|
|
81
|
+
chunks.push(ids.slice(i, i + chunkSize));
|
|
82
|
+
}
|
|
83
|
+
const pages = await Promise.all(
|
|
84
|
+
chunks.map(
|
|
85
|
+
(chunk) => this.ctx.http.request({
|
|
86
|
+
method: "POST",
|
|
87
|
+
path: `/product/${this.ctx.tenant}/products/search`,
|
|
88
|
+
query: { pageSize: chunk.length },
|
|
89
|
+
auth,
|
|
90
|
+
body: { q: `id:(${chunk.join(",")})` }
|
|
91
|
+
})
|
|
92
|
+
)
|
|
93
|
+
);
|
|
94
|
+
return pages.flat();
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
exports.ProductService = ProductService;
|
|
99
|
+
//# sourceMappingURL=product.cjs.map
|
|
100
|
+
//# sourceMappingURL=product.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/context.ts","../src/services/product.ts"],"names":[],"mappings":";;;AAkCA,gBAAuB,UAAA,CACrB,SAAA,EACA,KAAA,GAAQ,CAAA,EACU;AAClB,EAAA,IAAI,CAAA,GAAI,KAAA;AACR,EAAA,WAAS;AACP,IAAA,MAAM,IAAA,GAAO,MAAM,SAAA,CAAU,CAAC,CAAA;AAC9B,IAAA,KAAA,MAAW,EAAA,IAAM,IAAA,CAAK,KAAA,EAAO,MAAM,EAAA;AACnC,IAAA,IAAI,CAAC,KAAK,WAAA,EAAa;AACvB,IAAA,CAAA,IAAK,CAAA;AAAA,EACP;AACF;;;ACnCA,IAAM,IAAA,GAAoB,EAAE,IAAA,EAAM,WAAA,EAAY;AASvC,IAAM,iBAAN,MAAqB;AAAA,EAC1B,YAA6B,GAAA,EAAoB;AAApB,IAAA,IAAA,CAAA,GAAA,GAAA,GAAA;AAAA,EAAqB;AAAA,EAArB,GAAA;AAAA;AAAA,EAG7B,MAAM,GAAA,CACJ,SAAA,EACA,KAAA,EACA,OAAoB,IAAA,EACF;AAClB,IAAA,OAAO,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAAiB;AAAA,MACpC,MAAA,EAAQ,KAAA;AAAA,MACR,MAAM,CAAA,SAAA,EAAY,IAAA,CAAK,GAAA,CAAI,MAAM,aAAa,SAAS,CAAA,CAAA;AAAA,MACvD;AAAA,KACD,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,SAAA,CAAU,IAAA,EAAc,IAAA,GAAoB,IAAA,EAAwB;AACxE,IAAA,MAAM,IAAA,GAAO,MAAM,IAAA,CAAK,GAAA,CAAI,KAAK,OAAA,CAAmB;AAAA,MAClD,MAAA,EAAQ,KAAA;AAAA,MACR,IAAA,EAAM,CAAA,SAAA,EAAY,IAAA,CAAK,GAAA,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AAAA,UACR,IAAA,EAAM,CAAA,SAAA,EAAY,IAAA,CAAK,GAAA,CAAI,MAAM,CAAA,gBAAA,CAAA;AAAA,UACjC,KAAA,EAAO,EAAE,QAAA,EAAU,KAAA,CAAM,MAAA,EAAO;AAAA,UAChC,IAAA;AAAA,UACA,IAAA,EAAM,EAAE,CAAA,EAAG,CAAA,IAAA,EAAO,MAAM,IAAA,CAAK,GAAG,CAAC,CAAA,CAAA,CAAA;AAAI,SACtC;AAAA;AACH,KACF;AACA,IAAA,OAAO,MAAM,IAAA,EAAK;AAAA,EACpB;AAEF","file":"product.cjs","sourcesContent":["import type { HttpClient } from \"./http\";\nimport type { TokenProvider, AuthContext } from \"./auth\";\nimport type { Logger } from \"./logger\";\n\n/** Shared dependencies every service facade receives. */\nexport interface ClientContext {\n tenant: string;\n http: HttpClient;\n tokenProvider: TokenProvider;\n logger: Logger;\n}\n\n/**\n * A cursor-paged collection — `pageNumber`/`pageSize` indexing with a\n * `hasNextPage` signal driven by the source page being full. Used by all\n * paginated services and hooks across the SDK.\n */\nexport interface PaginatedItems<T> {\n items: T[];\n pageNumber: number;\n pageSize: number;\n hasNextPage: boolean;\n}\n\n/** Default `AuthContext` applied by a service when the caller passes none. */\nexport type DefaultAuth = AuthContext | undefined;\n\n/**\n * Async-iterates every item across pages of a `PaginatedItems<T>` source.\n * Stops when the source reports `hasNextPage: false`.\n *\n * @param fetchPage - given a 1-based page number, returns the page.\n * @param start - first page to fetch (default `1`).\n */\nexport async function* iterateAll<T>(\n fetchPage: (pageNumber: number) => Promise<PaginatedItems<T>>,\n start = 1,\n): AsyncIterable<T> {\n let p = start;\n for (;;) {\n const page = await fetchPage(p);\n for (const it of page.items) yield it;\n if (!page.hasNextPage) return;\n p += 1;\n }\n}\n\n","import type { ClientContext, PaginatedItems } from \"../core/context\";\nimport { iterateAll } from \"../core/context\";\nimport type { AuthContext } from \"../core/auth\";\nimport type {\n BasicProductWithId,\n BundleProductWithId,\n ParentVariantProductWithId,\n ProductMedia,\n} from \"../generated/product\";\n\nconst ANON: AuthContext = { kind: \"anonymous\" };\n\n/** A product as returned by the Product service (all generated fields). */\nexport type Product = BasicProductWithId | BundleProductWithId | ParentVariantProductWithId;\n\n/** A single product media entry (generated; `ProductMedia` is the list type). */\nexport type Media = ProductMedia[number];\n\n/** Catalog reads. Default auth: anonymous; pass customer for personalized pricing. */\nexport class ProductService {\n constructor(private readonly ctx: ClientContext) {}\n\n /** Fetches one product by id. */\n async get(\n productId: string,\n _opts?: Record<string, never>,\n auth: AuthContext = ANON,\n ): Promise<Product> {\n return this.ctx.http.request<Product>({\n method: \"GET\",\n path: `/product/${this.ctx.tenant}/products/${productId}`,\n auth,\n });\n }\n\n /** Fetches one product by its code. */\n async getByCode(code: string, auth: AuthContext = ANON): Promise<Product> {\n const rows = await this.ctx.http.request<Product[]>({\n method: \"GET\",\n path: `/product/${this.ctx.tenant}/products`,\n query: { q: `code:${code}` },\n auth,\n });\n const first = rows[0];\n if (!first) throw new Error(`No product with code \"${code}\"`);\n return first;\n }\n\n /** One page of products. */\n async list(\n params: { pageNumber?: number; pageSize?: number } = {},\n auth: AuthContext = ANON,\n ): Promise<PaginatedItems<Product>> {\n const pageNumber = params.pageNumber ?? 1;\n const pageSize = params.pageSize ?? 50;\n const items = await this.ctx.http.request<Product[]>({\n method: \"GET\",\n path: `/product/${this.ctx.tenant}/products`,\n query: { pageNumber, pageSize },\n auth,\n });\n return { items, pageNumber, pageSize, hasNextPage: items.length === pageSize };\n }\n\n /** Async-iterates every product across pages. */\n listAll(params: { pageSize?: number } = {}, auth: AuthContext = ANON): AsyncIterable<Product> {\n const pageSize = params.pageSize ?? 50;\n return iterateAll<Product>((pageNumber) => this.list({ pageNumber, pageSize }, auth));\n }\n\n /** Searches products by free-text query. */\n async search(\n query: string,\n params: { pageNumber?: number; pageSize?: number } = {},\n auth: AuthContext = ANON,\n ): Promise<PaginatedItems<Product>> {\n const pageNumber = params.pageNumber ?? 1;\n const pageSize = params.pageSize ?? 50;\n const items = await this.ctx.http.request<Product[]>({\n method: \"GET\",\n path: `/product/${this.ctx.tenant}/products`,\n query: { q: query, pageNumber, pageSize },\n auth,\n });\n return { items, pageNumber, pageSize, hasNextPage: items.length === pageSize };\n }\n\n /**\n * Bulk fetch by id. POSTs `/products/search` with `q=\"id:(id1,id2,…)\"`,\n * chunking when the list is larger than `options.chunkSize` (default\n * 100). An empty list short-circuits with no HTTP call. **Order is not\n * guaranteed** across chunks — re-index by `id` if order matters.\n */\n async searchByIds(\n ids: string[],\n options: { chunkSize?: number } = {},\n auth: AuthContext = ANON,\n ): Promise<Product[]> {\n if (ids.length === 0) return [];\n const chunkSize = options.chunkSize ?? 100;\n const chunks: string[][] = [];\n for (let i = 0; i < ids.length; i += chunkSize) {\n chunks.push(ids.slice(i, i + chunkSize));\n }\n const pages = await Promise.all(\n chunks.map((chunk) =>\n this.ctx.http.request<Product[]>({\n method: \"POST\",\n path: `/product/${this.ctx.tenant}/products/search`,\n query: { pageSize: chunk.length },\n auth,\n body: { q: `id:(${chunk.join(\",\")})` },\n }),\n ),\n );\n return pages.flat();\n }\n\n}\n"]}
|