refactor(orchestration): Align configuration and fixes (#9242)
RESOLVES FRMW-2712 **What** Refactor orchestration packages to use the latest configuration of typescript and fixes issues
This commit is contained in:
committed by
GitHub
parent
919d19095a
commit
79e3578932
@@ -1,5 +1,24 @@
|
||||
module.exports = {
|
||||
transform: { "^.+\\.[jt]s?$": "@swc/jest" },
|
||||
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`],
|
||||
}
|
||||
|
||||
@@ -3,19 +3,25 @@
|
||||
"version": "0.5.7",
|
||||
"description": "Medusa utilities to orchestrate modules",
|
||||
"main": "dist/index.js",
|
||||
"exports": {
|
||||
".": "./dist/index.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/medusajs/medusa",
|
||||
"directory": "packages/orchestration"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
"node": ">=20"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
"dist",
|
||||
"!dist/**/__tests__",
|
||||
"!dist/**/__fixtures__",
|
||||
"!dist/**/__mocks__"
|
||||
],
|
||||
"author": "Medusa",
|
||||
"license": "MIT",
|
||||
@@ -24,7 +30,7 @@
|
||||
"cross-env": "^5.2.1",
|
||||
"jest": "^29.7.0",
|
||||
"rimraf": "^5.0.1",
|
||||
"typescript": "^5.1.6"
|
||||
"typescript": "^5.6.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@medusajs/utils": "^1.11.9",
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import { IDistributedSchedulerStorage, SchedulerOptions } from "../../dist"
|
||||
import { IDistributedSchedulerStorage, SchedulerOptions } from "../../src"
|
||||
|
||||
export class MockSchedulerStorage implements IDistributedSchedulerStorage {
|
||||
async schedule(
|
||||
jobDefinition: string | { jobId: string },
|
||||
schedulerOptions: SchedulerOptions
|
||||
): Promise<void> {
|
||||
return Promise.resolve()
|
||||
return await Promise.resolve()
|
||||
}
|
||||
|
||||
async remove(jobId: string): Promise<void> {
|
||||
return Promise.resolve()
|
||||
return await Promise.resolve()
|
||||
}
|
||||
|
||||
async removeAll(): Promise<void> {
|
||||
return Promise.resolve()
|
||||
return await Promise.resolve()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
import { MedusaContainer, RemoteExpandProperty } from "@medusajs/types"
|
||||
import {
|
||||
IModuleService,
|
||||
MedusaContainer,
|
||||
RemoteExpandProperty,
|
||||
} from "@medusajs/types"
|
||||
import { lowerCaseFirst, toPascalCase } from "@medusajs/utils"
|
||||
import { remoteJoinerData } from "../../__fixtures__/joiner/data"
|
||||
import { serviceConfigs, serviceMock } from "../../__mocks__/joiner/mock_data"
|
||||
@@ -51,7 +55,7 @@ const fetchServiceDataCallback = jest.fn(
|
||||
? lowerCaseFirst(serviceConfig.serviceName) + "Service"
|
||||
: serviceConfig.serviceName
|
||||
|
||||
const service = container.resolve(moduleRegistryName)
|
||||
const service: IModuleService = container.resolve(moduleRegistryName)
|
||||
const methodName = relationship?.inverse
|
||||
? `getBy${toPascalCase(pkField)}`
|
||||
: "list"
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
import { MedusaContainer, RemoteExpandProperty } from "@medusajs/types"
|
||||
import {
|
||||
IModuleService,
|
||||
MedusaContainer,
|
||||
RemoteExpandProperty,
|
||||
} from "@medusajs/types"
|
||||
import { lowerCaseFirst, toPascalCase } from "@medusajs/utils"
|
||||
import { serviceConfigs, serviceMock } from "../../__mocks__/joiner/mock_data"
|
||||
import { RemoteJoiner } from "./../../joiner"
|
||||
@@ -23,7 +27,7 @@ const fetchServiceDataCallback = async (
|
||||
const moduleRegistryName =
|
||||
lowerCaseFirst(serviceConfig.serviceName) + "Service"
|
||||
|
||||
const service = container.resolve(moduleRegistryName)
|
||||
const service: IModuleService = container.resolve(moduleRegistryName)
|
||||
const methodName = relationship?.inverse
|
||||
? `getBy${toPascalCase(pkField)}`
|
||||
: "list"
|
||||
|
||||
@@ -4,17 +4,16 @@ import {
|
||||
JoinerServiceConfigAlias,
|
||||
ModuleJoinerConfig,
|
||||
RemoteExpandProperty,
|
||||
RemoteJoinerOptions,
|
||||
RemoteJoinerQuery,
|
||||
RemoteNestedExpands,
|
||||
} from "@medusajs/types"
|
||||
|
||||
import { RemoteJoinerOptions } from "@medusajs/types"
|
||||
import {
|
||||
MedusaError,
|
||||
deduplicate,
|
||||
extractRelationsFromGQL,
|
||||
isDefined,
|
||||
isString,
|
||||
MedusaError,
|
||||
} from "@medusajs/utils"
|
||||
import GraphQLParser from "./graphql-ast"
|
||||
|
||||
@@ -146,7 +145,7 @@ export class RemoteJoiner {
|
||||
}
|
||||
|
||||
constructor(
|
||||
private serviceConfigs: ModuleJoinerConfig[],
|
||||
serviceConfigs: ModuleJoinerConfig[],
|
||||
private remoteFetchData: RemoteFetchDataCallback,
|
||||
private options: {
|
||||
autoCreateServiceNameAlias?: boolean
|
||||
@@ -158,7 +157,7 @@ export class RemoteJoiner {
|
||||
this.entityMap = extractRelationsFromGQL(this.options.entitiesMap)
|
||||
}
|
||||
|
||||
this.serviceConfigs = this.buildReferences(
|
||||
this.buildReferences(
|
||||
JSON.parse(JSON.stringify(serviceConfigs), (key, value) => {
|
||||
if (key === "schema") {
|
||||
return
|
||||
@@ -831,14 +830,8 @@ export class RemoteJoiner {
|
||||
implodeMapping: InternalImplodeMapping[]
|
||||
options?: RemoteJoinerOptions
|
||||
}): Map<string, RemoteExpandProperty> {
|
||||
const {
|
||||
initialService,
|
||||
query,
|
||||
serviceConfig,
|
||||
expands,
|
||||
implodeMapping,
|
||||
options,
|
||||
} = params
|
||||
const { initialService, query, serviceConfig, expands, implodeMapping } =
|
||||
params
|
||||
|
||||
const parsedExpands = this.parseProperties({
|
||||
initialService,
|
||||
|
||||
@@ -294,7 +294,6 @@ export class OrchestratorBuilder {
|
||||
}
|
||||
|
||||
pruneAction(action: string) {
|
||||
const actionStep = this.findOrThrowStepByAction(action)
|
||||
const parentStep = this.findParentStepByAction(action, this.steps)!
|
||||
|
||||
if (Array.isArray(parentStep.next)) {
|
||||
|
||||
@@ -10,21 +10,19 @@
|
||||
"moduleResolution": "node",
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"noUnusedLocals": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"sourceMap": true,
|
||||
"noImplicitReturns": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"noImplicitThis": true,
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"downlevelIteration": true
|
||||
"skipLibCheck": true
|
||||
},
|
||||
"include": ["src"],
|
||||
"exclude": [
|
||||
"dist",
|
||||
"./src/**/__tests__",
|
||||
"./src/**/__mocks__",
|
||||
"./src/**/__fixtures__",
|
||||
"node_modules"
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user