fix(utils, types, medusa-plugin-meilisearch, medusa-plugin-algolia): move SoftDeletableFilterKey, variantKeys, indexTypes from types to utils (#4623)

* chore: move SoftDeletableKey from types to utils

* chore: move variantkeys, indextypes
This commit is contained in:
Riqwan Thamir
2023-07-27 20:12:26 +05:30
committed by GitHub
parent c85d479e52
commit 107ae23a3f
15 changed files with 25 additions and 15 deletions

View File

@@ -0,0 +1,8 @@
---
"@medusajs/utils": patch
"@medusajs/types": patch
"medusa-plugin-meilisearch": patch
"medusa-plugin-algolia": patch
---
fix(utils, types, medusa-plugin-meilisearch, medusa-plugin-algolia): move SoftDeletableFilterKey, variantKeys, indexTypes from types to utils

View File

@@ -162,9 +162,9 @@ class AlgoliaService extends SearchUtils.AbstractSearchService {
}
switch (type) {
case SearchTypes.indexTypes.PRODUCTS:
case SearchUtils.indexTypes.PRODUCTS:
const productsTransformer =
this.config_.settings?.[SearchTypes.indexTypes.PRODUCTS]
this.config_.settings?.[SearchUtils.indexTypes.PRODUCTS]
?.transformer ?? transformProduct
return documents.map(productsTransformer)

View File

@@ -1,4 +1,4 @@
import { variantKeys } from "@medusajs/types"
import { variantKeys } from "@medusajs/utils"
const prefix = `variant`

View File

@@ -105,9 +105,9 @@ class MeiliSearchService extends SearchUtils.AbstractSearchService {
}
switch (type) {
case SearchTypes.indexTypes.PRODUCTS:
case SearchUtils.indexTypes.PRODUCTS:
const productsTransformer =
this.config_.settings?.[SearchTypes.indexTypes.PRODUCTS]
this.config_.settings?.[SearchUtils.indexTypes.PRODUCTS]
?.transformer ?? transformProduct
return documents.map(productsTransformer)

View File

@@ -1,4 +1,4 @@
import { variantKeys } from "@medusajs/types"
import { variantKeys } from "@medusajs/utils"
const prefix = `variant`

View File

@@ -1,4 +1,5 @@
import { Context, DAL, RepositoryTransformOptions } from "@medusajs/types"
import { SoftDeletableFilterKey } from "@medusajs/utils"
import { SqlEntityManager } from "@mikro-orm/postgresql"
import {
buildQuery,
@@ -69,7 +70,7 @@ const mikroOrmUpdateDeletedAtRecursively = async <T extends object = any>(
const relationEntities = await collectionRelation.getItems({
filters: {
[DAL.SoftDeletableFilterKey]: {
[SoftDeletableFilterKey]: {
withDeleted: true,
},
},

View File

@@ -1,7 +1,7 @@
// TODO: Should we create a mikro orm specific package for this and the base repository?
import { Filter } from "@mikro-orm/core"
import { DAL } from "@medusajs/types"
import { SoftDeletableFilterKey } from "@medusajs/utils"
interface FilterArguments {
withDeleted?: boolean
@@ -9,7 +9,7 @@ interface FilterArguments {
export const SoftDeletable = (): ClassDecorator => {
return Filter({
name: DAL.SoftDeletableFilterKey,
name: SoftDeletableFilterKey,
cond: ({ withDeleted }: FilterArguments = {}) => {
if (withDeleted) {
return {}

View File

@@ -21,6 +21,4 @@ export type FindOptions<T = any> = {
options?: OptionsQuery<T, any>
}
export const SoftDeletableFilterKey = "softDeletable"
export * from "./repository-service"

View File

@@ -1,7 +1,5 @@
export * from "./index-types"
export * from "./interface"
export * from "./settings"
export * from "./variant-keys"
export type IndexSettings = {
/**

View File

@@ -0,0 +1 @@
export const SoftDeletableFilterKey = "softDeletable"

View File

@@ -22,3 +22,4 @@ export * from "./stringify-circular"
export * from "./to-kebab-case"
export * from "./to-pascal-case"
export * from "./wrap-handler"
export * from "./dal"

View File

@@ -1,5 +1,6 @@
import { DAL, FindConfig, SoftDeletableFilterKey } from "@medusajs/types"
import { deduplicate, isObject } from "../common"
import { DAL, FindConfig } from "@medusajs/types"
import { deduplicate, isObject, SoftDeletableFilterKey } from "../common"
export function buildQuery<T = any, TDto = any>(
filters: Record<string, any> = {},

View File

@@ -1,4 +1,6 @@
export * from "./abstract-service"
export * from "./is-search-service"
export * from "./search-relations"
export * from "./index-types"
export * from "./variant-keys"