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:
8
.changeset/lucky-frogs-sleep.md
Normal file
8
.changeset/lucky-frogs-sleep.md
Normal 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
|
||||
@@ -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)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { variantKeys } from "@medusajs/types"
|
||||
import { variantKeys } from "@medusajs/utils"
|
||||
|
||||
const prefix = `variant`
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { variantKeys } from "@medusajs/types"
|
||||
import { variantKeys } from "@medusajs/utils"
|
||||
|
||||
const prefix = `variant`
|
||||
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -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 {}
|
||||
|
||||
@@ -21,6 +21,4 @@ export type FindOptions<T = any> = {
|
||||
options?: OptionsQuery<T, any>
|
||||
}
|
||||
|
||||
export const SoftDeletableFilterKey = "softDeletable"
|
||||
|
||||
export * from "./repository-service"
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
export * from "./index-types"
|
||||
export * from "./interface"
|
||||
export * from "./settings"
|
||||
export * from "./variant-keys"
|
||||
|
||||
export type IndexSettings = {
|
||||
/**
|
||||
|
||||
1
packages/utils/src/common/dal.ts
Normal file
1
packages/utils/src/common/dal.ts
Normal file
@@ -0,0 +1 @@
|
||||
export const SoftDeletableFilterKey = "softDeletable"
|
||||
@@ -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"
|
||||
|
||||
@@ -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> = {},
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user