breaking: move shared HTTP utils to the framework (#9402)

Fixes: FRMW-2728, FRMW-2729

After this PR gets merged the following middleware will be exported from the `@medusajs/framework/http` import path.

- applyParamsAsFilters
- clearFiltersByKey
- applyDefaultFilters
- setContext
- getQueryConfig
- httpCompression
- maybeApplyLinkFilter
- refetchEntities
- unlessPath
- validateBody
- validateQuery

Co-authored-by: Adrien de Peretti <25098370+adrien2p@users.noreply.github.com>
This commit is contained in:
Harminder Virk
2024-10-03 15:12:00 +05:30
committed by GitHub
parent 193f93464f
commit 48e00169d2
557 changed files with 2365 additions and 3499 deletions

View File

@@ -5,7 +5,7 @@ import {
ModuleProvider,
ModulesSdkTypes,
} from "@medusajs/framework/types"
import { Lifetime, asFunction } from "awilix"
import { asFunction, Lifetime } from "awilix"
import * as providers from "../providers"

View File

@@ -1,7 +1,5 @@
{
"namespaces": [
"public"
],
"namespaces": ["public"],
"name": "public",
"tables": [
{
@@ -31,9 +29,7 @@
"indexes": [
{
"keyName": "tax_provider_pkey",
"columnNames": [
"id"
],
"columnNames": ["id"],
"composite": false,
"primary": true,
"unique": true
@@ -144,9 +140,7 @@
"schema": "public",
"indexes": [
{
"columnNames": [
"parent_id"
],
"columnNames": ["parent_id"],
"composite": false,
"keyName": "IDX_tax_region_parent_id",
"primary": false,
@@ -154,9 +148,7 @@
},
{
"keyName": "IDX_tax_region_deleted_at",
"columnNames": [
"deleted_at"
],
"columnNames": ["deleted_at"],
"composite": false,
"primary": false,
"unique": false,
@@ -180,9 +172,7 @@
},
{
"keyName": "tax_region_pkey",
"columnNames": [
"id"
],
"columnNames": ["id"],
"composite": false,
"primary": true,
"unique": true
@@ -203,26 +193,18 @@
"foreignKeys": {
"tax_region_provider_id_foreign": {
"constraintName": "tax_region_provider_id_foreign",
"columnNames": [
"provider_id"
],
"columnNames": ["provider_id"],
"localTableName": "public.tax_region",
"referencedColumnNames": [
"id"
],
"referencedColumnNames": ["id"],
"referencedTableName": "public.tax_provider",
"deleteRule": "set null",
"updateRule": "cascade"
},
"tax_region_parent_id_foreign": {
"constraintName": "tax_region_parent_id_foreign",
"columnNames": [
"parent_id"
],
"columnNames": ["parent_id"],
"localTableName": "public.tax_region",
"referencedColumnNames": [
"id"
],
"referencedColumnNames": ["id"],
"referencedTableName": "public.tax_region",
"deleteRule": "cascade",
"updateRule": "cascade"
@@ -352,9 +334,7 @@
"indexes": [
{
"keyName": "IDX_tax_rate_tax_region_id",
"columnNames": [
"tax_region_id"
],
"columnNames": ["tax_region_id"],
"composite": false,
"primary": false,
"unique": false,
@@ -362,9 +342,7 @@
},
{
"keyName": "IDX_tax_rate_deleted_at",
"columnNames": [
"deleted_at"
],
"columnNames": ["deleted_at"],
"composite": false,
"primary": false,
"unique": false,
@@ -380,9 +358,7 @@
},
{
"keyName": "tax_rate_pkey",
"columnNames": [
"id"
],
"columnNames": ["id"],
"composite": false,
"primary": true,
"unique": true
@@ -392,13 +368,9 @@
"foreignKeys": {
"tax_rate_tax_region_id_foreign": {
"constraintName": "tax_rate_tax_region_id_foreign",
"columnNames": [
"tax_region_id"
],
"columnNames": ["tax_region_id"],
"localTableName": "public.tax_rate",
"referencedColumnNames": [
"id"
],
"referencedColumnNames": ["id"],
"referencedTableName": "public.tax_region",
"deleteRule": "cascade",
"updateRule": "cascade"
@@ -499,9 +471,7 @@
"indexes": [
{
"keyName": "IDX_tax_rate_rule_tax_rate_id",
"columnNames": [
"tax_rate_id"
],
"columnNames": ["tax_rate_id"],
"composite": false,
"primary": false,
"unique": false,
@@ -509,9 +479,7 @@
},
{
"keyName": "IDX_tax_rate_rule_reference_id",
"columnNames": [
"reference_id"
],
"columnNames": ["reference_id"],
"composite": false,
"primary": false,
"unique": false,
@@ -519,9 +487,7 @@
},
{
"keyName": "IDX_tax_rate_rule_deleted_at",
"columnNames": [
"deleted_at"
],
"columnNames": ["deleted_at"],
"composite": false,
"primary": false,
"unique": false,
@@ -537,9 +503,7 @@
},
{
"keyName": "tax_rate_rule_pkey",
"columnNames": [
"id"
],
"columnNames": ["id"],
"composite": false,
"primary": true,
"unique": true
@@ -549,13 +513,9 @@
"foreignKeys": {
"tax_rate_rule_tax_rate_id_foreign": {
"constraintName": "tax_rate_rule_tax_rate_id_foreign",
"columnNames": [
"tax_rate_id"
],
"columnNames": ["tax_rate_id"],
"localTableName": "public.tax_rate_rule",
"referencedColumnNames": [
"id"
],
"referencedColumnNames": ["id"],
"referencedTableName": "public.tax_rate",
"deleteRule": "cascade",
"updateRule": "cascade"

View File

@@ -1,17 +1,27 @@
import { Migration } from '@mikro-orm/migrations';
import { Migration } from "@mikro-orm/migrations"
export class Migration20240710135844 extends Migration {
async up(): Promise<void> {
this.addSql('drop index if exists "IDX_tax_region_unique_country_province";');
this.addSql('CREATE UNIQUE INDEX IF NOT EXISTS "IDX_tax_region_unique_country_province" ON "tax_region" (country_code, province_code) WHERE deleted_at IS NULL;');
this.addSql('CREATE UNIQUE INDEX IF NOT EXISTS "IDX_tax_region_unique_country_nullable_province" ON "tax_region" (country_code) WHERE province_code IS NULL AND deleted_at IS NULL;');
this.addSql(
'drop index if exists "IDX_tax_region_unique_country_province";'
)
this.addSql(
'CREATE UNIQUE INDEX IF NOT EXISTS "IDX_tax_region_unique_country_province" ON "tax_region" (country_code, province_code) WHERE deleted_at IS NULL;'
)
this.addSql(
'CREATE UNIQUE INDEX IF NOT EXISTS "IDX_tax_region_unique_country_nullable_province" ON "tax_region" (country_code) WHERE province_code IS NULL AND deleted_at IS NULL;'
)
}
async down(): Promise<void> {
this.addSql('drop index if exists "IDX_tax_region_unique_country_province";');
this.addSql('drop index if exists "IDX_tax_region_unique_country_nullable_province";');
this.addSql('CREATE UNIQUE INDEX IF NOT EXISTS "IDX_tax_region_unique_country_province" ON "tax_region" (country_code, province_code);');
this.addSql(
'drop index if exists "IDX_tax_region_unique_country_province";'
)
this.addSql(
'drop index if exists "IDX_tax_region_unique_country_nullable_province";'
)
this.addSql(
'CREATE UNIQUE INDEX IF NOT EXISTS "IDX_tax_region_unique_country_province" ON "tax_region" (country_code, province_code);'
)
}
}

View File

@@ -2,9 +2,7 @@ import { Migration } from "@mikro-orm/migrations"
export class Migration20240924114005 extends Migration {
async up(): Promise<void> {
this.addSql(
`UPDATE "tax_rate" SET code = 'default' WHERE code IS NULL;`
)
this.addSql(`UPDATE "tax_rate" SET code = 'default' WHERE code IS NULL;`)
this.addSql(
`ALTER TABLE IF EXISTS "tax_rate" ALTER COLUMN "code" SET NOT NULL;`
)

View File

@@ -1,7 +1,7 @@
import { DAL } from "@medusajs/framework/types"
import {
DALUtils,
createPsqlIndexStatementHelper,
DALUtils,
generateEntityId,
} from "@medusajs/framework/utils"
import {

View File

@@ -1,9 +1,9 @@
import { DAL } from "@medusajs/framework/types"
import {
DALUtils,
Searchable,
createPsqlIndexStatementHelper,
DALUtils,
generateEntityId,
Searchable,
} from "@medusajs/framework/utils"
import {
BeforeCreate,
@@ -13,8 +13,8 @@ import {
Entity,
Filter,
ManyToOne,
OnInit,
OneToMany,
OnInit,
OptionalProps,
PrimaryKey,
Property,