chore: Refactor and improve abstract module service factory (#7688)
* chore: Refactor and improve abstract module service factory * align naming * clean up some template args and tests * partially migrate modules * partially migrate modules * migrate more modules * migrate last modules * fix typings * rename interface * rename interface * fixes * fixes * rm local plain tests
This commit is contained in:
@@ -9,9 +9,10 @@ import { MedusaContainer } from "../common"
|
|||||||
import { RepositoryService } from "../dal"
|
import { RepositoryService } from "../dal"
|
||||||
import { Logger } from "../logger"
|
import { Logger } from "../logger"
|
||||||
|
|
||||||
export type Constructor<T> = new (...args: any[]) => T
|
export type Constructor<T> = new (...args: any[]) => T | (new () => T)
|
||||||
|
|
||||||
export * from "../common/medusa-container"
|
export * from "../common/medusa-container"
|
||||||
export * from "./internal-module-service"
|
export * from "./medusa-internal-service"
|
||||||
export * from "./module-provider"
|
export * from "./module-provider"
|
||||||
|
|
||||||
export type LogLevel =
|
export type LogLevel =
|
||||||
|
|||||||
+1
-1
@@ -8,7 +8,7 @@ import {
|
|||||||
UpsertWithReplaceConfig,
|
UpsertWithReplaceConfig,
|
||||||
} from "../dal"
|
} from "../dal"
|
||||||
|
|
||||||
export interface InternalModuleService<
|
export interface IMedusaInternalService<
|
||||||
TEntity extends {},
|
TEntity extends {},
|
||||||
TContainer extends object = object
|
TContainer extends object = object
|
||||||
> {
|
> {
|
||||||
+9
-9
@@ -1,4 +1,4 @@
|
|||||||
import { internalModuleServiceFactory } from "../internal-module-service-factory"
|
import { MedusaInternalService } from "../medusa-internal-service"
|
||||||
import { lowerCaseFirst } from "../../common"
|
import { lowerCaseFirst } from "../../common"
|
||||||
|
|
||||||
const defaultContext = { __type: "MedusaContext" }
|
const defaultContext = { __type: "MedusaContext" }
|
||||||
@@ -39,14 +39,14 @@ describe("Internal Module Service Factory", () => {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
const internalModuleService = internalModuleServiceFactory<any>(Model)
|
const IMedusaInternalService = MedusaInternalService<any>(Model)
|
||||||
|
|
||||||
describe("Internal Module Service Methods", () => {
|
describe("Internal Module Service Methods", () => {
|
||||||
let instance
|
let instance
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.clearAllMocks()
|
jest.clearAllMocks()
|
||||||
instance = new internalModuleService(containerMock)
|
instance = new IMedusaInternalService(containerMock)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should throw model id undefined error on retrieve if id is not defined", async () => {
|
it("should throw model id undefined error on retrieve if id is not defined", async () => {
|
||||||
@@ -62,10 +62,10 @@ describe("Internal Module Service Factory", () => {
|
|||||||
static meta = { primaryKeys: ["id", "name"] }
|
static meta = { primaryKeys: ["id", "name"] }
|
||||||
}
|
}
|
||||||
|
|
||||||
const compositeInternalModuleService =
|
const compositeIMedusaInternalService =
|
||||||
internalModuleServiceFactory<any>(CompositeModel)
|
MedusaInternalService<any>(CompositeModel)
|
||||||
|
|
||||||
const instance = new compositeInternalModuleService(containerMock)
|
const instance = new compositeIMedusaInternalService(containerMock)
|
||||||
|
|
||||||
const err = await instance.retrieve().catch((e) => e)
|
const err = await instance.retrieve().catch((e) => e)
|
||||||
expect(err.message).toBe("compositeModel - id, name must be defined")
|
expect(err.message).toBe("compositeModel - id, name must be defined")
|
||||||
@@ -94,10 +94,10 @@ describe("Internal Module Service Factory", () => {
|
|||||||
static meta = { primaryKeys: ["id", "name"] }
|
static meta = { primaryKeys: ["id", "name"] }
|
||||||
}
|
}
|
||||||
|
|
||||||
const compositeInternalModuleService =
|
const compositeIMedusaInternalService =
|
||||||
internalModuleServiceFactory<any>(CompositeModel)
|
MedusaInternalService<any>(CompositeModel)
|
||||||
|
|
||||||
const instance = new compositeInternalModuleService(containerMock)
|
const instance = new compositeIMedusaInternalService(containerMock)
|
||||||
|
|
||||||
const entity = { id: "1", name: "Item" }
|
const entity = { id: "1", name: "Item" }
|
||||||
containerMock[
|
containerMock[
|
||||||
+10
-23
@@ -1,4 +1,4 @@
|
|||||||
import { abstractModuleServiceFactory } from "../abstract-module-service-factory"
|
import { MedusaService } from "../medusa-service"
|
||||||
|
|
||||||
const baseRepoMock = {
|
const baseRepoMock = {
|
||||||
serialize: jest.fn().mockImplementation((item) => item),
|
serialize: jest.fn().mockImplementation((item) => item),
|
||||||
@@ -41,13 +41,12 @@ describe("Abstract Module Service Factory", () => {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
const mainModelMock = class MainModelMock {}
|
class MainModelMock {}
|
||||||
const otherModelMock1 = class OtherModelMock1 {}
|
class OtherModelMock1 {}
|
||||||
const otherModelMock2 = class OtherModelMock2 {}
|
class OtherModelMock2 {}
|
||||||
|
|
||||||
const abstractModuleService = abstractModuleServiceFactory<
|
const abstractModuleService = MedusaService<
|
||||||
any,
|
MainModelMock,
|
||||||
any,
|
|
||||||
{
|
{
|
||||||
OtherModelMock1: {
|
OtherModelMock1: {
|
||||||
dto: any
|
dto: any
|
||||||
@@ -60,22 +59,10 @@ describe("Abstract Module Service Factory", () => {
|
|||||||
plural: "OtherModelMock2s"
|
plural: "OtherModelMock2s"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
>(
|
>(MainModelMock, {
|
||||||
mainModelMock,
|
OtherModelMock1,
|
||||||
[
|
OtherModelMock2,
|
||||||
{
|
})
|
||||||
model: otherModelMock1,
|
|
||||||
plural: "otherModelMock1s",
|
|
||||||
singular: "otherModelMock1",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
model: otherModelMock2,
|
|
||||||
plural: "otherModelMock2s",
|
|
||||||
singular: "otherModelMock2",
|
|
||||||
},
|
|
||||||
]
|
|
||||||
// Add more parameters as needed
|
|
||||||
)
|
|
||||||
|
|
||||||
describe("Main Model Methods", () => {
|
describe("Main Model Methods", () => {
|
||||||
let instance
|
let instance
|
||||||
@@ -6,7 +6,7 @@ export * from "./loaders/mikro-orm-connection-loader-factory"
|
|||||||
export * from "./loaders/container-loader-factory"
|
export * from "./loaders/container-loader-factory"
|
||||||
export * from "./create-pg-connection"
|
export * from "./create-pg-connection"
|
||||||
export * from "./migration-scripts"
|
export * from "./migration-scripts"
|
||||||
export * from "./internal-module-service-factory"
|
export * from "./medusa-internal-service"
|
||||||
export * from "./abstract-module-service-factory"
|
export * from "./medusa-service"
|
||||||
export * from "./definition"
|
export * from "./definition"
|
||||||
export * from "./event-builder-factory"
|
export * from "./event-builder-factory"
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
|
|
||||||
import { asClass } from "awilix"
|
import { asClass } from "awilix"
|
||||||
import { internalModuleServiceFactory } from "../internal-module-service-factory"
|
import { MedusaInternalService } from "../medusa-internal-service"
|
||||||
import { lowerCaseFirst } from "../../common"
|
import { lowerCaseFirst } from "../../common"
|
||||||
import {
|
import {
|
||||||
MikroOrmBaseRepository,
|
MikroOrmBaseRepository,
|
||||||
@@ -100,10 +100,7 @@ export function loadModuleServices({
|
|||||||
const finalService = moduleServicesMap.get(mappedServiceName)
|
const finalService = moduleServicesMap.get(mappedServiceName)
|
||||||
|
|
||||||
if (!finalService) {
|
if (!finalService) {
|
||||||
moduleServicesMap.set(
|
moduleServicesMap.set(mappedServiceName, MedusaInternalService(Model))
|
||||||
mappedServiceName,
|
|
||||||
internalModuleServiceFactory(Model)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
+4
-6
@@ -33,20 +33,18 @@ type SelectorAndData = {
|
|||||||
data: any
|
data: any
|
||||||
}
|
}
|
||||||
|
|
||||||
export function internalModuleServiceFactory<
|
export function MedusaInternalService<TContainer extends object = object>(
|
||||||
TContainer extends object = object
|
|
||||||
>(
|
|
||||||
model: any
|
model: any
|
||||||
): {
|
): {
|
||||||
new <TEntity extends object = any>(
|
new <TEntity extends object = any>(
|
||||||
container: TContainer
|
container: TContainer
|
||||||
): ModulesSdkTypes.InternalModuleService<TEntity, TContainer>
|
): ModulesSdkTypes.IMedusaInternalService<TEntity, TContainer>
|
||||||
} {
|
} {
|
||||||
const injectedRepositoryName = `${lowerCaseFirst(model.name)}Repository`
|
const injectedRepositoryName = `${lowerCaseFirst(model.name)}Repository`
|
||||||
const propertyRepositoryName = `__${injectedRepositoryName}__`
|
const propertyRepositoryName = `__${injectedRepositoryName}__`
|
||||||
|
|
||||||
class AbstractService_<TEntity extends object>
|
class AbstractService_<TEntity extends object>
|
||||||
implements ModulesSdkTypes.InternalModuleService<TEntity, TContainer>
|
implements ModulesSdkTypes.IMedusaInternalService<TEntity, TContainer>
|
||||||
{
|
{
|
||||||
readonly __container__: TContainer;
|
readonly __container__: TContainer;
|
||||||
[key: string]: any
|
[key: string]: any
|
||||||
@@ -525,5 +523,5 @@ export function internalModuleServiceFactory<
|
|||||||
|
|
||||||
return AbstractService_ as unknown as new <TEntity extends {}>(
|
return AbstractService_ as unknown as new <TEntity extends {}>(
|
||||||
container: TContainer
|
container: TContainer
|
||||||
) => ModulesSdkTypes.InternalModuleService<TEntity, TContainer>
|
) => ModulesSdkTypes.IMedusaInternalService<TEntity, TContainer>
|
||||||
}
|
}
|
||||||
+219
-165
@@ -12,11 +12,11 @@ import {
|
|||||||
SoftDeleteReturn,
|
SoftDeleteReturn,
|
||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
MapToConfig,
|
|
||||||
isString,
|
isString,
|
||||||
kebabCase,
|
kebabCase,
|
||||||
lowerCaseFirst,
|
lowerCaseFirst,
|
||||||
mapObjectTo,
|
mapObjectTo,
|
||||||
|
MapToConfig,
|
||||||
pluralize,
|
pluralize,
|
||||||
upperCaseFirst,
|
upperCaseFirst,
|
||||||
} from "../common"
|
} from "../common"
|
||||||
@@ -25,6 +25,7 @@ import {
|
|||||||
InjectTransactionManager,
|
InjectTransactionManager,
|
||||||
MedusaContext,
|
MedusaContext,
|
||||||
} from "./decorators"
|
} from "./decorators"
|
||||||
|
import { ModuleRegistrationName } from "./definition"
|
||||||
|
|
||||||
type BaseMethods =
|
type BaseMethods =
|
||||||
| "retrieve"
|
| "retrieve"
|
||||||
@@ -49,68 +50,74 @@ const methods: BaseMethods[] = [...readMethods, ...writeMethods]
|
|||||||
|
|
||||||
type ModelDTOConfig = {
|
type ModelDTOConfig = {
|
||||||
dto: object
|
dto: object
|
||||||
create?: object
|
create?: any
|
||||||
update?: object
|
update?: any
|
||||||
}
|
/**
|
||||||
type ModelDTOConfigRecord = Record<any, ModelDTOConfig>
|
* @internal
|
||||||
type ModelNamingConfig = {
|
*/
|
||||||
singular?: string
|
singular?: string
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
plural?: string
|
plural?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
type ModelsConfigTemplate = {
|
type EntitiesConfigTemplate = { [key: string]: ModelDTOConfig }
|
||||||
[ModelName: string]: ModelDTOConfig & ModelNamingConfig
|
|
||||||
|
type ModelConfigurationToDto<T extends ModelConfiguration> =
|
||||||
|
T extends abstract new (...args: any) => infer R
|
||||||
|
? R
|
||||||
|
: T extends { dto: infer DTO }
|
||||||
|
? DTO
|
||||||
|
: any
|
||||||
|
|
||||||
|
type ModelConfigurationsToConfigTemplate<
|
||||||
|
T extends Record<string, ModelConfiguration>
|
||||||
|
> = {
|
||||||
|
[Key in keyof T as `${Capitalize<Key & string>}`]: {
|
||||||
|
dto: ModelConfigurationToDto<T[Key]>
|
||||||
|
create: any
|
||||||
|
update: any
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type ExtractSingularName<
|
type ExtractSingularName<T extends Record<any, any>, K = keyof T> = Capitalize<
|
||||||
T extends Record<any, any>,
|
T[K] extends { singular?: string } ? T[K]["singular"] & string : K & string
|
||||||
K = keyof T
|
>
|
||||||
> = T[K] extends { singular?: string } ? T[K]["singular"] : K
|
|
||||||
|
|
||||||
type CreateMethodName<
|
|
||||||
TModelDTOConfig extends ModelDTOConfigRecord,
|
|
||||||
TModelName = keyof TModelDTOConfig
|
|
||||||
> = TModelDTOConfig[TModelName] extends { create?: object }
|
|
||||||
? `create${ExtractPluralName<TModelDTOConfig, TModelName>}`
|
|
||||||
: never
|
|
||||||
|
|
||||||
type UpdateMethodName<
|
|
||||||
TModelDTOConfig extends ModelDTOConfigRecord,
|
|
||||||
TModelName = keyof TModelDTOConfig
|
|
||||||
> = TModelDTOConfig[TModelName] extends { update?: object }
|
|
||||||
? `update${ExtractPluralName<TModelDTOConfig, TModelName>}`
|
|
||||||
: never
|
|
||||||
|
|
||||||
type ExtractPluralName<T extends Record<any, any>, K = keyof T> = T[K] extends {
|
type ExtractPluralName<T extends Record<any, any>, K = keyof T> = T[K] extends {
|
||||||
plural?: string
|
plural?: string
|
||||||
}
|
}
|
||||||
? T[K]["plural"]
|
? T[K]["plural"] & string
|
||||||
: Pluralize<K & string>
|
: Pluralize<K & string>
|
||||||
|
|
||||||
type ModelConfiguration =
|
// TODO: this will be removed in the follow up pr once the main entity concept will be removed
|
||||||
| Constructor<any>
|
type ModelConfiguration = Constructor<any> | ModelDTOConfig | any
|
||||||
| { singular?: string; plural?: string; model: Constructor<any> }
|
|
||||||
|
|
||||||
export interface AbstractModuleServiceBase<TContainer, TMainModelDTO> {
|
type ExtractMutationDtoOrAny<T> = T extends unknown ? any : T
|
||||||
get __container__(): TContainer
|
|
||||||
|
export interface AbstractModuleServiceBase<TEntryEntityConfig> {
|
||||||
|
new (container: Record<any, any>, ...args: any[]): this
|
||||||
|
|
||||||
|
get __container__(): Record<any, any>
|
||||||
|
|
||||||
retrieve(
|
retrieve(
|
||||||
id: string,
|
id: string,
|
||||||
config?: FindConfig<any>,
|
config?: FindConfig<any>,
|
||||||
sharedContext?: Context
|
sharedContext?: Context
|
||||||
): Promise<TMainModelDTO>
|
): Promise<TEntryEntityConfig>
|
||||||
|
|
||||||
list(
|
list(
|
||||||
filters?: any,
|
filters?: any,
|
||||||
config?: FindConfig<any>,
|
config?: FindConfig<any>,
|
||||||
sharedContext?: Context
|
sharedContext?: Context
|
||||||
): Promise<TMainModelDTO[]>
|
): Promise<TEntryEntityConfig[]>
|
||||||
|
|
||||||
listAndCount(
|
listAndCount(
|
||||||
filters?: any,
|
filters?: any,
|
||||||
config?: FindConfig<any>,
|
config?: FindConfig<any>,
|
||||||
sharedContext?: Context
|
sharedContext?: Context
|
||||||
): Promise<[TMainModelDTO[], number]>
|
): Promise<[TEntryEntityConfig[], number]>
|
||||||
|
|
||||||
delete(
|
delete(
|
||||||
primaryKeyValues: string | object | string[] | object[],
|
primaryKeyValues: string | object | string[] | object[],
|
||||||
@@ -131,56 +138,50 @@ export interface AbstractModuleServiceBase<TContainer, TMainModelDTO> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export type AbstractModuleService<
|
export type AbstractModuleService<
|
||||||
TContainer,
|
TEntryEntityConfig extends ModelConfiguration,
|
||||||
TMainModelDTO,
|
TEntitiesDtoConfig extends EntitiesConfigTemplate
|
||||||
TModelDTOConfig extends ModelsConfigTemplate
|
> = AbstractModuleServiceBase<TEntryEntityConfig> & {
|
||||||
> = AbstractModuleServiceBase<TContainer, TMainModelDTO> & {
|
[TEntityName in keyof TEntitiesDtoConfig as `retrieve${ExtractSingularName<
|
||||||
[TModelName in keyof TModelDTOConfig as `retrieve${ExtractSingularName<
|
TEntitiesDtoConfig,
|
||||||
TModelDTOConfig,
|
TEntityName
|
||||||
TModelName
|
>}`]: (
|
||||||
> &
|
|
||||||
string}`]: (
|
|
||||||
id: string,
|
id: string,
|
||||||
config?: FindConfig<any>,
|
config?: FindConfig<any>,
|
||||||
sharedContext?: Context
|
sharedContext?: Context
|
||||||
) => Promise<TModelDTOConfig[TModelName & string]["dto"]>
|
) => Promise<TEntitiesDtoConfig[TEntityName]["dto"]>
|
||||||
} & {
|
} & {
|
||||||
[TModelName in keyof TModelDTOConfig as `list${ExtractPluralName<
|
[TEntityName in keyof TEntitiesDtoConfig as `list${ExtractPluralName<
|
||||||
TModelDTOConfig,
|
TEntitiesDtoConfig,
|
||||||
TModelName
|
TEntityName
|
||||||
> &
|
>}`]: (
|
||||||
string}`]: (
|
|
||||||
filters?: any,
|
filters?: any,
|
||||||
config?: FindConfig<any>,
|
config?: FindConfig<any>,
|
||||||
sharedContext?: Context
|
sharedContext?: Context
|
||||||
) => Promise<TModelDTOConfig[TModelName & string]["dto"][]>
|
) => Promise<TEntitiesDtoConfig[TEntityName]["dto"][]>
|
||||||
} & {
|
} & {
|
||||||
[TModelName in keyof TModelDTOConfig as `listAndCount${ExtractPluralName<
|
[TEntityName in keyof TEntitiesDtoConfig as `listAndCount${ExtractPluralName<
|
||||||
TModelDTOConfig,
|
TEntitiesDtoConfig,
|
||||||
TModelName
|
TEntityName
|
||||||
> &
|
>}`]: {
|
||||||
string}`]: {
|
|
||||||
(filters?: any, config?: FindConfig<any>, sharedContext?: Context): Promise<
|
(filters?: any, config?: FindConfig<any>, sharedContext?: Context): Promise<
|
||||||
[TModelDTOConfig[TModelName & string]["dto"][], number]
|
[TEntitiesDtoConfig[TEntityName]["dto"][], number]
|
||||||
>
|
>
|
||||||
}
|
}
|
||||||
} & {
|
} & {
|
||||||
[TModelName in keyof TModelDTOConfig as `delete${ExtractPluralName<
|
[TEntityName in keyof TEntitiesDtoConfig as `delete${ExtractPluralName<
|
||||||
TModelDTOConfig,
|
TEntitiesDtoConfig,
|
||||||
TModelName
|
TEntityName
|
||||||
> &
|
>}`]: {
|
||||||
string}`]: {
|
|
||||||
(
|
(
|
||||||
primaryKeyValues: string | object | string[] | object[],
|
primaryKeyValues: string | object | string[] | object[],
|
||||||
sharedContext?: Context
|
sharedContext?: Context
|
||||||
): Promise<void>
|
): Promise<void>
|
||||||
}
|
}
|
||||||
} & {
|
} & {
|
||||||
[TModelName in keyof TModelDTOConfig as `softDelete${ExtractPluralName<
|
[TEntityName in keyof TEntitiesDtoConfig as `softDelete${ExtractPluralName<
|
||||||
TModelDTOConfig,
|
TEntitiesDtoConfig,
|
||||||
TModelName
|
TEntityName
|
||||||
> &
|
>}`]: {
|
||||||
string}`]: {
|
|
||||||
<TReturnableLinkableKeys extends string>(
|
<TReturnableLinkableKeys extends string>(
|
||||||
primaryKeyValues: string | object | string[] | object[],
|
primaryKeyValues: string | object | string[] | object[],
|
||||||
config?: SoftDeleteReturn<TReturnableLinkableKeys>,
|
config?: SoftDeleteReturn<TReturnableLinkableKeys>,
|
||||||
@@ -188,11 +189,10 @@ export type AbstractModuleService<
|
|||||||
): Promise<Record<string, string[]> | void>
|
): Promise<Record<string, string[]> | void>
|
||||||
}
|
}
|
||||||
} & {
|
} & {
|
||||||
[TModelName in keyof TModelDTOConfig as `restore${ExtractPluralName<
|
[TEntityName in keyof TEntitiesDtoConfig as `restore${ExtractPluralName<
|
||||||
TModelDTOConfig,
|
TEntitiesDtoConfig,
|
||||||
TModelName
|
TEntityName
|
||||||
> &
|
>}`]: {
|
||||||
string}`]: {
|
|
||||||
<TReturnableLinkableKeys extends string>(
|
<TReturnableLinkableKeys extends string>(
|
||||||
primaryKeyValues: string | object | string[] | object[],
|
primaryKeyValues: string | object | string[] | object[],
|
||||||
config?: RestoreReturn<TReturnableLinkableKeys>,
|
config?: RestoreReturn<TReturnableLinkableKeys>,
|
||||||
@@ -200,45 +200,103 @@ export type AbstractModuleService<
|
|||||||
): Promise<Record<string, string[]> | void>
|
): Promise<Record<string, string[]> | void>
|
||||||
}
|
}
|
||||||
} & {
|
} & {
|
||||||
[TModelName in keyof TModelDTOConfig as CreateMethodName<
|
[TEntityName in keyof TEntitiesDtoConfig as `create${ExtractPluralName<
|
||||||
TModelDTOConfig,
|
TEntitiesDtoConfig,
|
||||||
TModelName
|
TEntityName
|
||||||
>]: {
|
>}`]: {
|
||||||
(
|
(...args: any[]): Promise<any>
|
||||||
data: TModelDTOConfig[TModelName]["create"][],
|
|
||||||
sharedContext?: Context
|
|
||||||
): Promise<TModelDTOConfig[TModelName]["dto"][]>
|
|
||||||
}
|
}
|
||||||
} & {
|
} & {
|
||||||
[TModelName in keyof TModelDTOConfig as CreateMethodName<
|
[TEntityName in keyof TEntitiesDtoConfig as `update${ExtractPluralName<
|
||||||
TModelDTOConfig,
|
TEntitiesDtoConfig,
|
||||||
TModelName
|
TEntityName
|
||||||
>]: {
|
>}`]: {
|
||||||
(
|
(...args: any[]): Promise<any>
|
||||||
data: TModelDTOConfig[TModelName]["create"],
|
}
|
||||||
sharedContext?: Context
|
}
|
||||||
): Promise<TModelDTOConfig[TModelName]["dto"]>
|
|
||||||
|
// TODO: Because of a bug, those methods were not made visible which now cause issues with the fix as our interface are not consistent with the expectations
|
||||||
|
|
||||||
|
// are not consistent accross modules
|
||||||
|
/* & {
|
||||||
|
[TEntityName in keyof TEntitiesDtoConfig as `create${ExtractPluralName<
|
||||||
|
TEntitiesDtoConfig,
|
||||||
|
TEntityName
|
||||||
|
>}`]: {
|
||||||
|
(data: any[], sharedContext?: Context): Promise<
|
||||||
|
TEntitiesDtoConfig[TEntityName]["dto"][]
|
||||||
|
>
|
||||||
}
|
}
|
||||||
} & {
|
} & {
|
||||||
[TModelName in keyof TModelDTOConfig as UpdateMethodName<
|
[TEntityName in keyof TEntitiesDtoConfig as `create${ExtractPluralName<
|
||||||
TModelDTOConfig,
|
TEntitiesDtoConfig,
|
||||||
TModelName
|
TEntityName
|
||||||
>]: {
|
>}`]: {
|
||||||
(
|
(data: any, sharedContext?: Context): Promise<
|
||||||
data: TModelDTOConfig[TModelName]["update"][],
|
TEntitiesDtoConfig[TEntityName]["dto"][]
|
||||||
sharedContext?: Context
|
>
|
||||||
): Promise<TModelDTOConfig[TModelName]["dto"][]>
|
|
||||||
}
|
}
|
||||||
} & {
|
} & {
|
||||||
[TModelName in keyof TModelDTOConfig as UpdateMethodName<
|
[TEntityName in keyof TEntitiesDtoConfig as `update${ExtractPluralName<
|
||||||
TModelDTOConfig,
|
TEntitiesDtoConfig,
|
||||||
TModelName
|
TEntityName
|
||||||
>]: {
|
>}`]: {
|
||||||
(
|
(
|
||||||
data: TModelDTOConfig[TModelName]["update"],
|
data: TEntitiesDtoConfig[TEntityName]["update"][],
|
||||||
sharedContext?: Context
|
sharedContext?: Context
|
||||||
): Promise<TModelDTOConfig[TModelName]["dto"]>
|
): Promise<TEntitiesDtoConfig[TEntityName]["dto"][]>
|
||||||
}
|
}
|
||||||
|
} & {
|
||||||
|
[TEntityName in keyof TEntitiesDtoConfig as `update${ExtractPluralName<
|
||||||
|
TEntitiesDtoConfig,
|
||||||
|
TEntityName
|
||||||
|
>}`]: {
|
||||||
|
(
|
||||||
|
data: TEntitiesDtoConfig[TEntityName]["update"],
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<TEntitiesDtoConfig[TEntityName]["dto"]>
|
||||||
|
}
|
||||||
|
} & {
|
||||||
|
[TEntityName in keyof TEntitiesDtoConfig as `update${ExtractPluralName<
|
||||||
|
TEntitiesDtoConfig,
|
||||||
|
TEntityName
|
||||||
|
>}`]: {
|
||||||
|
(
|
||||||
|
idOrdSelector: any,
|
||||||
|
data: TEntitiesDtoConfig[TEntityName]["update"],
|
||||||
|
sharedContext?: Context
|
||||||
|
): Promise<TEntitiesDtoConfig[TEntityName]["dto"][]>
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
function buildMethodNamesFromModel(
|
||||||
|
model: ModelConfiguration,
|
||||||
|
suffixed: boolean = true
|
||||||
|
): Record<string, string> {
|
||||||
|
return methods.reduce((acc, method) => {
|
||||||
|
let modelName: string = ""
|
||||||
|
|
||||||
|
if (method === "retrieve") {
|
||||||
|
modelName =
|
||||||
|
"singular" in model && model.singular
|
||||||
|
? model.singular
|
||||||
|
: (model as { name: string }).name
|
||||||
|
} else {
|
||||||
|
modelName =
|
||||||
|
"plural" in model && model.plural
|
||||||
|
? model.plural
|
||||||
|
: pluralize((model as { name: string }).name)
|
||||||
|
}
|
||||||
|
|
||||||
|
const methodName = suffixed
|
||||||
|
? `${method}${upperCaseFirst(modelName)}`
|
||||||
|
: method
|
||||||
|
|
||||||
|
return { ...acc, [method]: methodName }
|
||||||
|
}, {})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -246,7 +304,7 @@ export type AbstractModuleService<
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* const otherModels = new Set([
|
* const entities = {
|
||||||
* Currency,
|
* Currency,
|
||||||
* Price,
|
* Price,
|
||||||
* PriceList,
|
* PriceList,
|
||||||
@@ -255,12 +313,10 @@ export type AbstractModuleService<
|
|||||||
* PriceRule,
|
* PriceRule,
|
||||||
* PriceSetRuleType,
|
* PriceSetRuleType,
|
||||||
* RuleType,
|
* RuleType,
|
||||||
* ])
|
* }
|
||||||
*
|
*
|
||||||
* const AbstractModuleService = ModulesSdkUtils.abstractModuleServiceFactory<
|
* class MyService extends ModulesSdkUtils.MedusaService<
|
||||||
* InjectedDependencies,
|
|
||||||
* PricingTypes.PriceSetDTO,
|
* PricingTypes.PriceSetDTO,
|
||||||
* // The configuration of each entity also accept singular/plural properties, if not provided then it is using english pluralization
|
|
||||||
* {
|
* {
|
||||||
* Currency: { dto: PricingTypes.CurrencyDTO }
|
* Currency: { dto: PricingTypes.CurrencyDTO }
|
||||||
* Price: { dto: PricingTypes.PriceDTO }
|
* Price: { dto: PricingTypes.PriceDTO }
|
||||||
@@ -269,61 +325,55 @@ export type AbstractModuleService<
|
|||||||
* PriceList: { dto: PricingTypes.PriceListDTO }
|
* PriceList: { dto: PricingTypes.PriceListDTO }
|
||||||
* PriceListRule: { dto: PricingTypes.PriceListRuleDTO }
|
* PriceListRule: { dto: PricingTypes.PriceListRuleDTO }
|
||||||
* }
|
* }
|
||||||
* >(PriceSet, [...otherModels], entityNameToLinkableKeysMap)
|
* >(PriceSet, entities, entityNameToLinkableKeysMap) {}
|
||||||
*
|
*
|
||||||
* @param mainModel
|
* @example
|
||||||
* @param otherModels
|
*
|
||||||
|
* // Here the DTO's and names will be inferred from the arguments
|
||||||
|
*
|
||||||
|
* const entities = {
|
||||||
|
* Currency,
|
||||||
|
* Price,
|
||||||
|
* PriceList,
|
||||||
|
* PriceListRule,
|
||||||
|
* PriceListRuleValue,
|
||||||
|
* PriceRule,
|
||||||
|
* PriceSetRuleType,
|
||||||
|
* RuleType,
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* class MyService extends ModulesSdkUtils.MedusaService(PriceSet, entities, entityNameToLinkableKeysMap) {}
|
||||||
|
*
|
||||||
|
* @param entryEntity
|
||||||
|
* @param entities
|
||||||
* @param entityNameToLinkableKeysMap
|
* @param entityNameToLinkableKeysMap
|
||||||
*/
|
*/
|
||||||
export function abstractModuleServiceFactory<
|
export function MedusaService<
|
||||||
TContainer,
|
TEntryEntityConfig extends ModelConfiguration = ModelConfiguration,
|
||||||
TMainModelDTO,
|
EntitiesConfig extends EntitiesConfigTemplate = { __empty: any },
|
||||||
ModelsConfig extends ModelsConfigTemplate
|
TEntities extends Record<string, ModelConfiguration> = Record<
|
||||||
|
string,
|
||||||
|
ModelConfiguration
|
||||||
|
>
|
||||||
>(
|
>(
|
||||||
mainModel: Constructor<any>,
|
entryEntity: (TEntryEntityConfig & { name: string }) | Constructor<any>,
|
||||||
otherModels: ModelConfiguration[],
|
entities: TEntities,
|
||||||
entityNameToLinkableKeysMap: MapToConfig = {}
|
entityNameToLinkableKeysMap: MapToConfig = {}
|
||||||
): {
|
): {
|
||||||
new (container: TContainer): AbstractModuleService<
|
new (...args: any[]): AbstractModuleService<
|
||||||
TContainer,
|
ModelConfigurationToDto<TEntryEntityConfig>,
|
||||||
TMainModelDTO,
|
EntitiesConfig extends { __empty: any }
|
||||||
ModelsConfig
|
? ModelConfigurationsToConfigTemplate<TEntities>
|
||||||
|
: EntitiesConfig
|
||||||
>
|
>
|
||||||
} {
|
} {
|
||||||
const buildMethodNamesFromModel = (
|
|
||||||
model: ModelConfiguration,
|
|
||||||
suffixed: boolean = true
|
|
||||||
): Record<string, string> => {
|
|
||||||
return methods.reduce((acc, method) => {
|
|
||||||
let modelName: string = ""
|
|
||||||
|
|
||||||
if (method === "retrieve") {
|
|
||||||
modelName =
|
|
||||||
"singular" in model && model.singular
|
|
||||||
? model.singular
|
|
||||||
: (model as Constructor<any>).name
|
|
||||||
} else {
|
|
||||||
modelName =
|
|
||||||
"plural" in model && model.plural
|
|
||||||
? model.plural
|
|
||||||
: pluralize((model as Constructor<any>).name)
|
|
||||||
}
|
|
||||||
|
|
||||||
const methodName = suffixed
|
|
||||||
? `${method}${upperCaseFirst(modelName)}`
|
|
||||||
: method
|
|
||||||
|
|
||||||
return { ...acc, [method]: methodName }
|
|
||||||
}, {})
|
|
||||||
}
|
|
||||||
|
|
||||||
const buildAndAssignMethodImpl = function (
|
const buildAndAssignMethodImpl = function (
|
||||||
klassPrototype: any,
|
klassPrototype: any,
|
||||||
method: string,
|
method: string,
|
||||||
methodName: string,
|
methodName: string,
|
||||||
model: Constructor<any>
|
modelName: string
|
||||||
): void {
|
): void {
|
||||||
const serviceRegistrationName = `${lowerCaseFirst(model.name)}Service`
|
const serviceRegistrationName = `${lowerCaseFirst(modelName)}Service`
|
||||||
|
|
||||||
const applyMethod = function (impl: Function, contextIndex) {
|
const applyMethod = function (impl: Function, contextIndex) {
|
||||||
klassPrototype[methodName] = impl
|
klassPrototype[methodName] = impl
|
||||||
@@ -465,7 +515,7 @@ export function abstractModuleServiceFactory<
|
|||||||
|
|
||||||
await this.eventBusModuleService_?.emit(
|
await this.eventBusModuleService_?.emit(
|
||||||
primaryKeyValues_.map((primaryKeyValue) => ({
|
primaryKeyValues_.map((primaryKeyValue) => ({
|
||||||
eventName: `${kebabCase(model.name)}.deleted`,
|
eventName: `${kebabCase(modelName)}.deleted`,
|
||||||
data: isString(primaryKeyValue)
|
data: isString(primaryKeyValue)
|
||||||
? { id: primaryKeyValue }
|
? { id: primaryKeyValue }
|
||||||
: primaryKeyValue,
|
: primaryKeyValue,
|
||||||
@@ -500,7 +550,7 @@ export function abstractModuleServiceFactory<
|
|||||||
|
|
||||||
await this.eventBusModuleService_?.emit(
|
await this.eventBusModuleService_?.emit(
|
||||||
softDeletedEntities.map(({ id }) => ({
|
softDeletedEntities.map(({ id }) => ({
|
||||||
eventName: `${kebabCase(model.name)}.deleted`,
|
eventName: `${kebabCase(modelName)}.deleted`,
|
||||||
metadata: { source: "", action: "", object: "" },
|
metadata: { source: "", action: "", object: "" },
|
||||||
data: { id },
|
data: { id },
|
||||||
}))
|
}))
|
||||||
@@ -558,19 +608,19 @@ export function abstractModuleServiceFactory<
|
|||||||
}
|
}
|
||||||
|
|
||||||
class AbstractModuleService_ {
|
class AbstractModuleService_ {
|
||||||
readonly __container__: Record<string, any>
|
readonly __container__: Record<any, any>
|
||||||
readonly baseRepository_: RepositoryService
|
readonly baseRepository_: RepositoryService
|
||||||
readonly eventBusModuleService_: IEventBusModuleService;
|
readonly eventBusModuleService_: IEventBusModuleService;
|
||||||
|
|
||||||
[key: string]: any
|
[key: string]: any
|
||||||
|
|
||||||
constructor(container: Record<string, any>) {
|
constructor(container: Record<any, any>) {
|
||||||
this.__container__ = container
|
this.__container__ = container
|
||||||
this.baseRepository_ = container.baseRepository
|
this.baseRepository_ = container.baseRepository
|
||||||
|
|
||||||
const hasEventBusModuleService = Object.keys(this.__container__).find(
|
const hasEventBusModuleService = Object.keys(this.__container__).find(
|
||||||
// TODO: Should use ModuleRegistrationName.EVENT_BUS but it would require to move it to the utils package to prevent circular dependencies
|
// TODO: Should use ModuleRegistrationName.EVENT_BUS but it would require to move it to the utils package to prevent circular dependencies
|
||||||
(key) => key === "eventBusModuleService"
|
(key) => key === ModuleRegistrationName.EVENT_BUS
|
||||||
)
|
)
|
||||||
|
|
||||||
this.eventBusModuleService_ = hasEventBusModuleService
|
this.eventBusModuleService_ = hasEventBusModuleService
|
||||||
@@ -592,18 +642,18 @@ export function abstractModuleServiceFactory<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const mainModelMethods = buildMethodNamesFromModel(mainModel, false)
|
const entryEntityMethods = buildMethodNamesFromModel(entryEntity, false)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build the main retrieve/list/listAndCount/delete/softDelete/restore methods for the main model
|
* Build the main retrieve/list/listAndCount/delete/softDelete/restore methods for the main model
|
||||||
*/
|
*/
|
||||||
|
|
||||||
for (let [method, methodName] of Object.entries(mainModelMethods)) {
|
for (let [method, methodName] of Object.entries(entryEntityMethods)) {
|
||||||
buildAndAssignMethodImpl(
|
buildAndAssignMethodImpl(
|
||||||
AbstractModuleService_.prototype,
|
AbstractModuleService_.prototype,
|
||||||
method,
|
method,
|
||||||
methodName,
|
methodName,
|
||||||
mainModel
|
entryEntity.name
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -611,22 +661,26 @@ export function abstractModuleServiceFactory<
|
|||||||
* Build the retrieve/list/listAndCount/delete/softDelete/restore methods for all the other models
|
* Build the retrieve/list/listAndCount/delete/softDelete/restore methods for all the other models
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const otherModelsMethods: [ModelConfiguration, Record<string, string>][] =
|
const entitiesMethods: [
|
||||||
otherModels.map((model) => [model, buildMethodNamesFromModel(model)])
|
string,
|
||||||
|
ModelConfiguration,
|
||||||
|
Record<string, string>
|
||||||
|
][] = Object.entries(entities).map(([name, config]) => [
|
||||||
|
name,
|
||||||
|
config,
|
||||||
|
buildMethodNamesFromModel(config),
|
||||||
|
])
|
||||||
|
|
||||||
for (let [model, modelsMethods] of otherModelsMethods) {
|
for (let [modelName, model, modelsMethods] of entitiesMethods) {
|
||||||
Object.entries(modelsMethods).forEach(([method, methodName]) => {
|
Object.entries(modelsMethods).forEach(([method, methodName]) => {
|
||||||
model = "model" in model ? model.model : model
|
|
||||||
buildAndAssignMethodImpl(
|
buildAndAssignMethodImpl(
|
||||||
AbstractModuleService_.prototype,
|
AbstractModuleService_.prototype,
|
||||||
method,
|
method,
|
||||||
methodName,
|
methodName,
|
||||||
model
|
modelName
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return AbstractModuleService_ as unknown as new (
|
return AbstractModuleService_ as any
|
||||||
container: TContainer
|
|
||||||
) => AbstractModuleService<TContainer, TMainModelDTO, ModelsConfig>
|
|
||||||
}
|
}
|
||||||
@@ -1,15 +1,15 @@
|
|||||||
import crypto from "crypto"
|
import crypto from "crypto"
|
||||||
import util from "util"
|
import util from "util"
|
||||||
import {
|
import {
|
||||||
|
ApiKeyTypes,
|
||||||
Context,
|
Context,
|
||||||
DAL,
|
DAL,
|
||||||
ApiKeyTypes,
|
FilterableApiKeyProps,
|
||||||
|
FindConfig,
|
||||||
IApiKeyModuleService,
|
IApiKeyModuleService,
|
||||||
ModulesSdkTypes,
|
|
||||||
InternalModuleDeclaration,
|
InternalModuleDeclaration,
|
||||||
ModuleJoinerConfig,
|
ModuleJoinerConfig,
|
||||||
FindConfig,
|
ModulesSdkTypes,
|
||||||
FilterableApiKeyProps,
|
|
||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
import { entityNameToLinkableKeysMap, joinerConfig } from "../joiner-config"
|
import { entityNameToLinkableKeysMap, joinerConfig } from "../joiner-config"
|
||||||
import { ApiKey } from "@models"
|
import { ApiKey } from "@models"
|
||||||
@@ -23,35 +23,32 @@ import {
|
|||||||
ApiKeyType,
|
ApiKeyType,
|
||||||
InjectManager,
|
InjectManager,
|
||||||
InjectTransactionManager,
|
InjectTransactionManager,
|
||||||
|
isObject,
|
||||||
|
isString,
|
||||||
MedusaContext,
|
MedusaContext,
|
||||||
MedusaError,
|
MedusaError,
|
||||||
ModulesSdkUtils,
|
ModulesSdkUtils,
|
||||||
isObject,
|
|
||||||
isString,
|
|
||||||
promiseAll,
|
promiseAll,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
|
|
||||||
const scrypt = util.promisify(crypto.scrypt)
|
const scrypt = util.promisify(crypto.scrypt)
|
||||||
|
|
||||||
const generateMethodForModels = []
|
|
||||||
|
|
||||||
type InjectedDependencies = {
|
type InjectedDependencies = {
|
||||||
baseRepository: DAL.RepositoryService
|
baseRepository: DAL.RepositoryService
|
||||||
apiKeyService: ModulesSdkTypes.InternalModuleService<any>
|
apiKeyService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class ApiKeyModuleService<TEntity extends ApiKey = ApiKey>
|
export default class ApiKeyModuleService<TEntity extends ApiKey = ApiKey>
|
||||||
extends ModulesSdkUtils.abstractModuleServiceFactory<
|
extends ModulesSdkUtils.MedusaService<
|
||||||
InjectedDependencies,
|
|
||||||
ApiKeyTypes.ApiKeyDTO,
|
ApiKeyTypes.ApiKeyDTO,
|
||||||
{
|
{
|
||||||
ApiKey: { dto: ApiKeyTypes.ApiKeyDTO }
|
ApiKey: { dto: ApiKeyTypes.ApiKeyDTO }
|
||||||
}
|
}
|
||||||
>(ApiKey, generateMethodForModels, entityNameToLinkableKeysMap)
|
>(ApiKey, {}, entityNameToLinkableKeysMap)
|
||||||
implements IApiKeyModuleService
|
implements IApiKeyModuleService
|
||||||
{
|
{
|
||||||
protected baseRepository_: DAL.RepositoryService
|
protected baseRepository_: DAL.RepositoryService
|
||||||
protected readonly apiKeyService_: ModulesSdkTypes.InternalModuleService<TEntity>
|
protected readonly apiKeyService_: ModulesSdkTypes.IMedusaInternalService<TEntity>
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
{ baseRepository, apiKeyService }: InjectedDependencies,
|
{ baseRepository, apiKeyService }: InjectedDependencies,
|
||||||
|
|||||||
@@ -21,23 +21,21 @@ import {
|
|||||||
ModulesSdkUtils,
|
ModulesSdkUtils,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import AuthProviderService from "./auth-provider"
|
import AuthProviderService from "./auth-provider"
|
||||||
import { populate } from "dotenv"
|
|
||||||
|
|
||||||
type InjectedDependencies = {
|
type InjectedDependencies = {
|
||||||
baseRepository: DAL.RepositoryService
|
baseRepository: DAL.RepositoryService
|
||||||
authIdentityService: ModulesSdkTypes.InternalModuleService<any>
|
authIdentityService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
providerIdentityService: ModulesSdkTypes.InternalModuleService<any>
|
providerIdentityService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
authProviderService: AuthProviderService
|
authProviderService: AuthProviderService
|
||||||
}
|
}
|
||||||
|
|
||||||
const generateMethodForModels = [AuthIdentity, ProviderIdentity]
|
const generateMethodForModels = { AuthIdentity, ProviderIdentity }
|
||||||
|
|
||||||
export default class AuthModuleService<
|
export default class AuthModuleService<
|
||||||
TAuthIdentity extends AuthIdentity = AuthIdentity,
|
TAuthIdentity extends AuthIdentity = AuthIdentity,
|
||||||
TProviderIdentity extends ProviderIdentity = ProviderIdentity
|
TProviderIdentity extends ProviderIdentity = ProviderIdentity
|
||||||
>
|
>
|
||||||
extends ModulesSdkUtils.abstractModuleServiceFactory<
|
extends ModulesSdkUtils.MedusaService<
|
||||||
InjectedDependencies,
|
|
||||||
AuthTypes.AuthIdentityDTO,
|
AuthTypes.AuthIdentityDTO,
|
||||||
{
|
{
|
||||||
AuthIdentity: { dto: AuthTypes.AuthIdentityDTO }
|
AuthIdentity: { dto: AuthTypes.AuthIdentityDTO }
|
||||||
@@ -47,8 +45,8 @@ export default class AuthModuleService<
|
|||||||
implements AuthTypes.IAuthModuleService
|
implements AuthTypes.IAuthModuleService
|
||||||
{
|
{
|
||||||
protected baseRepository_: DAL.RepositoryService
|
protected baseRepository_: DAL.RepositoryService
|
||||||
protected authIdentityService_: ModulesSdkTypes.InternalModuleService<TAuthIdentity>
|
protected authIdentityService_: ModulesSdkTypes.IMedusaInternalService<TAuthIdentity>
|
||||||
protected providerIdentityService_: ModulesSdkTypes.InternalModuleService<TProviderIdentity>
|
protected providerIdentityService_: ModulesSdkTypes.IMedusaInternalService<TProviderIdentity>
|
||||||
protected readonly authProviderService_: AuthProviderService
|
protected readonly authProviderService_: AuthProviderService
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
|||||||
@@ -10,16 +10,16 @@ import {
|
|||||||
ModulesSdkTypes,
|
ModulesSdkTypes,
|
||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
InjectManager,
|
|
||||||
InjectTransactionManager,
|
|
||||||
MedusaContext,
|
|
||||||
MedusaError,
|
|
||||||
ModulesSdkUtils,
|
|
||||||
createRawPropertiesFromBigNumber,
|
createRawPropertiesFromBigNumber,
|
||||||
decorateCartTotals,
|
decorateCartTotals,
|
||||||
deduplicate,
|
deduplicate,
|
||||||
|
InjectManager,
|
||||||
|
InjectTransactionManager,
|
||||||
isObject,
|
isObject,
|
||||||
isString,
|
isString,
|
||||||
|
MedusaContext,
|
||||||
|
MedusaError,
|
||||||
|
ModulesSdkUtils,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import {
|
import {
|
||||||
Address,
|
Address,
|
||||||
@@ -43,17 +43,17 @@ import { entityNameToLinkableKeysMap, joinerConfig } from "../joiner-config"
|
|||||||
|
|
||||||
type InjectedDependencies = {
|
type InjectedDependencies = {
|
||||||
baseRepository: DAL.RepositoryService
|
baseRepository: DAL.RepositoryService
|
||||||
cartService: ModulesSdkTypes.InternalModuleService<any>
|
cartService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
addressService: ModulesSdkTypes.InternalModuleService<any>
|
addressService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
lineItemService: ModulesSdkTypes.InternalModuleService<any>
|
lineItemService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
shippingMethodAdjustmentService: ModulesSdkTypes.InternalModuleService<any>
|
shippingMethodAdjustmentService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
shippingMethodService: ModulesSdkTypes.InternalModuleService<any>
|
shippingMethodService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
lineItemAdjustmentService: ModulesSdkTypes.InternalModuleService<any>
|
lineItemAdjustmentService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
lineItemTaxLineService: ModulesSdkTypes.InternalModuleService<any>
|
lineItemTaxLineService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
shippingMethodTaxLineService: ModulesSdkTypes.InternalModuleService<any>
|
shippingMethodTaxLineService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
}
|
}
|
||||||
|
|
||||||
const generateMethodForModels = [
|
const generateMethodForModels = {
|
||||||
Address,
|
Address,
|
||||||
LineItem,
|
LineItem,
|
||||||
LineItemAdjustment,
|
LineItemAdjustment,
|
||||||
@@ -61,7 +61,7 @@ const generateMethodForModels = [
|
|||||||
ShippingMethod,
|
ShippingMethod,
|
||||||
ShippingMethodAdjustment,
|
ShippingMethodAdjustment,
|
||||||
ShippingMethodTaxLine,
|
ShippingMethodTaxLine,
|
||||||
]
|
}
|
||||||
|
|
||||||
export default class CartModuleService<
|
export default class CartModuleService<
|
||||||
TCart extends Cart = Cart,
|
TCart extends Cart = Cart,
|
||||||
@@ -73,8 +73,7 @@ export default class CartModuleService<
|
|||||||
TShippingMethodTaxLine extends ShippingMethodTaxLine = ShippingMethodTaxLine,
|
TShippingMethodTaxLine extends ShippingMethodTaxLine = ShippingMethodTaxLine,
|
||||||
TShippingMethod extends ShippingMethod = ShippingMethod
|
TShippingMethod extends ShippingMethod = ShippingMethod
|
||||||
>
|
>
|
||||||
extends ModulesSdkUtils.abstractModuleServiceFactory<
|
extends ModulesSdkUtils.MedusaService<
|
||||||
InjectedDependencies,
|
|
||||||
CartTypes.CartDTO,
|
CartTypes.CartDTO,
|
||||||
{
|
{
|
||||||
Address: { dto: CartTypes.CartAddressDTO }
|
Address: { dto: CartTypes.CartAddressDTO }
|
||||||
@@ -89,14 +88,14 @@ export default class CartModuleService<
|
|||||||
implements ICartModuleService
|
implements ICartModuleService
|
||||||
{
|
{
|
||||||
protected baseRepository_: DAL.RepositoryService
|
protected baseRepository_: DAL.RepositoryService
|
||||||
protected cartService_: ModulesSdkTypes.InternalModuleService<TCart>
|
protected cartService_: ModulesSdkTypes.IMedusaInternalService<TCart>
|
||||||
protected addressService_: ModulesSdkTypes.InternalModuleService<TAddress>
|
protected addressService_: ModulesSdkTypes.IMedusaInternalService<TAddress>
|
||||||
protected lineItemService_: ModulesSdkTypes.InternalModuleService<TLineItem>
|
protected lineItemService_: ModulesSdkTypes.IMedusaInternalService<TLineItem>
|
||||||
protected shippingMethodAdjustmentService_: ModulesSdkTypes.InternalModuleService<TShippingMethodAdjustment>
|
protected shippingMethodAdjustmentService_: ModulesSdkTypes.IMedusaInternalService<TShippingMethodAdjustment>
|
||||||
protected shippingMethodService_: ModulesSdkTypes.InternalModuleService<TShippingMethod>
|
protected shippingMethodService_: ModulesSdkTypes.IMedusaInternalService<TShippingMethod>
|
||||||
protected lineItemAdjustmentService_: ModulesSdkTypes.InternalModuleService<TLineItemAdjustment>
|
protected lineItemAdjustmentService_: ModulesSdkTypes.IMedusaInternalService<TLineItemAdjustment>
|
||||||
protected lineItemTaxLineService_: ModulesSdkTypes.InternalModuleService<TLineItemTaxLine>
|
protected lineItemTaxLineService_: ModulesSdkTypes.IMedusaInternalService<TLineItemTaxLine>
|
||||||
protected shippingMethodTaxLineService_: ModulesSdkTypes.InternalModuleService<TShippingMethodTaxLine>
|
protected shippingMethodTaxLineService_: ModulesSdkTypes.IMedusaInternalService<TShippingMethodTaxLine>
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
{
|
{
|
||||||
@@ -449,6 +448,7 @@ export default class CartModuleService<
|
|||||||
return await this.lineItemService_.create(data, sharedContext)
|
return await this.lineItemService_.create(data, sharedContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
updateLineItems(
|
updateLineItems(
|
||||||
data: CartTypes.UpdateLineItemWithSelectorDTO[]
|
data: CartTypes.UpdateLineItemWithSelectorDTO[]
|
||||||
): Promise<CartTypes.CartLineItemDTO[]>
|
): Promise<CartTypes.CartLineItemDTO[]>
|
||||||
@@ -541,6 +541,7 @@ export default class CartModuleService<
|
|||||||
return await this.lineItemService_.update(toUpdate, sharedContext)
|
return await this.lineItemService_.update(toUpdate, sharedContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
async createAddresses(
|
async createAddresses(
|
||||||
data: CartTypes.CreateAddressDTO,
|
data: CartTypes.CreateAddressDTO,
|
||||||
sharedContext?: Context
|
sharedContext?: Context
|
||||||
@@ -577,6 +578,7 @@ export default class CartModuleService<
|
|||||||
return await this.addressService_.create(data, sharedContext)
|
return await this.addressService_.create(data, sharedContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
async updateAddresses(
|
async updateAddresses(
|
||||||
data: CartTypes.UpdateAddressDTO,
|
data: CartTypes.UpdateAddressDTO,
|
||||||
sharedContext?: Context
|
sharedContext?: Context
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export default async ({
|
|||||||
const logger =
|
const logger =
|
||||||
container.resolve<Logger>(ContainerRegistrationKeys.LOGGER) ?? console
|
container.resolve<Logger>(ContainerRegistrationKeys.LOGGER) ?? console
|
||||||
const { currencyService_ } = container.resolve<{
|
const { currencyService_ } = container.resolve<{
|
||||||
currencyService_: ModulesSdkTypes.InternalModuleService<Currency>
|
currencyService_: ModulesSdkTypes.IMedusaInternalService<Currency>
|
||||||
}>(ModuleRegistrationName.CURRENCY)
|
}>(ModuleRegistrationName.CURRENCY)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1,30 +1,29 @@
|
|||||||
import {
|
import {
|
||||||
|
BaseFilterable,
|
||||||
|
Context,
|
||||||
|
CurrencyTypes,
|
||||||
DAL,
|
DAL,
|
||||||
|
FilterableCurrencyProps,
|
||||||
|
FindConfig,
|
||||||
|
ICurrencyModuleService,
|
||||||
InternalModuleDeclaration,
|
InternalModuleDeclaration,
|
||||||
ModuleJoinerConfig,
|
ModuleJoinerConfig,
|
||||||
ModulesSdkTypes,
|
ModulesSdkTypes,
|
||||||
ICurrencyModuleService,
|
|
||||||
CurrencyTypes,
|
|
||||||
Context,
|
|
||||||
FindConfig,
|
|
||||||
FilterableCurrencyProps,
|
|
||||||
BaseFilterable,
|
|
||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
import { ModulesSdkUtils } from "@medusajs/utils"
|
import { ModulesSdkUtils } from "@medusajs/utils"
|
||||||
|
|
||||||
import { Currency } from "@models"
|
import { Currency } from "@models"
|
||||||
import { entityNameToLinkableKeysMap, joinerConfig } from "../joiner-config"
|
import { entityNameToLinkableKeysMap, joinerConfig } from "../joiner-config"
|
||||||
|
|
||||||
const generateMethodForModels = []
|
const generateMethodForModels = {}
|
||||||
|
|
||||||
type InjectedDependencies = {
|
type InjectedDependencies = {
|
||||||
baseRepository: DAL.RepositoryService
|
baseRepository: DAL.RepositoryService
|
||||||
currencyService: ModulesSdkTypes.InternalModuleService<any>
|
currencyService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class CurrencyModuleService<TEntity extends Currency = Currency>
|
export default class CurrencyModuleService<TEntity extends Currency = Currency>
|
||||||
extends ModulesSdkUtils.abstractModuleServiceFactory<
|
extends ModulesSdkUtils.MedusaService<
|
||||||
InjectedDependencies,
|
|
||||||
CurrencyTypes.CurrencyDTO,
|
CurrencyTypes.CurrencyDTO,
|
||||||
{
|
{
|
||||||
Currency: { dto: CurrencyTypes.CurrencyDTO }
|
Currency: { dto: CurrencyTypes.CurrencyDTO }
|
||||||
@@ -33,7 +32,7 @@ export default class CurrencyModuleService<TEntity extends Currency = Currency>
|
|||||||
implements ICurrencyModuleService
|
implements ICurrencyModuleService
|
||||||
{
|
{
|
||||||
protected baseRepository_: DAL.RepositoryService
|
protected baseRepository_: DAL.RepositoryService
|
||||||
protected readonly currencyService_: ModulesSdkTypes.InternalModuleService<TEntity>
|
protected readonly currencyService_: ModulesSdkTypes.IMedusaInternalService<TEntity>
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
{ baseRepository, currencyService }: InjectedDependencies,
|
{ baseRepository, currencyService }: InjectedDependencies,
|
||||||
|
|||||||
@@ -27,17 +27,17 @@ import { EntityManager } from "@mikro-orm/core"
|
|||||||
|
|
||||||
type InjectedDependencies = {
|
type InjectedDependencies = {
|
||||||
baseRepository: DAL.RepositoryService
|
baseRepository: DAL.RepositoryService
|
||||||
customerService: ModulesSdkTypes.InternalModuleService<any>
|
customerService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
addressService: ModulesSdkTypes.InternalModuleService<any>
|
addressService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
customerGroupService: ModulesSdkTypes.InternalModuleService<any>
|
customerGroupService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
customerGroupCustomerService: ModulesSdkTypes.InternalModuleService<any>
|
customerGroupCustomerService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
}
|
}
|
||||||
|
|
||||||
const generateMethodForModels = [
|
const generateMethodForModels = {
|
||||||
{ model: Address, singular: "Address", plural: "Addresses" },
|
Address: { singular: "Address", plural: "Addresses" },
|
||||||
CustomerGroup,
|
CustomerGroup,
|
||||||
CustomerGroupCustomer,
|
CustomerGroupCustomer,
|
||||||
]
|
}
|
||||||
|
|
||||||
export default class CustomerModuleService<
|
export default class CustomerModuleService<
|
||||||
TAddress extends Address = Address,
|
TAddress extends Address = Address,
|
||||||
@@ -45,8 +45,7 @@ export default class CustomerModuleService<
|
|||||||
TCustomerGroup extends CustomerGroup = CustomerGroup,
|
TCustomerGroup extends CustomerGroup = CustomerGroup,
|
||||||
TCustomerGroupCustomer extends CustomerGroupCustomer = CustomerGroupCustomer
|
TCustomerGroupCustomer extends CustomerGroupCustomer = CustomerGroupCustomer
|
||||||
>
|
>
|
||||||
extends ModulesSdkUtils.abstractModuleServiceFactory<
|
extends ModulesSdkUtils.MedusaService<
|
||||||
InjectedDependencies,
|
|
||||||
CustomerDTO,
|
CustomerDTO,
|
||||||
{
|
{
|
||||||
Address: { dto: any }
|
Address: { dto: any }
|
||||||
@@ -57,10 +56,10 @@ export default class CustomerModuleService<
|
|||||||
implements ICustomerModuleService
|
implements ICustomerModuleService
|
||||||
{
|
{
|
||||||
protected baseRepository_: DAL.RepositoryService
|
protected baseRepository_: DAL.RepositoryService
|
||||||
protected customerService_: ModulesSdkTypes.InternalModuleService<TCustomer>
|
protected customerService_: ModulesSdkTypes.IMedusaInternalService<TCustomer>
|
||||||
protected addressService_: ModulesSdkTypes.InternalModuleService<TAddress>
|
protected addressService_: ModulesSdkTypes.IMedusaInternalService<TAddress>
|
||||||
protected customerGroupService_: ModulesSdkTypes.InternalModuleService<TCustomerGroup>
|
protected customerGroupService_: ModulesSdkTypes.IMedusaInternalService<TCustomerGroup>
|
||||||
protected customerGroupCustomerService_: ModulesSdkTypes.InternalModuleService<TCustomerGroupCustomer>
|
protected customerGroupCustomerService_: ModulesSdkTypes.IMedusaInternalService<TCustomerGroupCustomer>
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
{
|
{
|
||||||
@@ -233,6 +232,7 @@ export default class CustomerModuleService<
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
async updateCustomerGroups(
|
async updateCustomerGroups(
|
||||||
groupId: string,
|
groupId: string,
|
||||||
data: CustomerTypes.CustomerGroupUpdatableFields,
|
data: CustomerTypes.CustomerGroupUpdatableFields,
|
||||||
@@ -372,6 +372,7 @@ export default class CustomerModuleService<
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
async updateAddresses(
|
async updateAddresses(
|
||||||
addressId: string,
|
addressId: string,
|
||||||
data: CustomerTypes.UpdateCustomerAddressDTO,
|
data: CustomerTypes.UpdateCustomerAddressDTO,
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ async function syncDatabaseProviders({ container }) {
|
|||||||
container.resolve(FulfillmentIdentifiersRegistrationName) ?? []
|
container.resolve(FulfillmentIdentifiersRegistrationName) ?? []
|
||||||
).filter(Boolean)
|
).filter(Boolean)
|
||||||
|
|
||||||
const providerService: ModulesSdkTypes.InternalModuleService<any> =
|
const providerService: ModulesSdkTypes.IMedusaInternalService<any> =
|
||||||
container.resolve(providerServiceRegistrationKey)
|
container.resolve(providerServiceRegistrationKey)
|
||||||
|
|
||||||
const providers = await providerService.list({})
|
const providers = await providerService.list({})
|
||||||
|
|||||||
@@ -14,18 +14,18 @@ import {
|
|||||||
UpdateServiceZoneDTO,
|
UpdateServiceZoneDTO,
|
||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
EmitEvents,
|
|
||||||
InjectManager,
|
|
||||||
InjectTransactionManager,
|
|
||||||
MedusaContext,
|
|
||||||
MedusaError,
|
|
||||||
ModulesSdkUtils,
|
|
||||||
arrayDifference,
|
arrayDifference,
|
||||||
deepEqualObj,
|
deepEqualObj,
|
||||||
|
EmitEvents,
|
||||||
getSetDifference,
|
getSetDifference,
|
||||||
|
InjectManager,
|
||||||
|
InjectTransactionManager,
|
||||||
isDefined,
|
isDefined,
|
||||||
isPresent,
|
isPresent,
|
||||||
isString,
|
isString,
|
||||||
|
MedusaContext,
|
||||||
|
MedusaError,
|
||||||
|
ModulesSdkUtils,
|
||||||
promiseAll,
|
promiseAll,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import {
|
import {
|
||||||
@@ -52,7 +52,7 @@ import { UpdateShippingOptionsInput } from "../types/service"
|
|||||||
import { buildCreatedShippingOptionEvents } from "../utils/events"
|
import { buildCreatedShippingOptionEvents } from "../utils/events"
|
||||||
import FulfillmentProviderService from "./fulfillment-provider"
|
import FulfillmentProviderService from "./fulfillment-provider"
|
||||||
|
|
||||||
const generateMethodForModels = [
|
const generateMethodForModels = {
|
||||||
ServiceZone,
|
ServiceZone,
|
||||||
ShippingOption,
|
ShippingOption,
|
||||||
GeoZone,
|
GeoZone,
|
||||||
@@ -61,19 +61,19 @@ const generateMethodForModels = [
|
|||||||
ShippingOptionType,
|
ShippingOptionType,
|
||||||
FulfillmentProvider,
|
FulfillmentProvider,
|
||||||
// Not adding Fulfillment to not auto generate the methods under the hood and only provide the methods we want to expose8
|
// Not adding Fulfillment to not auto generate the methods under the hood and only provide the methods we want to expose8
|
||||||
]
|
}
|
||||||
|
|
||||||
type InjectedDependencies = {
|
type InjectedDependencies = {
|
||||||
baseRepository: DAL.RepositoryService
|
baseRepository: DAL.RepositoryService
|
||||||
fulfillmentSetService: ModulesSdkTypes.InternalModuleService<any>
|
fulfillmentSetService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
serviceZoneService: ModulesSdkTypes.InternalModuleService<any>
|
serviceZoneService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
geoZoneService: ModulesSdkTypes.InternalModuleService<any>
|
geoZoneService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
shippingProfileService: ModulesSdkTypes.InternalModuleService<any>
|
shippingProfileService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
shippingOptionService: ModulesSdkTypes.InternalModuleService<any>
|
shippingOptionService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
shippingOptionRuleService: ModulesSdkTypes.InternalModuleService<any>
|
shippingOptionRuleService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
shippingOptionTypeService: ModulesSdkTypes.InternalModuleService<any>
|
shippingOptionTypeService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
fulfillmentProviderService: FulfillmentProviderService
|
fulfillmentProviderService: FulfillmentProviderService
|
||||||
fulfillmentService: ModulesSdkTypes.InternalModuleService<any>
|
fulfillmentService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class FulfillmentModuleService<
|
export default class FulfillmentModuleService<
|
||||||
@@ -86,8 +86,7 @@ export default class FulfillmentModuleService<
|
|||||||
TSippingOptionTypeEntity extends ShippingOptionType = ShippingOptionType,
|
TSippingOptionTypeEntity extends ShippingOptionType = ShippingOptionType,
|
||||||
TFulfillmentEntity extends Fulfillment = Fulfillment
|
TFulfillmentEntity extends Fulfillment = Fulfillment
|
||||||
>
|
>
|
||||||
extends ModulesSdkUtils.abstractModuleServiceFactory<
|
extends ModulesSdkUtils.MedusaService<
|
||||||
InjectedDependencies,
|
|
||||||
FulfillmentTypes.FulfillmentSetDTO,
|
FulfillmentTypes.FulfillmentSetDTO,
|
||||||
{
|
{
|
||||||
FulfillmentSet: { dto: FulfillmentTypes.FulfillmentSetDTO }
|
FulfillmentSet: { dto: FulfillmentTypes.FulfillmentSetDTO }
|
||||||
@@ -103,15 +102,15 @@ export default class FulfillmentModuleService<
|
|||||||
implements IFulfillmentModuleService
|
implements IFulfillmentModuleService
|
||||||
{
|
{
|
||||||
protected baseRepository_: DAL.RepositoryService
|
protected baseRepository_: DAL.RepositoryService
|
||||||
protected readonly fulfillmentSetService_: ModulesSdkTypes.InternalModuleService<TEntity>
|
protected readonly fulfillmentSetService_: ModulesSdkTypes.IMedusaInternalService<TEntity>
|
||||||
protected readonly serviceZoneService_: ModulesSdkTypes.InternalModuleService<TServiceZoneEntity>
|
protected readonly serviceZoneService_: ModulesSdkTypes.IMedusaInternalService<TServiceZoneEntity>
|
||||||
protected readonly geoZoneService_: ModulesSdkTypes.InternalModuleService<TGeoZoneEntity>
|
protected readonly geoZoneService_: ModulesSdkTypes.IMedusaInternalService<TGeoZoneEntity>
|
||||||
protected readonly shippingProfileService_: ModulesSdkTypes.InternalModuleService<TShippingProfileEntity>
|
protected readonly shippingProfileService_: ModulesSdkTypes.IMedusaInternalService<TShippingProfileEntity>
|
||||||
protected readonly shippingOptionService_: ModulesSdkTypes.InternalModuleService<TShippingOptionEntity>
|
protected readonly shippingOptionService_: ModulesSdkTypes.IMedusaInternalService<TShippingOptionEntity>
|
||||||
protected readonly shippingOptionRuleService_: ModulesSdkTypes.InternalModuleService<TShippingOptionRuleEntity>
|
protected readonly shippingOptionRuleService_: ModulesSdkTypes.IMedusaInternalService<TShippingOptionRuleEntity>
|
||||||
protected readonly shippingOptionTypeService_: ModulesSdkTypes.InternalModuleService<TSippingOptionTypeEntity>
|
protected readonly shippingOptionTypeService_: ModulesSdkTypes.IMedusaInternalService<TSippingOptionTypeEntity>
|
||||||
protected readonly fulfillmentProviderService_: FulfillmentProviderService
|
protected readonly fulfillmentProviderService_: FulfillmentProviderService
|
||||||
protected readonly fulfillmentService_: ModulesSdkTypes.InternalModuleService<TFulfillmentEntity>
|
protected readonly fulfillmentService_: ModulesSdkTypes.IMedusaInternalService<TFulfillmentEntity>
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
{
|
{
|
||||||
@@ -325,6 +324,7 @@ export default class FulfillmentModuleService<
|
|||||||
return createdFulfillmentSets
|
return createdFulfillmentSets
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
createServiceZones(
|
createServiceZones(
|
||||||
data: FulfillmentTypes.CreateServiceZoneDTO[],
|
data: FulfillmentTypes.CreateServiceZoneDTO[],
|
||||||
sharedContext?: Context
|
sharedContext?: Context
|
||||||
@@ -388,6 +388,7 @@ export default class FulfillmentModuleService<
|
|||||||
return createdServiceZones
|
return createdServiceZones
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
createShippingOptions(
|
createShippingOptions(
|
||||||
data: FulfillmentTypes.CreateShippingOptionDTO[],
|
data: FulfillmentTypes.CreateShippingOptionDTO[],
|
||||||
sharedContext?: Context
|
sharedContext?: Context
|
||||||
@@ -448,6 +449,7 @@ export default class FulfillmentModuleService<
|
|||||||
return createdSO
|
return createdSO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
createShippingProfiles(
|
createShippingProfiles(
|
||||||
data: FulfillmentTypes.CreateShippingProfileDTO[],
|
data: FulfillmentTypes.CreateShippingProfileDTO[],
|
||||||
sharedContext?: Context
|
sharedContext?: Context
|
||||||
@@ -501,6 +503,7 @@ export default class FulfillmentModuleService<
|
|||||||
return await this.shippingProfileService_.create(data_, sharedContext)
|
return await this.shippingProfileService_.create(data_, sharedContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
createGeoZones(
|
createGeoZones(
|
||||||
data: FulfillmentTypes.CreateGeoZoneDTO[],
|
data: FulfillmentTypes.CreateGeoZoneDTO[],
|
||||||
sharedContext?: Context
|
sharedContext?: Context
|
||||||
@@ -537,6 +540,7 @@ export default class FulfillmentModuleService<
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
async createShippingOptionRules(
|
async createShippingOptionRules(
|
||||||
data: FulfillmentTypes.CreateShippingOptionRuleDTO[],
|
data: FulfillmentTypes.CreateShippingOptionRuleDTO[],
|
||||||
sharedContext?: Context
|
sharedContext?: Context
|
||||||
@@ -924,6 +928,7 @@ export default class FulfillmentModuleService<
|
|||||||
: updatedFulfillmentSets[0]
|
: updatedFulfillmentSets[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
updateServiceZones(
|
updateServiceZones(
|
||||||
id: string,
|
id: string,
|
||||||
data: FulfillmentTypes.UpdateServiceZoneDTO,
|
data: FulfillmentTypes.UpdateServiceZoneDTO,
|
||||||
@@ -1223,6 +1228,7 @@ export default class FulfillmentModuleService<
|
|||||||
return [...created, ...updated]
|
return [...created, ...updated]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
updateShippingOptions(
|
updateShippingOptions(
|
||||||
id: string,
|
id: string,
|
||||||
data: FulfillmentTypes.UpdateShippingOptionDTO,
|
data: FulfillmentTypes.UpdateShippingOptionDTO,
|
||||||
@@ -1540,6 +1546,7 @@ export default class FulfillmentModuleService<
|
|||||||
return [...created, ...updated]
|
return [...created, ...updated]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
updateShippingProfiles(
|
updateShippingProfiles(
|
||||||
selector: FulfillmentTypes.FilterableShippingProfileProps,
|
selector: FulfillmentTypes.FilterableShippingProfileProps,
|
||||||
data: FulfillmentTypes.UpdateShippingProfileDTO,
|
data: FulfillmentTypes.UpdateShippingProfileDTO,
|
||||||
@@ -1643,6 +1650,7 @@ export default class FulfillmentModuleService<
|
|||||||
return Array.isArray(data) ? allProfiles : allProfiles[0]
|
return Array.isArray(data) ? allProfiles : allProfiles[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
updateGeoZones(
|
updateGeoZones(
|
||||||
data: FulfillmentTypes.UpdateGeoZoneDTO[],
|
data: FulfillmentTypes.UpdateGeoZoneDTO[],
|
||||||
sharedContext?: Context
|
sharedContext?: Context
|
||||||
@@ -1685,6 +1693,7 @@ export default class FulfillmentModuleService<
|
|||||||
return Array.isArray(data) ? serialized : serialized[0]
|
return Array.isArray(data) ? serialized : serialized[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
updateShippingOptionRules(
|
updateShippingOptionRules(
|
||||||
data: FulfillmentTypes.UpdateShippingOptionRuleDTO[],
|
data: FulfillmentTypes.UpdateShippingOptionRuleDTO[],
|
||||||
sharedContext?: Context
|
sharedContext?: Context
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ type InjectedDependencies = {
|
|||||||
|
|
||||||
// TODO rework DTO's
|
// TODO rework DTO's
|
||||||
|
|
||||||
export default class FulfillmentProviderService extends ModulesSdkUtils.internalModuleServiceFactory<InjectedDependencies>(
|
export default class FulfillmentProviderService extends ModulesSdkUtils.MedusaInternalService<InjectedDependencies>(
|
||||||
FulfillmentProvider
|
FulfillmentProvider
|
||||||
) {
|
) {
|
||||||
protected readonly fulfillmentProviderRepository_: DAL.RepositoryService
|
protected readonly fulfillmentProviderRepository_: DAL.RepositoryService
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ type InjectedDependencies = {
|
|||||||
|
|
||||||
export default class InventoryLevelService<
|
export default class InventoryLevelService<
|
||||||
TEntity extends InventoryLevel = InventoryLevel
|
TEntity extends InventoryLevel = InventoryLevel
|
||||||
> extends ModulesSdkUtils.internalModuleServiceFactory<InjectedDependencies>(
|
> extends ModulesSdkUtils.MedusaInternalService<InjectedDependencies>(
|
||||||
InventoryLevel
|
InventoryLevel
|
||||||
)<TEntity> {
|
)<TEntity> {
|
||||||
protected readonly inventoryLevelRepository: InventoryLevelRepository
|
protected readonly inventoryLevelRepository: InventoryLevelRepository
|
||||||
|
|||||||
@@ -30,20 +30,23 @@ import InventoryLevelService from "./inventory-level"
|
|||||||
|
|
||||||
type InjectedDependencies = {
|
type InjectedDependencies = {
|
||||||
baseRepository: DAL.RepositoryService
|
baseRepository: DAL.RepositoryService
|
||||||
inventoryItemService: ModulesSdkTypes.InternalModuleService<any>
|
inventoryItemService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
inventoryLevelService: InventoryLevelService<any>
|
inventoryLevelService: InventoryLevelService<any>
|
||||||
reservationItemService: ModulesSdkTypes.InternalModuleService<any>
|
reservationItemService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
}
|
}
|
||||||
|
|
||||||
const generateMethodForModels = [InventoryItem, InventoryLevel, ReservationItem]
|
const generateMethodForModels = {
|
||||||
|
InventoryItem,
|
||||||
|
InventoryLevel,
|
||||||
|
ReservationItem,
|
||||||
|
}
|
||||||
|
|
||||||
export default class InventoryModuleService<
|
export default class InventoryModuleService<
|
||||||
TInventoryItem extends InventoryItem = InventoryItem,
|
TInventoryItem extends InventoryItem = InventoryItem,
|
||||||
TInventoryLevel extends InventoryLevel = InventoryLevel,
|
TInventoryLevel extends InventoryLevel = InventoryLevel,
|
||||||
TReservationItem extends ReservationItem = ReservationItem
|
TReservationItem extends ReservationItem = ReservationItem
|
||||||
>
|
>
|
||||||
extends ModulesSdkUtils.abstractModuleServiceFactory<
|
extends ModulesSdkUtils.MedusaService<
|
||||||
InjectedDependencies,
|
|
||||||
InventoryNext.InventoryItemDTO,
|
InventoryNext.InventoryItemDTO,
|
||||||
{
|
{
|
||||||
InventoryItem: {
|
InventoryItem: {
|
||||||
@@ -61,8 +64,8 @@ export default class InventoryModuleService<
|
|||||||
{
|
{
|
||||||
protected baseRepository_: DAL.RepositoryService
|
protected baseRepository_: DAL.RepositoryService
|
||||||
|
|
||||||
protected readonly inventoryItemService_: ModulesSdkTypes.InternalModuleService<TInventoryItem>
|
protected readonly inventoryItemService_: ModulesSdkTypes.IMedusaInternalService<TInventoryItem>
|
||||||
protected readonly reservationItemService_: ModulesSdkTypes.InternalModuleService<TReservationItem>
|
protected readonly reservationItemService_: ModulesSdkTypes.IMedusaInternalService<TReservationItem>
|
||||||
protected readonly inventoryLevelService_: InventoryLevelService<TInventoryLevel>
|
protected readonly inventoryLevelService_: InventoryLevelService<TInventoryLevel>
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@@ -209,6 +212,7 @@ export default class InventoryModuleService<
|
|||||||
await promiseAll(checkLevels)
|
await promiseAll(checkLevels)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
async createReservationItems(
|
async createReservationItems(
|
||||||
input: InventoryNext.CreateReservationItemInput[],
|
input: InventoryNext.CreateReservationItemInput[],
|
||||||
context?: Context
|
context?: Context
|
||||||
@@ -365,6 +369,7 @@ export default class InventoryModuleService<
|
|||||||
return await this.inventoryItemService_.create(input)
|
return await this.inventoryItemService_.create(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
createInventoryLevels(
|
createInventoryLevels(
|
||||||
input: InventoryNext.CreateInventoryLevelInput,
|
input: InventoryNext.CreateInventoryLevelInput,
|
||||||
context?: Context
|
context?: Context
|
||||||
@@ -537,6 +542,7 @@ export default class InventoryModuleService<
|
|||||||
return await this.inventoryLevelService_.delete(inventoryLevel.id, context)
|
return await this.inventoryLevelService_.delete(inventoryLevel.id, context)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
async updateInventoryLevels(
|
async updateInventoryLevels(
|
||||||
updates: InventoryTypes.BulkUpdateInventoryLevelInput[],
|
updates: InventoryTypes.BulkUpdateInventoryLevelInput[],
|
||||||
context?: Context
|
context?: Context
|
||||||
@@ -623,6 +629,7 @@ export default class InventoryModuleService<
|
|||||||
* @param context
|
* @param context
|
||||||
* @return The updated inventory level
|
* @return The updated inventory level
|
||||||
*/
|
*/
|
||||||
|
// @ts-ignore
|
||||||
async updateReservationItems(
|
async updateReservationItems(
|
||||||
input: InventoryNext.UpdateReservationItemInput[],
|
input: InventoryNext.UpdateReservationItemInput[],
|
||||||
context?: Context
|
context?: Context
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ async function syncDatabaseProviders({
|
|||||||
const providerServiceRegistrationKey = lowerCaseFirst(
|
const providerServiceRegistrationKey = lowerCaseFirst(
|
||||||
NotificationProviderService.name
|
NotificationProviderService.name
|
||||||
)
|
)
|
||||||
const providerService: ModulesSdkTypes.InternalModuleService<NotificationProvider> =
|
const providerService: ModulesSdkTypes.IMedusaInternalService<NotificationProvider> =
|
||||||
container.resolve(providerServiceRegistrationKey)
|
container.resolve(providerServiceRegistrationKey)
|
||||||
|
|
||||||
const logger = container.resolve(ContainerRegistrationKeys.LOGGER) ?? console
|
const logger = container.resolve(ContainerRegistrationKeys.LOGGER) ?? console
|
||||||
|
|||||||
@@ -1,37 +1,36 @@
|
|||||||
import {
|
import {
|
||||||
Context,
|
Context,
|
||||||
DAL,
|
DAL,
|
||||||
NotificationTypes,
|
|
||||||
INotificationModuleService,
|
INotificationModuleService,
|
||||||
InternalModuleDeclaration,
|
InternalModuleDeclaration,
|
||||||
ModuleJoinerConfig,
|
ModuleJoinerConfig,
|
||||||
ModulesSdkTypes,
|
ModulesSdkTypes,
|
||||||
|
NotificationTypes,
|
||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
InjectManager,
|
InjectManager,
|
||||||
InjectTransactionManager,
|
InjectTransactionManager,
|
||||||
MedusaContext,
|
MedusaContext,
|
||||||
|
MedusaError,
|
||||||
ModulesSdkUtils,
|
ModulesSdkUtils,
|
||||||
promiseAll,
|
promiseAll,
|
||||||
MedusaError,
|
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import { entityNameToLinkableKeysMap, joinerConfig } from "../joiner-config"
|
import { entityNameToLinkableKeysMap, joinerConfig } from "../joiner-config"
|
||||||
import NotificationProviderService from "./notification-provider"
|
import NotificationProviderService from "./notification-provider"
|
||||||
import { NotificationModel, NotificationProvider } from "@models"
|
import { NotificationModel, NotificationProvider } from "@models"
|
||||||
|
|
||||||
const generateMethodForModels = [NotificationProvider]
|
const generateMethodForModels = { NotificationProvider }
|
||||||
|
|
||||||
type InjectedDependencies = {
|
type InjectedDependencies = {
|
||||||
baseRepository: DAL.RepositoryService
|
baseRepository: DAL.RepositoryService
|
||||||
notificationModelService: ModulesSdkTypes.InternalModuleService<any>
|
notificationModelService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
notificationProviderService: NotificationProviderService
|
notificationProviderService: NotificationProviderService
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class NotificationModuleService<
|
export default class NotificationModuleService<
|
||||||
TEntity extends NotificationModel = NotificationModel
|
TEntity extends NotificationModel = NotificationModel
|
||||||
>
|
>
|
||||||
extends ModulesSdkUtils.abstractModuleServiceFactory<
|
extends ModulesSdkUtils.MedusaService<
|
||||||
InjectedDependencies,
|
|
||||||
NotificationTypes.NotificationDTO,
|
NotificationTypes.NotificationDTO,
|
||||||
{
|
{
|
||||||
NotificationProvider: { dto: NotificationTypes.NotificationProviderDTO }
|
NotificationProvider: { dto: NotificationTypes.NotificationProviderDTO }
|
||||||
@@ -40,7 +39,7 @@ export default class NotificationModuleService<
|
|||||||
implements INotificationModuleService
|
implements INotificationModuleService
|
||||||
{
|
{
|
||||||
protected baseRepository_: DAL.RepositoryService
|
protected baseRepository_: DAL.RepositoryService
|
||||||
protected readonly notificationService_: ModulesSdkTypes.InternalModuleService<TEntity>
|
protected readonly notificationService_: ModulesSdkTypes.IMedusaInternalService<TEntity>
|
||||||
protected readonly notificationProviderService_: NotificationProviderService
|
protected readonly notificationProviderService_: NotificationProviderService
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Constructor, DAL, NotificationTypes } from "@medusajs/types"
|
import { DAL, NotificationTypes } from "@medusajs/types"
|
||||||
import { ModulesSdkUtils, MedusaError } from "@medusajs/utils"
|
import { MedusaError, ModulesSdkUtils } from "@medusajs/utils"
|
||||||
import { NotificationProvider } from "@models"
|
import { NotificationProvider } from "@models"
|
||||||
import { NotificationProviderRegistrationPrefix } from "@types"
|
import { NotificationProviderRegistrationPrefix } from "@types"
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@ type InjectedDependencies = {
|
|||||||
]: NotificationTypes.INotificationProvider
|
]: NotificationTypes.INotificationProvider
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class NotificationProviderService extends ModulesSdkUtils.internalModuleServiceFactory<InjectedDependencies>(
|
export default class NotificationProviderService extends ModulesSdkUtils.MedusaInternalService<InjectedDependencies>(
|
||||||
NotificationProvider
|
NotificationProvider
|
||||||
) {
|
) {
|
||||||
protected readonly notificationProviderRepository_: DAL.RepositoryService<NotificationProvider>
|
protected readonly notificationProviderRepository_: DAL.RepositoryService<NotificationProvider>
|
||||||
|
|||||||
@@ -6,12 +6,12 @@ import {
|
|||||||
RepositoryService,
|
RepositoryService,
|
||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
|
deduplicate,
|
||||||
InjectManager,
|
InjectManager,
|
||||||
InjectTransactionManager,
|
InjectTransactionManager,
|
||||||
MedusaContext,
|
MedusaContext,
|
||||||
MedusaError,
|
MedusaError,
|
||||||
ModulesSdkUtils,
|
ModulesSdkUtils,
|
||||||
deduplicate,
|
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import { OrderChange } from "@models"
|
import { OrderChange } from "@models"
|
||||||
import { OrderChangeStatus } from "@types"
|
import { OrderChangeStatus } from "@types"
|
||||||
@@ -22,7 +22,7 @@ type InjectedDependencies = {
|
|||||||
|
|
||||||
export default class OrderChangeService<
|
export default class OrderChangeService<
|
||||||
TEntity extends OrderChange = OrderChange
|
TEntity extends OrderChange = OrderChange
|
||||||
> extends ModulesSdkUtils.internalModuleServiceFactory<InjectedDependencies>(
|
> extends ModulesSdkUtils.MedusaInternalService<InjectedDependencies>(
|
||||||
OrderChange
|
OrderChange
|
||||||
)<TEntity> {
|
)<TEntity> {
|
||||||
protected readonly orderChangeRepository_: RepositoryService<TEntity>
|
protected readonly orderChangeRepository_: RepositoryService<TEntity>
|
||||||
|
|||||||
@@ -76,24 +76,24 @@ import OrderService from "./order-service"
|
|||||||
type InjectedDependencies = {
|
type InjectedDependencies = {
|
||||||
baseRepository: DAL.RepositoryService
|
baseRepository: DAL.RepositoryService
|
||||||
orderService: OrderService<any>
|
orderService: OrderService<any>
|
||||||
addressService: ModulesSdkTypes.InternalModuleService<any>
|
addressService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
lineItemService: ModulesSdkTypes.InternalModuleService<any>
|
lineItemService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
shippingMethodAdjustmentService: ModulesSdkTypes.InternalModuleService<any>
|
shippingMethodAdjustmentService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
shippingMethodService: ModulesSdkTypes.InternalModuleService<any>
|
shippingMethodService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
lineItemAdjustmentService: ModulesSdkTypes.InternalModuleService<any>
|
lineItemAdjustmentService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
lineItemTaxLineService: ModulesSdkTypes.InternalModuleService<any>
|
lineItemTaxLineService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
shippingMethodTaxLineService: ModulesSdkTypes.InternalModuleService<any>
|
shippingMethodTaxLineService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
transactionService: ModulesSdkTypes.InternalModuleService<any>
|
transactionService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
orderChangeService: OrderChangeService<any>
|
orderChangeService: OrderChangeService<any>
|
||||||
orderChangeActionService: ModulesSdkTypes.InternalModuleService<any>
|
orderChangeActionService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
orderItemService: ModulesSdkTypes.InternalModuleService<any>
|
orderItemService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
orderSummaryService: ModulesSdkTypes.InternalModuleService<any>
|
orderSummaryService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
orderShippingMethodService: ModulesSdkTypes.InternalModuleService<any>
|
orderShippingMethodService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
returnReasonService: ModulesSdkTypes.InternalModuleService<any>
|
returnReasonService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
returnService: ModulesSdkTypes.InternalModuleService<any>
|
returnService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
}
|
}
|
||||||
|
|
||||||
const generateMethodForModels = [
|
const generateMethodForModels = {
|
||||||
Address,
|
Address,
|
||||||
LineItem,
|
LineItem,
|
||||||
LineItemAdjustment,
|
LineItemAdjustment,
|
||||||
@@ -109,7 +109,7 @@ const generateMethodForModels = [
|
|||||||
OrderShippingMethod,
|
OrderShippingMethod,
|
||||||
ReturnReason,
|
ReturnReason,
|
||||||
Return,
|
Return,
|
||||||
]
|
}
|
||||||
|
|
||||||
export default class OrderModuleService<
|
export default class OrderModuleService<
|
||||||
TOrder extends Order = Order,
|
TOrder extends Order = Order,
|
||||||
@@ -129,8 +129,7 @@ export default class OrderModuleService<
|
|||||||
TReturnReason extends ReturnReason = ReturnReason,
|
TReturnReason extends ReturnReason = ReturnReason,
|
||||||
TReturn extends Return = Return
|
TReturn extends Return = Return
|
||||||
>
|
>
|
||||||
extends ModulesSdkUtils.abstractModuleServiceFactory<
|
extends ModulesSdkUtils.MedusaService<
|
||||||
InjectedDependencies,
|
|
||||||
OrderTypes.OrderDTO,
|
OrderTypes.OrderDTO,
|
||||||
{
|
{
|
||||||
Address: { dto: OrderTypes.OrderAddressDTO }
|
Address: { dto: OrderTypes.OrderAddressDTO }
|
||||||
@@ -156,21 +155,21 @@ export default class OrderModuleService<
|
|||||||
{
|
{
|
||||||
protected baseRepository_: DAL.RepositoryService
|
protected baseRepository_: DAL.RepositoryService
|
||||||
protected orderService_: OrderService<TOrder>
|
protected orderService_: OrderService<TOrder>
|
||||||
protected addressService_: ModulesSdkTypes.InternalModuleService<TAddress>
|
protected addressService_: ModulesSdkTypes.IMedusaInternalService<TAddress>
|
||||||
protected lineItemService_: ModulesSdkTypes.InternalModuleService<TLineItem>
|
protected lineItemService_: ModulesSdkTypes.IMedusaInternalService<TLineItem>
|
||||||
protected shippingMethodAdjustmentService_: ModulesSdkTypes.InternalModuleService<TShippingMethodAdjustment>
|
protected shippingMethodAdjustmentService_: ModulesSdkTypes.IMedusaInternalService<TShippingMethodAdjustment>
|
||||||
protected shippingMethodService_: ModulesSdkTypes.InternalModuleService<TShippingMethod>
|
protected shippingMethodService_: ModulesSdkTypes.IMedusaInternalService<TShippingMethod>
|
||||||
protected lineItemAdjustmentService_: ModulesSdkTypes.InternalModuleService<TLineItemAdjustment>
|
protected lineItemAdjustmentService_: ModulesSdkTypes.IMedusaInternalService<TLineItemAdjustment>
|
||||||
protected lineItemTaxLineService_: ModulesSdkTypes.InternalModuleService<TLineItemTaxLine>
|
protected lineItemTaxLineService_: ModulesSdkTypes.IMedusaInternalService<TLineItemTaxLine>
|
||||||
protected shippingMethodTaxLineService_: ModulesSdkTypes.InternalModuleService<TShippingMethodTaxLine>
|
protected shippingMethodTaxLineService_: ModulesSdkTypes.IMedusaInternalService<TShippingMethodTaxLine>
|
||||||
protected transactionService_: ModulesSdkTypes.InternalModuleService<TTransaction>
|
protected transactionService_: ModulesSdkTypes.IMedusaInternalService<TTransaction>
|
||||||
protected orderChangeService_: OrderChangeService<TOrderChange>
|
protected orderChangeService_: OrderChangeService<TOrderChange>
|
||||||
protected orderChangeActionService_: ModulesSdkTypes.InternalModuleService<TOrderChangeAction>
|
protected orderChangeActionService_: ModulesSdkTypes.IMedusaInternalService<TOrderChangeAction>
|
||||||
protected orderItemService_: ModulesSdkTypes.InternalModuleService<TOrderItem>
|
protected orderItemService_: ModulesSdkTypes.IMedusaInternalService<TOrderItem>
|
||||||
protected orderSummaryService_: ModulesSdkTypes.InternalModuleService<TOrderSummary>
|
protected orderSummaryService_: ModulesSdkTypes.IMedusaInternalService<TOrderSummary>
|
||||||
protected orderShippingMethodService_: ModulesSdkTypes.InternalModuleService<TOrderShippingMethod>
|
protected orderShippingMethodService_: ModulesSdkTypes.IMedusaInternalService<TOrderShippingMethod>
|
||||||
protected returnReasonService_: ModulesSdkTypes.InternalModuleService<TReturnReason>
|
protected returnReasonService_: ModulesSdkTypes.IMedusaInternalService<TReturnReason>
|
||||||
protected returnService_: ModulesSdkTypes.InternalModuleService<TReturn>
|
protected returnService_: ModulesSdkTypes.IMedusaInternalService<TReturn>
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
{
|
{
|
||||||
@@ -553,6 +552,7 @@ export default class OrderModuleService<
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
createLineItems(
|
createLineItems(
|
||||||
data: OrderTypes.CreateOrderLineItemForOrderDTO
|
data: OrderTypes.CreateOrderLineItemForOrderDTO
|
||||||
): Promise<OrderTypes.OrderLineItemDTO[]>
|
): Promise<OrderTypes.OrderLineItemDTO[]>
|
||||||
@@ -670,6 +670,7 @@ export default class OrderModuleService<
|
|||||||
return lineItems
|
return lineItems
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
updateLineItems(
|
updateLineItems(
|
||||||
data: OrderTypes.UpdateOrderLineItemWithSelectorDTO[]
|
data: OrderTypes.UpdateOrderLineItemWithSelectorDTO[]
|
||||||
): Promise<OrderTypes.OrderLineItemDTO[]>
|
): Promise<OrderTypes.OrderLineItemDTO[]>
|
||||||
@@ -883,6 +884,7 @@ export default class OrderModuleService<
|
|||||||
return await this.orderItemService_.update(toUpdate, sharedContext)
|
return await this.orderItemService_.update(toUpdate, sharedContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
async createAddresses(
|
async createAddresses(
|
||||||
data: OrderTypes.CreateOrderAddressDTO,
|
data: OrderTypes.CreateOrderAddressDTO,
|
||||||
sharedContext?: Context
|
sharedContext?: Context
|
||||||
@@ -919,6 +921,7 @@ export default class OrderModuleService<
|
|||||||
return await this.addressService_.create(data, sharedContext)
|
return await this.addressService_.create(data, sharedContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
async updateAddresses(
|
async updateAddresses(
|
||||||
data: OrderTypes.UpdateOrderAddressDTO,
|
data: OrderTypes.UpdateOrderAddressDTO,
|
||||||
sharedContext?: Context
|
sharedContext?: Context
|
||||||
@@ -955,6 +958,7 @@ export default class OrderModuleService<
|
|||||||
return await this.addressService_.update(data, sharedContext)
|
return await this.addressService_.update(data, sharedContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
async createShippingMethods(
|
async createShippingMethods(
|
||||||
data: OrderTypes.CreateOrderShippingMethodDTO
|
data: OrderTypes.CreateOrderShippingMethodDTO
|
||||||
): Promise<OrderTypes.OrderShippingMethodDTO>
|
): Promise<OrderTypes.OrderShippingMethodDTO>
|
||||||
@@ -1059,6 +1063,7 @@ export default class OrderModuleService<
|
|||||||
return sm.map((s) => s.shipping_method)
|
return sm.map((s) => s.shipping_method)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
async createLineItemAdjustments(
|
async createLineItemAdjustments(
|
||||||
adjustments: OrderTypes.CreateOrderLineItemAdjustmentDTO[]
|
adjustments: OrderTypes.CreateOrderLineItemAdjustmentDTO[]
|
||||||
): Promise<OrderTypes.OrderLineItemAdjustmentDTO[]>
|
): Promise<OrderTypes.OrderLineItemAdjustmentDTO[]>
|
||||||
@@ -1228,6 +1233,7 @@ export default class OrderModuleService<
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
async createShippingMethodAdjustments(
|
async createShippingMethodAdjustments(
|
||||||
adjustments: OrderTypes.CreateOrderShippingMethodAdjustmentDTO[]
|
adjustments: OrderTypes.CreateOrderShippingMethodAdjustmentDTO[]
|
||||||
): Promise<OrderTypes.OrderShippingMethodAdjustmentDTO[]>
|
): Promise<OrderTypes.OrderShippingMethodAdjustmentDTO[]>
|
||||||
@@ -1302,6 +1308,7 @@ export default class OrderModuleService<
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
createLineItemTaxLines(
|
createLineItemTaxLines(
|
||||||
taxLines: OrderTypes.CreateOrderLineItemTaxLineDTO[]
|
taxLines: OrderTypes.CreateOrderLineItemTaxLineDTO[]
|
||||||
): Promise<OrderTypes.OrderLineItemTaxLineDTO[]>
|
): Promise<OrderTypes.OrderLineItemTaxLineDTO[]>
|
||||||
@@ -1412,6 +1419,7 @@ export default class OrderModuleService<
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
createShippingMethodTaxLines(
|
createShippingMethodTaxLines(
|
||||||
taxLines: OrderTypes.CreateOrderShippingMethodTaxLineDTO[]
|
taxLines: OrderTypes.CreateOrderShippingMethodTaxLineDTO[]
|
||||||
): Promise<OrderTypes.OrderShippingMethodTaxLineDTO[]>
|
): Promise<OrderTypes.OrderShippingMethodTaxLineDTO[]>
|
||||||
@@ -2319,6 +2327,7 @@ export default class OrderModuleService<
|
|||||||
await this.orderSummaryService_.update(summaries, sharedContext)
|
await this.orderSummaryService_.update(summaries, sharedContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
async createReturnReasons(
|
async createReturnReasons(
|
||||||
transactionData: OrderTypes.CreateOrderReturnReasonDTO,
|
transactionData: OrderTypes.CreateOrderReturnReasonDTO,
|
||||||
sharedContext?: Context
|
sharedContext?: Context
|
||||||
@@ -2352,6 +2361,7 @@ export default class OrderModuleService<
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
updateReturnReasons(
|
updateReturnReasons(
|
||||||
data: OrderTypes.UpdateOrderReturnReasonWithSelectorDTO[]
|
data: OrderTypes.UpdateOrderReturnReasonWithSelectorDTO[]
|
||||||
): Promise<OrderTypes.OrderReturnReasonDTO[]>
|
): Promise<OrderTypes.OrderReturnReasonDTO[]>
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ type InjectedDependencies = {
|
|||||||
|
|
||||||
export default class OrderService<
|
export default class OrderService<
|
||||||
TEntity extends Order = Order
|
TEntity extends Order = Order
|
||||||
> extends ModulesSdkUtils.internalModuleServiceFactory<InjectedDependencies>(
|
> extends ModulesSdkUtils.MedusaInternalService<InjectedDependencies>(
|
||||||
Order
|
Order
|
||||||
)<TEntity> {
|
)<TEntity> {
|
||||||
protected readonly orderRepository_: RepositoryService<TEntity>
|
protected readonly orderRepository_: RepositoryService<TEntity>
|
||||||
|
|||||||
@@ -52,21 +52,21 @@ import PaymentProviderService from "./payment-provider"
|
|||||||
|
|
||||||
type InjectedDependencies = {
|
type InjectedDependencies = {
|
||||||
baseRepository: DAL.RepositoryService
|
baseRepository: DAL.RepositoryService
|
||||||
paymentService: ModulesSdkTypes.InternalModuleService<any>
|
paymentService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
captureService: ModulesSdkTypes.InternalModuleService<any>
|
captureService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
refundService: ModulesSdkTypes.InternalModuleService<any>
|
refundService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
paymentSessionService: ModulesSdkTypes.InternalModuleService<any>
|
paymentSessionService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
paymentCollectionService: ModulesSdkTypes.InternalModuleService<any>
|
paymentCollectionService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
paymentProviderService: PaymentProviderService
|
paymentProviderService: PaymentProviderService
|
||||||
}
|
}
|
||||||
|
|
||||||
const generateMethodForModels = [
|
const generateMethodForModels = {
|
||||||
PaymentCollection,
|
PaymentCollection,
|
||||||
Payment,
|
Payment,
|
||||||
PaymentSession,
|
PaymentSession,
|
||||||
Capture,
|
Capture,
|
||||||
Refund,
|
Refund,
|
||||||
]
|
}
|
||||||
|
|
||||||
export default class PaymentModuleService<
|
export default class PaymentModuleService<
|
||||||
TPaymentCollection extends PaymentCollection = PaymentCollection,
|
TPaymentCollection extends PaymentCollection = PaymentCollection,
|
||||||
@@ -75,8 +75,7 @@ export default class PaymentModuleService<
|
|||||||
TRefund extends Refund = Refund,
|
TRefund extends Refund = Refund,
|
||||||
TPaymentSession extends PaymentSession = PaymentSession
|
TPaymentSession extends PaymentSession = PaymentSession
|
||||||
>
|
>
|
||||||
extends ModulesSdkUtils.abstractModuleServiceFactory<
|
extends ModulesSdkUtils.MedusaService<
|
||||||
InjectedDependencies,
|
|
||||||
PaymentCollectionDTO,
|
PaymentCollectionDTO,
|
||||||
{
|
{
|
||||||
PaymentCollection: { dto: PaymentCollectionDTO }
|
PaymentCollection: { dto: PaymentCollectionDTO }
|
||||||
@@ -90,11 +89,11 @@ export default class PaymentModuleService<
|
|||||||
{
|
{
|
||||||
protected baseRepository_: DAL.RepositoryService
|
protected baseRepository_: DAL.RepositoryService
|
||||||
|
|
||||||
protected paymentService_: ModulesSdkTypes.InternalModuleService<TPayment>
|
protected paymentService_: ModulesSdkTypes.IMedusaInternalService<TPayment>
|
||||||
protected captureService_: ModulesSdkTypes.InternalModuleService<TCapture>
|
protected captureService_: ModulesSdkTypes.IMedusaInternalService<TCapture>
|
||||||
protected refundService_: ModulesSdkTypes.InternalModuleService<TRefund>
|
protected refundService_: ModulesSdkTypes.IMedusaInternalService<TRefund>
|
||||||
protected paymentSessionService_: ModulesSdkTypes.InternalModuleService<TPaymentSession>
|
protected paymentSessionService_: ModulesSdkTypes.IMedusaInternalService<TPaymentSession>
|
||||||
protected paymentCollectionService_: ModulesSdkTypes.InternalModuleService<TPaymentCollection>
|
protected paymentCollectionService_: ModulesSdkTypes.IMedusaInternalService<TPaymentCollection>
|
||||||
protected paymentProviderService_: PaymentProviderService
|
protected paymentProviderService_: PaymentProviderService
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@@ -126,6 +125,7 @@ export default class PaymentModuleService<
|
|||||||
return joinerConfig
|
return joinerConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
createPaymentCollections(
|
createPaymentCollections(
|
||||||
data: CreatePaymentCollectionDTO,
|
data: CreatePaymentCollectionDTO,
|
||||||
sharedContext?: Context
|
sharedContext?: Context
|
||||||
@@ -160,9 +160,10 @@ export default class PaymentModuleService<
|
|||||||
data: CreatePaymentCollectionDTO[],
|
data: CreatePaymentCollectionDTO[],
|
||||||
@MedusaContext() sharedContext?: Context
|
@MedusaContext() sharedContext?: Context
|
||||||
): Promise<PaymentCollection[]> {
|
): Promise<PaymentCollection[]> {
|
||||||
return this.paymentCollectionService_.create(data, sharedContext)
|
return await this.paymentCollectionService_.create(data, sharedContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
updatePaymentCollections(
|
updatePaymentCollections(
|
||||||
paymentCollectionId: string,
|
paymentCollectionId: string,
|
||||||
data: PaymentCollectionUpdatableFields,
|
data: PaymentCollectionUpdatableFields,
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ type InjectedDependencies = {
|
|||||||
|
|
||||||
export default class PriceListService<
|
export default class PriceListService<
|
||||||
TEntity extends PriceList = PriceList
|
TEntity extends PriceList = PriceList
|
||||||
> extends ModulesSdkUtils.internalModuleServiceFactory<InjectedDependencies>(
|
> extends ModulesSdkUtils.MedusaInternalService<InjectedDependencies>(
|
||||||
PriceList
|
PriceList
|
||||||
)<TEntity> {
|
)<TEntity> {
|
||||||
constructor(container: InjectedDependencies) {
|
constructor(container: InjectedDependencies) {
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ import {
|
|||||||
} from "@models"
|
} from "@models"
|
||||||
|
|
||||||
import { PriceListService, RuleTypeService } from "@services"
|
import { PriceListService, RuleTypeService } from "@services"
|
||||||
import { validatePriceListDates, eventBuilders } from "@utils"
|
import { eventBuilders, validatePriceListDates } from "@utils"
|
||||||
import { entityNameToLinkableKeysMap, joinerConfig } from "../joiner-config"
|
import { entityNameToLinkableKeysMap, joinerConfig } from "../joiner-config"
|
||||||
import { PriceListIdPrefix } from "../models/price-list"
|
import { PriceListIdPrefix } from "../models/price-list"
|
||||||
import { PriceSetIdPrefix } from "../models/price-set"
|
import { PriceSetIdPrefix } from "../models/price-set"
|
||||||
@@ -57,17 +57,17 @@ import { ServiceTypes } from "@types"
|
|||||||
type InjectedDependencies = {
|
type InjectedDependencies = {
|
||||||
baseRepository: DAL.RepositoryService
|
baseRepository: DAL.RepositoryService
|
||||||
pricingRepository: PricingRepositoryService
|
pricingRepository: PricingRepositoryService
|
||||||
priceSetService: ModulesSdkTypes.InternalModuleService<any>
|
priceSetService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
ruleTypeService: RuleTypeService<any>
|
ruleTypeService: RuleTypeService<any>
|
||||||
priceRuleService: ModulesSdkTypes.InternalModuleService<any>
|
priceRuleService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
priceSetRuleTypeService: ModulesSdkTypes.InternalModuleService<any>
|
priceSetRuleTypeService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
priceService: ModulesSdkTypes.InternalModuleService<any>
|
priceService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
priceListService: PriceListService<any>
|
priceListService: PriceListService<any>
|
||||||
priceListRuleService: ModulesSdkTypes.InternalModuleService<any>
|
priceListRuleService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
priceListRuleValueService: ModulesSdkTypes.InternalModuleService<any>
|
priceListRuleValueService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
}
|
}
|
||||||
|
|
||||||
const generateMethodForModels = [
|
const generateMethodForModels = {
|
||||||
PriceList,
|
PriceList,
|
||||||
PriceListRule,
|
PriceListRule,
|
||||||
PriceListRuleValue,
|
PriceListRuleValue,
|
||||||
@@ -75,7 +75,7 @@ const generateMethodForModels = [
|
|||||||
Price,
|
Price,
|
||||||
PriceSetRuleType,
|
PriceSetRuleType,
|
||||||
RuleType,
|
RuleType,
|
||||||
]
|
}
|
||||||
|
|
||||||
export default class PricingModuleService<
|
export default class PricingModuleService<
|
||||||
TPriceSet extends PriceSet = PriceSet,
|
TPriceSet extends PriceSet = PriceSet,
|
||||||
@@ -87,8 +87,7 @@ export default class PricingModuleService<
|
|||||||
TPriceListRule extends PriceListRule = PriceListRule,
|
TPriceListRule extends PriceListRule = PriceListRule,
|
||||||
TPriceListRuleValue extends PriceListRuleValue = PriceListRuleValue
|
TPriceListRuleValue extends PriceListRuleValue = PriceListRuleValue
|
||||||
>
|
>
|
||||||
extends ModulesSdkUtils.abstractModuleServiceFactory<
|
extends ModulesSdkUtils.MedusaService<
|
||||||
InjectedDependencies,
|
|
||||||
PricingTypes.PriceSetDTO,
|
PricingTypes.PriceSetDTO,
|
||||||
{
|
{
|
||||||
Price: { dto: PricingTypes.PriceDTO }
|
Price: { dto: PricingTypes.PriceDTO }
|
||||||
@@ -111,13 +110,13 @@ export default class PricingModuleService<
|
|||||||
protected baseRepository_: DAL.RepositoryService
|
protected baseRepository_: DAL.RepositoryService
|
||||||
protected readonly pricingRepository_: PricingRepositoryService
|
protected readonly pricingRepository_: PricingRepositoryService
|
||||||
protected readonly ruleTypeService_: RuleTypeService<TRuleType>
|
protected readonly ruleTypeService_: RuleTypeService<TRuleType>
|
||||||
protected readonly priceSetService_: ModulesSdkTypes.InternalModuleService<TPriceSet>
|
protected readonly priceSetService_: ModulesSdkTypes.IMedusaInternalService<TPriceSet>
|
||||||
protected readonly priceRuleService_: ModulesSdkTypes.InternalModuleService<TPriceRule>
|
protected readonly priceRuleService_: ModulesSdkTypes.IMedusaInternalService<TPriceRule>
|
||||||
protected readonly priceSetRuleTypeService_: ModulesSdkTypes.InternalModuleService<TPriceSetRuleType>
|
protected readonly priceSetRuleTypeService_: ModulesSdkTypes.IMedusaInternalService<TPriceSetRuleType>
|
||||||
protected readonly priceService_: ModulesSdkTypes.InternalModuleService<TPrice>
|
protected readonly priceService_: ModulesSdkTypes.IMedusaInternalService<TPrice>
|
||||||
protected readonly priceListService_: PriceListService<TPriceList>
|
protected readonly priceListService_: PriceListService<TPriceList>
|
||||||
protected readonly priceListRuleService_: ModulesSdkTypes.InternalModuleService<TPriceListRule>
|
protected readonly priceListRuleService_: ModulesSdkTypes.IMedusaInternalService<TPriceListRule>
|
||||||
protected readonly priceListRuleValueService_: ModulesSdkTypes.InternalModuleService<TPriceListRuleValue>
|
protected readonly priceListRuleValueService_: ModulesSdkTypes.IMedusaInternalService<TPriceListRuleValue>
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
{
|
{
|
||||||
@@ -641,6 +640,7 @@ export default class PricingModuleService<
|
|||||||
|
|
||||||
@InjectManager("baseRepository_")
|
@InjectManager("baseRepository_")
|
||||||
@EmitEvents()
|
@EmitEvents()
|
||||||
|
// @ts-ignore
|
||||||
async createPriceLists(
|
async createPriceLists(
|
||||||
data: PricingTypes.CreatePriceListDTO[],
|
data: PricingTypes.CreatePriceListDTO[],
|
||||||
@MedusaContext() sharedContext: Context = {}
|
@MedusaContext() sharedContext: Context = {}
|
||||||
@@ -653,6 +653,7 @@ export default class PricingModuleService<
|
|||||||
}
|
}
|
||||||
|
|
||||||
@InjectTransactionManager("baseRepository_")
|
@InjectTransactionManager("baseRepository_")
|
||||||
|
// @ts-ignore
|
||||||
async updatePriceLists(
|
async updatePriceLists(
|
||||||
data: PricingTypes.UpdatePriceListDTO[],
|
data: PricingTypes.UpdatePriceListDTO[],
|
||||||
@MedusaContext() sharedContext: Context = {}
|
@MedusaContext() sharedContext: Context = {}
|
||||||
@@ -1334,7 +1335,7 @@ export default class PricingModuleService<
|
|||||||
sharedContext
|
sharedContext
|
||||||
)
|
)
|
||||||
|
|
||||||
ruleTypeMap.set(ruleAttribute, ruleType)
|
ruleTypeMap.set(ruleAttribute, ruleType!)
|
||||||
}
|
}
|
||||||
|
|
||||||
const [priceListRule] = await this.priceListRuleService_.create(
|
const [priceListRule] = await this.priceListRuleService_.create(
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ type InjectedDependencies = {
|
|||||||
|
|
||||||
export default class RuleTypeService<
|
export default class RuleTypeService<
|
||||||
TEntity extends RuleType = RuleType
|
TEntity extends RuleType = RuleType
|
||||||
> extends ModulesSdkUtils.internalModuleServiceFactory<InjectedDependencies>(
|
> extends ModulesSdkUtils.MedusaInternalService<InjectedDependencies>(
|
||||||
RuleType
|
RuleType
|
||||||
)<TEntity> {
|
)<TEntity> {
|
||||||
protected readonly ruleTypeRepository_: DAL.RepositoryService<TEntity>
|
protected readonly ruleTypeRepository_: DAL.RepositoryService<TEntity>
|
||||||
|
|||||||
@@ -58,25 +58,25 @@ import { entityNameToLinkableKeysMap, joinerConfig } from "./../joiner-config"
|
|||||||
type InjectedDependencies = {
|
type InjectedDependencies = {
|
||||||
baseRepository: DAL.RepositoryService
|
baseRepository: DAL.RepositoryService
|
||||||
productService: ProductService<any>
|
productService: ProductService<any>
|
||||||
productVariantService: ModulesSdkTypes.InternalModuleService<any, any>
|
productVariantService: ModulesSdkTypes.IMedusaInternalService<any, any>
|
||||||
productTagService: ModulesSdkTypes.InternalModuleService<any>
|
productTagService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
productCategoryService: ProductCategoryService<any>
|
productCategoryService: ProductCategoryService<any>
|
||||||
productCollectionService: ModulesSdkTypes.InternalModuleService<any>
|
productCollectionService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
productImageService: ModulesSdkTypes.InternalModuleService<any>
|
productImageService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
productTypeService: ModulesSdkTypes.InternalModuleService<any>
|
productTypeService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
productOptionService: ModulesSdkTypes.InternalModuleService<any>
|
productOptionService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
productOptionValueService: ModulesSdkTypes.InternalModuleService<any>
|
productOptionValueService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
eventBusModuleService?: IEventBusModuleService
|
eventBusModuleService?: IEventBusModuleService
|
||||||
}
|
}
|
||||||
|
|
||||||
const generateMethodForModels = [
|
const generateMethodForModels = {
|
||||||
{ model: ProductCategory, singular: "Category", plural: "Categories" },
|
ProductCategory: { singular: "Category", plural: "Categories" },
|
||||||
{ model: ProductCollection, singular: "Collection", plural: "Collections" },
|
ProductCollection: { singular: "Collection", plural: "Collections" },
|
||||||
{ model: ProductOption, singular: "Option", plural: "Options" },
|
ProductOption: { singular: "Option", plural: "Options" },
|
||||||
{ model: ProductTag, singular: "Tag", plural: "Tags" },
|
ProductTag: { singular: "Tag", plural: "Tags" },
|
||||||
{ model: ProductType, singular: "Type", plural: "Types" },
|
ProductType: { singular: "Type", plural: "Types" },
|
||||||
{ model: ProductVariant, singular: "Variant", plural: "Variants" },
|
ProductVariant: { singular: "Variant", plural: "Variants" },
|
||||||
]
|
}
|
||||||
|
|
||||||
export default class ProductModuleService<
|
export default class ProductModuleService<
|
||||||
TProduct extends Product = Product,
|
TProduct extends Product = Product,
|
||||||
@@ -89,8 +89,7 @@ export default class ProductModuleService<
|
|||||||
TProductOption extends ProductOption = ProductOption,
|
TProductOption extends ProductOption = ProductOption,
|
||||||
TProductOptionValue extends ProductOptionValue = ProductOptionValue
|
TProductOptionValue extends ProductOptionValue = ProductOptionValue
|
||||||
>
|
>
|
||||||
extends ModulesSdkUtils.abstractModuleServiceFactory<
|
extends ModulesSdkUtils.MedusaService<
|
||||||
InjectedDependencies,
|
|
||||||
ProductTypes.ProductDTO,
|
ProductTypes.ProductDTO,
|
||||||
{
|
{
|
||||||
ProductCategory: {
|
ProductCategory: {
|
||||||
@@ -130,21 +129,21 @@ export default class ProductModuleService<
|
|||||||
protected baseRepository_: DAL.RepositoryService
|
protected baseRepository_: DAL.RepositoryService
|
||||||
protected readonly productService_: ProductService<TProduct>
|
protected readonly productService_: ProductService<TProduct>
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
protected readonly productVariantService_: ModulesSdkTypes.InternalModuleService<TProductVariant>
|
protected readonly productVariantService_: ModulesSdkTypes.IMedusaInternalService<TProductVariant>
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
protected readonly productCategoryService_: ProductCategoryService<TProductCategory>
|
protected readonly productCategoryService_: ProductCategoryService<TProductCategory>
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
protected readonly productTagService_: ModulesSdkTypes.InternalModuleService<TProductTag>
|
protected readonly productTagService_: ModulesSdkTypes.IMedusaInternalService<TProductTag>
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
protected readonly productCollectionService_: ModulesSdkTypes.InternalModuleService<TProductCollection>
|
protected readonly productCollectionService_: ModulesSdkTypes.IMedusaInternalService<TProductCollection>
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
protected readonly productImageService_: ModulesSdkTypes.InternalModuleService<TProductImage>
|
protected readonly productImageService_: ModulesSdkTypes.IMedusaInternalService<TProductImage>
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
protected readonly productTypeService_: ModulesSdkTypes.InternalModuleService<TProductType>
|
protected readonly productTypeService_: ModulesSdkTypes.IMedusaInternalService<TProductType>
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
protected readonly productOptionService_: ModulesSdkTypes.InternalModuleService<TProductOption>
|
protected readonly productOptionService_: ModulesSdkTypes.IMedusaInternalService<TProductOption>
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
protected readonly productOptionValueService_: ModulesSdkTypes.InternalModuleService<TProductOptionValue>
|
protected readonly productOptionValueService_: ModulesSdkTypes.IMedusaInternalService<TProductOptionValue>
|
||||||
protected readonly eventBusModuleService_?: IEventBusModuleService
|
protected readonly eventBusModuleService_?: IEventBusModuleService
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@@ -185,6 +184,7 @@ export default class ProductModuleService<
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Add options validation, among other things
|
// TODO: Add options validation, among other things
|
||||||
|
// @ts-ignore
|
||||||
createVariants(
|
createVariants(
|
||||||
data: ProductTypes.CreateProductVariantDTO[],
|
data: ProductTypes.CreateProductVariantDTO[],
|
||||||
sharedContext?: Context
|
sharedContext?: Context
|
||||||
@@ -299,6 +299,7 @@ export default class ProductModuleService<
|
|||||||
return Array.isArray(data) ? allVariants : allVariants[0]
|
return Array.isArray(data) ? allVariants : allVariants[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
updateVariants(
|
updateVariants(
|
||||||
id: string,
|
id: string,
|
||||||
data: ProductTypes.UpdateProductVariantDTO,
|
data: ProductTypes.UpdateProductVariantDTO,
|
||||||
@@ -413,6 +414,7 @@ export default class ProductModuleService<
|
|||||||
return productVariants
|
return productVariants
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
createTags(
|
createTags(
|
||||||
data: ProductTypes.CreateProductTagDTO[],
|
data: ProductTypes.CreateProductTagDTO[],
|
||||||
sharedContext?: Context
|
sharedContext?: Context
|
||||||
@@ -491,6 +493,7 @@ export default class ProductModuleService<
|
|||||||
return Array.isArray(data) ? allTags : allTags[0]
|
return Array.isArray(data) ? allTags : allTags[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
updateTags(
|
updateTags(
|
||||||
id: string,
|
id: string,
|
||||||
data: ProductTypes.UpdateProductTagDTO,
|
data: ProductTypes.UpdateProductTagDTO,
|
||||||
@@ -544,6 +547,7 @@ export default class ProductModuleService<
|
|||||||
return isString(idOrSelector) ? updatedTags[0] : updatedTags
|
return isString(idOrSelector) ? updatedTags[0] : updatedTags
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
createTypes(
|
createTypes(
|
||||||
data: ProductTypes.CreateProductTypeDTO[],
|
data: ProductTypes.CreateProductTypeDTO[],
|
||||||
sharedContext?: Context
|
sharedContext?: Context
|
||||||
@@ -611,6 +615,7 @@ export default class ProductModuleService<
|
|||||||
return Array.isArray(data) ? allTypes : allTypes[0]
|
return Array.isArray(data) ? allTypes : allTypes[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
updateTypes(
|
updateTypes(
|
||||||
id: string,
|
id: string,
|
||||||
data: ProductTypes.UpdateProductTypeDTO,
|
data: ProductTypes.UpdateProductTypeDTO,
|
||||||
@@ -658,6 +663,7 @@ export default class ProductModuleService<
|
|||||||
return isString(idOrSelector) ? updatedTypes[0] : updatedTypes
|
return isString(idOrSelector) ? updatedTypes[0] : updatedTypes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
createOptions(
|
createOptions(
|
||||||
data: ProductTypes.CreateProductOptionDTO[],
|
data: ProductTypes.CreateProductOptionDTO[],
|
||||||
sharedContext?: Context
|
sharedContext?: Context
|
||||||
@@ -754,6 +760,7 @@ export default class ProductModuleService<
|
|||||||
return Array.isArray(data) ? allOptions : allOptions[0]
|
return Array.isArray(data) ? allOptions : allOptions[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
updateOptions(
|
updateOptions(
|
||||||
id: string,
|
id: string,
|
||||||
data: ProductTypes.UpdateProductOptionDTO,
|
data: ProductTypes.UpdateProductOptionDTO,
|
||||||
@@ -870,6 +877,7 @@ export default class ProductModuleService<
|
|||||||
return productOptions
|
return productOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
createCollections(
|
createCollections(
|
||||||
data: ProductTypes.CreateProductCollectionDTO[],
|
data: ProductTypes.CreateProductCollectionDTO[],
|
||||||
sharedContext?: Context
|
sharedContext?: Context
|
||||||
@@ -989,6 +997,7 @@ export default class ProductModuleService<
|
|||||||
return Array.isArray(data) ? allCollections : allCollections[0]
|
return Array.isArray(data) ? allCollections : allCollections[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
updateCollections(
|
updateCollections(
|
||||||
id: string,
|
id: string,
|
||||||
data: ProductTypes.UpdateProductCollectionDTO,
|
data: ProductTypes.UpdateProductCollectionDTO,
|
||||||
@@ -1115,6 +1124,7 @@ export default class ProductModuleService<
|
|||||||
return collections
|
return collections
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
createCategories(
|
createCategories(
|
||||||
data: ProductTypes.CreateProductCategoryDTO[],
|
data: ProductTypes.CreateProductCategoryDTO[],
|
||||||
sharedContext?: Context
|
sharedContext?: Context
|
||||||
@@ -1218,6 +1228,7 @@ export default class ProductModuleService<
|
|||||||
return Array.isArray(data) ? result : result[0]
|
return Array.isArray(data) ? result : result[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
updateCategories(
|
updateCategories(
|
||||||
id: string,
|
id: string,
|
||||||
data: ProductTypes.UpdateProductCategoryDTO,
|
data: ProductTypes.UpdateProductCategoryDTO,
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
import {
|
import {
|
||||||
Context,
|
Context,
|
||||||
DAL,
|
DAL,
|
||||||
|
FilterableProductProps,
|
||||||
FindConfig,
|
FindConfig,
|
||||||
ProductTypes,
|
ProductTypes,
|
||||||
BaseFilterable,
|
|
||||||
FilterableProductProps,
|
|
||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
import { InjectManager, MedusaContext, ModulesSdkUtils } from "@medusajs/utils"
|
import { InjectManager, MedusaContext, ModulesSdkUtils } from "@medusajs/utils"
|
||||||
import { Product } from "@models"
|
import { Product } from "@models"
|
||||||
@@ -21,7 +20,7 @@ type NormalizedFilterableProductProps = ProductTypes.FilterableProductProps & {
|
|||||||
|
|
||||||
export default class ProductService<
|
export default class ProductService<
|
||||||
TEntity extends Product = Product
|
TEntity extends Product = Product
|
||||||
> extends ModulesSdkUtils.internalModuleServiceFactory<InjectedDependencies>(
|
> extends ModulesSdkUtils.MedusaInternalService<InjectedDependencies>(
|
||||||
Product
|
Product
|
||||||
)<TEntity> {
|
)<TEntity> {
|
||||||
protected readonly productRepository_: DAL.RepositoryService<TEntity>
|
protected readonly productRepository_: DAL.RepositoryService<TEntity>
|
||||||
|
|||||||
@@ -10,20 +10,20 @@ import {
|
|||||||
import {
|
import {
|
||||||
ApplicationMethodAllocation,
|
ApplicationMethodAllocation,
|
||||||
ApplicationMethodTargetType,
|
ApplicationMethodTargetType,
|
||||||
|
arrayDifference,
|
||||||
CampaignBudgetType,
|
CampaignBudgetType,
|
||||||
ComputedActions,
|
ComputedActions,
|
||||||
|
deduplicate,
|
||||||
InjectManager,
|
InjectManager,
|
||||||
InjectTransactionManager,
|
InjectTransactionManager,
|
||||||
|
isDefined,
|
||||||
|
isPresent,
|
||||||
|
isString,
|
||||||
MathBN,
|
MathBN,
|
||||||
MedusaContext,
|
MedusaContext,
|
||||||
MedusaError,
|
MedusaError,
|
||||||
ModulesSdkUtils,
|
ModulesSdkUtils,
|
||||||
PromotionType,
|
PromotionType,
|
||||||
arrayDifference,
|
|
||||||
deduplicate,
|
|
||||||
isDefined,
|
|
||||||
isPresent,
|
|
||||||
isString,
|
|
||||||
transformPropertiesToBigNumber,
|
transformPropertiesToBigNumber,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import {
|
import {
|
||||||
@@ -47,9 +47,9 @@ import {
|
|||||||
UpdatePromotionDTO,
|
UpdatePromotionDTO,
|
||||||
} from "@types"
|
} from "@types"
|
||||||
import {
|
import {
|
||||||
ComputeActionUtils,
|
|
||||||
allowedAllocationForQuantity,
|
allowedAllocationForQuantity,
|
||||||
areRulesValidForContext,
|
areRulesValidForContext,
|
||||||
|
ComputeActionUtils,
|
||||||
validateApplicationMethodAttributes,
|
validateApplicationMethodAttributes,
|
||||||
validatePromotionRuleAttributes,
|
validatePromotionRuleAttributes,
|
||||||
} from "@utils"
|
} from "@utils"
|
||||||
@@ -58,21 +58,21 @@ import { CreatePromotionRuleValueDTO } from "../types/promotion-rule-value"
|
|||||||
|
|
||||||
type InjectedDependencies = {
|
type InjectedDependencies = {
|
||||||
baseRepository: DAL.RepositoryService
|
baseRepository: DAL.RepositoryService
|
||||||
promotionService: ModulesSdkTypes.InternalModuleService<any>
|
promotionService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
applicationMethodService: ModulesSdkTypes.InternalModuleService<any>
|
applicationMethodService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
promotionRuleService: ModulesSdkTypes.InternalModuleService<any>
|
promotionRuleService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
promotionRuleValueService: ModulesSdkTypes.InternalModuleService<any>
|
promotionRuleValueService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
campaignService: ModulesSdkTypes.InternalModuleService<any>
|
campaignService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
campaignBudgetService: ModulesSdkTypes.InternalModuleService<any>
|
campaignBudgetService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
}
|
}
|
||||||
|
|
||||||
const generateMethodForModels = [
|
const generateMethodForModels = {
|
||||||
ApplicationMethod,
|
ApplicationMethod,
|
||||||
Campaign,
|
Campaign,
|
||||||
CampaignBudget,
|
CampaignBudget,
|
||||||
PromotionRule,
|
PromotionRule,
|
||||||
PromotionRuleValue,
|
PromotionRuleValue,
|
||||||
]
|
}
|
||||||
|
|
||||||
export default class PromotionModuleService<
|
export default class PromotionModuleService<
|
||||||
TApplicationMethod extends ApplicationMethod = ApplicationMethod,
|
TApplicationMethod extends ApplicationMethod = ApplicationMethod,
|
||||||
@@ -82,8 +82,7 @@ export default class PromotionModuleService<
|
|||||||
TCampaign extends Campaign = Campaign,
|
TCampaign extends Campaign = Campaign,
|
||||||
TCampaignBudget extends CampaignBudget = CampaignBudget
|
TCampaignBudget extends CampaignBudget = CampaignBudget
|
||||||
>
|
>
|
||||||
extends ModulesSdkUtils.abstractModuleServiceFactory<
|
extends ModulesSdkUtils.MedusaService<
|
||||||
InjectedDependencies,
|
|
||||||
PromotionTypes.PromotionDTO,
|
PromotionTypes.PromotionDTO,
|
||||||
{
|
{
|
||||||
ApplicationMethod: { dto: PromotionTypes.ApplicationMethodDTO }
|
ApplicationMethod: { dto: PromotionTypes.ApplicationMethodDTO }
|
||||||
@@ -96,12 +95,12 @@ export default class PromotionModuleService<
|
|||||||
implements PromotionTypes.IPromotionModuleService
|
implements PromotionTypes.IPromotionModuleService
|
||||||
{
|
{
|
||||||
protected baseRepository_: DAL.RepositoryService
|
protected baseRepository_: DAL.RepositoryService
|
||||||
protected promotionService_: ModulesSdkTypes.InternalModuleService<TPromotion>
|
protected promotionService_: ModulesSdkTypes.IMedusaInternalService<TPromotion>
|
||||||
protected applicationMethodService_: ModulesSdkTypes.InternalModuleService<TApplicationMethod>
|
protected applicationMethodService_: ModulesSdkTypes.IMedusaInternalService<TApplicationMethod>
|
||||||
protected promotionRuleService_: ModulesSdkTypes.InternalModuleService<TPromotionRule>
|
protected promotionRuleService_: ModulesSdkTypes.IMedusaInternalService<TPromotionRule>
|
||||||
protected promotionRuleValueService_: ModulesSdkTypes.InternalModuleService<TPromotionRuleValue>
|
protected promotionRuleValueService_: ModulesSdkTypes.IMedusaInternalService<TPromotionRuleValue>
|
||||||
protected campaignService_: ModulesSdkTypes.InternalModuleService<TCampaign>
|
protected campaignService_: ModulesSdkTypes.IMedusaInternalService<TCampaign>
|
||||||
protected campaignBudgetService_: ModulesSdkTypes.InternalModuleService<TCampaignBudget>
|
protected campaignBudgetService_: ModulesSdkTypes.IMedusaInternalService<TCampaignBudget>
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
{
|
{
|
||||||
@@ -839,6 +838,7 @@ export default class PromotionModuleService<
|
|||||||
}
|
}
|
||||||
|
|
||||||
@InjectManager("baseRepository_")
|
@InjectManager("baseRepository_")
|
||||||
|
// @ts-ignore
|
||||||
async updatePromotionRules(
|
async updatePromotionRules(
|
||||||
data: PromotionTypes.UpdatePromotionRuleDTO[],
|
data: PromotionTypes.UpdatePromotionRuleDTO[],
|
||||||
@MedusaContext() sharedContext: Context = {}
|
@MedusaContext() sharedContext: Context = {}
|
||||||
@@ -848,7 +848,7 @@ export default class PromotionModuleService<
|
|||||||
sharedContext
|
sharedContext
|
||||||
)
|
)
|
||||||
|
|
||||||
return this.listPromotionRules(
|
return await this.listPromotionRules(
|
||||||
{ id: updatedPromotionRules.map((r) => r.id) },
|
{ id: updatedPromotionRules.map((r) => r.id) },
|
||||||
{ relations: ["values"] },
|
{ relations: ["values"] },
|
||||||
sharedContext
|
sharedContext
|
||||||
@@ -1153,6 +1153,7 @@ export default class PromotionModuleService<
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
async createCampaigns(
|
async createCampaigns(
|
||||||
data: PromotionTypes.CreateCampaignDTO,
|
data: PromotionTypes.CreateCampaignDTO,
|
||||||
sharedContext?: Context
|
sharedContext?: Context
|
||||||
@@ -1262,6 +1263,7 @@ export default class PromotionModuleService<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
async updateCampaigns(
|
async updateCampaigns(
|
||||||
data: PromotionTypes.UpdateCampaignDTO,
|
data: PromotionTypes.UpdateCampaignDTO,
|
||||||
sharedContext?: Context
|
sharedContext?: Context
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ export default async ({ container }: LoaderOptions): Promise<void> => {
|
|||||||
// TODO: Add default logger to the container when running tests
|
// TODO: Add default logger to the container when running tests
|
||||||
const logger =
|
const logger =
|
||||||
container.resolve<Logger>(ContainerRegistrationKeys.LOGGER) ?? console
|
container.resolve<Logger>(ContainerRegistrationKeys.LOGGER) ?? console
|
||||||
const countryService_: ModulesSdkTypes.InternalModuleService<Country> =
|
const countryService_: ModulesSdkTypes.IMedusaInternalService<Country> =
|
||||||
container.resolve("countryService")
|
container.resolve("countryService")
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -32,18 +32,17 @@ import { entityNameToLinkableKeysMap, joinerConfig } from "../joiner-config"
|
|||||||
|
|
||||||
type InjectedDependencies = {
|
type InjectedDependencies = {
|
||||||
baseRepository: DAL.RepositoryService
|
baseRepository: DAL.RepositoryService
|
||||||
regionService: ModulesSdkTypes.InternalModuleService<any>
|
regionService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
countryService: ModulesSdkTypes.InternalModuleService<any>
|
countryService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
}
|
}
|
||||||
|
|
||||||
const generateMethodForModels = [Country]
|
const generateMethodForModels = { Country }
|
||||||
|
|
||||||
export default class RegionModuleService<
|
export default class RegionModuleService<
|
||||||
TRegion extends Region = Region,
|
TRegion extends Region = Region,
|
||||||
TCountry extends Country = Country
|
TCountry extends Country = Country
|
||||||
>
|
>
|
||||||
extends ModulesSdkUtils.abstractModuleServiceFactory<
|
extends ModulesSdkUtils.MedusaService<
|
||||||
InjectedDependencies,
|
|
||||||
RegionDTO,
|
RegionDTO,
|
||||||
{
|
{
|
||||||
Country: {
|
Country: {
|
||||||
@@ -54,8 +53,8 @@ export default class RegionModuleService<
|
|||||||
implements IRegionModuleService
|
implements IRegionModuleService
|
||||||
{
|
{
|
||||||
protected baseRepository_: DAL.RepositoryService
|
protected baseRepository_: DAL.RepositoryService
|
||||||
protected readonly regionService_: ModulesSdkTypes.InternalModuleService<TRegion>
|
protected readonly regionService_: ModulesSdkTypes.IMedusaInternalService<TRegion>
|
||||||
protected readonly countryService_: ModulesSdkTypes.InternalModuleService<TCountry>
|
protected readonly countryService_: ModulesSdkTypes.IMedusaInternalService<TCountry>
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
{ baseRepository, regionService, countryService }: InjectedDependencies,
|
{ baseRepository, regionService, countryService }: InjectedDependencies,
|
||||||
|
|||||||
@@ -27,21 +27,21 @@ import { entityNameToLinkableKeysMap, joinerConfig } from "../joiner-config"
|
|||||||
|
|
||||||
type InjectedDependencies = {
|
type InjectedDependencies = {
|
||||||
baseRepository: DAL.RepositoryService
|
baseRepository: DAL.RepositoryService
|
||||||
salesChannelService: ModulesSdkTypes.InternalModuleService<any>
|
salesChannelService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class SalesChannelModuleService<
|
export default class SalesChannelModuleService<
|
||||||
TEntity extends SalesChannel = SalesChannel
|
TEntity extends SalesChannel = SalesChannel
|
||||||
>
|
>
|
||||||
extends ModulesSdkUtils.abstractModuleServiceFactory<
|
extends ModulesSdkUtils.MedusaService<SalesChannelDTO>(
|
||||||
InjectedDependencies,
|
SalesChannel,
|
||||||
SalesChannelDTO,
|
{},
|
||||||
{}
|
entityNameToLinkableKeysMap
|
||||||
>(SalesChannel, [], entityNameToLinkableKeysMap)
|
)
|
||||||
implements ISalesChannelModuleService
|
implements ISalesChannelModuleService
|
||||||
{
|
{
|
||||||
protected baseRepository_: DAL.RepositoryService
|
protected baseRepository_: DAL.RepositoryService
|
||||||
protected readonly salesChannelService_: ModulesSdkTypes.InternalModuleService<TEntity>
|
protected readonly salesChannelService_: ModulesSdkTypes.IMedusaInternalService<TEntity>
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
{ baseRepository, salesChannelService }: InjectedDependencies,
|
{ baseRepository, salesChannelService }: InjectedDependencies,
|
||||||
|
|||||||
@@ -2,47 +2,45 @@ import { InternalModuleDeclaration } from "@medusajs/modules-sdk"
|
|||||||
import {
|
import {
|
||||||
Context,
|
Context,
|
||||||
CreateStockLocationInput,
|
CreateStockLocationInput,
|
||||||
|
DAL,
|
||||||
|
FilterableStockLocationProps,
|
||||||
IEventBusService,
|
IEventBusService,
|
||||||
|
IStockLocationServiceNext,
|
||||||
ModuleJoinerConfig,
|
ModuleJoinerConfig,
|
||||||
|
ModulesSdkTypes,
|
||||||
StockLocationAddressInput,
|
StockLocationAddressInput,
|
||||||
StockLocationTypes,
|
StockLocationTypes,
|
||||||
ModulesSdkTypes,
|
UpdateStockLocationNextInput,
|
||||||
DAL,
|
UpsertStockLocationInput,
|
||||||
IStockLocationServiceNext,
|
|
||||||
FilterableStockLocationProps,
|
|
||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
InjectManager,
|
InjectManager,
|
||||||
InjectTransactionManager,
|
InjectTransactionManager,
|
||||||
|
isString,
|
||||||
MedusaContext,
|
MedusaContext,
|
||||||
ModulesSdkUtils,
|
ModulesSdkUtils,
|
||||||
isString,
|
promiseAll,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import { entityNameToLinkableKeysMap, joinerConfig } from "../joiner-config"
|
import { entityNameToLinkableKeysMap, joinerConfig } from "../joiner-config"
|
||||||
import { StockLocation, StockLocationAddress } from "../models"
|
import { StockLocation, StockLocationAddress } from "../models"
|
||||||
import { UpdateStockLocationNextInput } from "@medusajs/types"
|
|
||||||
import { UpsertStockLocationInput } from "@medusajs/types"
|
|
||||||
import { promiseAll } from "@medusajs/utils"
|
|
||||||
|
|
||||||
type InjectedDependencies = {
|
type InjectedDependencies = {
|
||||||
eventBusModuleService: IEventBusService
|
eventBusModuleService: IEventBusService
|
||||||
baseRepository: DAL.RepositoryService
|
baseRepository: DAL.RepositoryService
|
||||||
stockLocationService: ModulesSdkTypes.InternalModuleService<any>
|
stockLocationService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
stockLocationAddressService: ModulesSdkTypes.InternalModuleService<any>
|
stockLocationAddressService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
}
|
}
|
||||||
|
|
||||||
const generateMethodForModels = [StockLocationAddress]
|
const generateMethodForModels = { StockLocationAddress }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service for managing stock locations.
|
* Service for managing stock locations.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export default class StockLocationModuleService<
|
export default class StockLocationModuleService<
|
||||||
TEntity extends StockLocation = StockLocation,
|
TEntity extends StockLocation = StockLocation,
|
||||||
TStockLocationAddress extends StockLocationAddress = StockLocationAddress
|
TStockLocationAddress extends StockLocationAddress = StockLocationAddress
|
||||||
>
|
>
|
||||||
extends ModulesSdkUtils.abstractModuleServiceFactory<
|
extends ModulesSdkUtils.MedusaService<
|
||||||
InjectedDependencies,
|
|
||||||
StockLocationTypes.StockLocationDTO,
|
StockLocationTypes.StockLocationDTO,
|
||||||
{
|
{
|
||||||
StockLocation: { dto: StockLocationTypes.StockLocationDTO }
|
StockLocation: { dto: StockLocationTypes.StockLocationDTO }
|
||||||
@@ -53,8 +51,8 @@ export default class StockLocationModuleService<
|
|||||||
{
|
{
|
||||||
protected readonly eventBusModuleService_: IEventBusService
|
protected readonly eventBusModuleService_: IEventBusService
|
||||||
protected baseRepository_: DAL.RepositoryService
|
protected baseRepository_: DAL.RepositoryService
|
||||||
protected readonly stockLocationService_: ModulesSdkTypes.InternalModuleService<TEntity>
|
protected readonly stockLocationService_: ModulesSdkTypes.IMedusaInternalService<TEntity>
|
||||||
protected readonly stockLocationAddressService_: ModulesSdkTypes.InternalModuleService<TStockLocationAddress>
|
protected readonly stockLocationAddressService_: ModulesSdkTypes.IMedusaInternalService<TStockLocationAddress>
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
import {
|
import {
|
||||||
|
Context,
|
||||||
DAL,
|
DAL,
|
||||||
InternalModuleDeclaration,
|
InternalModuleDeclaration,
|
||||||
|
IStoreModuleService,
|
||||||
ModuleJoinerConfig,
|
ModuleJoinerConfig,
|
||||||
ModulesSdkTypes,
|
ModulesSdkTypes,
|
||||||
IStoreModuleService,
|
|
||||||
StoreTypes,
|
StoreTypes,
|
||||||
Context,
|
|
||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
InjectManager,
|
InjectManager,
|
||||||
InjectTransactionManager,
|
InjectTransactionManager,
|
||||||
|
isString,
|
||||||
MedusaContext,
|
MedusaContext,
|
||||||
MedusaError,
|
MedusaError,
|
||||||
ModulesSdkUtils,
|
ModulesSdkUtils,
|
||||||
isString,
|
|
||||||
promiseAll,
|
promiseAll,
|
||||||
removeUndefined,
|
removeUndefined,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
@@ -22,16 +22,15 @@ import { Store } from "@models"
|
|||||||
import { entityNameToLinkableKeysMap, joinerConfig } from "../joiner-config"
|
import { entityNameToLinkableKeysMap, joinerConfig } from "../joiner-config"
|
||||||
import { UpdateStoreInput } from "@types"
|
import { UpdateStoreInput } from "@types"
|
||||||
|
|
||||||
const generateMethodForModels = []
|
const generateMethodForModels = {}
|
||||||
|
|
||||||
type InjectedDependencies = {
|
type InjectedDependencies = {
|
||||||
baseRepository: DAL.RepositoryService
|
baseRepository: DAL.RepositoryService
|
||||||
storeService: ModulesSdkTypes.InternalModuleService<any>
|
storeService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class StoreModuleService<TEntity extends Store = Store>
|
export default class StoreModuleService<TEntity extends Store = Store>
|
||||||
extends ModulesSdkUtils.abstractModuleServiceFactory<
|
extends ModulesSdkUtils.MedusaService<
|
||||||
InjectedDependencies,
|
|
||||||
StoreTypes.StoreDTO,
|
StoreTypes.StoreDTO,
|
||||||
{
|
{
|
||||||
Store: { dto: StoreTypes.StoreDTO }
|
Store: { dto: StoreTypes.StoreDTO }
|
||||||
@@ -40,7 +39,7 @@ export default class StoreModuleService<TEntity extends Store = Store>
|
|||||||
implements IStoreModuleService
|
implements IStoreModuleService
|
||||||
{
|
{
|
||||||
protected baseRepository_: DAL.RepositoryService
|
protected baseRepository_: DAL.RepositoryService
|
||||||
protected readonly storeService_: ModulesSdkTypes.InternalModuleService<TEntity>
|
protected readonly storeService_: ModulesSdkTypes.IMedusaInternalService<TEntity>
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
{ baseRepository, storeService }: InjectedDependencies,
|
{ baseRepository, storeService }: InjectedDependencies,
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import {
|
import {
|
||||||
Context,
|
Context,
|
||||||
DAL,
|
DAL,
|
||||||
|
InternalModuleDeclaration,
|
||||||
ITaxModuleService,
|
ITaxModuleService,
|
||||||
ITaxProvider,
|
ITaxProvider,
|
||||||
InternalModuleDeclaration,
|
|
||||||
ModuleJoinerConfig,
|
ModuleJoinerConfig,
|
||||||
ModulesSdkTypes,
|
ModulesSdkTypes,
|
||||||
TaxRegionDTO,
|
TaxRegionDTO,
|
||||||
@@ -12,11 +12,11 @@ import {
|
|||||||
import {
|
import {
|
||||||
InjectManager,
|
InjectManager,
|
||||||
InjectTransactionManager,
|
InjectTransactionManager,
|
||||||
|
isDefined,
|
||||||
|
isString,
|
||||||
MedusaContext,
|
MedusaContext,
|
||||||
MedusaError,
|
MedusaError,
|
||||||
ModulesSdkUtils,
|
ModulesSdkUtils,
|
||||||
isDefined,
|
|
||||||
isString,
|
|
||||||
promiseAll,
|
promiseAll,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import { TaxProvider, TaxRate, TaxRateRule, TaxRegion } from "@models"
|
import { TaxProvider, TaxRate, TaxRateRule, TaxRegion } from "@models"
|
||||||
@@ -24,14 +24,14 @@ import { entityNameToLinkableKeysMap, joinerConfig } from "../joiner-config"
|
|||||||
|
|
||||||
type InjectedDependencies = {
|
type InjectedDependencies = {
|
||||||
baseRepository: DAL.RepositoryService
|
baseRepository: DAL.RepositoryService
|
||||||
taxRateService: ModulesSdkTypes.InternalModuleService<any>
|
taxRateService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
taxRegionService: ModulesSdkTypes.InternalModuleService<any>
|
taxRegionService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
taxRateRuleService: ModulesSdkTypes.InternalModuleService<any>
|
taxRateRuleService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
taxProviderService: ModulesSdkTypes.InternalModuleService<any>
|
taxProviderService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
[key: `tp_${string}`]: ITaxProvider
|
[key: `tp_${string}`]: ITaxProvider
|
||||||
}
|
}
|
||||||
|
|
||||||
const generateForModels = [TaxRegion, TaxRateRule, TaxProvider]
|
const generateForModels = { TaxRegion, TaxRateRule, TaxProvider }
|
||||||
|
|
||||||
type ItemWithRates = {
|
type ItemWithRates = {
|
||||||
rates: TaxRate[]
|
rates: TaxRate[]
|
||||||
@@ -44,8 +44,7 @@ export default class TaxModuleService<
|
|||||||
TTaxRateRule extends TaxRateRule = TaxRateRule,
|
TTaxRateRule extends TaxRateRule = TaxRateRule,
|
||||||
TTaxProvider extends TaxProvider = TaxProvider
|
TTaxProvider extends TaxProvider = TaxProvider
|
||||||
>
|
>
|
||||||
extends ModulesSdkUtils.abstractModuleServiceFactory<
|
extends ModulesSdkUtils.MedusaService<
|
||||||
InjectedDependencies,
|
|
||||||
TaxTypes.TaxRateDTO,
|
TaxTypes.TaxRateDTO,
|
||||||
{
|
{
|
||||||
TaxRegion: { dto: TaxTypes.TaxRegionDTO }
|
TaxRegion: { dto: TaxTypes.TaxRegionDTO }
|
||||||
@@ -57,10 +56,10 @@ export default class TaxModuleService<
|
|||||||
{
|
{
|
||||||
protected readonly container_: InjectedDependencies
|
protected readonly container_: InjectedDependencies
|
||||||
protected baseRepository_: DAL.RepositoryService
|
protected baseRepository_: DAL.RepositoryService
|
||||||
protected taxRateService_: ModulesSdkTypes.InternalModuleService<TTaxRate>
|
protected taxRateService_: ModulesSdkTypes.IMedusaInternalService<TTaxRate>
|
||||||
protected taxRegionService_: ModulesSdkTypes.InternalModuleService<TTaxRegion>
|
protected taxRegionService_: ModulesSdkTypes.IMedusaInternalService<TTaxRegion>
|
||||||
protected taxRateRuleService_: ModulesSdkTypes.InternalModuleService<TTaxRateRule>
|
protected taxRateRuleService_: ModulesSdkTypes.IMedusaInternalService<TTaxRateRule>
|
||||||
protected taxProviderService_: ModulesSdkTypes.InternalModuleService<TTaxProvider>
|
protected taxProviderService_: ModulesSdkTypes.IMedusaInternalService<TTaxProvider>
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
{
|
{
|
||||||
@@ -293,6 +292,7 @@ export default class TaxModuleService<
|
|||||||
return Array.isArray(data) ? serialized : serialized[0]
|
return Array.isArray(data) ? serialized : serialized[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
createTaxRegions(
|
createTaxRegions(
|
||||||
data: TaxTypes.CreateTaxRegionDTO,
|
data: TaxTypes.CreateTaxRegionDTO,
|
||||||
sharedContext?: Context
|
sharedContext?: Context
|
||||||
@@ -349,6 +349,7 @@ export default class TaxModuleService<
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
createTaxRateRules(
|
createTaxRateRules(
|
||||||
data: TaxTypes.CreateTaxRateRuleDTO,
|
data: TaxTypes.CreateTaxRateRuleDTO,
|
||||||
sharedContext?: Context
|
sharedContext?: Context
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ import * as crypto from "crypto"
|
|||||||
|
|
||||||
import { Context, DAL } from "@medusajs/types"
|
import { Context, DAL } from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
|
arrayDifference,
|
||||||
InjectTransactionManager,
|
InjectTransactionManager,
|
||||||
MedusaError,
|
MedusaError,
|
||||||
ModulesSdkUtils,
|
ModulesSdkUtils,
|
||||||
arrayDifference,
|
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import jwt, { JwtPayload } from "jsonwebtoken"
|
import jwt, { JwtPayload } from "jsonwebtoken"
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ const DEFAULT_VALID_INVITE_DURATION = 60 * 60 * 24 * 1000
|
|||||||
|
|
||||||
export default class InviteService<
|
export default class InviteService<
|
||||||
TEntity extends Invite = Invite
|
TEntity extends Invite = Invite
|
||||||
> extends ModulesSdkUtils.internalModuleServiceFactory<InjectedDependencies>(
|
> extends ModulesSdkUtils.MedusaInternalService<InjectedDependencies>(
|
||||||
Invite
|
Invite
|
||||||
)<TEntity> {
|
)<TEntity> {
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
|
|||||||
@@ -23,19 +23,18 @@ import InviteService from "./invite"
|
|||||||
|
|
||||||
type InjectedDependencies = {
|
type InjectedDependencies = {
|
||||||
baseRepository: DAL.RepositoryService
|
baseRepository: DAL.RepositoryService
|
||||||
userService: ModulesSdkTypes.InternalModuleService<any>
|
userService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
inviteService: InviteService<any>
|
inviteService: InviteService<any>
|
||||||
eventBusModuleService: IEventBusModuleService
|
eventBusModuleService: IEventBusModuleService
|
||||||
}
|
}
|
||||||
|
|
||||||
const generateMethodForModels = [Invite]
|
const generateMethodForModels = { Invite }
|
||||||
|
|
||||||
export default class UserModuleService<
|
export default class UserModuleService<
|
||||||
TUser extends User = User,
|
TUser extends User = User,
|
||||||
TInvite extends Invite = Invite
|
TInvite extends Invite = Invite
|
||||||
>
|
>
|
||||||
extends ModulesSdkUtils.abstractModuleServiceFactory<
|
extends ModulesSdkUtils.MedusaService<
|
||||||
InjectedDependencies,
|
|
||||||
UserTypes.UserDTO,
|
UserTypes.UserDTO,
|
||||||
{
|
{
|
||||||
Invite: {
|
Invite: {
|
||||||
@@ -51,7 +50,7 @@ export default class UserModuleService<
|
|||||||
|
|
||||||
protected baseRepository_: DAL.RepositoryService
|
protected baseRepository_: DAL.RepositoryService
|
||||||
|
|
||||||
protected readonly userService_: ModulesSdkTypes.InternalModuleService<TUser>
|
protected readonly userService_: ModulesSdkTypes.IMedusaInternalService<TUser>
|
||||||
protected readonly inviteService_: InviteService<TInvite>
|
protected readonly inviteService_: InviteService<TInvite>
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@@ -199,6 +198,7 @@ export default class UserModuleService<
|
|||||||
return Array.isArray(data) ? serializedUsers : serializedUsers[0]
|
return Array.isArray(data) ? serializedUsers : serializedUsers[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
createInvites(
|
createInvites(
|
||||||
data: UserTypes.CreateInviteDTO[],
|
data: UserTypes.CreateInviteDTO[],
|
||||||
sharedContext?: Context
|
sharedContext?: Context
|
||||||
@@ -265,6 +265,7 @@ export default class UserModuleService<
|
|||||||
return await this.inviteService_.create(toCreate, sharedContext)
|
return await this.inviteService_.create(toCreate, sharedContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
updateInvites(
|
updateInvites(
|
||||||
data: UserTypes.UpdateInviteDTO[],
|
data: UserTypes.UpdateInviteDTO[],
|
||||||
sharedContext?: Context
|
sharedContext?: Context
|
||||||
|
|||||||
@@ -24,13 +24,13 @@ import { joinerConfig } from "../joiner-config"
|
|||||||
|
|
||||||
type InjectedDependencies = {
|
type InjectedDependencies = {
|
||||||
baseRepository: DAL.RepositoryService
|
baseRepository: DAL.RepositoryService
|
||||||
workflowExecutionService: ModulesSdkTypes.InternalModuleService<any>
|
workflowExecutionService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
workflowOrchestratorService: WorkflowOrchestratorService
|
workflowOrchestratorService: WorkflowOrchestratorService
|
||||||
}
|
}
|
||||||
|
|
||||||
export class WorkflowsModuleService implements IWorkflowEngineService {
|
export class WorkflowsModuleService implements IWorkflowEngineService {
|
||||||
protected baseRepository_: DAL.RepositoryService
|
protected baseRepository_: DAL.RepositoryService
|
||||||
protected workflowExecutionService_: ModulesSdkTypes.InternalModuleService<any>
|
protected workflowExecutionService_: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
protected workflowOrchestratorService_: WorkflowOrchestratorService
|
protected workflowOrchestratorService_: WorkflowOrchestratorService
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
|||||||
+2
-2
@@ -16,7 +16,7 @@ import { CronExpression, parseExpression } from "cron-parser"
|
|||||||
export class InMemoryDistributedTransactionStorage
|
export class InMemoryDistributedTransactionStorage
|
||||||
implements IDistributedTransactionStorage, IDistributedSchedulerStorage
|
implements IDistributedTransactionStorage, IDistributedSchedulerStorage
|
||||||
{
|
{
|
||||||
private workflowExecutionService_: ModulesSdkTypes.InternalModuleService<any>
|
private workflowExecutionService_: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
private workflowOrchestratorService_: WorkflowOrchestratorService
|
private workflowOrchestratorService_: WorkflowOrchestratorService
|
||||||
|
|
||||||
private storage: Map<string, TransactionCheckpoint> = new Map()
|
private storage: Map<string, TransactionCheckpoint> = new Map()
|
||||||
@@ -35,7 +35,7 @@ export class InMemoryDistributedTransactionStorage
|
|||||||
constructor({
|
constructor({
|
||||||
workflowExecutionService,
|
workflowExecutionService,
|
||||||
}: {
|
}: {
|
||||||
workflowExecutionService: ModulesSdkTypes.InternalModuleService<any>
|
workflowExecutionService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
}) {
|
}) {
|
||||||
this.workflowExecutionService_ = workflowExecutionService
|
this.workflowExecutionService_ = workflowExecutionService
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,14 +24,14 @@ import { joinerConfig } from "../joiner-config"
|
|||||||
|
|
||||||
type InjectedDependencies = {
|
type InjectedDependencies = {
|
||||||
baseRepository: DAL.RepositoryService
|
baseRepository: DAL.RepositoryService
|
||||||
workflowExecutionService: ModulesSdkTypes.InternalModuleService<any>
|
workflowExecutionService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
workflowOrchestratorService: WorkflowOrchestratorService
|
workflowOrchestratorService: WorkflowOrchestratorService
|
||||||
redisDisconnectHandler: () => Promise<void>
|
redisDisconnectHandler: () => Promise<void>
|
||||||
}
|
}
|
||||||
|
|
||||||
export class WorkflowsModuleService implements IWorkflowEngineService {
|
export class WorkflowsModuleService implements IWorkflowEngineService {
|
||||||
protected baseRepository_: DAL.RepositoryService
|
protected baseRepository_: DAL.RepositoryService
|
||||||
protected workflowExecutionService_: ModulesSdkTypes.InternalModuleService<any>
|
protected workflowExecutionService_: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
protected workflowOrchestratorService_: WorkflowOrchestratorService
|
protected workflowOrchestratorService_: WorkflowOrchestratorService
|
||||||
protected redisDisconnectHandler_: () => Promise<void>
|
protected redisDisconnectHandler_: () => Promise<void>
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export class RedisDistributedTransactionStorage
|
|||||||
implements IDistributedTransactionStorage, IDistributedSchedulerStorage
|
implements IDistributedTransactionStorage, IDistributedSchedulerStorage
|
||||||
{
|
{
|
||||||
private static TTL_AFTER_COMPLETED = 60 * 15 // 15 minutes
|
private static TTL_AFTER_COMPLETED = 60 * 15 // 15 minutes
|
||||||
private workflowExecutionService_: ModulesSdkTypes.InternalModuleService<any>
|
private workflowExecutionService_: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
private workflowOrchestratorService_: WorkflowOrchestratorService
|
private workflowOrchestratorService_: WorkflowOrchestratorService
|
||||||
|
|
||||||
private redisClient: Redis
|
private redisClient: Redis
|
||||||
@@ -37,7 +37,7 @@ export class RedisDistributedTransactionStorage
|
|||||||
redisWorkerConnection,
|
redisWorkerConnection,
|
||||||
redisQueueName,
|
redisQueueName,
|
||||||
}: {
|
}: {
|
||||||
workflowExecutionService: ModulesSdkTypes.InternalModuleService<any>
|
workflowExecutionService: ModulesSdkTypes.IMedusaInternalService<any>
|
||||||
redisConnection: Redis
|
redisConnection: Redis
|
||||||
redisWorkerConnection: Redis
|
redisWorkerConnection: Redis
|
||||||
redisQueueName: string
|
redisQueueName: string
|
||||||
|
|||||||
Reference in New Issue
Block a user