Skip to content

PWA-3450 : Commit for initial package after conversion from TypeScrip… #4462

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions packages/extensions/venia-pwa-live-search/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "@magento/venia-pwa-live-search",
"version": "1.0.0",
"description": "Live Search PWA Studio extension.",
"main": "src/index.jsx",
"scripts": {
"clean": " "
},
"repository": "https://github.com/github:magento/pwa-studio",
"license": "MIT",
"dependencies": {
"@magento/pwa-buildpack": "~11.5.3",
"@magento/storefront-search-as-you-type": "~1.0.4",
"@magento/venia-ui": "~11.5.0",
"currency-symbol-map": "^5.1.0"
},
"peerDependencies": {
"react": "^17.0.2"
},
"pwa-studio": {
"targets": {
"intercept": "src/targets/intercept"
}
}
}
9 changes: 9 additions & 0 deletions packages/extensions/venia-pwa-live-search/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
plugins: [
//require('postcss-import'),
require('tailwindcss/nesting')
//require('autoprefixer'),
//require('tailwindcss'),
//require('cssnano'),
]
};
192 changes: 192 additions & 0 deletions packages/extensions/venia-pwa-live-search/src/api/fragments.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
/*
Copyright 2024 Adobe
All Rights Reserved.

NOTICE: Adobe permits you to use, modify, and distribute this file in
accordance with the terms of the Adobe license agreement accompanying
it.
*/

const Facet = `
fragment Facet on Aggregation {
title
attribute
buckets {
title
__typename
... on CategoryView {
name
count
path
}
... on ScalarBucket {
count
}
... on RangeBucket {
from
to
count
}
... on StatsBucket {
min
max
}
}
}
`;

const ProductView = `
fragment ProductView on ProductSearchItem {
productView {
__typename
sku
name
inStock
url
urlKey
images {
label
url
roles
}
... on ComplexProductView {
priceRange {
maximum {
final {
amount {
value
currency
}
}
regular {
amount {
value
currency
}
}
}
minimum {
final {
amount {
value
currency
}
}
regular {
amount {
value
currency
}
}
}
}
options {
id
title
values {
title
... on ProductViewOptionValueSwatch {
id
inStock
type
value
}
}
}
}
... on SimpleProductView {
price {
final {
amount {
value
currency
}
}
regular {
amount {
value
currency
}
}
}
}
}
highlights {
attribute
value
matched_words
}
}
`;

const Product = `
fragment Product on ProductSearchItem {
product {
__typename
sku
description {
html
}
short_description {
html
}
name
canonical_url
small_image {
url
}
image {
url
}
thumbnail {
url
}
price_range {
minimum_price {
fixed_product_taxes {
amount {
value
currency
}
label
}
regular_price {
value
currency
}
final_price {
value
currency
}
discount {
percent_off
amount_off
}
}
maximum_price {
fixed_product_taxes {
amount {
value
currency
}
label
}
regular_price {
value
currency
}
final_price {
value
currency
}
discount {
percent_off
amount_off
}
}
}
}
}
`;

export { Facet, ProductView, Product };
26 changes: 26 additions & 0 deletions packages/extensions/venia-pwa-live-search/src/api/graphql.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
async function getGraphQL(
query = '',
variables = {},
store = '',
baseUrl = ''
) {
const graphqlEndpoint = baseUrl
? `${baseUrl}/graphql`
: `${window.origin}/graphql`;

const response = await fetch(graphqlEndpoint, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Store: store
},
body: JSON.stringify({
query,
variables
})
});

return response.json();
}

export { getGraphQL };
94 changes: 94 additions & 0 deletions packages/extensions/venia-pwa-live-search/src/api/mutations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
const CREATE_EMPTY_CART = `
mutation createEmptyCart($input: createEmptyCartInput) {
createEmptyCart(input: $input)
}
`;

const ADD_TO_CART = `
mutation addProductsToCart(
$cartId: String!
$cartItems: [CartItemInput!]!
) {
addProductsToCart(
cartId: $cartId
cartItems: $cartItems
) {
cart {
items {
product {
name
sku
}
quantity
}
}
user_errors {
code
message
}
}
}
`;

const ADD_TO_WISHLIST = `
mutation addProductsToWishlist(
$wishlistId: ID!
$wishlistItems: [WishlistItemInput!]!
) {
addProductsToWishlist(
wishlistId: $wishlistId
wishlistItems: $wishlistItems
) {
wishlist {
id
name
items_count
items_v2 {
items {
id
product {
uid
name
sku
}
}
}
}
}
}
`;

const REMOVE_FROM_WISHLIST = `
mutation removeProductsFromWishlist (
$wishlistId: ID!
$wishlistItemsIds: [ID!]!
) {
removeProductsFromWishlist(
wishlistId: $wishlistId
wishlistItemsIds: $wishlistItemsIds
) {
wishlist {
id
name
items_count
items_v2 {
items {
id
product {
uid
name
sku
}
}
}
}
}
}
`;

export {
CREATE_EMPTY_CART,
ADD_TO_CART,
ADD_TO_WISHLIST,
REMOVE_FROM_WISHLIST
};
Loading