pinelab-storefront-client
Advanced tools
Comparing version 0.43.0 to 0.44.0
@@ -0,1 +1,3 @@ | ||
import { CalculatedProduct } from '../'; | ||
import { ShopData } from './types/shop-data'; | ||
import { | ||
@@ -6,5 +8,3 @@ Collection, | ||
ProductList, | ||
} from '../../../common'; | ||
import { CalculatedProduct } from '../vendure/calculated-product'; | ||
import { ShopData } from './types/shop-data'; | ||
} from '../generated/graphql'; | ||
/** | ||
@@ -11,0 +11,0 @@ * Generates Gridsome pages based on given PageMap |
@@ -1,3 +0,3 @@ | ||
import { CalculatedProduct } from '../../vendure/calculated-product'; | ||
import { Collection, Country } from '../../../../common'; | ||
import { Collection, Country } from '../../generated/graphql'; | ||
import { CalculatedProduct } from '../../util/product.util'; | ||
export interface ShopData { | ||
@@ -4,0 +4,0 @@ /** |
export * from './gridsome/gridsome.service'; | ||
export * from './gridsome/types/gridsome-context'; | ||
export * from './gridsome/types/gridsome-result'; | ||
export * from './gridsome/types/shop-data'; | ||
export * from './gridsome/types/gridsome-context'; | ||
export * from './gridsome/types/gridsome-result'; | ||
@@ -7,0 +5,0 @@ export * from './util/product.util'; |
@@ -27,6 +27,4 @@ 'use strict'; | ||
__exportStar(require('./gridsome/gridsome.service'), exports); | ||
__exportStar(require('./gridsome/types/gridsome-context'), exports); | ||
__exportStar(require('./gridsome/types/gridsome-result'), exports); | ||
__exportStar(require('./gridsome/types/shop-data'), exports); | ||
__exportStar(require('./gridsome/types/gridsome-context'), exports); | ||
__exportStar(require('./gridsome/types/gridsome-result'), exports); | ||
@@ -33,0 +31,0 @@ __exportStar(require('./util/product.util'), exports); |
@@ -1,15 +0,37 @@ | ||
import { Product, ProductVariant } from '../../../common'; | ||
import { CalculatedProduct } from '../vendure/calculated-product'; | ||
import { VendureClient } from '../vendure/vendure.client'; | ||
import { Emitter } from 'mitt'; | ||
import { ProductVariant } from '../generated/graphql'; | ||
export interface CalculatedProduct { | ||
id: string; | ||
name?: string; | ||
description?: string; | ||
featuredAsset?: { | ||
preview: string; | ||
}; | ||
slug: string; | ||
lowestPrice: number; | ||
soldOut: boolean; | ||
} | ||
interface MinimalProduct { | ||
id: string; | ||
slug: string; | ||
variants: MinimalVariant[]; | ||
} | ||
interface MinimalVariant { | ||
stockLevel: string; | ||
priceWithTax: number; | ||
} | ||
interface SlugHolder { | ||
slug: string; | ||
} | ||
/** | ||
* Set lowest price based on lowest price of variants and set soldout if all are sold out | ||
*/ | ||
export declare function setCalculatedFields( | ||
product: Product | ||
): CalculatedProduct; | ||
export declare function setCalculatedFields<T extends MinimalProduct>( | ||
product: T | ||
): CalculatedProduct & T; | ||
/** | ||
* Remove duplicate products from given list of products | ||
*/ | ||
export declare function deduplicate(products: Product[]): Product[]; | ||
export declare function deduplicate<T extends SlugHolder>(products: T[]): T[]; | ||
/** | ||
@@ -19,7 +41,7 @@ * Hydrate products on client side. | ||
*/ | ||
export declare function hydrate( | ||
products: CalculatedProduct[] | CalculatedProduct, | ||
export declare function hydrate<T extends CalculatedProduct>( | ||
products: T[] | T, | ||
vendure: VendureClient | ||
): Promise<CalculatedProduct[] | CalculatedProduct | undefined>; | ||
export declare function isOutOfStock(variant: ProductVariant): boolean; | ||
): Promise<T[] | T | undefined>; | ||
export declare function isOutOfStock(variant: { stockLevel: string }): boolean; | ||
/** | ||
@@ -35,1 +57,2 @@ * Adds product to cart. Emitts error if something fails, never throws error | ||
): Promise<void>; | ||
export {}; |
@@ -1,3 +0,3 @@ | ||
import { CalculatedProduct } from '../vendure/calculated-product'; | ||
import { Collection } from '../../../common'; | ||
import { Collection } from '../generated/graphql'; | ||
import { CalculatedProduct } from './product.util'; | ||
/** | ||
@@ -4,0 +4,0 @@ * Removes all HTML tags from a HTML string and truncate to max X characters |
@@ -36,3 +36,7 @@ 'use strict'; | ||
} | ||
var seoDescription = getSeoDescription(item.description); | ||
var seoDescription = ( | ||
item === null || item === void 0 ? void 0 : item.description | ||
) | ||
? getSeoDescription(item.description) | ||
: undefined; | ||
var image = item.featuredAsset ? item.featuredAsset.preview : undefined; | ||
@@ -60,3 +64,3 @@ var script = []; | ||
return { | ||
title: item.name, | ||
title: (item === null || item === void 0 ? void 0 : item.name) || item.slug, | ||
meta: [ | ||
@@ -63,0 +67,0 @@ { key: 'description', name: 'description', content: seoDescription }, |
@@ -1,4 +0,4 @@ | ||
import { Order } from '../../../common'; | ||
import { OrderFieldsFragment } from '../generated/graphql'; | ||
export declare class Store { | ||
activeOrder: Order | undefined; | ||
activeOrder: OrderFieldsFragment | undefined; | ||
} |
import { Store } from './store'; | ||
import { GraphQLClient } from 'graphql-request'; | ||
import { CalculatedProduct } from '../util/product.util'; | ||
import { | ||
CreateAddressInput, | ||
CreateCustomerInput, | ||
DutchAddressLookupResult, | ||
DutchAddressLookupQuery, | ||
DutchPostalCodeInput, | ||
ErrorResult, | ||
Order, | ||
PaymentInput, | ||
ShippingMethodQuote, | ||
} from '../../../common'; | ||
import { CalculatedProduct } from './calculated-product'; | ||
EligibleShippingMethodsQuery, | ||
OrderFieldsFragment, | ||
ProductQuery, | ||
} from '../generated/graphql'; | ||
export declare class VendureClient { | ||
@@ -19,3 +18,3 @@ private store; | ||
constructor(store: Store); | ||
getActiveOrder(): Promise<Order>; | ||
getActiveOrder(): Promise<OrderFieldsFragment | undefined>; | ||
/** | ||
@@ -25,21 +24,35 @@ * Get all products, but only ID, slug and variant price and stockLevel | ||
getStockForProducts(): Promise<CalculatedProduct[]>; | ||
getProduct(slug: string): Promise<CalculatedProduct>; | ||
addProductToCart(productVariantId: string, quantity: number): Promise<Order>; | ||
getProduct( | ||
slug: string | ||
): Promise<CalculatedProduct & ProductQuery['product']>; | ||
addProductToCart( | ||
productVariantId: string, | ||
quantity: number | ||
): Promise<OrderFieldsFragment>; | ||
setLowestShippingMethod(): Promise<void>; | ||
getEligibleShippingMethods(): Promise<ShippingMethodQuote[]>; | ||
setOrderShippingMethod(shippingMethodId: string): Promise<Order>; | ||
adjustOrderLine(orderLineId: string, quantity: number): Promise<Order>; | ||
setCustomerForOrder(input: CreateCustomerInput): Promise<Order>; | ||
setOrderShippingAddress(input: CreateAddressInput): Promise<Order>; | ||
getEligibleShippingMethods(): Promise< | ||
EligibleShippingMethodsQuery['eligibleShippingMethods'] | ||
>; | ||
setOrderShippingMethod( | ||
shippingMethodId: string | ||
): Promise<OrderFieldsFragment>; | ||
adjustOrderLine( | ||
orderLineId: string, | ||
quantity: number | ||
): Promise<OrderFieldsFragment>; | ||
setCustomerForOrder(input: CreateCustomerInput): Promise<OrderFieldsFragment>; | ||
setOrderShippingAddress( | ||
input: CreateAddressInput | ||
): Promise<OrderFieldsFragment>; | ||
getNextOrderStates(): Promise<string[]>; | ||
transitionOrderToState(state: string): Promise<Order>; | ||
addPaymentToOrder(input: PaymentInput): Promise<Order>; | ||
getOrderByCode(code: string): Promise<Order | undefined>; | ||
transitionOrderToState(state: string): Promise<OrderFieldsFragment>; | ||
createMolliePaymentIntent(code: string): Promise<string>; | ||
getOrderByCode(code: string): Promise<OrderFieldsFragment | undefined>; | ||
getAddress( | ||
input: DutchPostalCodeInput | ||
): Promise<DutchAddressLookupResult | undefined>; | ||
applyCouponCode(couponCode: string): Promise<Order>; | ||
removeCouponCode(couponCode: string): Promise<Order>; | ||
validateResult<T extends ErrorResult>(result: T): void; | ||
request(document: string, variables?: any): Promise<any>; | ||
): Promise<DutchAddressLookupQuery['dutchAddressLookup'] | undefined>; | ||
applyCouponCode(couponCode: string): Promise<OrderFieldsFragment>; | ||
removeCouponCode(couponCode: string): Promise<OrderFieldsFragment>; | ||
validateResult(result: any): void; | ||
request<T = void, I = void>(document: string, variables?: I): Promise<T>; | ||
} |
@@ -210,2 +210,5 @@ 'use strict'; | ||
product = _a.sent().product; | ||
if (!product) { | ||
throw Error('No product found for slug ' + slug); | ||
} | ||
return [2 /*return*/, product_util_1.setCalculatedFields(product)]; | ||
@@ -221,3 +224,3 @@ } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var order; | ||
var addItemToOrder; | ||
return __generator(this, function (_a) { | ||
@@ -234,9 +237,9 @@ switch (_a.label) { | ||
case 1: | ||
order = _a.sent().addItemToOrder; | ||
this.validateResult(order); | ||
this.store.activeOrder = order; | ||
addItemToOrder = _a.sent().addItemToOrder; | ||
this.validateResult(addItemToOrder); | ||
this.store.activeOrder = addItemToOrder; | ||
return [4 /*yield*/, this.setLowestShippingMethod()]; | ||
case 2: | ||
_a.sent(); | ||
return [2 /*return*/, order]; | ||
return [2 /*return*/, addItemToOrder]; | ||
} | ||
@@ -312,3 +315,3 @@ }); | ||
return __awaiter(this, void 0, void 0, function () { | ||
var activeOrder; | ||
var adjustOrderLine; | ||
return __generator(this, function (_a) { | ||
@@ -325,6 +328,6 @@ switch (_a.label) { | ||
case 1: | ||
activeOrder = _a.sent().adjustOrderLine; | ||
this.validateResult(activeOrder); | ||
this.store.activeOrder = activeOrder; | ||
return [2 /*return*/, activeOrder]; | ||
adjustOrderLine = _a.sent().adjustOrderLine; | ||
this.validateResult(adjustOrderLine); | ||
this.store.activeOrder = adjustOrderLine; | ||
return [2 /*return*/, adjustOrderLine]; | ||
} | ||
@@ -336,3 +339,3 @@ }); | ||
return __awaiter(this, void 0, void 0, function () { | ||
var order; | ||
var setCustomerForOrder; | ||
return __generator(this, function (_a) { | ||
@@ -348,6 +351,6 @@ switch (_a.label) { | ||
case 1: | ||
order = _a.sent().setCustomerForOrder; | ||
this.validateResult(order); | ||
this.store.activeOrder = order; | ||
return [2 /*return*/, order]; | ||
setCustomerForOrder = _a.sent().setCustomerForOrder; | ||
this.validateResult(setCustomerForOrder); | ||
this.store.activeOrder = setCustomerForOrder; | ||
return [2 /*return*/, setCustomerForOrder]; | ||
} | ||
@@ -363,8 +366,2 @@ }); | ||
case 0: | ||
if (!input.company || input.company.length === 0) { | ||
input.company = '-'; // Dirty fix | ||
} | ||
if (!input.phoneNumber || input.phoneNumber.length === 0) { | ||
input.phoneNumber = '-'; // Dirty fix | ||
} | ||
return [ | ||
@@ -422,5 +419,5 @@ 4 /*yield*/, | ||
}; | ||
VendureClient.prototype.addPaymentToOrder = function (input) { | ||
VendureClient.prototype.createMolliePaymentIntent = function (code) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var addPaymentToOrder; | ||
var createMolliePaymentIntent; | ||
return __generator(this, function (_a) { | ||
@@ -431,11 +428,10 @@ switch (_a.label) { | ||
4 /*yield*/, | ||
this.request(vendure_queries_1.ADD_PAYMENT_TO_ORDER, { | ||
input: input, | ||
this.request(vendure_queries_1.CREATE_MOLLIE_PAYMENT_INTENT, { | ||
input: { paymentMethodCode: code }, | ||
}), | ||
]; | ||
case 1: | ||
addPaymentToOrder = _a.sent().addPaymentToOrder; | ||
this.validateResult(addPaymentToOrder); | ||
this.store.activeOrder = addPaymentToOrder; | ||
return [2 /*return*/, addPaymentToOrder]; | ||
createMolliePaymentIntent = _a.sent().createMolliePaymentIntent; | ||
this.validateResult(createMolliePaymentIntent); | ||
return [2 /*return*/, createMolliePaymentIntent.url]; | ||
} | ||
@@ -442,0 +438,0 @@ }); |
@@ -14,3 +14,3 @@ export declare const PRODUCT_FIELDS: string; | ||
export declare const TRANSITION_ORDER_TO_STATE: string; | ||
export declare const ADD_PAYMENT_TO_ORDER: string; | ||
export declare const CREATE_MOLLIE_PAYMENT_INTENT: string; | ||
export declare const GET_ORDER_BY_CODE: string; | ||
@@ -17,0 +17,0 @@ export declare const GET_DUTCH_ADDRESS: string; |
@@ -17,3 +17,3 @@ 'use strict'; | ||
exports.GET_ORDER_BY_CODE = | ||
exports.ADD_PAYMENT_TO_ORDER = | ||
exports.CREATE_MOLLIE_PAYMENT_INTENT = | ||
exports.TRANSITION_ORDER_TO_STATE = | ||
@@ -60,6 +60,6 @@ exports.GET_NEXT_ORDERSTATES = | ||
[ | ||
'\n {\n products {\n items {\n id\n slug\n variants {\n id\n stockLevel\n priceWithTax\n }\n }\n }\n }\n', | ||
'\n query products {\n products {\n items {\n id\n slug\n variants {\n id\n stockLevel\n priceWithTax\n }\n }\n }\n }\n', | ||
], | ||
[ | ||
'\n {\n products {\n items {\n id\n slug\n variants {\n id\n stockLevel\n priceWithTax\n }\n }\n }\n }\n', | ||
'\n query products {\n products {\n items {\n id\n slug\n variants {\n id\n stockLevel\n priceWithTax\n }\n }\n }\n }\n', | ||
] | ||
@@ -114,6 +114,6 @@ )) | ||
[ | ||
'\n {\n eligibleShippingMethods {\n id\n price\n priceWithTax\n name\n metadata\n }\n }\n', | ||
'\n query eligibleShippingMethods {\n eligibleShippingMethods {\n id\n price\n priceWithTax\n name\n metadata\n }\n }\n', | ||
], | ||
[ | ||
'\n {\n eligibleShippingMethods {\n id\n price\n priceWithTax\n name\n metadata\n }\n }\n', | ||
'\n query eligibleShippingMethods {\n eligibleShippingMethods {\n id\n price\n priceWithTax\n name\n metadata\n }\n }\n', | ||
] | ||
@@ -181,4 +181,4 @@ )) | ||
(templateObject_12 = __makeTemplateObject( | ||
['\n {\n nextOrderStates\n }\n'], | ||
['\n {\n nextOrderStates\n }\n'] | ||
['\n query nextOrderStates {\n nextOrderStates\n }\n'], | ||
['\n query nextOrderStates {\n nextOrderStates\n }\n'] | ||
)) | ||
@@ -200,15 +200,12 @@ ); | ||
); | ||
exports.ADD_PAYMENT_TO_ORDER = graphql_request_1.gql( | ||
exports.CREATE_MOLLIE_PAYMENT_INTENT = graphql_request_1.gql( | ||
templateObject_14 || | ||
(templateObject_14 = __makeTemplateObject( | ||
[ | ||
'\n ', | ||
'\n mutation addPaymentToOrder($input: PaymentInput!) {\n addPaymentToOrder(input: $input) {\n ... on Order {\n ...OrderFields\n }\n ... on ErrorResult {\n errorCode\n message\n }\n }\n }\n', | ||
'\n mutation createMolliePaymentIntent($input: MolliePaymentIntentInput!) {\n createMolliePaymentIntent(input: $input) {\n ... on MolliePaymentIntent {\n url\n }\n ... on MolliePaymentIntentError {\n errorCode\n message\n }\n }\n }\n', | ||
], | ||
[ | ||
'\n ', | ||
'\n mutation addPaymentToOrder($input: PaymentInput!) {\n addPaymentToOrder(input: $input) {\n ... on Order {\n ...OrderFields\n }\n ... on ErrorResult {\n errorCode\n message\n }\n }\n }\n', | ||
'\n mutation createMolliePaymentIntent($input: MolliePaymentIntentInput!) {\n createMolliePaymentIntent(input: $input) {\n ... on MolliePaymentIntent {\n url\n }\n ... on MolliePaymentIntentError {\n errorCode\n message\n }\n }\n }\n', | ||
] | ||
)), | ||
exports.ORDER_FIELDS | ||
)) | ||
); | ||
@@ -215,0 +212,0 @@ exports.GET_ORDER_BY_CODE = graphql_request_1.gql( |
{ | ||
"name": "pinelab-storefront-client", | ||
"version": "0.43.0", | ||
"version": "0.44.0", | ||
"description": "Generates static html pages with Gridsome and suplied Vue components", | ||
@@ -18,2 +18,3 @@ "author": "Martijn van de Brug <martijn@pinelab.studio>", | ||
"build": "rm -rf lib && yarn scss && yarn tsc --build && yarn copyfiles -u 1 'src/ministore/**/*' 'src/buefy-components/**/*' lib", | ||
"generate": "graphql-codegen", | ||
"dev-build": "yarn tsc --build && yarn copyfiles -u 1 'src/ministore/**/*' 'src/buefy-components/**/*' lib", | ||
@@ -25,2 +26,5 @@ "scss": "node-sass src/scss/styles.scss -o src/ministore --output-style compressed", | ||
"devDependencies": { | ||
"@graphql-codegen/cli": "1.21.3", | ||
"@graphql-codegen/typescript": "1.21.1", | ||
"@graphql-codegen/typescript-operations": "1.17.15", | ||
"@types/debounce": "^1.2.0", | ||
@@ -48,3 +52,3 @@ "@types/jest": "^27.4.0", | ||
}, | ||
"gitHead": "5a3ba1f1fefe1faabd7421ae21ad43e0def2880d" | ||
"gitHead": "60cd8951cdffe8ae85c649a5dce3b525716f2416" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
623869
7925
15
59