@cobrastyle/adapter-magento2 1.0.1

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.
@@ -0,0 +1,495 @@
1
+ import { applySuffix, buildCategoryUrl, joinSegments } from './urls';
2
+ // Product Mappers
3
+ export const mapPrice = (priceData, tiers) => {
4
+ const mappedTiers = (tiers ?? [])
5
+ .map((tier) => ({
6
+ quantity: tier.quantity,
7
+ final: tier.final_price.value,
8
+ currency: tier.final_price.currency,
9
+ discount: tier.discount && tier.discount.amount_off > 0
10
+ ? { amount: tier.discount.amount_off, percent: tier.discount.percent_off }
11
+ : undefined,
12
+ }))
13
+ .sort((a, b) => a.quantity - b.quantity);
14
+ return {
15
+ regular: priceData.regular_price.value,
16
+ final: priceData.final_price.value,
17
+ currency: priceData.regular_price.currency,
18
+ // Only include discount if there's an actual discount amount
19
+ discount: priceData.discount && priceData.discount.amount_off > 0
20
+ ? {
21
+ amount: priceData.discount.amount_off,
22
+ percent: priceData.discount.percent_off,
23
+ }
24
+ : undefined,
25
+ // Omit the field entirely when there are no tiers, so consumers can rely
26
+ // on `price.tiers?.length` as a "has volume pricing" check.
27
+ tiers: mappedTiers.length > 0 ? mappedTiers : undefined,
28
+ };
29
+ };
30
+ export const mapImages = (mediaGallery) => (mediaGallery ?? []).map((img, index) => ({
31
+ url: img.url,
32
+ label: img.label,
33
+ position: img.position ?? index,
34
+ isMain: index === 0,
35
+ }));
36
+ export const mapStock = (stockStatus) => ({
37
+ inStock: stockStatus === 'IN_STOCK',
38
+ });
39
+ // Maps a product's category references to link-ready CategoryReferences.
40
+ // The URL is built from the category's breadcrumb chain (ancestor url_keys,
41
+ // ordered by level) + its own url_key + the category suffix — never from the
42
+ // possibly-stale url_path. `categorySuffix` is storeConfig.category_url_suffix.
43
+ export const mapCategories = (categories, categorySuffix = '') => (categories ?? []).map((cat) => {
44
+ const ancestors = (cat.breadcrumbs ?? [])
45
+ .slice()
46
+ .sort((a, b) => (a.category_level ?? 0) - (b.category_level ?? 0))
47
+ .map((b) => b.category_url_key);
48
+ return {
49
+ id: cat.id,
50
+ name: cat.name,
51
+ urlKey: buildCategoryUrl(ancestors, cat.url_key, categorySuffix),
52
+ };
53
+ });
54
+ export const mapConfigurableOptions = (options) => (options ?? []).map((opt) => ({
55
+ id: opt.id,
56
+ attributeCode: opt.attribute_code,
57
+ label: opt.label,
58
+ values: opt.values.map((val) => {
59
+ // Only create swatch for ColorSwatchData type (hex colors)
60
+ // TextSwatchData and ImageSwatchData should render as text buttons
61
+ const isColorSwatch = val.swatch_data?.__typename === 'ColorSwatchData';
62
+ return {
63
+ id: val.uid,
64
+ label: val.label,
65
+ value: val.uid,
66
+ swatch: isColorSwatch ? { type: 'color', value: val.swatch_data.value } : undefined,
67
+ };
68
+ }),
69
+ }));
70
+ export const mapVariants = (variants) => (variants ?? []).map((v) => ({
71
+ id: v.product.id,
72
+ sku: v.product.sku,
73
+ name: v.product.name,
74
+ price: mapPrice(v.product.price_range.minimum_price),
75
+ stock: mapStock(v.product.stock_status),
76
+ attributes: v.attributes.map((attr) => ({
77
+ code: attr.code,
78
+ label: attr.label,
79
+ value: String(attr.value_index),
80
+ })),
81
+ }));
82
+ // Build technical attributes from `custom_attributesV2`. Values come from the
83
+ // product; display labels are joined in from the store's code→label metadata
84
+ // map (custom_attributesV2 only returns codes). Exported for unit testing.
85
+ export const mapCustomAttributes = (custom, labelMap) => {
86
+ const items = custom?.items;
87
+ if (!items?.length)
88
+ return [];
89
+ // Attribute codes to exclude (internal/system attributes that are flagged
90
+ // visible-on-front in Magento but aren't meaningful technical data).
91
+ const excludedCodes = new Set([
92
+ 'graveyard',
93
+ 'outboundarticle',
94
+ 'webshoparticle',
95
+ 'pdflinks',
96
+ ]);
97
+ return items
98
+ .filter(attr => !excludedCodes.has(attr.code))
99
+ .map(attr => {
100
+ // Select/multiselect: join all selected option labels. Text/number: use
101
+ // the scalar value directly.
102
+ const value = attr.selected_options?.length
103
+ ? attr.selected_options.map(opt => opt.label).join(', ')
104
+ : attr.value != null
105
+ ? String(attr.value)
106
+ : '';
107
+ return {
108
+ code: attr.code,
109
+ // Fall back to the raw code if the label map is unavailable.
110
+ label: labelMap?.get(attr.code) ?? attr.code,
111
+ value,
112
+ };
113
+ })
114
+ .filter(attr => attr.value && attr.value.trim() !== '' && attr.value !== '[]');
115
+ };
116
+ export const mapGroupedItems = (items, productSuffix = '') => items
117
+ .filter((item) => item.product !== null && item.product.sku !== undefined)
118
+ .sort((a, b) => a.position - b.position)
119
+ .map((item) => ({
120
+ quantity: item.qty,
121
+ position: item.position,
122
+ product: {
123
+ id: item.product.id ?? item.product.uid ?? item.product.sku,
124
+ sku: item.product.sku,
125
+ name: item.product.name,
126
+ urlKey: applySuffix(item.product.url_key ?? '', productSuffix),
127
+ description: '',
128
+ price: mapPrice(item.product.price_range.minimum_price),
129
+ images: item.product.thumbnail ? [{ url: item.product.thumbnail.url, label: item.product.thumbnail.label }] : [],
130
+ categories: [],
131
+ stock: mapStock(item.product.stock_status),
132
+ attributes: [],
133
+ type: 'simple',
134
+ },
135
+ }));
136
+ // `productSuffix`/`categorySuffix` are storeConfig.product_url_suffix /
137
+ // category_url_suffix (e.g. ".html"). productSuffix is appended to the
138
+ // product's url_key; categorySuffix is used for the product's category
139
+ // references (breadcrumb links). Both default to "" (clean URLs).
140
+ export const mapProduct = (product, productSuffix = '', categorySuffix = '', attributeLabels) => {
141
+ // Build technical attributes from custom_attributesV2
142
+ const technicalAttributes = mapCustomAttributes(product.custom_attributesV2, attributeLabels);
143
+ const baseProduct = {
144
+ id: product.id ?? product.uid ?? product.sku,
145
+ sku: product.sku,
146
+ name: product.name,
147
+ urlKey: applySuffix(product.url_key, productSuffix),
148
+ description: product.description?.html ?? '',
149
+ shortDescription: product.short_description?.html,
150
+ price: mapPrice(product.price_range.minimum_price, product.price_tiers),
151
+ images: mapImages(product.media_gallery),
152
+ categories: mapCategories(product.categories, categorySuffix),
153
+ stock: mapStock(product.stock_status),
154
+ attributes: technicalAttributes,
155
+ metaTitle: product.meta_title,
156
+ metaDescription: product.meta_description,
157
+ };
158
+ // Check for grouped product (using __typename from GraphQL)
159
+ if (product.__typename === 'GroupedProduct' && product.items) {
160
+ return {
161
+ ...baseProduct,
162
+ type: 'grouped',
163
+ items: mapGroupedItems(product.items, productSuffix),
164
+ };
165
+ }
166
+ if (product.configurable_options && product.variants) {
167
+ return {
168
+ ...baseProduct,
169
+ type: 'configurable',
170
+ configurableOptions: mapConfigurableOptions(product.configurable_options),
171
+ variants: mapVariants(product.variants),
172
+ };
173
+ }
174
+ return {
175
+ ...baseProduct,
176
+ type: 'simple',
177
+ };
178
+ };
179
+ const getProductType = (product) => {
180
+ if (product.__typename === 'GroupedProduct')
181
+ return 'grouped';
182
+ if (product.configurable_options)
183
+ return 'configurable';
184
+ return 'simple';
185
+ };
186
+ export const mapProductListItem = (product, productSuffix = '') => {
187
+ const galleryImages = product.media_gallery ?? [];
188
+ const hoverImageData = galleryImages.length > 1 ? galleryImages[1] : undefined;
189
+ return {
190
+ id: product.id ?? product.uid ?? product.sku,
191
+ sku: product.sku,
192
+ name: product.name,
193
+ urlKey: applySuffix(product.url_key, productSuffix),
194
+ price: mapPrice(product.price_range.minimum_price, product.price_tiers),
195
+ thumbnail: {
196
+ url: product.thumbnail?.url ?? galleryImages[0]?.url ?? '',
197
+ label: product.thumbnail?.label ?? product.name,
198
+ },
199
+ hoverImage: hoverImageData ? {
200
+ url: hoverImageData.url,
201
+ label: hoverImageData.label ?? product.name,
202
+ } : undefined,
203
+ stock: mapStock(product.stock_status),
204
+ type: getProductType(product),
205
+ };
206
+ };
207
+ // Cart Mappers
208
+ // `productSuffix` (storeConfig.product_url_suffix) is applied to each item's
209
+ // product url_key so cart line-item links resolve. Defaults to "".
210
+ export const mapCart = (magentoCart, productSuffix = '') => ({
211
+ id: magentoCart.id,
212
+ email: magentoCart.email ?? undefined,
213
+ items: mapCartItems(magentoCart.items ?? [], productSuffix),
214
+ totals: mapCartTotals(magentoCart.prices ?? {}),
215
+ appliedCoupons: (magentoCart.applied_coupons ?? []).map((c) => ({ code: c.code })),
216
+ shippingAddresses: (magentoCart.shipping_addresses ?? []).map(mapShippingAddress),
217
+ billingAddress: magentoCart.billing_address ? mapShippingAddress(magentoCart.billing_address) : undefined,
218
+ selectedShippingMethod: magentoCart.shipping_addresses?.[0]?.selected_shipping_method
219
+ ? mapShippingMethod(magentoCart.shipping_addresses[0].selected_shipping_method)
220
+ : undefined,
221
+ selectedPaymentMethod: magentoCart.selected_payment_method
222
+ ? { code: magentoCart.selected_payment_method.code, title: magentoCart.selected_payment_method.title }
223
+ : undefined,
224
+ availableShippingMethods: (magentoCart.shipping_addresses?.[0]?.available_shipping_methods ?? []).map(mapShippingMethod),
225
+ availablePaymentMethods: (magentoCart.available_payment_methods ?? []).map(mapPaymentMethod),
226
+ });
227
+ export const mapCartItems = (items, productSuffix = '') => items.filter((item) => item != null).map((item) => ({
228
+ id: item.uid,
229
+ uid: item.uid,
230
+ product: {
231
+ id: item.product.id,
232
+ sku: item.product.sku,
233
+ name: item.product.name,
234
+ urlKey: applySuffix(item.product.url_key ?? '', productSuffix),
235
+ thumbnail: {
236
+ url: item.product.thumbnail?.url ?? '',
237
+ label: item.product.thumbnail?.label,
238
+ },
239
+ },
240
+ quantity: item.quantity,
241
+ prices: {
242
+ price: item.prices.price.value,
243
+ rowTotal: item.prices.row_total.value,
244
+ rowTotalIncludingTax: item.prices.row_total_including_tax?.value ?? item.prices.row_total.value,
245
+ currency: item.prices.price.currency,
246
+ },
247
+ configurableOptions: item.configurable_options?.map((opt) => ({
248
+ optionLabel: opt.option_label,
249
+ valueLabel: opt.value_label,
250
+ })),
251
+ }));
252
+ export const mapCartTotals = (prices) => ({
253
+ subtotal: prices.subtotal_excluding_tax?.value ?? 0,
254
+ subtotalIncludingTax: prices.subtotal_including_tax?.value ?? 0,
255
+ grandTotal: prices.grand_total?.value ?? 0,
256
+ discounts: (prices.discounts ?? []).map((d) => ({
257
+ amount: d.amount.value,
258
+ label: d.label,
259
+ })),
260
+ taxes: (prices.applied_taxes ?? []).map((t) => ({
261
+ amount: t.amount.value,
262
+ label: t.label,
263
+ rate: 0,
264
+ })),
265
+ currency: prices.grand_total?.currency ?? 'USD',
266
+ });
267
+ export const mapShippingAddress = (addr) => ({
268
+ firstname: addr.firstname,
269
+ lastname: addr.lastname,
270
+ street: addr.street,
271
+ city: addr.city,
272
+ region: addr.region?.label,
273
+ regionCode: addr.region?.code,
274
+ postcode: addr.postcode,
275
+ country: addr.country?.label ?? '',
276
+ countryCode: addr.country?.code ?? addr.country_code ?? '',
277
+ telephone: addr.telephone ?? '',
278
+ company: addr.company,
279
+ });
280
+ export const mapShippingMethod = (method) => ({
281
+ carrierCode: method.carrier_code,
282
+ carrierTitle: method.carrier_title,
283
+ methodCode: method.method_code,
284
+ methodTitle: method.method_title,
285
+ amount: method.amount?.value ?? 0,
286
+ currency: method.amount?.currency ?? 'USD',
287
+ });
288
+ export const mapPaymentMethod = (method) => ({
289
+ code: method.code,
290
+ title: method.title,
291
+ });
292
+ // Directory Mappers
293
+ export const mapCountry = (country) => ({
294
+ code: country.two_letter_abbreviation ?? '',
295
+ name: country.full_name_locale ?? country.two_letter_abbreviation ?? '',
296
+ regions: (country.available_regions ?? []).map((r) => ({
297
+ id: r.id,
298
+ code: r.code,
299
+ name: r.name,
300
+ })),
301
+ });
302
+ export const mapCountries = (countries) => (countries ?? [])
303
+ .filter((c) => c?.two_letter_abbreviation && c?.full_name_locale)
304
+ .map(mapCountry)
305
+ .sort((a, b) => a.name.localeCompare(b.name));
306
+ // Category Mappers
307
+ //
308
+ // URLs are built from the url_key hierarchy + the store's category URL suffix,
309
+ // never from Magento's `url_path` (which can be stale). Ancestors come from the
310
+ // threaded `ancestorSegments` (during children recursion) or, at the top level,
311
+ // from the category's own breadcrumbs (ordered by category_level).
312
+ export const mapCategory = (cat, suffix = '', ancestorSegments) => {
313
+ // Ordered ancestor url_keys derived from breadcrumbs (root -> parent).
314
+ const breadcrumbCrumbs = (cat.breadcrumbs ?? [])
315
+ .slice()
316
+ .sort((a, b) => (a.category_level ?? 0) - (b.category_level ?? 0));
317
+ const ancestors = ancestorSegments ??
318
+ breadcrumbCrumbs
319
+ .map((b) => b.category_url_key)
320
+ .filter(Boolean);
321
+ const ownSegments = [...ancestors, cat.url_key].filter(Boolean);
322
+ return {
323
+ id: String(cat.uid ?? cat.id ?? ''),
324
+ name: cat.name,
325
+ urlKey: buildCategoryUrl(ancestors, cat.url_key, suffix),
326
+ description: cat.description,
327
+ image: cat.image,
328
+ productCount: cat.product_count ?? 0,
329
+ children: (cat.children ?? []).map((child) => mapCategory(child, suffix, ownSegments)),
330
+ breadcrumbs: breadcrumbCrumbs.map((b, i) => ({
331
+ id: String(b.category_uid ?? b.category_id ?? ''),
332
+ name: b.category_name ?? '',
333
+ // Cumulative path for each crumb: url_keys up to and including it.
334
+ urlKey: applySuffix(joinSegments(breadcrumbCrumbs
335
+ .slice(0, i + 1)
336
+ .map((c) => c.category_url_key)
337
+ .filter((k) => Boolean(k))), suffix),
338
+ })),
339
+ metaTitle: cat.meta_title,
340
+ metaDescription: cat.meta_description,
341
+ };
342
+ };
343
+ // Magento exposes `include_in_menu` as a per-category flag (Boolean, or 0/1 in
344
+ // older schemas). Categories may exist and be browsable while intentionally
345
+ // hidden from navigation, so we must not render them in the menu. A missing
346
+ // flag is treated as included for backward compatibility.
347
+ export const isIncludedInMenu = (cat) => cat?.include_in_menu !== false && cat?.include_in_menu !== 0;
348
+ // `urlKey` holds the ready-to-link relative path built from the url_key
349
+ // hierarchy (NOT Magento's `url_path`, which can be stale) plus the store's
350
+ // category URL suffix. `parentSegments` are the ancestor url_keys and `suffix`
351
+ // is `storeConfig.category_url_suffix` (e.g. ".html"), both threaded down the
352
+ // tree by the adapter's navigation.get.
353
+ export const mapNavigationItem = (cat, level = 1, parentSegments = [], suffix = '') => {
354
+ const segments = [...parentSegments, cat.url_key].filter(Boolean);
355
+ return {
356
+ id: String(cat.id ?? ''),
357
+ name: cat.name,
358
+ urlKey: buildCategoryUrl(parentSegments, cat.url_key, suffix),
359
+ level,
360
+ position: cat.position ?? 0,
361
+ children: (cat.children ?? [])
362
+ .filter(isIncludedInMenu)
363
+ .map((child) => mapNavigationItem(child, level + 1, segments, suffix)),
364
+ };
365
+ };
366
+ // CMS Mappers
367
+ export const mapCmsPage = (page) => ({
368
+ id: page.identifier,
369
+ identifier: page.identifier,
370
+ title: page.title,
371
+ content: page.content,
372
+ contentHeading: page.content_heading,
373
+ urlKey: page.url_key ?? page.identifier,
374
+ metaTitle: page.meta_title,
375
+ metaDescription: page.meta_description,
376
+ });
377
+ export const mapCmsBlock = (block) => ({
378
+ id: block.identifier,
379
+ identifier: block.identifier,
380
+ title: block.title ?? '',
381
+ content: block.content ?? '',
382
+ });
383
+ export const mapUrlResolver = (route) => {
384
+ if (!route) {
385
+ return { type: 'NOT_FOUND', id: '', urlKey: '' };
386
+ }
387
+ // Determine type from __typename or legacy type field
388
+ const typename = route.__typename || route.type;
389
+ let type = 'NOT_FOUND';
390
+ // Handle __typename values (e.g., 'SimpleProduct', 'ConfigurableProduct', 'CategoryTree', 'CmsPage')
391
+ if (typename?.includes('Product') || typename === 'PRODUCT') {
392
+ type = 'PRODUCT';
393
+ }
394
+ else if (typename === 'CategoryTree' || typename === 'CATEGORY') {
395
+ type = 'CATEGORY';
396
+ }
397
+ else if (typename === 'CmsPage' || typename === 'CMS_PAGE') {
398
+ type = 'CMS_PAGE';
399
+ }
400
+ return {
401
+ type,
402
+ id: String(route.id ?? route.identifier ?? ''),
403
+ // Unambiguous backend identifiers used for the follow-up entity fetch:
404
+ // categories are looked up by uid, products by sku.
405
+ uid: route.uid ?? undefined,
406
+ sku: route.sku ?? undefined,
407
+ urlKey: route.url_key ?? '',
408
+ };
409
+ };
410
+ // Customer Mappers
411
+ export const mapCustomer = (customer) => ({
412
+ id: String(customer.id ?? ''),
413
+ email: customer.email,
414
+ firstname: customer.firstname,
415
+ lastname: customer.lastname,
416
+ dateOfBirth: customer.date_of_birth,
417
+ gender: customer.gender === 1 ? 'male' : customer.gender === 2 ? 'female' : undefined,
418
+ createdAt: customer.created_at ?? '',
419
+ addresses: (customer.addresses ?? []).map(mapCustomerAddress),
420
+ });
421
+ export const mapCustomerAddress = (addr) => ({
422
+ id: String(addr.id ?? ''),
423
+ firstname: addr.firstname,
424
+ lastname: addr.lastname,
425
+ street: addr.street,
426
+ city: addr.city,
427
+ region: addr.region?.region,
428
+ regionCode: addr.region?.region_code,
429
+ regionId: addr.region?.region_id,
430
+ postcode: addr.postcode,
431
+ country: '',
432
+ countryCode: addr.country_code ?? '',
433
+ telephone: addr.telephone ?? '',
434
+ company: addr.company,
435
+ isDefaultShipping: addr.default_shipping ?? false,
436
+ isDefaultBilling: addr.default_billing ?? false,
437
+ });
438
+ // Order Mappers
439
+ export const mapCustomerOrder = (order) => ({
440
+ id: String(order.id ?? ''),
441
+ orderNumber: order.number,
442
+ createdAt: order.order_date,
443
+ status: order.status,
444
+ total: order.total?.grand_total?.value ?? 0,
445
+ subtotal: order.total?.subtotal_excl_tax?.value,
446
+ shipping: order.total?.total_shipping?.value,
447
+ tax: order.total?.total_tax?.value,
448
+ discount: (order.total?.discounts ?? []).reduce((sum, d) => sum + (d?.amount?.value ?? 0), 0) ||
449
+ undefined,
450
+ currency: order.total?.grand_total?.currency ?? 'SEK',
451
+ items: (order.items ?? [])
452
+ .filter((i) => i != null)
453
+ .map(mapCustomerOrderItem),
454
+ shippingAddress: order.shipping_address ? {
455
+ firstname: order.shipping_address.firstname ?? '',
456
+ lastname: order.shipping_address.lastname ?? '',
457
+ street: order.shipping_address.street ?? [],
458
+ city: order.shipping_address.city ?? '',
459
+ region: order.shipping_address.region,
460
+ postcode: order.shipping_address.postcode ?? '',
461
+ country: '',
462
+ countryCode: order.shipping_address.country_code ?? '',
463
+ telephone: order.shipping_address.telephone ?? '',
464
+ } : {
465
+ firstname: '',
466
+ lastname: '',
467
+ street: [],
468
+ city: '',
469
+ postcode: '',
470
+ country: '',
471
+ countryCode: '',
472
+ telephone: '',
473
+ },
474
+ });
475
+ export const mapCustomerOrderItem = (item) => ({
476
+ id: String(item.id ?? ''),
477
+ productName: item.product_name,
478
+ sku: item.product_sku,
479
+ quantity: item.quantity_ordered,
480
+ price: item.product_sale_price?.value ?? 0,
481
+ thumbnail: undefined,
482
+ });
483
+ // Wishlist mappers
484
+ export const mapWishlistItem = (item) => ({
485
+ id: String(item.id ?? ''),
486
+ addedAt: item.added_at ?? new Date().toISOString(),
487
+ product: mapProductListItem(item.product),
488
+ });
489
+ export const mapWishlist = (wishlist) => ({
490
+ id: String(wishlist.id ?? ''),
491
+ items: (wishlist.items_v2?.items ?? [])
492
+ .filter((i) => i != null)
493
+ .map(mapWishlistItem),
494
+ itemsCount: wishlist.items_count ?? 0,
495
+ });
@@ -0,0 +1,40 @@
1
+ export declare const GET_PRODUCT_BY_URL_KEY = "\n query GetProductByUrlKey($urlKey: String!) {\n products(filter: { url_key: { eq: $urlKey } }) {\n items {\n __typename\n id\n sku\n name\n url_key\n description { html }\n short_description { html }\n meta_title\n meta_description\n stock_status\n price_range {\n minimum_price {\n regular_price { value currency }\n final_price { value currency }\n discount { amount_off percent_off }\n }\n }\n price_tiers {\n quantity\n final_price { value currency }\n discount { amount_off percent_off }\n }\n media_gallery {\n url\n label\n position\n }\n categories {\n id\n name\n url_key\n breadcrumbs {\n category_url_key\n category_level\n }\n }\n custom_attributesV2(filters: { is_visible_on_front: true }) {\n items {\n code\n __typename\n ... on AttributeValue {\n value\n }\n ... on AttributeSelectedOptions {\n selected_options {\n label\n value\n }\n }\n }\n errors {\n message\n }\n }\n ... on ConfigurableProduct {\n configurable_options {\n id\n attribute_code\n label\n values {\n uid\n label\n swatch_data {\n __typename\n value\n }\n }\n }\n variants {\n product {\n id\n sku\n name\n stock_status\n price_range {\n minimum_price {\n regular_price { value currency }\n final_price { value currency }\n }\n }\n }\n attributes {\n code\n label\n value_index\n }\n }\n }\n ... on GroupedProduct {\n items {\n qty\n position\n product {\n ... on ProductInterface {\n __typename\n id\n uid\n sku\n name\n url_key\n stock_status\n price_range {\n minimum_price {\n regular_price { value currency }\n final_price { value currency }\n discount { amount_off percent_off }\n }\n }\n thumbnail { url label }\n }\n }\n }\n }\n }\n }\n }\n";
2
+ export declare const GET_PRODUCT_BY_ID = "\n query GetProductBySku($sku: String!) {\n products(filter: { sku: { eq: $sku } }) {\n items {\n id\n sku\n name\n url_key\n description { html }\n short_description { html }\n meta_title\n meta_description\n stock_status\n price_range {\n minimum_price {\n regular_price { value currency }\n final_price { value currency }\n discount { amount_off percent_off }\n }\n }\n price_tiers {\n quantity\n final_price { value currency }\n discount { amount_off percent_off }\n }\n media_gallery {\n url\n label\n position\n }\n categories {\n id\n name\n url_key\n breadcrumbs {\n category_url_key\n category_level\n }\n }\n custom_attributesV2(filters: { is_visible_on_front: true }) {\n items {\n code\n __typename\n ... on AttributeValue {\n value\n }\n ... on AttributeSelectedOptions {\n selected_options {\n label\n value\n }\n }\n }\n errors {\n message\n }\n }\n }\n }\n }\n";
3
+ export declare const GET_PRODUCT_ATTRIBUTE_LABELS = "\n query GetProductAttributeLabels {\n attributesList(entityType: CATALOG_PRODUCT, filters: { is_visible_on_front: true }) {\n items {\n code\n label\n }\n errors {\n message\n }\n }\n }\n";
4
+ export declare const GET_CATEGORY_BY_URL_KEY = "\n query GetCategoryByUrlKey($urlKey: String!) {\n categoryList(filters: { url_path: { eq: $urlKey } }) {\n id\n uid\n name\n url_key\n url_path\n description\n image\n meta_title\n meta_description\n product_count\n breadcrumbs {\n category_id\n category_uid\n category_name\n category_url_key\n category_url_path\n category_level\n }\n children {\n id\n uid\n name\n url_key\n url_path\n product_count\n }\n }\n }\n";
5
+ export declare const GET_CATEGORY_BY_URL_KEY_SINGLE = "\n query GetCategoryByUrlKeySingle($urlKey: String!) {\n categoryList(filters: { url_key: { eq: $urlKey } }) {\n id\n uid\n name\n url_key\n url_path\n description\n image\n meta_title\n meta_description\n product_count\n breadcrumbs {\n category_id\n category_uid\n category_name\n category_url_key\n category_url_path\n category_level\n }\n children {\n id\n uid\n name\n url_key\n url_path\n product_count\n }\n }\n }\n";
6
+ export declare const GET_CATEGORY_BY_UID = "\n query GetCategoryByUid($uid: String!) {\n categoryList(filters: { category_uid: { eq: $uid } }) {\n id\n uid\n name\n url_key\n url_path\n description\n image\n meta_title\n meta_description\n product_count\n breadcrumbs {\n category_id\n category_uid\n category_name\n category_url_key\n category_url_path\n category_level\n }\n children {\n id\n uid\n name\n url_key\n url_path\n product_count\n }\n }\n }\n";
7
+ export declare const GET_CATEGORY_SUGGESTIONS = "\n query GetCategorySuggestions($name: String!) {\n categoryList(filters: { name: { match: $name } }) {\n uid\n name\n url_key\n url_path\n }\n }\n";
8
+ export declare const GET_CATEGORY_PRODUCTS = "\n query GetCategoryProducts(\n $pageSize: Int!\n $currentPage: Int!\n $filter: ProductAttributeFilterInput!\n $sort: ProductAttributeSortInput\n ) {\n products(\n filter: $filter\n pageSize: $pageSize\n currentPage: $currentPage\n sort: $sort\n ) {\n total_count\n page_info {\n current_page\n page_size\n total_pages\n }\n items {\n id\n sku\n name\n url_key\n stock_status\n price_range {\n minimum_price {\n regular_price { value currency }\n final_price { value currency }\n discount { amount_off percent_off }\n }\n }\n price_tiers {\n quantity\n final_price { value currency }\n discount { amount_off percent_off }\n }\n thumbnail {\n url\n label\n }\n }\n aggregations(filter: { category: { includeDirectChildrenOnly: false } }) {\n attribute_code\n label\n options {\n value\n label\n count\n }\n }\n sort_fields {\n default\n options {\n value\n label\n }\n }\n }\n }\n";
9
+ export declare const GET_STORE_CONFIG = "\n query GetStoreConfig {\n storeConfig {\n root_category_uid\n root_category_id\n store_code\n store_name\n base_currency_code\n default_display_currency_code\n locale\n timezone\n category_url_suffix\n product_url_suffix\n use_store_in_url\n cms_home_page\n cms_no_route\n default_title\n default_description\n default_keywords\n title_prefix\n title_suffix\n title_separator\n }\n }\n";
10
+ export declare const GET_AVAILABLE_STORES = "\n query GetAvailableStores {\n availableStores(useCurrentGroup: false) {\n store_code\n store_name\n locale\n base_currency_code\n default_display_currency_code\n is_default_store\n base_url\n }\n }\n";
11
+ export declare const GET_COUNTRIES = "\n query GetCountries {\n countries {\n two_letter_abbreviation\n full_name_locale\n available_regions {\n id\n code\n name\n }\n }\n }\n";
12
+ export declare const GET_NAVIGATION = "\n query GetNavigation($id: Int!) {\n category(id: $id) {\n id\n children {\n id\n name\n url_key\n url_path\n position\n level\n include_in_menu\n children {\n id\n name\n url_key\n url_path\n position\n level\n include_in_menu\n children {\n id\n name\n url_key\n url_path\n position\n level\n include_in_menu\n }\n }\n }\n }\n }\n";
13
+ export declare const CREATE_EMPTY_CART = "\n mutation CreateEmptyCart {\n createEmptyCart\n }\n";
14
+ export declare const GET_CART = "\n query GetCart($cartId: String!) {\n cart(cart_id: $cartId) {\n id\n email\n items {\n uid\n product {\n id\n sku\n name\n url_key\n thumbnail { url label }\n }\n quantity\n prices {\n price { value currency }\n row_total { value currency }\n row_total_including_tax { value currency }\n }\n ... on ConfigurableCartItem {\n configurable_options {\n option_label\n value_label\n }\n }\n }\n prices {\n subtotal_excluding_tax { value currency }\n subtotal_including_tax { value currency }\n grand_total { value currency }\n discounts {\n amount { value currency }\n label\n }\n applied_taxes {\n amount { value currency }\n label\n }\n }\n applied_coupons {\n code\n }\n shipping_addresses {\n firstname\n lastname\n street\n city\n region { code label }\n postcode\n country { code label }\n telephone\n available_shipping_methods {\n carrier_code\n carrier_title\n method_code\n method_title\n amount { value currency }\n }\n selected_shipping_method {\n carrier_code\n carrier_title\n method_code\n method_title\n amount { value currency }\n }\n }\n billing_address {\n firstname\n lastname\n street\n city\n region { code label }\n postcode\n country { code label }\n telephone\n }\n available_payment_methods {\n code\n title\n }\n selected_payment_method {\n code\n title\n }\n }\n }\n";
15
+ export declare const ADD_TO_CART = "\n mutation AddToCart($cartId: String!, $cartItems: [CartItemInput!]!) {\n addProductsToCart(\n cartId: $cartId\n cartItems: $cartItems\n ) {\n cart {\n id\n items {\n uid\n product { id sku name url_key thumbnail { url label } }\n quantity\n prices {\n price { value currency }\n row_total { value currency }\n row_total_including_tax { value currency }\n }\n ... on ConfigurableCartItem {\n configurable_options {\n option_label\n value_label\n }\n }\n }\n prices {\n subtotal_excluding_tax { value currency }\n subtotal_including_tax { value currency }\n grand_total { value currency }\n }\n }\n user_errors {\n code\n message\n }\n }\n }\n";
16
+ export declare const UPDATE_CART_ITEM = "\n mutation UpdateCartItem($cartId: String!, $itemUid: ID!, $quantity: Float!) {\n updateCartItems(\n input: {\n cart_id: $cartId\n cart_items: [{ cart_item_uid: $itemUid, quantity: $quantity }]\n }\n ) {\n cart {\n id\n items {\n uid\n product { id sku name url_key thumbnail { url label } }\n quantity\n prices {\n price { value currency }\n row_total { value currency }\n row_total_including_tax { value currency }\n }\n }\n prices {\n subtotal_excluding_tax { value currency }\n subtotal_including_tax { value currency }\n grand_total { value currency }\n }\n }\n }\n }\n";
17
+ export declare const REMOVE_CART_ITEM = "\n mutation RemoveCartItem($cartId: String!, $itemUid: ID!) {\n removeItemFromCart(input: { cart_id: $cartId, cart_item_uid: $itemUid }) {\n cart {\n id\n items {\n uid\n product { id sku name url_key thumbnail { url label } }\n quantity\n prices {\n price { value currency }\n row_total { value currency }\n row_total_including_tax { value currency }\n }\n }\n prices {\n subtotal_excluding_tax { value currency }\n subtotal_including_tax { value currency }\n grand_total { value currency }\n }\n }\n }\n }\n";
18
+ export declare const URL_RESOLVER = "\n query UrlResolver($url: String!) {\n route(url: $url) {\n __typename\n ... on ProductInterface {\n id\n uid\n sku\n url_key\n }\n ... on CategoryTree {\n id\n uid\n url_key\n }\n ... on CmsPage {\n identifier\n url_key\n }\n }\n }\n";
19
+ export declare const GET_CMS_PAGE = "\n query GetCmsPage($identifier: String!) {\n cmsPage(identifier: $identifier) {\n identifier\n url_key\n title\n content\n content_heading\n meta_title\n meta_description\n }\n }\n";
20
+ export declare const GET_CMS_BLOCKS = "\n query GetCmsBlocks($identifiers: [String!]!) {\n cmsBlocks(identifiers: $identifiers) {\n items {\n identifier\n title\n content\n }\n }\n }\n";
21
+ export declare const SEARCH_PRODUCTS = "\n query SearchProducts($search: String!, $pageSize: Int!, $currentPage: Int!) {\n products(search: $search, pageSize: $pageSize, currentPage: $currentPage) {\n total_count\n page_info {\n current_page\n page_size\n total_pages\n }\n items {\n id\n sku\n name\n url_key\n stock_status\n price_range {\n minimum_price {\n regular_price { value currency }\n final_price { value currency }\n discount { amount_off percent_off }\n }\n }\n price_tiers {\n quantity\n final_price { value currency }\n discount { amount_off percent_off }\n }\n thumbnail {\n url\n label\n }\n }\n }\n }\n";
22
+ export declare const GENERATE_CUSTOMER_TOKEN = "\n mutation GenerateCustomerToken($email: String!, $password: String!) {\n generateCustomerToken(email: $email, password: $password) {\n token\n }\n }\n";
23
+ export declare const CREATE_CUSTOMER = "\n mutation CreateCustomer($input: CustomerCreateInput!) {\n createCustomerV2(input: $input) {\n customer {\n id\n email\n firstname\n lastname\n date_of_birth\n gender\n created_at\n }\n }\n }\n";
24
+ export declare const GET_CUSTOMER = "\n query GetCustomer {\n customer {\n id\n email\n firstname\n lastname\n date_of_birth\n gender\n created_at\n addresses {\n id\n firstname\n lastname\n street\n city\n region { region_code region region_id }\n postcode\n country_code\n telephone\n company\n default_shipping\n default_billing\n }\n }\n }\n";
25
+ export declare const CREATE_CUSTOMER_ADDRESS = "\n mutation CreateCustomerAddress($input: CustomerAddressInput!) {\n createCustomerAddress(input: $input) {\n \n id\n firstname\n lastname\n street\n city\n region { region_code region region_id }\n postcode\n country_code\n telephone\n company\n default_shipping\n default_billing\n\n }\n }\n";
26
+ export declare const UPDATE_CUSTOMER_ADDRESS = "\n mutation UpdateCustomerAddress($id: Int!, $input: CustomerAddressInput!) {\n updateCustomerAddress(id: $id, input: $input) {\n \n id\n firstname\n lastname\n street\n city\n region { region_code region region_id }\n postcode\n country_code\n telephone\n company\n default_shipping\n default_billing\n\n }\n }\n";
27
+ export declare const DELETE_CUSTOMER_ADDRESS = "\n mutation DeleteCustomerAddress($id: Int!) {\n deleteCustomerAddress(id: $id)\n }\n";
28
+ export declare const GET_CUSTOMER_ORDERS = "\n query GetCustomerOrders($pageSize: Int!, $currentPage: Int!) {\n customer {\n orders(pageSize: $pageSize, currentPage: $currentPage) {\n total_count\n page_info {\n current_page\n page_size\n total_pages\n }\n items {\n id\n number\n order_date\n status\n total {\n grand_total { value currency }\n subtotal_excl_tax { value currency }\n total_shipping { value currency }\n total_tax { value currency }\n discounts { amount { value currency } label }\n }\n shipping_address {\n firstname\n lastname\n street\n city\n region\n postcode\n country_code\n telephone\n }\n items {\n id\n product_name\n product_sku\n quantity_ordered\n product_sale_price {\n value\n currency\n }\n product_url_key\n }\n }\n }\n }\n }\n";
29
+ export declare const SET_SHIPPING_ADDRESS = "\n mutation SetShippingAddress($cartId: String!, $address: ShippingAddressInput!) {\n setShippingAddressesOnCart(\n input: { cart_id: $cartId, shipping_addresses: [$address] }\n ) {\n cart {\n id\n shipping_addresses {\n firstname\n lastname\n street\n city\n region { code label }\n postcode\n country { code label }\n telephone\n available_shipping_methods {\n carrier_code\n carrier_title\n method_code\n method_title\n amount { value currency }\n }\n }\n }\n }\n }\n";
30
+ export declare const SET_SHIPPING_METHOD = "\n mutation SetShippingMethod(\n $cartId: String!\n $carrierCode: String!\n $methodCode: String!\n ) {\n setShippingMethodsOnCart(\n input: {\n cart_id: $cartId\n shipping_methods: [\n { carrier_code: $carrierCode, method_code: $methodCode }\n ]\n }\n ) {\n cart {\n id\n shipping_addresses {\n selected_shipping_method {\n carrier_code\n carrier_title\n method_code\n method_title\n amount { value currency }\n }\n }\n prices {\n grand_total { value currency }\n }\n }\n }\n }\n";
31
+ export declare const SET_PAYMENT_METHOD = "\n mutation SetPaymentMethod($cartId: String!, $code: String!) {\n setPaymentMethodOnCart(\n input: { cart_id: $cartId, payment_method: { code: $code } }\n ) {\n cart {\n id\n selected_payment_method {\n code\n title\n }\n }\n }\n }\n";
32
+ export declare const PLACE_ORDER = "\n mutation PlaceOrder($cartId: String!) {\n placeOrder(input: { cart_id: $cartId }) {\n order {\n order_number\n }\n }\n }\n";
33
+ export declare const GET_RELATED_PRODUCTS = "\n query GetRelatedProducts($urlKey: String!) {\n products(filter: { url_key: { eq: $urlKey } }) {\n items {\n related_products {\n __typename\n id\n uid\n sku\n name\n url_key\n stock_status\n price_range {\n minimum_price {\n regular_price { value currency }\n final_price { value currency }\n discount { amount_off percent_off }\n }\n }\n thumbnail {\n url\n label\n }\n }\n upsell_products {\n __typename\n id\n uid\n sku\n name\n url_key\n stock_status\n price_range {\n minimum_price {\n regular_price { value currency }\n final_price { value currency }\n discount { amount_off percent_off }\n }\n }\n thumbnail {\n url\n label\n }\n }\n }\n }\n }\n";
34
+ export declare const GET_RELATED_PRODUCTS_BY_SKU = "\n query GetRelatedProductsBySku($sku: String!) {\n products(filter: { sku: { eq: $sku } }) {\n items {\n related_products {\n __typename\n id\n uid\n sku\n name\n url_key\n stock_status\n price_range {\n minimum_price {\n regular_price { value currency }\n final_price { value currency }\n discount { amount_off percent_off }\n }\n }\n thumbnail {\n url\n label\n }\n }\n upsell_products {\n __typename\n id\n uid\n sku\n name\n url_key\n stock_status\n price_range {\n minimum_price {\n regular_price { value currency }\n final_price { value currency }\n discount { amount_off percent_off }\n }\n }\n thumbnail {\n url\n label\n }\n }\n }\n }\n }\n";
35
+ export declare const GET_PRODUCTS_BY_SKUS = "\n query GetProductsBySkus($skus: [String!]!, $pageSize: Int!) {\n products(filter: { sku: { in: $skus } }, pageSize: $pageSize) {\n items {\n id\n sku\n name\n url_key\n stock_status\n price_range {\n minimum_price {\n regular_price { value currency }\n final_price { value currency }\n discount { amount_off percent_off }\n }\n }\n price_tiers {\n quantity\n final_price { value currency }\n discount { amount_off percent_off }\n }\n thumbnail { url label }\n }\n }\n }\n";
36
+ export declare const GET_CUSTOMER_CART = "\n query GetCustomerCart {\n customerCart {\n id\n }\n }\n";
37
+ export declare const MERGE_CARTS = "\n mutation MergeCarts($guestCartId: String!, $customerCartId: String!) {\n mergeCarts(source_cart_id: $guestCartId, destination_cart_id: $customerCartId) {\n id\n }\n }\n";
38
+ export declare const GET_CUSTOMER_WISHLIST = "\n query GetCustomerWishlist {\n customer {\n wishlists {\n id\n items_count\n items_v2 {\n items {\n id\n added_at\n product {\n sku\n name\n url_key\n stock_status\n price_range {\n minimum_price {\n regular_price { value currency }\n final_price { value currency }\n discount { amount_off percent_off }\n }\n }\n thumbnail {\n url\n label\n }\n }\n }\n }\n }\n }\n }\n";
39
+ export declare const ADD_TO_WISHLIST = "\n mutation AddToWishlist($wishlistId: ID!, $items: [WishlistItemInput!]!) {\n addProductsToWishlist(wishlistId: $wishlistId, wishlistItems: $items) {\n wishlist {\n id\n items_count\n items_v2 {\n items {\n id\n added_at\n product {\n sku\n name\n url_key\n stock_status\n price_range {\n minimum_price {\n regular_price { value currency }\n final_price { value currency }\n discount { amount_off percent_off }\n }\n }\n thumbnail {\n url\n label\n }\n }\n }\n }\n }\n user_errors {\n code\n message\n }\n }\n }\n";
40
+ export declare const REMOVE_FROM_WISHLIST = "\n mutation RemoveFromWishlist($wishlistId: ID!, $itemIds: [ID!]!) {\n removeProductsFromWishlist(wishlistId: $wishlistId, wishlistItemsIds: $itemIds) {\n wishlist {\n id\n items_count\n items_v2 {\n items {\n id\n added_at\n product {\n sku\n name\n url_key\n stock_status\n price_range {\n minimum_price {\n regular_price { value currency }\n final_price { value currency }\n discount { amount_off percent_off }\n }\n }\n thumbnail {\n url\n label\n }\n }\n }\n }\n }\n user_errors {\n code\n message\n }\n }\n }\n";