@stackend/api
Version:
JS bindings to api.stackend.com
300 lines • 10.1 kB
TypeScript
import { Checkout, UserError, Collection, GetCollectionRequest, GetCollectionResult, GetProductResult, GetProductsResult, ListProductsAndTypesResult, ListProductsRequest, ListProductTypesResult, MultipleProductListingsResult, Product, ProductVariant, SlimProduct, Country, AddressFieldName, SlimCollection, Cart } from './index';
import { ProductTypeTree } from './ProductTypeTree';
import { PageInfo, GraphQLList } from '../util/graphql';
import { CustomerType, TradeRegion, VatType } from './vat';
import { CurrencyInfo } from './currency';
export declare const SET_SHOP_DEFAULTS = "SET_SHOP_DEFAULTS";
export declare const RECEIVE_PRODUCT_TYPES = "RECEIVE_PRODUCT_TYPES";
export declare const RECEIVE_PRODUCT = "RECEIVE_PRODUCT";
export declare const RECEIVE_MULTIPLE_PRODUCTS = "RECEIVE_MULTIPLE_PRODUCTS";
export declare const RECEIVE_LISTING = "RECEIVE_LISTING";
export declare const RECEIVE_LISTINGS = "RECEIVE_LISTINGS";
export declare const RECEIVE_COLLECTION = "RECEIVE_COLLECTION";
export declare const RECEIVE_COLLECTIONS = "RECEIVE_COLLECTIONS";
export declare const RECEIVE_COLLECTION_LIST = "RECEIVE_COLLECTION_LIST";
export declare const RECEIVE_SHOPIFY_DOMAIN_REFERENCE_URL_ID = "RECEIVE_SHOPIFY_DOMAIN_REFERENCE_URL_ID";
export declare const SHOP_CLEAR_CACHE = "SHOP_CLEAR_CACHE";
export declare const BASKET_UPDATED = "BASKET_UPDATED";
export declare const ADD_TO_BASKET = "ADD_TO_BASKET";
export declare const REMOVE_FROM_BASKET = "REMOVE_FROM_BASKET";
export declare const RECEIVE_CHECKOUT = "RECEIVE_CHECKOUT";
export declare const CLEAR_CHECKOUT = "CLEAR_CHECKOUT";
export declare const RECEIVE_COUNTRIES = "RECEIVE_COUNTRIES";
export declare const RECEIVE_ADDRESS_FIELDS = "RECEIVE_ADDRESS_FIELDS";
export declare const SET_VATS = "SET_VATS";
export declare const SET_CUSTOMER_VAT_INFO = "SET_CUSTOMER_VAT_INFO";
export declare const RECEIVE_CURRENCY = "RECEIVE_CURRENCY";
export declare const RECEIVE_CART = "RECEIVE_CART";
export declare const CLEAR_CART = "CLEAR_CART";
export declare const SET_IS_SHOPIFY_APP = "SET_IS_SHOPIFY_APP";
export declare const SET_ENABLE_CART_NOTIFICATIONS = "SET_ENABLE_CART_NOTIFICATIONS";
export declare const DEFAULT_PRODUCT_TYPE = "";
export interface ShopConfig {
/** Shopify domain */
domain: string;
/** Storefront access token */
accessToken: string;
/** Country code */
countryCode: string;
/** Api version YYYY-MM */
apiVersion: string;
}
export interface AbstractProductListing extends PageInfo {
/** Cursor not next page */
nextCursor: string | null;
/** Cursor to previous page */
previousCursor: string | null;
/**
* The ListProductsRequest
*/
selection: ListProductsRequest;
}
export interface SlimProductListing extends AbstractProductListing {
/**
* Products for this page in the listing
*/
products: Array<SlimProduct>;
}
export interface VatState {
/** Should the UI display prices using VAT by default? */
showPricesUsingVAT: boolean;
/** Shops origin */
shopCountryCode: string;
/** Country code of the customer */
customerCountryCode: string | null;
/** Trade region of the customer */
customerTradeRegion: TradeRegion;
/** Type of customer */
customerType: CustomerType | null;
/** VAT rates as percent for the shops country */
vatRates: {
[VatType.STANDARD]: number | boolean;
[VatType.REDUCED]: number | boolean;
[VatType.REDUCED_ALT]: number | boolean;
[VatType.SUPER_REDUCED]: number | boolean;
[VatType.PARKING]: number | boolean;
};
/** Should vat price be shown for shipping rates? */
showVatForShipping: boolean;
/** Overrides from the standard vat rate
* Maps from product collection to VatType
*/
overrides: {
[collectionHandle: string]: VatType;
};
}
export interface ShopDefaults {
/**
* Default image size for products (1024)
*/
imageMaxWidth: number;
/**
* Default image size for product listings (256)
*/
listingImageMaxWidth: number;
/**
* Default page size (20)
*/
pageSize: number;
}
export interface ShopState {
/**
* Default settings for the shop
*/
defaults: ShopDefaults;
/**
* Product types
*/
productTypes: Array<string>;
/**
* Product types as a tree
*/
productTypeTree: ProductTypeTree;
/**
* Products by handle
*/
products: {
[handle: string]: Product;
};
/**
* Product listing arranged by getProductListKey
*/
productListings: {
[key: string]: SlimProductListing;
};
/**
* Collections of products arranged by handle
*/
collections: {
[handle: string]: Collection;
};
/**
* All collections as a list
*/
allCollections: Array<SlimCollection> | null;
basketUpdated: number;
/**
* Current cart, if any
*/
cart: Cart | null;
/**
* Current checkout, if any
*/
checkout: Checkout | null;
/**
* Last checkout errors, if any
*/
checkoutUserErrors: Array<UserError> | null;
/**
* Country codes, or null if not loaded
*/
countryCodes: Array<string> | null;
/**
* Countries by code
*/
countriesByCode: {
[code: string]: Country;
};
/**
* Required Address fields by country code
*/
addressFieldsByCountryCode: {
[code: string]: AddressFieldName[][];
};
/**
* Vats
*/
vats: VatState | null;
/**
* Currencies
*/
currencies: {
[currencyCode: string]: CurrencyInfo;
};
/**
* Reference Url id used for basket notification comments
*/
shopifyDomainReferenceUrlId: number;
/**
* Should cart notifications be enabled? (Posts a comment when someone adds a product to their cart)
*/
enableCartNotifications: boolean;
/**
* True if running as shopify app extension that requires integration with the shopify store.
*/
isShopifyApp: boolean;
}
export declare type SetShopDefaultsAction = {
type: typeof SET_SHOP_DEFAULTS;
defaults: ShopDefaults;
};
export declare type ReceiveProductTypesAction = {
type: typeof RECEIVE_PRODUCT_TYPES;
json: ListProductTypesResult;
};
export declare type ReceiveProductAction = {
type: typeof RECEIVE_PRODUCT;
json: GetProductResult;
};
export declare type ReceiveMultipleProductsAction = {
type: typeof RECEIVE_MULTIPLE_PRODUCTS;
json: GetProductsResult;
};
export declare type ReceiveListingAction = {
type: typeof RECEIVE_LISTING;
json: ListProductsAndTypesResult;
key: string;
request: ListProductsRequest;
};
export declare type ReceiveListingsAction = {
type: typeof RECEIVE_LISTINGS;
listings: MultipleProductListingsResult;
};
export declare type ReceiveCollectionAction = {
type: typeof RECEIVE_COLLECTION;
json: GetCollectionResult;
request: GetCollectionRequest;
};
export declare type ReceiveCollectionsAction = {
type: typeof RECEIVE_COLLECTIONS;
collections: {
[handle: string]: Collection;
};
};
export declare type ReceiveCollectionListAction = {
type: typeof RECEIVE_COLLECTION_LIST;
collections: GraphQLList<SlimCollection>;
};
export declare type ReceiveShopifyDomainReferenceUrlId = {
type: typeof RECEIVE_SHOPIFY_DOMAIN_REFERENCE_URL_ID;
shopifyDomainReferenceUrlId: number;
};
export declare type ClearCacheAction = {
type: typeof SHOP_CLEAR_CACHE;
};
export declare type ClearCartAction = {
type: typeof CLEAR_CART;
};
export declare type ReceiveCartAction = {
type: typeof RECEIVE_CART;
cart: Cart | null;
};
export declare type AddToBasketAction = {
type: typeof ADD_TO_BASKET;
product: Product;
variantId: string;
variant: ProductVariant;
quantity: number;
};
export declare type RemoveFromBasketAction = {
type: typeof REMOVE_FROM_BASKET;
product: Product;
variant: ProductVariant;
variantId: string;
quantity: number;
};
export declare type BasketUpdatedAction = {
type: typeof BASKET_UPDATED;
};
export declare type ReceiveCheckoutAction = {
type: typeof RECEIVE_CHECKOUT;
checkoutUserErrors: Array<UserError> | null;
checkout: Checkout;
};
export declare type ClearCheckoutAction = {
type: typeof CLEAR_CHECKOUT;
};
export declare type ReceiveCountriesAction = {
type: typeof RECEIVE_COUNTRIES;
countries: Array<Country>;
};
export declare type ReceiveAddressFieldsAction = {
type: typeof RECEIVE_ADDRESS_FIELDS;
countryCode: string;
addressFields: AddressFieldName[][];
};
export declare type SetVATsAction = {
type: typeof SET_VATS;
vats: VatState;
};
export declare type SetCustomerVATInfoAction = {
type: typeof SET_CUSTOMER_VAT_INFO;
customerCountryCode?: string;
customerTradeRegion?: TradeRegion;
customerType?: CustomerType;
};
export declare type ReceiveCurrencyAction = {
type: typeof RECEIVE_CURRENCY;
currency: CurrencyInfo;
};
export declare type SetIsShopifyAppAction = {
type: typeof SET_IS_SHOPIFY_APP;
shopifyApp: boolean;
};
export declare type SetEnableCartNotificationsAction = {
type: typeof SET_ENABLE_CART_NOTIFICATIONS;
enableCartNotifications: boolean;
};
export declare type ShopActions = SetShopDefaultsAction | ReceiveProductTypesAction | ReceiveProductAction | ReceiveMultipleProductsAction | ReceiveListingAction | ReceiveListingsAction | ReceiveCollectionAction | ReceiveCollectionsAction | ReceiveCollectionListAction | ReceiveShopifyDomainReferenceUrlId | ClearCacheAction | AddToBasketAction | RemoveFromBasketAction | BasketUpdatedAction | ReceiveCheckoutAction | ClearCheckoutAction | ReceiveCountriesAction | ReceiveAddressFieldsAction | SetVATsAction | SetCustomerVATInfoAction | ReceiveCurrencyAction | ClearCartAction | ReceiveCartAction | SetIsShopifyAppAction | SetEnableCartNotificationsAction;
export default function shopReducer(state: ShopState | undefined, action: ShopActions): ShopState;
//# sourceMappingURL=shopReducer.d.ts.map