From 09171cd7efb56a4b33ab17d85e8084c8d353569b Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Mon, 9 Dec 2024 16:31:05 +0200 Subject: [PATCH] chore: fix documentation links in TSDocs --- .../src/common/steps/create-remote-links.ts | 2 +- .../src/common/steps/dismiss-remote-links.ts | 2 +- .../src/common/steps/remove-remote-links.ts | 2 +- .../src/common/steps/use-query-graph.ts | 2 +- .../src/common/steps/use-remote-query.ts | 2 +- packages/core/types/src/auth/service.ts | 4 +- packages/core/types/src/payment/service.ts | 6 +-- packages/core/types/src/tax/common.ts | 4 +- packages/core/types/src/tax/mutations.ts | 4 +- packages/core/types/src/tax/service.ts | 2 +- .../src/utils/composer/create-hook.ts | 2 +- .../src/utils/composer/create-workflow.ts | 2 +- .../workflows-sdk/src/utils/composer/type.ts | 4 +- .../workflows-sdk/src/utils/composer/when.ts | 48 +++++++++++++++++++ 14 files changed, 67 insertions(+), 19 deletions(-) diff --git a/packages/core/core-flows/src/common/steps/create-remote-links.ts b/packages/core/core-flows/src/common/steps/create-remote-links.ts index 93b81f7d8be4a..b82d319b78e91 100644 --- a/packages/core/core-flows/src/common/steps/create-remote-links.ts +++ b/packages/core/core-flows/src/common/steps/create-remote-links.ts @@ -7,7 +7,7 @@ export const createLinksStepId = "create-remote-links" /** * This step creates remote links between two records of linked data models. * - * Learn more in the [Remote Link documentation.](https://docs.medusajs.com/advanced-development/modules/remote-link#create-link). + * Learn more in the [Remote Link documentation.](https://docs.medusajs.com/learn/fundamentals/module-links/remote-link#create-link). * * @example * import { diff --git a/packages/core/core-flows/src/common/steps/dismiss-remote-links.ts b/packages/core/core-flows/src/common/steps/dismiss-remote-links.ts index df9069e86e453..67bd30493f647 100644 --- a/packages/core/core-flows/src/common/steps/dismiss-remote-links.ts +++ b/packages/core/core-flows/src/common/steps/dismiss-remote-links.ts @@ -11,7 +11,7 @@ export const dismissRemoteLinkStepId = "dismiss-remote-links" /** * This step removes remote links between two records of linked data models. * - * Learn more in the [Remote Link documentation.](https://docs.medusajs.com/advanced-development/modules/remote-link#dismiss-link). + * Learn more in the [Remote Link documentation.](https://docs.medusajs.com/learn/fundamentals/module-links/remote-link#dismiss-link). * * @example * import { diff --git a/packages/core/core-flows/src/common/steps/remove-remote-links.ts b/packages/core/core-flows/src/common/steps/remove-remote-links.ts index 7ae9a83235f79..cd7af84a26ac2 100644 --- a/packages/core/core-flows/src/common/steps/remove-remote-links.ts +++ b/packages/core/core-flows/src/common/steps/remove-remote-links.ts @@ -9,7 +9,7 @@ export const removeRemoteLinkStepId = "remove-remote-links" /** * This step deletes linked records of a record. * - * Learn more in the [Remote Link documentation](https://docs.medusajs.com/advanced-development/modules/remote-link#cascade-delete-linked-records) + * Learn more in the [Remote Link documentation](https://docs.medusajs.com/learn/fundamentals/module-links/remote-link#cascade-delete-linked-records) * * @example * import { diff --git a/packages/core/core-flows/src/common/steps/use-query-graph.ts b/packages/core/core-flows/src/common/steps/use-query-graph.ts index d3297f82ce554..109a5a983784d 100644 --- a/packages/core/core-flows/src/common/steps/use-query-graph.ts +++ b/packages/core/core-flows/src/common/steps/use-query-graph.ts @@ -29,7 +29,7 @@ const step = createStep( /** * This step fetches data across modules using the Query. * - * Learn more in the [Query documentation](https://docs.medusajs.com/learn/advanced-development/module-links/query). + * Learn more in the [Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query). * * @example * To retrieve a list of records of a data model: diff --git a/packages/core/core-flows/src/common/steps/use-remote-query.ts b/packages/core/core-flows/src/common/steps/use-remote-query.ts index 377e8ab9d2902..27045d394c952 100644 --- a/packages/core/core-flows/src/common/steps/use-remote-query.ts +++ b/packages/core/core-flows/src/common/steps/use-remote-query.ts @@ -50,7 +50,7 @@ export const useRemoteQueryStepId = "use-remote-query" /** * This step fetches data across modules using the remote query. * - * Learn more in the [Remote Query documentation](https://docs.medusajs.com/learn/advanced-development/module-links/query). + * Learn more in the [Remote Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query). * * :::note * diff --git a/packages/core/types/src/auth/service.ts b/packages/core/types/src/auth/service.ts index d0a02fb97d293..b2119d5e5285f 100644 --- a/packages/core/types/src/auth/service.ts +++ b/packages/core/types/src/auth/service.ts @@ -23,7 +23,7 @@ export interface IAuthModuleService extends IModuleService { * underlying provider is called, passing it the `providerData` parameter as a parameter. The method * returns the data returned by the provider. * - * Refer to [this guide](https://docs.medusajs.com/experimental/auth/auth-flows) to learn more about the authentication flows. + * Refer to [this guide](https://docs.medusajs.com/resources/commerce-modules/auth/authentication-route) to learn more about the authentication flows. * * @param {string} provider - The ID of the provider to authenticate the user with. * @param {AuthenticationInput} providerData - The data to pass to the provider to authenticate the user. @@ -70,7 +70,7 @@ export interface IAuthModuleService extends IModuleService { * In that API route, you can call this method to validate the third-party provider's * callback and authenticate the user. * - * Learn more about this authentication flow in [this guide](https://docs.medusajs.com/experimental/auth/auth-flows#authentication-with-third-party-service). + * Learn more about this authentication flow in [this guide](https://docs.medusajs.com/resources/commerce-modules/auth/authentication-route#2-third-party-service-authenticate-flow). * * @param {string} provider - The ID of the provider to use to validate the callback. * @param {AuthenticationInput} providerData - The data to pass to the provider to validate the callback. diff --git a/packages/core/types/src/payment/service.ts b/packages/core/types/src/payment/service.ts index 10ee35bff5d0e..5d208cfbc1155 100644 --- a/packages/core/types/src/payment/service.ts +++ b/packages/core/types/src/payment/service.ts @@ -513,7 +513,7 @@ export interface IPaymentModuleService extends IModuleService { /** * This method authorizes a payment session using its associated payment provider. This creates a payment that can later be captured. * - * Learn more about the payment flow in [this guide](https://docs.medusajs.com/experimental/payment/payment-flow/) + * Learn more about the payment flow in [this guide](https://docs.medusajs.com/resources/commerce-modules/payment/payment-flow) * * @param {string} id - The payment session's ID. * @param {Record} context - Context data to pass to the associated payment provider. @@ -663,7 +663,7 @@ export interface IPaymentModuleService extends IModuleService { /** * This method captures a payment using its associated payment provider. * - * Learn more about the payment flow in [this guide](https://docs.medusajs.com/experimental/payment/payment-flow/) + * Learn more about the payment flow in [this guide](https://docs.medusajs.com/resources/commerce-modules/payment/payment-flow) * * @param {CreateCaptureDTO} data - The payment capture to be created. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. @@ -1058,7 +1058,7 @@ export interface IPaymentModuleService extends IModuleService { /** * This method retrieves webhook event data with the associated payment provider. * - * Learn more about handling webhook events in [this guide](https://docs.medusajs.com/experimental/payment/webhook-events/) + * Learn more about handling webhook events in [this guide](https://docs.medusajs.com/resources/commerce-modules/payment/webhook-events) * * @param {ProviderWebhookPayload} data - The webhook event's details. * @returns {Promise} Resolves when the webhook event is handled successfully. diff --git a/packages/core/types/src/tax/common.ts b/packages/core/types/src/tax/common.ts index a3fa60b287bcf..5b5a4c8a8c6e0 100644 --- a/packages/core/types/src/tax/common.ts +++ b/packages/core/types/src/tax/common.ts @@ -257,7 +257,7 @@ export interface TaxRateRuleDTO { * The snake-case name of the data model that the tax rule references. * For example, `product`. * - * Learn more in [this guide](https://docs.medusajs.com/experimental/tax/tax-rates-and-rules/#what-are-tax-rules). + * Learn more in [this guide](https://docs.medusajs.com/resources/commerce-modules/tax/tax-rates-and-rules#override-tax-rates-with-rules). */ reference: string @@ -265,7 +265,7 @@ export interface TaxRateRuleDTO { * The ID of the record of the data model that the tax rule references. * For example, `prod_123`. * - * Learn more in [this guide](https://docs.medusajs.com/experimental/tax/tax-rates-and-rules/#what-are-tax-rules). + * Learn more in [this guide](https://docs.medusajs.com/resources/commerce-modules/tax/tax-rates-and-rules#override-tax-rates-with-rules). */ reference_id: string diff --git a/packages/core/types/src/tax/mutations.ts b/packages/core/types/src/tax/mutations.ts index 06a1948212656..f39eb3a60ed3a 100644 --- a/packages/core/types/src/tax/mutations.ts +++ b/packages/core/types/src/tax/mutations.ts @@ -234,7 +234,7 @@ export interface CreateTaxRateRuleDTO { * The snake-case name of the data model that the tax rule references. * For example, `product`. * - * Learn more in [this guide](https://docs.medusajs.com/experimental/tax/tax-rates-and-rules/#what-are-tax-rules). + * Learn more in [this guide](https://docs.medusajs.com/resources/commerce-modules/tax/tax-rates-and-rules#override-tax-rates-with-rules). */ reference: string @@ -242,7 +242,7 @@ export interface CreateTaxRateRuleDTO { * The ID of the record of the data model that the tax rule references. * For example, `prod_123`. * - * Learn more in [this guide](https://docs.medusajs.com/experimental/tax/tax-rates-and-rules/#what-are-tax-rules). + * Learn more in [this guide](https://docs.medusajs.com/resources/commerce-modules/tax/tax-rates-and-rules#override-tax-rates-with-rules). */ reference_id: string diff --git a/packages/core/types/src/tax/service.ts b/packages/core/types/src/tax/service.ts index c300d2a20308d..8f9a8a4e7e888 100644 --- a/packages/core/types/src/tax/service.ts +++ b/packages/core/types/src/tax/service.ts @@ -667,7 +667,7 @@ export interface ITaxModuleService extends IModuleService { /** * This method retrieves tax lines for taxable items and shipping methods in a cart. * - * Learn more in [this guide](https://docs.medusajs.com/experimental/tax/tax-calculation-with-provider/). + * Learn more in [this guide](https://docs.medusajs.com/resources/commerce-modules/tax/tax-calculation-with-provider). * * @param {(TaxableItemDTO | TaxableShippingDTO)[]} items - The items and shipping methods to retrieve their tax lines. * @param {TaxCalculationContext} calculationContext - The context to pass to the underlying tax provider. It provides more diff --git a/packages/core/workflows-sdk/src/utils/composer/create-hook.ts b/packages/core/workflows-sdk/src/utils/composer/create-hook.ts index 7e76b8f6c6762..4447d332abe30 100644 --- a/packages/core/workflows-sdk/src/utils/composer/create-hook.ts +++ b/packages/core/workflows-sdk/src/utils/composer/create-hook.ts @@ -23,7 +23,7 @@ export type Hook = { * * A handler hook can later be registered to consume the hook and perform custom functionality. * - * Learn more in [this documentation](https://docs.medusajs.com/advanced-development/workflows/add-workflow-hook). + * Learn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/workflows/workflow-hooks). * * @param name - The hook's name. This is used when the hook handler is registered to consume the workflow. * @param input - The input to pass to the hook handler. diff --git a/packages/core/workflows-sdk/src/utils/composer/create-workflow.ts b/packages/core/workflows-sdk/src/utils/composer/create-workflow.ts index 5b3e9cef1b541..ef5a158601da1 100644 --- a/packages/core/workflows-sdk/src/utils/composer/create-workflow.ts +++ b/packages/core/workflows-sdk/src/utils/composer/create-workflow.ts @@ -42,7 +42,7 @@ global[OrchestrationUtils.SymbolMedusaWorkflowComposerContext] = null * createWorkflow, * WorkflowResponse * } from "@medusajs/framework/workflows-sdk" - * import { MedusaRequest, MedusaResponse } from "@medusajs/medusa" + * import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http" * import { * createProductStep, * getProductStep, diff --git a/packages/core/workflows-sdk/src/utils/composer/type.ts b/packages/core/workflows-sdk/src/utils/composer/type.ts index 4d1b1c06e56e0..5a816c14b1687 100644 --- a/packages/core/workflows-sdk/src/utils/composer/type.ts +++ b/packages/core/workflows-sdk/src/utils/composer/type.ts @@ -229,7 +229,7 @@ export type ReturnWorkflow = { /** * This method executes the workflow as a step. Useful when running a workflow within another. * - * Learn more in [this documentation](https://docs.medusajs.com/advanced-development/workflows/execute-another-workflow). + * Learn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/workflows/execute-another-workflow). * * @param param0 - The options to execute the workflow. * @returns The workflow's result @@ -266,7 +266,7 @@ export type ReturnWorkflow = { /** * The workflow's exposed hooks, used to register a handler to consume the hook. * - * Learn more in [this documentation](https://docs.medusajs.com/advanced-development/workflows/add-workflow-hook#how-to-consume-a-hook). + * Learn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/workflows/workflow-hooks#how-to-consume-a-hook). */ hooks: ConvertHooksToFunctions } diff --git a/packages/core/workflows-sdk/src/utils/composer/when.ts b/packages/core/workflows-sdk/src/utils/composer/when.ts index fa29b837b53ed..46c13713153cb 100644 --- a/packages/core/workflows-sdk/src/utils/composer/when.ts +++ b/packages/core/workflows-sdk/src/utils/composer/when.ts @@ -19,6 +19,48 @@ type ThenFunc = any>( ? WorkflowData | undefined : ReturnType +/** + * This function allows you to execute steps only if a condition is satisfied. As you can't use if conditions in + * a workflow's constructor function, use `when-then` instead. + * + * Learn more about why you can't use if conditions and `when-then` in [this documentation](https://docs.medusajs.com/learn/fundamentals/workflows/conditions). + * + * @param values - The data to pass to the second parameter function. + * @param condition - A function that returns a boolean value, indicating whether the steps in `then` should be executed. + * + * @example + * import { + * createWorkflow, + * WorkflowResponse, + * when, + * } from "@medusajs/framework/workflows-sdk" + * // step imports... + * + * const workflow = createWorkflow( + * "workflow", + * function (input: { + * is_active: boolean + * }) { + * + * const result = when( + * input, + * (input) => { + * return input.is_active + * } + * ).then(() => { + * const stepResult = isActiveStep() + * return stepResult + * }) + * + * // executed without condition + * const anotherStepResult = anotherStep(result) + * + * return new WorkflowResponse( + * anotherStepResult + * ) + * } + * ) + */ export function when( values: T, condition: ConditionFunction @@ -26,6 +68,9 @@ export function when( then: ThenFunc } +/** + * @internal + */ export function when( name: string, values: T, @@ -34,6 +79,9 @@ export function when( then: ThenFunc } +/** + * @internal + */ export function when(...args) { let [name, input, condition] = args if (args.length === 2) {