Skip to content

Commit

Permalink
Merge branch 'chore/handle-ambiguous-module-relation-ships-filtering'…
Browse files Browse the repository at this point in the history
… of github.com:medusajs/medusa into chore/handle-ambiguous-module-relation-ships-filtering
  • Loading branch information
adrien2p committed Oct 2, 2024
2 parents ae33c13 + 1e39b71 commit bf44b4b
Show file tree
Hide file tree
Showing 16 changed files with 479 additions and 43 deletions.
1 change: 0 additions & 1 deletion packages/cli/create-medusa-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"watch": "tsc --watch"
},
"dependencies": {
"@medusajs/utils": "^1.11.9",
"boxen": "^5",
"chalk": "^5.2.0",
"commander": "^10.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/create-medusa-app/src/commands/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
installNextjsStarter,
startNextjsStarter,
} from "../utils/nextjs-utils.js"
import { getNodeVersion, MIN_SUPPORTED_NODE_VERSION } from "@medusajs/utils"
import { getNodeVersion, MIN_SUPPORTED_NODE_VERSION } from "../utils/node-version.js"

const slugify = slugifyType.default

Expand Down
7 changes: 7 additions & 0 deletions packages/cli/create-medusa-app/src/utils/node-version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export function getNodeVersion(): number {
const [major] = process.versions.node.split('.').map(Number)

return major
}

export const MIN_SUPPORTED_NODE_VERSION = 20
16 changes: 15 additions & 1 deletion packages/core/js-sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,18 @@ class Medusa {
}

export default Medusa
export { FetchError } from "./client"

export { FetchError, Client } from "./client"
export { Admin } from "./admin"
export { Auth } from "./auth"
export { Store } from "./store"
export {
Config,
ClientHeaders,
ClientFetch,
FetchArgs,
FetchInput,
FetchStreamResponse,
Logger,
ServerSentEventMessage,
} from "./types"
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ export class OrchestratorBuilder {
this.steps = {
depth: -1,
parent: null,
next: steps
next: Object.keys(steps ?? {}).length
? JSON.parse(
JSON.stringify((steps.action ? steps : steps.next) as InternalStep)
JSON.stringify(
(steps!.action ? steps : steps!.next) as InternalStep
)
)
: undefined,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,16 @@ export class TransactionOrchestrator extends EventEmitter {

step.changeState(TransactionStepState.TIMEOUT)

if (error?.stack) {
const workflowId = transaction.modelId
const stepAction = step.definition.action
const sourcePath = transaction.getFlow().metadata?.sourcePath
const sourceStack = sourcePath
? `\n⮑ \sat ${sourcePath}: [${workflowId} -> ${stepAction} (${TransactionHandlerType.INVOKE})]`
: `\n⮑ \sat [${workflowId} -> ${stepAction} (${TransactionHandlerType.INVOKE})]`
error.stack += sourceStack
}

transaction.addError(
step.definition.action!,
TransactionHandlerType.INVOKE,
Expand Down Expand Up @@ -602,13 +612,21 @@ export class TransactionOrchestrator extends EventEmitter {
step.changeStatus(TransactionStepStatus.PERMANENT_FAILURE)

if (!isTimeout) {
transaction.addError(
step.definition.action!,
step.isCompensating()
? TransactionHandlerType.COMPENSATE
: TransactionHandlerType.INVOKE,
error
)
const handlerType = step.isCompensating()
? TransactionHandlerType.COMPENSATE
: TransactionHandlerType.INVOKE

if (error?.stack) {
const workflowId = transaction.modelId
const stepAction = step.definition.action
const sourcePath = transaction.getFlow().metadata?.sourcePath
const sourceStack = sourcePath
? `\n⮑ \sat ${sourcePath}: [${workflowId} -> ${stepAction} (${TransactionHandlerType.INVOKE})]`
: `\n⮑ \sat [${workflowId} -> ${stepAction} (${TransactionHandlerType.INVOKE})]`
error.stack += sourceStack
}

transaction.addError(step.definition.action!, handlerType, error)
}

if (!step.isCompensating()) {
Expand Down
1 change: 1 addition & 0 deletions packages/core/orchestration/src/transaction/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ export type TransactionFlow = {
metadata?: {
eventGroupId?: string
parentIdempotencyKey?: string
sourcePath?: string
[key: string]: unknown
}
hasAsyncSteps: boolean
Expand Down
29 changes: 15 additions & 14 deletions packages/core/types/src/fulfillment/provider.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
export type FulfillmentOption = {
/**
* The option's ID.
*
* @example express
*/
id: string
/**
* Whether the option can be used to return items.
*/
is_return?: boolean
[k: string]: unknown
}

export interface IFulfillmentProvider {
/**
* @ignore
*
* Return a unique identifier to retrieve the fulfillment plugin provider
*/
getIdentifier(): string
/**
* @ignore
*
* Return the available fulfillment options for the given data.
*/
getFulfillmentOptions(): Promise<Record<string, unknown>[]>
getFulfillmentOptions(): Promise<FulfillmentOption[]>
/**
* @ignore
*
* Validate the given fulfillment data.
*/
Expand All @@ -22,19 +33,16 @@ export interface IFulfillmentProvider {
context: Record<string, unknown>
): Promise<any>
/**
* @ignore
*
* Validate the given option.
*/
validateOption(data: Record<string, unknown>): Promise<boolean>
/**
* @ignore
*
* Check if the provider can calculate the fulfillment price.
*/
canCalculate(data: Record<string, unknown>): Promise<any>
/**
* @ignore
*
* Calculate the price for the given fulfillment option.
*/
Expand All @@ -44,7 +52,6 @@ export interface IFulfillmentProvider {
context: Record<string, unknown>
): Promise<any>
/**
* @ignore
*
* Create a fulfillment for the given data.
*/
Expand All @@ -55,25 +62,21 @@ export interface IFulfillmentProvider {
fulfillment: Record<string, unknown>
): Promise<Record<string, unknown>>
/**
* @ignore
*
* Cancel the given fulfillment.
*/
cancelFulfillment(fulfillment: Record<string, unknown>): Promise<any>
/**
* @ignore
*
* Get the documents for the given fulfillment data.
*/
getFulfillmentDocuments(data: Record<string, unknown>): Promise<any>
/**
* @ignore
*
* Create a return for the given data.
*/
createReturnFulfillment(fromData: Record<string, unknown>): Promise<any>
/**
* @ignore
*
* Get the documents for the given return data.
*/
Expand All @@ -82,13 +85,11 @@ export interface IFulfillmentProvider {
documentType: string
): Promise<any>
/**
* @ignore
*
* Get the documents for the given return data.
*/
getReturnDocuments(data: Record<string, unknown>): Promise<any>
/**
* @ignore
*
* Get the documents for the given shipment data.
*/
Expand Down
Loading

0 comments on commit bf44b4b

Please sign in to comment.