From 9e711720dd0d2ddc28e5eb821be690514f22d3b6 Mon Sep 17 00:00:00 2001 From: Harminder Virk Date: Tue, 24 Sep 2024 17:19:20 +0530 Subject: [PATCH] chore: upgrade moduleResolution to Node16 (#9269) --- _tsconfig.base.json | 26 +++++ define_jest_config.js | 28 ++++++ packages/core/framework/jest.config.js | 26 +---- packages/core/framework/src/config/types.ts | 35 +++---- .../src/feature-flags/feature-flag-loader.ts | 3 +- packages/core/framework/src/http/router.ts | 16 +++- .../core/framework/src/jobs/job-loader.ts | 11 ++- .../core/framework/src/links/link-loader.ts | 4 +- .../src/subscribers/subscriber-loader.ts | 11 ++- .../src/workflows/workflow-loader.ts | 4 +- packages/core/framework/tsconfig.json | 31 +----- .../src/medusa-test-runner.ts | 1 + packages/core/modules-sdk/jest.config.js | 19 +--- .../src/loaders/module-provider-loader.ts | 3 +- .../src/loaders/utils/load-internal.ts | 19 ++-- packages/core/modules-sdk/src/medusa-app.ts | 17 ++-- packages/core/modules-sdk/tsconfig.json | 27 +----- packages/core/orchestration/jest.config.js | 26 +---- packages/core/orchestration/tsconfig.json | 27 +----- packages/core/types/jest.config.js | 26 +---- .../core/types/src/common/config-module.ts | 1 + packages/core/types/tsconfig.json | 27 +----- packages/core/utils/jest.config.js | 26 +---- .../core/utils/src/common/dynamic-import.ts | 17 ++++ packages/core/utils/src/common/index.ts | 2 + .../core/utils/src/common/resolve-exports.ts | 6 ++ .../mikro-orm/mikro-orm-create-connection.ts | 6 +- .../mikro-orm-free-text-search-filter.ts | 8 +- .../src/dal/mikro-orm/mikro-orm-repository.ts | 4 +- .../src/dal/mikro-orm/mikro-orm-serializer.ts | 2 +- .../src/dml/helpers/entity-builder/index.ts | 8 ++ packages/core/utils/src/dml/index.ts | 3 + .../core/utils/src/dml/properties/index.ts | 12 +++ .../utils/src/dml/relations/belongs-to.ts | 4 +- .../core/utils/src/dml/relations/has-one.ts | 4 +- .../core/utils/src/dml/relations/index.ts | 6 ++ .../core/utils/src/dml/relations/nullable.ts | 4 +- packages/core/utils/src/modules-sdk/index.ts | 2 + .../modules-sdk/medusa-internal-service.ts | 3 +- .../src/modules-sdk/migration-scripts/seed.ts | 15 +-- .../mikro-orm-cli-config-builder.ts | 6 +- packages/core/utils/tsconfig.json | 27 +----- packages/core/workflows-sdk/jest.config.js | 26 +---- packages/core/workflows-sdk/tsconfig.json | 24 +---- packages/medusa/src/commands/exec.ts | 3 +- packages/modules/api-key/jest.config.js | 19 +--- packages/modules/api-key/package.json | 10 +- packages/modules/api-key/tsconfig.json | 31 +----- packages/modules/api-key/tsconfig.spec.json | 8 -- packages/modules/auth/jest.config.js | 19 +--- packages/modules/auth/package.json | 10 +- packages/modules/auth/tsconfig.json | 32 +------ packages/modules/auth/tsconfig.spec.json | 8 -- .../modules/cache-inmemory/jest.config.js | 17 +--- packages/modules/cache-inmemory/package.json | 7 +- packages/modules/cache-inmemory/tsconfig.json | 29 +----- .../modules/cache-inmemory/tsconfig.spec.json | 5 - packages/modules/cache-redis/jest.config.js | 17 +--- packages/modules/cache-redis/package.json | 7 +- packages/modules/cache-redis/tsconfig.json | 29 +----- .../modules/cache-redis/tsconfig.spec.json | 5 - packages/modules/cart/jest.config.js | 20 +--- packages/modules/cart/package.json | 10 +- packages/modules/cart/src/models/address.ts | 12 ++- packages/modules/cart/tsconfig.json | 31 +----- packages/modules/cart/tsconfig.spec.json | 8 -- packages/modules/currency/jest.config.js | 19 +--- packages/modules/currency/package.json | 10 +- packages/modules/currency/tsconfig.json | 31 +----- packages/modules/currency/tsconfig.spec.json | 8 -- packages/modules/customer/jest.config.js | 20 +--- packages/modules/customer/package.json | 10 +- packages/modules/customer/tsconfig.json | 31 +----- packages/modules/customer/tsconfig.spec.json | 8 -- .../modules/event-bus-local/jest.config.js | 17 +--- packages/modules/event-bus-local/package.json | 7 +- .../modules/event-bus-local/tsconfig.json | 29 +----- .../event-bus-local/tsconfig.spec.json | 5 - .../modules/event-bus-redis/jest.config.js | 17 +--- packages/modules/event-bus-redis/package.json | 7 +- .../src/services/__tests__/event-bus.ts | 8 +- .../modules/event-bus-redis/tsconfig.json | 29 +----- .../event-bus-redis/tsconfig.spec.json | 5 - packages/modules/file/jest.config.js | 19 +--- packages/modules/file/package.json | 10 +- packages/modules/file/tsconfig.json | 31 +----- packages/modules/file/tsconfig.spec.json | 8 -- packages/modules/fulfillment/jest.config.js | 20 +--- packages/modules/fulfillment/package.json | 10 +- .../src/models/shipping-option-type.ts | 6 -- packages/modules/fulfillment/tsconfig.json | 31 +----- .../modules/fulfillment/tsconfig.spec.json | 8 -- packages/modules/index/jest.config.js | 20 +--- packages/modules/index/package.json | 10 +- .../modules/index/src/utils/query-builder.ts | 4 +- packages/modules/index/tsconfig.build.json | 11 --- packages/modules/index/tsconfig.json | 31 +----- packages/modules/index/tsconfig.spec.json | 8 -- .../modules/inventory-next/jest.config.js | 19 +--- packages/modules/inventory-next/package.json | 10 +- .../src/models/inventory-item.ts | 4 +- .../src/models/inventory-level.ts | 6 +- .../src/models/reservation-item.ts | 4 +- packages/modules/inventory-next/tsconfig.json | 31 +----- .../modules/inventory-next/tsconfig.spec.json | 5 - packages/modules/link-modules/jest.config.js | 20 +--- packages/modules/link-modules/package.json | 10 +- .../link-modules/src/utils/generate-schema.ts | 2 +- packages/modules/link-modules/tsconfig.json | 36 ++----- .../modules/link-modules/tsconfig.spec.json | 5 - packages/modules/notification/jest.config.js | 19 +--- packages/modules/notification/package.json | 10 +- packages/modules/notification/tsconfig.json | 31 +----- .../modules/notification/tsconfig.spec.json | 8 -- packages/modules/order/jest.config.js | 20 +--- packages/modules/order/package.json | 10 +- .../__tests__/util/actions/exchanges.ts | 24 +++++ .../__tests__/util/actions/returns.ts | 31 +++++- .../src/services/order-module-service.ts | 2 +- packages/modules/order/src/types/index.ts | 1 + packages/modules/order/tsconfig.json | 34 +------ packages/modules/order/tsconfig.spec.json | 8 -- packages/modules/payment/jest.config.js | 19 +--- packages/modules/payment/package.json | 10 +- packages/modules/payment/tsconfig.json | 35 +------ packages/modules/payment/tsconfig.spec.json | 8 -- packages/modules/pricing/jest.config.js | 17 +--- packages/modules/pricing/package.json | 10 +- .../pricing/src/services/pricing-module.ts | 30 +++--- packages/modules/pricing/tsconfig.json | 32 +------ packages/modules/pricing/tsconfig.spec.json | 8 -- packages/modules/product/jest.config.js | 20 +--- packages/modules/product/package.json | 10 +- .../product/src/models/product-variant.ts | 3 - .../product/src/repositories/product.ts | 2 - packages/modules/product/tsconfig.json | 34 +------ packages/modules/product/tsconfig.spec.json | 8 -- packages/modules/promotion/jest.config.js | 19 +--- packages/modules/promotion/package.json | 10 +- .../src/services/promotion-module.ts | 11 ++- packages/modules/promotion/tsconfig.json | 31 +----- packages/modules/promotion/tsconfig.spec.json | 8 -- .../providers/auth-emailpass/jest.config.js | 15 ++- .../providers/auth-emailpass/package.json | 7 +- .../providers/auth-emailpass/tsconfig.json | 39 ++------ .../providers/auth-github/jest.config.js | 15 ++- .../providers/auth-github/package.json | 7 +- .../providers/auth-github/tsconfig.json | 37 ++------ .../providers/auth-google/jest.config.js | 15 ++- .../providers/auth-google/package.json | 7 +- .../providers/auth-google/tsconfig.json | 37 ++------ .../providers/file-local/jest.config.js | 10 ++ .../modules/providers/file-local/package.json | 7 +- .../file-local/src/services/local-file.ts | 2 +- .../providers/file-local/tsconfig.json | 39 ++------ .../providers/file-local/tsconfig.spec.json | 5 - .../modules/providers/file-s3/jest.config.js | 23 ++--- .../modules/providers/file-s3/package.json | 7 +- .../modules/providers/file-s3/tsconfig.json | 39 ++------ .../providers/file-s3/tsconfig.spec.json | 5 - .../fulfillment-manual/jest.config.js | 23 ++--- .../providers/fulfillment-manual/package.json | 7 +- .../fulfillment-manual/tsconfig.json | 39 ++------ .../fulfillment-manual/tsconfig.spec.json | 5 - .../notification-local/jest.config.js | 15 ++- .../providers/notification-local/package.json | 7 +- .../notification-local/tsconfig.json | 39 ++------ .../notification-sendgrid/jest.config.js | 23 ++--- .../notification-sendgrid/package.json | 7 +- .../notification-sendgrid/tsconfig.json | 39 ++------ .../notification-sendgrid/tsconfig.spec.json | 5 - .../providers/payment-stripe/jest.config.js | 23 ++--- .../providers/payment-stripe/package.json | 7 +- .../providers/payment-stripe/tsconfig.json | 39 ++------ .../payment-stripe/tsconfig.spec.json | 5 - packages/modules/region/jest.config.js | 20 +--- packages/modules/region/package.json | 10 +- packages/modules/region/tsconfig.json | 34 +------ packages/modules/region/tsconfig.spec.json | 8 -- packages/modules/sales-channel/jest.config.js | 20 +--- packages/modules/sales-channel/package.json | 10 +- packages/modules/sales-channel/tsconfig.json | 34 +------ .../modules/sales-channel/tsconfig.spec.json | 8 -- .../stock-location-next/jest.config.js | 23 ++--- .../modules/stock-location-next/package.json | 10 +- .../src/models/stock-location-address.ts | 4 +- .../src/models/stock-location.ts | 4 +- .../modules/stock-location-next/tsconfig.json | 31 +----- .../stock-location-next/tsconfig.spec.json | 5 - packages/modules/store/jest.config.js | 20 +--- packages/modules/store/package.json | 10 +- packages/modules/store/tsconfig.json | 34 +------ packages/modules/store/tsconfig.spec.json | 8 -- packages/modules/tax/jest.config.js | 20 +--- packages/modules/tax/package.json | 10 +- .../modules/tax/src/models/tax-rate-rule.ts | 11 ++- packages/modules/tax/src/models/tax-rate.ts | 11 ++- packages/modules/tax/src/models/tax-region.ts | 11 ++- packages/modules/tax/tsconfig.json | 34 +------ packages/modules/tax/tsconfig.spec.json | 8 -- packages/modules/user/jest.config.js | 20 +--- packages/modules/user/package.json | 10 +- packages/modules/user/tsconfig.json | 35 +------ packages/modules/user/tsconfig.spec.json | 8 -- .../workflow-engine-inmemory/jest.config.js | 20 +--- .../workflow-engine-inmemory/package.json | 10 +- .../utils/workflow-orchestrator-storage.ts | 2 +- .../workflow-engine-inmemory/tsconfig.json | 34 +------ .../tsconfig.spec.json | 8 -- .../workflow-engine-redis/jest.config.js | 20 +--- .../workflow-engine-redis/package.json | 10 +- .../src/services/workflow-orchestrator.ts | 5 +- .../utils/workflow-orchestrator-storage.ts | 2 +- .../workflow-engine-redis/tsconfig.json | 34 +------ .../workflow-engine-redis/tsconfig.spec.json | 8 -- yarn.lock | 94 ++++++++----------- 216 files changed, 981 insertions(+), 2439 deletions(-) create mode 100644 _tsconfig.base.json create mode 100644 define_jest_config.js create mode 100644 packages/core/utils/src/common/dynamic-import.ts create mode 100644 packages/core/utils/src/common/resolve-exports.ts create mode 100644 packages/core/utils/src/dml/helpers/entity-builder/index.ts create mode 100644 packages/core/utils/src/dml/properties/index.ts create mode 100644 packages/core/utils/src/dml/relations/index.ts delete mode 100644 packages/modules/api-key/tsconfig.spec.json delete mode 100644 packages/modules/auth/tsconfig.spec.json delete mode 100644 packages/modules/cache-inmemory/tsconfig.spec.json delete mode 100644 packages/modules/cache-redis/tsconfig.spec.json delete mode 100644 packages/modules/cart/tsconfig.spec.json delete mode 100644 packages/modules/currency/tsconfig.spec.json delete mode 100644 packages/modules/customer/tsconfig.spec.json delete mode 100644 packages/modules/event-bus-local/tsconfig.spec.json delete mode 100644 packages/modules/event-bus-redis/tsconfig.spec.json delete mode 100644 packages/modules/file/tsconfig.spec.json delete mode 100644 packages/modules/fulfillment/tsconfig.spec.json delete mode 100644 packages/modules/index/tsconfig.build.json delete mode 100644 packages/modules/index/tsconfig.spec.json delete mode 100644 packages/modules/inventory-next/tsconfig.spec.json delete mode 100644 packages/modules/link-modules/tsconfig.spec.json delete mode 100644 packages/modules/notification/tsconfig.spec.json delete mode 100644 packages/modules/order/tsconfig.spec.json delete mode 100644 packages/modules/payment/tsconfig.spec.json delete mode 100644 packages/modules/pricing/tsconfig.spec.json delete mode 100644 packages/modules/product/tsconfig.spec.json delete mode 100644 packages/modules/promotion/tsconfig.spec.json delete mode 100644 packages/modules/providers/file-local/tsconfig.spec.json delete mode 100644 packages/modules/providers/file-s3/tsconfig.spec.json delete mode 100644 packages/modules/providers/fulfillment-manual/tsconfig.spec.json delete mode 100644 packages/modules/providers/notification-sendgrid/tsconfig.spec.json delete mode 100644 packages/modules/providers/payment-stripe/tsconfig.spec.json delete mode 100644 packages/modules/region/tsconfig.spec.json delete mode 100644 packages/modules/sales-channel/tsconfig.spec.json delete mode 100644 packages/modules/stock-location-next/tsconfig.spec.json delete mode 100644 packages/modules/store/tsconfig.spec.json delete mode 100644 packages/modules/tax/tsconfig.spec.json delete mode 100644 packages/modules/user/tsconfig.spec.json delete mode 100644 packages/modules/workflow-engine-inmemory/tsconfig.spec.json delete mode 100644 packages/modules/workflow-engine-redis/tsconfig.spec.json diff --git a/_tsconfig.base.json b/_tsconfig.base.json new file mode 100644 index 0000000000..8c8f0acaf5 --- /dev/null +++ b/_tsconfig.base.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "lib": ["ES2021"], + "target": "ES2021", + "outDir": "${configDir}/dist", + "esModuleInterop": true, + "declaration": true, + "declarationMap": true, + "noUnusedLocals": true, + "module": "Node16", + "moduleResolution": "Node16", + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "sourceMap": true, + "noImplicitReturns": true, + "resolveJsonModule": true, + "forceConsistentCasingInFileNames": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "noImplicitThis": true, + "allowJs": true, + "skipLibCheck": true + }, + "include": ["${configDir}/src"], + "exclude": ["${configDir}/dist", "${configDir}/node_modules"] +} diff --git a/define_jest_config.js b/define_jest_config.js new file mode 100644 index 0000000000..8015a7f6ca --- /dev/null +++ b/define_jest_config.js @@ -0,0 +1,28 @@ +module.exports = function defineJestConfig(config) { + return { + transform: { + "^.+\\.[jt]s$": [ + "@swc/jest", + { + jsc: { + parser: { + syntax: "typescript", + decorators: true, + }, + transform: { + useDefineForClassFields: false, + legacyDecorator: true, + decoratorMetadata: true, + }, + target: "ES2021", + }, + }, + ], + }, + modulePathIgnorePatterns: [`dist/`], + testPathIgnorePatterns: [`dist/`, `node_modules/`], + testEnvironment: `node`, + moduleFileExtensions: [`js`, `ts`], + ...config, + } +} diff --git a/packages/core/framework/jest.config.js b/packages/core/framework/jest.config.js index 867ce6519f..22f0b7eb20 100644 --- a/packages/core/framework/jest.config.js +++ b/packages/core/framework/jest.config.js @@ -1,24 +1,2 @@ -module.exports = { - transform: { - "^.+\\.[jt]s$": [ - "@swc/jest", - { - jsc: { - parser: { - syntax: "typescript", - decorators: true, - }, - transform: { - useDefineForClassFields: false, - legacyDecorator: true, - decoratorMetadata: true, - }, - target: "ES2021", - }, - }, - ], - }, - testPathIgnorePatterns: [`dist/`, `node_modules/`], - testEnvironment: `node`, - moduleFileExtensions: [`js`, `ts`], -} +const defineJestConfig = require("../../../define_jest_config") +module.exports = defineJestConfig() diff --git a/packages/core/framework/src/config/types.ts b/packages/core/framework/src/config/types.ts index c1397c798c..506387db36 100644 --- a/packages/core/framework/src/config/types.ts +++ b/packages/core/framework/src/config/types.ts @@ -4,6 +4,7 @@ import { } from "@medusajs/types" import type { RedisOptions } from "ioredis" +// @ts-expect-error import type { InlineConfig } from "vite" /** @@ -15,7 +16,7 @@ export type AdminOptions = { /** * Whether to disable the admin dashboard. If set to `true`, the admin dashboard is disabled, * in both development and production environments. The default value is `false`. - * + * * @example * ```js title="medusa-config.js" * module.exports = defineConfig({ @@ -36,14 +37,14 @@ export type AdminOptions = { * - `/store` * - `/auth` * - `/` - * + * * :::note - * + * * When using Docker, make sure that the root path of the Docker image doesn't path the admin's `path`. For example, if the Docker image's root path is `/app`, change * the value of the `path` configuration, as it's `/app` by default. - * + * * ::: - * + * * @example * ```js title="medusa-config.js" * module.exports = defineConfig({ @@ -58,7 +59,7 @@ export type AdminOptions = { /** * The directory where the admin build is outputted when you run the `build` command. * The default value is `./build`. - * + * * @example * ```js title="medusa-config.js" * module.exports = defineConfig({ @@ -72,7 +73,7 @@ export type AdminOptions = { outDir?: string /** * The URL of your Medusa application. This is useful to set when you deploy the Medusa application. - * + * * @example * ```js title="medusa-config.js" * module.exports = defineConfig({ @@ -270,11 +271,11 @@ export type ProjectConfigOptions = { * * This is useful for production databases, which can be supported by setting the `rejectUnauthorized` attribute of `ssl` object to `false`. * During development, it’s recommended not to pass this option. - * + * * :::note - * + * * Make sure to add to the end of the database URL `?ssl_mode=disable` as well when disabling `rejectUnauthorized`. - * + * * ::: * * @example @@ -416,9 +417,9 @@ export type ProjectConfigOptions = { * // ... * }) * ``` - * + * * @ignore - * + * * @privateRemarks * Couldn't find any use for this option. */ @@ -499,7 +500,7 @@ export type ProjectConfigOptions = { jwtSecret?: string /** * The expiration time for the JWT token. Its format is based off the [ms package](https://github.com/vercel/ms). - * + * * If not provided, the default value is `24h`. * * @example @@ -760,7 +761,7 @@ export type ProjectConfigOptions = { * The configurations for your Medusa application are in `medusa-config.js` located in the root of your Medusa project. The configurations include configurations for database, modules, and more. * * `medusa-config.js` exports the value returned by the `defineConfig` utility function imported from `@medusajs/utils`. - * + * * `defineConfig` accepts as a parameter an object with the following properties: * * - {@link ConfigModule.projectConfig | projectConfig} (required): An object that holds general configurations related to the Medusa application, such as database or CORS configurations. @@ -866,12 +867,12 @@ export type ConfigModule = { /** * This property holds all custom modules installed in your Medusa application. - * + * * :::note - * + * * Medusa's commerce modules are configured by default, so only * add them to this property if you're changing their configurations or adding providers to a module. - * + * * ::: * * The keys of the `modules` configuration object refer to the module's registration name. Its value can be one of the following: diff --git a/packages/core/framework/src/feature-flags/feature-flag-loader.ts b/packages/core/framework/src/feature-flags/feature-flag-loader.ts index 61d555b6ef..02ad5ff541 100644 --- a/packages/core/framework/src/feature-flags/feature-flag-loader.ts +++ b/packages/core/framework/src/feature-flags/feature-flag-loader.ts @@ -1,5 +1,6 @@ import { ContainerRegistrationKeys, + dynamicImport, FlagRouter, isDefined, isObject, @@ -112,7 +113,7 @@ export async function featureFlagsLoader( return } - const fileExports = await import(join(flagDir, file.name)) + const fileExports = await dynamicImport(join(flagDir, file.name)) const featureFlag = fileExports.default if (!featureFlag) { diff --git a/packages/core/framework/src/http/router.ts b/packages/core/framework/src/http/router.ts index 5761c5c585..9b00ff9bab 100644 --- a/packages/core/framework/src/http/router.ts +++ b/packages/core/framework/src/http/router.ts @@ -1,4 +1,10 @@ -import { parseCorsOrigins, promiseAll, wrapHandler } from "@medusajs/utils" +import { + dynamicImport, + parseCorsOrigins, + promiseAll, + resolveExports, + wrapHandler, +} from "@medusajs/utils" import cors from "cors" import { type Express, @@ -348,7 +354,7 @@ class ApiRoutesLoader { const absolutePath = descriptor.absolutePath const route = descriptor.route - return await import(absolutePath).then((import_) => { + return await dynamicImport(absolutePath).then((import_) => { const map = this.#routesMap const config: RouteConfig = { @@ -486,8 +492,10 @@ class ApiRoutesLoader { const absolutePath = join(this.#sourceDir, middlewareFilePath) - await import(absolutePath).then((import_) => { - const middlewaresConfig = import_.default as MiddlewaresConfig | undefined + await dynamicImport(absolutePath).then((import_) => { + const middlewaresConfig = resolveExports(import_).default as + | MiddlewaresConfig + | undefined if (!middlewaresConfig) { log({ diff --git a/packages/core/framework/src/jobs/job-loader.ts b/packages/core/framework/src/jobs/job-loader.ts index 29548dd505..046db015b8 100644 --- a/packages/core/framework/src/jobs/job-loader.ts +++ b/packages/core/framework/src/jobs/job-loader.ts @@ -1,6 +1,11 @@ import type { SchedulerOptions } from "@medusajs/orchestration" import { MedusaContainer } from "@medusajs/types" -import { isObject, MedusaError, promiseAll } from "@medusajs/utils" +import { + dynamicImport, + isObject, + MedusaError, + promiseAll, +} from "@medusajs/utils" import { createStep, createWorkflow, @@ -150,11 +155,11 @@ export class JobLoader { fileEntries.map(async (entry) => { const fullPath = join(entry.path, entry.name) - const module_ = await import(fullPath) + const module_ = await dynamicImport(fullPath) const input = { config: module_.config, - handler: module_.default, + handler: module_.default.default, } this.validateConfig(input.config) diff --git a/packages/core/framework/src/links/link-loader.ts b/packages/core/framework/src/links/link-loader.ts index 0de771cf6e..85456be821 100644 --- a/packages/core/framework/src/links/link-loader.ts +++ b/packages/core/framework/src/links/link-loader.ts @@ -1,4 +1,4 @@ -import { promiseAll } from "@medusajs/utils" +import { dynamicImport, promiseAll } from "@medusajs/utils" import { logger } from "../logger" import { access, readdir } from "fs/promises" import { join } from "path" @@ -59,7 +59,7 @@ export class LinkLoader { return await promiseAll( fileEntries.map(async (entry) => { const fullPath = join(entry.path, entry.name) - return await import(fullPath) + return await dynamicImport(fullPath) }) ) }) diff --git a/packages/core/framework/src/subscribers/subscriber-loader.ts b/packages/core/framework/src/subscribers/subscriber-loader.ts index 77a4f81cb5..0153d6c842 100644 --- a/packages/core/framework/src/subscribers/subscriber-loader.ts +++ b/packages/core/framework/src/subscribers/subscriber-loader.ts @@ -1,5 +1,11 @@ import { Event, IEventBusModuleService, Subscriber } from "@medusajs/types" -import { Modules, kebabCase, promiseAll } from "@medusajs/utils" +import { + dynamicImport, + kebabCase, + Modules, + promiseAll, + resolveExports, +} from "@medusajs/utils" import { access, readdir } from "fs/promises" import { join, parse } from "path" @@ -115,7 +121,8 @@ export class SubscriberLoader { } private async createDescriptor(absolutePath: string) { - return await import(absolutePath).then((module_) => { + return await dynamicImport(absolutePath).then((module_) => { + module_ = resolveExports(module_) const isValid = this.validateSubscriber(module_, absolutePath) if (!isValid) { diff --git a/packages/core/framework/src/workflows/workflow-loader.ts b/packages/core/framework/src/workflows/workflow-loader.ts index c4f3c8177e..15fa2886aa 100644 --- a/packages/core/framework/src/workflows/workflow-loader.ts +++ b/packages/core/framework/src/workflows/workflow-loader.ts @@ -1,4 +1,4 @@ -import { promiseAll } from "@medusajs/utils" +import { dynamicImport, promiseAll } from "@medusajs/utils" import { logger } from "../logger" import { access, readdir } from "fs/promises" import { join } from "path" @@ -59,7 +59,7 @@ export class WorkflowLoader { return await promiseAll( fileEntries.map(async (entry) => { const fullPath = join(entry.path, entry.name) - return await import(fullPath) + return await dynamicImport(fullPath) }) ) }) diff --git a/packages/core/framework/tsconfig.json b/packages/core/framework/tsconfig.json index ea80f1e93f..f9a18581b3 100644 --- a/packages/core/framework/tsconfig.json +++ b/packages/core/framework/tsconfig.json @@ -1,32 +1,3 @@ { - "compilerOptions": { - "lib": ["ESNext"], - "target": "ESNext", - "outDir": "./dist", - "esModuleInterop": true, - "declarationMap": true, - "declaration": true, - "module": "commonjs", - "moduleResolution": "node", - "noUnusedLocals": true, - "forceConsistentCasingInFileNames": true, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "sourceMap": false, - "noImplicitReturns": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "noImplicitThis": true, - "allowJs": true, - "skipLibCheck": true, - "baseUrl": ".", - "resolveJsonModule": true, - "paths": { - }, - }, - "include": ["src"], - "exclude": [ - "dist", - "node_modules" - ] + "extends": "../../../_tsconfig.base.json" } diff --git a/packages/core/medusa-test-utils/src/medusa-test-runner.ts b/packages/core/medusa-test-utils/src/medusa-test-runner.ts index f038aa186d..c4ffb61ce2 100644 --- a/packages/core/medusa-test-utils/src/medusa-test-runner.ts +++ b/packages/core/medusa-test-utils/src/medusa-test-runner.ts @@ -163,6 +163,7 @@ export function medusaIntegrationTestRunner({ const { logger, container, MedusaAppLoader } = await import( "@medusajs/framework" ) + const appLoader = new MedusaAppLoader() container.register({ [ContainerRegistrationKeys.LOGGER]: asValue(logger), diff --git a/packages/core/modules-sdk/jest.config.js b/packages/core/modules-sdk/jest.config.js index 8d1d9b6599..22f0b7eb20 100644 --- a/packages/core/modules-sdk/jest.config.js +++ b/packages/core/modules-sdk/jest.config.js @@ -1,17 +1,2 @@ -module.exports = { - transform: { - "^.+\\.[jt]s$": [ - "@swc/jest", - { - jsc: { - parser: { syntax: "typescript", decorators: true }, - transform: { decoratorMetadata: true }, - target: "ES2021", - }, - }, - ], - }, - testPathIgnorePatterns: [`dist/`, `node_modules/`], - testEnvironment: `node`, - moduleFileExtensions: [`js`, `ts`], -} +const defineJestConfig = require("../../../define_jest_config") +module.exports = defineJestConfig() diff --git a/packages/core/modules-sdk/src/loaders/module-provider-loader.ts b/packages/core/modules-sdk/src/loaders/module-provider-loader.ts index e679b79138..a3e27f1eeb 100644 --- a/packages/core/modules-sdk/src/loaders/module-provider-loader.ts +++ b/packages/core/modules-sdk/src/loaders/module-provider-loader.ts @@ -1,5 +1,6 @@ import { MedusaContainer, ModuleProvider } from "@medusajs/types" import { + dynamicImport, isString, lowerCaseFirst, normalizeImportPathWithSource, @@ -44,7 +45,7 @@ export async function loadModuleProvider( if (isString(provider.resolve)) { const normalizedPath = normalizeImportPathWithSource(provider.resolve) - loadedProvider = await import(normalizedPath) + loadedProvider = await dynamicImport(normalizedPath) } } catch (error) { throw new Error( diff --git a/packages/core/modules-sdk/src/loaders/utils/load-internal.ts b/packages/core/modules-sdk/src/loaders/utils/load-internal.ts index 849b27c918..60a50957f1 100644 --- a/packages/core/modules-sdk/src/loaders/utils/load-internal.ts +++ b/packages/core/modules-sdk/src/loaders/utils/load-internal.ts @@ -11,11 +11,13 @@ import { } from "@medusajs/types" import { ContainerRegistrationKeys, - DmlEntity, - MedusaModuleType, - ModulesSdkUtils, createMedusaContainer, defineJoinerConfig, + DmlEntity, + dynamicImport, + MedusaModuleType, + ModulesSdkUtils, + resolveExports, toMikroOrmEntities, } from "@medusajs/utils" import { asFunction, asValue } from "awilix" @@ -65,7 +67,7 @@ export async function loadInternalModule( // If we want to benefit from the auto load mechanism, even if the module exports is provided, we need to ask for the module path loadedModule = resolution.moduleExports } else { - loadedModule = await import(modulePath) + loadedModule = await dynamicImport(modulePath) loadedModule = (loadedModule as any).default } } catch (error) { @@ -195,7 +197,8 @@ export async function loadModuleMigrations( let loadedModule: ModuleExports try { loadedModule = - moduleExports ?? (await import(resolution.resolutionPath as string)) + moduleExports ?? + (await dynamicImport(resolution.resolutionPath as string)) let runMigrations = loadedModule.runMigrations let revertMigration = loadedModule.revertMigration @@ -263,7 +266,7 @@ async function importAllFromDir(path: string) { return ( await Promise.all(filesToLoad.map((filePath) => import(filePath))) ).flatMap((value) => { - return Object.values(value) + return Object.values(resolveExports(value)) }) } @@ -284,7 +287,9 @@ export async function loadResources( } const [moduleService, services, models, repositories] = await Promise.all([ - import(modulePath).then((moduleExports) => moduleExports.default.service), + import(modulePath).then((moduleExports) => { + return resolveExports(moduleExports).default.service + }), importAllFromDir(resolve(normalizedPath, "services")).catch( defaultOnFail ), diff --git a/packages/core/modules-sdk/src/medusa-app.ts b/packages/core/modules-sdk/src/medusa-app.ts index 9f093ff982..67c0c96751 100644 --- a/packages/core/modules-sdk/src/medusa-app.ts +++ b/packages/core/modules-sdk/src/medusa-app.ts @@ -18,12 +18,13 @@ import { } from "@medusajs/types" import { ContainerRegistrationKeys, + createMedusaContainer, + dynamicImport, + isObject, + isString, MedusaError, Modules, ModulesSdkUtils, - createMedusaContainer, - isObject, - isString, promiseAll, } from "@medusajs/utils" import type { Knex } from "@mikro-orm/knex" @@ -36,7 +37,7 @@ import { RegisterModuleJoinerConfig, } from "./medusa-module" import { RemoteLink } from "./remote-link" -import { RemoteQuery, createQuery } from "./remote-query" +import { createQuery, RemoteQuery } from "./remote-query" import { MODULE_RESOURCE_TYPE, MODULE_SCOPE } from "./types" import { cleanGraphQLSchema } from "./utils" @@ -171,7 +172,7 @@ async function initializeLinks({ }) { try { const { initialize, getMigrationPlanner } = - moduleExports ?? (await import(LinkModulePackage)) + moduleExports ?? (await dynamicImport(LinkModulePackage)) const linkResolution = await initialize( config, @@ -298,9 +299,9 @@ async function MedusaApp_({ const modules: MedusaModuleConfig = modulesConfig ?? ( - await import( - modulesConfigPath ?? - process.cwd() + (modulesConfigFileName ?? "/modules-config") + await dynamicImport( + await (modulesConfigPath ?? + process.cwd() + (modulesConfigFileName ?? "/modules-config")) ) ).default diff --git a/packages/core/modules-sdk/tsconfig.json b/packages/core/modules-sdk/tsconfig.json index dde7c3bd93..f9a18581b3 100644 --- a/packages/core/modules-sdk/tsconfig.json +++ b/packages/core/modules-sdk/tsconfig.json @@ -1,28 +1,3 @@ { - "compilerOptions": { - "lib": ["es2021"], - "target": "es2021", - "outDir": "./dist", - "esModuleInterop": true, - "declarationMap": true, - "declaration": true, - "module": "commonjs", - "moduleResolution": "node", - "noUnusedLocals": true, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "forceConsistentCasingInFileNames": true, - "sourceMap": true, - "noImplicitReturns": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "noImplicitThis": true, - "allowJs": true, - "skipLibCheck": true - }, - "include": ["src"], - "exclude": [ - "dist", - "node_modules" - ] + "extends": "../../../_tsconfig.base.json" } diff --git a/packages/core/orchestration/jest.config.js b/packages/core/orchestration/jest.config.js index 867ce6519f..22f0b7eb20 100644 --- a/packages/core/orchestration/jest.config.js +++ b/packages/core/orchestration/jest.config.js @@ -1,24 +1,2 @@ -module.exports = { - transform: { - "^.+\\.[jt]s$": [ - "@swc/jest", - { - jsc: { - parser: { - syntax: "typescript", - decorators: true, - }, - transform: { - useDefineForClassFields: false, - legacyDecorator: true, - decoratorMetadata: true, - }, - target: "ES2021", - }, - }, - ], - }, - testPathIgnorePatterns: [`dist/`, `node_modules/`], - testEnvironment: `node`, - moduleFileExtensions: [`js`, `ts`], -} +const defineJestConfig = require("../../../define_jest_config") +module.exports = defineJestConfig() diff --git a/packages/core/orchestration/tsconfig.json b/packages/core/orchestration/tsconfig.json index d4c9e79afe..f9a18581b3 100644 --- a/packages/core/orchestration/tsconfig.json +++ b/packages/core/orchestration/tsconfig.json @@ -1,28 +1,3 @@ { - "compilerOptions": { - "lib": ["es2021"], - "target": "es2021", - "outDir": "./dist", - "esModuleInterop": true, - "declarationMap": true, - "declaration": true, - "module": "commonjs", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "noUnusedLocals": true, - "forceConsistentCasingInFileNames": true, - "sourceMap": true, - "noImplicitReturns": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "noImplicitThis": true, - "allowJs": true, - "skipLibCheck": true - }, - "include": ["src"], - "exclude": [ - "dist", - "node_modules" - ] + "extends": "../../../_tsconfig.base.json" } diff --git a/packages/core/types/jest.config.js b/packages/core/types/jest.config.js index 867ce6519f..22f0b7eb20 100644 --- a/packages/core/types/jest.config.js +++ b/packages/core/types/jest.config.js @@ -1,24 +1,2 @@ -module.exports = { - transform: { - "^.+\\.[jt]s$": [ - "@swc/jest", - { - jsc: { - parser: { - syntax: "typescript", - decorators: true, - }, - transform: { - useDefineForClassFields: false, - legacyDecorator: true, - decoratorMetadata: true, - }, - target: "ES2021", - }, - }, - ], - }, - testPathIgnorePatterns: [`dist/`, `node_modules/`], - testEnvironment: `node`, - moduleFileExtensions: [`js`, `ts`], -} +const defineJestConfig = require("../../../define_jest_config") +module.exports = defineJestConfig() diff --git a/packages/core/types/src/common/config-module.ts b/packages/core/types/src/common/config-module.ts index 7fc0c07345..431f898fed 100644 --- a/packages/core/types/src/common/config-module.ts +++ b/packages/core/types/src/common/config-module.ts @@ -4,6 +4,7 @@ import { } from "../modules-sdk" import type { RedisOptions } from "ioredis" +// @ts-ignore import type { InlineConfig } from "vite" /** diff --git a/packages/core/types/tsconfig.json b/packages/core/types/tsconfig.json index d4c9e79afe..f9a18581b3 100644 --- a/packages/core/types/tsconfig.json +++ b/packages/core/types/tsconfig.json @@ -1,28 +1,3 @@ { - "compilerOptions": { - "lib": ["es2021"], - "target": "es2021", - "outDir": "./dist", - "esModuleInterop": true, - "declarationMap": true, - "declaration": true, - "module": "commonjs", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "noUnusedLocals": true, - "forceConsistentCasingInFileNames": true, - "sourceMap": true, - "noImplicitReturns": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "noImplicitThis": true, - "allowJs": true, - "skipLibCheck": true - }, - "include": ["src"], - "exclude": [ - "dist", - "node_modules" - ] + "extends": "../../../_tsconfig.base.json" } diff --git a/packages/core/utils/jest.config.js b/packages/core/utils/jest.config.js index 867ce6519f..22f0b7eb20 100644 --- a/packages/core/utils/jest.config.js +++ b/packages/core/utils/jest.config.js @@ -1,24 +1,2 @@ -module.exports = { - transform: { - "^.+\\.[jt]s$": [ - "@swc/jest", - { - jsc: { - parser: { - syntax: "typescript", - decorators: true, - }, - transform: { - useDefineForClassFields: false, - legacyDecorator: true, - decoratorMetadata: true, - }, - target: "ES2021", - }, - }, - ], - }, - testPathIgnorePatterns: [`dist/`, `node_modules/`], - testEnvironment: `node`, - moduleFileExtensions: [`js`, `ts`], -} +const defineJestConfig = require("../../../define_jest_config") +module.exports = defineJestConfig() diff --git a/packages/core/utils/src/common/dynamic-import.ts b/packages/core/utils/src/common/dynamic-import.ts new file mode 100644 index 0000000000..48c6c9bc24 --- /dev/null +++ b/packages/core/utils/src/common/dynamic-import.ts @@ -0,0 +1,17 @@ +import { resolveExports } from "./resolve-exports" + +/** + * Utility that should be used instead of either await import() or require() + * to avoid bundling issues. That way we have a single place + * where we manage the strategy to dynamically import a module. + * + * This issue arise from migration to Node16 or NodeNext module resolution as well + * as ts-node not being maintained anymore and throwing deprecation warnings. + * all over the place. + * + * @param path + */ +export async function dynamicImport(path: string): Promise { + const module = require(path) + return resolveExports(module) +} diff --git a/packages/core/utils/src/common/index.ts b/packages/core/utils/src/common/index.ts index ab70f60feb..a9aa7e4d32 100644 --- a/packages/core/utils/src/common/index.ts +++ b/packages/core/utils/src/common/index.ts @@ -72,3 +72,5 @@ export * from "./trim-zeros" export * from "./upper-case-first" export * from "./validate-handle" export * from "./wrap-handler" +export * from "./resolve-exports" +export * from "./dynamic-import" diff --git a/packages/core/utils/src/common/resolve-exports.ts b/packages/core/utils/src/common/resolve-exports.ts new file mode 100644 index 0000000000..c0655adef1 --- /dev/null +++ b/packages/core/utils/src/common/resolve-exports.ts @@ -0,0 +1,6 @@ +export function resolveExports(moduleExports) { + if ("default" in moduleExports && "default" in moduleExports.default) { + return resolveExports(moduleExports.default) + } + return moduleExports +} diff --git a/packages/core/utils/src/dal/mikro-orm/mikro-orm-create-connection.ts b/packages/core/utils/src/dal/mikro-orm/mikro-orm-create-connection.ts index ca956691e2..13c8a67ab6 100644 --- a/packages/core/utils/src/dal/mikro-orm/mikro-orm-create-connection.ts +++ b/packages/core/utils/src/dal/mikro-orm/mikro-orm-create-connection.ts @@ -1,7 +1,9 @@ -import { ModuleServiceInitializeOptions } from "@medusajs/types" +import { Filter as MikroORMFilter } from "@mikro-orm/core" import { TSMigrationGenerator } from "@mikro-orm/migrations" +import { ModuleServiceInitializeOptions } from "@medusajs/types" import { isString } from "../../common" -import { FilterDef } from "@mikro-orm/core/typings" + +type FilterDef = Parameters[0] export class CustomTsMigrationGenerator extends TSMigrationGenerator { createStatement(sql: string, padLeft: number): string { diff --git a/packages/core/utils/src/dal/mikro-orm/mikro-orm-free-text-search-filter.ts b/packages/core/utils/src/dal/mikro-orm/mikro-orm-free-text-search-filter.ts index 1d85ae3bce..cddc0a9891 100644 --- a/packages/core/utils/src/dal/mikro-orm/mikro-orm-free-text-search-filter.ts +++ b/packages/core/utils/src/dal/mikro-orm/mikro-orm-free-text-search-filter.ts @@ -1,7 +1,11 @@ -import { EntityClass, EntityProperty } from "@mikro-orm/core/typings" import { EntityMetadata, EntitySchema, ReferenceType } from "@mikro-orm/core" import { SqlEntityManager } from "@mikro-orm/postgresql" -import type { FindOneOptions, FindOptions } from "@mikro-orm/core/drivers" +import type { + FindOptions, + EntityClass, + EntityProperty, + FindOneOptions, +} from "@mikro-orm/core" export const FreeTextSearchFilterKey = "freeTextSearch" diff --git a/packages/core/utils/src/dal/mikro-orm/mikro-orm-repository.ts b/packages/core/utils/src/dal/mikro-orm/mikro-orm-repository.ts index d161d55007..02f59994f4 100644 --- a/packages/core/utils/src/dal/mikro-orm/mikro-orm-repository.ts +++ b/packages/core/utils/src/dal/mikro-orm/mikro-orm-repository.ts @@ -16,13 +16,13 @@ import { ReferenceType, RequiredEntityData, } from "@mikro-orm/core" -import { FindOptions as MikroOptions } from "@mikro-orm/core/drivers/IDatabaseDriver" import { EntityClass, EntityName, EntityProperty, + FindOptions as MikroOptions, FilterQuery as MikroFilterQuery, -} from "@mikro-orm/core/typings" +} from "@mikro-orm/core" import { SqlEntityManager } from "@mikro-orm/postgresql" import { MedusaError, diff --git a/packages/core/utils/src/dal/mikro-orm/mikro-orm-serializer.ts b/packages/core/utils/src/dal/mikro-orm/mikro-orm-serializer.ts index 44a71527b3..e59c3983ed 100644 --- a/packages/core/utils/src/dal/mikro-orm/mikro-orm-serializer.ts +++ b/packages/core/utils/src/dal/mikro-orm/mikro-orm-serializer.ts @@ -8,10 +8,10 @@ import { Platform, Reference, ReferenceType, + SerializeOptions, SerializationContext, Utils, } from "@mikro-orm/core" -import { SerializeOptions } from "@mikro-orm/core/serialization/EntitySerializer" function isVisible( meta: EntityMetadata, diff --git a/packages/core/utils/src/dml/helpers/entity-builder/index.ts b/packages/core/utils/src/dml/helpers/entity-builder/index.ts new file mode 100644 index 0000000000..fb8783bd9b --- /dev/null +++ b/packages/core/utils/src/dml/helpers/entity-builder/index.ts @@ -0,0 +1,8 @@ +export * from "./apply-searchable" +export * from "./build-indexes" +export * from "./create-big-number-properties" +export * from "./create-default-properties" +export * from "./define-property" +export * from "./define-relationship" +export * from "./parse-entity-name" +export * from "./query-builder" diff --git a/packages/core/utils/src/dml/index.ts b/packages/core/utils/src/dml/index.ts index e04b59b4da..59ed093976 100644 --- a/packages/core/utils/src/dml/index.ts +++ b/packages/core/utils/src/dml/index.ts @@ -1,3 +1,6 @@ export * from "./entity-builder" export * from "./entity" +export * from "./helpers/entity-builder/index" export * from "./helpers/create-mikro-orm-entity" +export * from "./relations/index" +export * from "./properties/index" diff --git a/packages/core/utils/src/dml/properties/index.ts b/packages/core/utils/src/dml/properties/index.ts new file mode 100644 index 0000000000..9c55e70366 --- /dev/null +++ b/packages/core/utils/src/dml/properties/index.ts @@ -0,0 +1,12 @@ +export * from "./array" +export * from "./base" +export * from "./big-number" +export * from "./boolean" +export * from "./date-time" +export * from "./enum" +export * from "./id" +export * from "./json" +export * from "./nullable" +export * from "./number" +export * from "./primary-key" +export * from "./text" diff --git a/packages/core/utils/src/dml/relations/belongs-to.ts b/packages/core/utils/src/dml/relations/belongs-to.ts index e0187cb381..70ac8321d9 100644 --- a/packages/core/utils/src/dml/relations/belongs-to.ts +++ b/packages/core/utils/src/dml/relations/belongs-to.ts @@ -1,5 +1,5 @@ import { BaseRelationship } from "./base" -import { NullableModifier } from "./nullable" +import { RelationNullableModifier } from "./nullable" export class BelongsTo extends BaseRelationship { type = "belongsTo" as const @@ -12,6 +12,6 @@ export class BelongsTo extends BaseRelationship { * Apply nullable modifier on the schema */ nullable() { - return new NullableModifier>(this) + return new RelationNullableModifier>(this) } } diff --git a/packages/core/utils/src/dml/relations/has-one.ts b/packages/core/utils/src/dml/relations/has-one.ts index 7d080ec426..f6def0ace9 100644 --- a/packages/core/utils/src/dml/relations/has-one.ts +++ b/packages/core/utils/src/dml/relations/has-one.ts @@ -1,5 +1,5 @@ import { BaseRelationship } from "./base" -import { NullableModifier } from "./nullable" +import { RelationNullableModifier } from "./nullable" /** * HasOne relationship defines a relationship between two entities @@ -22,6 +22,6 @@ export class HasOne extends BaseRelationship { * Apply nullable modifier on the schema */ nullable() { - return new NullableModifier>(this) + return new RelationNullableModifier>(this) } } diff --git a/packages/core/utils/src/dml/relations/index.ts b/packages/core/utils/src/dml/relations/index.ts new file mode 100644 index 0000000000..8e94644d4c --- /dev/null +++ b/packages/core/utils/src/dml/relations/index.ts @@ -0,0 +1,6 @@ +export * from "./base" +export * from "./belongs-to" +export * from "./has-many" +export * from "./has-one" +export * from "./many-to-many" +export * from "./nullable" diff --git a/packages/core/utils/src/dml/relations/nullable.ts b/packages/core/utils/src/dml/relations/nullable.ts index c1a45a76b7..23f54cb527 100644 --- a/packages/core/utils/src/dml/relations/nullable.ts +++ b/packages/core/utils/src/dml/relations/nullable.ts @@ -6,7 +6,7 @@ const IsNullableModifier = Symbol.for("isNullableModifier") /** * Nullable modifier marks a schema node as nullable */ -export class NullableModifier> +export class RelationNullableModifier> implements RelationshipType { [IsNullableModifier]: true = true; @@ -14,7 +14,7 @@ export class NullableModifier> static isNullableModifier( modifier: any - ): modifier is NullableModifier { + ): modifier is RelationNullableModifier { return !!modifier?.[IsNullableModifier] } diff --git a/packages/core/utils/src/modules-sdk/index.ts b/packages/core/utils/src/modules-sdk/index.ts index bac0a1f2bc..a4ce8a257e 100644 --- a/packages/core/utils/src/modules-sdk/index.ts +++ b/packages/core/utils/src/modules-sdk/index.ts @@ -17,3 +17,5 @@ export * from "./mikro-orm-cli-config-builder" export * from "./module" export * from "./query-context" export * from "./query-filter" +export * from "./types/links-config" +export * from "./types/medusa-service" diff --git a/packages/core/utils/src/modules-sdk/medusa-internal-service.ts b/packages/core/utils/src/modules-sdk/medusa-internal-service.ts index ae14e93aa3..cc5db00de3 100644 --- a/packages/core/utils/src/modules-sdk/medusa-internal-service.ts +++ b/packages/core/utils/src/modules-sdk/medusa-internal-service.ts @@ -9,8 +9,7 @@ import { PerformedActions, UpsertWithReplaceConfig, } from "@medusajs/types" -import { EntitySchema } from "@mikro-orm/core" -import { EntityClass } from "@mikro-orm/core/typings" +import type { EntitySchema, EntityClass } from "@mikro-orm/core" import { doNotForceTransaction, isDefined, diff --git a/packages/core/utils/src/modules-sdk/migration-scripts/seed.ts b/packages/core/utils/src/modules-sdk/migration-scripts/seed.ts index a0d538fc0b..9c8724177b 100644 --- a/packages/core/utils/src/modules-sdk/migration-scripts/seed.ts +++ b/packages/core/utils/src/modules-sdk/migration-scripts/seed.ts @@ -4,6 +4,7 @@ import { EOL } from "os" import { resolve } from "path" import { mikroOrmCreateConnection } from "../../dal" import { loadDatabaseConfig } from "../load-module-database-config" +import { dynamicImport } from "../../common" /** * Utility function to build a seed script that will insert the seed data. @@ -42,12 +43,14 @@ export function buildSeedScript({ const logger_ = (logger ?? console) as unknown as Logger logger_.info(`Loading seed data from ${path}...`) - const dataSeed = await import(resolve(process.cwd(), path)).catch((e) => { - logger_.error( - `Failed to load seed data from ${path}. Please, provide a relative path and check that you export the following productCategoriesData, productsData, variantsData.${EOL}${e}` - ) - throw e - }) + const dataSeed = await dynamicImport(resolve(process.cwd(), path)).catch( + (e) => { + logger_.error( + `Failed to load seed data from ${path}. Please, provide a relative path and check that you export the following productCategoriesData, productsData, variantsData.${EOL}${e}` + ) + throw e + } + ) const dbData = loadDatabaseConfig(moduleName, options)! const entities = Object.values(models) as unknown as EntitySchema[] diff --git a/packages/core/utils/src/modules-sdk/mikro-orm-cli-config-builder.ts b/packages/core/utils/src/modules-sdk/mikro-orm-cli-config-builder.ts index f4266674ce..39fa9a0d4a 100644 --- a/packages/core/utils/src/modules-sdk/mikro-orm-cli-config-builder.ts +++ b/packages/core/utils/src/modules-sdk/mikro-orm-cli-config-builder.ts @@ -1,12 +1,12 @@ -import { MikroORMOptions } from "@mikro-orm/core/utils/Configuration" import { DmlEntity, toMikroOrmEntities } from "../dml" import { CustomTsMigrationGenerator } from "../dal" import type { AnyEntity, EntityClass, + EntitySchema, + MikroORMOptions, EntityClassGroup, -} from "@mikro-orm/core/typings" -import type { EntitySchema } from "@mikro-orm/core/metadata/EntitySchema" +} from "@mikro-orm/core" import { kebabCase } from "../common" type Options = Partial> & { diff --git a/packages/core/utils/tsconfig.json b/packages/core/utils/tsconfig.json index 81018ff8c5..f9a18581b3 100644 --- a/packages/core/utils/tsconfig.json +++ b/packages/core/utils/tsconfig.json @@ -1,28 +1,3 @@ { - "compilerOptions": { - "lib": ["es2021"], - "target": "es2021", - "outDir": "./dist", - "esModuleInterop": true, - "declaration": true, - "noUnusedLocals": true, - "declarationMap": true, - "module": "commonjs", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "sourceMap": true, - "noImplicitReturns": true, - "forceConsistentCasingInFileNames": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "noImplicitThis": true, - "allowJs": true, - "skipLibCheck": true - }, - "include": ["src"], - "exclude": [ - "dist", - "node_modules" - ] + "extends": "../../../_tsconfig.base.json" } diff --git a/packages/core/workflows-sdk/jest.config.js b/packages/core/workflows-sdk/jest.config.js index 867ce6519f..22f0b7eb20 100644 --- a/packages/core/workflows-sdk/jest.config.js +++ b/packages/core/workflows-sdk/jest.config.js @@ -1,24 +1,2 @@ -module.exports = { - transform: { - "^.+\\.[jt]s$": [ - "@swc/jest", - { - jsc: { - parser: { - syntax: "typescript", - decorators: true, - }, - transform: { - useDefineForClassFields: false, - legacyDecorator: true, - decoratorMetadata: true, - }, - target: "ES2021", - }, - }, - ], - }, - testPathIgnorePatterns: [`dist/`, `node_modules/`], - testEnvironment: `node`, - moduleFileExtensions: [`js`, `ts`], -} +const defineJestConfig = require("../../../define_jest_config") +module.exports = defineJestConfig() diff --git a/packages/core/workflows-sdk/tsconfig.json b/packages/core/workflows-sdk/tsconfig.json index 64fe4809c5..f9a18581b3 100644 --- a/packages/core/workflows-sdk/tsconfig.json +++ b/packages/core/workflows-sdk/tsconfig.json @@ -1,25 +1,3 @@ { - "compilerOptions": { - "lib": ["es2021"], - "target": "es2021", - "outDir": "./dist", - "esModuleInterop": true, - "declaration": true, - "noUnusedLocals": true, - "declarationMap": true, - "module": "commonjs", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "sourceMap": true, - "noImplicitReturns": true, - "forceConsistentCasingInFileNames": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "noImplicitThis": true, - "allowJs": true, - "skipLibCheck": true - }, - "include": ["src"], - "exclude": ["dist", "node_modules"] + "extends": "../../../_tsconfig.base.json" } diff --git a/packages/medusa/src/commands/exec.ts b/packages/medusa/src/commands/exec.ts index f89d84ce06..f641120e2d 100644 --- a/packages/medusa/src/commands/exec.ts +++ b/packages/medusa/src/commands/exec.ts @@ -4,6 +4,7 @@ import path from "path" import { existsSync } from "fs" import { logger } from "@medusajs/framework" import { ExecArgs } from "@medusajs/types" +import { dynamicImport } from "@medusajs/utils" type Options = { file: string @@ -22,7 +23,7 @@ export default async function exec({ file, args }: Options) { throw new Error(`File ${filePath} doesn't exist.`) } - const scriptToExec = (await import(path.resolve(filePath))).default + const scriptToExec = (await dynamicImport(path.resolve(filePath))).default if (!scriptToExec || typeof scriptToExec !== "function") { throw new Error(`File doesn't default export a function to execute.`) diff --git a/packages/modules/api-key/jest.config.js b/packages/modules/api-key/jest.config.js index d125300e58..e40a4f9eaa 100644 --- a/packages/modules/api-key/jest.config.js +++ b/packages/modules/api-key/jest.config.js @@ -1,22 +1,9 @@ -module.exports = { +const defineJestConfig = require("../../../define_jest_config") +module.exports = defineJestConfig({ moduleNameMapper: { "^@models": "/src/models", "^@services": "/src/services", "^@repositories": "/src/repositories", "^@types": "/src/types", }, - transform: { - "^.+\\.[jt]s$": [ - "@swc/jest", - { - jsc: { - parser: { syntax: "typescript", decorators: true }, - transform: { decoratorMetadata: true }, - }, - }, - ], - }, - testEnvironment: `node`, - moduleFileExtensions: [`js`, `ts`], - modulePathIgnorePatterns: ["dist/"], -} +}) diff --git a/packages/modules/api-key/package.json b/packages/modules/api-key/package.json index dc8a885b17..d11ce37d0f 100644 --- a/packages/modules/api-key/package.json +++ b/packages/modules/api-key/package.json @@ -5,7 +5,10 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "files": [ - "dist" + "dist", + "!dist/**/__tests__", + "!dist/**/__mocks__", + "!dist/**/__fixtures__" ], "engines": { "node": ">=20" @@ -23,7 +26,8 @@ "scripts": { "watch": "tsc --build --watch", "watch:test": "tsc --build tsconfig.spec.json --watch", - "build": "rimraf dist && tsc --build && tsc-alias -p tsconfig.json", + "resolve:aliases": "tsc --showConfig -p tsconfig.json > tsconfig.resolved.json && tsc-alias -p tsconfig.resolved.json && rimraf tsconfig.resolved.json", + "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --runInBand --bail --forceExit -- src/**/__tests__/**/*.ts", "test:integration": "jest --forceExit -- integration-tests/**/__tests__/**/*.ts", "migration:generate": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:generate", @@ -40,7 +44,7 @@ "rimraf": "^3.0.2", "ts-node": "^10.9.1", "tsc-alias": "^1.8.6", - "typescript": "^5.1.6" + "typescript": "^5.6.2" }, "dependencies": { "@medusajs/utils": "^1.11.9" diff --git a/packages/modules/api-key/tsconfig.json b/packages/modules/api-key/tsconfig.json index 78342ef37b..aca419d340 100644 --- a/packages/modules/api-key/tsconfig.json +++ b/packages/modules/api-key/tsconfig.json @@ -1,38 +1,11 @@ { + "extends": "../../../_tsconfig.base.json", "compilerOptions": { - "lib": ["es2021"], - "target": "es2021", - "outDir": "./dist", - "esModuleInterop": true, - "declarationMap": true, - "declaration": true, - "module": "commonjs", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "sourceMap": false, - "noImplicitReturns": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "noImplicitThis": true, - "allowJs": true, - "skipLibCheck": true, - "downlevelIteration": true, // to use ES5 specific tooling - "baseUrl": ".", - "resolveJsonModule": true, "paths": { "@models": ["./src/models"], "@services": ["./src/services"], "@repositories": ["./src/repositories"], "@types": ["./src/types"] } - }, - "include": ["src"], - "exclude": [ - "dist", - "./src/**/__tests__", - "./src/**/__mocks__", - "./src/**/__fixtures__", - "node_modules" - ] + } } diff --git a/packages/modules/api-key/tsconfig.spec.json b/packages/modules/api-key/tsconfig.spec.json deleted file mode 100644 index 48e47e8cbb..0000000000 --- a/packages/modules/api-key/tsconfig.spec.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": ["src", "integration-tests"], - "exclude": ["node_modules", "dist"], - "compilerOptions": { - "sourceMap": true - } -} diff --git a/packages/modules/auth/jest.config.js b/packages/modules/auth/jest.config.js index d125300e58..e40a4f9eaa 100644 --- a/packages/modules/auth/jest.config.js +++ b/packages/modules/auth/jest.config.js @@ -1,22 +1,9 @@ -module.exports = { +const defineJestConfig = require("../../../define_jest_config") +module.exports = defineJestConfig({ moduleNameMapper: { "^@models": "/src/models", "^@services": "/src/services", "^@repositories": "/src/repositories", "^@types": "/src/types", }, - transform: { - "^.+\\.[jt]s$": [ - "@swc/jest", - { - jsc: { - parser: { syntax: "typescript", decorators: true }, - transform: { decoratorMetadata: true }, - }, - }, - ], - }, - testEnvironment: `node`, - moduleFileExtensions: [`js`, `ts`], - modulePathIgnorePatterns: ["dist/"], -} +}) diff --git a/packages/modules/auth/package.json b/packages/modules/auth/package.json index 580f6ce284..8deeb51baa 100644 --- a/packages/modules/auth/package.json +++ b/packages/modules/auth/package.json @@ -5,7 +5,10 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "files": [ - "dist" + "dist", + "!dist/**/__tests__", + "!dist/**/__mocks__", + "!dist/**/__fixtures__" ], "engines": { "node": ">=20" @@ -23,7 +26,8 @@ "scripts": { "watch": "tsc --build --watch", "watch:test": "tsc --build tsconfig.spec.json --watch", - "build": "rimraf dist && tsc --build && tsc-alias -p tsconfig.json", + "resolve:aliases": "tsc --showConfig -p tsconfig.json > tsconfig.resolved.json && tsc-alias -p tsconfig.resolved.json && rimraf tsconfig.resolved.json", + "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --runInBand --bail --passWithNoTests --forceExit -- src", "test:integration": "jest --forceExit -- integration-tests/**/__tests__/**/*.ts", "migration:generate": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:generate", @@ -40,7 +44,7 @@ "medusa-test-utils": "^1.1.42", "rimraf": "^3.0.2", "tsc-alias": "^1.8.6", - "typescript": "^5.1.6" + "typescript": "^5.6.2" }, "dependencies": { "@medusajs/modules-sdk": "^1.12.11", diff --git a/packages/modules/auth/tsconfig.json b/packages/modules/auth/tsconfig.json index e97f654a8c..aca419d340 100644 --- a/packages/modules/auth/tsconfig.json +++ b/packages/modules/auth/tsconfig.json @@ -1,39 +1,11 @@ { + "extends": "../../../_tsconfig.base.json", "compilerOptions": { - "lib": ["es2021"], - "target": "es2021", - "outDir": "./dist", - "esModuleInterop": true, - "declarationMap": true, - "declaration": true, - "module": "commonjs", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "sourceMap": false, - "noImplicitReturns": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "noImplicitThis": true, - "allowJs": true, - "skipLibCheck": true, - "downlevelIteration": true, - // to use ES5 specific tooling - "baseUrl": ".", - "resolveJsonModule": true, "paths": { "@models": ["./src/models"], "@services": ["./src/services"], "@repositories": ["./src/repositories"], "@types": ["./src/types"] } - }, - "include": ["src"], - "exclude": [ - "dist", - "./src/**/__tests__", - "./src/**/__mocks__", - "./src/**/__fixtures__", - "node_modules" - ] + } } diff --git a/packages/modules/auth/tsconfig.spec.json b/packages/modules/auth/tsconfig.spec.json deleted file mode 100644 index 48e47e8cbb..0000000000 --- a/packages/modules/auth/tsconfig.spec.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": ["src", "integration-tests"], - "exclude": ["node_modules", "dist"], - "compilerOptions": { - "sourceMap": true - } -} diff --git a/packages/modules/cache-inmemory/jest.config.js b/packages/modules/cache-inmemory/jest.config.js index 3671181174..5744e175b0 100644 --- a/packages/modules/cache-inmemory/jest.config.js +++ b/packages/modules/cache-inmemory/jest.config.js @@ -1,15 +1,2 @@ -module.exports = { - transform: { - "^.+\\.[jt]s$": [ - "@swc/jest", - { - jsc: { - parser: { syntax: "typescript", decorators: true }, - transform: { decoratorMetadata: true }, - }, - }, - ], - }, - testEnvironment: `node`, - moduleFileExtensions: [`js`, `ts`], -} +const defineJestConfig = require("../../../define_jest_config") +module.exports = defineJestConfig({}) diff --git a/packages/modules/cache-inmemory/package.json b/packages/modules/cache-inmemory/package.json index 9d610b0d81..34c35b281c 100644 --- a/packages/modules/cache-inmemory/package.json +++ b/packages/modules/cache-inmemory/package.json @@ -15,7 +15,10 @@ "access": "public" }, "files": [ - "dist" + "dist", + "!dist/**/__tests__", + "!dist/**/__mocks__", + "!dist/**/__fixtures__" ], "author": "Medusa", "license": "MIT", @@ -24,7 +27,7 @@ "cross-env": "^5.2.1", "jest": "^29.7.0", "rimraf": "^5.0.1", - "typescript": "^5.1.6" + "typescript": "^5.6.2" }, "scripts": { "watch": "tsc --build --watch", diff --git a/packages/modules/cache-inmemory/tsconfig.json b/packages/modules/cache-inmemory/tsconfig.json index b3501c5fd6..f9a18581b3 100644 --- a/packages/modules/cache-inmemory/tsconfig.json +++ b/packages/modules/cache-inmemory/tsconfig.json @@ -1,30 +1,3 @@ { - "compilerOptions": { - "lib": ["es2021"], - "target": "es2021", - "outDir": "./dist", - "esModuleInterop": true, - "declarationMap": true, - "declaration": true, - "module": "commonjs", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "sourceMap": true, - "noImplicitReturns": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "noImplicitThis": true, - "allowJs": true, - "skipLibCheck": true, - "downlevelIteration": true // to use ES5 specific tooling - }, - "include": ["src"], - "exclude": [ - "dist", - "./src/**/__tests__", - "./src/**/__mocks__", - "./src/**/__fixtures__", - "node_modules" - ] + "extends": "../../../_tsconfig.base.json" } diff --git a/packages/modules/cache-inmemory/tsconfig.spec.json b/packages/modules/cache-inmemory/tsconfig.spec.json deleted file mode 100644 index 46adcc61f4..0000000000 --- a/packages/modules/cache-inmemory/tsconfig.spec.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": ["src", "integration-tests"], - "exclude": ["node_modules"] -} diff --git a/packages/modules/cache-redis/jest.config.js b/packages/modules/cache-redis/jest.config.js index 3671181174..5744e175b0 100644 --- a/packages/modules/cache-redis/jest.config.js +++ b/packages/modules/cache-redis/jest.config.js @@ -1,15 +1,2 @@ -module.exports = { - transform: { - "^.+\\.[jt]s$": [ - "@swc/jest", - { - jsc: { - parser: { syntax: "typescript", decorators: true }, - transform: { decoratorMetadata: true }, - }, - }, - ], - }, - testEnvironment: `node`, - moduleFileExtensions: [`js`, `ts`], -} +const defineJestConfig = require("../../../define_jest_config") +module.exports = defineJestConfig({}) diff --git a/packages/modules/cache-redis/package.json b/packages/modules/cache-redis/package.json index 70d629e74e..92852ed603 100644 --- a/packages/modules/cache-redis/package.json +++ b/packages/modules/cache-redis/package.json @@ -15,7 +15,10 @@ "node": ">=20" }, "files": [ - "dist" + "dist", + "!dist/**/__tests__", + "!dist/**/__mocks__", + "!dist/**/__fixtures__" ], "author": "Medusa", "license": "MIT", @@ -24,7 +27,7 @@ "cross-env": "^5.2.1", "jest": "^29.7.0", "rimraf": "^5.0.1", - "typescript": "^5.1.6" + "typescript": "^5.6.2" }, "scripts": { "watch": "tsc --build --watch", diff --git a/packages/modules/cache-redis/tsconfig.json b/packages/modules/cache-redis/tsconfig.json index b3501c5fd6..f9a18581b3 100644 --- a/packages/modules/cache-redis/tsconfig.json +++ b/packages/modules/cache-redis/tsconfig.json @@ -1,30 +1,3 @@ { - "compilerOptions": { - "lib": ["es2021"], - "target": "es2021", - "outDir": "./dist", - "esModuleInterop": true, - "declarationMap": true, - "declaration": true, - "module": "commonjs", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "sourceMap": true, - "noImplicitReturns": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "noImplicitThis": true, - "allowJs": true, - "skipLibCheck": true, - "downlevelIteration": true // to use ES5 specific tooling - }, - "include": ["src"], - "exclude": [ - "dist", - "./src/**/__tests__", - "./src/**/__mocks__", - "./src/**/__fixtures__", - "node_modules" - ] + "extends": "../../../_tsconfig.base.json" } diff --git a/packages/modules/cache-redis/tsconfig.spec.json b/packages/modules/cache-redis/tsconfig.spec.json deleted file mode 100644 index 9b62409191..0000000000 --- a/packages/modules/cache-redis/tsconfig.spec.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": ["src"], - "exclude": ["node_modules"] -} diff --git a/packages/modules/cart/jest.config.js b/packages/modules/cart/jest.config.js index 6af2cd1a96..e40a4f9eaa 100644 --- a/packages/modules/cart/jest.config.js +++ b/packages/modules/cart/jest.config.js @@ -1,23 +1,9 @@ -module.exports = { +const defineJestConfig = require("../../../define_jest_config") +module.exports = defineJestConfig({ moduleNameMapper: { "^@models": "/src/models", "^@services": "/src/services", "^@repositories": "/src/repositories", "^@types": "/src/types", - "^@utils": "/src/utils", }, - transform: { - "^.+\\.[jt]s$": [ - "@swc/jest", - { - jsc: { - parser: { syntax: "typescript", decorators: true }, - transform: { decoratorMetadata: true }, - }, - }, - ], - }, - testEnvironment: `node`, - moduleFileExtensions: [`js`, `ts`], - modulePathIgnorePatterns: ["dist/"], -} +}) diff --git a/packages/modules/cart/package.json b/packages/modules/cart/package.json index 3dd6efbfa1..856458d233 100644 --- a/packages/modules/cart/package.json +++ b/packages/modules/cart/package.json @@ -5,7 +5,10 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "files": [ - "dist" + "dist", + "!dist/**/__tests__", + "!dist/**/__mocks__", + "!dist/**/__fixtures__" ], "engines": { "node": ">=20" @@ -23,7 +26,8 @@ "scripts": { "watch": "tsc --build --watch", "watch:test": "tsc --build tsconfig.spec.json --watch", - "build": "rimraf dist && tsc --build && tsc-alias -p tsconfig.json", + "resolve:aliases": "tsc --showConfig -p tsconfig.json > tsconfig.resolved.json && tsc-alias -p tsconfig.resolved.json && rimraf tsconfig.resolved.json", + "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --runInBand --bail --passWithNoTests --forceExit -- src", "test:integration": "jest --forceExit -- integration-tests/**/__tests__/**/*.ts", "migration:generate": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:generate", @@ -41,7 +45,7 @@ "rimraf": "^3.0.2", "ts-node": "^10.9.1", "tsc-alias": "^1.8.6", - "typescript": "^5.1.6" + "typescript": "^5.6.2" }, "dependencies": { "@medusajs/utils": "^1.11.9" diff --git a/packages/modules/cart/src/models/address.ts b/packages/modules/cart/src/models/address.ts index 662b31768e..c73d1899f6 100644 --- a/packages/modules/cart/src/models/address.ts +++ b/packages/modules/cart/src/models/address.ts @@ -16,6 +16,12 @@ import { type OptionalAddressProps = DAL.SoftDeletableModelDateColumns +const PgIndex = createPsqlIndexStatementHelper({ + tableName: "cart_address", + columns: "deleted_at", + where: "deleted_at IS NOT NULL", +}) + @Entity({ tableName: "cart_address" }) @Filter(DALUtils.mikroOrmSoftDeletableFilterOptions) export default class Address { @@ -75,11 +81,7 @@ export default class Address { }) updated_at: Date - @createPsqlIndexStatementHelper({ - tableName: "cart_address", - columns: "deleted_at", - where: "deleted_at IS NOT NULL", - }).MikroORMIndex() + @PgIndex.MikroORMIndex() @Property({ columnType: "timestamptz", nullable: true }) deleted_at: Date | null = null diff --git a/packages/modules/cart/tsconfig.json b/packages/modules/cart/tsconfig.json index 78342ef37b..aca419d340 100644 --- a/packages/modules/cart/tsconfig.json +++ b/packages/modules/cart/tsconfig.json @@ -1,38 +1,11 @@ { + "extends": "../../../_tsconfig.base.json", "compilerOptions": { - "lib": ["es2021"], - "target": "es2021", - "outDir": "./dist", - "esModuleInterop": true, - "declarationMap": true, - "declaration": true, - "module": "commonjs", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "sourceMap": false, - "noImplicitReturns": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "noImplicitThis": true, - "allowJs": true, - "skipLibCheck": true, - "downlevelIteration": true, // to use ES5 specific tooling - "baseUrl": ".", - "resolveJsonModule": true, "paths": { "@models": ["./src/models"], "@services": ["./src/services"], "@repositories": ["./src/repositories"], "@types": ["./src/types"] } - }, - "include": ["src"], - "exclude": [ - "dist", - "./src/**/__tests__", - "./src/**/__mocks__", - "./src/**/__fixtures__", - "node_modules" - ] + } } diff --git a/packages/modules/cart/tsconfig.spec.json b/packages/modules/cart/tsconfig.spec.json deleted file mode 100644 index 48e47e8cbb..0000000000 --- a/packages/modules/cart/tsconfig.spec.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": ["src", "integration-tests"], - "exclude": ["node_modules", "dist"], - "compilerOptions": { - "sourceMap": true - } -} diff --git a/packages/modules/currency/jest.config.js b/packages/modules/currency/jest.config.js index d125300e58..e40a4f9eaa 100644 --- a/packages/modules/currency/jest.config.js +++ b/packages/modules/currency/jest.config.js @@ -1,22 +1,9 @@ -module.exports = { +const defineJestConfig = require("../../../define_jest_config") +module.exports = defineJestConfig({ moduleNameMapper: { "^@models": "/src/models", "^@services": "/src/services", "^@repositories": "/src/repositories", "^@types": "/src/types", }, - transform: { - "^.+\\.[jt]s$": [ - "@swc/jest", - { - jsc: { - parser: { syntax: "typescript", decorators: true }, - transform: { decoratorMetadata: true }, - }, - }, - ], - }, - testEnvironment: `node`, - moduleFileExtensions: [`js`, `ts`], - modulePathIgnorePatterns: ["dist/"], -} +}) diff --git a/packages/modules/currency/package.json b/packages/modules/currency/package.json index 05d5fb7ec6..1f4e4cdc6a 100644 --- a/packages/modules/currency/package.json +++ b/packages/modules/currency/package.json @@ -5,7 +5,10 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "files": [ - "dist" + "dist", + "!dist/**/__tests__", + "!dist/**/__mocks__", + "!dist/**/__fixtures__" ], "engines": { "node": ">=20" @@ -23,7 +26,8 @@ "scripts": { "watch": "tsc --build --watch", "watch:test": "tsc --build tsconfig.spec.json --watch", - "build": "rimraf dist && tsc --build && tsc-alias -p tsconfig.json", + "resolve:aliases": "tsc --showConfig -p tsconfig.json > tsconfig.resolved.json && tsc-alias -p tsconfig.resolved.json && rimraf tsconfig.resolved.json", + "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --runInBand --bail --forceExit -- src/**/__tests__/**/*.ts", "test:integration": "jest --forceExit -- integration-tests/**/__tests__/**/*.ts", "migration:generate": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:generate", @@ -41,7 +45,7 @@ "rimraf": "^3.0.2", "ts-node": "^10.9.1", "tsc-alias": "^1.8.6", - "typescript": "^5.1.6" + "typescript": "^5.6.2" }, "dependencies": { "@medusajs/utils": "^1.11.9" diff --git a/packages/modules/currency/tsconfig.json b/packages/modules/currency/tsconfig.json index 78342ef37b..aca419d340 100644 --- a/packages/modules/currency/tsconfig.json +++ b/packages/modules/currency/tsconfig.json @@ -1,38 +1,11 @@ { + "extends": "../../../_tsconfig.base.json", "compilerOptions": { - "lib": ["es2021"], - "target": "es2021", - "outDir": "./dist", - "esModuleInterop": true, - "declarationMap": true, - "declaration": true, - "module": "commonjs", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "sourceMap": false, - "noImplicitReturns": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "noImplicitThis": true, - "allowJs": true, - "skipLibCheck": true, - "downlevelIteration": true, // to use ES5 specific tooling - "baseUrl": ".", - "resolveJsonModule": true, "paths": { "@models": ["./src/models"], "@services": ["./src/services"], "@repositories": ["./src/repositories"], "@types": ["./src/types"] } - }, - "include": ["src"], - "exclude": [ - "dist", - "./src/**/__tests__", - "./src/**/__mocks__", - "./src/**/__fixtures__", - "node_modules" - ] + } } diff --git a/packages/modules/currency/tsconfig.spec.json b/packages/modules/currency/tsconfig.spec.json deleted file mode 100644 index 48e47e8cbb..0000000000 --- a/packages/modules/currency/tsconfig.spec.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": ["src", "integration-tests"], - "exclude": ["node_modules", "dist"], - "compilerOptions": { - "sourceMap": true - } -} diff --git a/packages/modules/customer/jest.config.js b/packages/modules/customer/jest.config.js index 2d7abe1f6e..e40a4f9eaa 100644 --- a/packages/modules/customer/jest.config.js +++ b/packages/modules/customer/jest.config.js @@ -1,21 +1,9 @@ -module.exports = { +const defineJestConfig = require("../../../define_jest_config") +module.exports = defineJestConfig({ moduleNameMapper: { "^@models": "/src/models", "^@services": "/src/services", "^@repositories": "/src/repositories", + "^@types": "/src/types", }, - transform: { - "^.+\\.[jt]s$": [ - "@swc/jest", - { - jsc: { - parser: { syntax: "typescript", decorators: true }, - transform: { decoratorMetadata: true }, - }, - }, - ], - }, - testEnvironment: `node`, - moduleFileExtensions: [`js`, `ts`], - modulePathIgnorePatterns: ["dist/"], -} +}) diff --git a/packages/modules/customer/package.json b/packages/modules/customer/package.json index 42cd56e523..3a2d2daf54 100644 --- a/packages/modules/customer/package.json +++ b/packages/modules/customer/package.json @@ -5,7 +5,10 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "files": [ - "dist" + "dist", + "!dist/**/__tests__", + "!dist/**/__mocks__", + "!dist/**/__fixtures__" ], "engines": { "node": ">=20" @@ -23,7 +26,8 @@ "scripts": { "watch": "tsc --build --watch", "watch:test": "tsc --build tsconfig.spec.json --watch", - "build": "rimraf dist && tsc --build && tsc-alias -p tsconfig.json", + "resolve:aliases": "tsc --showConfig -p tsconfig.json > tsconfig.resolved.json && tsc-alias -p tsconfig.resolved.json && rimraf tsconfig.resolved.json", + "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --runInBand --bail --passWithNoTests --forceExit -- src", "test:integration": "jest --forceExit -- integration-tests/**/__tests__/**/*.ts", "migration:generate": "MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:generate", @@ -41,7 +45,7 @@ "rimraf": "^3.0.2", "ts-node": "^10.9.1", "tsc-alias": "^1.8.6", - "typescript": "^5.1.6" + "typescript": "^5.6.2" }, "dependencies": { "@medusajs/utils": "^1.11.9" diff --git a/packages/modules/customer/tsconfig.json b/packages/modules/customer/tsconfig.json index 78342ef37b..aca419d340 100644 --- a/packages/modules/customer/tsconfig.json +++ b/packages/modules/customer/tsconfig.json @@ -1,38 +1,11 @@ { + "extends": "../../../_tsconfig.base.json", "compilerOptions": { - "lib": ["es2021"], - "target": "es2021", - "outDir": "./dist", - "esModuleInterop": true, - "declarationMap": true, - "declaration": true, - "module": "commonjs", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "sourceMap": false, - "noImplicitReturns": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "noImplicitThis": true, - "allowJs": true, - "skipLibCheck": true, - "downlevelIteration": true, // to use ES5 specific tooling - "baseUrl": ".", - "resolveJsonModule": true, "paths": { "@models": ["./src/models"], "@services": ["./src/services"], "@repositories": ["./src/repositories"], "@types": ["./src/types"] } - }, - "include": ["src"], - "exclude": [ - "dist", - "./src/**/__tests__", - "./src/**/__mocks__", - "./src/**/__fixtures__", - "node_modules" - ] + } } diff --git a/packages/modules/customer/tsconfig.spec.json b/packages/modules/customer/tsconfig.spec.json deleted file mode 100644 index 48e47e8cbb..0000000000 --- a/packages/modules/customer/tsconfig.spec.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": ["src", "integration-tests"], - "exclude": ["node_modules", "dist"], - "compilerOptions": { - "sourceMap": true - } -} diff --git a/packages/modules/event-bus-local/jest.config.js b/packages/modules/event-bus-local/jest.config.js index 3671181174..5744e175b0 100644 --- a/packages/modules/event-bus-local/jest.config.js +++ b/packages/modules/event-bus-local/jest.config.js @@ -1,15 +1,2 @@ -module.exports = { - transform: { - "^.+\\.[jt]s$": [ - "@swc/jest", - { - jsc: { - parser: { syntax: "typescript", decorators: true }, - transform: { decoratorMetadata: true }, - }, - }, - ], - }, - testEnvironment: `node`, - moduleFileExtensions: [`js`, `ts`], -} +const defineJestConfig = require("../../../define_jest_config") +module.exports = defineJestConfig({}) diff --git a/packages/modules/event-bus-local/package.json b/packages/modules/event-bus-local/package.json index 5ca1c02765..426b06d688 100644 --- a/packages/modules/event-bus-local/package.json +++ b/packages/modules/event-bus-local/package.json @@ -4,7 +4,10 @@ "description": "Local Event Bus Module for Medusa", "main": "dist/index.js", "files": [ - "dist" + "dist", + "!dist/**/__tests__", + "!dist/**/__mocks__", + "!dist/**/__fixtures__" ], "repository": { "type": "git", @@ -24,7 +27,7 @@ "cross-env": "^5.2.1", "jest": "^29.7.0", "rimraf": "^5.0.1", - "typescript": "^5.1.6" + "typescript": "^5.6.2" }, "scripts": { "watch": "tsc --build --watch", diff --git a/packages/modules/event-bus-local/tsconfig.json b/packages/modules/event-bus-local/tsconfig.json index b3501c5fd6..f9a18581b3 100644 --- a/packages/modules/event-bus-local/tsconfig.json +++ b/packages/modules/event-bus-local/tsconfig.json @@ -1,30 +1,3 @@ { - "compilerOptions": { - "lib": ["es2021"], - "target": "es2021", - "outDir": "./dist", - "esModuleInterop": true, - "declarationMap": true, - "declaration": true, - "module": "commonjs", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "sourceMap": true, - "noImplicitReturns": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "noImplicitThis": true, - "allowJs": true, - "skipLibCheck": true, - "downlevelIteration": true // to use ES5 specific tooling - }, - "include": ["src"], - "exclude": [ - "dist", - "./src/**/__tests__", - "./src/**/__mocks__", - "./src/**/__fixtures__", - "node_modules" - ] + "extends": "../../../_tsconfig.base.json" } diff --git a/packages/modules/event-bus-local/tsconfig.spec.json b/packages/modules/event-bus-local/tsconfig.spec.json deleted file mode 100644 index 9b62409191..0000000000 --- a/packages/modules/event-bus-local/tsconfig.spec.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": ["src"], - "exclude": ["node_modules"] -} diff --git a/packages/modules/event-bus-redis/jest.config.js b/packages/modules/event-bus-redis/jest.config.js index 3671181174..5744e175b0 100644 --- a/packages/modules/event-bus-redis/jest.config.js +++ b/packages/modules/event-bus-redis/jest.config.js @@ -1,15 +1,2 @@ -module.exports = { - transform: { - "^.+\\.[jt]s$": [ - "@swc/jest", - { - jsc: { - parser: { syntax: "typescript", decorators: true }, - transform: { decoratorMetadata: true }, - }, - }, - ], - }, - testEnvironment: `node`, - moduleFileExtensions: [`js`, `ts`], -} +const defineJestConfig = require("../../../define_jest_config") +module.exports = defineJestConfig({}) diff --git a/packages/modules/event-bus-redis/package.json b/packages/modules/event-bus-redis/package.json index 5c7056b4bf..034c028e04 100644 --- a/packages/modules/event-bus-redis/package.json +++ b/packages/modules/event-bus-redis/package.json @@ -4,7 +4,10 @@ "description": "Redis Event Bus Module for Medusa", "main": "dist/index.js", "files": [ - "dist" + "dist", + "!dist/**/__tests__", + "!dist/**/__mocks__", + "!dist/**/__fixtures__" ], "repository": { "type": "git", @@ -25,7 +28,7 @@ "jest": "^29.7.0", "medusa-test-utils": "^1.1.44", "rimraf": "^5.0.1", - "typescript": "^5.1.6" + "typescript": "^5.6.2" }, "scripts": { "watch": "tsc --build --watch", diff --git a/packages/modules/event-bus-redis/src/services/__tests__/event-bus.ts b/packages/modules/event-bus-redis/src/services/__tests__/event-bus.ts index b9a0851cb9..c63a44c153 100644 --- a/packages/modules/event-bus-redis/src/services/__tests__/event-bus.ts +++ b/packages/modules/event-bus-redis/src/services/__tests__/event-bus.ts @@ -339,8 +339,6 @@ describe("RedisEventBusService", () => { }) describe("worker_", () => { - let result!: any - describe("Successfully processes the jobs", () => { beforeEach(async () => { jest.clearAllMocks() @@ -395,7 +393,7 @@ describe("RedisEventBusService", () => { return Promise.reject("fail2") }) - result = await eventBus.worker_({ + await eventBus.worker_({ name: "eventName", data: { data: { test: 1 } }, opts: { attempts: 1 }, @@ -434,7 +432,7 @@ describe("RedisEventBusService", () => { } ) - result = await eventBus + await eventBus .worker_({ name: "eventName", data: { @@ -473,7 +471,7 @@ describe("RedisEventBusService", () => { } ) - result = await eventBus + await eventBus .worker_({ name: "eventName", data: { diff --git a/packages/modules/event-bus-redis/tsconfig.json b/packages/modules/event-bus-redis/tsconfig.json index b3501c5fd6..f9a18581b3 100644 --- a/packages/modules/event-bus-redis/tsconfig.json +++ b/packages/modules/event-bus-redis/tsconfig.json @@ -1,30 +1,3 @@ { - "compilerOptions": { - "lib": ["es2021"], - "target": "es2021", - "outDir": "./dist", - "esModuleInterop": true, - "declarationMap": true, - "declaration": true, - "module": "commonjs", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "sourceMap": true, - "noImplicitReturns": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "noImplicitThis": true, - "allowJs": true, - "skipLibCheck": true, - "downlevelIteration": true // to use ES5 specific tooling - }, - "include": ["src"], - "exclude": [ - "dist", - "./src/**/__tests__", - "./src/**/__mocks__", - "./src/**/__fixtures__", - "node_modules" - ] + "extends": "../../../_tsconfig.base.json" } diff --git a/packages/modules/event-bus-redis/tsconfig.spec.json b/packages/modules/event-bus-redis/tsconfig.spec.json deleted file mode 100644 index 9b62409191..0000000000 --- a/packages/modules/event-bus-redis/tsconfig.spec.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": ["src"], - "exclude": ["node_modules"] -} diff --git a/packages/modules/file/jest.config.js b/packages/modules/file/jest.config.js index d125300e58..e40a4f9eaa 100644 --- a/packages/modules/file/jest.config.js +++ b/packages/modules/file/jest.config.js @@ -1,22 +1,9 @@ -module.exports = { +const defineJestConfig = require("../../../define_jest_config") +module.exports = defineJestConfig({ moduleNameMapper: { "^@models": "/src/models", "^@services": "/src/services", "^@repositories": "/src/repositories", "^@types": "/src/types", }, - transform: { - "^.+\\.[jt]s$": [ - "@swc/jest", - { - jsc: { - parser: { syntax: "typescript", decorators: true }, - transform: { decoratorMetadata: true }, - }, - }, - ], - }, - testEnvironment: `node`, - moduleFileExtensions: [`js`, `ts`], - modulePathIgnorePatterns: ["dist/"], -} +}) diff --git a/packages/modules/file/package.json b/packages/modules/file/package.json index dab721ebf3..5712a55875 100644 --- a/packages/modules/file/package.json +++ b/packages/modules/file/package.json @@ -5,7 +5,10 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "files": [ - "dist" + "dist", + "!dist/**/__tests__", + "!dist/**/__mocks__", + "!dist/**/__fixtures__" ], "engines": { "node": ">=20" @@ -23,7 +26,8 @@ "scripts": { "watch": "tsc --build --watch", "watch:test": "tsc --build tsconfig.spec.json --watch", - "build": "rimraf dist && tsc --build && tsc-alias -p tsconfig.json", + "resolve:aliases": "tsc --showConfig -p tsconfig.json > tsconfig.resolved.json && tsc-alias -p tsconfig.resolved.json && rimraf tsconfig.resolved.json", + "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --passWithNoTests --runInBand --bail --forceExit -- src/**/__tests__/**/*.ts", "test:integration": "jest --passWithNoTests --forceExit -- integration-tests/**/__tests__/**/*.ts", "migration:generate": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:generate", @@ -43,7 +47,7 @@ "rimraf": "^3.0.2", "ts-node": "^10.9.1", "tsc-alias": "^1.8.6", - "typescript": "^5.1.6" + "typescript": "^5.6.2" }, "dependencies": { "@medusajs/modules-sdk": "^1.12.11", diff --git a/packages/modules/file/tsconfig.json b/packages/modules/file/tsconfig.json index 78342ef37b..aca419d340 100644 --- a/packages/modules/file/tsconfig.json +++ b/packages/modules/file/tsconfig.json @@ -1,38 +1,11 @@ { + "extends": "../../../_tsconfig.base.json", "compilerOptions": { - "lib": ["es2021"], - "target": "es2021", - "outDir": "./dist", - "esModuleInterop": true, - "declarationMap": true, - "declaration": true, - "module": "commonjs", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "sourceMap": false, - "noImplicitReturns": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "noImplicitThis": true, - "allowJs": true, - "skipLibCheck": true, - "downlevelIteration": true, // to use ES5 specific tooling - "baseUrl": ".", - "resolveJsonModule": true, "paths": { "@models": ["./src/models"], "@services": ["./src/services"], "@repositories": ["./src/repositories"], "@types": ["./src/types"] } - }, - "include": ["src"], - "exclude": [ - "dist", - "./src/**/__tests__", - "./src/**/__mocks__", - "./src/**/__fixtures__", - "node_modules" - ] + } } diff --git a/packages/modules/file/tsconfig.spec.json b/packages/modules/file/tsconfig.spec.json deleted file mode 100644 index 48e47e8cbb..0000000000 --- a/packages/modules/file/tsconfig.spec.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": ["src", "integration-tests"], - "exclude": ["node_modules", "dist"], - "compilerOptions": { - "sourceMap": true - } -} diff --git a/packages/modules/fulfillment/jest.config.js b/packages/modules/fulfillment/jest.config.js index 96be4c5bbd..3aab9b7072 100644 --- a/packages/modules/fulfillment/jest.config.js +++ b/packages/modules/fulfillment/jest.config.js @@ -1,4 +1,5 @@ -module.exports = { +const defineJestConfig = require("../../../define_jest_config") +module.exports = defineJestConfig({ moduleNameMapper: { "^@models": "/src/models", "^@services": "/src/services", @@ -6,19 +7,4 @@ module.exports = { "^@types": "/src/types", "^@utils": "/src/utils", }, - transform: { - "^.+\\.[jt]s$": [ - "@swc/jest", - { - jsc: { - parser: { syntax: "typescript", decorators: true }, - transform: { decoratorMetadata: true }, - }, - }, - ], - }, - testEnvironment: `node`, - moduleFileExtensions: [`js`, `ts`], - modulePathIgnorePatterns: ["dist/"], - /*setupFilesAfterEnv: ["/integration-tests/setup.js"],*/ -} +}) diff --git a/packages/modules/fulfillment/package.json b/packages/modules/fulfillment/package.json index d5ece4686c..551f506c6e 100644 --- a/packages/modules/fulfillment/package.json +++ b/packages/modules/fulfillment/package.json @@ -5,7 +5,10 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "files": [ - "dist" + "dist", + "!dist/**/__tests__", + "!dist/**/__mocks__", + "!dist/**/__fixtures__" ], "engines": { "node": ">=20" @@ -23,7 +26,8 @@ "scripts": { "watch": "tsc --build --watch", "watch:test": "tsc --build tsconfig.spec.json --watch", - "build": "rimraf dist && tsc --build && tsc-alias -p tsconfig.json", + "resolve:aliases": "tsc --showConfig -p tsconfig.json > tsconfig.resolved.json && tsc-alias -p tsconfig.resolved.json && rimraf tsconfig.resolved.json", + "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --runInBand --bail --forceExit --passWithNoTests -- src", "test:integration": "jest --forceExit -- integration-tests/**/__tests__/**/*.spec.ts", "migration:generate": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:generate", @@ -42,7 +46,7 @@ "rimraf": "^3.0.2", "ts-node": "^10.9.1", "tsc-alias": "^1.8.6", - "typescript": "^5.1.6" + "typescript": "^5.6.2" }, "dependencies": { "@medusajs/modules-sdk": "^1.12.11", diff --git a/packages/modules/fulfillment/src/models/shipping-option-type.ts b/packages/modules/fulfillment/src/models/shipping-option-type.ts index b0b45e604a..cfe586d6f1 100644 --- a/packages/modules/fulfillment/src/models/shipping-option-type.ts +++ b/packages/modules/fulfillment/src/models/shipping-option-type.ts @@ -26,12 +26,6 @@ const DeletedAtIndex = createPsqlIndexStatementHelper({ where: "deleted_at IS NOT NULL", }) -const ShippingOptionIdIndex = createPsqlIndexStatementHelper({ - tableName: "shipping_option_type", - columns: "shipping_option_id", - where: "deleted_at IS NULL", -}) - @Entity() @Filter(DALUtils.mikroOrmSoftDeletableFilterOptions) export default class ShippingOptionType { diff --git a/packages/modules/fulfillment/tsconfig.json b/packages/modules/fulfillment/tsconfig.json index e3f64c5ff6..748a37ffa8 100644 --- a/packages/modules/fulfillment/tsconfig.json +++ b/packages/modules/fulfillment/tsconfig.json @@ -1,25 +1,6 @@ { + "extends": "../../../_tsconfig.base.json", "compilerOptions": { - "lib": ["es2021"], - "target": "es2021", - "outDir": "./dist", - "esModuleInterop": true, - "declarationMap": true, - "declaration": true, - "module": "commonjs", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "sourceMap": false, - "noImplicitReturns": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "noImplicitThis": true, - "allowJs": true, - "skipLibCheck": true, - "downlevelIteration": true, // to use ES5 specific tooling - "baseUrl": ".", - "resolveJsonModule": true, "paths": { "@models": ["./src/models"], "@services": ["./src/services"], @@ -27,13 +8,5 @@ "@types": ["./src/types"], "@utils": ["./src/utils"] } - }, - "include": ["src"], - "exclude": [ - "dist", - "./src/**/__tests__", - "./src/**/__mocks__", - "./src/**/__fixtures__", - "node_modules" - ] + } } diff --git a/packages/modules/fulfillment/tsconfig.spec.json b/packages/modules/fulfillment/tsconfig.spec.json deleted file mode 100644 index 48e47e8cbb..0000000000 --- a/packages/modules/fulfillment/tsconfig.spec.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": ["src", "integration-tests"], - "exclude": ["node_modules", "dist"], - "compilerOptions": { - "sourceMap": true - } -} diff --git a/packages/modules/index/jest.config.js b/packages/modules/index/jest.config.js index d125300e58..3aab9b7072 100644 --- a/packages/modules/index/jest.config.js +++ b/packages/modules/index/jest.config.js @@ -1,22 +1,10 @@ -module.exports = { +const defineJestConfig = require("../../../define_jest_config") +module.exports = defineJestConfig({ moduleNameMapper: { "^@models": "/src/models", "^@services": "/src/services", "^@repositories": "/src/repositories", "^@types": "/src/types", + "^@utils": "/src/utils", }, - transform: { - "^.+\\.[jt]s$": [ - "@swc/jest", - { - jsc: { - parser: { syntax: "typescript", decorators: true }, - transform: { decoratorMetadata: true }, - }, - }, - ], - }, - testEnvironment: `node`, - moduleFileExtensions: [`js`, `ts`], - modulePathIgnorePatterns: ["dist/"], -} +}) diff --git a/packages/modules/index/package.json b/packages/modules/index/package.json index 5d43ed7965..172be863ac 100644 --- a/packages/modules/index/package.json +++ b/packages/modules/index/package.json @@ -5,7 +5,10 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "files": [ - "dist" + "dist", + "!dist/**/__tests__", + "!dist/**/__mocks__", + "!dist/**/__fixtures__" ], "engines": { "node": ">=20" @@ -23,7 +26,8 @@ "scripts": { "watch": "tsc --build --watch", "watch:test": "tsc --build tsconfig.spec.json --watch", - "build": "rimraf dist && tsc -p ./tsconfig.spec.json --noEmit && tsc -p ./tsconfig.build.json && tsc-alias -p ./tsconfig.build.json", + "resolve:aliases": "tsc --showConfig -p tsconfig.json > tsconfig.resolved.json && tsc-alias -p tsconfig.resolved.json && rimraf tsconfig.resolved.json", + "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --passWithNoTests ./src", "test:integration": "jest --runInBand --forceExit -- integration-tests/**/__tests__/**/*.ts", "migration:generate": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:generate", @@ -41,7 +45,7 @@ "rimraf": "^3.0.2", "ts-node": "^10.9.1", "tsc-alias": "^1.8.6", - "typescript": "^5.1.6" + "typescript": "^5.6.2" }, "dependencies": { "@medusajs/utils": "^1.11.9" diff --git a/packages/modules/index/src/utils/query-builder.ts b/packages/modules/index/src/utils/query-builder.ts index e75c28eecb..a0f36e7f09 100644 --- a/packages/modules/index/src/utils/query-builder.ts +++ b/packages/modules/index/src/utils/query-builder.ts @@ -116,9 +116,7 @@ export class QueryBuilder { const isList = graphqlType.endsWith("[]") graphqlType = graphqlType.replace("[]", "") - return ( - (graphqlToPostgresTypeMap[graphqlType] ?? "") + (isList ? "[]" : "") ?? "" - ) + return (graphqlToPostgresTypeMap[graphqlType] ?? "") + (isList ? "[]" : "") } private parseWhere( diff --git a/packages/modules/index/tsconfig.build.json b/packages/modules/index/tsconfig.build.json deleted file mode 100644 index 0b60e58d9e..0000000000 --- a/packages/modules/index/tsconfig.build.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": ["src"], - "exclude": [ - "dist", - "src/**/__tests__", - "src/**/__mocks__", - "src/**/__fixtures__", - "node_modules" - ] -} diff --git a/packages/modules/index/tsconfig.json b/packages/modules/index/tsconfig.json index 3965587692..748a37ffa8 100644 --- a/packages/modules/index/tsconfig.json +++ b/packages/modules/index/tsconfig.json @@ -1,35 +1,12 @@ { + "extends": "../../../_tsconfig.base.json", "compilerOptions": { - "lib": ["es2021"], - "target": "es2021", - "outDir": "./dist", - "esModuleInterop": true, - "declarationMap": true, - "declaration": true, - "module": "commonjs", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "sourceMap": false, - "noImplicitReturns": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "noImplicitThis": true, - "allowJs": true, - "skipLibCheck": true, - "downlevelIteration": true, // to use ES5 specific tooling - "baseUrl": ".", - "resolveJsonModule": true, "paths": { "@models": ["./src/models"], "@services": ["./src/services"], "@repositories": ["./src/repositories"], - "@types": ["./src/types"] + "@types": ["./src/types"], + "@utils": ["./src/utils"] } - }, - "include": ["src"], - "exclude": [ - "dist", - "node_modules" - ], + } } diff --git a/packages/modules/index/tsconfig.spec.json b/packages/modules/index/tsconfig.spec.json deleted file mode 100644 index 48e47e8cbb..0000000000 --- a/packages/modules/index/tsconfig.spec.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": ["src", "integration-tests"], - "exclude": ["node_modules", "dist"], - "compilerOptions": { - "sourceMap": true - } -} diff --git a/packages/modules/inventory-next/jest.config.js b/packages/modules/inventory-next/jest.config.js index 397da4a234..3aab9b7072 100644 --- a/packages/modules/inventory-next/jest.config.js +++ b/packages/modules/inventory-next/jest.config.js @@ -1,21 +1,10 @@ -module.exports = { +const defineJestConfig = require("../../../define_jest_config") +module.exports = defineJestConfig({ moduleNameMapper: { "^@models": "/src/models", "^@services": "/src/services", "^@repositories": "/src/repositories", "^@types": "/src/types", + "^@utils": "/src/utils", }, - transform: { - "^.+\\.[jt]s$": [ - "@swc/jest", - { - jsc: { - parser: { syntax: "typescript", decorators: true }, - transform: { decoratorMetadata: true }, - }, - }, - ], - }, - testEnvironment: `node`, - moduleFileExtensions: [`js`, `ts`], -} +}) diff --git a/packages/modules/inventory-next/package.json b/packages/modules/inventory-next/package.json index b3c225d150..4874b3682c 100644 --- a/packages/modules/inventory-next/package.json +++ b/packages/modules/inventory-next/package.json @@ -12,7 +12,10 @@ "access": "public" }, "files": [ - "dist" + "dist", + "!dist/**/__tests__", + "!dist/**/__mocks__", + "!dist/**/__fixtures__" ], "engines": { "node": ">=20" @@ -28,7 +31,7 @@ "rimraf": "^5.0.1", "ts-node": "^10.9.1", "tsc-alias": "^1.8.6", - "typescript": "^5.1.6" + "typescript": "^5.6.2" }, "dependencies": { "@medusajs/utils": "^1.11.9" @@ -42,7 +45,8 @@ "scripts": { "watch": "tsc --build --watch", "watch:test": "tsc --build tsconfig.spec.json --watch", - "build": "rimraf dist && tsc --build && tsc-alias -p tsconfig.json", + "resolve:aliases": "tsc --showConfig -p tsconfig.json > tsconfig.resolved.json && tsc-alias -p tsconfig.resolved.json && rimraf tsconfig.resolved.json", + "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --runInBand --bail --forceExit -- src/**/__tests__/**/*.ts", "test:integration": "jest --runInBand --forceExit -- integration-tests/**/__tests__/**/*.spec.ts", "migration:generate": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:generate", diff --git a/packages/modules/inventory-next/src/models/inventory-item.ts b/packages/modules/inventory-next/src/models/inventory-item.ts index 1bb49d9103..05f4b41001 100644 --- a/packages/modules/inventory-next/src/models/inventory-item.ts +++ b/packages/modules/inventory-next/src/models/inventory-item.ts @@ -145,12 +145,12 @@ export class InventoryItem { stocked_quantity: number @BeforeCreate() - private beforeCreate(): void { + beforeCreate(): void { this.id = generateEntityId(this.id, "iitem") } @OnInit() - private onInit(): void { + onInit(): void { this.id = generateEntityId(this.id, "iitem") } } diff --git a/packages/modules/inventory-next/src/models/inventory-level.ts b/packages/modules/inventory-next/src/models/inventory-level.ts index 5169151bc0..c30f95792a 100644 --- a/packages/modules/inventory-next/src/models/inventory-level.ts +++ b/packages/modules/inventory-next/src/models/inventory-level.ts @@ -114,18 +114,18 @@ export class InventoryLevel { available_quantity: BigNumber | number | null = null @BeforeCreate() - private beforeCreate(): void { + beforeCreate(): void { this.id = generateEntityId(this.id, "ilev") this.inventory_item_id ??= this.inventory_item?.id } @OnInit() - private onInit(): void { + onInit(): void { this.id = generateEntityId(this.id, "ilev") } @OnLoad() - private onLoad(): void { + onLoad(): void { if (isDefined(this.stocked_quantity) && isDefined(this.reserved_quantity)) { this.available_quantity = new BigNumber( MathBN.sub(this.raw_stocked_quantity, this.raw_reserved_quantity) diff --git a/packages/modules/inventory-next/src/models/reservation-item.ts b/packages/modules/inventory-next/src/models/reservation-item.ts index e2961ec572..48f6aadca4 100644 --- a/packages/modules/inventory-next/src/models/reservation-item.ts +++ b/packages/modules/inventory-next/src/models/reservation-item.ts @@ -111,12 +111,12 @@ export class ReservationItem { inventory_item: Rel @BeforeCreate() - private beforeCreate(): void { + beforeCreate(): void { this.id = generateEntityId(this.id, "resitem") } @OnInit() - private onInit(): void { + onInit(): void { this.id = generateEntityId(this.id, "resitem") } } diff --git a/packages/modules/inventory-next/tsconfig.json b/packages/modules/inventory-next/tsconfig.json index e3f64c5ff6..748a37ffa8 100644 --- a/packages/modules/inventory-next/tsconfig.json +++ b/packages/modules/inventory-next/tsconfig.json @@ -1,25 +1,6 @@ { + "extends": "../../../_tsconfig.base.json", "compilerOptions": { - "lib": ["es2021"], - "target": "es2021", - "outDir": "./dist", - "esModuleInterop": true, - "declarationMap": true, - "declaration": true, - "module": "commonjs", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "sourceMap": false, - "noImplicitReturns": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "noImplicitThis": true, - "allowJs": true, - "skipLibCheck": true, - "downlevelIteration": true, // to use ES5 specific tooling - "baseUrl": ".", - "resolveJsonModule": true, "paths": { "@models": ["./src/models"], "@services": ["./src/services"], @@ -27,13 +8,5 @@ "@types": ["./src/types"], "@utils": ["./src/utils"] } - }, - "include": ["src"], - "exclude": [ - "dist", - "./src/**/__tests__", - "./src/**/__mocks__", - "./src/**/__fixtures__", - "node_modules" - ] + } } diff --git a/packages/modules/inventory-next/tsconfig.spec.json b/packages/modules/inventory-next/tsconfig.spec.json deleted file mode 100644 index 9b62409191..0000000000 --- a/packages/modules/inventory-next/tsconfig.spec.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": ["src"], - "exclude": ["node_modules"] -} diff --git a/packages/modules/link-modules/jest.config.js b/packages/modules/link-modules/jest.config.js index d125300e58..3aab9b7072 100644 --- a/packages/modules/link-modules/jest.config.js +++ b/packages/modules/link-modules/jest.config.js @@ -1,22 +1,10 @@ -module.exports = { +const defineJestConfig = require("../../../define_jest_config") +module.exports = defineJestConfig({ moduleNameMapper: { "^@models": "/src/models", "^@services": "/src/services", "^@repositories": "/src/repositories", "^@types": "/src/types", + "^@utils": "/src/utils", }, - transform: { - "^.+\\.[jt]s$": [ - "@swc/jest", - { - jsc: { - parser: { syntax: "typescript", decorators: true }, - transform: { decoratorMetadata: true }, - }, - }, - ], - }, - testEnvironment: `node`, - moduleFileExtensions: [`js`, `ts`], - modulePathIgnorePatterns: ["dist/"], -} +}) diff --git a/packages/modules/link-modules/package.json b/packages/modules/link-modules/package.json index 885acd1fc7..ac9a4f53fd 100644 --- a/packages/modules/link-modules/package.json +++ b/packages/modules/link-modules/package.json @@ -5,7 +5,10 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "files": [ - "dist" + "dist", + "!dist/**/__tests__", + "!dist/**/__mocks__", + "!dist/**/__fixtures__" ], "repository": { "type": "git", @@ -24,7 +27,8 @@ "watch": "tsc --build --watch", "watch:test": "tsc --build tsconfig.spec.json --watch", "prepare": "cross-env NODE_ENV=production yarn run build", - "build": "rimraf dist && tsc --build && tsc-alias -p tsconfig.json", + "resolve:aliases": "tsc --showConfig -p tsconfig.json > tsconfig.resolved.json && tsc-alias -p tsconfig.resolved.json && rimraf tsconfig.resolved.json", + "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --passWithNoTests --runInBand --bail --forceExit -- src", "test:integration": "jest --forceExit -- integration-tests/**/__tests__/**/*.ts" }, @@ -37,7 +41,7 @@ "rimraf": "^5.0.1", "ts-node": "^10.9.1", "tsc-alias": "^1.8.6", - "typescript": "^5.5.0" + "typescript": "^5.6.2" }, "dependencies": { "@medusajs/modules-sdk": "^1.12.11", diff --git a/packages/modules/link-modules/src/utils/generate-schema.ts b/packages/modules/link-modules/src/utils/generate-schema.ts index 4c642de6e8..d57846ee49 100644 --- a/packages/modules/link-modules/src/utils/generate-schema.ts +++ b/packages/modules/link-modules/src/utils/generate-schema.ts @@ -83,7 +83,7 @@ export function generateGraphQLSchema( ? extend.relationship.isList : config.isList ?? extend.relationship.isList - const pathSegments = path.split(",").reverse() + // const pathSegments = path.split(",").reverse() /*const relationshipMarkerIndex = pathSegments.findIndex((segment) => { return !!joinerConfig.relationships!.find( diff --git a/packages/modules/link-modules/tsconfig.json b/packages/modules/link-modules/tsconfig.json index 85e7daec7c..748a37ffa8 100644 --- a/packages/modules/link-modules/tsconfig.json +++ b/packages/modules/link-modules/tsconfig.json @@ -1,36 +1,12 @@ { + "extends": "../../../_tsconfig.base.json", "compilerOptions": { - "lib": ["es2021"], - "target": "es2021", - "outDir": "./dist", - "esModuleInterop": true, - "declarationMap": true, - "declaration": true, - "module": "commonjs", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "sourceMap": false, - "noImplicitReturns": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "noImplicitThis": true, - "allowJs": true, - "skipLibCheck": true, - "downlevelIteration": true, // to use ES5 specific tooling - "baseUrl": ".", - "resolveJsonModule": true, "paths": { + "@models": ["./src/models"], "@services": ["./src/services"], - "@repositories": ["./src/repositories"] + "@repositories": ["./src/repositories"], + "@types": ["./src/types"], + "@utils": ["./src/utils"] } - }, - "include": ["src"], - "exclude": [ - "dist", - "./src/**/__tests__", - "./src/**/__mocks__", - "./src/**/__fixtures__", - "node_modules" - ] + } } diff --git a/packages/modules/link-modules/tsconfig.spec.json b/packages/modules/link-modules/tsconfig.spec.json deleted file mode 100644 index b887bbfa39..0000000000 --- a/packages/modules/link-modules/tsconfig.spec.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": ["src", "integration-tests"], - "exclude": ["node_modules", "dist"] -} diff --git a/packages/modules/notification/jest.config.js b/packages/modules/notification/jest.config.js index 6af2cd1a96..3aab9b7072 100644 --- a/packages/modules/notification/jest.config.js +++ b/packages/modules/notification/jest.config.js @@ -1,4 +1,5 @@ -module.exports = { +const defineJestConfig = require("../../../define_jest_config") +module.exports = defineJestConfig({ moduleNameMapper: { "^@models": "/src/models", "^@services": "/src/services", @@ -6,18 +7,4 @@ module.exports = { "^@types": "/src/types", "^@utils": "/src/utils", }, - transform: { - "^.+\\.[jt]s$": [ - "@swc/jest", - { - jsc: { - parser: { syntax: "typescript", decorators: true }, - transform: { decoratorMetadata: true }, - }, - }, - ], - }, - testEnvironment: `node`, - moduleFileExtensions: [`js`, `ts`], - modulePathIgnorePatterns: ["dist/"], -} +}) diff --git a/packages/modules/notification/package.json b/packages/modules/notification/package.json index dcc53d821a..25e1ec2f60 100644 --- a/packages/modules/notification/package.json +++ b/packages/modules/notification/package.json @@ -5,7 +5,10 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "files": [ - "dist" + "dist", + "!dist/**/__tests__", + "!dist/**/__mocks__", + "!dist/**/__fixtures__" ], "engines": { "node": ">=20" @@ -23,7 +26,8 @@ "scripts": { "watch": "tsc --build --watch", "watch:test": "tsc --build tsconfig.spec.json --watch", - "build": "rimraf dist && tsc --build && tsc-alias -p tsconfig.json", + "resolve:aliases": "tsc --showConfig -p tsconfig.json > tsconfig.resolved.json && tsc-alias -p tsconfig.resolved.json && rimraf tsconfig.resolved.json", + "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --runInBand --bail --forceExit --passWithNoTests -- src", "test:integration": "jest --forceExit -- integration-tests/**/__tests__/**/*.spec.ts", "migration:generate": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:generate", @@ -41,7 +45,7 @@ "rimraf": "^3.0.2", "ts-node": "^10.9.1", "tsc-alias": "^1.8.6", - "typescript": "^5.1.6" + "typescript": "^5.6.2" }, "dependencies": { "@medusajs/modules-sdk": "^1.12.11", diff --git a/packages/modules/notification/tsconfig.json b/packages/modules/notification/tsconfig.json index e3f64c5ff6..748a37ffa8 100644 --- a/packages/modules/notification/tsconfig.json +++ b/packages/modules/notification/tsconfig.json @@ -1,25 +1,6 @@ { + "extends": "../../../_tsconfig.base.json", "compilerOptions": { - "lib": ["es2021"], - "target": "es2021", - "outDir": "./dist", - "esModuleInterop": true, - "declarationMap": true, - "declaration": true, - "module": "commonjs", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "sourceMap": false, - "noImplicitReturns": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "noImplicitThis": true, - "allowJs": true, - "skipLibCheck": true, - "downlevelIteration": true, // to use ES5 specific tooling - "baseUrl": ".", - "resolveJsonModule": true, "paths": { "@models": ["./src/models"], "@services": ["./src/services"], @@ -27,13 +8,5 @@ "@types": ["./src/types"], "@utils": ["./src/utils"] } - }, - "include": ["src"], - "exclude": [ - "dist", - "./src/**/__tests__", - "./src/**/__mocks__", - "./src/**/__fixtures__", - "node_modules" - ] + } } diff --git a/packages/modules/notification/tsconfig.spec.json b/packages/modules/notification/tsconfig.spec.json deleted file mode 100644 index 48e47e8cbb..0000000000 --- a/packages/modules/notification/tsconfig.spec.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": ["src", "integration-tests"], - "exclude": ["node_modules", "dist"], - "compilerOptions": { - "sourceMap": true - } -} diff --git a/packages/modules/order/jest.config.js b/packages/modules/order/jest.config.js index d125300e58..3aab9b7072 100644 --- a/packages/modules/order/jest.config.js +++ b/packages/modules/order/jest.config.js @@ -1,22 +1,10 @@ -module.exports = { +const defineJestConfig = require("../../../define_jest_config") +module.exports = defineJestConfig({ moduleNameMapper: { "^@models": "/src/models", "^@services": "/src/services", "^@repositories": "/src/repositories", "^@types": "/src/types", + "^@utils": "/src/utils", }, - transform: { - "^.+\\.[jt]s$": [ - "@swc/jest", - { - jsc: { - parser: { syntax: "typescript", decorators: true }, - transform: { decoratorMetadata: true }, - }, - }, - ], - }, - testEnvironment: `node`, - moduleFileExtensions: [`js`, `ts`], - modulePathIgnorePatterns: ["dist/"], -} +}) diff --git a/packages/modules/order/package.json b/packages/modules/order/package.json index 2080ac5d20..0068c6f011 100644 --- a/packages/modules/order/package.json +++ b/packages/modules/order/package.json @@ -5,7 +5,10 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "files": [ - "dist" + "dist", + "!dist/**/__tests__", + "!dist/**/__mocks__", + "!dist/**/__fixtures__" ], "engines": { "node": ">=20" @@ -23,7 +26,8 @@ "scripts": { "watch": "tsc --build --watch", "watch:test": "tsc --build tsconfig.spec.json --watch", - "build": "rimraf dist && tsc --build && tsc-alias -p tsconfig.json", + "resolve:aliases": "tsc --showConfig -p tsconfig.json > tsconfig.resolved.json && tsc-alias -p tsconfig.resolved.json && rimraf tsconfig.resolved.json", + "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --runInBand --bail --forceExit -- src/**/__tests__/**/*.ts", "test:integration": "jest --forceExit -- integration-tests/**/__tests__/**/*.ts", "migration:generate": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:generate", @@ -41,7 +45,7 @@ "rimraf": "^3.0.2", "ts-node": "^10.9.1", "tsc-alias": "^1.8.6", - "typescript": "^5.1.6" + "typescript": "^5.6.2" }, "dependencies": { "@medusajs/utils": "^1.11.9" diff --git a/packages/modules/order/src/services/__tests__/util/actions/exchanges.ts b/packages/modules/order/src/services/__tests__/util/actions/exchanges.ts index 541809b230..5fbcd14e3a 100644 --- a/packages/modules/order/src/services/__tests__/util/actions/exchanges.ts +++ b/packages/modules/order/src/services/__tests__/util/actions/exchanges.ts @@ -4,14 +4,18 @@ import { calculateOrderChange } from "../../../../utils" describe("Order Exchange - Actions", function () { const originalOrder = { + id: "1", items: [ { id: "1", quantity: 1, unit_price: 10, + order_id: "1", detail: { quantity: 1, + order_id: "1", + delivered_quantity: 1, shipped_quantity: 1, fulfilled_quantity: 1, return_requested_quantity: 0, @@ -24,9 +28,12 @@ describe("Order Exchange - Actions", function () { id: "2", quantity: 2, unit_price: 100, + order_id: "1", detail: { quantity: 2, + order_id: "1", + delivered_quantity: 1, shipped_quantity: 1, fulfilled_quantity: 1, return_requested_quantity: 0, @@ -39,9 +46,12 @@ describe("Order Exchange - Actions", function () { id: "3", quantity: 3, unit_price: 20, + order_id: "1", detail: { quantity: 3, + order_id: "1", + delivered_quantity: 1, shipped_quantity: 3, fulfilled_quantity: 3, return_requested_quantity: 0, @@ -55,6 +65,7 @@ describe("Order Exchange - Actions", function () { { id: "ship_123", amount: 0, + order_id: "1", }, ], total: 270, @@ -113,10 +124,13 @@ describe("Order Exchange - Actions", function () { expect(toJson).toEqual([ { id: "1", + order_id: "1", quantity: 1, unit_price: 10, detail: { quantity: 1, + order_id: "1", + delivered_quantity: 1, shipped_quantity: 1, fulfilled_quantity: 1, return_requested_quantity: 0, @@ -127,10 +141,13 @@ describe("Order Exchange - Actions", function () { }, { id: "2", + order_id: "1", quantity: 2, unit_price: 100, detail: { quantity: 2, + order_id: "1", + delivered_quantity: 1, shipped_quantity: 1, fulfilled_quantity: 1, return_requested_quantity: 0, @@ -141,10 +158,13 @@ describe("Order Exchange - Actions", function () { }, { id: "3", + order_id: "1", quantity: 3, unit_price: 20, detail: { quantity: 3, + order_id: "1", + delivered_quantity: 1, shipped_quantity: 3, fulfilled_quantity: 3, return_requested_quantity: "1", @@ -166,6 +186,7 @@ describe("Order Exchange - Actions", function () { }, { id: "item_555", + order_id: "1", unit_price: 50, quantity: 1, actions: [ @@ -185,10 +206,12 @@ describe("Order Exchange - Actions", function () { expect(changes.order.shipping_methods).toEqual([ { id: "ship_123", + order_id: "1", amount: 0, }, { id: "shipping_345", + order_id: "1", amount: 5, actions: [ { @@ -200,6 +223,7 @@ describe("Order Exchange - Actions", function () { }, { id: "return_shipping_345", + order_id: "1", amount: 7.5, actions: [ { diff --git a/packages/modules/order/src/services/__tests__/util/actions/returns.ts b/packages/modules/order/src/services/__tests__/util/actions/returns.ts index 13152e94e6..fae9f68e37 100644 --- a/packages/modules/order/src/services/__tests__/util/actions/returns.ts +++ b/packages/modules/order/src/services/__tests__/util/actions/returns.ts @@ -4,14 +4,18 @@ import { calculateOrderChange } from "../../../../utils" describe("Order Return - Actions", function () { const originalOrder = { + id: "1", items: [ { id: "1", quantity: 1, unit_price: 10, + order_id: "1", detail: { + order_id: "1", quantity: 1, + delivered_quantity: 1, shipped_quantity: 1, fulfilled_quantity: 1, return_requested_quantity: 0, @@ -24,9 +28,12 @@ describe("Order Return - Actions", function () { id: "2", quantity: 2, unit_price: 100, + order_id: "1", detail: { + order_id: "1", quantity: 2, + delivered_quantity: 1, shipped_quantity: 1, fulfilled_quantity: 1, return_requested_quantity: 0, @@ -39,9 +46,12 @@ describe("Order Return - Actions", function () { id: "3", quantity: 3, unit_price: 20, + order_id: "1", detail: { + order_id: "1", quantity: 3, + delivered_quantity: 1, shipped_quantity: 3, fulfilled_quantity: 3, return_requested_quantity: 0, @@ -54,7 +64,8 @@ describe("Order Return - Actions", function () { shipping_methods: [ { id: "ship_123", - price: 0, + amount: 0, + order_id: "1", }, ], total: 270, @@ -130,10 +141,13 @@ describe("Order Return - Actions", function () { expect(toJson).toEqual([ { id: "1", + order_id: "1", quantity: 1, unit_price: 10, detail: { + order_id: "1", quantity: 1, + delivered_quantity: 1, shipped_quantity: 1, fulfilled_quantity: 1, return_requested_quantity: 0, @@ -144,11 +158,14 @@ describe("Order Return - Actions", function () { }, { id: "2", + order_id: "1", quantity: 2, unit_price: 100, detail: { + order_id: "1", quantity: 2, shipped_quantity: 1, + delivered_quantity: 1, fulfilled_quantity: 1, return_requested_quantity: "1", return_received_quantity: 0, @@ -158,11 +175,14 @@ describe("Order Return - Actions", function () { }, { id: "3", + order_id: "1", quantity: 3, unit_price: 20, detail: { quantity: 3, + order_id: "1", shipped_quantity: 3, + delivered_quantity: 1, fulfilled_quantity: 3, return_requested_quantity: "2", return_received_quantity: 0, @@ -261,10 +281,13 @@ describe("Order Return - Actions", function () { expect(toJsonReceived).toEqual([ { id: "1", + order_id: "1", quantity: 1, unit_price: 10, detail: { quantity: 1, + order_id: "1", + delivered_quantity: 1, shipped_quantity: 1, fulfilled_quantity: 1, return_requested_quantity: 0, @@ -275,10 +298,13 @@ describe("Order Return - Actions", function () { }, { id: "2", + order_id: "1", quantity: 2, unit_price: 100, detail: { quantity: 2, + order_id: "1", + delivered_quantity: 1, shipped_quantity: 1, fulfilled_quantity: 1, return_requested_quantity: "1", @@ -289,10 +315,13 @@ describe("Order Return - Actions", function () { }, { id: "3", + order_id: "1", quantity: 3, unit_price: 20, detail: { quantity: 3, + order_id: "1", + delivered_quantity: 1, shipped_quantity: 3, fulfilled_quantity: 3, return_requested_quantity: "0", diff --git a/packages/modules/order/src/services/order-module-service.ts b/packages/modules/order/src/services/order-module-service.ts index 0bcbaba238..04d1f94c08 100644 --- a/packages/modules/order/src/services/order-module-service.ts +++ b/packages/modules/order/src/services/order-module-service.ts @@ -64,6 +64,7 @@ import { import { CreateOrderChangeDTO, CreateOrderItemDTO, + UpdateReturnReasonDTO, CreateOrderLineItemDTO, CreateOrderLineItemTaxLineDTO, CreateOrderShippingMethodDTO, @@ -73,7 +74,6 @@ import { UpdateOrderLineItemTaxLineDTO, UpdateOrderShippingMethodTaxLineDTO, } from "@types" -import { UpdateReturnReasonDTO } from "src/types/return-reason" import { joinerConfig } from "../joiner-config" import { applyChangesToOrder, diff --git a/packages/modules/order/src/types/index.ts b/packages/modules/order/src/types/index.ts index 93542812ec..5d7661af4f 100644 --- a/packages/modules/order/src/types/index.ts +++ b/packages/modules/order/src/types/index.ts @@ -12,6 +12,7 @@ export * from "./shipping-method-adjustment" export * from "./shipping-method-tax-line" export * from "./transaction" export * from "./utils" +export * from "./return-reason" export type InitializeModuleInjectableDependencies = { logger?: Logger diff --git a/packages/modules/order/tsconfig.json b/packages/modules/order/tsconfig.json index d7907ec7af..748a37ffa8 100644 --- a/packages/modules/order/tsconfig.json +++ b/packages/modules/order/tsconfig.json @@ -1,38 +1,12 @@ { + "extends": "../../../_tsconfig.base.json", "compilerOptions": { - "lib": ["es2021"], - "target": "es2021", - "outDir": "./dist", - "esModuleInterop": true, - "declarationMap": true, - "declaration": true, - "module": "commonjs", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "sourceMap": true, - "noImplicitReturns": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "noImplicitThis": true, - "allowJs": true, - "skipLibCheck": true, - "downlevelIteration": true, // to use ES5 specific tooling - "baseUrl": ".", - "resolveJsonModule": true, "paths": { "@models": ["./src/models"], "@services": ["./src/services"], "@repositories": ["./src/repositories"], - "@types": ["./src/types"] + "@types": ["./src/types"], + "@utils": ["./src/utils"] } - }, - "include": ["src"], - "exclude": [ - "dist", - "./src/**/__tests__", - "./src/**/__mocks__", - "./src/**/__fixtures__", - "node_modules" - ] + } } diff --git a/packages/modules/order/tsconfig.spec.json b/packages/modules/order/tsconfig.spec.json deleted file mode 100644 index 48e47e8cbb..0000000000 --- a/packages/modules/order/tsconfig.spec.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": ["src", "integration-tests"], - "exclude": ["node_modules", "dist"], - "compilerOptions": { - "sourceMap": true - } -} diff --git a/packages/modules/payment/jest.config.js b/packages/modules/payment/jest.config.js index 88c5539673..3aab9b7072 100644 --- a/packages/modules/payment/jest.config.js +++ b/packages/modules/payment/jest.config.js @@ -1,19 +1,10 @@ -module.exports = { +const defineJestConfig = require("../../../define_jest_config") +module.exports = defineJestConfig({ moduleNameMapper: { "^@models": "/src/models", "^@services": "/src/services", "^@repositories": "/src/repositories", + "^@types": "/src/types", + "^@utils": "/src/utils", }, - transform: { - "^.+\\.[jt]s?$": [ - "ts-jest", - { - tsconfig: "tsconfig.spec.json", - isolatedModules: true, - }, - ], - }, - testEnvironment: `node`, - moduleFileExtensions: [`js`, `ts`], - modulePathIgnorePatterns: ["dist/"], -} +}) diff --git a/packages/modules/payment/package.json b/packages/modules/payment/package.json index 3ef2266bd6..baf0d8ec03 100644 --- a/packages/modules/payment/package.json +++ b/packages/modules/payment/package.json @@ -5,7 +5,10 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "files": [ - "dist" + "dist", + "!dist/**/__tests__", + "!dist/**/__mocks__", + "!dist/**/__fixtures__" ], "engines": { "node": ">=20" @@ -23,7 +26,8 @@ "scripts": { "watch": "tsc --build --watch", "watch:test": "tsc --build tsconfig.spec.json --watch", - "build": "rimraf dist && tsc --build && tsc-alias -p tsconfig.json", + "resolve:aliases": "tsc --showConfig -p tsconfig.json > tsconfig.resolved.json && tsc-alias -p tsconfig.resolved.json && rimraf tsconfig.resolved.json", + "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --runInBand --bail --passWithNoTests --forceExit -- src", "test:integration": "jest --forceExit -- integration-tests/**/__tests__/**/*.ts", "migration:generate": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:generate", @@ -42,7 +46,7 @@ "ts-jest": "^29.1.1", "ts-node": "^10.9.1", "tsc-alias": "^1.8.6", - "typescript": "^5.1.6" + "typescript": "^5.6.2" }, "dependencies": { "@medusajs/modules-sdk": "^1.12.11", diff --git a/packages/modules/payment/tsconfig.json b/packages/modules/payment/tsconfig.json index ef533cb8fe..748a37ffa8 100644 --- a/packages/modules/payment/tsconfig.json +++ b/packages/modules/payment/tsconfig.json @@ -1,37 +1,12 @@ { + "extends": "../../../_tsconfig.base.json", "compilerOptions": { - "lib": ["es2021"], - "target": "es2021", - "outDir": "./dist", - "esModuleInterop": true, - "declarationMap": true, - "declaration": true, - "module": "commonjs", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "sourceMap": false, - "noImplicitReturns": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "noImplicitThis": true, - "allowJs": true, - "skipLibCheck": true, - "downlevelIteration": true, // to use ES5 specific tooling - "baseUrl": ".", - "resolveJsonModule": true, "paths": { "@models": ["./src/models"], "@services": ["./src/services"], - "@repositories": ["./src/repositories"] + "@repositories": ["./src/repositories"], + "@types": ["./src/types"], + "@utils": ["./src/utils"] } - }, - "include": ["src"], - "exclude": [ - "dist", - "./src/**/__tests__", - "./src/**/__mocks__", - "./src/**/__fixtures__", - "node_modules" - ] + } } diff --git a/packages/modules/payment/tsconfig.spec.json b/packages/modules/payment/tsconfig.spec.json deleted file mode 100644 index 48e47e8cbb..0000000000 --- a/packages/modules/payment/tsconfig.spec.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": ["src", "integration-tests"], - "exclude": ["node_modules", "dist"], - "compilerOptions": { - "sourceMap": true - } -} diff --git a/packages/modules/pricing/jest.config.js b/packages/modules/pricing/jest.config.js index 1b7795a88b..3aab9b7072 100644 --- a/packages/modules/pricing/jest.config.js +++ b/packages/modules/pricing/jest.config.js @@ -1,4 +1,5 @@ -module.exports = { +const defineJestConfig = require("../../../define_jest_config") +module.exports = defineJestConfig({ moduleNameMapper: { "^@models": "/src/models", "^@services": "/src/services", @@ -6,16 +7,4 @@ module.exports = { "^@types": "/src/types", "^@utils": "/src/utils", }, - transform: { - "^.+\\.[jt]s?$": [ - "ts-jest", - { - tsconfig: "tsconfig.spec.json", - isolatedModules: true, - }, - ], - }, - testEnvironment: `node`, - moduleFileExtensions: [`js`, `ts`], - modulePathIgnorePatterns: ["dist/"], -} +}) diff --git a/packages/modules/pricing/package.json b/packages/modules/pricing/package.json index 110b9739ed..9c9b366e4a 100644 --- a/packages/modules/pricing/package.json +++ b/packages/modules/pricing/package.json @@ -5,7 +5,10 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "files": [ - "dist" + "dist", + "!dist/**/__tests__", + "!dist/**/__mocks__", + "!dist/**/__fixtures__" ], "engines": { "node": ">=20" @@ -23,7 +26,8 @@ "scripts": { "watch": "tsc --build --watch", "watch:test": "tsc --build tsconfig.spec.json --watch", - "build": "rimraf dist && tsc --build && tsc-alias -p tsconfig.json", + "resolve:aliases": "tsc --showConfig -p tsconfig.json > tsconfig.resolved.json && tsc-alias -p tsconfig.resolved.json && rimraf tsconfig.resolved.json", + "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --runInBand --bail --forceExit -- src/**/__tests__/**/*.ts", "test:integration": "jest --forceExit -- integration-tests/**/__tests__/**/*.ts", "migration:generate": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:generate", @@ -42,7 +46,7 @@ "ts-jest": "^29.1.1", "ts-node": "^10.9.1", "tsc-alias": "^1.8.6", - "typescript": "^5.1.6" + "typescript": "^5.6.2" }, "dependencies": { "@medusajs/utils": "^1.11.9" diff --git a/packages/modules/pricing/src/services/pricing-module.ts b/packages/modules/pricing/src/services/pricing-module.ts index d8605622b1..2b3067ad3c 100644 --- a/packages/modules/pricing/src/services/pricing-module.ts +++ b/packages/modules/pricing/src/services/pricing-module.ts @@ -47,9 +47,8 @@ import { PriceSet, } from "@models" -import { ServiceTypes } from "@types" import { eventBuilders, validatePriceListDates } from "@utils" -import { CreatePriceListDTO, UpsertPriceDTO } from "src/types/services" +import { ServiceTypes } from "@types" import { joinerConfig } from "../joiner-config" type InjectedDependencies = { @@ -590,7 +589,7 @@ export default class PricingModuleService price_list_id: priceListId, price_rules: hasRulesInput ? rules : undefined, rules_count: hasRulesInput ? ruleEntries.length : undefined, - } as UpsertPriceDTO + } as ServiceTypes.UpsertPriceDTO delete (entry as CreatePricesDTO).rules const entryHash = hashPrice(entry) @@ -967,7 +966,7 @@ export default class PricingModuleService ) ) .filter(Boolean) - .flat() as UpsertPriceDTO[] + .flat() as ServiceTypes.UpsertPriceDTO[] const priceSetMap = new Map( priceSets.map((p) => [p.id, p]) @@ -1025,18 +1024,18 @@ export default class PricingModuleService ) { const normalized = this.normalizePriceListDate(data) - const priceListsToCreate: CreatePriceListDTO[] = normalized.map( - (priceListData) => { + const priceListsToCreate: ServiceTypes.CreatePriceListDTO[] = + normalized.map((priceListData) => { const entry = { ...priceListData, rules: undefined, - } as CreatePriceListDTO + } as ServiceTypes.CreatePriceListDTO if (priceListData.prices) { entry.prices = this.normalizePrices( priceListData.prices, [] - ) as UpsertPriceDTO[] + ) as ServiceTypes.UpsertPriceDTO[] } if (priceListData.rules) { @@ -1060,8 +1059,7 @@ export default class PricingModuleService } return entry - } - ) + }) const priceLists = await this.priceListService_.create( priceListsToCreate, @@ -1156,7 +1154,7 @@ export default class PricingModuleService const normalizedData = this.normalizePriceListDate(data).map( (priceList) => { - const entry: Partial = { + const entry: Partial = { ...priceList, rules: undefined, price_list_rules: undefined, @@ -1214,17 +1212,17 @@ export default class PricingModuleService const pricesToUpsert = data .map((addPrice) => this.normalizePrices( - addPrice.prices as UpsertPriceDTO[], + addPrice.prices as ServiceTypes.UpsertPriceDTO[], existingPrices, addPrice.price_list_id ) ) .filter(Boolean) - .flat() as UpsertPriceDTO[] + .flat() as ServiceTypes.UpsertPriceDTO[] const priceListMap = new Map(priceLists.map((p) => [p.id, p])) - for (const { price_list_id: priceListId, prices } of data) { + for (const { price_list_id: priceListId } of data) { const priceList = priceListMap.get(priceListId) if (!priceList) { @@ -1276,7 +1274,7 @@ export default class PricingModuleService ) ) .filter(Boolean) - .flat() as UpsertPriceDTO[] + .flat() as ServiceTypes.UpsertPriceDTO[] const priceListMap = new Map(priceLists.map((p) => [p.id, p])) pricesToUpsert.forEach((price) => { @@ -1456,7 +1454,7 @@ export default class PricingModuleService data: ( | ServiceTypes.UpdatePriceListDTO | ServiceTypes.CreatePriceListDTO - | CreatePriceListDTO + | ServiceTypes.CreatePriceListDTO )[] ) { return data.map((priceListData: any) => { diff --git a/packages/modules/pricing/tsconfig.json b/packages/modules/pricing/tsconfig.json index 2dea213c40..748a37ffa8 100644 --- a/packages/modules/pricing/tsconfig.json +++ b/packages/modules/pricing/tsconfig.json @@ -1,26 +1,6 @@ { + "extends": "../../../_tsconfig.base.json", "compilerOptions": { - "lib": ["es2021"], - "target": "es2021", - "outDir": "./dist", - "esModuleInterop": true, - "declarationMap": true, - "declaration": true, - "module": "commonjs", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "sourceMap": false, - "noImplicitReturns": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "noImplicitThis": true, - "allowJs": true, - "skipLibCheck": true, - "downlevelIteration": true, - // to use ES5 specific tooling - "baseUrl": ".", - "resolveJsonModule": true, "paths": { "@models": ["./src/models"], "@services": ["./src/services"], @@ -28,13 +8,5 @@ "@types": ["./src/types"], "@utils": ["./src/utils"] } - }, - "include": ["src"], - "exclude": [ - "dist", - "./src/**/__tests__", - "./src/**/__mocks__", - "./src/**/__fixtures__", - "node_modules" - ] + } } diff --git a/packages/modules/pricing/tsconfig.spec.json b/packages/modules/pricing/tsconfig.spec.json deleted file mode 100644 index 48e47e8cbb..0000000000 --- a/packages/modules/pricing/tsconfig.spec.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": ["src", "integration-tests"], - "exclude": ["node_modules", "dist"], - "compilerOptions": { - "sourceMap": true - } -} diff --git a/packages/modules/product/jest.config.js b/packages/modules/product/jest.config.js index d125300e58..3aab9b7072 100644 --- a/packages/modules/product/jest.config.js +++ b/packages/modules/product/jest.config.js @@ -1,22 +1,10 @@ -module.exports = { +const defineJestConfig = require("../../../define_jest_config") +module.exports = defineJestConfig({ moduleNameMapper: { "^@models": "/src/models", "^@services": "/src/services", "^@repositories": "/src/repositories", "^@types": "/src/types", + "^@utils": "/src/utils", }, - transform: { - "^.+\\.[jt]s$": [ - "@swc/jest", - { - jsc: { - parser: { syntax: "typescript", decorators: true }, - transform: { decoratorMetadata: true }, - }, - }, - ], - }, - testEnvironment: `node`, - moduleFileExtensions: [`js`, `ts`], - modulePathIgnorePatterns: ["dist/"], -} +}) diff --git a/packages/modules/product/package.json b/packages/modules/product/package.json index 1b3ca9d4e5..92c5d762a5 100644 --- a/packages/modules/product/package.json +++ b/packages/modules/product/package.json @@ -5,7 +5,10 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "files": [ - "dist" + "dist", + "!dist/**/__tests__", + "!dist/**/__mocks__", + "!dist/**/__fixtures__" ], "engines": { "node": ">=20" @@ -23,7 +26,8 @@ "scripts": { "watch": "tsc --build --watch", "watch:test": "tsc --build tsconfig.spec.json --watch", - "build": "rimraf dist && tsc --build && tsc-alias -p tsconfig.json", + "resolve:aliases": "tsc --showConfig -p tsconfig.json > tsconfig.resolved.json && tsc-alias -p tsconfig.resolved.json && rimraf tsconfig.resolved.json", + "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --runInBand --bail --forceExit -- src/**/__tests__/**/*.ts", "test:integration": "jest --forceExit -- integration-tests/**/__tests__/**/*.ts", "migration:generate": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:generate", @@ -43,7 +47,7 @@ "rimraf": "^3.0.2", "ts-node": "^10.9.1", "tsc-alias": "^1.8.6", - "typescript": "^5.1.6" + "typescript": "^5.6.2" }, "dependencies": { "@medusajs/utils": "^1.11.9" diff --git a/packages/modules/product/src/models/product-variant.ts b/packages/modules/product/src/models/product-variant.ts index 371732ae5e..ccda0a8fda 100644 --- a/packages/modules/product/src/models/product-variant.ts +++ b/packages/modules/product/src/models/product-variant.ts @@ -2,19 +2,16 @@ import { createPsqlIndexStatementHelper, DALUtils, generateEntityId, - optionalNumericSerializer, Searchable, } from "@medusajs/utils" import { BeforeCreate, - Cascade, Collection, Entity, Filter, Index, ManyToMany, ManyToOne, - OneToMany, OnInit, PrimaryKey, Property, diff --git a/packages/modules/product/src/repositories/product.ts b/packages/modules/product/src/repositories/product.ts index 2d1d25f9a9..b9d64164c0 100644 --- a/packages/modules/product/src/repositories/product.ts +++ b/packages/modules/product/src/repositories/product.ts @@ -4,8 +4,6 @@ import { Context, DAL } from "@medusajs/types" import { SqlEntityManager } from "@mikro-orm/postgresql" import { DALUtils } from "@medusajs/utils" -import { UpdateProductInput } from "../types" - // eslint-disable-next-line max-len export class ProductRepository extends DALUtils.mikroOrmBaseRepositoryFactory( Product diff --git a/packages/modules/product/tsconfig.json b/packages/modules/product/tsconfig.json index 78342ef37b..748a37ffa8 100644 --- a/packages/modules/product/tsconfig.json +++ b/packages/modules/product/tsconfig.json @@ -1,38 +1,12 @@ { + "extends": "../../../_tsconfig.base.json", "compilerOptions": { - "lib": ["es2021"], - "target": "es2021", - "outDir": "./dist", - "esModuleInterop": true, - "declarationMap": true, - "declaration": true, - "module": "commonjs", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "sourceMap": false, - "noImplicitReturns": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "noImplicitThis": true, - "allowJs": true, - "skipLibCheck": true, - "downlevelIteration": true, // to use ES5 specific tooling - "baseUrl": ".", - "resolveJsonModule": true, "paths": { "@models": ["./src/models"], "@services": ["./src/services"], "@repositories": ["./src/repositories"], - "@types": ["./src/types"] + "@types": ["./src/types"], + "@utils": ["./src/utils"] } - }, - "include": ["src"], - "exclude": [ - "dist", - "./src/**/__tests__", - "./src/**/__mocks__", - "./src/**/__fixtures__", - "node_modules" - ] + } } diff --git a/packages/modules/product/tsconfig.spec.json b/packages/modules/product/tsconfig.spec.json deleted file mode 100644 index 48e47e8cbb..0000000000 --- a/packages/modules/product/tsconfig.spec.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": ["src", "integration-tests"], - "exclude": ["node_modules", "dist"], - "compilerOptions": { - "sourceMap": true - } -} diff --git a/packages/modules/promotion/jest.config.js b/packages/modules/promotion/jest.config.js index d0f98de225..3aab9b7072 100644 --- a/packages/modules/promotion/jest.config.js +++ b/packages/modules/promotion/jest.config.js @@ -1,21 +1,10 @@ -module.exports = { +const defineJestConfig = require("../../../define_jest_config") +module.exports = defineJestConfig({ moduleNameMapper: { "^@models": "/src/models", "^@services": "/src/services", "^@repositories": "/src/repositories", - "^@utils": "/src/utils", "^@types": "/src/types", + "^@utils": "/src/utils", }, - transform: { - "^.+\\.[jt]s?$": [ - "ts-jest", - { - tsconfig: "tsconfig.spec.json", - isolatedModules: true, - }, - ], - }, - testEnvironment: `node`, - moduleFileExtensions: [`js`, `ts`], - modulePathIgnorePatterns: ["dist/"], -} +}) diff --git a/packages/modules/promotion/package.json b/packages/modules/promotion/package.json index 4b5757145c..4f039311b1 100644 --- a/packages/modules/promotion/package.json +++ b/packages/modules/promotion/package.json @@ -5,7 +5,10 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "files": [ - "dist" + "dist", + "!dist/**/__tests__", + "!dist/**/__mocks__", + "!dist/**/__fixtures__" ], "engines": { "node": ">=20" @@ -23,7 +26,8 @@ "scripts": { "watch": "tsc --build --watch", "watch:test": "tsc --build tsconfig.spec.json --watch", - "build": "rimraf dist && tsc --build && tsc-alias -p tsconfig.json", + "resolve:aliases": "tsc --showConfig -p tsconfig.json > tsconfig.resolved.json && tsc-alias -p tsconfig.resolved.json && rimraf tsconfig.resolved.json", + "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --runInBand --passWithNoTests --bail --forceExit -- src", "test:integration": "jest --forceExit -- integration-tests/**/__tests__/**/*.ts", "migration:generate": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:generate", @@ -42,7 +46,7 @@ "ts-jest": "^29.1.1", "ts-node": "^10.9.1", "tsc-alias": "^1.8.6", - "typescript": "^5.1.6" + "typescript": "^5.6.2" }, "dependencies": { "@medusajs/utils": "1.11.9" diff --git a/packages/modules/promotion/src/services/promotion-module.ts b/packages/modules/promotion/src/services/promotion-module.ts index 9bbe87dfd7..06436fe631 100644 --- a/packages/modules/promotion/src/services/promotion-module.ts +++ b/packages/modules/promotion/src/services/promotion-module.ts @@ -53,7 +53,6 @@ import { validateApplicationMethodAttributes, validatePromotionRuleAttributes, } from "@utils" -import { EligibleItem } from "src/utils/compute-actions" import { joinerConfig } from "../joiner-config" import { CreatePromotionRuleValueDTO } from "../types/promotion-rule-value" @@ -340,9 +339,15 @@ export default class PromotionModuleService >() const methodIdPromoValueMap = new Map() // Keeps a map of all elgible items in the buy section and its eligible quantity - const eligibleBuyItemMap = new Map() + const eligibleBuyItemMap = new Map< + string, + ComputeActionUtils.EligibleItem[] + >() // Keeps a map of all elgible items in the target section and its eligible quantity - const eligibleTargetItemMap = new Map() + const eligibleTargetItemMap = new Map< + string, + ComputeActionUtils.EligibleItem[] + >() const automaticPromotions = preventAutoPromotions ? [] : await this.listPromotions( diff --git a/packages/modules/promotion/tsconfig.json b/packages/modules/promotion/tsconfig.json index e3f64c5ff6..748a37ffa8 100644 --- a/packages/modules/promotion/tsconfig.json +++ b/packages/modules/promotion/tsconfig.json @@ -1,25 +1,6 @@ { + "extends": "../../../_tsconfig.base.json", "compilerOptions": { - "lib": ["es2021"], - "target": "es2021", - "outDir": "./dist", - "esModuleInterop": true, - "declarationMap": true, - "declaration": true, - "module": "commonjs", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "sourceMap": false, - "noImplicitReturns": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "noImplicitThis": true, - "allowJs": true, - "skipLibCheck": true, - "downlevelIteration": true, // to use ES5 specific tooling - "baseUrl": ".", - "resolveJsonModule": true, "paths": { "@models": ["./src/models"], "@services": ["./src/services"], @@ -27,13 +8,5 @@ "@types": ["./src/types"], "@utils": ["./src/utils"] } - }, - "include": ["src"], - "exclude": [ - "dist", - "./src/**/__tests__", - "./src/**/__mocks__", - "./src/**/__fixtures__", - "node_modules" - ] + } } diff --git a/packages/modules/promotion/tsconfig.spec.json b/packages/modules/promotion/tsconfig.spec.json deleted file mode 100644 index 48e47e8cbb..0000000000 --- a/packages/modules/promotion/tsconfig.spec.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": ["src", "integration-tests"], - "exclude": ["node_modules", "dist"], - "compilerOptions": { - "sourceMap": true - } -} diff --git a/packages/modules/providers/auth-emailpass/jest.config.js b/packages/modules/providers/auth-emailpass/jest.config.js index f33ccadd61..818699559a 100644 --- a/packages/modules/providers/auth-emailpass/jest.config.js +++ b/packages/modules/providers/auth-emailpass/jest.config.js @@ -1,5 +1,10 @@ -module.exports = { - transform: { "^.+\\.[jt]s?$": "@swc/jest" }, - testEnvironment: `node`, - moduleFileExtensions: [`js`, `jsx`, `ts`, `tsx`, `json`], -} +const defineJestConfig = require("../../../../define_jest_config") +module.exports = defineJestConfig({ + moduleNameMapper: { + "^@models": "/src/models", + "^@services": "/src/services", + "^@repositories": "/src/repositories", + "^@types": "/src/types", + "^@utils": "/src/utils", + }, +}) diff --git a/packages/modules/providers/auth-emailpass/package.json b/packages/modules/providers/auth-emailpass/package.json index 420200dfc6..1f06d7d14a 100644 --- a/packages/modules/providers/auth-emailpass/package.json +++ b/packages/modules/providers/auth-emailpass/package.json @@ -9,7 +9,10 @@ "directory": "packages/modules/providers/auth-emailpass" }, "files": [ - "dist" + "dist", + "!dist/**/__tests__", + "!dist/**/__mocks__", + "!dist/**/__fixtures__" ], "engines": { "node": ">=20" @@ -26,7 +29,7 @@ "cross-env": "^5.2.1", "jest": "^29.7.0", "rimraf": "^5.0.1", - "typescript": "^5.3.3" + "typescript": "^5.6.2" }, "dependencies": { "@medusajs/utils": "^1.11.9", diff --git a/packages/modules/providers/auth-emailpass/tsconfig.json b/packages/modules/providers/auth-emailpass/tsconfig.json index 62fd156294..90f3a70b38 100644 --- a/packages/modules/providers/auth-emailpass/tsconfig.json +++ b/packages/modules/providers/auth-emailpass/tsconfig.json @@ -1,33 +1,12 @@ { + "extends": "../../../../_tsconfig.base.json", "compilerOptions": { - "lib": ["es2021"], - "target": "es2021", - "jsx": "react-jsx" /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */, - "outDir": "./dist", - "esModuleInterop": true, - "declarationMap": true, - "declaration": true, - "module": "commonjs", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "noImplicitReturns": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "noImplicitThis": true, - "allowJs": true, - "skipLibCheck": true, - "downlevelIteration": true, // to use ES5 specific tooling - "inlineSourceMap": true /* Emit a single file with source maps instead of having a separate file. */ - }, - "include": ["src"], - "exclude": [ - "dist", - "build", - "src/**/__tests__", - "src/**/__mocks__", - "src/**/__fixtures__", - "node_modules", - ".eslintrc.js" - ] + "paths": { + "@models": ["./src/models"], + "@services": ["./src/services"], + "@repositories": ["./src/repositories"], + "@types": ["./src/types"], + "@utils": ["./src/utils"] + } + } } diff --git a/packages/modules/providers/auth-github/jest.config.js b/packages/modules/providers/auth-github/jest.config.js index f33ccadd61..818699559a 100644 --- a/packages/modules/providers/auth-github/jest.config.js +++ b/packages/modules/providers/auth-github/jest.config.js @@ -1,5 +1,10 @@ -module.exports = { - transform: { "^.+\\.[jt]s?$": "@swc/jest" }, - testEnvironment: `node`, - moduleFileExtensions: [`js`, `jsx`, `ts`, `tsx`, `json`], -} +const defineJestConfig = require("../../../../define_jest_config") +module.exports = defineJestConfig({ + moduleNameMapper: { + "^@models": "/src/models", + "^@services": "/src/services", + "^@repositories": "/src/repositories", + "^@types": "/src/types", + "^@utils": "/src/utils", + }, +}) diff --git a/packages/modules/providers/auth-github/package.json b/packages/modules/providers/auth-github/package.json index 7d7eeb5e2b..b5e850079a 100644 --- a/packages/modules/providers/auth-github/package.json +++ b/packages/modules/providers/auth-github/package.json @@ -9,7 +9,10 @@ "directory": "packages/modules/providers/auth-github" }, "files": [ - "dist" + "dist", + "!dist/**/__tests__", + "!dist/**/__mocks__", + "!dist/**/__fixtures__" ], "engines": { "node": ">=20" @@ -29,7 +32,7 @@ "jest": "^29.7.0", "msw": "^2.3.0", "rimraf": "^5.0.1", - "typescript": "^5.1.6" + "typescript": "^5.6.2" }, "dependencies": { "@medusajs/utils": "^1.11.9" diff --git a/packages/modules/providers/auth-github/tsconfig.json b/packages/modules/providers/auth-github/tsconfig.json index 89a1f6bfc5..90f3a70b38 100644 --- a/packages/modules/providers/auth-github/tsconfig.json +++ b/packages/modules/providers/auth-github/tsconfig.json @@ -1,31 +1,12 @@ { + "extends": "../../../../_tsconfig.base.json", "compilerOptions": { - "lib": ["es2021"], - "target": "es2021", - "outDir": "./dist", - "esModuleInterop": true, - "declarationMap": true, - "declaration": true, - "module": "commonjs", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "noImplicitReturns": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "noImplicitThis": true, - "allowJs": true, - "skipLibCheck": true, - "inlineSourceMap": true /* Emit a single file with source maps instead of having a separate file. */ - }, - "include": ["src"], - "exclude": [ - "dist", - "build", - "src/**/__tests__", - "src/**/__mocks__", - "src/**/__fixtures__", - "node_modules", - ".eslintrc.js" - ] + "paths": { + "@models": ["./src/models"], + "@services": ["./src/services"], + "@repositories": ["./src/repositories"], + "@types": ["./src/types"], + "@utils": ["./src/utils"] + } + } } diff --git a/packages/modules/providers/auth-google/jest.config.js b/packages/modules/providers/auth-google/jest.config.js index f33ccadd61..818699559a 100644 --- a/packages/modules/providers/auth-google/jest.config.js +++ b/packages/modules/providers/auth-google/jest.config.js @@ -1,5 +1,10 @@ -module.exports = { - transform: { "^.+\\.[jt]s?$": "@swc/jest" }, - testEnvironment: `node`, - moduleFileExtensions: [`js`, `jsx`, `ts`, `tsx`, `json`], -} +const defineJestConfig = require("../../../../define_jest_config") +module.exports = defineJestConfig({ + moduleNameMapper: { + "^@models": "/src/models", + "^@services": "/src/services", + "^@repositories": "/src/repositories", + "^@types": "/src/types", + "^@utils": "/src/utils", + }, +}) diff --git a/packages/modules/providers/auth-google/package.json b/packages/modules/providers/auth-google/package.json index df8b4f82e7..d3cafc9e05 100644 --- a/packages/modules/providers/auth-google/package.json +++ b/packages/modules/providers/auth-google/package.json @@ -9,7 +9,10 @@ "directory": "packages/modules/providers/auth-google" }, "files": [ - "dist" + "dist", + "!dist/**/__tests__", + "!dist/**/__mocks__", + "!dist/**/__fixtures__" ], "engines": { "node": ">=20" @@ -29,7 +32,7 @@ "jest": "^29.7.0", "msw": "^2.3.0", "rimraf": "^5.0.1", - "typescript": "^5.1.6" + "typescript": "^5.6.2" }, "dependencies": { "@medusajs/utils": "^1.11.9", diff --git a/packages/modules/providers/auth-google/tsconfig.json b/packages/modules/providers/auth-google/tsconfig.json index 89a1f6bfc5..90f3a70b38 100644 --- a/packages/modules/providers/auth-google/tsconfig.json +++ b/packages/modules/providers/auth-google/tsconfig.json @@ -1,31 +1,12 @@ { + "extends": "../../../../_tsconfig.base.json", "compilerOptions": { - "lib": ["es2021"], - "target": "es2021", - "outDir": "./dist", - "esModuleInterop": true, - "declarationMap": true, - "declaration": true, - "module": "commonjs", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "noImplicitReturns": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "noImplicitThis": true, - "allowJs": true, - "skipLibCheck": true, - "inlineSourceMap": true /* Emit a single file with source maps instead of having a separate file. */ - }, - "include": ["src"], - "exclude": [ - "dist", - "build", - "src/**/__tests__", - "src/**/__mocks__", - "src/**/__fixtures__", - "node_modules", - ".eslintrc.js" - ] + "paths": { + "@models": ["./src/models"], + "@services": ["./src/services"], + "@repositories": ["./src/repositories"], + "@types": ["./src/types"], + "@utils": ["./src/utils"] + } + } } diff --git a/packages/modules/providers/file-local/jest.config.js b/packages/modules/providers/file-local/jest.config.js index e69de29bb2..818699559a 100644 --- a/packages/modules/providers/file-local/jest.config.js +++ b/packages/modules/providers/file-local/jest.config.js @@ -0,0 +1,10 @@ +const defineJestConfig = require("../../../../define_jest_config") +module.exports = defineJestConfig({ + moduleNameMapper: { + "^@models": "/src/models", + "^@services": "/src/services", + "^@repositories": "/src/repositories", + "^@types": "/src/types", + "^@utils": "/src/utils", + }, +}) diff --git a/packages/modules/providers/file-local/package.json b/packages/modules/providers/file-local/package.json index 4ae2c375c9..e16847634d 100644 --- a/packages/modules/providers/file-local/package.json +++ b/packages/modules/providers/file-local/package.json @@ -9,7 +9,10 @@ "directory": "packages/file-local" }, "files": [ - "dist" + "dist", + "!dist/**/__tests__", + "!dist/**/__mocks__", + "!dist/**/__fixtures__" ], "engines": { "node": ">=20" @@ -25,7 +28,7 @@ "cross-env": "^5.2.1", "jest": "^29.7.0", "rimraf": "^5.0.1", - "typescript": "^5.3.3" + "typescript": "^5.6.2" }, "dependencies": { "@medusajs/utils": "^1.11.9" diff --git a/packages/modules/providers/file-local/src/services/local-file.ts b/packages/modules/providers/file-local/src/services/local-file.ts index 808127aac4..c8c6047797 100644 --- a/packages/modules/providers/file-local/src/services/local-file.ts +++ b/packages/modules/providers/file-local/src/services/local-file.ts @@ -39,7 +39,7 @@ export class LocalFileService extends AbstractFileProviderService { const parsedFilename = path.parse(file.filename) const baseDir = file.access === "public" ? this.uploadDir_ : this.privateUploadDir_ - const dir = await this.ensureDirExists(baseDir, parsedFilename.dir) + await this.ensureDirExists(baseDir, parsedFilename.dir) const fileKey = path.join( parsedFilename.dir, diff --git a/packages/modules/providers/file-local/tsconfig.json b/packages/modules/providers/file-local/tsconfig.json index 62fd156294..90f3a70b38 100644 --- a/packages/modules/providers/file-local/tsconfig.json +++ b/packages/modules/providers/file-local/tsconfig.json @@ -1,33 +1,12 @@ { + "extends": "../../../../_tsconfig.base.json", "compilerOptions": { - "lib": ["es2021"], - "target": "es2021", - "jsx": "react-jsx" /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */, - "outDir": "./dist", - "esModuleInterop": true, - "declarationMap": true, - "declaration": true, - "module": "commonjs", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "noImplicitReturns": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "noImplicitThis": true, - "allowJs": true, - "skipLibCheck": true, - "downlevelIteration": true, // to use ES5 specific tooling - "inlineSourceMap": true /* Emit a single file with source maps instead of having a separate file. */ - }, - "include": ["src"], - "exclude": [ - "dist", - "build", - "src/**/__tests__", - "src/**/__mocks__", - "src/**/__fixtures__", - "node_modules", - ".eslintrc.js" - ] + "paths": { + "@models": ["./src/models"], + "@services": ["./src/services"], + "@repositories": ["./src/repositories"], + "@types": ["./src/types"], + "@utils": ["./src/utils"] + } + } } diff --git a/packages/modules/providers/file-local/tsconfig.spec.json b/packages/modules/providers/file-local/tsconfig.spec.json deleted file mode 100644 index 9b62409191..0000000000 --- a/packages/modules/providers/file-local/tsconfig.spec.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": ["src"], - "exclude": ["node_modules"] -} diff --git a/packages/modules/providers/file-s3/jest.config.js b/packages/modules/providers/file-s3/jest.config.js index 61fcbb7c82..818699559a 100644 --- a/packages/modules/providers/file-s3/jest.config.js +++ b/packages/modules/providers/file-s3/jest.config.js @@ -1,15 +1,10 @@ -module.exports = { - transform: { - "^.+\\.[jt]s$": [ - "@swc/jest", - { - jsc: { - parser: { syntax: "typescript", decorators: true }, - transform: { decoratorMetadata: true }, - }, - }, - ], +const defineJestConfig = require("../../../../define_jest_config") +module.exports = defineJestConfig({ + moduleNameMapper: { + "^@models": "/src/models", + "^@services": "/src/services", + "^@repositories": "/src/repositories", + "^@types": "/src/types", + "^@utils": "/src/utils", }, - testEnvironment: `node`, - moduleFileExtensions: [`js`, `jsx`, `ts`, `tsx`, `json`], -} +}) diff --git a/packages/modules/providers/file-s3/package.json b/packages/modules/providers/file-s3/package.json index eb2f4ba77c..722a473136 100644 --- a/packages/modules/providers/file-s3/package.json +++ b/packages/modules/providers/file-s3/package.json @@ -9,7 +9,10 @@ "directory": "packages/file-local" }, "files": [ - "dist" + "dist", + "!dist/**/__tests__", + "!dist/**/__mocks__", + "!dist/**/__fixtures__" ], "engines": { "node": ">=20" @@ -27,7 +30,7 @@ "cross-env": "^5.2.1", "jest": "^29.7.0", "rimraf": "^5.0.1", - "typescript": "^5.3.3" + "typescript": "^5.6.2" }, "dependencies": { "@aws-sdk/client-s3": "^3.556.0", diff --git a/packages/modules/providers/file-s3/tsconfig.json b/packages/modules/providers/file-s3/tsconfig.json index 62fd156294..90f3a70b38 100644 --- a/packages/modules/providers/file-s3/tsconfig.json +++ b/packages/modules/providers/file-s3/tsconfig.json @@ -1,33 +1,12 @@ { + "extends": "../../../../_tsconfig.base.json", "compilerOptions": { - "lib": ["es2021"], - "target": "es2021", - "jsx": "react-jsx" /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */, - "outDir": "./dist", - "esModuleInterop": true, - "declarationMap": true, - "declaration": true, - "module": "commonjs", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "noImplicitReturns": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "noImplicitThis": true, - "allowJs": true, - "skipLibCheck": true, - "downlevelIteration": true, // to use ES5 specific tooling - "inlineSourceMap": true /* Emit a single file with source maps instead of having a separate file. */ - }, - "include": ["src"], - "exclude": [ - "dist", - "build", - "src/**/__tests__", - "src/**/__mocks__", - "src/**/__fixtures__", - "node_modules", - ".eslintrc.js" - ] + "paths": { + "@models": ["./src/models"], + "@services": ["./src/services"], + "@repositories": ["./src/repositories"], + "@types": ["./src/types"], + "@utils": ["./src/utils"] + } + } } diff --git a/packages/modules/providers/file-s3/tsconfig.spec.json b/packages/modules/providers/file-s3/tsconfig.spec.json deleted file mode 100644 index 9b62409191..0000000000 --- a/packages/modules/providers/file-s3/tsconfig.spec.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": ["src"], - "exclude": ["node_modules"] -} diff --git a/packages/modules/providers/fulfillment-manual/jest.config.js b/packages/modules/providers/fulfillment-manual/jest.config.js index 61fcbb7c82..818699559a 100644 --- a/packages/modules/providers/fulfillment-manual/jest.config.js +++ b/packages/modules/providers/fulfillment-manual/jest.config.js @@ -1,15 +1,10 @@ -module.exports = { - transform: { - "^.+\\.[jt]s$": [ - "@swc/jest", - { - jsc: { - parser: { syntax: "typescript", decorators: true }, - transform: { decoratorMetadata: true }, - }, - }, - ], +const defineJestConfig = require("../../../../define_jest_config") +module.exports = defineJestConfig({ + moduleNameMapper: { + "^@models": "/src/models", + "^@services": "/src/services", + "^@repositories": "/src/repositories", + "^@types": "/src/types", + "^@utils": "/src/utils", }, - testEnvironment: `node`, - moduleFileExtensions: [`js`, `jsx`, `ts`, `tsx`, `json`], -} +}) diff --git a/packages/modules/providers/fulfillment-manual/package.json b/packages/modules/providers/fulfillment-manual/package.json index 0c96155467..2db86a4876 100644 --- a/packages/modules/providers/fulfillment-manual/package.json +++ b/packages/modules/providers/fulfillment-manual/package.json @@ -9,7 +9,10 @@ "directory": "packages/fulfillment-manual" }, "files": [ - "dist" + "dist", + "!dist/**/__tests__", + "!dist/**/__mocks__", + "!dist/**/__fixtures__" ], "engines": { "node": ">=20" @@ -25,7 +28,7 @@ "cross-env": "^5.2.1", "jest": "^29.7.0", "rimraf": "^5.0.1", - "typescript": "^5.3.3" + "typescript": "^5.6.2" }, "dependencies": { "@medusajs/utils": "^1.11.9", diff --git a/packages/modules/providers/fulfillment-manual/tsconfig.json b/packages/modules/providers/fulfillment-manual/tsconfig.json index 62fd156294..90f3a70b38 100644 --- a/packages/modules/providers/fulfillment-manual/tsconfig.json +++ b/packages/modules/providers/fulfillment-manual/tsconfig.json @@ -1,33 +1,12 @@ { + "extends": "../../../../_tsconfig.base.json", "compilerOptions": { - "lib": ["es2021"], - "target": "es2021", - "jsx": "react-jsx" /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */, - "outDir": "./dist", - "esModuleInterop": true, - "declarationMap": true, - "declaration": true, - "module": "commonjs", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "noImplicitReturns": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "noImplicitThis": true, - "allowJs": true, - "skipLibCheck": true, - "downlevelIteration": true, // to use ES5 specific tooling - "inlineSourceMap": true /* Emit a single file with source maps instead of having a separate file. */ - }, - "include": ["src"], - "exclude": [ - "dist", - "build", - "src/**/__tests__", - "src/**/__mocks__", - "src/**/__fixtures__", - "node_modules", - ".eslintrc.js" - ] + "paths": { + "@models": ["./src/models"], + "@services": ["./src/services"], + "@repositories": ["./src/repositories"], + "@types": ["./src/types"], + "@utils": ["./src/utils"] + } + } } diff --git a/packages/modules/providers/fulfillment-manual/tsconfig.spec.json b/packages/modules/providers/fulfillment-manual/tsconfig.spec.json deleted file mode 100644 index 9b62409191..0000000000 --- a/packages/modules/providers/fulfillment-manual/tsconfig.spec.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": ["src"], - "exclude": ["node_modules"] -} diff --git a/packages/modules/providers/notification-local/jest.config.js b/packages/modules/providers/notification-local/jest.config.js index f33ccadd61..818699559a 100644 --- a/packages/modules/providers/notification-local/jest.config.js +++ b/packages/modules/providers/notification-local/jest.config.js @@ -1,5 +1,10 @@ -module.exports = { - transform: { "^.+\\.[jt]s?$": "@swc/jest" }, - testEnvironment: `node`, - moduleFileExtensions: [`js`, `jsx`, `ts`, `tsx`, `json`], -} +const defineJestConfig = require("../../../../define_jest_config") +module.exports = defineJestConfig({ + moduleNameMapper: { + "^@models": "/src/models", + "^@services": "/src/services", + "^@repositories": "/src/repositories", + "^@types": "/src/types", + "^@utils": "/src/utils", + }, +}) diff --git a/packages/modules/providers/notification-local/package.json b/packages/modules/providers/notification-local/package.json index 0d4f578d18..e94e53ae72 100644 --- a/packages/modules/providers/notification-local/package.json +++ b/packages/modules/providers/notification-local/package.json @@ -9,7 +9,10 @@ "directory": "packages/modules/providers/notification-local" }, "files": [ - "dist" + "dist", + "!dist/**/__tests__", + "!dist/**/__mocks__", + "!dist/**/__fixtures__" ], "engines": { "node": ">=20" @@ -26,7 +29,7 @@ "cross-env": "^5.2.1", "jest": "^29.7.0", "rimraf": "^5.0.1", - "typescript": "^5.3.3" + "typescript": "^5.6.2" }, "dependencies": { "@medusajs/utils": "^1.11.9" diff --git a/packages/modules/providers/notification-local/tsconfig.json b/packages/modules/providers/notification-local/tsconfig.json index 62fd156294..90f3a70b38 100644 --- a/packages/modules/providers/notification-local/tsconfig.json +++ b/packages/modules/providers/notification-local/tsconfig.json @@ -1,33 +1,12 @@ { + "extends": "../../../../_tsconfig.base.json", "compilerOptions": { - "lib": ["es2021"], - "target": "es2021", - "jsx": "react-jsx" /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */, - "outDir": "./dist", - "esModuleInterop": true, - "declarationMap": true, - "declaration": true, - "module": "commonjs", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "noImplicitReturns": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "noImplicitThis": true, - "allowJs": true, - "skipLibCheck": true, - "downlevelIteration": true, // to use ES5 specific tooling - "inlineSourceMap": true /* Emit a single file with source maps instead of having a separate file. */ - }, - "include": ["src"], - "exclude": [ - "dist", - "build", - "src/**/__tests__", - "src/**/__mocks__", - "src/**/__fixtures__", - "node_modules", - ".eslintrc.js" - ] + "paths": { + "@models": ["./src/models"], + "@services": ["./src/services"], + "@repositories": ["./src/repositories"], + "@types": ["./src/types"], + "@utils": ["./src/utils"] + } + } } diff --git a/packages/modules/providers/notification-sendgrid/jest.config.js b/packages/modules/providers/notification-sendgrid/jest.config.js index 61fcbb7c82..818699559a 100644 --- a/packages/modules/providers/notification-sendgrid/jest.config.js +++ b/packages/modules/providers/notification-sendgrid/jest.config.js @@ -1,15 +1,10 @@ -module.exports = { - transform: { - "^.+\\.[jt]s$": [ - "@swc/jest", - { - jsc: { - parser: { syntax: "typescript", decorators: true }, - transform: { decoratorMetadata: true }, - }, - }, - ], +const defineJestConfig = require("../../../../define_jest_config") +module.exports = defineJestConfig({ + moduleNameMapper: { + "^@models": "/src/models", + "^@services": "/src/services", + "^@repositories": "/src/repositories", + "^@types": "/src/types", + "^@utils": "/src/utils", }, - testEnvironment: `node`, - moduleFileExtensions: [`js`, `jsx`, `ts`, `tsx`, `json`], -} +}) diff --git a/packages/modules/providers/notification-sendgrid/package.json b/packages/modules/providers/notification-sendgrid/package.json index 924fa621c6..67ceef3780 100644 --- a/packages/modules/providers/notification-sendgrid/package.json +++ b/packages/modules/providers/notification-sendgrid/package.json @@ -9,7 +9,10 @@ "directory": "packages/modules/providers/notification-sendgrid" }, "files": [ - "dist" + "dist", + "!dist/**/__tests__", + "!dist/**/__mocks__", + "!dist/**/__fixtures__" ], "engines": { "node": ">=20" @@ -28,7 +31,7 @@ "cross-env": "^5.2.1", "jest": "^29.7.0", "rimraf": "^5.0.1", - "typescript": "^5.3.3" + "typescript": "^5.6.2" }, "dependencies": { "@medusajs/utils": "^1.11.9", diff --git a/packages/modules/providers/notification-sendgrid/tsconfig.json b/packages/modules/providers/notification-sendgrid/tsconfig.json index 62fd156294..90f3a70b38 100644 --- a/packages/modules/providers/notification-sendgrid/tsconfig.json +++ b/packages/modules/providers/notification-sendgrid/tsconfig.json @@ -1,33 +1,12 @@ { + "extends": "../../../../_tsconfig.base.json", "compilerOptions": { - "lib": ["es2021"], - "target": "es2021", - "jsx": "react-jsx" /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */, - "outDir": "./dist", - "esModuleInterop": true, - "declarationMap": true, - "declaration": true, - "module": "commonjs", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "noImplicitReturns": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "noImplicitThis": true, - "allowJs": true, - "skipLibCheck": true, - "downlevelIteration": true, // to use ES5 specific tooling - "inlineSourceMap": true /* Emit a single file with source maps instead of having a separate file. */ - }, - "include": ["src"], - "exclude": [ - "dist", - "build", - "src/**/__tests__", - "src/**/__mocks__", - "src/**/__fixtures__", - "node_modules", - ".eslintrc.js" - ] + "paths": { + "@models": ["./src/models"], + "@services": ["./src/services"], + "@repositories": ["./src/repositories"], + "@types": ["./src/types"], + "@utils": ["./src/utils"] + } + } } diff --git a/packages/modules/providers/notification-sendgrid/tsconfig.spec.json b/packages/modules/providers/notification-sendgrid/tsconfig.spec.json deleted file mode 100644 index 9b62409191..0000000000 --- a/packages/modules/providers/notification-sendgrid/tsconfig.spec.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": ["src"], - "exclude": ["node_modules"] -} diff --git a/packages/modules/providers/payment-stripe/jest.config.js b/packages/modules/providers/payment-stripe/jest.config.js index 61fcbb7c82..818699559a 100644 --- a/packages/modules/providers/payment-stripe/jest.config.js +++ b/packages/modules/providers/payment-stripe/jest.config.js @@ -1,15 +1,10 @@ -module.exports = { - transform: { - "^.+\\.[jt]s$": [ - "@swc/jest", - { - jsc: { - parser: { syntax: "typescript", decorators: true }, - transform: { decoratorMetadata: true }, - }, - }, - ], +const defineJestConfig = require("../../../../define_jest_config") +module.exports = defineJestConfig({ + moduleNameMapper: { + "^@models": "/src/models", + "^@services": "/src/services", + "^@repositories": "/src/repositories", + "^@types": "/src/types", + "^@utils": "/src/utils", }, - testEnvironment: `node`, - moduleFileExtensions: [`js`, `jsx`, `ts`, `tsx`, `json`], -} +}) diff --git a/packages/modules/providers/payment-stripe/package.json b/packages/modules/providers/payment-stripe/package.json index 5660423b77..aaf1ef416a 100644 --- a/packages/modules/providers/payment-stripe/package.json +++ b/packages/modules/providers/payment-stripe/package.json @@ -9,7 +9,10 @@ "directory": "packages/payment-stripe" }, "files": [ - "dist" + "dist", + "!dist/**/__tests__", + "!dist/**/__mocks__", + "!dist/**/__fixtures__" ], "engines": { "node": ">=20" @@ -27,7 +30,7 @@ "cross-env": "^5.2.1", "jest": "^29.7.0", "rimraf": "^5.0.1", - "typescript": "^5.3.3" + "typescript": "^5.6.2" }, "peerDependencies": { "awilix": "^8.0.1" diff --git a/packages/modules/providers/payment-stripe/tsconfig.json b/packages/modules/providers/payment-stripe/tsconfig.json index 62fd156294..90f3a70b38 100644 --- a/packages/modules/providers/payment-stripe/tsconfig.json +++ b/packages/modules/providers/payment-stripe/tsconfig.json @@ -1,33 +1,12 @@ { + "extends": "../../../../_tsconfig.base.json", "compilerOptions": { - "lib": ["es2021"], - "target": "es2021", - "jsx": "react-jsx" /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */, - "outDir": "./dist", - "esModuleInterop": true, - "declarationMap": true, - "declaration": true, - "module": "commonjs", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "noImplicitReturns": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "noImplicitThis": true, - "allowJs": true, - "skipLibCheck": true, - "downlevelIteration": true, // to use ES5 specific tooling - "inlineSourceMap": true /* Emit a single file with source maps instead of having a separate file. */ - }, - "include": ["src"], - "exclude": [ - "dist", - "build", - "src/**/__tests__", - "src/**/__mocks__", - "src/**/__fixtures__", - "node_modules", - ".eslintrc.js" - ] + "paths": { + "@models": ["./src/models"], + "@services": ["./src/services"], + "@repositories": ["./src/repositories"], + "@types": ["./src/types"], + "@utils": ["./src/utils"] + } + } } diff --git a/packages/modules/providers/payment-stripe/tsconfig.spec.json b/packages/modules/providers/payment-stripe/tsconfig.spec.json deleted file mode 100644 index 9b62409191..0000000000 --- a/packages/modules/providers/payment-stripe/tsconfig.spec.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": ["src"], - "exclude": ["node_modules"] -} diff --git a/packages/modules/region/jest.config.js b/packages/modules/region/jest.config.js index d125300e58..3aab9b7072 100644 --- a/packages/modules/region/jest.config.js +++ b/packages/modules/region/jest.config.js @@ -1,22 +1,10 @@ -module.exports = { +const defineJestConfig = require("../../../define_jest_config") +module.exports = defineJestConfig({ moduleNameMapper: { "^@models": "/src/models", "^@services": "/src/services", "^@repositories": "/src/repositories", "^@types": "/src/types", + "^@utils": "/src/utils", }, - transform: { - "^.+\\.[jt]s$": [ - "@swc/jest", - { - jsc: { - parser: { syntax: "typescript", decorators: true }, - transform: { decoratorMetadata: true }, - }, - }, - ], - }, - testEnvironment: `node`, - moduleFileExtensions: [`js`, `ts`], - modulePathIgnorePatterns: ["dist/"], -} +}) diff --git a/packages/modules/region/package.json b/packages/modules/region/package.json index 008b303b15..92b82a2fc2 100644 --- a/packages/modules/region/package.json +++ b/packages/modules/region/package.json @@ -5,7 +5,10 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "files": [ - "dist" + "dist", + "!dist/**/__tests__", + "!dist/**/__mocks__", + "!dist/**/__fixtures__" ], "engines": { "node": ">=20" @@ -23,7 +26,8 @@ "scripts": { "watch": "tsc --build --watch", "watch:test": "tsc --build tsconfig.spec.json --watch", - "build": "rimraf dist && tsc --build && tsc-alias -p tsconfig.json", + "resolve:aliases": "tsc --showConfig -p tsconfig.json > tsconfig.resolved.json && tsc-alias -p tsconfig.resolved.json && rimraf tsconfig.resolved.json", + "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --runInBand --passWithNoTests --bail --forceExit -- src", "test:integration": "jest --forceExit -- integration-tests/**/__tests__/**/*.ts", "migration:generate": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:generate", @@ -41,7 +45,7 @@ "rimraf": "^3.0.2", "ts-node": "^10.9.1", "tsc-alias": "^1.8.6", - "typescript": "^5.1.6" + "typescript": "^5.6.2" }, "dependencies": { "@medusajs/utils": "^1.11.9" diff --git a/packages/modules/region/tsconfig.json b/packages/modules/region/tsconfig.json index 78342ef37b..748a37ffa8 100644 --- a/packages/modules/region/tsconfig.json +++ b/packages/modules/region/tsconfig.json @@ -1,38 +1,12 @@ { + "extends": "../../../_tsconfig.base.json", "compilerOptions": { - "lib": ["es2021"], - "target": "es2021", - "outDir": "./dist", - "esModuleInterop": true, - "declarationMap": true, - "declaration": true, - "module": "commonjs", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "sourceMap": false, - "noImplicitReturns": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "noImplicitThis": true, - "allowJs": true, - "skipLibCheck": true, - "downlevelIteration": true, // to use ES5 specific tooling - "baseUrl": ".", - "resolveJsonModule": true, "paths": { "@models": ["./src/models"], "@services": ["./src/services"], "@repositories": ["./src/repositories"], - "@types": ["./src/types"] + "@types": ["./src/types"], + "@utils": ["./src/utils"] } - }, - "include": ["src"], - "exclude": [ - "dist", - "./src/**/__tests__", - "./src/**/__mocks__", - "./src/**/__fixtures__", - "node_modules" - ] + } } diff --git a/packages/modules/region/tsconfig.spec.json b/packages/modules/region/tsconfig.spec.json deleted file mode 100644 index 48e47e8cbb..0000000000 --- a/packages/modules/region/tsconfig.spec.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": ["src", "integration-tests"], - "exclude": ["node_modules", "dist"], - "compilerOptions": { - "sourceMap": true - } -} diff --git a/packages/modules/sales-channel/jest.config.js b/packages/modules/sales-channel/jest.config.js index d125300e58..3aab9b7072 100644 --- a/packages/modules/sales-channel/jest.config.js +++ b/packages/modules/sales-channel/jest.config.js @@ -1,22 +1,10 @@ -module.exports = { +const defineJestConfig = require("../../../define_jest_config") +module.exports = defineJestConfig({ moduleNameMapper: { "^@models": "/src/models", "^@services": "/src/services", "^@repositories": "/src/repositories", "^@types": "/src/types", + "^@utils": "/src/utils", }, - transform: { - "^.+\\.[jt]s$": [ - "@swc/jest", - { - jsc: { - parser: { syntax: "typescript", decorators: true }, - transform: { decoratorMetadata: true }, - }, - }, - ], - }, - testEnvironment: `node`, - moduleFileExtensions: [`js`, `ts`], - modulePathIgnorePatterns: ["dist/"], -} +}) diff --git a/packages/modules/sales-channel/package.json b/packages/modules/sales-channel/package.json index 9ebf5530df..19a2534fff 100644 --- a/packages/modules/sales-channel/package.json +++ b/packages/modules/sales-channel/package.json @@ -5,7 +5,10 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "files": [ - "dist" + "dist", + "!dist/**/__tests__", + "!dist/**/__mocks__", + "!dist/**/__fixtures__" ], "engines": { "node": ">=20" @@ -23,7 +26,8 @@ "scripts": { "watch": "tsc --build --watch", "watch:test": "tsc --build tsconfig.spec.json --watch", - "build": "rimraf dist && tsc --build && tsc-alias -p tsconfig.json", + "resolve:aliases": "tsc --showConfig -p tsconfig.json > tsconfig.resolved.json && tsc-alias -p tsconfig.resolved.json && rimraf tsconfig.resolved.json", + "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --runInBand --bail --forceExit -- src/**/__tests__/**/*.ts", "test:integration": "jest --forceExit -- integration-tests/**/__tests__/**/*.ts", "migration:generate": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:generate", @@ -41,7 +45,7 @@ "rimraf": "^3.0.2", "ts-node": "^10.9.1", "tsc-alias": "^1.8.6", - "typescript": "^5.1.6" + "typescript": "^5.6.2" }, "dependencies": { "@medusajs/utils": "^1.11.9" diff --git a/packages/modules/sales-channel/tsconfig.json b/packages/modules/sales-channel/tsconfig.json index 78342ef37b..748a37ffa8 100644 --- a/packages/modules/sales-channel/tsconfig.json +++ b/packages/modules/sales-channel/tsconfig.json @@ -1,38 +1,12 @@ { + "extends": "../../../_tsconfig.base.json", "compilerOptions": { - "lib": ["es2021"], - "target": "es2021", - "outDir": "./dist", - "esModuleInterop": true, - "declarationMap": true, - "declaration": true, - "module": "commonjs", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "sourceMap": false, - "noImplicitReturns": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "noImplicitThis": true, - "allowJs": true, - "skipLibCheck": true, - "downlevelIteration": true, // to use ES5 specific tooling - "baseUrl": ".", - "resolveJsonModule": true, "paths": { "@models": ["./src/models"], "@services": ["./src/services"], "@repositories": ["./src/repositories"], - "@types": ["./src/types"] + "@types": ["./src/types"], + "@utils": ["./src/utils"] } - }, - "include": ["src"], - "exclude": [ - "dist", - "./src/**/__tests__", - "./src/**/__mocks__", - "./src/**/__fixtures__", - "node_modules" - ] + } } diff --git a/packages/modules/sales-channel/tsconfig.spec.json b/packages/modules/sales-channel/tsconfig.spec.json deleted file mode 100644 index 48e47e8cbb..0000000000 --- a/packages/modules/sales-channel/tsconfig.spec.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": ["src", "integration-tests"], - "exclude": ["node_modules", "dist"], - "compilerOptions": { - "sourceMap": true - } -} diff --git a/packages/modules/stock-location-next/jest.config.js b/packages/modules/stock-location-next/jest.config.js index 3671181174..3aab9b7072 100644 --- a/packages/modules/stock-location-next/jest.config.js +++ b/packages/modules/stock-location-next/jest.config.js @@ -1,15 +1,10 @@ -module.exports = { - transform: { - "^.+\\.[jt]s$": [ - "@swc/jest", - { - jsc: { - parser: { syntax: "typescript", decorators: true }, - transform: { decoratorMetadata: true }, - }, - }, - ], +const defineJestConfig = require("../../../define_jest_config") +module.exports = defineJestConfig({ + moduleNameMapper: { + "^@models": "/src/models", + "^@services": "/src/services", + "^@repositories": "/src/repositories", + "^@types": "/src/types", + "^@utils": "/src/utils", }, - testEnvironment: `node`, - moduleFileExtensions: [`js`, `ts`], -} +}) diff --git a/packages/modules/stock-location-next/package.json b/packages/modules/stock-location-next/package.json index 37c9043378..c4380cfe26 100644 --- a/packages/modules/stock-location-next/package.json +++ b/packages/modules/stock-location-next/package.json @@ -15,7 +15,10 @@ "access": "public" }, "files": [ - "dist" + "dist", + "!dist/**/__tests__", + "!dist/**/__mocks__", + "!dist/**/__fixtures__" ], "author": "Medusa", "license": "MIT", @@ -28,7 +31,7 @@ "rimraf": "^5.0.1", "ts-node": "^10.9.1", "tsc-alias": "^1.8.6", - "typescript": "^5.1.6" + "typescript": "^5.6.2" }, "dependencies": { "@medusajs/utils": "^1.11.9" @@ -42,7 +45,8 @@ "scripts": { "watch": "tsc --build --watch", "watch:test": "tsc --build tsconfig.spec.json --watch", - "build": "rimraf dist && tsc --build && tsc-alias -p tsconfig.json", + "resolve:aliases": "tsc --showConfig -p tsconfig.json > tsconfig.resolved.json && tsc-alias -p tsconfig.resolved.json && rimraf tsconfig.resolved.json", + "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --runInBand --bail --forceExit -- src/**/__tests__/**/*.ts", "test:integration": "jest --runInBand --forceExit -- integration-tests/**/__tests__/**/*.spec.ts", "migration:generate": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:generate", diff --git a/packages/modules/stock-location-next/src/models/stock-location-address.ts b/packages/modules/stock-location-next/src/models/stock-location-address.ts index d8ec2f3771..b968d16473 100644 --- a/packages/modules/stock-location-next/src/models/stock-location-address.ts +++ b/packages/modules/stock-location-next/src/models/stock-location-address.ts @@ -68,12 +68,12 @@ export class StockLocationAddress { metadata: Record | null @BeforeCreate() - private beforeCreate(): void { + beforeCreate(): void { this.id = generateEntityId(this.id, "laddr") } @OnInit() - private onInit(): void { + onInit(): void { this.id = generateEntityId(this.id, "laddr") } } diff --git a/packages/modules/stock-location-next/src/models/stock-location.ts b/packages/modules/stock-location-next/src/models/stock-location.ts index f27140ee3b..a3c95f0ad8 100644 --- a/packages/modules/stock-location-next/src/models/stock-location.ts +++ b/packages/modules/stock-location-next/src/models/stock-location.ts @@ -69,12 +69,12 @@ export class StockLocation { metadata: Record | null @BeforeCreate() - private beforeCreate(): void { + beforeCreate(): void { this.id = generateEntityId(this.id, "sloc") } @OnInit() - private onInit(): void { + onInit(): void { this.id = generateEntityId(this.id, "sloc") } } diff --git a/packages/modules/stock-location-next/tsconfig.json b/packages/modules/stock-location-next/tsconfig.json index e3f64c5ff6..748a37ffa8 100644 --- a/packages/modules/stock-location-next/tsconfig.json +++ b/packages/modules/stock-location-next/tsconfig.json @@ -1,25 +1,6 @@ { + "extends": "../../../_tsconfig.base.json", "compilerOptions": { - "lib": ["es2021"], - "target": "es2021", - "outDir": "./dist", - "esModuleInterop": true, - "declarationMap": true, - "declaration": true, - "module": "commonjs", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "sourceMap": false, - "noImplicitReturns": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "noImplicitThis": true, - "allowJs": true, - "skipLibCheck": true, - "downlevelIteration": true, // to use ES5 specific tooling - "baseUrl": ".", - "resolveJsonModule": true, "paths": { "@models": ["./src/models"], "@services": ["./src/services"], @@ -27,13 +8,5 @@ "@types": ["./src/types"], "@utils": ["./src/utils"] } - }, - "include": ["src"], - "exclude": [ - "dist", - "./src/**/__tests__", - "./src/**/__mocks__", - "./src/**/__fixtures__", - "node_modules" - ] + } } diff --git a/packages/modules/stock-location-next/tsconfig.spec.json b/packages/modules/stock-location-next/tsconfig.spec.json deleted file mode 100644 index 9b62409191..0000000000 --- a/packages/modules/stock-location-next/tsconfig.spec.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": ["src"], - "exclude": ["node_modules"] -} diff --git a/packages/modules/store/jest.config.js b/packages/modules/store/jest.config.js index d125300e58..3aab9b7072 100644 --- a/packages/modules/store/jest.config.js +++ b/packages/modules/store/jest.config.js @@ -1,22 +1,10 @@ -module.exports = { +const defineJestConfig = require("../../../define_jest_config") +module.exports = defineJestConfig({ moduleNameMapper: { "^@models": "/src/models", "^@services": "/src/services", "^@repositories": "/src/repositories", "^@types": "/src/types", + "^@utils": "/src/utils", }, - transform: { - "^.+\\.[jt]s$": [ - "@swc/jest", - { - jsc: { - parser: { syntax: "typescript", decorators: true }, - transform: { decoratorMetadata: true }, - }, - }, - ], - }, - testEnvironment: `node`, - moduleFileExtensions: [`js`, `ts`], - modulePathIgnorePatterns: ["dist/"], -} +}) diff --git a/packages/modules/store/package.json b/packages/modules/store/package.json index 16422cd79a..18e9c07a65 100644 --- a/packages/modules/store/package.json +++ b/packages/modules/store/package.json @@ -5,7 +5,10 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "files": [ - "dist" + "dist", + "!dist/**/__tests__", + "!dist/**/__mocks__", + "!dist/**/__fixtures__" ], "engines": { "node": ">=20" @@ -23,7 +26,8 @@ "scripts": { "watch": "tsc --build --watch", "watch:test": "tsc --build tsconfig.spec.json --watch", - "build": "rimraf dist && tsc --build && tsc-alias -p tsconfig.json", + "resolve:aliases": "tsc --showConfig -p tsconfig.json > tsconfig.resolved.json && tsc-alias -p tsconfig.resolved.json && rimraf tsconfig.resolved.json", + "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --runInBand --bail --forceExit -- src/**/__tests__/**/*.ts", "test:integration": "jest --forceExit -- integration-tests/**/__tests__/**/*.ts", "migration:generate": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:generate", @@ -41,7 +45,7 @@ "rimraf": "^3.0.2", "ts-node": "^10.9.1", "tsc-alias": "^1.8.6", - "typescript": "^5.1.6" + "typescript": "^5.6.2" }, "dependencies": { "@medusajs/utils": "^1.11.9" diff --git a/packages/modules/store/tsconfig.json b/packages/modules/store/tsconfig.json index 78342ef37b..748a37ffa8 100644 --- a/packages/modules/store/tsconfig.json +++ b/packages/modules/store/tsconfig.json @@ -1,38 +1,12 @@ { + "extends": "../../../_tsconfig.base.json", "compilerOptions": { - "lib": ["es2021"], - "target": "es2021", - "outDir": "./dist", - "esModuleInterop": true, - "declarationMap": true, - "declaration": true, - "module": "commonjs", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "sourceMap": false, - "noImplicitReturns": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "noImplicitThis": true, - "allowJs": true, - "skipLibCheck": true, - "downlevelIteration": true, // to use ES5 specific tooling - "baseUrl": ".", - "resolveJsonModule": true, "paths": { "@models": ["./src/models"], "@services": ["./src/services"], "@repositories": ["./src/repositories"], - "@types": ["./src/types"] + "@types": ["./src/types"], + "@utils": ["./src/utils"] } - }, - "include": ["src"], - "exclude": [ - "dist", - "./src/**/__tests__", - "./src/**/__mocks__", - "./src/**/__fixtures__", - "node_modules" - ] + } } diff --git a/packages/modules/store/tsconfig.spec.json b/packages/modules/store/tsconfig.spec.json deleted file mode 100644 index 48e47e8cbb..0000000000 --- a/packages/modules/store/tsconfig.spec.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": ["src", "integration-tests"], - "exclude": ["node_modules", "dist"], - "compilerOptions": { - "sourceMap": true - } -} diff --git a/packages/modules/tax/jest.config.js b/packages/modules/tax/jest.config.js index d125300e58..3aab9b7072 100644 --- a/packages/modules/tax/jest.config.js +++ b/packages/modules/tax/jest.config.js @@ -1,22 +1,10 @@ -module.exports = { +const defineJestConfig = require("../../../define_jest_config") +module.exports = defineJestConfig({ moduleNameMapper: { "^@models": "/src/models", "^@services": "/src/services", "^@repositories": "/src/repositories", "^@types": "/src/types", + "^@utils": "/src/utils", }, - transform: { - "^.+\\.[jt]s$": [ - "@swc/jest", - { - jsc: { - parser: { syntax: "typescript", decorators: true }, - transform: { decoratorMetadata: true }, - }, - }, - ], - }, - testEnvironment: `node`, - moduleFileExtensions: [`js`, `ts`], - modulePathIgnorePatterns: ["dist/"], -} +}) diff --git a/packages/modules/tax/package.json b/packages/modules/tax/package.json index ccfab351e4..cc313c2af8 100644 --- a/packages/modules/tax/package.json +++ b/packages/modules/tax/package.json @@ -5,7 +5,10 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "files": [ - "dist" + "dist", + "!dist/**/__tests__", + "!dist/**/__mocks__", + "!dist/**/__fixtures__" ], "engines": { "node": ">=20" @@ -23,7 +26,8 @@ "scripts": { "watch": "tsc --build --watch", "watch:test": "tsc --build tsconfig.spec.json --watch", - "build": "rimraf dist && tsc --build && tsc-alias -p tsconfig.json", + "resolve:aliases": "tsc --showConfig -p tsconfig.json > tsconfig.resolved.json && tsc-alias -p tsconfig.resolved.json && rimraf tsconfig.resolved.json", + "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --runInBand --bail --forceExit -- src/**/__tests__/**/*.ts", "test:integration": "jest --forceExit -- integration-tests/**/__tests__/**/*.spec.ts", "migration:generate": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:generate", @@ -41,7 +45,7 @@ "rimraf": "^3.0.2", "ts-node": "^10.9.1", "tsc-alias": "^1.8.6", - "typescript": "^5.1.6" + "typescript": "^5.6.2" }, "dependencies": { "@medusajs/modules-sdk": "^1.12.11", diff --git a/packages/modules/tax/src/models/tax-rate-rule.ts b/packages/modules/tax/src/models/tax-rate-rule.ts index 4614d38b9e..aca6224c0c 100644 --- a/packages/modules/tax/src/models/tax-rate-rule.ts +++ b/packages/modules/tax/src/models/tax-rate-rule.ts @@ -28,6 +28,11 @@ const taxRateIdIndexStatement = createPsqlIndexStatementHelper({ columns: "tax_rate_id", where: "deleted_at IS NULL", }) +const deletedAtIndexStatement = createPsqlIndexStatementHelper({ + tableName: TABLE_NAME, + columns: "deleted_at", + where: "deleted_at IS NOT NULL", +}) const referenceIdIndexName = "IDX_tax_rate_rule_reference_id" const referenceIdIndexStatement = createPsqlIndexStatementHelper({ @@ -96,11 +101,7 @@ export default class TaxRateRule { @Property({ columnType: "text", nullable: true }) created_by: string | null = null - @createPsqlIndexStatementHelper({ - tableName: TABLE_NAME, - columns: "deleted_at", - where: "deleted_at IS NOT NULL", - }).MikroORMIndex() + @deletedAtIndexStatement.MikroORMIndex() @Property({ columnType: "timestamptz", nullable: true }) deleted_at: Date | null = null diff --git a/packages/modules/tax/src/models/tax-rate.ts b/packages/modules/tax/src/models/tax-rate.ts index bfbffb1b94..3d4cb95d3f 100644 --- a/packages/modules/tax/src/models/tax-rate.ts +++ b/packages/modules/tax/src/models/tax-rate.ts @@ -42,6 +42,11 @@ const taxRegionIdIndexStatement = createPsqlIndexStatementHelper({ columns: "tax_region_id", where: "deleted_at IS NULL", }) +const deletedAtIndexStatement = createPsqlIndexStatementHelper({ + tableName: TABLE_NAME, + columns: "deleted_at", + where: "deleted_at IS NOT NULL", +}) @singleDefaultRegionIndexStatement.MikroORMIndex() @Entity({ tableName: TABLE_NAME }) @@ -107,11 +112,7 @@ export default class TaxRate { @Property({ columnType: "text", nullable: true }) created_by: string | null = null - @createPsqlIndexStatementHelper({ - tableName: TABLE_NAME, - columns: "deleted_at", - where: "deleted_at IS NOT NULL", - }).MikroORMIndex() + @deletedAtIndexStatement.MikroORMIndex() @Property({ columnType: "timestamptz", nullable: true }) deleted_at: Date | null = null diff --git a/packages/modules/tax/src/models/tax-region.ts b/packages/modules/tax/src/models/tax-region.ts index e37f824c73..400fd577c9 100644 --- a/packages/modules/tax/src/models/tax-region.ts +++ b/packages/modules/tax/src/models/tax-region.ts @@ -38,6 +38,11 @@ const countryCodeProvinceIndexStatement = createPsqlIndexStatementHelper({ unique: true, where: "deleted_at IS NULL", }) +const deletedAtIndexStatement = createPsqlIndexStatementHelper({ + tableName: TABLE_NAME, + columns: "deleted_at", + where: "deleted_at IS NOT NULL", +}) const countryCodeNullableProvinceIndexStatement = createPsqlIndexStatementHelper({ @@ -132,11 +137,7 @@ export default class TaxRegion { @Property({ columnType: "text", nullable: true }) created_by: string | null = null - @createPsqlIndexStatementHelper({ - tableName: TABLE_NAME, - columns: "deleted_at", - where: "deleted_at IS NOT NULL", - }).MikroORMIndex() + @deletedAtIndexStatement.MikroORMIndex() @Property({ columnType: "timestamptz", nullable: true }) deleted_at: Date | null = null diff --git a/packages/modules/tax/tsconfig.json b/packages/modules/tax/tsconfig.json index 78342ef37b..748a37ffa8 100644 --- a/packages/modules/tax/tsconfig.json +++ b/packages/modules/tax/tsconfig.json @@ -1,38 +1,12 @@ { + "extends": "../../../_tsconfig.base.json", "compilerOptions": { - "lib": ["es2021"], - "target": "es2021", - "outDir": "./dist", - "esModuleInterop": true, - "declarationMap": true, - "declaration": true, - "module": "commonjs", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "sourceMap": false, - "noImplicitReturns": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "noImplicitThis": true, - "allowJs": true, - "skipLibCheck": true, - "downlevelIteration": true, // to use ES5 specific tooling - "baseUrl": ".", - "resolveJsonModule": true, "paths": { "@models": ["./src/models"], "@services": ["./src/services"], "@repositories": ["./src/repositories"], - "@types": ["./src/types"] + "@types": ["./src/types"], + "@utils": ["./src/utils"] } - }, - "include": ["src"], - "exclude": [ - "dist", - "./src/**/__tests__", - "./src/**/__mocks__", - "./src/**/__fixtures__", - "node_modules" - ] + } } diff --git a/packages/modules/tax/tsconfig.spec.json b/packages/modules/tax/tsconfig.spec.json deleted file mode 100644 index 48e47e8cbb..0000000000 --- a/packages/modules/tax/tsconfig.spec.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": ["src", "integration-tests"], - "exclude": ["node_modules", "dist"], - "compilerOptions": { - "sourceMap": true - } -} diff --git a/packages/modules/user/jest.config.js b/packages/modules/user/jest.config.js index d125300e58..3aab9b7072 100644 --- a/packages/modules/user/jest.config.js +++ b/packages/modules/user/jest.config.js @@ -1,22 +1,10 @@ -module.exports = { +const defineJestConfig = require("../../../define_jest_config") +module.exports = defineJestConfig({ moduleNameMapper: { "^@models": "/src/models", "^@services": "/src/services", "^@repositories": "/src/repositories", "^@types": "/src/types", + "^@utils": "/src/utils", }, - transform: { - "^.+\\.[jt]s$": [ - "@swc/jest", - { - jsc: { - parser: { syntax: "typescript", decorators: true }, - transform: { decoratorMetadata: true }, - }, - }, - ], - }, - testEnvironment: `node`, - moduleFileExtensions: [`js`, `ts`], - modulePathIgnorePatterns: ["dist/"], -} +}) diff --git a/packages/modules/user/package.json b/packages/modules/user/package.json index 748da18781..8e113a708d 100644 --- a/packages/modules/user/package.json +++ b/packages/modules/user/package.json @@ -5,7 +5,10 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "files": [ - "dist" + "dist", + "!dist/**/__tests__", + "!dist/**/__mocks__", + "!dist/**/__fixtures__" ], "engines": { "node": ">=20" @@ -23,7 +26,8 @@ "scripts": { "watch": "tsc --build --watch", "watch:test": "tsc --build tsconfig.spec.json --watch", - "build": "rimraf dist && tsc --build && tsc-alias -p tsconfig.json", + "resolve:aliases": "tsc --showConfig -p tsconfig.json > tsconfig.resolved.json && tsc-alias -p tsconfig.resolved.json && rimraf tsconfig.resolved.json", + "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --runInBand --passWithNoTests --bail --forceExit -- src", "test:integration": "jest --forceExit -- integration-tests/**/__tests__/**/*.ts", "migration:generate": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:generate", @@ -43,7 +47,7 @@ "rimraf": "^3.0.2", "ts-node": "^10.9.1", "tsc-alias": "^1.8.6", - "typescript": "^5.1.6" + "typescript": "^5.6.2" }, "dependencies": { "@medusajs/utils": "^1.11.9", diff --git a/packages/modules/user/tsconfig.json b/packages/modules/user/tsconfig.json index e97f654a8c..748a37ffa8 100644 --- a/packages/modules/user/tsconfig.json +++ b/packages/modules/user/tsconfig.json @@ -1,39 +1,12 @@ { + "extends": "../../../_tsconfig.base.json", "compilerOptions": { - "lib": ["es2021"], - "target": "es2021", - "outDir": "./dist", - "esModuleInterop": true, - "declarationMap": true, - "declaration": true, - "module": "commonjs", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "sourceMap": false, - "noImplicitReturns": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "noImplicitThis": true, - "allowJs": true, - "skipLibCheck": true, - "downlevelIteration": true, - // to use ES5 specific tooling - "baseUrl": ".", - "resolveJsonModule": true, "paths": { "@models": ["./src/models"], "@services": ["./src/services"], "@repositories": ["./src/repositories"], - "@types": ["./src/types"] + "@types": ["./src/types"], + "@utils": ["./src/utils"] } - }, - "include": ["src"], - "exclude": [ - "dist", - "./src/**/__tests__", - "./src/**/__mocks__", - "./src/**/__fixtures__", - "node_modules" - ] + } } diff --git a/packages/modules/user/tsconfig.spec.json b/packages/modules/user/tsconfig.spec.json deleted file mode 100644 index 48e47e8cbb..0000000000 --- a/packages/modules/user/tsconfig.spec.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": ["src", "integration-tests"], - "exclude": ["node_modules", "dist"], - "compilerOptions": { - "sourceMap": true - } -} diff --git a/packages/modules/workflow-engine-inmemory/jest.config.js b/packages/modules/workflow-engine-inmemory/jest.config.js index d125300e58..3aab9b7072 100644 --- a/packages/modules/workflow-engine-inmemory/jest.config.js +++ b/packages/modules/workflow-engine-inmemory/jest.config.js @@ -1,22 +1,10 @@ -module.exports = { +const defineJestConfig = require("../../../define_jest_config") +module.exports = defineJestConfig({ moduleNameMapper: { "^@models": "/src/models", "^@services": "/src/services", "^@repositories": "/src/repositories", "^@types": "/src/types", + "^@utils": "/src/utils", }, - transform: { - "^.+\\.[jt]s$": [ - "@swc/jest", - { - jsc: { - parser: { syntax: "typescript", decorators: true }, - transform: { decoratorMetadata: true }, - }, - }, - ], - }, - testEnvironment: `node`, - moduleFileExtensions: [`js`, `ts`], - modulePathIgnorePatterns: ["dist/"], -} +}) diff --git a/packages/modules/workflow-engine-inmemory/package.json b/packages/modules/workflow-engine-inmemory/package.json index 891ba83bd4..deb47b63a8 100644 --- a/packages/modules/workflow-engine-inmemory/package.json +++ b/packages/modules/workflow-engine-inmemory/package.json @@ -5,7 +5,10 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "files": [ - "dist" + "dist", + "!dist/**/__tests__", + "!dist/**/__mocks__", + "!dist/**/__fixtures__" ], "engines": { "node": ">=20" @@ -23,7 +26,8 @@ "scripts": { "watch": "tsc --build --watch", "watch:test": "tsc --build tsconfig.spec.json --watch", - "build": "rimraf dist && tsc --build && tsc-alias -p tsconfig.json", + "resolve:aliases": "tsc --showConfig -p tsconfig.json > tsconfig.resolved.json && tsc-alias -p tsconfig.resolved.json && rimraf tsconfig.resolved.json", + "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --passWithNoTests --runInBand --bail --forceExit -- src", "test:integration": "jest --silent --forceExit -- integration-tests/**/__tests__/**/*.ts", "migration:generate": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:generate", @@ -41,7 +45,7 @@ "rimraf": "^3.0.2", "ts-node": "^10.9.1", "tsc-alias": "^1.8.6", - "typescript": "^5.1.6" + "typescript": "^5.6.2" }, "dependencies": { "@medusajs/orchestration": "^0.5.7", diff --git a/packages/modules/workflow-engine-inmemory/src/utils/workflow-orchestrator-storage.ts b/packages/modules/workflow-engine-inmemory/src/utils/workflow-orchestrator-storage.ts index 45280a7fa9..b9488f0866 100644 --- a/packages/modules/workflow-engine-inmemory/src/utils/workflow-orchestrator-storage.ts +++ b/packages/modules/workflow-engine-inmemory/src/utils/workflow-orchestrator-storage.ts @@ -289,7 +289,7 @@ export class InMemoryDistributedTransactionStorage } async removeAll(): Promise { - for (const [key, job] of this.scheduled) { + for (const [key] of this.scheduled) { await this.remove(key) } } diff --git a/packages/modules/workflow-engine-inmemory/tsconfig.json b/packages/modules/workflow-engine-inmemory/tsconfig.json index 78342ef37b..748a37ffa8 100644 --- a/packages/modules/workflow-engine-inmemory/tsconfig.json +++ b/packages/modules/workflow-engine-inmemory/tsconfig.json @@ -1,38 +1,12 @@ { + "extends": "../../../_tsconfig.base.json", "compilerOptions": { - "lib": ["es2021"], - "target": "es2021", - "outDir": "./dist", - "esModuleInterop": true, - "declarationMap": true, - "declaration": true, - "module": "commonjs", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "sourceMap": false, - "noImplicitReturns": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "noImplicitThis": true, - "allowJs": true, - "skipLibCheck": true, - "downlevelIteration": true, // to use ES5 specific tooling - "baseUrl": ".", - "resolveJsonModule": true, "paths": { "@models": ["./src/models"], "@services": ["./src/services"], "@repositories": ["./src/repositories"], - "@types": ["./src/types"] + "@types": ["./src/types"], + "@utils": ["./src/utils"] } - }, - "include": ["src"], - "exclude": [ - "dist", - "./src/**/__tests__", - "./src/**/__mocks__", - "./src/**/__fixtures__", - "node_modules" - ] + } } diff --git a/packages/modules/workflow-engine-inmemory/tsconfig.spec.json b/packages/modules/workflow-engine-inmemory/tsconfig.spec.json deleted file mode 100644 index 48e47e8cbb..0000000000 --- a/packages/modules/workflow-engine-inmemory/tsconfig.spec.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": ["src", "integration-tests"], - "exclude": ["node_modules", "dist"], - "compilerOptions": { - "sourceMap": true - } -} diff --git a/packages/modules/workflow-engine-redis/jest.config.js b/packages/modules/workflow-engine-redis/jest.config.js index d125300e58..3aab9b7072 100644 --- a/packages/modules/workflow-engine-redis/jest.config.js +++ b/packages/modules/workflow-engine-redis/jest.config.js @@ -1,22 +1,10 @@ -module.exports = { +const defineJestConfig = require("../../../define_jest_config") +module.exports = defineJestConfig({ moduleNameMapper: { "^@models": "/src/models", "^@services": "/src/services", "^@repositories": "/src/repositories", "^@types": "/src/types", + "^@utils": "/src/utils", }, - transform: { - "^.+\\.[jt]s$": [ - "@swc/jest", - { - jsc: { - parser: { syntax: "typescript", decorators: true }, - transform: { decoratorMetadata: true }, - }, - }, - ], - }, - testEnvironment: `node`, - moduleFileExtensions: [`js`, `ts`], - modulePathIgnorePatterns: ["dist/"], -} +}) diff --git a/packages/modules/workflow-engine-redis/package.json b/packages/modules/workflow-engine-redis/package.json index 9d199a5727..0f592d6a49 100644 --- a/packages/modules/workflow-engine-redis/package.json +++ b/packages/modules/workflow-engine-redis/package.json @@ -5,7 +5,10 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "files": [ - "dist" + "dist", + "!dist/**/__tests__", + "!dist/**/__mocks__", + "!dist/**/__fixtures__" ], "engines": { "node": ">=20" @@ -23,7 +26,8 @@ "scripts": { "watch": "tsc --build --watch", "watch:test": "tsc --build tsconfig.spec.json --watch", - "build": "rimraf dist && tsc --build && tsc-alias -p tsconfig.json", + "resolve:aliases": "tsc --showConfig -p tsconfig.json > tsconfig.resolved.json && tsc-alias -p tsconfig.resolved.json && rimraf tsconfig.resolved.json", + "build": "rimraf dist && tsc --build && npm run resolve:aliases", "test": "jest --passWithNoTests --runInBand --bail --forceExit -- src", "test:integration": "jest --forceExit -- integration-tests/**/__tests__/**/*.ts", "migration:generate": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:generate", @@ -41,7 +45,7 @@ "rimraf": "^3.0.2", "ts-node": "^10.9.1", "tsc-alias": "^1.8.6", - "typescript": "^5.1.6" + "typescript": "^5.6.2" }, "dependencies": { "@medusajs/orchestration": "^0.5.7", diff --git a/packages/modules/workflow-engine-redis/src/services/workflow-orchestrator.ts b/packages/modules/workflow-engine-redis/src/services/workflow-orchestrator.ts index 7f82432c8a..c5bf920537 100644 --- a/packages/modules/workflow-engine-redis/src/services/workflow-orchestrator.ts +++ b/packages/modules/workflow-engine-redis/src/services/workflow-orchestrator.ts @@ -92,7 +92,6 @@ export class WorkflowOrchestratorService { protected container_: MedusaContainer private subscribers: Subscribers = new Map() private activeStepsCount: number = 0 - private logger: Logger protected redisDistributedTransactionStorage_: RedisDistributedTransactionStorage @@ -101,7 +100,6 @@ export class WorkflowOrchestratorService { redisDistributedTransactionStorage, redisPublisher, redisSubscriber, - logger, sharedContainer, }: { dataLoaderOnly: boolean @@ -115,7 +113,6 @@ export class WorkflowOrchestratorService { this.container_ = sharedContainer this.redisPublisher = redisPublisher this.redisSubscriber = redisSubscriber - this.logger = logger redisDistributedTransactionStorage.setWorkflowOrchestratorService(this) @@ -263,7 +260,7 @@ export class WorkflowOrchestratorService { options?: WorkflowOrchestratorRunOptions, @MedusaContext() sharedContext: Context = {} ): Promise { - let { context, container } = options ?? {} + let { context } = options ?? {} if (!workflowId) { throw new Error("Workflow ID is required") diff --git a/packages/modules/workflow-engine-redis/src/utils/workflow-orchestrator-storage.ts b/packages/modules/workflow-engine-redis/src/utils/workflow-orchestrator-storage.ts index c9e1ece600..7df258de82 100644 --- a/packages/modules/workflow-engine-redis/src/utils/workflow-orchestrator-storage.ts +++ b/packages/modules/workflow-engine-redis/src/utils/workflow-orchestrator-storage.ts @@ -288,7 +288,7 @@ export class RedisDistributedTransactionStorage async scheduleTransactionTimeout( transaction: DistributedTransactionType, - timestamp: number, + _: number, interval: number ): Promise { await this.queue.add( diff --git a/packages/modules/workflow-engine-redis/tsconfig.json b/packages/modules/workflow-engine-redis/tsconfig.json index 78342ef37b..748a37ffa8 100644 --- a/packages/modules/workflow-engine-redis/tsconfig.json +++ b/packages/modules/workflow-engine-redis/tsconfig.json @@ -1,38 +1,12 @@ { + "extends": "../../../_tsconfig.base.json", "compilerOptions": { - "lib": ["es2021"], - "target": "es2021", - "outDir": "./dist", - "esModuleInterop": true, - "declarationMap": true, - "declaration": true, - "module": "commonjs", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "sourceMap": false, - "noImplicitReturns": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "noImplicitThis": true, - "allowJs": true, - "skipLibCheck": true, - "downlevelIteration": true, // to use ES5 specific tooling - "baseUrl": ".", - "resolveJsonModule": true, "paths": { "@models": ["./src/models"], "@services": ["./src/services"], "@repositories": ["./src/repositories"], - "@types": ["./src/types"] + "@types": ["./src/types"], + "@utils": ["./src/utils"] } - }, - "include": ["src"], - "exclude": [ - "dist", - "./src/**/__tests__", - "./src/**/__mocks__", - "./src/**/__fixtures__", - "node_modules" - ] + } } diff --git a/packages/modules/workflow-engine-redis/tsconfig.spec.json b/packages/modules/workflow-engine-redis/tsconfig.spec.json deleted file mode 100644 index 48e47e8cbb..0000000000 --- a/packages/modules/workflow-engine-redis/tsconfig.spec.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": ["src", "integration-tests"], - "exclude": ["node_modules", "dist"], - "compilerOptions": { - "sourceMap": true - } -} diff --git a/yarn.lock b/yarn.lock index 6a90e3f575..8722bd88d2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5582,7 +5582,7 @@ __metadata: rimraf: ^3.0.2 ts-node: ^10.9.1 tsc-alias: ^1.8.6 - typescript: ^5.1.6 + typescript: ^5.6.2 peerDependencies: "@mikro-orm/core": 5.9.7 "@mikro-orm/migrations": 5.9.7 @@ -5600,7 +5600,7 @@ __metadata: jest: ^29.7.0 rimraf: ^5.0.1 scrypt-kdf: ^2.0.1 - typescript: ^5.3.3 + typescript: ^5.6.2 languageName: unknown linkType: soft @@ -5615,7 +5615,7 @@ __metadata: jest: ^29.7.0 msw: ^2.3.0 rimraf: ^5.0.1 - typescript: ^5.1.6 + typescript: ^5.6.2 languageName: unknown linkType: soft @@ -5631,7 +5631,7 @@ __metadata: jsonwebtoken: ^9.0.2 msw: ^2.3.0 rimraf: ^5.0.1 - typescript: ^5.1.6 + typescript: ^5.6.2 languageName: unknown linkType: soft @@ -5651,7 +5651,7 @@ __metadata: scrypt-kdf: ^2.0.1 simple-oauth2: ^5.0.0 tsc-alias: ^1.8.6 - typescript: ^5.1.6 + typescript: ^5.6.2 peerDependencies: "@mikro-orm/core": 5.9.7 "@mikro-orm/migrations": 5.9.7 @@ -5670,7 +5670,7 @@ __metadata: cross-env: ^5.2.1 jest: ^29.7.0 rimraf: ^5.0.1 - typescript: ^5.1.6 + typescript: ^5.6.2 languageName: unknown linkType: soft @@ -5685,7 +5685,7 @@ __metadata: ioredis: ^5.4.1 jest: ^29.7.0 rimraf: ^5.0.1 - typescript: ^5.1.6 + typescript: ^5.6.2 peerDependencies: awilix: ^8.0.1 languageName: unknown @@ -5704,7 +5704,7 @@ __metadata: rimraf: ^3.0.2 ts-node: ^10.9.1 tsc-alias: ^1.8.6 - typescript: ^5.1.6 + typescript: ^5.6.2 peerDependencies: "@mikro-orm/core": 5.9.7 "@mikro-orm/migrations": 5.9.7 @@ -5747,7 +5747,7 @@ __metadata: rimraf: ^3.0.2 ts-node: ^10.9.1 tsc-alias: ^1.8.6 - typescript: ^5.1.6 + typescript: ^5.6.2 peerDependencies: "@mikro-orm/core": 5.9.7 "@mikro-orm/migrations": 5.9.7 @@ -5769,7 +5769,7 @@ __metadata: rimraf: ^3.0.2 ts-node: ^10.9.1 tsc-alias: ^1.8.6 - typescript: ^5.1.6 + typescript: ^5.6.2 peerDependencies: "@mikro-orm/core": 5.9.7 "@mikro-orm/migrations": 5.9.7 @@ -5842,7 +5842,7 @@ __metadata: cross-env: ^5.2.1 jest: ^29.7.0 rimraf: ^5.0.1 - typescript: ^5.1.6 + typescript: ^5.6.2 peerDependencies: ulid: ^2.3.0 languageName: unknown @@ -5861,7 +5861,7 @@ __metadata: jest: ^29.7.0 medusa-test-utils: ^1.1.44 rimraf: ^5.0.1 - typescript: ^5.1.6 + typescript: ^5.6.2 peerDependencies: awilix: ^8.0.1 languageName: unknown @@ -5875,7 +5875,7 @@ __metadata: cross-env: ^5.2.1 jest: ^29.7.0 rimraf: ^5.0.1 - typescript: ^5.3.3 + typescript: ^5.6.2 languageName: unknown linkType: soft @@ -5890,7 +5890,7 @@ __metadata: cross-env: ^5.2.1 jest: ^29.7.0 rimraf: ^5.0.1 - typescript: ^5.3.3 + typescript: ^5.6.2 peerDependencies: ulid: ^2.3.0 languageName: unknown @@ -5912,7 +5912,7 @@ __metadata: rimraf: ^3.0.2 ts-node: ^10.9.1 tsc-alias: ^1.8.6 - typescript: ^5.1.6 + typescript: ^5.6.2 peerDependencies: "@mikro-orm/core": 5.9.7 "@mikro-orm/migrations": 5.9.7 @@ -5966,7 +5966,7 @@ __metadata: express: ^4.17.1 jest: ^29.7.0 rimraf: ^5.0.1 - typescript: ^5.3.3 + typescript: ^5.6.2 languageName: unknown linkType: soft @@ -5985,7 +5985,7 @@ __metadata: rimraf: ^3.0.2 ts-node: ^10.9.1 tsc-alias: ^1.8.6 - typescript: ^5.1.6 + typescript: ^5.6.2 peerDependencies: "@mikro-orm/core": 5.9.7 "@mikro-orm/migrations": 5.9.7 @@ -6041,7 +6041,7 @@ __metadata: rimraf: ^3.0.2 ts-node: ^10.9.1 tsc-alias: ^1.8.6 - typescript: ^5.1.6 + typescript: ^5.6.2 peerDependencies: "@mikro-orm/core": 5.9.7 "@mikro-orm/migrations": 5.9.7 @@ -6063,7 +6063,7 @@ __metadata: rimraf: ^5.0.1 ts-node: ^10.9.1 tsc-alias: ^1.8.6 - typescript: ^5.1.6 + typescript: ^5.6.2 peerDependencies: "@mikro-orm/core": 5.9.7 "@mikro-orm/migrations": 5.9.7 @@ -6101,7 +6101,7 @@ __metadata: rimraf: ^5.0.1 ts-node: ^10.9.1 tsc-alias: ^1.8.6 - typescript: ^5.5.0 + typescript: ^5.6.2 peerDependencies: "@mikro-orm/core": 5.9.7 "@mikro-orm/migrations": 5.9.7 @@ -6268,7 +6268,7 @@ __metadata: cross-env: ^5.2.1 jest: ^29.7.0 rimraf: ^5.0.1 - typescript: ^5.3.3 + typescript: ^5.6.2 languageName: unknown linkType: soft @@ -6283,7 +6283,7 @@ __metadata: cross-env: ^5.2.1 jest: ^29.7.0 rimraf: ^5.0.1 - typescript: ^5.3.3 + typescript: ^5.6.2 languageName: unknown linkType: soft @@ -6301,7 +6301,7 @@ __metadata: rimraf: ^3.0.2 ts-node: ^10.9.1 tsc-alias: ^1.8.6 - typescript: ^5.1.6 + typescript: ^5.6.2 peerDependencies: "@mikro-orm/core": 5.9.7 "@mikro-orm/migrations": 5.9.7 @@ -6348,7 +6348,7 @@ __metadata: rimraf: ^3.0.2 ts-node: ^10.9.1 tsc-alias: ^1.8.6 - typescript: ^5.1.6 + typescript: ^5.6.2 peerDependencies: "@mikro-orm/core": 5.9.7 "@mikro-orm/migrations": 5.9.7 @@ -6370,7 +6370,7 @@ __metadata: jest: ^29.7.0 rimraf: ^5.0.1 stripe: latest - typescript: ^5.3.3 + typescript: ^5.6.2 peerDependencies: awilix: ^8.0.1 languageName: unknown @@ -6391,7 +6391,7 @@ __metadata: ts-jest: ^29.1.1 ts-node: ^10.9.1 tsc-alias: ^1.8.6 - typescript: ^5.1.6 + typescript: ^5.6.2 peerDependencies: "@mikro-orm/core": 5.9.7 "@mikro-orm/migrations": 5.9.7 @@ -6415,7 +6415,7 @@ __metadata: ts-jest: ^29.1.1 ts-node: ^10.9.1 tsc-alias: ^1.8.6 - typescript: ^5.1.6 + typescript: ^5.6.2 peerDependencies: "@mikro-orm/core": 5.9.7 "@mikro-orm/migrations": 5.9.7 @@ -6439,7 +6439,7 @@ __metadata: rimraf: ^3.0.2 ts-node: ^10.9.1 tsc-alias: ^1.8.6 - typescript: ^5.1.6 + typescript: ^5.6.2 peerDependencies: "@mikro-orm/core": 5.9.7 "@mikro-orm/migrations": 5.9.7 @@ -6462,7 +6462,7 @@ __metadata: ts-jest: ^29.1.1 ts-node: ^10.9.1 tsc-alias: ^1.8.6 - typescript: ^5.1.6 + typescript: ^5.6.2 peerDependencies: "@mikro-orm/core": 5.9.7 "@mikro-orm/migrations": 5.9.7 @@ -6484,7 +6484,7 @@ __metadata: rimraf: ^3.0.2 ts-node: ^10.9.1 tsc-alias: ^1.8.6 - typescript: ^5.1.6 + typescript: ^5.6.2 peerDependencies: "@mikro-orm/core": 5.9.7 "@mikro-orm/migrations": 5.9.7 @@ -6506,7 +6506,7 @@ __metadata: rimraf: ^3.0.2 ts-node: ^10.9.1 tsc-alias: ^1.8.6 - typescript: ^5.1.6 + typescript: ^5.6.2 peerDependencies: "@mikro-orm/core": 5.9.7 "@mikro-orm/migrations": 5.9.7 @@ -6528,7 +6528,7 @@ __metadata: rimraf: ^5.0.1 ts-node: ^10.9.1 tsc-alias: ^1.8.6 - typescript: ^5.1.6 + typescript: ^5.6.2 peerDependencies: "@mikro-orm/core": 5.9.7 "@mikro-orm/migrations": 5.9.7 @@ -6550,7 +6550,7 @@ __metadata: rimraf: ^3.0.2 ts-node: ^10.9.1 tsc-alias: ^1.8.6 - typescript: ^5.1.6 + typescript: ^5.6.2 peerDependencies: "@mikro-orm/core": 5.9.7 "@mikro-orm/migrations": 5.9.7 @@ -6573,7 +6573,7 @@ __metadata: rimraf: ^3.0.2 ts-node: ^10.9.1 tsc-alias: ^1.8.6 - typescript: ^5.1.6 + typescript: ^5.6.2 peerDependencies: "@mikro-orm/core": 5.9.7 "@mikro-orm/migrations": 5.9.7 @@ -6728,7 +6728,7 @@ __metadata: rimraf: ^3.0.2 ts-node: ^10.9.1 tsc-alias: ^1.8.6 - typescript: ^5.1.6 + typescript: ^5.6.2 peerDependencies: "@mikro-orm/core": 5.9.7 "@mikro-orm/migrations": 5.9.7 @@ -6781,7 +6781,7 @@ __metadata: rimraf: ^3.0.2 ts-node: ^10.9.1 tsc-alias: ^1.8.6 - typescript: ^5.1.6 + typescript: ^5.6.2 peerDependencies: "@mikro-orm/core": 5.9.7 "@mikro-orm/migrations": 5.9.7 @@ -6807,7 +6807,7 @@ __metadata: rimraf: ^3.0.2 ts-node: ^10.9.1 tsc-alias: ^1.8.6 - typescript: ^5.1.6 + typescript: ^5.6.2 peerDependencies: "@mikro-orm/core": 5.9.7 "@mikro-orm/migrations": 5.9.7 @@ -32791,16 +32791,6 @@ __metadata: languageName: node linkType: hard -"typescript@npm:^5.5.0": - version: 5.5.3 - resolution: "typescript@npm:5.5.3" - bin: - tsc: bin/tsc - tsserver: bin/tsserver - checksum: f52c71ccbc7080b034b9d3b72051d563601a4815bf3e39ded188e6ce60813f75dbedf11ad15dd4d32a12996a9ed8c7155b46c93a9b9c9bad1049766fe614bbdd - languageName: node - linkType: hard - "typescript@npm:^5.6.2": version: 5.6.2 resolution: "typescript@npm:5.6.2" @@ -32861,16 +32851,6 @@ __metadata: languageName: node linkType: hard -"typescript@patch:typescript@^5.5.0#~builtin": - version: 5.5.3 - resolution: "typescript@patch:typescript@npm%3A5.5.3#~builtin::version=5.5.3&hash=7ad353" - bin: - tsc: bin/tsc - tsserver: bin/tsserver - checksum: 5a437c416251334deeaf29897157032311f3f126547cfdc4b133768b606cb0e62bcee733bb97cf74c42fe7268801aea1392d8e40988cdef112e9546eba4c03c5 - languageName: node - linkType: hard - "typescript@patch:typescript@^5.6.2#~builtin": version: 5.6.2 resolution: "typescript@patch:typescript@npm%3A5.6.2#~builtin::version=5.6.2&hash=7ad353"