chore: dependecies reorg (#8535)

This commit is contained in:
Carlos R. L. Rodrigues
2024-08-23 07:16:04 -03:00
committed by GitHub
parent 59599ac237
commit 058378970a
126 changed files with 958 additions and 1266 deletions

View File

@@ -34,8 +34,11 @@
"@medusajs/orchestration": "^0.5.7",
"@medusajs/utils": "^1.11.9",
"@medusajs/workflows-sdk": "^0.1.6",
"awilix": "^8.0.1",
"ulid": "^2.3.0"
"json-2-csv": "^5.5.4"
},
"peerDependencies": {
"awilix": "*",
"ulid": "*"
},
"scripts": {
"prepublishOnly": "cross-env NODE_ENV=production tsc --build",

View File

@@ -1,15 +1,16 @@
import { LinkDefinition, RemoteLink } from "@medusajs/modules-sdk"
import { RemoteLink } from "@medusajs/modules-sdk"
import { LinkDefinition } from "@medusajs/types"
import { ContainerRegistrationKeys } from "@medusajs/utils"
import { createStep, StepResponse } from "@medusajs/workflows-sdk"
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/v2/advanced-development/modules/remote-link#create-link).
*
*
* @example
* import {
* import {
* createWorkflow
* } from "@medusajs/workflows-sdk"
* import {
@@ -18,7 +19,7 @@ export const createLinksStepId = "create-remote-links"
* import {
* Modules
* } from "@medusajs/utils"
*
*
* const helloWorldWorkflow = createWorkflow(
* "hello-world",
* () => {

View File

@@ -1,4 +1,5 @@
import { LinkDefinition, RemoteLink } from "@medusajs/modules-sdk"
import { RemoteLink } from "@medusajs/modules-sdk"
import { LinkDefinition } from "@medusajs/types"
import { createStep, StepResponse } from "@medusajs/workflows-sdk"
import { ContainerRegistrationKeys } from "@medusajs/utils"
@@ -9,11 +10,11 @@ export type DismissRemoteLinksStepInput = LinkDefinition | LinkDefinition[]
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/v2/advanced-development/modules/remote-link#dismiss-link).
*
*
* @example
* import {
* import {
* createWorkflow
* } from "@medusajs/workflows-sdk"
* import {
@@ -22,7 +23,7 @@ export const dismissRemoteLinkStepId = "dismiss-remote-links"
* import {
* Modules
* } from "@medusajs/utils"
*
*
* const helloWorldWorkflow = createWorkflow(
* "hello-world",
* () => {

View File

@@ -1,6 +1,7 @@
import { LinkDefinition, RemoteLink } from "@medusajs/modules-sdk"
import { RemoteLink } from "@medusajs/modules-sdk"
import { LinkDefinition } from "@medusajs/types"
import { ContainerRegistrationKeys, MedusaError } from "@medusajs/utils"
import { createStep, StepResponse } from "@medusajs/workflows-sdk"
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
export const updateRemoteLinksStepId = "update-remote-links-step"
export const updateRemoteLinksStep = createStep(

View File

@@ -1,5 +1,4 @@
import { LinkDefinition } from "@medusajs/modules-sdk"
import { BatchWorkflowInput } from "@medusajs/types"
import { BatchWorkflowInput, LinkDefinition } from "@medusajs/types"
import {
WorkflowData,
WorkflowResponse,

View File

@@ -1,4 +1,4 @@
import { LinkDefinition } from "@medusajs/modules-sdk"
import { LinkDefinition } from "@medusajs/types"
import {
WorkflowData,
WorkflowResponse,

View File

@@ -1,4 +1,4 @@
import { LinkDefinition } from "@medusajs/modules-sdk"
import { LinkDefinition } from "@medusajs/types"
import {
WorkflowData,
WorkflowResponse,

View File

@@ -1,4 +1,4 @@
import { LinkDefinition } from "@medusajs/modules-sdk"
import { LinkDefinition } from "@medusajs/types"
import {
WorkflowData,
WorkflowResponse,

View File

@@ -1,11 +1,12 @@
import {
IFileModuleService,
HttpTypes,
IFileModuleService,
IRegionModuleService,
} from "@medusajs/types"
import { ModuleRegistrationName, convertJsonToCsv } from "@medusajs/utils"
import { ModuleRegistrationName } from "@medusajs/utils"
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
import { normalizeForExport } from "../helpers/normalize-for-export"
import { convertJsonToCsv } from "../utlils"
const prodColumnPositions = new Map([
["Product Id", 0],

View File

@@ -1,16 +1,13 @@
import {
MedusaError,
ModuleRegistrationName,
convertCsvToJson,
} from "@medusajs/utils"
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
import { normalizeForImport } from "../helpers/normalize-for-import"
import {
IProductModuleService,
IRegionModuleService,
ISalesChannelModuleService,
} from "@medusajs/types"
import { MedusaError, ModuleRegistrationName } from "@medusajs/utils"
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
import { normalizeForImport } from "../helpers/normalize-for-import"
import { normalizeV1Products } from "../helpers/normalize-v1-import"
import { convertCsvToJson } from "../utlils"
export const parseProductCsvStepId = "parse-product-csv"
/**

View File

@@ -1,10 +1,11 @@
import { LinkDefinition } from "@medusajs/modules-sdk"
import {
AdditionalData,
InventoryTypes,
LinkDefinition,
PricingTypes,
ProductTypes,
} from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import {
WorkflowData,
WorkflowResponse,
@@ -18,7 +19,6 @@ import { createInventoryItemsWorkflow } from "../../inventory/workflows/create-i
import { createPriceSetsStep } from "../../pricing"
import { createProductVariantsStep } from "../steps/create-product-variants"
import { createVariantPricingLinkStep } from "../steps/create-variant-pricing-link"
import { Modules } from "@medusajs/utils"
/**
* @privateRemarks

View File

@@ -1,8 +1,8 @@
export * as TestDatabaseUtils from "./database"
export * as TestEventUtils from "./events"
export * as JestUtils from "./jest"
export { default as IdMap } from "./id-map"
export * from "./init-modules"
export * as JestUtils from "./jest"
export * from "./medusa-test-runner"
export { default as MockEventBusService } from "./mock-event-bus-service"
export * from "./module-test-runner"
export * from "./medusa-test-runner"

View File

@@ -3,9 +3,9 @@ import {
ModulesSdkUtils,
toMikroOrmEntities,
} from "@medusajs/utils"
import { MockEventBusService } from "."
import { getDatabaseURL, getMikroOrmWrapper, TestDatabase } from "./database"
import { initModules, InitModulesOptions } from "./init-modules"
import { TestDatabase, getDatabaseURL, getMikroOrmWrapper } from "./database"
import { InitModulesOptions, initModules } from "./init-modules"
import { default as MockEventBusService } from "./mock-event-bus-service"
export interface SuiteOptions<TService = unknown> {
MikroOrmWrapper: TestDatabase

View File

@@ -32,11 +32,12 @@
"@graphql-tools/schema": "^10.0.0",
"@medusajs/orchestration": "^0.5.7",
"@medusajs/utils": "^1.11.9",
"awilix": "^8.0.0",
"graphql": "^16.6.0",
"knex": "2.4.2",
"resolve-cwd": "^3.0.0"
},
"peerDependencies": {
"awilix": "*"
},
"scripts": {
"prepublishOnly": "cross-env NODE_ENV=production tsc --build",
"build": "rimraf dist && tsc --build",

View File

@@ -1,4 +1,3 @@
export * from "@medusajs/types/dist/modules-sdk"
export * from "./definitions"
export * from "./loaders"
export * from "./medusa-app"

View File

@@ -20,17 +20,17 @@ import {
} from "@medusajs/types"
import {
ContainerRegistrationKeys,
createMedusaContainer,
isObject,
isString,
MedusaError,
ModuleRegistrationName,
Modules,
ModulesSdkUtils,
createMedusaContainer,
isObject,
isString,
promiseAll,
} from "@medusajs/utils"
import type { Knex } from "@mikro-orm/knex"
import { asValue } from "awilix"
import type { Knex } from "knex"
import { MODULE_PACKAGE_NAMES } from "./definitions"
import {
MedusaModule,
@@ -39,8 +39,8 @@ import {
} from "./medusa-module"
import { RemoteLink } from "./remote-link"
import { RemoteQuery } from "./remote-query"
import { cleanGraphQLSchema } from "./utils"
import { MODULE_RESOURCE_TYPE, MODULE_SCOPE } from "./types"
import { cleanGraphQLSchema } from "./utils"
const LinkModulePackage = MODULE_PACKAGE_NAMES[Modules.LINK]

View File

@@ -1,5 +1,6 @@
import {
ILinkModule,
LinkDefinition,
LoadedModule,
ModuleJoinerRelationship,
} from "@medusajs/types"
@@ -12,7 +13,7 @@ import { linkingErrorMessage } from "./utils/linking-error"
/**
* The details of a data model's record whose linked records should be deleted. Usually used after the
* data model's record is deleted.
*
*
* The key is the data model's name. Its value is an object that has the ID of the data model's record.
*/
export type DeleteEntityInput = {
@@ -20,20 +21,6 @@ export type DeleteEntityInput = {
}
export type RestoreEntityInput = DeleteEntityInput
/**
* A link for two records of linked data models.
*
* The keys are the names of each module, and their value is an object that holds the ID of the linked data model's record.
*/
export type LinkDefinition = {
[moduleName: string]: {
// TODO: changing this to any temporarily as the "data" attribute is not being picked up correctly
[fieldName: string]: any
}
} & {
data?: Record<string, unknown>
}
type RemoteRelationship = ModuleJoinerRelationship & {
isPrimary: boolean
isForeign: boolean

View File

@@ -1,6 +1,5 @@
import { LoadedModule } from "@medusajs/types"
import { LinkDefinition, LoadedModule } from "@medusajs/types"
import { isPresent } from "@medusajs/utils"
import { LinkDefinition } from "../remote-link"
export const convertRecordsToLinkDefinition = (
links: object[],

View File

@@ -20,17 +20,19 @@
"author": "Medusa",
"license": "MIT",
"devDependencies": {
"@medusajs/types": "^1.11.16",
"cross-env": "^5.2.1",
"jest": "^29.7.0",
"rimraf": "^5.0.1",
"typescript": "^5.1.6"
},
"dependencies": {
"@medusajs/types": "^1.11.16",
"@medusajs/utils": "^1.11.9",
"awilix": "^8.0.0",
"graphql": "^16.6.0"
},
"peerDependencies": {
"awilix": "*"
},
"scripts": {
"prepublishOnly": "cross-env NODE_ENV=production tsc --build",
"build": "rimraf dist && tsc --build",

View File

@@ -2,12 +2,13 @@ import { isDefined } from "@medusajs/utils"
import { EventEmitter } from "events"
import { IDistributedTransactionStorage } from "./datastore/abstract-storage"
import { BaseInMemoryDistributedTransactionStorage } from "./datastore/base-in-memory-storage"
import { TransactionOrchestrator } from "./transaction-orchestrator"
import { TransactionStep, TransactionStepHandler } from "./transaction-step"
import {
TransactionFlow,
TransactionOrchestrator,
} from "./transaction-orchestrator"
import { TransactionStep, TransactionStepHandler } from "./transaction-step"
import { TransactionHandlerType, TransactionState } from "./types"
TransactionHandlerType,
TransactionState,
} from "./types"
/**
* @typedef TransactionMetadata

View File

@@ -8,6 +8,7 @@ import { TransactionStep, TransactionStepHandler } from "./transaction-step"
import {
DistributedTransactionEvent,
StepFeatures,
TransactionFlow,
TransactionHandlerType,
TransactionModelOptions,
TransactionOptions,
@@ -27,29 +28,6 @@ import {
TransactionTimeoutError,
} from "./errors"
export type TransactionFlow = {
modelId: string
options?: TransactionModelOptions
definition: TransactionStepsDefinition
transactionId: string
metadata?: {
eventGroupId?: string
[key: string]: unknown
}
hasAsyncSteps: boolean
hasFailedSteps: boolean
hasSkippedOnFailureSteps: boolean
hasWaitingSteps: boolean
hasSkippedSteps: boolean
hasRevertedSteps: boolean
timedOutAt: number | null
startedAt?: number
state: TransactionState
steps: {
[key: string]: TransactionStep
}
}
/**
* @class TransactionOrchestrator is responsible for managing and executing distributed transactions.
* It is based on a single transaction definition, which is used to execute all the transaction steps

View File

@@ -1,3 +1,4 @@
import { TransactionState } from "@medusajs/utils"
import { DistributedTransactionType } from "./distributed-transaction"
import { TransactionStep } from "./transaction-step"
export {
@@ -228,3 +229,26 @@ export type StepFeatures = {
}
export type TransactionOptions = TransactionModelOptions & StepFeatures
export type TransactionFlow = {
modelId: string
options?: TransactionModelOptions
definition: TransactionStepsDefinition
transactionId: string
metadata?: {
eventGroupId?: string
[key: string]: unknown
}
hasAsyncSteps: boolean
hasFailedSteps: boolean
hasSkippedOnFailureSteps: boolean
hasWaitingSteps: boolean
hasSkippedSteps: boolean
hasRevertedSteps: boolean
timedOutAt: number | null
startedAt?: number
state: TransactionState
steps: {
[key: string]: TransactionStep
}
}

View File

@@ -21,7 +21,7 @@
"author": "Medusa",
"license": "MIT",
"devDependencies": {
"awilix": "^8.0.0",
"awilix": "^8.0.1",
"bignumber.js": "^9.1.2",
"cross-env": "^5.2.1",
"ioredis": "^5.4.1",

View File

@@ -1,10 +1,5 @@
import { CamelCase, Prettify } from "../common"
/**
* Symbol to identify a DML entity from an object
*/
export const IsDmlEntity = Symbol.for("isDmlEntity")
/**
* Representation of DML schema. It must be a key-value pair
* with string based keys and properties/relationships
@@ -33,7 +28,6 @@ export interface IDmlEntity<
Schema extends DMLSchema,
Config extends IDmlEntityConfig
> {
[IsDmlEntity]: true
name: InferDmlEntityNameFromConfig<Config>
schema: Schema
}

View File

@@ -165,6 +165,20 @@ export type LinkModulesExtraFields = Record<
}
>
/**
* A link for two records of linked data models.
*
* The keys are the names of each module, and their value is an object that holds the ID of the linked data model's record.
*/
export type LinkDefinition = {
[moduleName: string]: {
// TODO: changing this to any temporarily as the "data" attribute is not being picked up correctly
[fieldName: string]: any
}
} & {
data?: Record<string, unknown>
}
export type ModuleJoinerConfig = Omit<
JoinerServiceConfig,
"serviceName" | "primaryKeys" | "relationships" | "extends"

View File

@@ -39,9 +39,7 @@
"bignumber.js": "^9.1.2",
"dotenv": "^16.4.5",
"dotenv-expand": "^11.0.6",
"json-2-csv": "^5.5.4",
"jsonwebtoken": "^9.0.2",
"knex": "2.4.2",
"pluralize": "^8.0.0",
"ulid": "^2.3.0"
},

View File

@@ -1,14 +0,0 @@
import { join } from "path"
export const getMedusaVersion = (): string => {
try {
return require(join(
process.cwd(),
`node_modules`,
`@medusajs/medusa`,
`package.json`
)).version
} catch (e) {
return ``
}
}

View File

@@ -25,12 +25,12 @@ import {
} from "@mikro-orm/core/typings"
import { SqlEntityManager } from "@mikro-orm/postgresql"
import {
MedusaError,
arrayDifference,
isString,
MedusaError,
promiseAll,
} from "../../common"
import { buildQuery } from "../../modules-sdk"
import { buildQuery } from "../../modules-sdk/build-query"
import {
getSoftDeletedCascadedEntitiesIdsMappedBy,
transactionWrapper,

View File

@@ -1,6 +1,6 @@
import { EntityMetadata, FindOptions, wrap } from "@mikro-orm/core"
import { SqlEntityManager } from "@mikro-orm/postgresql"
import { buildQuery } from "../../modules-sdk"
import { buildQuery } from "../../modules-sdk/build-query"
function detectCircularDependency(
manager: SqlEntityManager,

View File

@@ -6,13 +6,14 @@ import {
IDmlEntity,
IDmlEntityConfig,
InferDmlEntityNameFromConfig,
IsDmlEntity,
QueryCondition,
} from "@medusajs/types"
import { isObject, isString, toCamelCase } from "../common"
import { transformIndexWhere } from "./helpers/entity-builder/build-indexes"
import { BelongsTo } from "./relations/belongs-to"
const IsDmlEntity = Symbol.for("isDmlEntity")
function extractNameAndTableName<const Config extends IDmlEntityConfig>(
nameOrConfig: Config
) {
@@ -59,7 +60,7 @@ export class DmlEntity<
const TConfig extends IDmlEntityConfig
> implements IDmlEntity<Schema, TConfig>
{
[IsDmlEntity]: true = true
[IsDmlEntity] = true
name: InferDmlEntityNameFromConfig<TConfig>
schema: Schema

View File

@@ -1,7 +1,7 @@
export * from "./common"
export * from "./api-key"
export * from "./auth"
export * from "./bundles"
export * from "./common"
export * from "./dal"
export * from "./decorators"
export * from "./defaults"
@@ -26,6 +26,5 @@ export * from "./shipping"
export * from "./totals"
export * from "./totals/big-number"
export * from "./user"
export * from "./csv"
export const MedusaModuleType = Symbol.for("MedusaModule")

View File

@@ -1,4 +1,4 @@
import { Modules } from "../modules-sdk"
import { Modules } from "../modules-sdk/definition"
import { composeLinkName } from "./compose-link-name"
export const LINKS = {

View File

@@ -1,13 +1,13 @@
import { EventEmitter } from "events"
import { MikroORM, MikroORMOptions } from "@mikro-orm/core"
import {
MigrateOptions,
MigrationResult,
UmzugMigration,
} from "@mikro-orm/migrations"
import { MikroORM, MikroORMOptions } from "@mikro-orm/core"
import { PostgreSqlDriver } from "@mikro-orm/postgresql"
import { dirname } from "path"
import { EventEmitter } from "events"
import { access, mkdir, writeFile } from "fs/promises"
import { dirname } from "path"
/**
* Events emitted by the migrations class

View File

@@ -1,7 +1,7 @@
import { DAL, FindConfig } from "@medusajs/types"
import { deduplicate, isDefined, isObject } from "../common"
import { SoftDeletableFilterKey } from "../dal"
import { SoftDeletableFilterKey } from "../dal/mikro-orm/mikro-orm-soft-deletable-filter"
// Following convention here is fine, we can make it configurable if needed.
const DELETED_AT_FIELD_NAME = "deleted_at"

View File

@@ -1,6 +1,6 @@
import { LinkModulesExtraFields, ModuleJoinerConfig } from "@medusajs/types"
import { camelToSnakeCase, isObject, pluralize, toPascalCase } from "../common"
import { composeLinkName } from "../link"
import { composeLinkName } from "../link/compose-link-name"
export const DefineLinkSymbol = Symbol.for("DefineLink")

View File

@@ -11,16 +11,18 @@ import {
SoftDeleteReturn,
} from "@medusajs/types"
import {
MapToConfig,
isString,
kebabCase,
lowerCaseFirst,
mapObjectTo,
MapToConfig,
pluralize,
upperCaseFirst,
} from "../common"
import { DmlEntity } from "../dml"
import { InjectManager, MedusaContext } from "./decorators"
import { ModuleRegistrationName } from "./definition"
import { buildModelsNameToLinkableKeysMap } from "./joiner-config-builder"
import {
BaseMethods,
ExtractKeysFromConfig,
@@ -29,8 +31,6 @@ import {
ModelEntries,
ModelsConfigTemplate,
} from "./types/medusa-service"
import { buildModelsNameToLinkableKeysMap } from "./joiner-config-builder"
import { DmlEntity } from "../dml"
const readMethods = ["retrieve", "list", "listAndCount"] as BaseMethods[]
const writeMethods = [
@@ -55,12 +55,12 @@ function buildMethodNamesFromModel(
if (method === "retrieve") {
normalizedModelName =
"singular" in model && model.singular
model && "singular" in model && model.singular
? model.singular
: defaultMethodName
} else {
normalizedModelName =
"plural" in model && model.plural
model && "plural" in model && model.plural
? model.plural
: pluralize(defaultMethodName)
}

View File

@@ -30,9 +30,11 @@
"dependencies": {
"@medusajs/modules-sdk": "^1.12.11",
"@medusajs/orchestration": "^0.5.7",
"@medusajs/utils": "^1.11.9",
"awilix": "^8.0.1",
"ulid": "^2.3.0"
"@medusajs/utils": "^1.11.9"
},
"peerDependencies": {
"awilix": "*",
"ulid": "*"
},
"scripts": {
"prepublishOnly": "cross-env NODE_ENV=production tsc --build",

View File

@@ -16,7 +16,7 @@ import {
import { EOL } from "os"
import { ulid } from "ulid"
import { MedusaWorkflow } from "../medusa-workflow"
import { resolveValue } from "../utils/composer"
import { resolveValue } from "../utils/composer/helpers/resolve-value"
import {
ExportedWorkflow,
FlowCancelOptions,

View File

@@ -4,19 +4,19 @@ import {
WorkflowManager,
} from "@medusajs/orchestration"
import { LoadedModule, MedusaContainer } from "@medusajs/types"
import { isString, OrchestrationUtils } from "@medusajs/utils"
import { OrchestrationUtils, isString } from "@medusajs/utils"
import { exportWorkflow } from "../../helper"
import { createStep } from "./create-step"
import { StepResponse } from "./helpers"
import { proxify } from "./helpers/proxy"
import { StepResponse } from "./helpers/step-response"
import { WorkflowResponse } from "./helpers/workflow-response"
import {
CreateWorkflowComposerContext,
HookHandler,
ReturnWorkflow,
StepFunction,
WorkflowData,
HookHandler,
} from "./type"
import { WorkflowResponse } from "./helpers/workflow-response"
global[OrchestrationUtils.SymbolMedusaWorkflowComposerContext] = null