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