**What**
Add support for default sales channel
**How**
- Implement a new method in the salesChannelService `createDefault`
- call the new method above in the default loader
**Test**
- Unit tests of the sales channel service method createDefaulta
- Init default loader unit tests
Fixes CORE-316
**What**
- Add `transformQuery` to get endpoints for product, order and cart
- ensure that the default relations (when getting a singular entity) includes sales channels when enabled
- Add `EmptyQueryParams` class in common types to prevent query parameters while using `transformQuery`
- update product-, order- and cartFactory to include sales channels if provided
- remove `packages/medusa/src/controllers/products/admin-list-products.ts`
**Testing**
- expands sales channel for single order
- expands sales channels for orders with expand parameter
- returns single product with sales channel
- expands sales channels for products with expand parameter
- returns cart with sales channel for single cart
Fixes CORE-293
Co-authored-by: Sebastian Rindom <7554214+srindom@users.noreply.github.com>
Co-authored-by: Adrien de Peretti <25098370+adrien2p@users.noreply.github.com>
**What**
Since the release of the Tax API the line item totals calculations on orders with gift cards have been wrong. To understand the bug consider the below order:
Region:
- tax_rate: 25%
- gift_cards_taxable: true
Order:
- applied gift card: 1000
- items:
- A: unit_price: 1000
- B: unit_price: 500
- Subtotal: 1500
**Previous calculation method**
1. Determine how much of the gift card is used for each item using `item_total / subtotal * gift_card_amount`:
- Item A: 1000/1500 * 1000 = 666.67
- Item B: 500/1500 * 1000 = 333.33
2. Calculate line item totals including taxes using `(unit_price - gift_card) * (1 + tax_rate)`
- Item A: 1000 - 666.67 = 333.33; vat amount -> 83.33
- Item B: 500 - 333.33 = 166.67; vat amount -> 41.67
3. Add up the line item totals: order subtotal = 500; vat amount = 125; total = 625
This is all correct at the totals level; but at the line item level we should still use the "original prices" i.e. the line item total for item a should be (1000 * 1.25) = 1250 with a tax amount of 250.
**New calculation method**
1. Use default totals calculations
- Item A: subtotal: 1000, tax_total: 250, total: 1250
- Item B: subtotal: 500, tax_total: 125, total: 625
2. Add up the line item totals: subtotal: 1500, tax_total: 375, total: 1875
3. Reduce total with gift card: subtotal: 1500 - 1000 = 500, tax_total: 375 - 250 = 125, total = 625
Totals can now be forwarded correctly to accounting plugins.
Fixes CORE-310.
**What**
- Add `feature_flags` string array to store response
**Why**
- to provide conditional ui in admin corresponding to enabled features
Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
Bumps [moment](https://github.com/moment/moment) from 2.29.1 to 2.29.4.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/moment/moment/blob/develop/CHANGELOG.md">moment's changelog</a>.</em></p>
<blockquote>
<h3>2.29.4</h3>
<ul>
<li>Release Jul 6, 2022
<ul>
<li><a href="https://github-redirect.dependabot.com/moment/moment/pull/6015">#6015</a> [bugfix] Fix ReDoS in preprocessRFC2822 regex</li>
</ul>
</li>
</ul>
<h3>2.29.3 <a href="https://gist.github.com/ichernev/edebd440f49adcaec72e5e77b791d8be">Full changelog</a></h3>
<ul>
<li>Release Apr 17, 2022
<ul>
<li><a href="https://github-redirect.dependabot.com/moment/moment/pull/5995">#5995</a> [bugfix] Remove const usage</li>
<li><a href="https://github-redirect.dependabot.com/moment/moment/pull/5990">#5990</a> misc: fix advisory link</li>
</ul>
</li>
</ul>
<h3>2.29.2 <a href="https://gist.github.com/ichernev/1904b564f6679d9aac1ae08ce13bc45c">See full changelog</a></h3>
<ul>
<li>Release Apr 3 2022</li>
</ul>
<p>Address <a href="https://github.com/moment/moment/security/advisories/GHSA-8hfj-j24r-96c4">https://github.com/moment/moment/security/advisories/GHSA-8hfj-j24r-96c4</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="000ac1800e"><code>000ac18</code></a> Build 2.24.4</li>
<li><a href="f2006b6479"><code>f2006b6</code></a> Bump version to 2.24.4</li>
<li><a href="536ad0c348"><code>536ad0c</code></a> Update changelog for 2.29.4</li>
<li><a href="9a3b5894f3"><code>9a3b589</code></a> [bugfix] Fix redos in preprocessRFC2822 regex (<a href="https://github-redirect.dependabot.com/moment/moment/issues/6015">#6015</a>)</li>
<li><a href="6374fd860a"><code>6374fd8</code></a> Merge branch 'master' into develop</li>
<li><a href="b4e615307e"><code>b4e6153</code></a> Revert "[bugfix] Fix redos in preprocessRFC2822 regex (<a href="https://github-redirect.dependabot.com/moment/moment/issues/6015">#6015</a>)"</li>
<li><a href="7aebb1617f"><code>7aebb16</code></a> [bugfix] Fix redos in preprocessRFC2822 regex (<a href="https://github-redirect.dependabot.com/moment/moment/issues/6015">#6015</a>)</li>
<li><a href="57c90622e4"><code>57c9062</code></a> Build 2.29.3</li>
<li><a href="aaf50b6bca"><code>aaf50b6</code></a> Fixup release complaints</li>
<li><a href="26f4aef9ca"><code>26f4aef</code></a> Bump version to 2.29.3</li>
<li>Additional commits viewable in <a href="https://github.com/moment/moment/compare/2.29.1...2.29.4">compare view</a></li>
</ul>
</details>
<br />
[](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
<details>
<summary>Dependabot commands and options</summary>
<br />
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language
You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/medusajs/medusa/network/alerts).
</details>
* fix: caching deps + add true parallelization to integration tests api
* fix: github action
* chore: upgrade to yarn berry (#1762)
* init migration
* remove: yarn.lock from all pkgs
* fix: build script in pkgs
* adjust yarn config
* fix: yarn.lock and yarnrc.yml
* fix: github actions
* fix: wrong type
* fix (medusa-react): use dts-cli instead of tsdx
* fix: yarn.lock
* fix: yarn v
* fix: prepare script
* add: comment on why we need to downgrade yarn before medusa-dev
* chore: move to Turborepo (#1763)
* increase number of parallel nodes
* fix (medusa-fulfillment-webshipper): build script
* fix: use new version of medusa-dev
* fix: rename cache-bootstrap to cache-deps
Bumps [moment](https://github.com/moment/moment) from 2.29.1 to 2.29.4.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/moment/moment/blob/develop/CHANGELOG.md">moment's changelog</a>.</em></p>
<blockquote>
<h3>2.29.4</h3>
<ul>
<li>Release Jul 6, 2022
<ul>
<li><a href="https://github-redirect.dependabot.com/moment/moment/pull/6015">#6015</a> [bugfix] Fix ReDoS in preprocessRFC2822 regex</li>
</ul>
</li>
</ul>
<h3>2.29.3 <a href="https://gist.github.com/ichernev/edebd440f49adcaec72e5e77b791d8be">Full changelog</a></h3>
<ul>
<li>Release Apr 17, 2022
<ul>
<li><a href="https://github-redirect.dependabot.com/moment/moment/pull/5995">#5995</a> [bugfix] Remove const usage</li>
<li><a href="https://github-redirect.dependabot.com/moment/moment/pull/5990">#5990</a> misc: fix advisory link</li>
</ul>
</li>
</ul>
<h3>2.29.2 <a href="https://gist.github.com/ichernev/1904b564f6679d9aac1ae08ce13bc45c">See full changelog</a></h3>
<ul>
<li>Release Apr 3 2022</li>
</ul>
<p>Address <a href="https://github.com/moment/moment/security/advisories/GHSA-8hfj-j24r-96c4">https://github.com/moment/moment/security/advisories/GHSA-8hfj-j24r-96c4</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="000ac1800e"><code>000ac18</code></a> Build 2.24.4</li>
<li><a href="f2006b6479"><code>f2006b6</code></a> Bump version to 2.24.4</li>
<li><a href="536ad0c348"><code>536ad0c</code></a> Update changelog for 2.29.4</li>
<li><a href="9a3b5894f3"><code>9a3b589</code></a> [bugfix] Fix redos in preprocessRFC2822 regex (<a href="https://github-redirect.dependabot.com/moment/moment/issues/6015">#6015</a>)</li>
<li><a href="6374fd860a"><code>6374fd8</code></a> Merge branch 'master' into develop</li>
<li><a href="b4e615307e"><code>b4e6153</code></a> Revert "[bugfix] Fix redos in preprocessRFC2822 regex (<a href="https://github-redirect.dependabot.com/moment/moment/issues/6015">#6015</a>)"</li>
<li><a href="7aebb1617f"><code>7aebb16</code></a> [bugfix] Fix redos in preprocessRFC2822 regex (<a href="https://github-redirect.dependabot.com/moment/moment/issues/6015">#6015</a>)</li>
<li><a href="57c90622e4"><code>57c9062</code></a> Build 2.29.3</li>
<li><a href="aaf50b6bca"><code>aaf50b6</code></a> Fixup release complaints</li>
<li><a href="26f4aef9ca"><code>26f4aef</code></a> Bump version to 2.29.3</li>
<li>Additional commits viewable in <a href="https://github.com/moment/moment/compare/2.29.1...2.29.4">compare view</a></li>
</ul>
</details>
<br />
[](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
<details>
<summary>Dependabot commands and options</summary>
<br />
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language
You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/medusajs/medusa/network/alerts).
</details>
**What**
- Add tag to indicate methods are part of an experimental feature under development
**Why**
- To notify developers because we cant support featureflags in the same way from the client side libraries.
**Usage**
**Create a new feature flag**
```
$ medusa-dev ff create [name of flag] -d [description of what flag is for]
```
Will put a new file in `packages/medusa/src/loaders/feature-flags/[kebab-cased-flag-name].ts` and fill out the details.
**List feature flags**
```
$ medusa-dev ff list
```
Note: your Medusa repo must be built for the flags to show up
**Delete a feature flag**
```
$ medusa-dev ff delete [name of flag]
```
Will delete a file at `packages/medusa/src/loaders/feature-flags/[kebab-cased-flag-name].ts` if it exists.
**What**
- added `SalesChannel` entity
- added `SalesChannel` repository
- added `SalesChannel` relations to the order, cart and store entities
- added a migrations file
**How**
- introduced entities and relations under a new feature flag "sales-channels"
Fixes CORE-271
Co-authored-by: Philip Korsholm <88927411+pKorsholm@users.noreply.github.com>
* feat: add feature flag loading in projects
* fix: make feature flag consume itself
* fix: rename container registration to featureFlagRouter
* fix: refactor
* behavioral feature flags
* add environment to server
* limit "useTemplateDb" to non feature flagged migrations
* filter migrations and entities according to those which are enabled in the environment
* run only migrations that are enabled when running 'medusa migrations run'
* add logging to the featureflag loader
* initial implementation of featureFlagEntity
* column descriptors
* initial startServerWithEnv (to be refactored)
* update commands
* final touches
* update loaders to fix unit tests
* enable all batch job tests
* update seed method
* add api test capabilities
* revert batch job test
* revert formatting changes
* pr feedback
* pr feedback
* remove unused imports
* rename feature flag decorators
* pr feedback
Co-authored-by: Sebastian Rindom <skrindom@gmail.com>
* fix(medusa): Remove deps mongoose, mongodb and transaction service + base model
* chore: delete permissions+add-ons legacy plugins
Co-authored-by: Sebastian Rindom <skrindom@gmail.com>