Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: module type depreciacion #1516

Merged
merged 3 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .changeset/eight-islands-scream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
"@vue-storefront/magento-sdk": patch
---

### Change Log

- [CHANGED] Deprecated the `MagentoModuleType` interface in `index.ts`. It is no longer necessary to use this type. Please, check documentation of `magentoModule` for alternatives. Below you can find a snippet of the new way of using `magentoModule`. Pay attention to the `buildModule` function that is used to create a module instance, it no longer requires the `MagentoModuleType` type as a generic parameter.

```ts
import { initSDK, buildModule } from '@vue-storefront/sdk';
import { magentoModule, MagentoModuleType } from '@vue-storefront/magento2-sdk'

const sdkConfig = {
magento:
buildModule(
magentoModule,
{
apiUrl: 'http://localhost:8181/magento',
}
)
};

export const sdk = initSDK(sdkConfig);
```

- [CHANGED] Made the `ssrApiUrl` property in `ModuleOptions.ts` optional.
13 changes: 8 additions & 5 deletions packages/sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@
import { connector } from './connector';
import { ModuleOptions } from './types';

/**
* @deprecated This type is deprecated and will be removed in the next major version.
* It is no longer necessary to use this type. Please, check documentation of `magentoModule`.
*/
export interface MagentoModuleType extends Module {
connector: ReturnType<typeof connector>;
}

/**
* Magento module.
*
* @example
*
* @example

Check failure on line 16 in packages/sdk/src/index.ts

View workflow job for this annotation

GitHub Actions / Continuous Integration / Run CI (18)

Delete `Β·`
* Initialization of the Magento module.
*
* ```js
Expand All @@ -19,7 +22,7 @@
*
* const sdkConfig = {
* magento:
* buildModule<MagentoModuleType>(
* buildModule(
* magentoModule,
* {
* apiUrl: 'http://localhost:8181/magento',
Expand All @@ -30,10 +33,10 @@
* export const sdk = initSDK<typeof sdkConfig>(sdkConfig);
* ```
*/
export const magentoModule = (options: ModuleOptions): MagentoModuleType => {
export const magentoModule = (options: ModuleOptions) => {
return {
connector: connector(options),
};
} satisfies Module;
};

export { client } from './client';
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/src/types/ModuleOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ export interface ModuleOptions {
/**
* The SSR API URL of the Magento instance
*/
ssrApiUrl: string;
ssrApiUrl?: string;
}
Loading