chore(core-flows): [11] export types and types, add basic TSDocs (#8521)
This commit is contained in:
1 parent
945b920708
commit
4c2d605599
25 files changed
+100
-24
No files matched your search
@@ -6,7 +6,7 @@ import {
|
|||||||
import { ModuleRegistrationName } from "@medusajs/utils"
|
import { ModuleRegistrationName } from "@medusajs/utils"
|
||||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||||
|
|
||||||
interface StepInput {
|
export interface CreatePaymentSessionStepInput {
|
||||||
payment_collection_id: string
|
payment_collection_id: string
|
||||||
provider_id: string
|
provider_id: string
|
||||||
amount: BigNumberInput
|
amount: BigNumberInput
|
||||||
@@ -16,9 +16,12 @@ interface StepInput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const createPaymentSessionStepId = "create-payment-session"
|
export const createPaymentSessionStepId = "create-payment-session"
|
||||||
|
/**
|
||||||
|
* This step creates a payment session.
|
||||||
|
*/
|
||||||
export const createPaymentSessionStep = createStep(
|
export const createPaymentSessionStep = createStep(
|
||||||
createPaymentSessionStepId,
|
createPaymentSessionStepId,
|
||||||
async (input: StepInput, { container }) => {
|
async (input: CreatePaymentSessionStepInput, { container }) => {
|
||||||
const service = container.resolve<IPaymentModuleService>(
|
const service = container.resolve<IPaymentModuleService>(
|
||||||
ModuleRegistrationName.PAYMENT
|
ModuleRegistrationName.PAYMENT
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -3,6 +3,9 @@ import { ModuleRegistrationName } from "@medusajs/utils"
|
|||||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||||
|
|
||||||
export const createRefundReasonStepId = "create-refund-reason"
|
export const createRefundReasonStepId = "create-refund-reason"
|
||||||
|
/**
|
||||||
|
* This step creates one or more refund reasons.
|
||||||
|
*/
|
||||||
export const createRefundReasonStep = createStep(
|
export const createRefundReasonStep = createStep(
|
||||||
createRefundReasonStepId,
|
createRefundReasonStepId,
|
||||||
async (data: CreateRefundReasonDTO[], { container }) => {
|
async (data: CreateRefundReasonDTO[], { container }) => {
|
||||||
|
|||||||
@@ -9,16 +9,20 @@ import {
|
|||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||||
|
|
||||||
interface StepInput {
|
export interface DeletePaymentSessionStepInput {
|
||||||
ids: string[]
|
ids: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: This step should not be used alone as it doesn't consider a revert
|
|
||||||
// Use deletePaymentSessionsWorkflow instead that uses this step
|
|
||||||
export const deletePaymentSessionsStepId = "delete-payment-sessions"
|
export const deletePaymentSessionsStepId = "delete-payment-sessions"
|
||||||
|
/**
|
||||||
|
* This step deletes one or more payment sessions.
|
||||||
|
*
|
||||||
|
* Note: This step should not be used alone as it doesn't consider a revert
|
||||||
|
* Use deletePaymentSessionsWorkflow instead that uses this step
|
||||||
|
*/
|
||||||
export const deletePaymentSessionsStep = createStep(
|
export const deletePaymentSessionsStep = createStep(
|
||||||
deletePaymentSessionsStepId,
|
deletePaymentSessionsStepId,
|
||||||
async (input: StepInput, { container }) => {
|
async (input: DeletePaymentSessionStepInput, { container }) => {
|
||||||
const { ids = [] } = input
|
const { ids = [] } = input
|
||||||
const deleted: PaymentSessionDTO[] = []
|
const deleted: PaymentSessionDTO[] = []
|
||||||
const logger = container.resolve<Logger>(ContainerRegistrationKeys.LOGGER)
|
const logger = container.resolve<Logger>(ContainerRegistrationKeys.LOGGER)
|
||||||
|
|||||||
@@ -3,6 +3,9 @@ import { ModuleRegistrationName } from "@medusajs/utils"
|
|||||||
import { createStep, StepResponse } from "@medusajs/workflows-sdk"
|
import { createStep, StepResponse } from "@medusajs/workflows-sdk"
|
||||||
|
|
||||||
export const deleteRefundReasonsStepId = "delete-refund-reasons"
|
export const deleteRefundReasonsStepId = "delete-refund-reasons"
|
||||||
|
/**
|
||||||
|
* This step deletes one or more refund reasons.
|
||||||
|
*/
|
||||||
export const deleteRefundReasonsStep = createStep(
|
export const deleteRefundReasonsStep = createStep(
|
||||||
deleteRefundReasonsStepId,
|
deleteRefundReasonsStepId,
|
||||||
async (ids: string[], { container }) => {
|
async (ids: string[], { container }) => {
|
||||||
|
|||||||
@@ -10,15 +10,18 @@ import {
|
|||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||||
|
|
||||||
interface StepInput {
|
export interface UpdatePaymentCollectionStepInput {
|
||||||
selector: FilterablePaymentCollectionProps
|
selector: FilterablePaymentCollectionProps
|
||||||
update: PaymentCollectionUpdatableFields
|
update: PaymentCollectionUpdatableFields
|
||||||
}
|
}
|
||||||
|
|
||||||
export const updatePaymentCollectionStepId = "update-payment-collection"
|
export const updatePaymentCollectionStepId = "update-payment-collection"
|
||||||
|
/**
|
||||||
|
* This step updates payment collections matching the specified filters.
|
||||||
|
*/
|
||||||
export const updatePaymentCollectionStep = createStep(
|
export const updatePaymentCollectionStep = createStep(
|
||||||
updatePaymentCollectionStepId,
|
updatePaymentCollectionStepId,
|
||||||
async (data: StepInput, { container }) => {
|
async (data: UpdatePaymentCollectionStepInput, { container }) => {
|
||||||
if (!isPresent(data) || !isPresent(data.selector)) {
|
if (!isPresent(data) || !isPresent(data.selector)) {
|
||||||
return new StepResponse([], [])
|
return new StepResponse([], [])
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ import {
|
|||||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||||
|
|
||||||
export const updateRefundReasonStepId = "update-refund-reasons"
|
export const updateRefundReasonStepId = "update-refund-reasons"
|
||||||
|
/**
|
||||||
|
* This step updates one or more refund reasons.
|
||||||
|
*/
|
||||||
export const updateRefundReasonsStep = createStep(
|
export const updateRefundReasonsStep = createStep(
|
||||||
updateRefundReasonStepId,
|
updateRefundReasonStepId,
|
||||||
async (data: UpdateRefundReasonDTO[], { container }) => {
|
async (data: UpdateRefundReasonDTO[], { container }) => {
|
||||||
|
|||||||
+5
-2
@@ -1,16 +1,19 @@
|
|||||||
import { MedusaError } from "@medusajs/utils"
|
import { MedusaError } from "@medusajs/utils"
|
||||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||||
|
|
||||||
interface StepInput {
|
export interface ValidateDeletedPaymentSessionsStepInput {
|
||||||
idsToDelete: string[]
|
idsToDelete: string[]
|
||||||
idsDeleted: string[]
|
idsDeleted: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export const validateDeletedPaymentSessionsStepId =
|
export const validateDeletedPaymentSessionsStepId =
|
||||||
"validate-deleted-payment-sessions"
|
"validate-deleted-payment-sessions"
|
||||||
|
/**
|
||||||
|
* This step validates that the specified payment session IDs were deleted.
|
||||||
|
*/
|
||||||
export const validateDeletedPaymentSessionsStep = createStep(
|
export const validateDeletedPaymentSessionsStep = createStep(
|
||||||
validateDeletedPaymentSessionsStepId,
|
validateDeletedPaymentSessionsStepId,
|
||||||
async (input: StepInput) => {
|
async (input: ValidateDeletedPaymentSessionsStepInput) => {
|
||||||
const { idsToDelete = [], idsDeleted = [] } = input
|
const { idsToDelete = [], idsDeleted = [] } = input
|
||||||
|
|
||||||
if (idsToDelete.length !== idsDeleted.length) {
|
if (idsToDelete.length !== idsDeleted.length) {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import { useRemoteQueryStep } from "../../common"
|
|||||||
import { createPaymentSessionStep } from "../steps"
|
import { createPaymentSessionStep } from "../steps"
|
||||||
import { deletePaymentSessionsWorkflow } from "./delete-payment-sessions"
|
import { deletePaymentSessionsWorkflow } from "./delete-payment-sessions"
|
||||||
|
|
||||||
interface WorkflowInput {
|
export interface CreatePaymentSessionsWorkflowInput {
|
||||||
payment_collection_id: string
|
payment_collection_id: string
|
||||||
provider_id: string
|
provider_id: string
|
||||||
data?: Record<string, unknown>
|
data?: Record<string, unknown>
|
||||||
@@ -18,9 +18,12 @@ interface WorkflowInput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const createPaymentSessionsWorkflowId = "create-payment-sessions"
|
export const createPaymentSessionsWorkflowId = "create-payment-sessions"
|
||||||
|
/**
|
||||||
|
* This workflow creates payment sessions.
|
||||||
|
*/
|
||||||
export const createPaymentSessionsWorkflow = createWorkflow(
|
export const createPaymentSessionsWorkflow = createWorkflow(
|
||||||
createPaymentSessionsWorkflowId,
|
createPaymentSessionsWorkflowId,
|
||||||
(input: WorkflowData<WorkflowInput>): WorkflowResponse<PaymentSessionDTO> => {
|
(input: WorkflowData<CreatePaymentSessionsWorkflowInput>): WorkflowResponse<PaymentSessionDTO> => {
|
||||||
const paymentCollection = useRemoteQueryStep({
|
const paymentCollection = useRemoteQueryStep({
|
||||||
entry_point: "payment_collection",
|
entry_point: "payment_collection",
|
||||||
fields: ["id", "amount", "currency_code", "payment_sessions.*"],
|
fields: ["id", "amount", "currency_code", "payment_sessions.*"],
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ import {
|
|||||||
import { createRefundReasonStep } from "../steps/create-refund-reasons"
|
import { createRefundReasonStep } from "../steps/create-refund-reasons"
|
||||||
|
|
||||||
export const createRefundReasonsWorkflowId = "create-refund-reasons-workflow"
|
export const createRefundReasonsWorkflowId = "create-refund-reasons-workflow"
|
||||||
|
/**
|
||||||
|
* This workflow creates one or more refund reasons.
|
||||||
|
*/
|
||||||
export const createRefundReasonsWorkflow = createWorkflow(
|
export const createRefundReasonsWorkflow = createWorkflow(
|
||||||
createRefundReasonsWorkflowId,
|
createRefundReasonsWorkflowId,
|
||||||
(
|
(
|
||||||
|
|||||||
+5
-2
@@ -8,14 +8,17 @@ import {
|
|||||||
validateDeletedPaymentSessionsStep,
|
validateDeletedPaymentSessionsStep,
|
||||||
} from "../steps"
|
} from "../steps"
|
||||||
|
|
||||||
interface WorkflowInput {
|
export interface DeletePaymentSessionsWorkflowInput {
|
||||||
ids: string[]
|
ids: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export const deletePaymentSessionsWorkflowId = "delete-payment-sessions"
|
export const deletePaymentSessionsWorkflowId = "delete-payment-sessions"
|
||||||
|
/**
|
||||||
|
* This workflow deletes one or more payment sessions.
|
||||||
|
*/
|
||||||
export const deletePaymentSessionsWorkflow = createWorkflow(
|
export const deletePaymentSessionsWorkflow = createWorkflow(
|
||||||
deletePaymentSessionsWorkflowId,
|
deletePaymentSessionsWorkflowId,
|
||||||
(input: WorkflowData<WorkflowInput>) => {
|
(input: WorkflowData<DeletePaymentSessionsWorkflowInput>) => {
|
||||||
const idsDeleted = deletePaymentSessionsStep({ ids: input.ids })
|
const idsDeleted = deletePaymentSessionsStep({ ids: input.ids })
|
||||||
|
|
||||||
validateDeletedPaymentSessionsStep({
|
validateDeletedPaymentSessionsStep({
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ import {
|
|||||||
import { deleteRefundReasonsStep } from "../steps"
|
import { deleteRefundReasonsStep } from "../steps"
|
||||||
|
|
||||||
export const deleteRefundReasonsWorkflowId = "delete-refund-reasons-workflow"
|
export const deleteRefundReasonsWorkflowId = "delete-refund-reasons-workflow"
|
||||||
|
/**
|
||||||
|
* This workflow deletes one or more refund reasons.
|
||||||
|
*/
|
||||||
export const deleteRefundReasonsWorkflow = createWorkflow(
|
export const deleteRefundReasonsWorkflow = createWorkflow(
|
||||||
deleteRefundReasonsWorkflowId,
|
deleteRefundReasonsWorkflowId,
|
||||||
(input: WorkflowData<{ ids: string[] }>): WorkflowResponse<void> => {
|
(input: WorkflowData<{ ids: string[] }>): WorkflowResponse<void> => {
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ import {
|
|||||||
import { updateRefundReasonsStep } from "../steps"
|
import { updateRefundReasonsStep } from "../steps"
|
||||||
|
|
||||||
export const updateRefundReasonsWorkflowId = "update-refund-reasons"
|
export const updateRefundReasonsWorkflowId = "update-refund-reasons"
|
||||||
|
/**
|
||||||
|
* This workflow updates one or more refund reasons.
|
||||||
|
*/
|
||||||
export const updateRefundReasonsWorkflow = createWorkflow(
|
export const updateRefundReasonsWorkflow = createWorkflow(
|
||||||
updateRefundReasonsWorkflowId,
|
updateRefundReasonsWorkflowId,
|
||||||
(
|
(
|
||||||
|
|||||||
@@ -7,15 +7,18 @@ import {
|
|||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||||
|
|
||||||
type StepInput = {
|
export type AuthorizePaymentSessionStepInput = {
|
||||||
id: string
|
id: string
|
||||||
context: Record<string, unknown>
|
context: Record<string, unknown>
|
||||||
}
|
}
|
||||||
|
|
||||||
export const authorizePaymentSessionStepId = "authorize-payment-session-step"
|
export const authorizePaymentSessionStepId = "authorize-payment-session-step"
|
||||||
|
/**
|
||||||
|
* This step authorizes a payment session.
|
||||||
|
*/
|
||||||
export const authorizePaymentSessionStep = createStep(
|
export const authorizePaymentSessionStep = createStep(
|
||||||
authorizePaymentSessionStepId,
|
authorizePaymentSessionStepId,
|
||||||
async (input: StepInput, { container }) => {
|
async (input: AuthorizePaymentSessionStepInput, { container }) => {
|
||||||
let payment: PaymentDTO | undefined
|
let payment: PaymentDTO | undefined
|
||||||
const logger = container.resolve<Logger>(ContainerRegistrationKeys.LOGGER)
|
const logger = container.resolve<Logger>(ContainerRegistrationKeys.LOGGER)
|
||||||
const paymentModule = container.resolve<IPaymentModuleService>(
|
const paymentModule = container.resolve<IPaymentModuleService>(
|
||||||
|
|||||||
@@ -6,14 +6,17 @@ import {
|
|||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import { createStep } from "@medusajs/workflows-sdk"
|
import { createStep } from "@medusajs/workflows-sdk"
|
||||||
|
|
||||||
type StepInput = {
|
export type CancelPaymentStepInput = {
|
||||||
paymentIds: string | string[]
|
paymentIds: string | string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export const cancelPaymentStepId = "cancel-payment-step"
|
export const cancelPaymentStepId = "cancel-payment-step"
|
||||||
|
/**
|
||||||
|
* This step cancels one or more payments.
|
||||||
|
*/
|
||||||
export const cancelPaymentStep = createStep(
|
export const cancelPaymentStep = createStep(
|
||||||
cancelPaymentStepId,
|
cancelPaymentStepId,
|
||||||
async (input: StepInput, { container }) => {
|
async (input: CancelPaymentStepInput, { container }) => {
|
||||||
const logger = container.resolve<Logger>(ContainerRegistrationKeys.LOGGER)
|
const logger = container.resolve<Logger>(ContainerRegistrationKeys.LOGGER)
|
||||||
const paymentModule = container.resolve<IPaymentModuleService>(
|
const paymentModule = container.resolve<IPaymentModuleService>(
|
||||||
ModuleRegistrationName.PAYMENT
|
ModuleRegistrationName.PAYMENT
|
||||||
|
|||||||
@@ -2,16 +2,19 @@ import { BigNumberInput, IPaymentModuleService } from "@medusajs/types"
|
|||||||
import { ModuleRegistrationName } from "@medusajs/utils"
|
import { ModuleRegistrationName } from "@medusajs/utils"
|
||||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||||
|
|
||||||
type StepInput = {
|
export type CapturePaymentStepInput = {
|
||||||
payment_id: string
|
payment_id: string
|
||||||
captured_by?: string
|
captured_by?: string
|
||||||
amount?: BigNumberInput
|
amount?: BigNumberInput
|
||||||
}
|
}
|
||||||
|
|
||||||
export const capturePaymentStepId = "capture-payment-step"
|
export const capturePaymentStepId = "capture-payment-step"
|
||||||
|
/**
|
||||||
|
* This step captures a payment.
|
||||||
|
*/
|
||||||
export const capturePaymentStep = createStep(
|
export const capturePaymentStep = createStep(
|
||||||
capturePaymentStepId,
|
capturePaymentStepId,
|
||||||
async (input: StepInput, { container }) => {
|
async (input: CapturePaymentStepInput, { container }) => {
|
||||||
const paymentModule = container.resolve<IPaymentModuleService>(
|
const paymentModule = container.resolve<IPaymentModuleService>(
|
||||||
ModuleRegistrationName.PAYMENT
|
ModuleRegistrationName.PAYMENT
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -2,16 +2,19 @@ import { BigNumberInput, IPaymentModuleService } from "@medusajs/types"
|
|||||||
import { ModuleRegistrationName } from "@medusajs/utils"
|
import { ModuleRegistrationName } from "@medusajs/utils"
|
||||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||||
|
|
||||||
type StepInput = {
|
export type RefundPaymentStepInput = {
|
||||||
payment_id: string
|
payment_id: string
|
||||||
created_by?: string
|
created_by?: string
|
||||||
amount?: BigNumberInput
|
amount?: BigNumberInput
|
||||||
}
|
}
|
||||||
|
|
||||||
export const refundPaymentStepId = "refund-payment-step"
|
export const refundPaymentStepId = "refund-payment-step"
|
||||||
|
/**
|
||||||
|
* This step refunds a payment.
|
||||||
|
*/
|
||||||
export const refundPaymentStep = createStep(
|
export const refundPaymentStep = createStep(
|
||||||
refundPaymentStepId,
|
refundPaymentStepId,
|
||||||
async (input: StepInput, { container }) => {
|
async (input: RefundPaymentStepInput, { container }) => {
|
||||||
const paymentModule = container.resolve<IPaymentModuleService>(
|
const paymentModule = container.resolve<IPaymentModuleService>(
|
||||||
ModuleRegistrationName.PAYMENT
|
ModuleRegistrationName.PAYMENT
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ import { emitEventStep } from "../../common"
|
|||||||
import { capturePaymentStep } from "../steps/capture-payment"
|
import { capturePaymentStep } from "../steps/capture-payment"
|
||||||
|
|
||||||
export const capturePaymentWorkflowId = "capture-payment-workflow"
|
export const capturePaymentWorkflowId = "capture-payment-workflow"
|
||||||
|
/**
|
||||||
|
* This workflow captures a payment.
|
||||||
|
*/
|
||||||
export const capturePaymentWorkflow = createWorkflow(
|
export const capturePaymentWorkflow = createWorkflow(
|
||||||
capturePaymentWorkflowId,
|
capturePaymentWorkflowId,
|
||||||
(
|
(
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ import { emitEventStep } from "../../common"
|
|||||||
import { refundPaymentStep } from "../steps/refund-payment"
|
import { refundPaymentStep } from "../steps/refund-payment"
|
||||||
|
|
||||||
export const refundPaymentWorkflowId = "refund-payment-workflow"
|
export const refundPaymentWorkflowId = "refund-payment-workflow"
|
||||||
|
/**
|
||||||
|
* This workflow refunds a payment.
|
||||||
|
*/
|
||||||
export const refundPaymentWorkflow = createWorkflow(
|
export const refundPaymentWorkflow = createWorkflow(
|
||||||
refundPaymentWorkflowId,
|
refundPaymentWorkflowId,
|
||||||
(
|
(
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ import { removePriceListPricesWorkflowStep } from "../steps/remove-price-list-pr
|
|||||||
import { updatePriceListPricesWorkflowStep } from "../steps/update-price-list-prices-workflow"
|
import { updatePriceListPricesWorkflowStep } from "../steps/update-price-list-prices-workflow"
|
||||||
|
|
||||||
export const batchPriceListPricesWorkflowId = "batch-price-list-prices"
|
export const batchPriceListPricesWorkflowId = "batch-price-list-prices"
|
||||||
|
/**
|
||||||
|
* This workflow manages price lists' prices by creating, updating, or removing them.
|
||||||
|
*/
|
||||||
export const batchPriceListPricesWorkflow = createWorkflow(
|
export const batchPriceListPricesWorkflow = createWorkflow(
|
||||||
batchPriceListPricesWorkflowId,
|
batchPriceListPricesWorkflowId,
|
||||||
(
|
(
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ import { validatePriceListsStep } from "../steps/validate-price-lists"
|
|||||||
import { validateVariantPriceLinksStep } from "../steps/validate-variant-price-links"
|
import { validateVariantPriceLinksStep } from "../steps/validate-variant-price-links"
|
||||||
|
|
||||||
export const createPriceListPricesWorkflowId = "create-price-list-prices"
|
export const createPriceListPricesWorkflowId = "create-price-list-prices"
|
||||||
|
/**
|
||||||
|
* This workflow creates prices in price lists.
|
||||||
|
*/
|
||||||
export const createPriceListPricesWorkflow = createWorkflow(
|
export const createPriceListPricesWorkflow = createWorkflow(
|
||||||
createPriceListPricesWorkflowId,
|
createPriceListPricesWorkflowId,
|
||||||
(
|
(
|
||||||
|
|||||||
@@ -6,12 +6,15 @@ import {
|
|||||||
} from "@medusajs/workflows-sdk"
|
} from "@medusajs/workflows-sdk"
|
||||||
import { createPriceListsStep, validateVariantPriceLinksStep } from "../steps"
|
import { createPriceListsStep, validateVariantPriceLinksStep } from "../steps"
|
||||||
|
|
||||||
type WorkflowInput = { price_lists_data: CreatePriceListWorkflowInputDTO[] }
|
export type CreatePriceListsWorkflowInput = { price_lists_data: CreatePriceListWorkflowInputDTO[] }
|
||||||
|
|
||||||
export const createPriceListsWorkflowId = "create-price-lists"
|
export const createPriceListsWorkflowId = "create-price-lists"
|
||||||
|
/**
|
||||||
|
* This workflow creates one or more price lists.
|
||||||
|
*/
|
||||||
export const createPriceListsWorkflow = createWorkflow(
|
export const createPriceListsWorkflow = createWorkflow(
|
||||||
createPriceListsWorkflowId,
|
createPriceListsWorkflowId,
|
||||||
(input: WorkflowData<WorkflowInput>): WorkflowResponse<PriceListDTO[]> => {
|
(input: WorkflowData<CreatePriceListsWorkflowInput>): WorkflowResponse<PriceListDTO[]> => {
|
||||||
const variantPriceMap = validateVariantPriceLinksStep(
|
const variantPriceMap = validateVariantPriceLinksStep(
|
||||||
input.price_lists_data
|
input.price_lists_data
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ import { createWorkflow, WorkflowData } from "@medusajs/workflows-sdk"
|
|||||||
import { deletePriceListsStep } from "../steps"
|
import { deletePriceListsStep } from "../steps"
|
||||||
|
|
||||||
export const deletePriceListsWorkflowId = "delete-price-lists"
|
export const deletePriceListsWorkflowId = "delete-price-lists"
|
||||||
|
/**
|
||||||
|
* This workflow deletes one or more price lists.
|
||||||
|
*/
|
||||||
export const deletePriceListsWorkflow = createWorkflow(
|
export const deletePriceListsWorkflow = createWorkflow(
|
||||||
deletePriceListsWorkflowId,
|
deletePriceListsWorkflowId,
|
||||||
(input: WorkflowData<{ ids: string[] }>): WorkflowData<void> => {
|
(input: WorkflowData<{ ids: string[] }>): WorkflowData<void> => {
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ import {
|
|||||||
import { removePriceListPricesStep } from "../steps/remove-price-list-prices"
|
import { removePriceListPricesStep } from "../steps/remove-price-list-prices"
|
||||||
|
|
||||||
export const removePriceListPricesWorkflowId = "remove-price-list-prices"
|
export const removePriceListPricesWorkflowId = "remove-price-list-prices"
|
||||||
|
/**
|
||||||
|
* This workflow removes price lists' prices.
|
||||||
|
*/
|
||||||
export const removePriceListPricesWorkflow = createWorkflow(
|
export const removePriceListPricesWorkflow = createWorkflow(
|
||||||
removePriceListPricesWorkflowId,
|
removePriceListPricesWorkflowId,
|
||||||
(input: WorkflowData<{ ids: string[] }>): WorkflowResponse<string[]> => {
|
(input: WorkflowData<{ ids: string[] }>): WorkflowResponse<string[]> => {
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ import { validatePriceListsStep } from "../steps/validate-price-lists"
|
|||||||
import { validateVariantPriceLinksStep } from "../steps/validate-variant-price-links"
|
import { validateVariantPriceLinksStep } from "../steps/validate-variant-price-links"
|
||||||
|
|
||||||
export const updatePriceListPricesWorkflowId = "update-price-list-prices"
|
export const updatePriceListPricesWorkflowId = "update-price-list-prices"
|
||||||
|
/**
|
||||||
|
* This workflow update price lists' prices.
|
||||||
|
*/
|
||||||
export const updatePriceListPricesWorkflow = createWorkflow(
|
export const updatePriceListPricesWorkflow = createWorkflow(
|
||||||
updatePriceListPricesWorkflowId,
|
updatePriceListPricesWorkflowId,
|
||||||
(
|
(
|
||||||
|
|||||||
@@ -3,6 +3,9 @@ import { WorkflowData, createWorkflow } from "@medusajs/workflows-sdk"
|
|||||||
import { updatePriceListsStep, validatePriceListsStep } from "../steps"
|
import { updatePriceListsStep, validatePriceListsStep } from "../steps"
|
||||||
|
|
||||||
export const updatePriceListsWorkflowId = "update-price-lists"
|
export const updatePriceListsWorkflowId = "update-price-lists"
|
||||||
|
/**
|
||||||
|
* This workflow updates one or more price lists.
|
||||||
|
*/
|
||||||
export const updatePriceListsWorkflow = createWorkflow(
|
export const updatePriceListsWorkflow = createWorkflow(
|
||||||
updatePriceListsWorkflowId,
|
updatePriceListsWorkflowId,
|
||||||
(
|
(
|
||||||
|
|||||||
Reference in new issue
Block a user