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 authored and GitHub committed 2023-07-27 16:42:26 +02:00
1 parent c85d479e52
commit 107ae23a3f
15 files changed
+25 -15

No files matched your search

+8
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
@@ -162,9 +162,9 @@ class AlgoliaService extends SearchUtils.AbstractSearchService {
} }
switch (type) { switch (type) {
case SearchTypes.indexTypes.PRODUCTS: case SearchUtils.indexTypes.PRODUCTS:
const productsTransformer = const productsTransformer =
this.config_.settings?.[SearchTypes.indexTypes.PRODUCTS] this.config_.settings?.[SearchUtils.indexTypes.PRODUCTS]
?.transformer ?? transformProduct ?.transformer ?? transformProduct
return documents.map(productsTransformer) return documents.map(productsTransformer)
@@ -1,4 +1,4 @@
import { variantKeys } from "@medusajs/types" import { variantKeys } from "@medusajs/utils"
const prefix = `variant` const prefix = `variant`
@@ -105,9 +105,9 @@ class MeiliSearchService extends SearchUtils.AbstractSearchService {
} }
switch (type) { switch (type) {
case SearchTypes.indexTypes.PRODUCTS: case SearchUtils.indexTypes.PRODUCTS:
const productsTransformer = const productsTransformer =
this.config_.settings?.[SearchTypes.indexTypes.PRODUCTS] this.config_.settings?.[SearchUtils.indexTypes.PRODUCTS]
?.transformer ?? transformProduct ?.transformer ?? transformProduct
return documents.map(productsTransformer) return documents.map(productsTransformer)
@@ -1,4 +1,4 @@
import { variantKeys } from "@medusajs/types" import { variantKeys } from "@medusajs/utils"
const prefix = `variant` const prefix = `variant`
+2 -1
View File
@@ -1,4 +1,5 @@
import { Context, DAL, RepositoryTransformOptions } from "@medusajs/types" import { Context, DAL, RepositoryTransformOptions } from "@medusajs/types"
import { SoftDeletableFilterKey } from "@medusajs/utils"
import { SqlEntityManager } from "@mikro-orm/postgresql" import { SqlEntityManager } from "@mikro-orm/postgresql"
import { import {
buildQuery, buildQuery,
@@ -69,7 +70,7 @@ const mikroOrmUpdateDeletedAtRecursively = async <T extends object = any>(
const relationEntities = await collectionRelation.getItems({ const relationEntities = await collectionRelation.getItems({
filters: { filters: {
[DAL.SoftDeletableFilterKey]: { [SoftDeletableFilterKey]: {
withDeleted: true, withDeleted: true,
}, },
}, },
+2 -2
View File
@@ -1,7 +1,7 @@
// TODO: Should we create a mikro orm specific package for this and the base repository? // TODO: Should we create a mikro orm specific package for this and the base repository?
import { Filter } from "@mikro-orm/core" import { Filter } from "@mikro-orm/core"
import { DAL } from "@medusajs/types" import { SoftDeletableFilterKey } from "@medusajs/utils"
interface FilterArguments { interface FilterArguments {
withDeleted?: boolean withDeleted?: boolean
@@ -9,7 +9,7 @@ interface FilterArguments {
export const SoftDeletable = (): ClassDecorator => { export const SoftDeletable = (): ClassDecorator => {
return Filter({ return Filter({
name: DAL.SoftDeletableFilterKey, name: SoftDeletableFilterKey,
cond: ({ withDeleted }: FilterArguments = {}) => { cond: ({ withDeleted }: FilterArguments = {}) => {
if (withDeleted) { if (withDeleted) {
return {} return {}
-2
View File
@@ -21,6 +21,4 @@ export type FindOptions<T = any> = {
options?: OptionsQuery<T, any> options?: OptionsQuery<T, any>
} }
export const SoftDeletableFilterKey = "softDeletable"
export * from "./repository-service" export * from "./repository-service"
-2
View File
@@ -1,7 +1,5 @@
export * from "./index-types"
export * from "./interface" export * from "./interface"
export * from "./settings" export * from "./settings"
export * from "./variant-keys"
export type IndexSettings = { export type IndexSettings = {
/** /**
+1
View File
@@ -0,0 +1 @@
export const SoftDeletableFilterKey = "softDeletable"
+1
View File
@@ -22,3 +22,4 @@ export * from "./stringify-circular"
export * from "./to-kebab-case" export * from "./to-kebab-case"
export * from "./to-pascal-case" export * from "./to-pascal-case"
export * from "./wrap-handler" export * from "./wrap-handler"
export * from "./dal"
@@ -1,5 +1,6 @@
import { DAL, FindConfig, SoftDeletableFilterKey } from "@medusajs/types" import { DAL, FindConfig } from "@medusajs/types"
import { deduplicate, isObject } from "../common"
import { deduplicate, isObject, SoftDeletableFilterKey } from "../common"
export function buildQuery<T = any, TDto = any>( export function buildQuery<T = any, TDto = any>(
filters: Record<string, any> = {}, filters: Record<string, any> = {},
+2
View File
@@ -1,4 +1,6 @@
export * from "./abstract-service" export * from "./abstract-service"
export * from "./is-search-service" export * from "./is-search-service"
export * from "./search-relations" export * from "./search-relations"
export * from "./index-types"
export * from "./variant-keys"