Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@types/shopify-buy

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/shopify-buy - npm Package Compare versions

Comparing version 2.10.10 to 2.17.0

1871

shopify-buy/index.d.ts

@@ -1,2 +0,2 @@

// Type definitions for shopify-buy 2.10
// Type definitions for shopify-buy 2.17
// Project: https://github.com/Shopify/js-buy-sdk#readme

@@ -8,497 +8,1746 @@ // Definitions by: Martin Köhn <https://github.com/openminder>

// Maciej Baron <https://github.com/MaciekBaron>
// Martin Badin <https://github.com/martin-badin>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.7
/**
* The JS Buy SDK is a lightweight library that allows you to build ecommerce into any website.
* It is based on Shopify’s API and provides the ability to retrieve products and collections from your shop,
* add products to a cart, and checkout.
* It can render data on the client side or server. This will allow you to add ecommerce functionality to any
* website or javascript application. This is helpful if you already have a website and need to add ecommerce
* or only need a simple buy button on your site.
*/
declare namespace ShopifyBuy {
export function buildClient(config: Config): Client;
/**
* Cart
*/
interface Cart extends Node {
attribute?: Attribute;
attributes: Attribute[];
buyerIdentity: CartBuyerIdentity;
checkoutUrl: URL;
cost: CartCost;
createdAt: DateTime;
discountAllocations: CartDiscountAllocation[];
discountCodes: CartDiscountCode[];
note: string;
totalQuantity: number;
updatedAt: DateTime;
/**
* @deprecated
*/
estimatedCost: CartEstimatedCost;
deliveryGroups: CartDeliveryGroup[];
lines: CartLine[];
}
export interface Client {
product: ShopifyBuy.ProductResource;
collection: ShopifyBuy.CollectionResource;
checkout: ShopifyBuy.CheckoutResource;
shop: ShopResource;
image: Image;
fetchNextPage<T extends GraphModel>(nextArray: T[]): T[];
interface CartAutomaticDiscountAllocation {
discountedAmount: MoneyV2;
title: string;
}
export interface Config {
domain: string;
storefrontAccessToken: string;
language?: string | undefined;
interface CartBuyerIdentity {
countryCode?: CountryCode;
customer?: Customer;
deliveryAddressPreferences: DeliveryAddress[];
email?: string;
phone?: string;
purchasingCompany?: PurchasingCompany;
}
export interface ProductResource {
fetch(id: string): Promise<Product>;
fetchAll(pageSizeopt?: number): Promise<Product[]>;
fetchByHandle(handle: string): Promise<Product>;
fetchMultiple(ids: string[]): Promise<Product[]>;
fetchQuery(query: Query): Promise<Product[]>;
interface CartCodeDiscountAllocation {
code: string;
discountedAmount: MoneyV2;
}
/**
* Product Helper Namespace
* @link https://shopify.github.io/js-buy-sdk/ProductResource.html
*/
variantForOptions(product: Product, options: Option): ProductVariant;
interface CartDeliveryGroup extends Node {
deliveryAddress: MailingAddress;
deliveryOptions: CartDeliveryOption[];
selectedDeliveryOption?: CartDeliveryOption;
cartLines: CartLine;
}
export interface CollectionResource {
fetch(id: string): Promise<Product[]>;
fetchWithProducts(id: string): Promise<any[]>; // TODO fix to be a type: Docs: Fetches a single collection by ID on the shop, not including products.
fetchAll(pageSizeopt?: number): Promise<any[]>; // TODO fix to be a type: Docs: Fetches all collections on the shop, not including products.
fetchAllWithProducts(): Promise<any[]>; // TODO fix to be a type: DOC: Fetches all collections on the shop, including products.
fetchByHandle(handle: string): Promise<any[]>; // TODO fix to be a type: DOC: Fetches a collection by handle on the shop. Assuming it does not give products
fetchQuery(query: Query): Promise<any[]>; // TODO fix to be a type: DOC: Fetches a collection by handle on the shop. Assuming it does not give products
interface CartDeliveryOption {
code?: string;
deliveryMethodType: DeliveryMethodType;
description?: string;
estimatedCost: MoneyV2;
handle: string;
title?: string;
}
export interface CheckoutResource {
create(
email?: string,
lineItems?: LineItem[],
shippingAddress?: Address,
note?: string,
customAttributes?: AttributeInput[],
): Promise<Cart>;
interface CartDiscountCode {
applicable: boolean;
code: string;
}
fetch(id: string): Promise<Cart>;
interface CartEstimatedCost {
checkoutChargeAmount: MoneyV2;
subtotalAmount: MoneyV2;
totalAmount: MoneyV2;
totalDutyAmount?: MoneyV2;
totalTaxAmount?: MoneyV2;
}
addLineItems(checkoutId: string | number, lineItems: LineItemToAdd[]): Promise<Cart>;
interface CartLine extends Node {
attribute?: Attribute;
attributes: Attribute[];
cost: CartLineCost;
discountAllocations: CartDiscountAllocation[];
merchandise: Merchandise;
quantity: number;
sellingPlanAllocation?: SellingPlanAllocation;
estimatedCost: MoneyV2;
}
interface CartLineEstimatedCost {
amount: MoneyV2;
compareAtAmount?: MoneyV2;
subtotalAmount: MoneyV2;
totalAmount: MoneyV2;
}
/**
* Common
*/
interface ApiVersion {
displayName: string;
handle: string;
supported: boolean;
}
interface Attribute {
key: string;
value?: string;
}
interface Brand {
colors: BrandColors;
coverImage?: MediaImage;
logo?: MediaImage;
shortDescription?: string;
slogan?: string;
squareLogo?: MediaImage;
}
interface BrandColorGroup {
background: Color;
foreground: Color;
}
interface BrandColors {
primary: BrandColorGroup[];
secondary: BrandColorGroup[];
}
interface ContentEntry extends Node {
field?: Metafield;
handle: string;
type: string;
updatedAt: DateTime;
}
interface Country {
availableLanguages: Language[];
currency: Currency;
isoCode: CurrencyCode;
name: string;
unitSystem: UnitSystem;
}
interface Currency {
isoCode: CurrencyCode;
name: string;
symbol: string;
}
interface Domain {
host: string;
sslEnabled: boolean;
url: URL;
}
interface Filter {
id: string;
label: string;
type: FilterType;
values: FilterValue[];
}
interface FilterValue {
count: number;
id: string;
input: JSON;
label: string;
}
interface Image {
altText?: string;
height?: number;
id?: ID;
url: URL;
width?: number;
/**
* Remove all line items from cart
* @deprecated
*/
clearLineItems(checkoutId: string | number, lineItems: LineItem[]): Promise<Cart>;
originalSrc: URL;
/**
* Add items to cart. Updates cart's lineItems
* @deprecated
*/
addVariants(item: Item, nextItem?: Array<Item>): Promise<Cart>;
src: URL;
/**
* Remove a line item from cart based on line item id
* @deprecated
*/
removeLineItems(checkoutId: string | number, lineItemIds: string[]): Promise<Cart>;
transformedSrc: URL;
}
interface Language {
endonymName: string;
isoCode: LanguageCode;
name: string;
}
interface Localization {
availableCountries: Country[];
availableLanguages: Language[];
country: Country;
language: Language;
}
interface MailingAddress extends Node {
address1?: string;
address2?: string;
city?: string;
company?: string;
country?: string;
countryCodeV2?: CountryCode;
firstName?: string;
formatted: string[];
formattedArea?: string;
lastName?: string;
latitude?: number;
longitude?: number;
name?: string;
phone?: string;
province?: string;
provinceCode?: string;
zip?: string;
/**
* Add discount to cart
* @deprecated
*/
addDiscount(checkoutId: string | number, discountCode: string): Promise<Cart>;
countryCode?: string;
}
interface Metafield extends Node {
createdAt: DateTime;
description?: string;
key: string;
namespace: string;
parentResource: MetafieldParentResource;
reference?: MetafieldReference;
type: string;
updatedAt: DateTime;
value: string;
}
interface MoneyV2 {
amount: number;
currencyCode: CurrencyCode;
}
interface PageInfo {
endCursor?: string;
hasNextPage: boolean;
hasPreviousPage: boolean;
startCursor?: string;
}
interface QueryRoot {
blog?: Blog;
cart?: Cart;
collection?: Collection;
contentEntry?: ContentEntry;
customer?: Customer;
localization: Localization;
menu?: Menu;
node?: Node;
nodes: Node[];
page?: Page;
product?: Product;
productRecommendations?: Product[];
publicApiVersions: ApiVersion[];
shop: Shop;
/**
* Remove discounts from cart
* @deprecated
*/
removeDiscount(checkoutId: string | number): Promise<Cart>;
blogByHandle?: Blog;
/**
* Update line item quantities based on an array of line item ids
* @deprecated
*/
updateLineItems(checkoutId: string | number, lineItems: AttributeInput[]): Promise<Cart>;
collectionByHandle?: Collection;
/**
* @deprecated
*/
pageByHandle?: Page;
/**
* @deprecated
*/
productByHandle?: Product;
}
export interface ShopResource {
fetchInfo(): Promise<Shop>;
fetchPolicies(): Promise<Shop>;
interface SEO {
description?: string;
title?: string;
}
export interface Query {
/**
* query: title, collection_type, updated_at
* TODO probably will remove before Defintely Typed PR,
* as their community guidelines
*/
query: string;
sortKey: string;
after?: string | undefined;
before?: string | undefined;
first?: number | undefined;
last?: number | undefined;
reverse?: boolean | undefined;
/**
* Customers
*/
interface Customer extends Node, HasMetafields {
acceptsMarketing: boolean;
createdAt: DateTime;
defaultAddress?: MailingAddress;
displayName: string;
email?: string;
firstName?: string;
lastIncompleteCheckout?: Checkout;
lastName?: string;
numberOfOrders: number;
phone?: string;
tags: string[];
updatedAt: DateTime;
addresses: MailingAddress[];
orders: Order[];
}
export interface Product extends GraphModel {
interface CustomerAccessToken {
accessToken: string;
expiresAt: DateTime;
}
/**
* GraphQL
*/
// GraphQL Types - Scalars
type Color = string;
type DateTime = string;
type ID = string;
type URL = string;
type JSON = Record<string, unknown>;
// end GraphQL Types - Scalars
// GraphQL Types - Enums
enum ArticleSortKeys {
AUTHOR = 'author',
BLOG_TITLE = 'blog_title',
ID = 'id',
PUBLISHED_AT = 'published_at',
RELEVANCE = 'query',
TITLE = 'title',
UPDATED_AT = 'updated_at',
}
enum BlogSortKeys {
HANDLE = 'HANDLE',
ID = 'id',
RELEVANCE = 'query',
TITLE = 'title',
}
enum CardBrand {
AMERICAN_EXPRESS = 'AMERICAN_EXPRESS',
DINERS_CLUB = 'DINERS_CLUB',
DISCOVER = 'DISCOVER',
ELO = 'ELO',
JCB = 'JCB',
MASTERCARD = 'MASTERCARD',
UNIONPAY = 'UNIONPAY',
VISA = 'VISA',
}
enum CartErrorCode {
INVALID = 'INVALID',
INVALID_MERCHANDISE_LINE = 'INVALID_MERCHANDISE_LINE',
LESS_THAN = 'LESS_THAN',
MISSING_DISCOUNT_CODE = 'MISSING_DISCOUNT_CODE',
MISSING_NOTE = 'MISSING_NOTE',
}
enum CheckoutErrorCode {
ALREADY_COMPLETED = 'ALREADY_COMPLETED',
BAD_DOMAIN = 'BAD_DOMAIN',
BLANK = 'BLANK',
CART_DOES_NOT_MEET_DISCOUNT_REQUIREMENTS_NOTICE = 'CART_DOES_NOT_MEET_DISCOUNT_REQUIREMENTS_NOTICE',
CUSTOMER_ALREADY_USED_ONCE_PER_CUSTOMER_DISCOUNT_NOTICE = 'CUSTOMER_ALREADY_USED_ONCE_PER_CUSTOMER_DISCOUNT_NOTICE',
DISCOUNT_ALREADY_APPLIED = 'DISCOUNT_ALREADY_APPLIED',
DISCOUNT_DISABLED = 'DISCOUNT_DISABLED',
DISCOUNT_EXPIRED = 'DISCOUNT_EXPIRED',
DISCOUNT_LIMIT_REACHED = 'DISCOUNT_LIMIT_REACHED',
DISCOUNT_NOT_FOUND = 'DISCOUNT_NOT_FOUND',
EMPTY = 'EMPTY',
EXPIRED_QUEUE_TOKEN = 'EXPIRED_QUEUE_TOKEN',
GIFT_CARD_ALREADY_APPLIED = 'GIFT_CARD_ALREADY_APPLIED',
GIFT_CARD_CODE_INVALID = 'GIFT_CARD_CODE_INVALID',
GIFT_CARD_CURRENCY_MISMATCH = 'GIFT_CARD_CURRENCY_MISMATCH',
GIFT_CARD_DEPLETED = 'GIFT_CARD_DEPLETED',
GIFT_CARD_DISABLED = 'GIFT_CARD_DISABLED',
GIFT_CARD_EXPIRED = 'GIFT_CARD_EXPIRED',
GIFT_CARD_NOT_FOUND = 'GIFT_CARD_NOT_FOUND',
GIFT_CARD_UNUSABLE = 'GIFT_CARD_UNUSABLE',
GREATER_THAN_OR_EQUAL_TO = 'GREATER_THAN_OR_EQUAL_TO',
HIGHER_VALUE_DISCOUNT_APPLIED = 'HIGHER_VALUE_DISCOUNT_APPLIED',
INVALID = 'INVALID',
INVALID_COUNTRY_AND_CURRENCY = 'INVALID_COUNTRY_AND_CURRENCY',
INVALID_FOR_COUNTRY = 'INVALID_FOR_COUNTRY',
INVALID_FOR_COUNTRY_AND_PROVINCE = 'INVALID_FOR_COUNTRY_AND_PROVINCE',
INVALID_PROVINCE_IN_COUNTRY = 'INVALID_PROVINCE_IN_COUNTRY',
INVALID_QUEUE_TOKEN = 'INVALID_QUEUE_TOKEN',
INVALID_REGION_IN_COUNTRY = 'INVALID_REGION_IN_COUNTRY',
INVALID_STATE_IN_COUNTRY = 'INVALID_STATE_IN_COUNTRY',
LESS_THAN = 'LESS_THAN',
LESS_THAN_OR_EQUAL_TO = 'LESS_THAN_OR_EQUAL_TO',
LINE_ITEM_NOT_FOUND = 'LINE_ITEM_NOT_FOUND',
LOCKED = 'LOCKED',
MAXIMUM_DISCOUNT_CODE_LIMIT_REACHED = 'MAXIMUM_DISCOUNT_CODE_LIMIT_REACHED',
MISSING_PAYMENT_INPUT = 'MISSING_PAYMENT_INPUT',
NOT_ENOUGH_IN_STOCK = 'NOT_ENOUGH_IN_STOCK',
NOT_SUPPORTED = 'NOT_SUPPORTED',
PRESENT = 'PRESENT',
PRODUCT_NOT_AVAILABLE = 'PRODUCT_NOT_AVAILABLE',
SHIPPING_RATE_EXPIRED = 'SHIPPING_RATE_EXPIRED',
THROTTLED_DURING_CHECKOUT = 'THROTTLED_DURING_CHECKOUT',
TOO_LONG = 'TOO_LONG',
TOTAL_PRICE_MISMATCH = 'TOTAL_PRICE_MISMATCH',
UNABLE_TO_APPLY = 'UNABLE_TO_APPLY',
}
enum CollectionSortKeys {
ID = 'id',
RELEVANCE = 'query',
TITLE = 'title',
UPDATED_AT = 'updated_at',
}
// TODO: https://shopify.dev/api/storefront/unstable/enums/CountryCode
type CountryCode = string;
enum CropRegion {
BOTTOM = 'BOTTOM',
CENTER = 'CENTER',
LEFT = 'LEFT',
RIGHT = 'RIGHT',
TOP = 'TOP',
}
// TODO: https://shopify.dev/api/storefront/unstable/enums/CurrencyCode
type CurrencyCode = string;
enum CustomerErrorCode {
ALREADY_ENABLED = 'ALREADY_ENABLED',
BAD_DOMAIN = 'BAD_DOMAIN',
BLANK = 'BLANK',
CONTAINS_HTML_TAGS = 'CONTAINS_HTML_TAGS',
CONTAINS_URL = 'CONTAINS_URL',
CUSTOMER_DISABLED = 'CUSTOMER_DISABLED',
INVALID = 'INVALID',
INVALID_MULTIPASS_REQUEST = 'INVALID_MULTIPASS_REQUEST',
NOT_FOUND = 'NOT_FOUND',
PASSWORD_STARTS_OR_ENDS_WITH_WHITESPACE = 'PASSWORD_STARTS_OR_ENDS_WITH_WHITESPACE',
TAKEN = 'TAKEN',
TOKEN_INVALID = 'TOKEN_INVALID',
TOO_LONG = 'TOO_LONG',
TOO_SHORT = 'TOO_SHORT',
UNIDENTIFIED_CUSTOMER = 'UNIDENTIFIED_CUSTOMER',
}
enum DeliveryMethodType {
LOCAL = 'LOCAL',
NONE = 'NONE',
PICKUP_POINT = 'PICKUP_POINT',
PICK_UP = 'PICK_UP',
RETAIL = 'RETAIL',
SHIPPING = 'SHIPPING',
}
enum DigitalWallet {
ANDROID_PAY = 'ANDROID_PAY',
APPLE_PAY = 'APPLE_PAY',
FACEBOOK_PAY = 'FACEBOOK_PAY',
GOOGLE_PAY = 'GOOGLE_PAY',
SHOPIFY_PAY = 'SHOPIFY_PAY',
}
enum DiscountApplicationAllocationMethod {
ACROSS = 'ACROSS',
EACH = 'EACH',
/**
* A product description.
* @deprecated
*/
description: string;
ONE = 'ONE',
}
// TODO: https://shopify.dev/api/storefront/unstable/enums/DiscountApplicationTargetSelection
type DiscountApplicationTargetSelection = string;
// TODO: https://shopify.dev/api/storefront/unstable/enums/DiscountApplicationTargetType
type DiscountApplicationTargetType = string;
// TODO: https://shopify.dev/api/storefront/unstable/enums/FilterType
type FilterType = string;
// TODO: https://shopify.dev/api/storefront/unstable/enums/ImageContentType
type ImageContentType = string;
// TODO: https://shopify.dev/api/storefront/unstable/enums/LanguageCode
type LanguageCode = string;
// TODO: https://shopify.dev/api/storefront/unstable/enums/LocationSortKeys
type LocationSortKeys = string;
// TODO: https://shopify.dev/api/storefront/unstable/enums/MediaContentType
type MediaContentType = string;
// TODO: https://shopify.dev/api/storefront/unstable/enums/MediaHost
type MediaHost = string;
// TODO: https://shopify.dev/api/storefront/unstable/enums/MenuItemType
type MenuItemType = string;
// TODO: https://shopify.dev/api/storefront/unstable/enums/OrderCancelReason
type OrderCancelReason = string;
// TODO: https://shopify.dev/api/storefront/unstable/enums/OrderFinancialStatus
type OrderFinancialStatus = string;
// TODO: https://shopify.dev/api/storefront/unstable/enums/OrderFulfillmentStatus
type OrderFulfillmentStatus = string;
// TODO: https://shopify.dev/api/storefront/unstable/enums/OrderSortKeys
type OrderSortKeys = string;
// TODO: https://shopify.dev/api/storefront/unstable/enums/PageSortKeys
type PageSortKeys = string;
// TODO: https://shopify.dev/api/storefront/unstable/enums/PaymentTokenType
type PaymentTokenType = string;
// TODO: https://shopify.dev/api/storefront/unstable/enums/ProductCollectionSortKeys
type ProductCollectionSortKeys = string;
// TODO: https://shopify.dev/api/storefront/unstable/enums/ProductImageSortKeys
type ProductImageSortKeys = string;
// TODO: https://shopify.dev/api/storefront/unstable/enums/ProductMediaSortKeys
type ProductMediaSortKeys = string;
// TODO: https://shopify.dev/api/storefront/unstable/enums/ProductSortKeys
type ProductSortKeys = string;
// TODO: https://shopify.dev/api/storefront/unstable/enums/ProductVariantSortKeys
type ProductVariantSortKeys = string;
// TODO: https://shopify.dev/api/storefront/unstable/enums/SellingPlanCheckoutChargeType
type SellingPlanCheckoutChargeType = string;
// TODO: https://shopify.dev/api/storefront/unstable/enums/TransactionKind
type TransactionKind = string;
// TODO: https://shopify.dev/api/storefront/unstable/enums/TransactionStatus
type TransactionStatus = string;
// TODO: https://shopify.dev/api/storefront/unstable/enums/UnitPriceMeasurementMeasuredType
type UnitPriceMeasurementMeasuredType = string;
// TODO: https://shopify.dev/api/storefront/unstable/enums/UnitPriceMeasurementMeasuredUnit
type UnitPriceMeasurementMeasuredUnit = string;
// TODO: https://shopify.dev/api/storefront/unstable/enums/UnitSystem
type UnitSystem = string;
// TODO: https://shopify.dev/api/storefront/unstable/enums/WeightUnit
type WeightUnit = string;
// end GraphQL Types - Enums
// GraphQL Types - Unions
type DeliveryAddress = MailingAddress;
type Merchandise = ProductVariant;
type MetafieldParentResource =
| Article
| Blog
| Collection
| ContentEntry
| Customer
| Order
| Page
| Product
| ProductVariant
| Shop;
type MetafieldReference =
| Collection
| ContentEntry
| GenericFile
| MediaImage
| Page
| Product
| ProductVariant
| Video;
type PricingValue = MoneyV2 | PricingPercentageValue;
type SellingPlanCheckoutChargeValue = MoneyV2 | SellingPlanCheckoutChargePercentageValue;
type SellingPlanPriceAdjustmentValue =
| SellingPlanFixedAmountPriceAdjustment
| SellingPlanFixedPriceAdjustment
| SellingPlanPercentagePriceAdjustment;
// end GraphQL Types - Unions
// GraphQL Types - Interfaces
interface CartDiscountAllocation {
discountedAmount: MoneyV2;
}
interface DiscountApplication {
allocationMethod: DiscountApplicationAllocationMethod;
targetSelection: DiscountApplicationTargetSelection;
targetType: DiscountApplicationTargetType;
value: PricingValue;
}
interface DisplayableError {
field: string[];
message: string;
}
interface HasMetafields {
metafield?: Metafield;
metafields: Metafield[];
}
interface Media {
alt?: string;
mediaContentType: MediaContentType;
previewImage?: Image;
}
interface Node {
id: ID;
}
interface OnlineStorePublishable {
onlineStoreUrl?: URL;
}
// end GraphQL Types - Interfaces
// GraphQL Types - Input Objects
interface AttributeInput {
key: string;
value: string;
}
interface CartBuyerIdentityInput {
countryCode?: CountryCode;
customerAccessToken?: string;
deliveryAddressPreferences: DeliveryAddressInput;
email?: string;
phone?: string;
}
interface CartInput {
attributes?: AttributeInput[];
buyerIdentity?: CartBuyerIdentityInput;
discountCodes?: string[];
lines?: CartLineInput[];
note?: string;
}
interface CartLineInput {
attributes?: AttributeInput[];
merchandiseId: ID;
quantity?: number;
sellingPlanId?: number;
}
interface CartLineUpdateInput {
attributes?: AttributeInput[];
id: ID;
merchandiseId?: ID;
quantity?: number;
sellingPlanId?: ID;
}
interface CartSelectedDeliveryOptionInput {
deliveryGroupId: ID;
deliveryOptionHandle: string;
}
interface CheckoutAttributesUpdateV2Input {
allowPartialAddresses?: boolean;
customAttributes?: AttributeInput[];
note?: string;
}
interface CheckoutBuyerIdentityInput {
countryCode: CountryCode;
}
interface CheckoutCreateInput {
allowPartialAddresses?: boolean;
buyerIdentity?: CheckoutBuyerIdentityInput;
customAttributes?: AttributeInput[];
email?: string;
lineItems?: CheckoutLineItemInput[];
note?: string;
/**
* Product unique ID
* @deprecated
*/
id: string | number;
presentmentCurrencyCode?: CurrencyCode;
shippingAddress?: MailingAddressInput;
}
interface CheckoutLineItemInput {
customAttributes?: AttributeInput[];
quantity: number;
variantId: ID;
}
interface CheckoutLineItemUpdateInput {
customAttributes?: AttributeInput[];
id?: ID;
quantity?: number;
variantId?: ID;
}
interface ContentEntryHandleInput {
handle?: string;
type?: string;
}
interface CreditCardPaymentInputV2 {
billingAddress: MailingAddressInput;
idempotencyKey: string;
paymentAmount: MoneyInput;
test?: boolean;
vaultId: string;
}
interface CustomerAccessTokenCreateInput {
email: string;
password: string;
}
interface CustomerActivateInput {
activationToken: string;
password: string;
}
interface CustomerCreateInput {
acceptsMarketing?: boolean;
email: string;
firstName?: string;
lastName?: string;
password: string;
phone?: string;
}
interface CustomerResetInput {
password: string;
resetToken: string;
}
interface CustomerUpdateInput {
acceptsMarketing?: boolean;
email?: string;
firstName?: string;
lastName?: string;
password: string;
phone?: string;
}
interface DeliveryAddressInput {
deliveryAddress?: MailingAddressInput;
}
interface GeoCoordinateInput {
latitude: number;
longitude: number;
}
interface HasMetafieldsIdentifier {
key: string;
namespace: string;
}
interface ImageTransformInput {
crop?: CropRegion;
maxHeight?: number;
maxWidth?: number;
preferredContentType?: ImageContentType;
scale?: number;
}
interface MailingAddressInput {
address1?: string;
address2?: string;
city?: string;
company?: string;
country?: string;
firstName?: string;
lastName?: string;
phone?: string;
province?: string;
zip?: string;
}
interface MetafieldFilter {
key: string;
namespace: string;
value: string;
}
interface MoneyInput {
amount: number;
currencyCode: CurrencyCode;
}
interface PriceRangeFilter {
max?: number;
min?: number;
}
interface ProductFilter {
available?: boolean;
price?: PriceRangeFilter;
productMetafield?: MetafieldFilter;
productType?: string;
productVendor?: string;
tag?: string;
variantMetafield?: MetafieldFilter;
variantOption?: VariantOptionFilter;
}
interface SelectedOptionInput {
name: string;
value: string;
}
interface TokenizedPaymentInputV3 {
billingAddress: MailingAddressInput;
idempotencyKey: string;
identifier?: string;
paymentAmount: MoneyInput;
paymentData: string;
test?: boolean;
type: PaymentTokenType;
}
interface VariantOptionFilter {
name?: string;
value?: string;
}
// end GraphQL Types - Input Objects
/**
* Checkout
*/
interface AppliedGiftCard extends Node {
amountUsed: MoneyV2;
balance: MoneyV2;
lastCharacters: string;
presentmentAmountUsed: MoneyV2;
/**
* An Array of Objects that contain meta data about an image including src of the images.
* @deprecated
*/
images: Array<Image>;
amountUsedV2: MoneyV2;
/**
* All variants of a product.
* @deprecated
*/
variants: Array<ProductVariant>;
balanceV2: MoneyV2;
}
interface AutomaticDiscountApplication extends DiscountApplication {
title: string;
}
interface AvailableShippingRates {
ready: boolean;
shippingRates: null | ShippingRate[];
}
interface CartCost {
checkoutChargeAmount: MoneyV2;
subtotalAmount: MoneyV2;
subtotalAmountEstimated: boolean;
totalAmount: MoneyV2;
totalAmountEstimated: boolean;
totalTaxAmount: MoneyV2;
totalTaxAmountEstimated: boolean;
}
interface CartCustomDiscountAllocation extends CartDiscountAllocation {
title: string;
}
interface CartLineCost {
amountPerQuantity: MoneyV2;
compareAtAmountPerQuantity: MoneyV2;
subtotalAmount: MoneyV2;
totalAmount: MoneyV2;
}
interface Checkout extends Node {
appliedGiftCards: AppliedGiftCard[];
availableShippingRates?: AvailableShippingRates;
buyerIdentity: CheckoutBuyerIdentity;
completedAt?: DateTime;
createdAt: DateTime;
currencyCode: CurrencyCode;
customAttributes: Attribute[];
email?: string;
lineItemsSubtotalPrice: MoneyV2;
note?: string;
order?: Order;
orderStatusUrl?: URL;
paymentDue: MoneyV2;
ready: boolean;
requiresShipping: boolean;
shippingAddress?: MailingAddress;
shippingDiscountAllocations: DiscountAllocation[];
shippingLine?: ShippingRate;
subtotalPrice: MoneyV2;
taxExempt: boolean;
taxesIncluded: boolean;
totalDuties?: MoneyV2;
totalPrice: MoneyV2;
totalTax: MoneyV2;
updatedAt: DateTime;
webUrl: URL;
/**
* Get an array of Product Options. Product Options can be used to define
* the currently selectedVariant from which you can get a checkout url (ProductVariant.checkoutUrl)
* or can be added to a cart (Cart.createLineItemsFromVariants).
* @deprecated
*/
options: Array<Option>;
paymentDueV2: MoneyV2;
/**
* Retrieve variant for currently selected options. By default the first value in each option is selected
* which means selectedVariant will never be null. With a selectedVariant you can
* create checkout url (ProductVariant.checkoutUrl) or
* it can be added to a cart (Cart.createLineItemsFromVariants).
* @deprecated
*/
selectedVariant: ProductVariant;
subtotalPriceV2: MoneyV2;
/**
* Retrieve image for currently selected variantImage.
* @deprecated
*/
selectedVariantImage: Image;
totalPriceV2: MoneyV2;
/**
* A read only Array of Strings represented currently selected option values. eg. ["Large", "Red"]
* @deprecated
*/
selections: Array<string>;
totalTaxV2: MoneyV2;
discountApplications: DiscountApplication[];
lineItems: CheckoutLineItem[];
}
/**
* The product title
*/
interface CheckoutBuyerIdentity {
countryCode: CountryCode;
}
interface CheckoutLineItem extends Node {
customAttributes: Attribute[];
discountAllocations: DiscountAllocation[];
quantity: number;
title: string;
unitPrice?: MoneyV2;
variant?: ProductVariant;
}
interface Company {
createdAt: DateTime;
externalId?: string;
name: string;
updatedAt: DateTime;
}
interface CompanyContact {
createdAt: DateTime;
locale?: string;
title?: string;
updatedAt: DateTime;
}
interface CompanyLocation {
createdAt: DateTime;
externalId?: string;
locale?: string;
name: string;
updatedAt: DateTime;
}
interface CreditCard {
brand?: string;
expiryMonth?: number;
expiryYear?: number;
firstDigits?: string;
firstName?: string;
lastDigits?: string;
lastName?: string;
maskedNumber?: string;
}
interface DiscountAllocation {
allocatedAmount: MoneyV2;
discountApplication: DiscountApplication;
}
interface DiscountCodeApplication extends DiscountApplication {
applicable: boolean;
code: string;
}
interface Location extends Node {
address: LocationAddress;
name: string;
}
interface ManualDiscountApplication extends DiscountApplication {
description?: string;
title: string;
}
interface Payment extends Node {
amount: MoneyV2;
billingAddress?: MailingAddress;
checkout: Checkout;
creditCard?: CreditCard;
errorMessage?: string;
idempotencyKe?: string;
nextActionUrl?: URL;
ready: boolean;
test: boolean;
transaction?: Transaction;
}
interface PaymentSettings {
acceptedCardBrands: CardBrand[];
cardVaultUrl: URL;
countryCode: CountryCode;
currencyCode: CurrencyCode;
enabledPresentmentCurrencies: CurrencyCode[];
shopifyPaymentsAccountId?: string;
supportedDigitalWallets: DigitalWallet;
}
interface PricingPercentageValue {
percentage: number;
}
interface PurchasingCompany {
company: Company;
contact?: CompanyContact;
location: CompanyLocation;
}
interface ScriptDiscountApplication extends DiscountApplication {
title: string;
}
interface ShippingRate {
handle: string;
price: MoneyV2;
title: string;
/**
* The product’s vendor name
* @deprecated
*/
vendor: string;
priceV2: MoneyV2;
}
export interface ProductVariant extends GraphModel {
/**
* Variant in stock. Always true if inventory tracking is disabled.
*/
interface StoreAvailability {
available: boolean;
location: Location;
pickUpTime: string;
}
interface Transaction {
amount: MoneyV2;
kind: TransactionKind;
statusV2?: TransactionStatus;
test: boolean;
/**
* Compare at price for variant. The compareAtPrice would be the price of the
* product previously before the product went on sale.
* @deprecated
*/
compareAtPrice: string;
amountV2: MoneyV2;
/**
* Price of variant, formatted according to shop currency format string. For instance "$10.00"
* @deprecated
*/
formattedPrice: string;
status: TransactionStatus;
}
/**
* Online Store
*/
interface Article extends Node, HasMetafields, OnlineStorePublishable {
authorV2?: ArticleAuthor;
blog: Blog;
content: string;
contentHtml: string;
excerpt?: string;
excerptHtml?: string;
handle: string;
image?: Image;
publishedAt: DateTime;
seo?: SEO;
tags: string[];
title: string[];
/**
* Variant weight in grams. If no weight is defined grams will be 0.
* @deprecated
*/
grams: number;
author: ArticleAuthor;
comments: Comment[];
}
/**
* Variant unique ID
*/
id: string | number;
interface ArticleAuthor {
bio?: string;
email: string;
firstName: string;
lastName: string;
name: string;
}
/**
* Image for variant
*/
interface Blog extends Node, HasMetafields, OnlineStorePublishable {
articleByHandle?: Article;
authors: ArticleAuthor[];
handle: string;
seo?: SEO;
title: string;
articles: Article[];
}
image: Image;
interface Comment extends Node {
author: CommentAuthor;
content: string;
contentHtml: string;
}
interface CommentAuthor {
email: string;
name: string;
}
interface LocationAddress {
address1?: string;
address2?: string;
city?: string;
country?: string;
countryCode?: string;
formatted: string[];
latitude?: number;
longitude?: number;
phone?: string;
province?: string;
provinceCode?: string;
zip?: string;
}
interface Menu extends Node {
handle: string;
items: MenuItem[];
itemsCount: number;
title: string;
}
interface MenuItem extends Node {
items: MenuItem[];
resourceId?: ID;
tags: string[];
type: MenuItemType;
url: URL;
}
interface Page extends Node, HasMetafields, OnlineStorePublishable {
body: string;
bodySummary: string;
createdAt: DateTime;
handle: string;
seo: SEO;
title: string;
updatedAt: DateTime;
}
interface Shop extends Node, HasMetafields {
brand?: Brand;
description?: string;
moneyFormat: string;
name: string;
paymentSettings: PaymentSettings;
primaryDomain: Domain;
privacyPolicy?: ShopPolicy;
refundPolicy?: ShopPolicy;
shippingPolicy?: ShopPolicy;
shipsToCountries: CountryCode;
subscriptionPolicy?: ShopPolicyWithDefault;
termsOfService?: ShopPolicy;
}
interface ShopPolicy extends Node {
body: string;
handle: string;
title: string;
url: URL;
}
interface ShopPolicyWithDefault {
body: string;
handle: string;
id?: ID;
title: string;
url: URL;
}
interface UrlRedirect extends Node {
path: string;
target: string;
}
/**
* Orders
*/
interface Fulfillment {
trackingCompany: string;
trackingInfo: FulfillmentTrackingInfo[];
fulfillmentLineItems: FulfillmentLineItem[];
}
interface FulfillmentLineItem {
lineItem: OrderLineItem;
quantity: number;
}
interface FulfillmentTrackingInfo {
number: string;
url: URL;
}
interface Order extends Node, HasMetafields {
cancelReason?: OrderCancelReason;
canceledAt?: DateTime;
currencyCode: CurrencyCode;
currentSubtotalPrice: MoneyV2;
currentTotalDuties?: MoneyV2;
currentTotalPrice: MoneyV2;
currentTotalTax: MoneyV2;
customAttributes: Attribute[];
customerLocale?: string;
customerUrl?: URL;
edited: boolean;
email?: string;
financialStatus?: OrderFinancialStatus;
fulfillmentStatus: OrderFulfillmentStatus;
name: string;
orderNumber: number;
originalTotalDuties?: MoneyV2;
originalTotalPrice: MoneyV2;
phone?: string;
processedAt: DateTime;
shippingAddress?: MailingAddress;
shippingDiscountAllocations: DiscountAllocation[];
statusUrl: URL;
subtotalPrice?: MoneyV2;
successfulFulfillments?: Fulfillment[];
totalPrice: MoneyV2;
totalRefunded: MoneyV2;
totalShippingPrice: MoneyV2;
totalTax?: MoneyV2;
/**
* Image variants available for a variant.
* @deprecated
*/
imageVariant: Array<ImageVariant>;
subtotalPriceV2?: MoneyV2;
/**
* Option values associated with this variant, ex {name: "color", value: "Blue"}
* @deprecated
*/
optionValues: Array<OptionValue>;
totalPriceV2: MoneyV2;
/**
* Price of the variant. The price will be in the following form: "10.00"
* @deprecated
*/
price: string;
totalRefundedV2: MoneyV2;
/**
* ID of product variant belongs to
* @deprecated
*/
productId: string | number;
totalShippingPriceV2: MoneyV2;
/**
* Title of product variant belongs to
* @deprecated
*/
productTitle: string;
totalTaxV2?: MoneyV2;
discountApplications: DiscountAllocation[];
lineItems: OrderLineItem[];
}
/**
* Title of variant
*/
interface OrderLineItem {
currentQuantity: number;
customAttributes: Attribute[];
discountAllocations: DiscountAllocation[];
discountedTotalPrice: MoneyV2;
originalTotalPrice: MoneyV2;
quantity: number;
title: string;
variant?: ProductVariant;
}
/*
* Get a checkout url for a specific product variant.
* You can optionally pass a quantity.
* If no quantity is passed then quantity will default to 1.
*/
checkoutUrl(quantitiy: number): string;
/**
* Products
*/
interface Collection extends Node, HasMetafields, OnlineStorePublishable {
description: string;
descriptionHtml: string;
handle: string;
image: Image;
seo: SEO;
title: string;
updatedAt: DateTime;
products: Product[];
}
export interface Option {
/**
* name of option (ex. "Size", "Color")
*/
// interface ExternalVideo {}
interface GenericFile extends Node {
alt?: string;
mimeType?: string;
originalFileSize?: number;
previewImage?: Image;
url?: URL;
}
interface MediaImage extends Node, Media {
image: Image;
}
// interface Model3d {}
// interface Model3dSource {}
interface Product extends Node, HasMetafields, OnlineStorePublishable {
availableForSale: boolean;
compareAtPriceRange: ProductPriceRange;
createdAt: DateTime;
description: string;
descriptionHtml: string;
featuredImage: Image;
handle: string;
isGiftCard: boolean;
options: ProductOption[];
priceRange: ProductPriceRange;
productType: string;
publishedAt: DateTime;
requiresSellingPlan: boolean;
seo: SEO;
tags: string[];
title: string;
totalInventory?: number;
updatedAt: DateTime;
variantBySelectedOptions?: ProductVariant;
vendor: string;
collections: Collection[];
images: Image[];
media: Media[];
sellingPlanGroups: SellingPlanGroup[];
variants: ProductVariant[];
}
interface ProductOption extends Node {
name: string;
values: string;
}
/**
* get/set the currently selected option value with one of the values from the Product Options/values array.
* For instance if the option values array had the following ["Large", "Medium", "Small"] setting selected to be
* "Large", "Medium", or "Small" would be valid any other value would throw an Error.
*/
selected: string;
interface ProductPriceRange {
maxVariantPrice: MoneyV2;
minVariantPrice: MoneyV2;
}
/**
* an Array possible values for option. For instance if this option
* is a "Size" option an example value for values could be: ["Large", "Medium", "Small"]
*/
values: Array<OptionValue>;
interface ProductVariant extends Node, HasMetafields {
availableForSale: boolean;
barcode: string;
compareAtPrice: MoneyV2;
currentlyNotInStock: boolean;
image: Image;
price: MoneyV2;
product: Product;
quantityAvailable?: number;
requiresShipping: boolean;
selectedOptions: SelectedOption[];
sku?: string;
title: string;
unitPrice?: MoneyV2;
unitPriceMeasurement?: UnitPriceMeasurement;
weight?: number;
weightUnit?: WeightUnit;
sellingPlanAllocations: SellingPlanAllocation[];
storeAvailability: StoreAvailability[];
}
export interface OptionValue {
interface SelectedOption {
name: string;
option_id: string;
value: any;
value: string;
}
export interface CustomAttribute {
key: string;
interface SellingPlan extends Node {
checkoutCharge: SellingPlanCheckoutCharge;
description?: string;
name: string;
options: SellingPlanOption[];
priceAdjustments: SellingPlanPriceAdjustment[];
recurringDeliveries: boolean;
}
interface SellingPlanAllocation {
checkoutChargeAmount: MoneyV2;
priceAdjustments: SellingPlanAllocationPriceAdjustment[];
remainingBalanceChargeAmount: MoneyV2;
sellingPlan: SellingPlan;
}
interface SellingPlanAllocationPriceAdjustment {
compareAtPrice: MoneyV2;
perDeliveryPrice: MoneyV2;
price: MoneyV2;
unitPrice?: MoneyV2;
}
interface SellingPlanCheckoutCharge {
type: SellingPlanCheckoutChargeType;
value: SellingPlanCheckoutChargeValue;
}
interface SellingPlanCheckoutChargePercentageValue {
percentage: number;
}
interface SellingPlanFixedAmountPriceAdjustment {
adjustmentAmount: MoneyV2;
}
interface SellingPlanFixedPriceAdjustment {
price: MoneyV2;
}
interface SellingPlanGroup {
appName?: string;
name: string;
options: SellingPlanGroupOption[];
sellingPlans: SellingPlan[];
}
interface SellingPlanGroupOption {
name: string;
values: string[];
}
interface SellingPlanOption {
name: string;
value: string;
}
export interface CustomAttributeV2 {
customAttributes: {
key: string;
value: string;
}[];
interface SellingPlanPercentagePriceAdjustment {
adjustmentPercentage: number;
}
export interface Collection {
handle: string;
body_html: string;
image: Image;
id: string;
metafields: any[];
published: boolean;
published_at: string;
published_scope: string;
sort_order: string;
template_suffix: string;
title: string;
updated_at: string;
interface SellingPlanPriceAdjustment {
adjustmentValue: SellingPlanPriceAdjustmentValue;
orderCount?: number;
}
export interface Cart extends GraphModel {
interface UnitPriceMeasurement {
measuredType?: UnitPriceMeasurementMeasuredType;
quantityUnit?: UnitPriceMeasurementMeasuredUnit;
quantityValue: number;
referenceUnit?: UnitPriceMeasurementMeasuredUnit;
referenceValue: number;
}
interface Video extends Node, Media {
sources: VideoSource[];
}
interface VideoSource {
format: string;
height: number;
mimeType: string;
url: string;
width: number;
}
/**
* Config
*
* @see https://github.com/Shopify/js-buy-sdk/blob/master/src/config.js
*/
interface ConfigAttrs {
apiVersion?: string;
domain: string;
language?: string;
source?: string;
storefrontAccessToken: string;
/**
* Get checkout URL for current cart
* @deprecated
*/
checkoutUrl: string;
accessToken?: string;
/**
* @deprecated
*/
apiKey?: string;
}
class Config {
apiVersion: string;
domain: string;
language?: string;
source?: string;
storefrontAccessToken: string;
constructor(attrs: ConfigAttrs);
}
/**
* GraphQL client
*
* @see https://github.com/Shopify/js-buy-sdk/blob/master/src/graphql-client.js
*/
// TODO: implement from graphql-js-client
type GraphQLJSClient = unknown;
/**
* Collection resource
*
* @see https://github.com/Shopify/js-buy-sdk/blob/master/src/collection-resource.js
*/
class CollectionResource extends Resource {
/**
* get ID for current cart
* Fetches all collections on the shop, not including products.
* To fetch collections with products use [fetchAllsWithProducts]{@link Client#fetchAllsWithProducts}.
*/
id: string | number;
fetchAll(first?: number): Promise<Collection[]>;
/**
* Gets the total quantity of all line items. Example: you've added two variants
* with quantities 3 and 2. lineItemCount will be 5.
* Fetches all collections on the shop, including products.
*/
lineItemCount: number;
fetchAllWithProducts(options?: { first?: number; productsFirst?: number }): Promise<Collection[]>;
/**
* Get an Array of CartLineItemModel's
* Fetches a single collection by ID on the shop, not including products.
* To fetch the collection with products use [fetchWithProducts]{@link Client#fetchWithProducts}.
*/
lineItems: LineItem[];
fetch(id: ID): Promise<Collection>;
/**
* Get current subtotal price for all line items, before shipping, taxes, and discounts.
* Example: two items have been added to the cart that cost $1.25 then the subtotal will be 2.50
* Fetches a single collection by ID on the shop, including products.
*/
subtotalPrice: string;
fetchWithProducts(id: ID, options?: { productsFirst?: number }): Promise<Collection>;
/**
* Get completed at date.
* Fetches a collection by handle on the shop.
*/
completedAt: string | null;
fetchByHandle(handle: string): Promise<Collection>;
/**
* Get checkout url
* Fetches all collections on the shop that match the query.
*/
webUrl: string;
fetchQuery(options?: {
first?: number;
sortKey?: CollectionSortKeys;
query?: string;
reverse?: boolean;
}): Promise<Collection[]>;
}
export interface LineItem extends GraphModel {
/**
* Collection resource
*
* @see https://github.com/Shopify/js-buy-sdk/blob/master/src/collection-resource.js
*/
class CheckoutResource extends Resource {
/**
* Compare at price for variant. The compareAtPrice would be the price of the product
* previously before the product went on sale.
* If no compareAtPrice is set then this value will be null. An example value: "5.00".
* Fetches a checkout by ID.
*/
compareAtPrice: string | null;
fetch(id: ID): Promise<Checkout>;
/**
* Variant's weight in grams. If no weight is set then 0 is returned.
* Creates a checkout.
*/
grams: number;
create(input?: {
email?: string;
lineItems?: CheckoutLineItemInput[];
shippingAddress?: MailingAddressInput;
customAttributes?: AttributeInput[];
presentmentCurrencyCode?: CurrencyCode;
}): Promise<Checkout>;
/**
* A line item ID.
* Replaces the value of checkout's custom attributes and/or note with values defined in the input
*/
id: string | number;
updateAttributes(
checkoutId: ID,
input: {
allowPartialAddresses?: boolean;
customAttributes?: AttributeInput[];
note?: string;
},
): Promise<Checkout>;
/**
* Variant's image.
* Replaces the value of checkout's email address
*/
image: Image;
updateEmail(checkoutId: ID, email: string): Promise<Checkout>;
/**
* The total price for this line item. For instance if the variant costs 1.50 and you have a
* quantity of 2 then line_price will be 3.00.
* Adds line items to an existing checkout.
*/
linePrice: string;
addLineItems(checkoutId: ID, lineItems: CheckoutLineItemInput[]): Promise<Checkout>;
/**
* Price of the variant. For example: "5.00".
* Applies a discount to an existing checkout using a discount code.
*/
price: string;
addDiscount(checkoutId: ID, discountCode: string): Promise<Checkout>;
/**
* ID of variant's product.
* Removes the applied discount from an existing checkout.
*/
productId: string | number;
removeDiscount(checkoutId: ID): Promise<Checkout>;
/**
* Count of variants to order.
* Applies gift cards to an existing checkout using a list of gift card codes
*/
quantity: number;
addGiftCards(checkoutId: ID, giftCardCodes: string): Promise<Checkout>;
/**
* Product title of variant's parent product.
* Remove a gift card from an existing checkout
*/
title: string;
removeGiftCard(checkoutId: ID, appliedGiftCardId: ID): Promise<Checkout>;
/**
* ID of line item variant.
* Removes line items from an existing checkout.
*/
variantId: string | number;
removeLineItems(checkoutId: ID, lineItemIds: string[]): Promise<Checkout>;
/**
* Title of variant.
* Replace line items on an existing checkout.
*/
variantTitle: string;
}
replaceLineItems(checkoutId: ID, lineItems: CheckoutLineItemInput[]): Promise<Checkout>;
export interface LineItemToAdd {
variantId: string | number;
quantity: number;
customAttributes?: CustomAttribute[] | undefined;
}
/**
* Updates line items on an existing checkout.
*/
updateLineItems(checkoutId: ID, lineItems: CheckoutLineItemInput[]): Promise<Checkout>;
export interface Item {
variant: ProductVariant;
quantity: number;
/**
* Updates shipping address on an existing checkout.
*/
updateShippingAddress(checkoutId: ID, shippingAddress: MailingAddressInput): Promise<Checkout>;
}
export interface Address {
address1: String;
address2: String;
city: String;
company: String;
country: String;
firstName: String;
lastName: String;
phone: String;
province: String;
zip: String;
}
/**
* https://help.shopify.com/api/custom-storefronts/storefront-api/reference/input_object/attributeinput
* https://help.shopify.com/api/custom-storefronts/storefront-api/reference/input_object/checkoutlineitemupdateinput
* Image resource
*
* @see https://github.com/Shopify/js-buy-sdk/blob/master/src/image-resource.js
*/
export interface AttributeInput {
key?: string | undefined;
value?: string | undefined;
id?: string | number | undefined;
quantity?: number | undefined;
variantId?: string | undefined;
class ImageResource extends Resource {
helpers: {
/**
* Generates the image src for a resized image with maximum dimensions `maxWidth` and `maxHeight`.
* Images do not scale up.
*/
imageForSize(image: Image, options: { maxWidth: number; maxHeight: number }): string;
};
}
/**
* TODO Validate schema matches js-buy
* Derived from REST API Docs: https://help.shopify.com/api/custom-storefronts/storefront-api/reference/object/shop#fields
* Product resource
*
* @see https://github.com/Shopify/js-buy-sdk/blob/master/src/product-resource.js
*/
export interface Shop {
description: string;
moneyFormat: string;
name: string;
class ProductResource extends Resource {
/**
* TODO Add types for the Shop properties below
* PaymentSettings, ShopPolicy etc
* Fetches all products on the shop.
*/
paymentSettings: any;
primaryDomain: any;
privacyPolicy: any;
refundPolicy: any;
termsOfService: any;
fetchAll(first?: number): Promise<Product[]>;
/**
* Fetches a single product by ID on the shop.
*/
fetch(id: ID): Promise<Product>;
/**
* Fetches multiple products by ID on the shop.
*/
fetchMultiple(ids: ID[]): Promise<Product[]>;
/**
* Fetches a single product by handle on the shop.
*/
fetchByHandle(handle: string): Promise<Product>;
/**
* Fetches all products on the shop that match the query.
*/
fetchQuery(options?: {
first?: number;
sortKey?: ProductSortKeys;
query?: string;
reverse?: boolean;
}): Promise<Product[]>;
/**
* Find recommended products related to a given productId.
* To learn more about how recommendations are generated, see https://shopify.dev/themes/product-merchandising/recommendations.
*/
fetchRecommendations(productId: ID): Promise<Product[]>;
}
/**
* Internal Image description
* Resource
*
* @see https://github.com/Shopify/js-buy-sdk/blob/master/src/resource.js
*/
export interface Image extends GraphModel {
id: string | number;
created_at: string;
position: number;
updated_at: string;
product_id: string;
src: string;
variant_ids: Array<string>;
class Resource {
graphQLClient: GraphQLJSClient;
constructor(client: GraphQLJSClient);
}
export interface ImageVariant extends Image {
name: string;
dimensions: string;
src: string;
/**
* Shop Resource
*
* @see https://github.com/Shopify/js-buy-sdk/blob/master/src/shop-resource.js
*/
class ShopResource extends Resource {
/**
* Returns src URL for new image size/variant
* @param image The image you would like a different size for.
* @param options Image Max width and height configuration.
* Fetches shop information (`currencyCode`, `description`, `moneyFormat`, `name`, and `primaryDomain`).
* See the {@link https://help.shopify.com/api/storefront-api/reference/object/shop|Storefront API reference} for more information.
*/
imageForSize(image: Image, options: ImageOptions): string;
}
fetchInfo(): Promise<Shop>;
export interface ImageOptions {
maxWidth: number;
maxHeight: number;
/**
* Fetches shop policies (privacy policy, terms of service and refund policy).
*/
fetchPolicies(): Promise<Shop>;
}
}
let NO_IMAGE_URI: string;
interface FetchOptions {
body: string;
method: string;
mode: string;
headers: Record<string, string>;
}
/*
* Base Model for the higher level returned objects from the API using GraphQL
type FetchFunction = (url: string, options: FetchOptions) => Promise<unknown>;
declare class ShopifyBuy {
collection: ShopifyBuy.CollectionResource;
checkout: ShopifyBuy.CheckoutResource;
image: ShopifyBuy.ImageResource;
product: ShopifyBuy.ProductResource;
shop: ShopifyBuy.ShopResource;
graphQLClient: ShopifyBuy.GraphQLJSClient;
/**
* Primary entry point for building a new Client.
*/
export interface GraphModel {
attrs?: any;
onlineStoreUrl?: string | undefined;
}
static buildClient(config: ShopifyBuy.Config, fetchFunction?: FetchFunction): ShopifyBuy;
constructor(
config: ShopifyBuy.Config,
GraphQLClientClass?: ShopifyBuy.GraphQLJSClient,
fetchFunction?: FetchFunction,
);
/**
* Fetches the next page of models
*/
fetchNextPage<T extends ShopifyBuy.Node>(models: T[]): Promise<T[]>;
}
declare module 'shopify-buy' {
export = ShopifyBuy;
}
export = ShopifyBuy;
export as namespace ShopifyBuy;

11

shopify-buy/package.json
{
"name": "@types/shopify-buy",
"version": "2.10.10",
"version": "2.17.0",
"description": "TypeScript definitions for shopify-buy",

@@ -32,2 +32,7 @@ "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/shopify-buy",

"githubUsername": "MaciekBaron"
},
{
"name": "Martin Badin",
"url": "https://github.com/martin-badin",
"githubUsername": "martin-badin"
}

@@ -44,4 +49,4 @@ ],

"dependencies": {},
"typesPublisherContentHash": "3299d9a1eca8cfc9e46dfc74b08e4d7a35d7fc668c2b8d644c0eacac2bd226a7",
"typeScriptVersion": "3.8"
"typesPublisherContentHash": "aa722b40df1ab5cc4d3455a5fb5021d9226f24482ebc1eb8fc4b48a8f0eaabaa",
"typeScriptVersion": "4.2"
}

@@ -11,3 +11,3 @@ # Installation

### Additional Details
* Last updated: Fri, 28 Jan 2022 19:31:29 GMT
* Last updated: Thu, 16 Feb 2023 06:02:34 GMT
* Dependencies: none

@@ -17,2 +17,2 @@ * Global values: `ShopifyBuy`

# Credits
These definitions were written by [Martin Köhn](https://github.com/openminder), [Stephen Traiforos](https://github.com/straiforos), [Juan Manuel Incaurgarat](https://github.com/kilinkis), [Chris Worman](https://github.com/chrisworman-pela), and [Maciej Baron](https://github.com/MaciekBaron).
These definitions were written by [Martin Köhn](https://github.com/openminder), [Stephen Traiforos](https://github.com/straiforos), [Juan Manuel Incaurgarat](https://github.com/kilinkis), [Chris Worman](https://github.com/chrisworman-pela), [Maciej Baron](https://github.com/MaciekBaron), and [Martin Badin](https://github.com/martin-badin).
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc