chore(core-flows): [10] export types and types, add basic TSDocs (#8520)

* chore(core-flows): [10] export types and types, add basic TSDocs

* fix overlapping names

* fix overlapping name
This commit is contained in:
Shahed Nasser
2024-08-09 10:08:27 +03:00
committed by GitHub
parent a93b025233
commit f659c6d8bd
25 changed files with 99 additions and 31 deletions
@@ -2,11 +2,14 @@ import { IOrderModuleService } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/utils"
import { createStep, StepResponse } from "@medusajs/workflows-sdk"
type ArchiveOrdersStepInput = {
export type ArchiveOrdersStepInput = {
orderIds: string[]
}
export const archiveOrdersStepId = "archive-orders"
/**
* This step archives one or more orders.
*/
export const archiveOrdersStep = createStep(
archiveOrdersStepId,
async (data: ArchiveOrdersStepInput, { container }) => {
@@ -2,12 +2,13 @@ import { CancelOrderFulfillmentDTO, IOrderModuleService } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/utils"
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
type CancelOrderFulfillmentStepInput = CancelOrderFulfillmentDTO
export const cancelOrderFulfillmentStepId = "cancel-order-fulfillment"
/**
* This step cancels an order's fulfillment.
*/
export const cancelOrderFulfillmentStep = createStep(
cancelOrderFulfillmentStepId,
async (data: CancelOrderFulfillmentStepInput, { container }) => {
async (data: CancelOrderFulfillmentDTO, { container }) => {
const service = container.resolve<IOrderModuleService>(
ModuleRegistrationName.ORDER
)
@@ -11,6 +11,9 @@ import {
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
export const cancelOrderChangeStepId = "cancel-order-change"
/**
* This step cancels an order change.
*/
export const cancelOrderChangeStep = createStep(
cancelOrderChangeStepId,
async (data: CancelOrderChangeDTO, { container }) => {
@@ -2,14 +2,17 @@ import { IOrderModuleService } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/utils"
import { createStep, StepResponse } from "@medusajs/workflows-sdk"
type CompleteOrdersStepInput = {
export type CancelOrdersStepInput = {
orderIds: string[]
}
export const cancelOrdersStepId = "cancel-orders"
/**
* This step cancels one or more orders.
*/
export const cancelOrdersStep = createStep(
cancelOrdersStepId,
async (data: CompleteOrdersStepInput, { container }) => {
async (data: CancelOrdersStepInput, { container }) => {
const service = container.resolve<IOrderModuleService>(
ModuleRegistrationName.ORDER
)
@@ -2,11 +2,14 @@ import { IOrderModuleService } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/utils"
import { createStep, StepResponse } from "@medusajs/workflows-sdk"
type CompleteOrdersStepInput = {
export type CompleteOrdersStepInput = {
orderIds: string[]
}
export const completeOrdersStepId = "complete-orders"
/**
* This step completes one or more orders.
*/
export const completeOrdersStep = createStep(
completeOrdersStepId,
async (data: CompleteOrdersStepInput, { container }) => {
@@ -2,11 +2,14 @@ import { OrderChangeDTO } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/utils"
import { createStep, StepResponse } from "@medusajs/workflows-sdk"
type ConfirmOrderChangesInput = {
export type ConfirmOrderChangesInput = {
orderId: string
changes: OrderChangeDTO[]
}
/**
* This step confirms changes of an order.
*/
export const confirmOrderChanges = createStep(
"confirm-order-changes",
async (input: ConfirmOrderChangesInput, { container }) => {
@@ -2,14 +2,17 @@ import { CreateOrderLineItemDTO } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/utils"
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
interface StepInput {
export interface CreateOrderLineItemsStepInput {
items: CreateOrderLineItemDTO[]
}
export const createOrderLineItemsStepId = "create-order-line-items-step"
/**
* This step creates order line items.
*/
export const createOrderLineItemsStep = createStep(
createOrderLineItemsStepId,
async (input: StepInput, { container }) => {
async (input: CreateOrderLineItemsStepInput, { container }) => {
const orderModule = container.resolve(ModuleRegistrationName.ORDER)
const createdItems = input.items.length
@@ -6,6 +6,9 @@ import { ModuleRegistrationName } from "@medusajs/utils"
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
export const createOrderChangeActionsStepId = "create-order-change-actions"
/**
* This step creates order change actions.
*/
export const createOrderChangeActionsStep = createStep(
createOrderChangeActionsStepId,
async (data: CreateOrderChangeActionDTO[], { container }) => {
@@ -3,6 +3,9 @@ import { ModuleRegistrationName } from "@medusajs/utils"
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
export const createOrderChangeStepId = "create-order-change"
/**
* This step creates an order change.
*/
export const createOrderChangeStep = createStep(
createOrderChangeStepId,
async (data: CreateOrderChangeDTO, { container }) => {
@@ -5,13 +5,16 @@ import {
import { ModuleRegistrationName } from "@medusajs/utils"
import { createStep, StepResponse } from "@medusajs/workflows-sdk"
interface StepInput {
export interface CreateOrderShippingMethodsStepInput {
shipping_methods: CreateOrderShippingMethodDTO[]
}
/**
* This step creates order shipping methods.
*/
export const createOrderShippingMethods = createStep(
"create-order-shipping-methods",
async (input: StepInput, { container }) => {
async (input: CreateOrderShippingMethodsStepInput, { container }) => {
const service = container.resolve<IOrderModuleService>(
ModuleRegistrationName.ORDER
)
@@ -2,12 +2,13 @@ import { CreateOrderDTO, IOrderModuleService } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/utils"
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
type CreateOrdersStepInput = CreateOrderDTO[]
export const createOrdersStepId = "create-orders"
/**
* This step creates one or more orders.
*/
export const createOrdersStep = createStep(
createOrdersStepId,
async (data: CreateOrdersStepInput, { container }) => {
async (data: CreateOrderDTO[], { container }) => {
const service = container.resolve<IOrderModuleService>(
ModuleRegistrationName.ORDER
)
@@ -11,6 +11,9 @@ import {
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
export const declineOrderChangeStepId = "decline-order-change"
/**
* This step declines an order change.
*/
export const declineOrderChangeStep = createStep(
declineOrderChangeStepId,
async (data: DeclineOrderChangeDTO, { container }) => {
@@ -2,13 +2,16 @@ import { IOrderModuleService } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/utils"
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
interface StepInput {
export interface DeleteOrderLineItemsStepInput {
ids: string[]
}
/**
* This step deletes order line items.
*/
export const deleteOrderLineItems = createStep(
"delete-order-line-items",
async (input: StepInput, { container }) => {
async (input: DeleteOrderLineItemsStepInput, { container }) => {
const service = container.resolve<IOrderModuleService>(
ModuleRegistrationName.ORDER
)
@@ -3,6 +3,9 @@ import { ModuleRegistrationName } from "@medusajs/utils"
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
export const deleteOrderChangeActionsStepId = "delete-order-change-actions"
/**
* This step deletes order change actions.
*/
export const deleteOrderChangeActionsStep = createStep(
deleteOrderChangeActionsStepId,
async (data: { ids: string[] }, { container }) => {
@@ -3,6 +3,9 @@ import { ModuleRegistrationName } from "@medusajs/utils"
import { createStep, StepResponse } from "@medusajs/workflows-sdk"
export const deleteOrderChangesStepId = "delete-order-change"
/**
* This step deletes order changes.
*/
export const deleteOrderChangesStep = createStep(
deleteOrderChangesStepId,
async (data: { ids: string[] }, { container }) => {
@@ -2,13 +2,17 @@ import { IOrderModuleService } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/utils"
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
interface StepInput {
export interface DeleteOrderShippingMethodsStepInput {
ids: string[]
}
/**
* This step deletes order shipping methods.
*/
export const deleteOrderShippingMethods = createStep(
"delete-order-shipping-methods",
async (input: StepInput, { container }) => {
async (input: DeleteOrderShippingMethodsStepInput, { container }) => {
const service = container.resolve<IOrderModuleService>(
ModuleRegistrationName.ORDER
)
@@ -12,7 +12,7 @@ import {
import { MedusaError, ModuleRegistrationName } from "@medusajs/utils"
import { createStep, StepResponse } from "@medusajs/workflows-sdk"
interface StepInput {
export interface GetOrderItemTaxLinesStepInput {
order: OrderWorkflowDTO
items: OrderLineItemDTO[]
shipping_methods: OrderShippingMethodDTO[]
@@ -98,9 +98,12 @@ function normalizeLineItemsForShipping(
}
export const getOrderItemTaxLinesStepId = "get-order-item-tax-lines"
/**
* This step retrieves the tax lines for an order's line items and shipping methods.
*/
export const getOrderItemTaxLinesStep = createStep(
getOrderItemTaxLinesStepId,
async (data: StepInput, { container }) => {
async (data: GetOrderItemTaxLinesStepInput, { container }) => {
const {
order,
items = [],
@@ -3,6 +3,9 @@ import { ModuleRegistrationName } from "@medusajs/utils"
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
export const previewOrderChangeStepId = "preview-order-change"
/**
* This step retrieves a preview of an order change.
*/
export const previewOrderChangeStep = createStep(
previewOrderChangeStepId,
async (orderId: string, { container }) => {
@@ -5,12 +5,13 @@ import {
import { ModuleRegistrationName } from "@medusajs/utils"
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
type RegisterOrderFulfillmentStepInput = RegisterOrderFulfillmentDTO
export const registerOrderFulfillmentStepId = "register-order-fullfillment"
/**
* This step registers a fulfillment for an order.
*/
export const registerOrderFulfillmentStep = createStep(
registerOrderFulfillmentStepId,
async (data: RegisterOrderFulfillmentStepInput, { container }) => {
async (data: RegisterOrderFulfillmentDTO, { container }) => {
const service = container.resolve<IOrderModuleService>(
ModuleRegistrationName.ORDER
)
@@ -2,12 +2,13 @@ import { IOrderModuleService, RegisterOrderShipmentDTO } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/utils"
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
type RegisterOrderShipmentStepInput = RegisterOrderShipmentDTO
export const registerOrderShipmentStepId = "register-order-shipment"
/**
* This step registers a shipment for an order.
*/
export const registerOrderShipmentStep = createStep(
registerOrderShipmentStepId,
async (data: RegisterOrderShipmentStepInput, { container }) => {
async (data: RegisterOrderShipmentDTO, { container }) => {
const service = container.resolve<IOrderModuleService>(
ModuleRegistrationName.ORDER
)
@@ -9,16 +9,19 @@ import {
import { ModuleRegistrationName, promiseAll } from "@medusajs/utils"
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
interface StepInput {
export interface SetOrderTaxLinesForItemsStepInput {
order: OrderDTO
item_tax_lines: ItemTaxLineDTO[]
shipping_tax_lines: ShippingTaxLineDTO[]
}
export const setOrderTaxLinesForItemsStepId = "set-order-tax-lines-for-items"
/**
* This step sets the tax lines of an order's items and shipping methods.
*/
export const setOrderTaxLinesForItemsStep = createStep(
setOrderTaxLinesForItemsStepId,
async (data: StepInput, { container }) => {
async (data: SetOrderTaxLinesForItemsStepInput, { container }) => {
const { order, item_tax_lines, shipping_tax_lines } = data
const orderService = container.resolve<IOrderModuleService>(
ModuleRegistrationName.ORDER
@@ -10,6 +10,9 @@ import {
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
export const updateOrderChangeActionsStepId = "update-order-change-actions"
/**
* This step updates order change actions.
*/
export const updateOrderChangeActionsStep = createStep(
updateOrderChangeActionsStepId,
async (data: UpdateOrderChangeActionDTO[], { container }) => {
@@ -6,6 +6,9 @@ import {
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
export const updateOrderExchangesStepId = "update-order-exchange"
/**
* This step update order changes.
*/
export const updateOrderExchangesStep = createStep(
updateOrderExchangesStepId,
async (data: UpdateOrderExchangeDTO[], { container }) => {
@@ -9,6 +9,9 @@ import {
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
export const updateOrderShippingMethodsStepId = "update-order-shopping-methods"
/**
* This step updats order shipping methods.
*/
export const updateOrderShippingMethodsStep = createStep(
updateOrderShippingMethodsStepId,
async (data: UpdateOrderShippingMethodDTO[], { container }) => {
@@ -2,7 +2,7 @@ import { OrderLineItemDTO, OrderShippingMethodDTO } from "@medusajs/types"
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
import { updateOrderTaxLinesWorkflow } from "../workflows/update-tax-lines"
interface StepInput {
export interface UpdateOrderTaxLinesStepInput {
order_id: string
items?: OrderLineItemDTO[]
shipping_methods?: OrderShippingMethodDTO[]
@@ -10,9 +10,12 @@ interface StepInput {
}
export const updateOrderTaxLinesStepId = "update-order-tax-lines-step"
/**
* This step updates tax lines for an order's line items and shipping methods.
*/
export const updateOrderTaxLinesStep = createStep(
updateOrderTaxLinesStepId,
async (input: StepInput, { container }) => {
async (input: UpdateOrderTaxLinesStepInput, { container }) => {
const { transaction } = await updateOrderTaxLinesWorkflow(container).run({
input,
})