feat(medusa): integrate pricing module to core (#5304)
* add pricing integraiton feature flag * init * first endpoint * cleanup * remove console.logs * refactor to util and implement across endpoints * add changeset * rename variables * remove mistype * feat(medusa): move price module integration to pricing service (#5322) * initial changes * chore: make product service always internal for pricing module * add notes --------- Co-authored-by: Riqwan Thamir <rmthamir@gmail.com> * nit * cleanup * update to object querying * update cart integration test * remove uppercase currency_code * nit * Feat/admin product pricing module reads (#5354) * initial changes to list prices for admin * working price module implementation of list prices * nit * variant pricing * redo integration test changes * cleanup * cleanup * fix unit tests * [wip] Core <> Pricing - price updates (#5364) * chore: update medusa-app * wip * get links and modules working with migration * wip * chore: make test pass * Feat/rule type utils (#5371) * initial rule type utils * update migration script * chore: cleanup * ensure prices are always decorated * chore: use seed instead * chore: fix oas conflict * region id add to admin price read! --------- Co-authored-by: Philip Korsholm <88927411+pKorsholm@users.noreply.github.com> Co-authored-by: Philip Korsholm <philip.korsholm@hotmail.com> * pr feedback * create remoteQueryFunction type * fix merge * fix loaders issue * Feat(medusa, types, pricing): pricing module migration script (#5409) * add migration script for money amounts in pricing module * add changeset * rename file * cleanup imports * update changeset * add check for pricing module and ff * feat(medusa,workflows,types): update prices on product and variant update (#5412) * wip * chore: update product prices through workflow * chore: cleanup * chore: update product handler updates prices for variants * chore: handle reverts * chore: address pr comments * chore: scope workflow handlers to flag handlers * chore: update return * chore: update db url * chore: remove migration * chore: increase jest timeout * Feat(medusa): update migration and initDb to run link-migrations (#5437) * initial * loader update * more progress on loaders * update integration tests and remote-query loader * remove helper * migrate isolated modules * fix test * fix integration test * update with pr feedback * unregister medusa-app * re-register medusaApp * fix featureflag * set timeout * set timeout * conditionally run link-module migrations * pr feedback 1 * add driver options for db * throw if link is not defined in migration script * pass config module directly * include container in migrate command * chore: increase timeout * rm redis from api integration tests to test * chore: temporarily skip tests * chore: undo skips + add timeout for workflow tests * chore: increase timeout for order edits * re-add redis * include final resolution * add sharedcontainer to medusaapp loader * chore: move migration under run command * try removing redis_url from api tests * chore: cleanup server on process exit * chore: clear container on exit * chore: adjustments * chore: remove consoles * chore: close express app on finish * chore: destroy pg connection on shutdown * chore: skip * chore: unskip test * chore: cleanup container pg connection * chore: skip --------- Co-authored-by: Riqwan Thamir <rmthamir@gmail.com>
This commit is contained in:
@@ -1,2 +1,3 @@
|
||||
export * from "./create-products"
|
||||
export * as UpdateProductVariants from "./update-product-variants"
|
||||
export * from "./update-products"
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
import {
|
||||
TransactionStepsDefinition,
|
||||
WorkflowManager,
|
||||
} from "@medusajs/orchestration"
|
||||
import { InputAlias, Workflows } from "../../definitions"
|
||||
import { exportWorkflow, pipe } from "../../helper"
|
||||
|
||||
import { ProductTypes, WorkflowTypes } from "@medusajs/types"
|
||||
import { ProductHandlers } from "../../handlers"
|
||||
|
||||
export enum UpdateProductVariantsActions {
|
||||
prepare = "prepare",
|
||||
updateProductVariants = "updateProductVariants",
|
||||
revertProductVariantsUpdate = "revertProductVariantsUpdate",
|
||||
upsertPrices = "upsertPrices",
|
||||
}
|
||||
|
||||
export const workflowSteps: TransactionStepsDefinition = {
|
||||
next: {
|
||||
action: UpdateProductVariantsActions.prepare,
|
||||
noCompensation: true,
|
||||
next: {
|
||||
action: UpdateProductVariantsActions.updateProductVariants,
|
||||
noCompensation: true,
|
||||
next: [
|
||||
{
|
||||
action: UpdateProductVariantsActions.upsertPrices,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
const handlers = new Map([
|
||||
[
|
||||
UpdateProductVariantsActions.prepare,
|
||||
{
|
||||
invoke: pipe(
|
||||
{
|
||||
merge: true,
|
||||
inputAlias: InputAlias.ProductVariantsUpdateInputData,
|
||||
invoke: {
|
||||
from: InputAlias.ProductVariantsUpdateInputData,
|
||||
},
|
||||
},
|
||||
ProductHandlers.updateProductVariantsPrepareData
|
||||
),
|
||||
},
|
||||
],
|
||||
[
|
||||
UpdateProductVariantsActions.updateProductVariants,
|
||||
{
|
||||
invoke: pipe(
|
||||
{
|
||||
merge: true,
|
||||
invoke: {
|
||||
from: UpdateProductVariantsActions.prepare,
|
||||
},
|
||||
},
|
||||
ProductHandlers.updateProductVariants
|
||||
),
|
||||
},
|
||||
],
|
||||
[
|
||||
UpdateProductVariantsActions.upsertPrices,
|
||||
{
|
||||
invoke: pipe(
|
||||
{
|
||||
merge: true,
|
||||
invoke: [
|
||||
{
|
||||
from: UpdateProductVariantsActions.prepare,
|
||||
},
|
||||
],
|
||||
},
|
||||
ProductHandlers.upsertVariantPrices
|
||||
),
|
||||
compensate: pipe(
|
||||
{
|
||||
merge: true,
|
||||
invoke: [
|
||||
{
|
||||
from: UpdateProductVariantsActions.prepare,
|
||||
},
|
||||
{
|
||||
from: UpdateProductVariantsActions.upsertPrices,
|
||||
},
|
||||
],
|
||||
},
|
||||
ProductHandlers.revertVariantPrices
|
||||
),
|
||||
},
|
||||
],
|
||||
])
|
||||
|
||||
WorkflowManager.register(
|
||||
Workflows.UpdateProductVariants,
|
||||
workflowSteps,
|
||||
handlers
|
||||
)
|
||||
|
||||
export const updateProductVariants = exportWorkflow<
|
||||
WorkflowTypes.ProductWorkflow.UpdateProductVariantsWorkflowInputDTO,
|
||||
ProductTypes.ProductVariantDTO[]
|
||||
>(
|
||||
Workflows.UpdateProductVariants,
|
||||
UpdateProductVariantsActions.updateProductVariants
|
||||
)
|
||||
@@ -1,16 +1,17 @@
|
||||
import { ProductTypes, WorkflowTypes } from "@medusajs/types"
|
||||
|
||||
import { InputAlias, Workflows } from "../../definitions"
|
||||
import {
|
||||
TransactionStepsDefinition,
|
||||
WorkflowManager,
|
||||
} from "@medusajs/orchestration"
|
||||
import { exportWorkflow, pipe } from "../../helper"
|
||||
import { CreateProductsActions } from "./create-products"
|
||||
import { InputAlias, Workflows } from "../../definitions"
|
||||
import { InventoryHandlers, ProductHandlers } from "../../handlers"
|
||||
import * as MiddlewareHandlers from "../../handlers/middlewares"
|
||||
import { detachSalesChannelFromProducts } from "../../handlers/product"
|
||||
import { exportWorkflow, pipe } from "../../helper"
|
||||
import { CreateProductsActions } from "./create-products"
|
||||
import { prepareCreateInventoryItems } from "./prepare-create-inventory-items"
|
||||
import { UpdateProductVariantsActions } from "./update-product-variants"
|
||||
|
||||
export enum UpdateProductsActions {
|
||||
prepare = "prepare",
|
||||
@@ -32,6 +33,10 @@ export const updateProductsWorkflowSteps: TransactionStepsDefinition = {
|
||||
next: {
|
||||
action: UpdateProductsActions.updateProducts,
|
||||
next: [
|
||||
{
|
||||
action: UpdateProductVariantsActions.upsertPrices,
|
||||
saveResponse: false,
|
||||
},
|
||||
{
|
||||
action: UpdateProductsActions.attachSalesChannels,
|
||||
saveResponse: false,
|
||||
@@ -59,7 +64,7 @@ export const updateProductsWorkflowSteps: TransactionStepsDefinition = {
|
||||
},
|
||||
}
|
||||
|
||||
const handlers = new Map([
|
||||
const handlers = new Map<string, any>([
|
||||
[
|
||||
UpdateProductsActions.prepare,
|
||||
{
|
||||
@@ -350,6 +355,37 @@ const handlers = new Map([
|
||||
),
|
||||
},
|
||||
],
|
||||
[
|
||||
UpdateProductVariantsActions.upsertPrices,
|
||||
{
|
||||
invoke: pipe(
|
||||
{
|
||||
merge: true,
|
||||
invoke: [
|
||||
{
|
||||
from: InputAlias.ProductsInputData,
|
||||
alias: ProductHandlers.updateProducts.aliases.products,
|
||||
},
|
||||
{
|
||||
from: UpdateProductsActions.prepare,
|
||||
},
|
||||
],
|
||||
},
|
||||
ProductHandlers.upsertVariantPrices
|
||||
),
|
||||
compensate: pipe(
|
||||
{
|
||||
merge: true,
|
||||
invoke: [
|
||||
{
|
||||
from: UpdateProductVariantsActions.upsertPrices,
|
||||
},
|
||||
],
|
||||
},
|
||||
ProductHandlers.revertVariantPrices
|
||||
),
|
||||
},
|
||||
],
|
||||
])
|
||||
|
||||
WorkflowManager.register(
|
||||
|
||||
Reference in New Issue
Block a user