Skip to content

Commit

Permalink
chore: deprecate magentoModule
Browse files Browse the repository at this point in the history
  • Loading branch information
WojtekTheWebDev committed Apr 17, 2024
1 parent 53a00e1 commit 251395f
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 1 deletion.
38 changes: 38 additions & 0 deletions .changeset/eighty-papayas-occur.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
"@vue-storefront/magento-sdk": patch
---

[CHANGED] `magentoModule` has been deprecated. Use `middlewareModule` from `@vue-storefront/sdk` package instead.

```diff
- import { initSDK, buildModule } from '@vue-storefront/sdk';
- import { magentoModule } from '@vsf-enterprise/magento-sdk'
+ import { initSDK, buildModule, middlewareModule } from '@vue-storefront/sdk';
+ import { Endpoints as MagentoEndpoints } from '@vsf-enterprise/sapcc-api'; // In Alokai Storefront you should import it from `storefront-middleware/types.ts`

const sdkConfig = {
magento:
buildModule(
- magentoModule,
+ middlewareModule<MagentoEndpoints>,
{ apiUrl: 'http://localhost:8181/magento' }
)
};
```

Updating your `magentoModule` to this version should not disrupt your existing code; however, switching to `middlewareModule` will require certain modifications.

To migrate:

- Use custom query as a second argument of `middlewareModule` function.

```diff
const customQuery = {
cart: 'cart-custom-query',
metadata: {
fields: 'id items { uid }'
}
};
- const cart = await sdk.magento.cart({ cartId: '123'}, { customQuery });
+ const cart = await sdk.magento.cart({ cartId: '123'}, customQuery);
```
5 changes: 5 additions & 0 deletions .changeset/gorgeous-news-notice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@vue-storefront/magento-api": patch
---

[CHANGED] Update TSDocs of API methods. Now, they contain examples of usage.
37 changes: 36 additions & 1 deletion packages/sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,42 @@ export interface MagentoModuleType extends Module {
/**
* Magento module.
*
* @example
* @deprecated
*
* Use `middlewareModule` instead.
*
* ```diff
* - import { initSDK, buildModule } from '@vue-storefront/sdk';
* - import { magentoModule } from '@vsf-enterprise/magento-sdk'
* + import { initSDK, buildModule, middlewareModule } from '@vue-storefront/sdk';
* + import { Endpoints as MagentoEndpoints } from '@vsf-enterprise/magento-api';
*
* const sdkConfig = {
* magneto:
* buildModule(
* - magentoModule,
* + middlewareModule<MagentoEndpoints>,
* { apiUrl: 'http://localhost:8181/magneto' }
* )
* };
*
* export const sdk = initSDK(sdkConfig);
*
* // Breaking changes:
* // - Custom queries are now a second argument of the methods.
*
* const customQuery = {
* cart: 'cart-custom-query',
* metadata: {
* fields: 'id items { uid }'
* }
* };
* - const cart = await sdk.magento.cart({ cartId: '123'}, { customQuery });
* + const cart = await sdk.magento.cart({ cartId: '123'}, customQuery);
*
* ```
*
* @example
* Initialization of the Magento module.
*
* ```js
Expand Down

0 comments on commit 251395f

Please sign in to comment.