feat(fulfillment): implementation part 2 (#6408)

**What**

> [!NOTE]  
> I can see this pr becoming huge, so I d like to get this partial one merged 👍 


- Fixes shared connection usage (mikro orm compare the instance to its own package and therefore was resulting in not trully reusing the provided connection leading to exhausting the connection pool as multiple connections was created and end up not being all destroyed properly under the hood, discovered in my integration tests)
- Create shipping options method implementation
- DTO's definition and service interface update
- integration tests 
- Re work of the indexes with new util update
- Test runner utils to remove a big chunk of the boilerplate of the packages integrations

FIXES CORE-1742
This commit is contained in:
Adrien de Peretti
2024-02-19 13:33:46 +01:00
committed by GitHub
parent 680dfcdad3
commit 1d91b7429b
59 changed files with 2213 additions and 1741 deletions

View File

@@ -84,7 +84,7 @@ describe("createPsqlIndexStatementHelper", function () {
const indexStatement = createPsqlIndexStatementHelper(options)
expect(indexStatement.expression).toEqual(
`CREATE UNIQUE INDEX IF NOT EXISTS "IDX_table_name_column_name_1_column_name_2" ON "${
`CREATE UNIQUE INDEX IF NOT EXISTS "IDX_table_name_column_name_1_column_name_2_unique" ON "${
options.tableName
}" (${options.columns.join(", ")}) WHERE ${options.where}`
)

View File

@@ -47,7 +47,7 @@ export function createPsqlIndexStatementHelper({
const columnsName = Array.isArray(columns) ? columns.join("_") : columns
columns = Array.isArray(columns) ? columns.join(", ") : columns
name = name || `IDX_${tableName}_${columnsName}`
name = name || `IDX_${tableName}_${columnsName}${unique ? "_unique" : ""}`
const typeStr = type ? ` USING ${type}` : ""
const optionsStr = where ? ` WHERE ${where}` : ""
@@ -63,7 +63,7 @@ export function createPsqlIndexStatementHelper({
},
name,
expression,
MikroORMIndex: (options = {}) => {
MikroORMIndex: (options?: Parameters<typeof Index>[0]) => {
return Index({
name,
expression,

View File

@@ -97,13 +97,6 @@ export interface AbstractModuleServiceBase<TContainer, TMainModelDTO> {
): Promise<Record<string, string[]> | void>
}
/**
* Multiple issues on typescript around mapped types function are open, so
* when overriding a method from the base class that is mapped dynamically from the
* other models, we will have to ignore the error (2425)
*
* see: https://github.com/microsoft/TypeScript/issues/48125
*/
export type AbstractModuleService<
TContainer,
TMainModelDTO,

View File

@@ -1,4 +1,4 @@
import knex from "knex"
import { knex } from "@mikro-orm/knex"
import { ModuleServiceInitializeOptions } from "@medusajs/types"
type Options = ModuleServiceInitializeOptions["database"]