chore: dependecies reorg (#8535)
This commit is contained in:
committed by
GitHub
parent
59599ac237
commit
058378970a
@@ -34,7 +34,6 @@
|
||||
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@medusajs/modules-sdk": "^1.12.11",
|
||||
"@medusajs/types": "^1.11.16",
|
||||
"@mikro-orm/cli": "5.9.7",
|
||||
"cross-env": "^5.2.1",
|
||||
@@ -46,10 +45,12 @@
|
||||
"typescript": "^5.1.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"@medusajs/utils": "^1.11.9",
|
||||
"@mikro-orm/core": "5.9.7",
|
||||
"@mikro-orm/migrations": "5.9.7",
|
||||
"@mikro-orm/postgresql": "5.9.7",
|
||||
"awilix": "^8.0.0"
|
||||
"@medusajs/utils": "^1.11.9"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@mikro-orm/core": "*",
|
||||
"@mikro-orm/migrations": "*",
|
||||
"@mikro-orm/postgresql": "*",
|
||||
"awilix": "*"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,13 +45,15 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@medusajs/modules-sdk": "^1.12.9",
|
||||
"@medusajs/utils": "^1.11.7",
|
||||
"@mikro-orm/core": "5.9.7",
|
||||
"@mikro-orm/migrations": "5.9.7",
|
||||
"@mikro-orm/postgresql": "5.9.7",
|
||||
"awilix": "^8.0.0",
|
||||
"@medusajs/utils": "^1.11.9",
|
||||
"jsonwebtoken": "^9.0.2",
|
||||
"scrypt-kdf": "^2.0.1",
|
||||
"simple-oauth2": "^5.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@mikro-orm/core": "*",
|
||||
"@mikro-orm/migrations": "*",
|
||||
"@mikro-orm/postgresql": "*",
|
||||
"awilix": "*"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
"author": "Medusa",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@medusajs/types": "^1.11.6",
|
||||
"@medusajs/types": "^1.11.9",
|
||||
"cross-env": "^5.2.1",
|
||||
"jest": "^29.7.0",
|
||||
"rimraf": "^5.0.1",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ModuleExports } from "@medusajs/modules-sdk"
|
||||
import { ModuleExports } from "@medusajs/types"
|
||||
import InMemoryCacheService from "./services/inmemory-cache"
|
||||
|
||||
const service = InMemoryCacheService
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { MedusaModule } from "@medusajs/modules-sdk"
|
||||
import {
|
||||
ExternalModuleDeclaration,
|
||||
ICacheService,
|
||||
InternalModuleDeclaration,
|
||||
MedusaModule,
|
||||
} from "@medusajs/modules-sdk"
|
||||
import { ICacheService } from "@medusajs/types"
|
||||
import { InMemoryCacheModuleOptions } from "../types"
|
||||
} from "@medusajs/types"
|
||||
import { Modules } from "@medusajs/utils"
|
||||
import { InMemoryCacheModuleOptions } from "../types"
|
||||
|
||||
export const initialize = async (
|
||||
options?: InMemoryCacheModuleOptions | ExternalModuleDeclaration
|
||||
|
||||
@@ -35,7 +35,9 @@
|
||||
"dependencies": {
|
||||
"@medusajs/modules-sdk": "^1.12.11",
|
||||
"@medusajs/utils": "^1.11.9",
|
||||
"awilix": "^8.0.0",
|
||||
"ioredis": "^5.4.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"awilix": "*"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ModuleExports } from "@medusajs/modules-sdk"
|
||||
import { ModuleExports } from "@medusajs/types"
|
||||
import Loader from "./loaders"
|
||||
import { RedisCacheService } from "./services"
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { MedusaModule } from "@medusajs/modules-sdk"
|
||||
import {
|
||||
ExternalModuleDeclaration,
|
||||
ICacheService,
|
||||
InternalModuleDeclaration,
|
||||
MedusaModule,
|
||||
} from "@medusajs/modules-sdk"
|
||||
import { ICacheService } from "@medusajs/types"
|
||||
import { RedisCacheModuleOptions } from "../types"
|
||||
} from "@medusajs/types"
|
||||
import { Modules } from "@medusajs/utils"
|
||||
import { RedisCacheModuleOptions } from "../types"
|
||||
|
||||
export const initialize = async (
|
||||
options?: RedisCacheModuleOptions | ExternalModuleDeclaration
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { LoaderOptions } from "@medusajs/modules-sdk"
|
||||
import { LoaderOptions } from "@medusajs/types"
|
||||
import { asValue } from "awilix"
|
||||
import Redis from "ioredis"
|
||||
import { RedisCacheModuleOptions } from "../types"
|
||||
|
||||
@@ -34,8 +34,7 @@
|
||||
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@medusajs/modules-sdk": "^1.12.11",
|
||||
"@medusajs/types": "workspace:^",
|
||||
"@medusajs/types": "^1.11.16",
|
||||
"@mikro-orm/cli": "5.9.7",
|
||||
"cross-env": "^5.2.1",
|
||||
"jest": "^29.7.0",
|
||||
@@ -46,10 +45,12 @@
|
||||
"typescript": "^5.1.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"@medusajs/utils": "^1.11.9",
|
||||
"@mikro-orm/core": "5.9.7",
|
||||
"@mikro-orm/migrations": "5.9.7",
|
||||
"@mikro-orm/postgresql": "5.9.7",
|
||||
"awilix": "^8.0.0"
|
||||
"@medusajs/utils": "^1.11.9"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@mikro-orm/core": "*",
|
||||
"@mikro-orm/migrations": "*",
|
||||
"@mikro-orm/postgresql": "*",
|
||||
"awilix": "*"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,22 +34,23 @@
|
||||
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@medusajs/modules-sdk": "^1.12.11",
|
||||
"@medusajs/types": "^1.11.16",
|
||||
"@mikro-orm/cli": "5.9.7",
|
||||
"cross-env": "^5.2.1",
|
||||
"jest": "^29.7.0",
|
||||
"medusa-test-utils": "workspace:^",
|
||||
"medusa-test-utils": "^1.1.44",
|
||||
"rimraf": "^3.0.2",
|
||||
"ts-node": "^10.9.1",
|
||||
"tsc-alias": "^1.8.6",
|
||||
"typescript": "^5.1.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"@medusajs/utils": "^1.11.9",
|
||||
"@mikro-orm/core": "5.9.7",
|
||||
"@mikro-orm/migrations": "5.9.7",
|
||||
"@mikro-orm/postgresql": "5.9.7",
|
||||
"awilix": "^8.0.0"
|
||||
"@medusajs/utils": "^1.11.9"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@mikro-orm/core": "*",
|
||||
"@mikro-orm/migrations": "*",
|
||||
"@mikro-orm/postgresql": "*",
|
||||
"awilix": "*"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
"orm:cache:clear": "MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@medusajs/types": "workspace:^",
|
||||
"@medusajs/types": "^1.11.16",
|
||||
"@mikro-orm/cli": "5.9.7",
|
||||
"cross-env": "^5.2.1",
|
||||
"jest": "^29.7.0",
|
||||
@@ -45,11 +45,12 @@
|
||||
"typescript": "^5.1.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"@medusajs/modules-sdk": "^1.12.11",
|
||||
"@medusajs/utils": "^1.11.9",
|
||||
"@mikro-orm/core": "5.9.7",
|
||||
"@mikro-orm/migrations": "5.9.7",
|
||||
"@mikro-orm/postgresql": "5.9.7",
|
||||
"awilix": "^8.0.0"
|
||||
"@medusajs/utils": "^1.11.9"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@mikro-orm/core": "*",
|
||||
"@mikro-orm/migrations": "*",
|
||||
"@mikro-orm/postgresql": "*",
|
||||
"awilix": "*"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@medusajs/modules-sdk": "^1.12.8",
|
||||
"@medusajs/utils": "^1.11.5",
|
||||
"@medusajs/utils": "^1.11.9",
|
||||
"ulid": "^2.3.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ModuleExports } from "@medusajs/modules-sdk"
|
||||
import { ModuleExports } from "@medusajs/types"
|
||||
import Loader from "./loaders"
|
||||
import LocalEventBus from "./services/event-bus-local"
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { LoaderOptions } from "@medusajs/modules-sdk"
|
||||
import { LoaderOptions } from "@medusajs/types"
|
||||
|
||||
export default async ({ logger }: LoaderOptions): Promise<void> => {
|
||||
logger?.warn(
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { MedusaContainer } from "@medusajs/modules-sdk"
|
||||
import {
|
||||
Event,
|
||||
EventBusTypes,
|
||||
Logger,
|
||||
MedusaContainer,
|
||||
Message,
|
||||
Event,
|
||||
Subscriber,
|
||||
} from "@medusajs/types"
|
||||
import { AbstractEventBusModuleService } from "@medusajs/utils"
|
||||
|
||||
@@ -36,8 +36,10 @@
|
||||
"dependencies": {
|
||||
"@medusajs/modules-sdk": "^1.12.11",
|
||||
"@medusajs/utils": "^1.11.9",
|
||||
"awilix": "^8.0.0",
|
||||
"bullmq": "5.12.0",
|
||||
"ioredis": "^5.4.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"awilix": "*"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ModuleExports } from "@medusajs/modules-sdk"
|
||||
import { ModuleExports } from "@medusajs/types"
|
||||
import Loader from "./loaders"
|
||||
import RedisEventBusService from "./services/event-bus-redis"
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { MedusaModule } from "@medusajs/modules-sdk"
|
||||
import {
|
||||
ExternalModuleDeclaration,
|
||||
IEventBusService,
|
||||
InternalModuleDeclaration,
|
||||
MedusaModule,
|
||||
} from "@medusajs/modules-sdk"
|
||||
import { IEventBusService } from "@medusajs/types"
|
||||
import { EventBusRedisModuleOptions } from "../types"
|
||||
} from "@medusajs/types"
|
||||
import { Modules } from "@medusajs/utils"
|
||||
import { EventBusRedisModuleOptions } from "../types"
|
||||
|
||||
export const initialize = async (
|
||||
options?: EventBusRedisModuleOptions | ExternalModuleDeclaration
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { LoaderOptions } from "@medusajs/modules-sdk"
|
||||
import { LoaderOptions } from "@medusajs/types"
|
||||
import { asValue } from "awilix"
|
||||
import Redis from "ioredis"
|
||||
import { EOL } from "os"
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import { InternalModuleDeclaration } from "@medusajs/modules-sdk"
|
||||
import { Event, Logger, Message } from "@medusajs/types"
|
||||
import {
|
||||
Event,
|
||||
InternalModuleDeclaration,
|
||||
Logger,
|
||||
Message,
|
||||
} from "@medusajs/types"
|
||||
import {
|
||||
AbstractEventBusModuleService,
|
||||
isPresent,
|
||||
|
||||
@@ -48,10 +48,12 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@medusajs/modules-sdk": "^1.12.11",
|
||||
"@medusajs/utils": "^1.11.8",
|
||||
"@mikro-orm/core": "5.9.7",
|
||||
"@mikro-orm/migrations": "5.9.7",
|
||||
"@mikro-orm/postgresql": "5.9.7",
|
||||
"awilix": "^8.0.0"
|
||||
"@medusajs/utils": "^1.11.9"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@mikro-orm/core": "*",
|
||||
"@mikro-orm/migrations": "*",
|
||||
"@mikro-orm/postgresql": "*",
|
||||
"awilix": "*"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@medusajs/fulfillment-manual": "workspace:*",
|
||||
"@medusajs/types": "^1.11.16",
|
||||
"@mikro-orm/cli": "5.9.7",
|
||||
"cross-env": "^5.2.1",
|
||||
"jest": "^29.7.0",
|
||||
@@ -46,11 +47,12 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@medusajs/modules-sdk": "^1.12.11",
|
||||
"@medusajs/types": "^1.11.16",
|
||||
"@medusajs/utils": "^1.11.9",
|
||||
"@mikro-orm/core": "5.9.7",
|
||||
"@mikro-orm/migrations": "5.9.7",
|
||||
"@mikro-orm/postgresql": "5.9.7",
|
||||
"awilix": "^8.0.0"
|
||||
"@medusajs/utils": "^1.11.9"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@mikro-orm/core": "*",
|
||||
"@mikro-orm/migrations": "*",
|
||||
"@mikro-orm/postgresql": "*",
|
||||
"awilix": "*"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,12 +31,13 @@
|
||||
"typescript": "^5.1.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"@medusajs/modules-sdk": "^1.12.10",
|
||||
"@medusajs/utils": "^1.11.8",
|
||||
"@mikro-orm/core": "5.9.7",
|
||||
"@mikro-orm/migrations": "5.9.7",
|
||||
"@mikro-orm/postgresql": "5.9.7",
|
||||
"awilix": "^8.0.0"
|
||||
"@medusajs/utils": "^1.11.9"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@mikro-orm/core": "*",
|
||||
"@mikro-orm/migrations": "*",
|
||||
"@mikro-orm/postgresql": "*",
|
||||
"awilix": "*"
|
||||
},
|
||||
"scripts": {
|
||||
"watch": "tsc --build --watch",
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { InternalModuleDeclaration } from "@medusajs/modules-sdk"
|
||||
import {
|
||||
BigNumberInput,
|
||||
Context,
|
||||
DAL,
|
||||
InternalModuleDeclaration,
|
||||
InventoryTypes,
|
||||
ModuleJoinerConfig,
|
||||
ModulesSdkTypes,
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import { MedusaModule } from "@medusajs/modules-sdk"
|
||||
import { ILinkModule, ModuleJoinerConfig } from "@medusajs/types"
|
||||
import { defineLink, isObject, Modules } from "@medusajs/utils"
|
||||
import { moduleIntegrationTestRunner } from "medusa-test-utils"
|
||||
import { MigrationsExecutionPlanner } from "../../src"
|
||||
import { MedusaModule, ModuleJoinerConfig } from "@medusajs/modules-sdk"
|
||||
import {
|
||||
Car,
|
||||
carJoinerConfig,
|
||||
@@ -8,9 +11,6 @@ import {
|
||||
userJoinerConfig,
|
||||
UserModule,
|
||||
} from "../__fixtures__/migrations"
|
||||
import { defineLink, isObject, Modules } from "@medusajs/utils"
|
||||
import { moduleIntegrationTestRunner } from "medusa-test-utils"
|
||||
import { ILinkModule } from "@medusajs/types"
|
||||
|
||||
jest.setTimeout(30000)
|
||||
|
||||
|
||||
@@ -41,9 +41,12 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@medusajs/modules-sdk": "^1.12.11",
|
||||
"@medusajs/utils": "^1.11.9",
|
||||
"@mikro-orm/core": "5.9.7",
|
||||
"@mikro-orm/postgresql": "5.9.7",
|
||||
"awilix": "^8.0.0"
|
||||
"@medusajs/utils": "^1.11.9"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@mikro-orm/core": "*",
|
||||
"@mikro-orm/migrations": "*",
|
||||
"@mikro-orm/postgresql": "*",
|
||||
"awilix": "*"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import {
|
||||
InternalModuleDeclaration,
|
||||
MedusaModule,
|
||||
MODULE_RESOURCE_TYPE,
|
||||
MODULE_SCOPE,
|
||||
@@ -7,6 +6,7 @@ import {
|
||||
import {
|
||||
ExternalModuleDeclaration,
|
||||
ILinkModule,
|
||||
InternalModuleDeclaration,
|
||||
LinkModuleDefinition,
|
||||
ModuleExports,
|
||||
ModuleJoinerConfig,
|
||||
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
LoaderOptions,
|
||||
ModuleServiceInitializeCustomDataLayerOptions,
|
||||
ModuleServiceInitializeOptions,
|
||||
} from "@medusajs/modules-sdk"
|
||||
} from "@medusajs/types"
|
||||
import { ModulesSdkUtils } from "@medusajs/utils"
|
||||
|
||||
import { EntitySchema } from "@mikro-orm/core"
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { BaseRepository, getLinkRepository } from "@repositories"
|
||||
import { LinkService, getModuleService } from "@services"
|
||||
|
||||
import { LoaderOptions } from "@medusajs/modules-sdk"
|
||||
import {
|
||||
InternalModuleDeclaration,
|
||||
LoaderOptions,
|
||||
ModuleJoinerConfig,
|
||||
ModulesSdkTypes,
|
||||
} from "@medusajs/types"
|
||||
|
||||
@@ -46,10 +46,12 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@medusajs/modules-sdk": "^1.12.11",
|
||||
"@medusajs/utils": "^1.11.9",
|
||||
"@mikro-orm/core": "5.9.7",
|
||||
"@mikro-orm/migrations": "5.9.7",
|
||||
"@mikro-orm/postgresql": "5.9.7",
|
||||
"awilix": "^8.0.0"
|
||||
"@medusajs/utils": "^1.11.9"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@mikro-orm/core": "*",
|
||||
"@mikro-orm/migrations": "*",
|
||||
"@mikro-orm/postgresql": "*",
|
||||
"awilix": "*"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@medusajs/modules-sdk": "^1.12.11",
|
||||
"@medusajs/types": "^1.11.16",
|
||||
"@mikro-orm/cli": "5.9.7",
|
||||
"cross-env": "^5.2.1",
|
||||
@@ -46,10 +45,12 @@
|
||||
"typescript": "^5.1.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"@medusajs/utils": "^1.11.9",
|
||||
"@mikro-orm/core": "5.9.7",
|
||||
"@mikro-orm/migrations": "5.9.7",
|
||||
"@mikro-orm/postgresql": "5.9.7",
|
||||
"awilix": "^8.0.0"
|
||||
"@medusajs/utils": "^1.11.9"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@mikro-orm/core": "*",
|
||||
"@mikro-orm/migrations": "*",
|
||||
"@mikro-orm/postgresql": "*",
|
||||
"awilix": "*"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,11 +47,13 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@medusajs/modules-sdk": "^1.12.11",
|
||||
"@medusajs/utils": "^1.11.9",
|
||||
"@mikro-orm/core": "5.9.7",
|
||||
"@mikro-orm/migrations": "5.9.7",
|
||||
"@mikro-orm/postgresql": "5.9.7",
|
||||
"awilix": "^8.0.0",
|
||||
"bignumber.js": "^9.1.2"
|
||||
"@medusajs/utils": "^1.11.9"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@mikro-orm/core": "*",
|
||||
"@mikro-orm/migrations": "*",
|
||||
"@mikro-orm/postgresql": "*",
|
||||
"awilix": "*",
|
||||
"bignumber.js": "*"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@medusajs/modules-sdk": "^1.12.11",
|
||||
"@medusajs/types": "^1.11.16",
|
||||
"@mikro-orm/cli": "5.9.7",
|
||||
"cross-env": "^5.2.1",
|
||||
@@ -47,10 +46,12 @@
|
||||
"typescript": "^5.1.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"@medusajs/utils": "^1.11.9",
|
||||
"@mikro-orm/core": "5.9.7",
|
||||
"@mikro-orm/migrations": "5.9.7",
|
||||
"@mikro-orm/postgresql": "5.9.7",
|
||||
"awilix": "^8.0.0"
|
||||
"@medusajs/utils": "^1.11.9"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@mikro-orm/core": "*",
|
||||
"@mikro-orm/migrations": "*",
|
||||
"@mikro-orm/postgresql": "*",
|
||||
"awilix": "*"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import * as entities from "./src/models"
|
||||
import { defineMikroOrmCliConfig, Modules } from "@medusajs/utils"
|
||||
import * as entities from "./src/models"
|
||||
|
||||
export default defineMikroOrmCliConfig(Modules.PRODUCT, {
|
||||
entities: Object.values(entities),
|
||||
databaseName: "medusa-products",
|
||||
})
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@medusajs/modules-sdk": "^1.12.11",
|
||||
"@medusajs/types": "^1.11.16",
|
||||
"@mikro-orm/cli": "5.9.7",
|
||||
"cross-env": "^5.2.1",
|
||||
@@ -48,10 +47,12 @@
|
||||
"typescript": "^5.1.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"@medusajs/utils": "^1.11.9",
|
||||
"@mikro-orm/core": "5.9.7",
|
||||
"@mikro-orm/migrations": "5.9.7",
|
||||
"@mikro-orm/postgresql": "5.9.7",
|
||||
"awilix": "^8.0.0"
|
||||
"@medusajs/utils": "^1.11.9"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@mikro-orm/core": "*",
|
||||
"@mikro-orm/migrations": "*",
|
||||
"@mikro-orm/postgresql": "*",
|
||||
"awilix": "*"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@medusajs/modules-sdk": "^1.12.11",
|
||||
"@medusajs/types": "^1.11.16",
|
||||
"@mikro-orm/cli": "5.9.7",
|
||||
"cross-env": "^5.2.1",
|
||||
@@ -47,10 +46,12 @@
|
||||
"typescript": "^5.1.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"@medusajs/utils": "1.11.9",
|
||||
"@mikro-orm/core": "5.9.7",
|
||||
"@mikro-orm/migrations": "5.9.7",
|
||||
"@mikro-orm/postgresql": "5.9.7",
|
||||
"awilix": "^8.0.0"
|
||||
"@medusajs/utils": "1.11.9"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@mikro-orm/core": "*",
|
||||
"@mikro-orm/migrations": "*",
|
||||
"@mikro-orm/postgresql": "*",
|
||||
"awilix": "*"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
"typescript": "^5.3.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@medusajs/utils": "^1.11.7",
|
||||
"@medusajs/utils": "^1.11.9",
|
||||
"scrypt-kdf": "^2.0.1"
|
||||
},
|
||||
"keywords": [
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
"typescript": "^5.1.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"@medusajs/utils": "^1.11.7",
|
||||
"@medusajs/utils": "^1.11.9",
|
||||
"jsonwebtoken": "^9.0.2"
|
||||
},
|
||||
"keywords": [
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
"typescript": "^5.3.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@medusajs/utils": "^1.11.7"
|
||||
"@medusajs/utils": "^1.11.9"
|
||||
},
|
||||
"keywords": [
|
||||
"medusa-plugin",
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-s3": "^3.556.0",
|
||||
"@aws-sdk/s3-request-presigner": "^3.556.0",
|
||||
"@medusajs/utils": "^1.11.7",
|
||||
"@medusajs/utils": "^1.11.9",
|
||||
"ulid": "^2.3.0"
|
||||
},
|
||||
"keywords": [
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
"typescript": "^5.3.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@medusajs/utils": "^1.11.7",
|
||||
"@medusajs/utils": "^1.11.9",
|
||||
"body-parser": "^1.19.0",
|
||||
"express": "^4.17.1"
|
||||
},
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
"typescript": "^5.3.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@medusajs/utils": "^1.11.7"
|
||||
"@medusajs/utils": "^1.11.9"
|
||||
},
|
||||
"keywords": [
|
||||
"medusa-provider",
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
"typescript": "^5.3.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@medusajs/utils": "^1.11.7",
|
||||
"@medusajs/utils": "^1.11.9",
|
||||
"@sendgrid/mail": "^8.1.3"
|
||||
},
|
||||
"keywords": [
|
||||
|
||||
@@ -25,17 +25,16 @@
|
||||
"devDependencies": {
|
||||
"@medusajs/medusa": "^1.20.3",
|
||||
"@types/stripe": "^8.0.417",
|
||||
"awilix": "^8.0.1",
|
||||
"cross-env": "^5.2.1",
|
||||
"jest": "^29.7.0",
|
||||
"rimraf": "^5.0.1",
|
||||
"typescript": "^5.3.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@medusajs/medusa": "^1.12.0"
|
||||
"awilix": "*"
|
||||
},
|
||||
"dependencies": {
|
||||
"@medusajs/utils": "^1.11.7",
|
||||
"@medusajs/utils": "^1.11.9",
|
||||
"body-parser": "^1.19.0",
|
||||
"express": "^4.17.1",
|
||||
"stripe": "latest"
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@medusajs/modules-sdk": "^1.12.11",
|
||||
"@medusajs/types": "^1.11.16",
|
||||
"@mikro-orm/cli": "5.9.7",
|
||||
"cross-env": "^5.2.1",
|
||||
@@ -46,10 +45,12 @@
|
||||
"typescript": "^5.1.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"@medusajs/utils": "^1.11.9",
|
||||
"@mikro-orm/core": "5.9.7",
|
||||
"@mikro-orm/migrations": "5.9.7",
|
||||
"@mikro-orm/postgresql": "5.9.7",
|
||||
"awilix": "^8.0.0"
|
||||
"@medusajs/utils": "^1.11.9"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@mikro-orm/core": "*",
|
||||
"@mikro-orm/migrations": "*",
|
||||
"@mikro-orm/postgresql": "*",
|
||||
"awilix": "*"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@medusajs/modules-sdk": "^1.12.11",
|
||||
"@medusajs/types": "^1.11.14",
|
||||
"@mikro-orm/cli": "5.9.7",
|
||||
"cross-env": "^5.2.1",
|
||||
@@ -46,10 +45,12 @@
|
||||
"typescript": "^5.1.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"@medusajs/utils": "^1.11.7",
|
||||
"@mikro-orm/core": "5.9.7",
|
||||
"@mikro-orm/migrations": "5.9.7",
|
||||
"@mikro-orm/postgresql": "5.9.7",
|
||||
"awilix": "^8.0.0"
|
||||
"@medusajs/utils": "^1.11.9"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@mikro-orm/core": "*",
|
||||
"@mikro-orm/migrations": "*",
|
||||
"@mikro-orm/postgresql": "*",
|
||||
"awilix": "*"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,12 +31,13 @@
|
||||
"typescript": "^5.1.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"@medusajs/modules-sdk": "^1.12.11",
|
||||
"@medusajs/utils": "^1.11.9",
|
||||
"@mikro-orm/core": "5.9.7",
|
||||
"@mikro-orm/migrations": "5.9.7",
|
||||
"@mikro-orm/postgresql": "5.9.7",
|
||||
"awilix": "^8.0.0"
|
||||
"@medusajs/utils": "^1.11.9"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@mikro-orm/core": "*",
|
||||
"@mikro-orm/migrations": "*",
|
||||
"@mikro-orm/postgresql": "*",
|
||||
"awilix": "*"
|
||||
},
|
||||
"scripts": {
|
||||
"watch": "tsc --build --watch",
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { InternalModuleDeclaration } from "@medusajs/modules-sdk"
|
||||
import {
|
||||
Context,
|
||||
CreateStockLocationInput,
|
||||
@@ -6,6 +5,7 @@ import {
|
||||
FilterableStockLocationProps,
|
||||
IEventBusService,
|
||||
IStockLocationService,
|
||||
InternalModuleDeclaration,
|
||||
ModuleJoinerConfig,
|
||||
ModulesSdkTypes,
|
||||
StockLocationAddressInput,
|
||||
@@ -16,9 +16,9 @@ import {
|
||||
import {
|
||||
InjectManager,
|
||||
InjectTransactionManager,
|
||||
isString,
|
||||
MedusaContext,
|
||||
MedusaService,
|
||||
isString,
|
||||
promiseAll,
|
||||
} from "@medusajs/utils"
|
||||
import { joinerConfig } from "../joiner-config"
|
||||
|
||||
@@ -34,22 +34,23 @@
|
||||
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@medusajs/modules-sdk": "^1.12.11",
|
||||
"@medusajs/types": "^1.11.16",
|
||||
"@mikro-orm/cli": "5.9.7",
|
||||
"cross-env": "^5.2.1",
|
||||
"jest": "^29.7.0",
|
||||
"medusa-test-utils": "workspace:^",
|
||||
"medusa-test-utils": "^1.1.44",
|
||||
"rimraf": "^3.0.2",
|
||||
"ts-node": "^10.9.1",
|
||||
"tsc-alias": "^1.8.6",
|
||||
"typescript": "^5.1.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"@medusajs/utils": "^1.11.9",
|
||||
"@mikro-orm/core": "5.9.7",
|
||||
"@mikro-orm/migrations": "5.9.7",
|
||||
"@mikro-orm/postgresql": "5.9.7",
|
||||
"awilix": "^8.0.0"
|
||||
"@medusajs/utils": "^1.11.9"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@mikro-orm/core": "*",
|
||||
"@mikro-orm/migrations": "*",
|
||||
"@mikro-orm/postgresql": "*",
|
||||
"awilix": "*"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,10 +46,12 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@medusajs/modules-sdk": "^1.12.9",
|
||||
"@medusajs/utils": "^1.11.7",
|
||||
"@mikro-orm/core": "5.9.7",
|
||||
"@mikro-orm/migrations": "5.9.7",
|
||||
"@mikro-orm/postgresql": "5.9.7",
|
||||
"awilix": "^8.0.0"
|
||||
"@medusajs/utils": "^1.11.9"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@mikro-orm/core": "*",
|
||||
"@mikro-orm/migrations": "*",
|
||||
"@mikro-orm/postgresql": "*",
|
||||
"awilix": "*"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@medusajs/modules-sdk": "^1.12.11",
|
||||
"@medusajs/types": "^1.11.15",
|
||||
"@mikro-orm/cli": "5.9.7",
|
||||
"@swc/core": "^1.5.29",
|
||||
@@ -48,11 +47,13 @@
|
||||
"typescript": "^5.1.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"@medusajs/utils": "^1.11.8",
|
||||
"@mikro-orm/core": "5.9.7",
|
||||
"@mikro-orm/migrations": "5.9.7",
|
||||
"@mikro-orm/postgresql": "5.9.7",
|
||||
"awilix": "^8.0.0",
|
||||
"@medusajs/utils": "^1.11.9",
|
||||
"jsonwebtoken": "^9.0.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@mikro-orm/core": "*",
|
||||
"@mikro-orm/migrations": "*",
|
||||
"@mikro-orm/postgresql": "*",
|
||||
"awilix": "*"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import * as entities from "./src/models"
|
||||
import { defineMikroOrmCliConfig, Modules } from "@medusajs/utils"
|
||||
import * as entities from "./src/models"
|
||||
|
||||
export default defineMikroOrmCliConfig(Modules.WORKFLOW_ENGINE, {
|
||||
entities: Object.values(entities),
|
||||
databaseName: "medusa-workflow-engine-inmemory",
|
||||
})
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@medusajs/modules-sdk": "^1.12.11",
|
||||
"@medusajs/types": "^1.11.16",
|
||||
"@mikro-orm/cli": "5.9.7",
|
||||
"cross-env": "^5.2.1",
|
||||
@@ -46,12 +45,15 @@
|
||||
"typescript": "^5.1.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"@medusajs/orchestration": "^0.5.7",
|
||||
"@medusajs/utils": "^1.11.9",
|
||||
"@medusajs/workflows-sdk": "^0.1.6",
|
||||
"@mikro-orm/core": "5.9.7",
|
||||
"@mikro-orm/migrations": "5.9.7",
|
||||
"@mikro-orm/postgresql": "5.9.7",
|
||||
"awilix": "^8.0.0",
|
||||
"cron-parser": "^4.9.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@mikro-orm/core": "*",
|
||||
"@mikro-orm/migrations": "*",
|
||||
"@mikro-orm/postgresql": "*",
|
||||
"awilix": "*"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { MedusaApp } from "@medusajs/modules-sdk"
|
||||
import {
|
||||
TransactionStepTimeoutError,
|
||||
TransactionTimeoutError,
|
||||
@@ -15,428 +14,395 @@ import {
|
||||
Modules,
|
||||
TransactionHandlerType,
|
||||
TransactionStepState,
|
||||
createMedusaContainer,
|
||||
} from "@medusajs/utils"
|
||||
import { WorkflowsModuleService } from "@medusajs/workflow-engine-inmemory/dist/services"
|
||||
import { asFunction, asValue } from "awilix"
|
||||
import Redis from "ioredis"
|
||||
import { knex } from "knex"
|
||||
import { asValue } from "awilix"
|
||||
import { moduleIntegrationTestRunner } from "medusa-test-utils"
|
||||
import { setTimeout } from "timers/promises"
|
||||
import "../__fixtures__"
|
||||
import { createScheduled } from "../__fixtures__/workflow_scheduled"
|
||||
import { DB_URL, TestDatabase } from "../utils"
|
||||
import { TestDatabase } from "../utils"
|
||||
|
||||
jest.setTimeout(100000)
|
||||
|
||||
const sharedPgConnection = knex<any, any>({
|
||||
client: "pg",
|
||||
searchPath: process.env.MEDUSA_WORKFLOW_ENGINE_DB_SCHEMA,
|
||||
connection: {
|
||||
connectionString: DB_URL,
|
||||
debug: false,
|
||||
},
|
||||
})
|
||||
|
||||
const afterEach_ = async () => {
|
||||
await TestDatabase.clearTables(sharedPgConnection)
|
||||
}
|
||||
|
||||
function times(num) {
|
||||
let resolver
|
||||
let counter = 0
|
||||
const promise = new Promise((resolve) => {
|
||||
resolver = resolve
|
||||
})
|
||||
|
||||
return {
|
||||
next: () => {
|
||||
counter += 1
|
||||
if (counter === num) {
|
||||
resolver()
|
||||
}
|
||||
moduleIntegrationTestRunner<IWorkflowEngineService>({
|
||||
moduleName: Modules.WORKFLOW_ENGINE,
|
||||
resolve: __dirname + "/../..",
|
||||
moduleOptions: {
|
||||
redis: {
|
||||
url: "localhost:6379",
|
||||
},
|
||||
promise,
|
||||
}
|
||||
}
|
||||
},
|
||||
testSuite: ({ service: workflowOrcModule, medusaApp }) => {
|
||||
describe("Workflow Orchestrator module", function () {
|
||||
const afterEach_ = async () => {
|
||||
await TestDatabase.clearTables()
|
||||
}
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks()
|
||||
})
|
||||
|
||||
describe("Workflow Orchestrator module", function () {
|
||||
let workflowOrcModule: IWorkflowEngineService
|
||||
let query: RemoteQueryFunction
|
||||
let sharedContainer_: MedusaContainer
|
||||
function times(num) {
|
||||
let resolver
|
||||
let counter = 0
|
||||
const promise = new Promise((resolve) => {
|
||||
resolver = resolve
|
||||
})
|
||||
|
||||
beforeAll(async () => {
|
||||
const container = createMedusaContainer()
|
||||
container.register(ContainerRegistrationKeys.LOGGER, asValue(console))
|
||||
return {
|
||||
next: () => {
|
||||
counter += 1
|
||||
if (counter === num) {
|
||||
resolver()
|
||||
}
|
||||
},
|
||||
promise,
|
||||
}
|
||||
}
|
||||
|
||||
// Clear any residual data in Redis
|
||||
const redisClient = new Redis()
|
||||
redisClient.flushall()
|
||||
let query: RemoteQueryFunction
|
||||
let sharedContainer_: MedusaContainer
|
||||
|
||||
const {
|
||||
runMigrations,
|
||||
query: remoteQuery,
|
||||
modules,
|
||||
sharedContainer,
|
||||
onApplicationStart,
|
||||
} = await MedusaApp({
|
||||
sharedContainer: container,
|
||||
sharedResourcesConfig: {
|
||||
database: {
|
||||
connection: sharedPgConnection,
|
||||
},
|
||||
},
|
||||
modulesConfig: {
|
||||
workflows: {
|
||||
resolve: __dirname + "/../..",
|
||||
options: {
|
||||
redis: {
|
||||
url: "localhost:6379",
|
||||
beforeEach(() => {
|
||||
query = medusaApp.query
|
||||
sharedContainer_ = medusaApp.sharedContainer
|
||||
})
|
||||
|
||||
it(`should export the appropriate linkable configuration`, () => {
|
||||
const linkable = Module(Modules.WORKFLOW_ENGINE, {
|
||||
service: WorkflowsModuleService,
|
||||
}).linkable
|
||||
|
||||
expect(Object.keys(linkable)).toEqual(["workflowExecution"])
|
||||
|
||||
Object.keys(linkable).forEach((key) => {
|
||||
delete linkable[key].toJSON
|
||||
})
|
||||
|
||||
expect(linkable).toEqual({
|
||||
workflowExecution: {
|
||||
id: {
|
||||
linkable: "workflow_execution_id",
|
||||
primaryKey: "id",
|
||||
serviceName: "workflows",
|
||||
field: "workflowExecution",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
query = remoteQuery
|
||||
sharedContainer_ = sharedContainer!
|
||||
|
||||
await runMigrations()
|
||||
await onApplicationStart()
|
||||
|
||||
workflowOrcModule = modules.workflows as unknown as IWorkflowEngineService
|
||||
})
|
||||
|
||||
it(`should export the appropriate linkable configuration`, () => {
|
||||
const linkable = Module(Modules.WORKFLOW_ENGINE, {
|
||||
service: WorkflowsModuleService,
|
||||
}).linkable
|
||||
|
||||
expect(Object.keys(linkable)).toEqual(["workflowExecution"])
|
||||
|
||||
Object.keys(linkable).forEach((key) => {
|
||||
delete linkable[key].toJSON
|
||||
})
|
||||
|
||||
expect(linkable).toEqual({
|
||||
workflowExecution: {
|
||||
id: {
|
||||
linkable: "workflow_execution_id",
|
||||
primaryKey: "id",
|
||||
serviceName: "workflows",
|
||||
field: "workflowExecution",
|
||||
},
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
describe("Testing basic workflow", function () {
|
||||
afterEach(afterEach_)
|
||||
|
||||
it("should return a list of workflow executions and remove after completed when there is no retentionTime set", async () => {
|
||||
await workflowOrcModule.run("workflow_1", {
|
||||
input: {
|
||||
value: "123",
|
||||
},
|
||||
throwOnError: true,
|
||||
})
|
||||
})
|
||||
|
||||
let executionsList = await query({
|
||||
workflow_executions: {
|
||||
fields: ["workflow_id", "transaction_id", "state"],
|
||||
},
|
||||
})
|
||||
describe("Testing basic workflow", function () {
|
||||
afterEach(afterEach_)
|
||||
|
||||
expect(executionsList).toHaveLength(1)
|
||||
it("should return a list of workflow executions and remove after completed when there is no retentionTime set", async () => {
|
||||
await workflowOrcModule.run("workflow_1", {
|
||||
input: {
|
||||
value: "123",
|
||||
},
|
||||
throwOnError: true,
|
||||
})
|
||||
|
||||
const { result } = await workflowOrcModule.setStepSuccess({
|
||||
idempotencyKey: {
|
||||
action: TransactionHandlerType.INVOKE,
|
||||
stepId: "new_step_name",
|
||||
workflowId: "workflow_1",
|
||||
transactionId: executionsList[0].transaction_id,
|
||||
},
|
||||
stepResponse: { uhuuuu: "yeaah!" },
|
||||
})
|
||||
let executionsList = await query({
|
||||
workflow_executions: {
|
||||
fields: ["workflow_id", "transaction_id", "state"],
|
||||
},
|
||||
})
|
||||
|
||||
executionsList = await query({
|
||||
workflow_executions: {
|
||||
fields: ["id"],
|
||||
},
|
||||
})
|
||||
expect(executionsList).toHaveLength(1)
|
||||
|
||||
expect(executionsList).toHaveLength(0)
|
||||
expect(result).toEqual({
|
||||
done: {
|
||||
inputFromSyncStep: "oh",
|
||||
},
|
||||
})
|
||||
})
|
||||
const { result } = await workflowOrcModule.setStepSuccess({
|
||||
idempotencyKey: {
|
||||
action: TransactionHandlerType.INVOKE,
|
||||
stepId: "new_step_name",
|
||||
workflowId: "workflow_1",
|
||||
transactionId: executionsList[0].transaction_id,
|
||||
},
|
||||
stepResponse: { uhuuuu: "yeaah!" },
|
||||
})
|
||||
|
||||
it("should return a list of workflow executions and keep it saved when there is a retentionTime set", async () => {
|
||||
await workflowOrcModule.run("workflow_2", {
|
||||
input: {
|
||||
value: "123",
|
||||
},
|
||||
throwOnError: true,
|
||||
transactionId: "transaction_1",
|
||||
})
|
||||
executionsList = await query({
|
||||
workflow_executions: {
|
||||
fields: ["id"],
|
||||
},
|
||||
})
|
||||
|
||||
let executionsList = await query({
|
||||
workflow_executions: {
|
||||
fields: ["id"],
|
||||
},
|
||||
})
|
||||
expect(executionsList).toHaveLength(0)
|
||||
expect(result).toEqual({
|
||||
done: {
|
||||
inputFromSyncStep: "oh",
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
expect(executionsList).toHaveLength(1)
|
||||
it("should return a list of workflow executions and keep it saved when there is a retentionTime set", async () => {
|
||||
await workflowOrcModule.run("workflow_2", {
|
||||
input: {
|
||||
value: "123",
|
||||
},
|
||||
throwOnError: true,
|
||||
transactionId: "transaction_1",
|
||||
})
|
||||
|
||||
await workflowOrcModule.setStepSuccess({
|
||||
idempotencyKey: {
|
||||
action: TransactionHandlerType.INVOKE,
|
||||
stepId: "new_step_name",
|
||||
workflowId: "workflow_2",
|
||||
transactionId: "transaction_1",
|
||||
},
|
||||
stepResponse: { uhuuuu: "yeaah!" },
|
||||
})
|
||||
let executionsList = await query({
|
||||
workflow_executions: {
|
||||
fields: ["id"],
|
||||
},
|
||||
})
|
||||
|
||||
executionsList = await query({
|
||||
workflow_executions: {
|
||||
fields: ["id"],
|
||||
},
|
||||
})
|
||||
expect(executionsList).toHaveLength(1)
|
||||
|
||||
expect(executionsList).toHaveLength(1)
|
||||
})
|
||||
await workflowOrcModule.setStepSuccess({
|
||||
idempotencyKey: {
|
||||
action: TransactionHandlerType.INVOKE,
|
||||
stepId: "new_step_name",
|
||||
workflowId: "workflow_2",
|
||||
transactionId: "transaction_1",
|
||||
},
|
||||
stepResponse: { uhuuuu: "yeaah!" },
|
||||
})
|
||||
|
||||
it("should revert the entire transaction when a step timeout expires", async () => {
|
||||
const { transaction, result, errors } = await workflowOrcModule.run(
|
||||
"workflow_step_timeout",
|
||||
{
|
||||
input: {
|
||||
executionsList = await query({
|
||||
workflow_executions: {
|
||||
fields: ["id"],
|
||||
},
|
||||
})
|
||||
|
||||
expect(executionsList).toHaveLength(1)
|
||||
})
|
||||
|
||||
it("should revert the entire transaction when a step timeout expires", async () => {
|
||||
const { transaction, result, errors } = await workflowOrcModule.run(
|
||||
"workflow_step_timeout",
|
||||
{
|
||||
input: {
|
||||
myInput: "123",
|
||||
},
|
||||
throwOnError: false,
|
||||
logOnError: true,
|
||||
}
|
||||
)
|
||||
|
||||
expect(transaction.flow.state).toEqual("reverted")
|
||||
expect(result).toEqual({
|
||||
myInput: "123",
|
||||
},
|
||||
throwOnError: false,
|
||||
logOnError: true,
|
||||
}
|
||||
)
|
||||
})
|
||||
expect(errors).toHaveLength(1)
|
||||
expect(errors[0].action).toEqual("step_1")
|
||||
expect(errors[0].error).toBeInstanceOf(TransactionStepTimeoutError)
|
||||
})
|
||||
|
||||
expect(transaction.flow.state).toEqual("reverted")
|
||||
expect(result).toEqual({
|
||||
myInput: "123",
|
||||
})
|
||||
expect(errors).toHaveLength(1)
|
||||
expect(errors[0].action).toEqual("step_1")
|
||||
expect(errors[0].error).toBeInstanceOf(TransactionStepTimeoutError)
|
||||
})
|
||||
it("should revert the entire transaction when the transaction timeout expires", async () => {
|
||||
const { transaction, result, errors } = await workflowOrcModule.run(
|
||||
"workflow_transaction_timeout",
|
||||
{
|
||||
input: {},
|
||||
transactionId: "trx",
|
||||
throwOnError: false,
|
||||
}
|
||||
)
|
||||
|
||||
it("should revert the entire transaction when the transaction timeout expires", async () => {
|
||||
const { transaction, result, errors } = await workflowOrcModule.run(
|
||||
"workflow_transaction_timeout",
|
||||
{
|
||||
input: {},
|
||||
transactionId: "trx",
|
||||
throwOnError: false,
|
||||
}
|
||||
)
|
||||
expect(transaction.flow.state).toEqual("reverted")
|
||||
expect(result).toEqual({ executed: true })
|
||||
expect(errors).toHaveLength(1)
|
||||
expect(errors[0].action).toEqual("step_1")
|
||||
expect(
|
||||
TransactionTimeoutError.isTransactionTimeoutError(errors[0].error)
|
||||
).toBe(true)
|
||||
})
|
||||
|
||||
expect(transaction.flow.state).toEqual("reverted")
|
||||
expect(result).toEqual({ executed: true })
|
||||
expect(errors).toHaveLength(1)
|
||||
expect(errors[0].action).toEqual("step_1")
|
||||
expect(
|
||||
TransactionTimeoutError.isTransactionTimeoutError(errors[0].error)
|
||||
).toBe(true)
|
||||
})
|
||||
it("should revert the entire transaction when a step timeout expires in a async step", async () => {
|
||||
await workflowOrcModule.run("workflow_step_timeout_async", {
|
||||
input: {
|
||||
myInput: "123",
|
||||
},
|
||||
transactionId: "transaction_1",
|
||||
throwOnError: false,
|
||||
})
|
||||
|
||||
it("should revert the entire transaction when a step timeout expires in a async step", async () => {
|
||||
await workflowOrcModule.run("workflow_step_timeout_async", {
|
||||
input: {
|
||||
myInput: "123",
|
||||
},
|
||||
transactionId: "transaction_1",
|
||||
throwOnError: false,
|
||||
})
|
||||
await setTimeout(200)
|
||||
|
||||
await setTimeout(200)
|
||||
const { transaction, result, errors } = await workflowOrcModule.run(
|
||||
"workflow_step_timeout_async",
|
||||
{
|
||||
input: {
|
||||
myInput: "123",
|
||||
},
|
||||
transactionId: "transaction_1",
|
||||
throwOnError: false,
|
||||
}
|
||||
)
|
||||
|
||||
const { transaction, result, errors } = await workflowOrcModule.run(
|
||||
"workflow_step_timeout_async",
|
||||
{
|
||||
input: {
|
||||
expect(transaction.flow.state).toEqual("reverted")
|
||||
expect(result).toEqual(undefined)
|
||||
expect(errors).toHaveLength(1)
|
||||
expect(errors[0].action).toEqual("step_1_async")
|
||||
expect(
|
||||
TransactionStepTimeoutError.isTransactionStepTimeoutError(
|
||||
errors[0].error
|
||||
)
|
||||
).toBe(true)
|
||||
})
|
||||
|
||||
it("should revert the entire transaction when the transaction timeout expires in a transaction containing an async step", async () => {
|
||||
await workflowOrcModule.run("workflow_transaction_timeout_async", {
|
||||
input: {},
|
||||
transactionId: "transaction_1",
|
||||
throwOnError: false,
|
||||
})
|
||||
|
||||
await setTimeout(200)
|
||||
|
||||
const { transaction, result, errors } = await workflowOrcModule.run(
|
||||
"workflow_transaction_timeout_async",
|
||||
{
|
||||
input: {},
|
||||
transactionId: "transaction_1",
|
||||
throwOnError: false,
|
||||
}
|
||||
)
|
||||
|
||||
expect(transaction.flow.state).toEqual("reverted")
|
||||
expect(result).toEqual(undefined)
|
||||
expect(errors).toHaveLength(1)
|
||||
expect(errors[0].action).toEqual("step_1")
|
||||
expect(
|
||||
TransactionTimeoutError.isTransactionTimeoutError(errors[0].error)
|
||||
).toBe(true)
|
||||
})
|
||||
|
||||
it("should complete an async workflow that returns a StepResponse", async () => {
|
||||
const { transaction, result } = await workflowOrcModule.run(
|
||||
"workflow_async_background",
|
||||
{
|
||||
input: {
|
||||
myInput: "123",
|
||||
},
|
||||
transactionId: "transaction_1",
|
||||
throwOnError: false,
|
||||
}
|
||||
)
|
||||
|
||||
expect(transaction.flow.state).toEqual(TransactionStepState.INVOKING)
|
||||
expect(result).toEqual(undefined)
|
||||
|
||||
await setTimeout(205)
|
||||
|
||||
const trx = await workflowOrcModule.run("workflow_async_background", {
|
||||
input: {
|
||||
myInput: "123",
|
||||
},
|
||||
transactionId: "transaction_1",
|
||||
throwOnError: false,
|
||||
})
|
||||
|
||||
expect(trx.transaction.flow.state).toEqual(TransactionStepState.DONE)
|
||||
expect(trx.result).toEqual({
|
||||
myInput: "123",
|
||||
},
|
||||
transactionId: "transaction_1",
|
||||
throwOnError: false,
|
||||
}
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
expect(transaction.flow.state).toEqual("reverted")
|
||||
expect(result).toEqual(undefined)
|
||||
expect(errors).toHaveLength(1)
|
||||
expect(errors[0].action).toEqual("step_1_async")
|
||||
expect(
|
||||
TransactionStepTimeoutError.isTransactionStepTimeoutError(
|
||||
errors[0].error
|
||||
)
|
||||
).toBe(true)
|
||||
})
|
||||
it("should subsctibe to a async workflow and receive the response when it finishes", (done) => {
|
||||
const transactionId = "trx_123"
|
||||
|
||||
it("should revert the entire transaction when the transaction timeout expires in a transaction containing an async step", async () => {
|
||||
await workflowOrcModule.run("workflow_transaction_timeout_async", {
|
||||
input: {},
|
||||
transactionId: "transaction_1",
|
||||
throwOnError: false,
|
||||
const onFinish = jest.fn(() => {
|
||||
done()
|
||||
})
|
||||
|
||||
void workflowOrcModule.run("workflow_async_background", {
|
||||
input: {
|
||||
myInput: "123",
|
||||
},
|
||||
transactionId,
|
||||
throwOnError: false,
|
||||
})
|
||||
|
||||
void workflowOrcModule.subscribe({
|
||||
workflowId: "workflow_async_background",
|
||||
transactionId,
|
||||
subscriber: (event) => {
|
||||
if (event.eventType === "onFinish") {
|
||||
onFinish()
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
expect(onFinish).toHaveBeenCalledTimes(0)
|
||||
})
|
||||
})
|
||||
|
||||
await setTimeout(200)
|
||||
// Note: These tests depend on actual Redis instance and waiting for the scheduled jobs to run, which isn't great.
|
||||
// Mocking bullmq, however, would make the tests close to useless, so we can keep them very minimal and serve as smoke tests.
|
||||
describe("Scheduled workflows", () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks()
|
||||
})
|
||||
|
||||
const { transaction, result, errors } = await workflowOrcModule.run(
|
||||
"workflow_transaction_timeout_async",
|
||||
{
|
||||
input: {},
|
||||
transactionId: "transaction_1",
|
||||
throwOnError: false,
|
||||
}
|
||||
)
|
||||
it("should execute a scheduled workflow", async () => {
|
||||
const wait = times(2)
|
||||
const spy = createScheduled("standard", wait.next)
|
||||
|
||||
expect(transaction.flow.state).toEqual("reverted")
|
||||
expect(result).toEqual(undefined)
|
||||
expect(errors).toHaveLength(1)
|
||||
expect(errors[0].action).toEqual("step_1")
|
||||
expect(
|
||||
TransactionTimeoutError.isTransactionTimeoutError(errors[0].error)
|
||||
).toBe(true)
|
||||
})
|
||||
await wait.promise
|
||||
expect(spy).toHaveBeenCalledTimes(2)
|
||||
WorkflowManager.unregister("standard")
|
||||
})
|
||||
|
||||
it("should complete an async workflow that returns a StepResponse", async () => {
|
||||
const { transaction, result } = await workflowOrcModule.run(
|
||||
"workflow_async_background",
|
||||
{
|
||||
input: {
|
||||
myInput: "123",
|
||||
},
|
||||
transactionId: "transaction_1",
|
||||
throwOnError: false,
|
||||
}
|
||||
)
|
||||
it("should stop executions after the set number of executions", async () => {
|
||||
const wait = times(2)
|
||||
const spy = await createScheduled("num-executions", wait.next, {
|
||||
cron: "* * * * * *",
|
||||
numberOfExecutions: 2,
|
||||
})
|
||||
|
||||
expect(transaction.flow.state).toEqual(TransactionStepState.INVOKING)
|
||||
expect(result).toEqual(undefined)
|
||||
await wait.promise
|
||||
expect(spy).toHaveBeenCalledTimes(2)
|
||||
|
||||
await setTimeout(205)
|
||||
// Make sure that on the next tick it doesn't execute again
|
||||
await setTimeout(1100)
|
||||
expect(spy).toHaveBeenCalledTimes(2)
|
||||
|
||||
const trx = await workflowOrcModule.run("workflow_async_background", {
|
||||
input: {
|
||||
myInput: "123",
|
||||
},
|
||||
transactionId: "transaction_1",
|
||||
throwOnError: false,
|
||||
})
|
||||
WorkflowManager.unregister("num-execution")
|
||||
})
|
||||
|
||||
expect(trx.transaction.flow.state).toEqual(TransactionStepState.DONE)
|
||||
expect(trx.result).toEqual({
|
||||
myInput: "123",
|
||||
it("should remove scheduled workflow if workflow no longer exists", async () => {
|
||||
const wait = times(1)
|
||||
const logger = sharedContainer_.resolve<Logger>(
|
||||
ContainerRegistrationKeys.LOGGER
|
||||
)
|
||||
|
||||
const spy = await createScheduled("remove-scheduled", wait.next, {
|
||||
cron: "* * * * * *",
|
||||
})
|
||||
const logSpy = jest.spyOn(logger, "warn")
|
||||
|
||||
await wait.promise
|
||||
expect(spy).toHaveBeenCalledTimes(1)
|
||||
WorkflowManager["workflows"].delete("remove-scheduled")
|
||||
|
||||
await setTimeout(1100)
|
||||
expect(spy).toHaveBeenCalledTimes(1)
|
||||
expect(logSpy).toHaveBeenCalledWith(
|
||||
"Tried to execute a scheduled workflow with ID remove-scheduled that does not exist, removing it from the scheduler."
|
||||
)
|
||||
})
|
||||
|
||||
// TODO: investigate why it fails intermittently
|
||||
it.skip("the scheduled workflow should have access to the shared container", async () => {
|
||||
const wait = times(1)
|
||||
sharedContainer_.register("test-value", asValue("test"))
|
||||
|
||||
const spy = await createScheduled("shared-container-job", wait.next, {
|
||||
cron: "* * * * * *",
|
||||
})
|
||||
await wait.promise
|
||||
|
||||
expect(spy).toHaveBeenCalledTimes(1)
|
||||
|
||||
expect(spy).toHaveReturnedWith(
|
||||
expect.objectContaining({ output: { testValue: "test" } })
|
||||
)
|
||||
WorkflowManager.unregister("shared-container-job")
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
it("should subsctibe to a async workflow and receive the response when it finishes", (done) => {
|
||||
const transactionId = "trx_123"
|
||||
|
||||
const onFinish = jest.fn(() => {
|
||||
done()
|
||||
})
|
||||
|
||||
void workflowOrcModule.run("workflow_async_background", {
|
||||
input: {
|
||||
myInput: "123",
|
||||
},
|
||||
transactionId,
|
||||
throwOnError: false,
|
||||
})
|
||||
|
||||
void workflowOrcModule.subscribe({
|
||||
workflowId: "workflow_async_background",
|
||||
transactionId,
|
||||
subscriber: (event) => {
|
||||
if (event.eventType === "onFinish") {
|
||||
onFinish()
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
expect(onFinish).toHaveBeenCalledTimes(0)
|
||||
})
|
||||
})
|
||||
|
||||
// Note: These tests depend on actual Redis instance and waiting for the scheduled jobs to run, which isn't great.
|
||||
// Mocking bullmq, however, would make the tests close to useless, so we can keep them very minimal and serve as smoke tests.
|
||||
describe("Scheduled workflows", () => {
|
||||
it("should execute a scheduled workflow", async () => {
|
||||
const wait = times(2)
|
||||
const spy = createScheduled("standard", wait.next)
|
||||
|
||||
await wait.promise
|
||||
expect(spy).toHaveBeenCalledTimes(2)
|
||||
WorkflowManager.unregister("standard")
|
||||
})
|
||||
|
||||
it("should stop executions after the set number of executions", async () => {
|
||||
const wait = times(2)
|
||||
const spy = await createScheduled("num-executions", wait.next, {
|
||||
cron: "* * * * * *",
|
||||
numberOfExecutions: 2,
|
||||
})
|
||||
|
||||
await wait.promise
|
||||
expect(spy).toHaveBeenCalledTimes(2)
|
||||
|
||||
// Make sure that on the next tick it doesn't execute again
|
||||
await setTimeout(1100)
|
||||
expect(spy).toHaveBeenCalledTimes(2)
|
||||
|
||||
WorkflowManager.unregister("num-execution")
|
||||
})
|
||||
|
||||
it("should remove scheduled workflow if workflow no longer exists", async () => {
|
||||
const wait = times(1)
|
||||
const logger = sharedContainer_.resolve<Logger>(
|
||||
ContainerRegistrationKeys.LOGGER
|
||||
)
|
||||
|
||||
const spy = await createScheduled("remove-scheduled", wait.next, {
|
||||
cron: "* * * * * *",
|
||||
})
|
||||
const logSpy = jest.spyOn(logger, "warn")
|
||||
|
||||
await wait.promise
|
||||
expect(spy).toHaveBeenCalledTimes(1)
|
||||
WorkflowManager["workflows"].delete("remove-scheduled")
|
||||
|
||||
await setTimeout(1100)
|
||||
expect(spy).toHaveBeenCalledTimes(1)
|
||||
expect(logSpy).toHaveBeenCalledWith(
|
||||
"Tried to execute a scheduled workflow with ID remove-scheduled that does not exist, removing it from the scheduler."
|
||||
)
|
||||
})
|
||||
|
||||
it("the scheduled workflow should have access to the shared container", async () => {
|
||||
const wait = times(1)
|
||||
sharedContainer_.register(
|
||||
"test-value",
|
||||
asFunction(() => "test")
|
||||
)
|
||||
|
||||
const spy = await createScheduled("shared-container-job", wait.next, {
|
||||
cron: "* * * * * *",
|
||||
})
|
||||
|
||||
await wait.promise
|
||||
expect(spy).toHaveBeenCalledTimes(1)
|
||||
|
||||
expect(spy).toHaveReturnedWith(
|
||||
expect.objectContaining({ output: { testValue: "test" } })
|
||||
)
|
||||
WorkflowManager.unregister("shared-container-job")
|
||||
})
|
||||
})
|
||||
},
|
||||
})
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
if (typeof process.env.DB_TEMP_NAME === "undefined") {
|
||||
const tempName = parseInt(process.env.JEST_WORKER_ID || "1")
|
||||
process.env.DB_TEMP_NAME = `medusa-workflow-engine-redis-${tempName}`
|
||||
}
|
||||
|
||||
process.env.MEDUSA_WORKFLOW_ENGINE_DB_SCHEMA = "public"
|
||||
@@ -1,3 +0,0 @@
|
||||
import { JestUtils } from "medusa-test-utils"
|
||||
|
||||
JestUtils.afterAllHookDropDatabase()
|
||||
@@ -20,10 +20,6 @@ interface TestDatabase {
|
||||
|
||||
export const TestDatabase: TestDatabase = {
|
||||
clearTables: async (knex) => {
|
||||
await knex.raw(`
|
||||
TRUNCATE TABLE workflow_execution CASCADE;
|
||||
`)
|
||||
|
||||
await cleanRedis()
|
||||
},
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ module.exports = {
|
||||
"^@models": "<rootDir>/src/models",
|
||||
"^@services": "<rootDir>/src/services",
|
||||
"^@repositories": "<rootDir>/src/repositories",
|
||||
"^@types": "<rootDir>/src/types",
|
||||
},
|
||||
transform: {
|
||||
"^.+\\.[jt]s$": [
|
||||
@@ -18,6 +19,4 @@ module.exports = {
|
||||
testEnvironment: `node`,
|
||||
moduleFileExtensions: [`js`, `ts`],
|
||||
modulePathIgnorePatterns: ["dist/"],
|
||||
setupFiles: ["<rootDir>/integration-tests/setup-env.js"],
|
||||
setupFilesAfterEnv: ["<rootDir>/integration-tests/setup.js"],
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import * as entities from "./src/models"
|
||||
import { defineMikroOrmCliConfig, Modules } from "@medusajs/utils"
|
||||
import * as entities from "./src/models"
|
||||
|
||||
export default defineMikroOrmCliConfig(Modules.WORKFLOW_ENGINE, {
|
||||
entities: Object.values(entities),
|
||||
databaseName: "medusa-workflow-engine-redis",
|
||||
})
|
||||
|
||||
@@ -45,16 +45,16 @@
|
||||
"typescript": "^5.1.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"@medusajs/modules-sdk": "^1.12.11",
|
||||
"@medusajs/orchestration": "^0.5.7",
|
||||
"@medusajs/utils": "^1.11.9",
|
||||
"@medusajs/workflows-sdk": "^0.1.6",
|
||||
"@mikro-orm/core": "5.9.7",
|
||||
"@mikro-orm/migrations": "5.9.7",
|
||||
"@mikro-orm/postgresql": "5.9.7",
|
||||
"awilix": "^8.0.0",
|
||||
"bullmq": "5.12.0",
|
||||
"dotenv": "^16.4.5",
|
||||
"ioredis": "^5.4.1",
|
||||
"knex": "2.4.2"
|
||||
"ioredis": "^5.4.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@mikro-orm/core": "*",
|
||||
"@mikro-orm/migrations": "*",
|
||||
"@mikro-orm/postgresql": "*",
|
||||
"awilix": "*"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { LoaderOptions } from "@medusajs/modules-sdk"
|
||||
import { LoaderOptions } from "@medusajs/types"
|
||||
import { asValue } from "awilix"
|
||||
import Redis from "ioredis"
|
||||
import { RedisWorkflowsOptions } from "../types"
|
||||
|
||||
Reference in New Issue
Block a user