Skip to content

Commit 151a979

Browse files
authored
Merge pull request #38 from vuestorefront-community/dev
chore: release version 1.4.0
2 parents 48d7338 + deb5af2 commit 151a979

File tree

58 files changed

+799
-255
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+799
-255
lines changed

docs/.vuepress/config.js

+11-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ module.exports = {
6060
children: [
6161
['/', 'Introduction'],
6262
'/essentials/configuration',
63-
'/essentials/feature_list',
63+
'/essentials/customQueries',
6464
'/essentials/payment',
6565
'/essentials/maintainers'
6666
]
@@ -85,9 +85,18 @@ module.exports = {
8585
]
8686
},
8787
{
88+
title: 'Tips',
89+
collapsable: true,
90+
children: [
91+
['/tips/customTypes', 'Custom types'],
92+
['/tips/i18n', 'i18n'],
93+
]
94+
},{
8895
title: 'Reference',
8996
children: [
90-
['/api-reference/', 'API Reference'],
97+
['/api/featureList', 'Feature List'],
98+
['/api/apiList', 'Api List'],
99+
91100
]
92101
},
93102
],

docs/api/list.md docs/api/apiList.md

+5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ export interface OdooApiMethods {
2323
sendResetPassword(params: GraphQlSendResetPasswordParams, customQuery?: CustomQuery): Promise<FetchResult<DefaultGraphQlMutationResponse>>;
2424
changePassword(params: GraphQlResetPasswordParams, customQuery?: CustomQuery): Promise<FetchResult<DefaultGraphQlMutationResponse>>;
2525

26+
cartAddMultipleItems(params: GraphQlAddMultipleProductsParams, customQuery?: CustomQuery): Promise<FetchResult<cartAddMultipleItemsResult>>;
27+
cartRemoveMultipleItems(params: GraphQlRemoveMultipleProductsParams, customQuery?: CustomQuery): Promise<FetchResult<cartRemoveMultipleItemsResult>>;
28+
2629
cartLoad(customQuery?: CustomQuery): Promise<FetchResult<CartLoadResult>>;
2730
cartAddItem(params: GraphQlCartAddItemParams, customQuery?: CustomQuery): Promise<FetchResult<CartAddItemResult>>;
2831
cartRemoveItem(params: GraphQlCartRemoveItemParams, customQuery?: CustomQuery): Promise<FetchResult<CartRemoveItemResult>>;
@@ -50,6 +53,8 @@ export interface OdooApiMethods {
5053
paymentMakeExternal(params: GraphQlMakePaymentParams, customQuery?: CustomQuery): Promise<FetchResult<PaymentMakeExternalResult>>;
5154
paymentConfirmation(customQuery?: CustomQuery): Promise<FetchResult>;
5255

56+
subscribeNewsLetter(customQuery?: CustomQuery): Promise<FetchResult>;
57+
5358
ordersGet(params: GraphQlOrdersParams, customQuery?: CustomQuery): Promise<FetchResult<OrdersResponse>>;
5459
}
5560

File renamed without changes.

docs/composables/customQueries.md

+8
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,17 @@ From [VSF2 docs](https://docs.vuestorefront.io/v2/advanced/extending-graphql-que
55
we can use custom query on existing APIS.
66
Most of the apis use 'customQuery' index.
77
### Use Cart
8+
``` ts
9+
const { load: loadCart, cart } = useCart();
810

11+
await loadCart({ customQuery: { cartLoad: 'customCartLoad' } });
12+
```
913
### Use Category
14+
``` ts
15+
const { categories, search: searchCategories } = useCategory();
1016

17+
await loadCart({ pageSize: 100, customQuery: { getCategory: 'customGetCategory' } });
18+
```
1119
### Use CountrySearch
1220

1321
### Use Facet

docs/composables/useCart.md

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ type Order = {
2424
amountDelivery: number;
2525
currency: Currency;
2626
orderLines?: OrderLine[];
27+
websiteOrderLine?: OrderLine[];
2728
stage: OrderStage;
2829
orderUrl: string;
2930
transactions: PaymentTransaction[];

docs/composables/useFacet.md

+9-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,15 @@
99

1010
```ts
1111
type FacetSearchResult = {
12-
categories: Category[]
13-
products: Product[]
14-
attributes: Attribute[]
15-
totalProducts: number
12+
minPrice: number;
13+
maxPrice: number;
14+
products: Product[];
15+
categories: Category[];
16+
facets: Record<string, string>;
17+
totalProducts: number;
18+
perPageOptions: number;
19+
itemsPerPage: number;
20+
attributes: AttributeValue[];
1621
}
1722
```
1823

docs/composables/useOrder.md

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ type Order = {
2121
amountDelivery: number;
2222
currency: Currency;
2323
orderLines?: OrderLine[];
24+
websiteOrderLine?: OrderLine[];
2425
stage: OrderStage;
2526
orderUrl: string;
2627
transactions: PaymentTransaction[];

docs/composables/useProduct.md

+20-16
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,30 @@ type Product = {
1313
displayName?: string;
1414
slug?: string;
1515
isInStock?: boolean;
16-
qty: number;
17-
sku: string;
18-
image: string;
19-
variantImage: string;
20-
smallImage: string;
21-
mediaGallery: ProductImage[];
22-
price: number;
23-
weight: number;
24-
priceAfterDiscount: number;
25-
hasDiscountedPrice: number;
26-
listPrice: number;
16+
qty?: number;
17+
sku?: string;
18+
image?: string;
19+
variantImage?: string;
20+
smallImage?: string;
21+
mediaGallery?: ProductImage[];
22+
price?: number;
23+
weight?: number;
24+
priceAfterDiscount?: number;
25+
hasDiscountedPrice?: number;
26+
listPrice?: number;
2727
realProduct?: ProductVariant;
28-
firstVariant: number;
29-
currency: Currency;
30-
isInWishlist: boolean;
28+
firstVariant?: number;
29+
currency?: Currency;
30+
isInWishlist?: boolean;
3131
alternativeProducts?: Product[];
32+
productVariants?: Product[]
3233
accessoryProducts?: Product[];
33-
attributeValues: Attribute[];
34+
attributeValues?: AttributeValue[];
3435
productTemplate?: Product;
35-
categories: Category[];
36+
categories?: Category[];
37+
seoTitle?: string;
38+
seoDescription?: string;
39+
imageWebp?: string;
3640
}
3741
```
3842

docs/composables/useShipping.md

+36-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,27 @@
22
**UseShipping** composable can be used to:
33

44
- Search available shipping methods
5-
- load the shipping method and shipping address choosed for current cart
5+
- Load the shipping method and shipping address choosed for **current cart**
6+
- Save the shippingAddress ( update if has an id in params / add if doesn't have id)
67

78
## API
9+
The **UseShipping** VSF Core Interface
10+
```ts
11+
error: ComputedProperty<UseShippingErrors>;
12+
loading: ComputedProperty<boolean>;
13+
shipping: ComputedProperty<Address>;
14+
load(params: {
15+
customQuery?: CustomQuery;
16+
}): Promise<void>;
17+
save: (params: {
18+
params: GraphQlUpdateAddressParams;
19+
shippingDetails: Address;
20+
customQuery?: CustomQuery;
21+
}) => Promise<void>;
22+
23+
```
24+
25+
### Types
826
An **Address** (Partner) in odoo
927
```ts
1028
type Address = {
@@ -24,6 +42,23 @@ type Address = {
2442
password?: string;
2543
}
2644

45+
type GraphQlUpdateAddressParams = {
46+
id: number;
47+
name: string
48+
street: string
49+
street2?: string
50+
zip: string
51+
city: string
52+
stateId: number
53+
countryId: number
54+
phone: string
55+
email?: string
56+
};
57+
58+
interface UseShippingErrors {
59+
load: Error;
60+
save: Error;
61+
}
2762
```
2863

2964
## Example

docs/essentials/configuration.md

+31-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Want to try out the integration on your local machine? Check out our explanatory
66
<iframe width="100%" height="669" src="https://www.youtube.com/watch?v=FQMcbncdX_g&t=179s" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
77

88
## Middleware
9-
Odoo use graphql and jsonrpc calls
9+
Odoo use graphql
1010
- graphqlBaseUrl for **graphql**
1111

1212

@@ -50,4 +50,33 @@ export BASE_URL=https://vsf.odoo.com/
5050
export REDIS_HOST=<redis_host>
5151
export REDIS_PORT=<redis_port>
5252
# export REDIS_PASSWORD=<redis_password>
53-
```
53+
```
54+
55+
## Image handle
56+
Always use the **getImage** method!
57+
58+
#### WHY ?
59+
- He is build to fetch from correct baseURL (CDN for production / odoo others)
60+
- He is already injected in vue
61+
62+
#### HOW ?
63+
64+
```ts
65+
// from template
66+
$image(productGetters.getCoverImage(product))
67+
$image( image url )
68+
69+
// from setup
70+
{ url: root.$image(img.small) }
71+
72+
73+
```
74+
75+
#### Assets
76+
The assets folder on build stagging / prod will be sent to CDN with some hash.
77+
78+
To nuxt compile the assets links with the rigth use require.
79+
80+
```ts
81+
:placeholder="require('~/assets/images/product/product_placeholder.png')"
82+
```

docs/essentials/customQueries.md

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Custom queries
2+
3+
## Introduction
4+
Following the [Extending GraphQL Queries](https://docs.vuestorefront.io/v2/composition/extending-graphql-queries.html)
5+
,we can override the base queries from odoo to our custom queries.
6+
7+
8+
9+
10+
#### <span style="color:#4f56d6">Import the customQueries file to middleware</span>
11+
12+
```js
13+
// middleware.config.js
14+
const customQueries = require('./custom-project-api/customQueries');
15+
16+
module.exports = {
17+
integrations: {
18+
odoo: {
19+
location: '@vue-storefront/odoo-api/server',
20+
configuration: {
21+
odooBaseUrl,
22+
graphqlBaseUrl
23+
},
24+
customQueries
25+
}
26+
}
27+
};
28+
29+
```
30+
31+
#### <span style="color:#4f56d6">Custom queries file must follow</span>
32+
33+
```js
34+
// custom-project-api/customQueries.js
35+
36+
module.exports = {
37+
customGetProduct: ({variables}) => ({
38+
varialbes,
39+
query: gql`
40+
query {
41+
product {
42+
id
43+
name
44+
}
45+
}
46+
`,
47+
variables
48+
}),
49+
50+
```
51+
52+
#### <span style="color:#4f56d6">Reload application and pass the custom query on the composable search method</span>

docs/tips/customTypes.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Custom types
2+
If the project need a custom type, try to extend the base type.
3+
4+
### Odoo Convetion
5+
- <span style="color:#4f56d6"> projectName + type</span>
6+
7+
8+
```js
9+
import { Product, Category } from '@vue-storefront/odoo-api';
10+
11+
// Project name = BlueBrothers
12+
13+
export interface BlueBrothersProduct extends Product {
14+
strangeLabel?: string,
15+
acessories?: Accessory[]
16+
...
17+
}
18+
19+
export interface BlueBrothersCategory extends Category {
20+
subCategory?: BlueBrothersCategory
21+
...
22+
}
23+
24+
```

docs/tips/i18n.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# i18n
2+
Always register the string on en.json or other language files whhen you
3+
use $t(''). WHY ?
4+
5+
6+
- Don't pollute the console of browser
7+
- Speed up the building process
8+
- Speed up the CI building process
9+
10+
### Tools to automate / speed up
11+
12+
- [i18n Manager](https://www.electronjs.org/apps/i18n-manager)
13+
- [VsCode Ally](https://marketplace.visualstudio.com/items?itemName=Lokalise.i18n-ally)
14+
15+

packages/api-client/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vue-storefront/odoo-api",
3-
"version": "1.3.0",
3+
"version": "1.4.0",
44
"private": false,
55
"sideEffects": false,
66
"server": "server/index.js",
@@ -17,7 +17,7 @@
1717
"update:update": "ncu -u"
1818
},
1919
"dependencies": {
20-
"@vue-storefront/core": "2.5.4",
20+
"@vue-storefront/core": "2.5.6",
2121
"apollo-cache-inmemory": "^1.6.6",
2222
"apollo-client": "^2.6.10",
2323
"apollo-link": "^1.2.14",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import gql from 'graphql-tag';
2+
export default gql`
3+
mutation($promo: String!){
4+
applyCoupon(promo: $promo){
5+
applied
6+
}
7+
}`;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/* eslint-disable @typescript-eslint/no-unused-vars */
2+
import gql from 'graphql-tag';
3+
import { Context, CustomQuery } from '@vue-storefront/core';
4+
import mutation from './applyCouponMutation';
5+
import ApolloClient from 'apollo-client';
6+
import { GraphQlApplyCouponParams, ApplyCouponResult } from '../../index';
7+
import { FetchResult } from 'apollo-link/lib/types';
8+
9+
export default async function applyCoupon(
10+
context: Context,
11+
applyCouponParams: GraphQlApplyCouponParams,
12+
customQuery?: CustomQuery
13+
): Promise<FetchResult<ApplyCouponResult>> {
14+
const apolloClient = context.client.apollo as ApolloClient<any>;
15+
16+
const { applyCoupon } = context.extendQuery(
17+
customQuery, { applyCoupon: { mutation, variables: applyCouponParams } }
18+
);
19+
20+
const response = await apolloClient.mutate({
21+
mutation: gql`${applyCoupon.mutation}`,
22+
variables: applyCoupon.variables
23+
});
24+
25+
return response;
26+
}

0 commit comments

Comments
 (0)