chore: cleanup inspection (#6358)

This commit is contained in:
Adrien de Peretti authored and GitHub committed 2024-02-09 14:40:09 +01:00
1 parent 94062d28be
commit b91a1ca5b8
19 files changed
+66 -72

No files matched your search

+6
View File
@@ -0,0 +1,6 @@
---
"@medusajs/pricing": patch
"@medusajs/product": patch
---
chore: cleanup inspection
+2 -2
View File
@@ -1,13 +1,13 @@
import { import {
ExternalModuleDeclaration, ExternalModuleDeclaration,
InternalModuleDeclaration, InternalModuleDeclaration,
MODULE_PACKAGE_NAMES,
MedusaModule, MedusaModule,
MODULE_PACKAGE_NAMES,
Modules, Modules,
} from "@medusajs/modules-sdk" } from "@medusajs/modules-sdk"
import { IAuthModuleService, ModulesSdkTypes } from "@medusajs/types" import { IAuthModuleService, ModulesSdkTypes } from "@medusajs/types"
import { InitializeModuleInjectableDependencies } from "../types" import { InitializeModuleInjectableDependencies } from "@types"
import { moduleDefinition } from "../module-definition" import { moduleDefinition } from "../module-definition"
export const initialize = async ( export const initialize = async (
-3
View File
@@ -1,9 +1,6 @@
import { import {
BeforeCreate, BeforeCreate,
Cascade,
Entity, Entity,
Index,
ManyToOne,
OnInit, OnInit,
OptionalProps, OptionalProps,
PrimaryKey, PrimaryKey,
-1
View File
@@ -1,6 +1,5 @@
import { AbstractAuthModuleProvider, MedusaError } from "@medusajs/utils" import { AbstractAuthModuleProvider, MedusaError } from "@medusajs/utils"
import { import {
AuthProviderScope,
AuthenticationInput, AuthenticationInput,
AuthenticationResponse, AuthenticationResponse,
ModulesSdkTypes, ModulesSdkTypes,
+6 -8
View File
@@ -19,7 +19,6 @@ import { entityNameToLinkableKeysMap, joinerConfig } from "../joiner-config"
import { import {
AbstractAuthModuleProvider, AbstractAuthModuleProvider,
InjectManager, InjectManager,
InjectTransactionManager,
MedusaContext, MedusaContext,
MedusaError, MedusaError,
ModulesSdkUtils, ModulesSdkUtils,
@@ -74,13 +73,12 @@ export default class AuthModuleService<TAuthUser extends AuthUser = AuthUser>
): Promise<AuthTypes.AuthUserDTO | AuthTypes.AuthUserDTO[]> { ): Promise<AuthTypes.AuthUserDTO | AuthTypes.AuthUserDTO[]> {
const authUsers = await this.authUserService_.create(data, sharedContext) const authUsers = await this.authUserService_.create(data, sharedContext)
const serializedUsers = await this.baseRepository_.serialize< return await this.baseRepository_.serialize<AuthTypes.AuthUserDTO[]>(
AuthTypes.AuthUserDTO[] authUsers,
>(authUsers, { {
populate: true, populate: true,
}) }
)
return serializedUsers
} }
update( update(
+1 -1
View File
@@ -7,7 +7,7 @@ import {
} from "@medusajs/modules-sdk" } from "@medusajs/modules-sdk"
import { ICartModuleService, ModulesSdkTypes } from "@medusajs/types" import { ICartModuleService, ModulesSdkTypes } from "@medusajs/types"
import { moduleDefinition } from "../module-definition" import { moduleDefinition } from "../module-definition"
import { InitializeModuleInjectableDependencies } from "../types" import { InitializeModuleInjectableDependencies } from "@types"
export const initialize = async ( export const initialize = async (
options?: options?:
+10 -9
View File
@@ -403,7 +403,8 @@ export default class CartModuleService<
itemIdsOrSelector: string | string[] | Partial<CartTypes.CartLineItemDTO>, itemIdsOrSelector: string | string[] | Partial<CartTypes.CartLineItemDTO>,
@MedusaContext() sharedContext: Context = {} @MedusaContext() sharedContext: Context = {}
): Promise<void> { ): Promise<void> {
let toDelete: string[] = [] let toDelete: string[]
if (isObject(itemIdsOrSelector)) { if (isObject(itemIdsOrSelector)) {
const items = await this.listLineItems( const items = await this.listLineItems(
{ ...itemIdsOrSelector } as Partial<CartTypes.CartLineItemDTO>, { ...itemIdsOrSelector } as Partial<CartTypes.CartLineItemDTO>,
@@ -518,7 +519,7 @@ export default class CartModuleService<
): Promise< ): Promise<
CartTypes.CartShippingMethodDTO[] | CartTypes.CartShippingMethodDTO CartTypes.CartShippingMethodDTO[] | CartTypes.CartShippingMethodDTO
> { > {
let methods: ShippingMethod[] = [] let methods: ShippingMethod[]
if (isString(cartIdOrData)) { if (isString(cartIdOrData)) {
methods = await this.addShippingMethods_( methods = await this.addShippingMethods_(
cartIdOrData, cartIdOrData,
@@ -588,7 +589,7 @@ export default class CartModuleService<
| Partial<CartTypes.CartShippingMethodDTO>, | Partial<CartTypes.CartShippingMethodDTO>,
@MedusaContext() sharedContext: Context = {} @MedusaContext() sharedContext: Context = {}
): Promise<void> { ): Promise<void> {
let toDelete: string[] = [] let toDelete: string[]
if (isObject(methodIdsOrSelector)) { if (isObject(methodIdsOrSelector)) {
const methods = await this.listShippingMethods( const methods = await this.listShippingMethods(
{ {
@@ -742,7 +743,7 @@ export default class CartModuleService<
| Partial<CartTypes.LineItemAdjustmentDTO>, | Partial<CartTypes.LineItemAdjustmentDTO>,
@MedusaContext() sharedContext: Context = {} @MedusaContext() sharedContext: Context = {}
): Promise<void> { ): Promise<void> {
let ids: string[] = [] let ids: string[]
if (isObject(adjustmentIdsOrSelector)) { if (isObject(adjustmentIdsOrSelector)) {
const adjustments = await this.listLineItemAdjustments( const adjustments = await this.listLineItemAdjustments(
{ {
@@ -911,7 +912,7 @@ export default class CartModuleService<
| Partial<CartTypes.ShippingMethodAdjustmentDTO>, | Partial<CartTypes.ShippingMethodAdjustmentDTO>,
@MedusaContext() sharedContext: Context = {} @MedusaContext() sharedContext: Context = {}
): Promise<void> { ): Promise<void> {
let ids: string[] = [] let ids: string[]
if (isObject(adjustmentIdsOrSelector)) { if (isObject(adjustmentIdsOrSelector)) {
const adjustments = await this.listShippingMethodAdjustments( const adjustments = await this.listShippingMethodAdjustments(
{ {
@@ -956,7 +957,7 @@ export default class CartModuleService<
| CartTypes.CreateLineItemTaxLineDTO, | CartTypes.CreateLineItemTaxLineDTO,
@MedusaContext() sharedContext: Context = {} @MedusaContext() sharedContext: Context = {}
): Promise<CartTypes.LineItemTaxLineDTO[] | CartTypes.LineItemTaxLineDTO> { ): Promise<CartTypes.LineItemTaxLineDTO[] | CartTypes.LineItemTaxLineDTO> {
let addedTaxLines: LineItemTaxLine[] = [] let addedTaxLines: LineItemTaxLine[]
if (isString(cartIdOrData)) { if (isString(cartIdOrData)) {
// existence check // existence check
await this.retrieve(cartIdOrData, { select: ["id"] }, sharedContext) await this.retrieve(cartIdOrData, { select: ["id"] }, sharedContext)
@@ -1065,7 +1066,7 @@ export default class CartModuleService<
| CartTypes.FilterableShippingMethodTaxLineProps, | CartTypes.FilterableShippingMethodTaxLineProps,
@MedusaContext() sharedContext: Context = {} @MedusaContext() sharedContext: Context = {}
): Promise<void> { ): Promise<void> {
let ids: string[] = [] let ids: string[]
if (isObject(taxLineIdsOrSelector)) { if (isObject(taxLineIdsOrSelector)) {
const taxLines = await this.listLineItemTaxLines( const taxLines = await this.listLineItemTaxLines(
{ {
@@ -1112,7 +1113,7 @@ export default class CartModuleService<
): Promise< ): Promise<
CartTypes.ShippingMethodTaxLineDTO[] | CartTypes.ShippingMethodTaxLineDTO CartTypes.ShippingMethodTaxLineDTO[] | CartTypes.ShippingMethodTaxLineDTO
> { > {
let addedTaxLines: ShippingMethodTaxLine[] = [] let addedTaxLines: ShippingMethodTaxLine[]
if (isString(cartIdOrData)) { if (isString(cartIdOrData)) {
// existence check // existence check
await this.retrieve(cartIdOrData, { select: ["id"] }, sharedContext) await this.retrieve(cartIdOrData, { select: ["id"] }, sharedContext)
@@ -1222,7 +1223,7 @@ export default class CartModuleService<
| CartTypes.FilterableShippingMethodTaxLineProps, | CartTypes.FilterableShippingMethodTaxLineProps,
@MedusaContext() sharedContext: Context = {} @MedusaContext() sharedContext: Context = {}
): Promise<void> { ): Promise<void> {
let ids: string[] = [] let ids: string[]
if (isObject(taxLineIdsOrSelector)) { if (isObject(taxLineIdsOrSelector)) {
const taxLines = await this.listShippingMethodTaxLines( const taxLines = await this.listShippingMethodTaxLines(
{ {
+1 -1
View File
@@ -7,7 +7,7 @@ import {
} from "@medusajs/modules-sdk" } from "@medusajs/modules-sdk"
import { ICustomerModuleService, ModulesSdkTypes } from "@medusajs/types" import { ICustomerModuleService, ModulesSdkTypes } from "@medusajs/types"
import { moduleDefinition } from "../module-definition" import { moduleDefinition } from "../module-definition"
import { InitializeModuleInjectableDependencies } from "../types" import { InitializeModuleInjectableDependencies } from "@types"
export const initialize = async ( export const initialize = async (
options?: options?:
+1 -3
View File
@@ -6,11 +6,9 @@ import {
Collection, Collection,
Entity, Entity,
Filter, Filter,
Index,
ManyToMany, ManyToMany,
ManyToOne,
OnInit,
OneToMany, OneToMany,
OnInit,
OptionalProps, OptionalProps,
PrimaryKey, PrimaryKey,
Property, Property,
@@ -176,7 +176,7 @@ export default class CustomerModuleService<
| { | {
selector: CustomerTypes.FilterableCustomerProps selector: CustomerTypes.FilterableCustomerProps
data: CustomerTypes.CustomerUpdatableFields data: CustomerTypes.CustomerUpdatableFields
} = [] }
if (isString(idsOrSelector)) { if (isString(idsOrSelector)) {
updateData = { updateData = {
@@ -269,7 +269,7 @@ export default class CustomerModuleService<
| { | {
selector: CustomerTypes.FilterableCustomerGroupProps selector: CustomerTypes.FilterableCustomerGroupProps
data: CustomerTypes.CustomerGroupUpdatableFields data: CustomerTypes.CustomerGroupUpdatableFields
} = [] }
if (isString(groupIdOrSelector) || Array.isArray(groupIdOrSelector)) { if (isString(groupIdOrSelector) || Array.isArray(groupIdOrSelector)) {
const groupIdOrSelectorArray = Array.isArray(groupIdOrSelector) const groupIdOrSelectorArray = Array.isArray(groupIdOrSelector)
@@ -373,12 +373,10 @@ export default class CustomerModuleService<
| CustomerTypes.CreateCustomerAddressDTO[], | CustomerTypes.CreateCustomerAddressDTO[],
@MedusaContext() sharedContext: Context = {} @MedusaContext() sharedContext: Context = {}
) { ) {
const addresses = await this.addressService_.create( return await this.addressService_.create(
Array.isArray(data) ? data : [data], Array.isArray(data) ? data : [data],
sharedContext sharedContext
) )
return addresses
} }
async updateAddresses( async updateAddresses(
@@ -411,7 +409,7 @@ export default class CustomerModuleService<
| { | {
selector: CustomerTypes.FilterableCustomerAddressProps selector: CustomerTypes.FilterableCustomerAddressProps
data: CustomerTypes.UpdateCustomerAddressDTO data: CustomerTypes.UpdateCustomerAddressDTO
} = [] }
if (isString(addressIdOrSelector)) { if (isString(addressIdOrSelector)) {
updateData = [ updateData = [
{ {
@@ -4,11 +4,10 @@ import {
Collection, Collection,
Entity, Entity,
Filter, Filter,
Index,
ManyToOne, ManyToOne,
OnInit,
OneToMany, OneToMany,
OneToOne, OneToOne,
OnInit,
OptionalProps, OptionalProps,
PrimaryKey, PrimaryKey,
PrimaryKeyType, PrimaryKeyType,
@@ -84,7 +83,11 @@ export default class PriceSetMoneyAmount {
}) })
updated_at: Date updated_at: Date
@Property({ columnType: "timestamptz", nullable: true , index: "IDX_price_set_money_amount_deleted_at"}) @Property({
columnType: "timestamptz",
nullable: true,
index: "IDX_price_set_money_amount_deleted_at",
})
deleted_at: Date | null deleted_at: Date | null
@BeforeCreate() @BeforeCreate()
+14 -16
View File
@@ -48,9 +48,9 @@ import {
PriceRuleService, PriceRuleService,
RuleTypeService, RuleTypeService,
} from "@services" } from "@services"
import {entityNameToLinkableKeysMap, joinerConfig} from "../joiner-config" import { entityNameToLinkableKeysMap, joinerConfig } from "../joiner-config"
import {validatePriceListDates} from "@utils" import { validatePriceListDates } from "@utils"
import {ServiceTypes} from "@types" import { ServiceTypes } from "@types"
type InjectedDependencies = { type InjectedDependencies = {
baseRepository: DAL.RepositoryService baseRepository: DAL.RepositoryService
@@ -950,7 +950,7 @@ export default class PricingModuleService<
priceListsToCreate priceListsToCreate
)) as unknown as PricingTypes.PriceListDTO[] )) as unknown as PricingTypes.PriceListDTO[]
for (var i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
const { rules = {}, prices = [] } = data[i] const { rules = {}, prices = [] } = data[i]
const priceList = priceLists[i] const priceList = priceLists[i]
@@ -1167,12 +1167,11 @@ export default class PricingModuleService<
): Promise<PricingTypes.PriceListRuleDTO[]> { ): Promise<PricingTypes.PriceListRuleDTO[]> {
const priceLists = await this.createPriceListRules_(data, sharedContext) const priceLists = await this.createPriceListRules_(data, sharedContext)
return await this.baseRepository_.serialize<PricingTypes.PriceListRuleDTO[]>( return await this.baseRepository_.serialize<
priceLists, PricingTypes.PriceListRuleDTO[]
{ >(priceLists, {
populate: true, populate: true,
} })
)
} }
@InjectTransactionManager("baseRepository_") @InjectTransactionManager("baseRepository_")
@@ -1193,12 +1192,11 @@ export default class PricingModuleService<
sharedContext sharedContext
) )
return await this.baseRepository_.serialize<PricingTypes.PriceListRuleDTO[]>( return await this.baseRepository_.serialize<
priceLists, PricingTypes.PriceListRuleDTO[]
{ >(priceLists, {
populate: true, populate: true,
} })
)
} }
@InjectManager("baseRepository_") @InjectManager("baseRepository_")
@@ -1,5 +1,4 @@
import { PriceSet, PriceSetMoneyAmount, RuleType } from "@models" import { PriceSet, PriceSetMoneyAmount, RuleType } from "@models"
import { PriceSetDTO, PriceSetMoneyAmountDTO, RuleTypeDTO } from "@medusajs/types"
export interface CreatePriceRuleDTO { export interface CreatePriceRuleDTO {
id?: string id?: string
@@ -1,4 +1,4 @@
import { BaseFilterable, PriceSetDTO, PriceSetMoneyAmountDTO, RuleTypeDTO } from "@medusajs/types" import { BaseFilterable, PriceSetDTO, RuleTypeDTO } from "@medusajs/types"
import { PriceSet, PriceSetMoneyAmount, RuleType } from "@models" import { PriceSet, PriceSetMoneyAmount, RuleType } from "@models"
export interface CreatePriceRuleDTO { export interface CreatePriceRuleDTO {
+1 -1
View File
@@ -7,7 +7,7 @@ import {
} from "@medusajs/modules-sdk" } from "@medusajs/modules-sdk"
import { IProductModuleService, ModulesSdkTypes } from "@medusajs/types" import { IProductModuleService, ModulesSdkTypes } from "@medusajs/types"
import { InitializeModuleInjectableDependencies } from "../types" import { InitializeModuleInjectableDependencies } from "@types"
import { moduleDefinition } from "../module-definition" import { moduleDefinition } from "../module-definition"
export const initialize = async ( export const initialize = async (
@@ -751,7 +751,7 @@ export default class PromotionModuleService<
sharedContext sharedContext
) )
return this.retrieve( return await this.retrieve(
promotionId, promotionId,
{ relations: ["rules", "rules.values"] }, { relations: ["rules", "rules.values"] },
sharedContext sharedContext
@@ -784,7 +784,7 @@ export default class PromotionModuleService<
sharedContext sharedContext
) )
return this.retrieve( return await this.retrieve(
promotionId, promotionId,
{ {
relations: [ relations: [
@@ -825,7 +825,7 @@ export default class PromotionModuleService<
sharedContext sharedContext
) )
return this.retrieve( return await this.retrieve(
promotionId, promotionId,
{ {
relations: [ relations: [
@@ -882,7 +882,7 @@ export default class PromotionModuleService<
): Promise<PromotionTypes.PromotionDTO> { ): Promise<PromotionTypes.PromotionDTO> {
await this.removePromotionRules_(promotionId, rulesData, sharedContext) await this.removePromotionRules_(promotionId, rulesData, sharedContext)
return this.retrieve( return await this.retrieve(
promotionId, promotionId,
{ relations: ["rules", "rules.values"] }, { relations: ["rules", "rules.values"] },
sharedContext sharedContext
@@ -926,7 +926,7 @@ export default class PromotionModuleService<
sharedContext sharedContext
) )
return this.retrieve( return await this.retrieve(
promotionId, promotionId,
{ {
relations: [ relations: [
@@ -954,7 +954,7 @@ export default class PromotionModuleService<
sharedContext sharedContext
) )
return this.retrieve( return await this.retrieve(
promotionId, promotionId,
{ {
relations: [ relations: [
@@ -5,7 +5,7 @@ import {
MedusaError, MedusaError,
PromotionType, PromotionType,
} from "@medusajs/utils" } from "@medusajs/utils"
import { areRulesValidForContext } from "../validations/promotion-rule" import { areRulesValidForContext } from "../validations"
import { computeActionForBudgetExceeded } from "./usage" import { computeActionForBudgetExceeded } from "./usage"
export function getComputedActionsForBuyGet( export function getComputedActionsForBuyGet(
@@ -2,16 +2,13 @@ import {
ApplicationMethodAllocation, ApplicationMethodAllocation,
ApplicationMethodTargetType, ApplicationMethodTargetType,
ApplicationMethodType, ApplicationMethodType,
MedusaError,
PromotionType,
isDefined, isDefined,
isPresent, isPresent,
MedusaError,
PromotionType,
} from "@medusajs/utils" } from "@medusajs/utils"
import { Promotion } from "@models" import { Promotion } from "@models"
import { import { CreateApplicationMethodDTO, UpdateApplicationMethodDTO } from "@types"
CreateApplicationMethodDTO,
UpdateApplicationMethodDTO,
} from "../../types"
export const allowedAllocationTargetTypes: string[] = [ export const allowedAllocationTargetTypes: string[] = [
ApplicationMethodTargetType.SHIPPING_METHODS, ApplicationMethodTargetType.SHIPPING_METHODS,
@@ -1,12 +1,12 @@
import { PromotionRuleDTO, PromotionRuleOperatorValues } from "@medusajs/types" import { PromotionRuleDTO, PromotionRuleOperatorValues } from "@medusajs/types"
import { import {
MedusaError,
PromotionRuleOperator,
isPresent, isPresent,
isString, isString,
MedusaError,
pickValueFromObject, pickValueFromObject,
PromotionRuleOperator,
} from "@medusajs/utils" } from "@medusajs/utils"
import { CreatePromotionRuleDTO } from "../../types" import { CreatePromotionRuleDTO } from "@types"
export function validatePromotionRuleAttributes( export function validatePromotionRuleAttributes(
promotionRulesData: CreatePromotionRuleDTO[] promotionRulesData: CreatePromotionRuleDTO[]