Interface TypeScript tipada e simplificada para todas as operações da Storefront API.
npm install @meu-site/storefront-sdk import { createStorefrontClient } from '@meu-site/storefront-sdk';
const storefront = createStorefrontClient({
hostname: 'minhaloja',
baseUrl: 'https://minhaloja.acessocomercial.com'
}); // Listar produtos
const products = await storefront.products.list({ first: 10 });
// Buscar produto por ID
const product = await storefront.products.getById('product-id'); // Consultar carrinho
const cart = await storefront.cart.get();
// Adicionar item
await storefront.cart.addItem({ productId: 'abc', quantity: 1 });
// Remover item
await storefront.cart.removeItem({ itemId: 'item-id' });
// Aplicar cupom
await storefront.cart.applyCoupon({ code: 'DESCONTO10' });
// Calcular frete
await storefront.cart.calculateShipping({ zipCode: '01001000' }); // Login
await storefront.auth.login({
email: 'cliente@email.com',
password: 'senha123'
});
// Signup
await storefront.auth.signup({
name: 'João Silva',
email: 'joao@email.com',
password: 'senha123'
});
// Logout
await storefront.auth.logout();
// Google login
await storefront.auth.googleLogin({ token: 'google-oauth-token' });
// Solicitar reset de senha
await storefront.auth.resetPassword({ email: 'joao@email.com' }); // Listar pedidos do cliente
const orders = await storefront.orders.list();
// Finalizar checkout
await storefront.orders.checkout({ /* checkout data */ }); // Dados da loja
const store = await storefront.store.get();
// Seções da homepage
const sections = await storefront.store.getSections();
// Menus de navegação
const menus = await storefront.store.getMenus(); O SDK exporta todos os tipos para uso direto:
import type {
Product,
ShoppingCart,
ShoppingCartProduct,
ShoppingCartCoupon,
Store,
Image,
Order,
User,
} from '@meu-site/storefront-sdk'; npm run update # Faz introspection na API e gera schema.graphql