chore(core-flows): [14] export types and steps, add basic TSDocs (#8524)
This commit is contained in:
@@ -4,6 +4,9 @@ import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
export const batchLinkProductsToCollectionStepId =
|
||||
"batch-link-products-to-collection"
|
||||
/**
|
||||
* This step creates links between product and collection records.
|
||||
*/
|
||||
export const batchLinkProductsToCollectionStep = createStep(
|
||||
batchLinkProductsToCollectionStepId,
|
||||
async (data: LinkWorkflowInput, { container }) => {
|
||||
|
||||
@@ -4,6 +4,9 @@ import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
export const batchLinkProductsToCategoryStepId =
|
||||
"batch-link-products-to-category"
|
||||
/**
|
||||
* This step creates links between product and category records.
|
||||
*/
|
||||
export const batchLinkProductsToCategoryStep = createStep(
|
||||
batchLinkProductsToCategoryStepId,
|
||||
async (
|
||||
|
||||
@@ -3,6 +3,9 @@ import { ModuleRegistrationName } from "@medusajs/utils"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
export const createCollectionsStepId = "create-collections"
|
||||
/**
|
||||
* This step creates one or more collection.
|
||||
*/
|
||||
export const createCollectionsStep = createStep(
|
||||
createCollectionsStepId,
|
||||
async (data: ProductTypes.CreateProductCollectionDTO[], { container }) => {
|
||||
|
||||
@@ -3,6 +3,9 @@ import { ModuleRegistrationName } from "@medusajs/utils"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
export const createProductOptionsStepId = "create-product-options"
|
||||
/**
|
||||
* This step creates one or more product options.
|
||||
*/
|
||||
export const createProductOptionsStep = createStep(
|
||||
createProductOptionsStepId,
|
||||
async (data: ProductTypes.CreateProductOptionDTO[], { container }) => {
|
||||
|
||||
@@ -3,6 +3,9 @@ import { ModuleRegistrationName } from "@medusajs/utils"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
export const createProductTagsStepId = "create-product-tags"
|
||||
/**
|
||||
* This step creates one or more product tags.
|
||||
*/
|
||||
export const createProductTagsStep = createStep(
|
||||
createProductTagsStepId,
|
||||
async (data: ProductTypes.CreateProductTagDTO[], { container }) => {
|
||||
|
||||
@@ -3,6 +3,9 @@ import { ModuleRegistrationName } from "@medusajs/utils"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
export const createProductTypesStepId = "create-product-types"
|
||||
/**
|
||||
* This step creates one or more product types.
|
||||
*/
|
||||
export const createProductTypesStep = createStep(
|
||||
createProductTypesStepId,
|
||||
async (data: ProductTypes.CreateProductTypeDTO[], { container }) => {
|
||||
|
||||
@@ -3,6 +3,9 @@ import { ModuleRegistrationName } from "@medusajs/utils"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
export const createProductVariantsStepId = "create-product-variants"
|
||||
/**
|
||||
* This step creates one or more product variants.
|
||||
*/
|
||||
export const createProductVariantsStep = createStep(
|
||||
createProductVariantsStepId,
|
||||
async (data: ProductTypes.CreateProductVariantDTO[], { container }) => {
|
||||
|
||||
@@ -3,6 +3,9 @@ import { ModuleRegistrationName } from "@medusajs/utils"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
export const createProductsStepId = "create-products"
|
||||
/**
|
||||
* This step creates one or more products.
|
||||
*/
|
||||
export const createProductsStep = createStep(
|
||||
createProductsStepId,
|
||||
async (data: ProductTypes.CreateProductDTO[], { container }) => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ContainerRegistrationKeys, Modules } from "@medusajs/utils"
|
||||
import { createStep, StepResponse } from "@medusajs/workflows-sdk"
|
||||
|
||||
type StepInput = {
|
||||
export type CreateVariantPricingLinkStepInput = {
|
||||
links: {
|
||||
variant_id: string
|
||||
price_set_id: string
|
||||
@@ -9,9 +9,12 @@ type StepInput = {
|
||||
}
|
||||
|
||||
export const createVariantPricingLinkStepId = "create-variant-pricing-link"
|
||||
/**
|
||||
* This step creates links between variant and price set records.
|
||||
*/
|
||||
export const createVariantPricingLinkStep = createStep(
|
||||
createVariantPricingLinkStepId,
|
||||
async (data: StepInput, { container }) => {
|
||||
async (data: CreateVariantPricingLinkStepInput, { container }) => {
|
||||
const remoteLink = container.resolve(ContainerRegistrationKeys.REMOTE_LINK)
|
||||
await remoteLink.create(
|
||||
data.links.map((entry) => ({
|
||||
|
||||
@@ -3,6 +3,9 @@ import { ModuleRegistrationName } from "@medusajs/utils"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
export const deleteCollectionsStepId = "delete-collections"
|
||||
/**
|
||||
* This step deletes one or more collections.
|
||||
*/
|
||||
export const deleteCollectionsStep = createStep(
|
||||
deleteCollectionsStepId,
|
||||
async (ids: string[], { container }) => {
|
||||
|
||||
@@ -3,6 +3,9 @@ import { ModuleRegistrationName } from "@medusajs/utils"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
export const deleteProductOptionsStepId = "delete-product-options"
|
||||
/**
|
||||
* This step deletes one or more product options.
|
||||
*/
|
||||
export const deleteProductOptionsStep = createStep(
|
||||
deleteProductOptionsStepId,
|
||||
async (ids: string[], { container }) => {
|
||||
|
||||
@@ -3,6 +3,9 @@ import { ModuleRegistrationName } from "@medusajs/utils"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
export const deleteProductTagsStepId = "delete-product-tags"
|
||||
/**
|
||||
* This step deletes one or more product tags.
|
||||
*/
|
||||
export const deleteProductTagsStep = createStep(
|
||||
deleteProductTagsStepId,
|
||||
async (ids: string[], { container }) => {
|
||||
|
||||
@@ -3,6 +3,9 @@ import { ModuleRegistrationName } from "@medusajs/utils"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
export const deleteProductTypesStepId = "delete-product-types"
|
||||
/**
|
||||
* This step deletes one or more product types.
|
||||
*/
|
||||
export const deleteProductTypesStep = createStep(
|
||||
deleteProductTypesStepId,
|
||||
async (ids: string[], { container }) => {
|
||||
|
||||
@@ -3,6 +3,9 @@ import { ModuleRegistrationName } from "@medusajs/utils"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
export const deleteProductVariantsStepId = "delete-product-variants"
|
||||
/**
|
||||
* This step deletes one or more product variants.
|
||||
*/
|
||||
export const deleteProductVariantsStep = createStep(
|
||||
deleteProductVariantsStepId,
|
||||
async (ids: string[], { container }) => {
|
||||
|
||||
@@ -3,6 +3,9 @@ import { ModuleRegistrationName } from "@medusajs/utils"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
export const deleteProductsStepId = "delete-products"
|
||||
/**
|
||||
* This step deletes one or more products.
|
||||
*/
|
||||
export const deleteProductsStep = createStep(
|
||||
deleteProductsStepId,
|
||||
async (ids: string[], { container }) => {
|
||||
|
||||
@@ -58,6 +58,9 @@ const csvSortFunction = (a: string, b: string) => {
|
||||
}
|
||||
|
||||
export const generateProductCsvStepId = "generate-product-csv"
|
||||
/**
|
||||
* This step generates a CSV file to be exported.
|
||||
*/
|
||||
export const generateProductCsvStep = createStep(
|
||||
generateProductCsvStepId,
|
||||
async (products: HttpTypes.AdminProduct[], { container }) => {
|
||||
|
||||
@@ -5,15 +5,18 @@ import {
|
||||
} from "@medusajs/utils"
|
||||
import { createStep, StepResponse } from "@medusajs/workflows-sdk"
|
||||
|
||||
type StepInput = {
|
||||
export type GetAllProductsStepInput = {
|
||||
select: string[]
|
||||
filter?: FilterableProductProps
|
||||
}
|
||||
|
||||
export const getAllProductsStepId = "get-all-products"
|
||||
/**
|
||||
* This step retrieves all products.
|
||||
*/
|
||||
export const getAllProductsStep = createStep(
|
||||
getAllProductsStepId,
|
||||
async (data: StepInput, { container }) => {
|
||||
async (data: GetAllProductsStepInput, { container }) => {
|
||||
const remoteQuery: RemoteQueryFunction = container.resolve(
|
||||
ContainerRegistrationKeys.REMOTE_QUERY
|
||||
)
|
||||
|
||||
@@ -2,14 +2,17 @@ import { IProductModuleService } from "@medusajs/types"
|
||||
import { ModuleRegistrationName } from "@medusajs/utils"
|
||||
import { createStep, StepResponse } from "@medusajs/workflows-sdk"
|
||||
|
||||
type StepInput = {
|
||||
export type GetProductsStepInput = {
|
||||
ids?: string[]
|
||||
}
|
||||
|
||||
export const getProductsStepId = "get-products"
|
||||
/**
|
||||
* This step retrieves products.
|
||||
*/
|
||||
export const getProductsStep = createStep(
|
||||
getProductsStepId,
|
||||
async (data: StepInput, { container }) => {
|
||||
async (data: GetProductsStepInput, { container }) => {
|
||||
const service = container.resolve<IProductModuleService>(
|
||||
ModuleRegistrationName.PRODUCT
|
||||
)
|
||||
|
||||
@@ -6,14 +6,17 @@ import {
|
||||
} from "@medusajs/utils"
|
||||
import { createStep, StepResponse } from "@medusajs/workflows-sdk"
|
||||
|
||||
type StepInput = {
|
||||
export type GetVariantPricingLinkStepInput = {
|
||||
ids: string[]
|
||||
}
|
||||
|
||||
export const getVariantPricingLinkStepId = "get-variant-pricing-link"
|
||||
/**
|
||||
* This step retrieves links between a product variant and its linked price sets.
|
||||
*/
|
||||
export const getVariantPricingLinkStep = createStep(
|
||||
getVariantPricingLinkStepId,
|
||||
async (data: StepInput, { container }) => {
|
||||
async (data: GetVariantPricingLinkStepInput, { container }) => {
|
||||
if (!data.ids.length) {
|
||||
return new StepResponse([])
|
||||
}
|
||||
|
||||
@@ -3,6 +3,9 @@ import { ModuleRegistrationName } from "@medusajs/utils"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
export const groupProductsForBatchStepId = "group-products-for-batch"
|
||||
/**
|
||||
* This step groups products to be created and updated.
|
||||
*/
|
||||
export const groupProductsForBatchStep = createStep(
|
||||
groupProductsForBatchStepId,
|
||||
async (
|
||||
|
||||
@@ -13,6 +13,9 @@ import {
|
||||
import { normalizeV1Products } from "../helpers/normalize-v1-import"
|
||||
|
||||
export const parseProductCsvStepId = "parse-product-csv"
|
||||
/**
|
||||
* This step parses a CSV file holding products to import.
|
||||
*/
|
||||
export const parseProductCsvStep = createStep(
|
||||
parseProductCsvStepId,
|
||||
async (fileContent: string, { container }) => {
|
||||
|
||||
@@ -5,12 +5,15 @@ import {
|
||||
} from "@medusajs/utils"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
type UpdateCollectionsStepInput = {
|
||||
export type UpdateCollectionsStepInput = {
|
||||
selector: ProductTypes.FilterableProductCollectionProps
|
||||
update: ProductTypes.UpdateProductCollectionDTO
|
||||
}
|
||||
|
||||
export const updateCollectionsStepId = "update-collections"
|
||||
/**
|
||||
* This step updates collections matching the specified filters.
|
||||
*/
|
||||
export const updateCollectionsStep = createStep(
|
||||
updateCollectionsStepId,
|
||||
async (data: UpdateCollectionsStepInput, { container }) => {
|
||||
|
||||
@@ -5,12 +5,15 @@ import {
|
||||
} from "@medusajs/utils"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
type UpdateProductOptionsStepInput = {
|
||||
export type UpdateProductOptionsStepInput = {
|
||||
selector: ProductTypes.FilterableProductOptionProps
|
||||
update: ProductTypes.UpdateProductOptionDTO
|
||||
}
|
||||
|
||||
export const updateProductOptionsStepId = "update-product-options"
|
||||
/**
|
||||
* This step updates product options matching the specified filters.
|
||||
*/
|
||||
export const updateProductOptionsStep = createStep(
|
||||
updateProductOptionsStepId,
|
||||
async (data: UpdateProductOptionsStepInput, { container }) => {
|
||||
|
||||
@@ -5,12 +5,15 @@ import {
|
||||
} from "@medusajs/utils"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
type UpdateProductTagsStepInput = {
|
||||
export type UpdateProductTagsStepInput = {
|
||||
selector: ProductTypes.FilterableProductTagProps
|
||||
update: ProductTypes.UpdateProductTagDTO
|
||||
}
|
||||
|
||||
export const updateProductTagsStepId = "update-product-tags"
|
||||
/**
|
||||
* This step updates product tags matching the specified filters.
|
||||
*/
|
||||
export const updateProductTagsStep = createStep(
|
||||
updateProductTagsStepId,
|
||||
async (data: UpdateProductTagsStepInput, { container }) => {
|
||||
|
||||
@@ -5,12 +5,15 @@ import {
|
||||
} from "@medusajs/utils"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
type UpdateProductTypesStepInput = {
|
||||
export type UpdateProductTypesStepInput = {
|
||||
selector: ProductTypes.FilterableProductTypeProps
|
||||
update: ProductTypes.UpdateProductTypeDTO
|
||||
}
|
||||
|
||||
export const updateProductTypesStepId = "update-product-types"
|
||||
/**
|
||||
* This step updates product types matching the specified filters.
|
||||
*/
|
||||
export const updateProductTypesStep = createStep(
|
||||
updateProductTypesStepId,
|
||||
async (data: UpdateProductTypesStepInput, { container }) => {
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
} from "@medusajs/utils"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
type UpdateProductVariantsStepInput =
|
||||
export type UpdateProductVariantsStepInput =
|
||||
| {
|
||||
selector: ProductTypes.FilterableProductVariantProps
|
||||
update: ProductTypes.UpdateProductVariantDTO
|
||||
@@ -16,6 +16,9 @@ type UpdateProductVariantsStepInput =
|
||||
}
|
||||
|
||||
export const updateProductVariantsStepId = "update-product-variants"
|
||||
/**
|
||||
* This step updates one or more product variants.
|
||||
*/
|
||||
export const updateProductVariantsStep = createStep(
|
||||
updateProductVariantsStepId,
|
||||
async (data: UpdateProductVariantsStepInput, { container }) => {
|
||||
|
||||
@@ -16,6 +16,9 @@ export type UpdateProductsStepInput =
|
||||
}
|
||||
|
||||
export const updateProductsStepId = "update-products"
|
||||
/**
|
||||
* This step updates one or more products.
|
||||
*/
|
||||
export const updateProductsStep = createStep(
|
||||
updateProductsStepId,
|
||||
async (data: UpdateProductsStepInput, { container }) => {
|
||||
|
||||
@@ -2,6 +2,9 @@ import { createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
export const waitConfirmationProductImportStepId =
|
||||
"wait-confirmation-product-import"
|
||||
/**
|
||||
* This step waits until a product import is confirmed.
|
||||
*/
|
||||
export const waitConfirmationProductImportStep = createStep(
|
||||
{
|
||||
name: waitConfirmationProductImportStepId,
|
||||
|
||||
Reference in New Issue
Block a user