Skip to content

Commit

Permalink
Merge 65d70ef into 0fb09fd
Browse files Browse the repository at this point in the history
  • Loading branch information
andrzejewsky committed Jan 12, 2021
2 parents 0fb09fd + 65d70ef commit 8fe4acd
Show file tree
Hide file tree
Showing 9 changed files with 167 additions and 128 deletions.
11 changes: 9 additions & 2 deletions packages/core/docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,18 @@ module.exports = {
{
title: 'Migration guide RC.1',
children: [
['/migrate/', 'Overview'],
['/migrate/rc1', 'Overview'],
['/migrate/integrators-rc1', 'Integrators'],
['/migrate/projects-rc1', 'Projects'],
]
},
{
title: 'Migration guide 2.2.0',
children: [
['/migrate/2.2.0', 'Overview'],
['/migrate/integrators-2.2.0', 'Integrators'],
['/migrate/projects-2.2.0', 'Projects'],
]
}
],
'/commercetools/': [
Expand Down Expand Up @@ -186,7 +194,6 @@ module.exports = {
children: [
['/integrate/integration-guide', 'Integration guide'],
['/general/cms', 'CMS'],
['/integrate/api-middleware', 'API middleware'],
]
},
{
Expand Down
3 changes: 2 additions & 1 deletion packages/core/docs/commercetools/composables.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ const customQuery = (query, variables) => {
variables: newVariables
}
}
search({ id: '12345' }, customQuery)

search({ id: '12345', customQuery })
```

Use it for: `useProduct`, `useCategory`, `useUser`, `useUserOrders` methods.
Expand Down
52 changes: 0 additions & 52 deletions packages/core/docs/integrate/api-middleware.md

This file was deleted.

10 changes: 5 additions & 5 deletions packages/core/docs/integrate/integration-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,12 @@ interface LineItem { /* ... */}
interface ProductVariant { /* ... */ }

const factoryParams: UseCartFactoryParams<Cart, LineItem, ProductVariant> = {
loadCart: async (context: Context) => {
load: async (context: Context) => {
const { data } = await context.$ct.api.getCart();

return data.cart;
},
addToCart: async (context: Context, params) => {
addItem: async (context: Context, params) => {
const { currentCart, product, quantity } = params;
const { data } = await context.$ct.api.addToCart(loadedCart, product, quantity, customQuery);

Expand Down Expand Up @@ -304,7 +304,7 @@ const factoryParams: UseUserFactoryParams = {
setup() {
return useCart();
},
loadUser: async (context: UserContext) => {
load: async (context: UserContext) => {
const { data } = await context.$ct.api.getUser();

context.setCart(data.activeCart);
Expand All @@ -329,7 +329,7 @@ const useCart = () => {
const cart = vsfRef(null, 'my-own-cart')
const context = generateContext(); // we do the job for you

const addToCart = async (product) => {
const addToCart = async ({ product }) => {
return context.$ownAPI.updateCart(product)
}

Expand Down Expand Up @@ -405,7 +405,7 @@ import { onSSR } from '@vue-storefront/core';

export default {
setup () {
const { cart, loadCart } = useCart();
const { cart, load: loadCart } = useCart();

const items = computed(() => cartGetters.getItems(cart.value))

Expand Down
8 changes: 8 additions & 0 deletions packages/core/docs/migrate/2.2.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Migration guide 2.2.0

This version introduces many renamings or changes related to the function declarations among of the core. We had to proceed with this in order to keep the convention and unify the naming across whole VSF.

We changes the composables and our factories according to the following rules:
- each composable return always one field with the response from the api
- each composable function takes one argument wich is an object of given parameters
- each factory param function takes two argumens, first one is context (as it was before) and second one contains a function parmeters along with other options (such as customQuery)
68 changes: 0 additions & 68 deletions packages/core/docs/migrate/index.md
Original file line number Diff line number Diff line change
@@ -1,70 +1,2 @@
# Migration guide

This guide contains a list of changes, in order to upgrade your VSF next to the RC.1 version.

## The general overview

In general, besides the smaller changes, we totally have changed the way of accessing configuration or API functions.
Always, instead of using configuration or networking stored in the global objects, we recommend to use context, provided by us.

Each time you want to access an integration stuff, such as network client, configuration or API functions please use `useVSFContext`

```js
import { useVSFContext } from '@vue-storefront/core';

export default {
setup () {
const { $integrationTag } = useVSFContext();
}
}

```

For more information, please read the section [Application Context](/general/context) in the general docs.

## List of changes for certain users

- [Changes for integrators](/migrate/integrators)
- [Changes for projects](/migrate/projects)


## Common problems

### Composition API already installed

```
[vue-composition-api] already installed. Vue.use(VueCompositionAPI) should be called only once.
```

**Solution**: Please make sure that you have everywhere the same version of vue composition api as the one we use in the core

### Using Composition API before is being installed

```
Uncaught Error: [vue-composition-api] must call Vue.use(plugin) before using any function.
```
**Solution**: if you are using compositon API (eg. `ref`) above the component, please make sure that you have `vue-composition-api` installed, or move these calls inside of the `setup` function.

### Some of our package doesn't work, the context doesn't return anything or has missing data

**Solution**: Please make sure that you put package in the raw sources section, and if the integration has nuxt module and extend an existing one, should be aded before our core nuxt module and the one with integration

```js
{
['@vue-storefront/some-new-integration/nuxt', {}], // 2
['@vue-storefront/nuxt', {
coreDevelopment: true,
useRawSource: {
dev: [
'@vue-storefront/core'
'@vue-storefront/other-package' // 1
],
prod: [
'@vue-storefront/core',
'@vue-storefront/other-package' // 1
]
}
}],
['@vue-storefront/some-integration/nuxt', {}]
}
```
28 changes: 28 additions & 0 deletions packages/core/docs/migrate/integrators-2.2.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Integrators upgrade notes

## Factory usage

We have changes a bit the naming and signatures of core factory functions. Below is the full list of what hs been implemented or changed:

| Factory | Old method | New method | Old signature | New signature |
|------------|--------|---------------|---------------|---|
| useCartFactory | addToCart | addItem | context, { currentCart: cart.value, product, quantity }, customQuery | context, { currentCart: cart.value, product, quantity, customQuery } |
| useCartFactory | loadCart | load | context: Context, customQuery?: CustomQuery | context: Context, { customQuery?: any } |
| useCartFactory | removeFromCart | removeItem | context: Context, params: { currentCart: CART, product: CART_ITEM }, customQuery?: CustomQuery | context: Context, params: { currentCart: CART, product: CART_ITEM, customQuery?: CustomQuery } |
| useCartFactory | updateQuantity | updateItemQty | context: Context, params: { currentCart: CART, product: CART_ITEM, quantity: number }, customQuery?: CustomQuery | context: Context, params: { currentCart: CART, product: CART_ITEM, customQuery?: CustomQuery } |
| useCartFactory | clearCart | clear | context: Context, prams: { currentCart: CART } | context: Context, params: { currentCart: CART } |
| useCartFactory | applyCoupon | No changes | context: Context, params: { currentCart: CART; couponCode: string }, customQuery?: CustomQuery | context: Context, params: { currentCart: CART, couponCode: string, customQuery?: CustomQuery } |
| useCartFactory | removeCoupon | No changes | context: Context, params: { currentCart: CART; coupon: COUPON }, customQuery?: CustomQuery | context: Context, params: { currentCart: CART; coupon: COUPON, customQuery?: CustomQuery } |
| useCategoryFactory | categorySearch | No changes | context: Context, searchParams: CATEGORY_SEARCH_PARAMS, customQuery: CustomQuery | context: Context, params: CATEGORY_SEARCH_PARAMS & { customQuery?: CustomQuery } |
| useProductFactory | productsSearch | No changes | context: Context, searchParams: PRODUCT_SEARCH_PARAMS, customQuery?: CustomQuery | context: Context, params: PRODUCT_SEARCH_PARAMS & { customQuery?: CustomQuery } |
| useReviewFactory | searchReviews | No changes | context: Context, params: REVIEWS_SEARCH_PARAMS, customQuery?: CustomQuery | context: Context, params: REVIEWS_SEARCH_PARAMS & { customQuery?: CustomQuery } |
| useReviewFactory | addReview | No changes | context: Context, params: REVIEW_ADD_PARAMS, customQuery?: CustomQuery | context: Context, params: REVIEW_ADD_PARAMS & { customQuery?: CustomQuery } |
| useUserBillingFactory | setDefault | setDefaultAddress | context: Context, params: { address: Readonly<USER_BILLING_ITEM>; shipping: Readonly<USER_BILLING>; }) | No changes |
| useUserShippingFactory | setDefault | setDefaultAddress | context: Context, params: { address: Readonly<USER_SHIPPING_ITEM>; shipping: Readonly<USER_SHIPPING>; }) | No changes |
| useUserFactory | loadUser | load | context: Context, | context: Context, params?: {} |
| useUserOrdersFactory | searchOrders | No changes | context: Context, params: ORDER_SEARCH_PARAMS, customQuery?: CustomQuery | context: Context, params: ORDER_SEARCH_PARAMS & { customQuery?: CustomQuery } |
| useWishlistFactory | addToWishlist | addItem | context, { currentWishlist: WISHLIST, product: PRODUCT }, customQuery | context, { currentWishlist: WISHLIST, product: PRODUCT, customQuery } |
| useWishlistFactory | loadWishlist | load | context: Context, customQuery?: CustomQuery | No changes |
| useWishlistFactory | removeFromWishlist | removeItem | context: Context, params: { currentWishlist: WISHLIST, product: WISHLIST_ITEM }, customQuery?: CustomQuery | context: Context, params: { currentWishlist: WISHLIST, product: WISHLIST_ITEM, customQuery?: CustomQuery } |
| useWishlistFactory | clearWishlist | clear | context: Context, params: { currentWishlist: WISHLIST } | No changes |
| useWishlistFactory | loadWishlist | load | context: Context, customQuery?: CustomQuery | context: Context, { customQuery?: any } |
45 changes: 45 additions & 0 deletions packages/core/docs/migrate/projects-2.2.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Project upgrade notes

## Composables usage

We have changes a bit the naming and signatures of composable functions. Below is the full list of what hs been implemented or changed:

| Composable | Method | Old signature | New signature |
|------------|--------|---------------|---------------|
| useCart | addToCart | (product: PRODUCT, quantity: number, customQuery?: CustomQuery) | ({ product: PRODUCT, quantity: number, customQuery?: CustomQuery }) |
| useCart | removeFromCart | (product: CART_ITEM, customQuery?: CustomQuery) | ({ product: CART_ITEM, customQuery?: CustomQuery }) |
| useCart | updateQuantity | (product: CART_ITEM, quantity?: number, customQuery?: CustomQuery) | ({ product: CART_ITEM, quantity?: number, customQuery?: CustomQuery }) |
| useCart | load | (customQuery?: CustomQuery) | ({ customQuery?: CustomQuery } = {}) |
| useCart | clearCart | () | () |
| useCart | applyCoupon | (couponCode: string, customQuery?: CustomQuery) | ({ couponCode: string, customQuery?: CustomQuery }) |
| useCart | isOnCart | (product: PRODUCT) | ({ product: PRODUCT }) |
| useCart | removeCoupon | (coupon: COUPON, customQuery?: CustomQuery) | ({ coupon: COUPON, customQuery?: CustomQuery }) |
| useCart | setCart | (newCart: CART) | ({ newCart: CART }) |
| useCategory | search | (searchParams: CATEGORY_SEARCH_PARAMS, customQuery?: CustomQuery) | ({ ...searchParams: CATEGORY_SEARCH_PARAMS, customQuery?: CustomQuery }) |
| useContent | search | (params: CONTENT_SEARCH_PARAMS) | No changes |
| useFacet | search | (params?: AgnosticFacetSearchParams) | No changes |
| useProduct | search | (searchParams: PRODUCT_SEARCH_PARAMS, customQuery?: CustomQuery) | ({ ...searchParams: PRODUCT_SEARCH_PARAMS, customQuery?: CustomQuery }) |
| useReview | search | (searchParams: REVIEWS_SEARCH_PARAMS, customQuery?: CustomQuery) | ({ ...searchParams: REVIEWS_SEARCH_PARAMS, customQuery?: CustomQuery }) |
| useReview | addReview | (addParams: REVIEW_ADD_PARAMS, customQuery?: CustomQuery) | ({ ...addParams: REVIEW_ADD_PARAMS, customQuery?: CustomQuery }) |
| useUserBilling | addAddress | (address: USER_BILLING_ITEM) | ({ address: USER_BILLING_ITEM }) |
| useUserBilling | deleteAddress | (address: USER_BILLING_ITEM) | ({ address: USER_BILLING_ITEM }) |
| useUserBilling | updateAddress | (address: USER_BILLING_ITEM) | ({ address: USER_BILLING_ITEM }) |
| useUserBilling | setDefault | (address: USER_BILLING_ITEM) | ({ address: USER_BILLING_ITEM }) |
| useUserBilling | load | () | () |
| useUserShipping | addAddress | (address: USER_SHIPPING_ITEM) | ({ address: USER_SHIPPING_ITEM }) |
| useUserShipping | deleteAddress | (address: USER_SHIPPING_ITEM) | ({ address: USER_SHIPPING_ITEM }) |
| useUserShipping | updateAddress | (address: USER_SHIPPING_ITEM) | ({ address: USER_SHIPPING_ITEM }) |
| useUserShipping | setDefault | (address: USER_SHIPPING_ITEM) | ({ address: USER_SHIPPING_ITEM }) |
| useUserShipping | load | () | () |
| useUser | updateUser | (params: UPDATE_USER_PARAMS) | ({ user: UPDATE_USER_PARAMS }) |
| useUser | register | (registerUserData: REGISTER_USER_PARAMS) | ({ user: REGISTER_USER_PARAMS }) |
| useUser | login | (loginUserData: { username: string; password: string; }) | ({ user: LOGIN_USER_PARAMS }) |
| useUser | logout | () | () |
| useUser | changePassword | (currentPassword: string, newPassword: string) | ({ currentPassword: string, newPassword: string }) |
| useUser | load | () | () |
| useUserOrders | searchOrders | (searchParams: ORDER_SEARCH_PARAMS, customQuery?: CustomQuery) | ({ ...searchParams: ORDER_SEARCH_PARAMS, customQuery?: CustomQuery } = {}) |
| useWishlist | addToWishlist | (product: PRODUCT, customQuery?: CustomQuery) | ({ product: PRODUCT, customQuery?: CustomQuery }) |
| useWishlist | removeFromWishlist | (product: WISHLIST_ITEM, customQuery?: CustomQuery) | ({ product: WISHLIST_ITEM, customQuery?: CustomQuery }) |
| useWishlist | load | (customQuery?: CustomQuery) | ({ customQuery?: CustomQuery } = {}) |
| useWishlist | clearWishlist | () | () |
| useWishlist | isOnWishlist | (product: PRODUCT) | ({ product: PRODUCT }) |
70 changes: 70 additions & 0 deletions packages/core/docs/migrate/rc1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Migration guide

This guide contains a list of changes, in order to upgrade your VSF next to the RC.1 version.

## The general overview

In general, besides the smaller changes, we totally have changed the way of accessing configuration or API functions.
Always, instead of using configuration or networking stored in the global objects, we recommend to use context, provided by us.

Each time you want to access an integration stuff, such as network client, configuration or API functions please use `useVSFContext`

```js
import { useVSFContext } from '@vue-storefront/core';

export default {
setup () {
const { $integrationTag } = useVSFContext();
}
}

```

For more information, please read the section [Application Context](/general/context) in the general docs.

## List of changes for certain users

- [Changes for integrators](/migrate/integrators)
- [Changes for projects](/migrate/projects)


## Common problems

### Composition API already installed

```
[vue-composition-api] already installed. Vue.use(VueCompositionAPI) should be called only once.
```

**Solution**: Please make sure that you have everywhere the same version of vue composition api as the one we use in the core

### Using Composition API before is being installed

```
Uncaught Error: [vue-composition-api] must call Vue.use(plugin) before using any function.
```
**Solution**: if you are using compositon API (eg. `ref`) above the component, please make sure that you have `vue-composition-api` installed, or move these calls inside of the `setup` function.

### Some of our package doesn't work, the context doesn't return anything or has missing data

**Solution**: Please make sure that you put package in the raw sources section, and if the integration has nuxt module and extend an existing one, should be aded before our core nuxt module and the one with integration

```js
{
['@vue-storefront/some-new-integration/nuxt', {}], // 2
['@vue-storefront/nuxt', {
coreDevelopment: true,
useRawSource: {
dev: [
'@vue-storefront/core'
'@vue-storefront/other-package' // 1
],
prod: [
'@vue-storefront/core',
'@vue-storefront/other-package' // 1
]
}
}],
['@vue-storefront/some-integration/nuxt', {}]
}
```

0 comments on commit 8fe4acd

Please sign in to comment.