@cobrastyle/adapter-magento2 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/magento-types.d.ts +5 -0
- package/dist/mappers.js +7 -0
- package/dist/queries.d.ts +3 -3
- package/dist/queries.js +3 -0
- package/package.json +3 -3
package/dist/magento-types.d.ts
CHANGED
|
@@ -301,6 +301,11 @@ export interface MagentoCategory {
|
|
|
301
301
|
breadcrumbs?: MagentoCategoryBreadcrumb[] | null;
|
|
302
302
|
meta_title?: string;
|
|
303
303
|
meta_description?: string;
|
|
304
|
+
/**
|
|
305
|
+
* PRODUCTS | PAGE | PRODUCTS_AND_PAGE. Magento's enum is a plain String in the
|
|
306
|
+
* GraphQL schema, so it is typed loosely here and narrowed by the mapper.
|
|
307
|
+
*/
|
|
308
|
+
display_mode?: string | null;
|
|
304
309
|
}
|
|
305
310
|
export interface MagentoCmsPage {
|
|
306
311
|
identifier: string;
|
package/dist/mappers.js
CHANGED
|
@@ -462,8 +462,15 @@ export const mapCategory = (cat, suffix = '', ancestorSegments) => {
|
|
|
462
462
|
})),
|
|
463
463
|
metaTitle: cat.meta_title,
|
|
464
464
|
metaDescription: cat.meta_description,
|
|
465
|
+
displayMode: mapDisplayMode(cat.display_mode),
|
|
465
466
|
};
|
|
466
467
|
};
|
|
468
|
+
/**
|
|
469
|
+
* Narrow Magento's `display_mode` to our union. Unknown or absent values map to
|
|
470
|
+
* undefined rather than a guessed default, so the storefront's own fallback
|
|
471
|
+
* (render products, the historic behaviour) stays in one place.
|
|
472
|
+
*/
|
|
473
|
+
const mapDisplayMode = (mode) => mode === 'PRODUCTS' || mode === 'PAGE' || mode === 'PRODUCTS_AND_PAGE' ? mode : undefined;
|
|
467
474
|
// Magento exposes `include_in_menu` as a per-category flag (Boolean, or 0/1 in
|
|
468
475
|
// older schemas). Categories may exist and be browsable while intentionally
|
|
469
476
|
// hidden from navigation, so we must not render them in the menu. A missing
|
package/dist/queries.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
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 maximum_price {\n final_price { value currency }\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 ... on BundleProduct {\n dynamic_price\n price_view\n bundleItems: items {\n uid\n option_id\n title\n type\n required\n position\n options {\n uid\n id\n label\n quantity\n can_change_quantity\n is_default\n price\n price_type\n product {\n sku\n price_range { minimum_price { final_price { value currency } } }\n }\n }\n }\n }\n }\n }\n }\n";
|
|
2
2
|
export declare const GET_PRODUCT_BY_ID = "\n query GetProductBySku($sku: String!) {\n products(filter: { sku: { eq: $sku } }) {\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 maximum_price {\n final_price { value currency }\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 ... on BundleProduct {\n dynamic_price\n price_view\n bundleItems: items {\n uid\n option_id\n title\n type\n required\n position\n options {\n uid\n id\n label\n quantity\n can_change_quantity\n is_default\n price\n price_type\n product {\n sku\n price_range { minimum_price { final_price { value currency } } }\n }\n }\n }\n }\n }\n }\n }\n";
|
|
3
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";
|
|
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 display_mode\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 display_mode\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 display_mode\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
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
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
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";
|
package/dist/queries.js
CHANGED
|
@@ -330,6 +330,7 @@ export const GET_CATEGORY_BY_URL_KEY = `
|
|
|
330
330
|
meta_title
|
|
331
331
|
meta_description
|
|
332
332
|
product_count
|
|
333
|
+
display_mode
|
|
333
334
|
breadcrumbs {
|
|
334
335
|
category_id
|
|
335
336
|
category_uid
|
|
@@ -363,6 +364,7 @@ export const GET_CATEGORY_BY_URL_KEY_SINGLE = `
|
|
|
363
364
|
meta_title
|
|
364
365
|
meta_description
|
|
365
366
|
product_count
|
|
367
|
+
display_mode
|
|
366
368
|
breadcrumbs {
|
|
367
369
|
category_id
|
|
368
370
|
category_uid
|
|
@@ -397,6 +399,7 @@ export const GET_CATEGORY_BY_UID = `
|
|
|
397
399
|
meta_title
|
|
398
400
|
meta_description
|
|
399
401
|
product_count
|
|
402
|
+
display_mode
|
|
400
403
|
breadcrumbs {
|
|
401
404
|
category_id
|
|
402
405
|
category_uid
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cobrastyle/adapter-magento2",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
"dist"
|
|
14
14
|
],
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@cobrastyle/shared-types": "1.
|
|
16
|
+
"@cobrastyle/shared-types": "1.2.0"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@types/node": "^20.0.0",
|
|
20
20
|
"typescript": "^5.3.0",
|
|
21
|
-
"@cobrastyle/adapter-conformance": "1.0.
|
|
21
|
+
"@cobrastyle/adapter-conformance": "1.0.3"
|
|
22
22
|
},
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"repository": {
|