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

chore(workflows, core-flows, ...): Split workflows tooling and definitions #5705

Merged
merged 13 commits into from
Nov 24, 2023
8 changes: 8 additions & 0 deletions .changeset/fresh-birds-serve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@medusajs/core-flows": patch
"@medusajs/orchestration": patch
"@medusajs/medusa": patch
"@medusajs/workflows-sdk": patch
---

chore(workflows, core-flows, ...): Split workflows tooling and definitions
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ packages/*
!packages/create-medusa-app
!packages/product
!packages/orchestration
!packages/workflows
!packages/workflows-sdk
!packages/core-flows


**/models/*
Expand Down
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ module.exports = {
"./packages/create-medusa-app/tsconfig.json",
"./packages/product/tsconfig.json",
"./packages/orchestration/tsconfig.json",
"./packages/workflows/tsconfig.spec.json",
"./packages/workflows-sdk/tsconfig.spec.json",
"./packages/core-flows/tsconfig.spec.json",
],
},
rules: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { IInventoryService, WorkflowTypes } from "@medusajs/types"
import {
CreateInventoryItemActions,
createInventoryItems,
pipe,
} from "@medusajs/workflows"
} from "@medusajs/core-flows"

import { pipe } from "@medusajs/workflows-sdk"
import path from "path"
import { startBootstrapApp } from "../../../../environment-helpers/bootstrap-app"
import { getContainer } from "../../../../environment-helpers/use-container"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
import { IProductModuleService, WorkflowTypes } from "@medusajs/types"
import {
createProducts,
CreateProductsActions,
Handlers,
createProducts,
pipe,
} from "@medusajs/workflows"
} from "@medusajs/core-flows"
import path from "path"
import { startBootstrapApp } from "../../../../environment-helpers/bootstrap-app"
import { getContainer } from "../../../../environment-helpers/use-container"
import { initDb, useDb } from "../../../../environment-helpers/use-db"
import { pipe } from "@medusajs/workflows-sdk"

jest.setTimeout(30000)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { WorkflowTypes } from "@medusajs/types"
import {
Handlers,
pipe,
updateProducts,
UpdateProductsActions,
} from "@medusajs/workflows"
} from "@medusajs/core-flows"
import { pipe } from "@medusajs/workflows-sdk"
import path from "path"

import { startBootstrapApp } from "../../../../environment-helpers/bootstrap-app"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
parallelize,
StepResponse,
transform,
} from "@medusajs/workflows"
} from "@medusajs/workflows-sdk"

jest.setTimeout(30000)

Expand Down
2 changes: 1 addition & 1 deletion integration-tests/plugins/medusa-config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { Modules } = require("@medusajs/modules-sdk")
const { Workflows } = require("@medusajs/workflows")
const { Workflows } = require("@medusajs/core-flows")
const DB_HOST = process.env.DB_HOST
const DB_USERNAME = process.env.DB_USERNAME
const DB_PASSWORD = process.env.DB_PASSWORD
Expand Down
1 change: 1 addition & 0 deletions packages/core-flows/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# @medusajs/core-flows
42 changes: 42 additions & 0 deletions packages/core-flows/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "@medusajs/core-flows",
"version": "0.0.1",
"description": "Set of workflow definitions for Medusa",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/medusajs/medusa",
"directory": "packages/core-flows"
},
"publishConfig": {
"access": "public"
},
"files": [
"dist"
],
"author": "Medusa",
"license": "MIT",
"devDependencies": {
"@medusajs/types": "^1.11.7",
"cross-env": "^5.2.1",
"jest": "^29.6.3",
"rimraf": "^5.0.1",
"ts-jest": "^29.1.1",
"typescript": "^5.1.6"
},
"dependencies": {
"@medusajs/modules-sdk": "^1.12.3",
"@medusajs/orchestration": "^0.4.4",
"@medusajs/utils": "^1.11.0",
"@medusajs/workflows-sdk": "^0.1.0",
"awilix": "^8.0.1",
"ulid": "^2.3.0"
},
"scripts": {
"prepublishOnly": "cross-env NODE_ENV=production tsc --build",
"build": "rimraf dist && tsc --build",
"watch": "tsc --build --watch",
"test": "jest --runInBand --bail --forceExit --passWithNoTests"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
RegionHandlers,
SalesChannelHandlers,
} from "../../handlers"
import { exportWorkflow, pipe } from "../../helper"
import { exportWorkflow, pipe } from "@medusajs/workflows-sdk"

enum CreateCartActions {
setContext = "setContext",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from "./cart"
export * from "./product"
export * from "./inventory"
export * from './price-list'
export * from "./price-list"
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
TransactionStepsDefinition,
WorkflowManager,
} from "@medusajs/orchestration"
import { exportWorkflow, pipe } from "../../helper"
import { exportWorkflow, pipe } from "@medusajs/workflows-sdk"

import { InventoryTypes, WorkflowTypes } from "@medusajs/types"
import { InventoryHandlers } from "../../handlers"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
WorkflowManager,
} from "@medusajs/orchestration"
import { PricingTypes, WorkflowTypes } from "@medusajs/types"
import { exportWorkflow, pipe } from "../../helper"
import { exportWorkflow, pipe } from "@medusajs/workflows-sdk"

import { Workflows } from "../../definitions"
import { PriceListHandlers } from "../../handlers"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from "./create-price-lists"
export * from "./remove-price-lists"
export * from "./remove-price-list-prices"
export * from "./remove-product-prices"
export * from "./remove-variant-prices"
export * from "./update-price-lists"
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
WorkflowManager,
} from "@medusajs/orchestration"
import { WorkflowTypes } from "@medusajs/types"
import { exportWorkflow, pipe } from "../../helper"
import { exportWorkflow, pipe } from "@medusajs/workflows-sdk"

import { Workflows } from "../../definitions"
import { PriceListHandlers } from "../../handlers"
Expand Down Expand Up @@ -62,7 +62,7 @@ WorkflowManager.register(
handlers
)

export const removePriceListProductPrices = exportWorkflow<
export const removePriceListPrices = exportWorkflow<
WorkflowTypes.PriceListWorkflow.RemovePriceListPricesWorkflowInputDTO,
string[]
>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
TransactionStepsDefinition,
WorkflowManager,
} from "@medusajs/orchestration"
import { exportWorkflow, pipe } from "../../helper"
import { exportWorkflow, pipe } from "@medusajs/workflows-sdk"

import { PriceListHandlers } from "../../handlers"
import { Workflows } from "../../definitions"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
WorkflowManager,
} from "@medusajs/orchestration"
import { WorkflowTypes } from "@medusajs/types"
import { exportWorkflow, pipe } from "../../helper"
import { exportWorkflow, pipe } from "@medusajs/workflows-sdk"

import { Workflows } from "../../definitions"
import { PriceListHandlers } from "../../handlers"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
WorkflowManager,
} from "@medusajs/orchestration"
import { WorkflowTypes } from "@medusajs/types"
import { exportWorkflow, pipe } from "../../helper"
import { exportWorkflow, pipe } from "@medusajs/workflows-sdk"

import { Workflows } from "../../definitions"
import { PriceListHandlers } from "../../handlers"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
WorkflowManager,
} from "@medusajs/orchestration"
import { WorkflowTypes } from "@medusajs/types"
import { exportWorkflow, pipe } from "../../helper"
import { exportWorkflow, pipe } from "@medusajs/workflows-sdk"

import { Workflows } from "../../definitions"
import { PriceListHandlers } from "../../handlers"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
WorkflowManager,
} from "@medusajs/orchestration"
import { InputAlias, Workflows } from "../../definitions"
import { exportWorkflow, pipe } from "../../helper"
import { exportWorkflow, pipe } from "@medusajs/workflows-sdk"

import { ProductTypes, WorkflowTypes } from "@medusajs/types"
import { ProductHandlers } from "../../handlers"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
TransactionStepsDefinition,
WorkflowManager,
} from "@medusajs/orchestration"
import { exportWorkflow, pipe } from "../../helper"
import { exportWorkflow, pipe } from "@medusajs/workflows-sdk"

import { ProductTypes, WorkflowTypes } from "@medusajs/types"
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ProductTypes } from "@medusajs/types"
import { WorkflowArguments } from "../../helper"
import { WorkflowArguments } from "@medusajs/workflows-sdk"

type AssociationTaggedVariant = ProductTypes.ProductVariantDTO & {
_associationTag?: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
WorkflowManager,
} from "@medusajs/orchestration"
import { InputAlias, Workflows } from "../../definitions"
import { exportWorkflow, pipe } from "../../helper"
import { exportWorkflow, pipe } from "@medusajs/workflows-sdk"

import { ProductTypes, WorkflowTypes } from "@medusajs/types"
import { ProductHandlers } from "../../handlers"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ 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 { exportWorkflow, pipe } from "@medusajs/workflows-sdk"
import { CreateProductsActions } from "./create-products"
import { prepareCreateInventoryItems } from "./prepare-create-inventory-items"
import { UpdateProductVariantsActions } from "./update-product-variants"
Expand Down Expand Up @@ -137,7 +137,7 @@ const handlers = new Map<string, any>([
},
],
},
MiddlewareHandlers.mapData((d) => ({
MiddlewareHandlers.mapData((d: any) => ({
productsHandleSalesChannelsMap:
d.preparedData.productHandleAddedChannelsMap,
})),
Expand All @@ -157,7 +157,7 @@ const handlers = new Map<string, any>([
},
],
},
MiddlewareHandlers.mapData((d) => ({
MiddlewareHandlers.mapData((d: any) => ({
productsHandleSalesChannelsMap:
d.preparedData.productHandleAddedChannelsMap,
})),
Expand All @@ -183,7 +183,7 @@ const handlers = new Map<string, any>([
},
],
},
MiddlewareHandlers.mapData((d) => ({
MiddlewareHandlers.mapData((d: any) => ({
productsHandleSalesChannelsMap:
d.preparedData.productHandleRemovedChannelsMap,
})),
Expand All @@ -204,7 +204,7 @@ const handlers = new Map<string, any>([
},
],
},
MiddlewareHandlers.mapData((d) => ({
MiddlewareHandlers.mapData((d: any) => ({
productsHandleSalesChannelsMap:
d.preparedData.productHandleRemovedChannelsMap,
})),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AddressDTO } from "@medusajs/types"
import { MedusaError } from "@medusajs/utils"

import { WorkflowArguments } from "../../helper"
import { WorkflowArguments } from "@medusajs/workflows-sdk"

type AddressesDTO = {
shipping_address_id?: string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CartWorkflow } from "@medusajs/types"
import { SalesChannelFeatureFlag } from "@medusajs/utils"

import { WorkflowArguments } from "../../helper"
import { WorkflowArguments } from "@medusajs/workflows-sdk"

type HandlerInputData = {
line_items: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CartDTO } from "@medusajs/types"
import { WorkflowArguments } from "../../helper"
import { WorkflowArguments } from "@medusajs/workflows-sdk"

enum Aliases {
SalesChannel = "SalesChannel",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { WorkflowArguments } from "../../helper"
import { WorkflowArguments } from "@medusajs/workflows-sdk"

enum Aliases {
Cart = "cart",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CartDTO } from "@medusajs/types"
import { WorkflowArguments } from "../../helper"
import { WorkflowArguments } from "@medusajs/workflows-sdk"

type HandlerInputData = {
cart: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { WorkflowArguments } from "../../helper"
import { WorkflowArguments } from "@medusajs/workflows-sdk"

type ContextDTO = {
context?: Record<any, any>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { validateEmail } from "@medusajs/utils"

import { WorkflowArguments } from "../../helper"
import { WorkflowArguments } from "@medusajs/workflows-sdk"

type CustomerDTO = {
customer_id?: string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { InventoryItemDTO } from "@medusajs/types"
import { WorkflowArguments } from "../../helper"
import { WorkflowArguments } from "@medusajs/workflows-sdk"

export async function attachInventoryItems({
container,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IInventoryService, InventoryItemDTO } from "@medusajs/types"
import { WorkflowArguments } from "../../helper"
import { WorkflowArguments } from "@medusajs/workflows-sdk"
import { promiseAll } from "@medusajs/utils"

type Result = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { InventoryItemDTO } from "@medusajs/types"
import { WorkflowArguments } from "../../helper"
import { WorkflowArguments } from "@medusajs/workflows-sdk"
import { promiseAll } from "@medusajs/utils"

export async function detachInventoryItems({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { InventoryItemDTO } from "@medusajs/types"
import { WorkflowArguments } from "../../helper"
import { WorkflowArguments } from "@medusajs/workflows-sdk"

export async function removeInventoryItems({
container,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
InventoryItemDTO,
SharedContext,
} from "@medusajs/types"
import { WorkflowArguments } from "../../helper"
import { WorkflowArguments } from "@medusajs/workflows-sdk"

export async function restoreInventoryItems({
container,
Expand Down
Loading