Skip to content

Commit

Permalink
feat: add contextCompareShopwareVersion to SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
tajespasarela committed Feb 4, 2025
1 parent 76206c6 commit c3f54e8
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/fluffy-teachers-complain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@shopware-ag/meteor-admin-sdk": minor
---

Add `contextCompareShopwareVersion` to sdk to compare the current Shopware version
30 changes: 29 additions & 1 deletion docs/admin-sdk/docs/guide/2_api-reference/context.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,34 @@ string
'6.4.0.0'
```


## Shopware compare version

### Compare current Shopware version with a given version

#### Usage:
```ts
const isRightVersion = await sw.context.compareShopwareVersion({version:'6.4.0', comparator: '>='})
```

#### Parameters
| Name | Description |
|:-------------|:------------------------------------------------------------------------------------------------------------------|
| `version` | The string with the version to compare |
| `comparator` | The operator to compare. Possible values: `'='` `'>'` `'<'` `'<='` `'>='`<br/> If not provided `'='` will be used |


#### Return value:

```ts
boolean
```

#### Example value:
```ts
true
```

## App information

### Get app information
Expand Down Expand Up @@ -327,7 +355,7 @@ Promise<{
id: string,
locationId: string
}>
}}>
}>
```

#### Example value:
Expand Down
9 changes: 9 additions & 0 deletions packages/admin-sdk/src/context/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const getLocale = createSender('contextLocale', {});
export const subscribeLocale = createSubscriber('contextLocale');
export const getCurrency = createSender('contextCurrency', {});
export const getShopwareVersion = createSender('contextShopwareVersion', {});
export const compareShopwareVersion = createSender('contextCompareShopwareVersion', {});
export const getUserInformation = createSender('contextUserInformation', {});
export const getUserTimezone = createSender('contextUserTimezone', {});
export const getAppInformation = createSender('contextAppInformation', {});
Expand Down Expand Up @@ -55,6 +56,14 @@ export type contextCurrency = {
export type contextShopwareVersion = {
responseType: string,
}
/**
* Get the current Shopware version comparison
*/
export type contextCompareShopwareVersion = {
responseType: boolean,
version: string,
comparator?: '=' | '>'| '<'|'<=' | '>=',
};

/**
* Get the current app information
Expand Down
4 changes: 3 additions & 1 deletion packages/admin-sdk/src/message-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import type {
contextModuleInformation,
contextUserInformation,
contextUserTimezone,
} from './context/index';
contextCompareShopwareVersion,
} from './context';
import type { uiComponentSectionRenderer } from './ui/component-section/index';
import type { uiTabsAddTabItem } from './ui/tabs';
import type { uiModulePaymentOverviewCard } from './ui/module/payment/overview-card';
Expand Down Expand Up @@ -55,6 +56,7 @@ export interface ShopwareMessageTypes {
contextLocale: contextLocale,
contextCurrency: contextCurrency,
contextShopwareVersion: contextShopwareVersion,
contextCompareShopwareVersion: contextCompareShopwareVersion,
contextUserInformation: contextUserInformation,
contextUserTimezone: contextUserTimezone,
contextAppInformation: contextAppInformation,
Expand Down

0 comments on commit c3f54e8

Please sign in to comment.