chore: dependecies reorg (#8535)
This commit is contained in:
committed by
GitHub
parent
59599ac237
commit
058378970a
@@ -39,9 +39,7 @@
|
||||
"bignumber.js": "^9.1.2",
|
||||
"dotenv": "^16.4.5",
|
||||
"dotenv-expand": "^11.0.6",
|
||||
"json-2-csv": "^5.5.4",
|
||||
"jsonwebtoken": "^9.0.2",
|
||||
"knex": "2.4.2",
|
||||
"pluralize": "^8.0.0",
|
||||
"ulid": "^2.3.0"
|
||||
},
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
import { join } from "path"
|
||||
|
||||
export const getMedusaVersion = (): string => {
|
||||
try {
|
||||
return require(join(
|
||||
process.cwd(),
|
||||
`node_modules`,
|
||||
`@medusajs/medusa`,
|
||||
`package.json`
|
||||
)).version
|
||||
} catch (e) {
|
||||
return ``
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
import { csv2json } from "json-2-csv"
|
||||
|
||||
export interface ConvertCsvToJsonOptions<T> {}
|
||||
|
||||
export const convertCsvToJson = <T extends object>(
|
||||
data: string,
|
||||
options?: ConvertCsvToJsonOptions<T>
|
||||
): T[] => {
|
||||
return csv2json(data, {
|
||||
preventCsvInjection: true,
|
||||
delimiter: { field: detectDelimiter(data) },
|
||||
}) as T[]
|
||||
}
|
||||
|
||||
const delimiters = [",", ";", "|"]
|
||||
|
||||
const detectDelimiter = (data: string) => {
|
||||
let delimiter = ","
|
||||
const header = data.split("\n")[0]
|
||||
|
||||
for (const del of delimiters) {
|
||||
if (header.split(del).length > 1) {
|
||||
delimiter = del
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return delimiter
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
export * from "./jsontocsv"
|
||||
export * from "./csvtojson"
|
||||
@@ -1,21 +0,0 @@
|
||||
import { json2csv } from "json-2-csv"
|
||||
|
||||
export interface ConvertJsonToCsvOptions<T> {
|
||||
sortHeader?: boolean | ((aKey: string, bKey: string) => number)
|
||||
}
|
||||
|
||||
export const convertJsonToCsv = <T extends object>(
|
||||
data: T[],
|
||||
options?: ConvertJsonToCsvOptions<T>
|
||||
) => {
|
||||
return json2csv(data, {
|
||||
prependHeader: true,
|
||||
sortHeader: options?.sortHeader ?? false,
|
||||
arrayIndexesAsKeys: true,
|
||||
expandNestedObjects: true,
|
||||
expandArrayObjects: true,
|
||||
unwindArrays: false,
|
||||
preventCsvInjection: true,
|
||||
emptyFieldValue: "",
|
||||
})
|
||||
}
|
||||
@@ -25,12 +25,12 @@ import {
|
||||
} from "@mikro-orm/core/typings"
|
||||
import { SqlEntityManager } from "@mikro-orm/postgresql"
|
||||
import {
|
||||
MedusaError,
|
||||
arrayDifference,
|
||||
isString,
|
||||
MedusaError,
|
||||
promiseAll,
|
||||
} from "../../common"
|
||||
import { buildQuery } from "../../modules-sdk"
|
||||
import { buildQuery } from "../../modules-sdk/build-query"
|
||||
import {
|
||||
getSoftDeletedCascadedEntitiesIdsMappedBy,
|
||||
transactionWrapper,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { EntityMetadata, FindOptions, wrap } from "@mikro-orm/core"
|
||||
import { SqlEntityManager } from "@mikro-orm/postgresql"
|
||||
import { buildQuery } from "../../modules-sdk"
|
||||
import { buildQuery } from "../../modules-sdk/build-query"
|
||||
|
||||
function detectCircularDependency(
|
||||
manager: SqlEntityManager,
|
||||
|
||||
@@ -6,13 +6,14 @@ import {
|
||||
IDmlEntity,
|
||||
IDmlEntityConfig,
|
||||
InferDmlEntityNameFromConfig,
|
||||
IsDmlEntity,
|
||||
QueryCondition,
|
||||
} from "@medusajs/types"
|
||||
import { isObject, isString, toCamelCase } from "../common"
|
||||
import { transformIndexWhere } from "./helpers/entity-builder/build-indexes"
|
||||
import { BelongsTo } from "./relations/belongs-to"
|
||||
|
||||
const IsDmlEntity = Symbol.for("isDmlEntity")
|
||||
|
||||
function extractNameAndTableName<const Config extends IDmlEntityConfig>(
|
||||
nameOrConfig: Config
|
||||
) {
|
||||
@@ -59,7 +60,7 @@ export class DmlEntity<
|
||||
const TConfig extends IDmlEntityConfig
|
||||
> implements IDmlEntity<Schema, TConfig>
|
||||
{
|
||||
[IsDmlEntity]: true = true
|
||||
[IsDmlEntity] = true
|
||||
|
||||
name: InferDmlEntityNameFromConfig<TConfig>
|
||||
schema: Schema
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
export * from "./common"
|
||||
export * from "./api-key"
|
||||
export * from "./auth"
|
||||
export * from "./bundles"
|
||||
export * from "./common"
|
||||
export * from "./dal"
|
||||
export * from "./decorators"
|
||||
export * from "./defaults"
|
||||
@@ -26,6 +26,5 @@ export * from "./shipping"
|
||||
export * from "./totals"
|
||||
export * from "./totals/big-number"
|
||||
export * from "./user"
|
||||
export * from "./csv"
|
||||
|
||||
export const MedusaModuleType = Symbol.for("MedusaModule")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Modules } from "../modules-sdk"
|
||||
import { Modules } from "../modules-sdk/definition"
|
||||
import { composeLinkName } from "./compose-link-name"
|
||||
|
||||
export const LINKS = {
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { EventEmitter } from "events"
|
||||
import { MikroORM, MikroORMOptions } from "@mikro-orm/core"
|
||||
import {
|
||||
MigrateOptions,
|
||||
MigrationResult,
|
||||
UmzugMigration,
|
||||
} from "@mikro-orm/migrations"
|
||||
import { MikroORM, MikroORMOptions } from "@mikro-orm/core"
|
||||
import { PostgreSqlDriver } from "@mikro-orm/postgresql"
|
||||
import { dirname } from "path"
|
||||
import { EventEmitter } from "events"
|
||||
import { access, mkdir, writeFile } from "fs/promises"
|
||||
import { dirname } from "path"
|
||||
|
||||
/**
|
||||
* Events emitted by the migrations class
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { DAL, FindConfig } from "@medusajs/types"
|
||||
import { deduplicate, isDefined, isObject } from "../common"
|
||||
|
||||
import { SoftDeletableFilterKey } from "../dal"
|
||||
import { SoftDeletableFilterKey } from "../dal/mikro-orm/mikro-orm-soft-deletable-filter"
|
||||
|
||||
// Following convention here is fine, we can make it configurable if needed.
|
||||
const DELETED_AT_FIELD_NAME = "deleted_at"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { LinkModulesExtraFields, ModuleJoinerConfig } from "@medusajs/types"
|
||||
import { camelToSnakeCase, isObject, pluralize, toPascalCase } from "../common"
|
||||
import { composeLinkName } from "../link"
|
||||
import { composeLinkName } from "../link/compose-link-name"
|
||||
|
||||
export const DefineLinkSymbol = Symbol.for("DefineLink")
|
||||
|
||||
|
||||
@@ -11,16 +11,18 @@ import {
|
||||
SoftDeleteReturn,
|
||||
} from "@medusajs/types"
|
||||
import {
|
||||
MapToConfig,
|
||||
isString,
|
||||
kebabCase,
|
||||
lowerCaseFirst,
|
||||
mapObjectTo,
|
||||
MapToConfig,
|
||||
pluralize,
|
||||
upperCaseFirst,
|
||||
} from "../common"
|
||||
import { DmlEntity } from "../dml"
|
||||
import { InjectManager, MedusaContext } from "./decorators"
|
||||
import { ModuleRegistrationName } from "./definition"
|
||||
import { buildModelsNameToLinkableKeysMap } from "./joiner-config-builder"
|
||||
import {
|
||||
BaseMethods,
|
||||
ExtractKeysFromConfig,
|
||||
@@ -29,8 +31,6 @@ import {
|
||||
ModelEntries,
|
||||
ModelsConfigTemplate,
|
||||
} from "./types/medusa-service"
|
||||
import { buildModelsNameToLinkableKeysMap } from "./joiner-config-builder"
|
||||
import { DmlEntity } from "../dml"
|
||||
|
||||
const readMethods = ["retrieve", "list", "listAndCount"] as BaseMethods[]
|
||||
const writeMethods = [
|
||||
@@ -55,12 +55,12 @@ function buildMethodNamesFromModel(
|
||||
|
||||
if (method === "retrieve") {
|
||||
normalizedModelName =
|
||||
"singular" in model && model.singular
|
||||
model && "singular" in model && model.singular
|
||||
? model.singular
|
||||
: defaultMethodName
|
||||
} else {
|
||||
normalizedModelName =
|
||||
"plural" in model && model.plural
|
||||
model && "plural" in model && model.plural
|
||||
? model.plural
|
||||
: pluralize(defaultMethodName)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user