Skip to content

Commit

Permalink
Merge branch 'develop' into feat/show-db-error-message
Browse files Browse the repository at this point in the history
  • Loading branch information
shahednasser authored Nov 6, 2023
2 parents c371cbc + 2576a0f commit 98f7193
Show file tree
Hide file tree
Showing 61 changed files with 766 additions and 607 deletions.
6 changes: 6 additions & 0 deletions .changeset/big-chefs-dream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@medusajs/pricing": patch
"@medusajs/product": patch
---

feat(product, pricing, utils): Transaction issues and reference issues + refactoring
5 changes: 5 additions & 0 deletions .changeset/breezy-suns-marry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@medusajs/admin-ui": patch
---

fix(admin-ui): Fixes an issue where using the bulk editor with comma as the decimal separator would convert the input to NaN
2 changes: 1 addition & 1 deletion .github/actions/setup-server/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ inputs:
node-version:
description: "Node version"
required: false
default: "16.20.2"
default: "16.10.0"
cache-extension:
description: "Extension for fetching cached dependencies"
required: true
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: "16.20.2"
node-version: "16.10.0"
cache: "yarn"

- name: Assert changed
Expand Down Expand Up @@ -48,7 +48,7 @@ jobs:
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: "16.20.2"
node-version: "16.10.0"
cache: "yarn"

- name: Assert changed
Expand Down Expand Up @@ -171,7 +171,7 @@ jobs:
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: "16.20.2"
node-version: "16.10.0"
cache: "yarn"

- name: Install dependencies
Expand Down Expand Up @@ -223,7 +223,7 @@ jobs:
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: "16.20.2"
node-version: "16.10.0"
cache: "yarn"

- name: Install dependencies
Expand Down Expand Up @@ -275,7 +275,7 @@ jobs:
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: "16.20.2"
node-version: "16.10.0"
cache: "yarn"

- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codegen-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: "16.20.2"
node-version: "16.10.0"
cache: "yarn"

- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs-freshness-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: "16.20.2"
node-version: "16.10.0"
cache: "yarn"

- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs-new-announcement.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: "16.20.2"
node-version: "16.10.0"
cache: "yarn"

- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs-remove-announcement.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: "16.20.2"
node-version: "16.10.0"
cache: "yarn"

- name: Install dependencies
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/generate-references.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: "16.20.2"
node-version: "16.10.0"
cache: "yarn"

- name: Install dependencies
Expand Down Expand Up @@ -89,7 +89,7 @@ jobs:
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: "16.20.2"
node-version: "16.10.0"
cache: "yarn"

- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/oas-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: "16.20.2"
node-version: "16.10.0"
cache: "yarn"

- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-notifications.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: "16.20.2"
node-version: "16.10.0"
cache: "yarn"

- name: Post to Slack channel
Expand Down
1 change: 1 addition & 0 deletions integration-tests/environment-helpers/bootstrap-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ module.exports = {

const shutdown = async () => {
await Promise.all([
container.dispose(),
expressServer.close(),
db?.destroy(),
pgConnection?.context?.destroy(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const env = {
MEDUSA_FF_ISOLATE_PRODUCT_DOMAIN: true,
}

describe.skip("[Product & Pricing Module] POST /admin/products", () => {
describe("[Product & Pricing Module] POST /admin/products", () => {
let dbConnection
let appContainer
let shutdownServer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const env = {
MEDUSA_FF_ISOLATE_PRODUCT_DOMAIN: true,
}

describe.skip("[Product & Pricing Module] POST /admin/products/:id/variants/:id", () => {
describe("[Product & Pricing Module] POST /admin/products/:id/variants/:id", () => {
let dbConnection
let appContainer
let shutdownServer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const env = {
MEDUSA_FF_ISOLATE_PRODUCT_DOMAIN: true,
}

describe.skip("[Product & Pricing Module] POST /admin/products/:id", () => {
describe("[Product & Pricing Module] POST /admin/products/:id", () => {
let dbConnection
let appContainer
let shutdownServer
Expand Down Expand Up @@ -172,9 +172,7 @@ describe.skip("[Product & Pricing Module] POST /admin/products/:id", () => {
],
}

console.log("I am here first")
await api.post(`/admin/products/${product.id}`, data, adminHeaders)
console.log("I am here")

const response = await api.get(
`/admin/products/${product.id}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { getContainer } from "../../../../environment-helpers/use-container"
import { initDb, useDb } from "../../../../environment-helpers/use-db"
import { simpleProductFactory } from "../../../../factories"

jest.setTimeout(30000)
jest.setTimeout(100000)

describe("UpdateProduct workflow", function () {
let dbConnection
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/plugins/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = {
`/www/`,
`/dist/`,
`/node_modules/`,
"<rootDir>/node_modules",
`<rootDir>/node_modules/`,
`__tests__/fixtures`,
`__testfixtures__`,
`.cache`,
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/plugins/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "MIT",
"private": true,
"scripts": {
"test:integration": "node --expose-gc ./../../node_modules/.bin/jest --silent=false --runInBand --bail --logHeapUsage --forceExit",
"test:integration": "node --expose-gc ./../../node_modules/.bin/jest --silent=false --runInBand --bail --detectOpenHandles --logHeapUsage --clearMocks --no-compilation-cache --forceExit",
"build": "babel src -d dist --extensions \".ts,.js\""
},
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1511,7 +1511,7 @@ const PriceListProductPricesForm = ({
ref={tableRef}
>
<thead>
<tr className="[&_th]:txt-compact-small-plus text-ui-fg-subtle [&_th]:border-ui-border-base h-10 [&_th]:min-w-[220px] [&_th]:border-r [&_th]:border-b [&_th:last-of-type]:border-r-0">
<tr className="[&_th]:txt-compact-small-plus text-ui-fg-subtle [&_th]:border-ui-border-base h-10 [&_th:last-of-type]:border-r-0 [&_th]:min-w-[220px] [&_th]:border-b [&_th]:border-r">
<th className="max-w-[220px] text-left">
<div className="px-4 py-2.5">
{t(
Expand Down Expand Up @@ -1586,7 +1586,7 @@ const PriceListProductPricesForm = ({
</tr>
</thead>
<tbody>
<tr className="bg-ui-bg-subtle h-10 [&_td:last-of-type]:border-r-0 [&_td]:border-r [&_td]:border-b">
<tr className="bg-ui-bg-subtle h-10 [&_td:last-of-type]:border-r-0 [&_td]:border-b [&_td]:border-r">
<td className="w-[220px] max-w-[220px]">
<div className="grid w-[220px] grid-cols-[16px_1fr] gap-x-3 overflow-hidden px-4 py-2.5">
<div className="bg-ui-bg-component h-[22px] w-4 rounded-[4px]">
Expand Down Expand Up @@ -1828,7 +1828,7 @@ const Cell = React.forwardRef<HTMLInputElement, CellProps>(
*/
const formattedValue = strippedValue
? formatValue({
value: strippedValue,
value: strippedValue.replace(/,/g, "."), // If the current locale uses commas as decimal separators, then we need to replace them with dots.
decimalScale: decimalScale ?? 0,
disableGroupSeparators: true,
})
Expand Down Expand Up @@ -2138,7 +2138,7 @@ const Cell = React.forwardRef<HTMLInputElement, CellProps>(
{borders.bottom && borders.right && (
<div
onMouseDown={onDragToFillStart}
className="bg-ui-bg-interactive absolute -right-1 -bottom-1 z-50 h-2 w-2 cursor-crosshair rounded-full"
className="bg-ui-bg-interactive absolute -bottom-1 -right-1 z-50 h-2 w-2 cursor-crosshair rounded-full"
/>
)}
</td>
Expand Down
1 change: 1 addition & 0 deletions packages/medusa/oas/admin.oas.base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ tags:
description: How to manage users
url: https://docs.medusajs.com/modules/users/admin/manage-users
servers:
- url: http://localhost:9000
- url: https://api.medusa-commerce.com
paths: { }
components:
Expand Down
1 change: 1 addition & 0 deletions packages/medusa/oas/store.oas.base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ tags:
description: How to create a swap in a storefront
url: https://docs.medusajs.com/modules/orders/storefront/create-swap
servers:
- url: http://localhost:9000
- url: https://api.medusa-commerce.com
paths: { }
components:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { EntityManager } from "typeorm"
import PublishableApiKeyService from "../../../../services/publishable-api-key"

/**
* @oas [post] /admin/publishable-api-key/{id}
* @oas [post] /admin/publishable-api-keys/{id}
* operationId: "PostPublishableApiKysPublishableApiKey"
* summary: "Update Publishable API Key"
* description: "Update a Publishable API Key's details."
Expand Down
2 changes: 1 addition & 1 deletion packages/pricing/src/repositories/pricing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class PricingRepository
pricingContext: PricingContext = { context: {} },
sharedContext: Context = {}
): Promise<CalculatedPriceSetDTO[]> {
const manager = this.getActiveManager<SqlEntityManager>()
const manager = this.getActiveManager<SqlEntityManager>(sharedContext)
const knex = manager.getKnex()
const context = pricingContext.context || {}

Expand Down
8 changes: 3 additions & 5 deletions packages/pricing/src/services/currency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import {
import { Currency } from "@models"
import { CurrencyRepository } from "@repositories"

import { doNotForceTransaction, shouldForceTransaction } from "@medusajs/utils"

type InjectedDependencies = {
currencyRepository: DAL.RepositoryService
}
Expand Down Expand Up @@ -75,7 +73,7 @@ export default class CurrencyService<TEntity extends Currency = Currency> {
return queryOptions
}

@InjectTransactionManager(shouldForceTransaction, "currencyRepository_")
@InjectTransactionManager("currencyRepository_")
async create(
data: PricingTypes.CreateCurrencyDTO[],
@MedusaContext() sharedContext: Context = {}
Expand All @@ -86,7 +84,7 @@ export default class CurrencyService<TEntity extends Currency = Currency> {
)) as TEntity[]
}

@InjectTransactionManager(shouldForceTransaction, "currencyRepository_")
@InjectTransactionManager("currencyRepository_")
async update(
data: PricingTypes.UpdateCurrencyDTO[],
@MedusaContext() sharedContext: Context = {}
Expand All @@ -97,7 +95,7 @@ export default class CurrencyService<TEntity extends Currency = Currency> {
)) as TEntity[]
}

@InjectTransactionManager(doNotForceTransaction, "currencyRepository_")
@InjectTransactionManager("currencyRepository_")
async delete(
ids: string[],
@MedusaContext() sharedContext: Context = {}
Expand Down
8 changes: 3 additions & 5 deletions packages/pricing/src/services/money-amount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import {
import { MoneyAmount } from "@models"
import { MoneyAmountRepository } from "@repositories"

import { doNotForceTransaction, shouldForceTransaction } from "@medusajs/utils"

type InjectedDependencies = {
moneyAmountRepository: DAL.RepositoryService
}
Expand Down Expand Up @@ -73,7 +71,7 @@ export default class MoneyAmountService<
)) as [TEntity[], number]
}

@InjectTransactionManager(shouldForceTransaction, "moneyAmountRepository_")
@InjectTransactionManager("moneyAmountRepository_")
async create(
data: PricingTypes.CreateMoneyAmountDTO[],
@MedusaContext() sharedContext: Context = {}
Expand All @@ -84,7 +82,7 @@ export default class MoneyAmountService<
)) as TEntity[]
}

@InjectTransactionManager(shouldForceTransaction, "moneyAmountRepository_")
@InjectTransactionManager("moneyAmountRepository_")
async update(
data: PricingTypes.UpdateMoneyAmountDTO[],
@MedusaContext() sharedContext: Context = {}
Expand All @@ -95,7 +93,7 @@ export default class MoneyAmountService<
)) as TEntity[]
}

@InjectTransactionManager(doNotForceTransaction, "moneyAmountRepository_")
@InjectTransactionManager("moneyAmountRepository_")
async delete(
ids: string[],
@MedusaContext() sharedContext: Context = {}
Expand Down
8 changes: 3 additions & 5 deletions packages/pricing/src/services/price-rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import {
InjectTransactionManager,
MedusaContext,
ModulesSdkUtils,
doNotForceTransaction,
retrieveEntity,
shouldForceTransaction,
} from "@medusajs/utils"
import { PriceRule } from "@models"
import { PriceRuleRepository } from "@repositories"
Expand Down Expand Up @@ -65,7 +63,7 @@ export default class PriceRuleService<TEntity extends PriceRule = PriceRule> {
)) as [TEntity[], number]
}

@InjectTransactionManager(shouldForceTransaction, "priceRuleRepository_")
@InjectTransactionManager("priceRuleRepository_")
async create(
data: PricingTypes.CreatePriceRuleDTO[],
@MedusaContext() sharedContext: Context = {}
Expand All @@ -76,7 +74,7 @@ export default class PriceRuleService<TEntity extends PriceRule = PriceRule> {
)) as TEntity[]
}

@InjectTransactionManager(shouldForceTransaction, "priceRuleRepository_")
@InjectTransactionManager("priceRuleRepository_")
async update(
data: PricingTypes.UpdatePriceRuleDTO[],
@MedusaContext() sharedContext: Context = {}
Expand All @@ -87,7 +85,7 @@ export default class PriceRuleService<TEntity extends PriceRule = PriceRule> {
)) as TEntity[]
}

@InjectTransactionManager(doNotForceTransaction, "priceRuleRepository_")
@InjectTransactionManager("priceRuleRepository_")
async delete(
ids: string[],
@MedusaContext() sharedContext: Context = {}
Expand Down
Loading

0 comments on commit 98f7193

Please sign in to comment.