Skip to content

Commit

Permalink
chore: fix documentation links in TSDocs
Browse files Browse the repository at this point in the history
  • Loading branch information
shahednasser committed Dec 9, 2024
1 parent 9534751 commit 09171cd
Show file tree
Hide file tree
Showing 14 changed files with 67 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
4 changes: 2 additions & 2 deletions packages/core/types/src/auth/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions packages/core/types/src/payment/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, unknown>} context - Context data to pass to the associated payment provider.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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<void>} Resolves when the webhook event is handled successfully.
Expand Down
4 changes: 2 additions & 2 deletions packages/core/types/src/tax/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,15 +257,15 @@ 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

/**
* 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

Expand Down
4 changes: 2 additions & 2 deletions packages/core/types/src/tax/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,15 +234,15 @@ 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

/**
* 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

Expand Down
2 changes: 1 addition & 1 deletion packages/core/types/src/tax/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export type Hook<Name extends string, Input> = {
*
* 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions packages/core/workflows-sdk/src/utils/composer/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ export type ReturnWorkflow<TData, TResult, THooks extends any[]> = {
/**
* 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
Expand Down Expand Up @@ -266,7 +266,7 @@ export type ReturnWorkflow<TData, TResult, THooks extends any[]> = {
/**
* 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<THooks>
}
Expand Down
48 changes: 48 additions & 0 deletions packages/core/workflows-sdk/src/utils/composer/when.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,58 @@ type ThenFunc = <ThenResolver extends () => any>(
? WorkflowData<ReturnedWorkflowData> | undefined
: ReturnType<ThenResolver>

/**
* 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<T extends object | WorkflowData, Then extends Function>(
values: T,
condition: ConditionFunction<T>
): {
then: ThenFunc
}

/**
* @internal
*/
export function when<T extends object | WorkflowData, Then extends Function>(
name: string,
values: T,
Expand All @@ -34,6 +79,9 @@ export function when<T extends object | WorkflowData, Then extends Function>(
then: ThenFunc
}

/**
* @internal
*/
export function when(...args) {
let [name, input, condition] = args
if (args.length === 2) {
Expand Down

0 comments on commit 09171cd

Please sign in to comment.