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

feat(product, pricing, utils): Transaction issues and reference issues #5533

Merged
merged 29 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
5f1f59b
feat(product, pricing, utils): Transaction issues and reference issues
adrien2p Nov 2, 2023
5817a97
fixes decorators
adrien2p Nov 2, 2023
ff8ff5c
cleanup
adrien2p Nov 2, 2023
aa4da68
fix product module upsert
adrien2p Nov 2, 2023
a109dc2
fix missing active manager
adrien2p Nov 2, 2023
42b3761
increase timeout
adrien2p Nov 2, 2023
de2ad8b
Merge branch 'develop' into feat/product-pricing-transaction
adrien2p Nov 2, 2023
56a021e
revert package.json
adrien2p Nov 2, 2023
a9dabe9
Merge branch 'feat/product-pricing-transaction' of github.com:medusaj…
adrien2p Nov 2, 2023
5b99e64
WIP
adrien2p Nov 2, 2023
5d5f492
try another node version based on findings with memory issues with je…
adrien2p Nov 2, 2023
7fed0e4
re add bail
adrien2p Nov 2, 2023
936ddf2
Merge branch 'develop' into feat/product-pricing-transaction
adrien2p Nov 2, 2023
0180c81
Merge branch 'develop' into feat/product-pricing-transaction
carlos-r-l-rodrigues Nov 2, 2023
6b26fbd
fix variant options
adrien2p Nov 2, 2023
1d8ddf6
Merge branch 'feat/product-pricing-transaction' of github.com:medusaj…
adrien2p Nov 2, 2023
383bfcb
Merge branch 'develop' into feat/product-pricing-transaction
carlos-r-l-rodrigues Nov 2, 2023
6cab021
chore: bulk create pricing
carlos-r-l-rodrigues Nov 2, 2023
f03f3cc
chore: workflow bulk
carlos-r-l-rodrigues Nov 2, 2023
6c2bd65
Merge branch 'develop' into feat/product-pricing-transaction
riqwan Nov 3, 2023
19e6fdb
Create big-chefs-dream.md
adrien2p Nov 3, 2023
67afc3a
fix missing update for upserty
adrien2p Nov 3, 2023
fbb081d
Merge branch 'feat/product-pricing-transaction' of github.com:medusaj…
adrien2p Nov 3, 2023
453541c
Add integration tests for product options upsert
adrien2p Nov 3, 2023
7af03cb
rm unnecessary return
adrien2p Nov 3, 2023
fbee853
fix product prices workflow issue
adrien2p Nov 3, 2023
9ba71ed
cleanup
adrien2p Nov 3, 2023
d6551f1
fix flag
adrien2p Nov 3, 2023
104023d
fix model
adrien2p Nov 3, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/big-chefs-dream.md
@@ -0,0 +1,6 @@
---
"@medusajs/pricing": patch
"@medusajs/product": patch
---

feat(product, pricing, utils): Transaction issues and reference issues + refactoring
2 changes: 1 addition & 1 deletion .github/actions/setup-server/action.yml
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
2 changes: 1 addition & 1 deletion packages/pricing/src/repositories/pricing.ts
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)
adrien2p marked this conversation as resolved.
Show resolved Hide resolved
const knex = manager.getKnex()
const context = pricingContext.context || {}

Expand Down
8 changes: 3 additions & 5 deletions packages/pricing/src/services/currency.ts
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
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
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
17 changes: 3 additions & 14 deletions packages/pricing/src/services/price-set-money-amount-rules.ts
Expand Up @@ -8,8 +8,6 @@ import {
} from "@medusajs/utils"
import { PriceSetMoneyAmountRules } from "@models"

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

type InjectedDependencies = {
priceSetMoneyAmountRulesRepository: DAL.RepositoryService
}
Expand Down Expand Up @@ -79,10 +77,7 @@ export default class PriceSetMoneyAmountRulesService<
return queryOptions
}

@InjectTransactionManager(
shouldForceTransaction,
"priceSetMoneyAmountRulesRepository_"
)
@InjectTransactionManager("priceSetMoneyAmountRulesRepository_")
async create(
data: PricingTypes.CreatePriceSetMoneyAmountRulesDTO[],
@MedusaContext() sharedContext: Context = {}
Expand All @@ -93,10 +88,7 @@ export default class PriceSetMoneyAmountRulesService<
)) as TEntity[]
}

@InjectTransactionManager(
shouldForceTransaction,
"priceSetMoneyAmountRulesRepository_"
)
@InjectTransactionManager("priceSetMoneyAmountRulesRepository_")
async update(
data: PricingTypes.UpdatePriceSetMoneyAmountRulesDTO[],
@MedusaContext() sharedContext: Context = {}
Expand All @@ -107,10 +99,7 @@ export default class PriceSetMoneyAmountRulesService<
)) as TEntity[]
}

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