refactor(modules-sdk): Align configuration and fixes (#9239)
* refactor(modules-sdk): Align configuration and fixes * typo * fix configuration
This commit is contained in:
committed by
GitHub
parent
d0f1028820
commit
919d19095a
@@ -1,15 +1,17 @@
|
||||
module.exports = {
|
||||
transform: {
|
||||
"^.+\\.[jt]s?$": [
|
||||
"^.+\\.[jt]s$": [
|
||||
"@swc/jest",
|
||||
{
|
||||
jsc: {
|
||||
parser: { syntax: "typescript", decorators: true },
|
||||
transform: { decoratorMetadata: true },
|
||||
target: "ES2021",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
testPathIgnorePatterns: [`dist/`, `node_modules/`],
|
||||
testEnvironment: `node`,
|
||||
moduleFileExtensions: [`js`, `ts`],
|
||||
}
|
||||
|
||||
@@ -3,28 +3,39 @@
|
||||
"version": "1.12.11",
|
||||
"description": "SDK for medusa modules",
|
||||
"main": "dist/index.js",
|
||||
"export": {
|
||||
".": "./dist/index.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/medusajs/medusa",
|
||||
"directory": "packages/modules-sdk"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
"node": ">=20"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
"dist",
|
||||
"!dist/**/__tests__",
|
||||
"!dist/**/__fixtures__",
|
||||
"!dist/**/__mocks__"
|
||||
],
|
||||
"author": "Medusa",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"build": "rimraf dist && tsc --build",
|
||||
"test": "jest --runInBand --bail --forceExit",
|
||||
"watch": "tsc --build --watch"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@medusajs/types": "^1.11.16",
|
||||
"cross-env": "^5.2.1",
|
||||
"jest": "^29.7.0",
|
||||
"rimraf": "^5.0.1",
|
||||
"typescript": "^5.1.6"
|
||||
"typescript": "^5.6.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@graphql-codegen/cli": "^5.0.2",
|
||||
@@ -39,10 +50,5 @@
|
||||
"peerDependencies": {
|
||||
"@mikro-orm/core": "5.9.7",
|
||||
"awilix": "^8.0.1"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "rimraf dist && tsc --build",
|
||||
"test": "jest --runInBand --bail --forceExit",
|
||||
"watch": "tsc --build --watch"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ describe("Medusa Modules", () => {
|
||||
} as InternalModuleDeclaration,
|
||||
})
|
||||
|
||||
const moduleB = await MedusaModule.bootstrap({
|
||||
await MedusaModule.bootstrap({
|
||||
moduleKey: "moduleKey",
|
||||
defaultPath: "@path",
|
||||
declaration: {
|
||||
@@ -146,7 +146,7 @@ describe("Medusa Modules", () => {
|
||||
})
|
||||
|
||||
it("should return the module flagged as 'main' when multiple instances are available", async () => {
|
||||
const moduleA = await MedusaModule.bootstrap({
|
||||
await MedusaModule.bootstrap({
|
||||
moduleKey: "moduleKey",
|
||||
defaultPath: "@path",
|
||||
declaration: {
|
||||
|
||||
@@ -2,11 +2,6 @@ import { createMedusaContainer } from "@medusajs/utils"
|
||||
import { asFunction, Lifetime } from "awilix"
|
||||
import { moduleProviderLoader } from "../module-provider-loader"
|
||||
|
||||
const logger = {
|
||||
warn: jest.fn(),
|
||||
error: jest.fn(),
|
||||
} as any
|
||||
|
||||
describe("modules loader", () => {
|
||||
let container
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ describe("load internal - load resources", () => {
|
||||
|
||||
const generatedJoinerConfig = (
|
||||
resources.moduleService.prototype as IModuleService
|
||||
).__joinerConfig()
|
||||
).__joinerConfig?.()!
|
||||
|
||||
expect(generatedJoinerConfig).toEqual(
|
||||
expect.objectContaining({
|
||||
@@ -141,7 +141,7 @@ describe("load internal - load resources", () => {
|
||||
|
||||
const generatedJoinerConfig = (
|
||||
resources.moduleService.prototype as IModuleService
|
||||
).__joinerConfig()
|
||||
).__joinerConfig?.()!
|
||||
|
||||
expect(generatedJoinerConfig).toEqual(
|
||||
expect.objectContaining({
|
||||
@@ -221,7 +221,7 @@ describe("load internal - load resources", () => {
|
||||
|
||||
const generatedJoinerConfig = (
|
||||
resources.moduleService.prototype as IModuleService
|
||||
).__joinerConfig()
|
||||
).__joinerConfig?.()!
|
||||
|
||||
expect(generatedJoinerConfig).toEqual({
|
||||
serviceName: "module-without-joiner-config",
|
||||
@@ -296,7 +296,7 @@ describe("load internal - load resources", () => {
|
||||
|
||||
const generatedJoinerConfig = (
|
||||
resources.moduleService.prototype as IModuleService
|
||||
).__joinerConfig()
|
||||
).__joinerConfig?.()!
|
||||
|
||||
expect(generatedJoinerConfig).toEqual({
|
||||
serviceName: "module-service",
|
||||
|
||||
@@ -472,8 +472,7 @@ export class RemoteLink {
|
||||
|
||||
for (const link of allLinks) {
|
||||
const service = this.getLinkModuleOrThrow(link)
|
||||
const { moduleA, moduleB, moduleBKey, primaryKeys } =
|
||||
this.getLinkDataConfig(link)
|
||||
const { moduleA, moduleB } = this.getLinkDataConfig(link)
|
||||
|
||||
if (!serviceLinks.has(service.__definition.key)) {
|
||||
serviceLinks.set(service.__definition.key, [])
|
||||
|
||||
@@ -51,6 +51,16 @@ export type Product = {
|
||||
sales_channels_link?: Array<LinkProductSalesChannel>
|
||||
sales_channels?: Array<SalesChannel>
|
||||
metadata?: Maybe<Scalars["JSON"]["output"]>
|
||||
translation?: Maybe<ProductTranslation>
|
||||
categories?: Array<ProductCategory>
|
||||
}
|
||||
|
||||
export type ProductTranslation = {
|
||||
__typename?: "ProductTranslation"
|
||||
id: Scalars["ID"]["output"]
|
||||
title: Scalars["String"]["output"]
|
||||
description: Scalars["String"]["output"]
|
||||
product?: Maybe<Product>
|
||||
}
|
||||
|
||||
export type ProductVariant = {
|
||||
@@ -60,6 +70,16 @@ export type ProductVariant = {
|
||||
title: Scalars["String"]["output"]
|
||||
sku: Scalars["String"]["output"]
|
||||
product?: Maybe<Product>
|
||||
calculated_price?: Maybe<Scalars["JSON"]["output"]>
|
||||
translation?: Maybe<ProductVariantTranslation>
|
||||
}
|
||||
|
||||
export type ProductVariantTranslation = {
|
||||
__typename?: "ProductVariantTranslation"
|
||||
id: Scalars["ID"]["output"]
|
||||
title: Scalars["String"]["output"]
|
||||
description: Scalars["String"]["output"]
|
||||
variant?: Maybe<ProductVariant>
|
||||
}
|
||||
|
||||
export type ProductCategory = {
|
||||
@@ -67,6 +87,15 @@ export type ProductCategory = {
|
||||
id: Scalars["ID"]["output"]
|
||||
handle: Scalars["String"]["output"]
|
||||
title?: Maybe<Scalars["String"]["output"]>
|
||||
translation?: Maybe<ProductCategoryTranslation>
|
||||
}
|
||||
|
||||
export type ProductCategoryTranslation = {
|
||||
__typename?: "ProductCategoryTranslation"
|
||||
id: Scalars["ID"]["output"]
|
||||
title: Scalars["String"]["output"]
|
||||
description: Scalars["String"]["output"]
|
||||
category?: Maybe<ProductCategory>
|
||||
}
|
||||
|
||||
export type SalesChannel = {
|
||||
|
||||
@@ -107,7 +107,6 @@ describe("toRemoteQuery", () => {
|
||||
"description",
|
||||
"variants.title",
|
||||
"variants.calculated_price",
|
||||
"variants.options.*",
|
||||
],
|
||||
filters: {
|
||||
variants: {
|
||||
@@ -150,9 +149,6 @@ describe("toRemoteQuery", () => {
|
||||
},
|
||||
},
|
||||
__fields: ["title", "calculated_price"],
|
||||
options: {
|
||||
__fields: ["*"],
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
@@ -172,22 +168,22 @@ describe("toRemoteQuery", () => {
|
||||
"id",
|
||||
"title",
|
||||
"description",
|
||||
"product_translation.*",
|
||||
"translation.*",
|
||||
"categories.*",
|
||||
"categories.category_translation.*",
|
||||
"categories.translation.*",
|
||||
"variants.*",
|
||||
"variants.variant_translation.*",
|
||||
"variants.translation.*",
|
||||
],
|
||||
filters: {
|
||||
id: "prod_01J742X0QPFW3R2ZFRTRC34FS8",
|
||||
},
|
||||
context: {
|
||||
product_translation: langContext,
|
||||
translation: langContext,
|
||||
categories: {
|
||||
category_translation: langContext,
|
||||
translation: langContext,
|
||||
},
|
||||
variants: {
|
||||
variant_translation: langContext,
|
||||
translation: langContext,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -202,7 +198,7 @@ describe("toRemoteQuery", () => {
|
||||
id: "prod_01J742X0QPFW3R2ZFRTRC34FS8",
|
||||
},
|
||||
},
|
||||
product_translation: {
|
||||
translation: {
|
||||
__args: {
|
||||
context: {
|
||||
context: {
|
||||
@@ -213,7 +209,7 @@ describe("toRemoteQuery", () => {
|
||||
__fields: ["*"],
|
||||
},
|
||||
categories: {
|
||||
category_translation: {
|
||||
translation: {
|
||||
__args: {
|
||||
context: {
|
||||
context: {
|
||||
@@ -226,7 +222,7 @@ describe("toRemoteQuery", () => {
|
||||
__fields: ["*"],
|
||||
},
|
||||
variants: {
|
||||
variant_translation: {
|
||||
translation: {
|
||||
__args: {
|
||||
context: {
|
||||
context: {
|
||||
|
||||
@@ -8,22 +8,21 @@
|
||||
"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,
|
||||
"downlevelIteration": true // to use ES5 specific tooling
|
||||
"skipLibCheck": true
|
||||
},
|
||||
"include": ["./src/**/*"],
|
||||
"include": ["src"],
|
||||
"exclude": [
|
||||
"./dist/**/*",
|
||||
"./src/**/__tests__",
|
||||
"./src/**/__mocks__",
|
||||
"dist",
|
||||
"node_modules"
|
||||
]
|
||||
}
|
||||
|
||||
22
yarn.lock
22
yarn.lock
@@ -6252,7 +6252,7 @@ __metadata:
|
||||
jest: ^29.7.0
|
||||
resolve-cwd: ^3.0.0
|
||||
rimraf: ^5.0.1
|
||||
typescript: ^5.1.6
|
||||
typescript: ^5.6.2
|
||||
peerDependencies:
|
||||
"@mikro-orm/core": 5.9.7
|
||||
awilix: ^8.0.1
|
||||
@@ -32686,6 +32686,16 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"typescript@npm:^5.6.2":
|
||||
version: 5.6.2
|
||||
resolution: "typescript@npm:5.6.2"
|
||||
bin:
|
||||
tsc: bin/tsc
|
||||
tsserver: bin/tsserver
|
||||
checksum: 3ed8297a8c7c56b7fec282532503d1ac795239d06e7c4966b42d4330c6cf433a170b53bcf93a130a7f14ccc5235de5560df4f1045eb7f3550b46ebed16d3c5e5
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"typescript@patch:typescript@4.9.5#~builtin<compat/typescript>, typescript@patch:typescript@^4.1.3#~builtin<compat/typescript>":
|
||||
version: 4.9.5
|
||||
resolution: "typescript@patch:typescript@npm%3A4.9.5#~builtin<compat/typescript>::version=4.9.5&hash=7ad353"
|
||||
@@ -32746,6 +32756,16 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"typescript@patch:typescript@^5.6.2#~builtin<compat/typescript>":
|
||||
version: 5.6.2
|
||||
resolution: "typescript@patch:typescript@npm%3A5.6.2#~builtin<compat/typescript>::version=5.6.2&hash=7ad353"
|
||||
bin:
|
||||
tsc: bin/tsc
|
||||
tsserver: bin/tsserver
|
||||
checksum: e6c1662e4852e22fe4bbdca471dca3e3edc74f6f1df043135c44a18a7902037023ccb0abdfb754595ca9028df8920f2f8492c00fc3cbb4309079aae8b7de71cd
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"ua-parser-js@npm:^1.0.35":
|
||||
version: 1.0.37
|
||||
resolution: "ua-parser-js@npm:1.0.37"
|
||||
|
||||
Reference in New Issue
Block a user