chore: payment auto capture + remove enum from utils (#7513)
What: - handles payments session that are auto captured - removes all the enums from `@medusajs/types` - move all `@medusajs/types` to devDependencies
This commit is contained in:
1 parent
2c5ba408d4
commit
f1ced57d5f
68 files changed
+210
-333
No files matched your search
@@ -8,7 +8,7 @@ const { ModuleRegistrationName, Modules } = require("@medusajs/modules-sdk")
|
|||||||
const {
|
const {
|
||||||
createVariantPriceSet,
|
createVariantPriceSet,
|
||||||
} = require("../../../modules/helpers/create-variant-price-set")
|
} = require("../../../modules/helpers/create-variant-price-set")
|
||||||
const { PriceListStatus, PriceListType } = require("@medusajs/types")
|
const { PriceListStatus, PriceListType } = require("@medusajs/utils")
|
||||||
|
|
||||||
let {
|
let {
|
||||||
ProductOptionValue,
|
ProductOptionValue,
|
||||||
|
|||||||
@@ -18,11 +18,11 @@ import {
|
|||||||
ISalesChannelModuleService,
|
ISalesChannelModuleService,
|
||||||
IStoreModuleService,
|
IStoreModuleService,
|
||||||
ITaxModuleService,
|
ITaxModuleService,
|
||||||
ProductStatus,
|
|
||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
ContainerRegistrationKeys,
|
ContainerRegistrationKeys,
|
||||||
MedusaError,
|
MedusaError,
|
||||||
|
ProductStatus,
|
||||||
PromotionRuleOperator,
|
PromotionRuleOperator,
|
||||||
PromotionType,
|
PromotionType,
|
||||||
RuleOperator,
|
RuleOperator,
|
||||||
|
|||||||
+4
-8
@@ -1,17 +1,13 @@
|
|||||||
|
import { IPricingModuleService } from "@medusajs/types"
|
||||||
|
import { PriceListStatus, PriceListType } from "@medusajs/utils"
|
||||||
|
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
||||||
import {
|
import {
|
||||||
simpleProductFactory,
|
simpleProductFactory,
|
||||||
simpleRegionFactory,
|
simpleRegionFactory,
|
||||||
} from "../../../../factories"
|
} from "../../../../factories"
|
||||||
|
import { createAdminUser } from "../../../../helpers/create-admin-user"
|
||||||
import {
|
|
||||||
IPricingModuleService,
|
|
||||||
PriceListStatus,
|
|
||||||
PriceListType,
|
|
||||||
} from "@medusajs/types"
|
|
||||||
import { createDefaultRuleTypes } from "../../../helpers/create-default-rule-types"
|
import { createDefaultRuleTypes } from "../../../helpers/create-default-rule-types"
|
||||||
import { createVariantPriceSet } from "../../../helpers/create-variant-price-set"
|
import { createVariantPriceSet } from "../../../helpers/create-variant-price-set"
|
||||||
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
|
||||||
import { createAdminUser } from "../../../../helpers/create-admin-user"
|
|
||||||
|
|
||||||
jest.setTimeout(50000)
|
jest.setTimeout(50000)
|
||||||
|
|
||||||
|
|||||||
@@ -4,9 +4,8 @@ import {
|
|||||||
IPricingModuleService,
|
IPricingModuleService,
|
||||||
IProductModuleService,
|
IProductModuleService,
|
||||||
IRegionModuleService,
|
IRegionModuleService,
|
||||||
PriceListStatus,
|
|
||||||
PriceListType,
|
|
||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
|
import { PriceListStatus, PriceListType } from "@medusajs/utils"
|
||||||
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
||||||
import { createAdminUser } from "../../../../helpers/create-admin-user"
|
import { createAdminUser } from "../../../../helpers/create-admin-user"
|
||||||
import { createVariantPriceSet } from "../../../helpers/create-variant-price-set"
|
import { createVariantPriceSet } from "../../../helpers/create-variant-price-set"
|
||||||
|
|||||||
@@ -1,19 +1,15 @@
|
|||||||
|
import { IPricingModuleService } from "@medusajs/types"
|
||||||
|
import { PriceListStatus, PriceListType } from "@medusajs/utils"
|
||||||
|
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
||||||
import {
|
import {
|
||||||
simpleCustomerFactory,
|
simpleCustomerFactory,
|
||||||
simpleCustomerGroupFactory,
|
simpleCustomerGroupFactory,
|
||||||
simpleProductFactory,
|
simpleProductFactory,
|
||||||
simpleRegionFactory,
|
simpleRegionFactory,
|
||||||
} from "../../../../factories"
|
} from "../../../../factories"
|
||||||
|
import { createAdminUser } from "../../../../helpers/create-admin-user"
|
||||||
import {
|
|
||||||
IPricingModuleService,
|
|
||||||
PriceListStatus,
|
|
||||||
PriceListType,
|
|
||||||
} from "@medusajs/types"
|
|
||||||
import { createDefaultRuleTypes } from "../../../helpers/create-default-rule-types"
|
import { createDefaultRuleTypes } from "../../../helpers/create-default-rule-types"
|
||||||
import { createVariantPriceSet } from "../../../helpers/create-variant-price-set"
|
import { createVariantPriceSet } from "../../../helpers/create-variant-price-set"
|
||||||
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
|
||||||
import { createAdminUser } from "../../../../helpers/create-admin-user"
|
|
||||||
|
|
||||||
jest.setTimeout(50000)
|
jest.setTimeout(50000)
|
||||||
|
|
||||||
|
|||||||
@@ -3,11 +3,10 @@ import {
|
|||||||
CreateProductDTO,
|
CreateProductDTO,
|
||||||
IPricingModuleService,
|
IPricingModuleService,
|
||||||
IProductModuleService,
|
IProductModuleService,
|
||||||
PriceListStatus,
|
|
||||||
PriceListType,
|
|
||||||
ProductDTO,
|
ProductDTO,
|
||||||
ProductVariantDTO,
|
ProductVariantDTO,
|
||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
|
import { PriceListStatus, PriceListType } from "@medusajs/utils"
|
||||||
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
||||||
import { createAdminUser } from "../../../../helpers/create-admin-user"
|
import { createAdminUser } from "../../../../helpers/create-admin-user"
|
||||||
import { createVariantPriceSet } from "../../../helpers/create-variant-price-set"
|
import { createVariantPriceSet } from "../../../helpers/create-variant-price-set"
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
"author": "Medusa",
|
"author": "Medusa",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@medusajs/types": "^1.11.15",
|
||||||
"@types/js-yaml": "^4.0.9",
|
"@types/js-yaml": "^4.0.9",
|
||||||
"jest": "^29.1.0",
|
"jest": "^29.1.0",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
@@ -37,7 +38,6 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/medusa": "^1.20.4",
|
"@medusajs/medusa": "^1.20.4",
|
||||||
"@medusajs/openapi-typescript-codegen": "^0.2.1",
|
"@medusajs/openapi-typescript-codegen": "^0.2.1",
|
||||||
"@medusajs/types": "^1.11.15",
|
|
||||||
"@medusajs/utils": "^1.11.8",
|
"@medusajs/utils": "^1.11.8",
|
||||||
"@readme/json-schema-ref-parser": "^1.2.0",
|
"@readme/json-schema-ref-parser": "^1.2.0",
|
||||||
"@readme/openapi-parser": "^2.4.0",
|
"@readme/openapi-parser": "^2.4.0",
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export const validateCartPaymentsStep = createStep(
|
|||||||
]
|
]
|
||||||
|
|
||||||
const paymentsToProcess = paymentCollection.payment_sessions?.filter((ps) =>
|
const paymentsToProcess = paymentCollection.payment_sessions?.filter((ps) =>
|
||||||
processablePaymentStatuses.includes(ps.status)
|
processablePaymentStatuses.includes(ps.status as PaymentSessionStatus)
|
||||||
)
|
)
|
||||||
|
|
||||||
if (!paymentsToProcess?.length) {
|
if (!paymentsToProcess?.length) {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
"author": "Medusa",
|
"author": "Medusa",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@medusajs/types": "^1.11.16",
|
||||||
"cross-env": "^5.2.1",
|
"cross-env": "^5.2.1",
|
||||||
"jest": "^29.6.3",
|
"jest": "^29.6.3",
|
||||||
"msw": "^2.3.0",
|
"msw": "^2.3.0",
|
||||||
@@ -28,7 +29,6 @@
|
|||||||
"typescript": "^5.1.6"
|
"typescript": "^5.1.6"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/types": "^1.11.16",
|
|
||||||
"qs": "^6.12.1"
|
"qs": "^6.12.1"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
"author": "Medusa",
|
"author": "Medusa",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@medusajs/types": "^1.11.16",
|
||||||
"cross-env": "^5.2.1",
|
"cross-env": "^5.2.1",
|
||||||
"jest": "^29.6.3",
|
"jest": "^29.6.3",
|
||||||
"rimraf": "^5.0.1",
|
"rimraf": "^5.0.1",
|
||||||
@@ -30,7 +31,6 @@
|
|||||||
"@graphql-tools/merge": "^9.0.0",
|
"@graphql-tools/merge": "^9.0.0",
|
||||||
"@graphql-tools/schema": "^10.0.0",
|
"@graphql-tools/schema": "^10.0.0",
|
||||||
"@medusajs/orchestration": "^0.5.7",
|
"@medusajs/orchestration": "^0.5.7",
|
||||||
"@medusajs/types": "^1.11.16",
|
|
||||||
"@medusajs/utils": "^1.11.9",
|
"@medusajs/utils": "^1.11.9",
|
||||||
"awilix": "^8.0.0",
|
"awilix": "^8.0.0",
|
||||||
"graphql": "^16.6.0",
|
"graphql": "^16.6.0",
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
import {
|
import { ModuleDefinition } from "@medusajs/types"
|
||||||
MODULE_RESOURCE_TYPE,
|
|
||||||
MODULE_SCOPE,
|
|
||||||
ModuleDefinition,
|
|
||||||
} from "@medusajs/types"
|
|
||||||
|
|
||||||
import { upperCaseFirst } from "@medusajs/utils"
|
import { upperCaseFirst } from "@medusajs/utils"
|
||||||
|
import { MODULE_RESOURCE_TYPE, MODULE_SCOPE } from "./types"
|
||||||
|
|
||||||
export enum LinkModuleUtils {
|
export enum LinkModuleUtils {
|
||||||
REMOTE_QUERY = "remoteQuery",
|
REMOTE_QUERY = "remoteQuery",
|
||||||
|
|||||||
@@ -5,3 +5,4 @@ export * from "./medusa-app"
|
|||||||
export * from "./medusa-module"
|
export * from "./medusa-module"
|
||||||
export * from "./remote-link"
|
export * from "./remote-link"
|
||||||
export * from "./remote-query"
|
export * from "./remote-query"
|
||||||
|
export * from "./types"
|
||||||
@@ -1,11 +1,8 @@
|
|||||||
import {
|
import { InternalModuleDeclaration } from "@medusajs/types"
|
||||||
InternalModuleDeclaration,
|
import { MODULE_RESOURCE_TYPE, MODULE_SCOPE } from "../../types"
|
||||||
MODULE_RESOURCE_TYPE,
|
|
||||||
MODULE_SCOPE,
|
|
||||||
} from "@medusajs/types"
|
|
||||||
|
|
||||||
import { MedusaModule } from "../../medusa-module"
|
|
||||||
import { asValue } from "awilix"
|
import { asValue } from "awilix"
|
||||||
|
import { MedusaModule } from "../../medusa-module"
|
||||||
|
|
||||||
const mockRegisterMedusaModule = jest.fn().mockImplementation(() => {
|
const mockRegisterMedusaModule = jest.fn().mockImplementation(() => {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
import {
|
import { ModuleResolution } from "@medusajs/types"
|
||||||
MODULE_RESOURCE_TYPE,
|
|
||||||
MODULE_SCOPE,
|
|
||||||
ModuleResolution,
|
|
||||||
} from "@medusajs/types"
|
|
||||||
import { createMedusaContainer } from "@medusajs/utils"
|
import { createMedusaContainer } from "@medusajs/utils"
|
||||||
|
import { MODULE_RESOURCE_TYPE, MODULE_SCOPE } from "../../types"
|
||||||
import { moduleLoader } from "../module-loader"
|
import { moduleLoader } from "../module-loader"
|
||||||
|
|
||||||
const logger = {
|
const logger = {
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
import {
|
import { InternalModuleDeclaration, ModuleDefinition } from "@medusajs/types"
|
||||||
InternalModuleDeclaration,
|
|
||||||
MODULE_RESOURCE_TYPE,
|
|
||||||
MODULE_SCOPE,
|
|
||||||
ModuleDefinition,
|
|
||||||
} from "@medusajs/types"
|
|
||||||
import { ModulesDefinition } from "../../definitions"
|
import { ModulesDefinition } from "../../definitions"
|
||||||
|
import { MODULE_RESOURCE_TYPE, MODULE_SCOPE } from "../../types"
|
||||||
import { registerMedusaModule } from "../register-modules"
|
import { registerMedusaModule } from "../register-modules"
|
||||||
|
|
||||||
const RESOLVED_PACKAGE = "@medusajs/test-service-resolved"
|
const RESOLVED_PACKAGE = "@medusajs/test-service-resolved"
|
||||||
|
|||||||
@@ -1,12 +1,7 @@
|
|||||||
import {
|
import { Logger, MedusaContainer, ModuleResolution } from "@medusajs/types"
|
||||||
Logger,
|
|
||||||
MedusaContainer,
|
|
||||||
MODULE_SCOPE,
|
|
||||||
ModuleResolution,
|
|
||||||
} from "@medusajs/types"
|
|
||||||
|
|
||||||
import { asValue } from "awilix"
|
import { asValue } from "awilix"
|
||||||
import { EOL } from "os"
|
import { EOL } from "os"
|
||||||
|
import { MODULE_SCOPE } from "../types"
|
||||||
import { loadInternalModule } from "./utils"
|
import { loadInternalModule } from "./utils"
|
||||||
|
|
||||||
export const moduleLoader = async ({
|
export const moduleLoader = async ({
|
||||||
|
|||||||
@@ -1,16 +1,14 @@
|
|||||||
import {
|
import {
|
||||||
ExternalModuleDeclaration,
|
ExternalModuleDeclaration,
|
||||||
InternalModuleDeclaration,
|
InternalModuleDeclaration,
|
||||||
MODULE_RESOURCE_TYPE,
|
|
||||||
MODULE_SCOPE,
|
|
||||||
ModuleDefinition,
|
ModuleDefinition,
|
||||||
ModuleExports,
|
ModuleExports,
|
||||||
ModuleResolution,
|
ModuleResolution,
|
||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
|
|
||||||
import { isObject, isString } from "@medusajs/utils"
|
import { isObject, isString } from "@medusajs/utils"
|
||||||
import resolveCwd from "resolve-cwd"
|
import resolveCwd from "resolve-cwd"
|
||||||
import { ModulesDefinition } from "../definitions"
|
import { ModulesDefinition } from "../definitions"
|
||||||
|
import { MODULE_RESOURCE_TYPE, MODULE_SCOPE } from "../types"
|
||||||
|
|
||||||
export const registerMedusaModule = (
|
export const registerMedusaModule = (
|
||||||
moduleKey: string,
|
moduleKey: string,
|
||||||
|
|||||||
@@ -3,21 +3,21 @@ import {
|
|||||||
InternalModuleDeclaration,
|
InternalModuleDeclaration,
|
||||||
Logger,
|
Logger,
|
||||||
MedusaContainer,
|
MedusaContainer,
|
||||||
MODULE_RESOURCE_TYPE,
|
|
||||||
ModuleExports,
|
ModuleExports,
|
||||||
ModuleLoaderFunction,
|
ModuleLoaderFunction,
|
||||||
ModuleResolution,
|
ModuleResolution,
|
||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
ContainerRegistrationKeys,
|
ContainerRegistrationKeys,
|
||||||
createMedusaContainer,
|
|
||||||
MedusaModuleType,
|
MedusaModuleType,
|
||||||
ModulesSdkUtils,
|
ModulesSdkUtils,
|
||||||
|
createMedusaContainer,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import { asFunction, asValue } from "awilix"
|
import { asFunction, asValue } from "awilix"
|
||||||
import { statSync } from "fs"
|
import { statSync } from "fs"
|
||||||
import { readdir } from "fs/promises"
|
import { readdir } from "fs/promises"
|
||||||
import { join, resolve } from "path"
|
import { join, resolve } from "path"
|
||||||
|
import { MODULE_RESOURCE_TYPE } from "../../types"
|
||||||
|
|
||||||
type ModuleResource = {
|
type ModuleResource = {
|
||||||
services: Function[]
|
services: Function[]
|
||||||
|
|||||||
@@ -6,8 +6,6 @@ import {
|
|||||||
InternalModuleDeclaration,
|
InternalModuleDeclaration,
|
||||||
LoadedModule,
|
LoadedModule,
|
||||||
MedusaContainer,
|
MedusaContainer,
|
||||||
MODULE_RESOURCE_TYPE,
|
|
||||||
MODULE_SCOPE,
|
|
||||||
ModuleDefinition,
|
ModuleDefinition,
|
||||||
ModuleExports,
|
ModuleExports,
|
||||||
ModuleJoinerConfig,
|
ModuleJoinerConfig,
|
||||||
@@ -18,10 +16,10 @@ import {
|
|||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
ContainerRegistrationKeys,
|
ContainerRegistrationKeys,
|
||||||
|
ModulesSdkUtils,
|
||||||
createMedusaContainer,
|
createMedusaContainer,
|
||||||
isObject,
|
isObject,
|
||||||
isString,
|
isString,
|
||||||
ModulesSdkUtils,
|
|
||||||
promiseAll,
|
promiseAll,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import { asValue } from "awilix"
|
import { asValue } from "awilix"
|
||||||
@@ -33,6 +31,7 @@ import {
|
|||||||
import { MedusaModule } from "./medusa-module"
|
import { MedusaModule } from "./medusa-module"
|
||||||
import { RemoteLink } from "./remote-link"
|
import { RemoteLink } from "./remote-link"
|
||||||
import { RemoteQuery } from "./remote-query"
|
import { RemoteQuery } from "./remote-query"
|
||||||
|
import { MODULE_RESOURCE_TYPE, MODULE_SCOPE } from "./types"
|
||||||
import { cleanGraphQLSchema } from "./utils"
|
import { cleanGraphQLSchema } from "./utils"
|
||||||
|
|
||||||
const LinkModulePackage = MODULE_PACKAGE_NAMES[Modules.LINK]
|
const LinkModulePackage = MODULE_PACKAGE_NAMES[Modules.LINK]
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ import {
|
|||||||
LinkModuleDefinition,
|
LinkModuleDefinition,
|
||||||
LoadedModule,
|
LoadedModule,
|
||||||
MedusaContainer,
|
MedusaContainer,
|
||||||
MODULE_RESOURCE_TYPE,
|
|
||||||
MODULE_SCOPE,
|
|
||||||
ModuleBootstrapDeclaration,
|
ModuleBootstrapDeclaration,
|
||||||
ModuleDefinition,
|
ModuleDefinition,
|
||||||
ModuleExports,
|
ModuleExports,
|
||||||
@@ -19,15 +17,15 @@ import {
|
|||||||
simpleHash,
|
simpleHash,
|
||||||
stringifyCircular,
|
stringifyCircular,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
|
import { asValue } from "awilix"
|
||||||
import { EOL } from "os"
|
import { EOL } from "os"
|
||||||
import {
|
import {
|
||||||
moduleLoader,
|
moduleLoader,
|
||||||
registerMedusaLinkModule,
|
registerMedusaLinkModule,
|
||||||
registerMedusaModule,
|
registerMedusaModule,
|
||||||
} from "./loaders"
|
} from "./loaders"
|
||||||
|
|
||||||
import { asValue } from "awilix"
|
|
||||||
import { loadModuleMigrations } from "./loaders/utils"
|
import { loadModuleMigrations } from "./loaders/utils"
|
||||||
|
import { MODULE_RESOURCE_TYPE, MODULE_SCOPE } from "./types"
|
||||||
|
|
||||||
const logger: any = {
|
const logger: any = {
|
||||||
log: (a) => console.log(a),
|
log: (a) => console.log(a),
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
export enum MODULE_SCOPE {
|
||||||
|
INTERNAL = "internal",
|
||||||
|
EXTERNAL = "external",
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum MODULE_RESOURCE_TYPE {
|
||||||
|
SHARED = "shared",
|
||||||
|
ISOLATED = "isolated",
|
||||||
|
}
|
||||||
@@ -104,14 +104,9 @@ export type FilterQuery<T = any, Prev extends number = 3> = Prev extends never
|
|||||||
: never
|
: never
|
||||||
}
|
}
|
||||||
|
|
||||||
declare enum QueryOrder {
|
declare type QueryOrder = "ASC" | "DESC" | "asc" | "desc"
|
||||||
ASC = "ASC",
|
|
||||||
DESC = "DESC",
|
|
||||||
asc = "asc",
|
|
||||||
desc = "desc",
|
|
||||||
}
|
|
||||||
|
|
||||||
type QueryOrderKeysFlat = QueryOrder | 1 | -1 | keyof typeof QueryOrder
|
type QueryOrderKeysFlat = QueryOrder | 1 | -1
|
||||||
type QueryOrderKeys<T> = QueryOrderKeysFlat | QueryOrderMap<T>
|
type QueryOrderKeys<T> = QueryOrderKeysFlat | QueryOrderMap<T>
|
||||||
type QueryOrderMap<T> = {
|
type QueryOrderMap<T> = {
|
||||||
[K in keyof T as ExcludeFunctions<T, K>]?: QueryOrderKeys<
|
[K in keyof T as ExcludeFunctions<T, K>]?: QueryOrderKeys<
|
||||||
|
|||||||
@@ -24,16 +24,6 @@ export type LogLevel =
|
|||||||
| "migration"
|
| "migration"
|
||||||
export type LoggerOptions = boolean | "all" | LogLevel[]
|
export type LoggerOptions = boolean | "all" | LogLevel[]
|
||||||
|
|
||||||
export enum MODULE_SCOPE {
|
|
||||||
INTERNAL = "internal",
|
|
||||||
EXTERNAL = "external",
|
|
||||||
}
|
|
||||||
|
|
||||||
export enum MODULE_RESOURCE_TYPE {
|
|
||||||
SHARED = "shared",
|
|
||||||
ISOLATED = "isolated",
|
|
||||||
}
|
|
||||||
|
|
||||||
export type CustomModuleDefinition = {
|
export type CustomModuleDefinition = {
|
||||||
key?: string
|
key?: string
|
||||||
registrationName?: string
|
registrationName?: string
|
||||||
@@ -43,8 +33,8 @@ export type CustomModuleDefinition = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export type InternalModuleDeclaration = {
|
export type InternalModuleDeclaration = {
|
||||||
scope: MODULE_SCOPE.INTERNAL
|
scope: "internal"
|
||||||
resources: MODULE_RESOURCE_TYPE
|
resources: "shared" | "isolated"
|
||||||
dependencies?: string[]
|
dependencies?: string[]
|
||||||
definition?: CustomModuleDefinition // That represent the definition of the module, such as the one we have for the medusa supported modules. This property is used for custom made modules.
|
definition?: CustomModuleDefinition // That represent the definition of the module, such as the one we have for the medusa supported modules. This property is used for custom made modules.
|
||||||
resolve?: string | ModuleExports
|
resolve?: string | ModuleExports
|
||||||
@@ -61,7 +51,7 @@ export type InternalModuleDeclaration = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export type ExternalModuleDeclaration = {
|
export type ExternalModuleDeclaration = {
|
||||||
scope: MODULE_SCOPE.EXTERNAL
|
scope: "external"
|
||||||
definition?: CustomModuleDefinition // That represent the definition of the module, such as the one we have for the medusa supported modules. This property is used for custom made modules.
|
definition?: CustomModuleDefinition // That represent the definition of the module, such as the one we have for the medusa supported modules. This property is used for custom made modules.
|
||||||
server?: {
|
server?: {
|
||||||
type: "http"
|
type: "http"
|
||||||
|
|||||||
@@ -2,69 +2,21 @@ import { BaseFilterable } from "../dal"
|
|||||||
import { OperatorMap } from "../dal/utils"
|
import { OperatorMap } from "../dal/utils"
|
||||||
import { BigNumberValue } from "../totals"
|
import { BigNumberValue } from "../totals"
|
||||||
/* ********** PAYMENT COLLECTION ********** */
|
/* ********** PAYMENT COLLECTION ********** */
|
||||||
/**
|
|
||||||
* @enum
|
|
||||||
*
|
|
||||||
* The payment collection's status.
|
|
||||||
*/
|
|
||||||
export enum PaymentCollectionStatus {
|
|
||||||
/**
|
|
||||||
* The payment collection isn't paid.
|
|
||||||
*/
|
|
||||||
NOT_PAID = "not_paid",
|
|
||||||
|
|
||||||
/**
|
export type PaymentCollectionStatus =
|
||||||
* The payment sessions in the payment collection are await authorization.
|
| "not_paid"
|
||||||
*/
|
| "awaiting"
|
||||||
AWAITING = "awaiting",
|
| "authorized"
|
||||||
|
| "partially_authorized"
|
||||||
|
| "canceled"
|
||||||
|
|
||||||
/**
|
export type PaymentSessionStatus =
|
||||||
* The payment sessions in the payment collection are authorized.
|
| "authorized"
|
||||||
*/
|
| "captured"
|
||||||
AUTHORIZED = "authorized",
|
| "pending"
|
||||||
|
| "requires_more"
|
||||||
/**
|
| "error"
|
||||||
* Some of the payments in the payment collection are authorized.
|
| "canceled"
|
||||||
*/
|
|
||||||
PARTIALLY_AUTHORIZED = "partially_authorized",
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The payments in the payment collection are canceled.
|
|
||||||
*/
|
|
||||||
CANCELED = "canceled",
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @enum
|
|
||||||
*
|
|
||||||
* The status of a payment session.
|
|
||||||
*/
|
|
||||||
export enum PaymentSessionStatus {
|
|
||||||
/**
|
|
||||||
* The payment is authorized.
|
|
||||||
*/
|
|
||||||
AUTHORIZED = "authorized",
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The payment is pending.
|
|
||||||
*/
|
|
||||||
PENDING = "pending",
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The payment requires an action.
|
|
||||||
*/
|
|
||||||
REQUIRES_MORE = "requires_more",
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An error occurred while processing the payment.
|
|
||||||
*/
|
|
||||||
ERROR = "error",
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The payment is canceled.
|
|
||||||
*/
|
|
||||||
CANCELED = "canceled",
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The payment collection details.
|
* The payment collection details.
|
||||||
|
|||||||
@@ -17,27 +17,11 @@ export type PaymentCustomerDTO = Partial<CustomerDTO>
|
|||||||
/**
|
/**
|
||||||
* Normalized events from payment provider to internal payment module events.
|
* Normalized events from payment provider to internal payment module events.
|
||||||
*/
|
*/
|
||||||
export enum PaymentActions {
|
export type PaymentActions =
|
||||||
/**
|
| "authorized"
|
||||||
* Payment session has been authorized and there are available funds for capture.
|
| "captured"
|
||||||
*/
|
| "failed"
|
||||||
AUTHORIZED = "authorized",
|
| "not_supported"
|
||||||
|
|
||||||
/**
|
|
||||||
* Payment was successful and the mount is captured.
|
|
||||||
*/
|
|
||||||
SUCCESSFUL = "captured",
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Payment failed.
|
|
||||||
*/
|
|
||||||
FAILED = "failed",
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Received an event that is not processable.
|
|
||||||
*/
|
|
||||||
NOT_SUPPORTED = "not_supported",
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @interface
|
* @interface
|
||||||
@@ -217,7 +201,7 @@ export type WebhookActionResult =
|
|||||||
/**
|
/**
|
||||||
* Received an event that is not processable.
|
* Received an event that is not processable.
|
||||||
*/
|
*/
|
||||||
action: PaymentActions.NOT_SUPPORTED
|
action: "not_supported"
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -12,32 +12,17 @@ import { RuleTypeDTO } from "./rule-type"
|
|||||||
*
|
*
|
||||||
* The price list's status.
|
* The price list's status.
|
||||||
*/
|
*/
|
||||||
export enum PriceListStatus {
|
export type PriceListStatus = "active" | "draft"
|
||||||
/**
|
|
||||||
* The price list is enabled and its prices can be used.
|
|
||||||
*/
|
|
||||||
ACTIVE = "active",
|
|
||||||
/**
|
|
||||||
* The price list is disabled, meaning its prices can't be used yet.
|
|
||||||
*/
|
|
||||||
DRAFT = "draft",
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum
|
* @enum
|
||||||
*
|
*
|
||||||
* The price list's type.
|
* The price list's type.
|
||||||
|
* "sale" - The price list's prices are used for a sale.
|
||||||
|
* "override" - The price list's prices override original prices. This affects the calculated price of associated price sets.
|
||||||
*/
|
*/
|
||||||
export enum PriceListType {
|
|
||||||
/**
|
export type PriceListType = "sale" | "override"
|
||||||
* The price list's prices are used for a sale.
|
|
||||||
*/
|
|
||||||
SALE = "sale",
|
|
||||||
/**
|
|
||||||
* The price list's prices override original prices. This affects the calculated price of associated price sets.
|
|
||||||
*/
|
|
||||||
OVERRIDE = "override",
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @interface
|
* @interface
|
||||||
|
|||||||
@@ -4,12 +4,7 @@ import { OperatorMap } from "../dal/utils"
|
|||||||
/**
|
/**
|
||||||
* @enum
|
* @enum
|
||||||
*/
|
*/
|
||||||
export enum ProductStatus {
|
export type ProductStatus = "draft" | "proposed" | "published" | "rejected"
|
||||||
DRAFT = "draft",
|
|
||||||
PROPOSED = "proposed",
|
|
||||||
PUBLISHED = "published",
|
|
||||||
REJECTED = "rejected",
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @interface
|
* @interface
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
"author": "Medusa",
|
"author": "Medusa",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@medusajs/types": "^1.11.16",
|
||||||
"@types/express": "^4.17.17",
|
"@types/express": "^4.17.17",
|
||||||
"cross-env": "^5.2.1",
|
"cross-env": "^5.2.1",
|
||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
@@ -30,7 +31,6 @@
|
|||||||
"typescript": "^5.1.6"
|
"typescript": "^5.1.6"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/types": "^1.11.16",
|
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "5.9.7",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "5.9.7",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "5.9.7",
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import { MODULE_RESOURCE_TYPE } from "@medusajs/types"
|
|
||||||
|
|
||||||
export function shouldForceTransaction(target: any): boolean {
|
export function shouldForceTransaction(target: any): boolean {
|
||||||
return target.moduleDeclaration?.resources === MODULE_RESOURCE_TYPE.ISOLATED
|
return target.moduleDeclaration?.resources === "isolated"
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,4 @@
|
|||||||
import {
|
import { Logger, MedusaContainer, ModulesSdkTypes } from "@medusajs/types"
|
||||||
Logger,
|
|
||||||
MedusaContainer,
|
|
||||||
MODULE_RESOURCE_TYPE,
|
|
||||||
MODULE_SCOPE,
|
|
||||||
ModulesSdkTypes,
|
|
||||||
} from "@medusajs/types"
|
|
||||||
import { PostgreSqlDriver, SqlEntityManager } from "@mikro-orm/postgresql"
|
import { PostgreSqlDriver, SqlEntityManager } from "@mikro-orm/postgresql"
|
||||||
import { asValue } from "awilix"
|
import { asValue } from "awilix"
|
||||||
import { ContainerRegistrationKeys, MedusaError } from "../../common"
|
import { ContainerRegistrationKeys, MedusaError } from "../../common"
|
||||||
@@ -60,8 +54,8 @@ export async function mikroOrmConnectionLoader({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
moduleDeclaration?.scope === MODULE_SCOPE.INTERNAL &&
|
moduleDeclaration?.scope === "internal" &&
|
||||||
moduleDeclaration.resources === MODULE_RESOURCE_TYPE.SHARED
|
moduleDeclaration.resources === "shared"
|
||||||
) {
|
) {
|
||||||
const shouldSwallowError = true
|
const shouldSwallowError = true
|
||||||
const dbConfig = loadDatabaseConfig(
|
const dbConfig = loadDatabaseConfig(
|
||||||
|
|||||||
@@ -8,6 +8,10 @@ export enum PaymentSessionStatus {
|
|||||||
* The payment is authorized.
|
* The payment is authorized.
|
||||||
*/
|
*/
|
||||||
AUTHORIZED = "authorized",
|
AUTHORIZED = "authorized",
|
||||||
|
/**
|
||||||
|
* The payment is captured.
|
||||||
|
*/
|
||||||
|
CAPTURED = "captured",
|
||||||
/**
|
/**
|
||||||
* The payment is pending.
|
* The payment is pending.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { PriceListStatus, PriceListType } from "@medusajs/types"
|
import { PriceListStatus, PriceListType } from "@medusajs/utils"
|
||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
import {
|
import {
|
||||||
createFindParams,
|
createFindParams,
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@medusajs/types": "^1.11.16",
|
||||||
"@mikro-orm/cli": "5.9.7",
|
"@mikro-orm/cli": "5.9.7",
|
||||||
"cross-env": "^5.2.1",
|
"cross-env": "^5.2.1",
|
||||||
"jest": "^29.6.3",
|
"jest": "^29.6.3",
|
||||||
@@ -49,7 +50,6 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/modules-sdk": "^1.12.11",
|
"@medusajs/modules-sdk": "^1.12.11",
|
||||||
"@medusajs/types": "^1.11.16",
|
|
||||||
"@medusajs/utils": "^1.11.9",
|
"@medusajs/utils": "^1.11.9",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "5.9.7",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "5.9.7",
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@medusajs/types": "^1.11.16",
|
||||||
"@mikro-orm/cli": "5.9.7",
|
"@mikro-orm/cli": "5.9.7",
|
||||||
"cross-env": "^5.2.1",
|
"cross-env": "^5.2.1",
|
||||||
"jest": "^29.6.3",
|
"jest": "^29.6.3",
|
||||||
@@ -49,7 +50,6 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/modules-sdk": "^1.12.11",
|
"@medusajs/modules-sdk": "^1.12.11",
|
||||||
"@medusajs/types": "^1.11.16",
|
|
||||||
"@medusajs/utils": "^1.11.9",
|
"@medusajs/utils": "^1.11.9",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "5.9.7",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "5.9.7",
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@medusajs/types": "^1.11.15",
|
||||||
"@mikro-orm/cli": "5.9.7",
|
"@mikro-orm/cli": "5.9.7",
|
||||||
"cross-env": "^5.2.1",
|
"cross-env": "^5.2.1",
|
||||||
"faker": "^5.5.3",
|
"faker": "^5.5.3",
|
||||||
@@ -48,7 +49,6 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/modules-sdk": "^1.12.10",
|
"@medusajs/modules-sdk": "^1.12.10",
|
||||||
"@medusajs/types": "^1.11.15",
|
|
||||||
"@medusajs/utils": "^1.11.8",
|
"@medusajs/utils": "^1.11.8",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "5.9.7",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "5.9.7",
|
||||||
|
|||||||
@@ -33,7 +33,6 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/modules-sdk": "^1.12.10",
|
"@medusajs/modules-sdk": "^1.12.10",
|
||||||
"@medusajs/types": "^1.11.15",
|
|
||||||
"@medusajs/utils": "^1.11.8",
|
"@medusajs/utils": "^1.11.8",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "5.9.7",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "5.9.7",
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
"test:integration": "jest --passWithNoTests"
|
"test:integration": "jest --passWithNoTests"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@medusajs/types": "^1.11.16",
|
||||||
"cross-env": "^5.2.1",
|
"cross-env": "^5.2.1",
|
||||||
"jest": "^29.6.3",
|
"jest": "^29.6.3",
|
||||||
"pg-god": "^1.0.12",
|
"pg-god": "^1.0.12",
|
||||||
@@ -40,7 +41,6 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/modules-sdk": "^1.12.11",
|
"@medusajs/modules-sdk": "^1.12.11",
|
||||||
"@medusajs/types": "^1.11.16",
|
|
||||||
"@medusajs/utils": "^1.11.9",
|
"@medusajs/utils": "^1.11.9",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "5.9.7",
|
||||||
"@mikro-orm/postgresql": "5.9.7",
|
"@mikro-orm/postgresql": "5.9.7",
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
InternalModuleDeclaration,
|
InternalModuleDeclaration,
|
||||||
|
MODULE_RESOURCE_TYPE,
|
||||||
|
MODULE_SCOPE,
|
||||||
MedusaModule,
|
MedusaModule,
|
||||||
ModuleRegistrationName,
|
ModuleRegistrationName,
|
||||||
} from "@medusajs/modules-sdk"
|
} from "@medusajs/modules-sdk"
|
||||||
@@ -8,8 +10,6 @@ import {
|
|||||||
ILinkModule,
|
ILinkModule,
|
||||||
LinkModuleDefinition,
|
LinkModuleDefinition,
|
||||||
LoaderOptions,
|
LoaderOptions,
|
||||||
MODULE_RESOURCE_TYPE,
|
|
||||||
MODULE_SCOPE,
|
|
||||||
ModuleExports,
|
ModuleExports,
|
||||||
ModuleJoinerConfig,
|
ModuleJoinerConfig,
|
||||||
ModuleServiceInitializeCustomDataLayerOptions,
|
ModuleServiceInitializeCustomDataLayerOptions,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { MODULE_RESOURCE_TYPE } from "@medusajs/types"
|
import { MODULE_RESOURCE_TYPE } from "@medusajs/modules-sdk"
|
||||||
|
|
||||||
export * from "./compose-link-name"
|
export * from "./compose-link-name"
|
||||||
export * from "./generate-entity"
|
export * from "./generate-entity"
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@medusajs/types": "^1.11.16",
|
||||||
"@mikro-orm/cli": "5.9.7",
|
"@mikro-orm/cli": "5.9.7",
|
||||||
"cross-env": "^5.2.1",
|
"cross-env": "^5.2.1",
|
||||||
"jest": "^29.6.3",
|
"jest": "^29.6.3",
|
||||||
@@ -49,7 +50,6 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/modules-sdk": "^1.12.11",
|
"@medusajs/modules-sdk": "^1.12.11",
|
||||||
"@medusajs/types": "^1.11.16",
|
|
||||||
"@medusajs/utils": "^1.11.9",
|
"@medusajs/utils": "^1.11.9",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "5.9.7",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "5.9.7",
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@medusajs/types": "^1.11.16",
|
||||||
"@mikro-orm/cli": "5.9.7",
|
"@mikro-orm/cli": "5.9.7",
|
||||||
"cross-env": "^5.2.1",
|
"cross-env": "^5.2.1",
|
||||||
"jest": "^29.6.3",
|
"jest": "^29.6.3",
|
||||||
@@ -49,7 +50,6 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/modules-sdk": "^1.12.11",
|
"@medusajs/modules-sdk": "^1.12.11",
|
||||||
"@medusajs/types": "^1.11.16",
|
|
||||||
"@medusajs/utils": "^1.11.9",
|
"@medusajs/utils": "^1.11.9",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "5.9.7",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "5.9.7",
|
||||||
|
|||||||
@@ -2,11 +2,14 @@ import {
|
|||||||
CreatePaymentProviderSession,
|
CreatePaymentProviderSession,
|
||||||
PaymentProviderError,
|
PaymentProviderError,
|
||||||
PaymentProviderSessionResponse,
|
PaymentProviderSessionResponse,
|
||||||
PaymentSessionStatus,
|
|
||||||
ProviderWebhookPayload,
|
ProviderWebhookPayload,
|
||||||
WebhookActionResult,
|
WebhookActionResult,
|
||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
import { AbstractPaymentProvider, PaymentActions } from "@medusajs/utils"
|
import {
|
||||||
|
AbstractPaymentProvider,
|
||||||
|
PaymentActions,
|
||||||
|
PaymentSessionStatus,
|
||||||
|
} from "@medusajs/utils"
|
||||||
|
|
||||||
export class SystemProviderService extends AbstractPaymentProvider {
|
export class SystemProviderService extends AbstractPaymentProvider {
|
||||||
static identifier = "system"
|
static identifier = "system"
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
|
BigNumberInput,
|
||||||
CaptureDTO,
|
CaptureDTO,
|
||||||
Context,
|
Context,
|
||||||
CreateCaptureDTO,
|
CreateCaptureDTO,
|
||||||
@@ -18,7 +19,6 @@ import {
|
|||||||
PaymentDTO,
|
PaymentDTO,
|
||||||
PaymentProviderDTO,
|
PaymentProviderDTO,
|
||||||
PaymentSessionDTO,
|
PaymentSessionDTO,
|
||||||
PaymentSessionStatus,
|
|
||||||
ProviderWebhookPayload,
|
ProviderWebhookPayload,
|
||||||
RefundDTO,
|
RefundDTO,
|
||||||
UpdatePaymentCollectionDTO,
|
UpdatePaymentCollectionDTO,
|
||||||
@@ -37,6 +37,7 @@ import {
|
|||||||
ModulesSdkUtils,
|
ModulesSdkUtils,
|
||||||
PaymentActions,
|
PaymentActions,
|
||||||
PaymentCollectionStatus,
|
PaymentCollectionStatus,
|
||||||
|
PaymentSessionStatus,
|
||||||
promiseAll,
|
promiseAll,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import { IsolationLevel } from "@mikro-orm/core"
|
import { IsolationLevel } from "@mikro-orm/core"
|
||||||
@@ -417,6 +418,7 @@ export default class PaymentModuleService<
|
|||||||
"data",
|
"data",
|
||||||
"provider_id",
|
"provider_id",
|
||||||
"amount",
|
"amount",
|
||||||
|
"raw_amount",
|
||||||
"currency_code",
|
"currency_code",
|
||||||
"payment_collection_id",
|
"payment_collection_id",
|
||||||
],
|
],
|
||||||
@@ -434,14 +436,19 @@ export default class PaymentModuleService<
|
|||||||
return await this.baseRepository_.serialize(payment, { populate: true })
|
return await this.baseRepository_.serialize(payment, { populate: true })
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data, status } =
|
let { data, status } = await this.paymentProviderService_.authorizePayment(
|
||||||
await this.paymentProviderService_.authorizePayment(
|
{
|
||||||
{
|
provider_id: session.provider_id,
|
||||||
provider_id: session.provider_id,
|
data: session.data,
|
||||||
data: session.data,
|
},
|
||||||
},
|
context
|
||||||
context
|
)
|
||||||
)
|
|
||||||
|
let autoCapture = false
|
||||||
|
if (status === PaymentSessionStatus.CAPTURED) {
|
||||||
|
status = PaymentSessionStatus.AUTHORIZED
|
||||||
|
autoCapture = true
|
||||||
|
}
|
||||||
|
|
||||||
await this.paymentSessionService_.update(
|
await this.paymentSessionService_.update(
|
||||||
{
|
{
|
||||||
@@ -479,6 +486,13 @@ export default class PaymentModuleService<
|
|||||||
sharedContext
|
sharedContext
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (autoCapture) {
|
||||||
|
await this.capturePayment_(
|
||||||
|
{ payment_id: payment.id, amount: session.amount as BigNumberInput },
|
||||||
|
sharedContext
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return await this.retrievePayment(
|
return await this.retrievePayment(
|
||||||
payment.id,
|
payment.id,
|
||||||
{ relations: ["payment_collection"] },
|
{ relations: ["payment_collection"] },
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { PriceListStatus, PriceListType } from "@medusajs/utils"
|
import { PriceListStatus, PriceListType } from "@medusajs/types"
|
||||||
|
|
||||||
export interface CreatePriceListDTO {
|
export interface CreatePriceListDTO {
|
||||||
title: string
|
title: string
|
||||||
|
|||||||
+4
-3
@@ -1,4 +1,5 @@
|
|||||||
import { ProductTypes } from "@medusajs/types"
|
import { ProductTypes } from "@medusajs/types"
|
||||||
|
import { ProductStatus } from "@medusajs/utils"
|
||||||
import { Image } from "@models"
|
import { Image } from "@models"
|
||||||
import faker from "faker"
|
import faker from "faker"
|
||||||
|
|
||||||
@@ -19,7 +20,7 @@ export const buildProductOnlyData = ({
|
|||||||
discountable?: boolean
|
discountable?: boolean
|
||||||
thumbnail?: string
|
thumbnail?: string
|
||||||
images?: { id?: string; url: string }[]
|
images?: { id?: string; url: string }[]
|
||||||
status?: ProductTypes.ProductStatus
|
status?: ProductStatus
|
||||||
} = {}) => {
|
} = {}) => {
|
||||||
return {
|
return {
|
||||||
title: title ?? faker.commerce.productName(),
|
title: title ?? faker.commerce.productName(),
|
||||||
@@ -28,7 +29,7 @@ export const buildProductOnlyData = ({
|
|||||||
is_giftcard: is_giftcard ?? false,
|
is_giftcard: is_giftcard ?? false,
|
||||||
discountable: discountable ?? true,
|
discountable: discountable ?? true,
|
||||||
thumbnail: thumbnail as string,
|
thumbnail: thumbnail as string,
|
||||||
status: status ?? ProductTypes.ProductStatus.PUBLISHED,
|
status: status ?? ProductStatus.PUBLISHED,
|
||||||
images: (images ?? []) as Image[],
|
images: (images ?? []) as Image[],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -58,7 +59,7 @@ export const buildProductAndRelationsData = ({
|
|||||||
is_giftcard: is_giftcard ?? false,
|
is_giftcard: is_giftcard ?? false,
|
||||||
discountable: discountable ?? true,
|
discountable: discountable ?? true,
|
||||||
thumbnail: thumbnail as string,
|
thumbnail: thumbnail as string,
|
||||||
status: status ?? ProductTypes.ProductStatus.PUBLISHED,
|
status: status ?? ProductStatus.PUBLISHED,
|
||||||
images: (images ?? []) as Image[],
|
images: (images ?? []) as Image[],
|
||||||
type_id,
|
type_id,
|
||||||
tags: tags ?? [{ value: "tag-1" }],
|
tags: tags ?? [{ value: "tag-1" }],
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { ProductTypes } from "@medusajs/types"
|
import { ProductStatus } from "@medusajs/utils"
|
||||||
|
|
||||||
export const productsData = [
|
export const productsData = [
|
||||||
{
|
{
|
||||||
id: "test-1",
|
id: "test-1",
|
||||||
title: "product 1",
|
title: "product 1",
|
||||||
status: ProductTypes.ProductStatus.PUBLISHED,
|
status: ProductStatus.PUBLISHED,
|
||||||
tags: [
|
tags: [
|
||||||
{
|
{
|
||||||
id: "tag-1",
|
id: "tag-1",
|
||||||
@@ -15,7 +15,7 @@ export const productsData = [
|
|||||||
{
|
{
|
||||||
id: "test-2",
|
id: "test-2",
|
||||||
title: "product",
|
title: "product",
|
||||||
status: ProductTypes.ProductStatus.PUBLISHED,
|
status: ProductStatus.PUBLISHED,
|
||||||
tags: [
|
tags: [
|
||||||
{
|
{
|
||||||
id: "tag-2",
|
id: "tag-2",
|
||||||
@@ -26,7 +26,7 @@ export const productsData = [
|
|||||||
{
|
{
|
||||||
id: "test-3",
|
id: "test-3",
|
||||||
title: "product 3",
|
title: "product 3",
|
||||||
status: ProductTypes.ProductStatus.PUBLISHED,
|
status: ProductStatus.PUBLISHED,
|
||||||
tags: [
|
tags: [
|
||||||
{
|
{
|
||||||
id: "tag-3",
|
id: "tag-3",
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { ProductTypes } from "@medusajs/types"
|
import { ProductStatus } from "@medusajs/utils"
|
||||||
import { SqlEntityManager } from "@mikro-orm/postgresql"
|
import { SqlEntityManager } from "@mikro-orm/postgresql"
|
||||||
import {
|
import {
|
||||||
Image,
|
Image,
|
||||||
@@ -18,7 +18,7 @@ export async function createProductAndTags(
|
|||||||
data: {
|
data: {
|
||||||
id?: string
|
id?: string
|
||||||
title: string
|
title: string
|
||||||
status: ProductTypes.ProductStatus
|
status: ProductStatus
|
||||||
tags?: { id: string; value: string }[]
|
tags?: { id: string; value: string }[]
|
||||||
collection_id?: string
|
collection_id?: string
|
||||||
}[]
|
}[]
|
||||||
@@ -37,7 +37,7 @@ export async function createProductAndTypes(
|
|||||||
data: {
|
data: {
|
||||||
id?: string
|
id?: string
|
||||||
title: string
|
title: string
|
||||||
status: ProductTypes.ProductStatus
|
status: ProductStatus
|
||||||
type?: { id: string; value: string }
|
type?: { id: string; value: string }
|
||||||
}[]
|
}[]
|
||||||
) {
|
) {
|
||||||
|
|||||||
+4
-3
@@ -1,5 +1,6 @@
|
|||||||
import { Modules } from "@medusajs/modules-sdk"
|
import { Modules } from "@medusajs/modules-sdk"
|
||||||
import { IProductModuleService, ProductTypes } from "@medusajs/types"
|
import { IProductModuleService } from "@medusajs/types"
|
||||||
|
import { ProductStatus } from "@medusajs/utils"
|
||||||
import { Product, ProductCategory } from "@models"
|
import { Product, ProductCategory } from "@models"
|
||||||
import {
|
import {
|
||||||
MockEventBusService,
|
MockEventBusService,
|
||||||
@@ -33,13 +34,13 @@ moduleIntegrationTestRunner({
|
|||||||
productOne = testManager.create(Product, {
|
productOne = testManager.create(Product, {
|
||||||
id: "product-1",
|
id: "product-1",
|
||||||
title: "product 1",
|
title: "product 1",
|
||||||
status: ProductTypes.ProductStatus.PUBLISHED,
|
status: ProductStatus.PUBLISHED,
|
||||||
})
|
})
|
||||||
|
|
||||||
productTwo = testManager.create(Product, {
|
productTwo = testManager.create(Product, {
|
||||||
id: "product-2",
|
id: "product-2",
|
||||||
title: "product 2",
|
title: "product 2",
|
||||||
status: ProductTypes.ProductStatus.PUBLISHED,
|
status: ProductStatus.PUBLISHED,
|
||||||
})
|
})
|
||||||
|
|
||||||
const productCategoriesData = [
|
const productCategoriesData = [
|
||||||
|
|||||||
+11
-7
@@ -1,9 +1,13 @@
|
|||||||
import { IProductModuleService, ProductTypes } from "@medusajs/types"
|
|
||||||
import { Product, ProductCollection } from "@models"
|
|
||||||
import { MockEventBusService } from "medusa-test-utils"
|
|
||||||
import { createCollections } from "../../../__fixtures__/product"
|
|
||||||
import { Modules } from "@medusajs/modules-sdk"
|
import { Modules } from "@medusajs/modules-sdk"
|
||||||
import { moduleIntegrationTestRunner, SuiteOptions } from "medusa-test-utils"
|
import { IProductModuleService } from "@medusajs/types"
|
||||||
|
import { ProductStatus } from "@medusajs/utils"
|
||||||
|
import { Product, ProductCollection } from "@models"
|
||||||
|
import {
|
||||||
|
MockEventBusService,
|
||||||
|
SuiteOptions,
|
||||||
|
moduleIntegrationTestRunner,
|
||||||
|
} from "medusa-test-utils"
|
||||||
|
import { createCollections } from "../../../__fixtures__/product"
|
||||||
|
|
||||||
jest.setTimeout(30000)
|
jest.setTimeout(30000)
|
||||||
|
|
||||||
@@ -29,13 +33,13 @@ moduleIntegrationTestRunner({
|
|||||||
productOne = testManager.create(Product, {
|
productOne = testManager.create(Product, {
|
||||||
id: "product-1",
|
id: "product-1",
|
||||||
title: "product 1",
|
title: "product 1",
|
||||||
status: ProductTypes.ProductStatus.PUBLISHED,
|
status: ProductStatus.PUBLISHED,
|
||||||
})
|
})
|
||||||
|
|
||||||
productTwo = testManager.create(Product, {
|
productTwo = testManager.create(Product, {
|
||||||
id: "product-2",
|
id: "product-2",
|
||||||
title: "product 2",
|
title: "product 2",
|
||||||
status: ProductTypes.ProductStatus.PUBLISHED,
|
status: ProductStatus.PUBLISHED,
|
||||||
})
|
})
|
||||||
|
|
||||||
const productCollectionsData = [
|
const productCollectionsData = [
|
||||||
|
|||||||
+6
-5
@@ -1,7 +1,8 @@
|
|||||||
import { IProductModuleService, ProductTypes } from "@medusajs/types"
|
|
||||||
import { Product, ProductOption } from "@models"
|
|
||||||
import { Modules } from "@medusajs/modules-sdk"
|
import { Modules } from "@medusajs/modules-sdk"
|
||||||
import { moduleIntegrationTestRunner, SuiteOptions } from "medusa-test-utils"
|
import { IProductModuleService } from "@medusajs/types"
|
||||||
|
import { ProductStatus } from "@medusajs/utils"
|
||||||
|
import { Product, ProductOption } from "@models"
|
||||||
|
import { SuiteOptions, moduleIntegrationTestRunner } from "medusa-test-utils"
|
||||||
|
|
||||||
jest.setTimeout(30000)
|
jest.setTimeout(30000)
|
||||||
|
|
||||||
@@ -22,13 +23,13 @@ moduleIntegrationTestRunner({
|
|||||||
productOne = testManager.create(Product, {
|
productOne = testManager.create(Product, {
|
||||||
id: "product-1",
|
id: "product-1",
|
||||||
title: "product 1",
|
title: "product 1",
|
||||||
status: ProductTypes.ProductStatus.PUBLISHED,
|
status: ProductStatus.PUBLISHED,
|
||||||
})
|
})
|
||||||
|
|
||||||
productTwo = testManager.create(Product, {
|
productTwo = testManager.create(Product, {
|
||||||
id: "product-2",
|
id: "product-2",
|
||||||
title: "product 2",
|
title: "product 2",
|
||||||
status: ProductTypes.ProductStatus.PUBLISHED,
|
status: ProductStatus.PUBLISHED,
|
||||||
})
|
})
|
||||||
|
|
||||||
optionOne = testManager.create(ProductOption, {
|
optionOne = testManager.create(ProductOption, {
|
||||||
|
|||||||
+5
-4
@@ -1,7 +1,8 @@
|
|||||||
import { Modules } from "@medusajs/modules-sdk"
|
import { Modules } from "@medusajs/modules-sdk"
|
||||||
import { IProductModuleService, ProductTypes } from "@medusajs/types"
|
import { IProductModuleService } from "@medusajs/types"
|
||||||
|
import { ProductStatus } from "@medusajs/utils"
|
||||||
import { Product, ProductTag } from "@models"
|
import { Product, ProductTag } from "@models"
|
||||||
import { moduleIntegrationTestRunner, SuiteOptions } from "medusa-test-utils"
|
import { SuiteOptions, moduleIntegrationTestRunner } from "medusa-test-utils"
|
||||||
|
|
||||||
jest.setTimeout(30000)
|
jest.setTimeout(30000)
|
||||||
|
|
||||||
@@ -22,13 +23,13 @@ moduleIntegrationTestRunner({
|
|||||||
productOne = testManager.create(Product, {
|
productOne = testManager.create(Product, {
|
||||||
id: "product-1",
|
id: "product-1",
|
||||||
title: "product 1",
|
title: "product 1",
|
||||||
status: ProductTypes.ProductStatus.PUBLISHED,
|
status: ProductStatus.PUBLISHED,
|
||||||
})
|
})
|
||||||
|
|
||||||
productTwo = testManager.create(Product, {
|
productTwo = testManager.create(Product, {
|
||||||
id: "product-2",
|
id: "product-2",
|
||||||
title: "product 2",
|
title: "product 2",
|
||||||
status: ProductTypes.ProductStatus.PUBLISHED,
|
status: ProductStatus.PUBLISHED,
|
||||||
})
|
})
|
||||||
|
|
||||||
tagOne = testManager.create(ProductTag, {
|
tagOne = testManager.create(ProductTag, {
|
||||||
|
|||||||
+4
-3
@@ -1,5 +1,6 @@
|
|||||||
import { Modules } from "@medusajs/modules-sdk"
|
import { Modules } from "@medusajs/modules-sdk"
|
||||||
import { IProductModuleService, ProductTypes } from "@medusajs/types"
|
import { IProductModuleService } from "@medusajs/types"
|
||||||
|
import { ProductStatus } from "@medusajs/utils"
|
||||||
import { Product, ProductVariant } from "@models"
|
import { Product, ProductVariant } from "@models"
|
||||||
|
|
||||||
import { moduleIntegrationTestRunner, SuiteOptions } from "medusa-test-utils"
|
import { moduleIntegrationTestRunner, SuiteOptions } from "medusa-test-utils"
|
||||||
@@ -22,7 +23,7 @@ moduleIntegrationTestRunner({
|
|||||||
productOne = await service.create({
|
productOne = await service.create({
|
||||||
id: "product-1",
|
id: "product-1",
|
||||||
title: "product 1",
|
title: "product 1",
|
||||||
status: ProductTypes.ProductStatus.PUBLISHED,
|
status: ProductStatus.PUBLISHED,
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
title: "size",
|
title: "size",
|
||||||
@@ -38,7 +39,7 @@ moduleIntegrationTestRunner({
|
|||||||
productTwo = await service.create({
|
productTwo = await service.create({
|
||||||
id: "product-2",
|
id: "product-2",
|
||||||
title: "product 2",
|
title: "product 2",
|
||||||
status: ProductTypes.ProductStatus.PUBLISHED,
|
status: ProductStatus.PUBLISHED,
|
||||||
})
|
})
|
||||||
|
|
||||||
variantOne = await service.createVariants({
|
variantOne = await service.createVariants({
|
||||||
|
|||||||
+5
-6
@@ -1,14 +1,14 @@
|
|||||||
import { Modules } from "@medusajs/modules-sdk"
|
import { Modules } from "@medusajs/modules-sdk"
|
||||||
import { IProductModuleService, ProductTypes } from "@medusajs/types"
|
import { IProductModuleService } from "@medusajs/types"
|
||||||
import { kebabCase } from "@medusajs/utils"
|
import { kebabCase, ProductStatus } from "@medusajs/utils"
|
||||||
import {
|
import {
|
||||||
Product,
|
Product,
|
||||||
ProductCategory,
|
ProductCategory,
|
||||||
ProductCollection,
|
ProductCollection,
|
||||||
ProductType,
|
ProductType,
|
||||||
ProductVariant,
|
|
||||||
} from "@models"
|
} from "@models"
|
||||||
|
|
||||||
|
import { UpdateProductInput } from "@types"
|
||||||
import {
|
import {
|
||||||
MockEventBusService,
|
MockEventBusService,
|
||||||
moduleIntegrationTestRunner,
|
moduleIntegrationTestRunner,
|
||||||
@@ -17,7 +17,6 @@ import {
|
|||||||
import { createCollections, createTypes } from "../../../__fixtures__/product"
|
import { createCollections, createTypes } from "../../../__fixtures__/product"
|
||||||
import { createProductCategories } from "../../../__fixtures__/product-category"
|
import { createProductCategories } from "../../../__fixtures__/product-category"
|
||||||
import { buildProductAndRelationsData } from "../../../__fixtures__/product/data/create-product"
|
import { buildProductAndRelationsData } from "../../../__fixtures__/product/data/create-product"
|
||||||
import { UpdateProductInput } from "@types"
|
|
||||||
|
|
||||||
jest.setTimeout(300000)
|
jest.setTimeout(300000)
|
||||||
|
|
||||||
@@ -114,7 +113,7 @@ moduleIntegrationTestRunner({
|
|||||||
productOne = service.create({
|
productOne = service.create({
|
||||||
id: "product-1",
|
id: "product-1",
|
||||||
title: "product 1",
|
title: "product 1",
|
||||||
status: ProductTypes.ProductStatus.PUBLISHED,
|
status: ProductStatus.PUBLISHED,
|
||||||
variants: [
|
variants: [
|
||||||
{
|
{
|
||||||
id: "variant-1",
|
id: "variant-1",
|
||||||
@@ -126,7 +125,7 @@ moduleIntegrationTestRunner({
|
|||||||
productTwo = service.create({
|
productTwo = service.create({
|
||||||
id: "product-2",
|
id: "product-2",
|
||||||
title: "product 2",
|
title: "product 2",
|
||||||
status: ProductTypes.ProductStatus.PUBLISHED,
|
status: ProductStatus.PUBLISHED,
|
||||||
categories: [{ id: productCategoryOne.id }],
|
categories: [{ id: productCategoryOne.id }],
|
||||||
collection_id: productCollectionOne.id,
|
collection_id: productCollectionOne.id,
|
||||||
tags: tagsData,
|
tags: tagsData,
|
||||||
|
|||||||
+7
-9
@@ -1,12 +1,10 @@
|
|||||||
import { ProductOptionService } from "@services"
|
|
||||||
import { Product } from "@models"
|
|
||||||
|
|
||||||
import { createOptions } from "../../../__fixtures__/product"
|
|
||||||
import { ProductTypes } from "@medusajs/types"
|
|
||||||
|
|
||||||
import { Modules } from "@medusajs/modules-sdk"
|
import { Modules } from "@medusajs/modules-sdk"
|
||||||
import { moduleIntegrationTestRunner, SuiteOptions } from "medusa-test-utils"
|
|
||||||
import { IProductModuleService } from "@medusajs/types"
|
import { IProductModuleService } from "@medusajs/types"
|
||||||
|
import { ProductStatus } from "@medusajs/utils"
|
||||||
|
import { Product } from "@models"
|
||||||
|
import { ProductOptionService } from "@services"
|
||||||
|
import { moduleIntegrationTestRunner, SuiteOptions } from "medusa-test-utils"
|
||||||
|
import { createOptions } from "../../../__fixtures__/product"
|
||||||
|
|
||||||
jest.setTimeout(30000)
|
jest.setTimeout(30000)
|
||||||
|
|
||||||
@@ -29,13 +27,13 @@ moduleIntegrationTestRunner({
|
|||||||
const productOneData = {
|
const productOneData = {
|
||||||
id: "product-1",
|
id: "product-1",
|
||||||
title: "product 1",
|
title: "product 1",
|
||||||
status: ProductTypes.ProductStatus.PUBLISHED,
|
status: ProductStatus.PUBLISHED,
|
||||||
}
|
}
|
||||||
|
|
||||||
const productTwoData = {
|
const productTwoData = {
|
||||||
id: "product-2",
|
id: "product-2",
|
||||||
title: "product 2",
|
title: "product 2",
|
||||||
status: ProductTypes.ProductStatus.PUBLISHED,
|
status: ProductStatus.PUBLISHED,
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
|
import { Modules } from "@medusajs/modules-sdk"
|
||||||
|
import { IProductModuleService } from "@medusajs/types"
|
||||||
|
import { ProductStatus } from "@medusajs/utils"
|
||||||
import { Product } from "@models"
|
import { Product } from "@models"
|
||||||
import { ProductTagService } from "@services"
|
import { ProductTagService } from "@services"
|
||||||
|
|
||||||
import { ProductTypes } from "@medusajs/types"
|
|
||||||
import { createProductAndTags } from "../../../__fixtures__/product"
|
|
||||||
import { Modules } from "@medusajs/modules-sdk"
|
|
||||||
import { moduleIntegrationTestRunner, SuiteOptions } from "medusa-test-utils"
|
import { moduleIntegrationTestRunner, SuiteOptions } from "medusa-test-utils"
|
||||||
import { IProductModuleService } from "@medusajs/types"
|
import { createProductAndTags } from "../../../__fixtures__/product"
|
||||||
|
|
||||||
jest.setTimeout(30000)
|
jest.setTimeout(30000)
|
||||||
|
|
||||||
@@ -27,7 +26,7 @@ moduleIntegrationTestRunner({
|
|||||||
{
|
{
|
||||||
id: "test-1",
|
id: "test-1",
|
||||||
title: "product 1",
|
title: "product 1",
|
||||||
status: ProductTypes.ProductStatus.PUBLISHED,
|
status: ProductStatus.PUBLISHED,
|
||||||
tags: [
|
tags: [
|
||||||
{
|
{
|
||||||
id: "tag-1",
|
id: "tag-1",
|
||||||
@@ -38,7 +37,7 @@ moduleIntegrationTestRunner({
|
|||||||
{
|
{
|
||||||
id: "test-2",
|
id: "test-2",
|
||||||
title: "product",
|
title: "product",
|
||||||
status: ProductTypes.ProductStatus.PUBLISHED,
|
status: ProductStatus.PUBLISHED,
|
||||||
tags: [
|
tags: [
|
||||||
{
|
{
|
||||||
id: "tag-2",
|
id: "tag-2",
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
import { ProductTypeService } from "@services"
|
|
||||||
import { Product } from "@models"
|
|
||||||
|
|
||||||
import { createProductAndTypes } from "../../../__fixtures__/product"
|
|
||||||
import { ProductTypes } from "@medusajs/types"
|
|
||||||
import { Modules } from "@medusajs/modules-sdk"
|
import { Modules } from "@medusajs/modules-sdk"
|
||||||
import { moduleIntegrationTestRunner, SuiteOptions } from "medusa-test-utils"
|
|
||||||
import { IProductModuleService } from "@medusajs/types"
|
import { IProductModuleService } from "@medusajs/types"
|
||||||
|
import { ProductStatus } from "@medusajs/utils"
|
||||||
|
import { Product } from "@models"
|
||||||
|
import { ProductTypeService } from "@services"
|
||||||
|
import { moduleIntegrationTestRunner, SuiteOptions } from "medusa-test-utils"
|
||||||
|
import { createProductAndTypes } from "../../../__fixtures__/product"
|
||||||
|
|
||||||
jest.setTimeout(30000)
|
jest.setTimeout(30000)
|
||||||
|
|
||||||
@@ -27,7 +26,7 @@ moduleIntegrationTestRunner({
|
|||||||
{
|
{
|
||||||
id: "product-1",
|
id: "product-1",
|
||||||
title: "product 1",
|
title: "product 1",
|
||||||
status: ProductTypes.ProductStatus.PUBLISHED,
|
status: ProductStatus.PUBLISHED,
|
||||||
type: {
|
type: {
|
||||||
id: "type-1",
|
id: "type-1",
|
||||||
value: "Type 1",
|
value: "Type 1",
|
||||||
@@ -36,7 +35,7 @@ moduleIntegrationTestRunner({
|
|||||||
{
|
{
|
||||||
id: "product-2",
|
id: "product-2",
|
||||||
title: "product",
|
title: "product",
|
||||||
status: ProductTypes.ProductStatus.PUBLISHED,
|
status: ProductStatus.PUBLISHED,
|
||||||
type: {
|
type: {
|
||||||
id: "type-2",
|
id: "type-2",
|
||||||
value: "Type 2",
|
value: "Type 2",
|
||||||
|
|||||||
+4
-7
@@ -1,8 +1,5 @@
|
|||||||
import {
|
import { InternalModuleService, IProductModuleService } from "@medusajs/types"
|
||||||
InternalModuleService,
|
import { ProductStatus } from "@medusajs/utils"
|
||||||
IProductModuleService,
|
|
||||||
ProductTypes,
|
|
||||||
} from "@medusajs/types"
|
|
||||||
import { Collection } from "@mikro-orm/core"
|
import { Collection } from "@mikro-orm/core"
|
||||||
import { Product, ProductOption, ProductTag, ProductVariant } from "@models"
|
import { Product, ProductOption, ProductTag, ProductVariant } from "@models"
|
||||||
import {
|
import {
|
||||||
@@ -42,7 +39,7 @@ moduleIntegrationTestRunner({
|
|||||||
productOne = testManager.create(Product, {
|
productOne = testManager.create(Product, {
|
||||||
id: "product-1",
|
id: "product-1",
|
||||||
title: "product 1",
|
title: "product 1",
|
||||||
status: ProductTypes.ProductStatus.PUBLISHED,
|
status: ProductStatus.PUBLISHED,
|
||||||
})
|
})
|
||||||
|
|
||||||
variantOne = testManager.create(ProductVariant, {
|
variantOne = testManager.create(ProductVariant, {
|
||||||
@@ -251,7 +248,7 @@ moduleIntegrationTestRunner({
|
|||||||
productOne = testManager.create(Product, {
|
productOne = testManager.create(Product, {
|
||||||
id: "product-1",
|
id: "product-1",
|
||||||
title: "product 1",
|
title: "product 1",
|
||||||
status: ProductTypes.ProductStatus.PUBLISHED,
|
status: ProductStatus.PUBLISHED,
|
||||||
})
|
})
|
||||||
|
|
||||||
variantOne = testManager.create(ProductVariant, {
|
variantOne = testManager.create(ProductVariant, {
|
||||||
|
|||||||
@@ -8,23 +8,18 @@ import {
|
|||||||
createProductVariants,
|
createProductVariants,
|
||||||
} from "../../../__fixtures__/product"
|
} from "../../../__fixtures__/product"
|
||||||
|
|
||||||
|
import { Modules } from "@medusajs/modules-sdk"
|
||||||
|
import { IProductModuleService, ProductDTO } from "@medusajs/types"
|
||||||
|
import { ProductStatus, kebabCase } from "@medusajs/utils"
|
||||||
|
import { SqlEntityManager } from "@mikro-orm/postgresql"
|
||||||
|
import { ProductService } from "@services"
|
||||||
|
import { SuiteOptions, moduleIntegrationTestRunner } from "medusa-test-utils"
|
||||||
|
import { createProductCategories } from "../../../__fixtures__/product-category"
|
||||||
import {
|
import {
|
||||||
categoriesData,
|
categoriesData,
|
||||||
productsData,
|
productsData,
|
||||||
variantsData,
|
variantsData,
|
||||||
} from "../../../__fixtures__/product/data"
|
} from "../../../__fixtures__/product/data"
|
||||||
import { ProductService } from "@services"
|
|
||||||
import {
|
|
||||||
IProductModuleService,
|
|
||||||
ProductDTO,
|
|
||||||
ProductTypes,
|
|
||||||
} from "@medusajs/types"
|
|
||||||
import { kebabCase } from "@medusajs/utils"
|
|
||||||
import { SqlEntityManager } from "@mikro-orm/postgresql"
|
|
||||||
import { createProductCategories } from "../../../__fixtures__/product-category"
|
|
||||||
import { Modules } from "@medusajs/modules-sdk"
|
|
||||||
import { moduleIntegrationTestRunner, SuiteOptions } from "medusa-test-utils"
|
|
||||||
import { ProductTag } from "../../../../src/models"
|
|
||||||
|
|
||||||
jest.setTimeout(30000)
|
jest.setTimeout(30000)
|
||||||
|
|
||||||
@@ -52,7 +47,7 @@ moduleIntegrationTestRunner({
|
|||||||
productOne = testManager.create(Product, {
|
productOne = testManager.create(Product, {
|
||||||
id: "product-1",
|
id: "product-1",
|
||||||
title: "product 1",
|
title: "product 1",
|
||||||
status: ProductTypes.ProductStatus.PUBLISHED,
|
status: ProductStatus.PUBLISHED,
|
||||||
})
|
})
|
||||||
|
|
||||||
await testManager.persistAndFlush([productOne])
|
await testManager.persistAndFlush([productOne])
|
||||||
@@ -145,7 +140,7 @@ moduleIntegrationTestRunner({
|
|||||||
productOne = testManager.create(Product, {
|
productOne = testManager.create(Product, {
|
||||||
id: "product-1",
|
id: "product-1",
|
||||||
title: "product 1",
|
title: "product 1",
|
||||||
status: ProductTypes.ProductStatus.PUBLISHED,
|
status: ProductStatus.PUBLISHED,
|
||||||
})
|
})
|
||||||
|
|
||||||
await testManager.persistAndFlush([productOne])
|
await testManager.persistAndFlush([productOne])
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@medusajs/types": "^1.11.16",
|
||||||
"@mikro-orm/cli": "5.9.7",
|
"@mikro-orm/cli": "5.9.7",
|
||||||
"cross-env": "^5.2.1",
|
"cross-env": "^5.2.1",
|
||||||
"faker": "^5.5.3",
|
"faker": "^5.5.3",
|
||||||
@@ -51,7 +52,6 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/modules-sdk": "^1.12.11",
|
"@medusajs/modules-sdk": "^1.12.11",
|
||||||
"@medusajs/types": "^1.11.16",
|
|
||||||
"@medusajs/utils": "^1.11.9",
|
"@medusajs/utils": "^1.11.9",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "5.9.7",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "5.9.7",
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
export function shouldForceTransaction(): boolean {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
export function doNotForceTransaction(): boolean {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
@@ -37,6 +37,7 @@
|
|||||||
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@medusajs/types": "^1.11.16",
|
||||||
"@mikro-orm/cli": "5.9.7",
|
"@mikro-orm/cli": "5.9.7",
|
||||||
"cross-env": "^5.2.1",
|
"cross-env": "^5.2.1",
|
||||||
"jest": "^29.6.3",
|
"jest": "^29.6.3",
|
||||||
@@ -49,7 +50,6 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/modules-sdk": "^1.12.11",
|
"@medusajs/modules-sdk": "^1.12.11",
|
||||||
"@medusajs/types": "^1.11.16",
|
|
||||||
"@medusajs/utils": "1.11.9",
|
"@medusajs/utils": "1.11.9",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "5.9.7",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "5.9.7",
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import {
|
|||||||
MedusaContainer,
|
MedusaContainer,
|
||||||
PaymentProviderError,
|
PaymentProviderError,
|
||||||
PaymentProviderSessionResponse,
|
PaymentProviderSessionResponse,
|
||||||
PaymentSessionStatus,
|
|
||||||
ProviderWebhookPayload,
|
ProviderWebhookPayload,
|
||||||
UpdatePaymentProviderSession,
|
UpdatePaymentProviderSession,
|
||||||
WebhookActionResult,
|
WebhookActionResult,
|
||||||
@@ -16,8 +15,9 @@ import {
|
|||||||
BigNumber,
|
BigNumber,
|
||||||
MedusaError,
|
MedusaError,
|
||||||
PaymentActions,
|
PaymentActions,
|
||||||
|
PaymentSessionStatus,
|
||||||
|
isDefined,
|
||||||
isPaymentProviderError,
|
isPaymentProviderError,
|
||||||
isDefined
|
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
|
|
||||||
import { CreatePaymentProviderSession } from "@medusajs/types"
|
import { CreatePaymentProviderSession } from "@medusajs/types"
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@medusajs/types": "^1.11.16",
|
||||||
"@mikro-orm/cli": "5.9.7",
|
"@mikro-orm/cli": "5.9.7",
|
||||||
"cross-env": "^5.2.1",
|
"cross-env": "^5.2.1",
|
||||||
"jest": "^29.6.3",
|
"jest": "^29.6.3",
|
||||||
@@ -49,7 +50,6 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/modules-sdk": "^1.12.11",
|
"@medusajs/modules-sdk": "^1.12.11",
|
||||||
"@medusajs/types": "^1.11.16",
|
|
||||||
"@medusajs/utils": "^1.11.9",
|
"@medusajs/utils": "^1.11.9",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "5.9.7",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "5.9.7",
|
||||||
|
|||||||
@@ -33,7 +33,6 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/modules-sdk": "^1.12.11",
|
"@medusajs/modules-sdk": "^1.12.11",
|
||||||
"@medusajs/types": "^1.11.16",
|
|
||||||
"@medusajs/utils": "^1.11.9",
|
"@medusajs/utils": "^1.11.9",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "5.9.7",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "5.9.7",
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@medusajs/types": "^1.11.16",
|
||||||
"@mikro-orm/cli": "5.9.7",
|
"@mikro-orm/cli": "5.9.7",
|
||||||
"cross-env": "^5.2.1",
|
"cross-env": "^5.2.1",
|
||||||
"jest": "^29.6.3",
|
"jest": "^29.6.3",
|
||||||
@@ -49,7 +50,6 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/modules-sdk": "^1.12.11",
|
"@medusajs/modules-sdk": "^1.12.11",
|
||||||
"@medusajs/types": "^1.11.16",
|
|
||||||
"@medusajs/utils": "^1.11.9",
|
"@medusajs/utils": "^1.11.9",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "5.9.7",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "5.9.7",
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@medusajs/types": "^1.11.15",
|
||||||
"@mikro-orm/cli": "5.9.7",
|
"@mikro-orm/cli": "5.9.7",
|
||||||
"cross-env": "^5.2.1",
|
"cross-env": "^5.2.1",
|
||||||
"jest": "^29.6.3",
|
"jest": "^29.6.3",
|
||||||
@@ -49,7 +50,6 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/modules-sdk": "^1.12.10",
|
"@medusajs/modules-sdk": "^1.12.10",
|
||||||
"@medusajs/types": "^1.11.15",
|
|
||||||
"@medusajs/utils": "^1.11.8",
|
"@medusajs/utils": "^1.11.8",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "5.9.7",
|
||||||
"@mikro-orm/migrations": "5.9.7",
|
"@mikro-orm/migrations": "5.9.7",
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@medusajs/types": "^1.11.16",
|
||||||
"@mikro-orm/cli": "5.9.7",
|
"@mikro-orm/cli": "5.9.7",
|
||||||
"cross-env": "^5.2.1",
|
"cross-env": "^5.2.1",
|
||||||
"jest": "^29.6.3",
|
"jest": "^29.6.3",
|
||||||
@@ -46,7 +47,6 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/modules-sdk": "^1.12.11",
|
"@medusajs/modules-sdk": "^1.12.11",
|
||||||
"@medusajs/types": "^1.11.16",
|
|
||||||
"@medusajs/utils": "^1.11.9",
|
"@medusajs/utils": "^1.11.9",
|
||||||
"@medusajs/workflows-sdk": "^0.1.6",
|
"@medusajs/workflows-sdk": "^0.1.6",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "5.9.7",
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@medusajs/types": "^1.11.16",
|
||||||
"@mikro-orm/cli": "5.9.7",
|
"@mikro-orm/cli": "5.9.7",
|
||||||
"cross-env": "^5.2.1",
|
"cross-env": "^5.2.1",
|
||||||
"jest": "^29.6.3",
|
"jest": "^29.6.3",
|
||||||
@@ -46,7 +47,6 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@medusajs/modules-sdk": "^1.12.11",
|
"@medusajs/modules-sdk": "^1.12.11",
|
||||||
"@medusajs/types": "^1.11.16",
|
|
||||||
"@medusajs/utils": "^1.11.9",
|
"@medusajs/utils": "^1.11.9",
|
||||||
"@medusajs/workflows-sdk": "^0.1.6",
|
"@medusajs/workflows-sdk": "^0.1.6",
|
||||||
"@mikro-orm/core": "5.9.7",
|
"@mikro-orm/core": "5.9.7",
|
||||||
|
|||||||
Reference in new issue
Block a user